emp_functions.qsrc 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  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. 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. if srch_day_l <= day: srch_day_l = day + 1
  284. else
  285. srch_day_l = rnd_day
  286. end
  287. :setdayloop
  288. gs 'shortgs', 'dow', transient_evt_year, transient_evt_month, srch_day_l
  289. if result = transient_evt_dow:
  290. transient_evt_day = srch_day_l
  291. srch_day_l = 99
  292. else
  293. srch_day_l += 1
  294. end
  295. if srch_day_l <= srch_day_u: jump 'setdayloop'
  296. end
  297. ! ------ Helper Functions ------
  298. if $ARGS[0] = 'job_evt':
  299. !! Jobs ID list
  300. $evt_job[1] = 'Photography'
  301. $evt_job[2] = 'Modelling'
  302. $evt_job[3] = 'Music Gig'
  303. $evt_job[4] = 'Dance Show'
  304. $evt_job[5] = 'Ballet Performance'
  305. $evt_job[6] = 'Acting'
  306. $evt_job[50] = 'Sport'
  307. end
  308. if $ARGS[0] = 'wage_evt':
  309. !! calculate wages
  310. !! Assume you''ll never earn less than 100 roubles
  311. !! 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)
  312. !! 5 is for custom payments
  313. if ARGS[1] = 0:
  314. transient_evt_wages = 0
  315. elseif ARGS[1] = 1:
  316. transient_evt_wages = func('shortgs','round_tool',rand(100,500), 50)
  317. elseif ARGS[1] = 2:
  318. transient_evt_wages = func('shortgs','round_tool',rand(500,1000), 50)
  319. elseif ARGS[1] = 3:
  320. transient_evt_wages = func('shortgs','round_tool',rand(1000,2000), 50)
  321. elseif ARGS[1] = 4:
  322. transient_evt_wages = func('shortgs','round_tool',rand(2000,4000), 50)
  323. elseif ARGS[1] = 5:
  324. transient_evt_wages = ARGS[2]
  325. end
  326. end
  327. if $ARGS[0] = 'cat_evt':
  328. !! Construct Array Table and clear transients when an event is created and accepted.
  329. !! Create global variables for the current live event.
  330. !! Use 0 to create hidden events, 1 to show in journal
  331. evt_silent[] = transient_evt_silent
  332. !! Event job descriptor used in Journal
  333. evt_event[] = transient_evt
  334. !! Additional job ID if required
  335. evt_event_sub[] = transient_evt_sub
  336. !! Day of Week used in Journal and content areas
  337. evt_dow[] = transient_evt_dow
  338. !! Event Date to check against current date & used in Journal and content areas
  339. evt_day[] = transient_evt_day
  340. !! Event month to check against current month & used in Journal and content areas
  341. evt_month[] = transient_evt_month
  342. !! Event Year to check against year & used in Journal and content areas
  343. evt_year[] = transient_evt_year
  344. !! Event hour to check against hour & used in Journal and content areas
  345. evt_hour[] = transient_evt_hour
  346. !! Event minutes to check against minut & used in Journal and content areas
  347. evt_minutes[] = transient_evt_minutes
  348. !! How long the event is to last
  349. evt_duration[] = transient_evt_duration
  350. !! How much wages, generated or manual using function
  351. evt_wages[] = transient_evt_wages
  352. !! Journal location as reminder
  353. $evt_journal[] = $transient_journal
  354. !! 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
  355. !! Event area triggers such as city_residential
  356. $evt_loc[] = $transient_loc
  357. $evt_loc_arg[] = $transient_arg
  358. !! Content location - optional
  359. $evt_trigger_exec = $transient_evt_exec
  360. $evt_trigger[] = $transient_trigger
  361. !! Journal and event description
  362. $evt_desc[] = $transient_desc
  363. if transient_evt_silent = 1:
  364. *clr & cla
  365. 'Job accepted, you currently have ' + arrsize('evt_event') + ' jobs assigned to you. Please look at your journal for more information.'
  366. gs 'emp_functions', 'del_evt', 1
  367. act 'Return': gt 'emp_functions', 'evt_init'
  368. end
  369. end
  370. !! delete event after firing or cancelled
  371. if $ARGS[0] = 'del_evt':
  372. !! Delete transients
  373. if ARGS[1] = 1:
  374. killvar 'transient_evt_silent'
  375. killvar 'transient_event_type'
  376. killvar 'transient_evt_year'
  377. killvar 'transient_evt_month'
  378. killvar 'transient_evt_hour'
  379. killvar 'transient_evt_minutes'
  380. killvar 'transient_evt_duration'
  381. killvar 'transient_evt_wages'
  382. killvar '$transient_loc '
  383. killvar '$transient_arg'
  384. killvar '$transient_trigger'
  385. killvar '$transient_img'
  386. killvar '$transient_desc'
  387. killvar 'rnd_min'
  388. killvar 'mseed'
  389. killvar 'dseed'
  390. end
  391. ! Delete array entry
  392. if ARGS[1] = 2:
  393. !! delete event after firing or cancelled.
  394. !! killvar 'arr_name', index
  395. if ARGS[2] >= 0:
  396. evt_idx = ARGS[2]
  397. cla
  398. 'You''re about to delete this job: '
  399. 'Delete: ' + evt_event
  400. 'Index: ' + evt_idx
  401. Act 'Confirm?':
  402. cla
  403. 'Are you sure?'
  404. act 'Deleting':
  405. cla
  406. killvar 'evt_silent', evt_idx
  407. killvar 'evt_event', evt_idx
  408. killvar 'evt_dow', evt_idx
  409. killvar 'evt_day', evt_idx
  410. killvar 'evt_month', evt_idx
  411. killvar 'evt_year', evt_idx
  412. killvar 'evt_hour', evt_idx
  413. killvar 'evt_minutes', evt_idx
  414. killvar 'evt_duration', evt_idx
  415. killvar 'evt_wages', evt_idx
  416. killvar '$evt_mc_locat', evt_idx
  417. killvar '$evt_loc', evt_idx
  418. killvar '$evt_loc_arg', evt_idx
  419. killvar '$evt_exec', evt_idx
  420. killvar '$evt_media', evt_idx
  421. killvar '$evt_desc', evt_idx
  422. act 'Return': gs 'journal_work', 'start'
  423. end
  424. act 'Cancel': gs 'journal_work', 'start'
  425. end
  426. else
  427. '<<evt_idx>> - Invalid record - please check your index'
  428. end
  429. end
  430. end
  431. if $ARGS[0] = 'evt_day_suffix':
  432. if ARGS[1] ! '':
  433. query_day = ARGS[1]
  434. else
  435. query_day = transient_evt_day
  436. end
  437. if query_day => 20 and query_day < 30:
  438. test_day = query_day - 20
  439. else
  440. test_day = query_day
  441. end
  442. if transient_evt_day ! '':
  443. if test_day => 4 and test_day <= 10:
  444. $evt_suffix = 'th'
  445. elseif test_day = 1 or test_day = 31:
  446. $evt_suffix = 'st'
  447. elseif test_day = 2:
  448. $evt_suffix = 'nd'
  449. elseif test_day= 3:
  450. $evt_suffix = 'rd'
  451. else
  452. $evt_suffix = 'th'
  453. end
  454. end
  455. if day => 4 and day <=10:
  456. $date_suffix = 'th'
  457. elseif day = 1 or day = 21 or day = 31:
  458. $date_suffix = 'st'
  459. elseif day = 2 or day = 22:
  460. $date_suffix = 'nd'
  461. elseif test_day= 3:
  462. $date_suffix = 'rd'
  463. else
  464. $date_suffix = 'th'
  465. end
  466. killvar 'test_day'
  467. killvar 'query_day'
  468. end
  469. if $ARGS[0] = 'evt_day_chk':
  470. !! Daily event trigger to check if there is an event at currently location to reduce calls/overheads
  471. evt_chk = 0
  472. if evt_daily_chk ! daystart:
  473. evt_daily_chk = daystart
  474. job_idx = 0
  475. :evt_day_chk
  476. if month = evt_month and day = evt_day: evt_chk = 1
  477. job_idx += 1
  478. if job_idx < arrsize('evt_event') : jump 'evt_day_chk'
  479. killvar 'job_idx'
  480. end
  481. end
  482. !! --------------------- End Event Generator
  483. !! --------------------- Job management system
  484. !! book role, creates a time slot for emp_rota_week in format day_hour to be used in schedule mode.
  485. if $ARGS[0] = 'emp_booking':
  486. gs 'emp_functions', 'emp_chk_clk'
  487. if emp_rota_fail = 0:
  488. gs 'emp_functions', 'loop_configure'
  489. j_finish = emp_job_end[j_id]
  490. :jmp_daily_book
  491. j_idx = emp_job_start[j_id]
  492. :jmp_hour_book
  493. emp_rota_week[d_idx + '_' + j_idx] = j_id
  494. j_idx += 1
  495. if j_idx <= j_finish: jump 'jmp_hour_book'
  496. d_idx += 1
  497. if d_idx <= d_end: jump 'jmp_daily_book'
  498. emp_job_status[j_id] = 1
  499. emp_job[active] += 1
  500. killvar 'j_idx'
  501. killvar 'j_finish'
  502. killvar 'd_idx'
  503. killvar 'd_end'
  504. else
  505. msg 'Sorry, you''ve already got a job for this time period.'
  506. end
  507. killvar 'emp_rota_fail'
  508. end
  509. !! check if time slots are avaialble for this role.
  510. if $ARGS[0] = 'emp_chk_clk':
  511. gs 'emp_functions', 'loop_configure'
  512. j_finish = emp_job_end[j_id]
  513. :jmp_daily_chk
  514. j_idx = emp_job_start[j_id]
  515. :jmp_job_chk
  516. if emp_rota_week[d_idx + '_' + j_idx] > 0:
  517. !! booking failed
  518. emp_rota_fail = 1
  519. else
  520. !! booking passed
  521. emp_rota_fail = 0
  522. end
  523. j_idx +=1
  524. if j_idx <= j_finish and emp_rota_fail = 0: jump 'jmp_job_chk'
  525. d_idx += 1
  526. if d_idx <= d_end and emp_rota_fail = 0: jump 'jmp_daily_chk'
  527. end
  528. if $ARGS[0] = 'emp_terminate':
  529. if ARGS[1] >= 4:
  530. gs 'emp_functions', 'loop_configure'
  531. j_finish = emp_job_end[j_id]
  532. :jmp_daily_book
  533. j_idx = emp_job_start[j_id]
  534. :jmp_hour_book
  535. emp_rota_week[d_idx + '_' + j_idx] = 0
  536. j_idx += 1
  537. if j_idx <= j_finish: jump 'jmp_hour_book'
  538. d_idx += 1
  539. if d_idx <= d_end: jump 'jmp_daily_book'
  540. !! Set the termination value
  541. emp_job_status[j_id] = ARGS[1]
  542. emp_job[active] -= 1
  543. else
  544. msg 'Job termination failed. Please ensure you set to 4 - Terminated or 5 - Fired'
  545. end
  546. killvar 'j_idx'
  547. killvar 'j_finish'
  548. killvar 'd_idx'
  549. killvar 'd_end'
  550. end
  551. if $ARGS[0] = 'loop_configure':
  552. if j_day= 0 or j_day = 1 or j_day = 2:
  553. d_idx = 1
  554. else
  555. d_idx= 6
  556. end
  557. if j_day <= 1:
  558. d_end = 5
  559. else
  560. d_end= 7
  561. end
  562. end
  563. --- emp_functions ---------------------------------