/* Decoded by unphp.net */ ?>$txtCode, 'JourDebut' =>$txtIntitule, 'JourFin' =>$txtRepos, 'DebutNuit' =>$txtDnuit, 'FinNuit' =>$txtFnuit, 'LM' =>$LM, 'MM' =>$MM, 'MJ' =>$MJ, 'JV' =>$JV, 'VS' =>$VS, 'SD' =>$SD, 'DL' =>$DL, ); if ( $key == 'modif' ) { $condition = "Code = '{$txtCode}'"; $obj->executeQuery("tblJournee", $updCategorie,$condition); } else { $obj->executeQuery("tblJournee", $updCategorie); $requete = "select debut, fin, Periode from sr_periode where statut = 'Ouvert'"; $resultat = $obj->showData($requete); foreach ($resultat as $key ) { extract($key); $debut = date_create(str_replace("/", "-", $debut)); $fin = date_create(str_replace("/", "-", $fin)); $dDebut = date_format($debut,"d/m/Y"); $dFin = date_format($fin,"d/m/Y"); $debut = date_format($debut, "m/d/Y"); //echo "datedebut = ".$dateDebut; $fin = date_format($fin, "m/d/Y"); ////var_dump($debut); $date1 = strtotime($debut); $date2 = strtotime($fin); $nbr = 1; for ($j=$date1 ; $j <= $date2 ; $j += 3600 * 24) { $d1 = date("d/m/Y",$j); $k = $j + 3600 * 24; $d2 = date("d/m/Y", $k); $num_sem = date("W",$j); //var_dump($d1,$d2); //foreach ($result as $key) { //extract($key); $jourDebut = ToTime($txtIntitule); $jourFin = ToTime($txtRepos); if($jourDebut == "00:00:00"){ $Ddebut = $d1 . " " . $jourDebut; $Dfin = $d1 . " " . $jourFin; }else{ $Ddebut = $d1 . " " . $jourDebut; $Dfin = $d2 . " " . $jourFin; } $req = "select num_sem as deb,exercice from tblsemaine where '{$Ddebut}' between datedebutsem and datefinsem"; $res = $obj->getData($req); extract($res); $req = "select num_sem as fn,exercice from tblsemaine where '{$Dfin}' between datedebutsem and datefinsem"; $res = $obj->getData($req); extract($res); $We = WeekEnd($Ddebut,$Dfin,$updCategorie); $codes = "J". $nbr; $toCal = array( 'periode' => $Periode, 'Ddebut' => $Ddebut, 'Dfin' => $Dfin, 'debut' => $Ddebut, 'fin' => $Dfin, 'code' => $codes, 'codeCalendrier' => $txtCode, 'sdebut' => $deb, 'sfin' => $fn, 'exercice' => $exercice, 'weekEnd' => $We, ); $obj->executeQuery("sr_calendrier",$toCal); //} $nbr++; } } } function ToTime($time){ if(empty($time)) return "00:00:00"; else return substr($time, 0,8); } function WeekEnd($Jdeb,$Jfin,$arr){ extract($arr); var_dump($Jdeb,$Jfin); $Jdeb = date_create(str_replace("/", "-", $Jdeb)); $Jfin = date_create(str_replace("/", "-", $Jfin)); $dJdeb = date_format($Jdeb,"d/m/Y"); $dJfin = date_format($Jfin,"d/m/Y"); $Jdeb = date_format($Jdeb, "m/d/Y"); //echo "dateJdeb = ".$dateJdeb; $Jfin = date_format($Jfin, "m/d/Y"); ////var_dump($Jdeb); $date1 = strtotime($Jdeb); $date2 = strtotime($Jfin); $Jd = date("w",$date1); $Jf = date("w",$date2); $ensemble = ToCode($Jd,$Jf); var_dump($ensemble); $retour = 0; if($LM == 1 && ($ensemble == '11' || $ensemble == '12')){ $retour = 1; } if($MM == 1 && ($ensemble == '22' || $ensemble == '23')){ $retour = 1; } if($MJ == 1 && ($ensemble == '33' || $ensemble == '34')){ $retour = 1; } if($JV == 1 && ($ensemble == '44' || $ensemble == '45')){ $retour = 1; } if($VS == 1 && ($ensemble == '55' || $ensemble == '56')){ $retour = 1; } if($SD == 1 && ($ensemble == '66' || $ensemble == '60')){ $retour = 1; } if($DL == 1 && ($ensemble == '00' || $ensemble == '01')){ $retour = 1; } //var_dump($arr,$Jd,$Jf,$ensemble,$retour); return $retour; } function ToCode($v1,$v2){ $ensemble = ""; $ensemble = $v1 .$v2; return $ensemble; } ?>