# masseuse_schedule


if $ARGS[0] = 'schedule_reset':
	i = 1
	if masseuse['shifts_required'] = 5:
		:loop_masseuse_sched_part
		if masseuse['<<i>>_shift_1'] ! 1:
			masseuse['<<i>>_shift_1'] = 0
			masseuse['<<i>>_shift_1_taken'] = rand(0,2)
		end
		if masseuse['<<i>>_shift_2'] ! 1: 
			masseuse['<<i>>_shift_2'] = 0
			masseuse['<<i>>_shift_2_taken'] = rand(0,2)
		end
		if masseuse['<<i>>_shift_3'] ! 1: 
			masseuse['<<i>>_shift_3'] = 0
			masseuse['<<i>>_shift_3_taken'] = rand(-1,2)
		end
		i += 1
		if i < 8: jump 'loop_masseuse_sched_part'
	elseif masseuse['shifts_required'] = 10:
		:loop_masseuse_sched_full
		if masseuse['<<i>>_shift_1'] ! 1: 
			masseuse['<<i>>_shift_1'] = 0
			masseuse['<<i>>_shift_1_taken'] = rand(-3,2)
		end
		if masseuse['<<i>>_shift_2'] ! 1: 
			masseuse['<<i>>_shift_2'] = 0
			masseuse['<<i>>_shift_2_taken'] = rand(-3,2)
		end
		if masseuse['<<i>>_shift_3'] ! 1: 
			masseuse['<<i>>_shift_3'] = 0
			masseuse['<<i>>_shift_3_taken'] = rand(-3,2)
		end
		i += 1
		if i < 8: jump 'loop_masseuse_sched_full'
	end
end


if $ARGS[0] = 'start':

	act'Finish scheduling':gt'salon','start'
	if masseuse['schedule_update'] = 0: masseuse['schedule_update'] = daystart & gs 'masseuse_schedule','schedule_reset'
	gs 'stat'
	'<Table border=1><TR><TH>Sunday</TH> <TH>Monday</TH> <TH>Tuesday</TH> <TH>Wednesday</TH> <TH>Thursday</TH> <TH>Friday</TH> <TH>Saturday</TH></TR>'

!! ---------------------------------------------- 09:00 Shifts ---------------------------------------------------------------------------------

!! First Sunday Shift
	*P '<tr><td>' 
	if masseuse['7_shift_1'] = 0 and masseuse['7_shift_1_taken'] < 2 and no (week = 7 and hour > 8 and hour < 13):
		'<a href="exec:masseuse[''7_shift_1''] = 1 & gt''masseuse_schedule'',''start''"> 09:00-13:00 shift</a>'
	elseif masseuse['7_shift_1_taken'] = 2 or (week = 7 and hour > 8 and hour < 13):
		'09:00-13:00 shift'
		'<i>not available</i>'
	elseif masseuse['7_shift_1'] = 2:
		'09:00-13:00 shift'
		'<i>already worked</i>'
	else
		'09:00-13:00 shift'
		'<a href="exec:masseuse[''7_shift_1''] = 0 & gt''masseuse_schedule'',''start''"> Cancel Shift</a>'
	end
	'</td><td>'

!! First Monday Shift

	if masseuse['1_shift_1'] = 0 and masseuse['1_shift_1_taken'] < 2 and no (week = 1 and hour > 8 and hour < 13):
		'<a href="exec:masseuse[''1_shift_1''] = 1 & gt''masseuse_schedule'',''start''"> 09:00-13:00 shift</a>'
	elseif masseuse['1_shift_1_taken'] = 2 or (week = 1 and hour > 8 and hour < 13):
		'09:00-13:00 shift'
		'<i>not available</i>'
	elseif masseuse['1_shift_1'] = 2:
		'09:00-13:00 shift'
		'<i>already worked</i>'
	else
		'09:00-13:00 shift'
		'<a href="exec:masseuse[''1_shift_1''] = 0 & gt''masseuse_schedule'',''start''"> Cancel Shift</a>'
	end
	'</td><td>'

