php - assignment shifts work with forecast curve -


i need assign work shifts follow forecast curve.

example.

this forecast curve:

08:00        08:15 08:30 08:45 09:00 09:15 09:30 09:45 10:00 .....17:00 6(persons)   6     6     7     7     8     12    16    14         10 

and have shift preconfigured. example:

08:00 12:00,08:15 12:15,08:30 12:30,08:45 12:45,09:00 13:00.... 16:00 20:00, 16:15 20:15...

each person has shift. example:

carl  08:00 12:00 rich  08:30 12:30 jason 09:45 13:45 louis 10:00 14:00 

but assigned @ random. so, i'd curve, says there 6 people, must obligatorily 6 people, @ 08:00, 6 people turn starts 08:00.

then situation become (suppose 6 people start @ 08:00 12:00):

 08:00        08:15 08:30 08:45 09:00 09:15 09:30 09:45 10:00 .....12:00 13:00  6(persons)   6     6     7     7     8     12    16    14         10    10  6            6     6     6     6     6     6     6     6          6     0 

now comes request.

i script in php assign random shifts, following curve , changing situation in way.

 08:00        08:15 08:30 08:45 09:00 09:15 09:30 09:45 10:00 .....12:00  13:00  6(persons)   6     6     7     7     8     12    16    14         10     10  6            6     6     7     7     8     12    16    16         16     10 

is not necessary equal forecast. impossible because shifts minimum of 4 hours. means 4 hours have 6 people (example) assigning shifts people:

name  08:00 12:00(6 people start) name  08:45 12:45(1 person start) name  09:15 13:15(1 person start) name  09:30 13:30(4 people start) 

this script assign shifts random:

function sumatra($inizio,$plus){         $accrued_time = strtotime($inizio);      $current_session = strtotime($plus) - strtotime("00:00:00");      return date("h:i", ($accrued_time + $current_session));         }  $link=connect_db();   $sel="select op.id, op.nome, op.cognome, op.ore_giornaliere_time, ( select tp.inizio turni_preconf tp tp.tot_ore = op.ore_giornaliere order rand( )  limit 1 ) randomin operatori op";  $res_sel=mysql_query($sel,$link);   while($er=mysql_fetch_array($res_sel)){      echo $er['nome'].' '.$er['cognome'].': '.remove_sec($er['randomin']).'/'.sumatra($er['randomin'],$er['ore_giornaliere_time']).'<br>';       } 

and sql schema http://sqlfiddle.com/#!2/043c0


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -