У меня есть отчет о машинах, которые неактивны, отчет фильтруется по интервалу дат
Пример: с '2019-02-24' до '2019-02-26'
Пользователь может установить «смещение» на фильтре, например: смещение A, смещение B и смещение C
Значения машин поступают следующим образом из BD: Maq 01: остановлен. 2019-02-24 09: 00: 00 'возвращено' 2019-02-24 11: 00: 00 '
У каждой смены есть определенный график
Смена A: с 05:00:00 до 13:30: 00;
смена B: 13:31:00 до 22:00; 00;
смена C: 22:01:00 до 04: 59: 00;
все значения преобразуются в srtotime
Предполагая, что пользователь выбирает интервал между «2019-02-24» e «2019-02-26» и «shift» A (с 05:00 до13:30):
values from BD: Machine 01
stopped '2019-02-24 09:00:00', returned: '2019-02-24 10:00:00' = 1 hour stopped on 24/02 shift A;
stopped '2019-02-25 12:00:00', returned: '2019-02-25 15:00:00' = 1:30 hours stopped on 24/02 shift A;
I would like to create this parameter, the code identify that the shift chosen is shift A (05:00 ás 13:30), in all day selected, and then compile everything
ex: Mach 01 = hours stopped between 24/02 and 26 on shift A: 02:30:00
мой код пока:
$data_ida = '2019-02-24';
data_volta '2019-02-26'
$sql_ = "SELECT * FROM manutencao WHERE data BETWEEN '$data_ida' - interval 90 day AND '$data_volta' AND h_retorno != '0000-00-00 00:00:00' ORDER BY id ASC";
$disp_sql_ = $mysqli->query($sql_);
$consulta = $disp_sql_->num_rows;
if($consulta > 0){
while($data_2 = $disp_sql_->fetch_array())
{
$h_stopped = $data_2['h_parada'];
$h_returned = $data_2['h_retorno'];
$num_mach = $data_2['num'];
$day_begin = strtotime($data_ida." 00:00:00");
$day_end = strtotime($data_volta." 23:59:00");
$hour_begin_mach = strtotime($h_stopped);
$hour_end_mach = strtotime($h_retorned);
if($hour_begin_mach >= $day_begin && $hour_end_mach <= $day_end){
if($shift == 'a'){
$shift_begin = '05:00:00';
$shift_end = '13:29:00';
}elseif($shift == 'b'){
$shift_begin = '13:30:00';
$shift_end = '22:00:00';
}elseif($shift == 'c'){
$shift_begin = '22:01:00';
$shift_end = '04:59:00';
}
$strtotime_shift_begin = strtotime($data_ida." ".$shift_begin);
$strtotime_shift_end = strtotime($data_volta." ".$shift_end);
if($strtotime_shift_begin <= $hour_begin_mach && $strtotime_shift_end >= $hour_end_mach ){
$diff = $hour_end_mach - $hour_begin_mach ;
$stopped []= array('machine' => $num_mach, 'seconds' => $diff);
}}
как я могу сделать этот код выше, когда интервал между датами больше 1 (например, 24 /02, 25/02 и 26/02)?
извините за плохой английский