!! First Tuesday Shift

	if masseuse['2_shift_1'] = 0 and masseuse['2_shift_1_taken'] < 2 and no (week = 2 and hour > 8 and hour < 13):
		'<a href="exec:masseuse[''2_shift_1''] = 1 & gt''masseuse_schedule'',''start''"> 09:00-13:00 shift</a>'
	elseif masseuse['2_shift_1_taken'] = 2 or (week = 2 and hour > 8 and hour < 13):
		'09:00-13:00 shift'
		'<i>not available</i>'
	elseif masseuse['2_shift_1'] = 2:
		'09:00-13:00 shift'
		'<i>already worked</i>'
	else
		'09:00-13:00 shift'
		'<a href="exec:masseuse[''2_shift_1''] = 0 & gt''masseuse_schedule'',''start''"> Cancel Shift</a>'
	end
	'</td><td>'

!! First Wednesday Shift

	if masseuse['3_shift_1'] = 0 and masseuse['3_shift_1_taken'] < 2 and no (week = 3 and hour > 8 and hour < 13):
		'<a href="exec:masseuse[''3_shift_1''] = 1 & gt''masseuse_schedule'',''start''"> 09:00-13:00 shift</a>'
	elseif masseuse['3_shift_1_taken'] = 2 or (week = 3 and hour > 8 and hour < 13):
		'09:00-13:00 shift'
		'<i>not available</i>'
	elseif masseuse['3_shift_1'] = 2:
		'09:00-13:00 shift'
		'<i>already worked</i>'
	else
		'09:00-13:00 shift'
		'<a href="exec:masseuse[''3_shift_1''] = 0 & gt''masseuse_schedule'',''start''"> Cancel Shift</a>'
	end
	'</td><td>'

!! First Thursday Shift

	if masseuse['4_shift_1'] = 0 and masseuse['4_shift_1_taken'] < 2 and no (week = 4 and hour > 8 and hour < 13):
		'<a href="exec:masseuse[''4_shift_1''] = 1 & gt''masseuse_schedule'',''start''"> 09:00-13:00 shift</a>'
	elseif masseuse['4_shift_1_taken'] = 2 or (week = 4 and hour > 8 and hour < 13):
		'09:00-13:00 shift'
		'<i>not available</i>'
	elseif masseuse['4_shift_1'] = 2:
		'09:00-13:00 shift'
		'<i>already worked</i>'
	else
		'09:00-13:00 shift'
		'<a href="exec:masseuse[''4_shift_1''] = 0 & gt''masseuse_schedule'',''start''"> Cancel Shift</a>'
	end
	'</td><td>'

!! First Friday Shift
	
	if masseuse['5_shift_1'] = 0 and masseuse['5_shift_1_taken'] < 2 and no (week = 5 and hour > 8 and hour < 13):
		'<a href="exec:masseuse[''5_shift_1''] = 1 & gt''masseuse_schedule'',''start''"> 09:00-13:00 shift</a>'
	elseif masseuse['5_shift_1_taken'] = 2 or (week = 5 and hour > 8 and hour < 13):
		'09:00-13:00 shift'
		'<i>not available</i>'
	elseif masseuse['5_shift_1'] = 2:
		'09:00-13:00 shift'
		'<i>already worked</i>'
	else
		'09:00-13:00 shift'
		'<a href="exec:masseuse[''5_shift_1''] = 0 & gt''masseuse_schedule'',''start''"> Cancel Shift</a>'
	end
	'</td><td>'

!! First Saturday Shift

	if masseuse['6_shift_1'] = 0 and masseuse['6_shift_1_taken'] < 2 and no (week = 6 and hour > 8 and hour < 13):
		'<a href="exec:masseuse[''6_shift_1''] = 1 & gt''masseuse_schedule'',''start''"> 09:00-13:00 shift</a>'
	elseif masseuse['6_shift_1_taken'] = 2 or (week = 6 and hour > 8 and hour < 13):
		'09:00-13:00 shift'
		'<i>not available</i>'
	elseif masseuse['6_shift_1'] = 2:
		'09:00-13:00 shift'
		'<i>already worked</i>'
	else
		'09:00-13:00 shift'
		'<a href="exec:masseuse[''6_shift_1''] = 0 & gt''masseuse_schedule'',''start''"> Cancel Shift</a>'
	end
	'</td></tr>'
	
	
!! ---------------------------------------------- 13:00 Shifts ---------------------------------------------------------------------------------

!! Second Sunday Shift
	*P '<tr><td>' 
	if masseuse['7_shift_2'] = 0 and masseuse['7_shift_2_taken'] < 2 and no (week = 7 and hour > 12 and hour < 17):
		'<a href="exec:masseuse[''7_shift_2''] = 1 & gt''masseuse_schedule'',''start''"> 13:00-17:00 shift</a>'
	elseif masseuse['7_shift_2_taken'] = 2 or (week = 7 and hour > 12 and hour < 17):
		'13:00-17:00 shift'
		'<i>not available</i>'
	elseif masseuse['7_shift_2'] = 2:
		'13:00-17:00 shift'
		'<i>already worked</i>'
	else
		'13:00-17:00 shift'
		'<a href="exec:masseuse[''7_shift_2''] = 0 & gt''masseuse_schedule'',''start''"> Cancel Shift</a>'
	end
	'</td><td>'

!! Second Monday Shift

	if masseuse['1_shift_2'] = 0 and masseuse['1_shift_2_taken'] < 2 and no (week = 1 and hour > 12 and hour < 17):
		'<a href="exec:masseuse[''1_shift_2''] = 1 & gt''masseuse_schedule'',''start''"> 13:00-17:00 shift</a>'
	elseif masseuse['1_shift_2_taken'] = 2 or (week = 1 and hour > 12 and hour < 17):
		'13:00-17:00 shift'
		'<i>not available</i>'
	elseif masseuse['1_shift_2'] = 2:
		'13:00-17:00 shift'
		'<i>already worked</i>'
	else
		'13:00-17:00 shift'
		'<a href="exec:masseuse[''1_shift_2''] = 0 & gt''masseuse_schedule'',''start''"> Cancel Shift</a>'
	end
	'</td><td>'

!! Second Tuesday Shift

	if masseuse['2_shift_2'] = 0 and masseuse['2_shift_2_taken'] < 2 and no (week = 2 and hour > 12 and hour < 17):
		'<a href="exec:masseuse[''2_shift_2''] = 1 & gt''masseuse_schedule'',''start''"> 13:00-17:00 shift</a>'
	elseif masseuse['2_shift_2_taken'] = 2 or (week = 2 and hour > 12 and hour < 17):
		'13:00-17:00 shift'
		'<i>not available</i>'
	elseif masseuse['2_shift_2'] = 2:
		'13:00-17:00 shift'
		'<i>already worked</i>'
	else
		'13:00-17:00 shift'
		'<a href="exec:masseuse[''2_shift_2''] = 0 & gt''masseuse_schedule'',''start''"> Cancel Shift</a>'
	end
	'</td><td>'

!! Second Wednesday Shift

	if masseuse['3_shift_2'] = 0 and masseuse['3_shift_2_taken'] < 2 and no (week = 3 and hour > 12 and hour < 17):
		'<a href="exec:masseuse[''3_shift_2''] = 1 & gt''masseuse_schedule'',''start''"> 13:00-17:00 shift</a>'
	elseif masseuse['3_shift_2_taken'] = 2 or (week = 3 and hour > 12 and hour < 17):
		'13:00-17:00 shift'
		'<i>not available</i>'
	elseif masseuse['3_shift_2'] = 2:
		'13:00-17:00 shift'
		'<i>already worked</i>'
	else
		'13:00-17:00 shift'
		'<a href="exec:masseuse[''3_shift_2''] = 0 & gt''masseuse_schedule'',''start''"> Cancel Shift</a>'
	end
	'</td><td>'

!! Second Thursday Shift

	if masseuse['4_shift_2'] = 0 and masseuse['4_shift_2_taken'] < 2 and no (week = 4 and hour > 12 and hour < 17):
		'<a href="exec:masseuse[''4_shift_2''] = 1 & gt''masseuse_schedule'',''start''"> 13:00-17:00 shift</a>'
	elseif masseuse['4_shift_2_taken'] = 2 or (week = 4 and hour > 12 and hour < 17):
		'13:00-17:00 shift'
		'<i>not available</i>'
	elseif masseuse['4_shift_2'] = 2:
		'13:00-17:00 shift'
		'<i>already worked</i>'
	else
		'13:00-17:00 shift'
		'<a href="exec:masseuse[''4_shift_2''] = 0 & gt''masseuse_schedule'',''start''"> Cancel Shift</a>'
	end
	'</td><td>'

