3
I intend to create a monthly shift schedule. I’ve got four shifts:
T.M = Morning shift (has 11 assistants this shift, but on each day break 3)
T.T = Afternoon shift (has 5 assistants this shift, but on each day break 2)
T.I = Intermediate shift (has 4 assistants this shift, but on each day break 2)
T.N = Night Shift (has 4 assistants this shift, but in each day break 2)
F = Leave
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 take off 1, in the following week work 3 nights and take off 1.
I wanted to create a table for each month that would automatically generate the time scale per shift, but I haven’t found a way to do so yet.
At this moment I thought of this logic that I will present, but it does not shape the scale as I intend and I think that 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 I created 1 work in mysql: Table with types of collaborators:
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;
Friend, To make it a little clearer, the assistants can be registered in more than one shift? Or are exclusive of a certain shift?
– Irahe Kasprzykowski
@Irahe Kasprzykowski In all shifts they are auxiliary, and the rotary auxiliaries can also do any shift.
– Bruno