emp_functions.qsrc 19 KB

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