I plan to create a monthly shift schedule. I have 4 turns:
-
T.M = Morning shift (11 helpers this shift, but each day 3)
-
T.T = Afternoon shift (there are 5 aids this shift, but each day 2)
-
T.I = Intermediate Shift (there are 4 assistants this turn, but each day 2)
-
T.N = Night Shift (there are 4 assistants this turn, but each day 2)
-
F = Gaps
In the morning, afternoon and intermediate shift the cycle is work 4 days and play 1. In the night shift the cycle is in a week work 2 nights and spare 1, the following week work 3 nights and spare 1.
I wanted to create a table for each month that generated the schedule automatically by shift, but I have not found a way to do that yet.
At this point I thought of this logic that I will present, but it does not form the scale as I intend and I think the error is in logic:
<?php
$diasDaSemana=array(
"segunda-feira"=>array(
"tm"=>array(
"ativos"=>5,
"folgas"=>3
),
"tt"=>array(
"ativos"=>4,
"folgas"=>1
),
"tt2"=>array(
"ativos"=>2,
"folgas"=>2
),
"tn"=>array(
"ativos"=>1,
"folgas"=>0
),
"tr"=>array(
"ativos"=>3,
"folgas"=>2
)
),
"terça-feira"=>array(
"tm"=>array(
"ativos"=>5,
"folgas"=>3
),
"tt"=>array(
"ativos"=>4,
"folgas"=>1
),
"tt2"=>array(
"ativos"=>2,
"folgas"=>2
),
"tn"=>array(
"ativos"=>1,
"folgas"=>0
),
"tr"=>array(
"ativos"=>3,
"folgas"=>2
)
),
"quarta-feira"=>array(
"tm"=>array(
"ativos"=>5,
"folgas"=>3
),
"tt"=>array(
"ativos"=>4,
"folgas"=>1
),
"tt2"=>array(
"ativos"=>2,
"folgas"=>2
),
"tn"=>array(
"ativos"=>1,
"folgas"=>0
),
"tr"=>array(
"ativos"=>3,
"folgas"=>2
)
),
"quinta-feira"=>array(
"tm"=>array(
"ativos"=>5,
"folgas"=>3
),
"tt"=>array(
"ativos"=>4,
"folgas"=>1
),
"tt2"=>array(
"ativos"=>2,
"folgas"=>2
),
"tn"=>array(
"ativos"=>1,
"folgas"=>0
),
"tr"=>array(
"ativos"=>3,
"folgas"=>2
)
),
"sexta-feira"=>array(
"tm"=>array(
"ativos"=>5,
"folgas"=>3
),
"tt"=>array(
"ativos"=>4,
"folgas"=>1
),
"tt2"=>array(
"ativos"=>2,
"folgas"=>2
),
"tn"=>array(
"ativos"=>1,
"folgas"=>0
),
"tr"=>array(
"ativos"=>3,
"folgas"=>2
)
),
"sábado"=>array(
"tm"=>array(
"ativos"=>5,
"folgas"=>3
),
"tt"=>array(
"ativos"=>4,
"folgas"=>1
),
"tt2"=>array(
"ativos"=>2,
"folgas"=>2
),
"tn"=>array(
"ativos"=>1,
"folgas"=>0
),
"tr"=>array(
"ativos"=>3,
"folgas"=>2
)
),
"domingo"=>array(
"tm"=>array(
"ativos"=>5,
"folgas"=>3
),
"tt"=>array(
"ativos"=>4,
"folgas"=>1
),
"tt2"=>array(
"ativos"=>2,
"folgas"=>2
),
"tn"=>array(
"ativos"=>1,
"folgas"=>0
),
"tr"=>array(
"ativos"=>3,
"folgas"=>2
)
)
);
foreach ($diasDaSemana as $dias => $turnos) {
foreach ($turnos as $turno => $value) {
$limiteAtivo = $value["ativo"];
$limiteFolga = $value["folga"];
$selectAtivo="SELECT * FROM colaboradores WHERE turno='$turno' ORDER BY ultimaFolga ASC LIMIT $limiteAtivo";
$selectAtivo="SELECT * FROM colaboradores WHERE turno='$turno' ORDER BY ultimaFolga DESC LIMIT $limiteFolga";
}
}
In addition to this, I created 1 trab in mysql: Table with employee types:
CREATE TABLE 'Colaboradores' (
'Id' int(11) NOT NULL AUTO_INCREMENT,
'id_colaborador' int(11) DEFAULT NULL,
'ultimaFolga' date DEFAULT NULL,
'turno' varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY ('Id')
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;