emp_functions.qsrc 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. # emp_functions
  2. !! Employmnent and Event Systems
  3. !! 2023-02-12
  4. !! Author: Hooded Silence
  5. !!
  6. !! v.01 - Initial code base
  7. !! v.02 - Event generator partially integrated
  8. !! v.03 - Job management system integrated
  9. !! v.04 - Start of event generation code integration
  10. !! v.05 - Date suffix modification
  11. !! --------------------- UI Interface for Journal
  12. if $ARGS[0] = 'gen_schedule':
  13. *clr & cla
  14. if theme['is_dark'] = 1:
  15. $header_theme = '#91B0B4'
  16. $body_theme = '#303030'
  17. $body_theme_alt = '#474747'
  18. $font_theme = '#000000'
  19. else
  20. $header_theme = '#e27c00'
  21. $body_theme = '#E0DED4'
  22. $body_theme_alt = '#D58B32'
  23. $font_theme = '#FFFFFF'
  24. end
  25. if function_sw = 1: '<center><h2>' + $npc_firstname['A<<mod_npc_id>>'] + ' ' + $npc_lastname['A<<mod_npc_id>>'] + '</h2></center>'
  26. if function_sw = 2:
  27. gs 'journal', 'journalmenu'
  28. '<center><h2>Work</h2></center>'
  29. end
  30. !! Enable selector if attending school or Uni by NPC group type or by character and set default to School
  31. if (npc_grupTipe['A<<mod_npc_id>>']>= 1 and npc_grupTipe['A<<mod_npc_id>>']<= 5) or mod_npc_id = 34 and function_sw <= 1:
  32. if flag_schedule = 0: flag_schedule = 1
  33. school_group = 1
  34. '<center>Change to: <a href="exec: flag_schedule = 1 & gs ''emp_functions'', ''gen_schedule''">School</a> | <a href="exec: flag_schedule = 2 & gs ''emp_functions'', ''gen_schedule''">University</a> | <a href="exec: flag_schedule = 3 & gs ''emp_functions'', ''gen_schedule''">Holiday</a> </center>'
  35. else
  36. !! Set schedule to holiday / non-edu NPCs
  37. flag_schedule = 3
  38. end
  39. !! Initiate loop variables
  40. i_day = 1
  41. mod_max_day = 7
  42. i_hour = ARGS[1]
  43. mod_max_hour = ARGS[1] + 8
  44. header_switch = 1
  45. killvar '$tablebody'
  46. killvar '$tableheader'
  47. !! create header, using header switch to fill in :00 or :30 automatically using mod to determine odd/even and set display hour automatically.
  48. $tableheader = '<tr border="1" align="center" bgcolor="<<$header_theme>>"><th style="padding: 10px;"></th>'
  49. :jmp_header_create
  50. if (i_hour mod 2) = 0:
  51. display_hour = i_hour/ 2
  52. end
  53. if display_hour = 24: Display_hour = 0
  54. if header_switch = 1:
  55. header_switch += 1
  56. $tableheader += '<th style="padding: 10px;"><font color="<<$font_theme>>">' + iif(display_hour < 10, '0<<display_hour >>', display_hour) + ':00</font></th>'
  57. elseif header_switch=2:
  58. header_switch = 1
  59. $tableheader += '<th style="padding: 10px;"><font color="<<$font_theme>>">' + iif(display_hour < 10, '0<< display_hour>>', display_hour) + ':30</font></th>'
  60. end
  61. i_hour += 1
  62. if i_hour <= mod_max_hour: jump 'jmp_header_create'
  63. ! Reset i_hour for next loop
  64. killvar 'display_hour'
  65. i_hour = ARGS[1]
  66. header_switch = 1
  67. !! Close out table header
  68. $tableheader += '</tr>'
  69. !! Create table body, with alternating colour rows for legibility
  70. :jmp_day_create
  71. !Set day
  72. if i_day = 1 or i_day = 3 or i_day = 5 or i_day = 7:
  73. $tablebody += '<tr><td style="padding: 10px;" bgcolor="<<$header_theme>>"><b><font color="<<$font_theme>>">' + $week[i_day] + '</font></b></td>'
  74. else
  75. $tablebody += '<tr bgcolor="<<$body_theme_alt>>"><td style="padding: 10px;" bgcolor="<<$header_theme>>"><b><font color="<<$font_theme>>">' + $week[i_day] + '</font></b></td>'
  76. end
  77. !! fill the slots from the NPC schedule
  78. :jmp_hour_create
  79. if i_day >= 1:
  80. !! Create function switcher:
  81. !! 1: NPC tracker
  82. !! 2: Job tracker
  83. !! 3: Event Tracker
  84. if function_sw = 1 or function_sw = 0:
  85. dynamic $schedule_tracker
  86. elseif function_sw = 2:
  87. flag_active = 1
  88. j_id = emp_rota_week['<<i_day>>_<<i_hour>>']
  89. if emp_rota_week['<<i_day>>_<<i_hour>>'] ! 0:
  90. $transient_tb = '<a href="exec:gs ''emp_functions'', ''job_info'', <<j_id>>">' + $emp_job_title[j_id] + '</a>'
  91. else
  92. $transient_tb = 'Free'
  93. end
  94. elseif function_sw = 3:
  95. else
  96. msg 'Error - Failed to create body. Please set content switch.'
  97. end
  98. if flag_active = 0:
  99. $tablebody += '<td style="padding: 10px;">Slot: ' + i_hour +'</td>'
  100. else
  101. $tablebody += '<td style="padding: 10px;">' + $transient_tb +'</td>'
  102. flag_active = 0
  103. end
  104. killvar '$transient_tb'
  105. else
  106. i_day += 1
  107. jump 'jmp_day_create'
  108. end
  109. i_hour += 1
  110. if i_hour <= mod_max_hour: jump 'jmp_hour_create'
  111. $tablebody +='</tr>'
  112. i_day += 1
  113. i_hour = ARGS[1]
  114. if i_day <= mod_max_day: jump 'jmp_day_create'
  115. !! Create navigaton bars
  116. if (mod_max_hour + 8) <= 48:
  117. set_hour = ARGS[1] + 8
  118. $msg_forward = '<a href="exec:gs ''emp_functions'', ''gen_schedule'', <<set_hour>>"><b>Forward 4 hours</b></a>'
  119. else
  120. $msg_forward = 'End of Day'
  121. end
  122. if (mod_max_hour - 8) >0 :
  123. set_hour = ARGS[1] - 8
  124. $msg_back = '<a href="exec:gs ''emp_functions'', ''gen_schedule'', <<set_hour>>"><b>Back 4 hours</b></a>'
  125. else
  126. $msg_back = 'Start of day'
  127. end
  128. !! Start the table constuction
  129. '<center><table border=0 cellpadding=1 bgcolor="<<$body_theme>>" width="95%" align="center"><<$tableheader>><<$tablebody>></table>'
  130. '<<$msg_back>> | <<$msg_forward>>'
  131. killvar '$tablebody'
  132. killvar '$tableheader'
  133. killvar '$msg_back'
  134. killvar '$msg_forward'
  135. *nl
  136. if function_sw = 1:
  137. '<b>Note:</b> Times are approximate, some characters will appear at quarter past or quarter to the hour.</center>'
  138. end
  139. if function_sw = 2:
  140. '<b>Note:</b> Times are approximate, some jobs may extend past the allotted time or have flexi-starts.</center>'
  141. end
  142. act 'Back':
  143. killvar 'flag_schedule'
  144. killvar 'school_group'
  145. gt $loc, $loc_arg
  146. end
  147. end
  148. !! Job Info popup
  149. if $ARGS[0] = 'job_info':
  150. j_id = ARGS[1]
  151. killvar '$msg_body'
  152. $msg_body += '<p>Job Title: ' + $emp_job_title[j_id] + '</p>'
  153. $msg_body += '<p>Location: ' + $emp_job_loc[j_id] + '</p>'
  154. $msg_body += '<p>Notes: ' + $emp_job_notes[j_id]+ '</p>'
  155. $msg_body += '<p>Wages: ' + func('agentned', 'format_price_string', emp_job_wages[j_id]) + '<b>₽</b></p>'
  156. msg '<<$msg_body>>'
  157. killvar '$msg_body'
  158. end
  159. !! --------------------- Event Generator
  160. !! Author - Hooded Silence
  161. !! Date created - 26 Aug 22
  162. !! Event Generator - filler content only for one off events or recurring work from NPCs
  163. !!
  164. !! v. 01 - Initial code base
  165. !! v. 02 - UI improvements and feature feedback
  166. !! V. 03 - Initial integration into mainline code
  167. if $ARGS[0] = 'evt_init' :
  168. !! Placeholder, pending integration
  169. gt $loc, $loc_arg
  170. end
  171. if $ARGS[0] = 'disp_evt':
  172. if ARGS[1] = 1:
  173. gs 'emp_functions','evt_day_suffix'
  174. 'I have this job for you do you want to acccept it?'
  175. *nl
  176. 'Event Scheduled for: ' + transient_evt_day + $evt_suffix + ', '+ $monthName[transient_evt_month] +' '+ '20' + transient_evt_year
  177. 'Job: ' + $evt_job[transient_evt_type]
  178. 'Pay: ' + func('agentned', 'format_price_string', transient_evt_wages)
  179. 'Time: ' + transient_evt_hour + ':' + iif(transient_evt_minutes >= 0 and transient_evt_minutes <= 4, '00', '30')
  180. 'Duration: ' + transient_evt_duration + iif(transient_evt_duration = 1, ' hour', ' hours')
  181. 'Location: ' + $transient_journal
  182. 'Job Details: ' + $transient_desc
  183. act 'Accept the job' : gs 'emp_functions', 'cat_evt'
  184. act 'Decline the job':
  185. gs 'emp_functions', 'del_evt', 1
  186. gt 'emp_functions', 'evt_init'
  187. end
  188. end
  189. !! create table for all jobs:
  190. if ARGS[1] = 2:
  191. if arrsize('evt_event') > 0:
  192. killvar '$evtbody'
  193. job_idx = 0
  194. *nl
  195. :jmp_list_create
  196. if evt_silent[job_idx] = 1:
  197. gs 'emp_functions','evt_day_suffix',evt_day[job_idx]
  198. $evtbody += '<tr><td>' +$week[evt_dow[job_idx]]+' '+ evt_day[job_idx] + $evt_suffix + ', '+ $monthName[evt_month[job_idx]] +' 20'+ evt_year[job_idx] + '</td><td>' + $evt_job[evt_event[job_idx]] + '</td>'
  199. $evtbody += '<td>' + func('agentned', 'format_price_string', evt_wages[job_idx]) + '₽</td><td>' + evt_hour[job_idx] + ':' + iif(evt_minutes[job_idx] >= 0 and evt_minutes[job_idx] <= 4, '00', '30') + '</td>'
  200. $evtbody += '<td>' + evt_duration[job_idx] + iif(evt_duration[job_idx] = 1, ' hour', ' hours') + '</td><td>' + $evt_journal[job_idx] + '</td>'
  201. $evtbody += '<td><a href="exec: gs ''emp_functions'',''del_evt'', 2, <<job_idx>>"><img src="images\system\icons\evt_del.png"></a></a></td></tr>'
  202. end
  203. job_idx += 1
  204. if job_idx < arrsize('evt_event') : jump 'jmp_list_create'
  205. if $evtbody ! '':
  206. '<center><h2>Current Task List</h2></center>'
  207. $evtheader = '<tr><th>Date</th><th>Task</th><th>Pay</th><th>Time</th><th>Duration</th><th>Location</th><th>Cancel Job</th></tr>'
  208. '<center><table width="90%" align="center" width="90%" cellspacing="5" cellpadding="5" valign="top"><tr><<$evtheader>><<$evtbody>></tr></table></center>'
  209. killvar '$evtbody'
  210. killvar '$evtheader'
  211. else
  212. 'You haven''t taken on any jobs yet.'
  213. end
  214. end
  215. end
  216. !! Display the location acts
  217. if ARGS[1] = 3 and evt_chk = 1:
  218. act_idx = 0
  219. act_tracker = 0
  220. act_found = 0
  221. :jmp_act_create
  222. if evt_hour[act_tracker] = hour or evt_hour[act_tracker] = (hour -1):
  223. act_found = 1
  224. act_idx = act_tracker
  225. end
  226. act_tracker +=1
  227. if act_found = 0:
  228. if act_tracker < arrsize('evt_event'): jump 'jmp_act_create'
  229. end
  230. if ((evt_hour[act_idx] = hour and evt_minutes[act_idx] <= minut) or evt_hour[act_idx] = (hour - 1)) and $loc = $evt_loc[act_idx]:
  231. act 'Attend your ' + $evt_job[evt_event[act_idx]] + ' event':
  232. gs 'emp_functions', 'array_init'
  233. if evt_event = 1:
  234. gt 'photography_work', 'evt_stage'
  235. elseif $evt_trigger_exec ! '':
  236. gt $evt_trigger_exec[act_idx], $evt_trigger[act_idx]
  237. else
  238. gt $evt_loc[act_idx], $evt_loc_arg[act_idx]
  239. end
  240. killvar 'act_tracker'
  241. killvar 'act_found'
  242. end
  243. end
  244. end
  245. end
  246. if $ARGS[0] = 'gen_evt':
  247. !! Get the current year - remove 2000 to get the right year for search function.
  248. transient_evt_year = year - 2000
  249. !! Figure out the month for the seed and ensure it rolls over into new calendar year.
  250. if month = 12:
  251. evt_mseed = 1
  252. transient_evt_year += 1
  253. else
  254. evt_mseed = month + 1
  255. end
  256. !! randomise the month and month + 1
  257. transient_evt_month = rand(month, evt_mseed)
  258. :jmp_job_create
  259. if transient_evt_month = month:
  260. if (day + 7) > monthsend[transient_evt_month]:
  261. transient_evt_month += 1
  262. evt_dseed = 1
  263. end
  264. else
  265. evt_dseed = day + 1
  266. end
  267. rnd_day = rand(evt_dseed, monthsend[transient_evt_month])
  268. if transient_evt_month = month and rnd_day <= day: jump 'jmp_job_create'
  269. !! Set event transients - will be deleted upon completion
  270. transient_evt_hour = rand(9, 20)
  271. !! For simplicity sake make minutes on the hour or at half hour intervals, store as a single int.
  272. transient_evt_minutes = rand(0, 9)
  273. !! Set as multiples of 60
  274. if transient_evt_duration = '':
  275. transient_evt_duration = rand(1,8)
  276. end
  277. !! logic check for when randomising event duration
  278. if transient_evt_duration + transient_evt_hour >= 22:
  279. transient_evt_hour = 22 - transient_evt_duration
  280. end
  281. !! find a suitable date
  282. srch_day_u = rnd_day + 7
  283. if srch_day_u >= monthsend[transient_evt_month]:
  284. srch_day_u = monthsend[transient_evt_month]
  285. srch_day_l = monthsend[transient_evt_month] - rand(7,14)
  286. if srch_day_l <= day: srch_day_l = day + 1
  287. else
  288. srch_day_l = rnd_day
  289. end
  290. :setdayloop
  291. gs 'shortgs', 'dow', transient_evt_year, transient_evt_month, srch_day_l
  292. if result = transient_evt_dow:
  293. transient_evt_day = srch_day_l
  294. srch_day_l = 99
  295. else
  296. srch_day_l += 1
  297. end
  298. if srch_day_l <= srch_day_u: jump 'setdayloop'
  299. end
  300. ! ------ Helper Functions ------
  301. if $ARGS[0] = 'job_evt':
  302. !! Jobs ID list
  303. $evt_job[1] = 'Photography'
  304. $evt_job[2] = 'Modelling'
  305. $evt_job[3] = 'Music Gig'
  306. $evt_job[4] = 'Dance Show'
  307. $evt_job[5] = 'Ballet Performance'
  308. $evt_job[6] = 'Acting'
  309. $evt_job[50] = 'Sport'
  310. end
  311. if $ARGS[0] = 'wage_evt':
  312. !! calculate wages
  313. !! Assume you''ll never earn less than 100 roubles
  314. !! 0 for none, 1 - for a small payment (100-500), 2 - moderate payment (500-1000), 3 - large payment (1000-2000), 4 - huge payment (2000-4000)
  315. !! 5 is for custom payments
  316. if ARGS[1] = 0:
  317. transient_evt_wages = 0
  318. elseif ARGS[1] = 1:
  319. transient_evt_wages = func('shortgs','round_tool',rand(100,500), 50)
  320. elseif ARGS[1] = 2:
  321. transient_evt_wages = func('shortgs','round_tool',rand(500,1000), 50)
  322. elseif ARGS[1] = 3:
  323. transient_evt_wages = func('shortgs','round_tool',rand(1000,2000), 50)
  324. elseif ARGS[1] = 4:
  325. transient_evt_wages = func('shortgs','round_tool',rand(2000,4000), 50)
  326. elseif ARGS[1] = 5:
  327. transient_evt_wages = ARGS[2]
  328. end
  329. end
  330. if $ARGS[0] = 'cat_evt':
  331. !! Construct Array Table and clear transients when an event is created and accepted.
  332. !! Create global variables for the current live event.
  333. !! Use 0 to create hidden events, 1 to show in journal
  334. evt_silent[] = transient_evt_silent
  335. !! Event job descriptor used in Journal
  336. evt_event[] = transient_evt
  337. !! Additional job ID if required
  338. evt_event_sub[] = transient_evt_sub
  339. !! Day of Week used in Journal and content areas
  340. evt_dow[] = transient_evt_dow
  341. !! Event Date to check against current date & used in Journal and content areas
  342. evt_day[] = transient_evt_day
  343. !! Event month to check against current month & used in Journal and content areas
  344. evt_month[] = transient_evt_month
  345. !! Event Year to check against year & used in Journal and content areas
  346. evt_year[] = transient_evt_year
  347. !! Event hour to check against hour & used in Journal and content areas
  348. evt_hour[] = transient_evt_hour
  349. !! Event minutes to check against minut & used in Journal and content areas
  350. evt_minutes[] = transient_evt_minutes
  351. !! How long the event is to last
  352. evt_duration[] = transient_evt_duration
  353. !! How much wages, generated or manual using function
  354. evt_wages[] = transient_evt_wages
  355. !! Journal location as reminder
  356. $evt_journal[] = $transient_journal
  357. !! The following are event location triggers to allow the content to appear in areas such as community center but host their content elsewhere such as Photography shop
  358. !! Event area triggers such as city_residential
  359. $evt_loc[] = $transient_loc
  360. $evt_loc_arg[] = $transient_arg
  361. !! Content location - optional
  362. $evt_trigger_exec = $transient_evt_exec
  363. $evt_trigger[] = $transient_trigger
  364. !! Journal and event description
  365. $evt_desc[] = $transient_desc
  366. if transient_evt_silent = 1:
  367. *clr & cla
  368. 'Job accepted, you currently have ' + arrsize('evt_event') + ' jobs assigned to you. Please look at your journal for more information.'
  369. gs 'emp_functions', 'del_evt', 1
  370. act 'Return': gt 'emp_functions', 'evt_init'
  371. end
  372. end
  373. !! delete event after firing or cancelled
  374. if $ARGS[0] = 'del_evt':
  375. !! Delete transients
  376. if ARGS[1] = 1:
  377. killvar 'transient_evt_silent'
  378. killvar 'transient_event_type'
  379. killvar 'transient_evt_year'
  380. killvar 'transient_evt_month'
  381. killvar 'transient_evt_hour'
  382. killvar 'transient_evt_minutes'
  383. killvar 'transient_evt_duration'
  384. killvar 'transient_evt_wages'
  385. killvar '$transient_loc '
  386. killvar '$transient_arg'
  387. killvar '$transient_trigger'
  388. killvar '$transient_img'
  389. killvar '$transient_desc'
  390. killvar 'rnd_min'
  391. killvar 'mseed'
  392. killvar 'dseed'
  393. end
  394. ! Delete array entry
  395. if ARGS[1] = 2:
  396. !! delete event after firing or cancelled.
  397. !! killvar 'arr_name', index
  398. if ARGS[2] >= 0:
  399. evt_idx = ARGS[2]
  400. cla
  401. 'You''re about to delete this job: '
  402. 'Delete: ' + evt_event
  403. 'Index: ' + evt_idx
  404. Act 'Confirm?':
  405. cla
  406. 'Are you sure?'
  407. act 'Deleting':
  408. cla
  409. killvar 'evt_silent', evt_idx
  410. killvar 'evt_event', evt_idx
  411. killvar 'evt_dow', evt_idx
  412. killvar 'evt_day', evt_idx
  413. killvar 'evt_month', evt_idx
  414. killvar 'evt_year', evt_idx
  415. killvar 'evt_hour', evt_idx
  416. killvar 'evt_minutes', evt_idx
  417. killvar 'evt_duration', evt_idx
  418. killvar 'evt_wages', evt_idx
  419. killvar '$evt_mc_locat', evt_idx
  420. killvar '$evt_loc', evt_idx
  421. killvar '$evt_loc_arg', evt_idx
  422. killvar '$evt_exec', evt_idx
  423. killvar '$evt_media', evt_idx
  424. killvar '$evt_desc', evt_idx
  425. act 'Return': gs 'journal_work', 'start'
  426. end
  427. act 'Cancel': gs 'journal_work', 'start'
  428. end
  429. else
  430. '<<evt_idx>> - Invalid record - please check your index'
  431. end
  432. end
  433. end
  434. if $ARGS[0] = 'evt_day_suffix':
  435. if ARGS[1] ! '':
  436. query_day = ARGS[1]
  437. else
  438. query_day = transient_evt_day
  439. end
  440. if query_day => 20 and query_day < 30:
  441. test_day = query_day - 20
  442. else
  443. test_day = query_day
  444. end
  445. if transient_evt_day ! '':
  446. if test_day => 4 and test_day <= 10:
  447. $evt_suffix = 'th'
  448. elseif test_day = 1 or test_day = 31:
  449. $evt_suffix = 'st'
  450. elseif test_day = 2:
  451. $evt_suffix = 'nd'
  452. elseif test_day= 3:
  453. $evt_suffix = 'rd'
  454. else
  455. $evt_suffix = 'th'
  456. end
  457. end
  458. if day => 4 and day <=10:
  459. $date_suffix = 'th'
  460. elseif day = 1 or day = 21 or day = 31:
  461. $date_suffix = 'st'
  462. elseif day = 2 or day = 22:
  463. $date_suffix = 'nd'
  464. elseif test_day= 3:
  465. $date_suffix = 'rd'
  466. else
  467. $date_suffix = 'th'
  468. end
  469. killvar 'test_day'
  470. killvar 'query_day'
  471. end
  472. if $ARGS[0] = 'evt_day_chk':
  473. !! Daily event trigger to check if there is an event at currently location to reduce calls/overheads
  474. evt_chk = 0
  475. if evt_daily_chk ! daystart:
  476. evt_daily_chk = daystart
  477. job_idx = 0
  478. :evt_day_chk
  479. if month = evt_month and day = evt_day: evt_chk = 1
  480. job_idx += 1
  481. if job_idx < arrsize('evt_event') : jump 'evt_day_chk'
  482. killvar 'job_idx'
  483. end
  484. end
  485. !! --------------------- End Event Generator
  486. !! --------------------- Job management system
  487. !! book role, creates a time slot for emp_rota_week in format day_hour to be used in schedule mode.
  488. if $ARGS[0] = 'emp_booking':
  489. gs 'emp_functions', 'emp_chk_clk'
  490. if emp_rota_fail = 0:
  491. gs 'emp_functions', 'loop_configure'
  492. j_finish = emp_job_end[j_id]
  493. :jmp_daily_book
  494. j_idx = emp_job_start[j_id]
  495. :jmp_hour_book
  496. emp_rota_week['<<d_idx>>_<<j_idx>>'] = j_id
  497. j_idx += 1
  498. if j_idx <= j_finish: jump 'jmp_hour_book'
  499. d_idx += 1
  500. if d_idx <= d_end: jump 'jmp_daily_book'
  501. emp_job_status[j_id] = 1
  502. emp_job[active] += 1
  503. killvar 'j_idx'
  504. killvar 'j_finish'
  505. killvar 'd_idx'
  506. killvar 'd_end'
  507. else
  508. msg 'Sorry, you''ve already got a job for this time period.'
  509. end
  510. killvar 'emp_rota_fail'
  511. end
  512. !! check if time slots are avaialble for this role.
  513. if $ARGS[0] = 'emp_chk_clk':
  514. gs 'emp_functions', 'loop_configure'
  515. j_finish = emp_job_end[j_id]
  516. :jmp_daily_chk
  517. j_idx = emp_job_start[j_id]
  518. :jmp_job_chk
  519. if emp_rota_week['<<d_idx>>_<<j_idx>>'] > 0:
  520. !! booking failed
  521. emp_rota_fail = 1
  522. else
  523. !! booking passed
  524. emp_rota_fail = 0
  525. end
  526. j_idx +=1
  527. if j_idx <= j_finish and emp_rota_fail = 0: jump 'jmp_job_chk'
  528. d_idx += 1
  529. if d_idx <= d_end and emp_rota_fail = 0: jump 'jmp_daily_chk'
  530. end
  531. if $ARGS[0] = 'emp_terminate':
  532. if ARGS[1] >= 4:
  533. gs 'emp_functions', 'loop_configure'
  534. j_finish = emp_job_end[j_id]
  535. :jmp_daily_book
  536. j_idx = emp_job_start[j_id]
  537. :jmp_hour_book
  538. emp_rota_week['<<d_idx>>_<<j_idx>>'] = 0
  539. j_idx += 1
  540. if j_idx <= j_finish: jump 'jmp_hour_book'
  541. d_idx += 1
  542. if d_idx <= d_end: jump 'jmp_daily_book'
  543. !! Set the termination value
  544. emp_job_status[j_id] = ARGS[1]
  545. emp_job[active] -= 1
  546. else
  547. msg 'Job termination failed. Please ensure you set to 4 - Terminated or 5 - Fired'
  548. end
  549. end
  550. if $ARGS[0] = 'loop_configure':
  551. if j_day= 0 or j_day = 1 or j_day = 2:
  552. d_idx = 1
  553. else
  554. d_idx= 6
  555. end
  556. if j_day <= 1:
  557. d_end = 5
  558. else
  559. d_end= 7
  560. end
  561. end
  562. killvar 'i_day'
  563. killvar 'i_hour'
  564. killvar 'j_id'
  565. killvar 'j_idx'
  566. killvar 'j_day'
  567. killvar 'j_finish'
  568. killvar 'd_idx'
  569. killvar 'd_end'
  570. killvar 'evt_idx'
  571. killvar 'set_hour'
  572. killvar 'mod_max_day'
  573. killvar 'mod_max_hour'
  574. killvar 'header_switch'
  575. --- emp_functions ---------------------------------