1
0

emp_functions.qsrc 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  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 reminder: ' + $transient_mc_locat
  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 evt_event[0] ! '':
  189. killvar '$evtbody'
  190. job_idx = 0
  191. *nl
  192. :jmp_list_create
  193. !!if evt_silent[job_idx] = 1:
  194. $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>'
  195. $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>'
  196. $evtbody += '<td>' + evt_duration[job_idx] + iif(evt_duration[job_idx] = 1, ' hour', ' hours') + '</td><td>' + $evt_mc_locat[job_idx] + '</td>'
  197. $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>'
  198. !!end
  199. job_idx += 1
  200. if job_idx < arrsize('evt_event') : jump 'jmp_list_create'
  201. !!if evt_silent[job_idx] = 1:
  202. '<center><h2>Current Task List</h2></center>'
  203. $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>'
  204. '<center><table width="90%" align="center" width="90%" cellspacing="5" cellpadding="5" valign="top"><tr><<$evtheader>><<$evtbody>></tr></table></center>'
  205. !!end
  206. killvar '$evtbody'
  207. killvar '$evtheader'
  208. else
  209. 'You haven''t taken on any jobs yet.'
  210. end
  211. end
  212. !! Display the location acts
  213. if ARGS[1] = 3 and evt_chk = 1:
  214. act_idx = 0
  215. act_tracker = 0
  216. act_found = 0
  217. :jmp_act_create
  218. if evt_hour[act_tracker] = hour or evt_hour[act_tracker] = (hour -1):
  219. act_found = 1
  220. act_idx = act_tracker
  221. end
  222. act_tracker +=1
  223. if act_found = 0:
  224. if act_tracker < arrsize('evt_event'): jump 'jmp_act_create'
  225. end
  226. 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]:
  227. act 'Attend your ' + $evt_job[evt_event[act_idx]] + ' event':
  228. gs 'emp_functions', 'array_init'
  229. if $evt_trigger_exec ! '':
  230. gt $evt_trigger_exec[act_idx], $evt_trigger[act_idx]
  231. else
  232. gt $evt_loc[act_idx], $evt_loc_arg[act_idx]
  233. end
  234. killvar 'act_tracker'
  235. killvar 'act_found'
  236. end
  237. end
  238. end
  239. end
  240. if $ARGS[0] = 'gen_evt':
  241. !! Get the current year - remove 2000 to get the right year for search function.
  242. transient_evt_year = year - 2000
  243. !! Figure out the month for the seed and ensure it rolls over into new calendar year.
  244. if month = 12:
  245. evt_mseed = 1
  246. transient_evt_year += 1
  247. else
  248. evt_mseed = month + 1
  249. end
  250. !! randomise the month and month + 1
  251. transient_evt_month = rand(month, evt_mseed)
  252. :jmp_job_create
  253. if transient_evt_month = month:
  254. if (day + 7) > monthsend[transient_evt_month]:
  255. transient_evt_month += 1
  256. evt_dseed = 1
  257. end
  258. else
  259. evt_dseed = day + 1
  260. end
  261. rnd_day = rand(evt_dseed, monthsend[transient_evt_month])
  262. if transient_evt_month = month and rnd_day <= day: jump 'jmp_job_create'
  263. !! Set event transients - will be deleted upon completion
  264. transient_evt_hour = rand(9, 20)
  265. !! For simplicity sake make minutes on the hour or at half hour intervals, store as a single int.
  266. transient_evt_minutes = rand(0, 9)
  267. !! Set as multiples of 60
  268. transient_evt_duration = rand(1,8)
  269. !! logic check for when randomising event duration
  270. if transient_evt_duration + transient_evt_hour >= 22:
  271. transient_evt_hour = 22 - transient_evt_duration
  272. end
  273. !! find a suitable date
  274. srch_day_u = rnd_day + 7
  275. if srch_day_u >= monthsend[transient_evt_month]:
  276. srch_day_u = monthsend[transient_evt_month]
  277. srch_day_l = monthsend[transient_evt_month] - rand(7,14)
  278. else
  279. srch_day_l = rnd_day
  280. end
  281. :setdayloop
  282. gs 'shortgs', 'dow', transient_evt_year, transient_evt_month, srch_day_l
  283. if result = transient_evt_dow:
  284. transient_evt_day = srch_day_l
  285. srch_day_l = 99
  286. else
  287. srch_day_l += 1
  288. end
  289. if srch_day_l <= srch_day_u: jump 'setdayloop'
  290. end
  291. ! ------ Helper Functions ------
  292. if $ARGS[0] = 'job_evt':
  293. !! Jobs ID list
  294. $evt_job[1] = 'Photography'
  295. $evt_job[2] = 'Modelling'
  296. $evt_job[3] = 'Music Gig'
  297. $evt_job[4] = 'Dance Show'
  298. $evt_job[5] = 'Ballet Performance'
  299. $evt_job[6] = 'Acting'
  300. $evt_job[50] = 'Sport'
  301. end
  302. if $ARGS[0] = 'wage_evt':
  303. !! calculate wages
  304. !! Assume you''ll never earn less than 100 roubles
  305. !! 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)
  306. !! 5 is for custom payments
  307. if ARGS[1] = 0:
  308. transient_evt_wages = 0
  309. elseif ARGS[1] = 1:
  310. transient_evt_wages = func('shortgs','round_tool',rand(100,500), 50)
  311. elseif ARGS[1] = 2:
  312. transient_evt_wages = func('shortgs','round_tool',rand(500,1000), 50)
  313. elseif ARGS[1] = 3:
  314. transient_evt_wages = func('shortgs','round_tool',rand(1000,2000), 50)
  315. elseif ARGS[1] = 4:
  316. transient_evt_wages = func('shortgs','round_tool',rand(2000,4000), 50)
  317. elseif ARGS[1] = 5:
  318. transient_evt_wages = ARGS[2]
  319. end
  320. end
  321. if $ARGS[0] = 'cat_evt':
  322. !! Construct Array Table and clear transients when an event is created and accepted.
  323. !! Create global variables for the current live event.
  324. !! Use 0 to create hidden events, 1 to show in journal
  325. evt_silent[] = transient_evt_silent
  326. !! Event type used in Journal
  327. evt_event[] = transient_evt_type
  328. !! Additional ID if required
  329. evt_event_sub[] = transient_evt_sub_type
  330. !! Day of Week used in Journal and content areas
  331. evt_dow[] = transient_evt_dow
  332. !! Event Date to check against current date & used in Journal and content areas
  333. evt_day[] = transient_evt_day
  334. !! Event month to check against current month & used in Journal and content areas
  335. evt_month[] = transient_evt_month
  336. !! Event Year to check against year & used in Journal and content areas
  337. evt_year[] = transient_evt_year
  338. !! Event hour to check against hour & used in Journal and content areas
  339. evt_hour[] = transient_evt_hour
  340. !! Event minutes to check against minut & used in Journal and content areas
  341. evt_minutes[] = transient_evt_minutes
  342. !! How long the event is to last
  343. evt_duration[] = transient_evt_duration
  344. !! How much wages, generated or manual using function
  345. evt_wages[] = transient_evt_wages
  346. !! Journal location as reminder
  347. $evt_mc_locat[] = $transient_mc_locat
  348. !! 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
  349. !! Event area triggers such as city_residential
  350. $evt_loc[] = $transient_loc
  351. $evt_loc_arg[] = $transient_arg
  352. !! Content location - optional
  353. $evt_trigger_exec = $transient_evt_exec
  354. $evt_trigger[] = $transient_trigger
  355. !! Journal and event description
  356. $evt_desc[] = $transient_desc
  357. if transient_evt_silent = 1:
  358. *clr & cla
  359. 'Job accepted, you currently have ' + arrsize('evt_event') + ' jobs assigned to you. Please look at your journal for more information.'
  360. gs 'emp_functions', 'del_evt', 1
  361. act 'Return': gt 'emp_functions', 'evt_init'
  362. end
  363. end
  364. !! delete event after firing or cancelled
  365. if $ARGS[0] = 'del_evt':
  366. !! Delete transients
  367. if ARGS[1] = 1:
  368. killvar 'transient_evt_silent'
  369. killvar 'transient_event_type'
  370. killvar 'transient_evt_year'
  371. killvar 'transient_evt_month'
  372. killvar 'transient_evt_hour'
  373. killvar 'transient_evt_minutes'
  374. killvar 'transient_evt_duration'
  375. killvar 'transient_evt_wages'
  376. killvar '$transient_loc '
  377. killvar '$transient_arg'
  378. killvar '$transient_trigger'
  379. killvar '$transient_img'
  380. killvar '$transient_desc'
  381. killvar 'rnd_min'
  382. killvar 'mseed'
  383. killvar 'dseed'
  384. end
  385. ! Delete array entry
  386. if ARGS[1] = 2:
  387. !! delete event after firing or cancelled.
  388. !! killvar 'arr_name', index
  389. if ARGS[2] >= 0:
  390. evt_idx = ARGS[2]
  391. cla
  392. 'You''re about to delete this job: '
  393. 'Delete: ' + evt_event
  394. 'Index: ' + evt_idx
  395. Act 'Confirm?':
  396. cla
  397. 'Are you sure?'
  398. act 'Deleting':
  399. cla
  400. killvar 'evt_silent', evt_idx
  401. killvar 'evt_event', evt_idx
  402. killvar 'evt_dow', evt_idx
  403. killvar 'evt_day', evt_idx
  404. killvar 'evt_month', evt_idx
  405. killvar 'evt_year', evt_idx
  406. killvar 'evt_hour', evt_idx
  407. killvar 'evt_minutes', evt_idx
  408. killvar 'evt_duration', evt_idx
  409. killvar 'evt_wages', evt_idx
  410. killvar '$evt_mc_locat', evt_idx
  411. killvar '$evt_loc', evt_idx
  412. killvar '$evt_loc_arg', evt_idx
  413. killvar '$evt_exec', evt_idx
  414. killvar '$evt_media', evt_idx
  415. killvar '$evt_desc', evt_idx
  416. act 'Return': gs 'journal_work', 'start'
  417. end
  418. act 'Cancel': gs 'journal_work', 'start'
  419. end
  420. else
  421. '<<evt_idx>> - Invalid record - please check your index'
  422. end
  423. end
  424. end
  425. if $ARGS[0] = 'evt_day_suffix':
  426. if ARGS[1] ! '':
  427. query_day = ARGS[1]
  428. else
  429. query_day = transient_evt_day
  430. end
  431. if query_day => 20 and query_day <= 29:
  432. test_day = query_day - 20
  433. else
  434. test_day = query_day
  435. end
  436. if (test_day => 4 and test_day <= 10) or (day => 4 and day <=10):
  437. $evt_suffix = 'th'
  438. elseif (test_day = 1 or test_day = 31) or (day = 1 or day = 21 or day = 31):
  439. $evt_suffix = 'st'
  440. elseif (test_day = 2) or (day = 2 or day = 22):
  441. $evt_suffix = 'nd'
  442. elseif test_day= 3:
  443. $evt_suffix = 'rd'
  444. else
  445. $evt_suffix = 'th'
  446. end
  447. killvar 'test_day'
  448. killvar 'query_day'
  449. end
  450. if $ARGS[0] = 'evt_day_chk':
  451. !! Daily event trigger to check if there is an event at currently location to reduce calls/overheads
  452. evt_chk = 0
  453. if evt_daily_chk ! daystart:
  454. evt_daily_chk = daystart
  455. job_idx = 0
  456. :evt_day_chk
  457. if month = evt_month and day = evt_day: evt_chk = 1
  458. job_idx += 1
  459. if job_idx < arrsize('evt_event') : jump 'evt_day_chk'
  460. end
  461. end
  462. !! --------------------- End Event Generator
  463. !! --------------------- Job management system
  464. !! book role, creates a time slot for emp_rota_week in format day_hour to be used in schedule mode.
  465. if $ARGS[0] = 'emp_booking':
  466. gs 'emp_functions', 'emp_chk_clk'
  467. if emp_rota_fail = 0:
  468. gs 'emp_functions', 'loop_configure'
  469. j_finish = emp_job_end[j_id]
  470. :jmp_daily_book
  471. j_idx = emp_job_start[j_id]
  472. :jmp_hour_book
  473. emp_rota_week[d_idx + '_' + j_idx] = j_id
  474. j_idx += 1
  475. if j_idx <= j_finish: jump 'jmp_hour_book'
  476. d_idx += 1
  477. if d_idx <= d_end: jump 'jmp_daily_book'
  478. emp_job_status[j_id] = 1
  479. emp_job[active] += 1
  480. killvar 'j_idx'
  481. killvar 'j_finish'
  482. killvar 'd_idx'
  483. killvar 'd_end'
  484. else
  485. msg 'Sorry, you''ve already got a job for this time period.'
  486. end
  487. killvar 'emp_rota_fail'
  488. end
  489. !! check if time slots are avaialble for this role.
  490. if $ARGS[0] = 'emp_chk_clk':
  491. gs 'emp_functions', 'loop_configure'
  492. j_finish = emp_job_end[j_id]
  493. :jmp_daily_chk
  494. j_idx = emp_job_start[j_id]
  495. :jmp_job_chk
  496. if emp_rota_week[d_idx + '_' + j_idx] > 0:
  497. !! booking failed
  498. emp_rota_fail = 1
  499. else
  500. !! booking passed
  501. emp_rota_fail = 0
  502. end
  503. j_idx +=1
  504. if j_idx <= j_finish and emp_rota_fail = 0: jump 'jmp_job_chk'
  505. d_idx += 1
  506. if d_idx <= d_end and emp_rota_fail = 0: jump 'jmp_daily_chk'
  507. end
  508. if $ARGS[0] = 'emp_terminate':
  509. if ARGS[1] >= 4:
  510. gs 'emp_functions', 'loop_configure'
  511. j_finish = emp_job_end[j_id]
  512. :jmp_daily_book
  513. j_idx = emp_job_start[j_id]
  514. :jmp_hour_book
  515. emp_rota_week[d_idx + '_' + j_idx] = 0
  516. j_idx += 1
  517. if j_idx <= j_finish: jump 'jmp_hour_book'
  518. d_idx += 1
  519. if d_idx <= d_end: jump 'jmp_daily_book'
  520. !! Set the termination value
  521. emp_job_status[j_id] = ARGS[1]
  522. emp_job[active] -= 1
  523. else
  524. msg 'Job termination failed. Please ensure you set to 4 - Terminated or 5 - Fired'
  525. end
  526. killvar 'j_idx'
  527. killvar 'j_finish'
  528. killvar 'd_idx'
  529. killvar 'd_end'
  530. end
  531. if $ARGS[0] = 'loop_configure':
  532. if j_day= 0 or j_day = 1 or j_day = 2:
  533. d_idx = 1
  534. else
  535. d_idx= 6
  536. end
  537. if j_day <= 1:
  538. d_end = 5
  539. else
  540. d_end= 7
  541. end
  542. end
  543. --- emp_functions ---------------------------------