!! Second Friday Shift
	
	if masseuse['5_shift_2'] = 0 and masseuse['5_shift_2_taken'] < 2 and no (week = 5 and hour > 12 and hour < 17):
		'<a href="exec:masseuse[''5_shift_2''] = 1 & gt''masseuse_schedule'',''start''"> 13:00-17:00 shift</a>'
	elseif masseuse['5_shift_2_taken'] = 2 or (week = 5 and hour > 12 and hour < 17):
		'13:00-17:00 shift'
		'<i>not available</i>'
	elseif masseuse['5_shift_2'] = 2:
		'13:00-17:00 shift'
		'<i>already worked</i>'
	else
		'13:00-17:00 shift'
		'<a href="exec:masseuse[''5_shift_2''] = 0 & gt''masseuse_schedule'',''start''"> Cancel Shift</a>'
	end
	'</td><td>'

!! Second Saturday Shift

	if masseuse['6_shift_2'] = 0 and masseuse['6_shift_2_taken'] < 2 and no (week = 6 and hour > 12 and hour < 17):
		'<a href="exec:masseuse[''6_shift_2''] = 1 & gt''masseuse_schedule'',''start''"> 13:00-17:00 shift</a>'
	elseif masseuse['6_shift_2_taken'] = 2 or (week = 6 and hour > 12 and hour < 17):
		'13:00-17:00 shift'
		'<i>not available</i>'
	elseif masseuse['6_shift_2'] = 2:
		'13:00-17:00 shift'
		'<i>already worked</i>'
	else
		'13:00-17:00 shift'
		'<a href="exec:masseuse[''6_shift_2''] = 0 & gt''masseuse_schedule'',''start''"> Cancel Shift</a>'
	end
	'</td></tr>'
	
	
!! ---------------------------------------------- 17:00 Shifts ---------------------------------------------------------------------------------

!! Third Sunday Shift
	*P '<tr><td>' 
	if masseuse['7_shift_3'] = 0 and masseuse['7_shift_3_taken'] < 2 and no (week = 7 and hour > 16 and hour < 21):
		'<a href="exec:masseuse[''7_shift_3''] = 1 & gt''masseuse_schedule'',''start''"> 17:00-21:00 shift</a>'
	elseif masseuse['7_shift_3_taken'] = 2 or (week = 7 and hour > 16 and hour < 21):
		'17:00-21:00 shift'
		'<i>not available</i>'
	elseif masseuse['7_shift_3'] = 2:
		'17:00-21:00 shift'
		'<i>already worked</i>'
	else
		'17:00-21:00 shift'
		'<a href="exec:masseuse[''7_shift_3''] = 0 & gt''masseuse_schedule'',''start''"> Cancel Shift</a>'
	end
	'</td><td>'

!! Third Monday Shift

	if masseuse['1_shift_3'] = 0 and masseuse['1_shift_3_taken'] < 2 and no (week = 1 and hour > 16 and hour < 21):
		'<a href="exec:masseuse[''1_shift_3''] = 1 & gt''masseuse_schedule'',''start''"> 17:00-21:00 shift</a>'
	elseif masseuse['1_shift_3_taken'] = 2 or (week = 1 and hour > 16 and hour < 21):
		'17:00-21:00 shift'
		'<i>not available</i>'
	elseif masseuse['1_shift_3'] = 2:
		'17:00-21:00 shift'
		'<i>already worked</i>'
	else
		'17:00-21:00 shift'
		'<a href="exec:masseuse[''1_shift_3''] = 0 & gt''masseuse_schedule'',''start''"> Cancel Shift</a>'
	end
	'</td><td>'

