Esempio n. 1
0
 private function existeSolapamientodb($data, $numFila, $recursos)
 {
     $fechaDesde = sgrDate::dateCSVtoSpanish($data['F_DESDE_HORARIO1']);
     $fechaHasta = sgrDate::dateCSVtoSpanish($data['F_HASTA_HORARIO1']);
     $nRepeticiones = sgrDate::numRepeticiones($fechaDesde, $fechaHasta, $data['COD_DIA_SEMANA']);
     for ($j = 0; $j < $nRepeticiones; $j++) {
         //foreach
         //fecha Evento
         $startDate = sgrDate::timeStamp_fristDayNextToDate($fechaDesde, $data['COD_DIA_SEMANA'], 'Y-m-d');
         $currentfecha = sgrDate::fechaEnesimoDia($startDate, $j);
         $sgrEvento = new sgrEvento();
         foreach ($recursos as $recurso) {
             if (0 < $sgrEvento->solapa($recurso->id, $currentfecha, $data['INI'], $data['FIN'])) {
                 //hay solape: fin -> return true
                 return true;
             }
         }
         //fin foreach cada puesto o equipo, (espacio el array recurso solo contiene un elemento)
     }
     //fin foreach repeticion periodica
     return false;
 }
Esempio n. 2
0
 private function editEvents($fechaInicio, $fechaFin, $idSerie)
 {
     $result = '';
     $repetir = Input::get('repetir');
     $dias = Input::get('dias');
     //1->lunes...., 5->viernes
     if ($repetir == 'SR') {
         //SR == sin repetición (no periódico)
         //$dias = array(date('N',sgrDate::gettimestamp($fechaInicio,'d-m-Y')));
         $dias = array(date('N', strtotime($fechaInicio)));
         $fechaFin = $fechaInicio;
     }
     foreach ($dias as $dWeek) {
         if (Input::get('repetir') == 'SR') {
             $nRepeticiones = 1;
         } else {
             $nRepeticiones = sgrDate::numRepeticiones($fechaInicio, $fechaFin, $dWeek);
         }
         for ($j = 0; $j < $nRepeticiones; $j++) {
             $startDate = sgrDate::timeStamp_fristDayNextToDate($fechaInicio, $dWeek);
             //return timestamp
             $currentfecha = sgrDate::fechaEnesimoDia($startDate, $j);
             //return string Y-m-d
             $result = $this->saveEvent(Input::all(), $currentfecha, $idSerie);
         }
     }
     return $result;
 }