!! Third Tuesday Shift

	if masseuse['2_shift_3'] = 0 and masseuse['2_shift_3_taken'] < 2 and no (week = 2 and hour > 16 and hour < 21):
		'<a href="exec:masseuse[''2_shift_3''] = 1 & gt''masseuse_schedule'',''start''"> 17:00-21:00 shift</a>'
	elseif masseuse['2_shift_3_taken'] = 2 or (week = 2 and hour > 16 and hour < 21):
		'17:00-21:00 shift'
		'<i>not available</i>'
	elseif masseuse['2_shift_3'] = 2:
		'17:00-21:00 shift'
		'<i>already worked</i>'
	else
		'17:00-21:00 shift'
		'<a href="exec:masseuse[''2_shift_3''] = 0 & gt''masseuse_schedule'',''start''"> Cancel Shift</a>'
	end
	'</td><td>'

!! Third Wednesday Shift

	if masseuse['3_shift_3'] = 0 and masseuse['3_shift_3_taken'] < 2 and no (week = 3 and hour > 16 and hour < 21):
		'<a href="exec:masseuse[''3_shift_3''] = 1 & gt''masseuse_schedule'',''start''"> 17:00-21:00 shift</a>'
	elseif masseuse['3_shift_3_taken'] = 2 or (week = 3 and hour > 16 and hour < 21):
		'17:00-21:00 shift'
		'<i>not available</i>'
	elseif masseuse['3_shift_3'] = 2:
		'17:00-21:00 shift'
		'<i>already worked</i>'
	else
		'17:00-21:00 shift'
		'<a href="exec:masseuse[''3_shift_3''] = 0 & gt''masseuse_schedule'',''start''"> Cancel Shift</a>'
	end
	'</td><td>'

!! Third Thursday Shift

	if masseuse['4_shift_3'] = 0 and masseuse['4_shift_3_taken'] < 2 and no (week = 4 and hour > 16 and hour < 21):
		'<a href="exec:masseuse[''4_shift_3''] = 1 & gt''masseuse_schedule'',''start''"> 17:00-21:00 shift</a>'
	elseif masseuse['4_shift_3_taken'] = 2 or (week = 4 and hour > 16 and hour < 21):
		'17:00-21:00 shift'
		'<i>not available</i>'
	elseif masseuse['4_shift_3'] = 2:
		'17:00-21:00 shift'
		'<i>already worked</i>'
	else
		'17:00-21:00 shift'
		'<a href="exec:masseuse[''4_shift_3''] = 0 & gt''masseuse_schedule'',''start''"> Cancel Shift</a>'
	end
	'</td><td>'

!! Third Friday Shift
	
	if masseuse['5_shift_3'] = 0 and masseuse['5_shift_3_taken'] < 2 and no (week = 5 and hour > 16 and hour < 21):
		'<a href="exec:masseuse[''5_shift_3''] = 1 & gt''masseuse_schedule'',''start''"> 17:00-21:00 shift</a>'
	elseif masseuse['5_shift_3_taken'] = 2 or (week = 5 and hour > 16 and hour < 21):
		'17:00-21:00 shift'
		'<i>not available</i>'
	elseif masseuse['5_shift_3'] = 2:
		'17:00-21:00 shift'
		'<i>already worked</i>'
	else
		'17:00-21:00 shift'
		'<a href="exec:masseuse[''5_shift_3''] = 0 & gt''masseuse_schedule'',''start''"> Cancel Shift</a>'
	end
	'</td><td>'

!! Third Saturday Shift

	if masseuse['6_shift_3'] = 0 and masseuse['6_shift_3_taken'] < 2 and no (week = 6 and hour > 16 and hour < 21):
		'<a href="exec:masseuse[''6_shift_3''] = 1 & gt''masseuse_schedule'',''start''"> 17:00-21:00 shift</a>'
	elseif masseuse['6_shift_3_taken'] = 2 or (week = 6 and hour > 16 and hour < 21):
		'17:00-21:00 shift'
		'<i>not available</i>'
	elseif masseuse['6_shift_3'] = 2:
		'17:00-21:00 shift'
		'<i>already worked</i>'
	else
		'17:00-21:00 shift'
		'<a href="exec:masseuse[''6_shift_3''] = 0 & gt''masseuse_schedule'',''start''"> Cancel Shift</a>'
	end
	'</td></tr>'
	
end

--- masseuse_schedule ---------------------------------
