public function testEnfantTest() { $enfant = enfant::create(['id' => '100', 'nom' => 'moumou', 'prenom' => 'sara', 'sexe' => 'f', 'naissance' => '', 'niveau_classe' => 'CP', 'garderie' => '1', 'prendre_bus' => '0', 'responsable_bus' => 'alex', 'rentre_seul' => '0', 'mange_cantine' => '1', 'exception_porc' => '0', 'exception_viande' => '0', 'exception_autre' => '']); $this->assertEquals(0, Enfant::find(100)->expentionelles()->count()); $enfant->expentionelles()->create(['id' => '20', 'type' => 'bus_soir', 'jour' => '2016-04-15', 'inscrit' => '', 'enfant_id' => '100', 'modicate_by' => '1']); $this->assertEquals(1, Enfant::find(100)->expentionelles()->count()); $enfant->expentionelles()->create(['id' => '22', 'type' => 'cantine', 'jour' => '2016-04-15', 'inscrit' => '', 'enfant_id' => '100', 'modicate_by' => '2']); $this->assertEquals(2, Enfant::find(100)->expentionelles()->count()); Exceptionnelle::destroy(22); $this->assertEquals(1, Enfant::find(100)->expentionelles()->count()); }
public function testInscription(Request $request) { if (!$request->ajax()) { abort(404); } $data = $request->all(); $dates = $data['date']; if (date('N', strtotime($dates)) >= 6) { return response()->json(['response' => 'week_end']); } if (Feries::est_ferie($dates) == true) { return response()->json(['response' => 'ferie']); } $xmlurl = 'http://telechargement.index-education.com/vacances.xml'; $xml = simplexml_load_file($xmlurl); $calendrier = $xml->calendrier; $json = json_encode($calendrier->zone[2]); $tab = json_decode($json, true); foreach ($tab['vacances'] as $vac) { $debut = date('Y-m-d', strtotime($vac['@attributes']['debut'])); $fin = date('Y-m-d', strtotime($vac['@attributes']['fin'])); if ($dates > $debut && $dates < $fin) { return response()->json(['response' => 'vacances']); } } $type = $data['type']; $id = $data['id']; $exep = Exceptionnelle::where('enfant_id', $id)->where('type', $type)->where('jour', $dates)->get()->count(); if ($exep == 1) { return response()->json(['response' => 'fail']); } $reg = Reguliere::where('enfant_id', $id)->where('type', $type)->first(); if ($reg != null && $reg->count() != 0) { $jours = str_split($reg->jours); $day = date('w', strtotime($dates)); if (in_array($day, $jours)) { return response()->json(['ok' => 'Desinscription']); } } return response()->json(['ok' => 'Inscription']); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $event = Exceptionnelle::findOrFail($id); $idE = $event->enfant_id; $event->delete(); return redirect(route('inscription.show', $idE)); }
public function exportFiches($type, $jour) { $tabVacances = Feries::chargement(); $semaine = [$jour, date('Y-m-d', strtotime(date('Y-m-d', strtotime($jour)) . "+4 day"))]; if ($type == 'garderie') { Excel::load('fichiers/garderie.xlsx', function ($file) use($semaine) { for ($i = 0; $i < 2; $i++) { $cycles = ['primaire', 'maternelle']; $cycle = $cycles[$i]; $enfants = Enfant::where('garderie', true)->whereHas('classe', function ($q) use($cycle) { return $q->where('cycle', $cycle); })->get(); $nb = $enfants->count(); $file->setFileName('garderie' . date('d/m/Y', strtotime($semaine[0]))); $file->setActiveSheetIndex($i)->setCellValue('D2', 'S' . date('W', strtotime($semaine[0]))); $file->setActiveSheetIndex($i)->setCellValue('E6', date('d/m/Y', strtotime($semaine[0]))); $file->setActiveSheetIndex($i)->setCellValue('K6', date('d/m/Y', strtotime($semaine[1]))); $ligne = 10; foreach ($enfants as $cle => $enfant) { $file->setActiveSheetIndex($i)->setCellValue('A' . $ligne, $enfant->classe->niveau); $file->setActiveSheetIndex($i)->setCellValue('B' . $ligne, $enfant->nom); $file->setActiveSheetIndex($i)->setCellValue('C' . $ligne, $enfant->prenom); $ligne++; } } })->export('xlsx'); } else { if ($type == 'cantine') { $regs = Reguliere::with(['Enfant', 'Enfant.Classe'])->where('type', 'cantine')->get(); $exeps = Exceptionnelle::with(['Enfant', 'Enfant.Classe'])->whereBetween('jour', $semaine)->where('type', 'cantine')->get(); $ferie = []; for ($i = 0; $i < 5; $i++) { $monjour = date('Y-m-d', strtotime($i . 'day' . $semaine[0])); if (Feries::est_ferie($monjour) || Feries::est_vacances($monjour, $tabVacances)) { $ferie[] = $i + 1; } } foreach ($regs as $reg) { $inscrits[$reg->enfant_id]['inscription'] = str_split($reg->jours); $inscrits[$reg->enfant_id]['enfant'] = $reg; if (!empty($ferie)) { foreach ($ferie as $f) { $cle = array_search($f, $inscrits[$reg->enfant_id]['inscription']); if ($cle !== null) { unset($inscrits[$reg->enfant_id]['inscription'][$cle]); } } } } foreach ($exeps as $exep) { //if($exep->inscrit === 1){ // Fred : 13/12/15 correction de bug propagée, mettre entre ' les comparaisons d'inscrits if ($exep->inscrit === '1') { $inscrits[$exep->enfant_id]['inscription'][] = date('w', strtotime($exep->jour)); if (!isset($inscrits[$exep->enfant_id]['enfant'])) { $inscrits[$exep->enfant_id]['enfant'] = $exep; } } else { $cle = array_search(date('w', strtotime($exep->jour)), $inscrits[$exep->enfant_id]['inscription']); if ($cle !== false) { unset($inscrits[$exep->enfant_id]['inscription'][$cle]); } } } Excel::load('fichiers/cantine.xlsx', function ($file) use($inscrits, $semaine) { $cycles = ['primaire', 'maternelle', 'adulte']; $file->setFileName('cantine' . date('d/m/Y', strtotime($semaine[0]))); for ($i = 0; $i < 3; $i++) { $cycle = $cycles[$i]; $file->setActiveSheetIndex($i)->setCellValue('A3', 'S' . date('W', strtotime($semaine[0]))); $file->setActiveSheetIndex($i)->setCellValue('C3', date('d/m/Y', strtotime($semaine[0]))); $file->setActiveSheetIndex($i)->setCellValue('D3', date('d/m/Y', strtotime($semaine[1]))); } $ligne = [6, 6, 6]; foreach ($inscrits as $inscrit) { //if($inscrit['enfant']->enfant_id == 32){dd($inscrit['enfant']->enfant->classe->cycle);} $cycle = $inscrit['enfant']->enfant->classe->cycle; switch ($cycle) { case 'Primaire': $feuille = 0; break; case 'Maternelle': $feuille = 1; break; default: $feuille = 2; break; } $file->setActiveSheetIndex($feuille)->setCellValue('A' . $ligne[$feuille], $inscrit['enfant']->enfant->classe->niveau); $file->setActiveSheetIndex($feuille)->setCellValue('B' . $ligne[$feuille], $inscrit['enfant']->enfant->classe->instituteur); $file->setActiveSheetIndex($feuille)->setCellValue('C' . $ligne[$feuille], $inscrit['enfant']->enfant->nom); $file->setActiveSheetIndex($feuille)->setCellValue('D' . $ligne[$feuille], $inscrit['enfant']->enfant->prenom); for ($j = 1; $j <= 5; $j++) { if (in_array($j, $inscrit['inscription'])) { $file->setActiveSheetIndex($feuille)->setCellValue(chr(ord('D') + $j) . $ligne[$feuille], 'F'); } } $ligne[$feuille]++; } })->export('xls'); } else { if ($type == 'bus_matin' || $type == 'bus_soir') { $regs = Reguliere::whereHas('enfant', function ($q) { return $q->orderBy('enfants.arret_id'); })->with(['enfant', 'enfant.classe', 'enfant.arret', 'enfant.arret.ligne'])->where('jours', 'LIKE', '%' . date('N', strtotime($semaine[0])) . '%')->where('type', $type)->get(); //dd($regs, date('N', strtotime($semaine[0]))); $exeps = Exceptionnelle::with('enfant', 'enfant.classe')->where('jour', date('Y-m-d', strtotime($semaine[0])))->where('type', $type)->get(); foreach ($regs as $reg) { if ($reg->enfant != null && $reg->enfant->arret != null) { $inscrits[$reg->enfant->arret->ligne->id][$reg->enfant->arret->numero_arret][$reg->enfant_id] = $reg; if (!isset($inscrits[$reg->enfant->arret->ligne->id]['nom'])) { $inscrits[$reg->enfant->arret->ligne->id]['nom'] = $reg->enfant->arret->ligne; } if (!isset($inscrits[$reg->enfant->arret->ligne->id][$reg->enfant->arret->numero_arret]['nom'])) { $inscrits[$reg->enfant->arret->ligne->id][$reg->enfant->arret->numero_arret]['nom'] = $reg->enfant->arret; } } } foreach ($exeps as $exep) { if ($reg->enfant != null && $reg->enfant->arret != null && $exep->enfant->arret) { //if($exep->inscrit === 1){// Fred : 13/12/15 correction de bug propagée, mettre entre ' les comparaisons d'inscrits if ($exep->inscrit === '1') { $inscrits[$exep->enfant->arret->ligne->id][$exep->enfant->arret->numero_arret][$exep->enfant_id] = $exep; if (!isset($inscrits[$exep->enfant->arret->ligne->id]['nom'])) { $inscrits[$exep->enfant->arret->ligne->id]['nom'] = $exep->enfant->arret->ligne; } if (!isset($inscrits[$exep->enfant->arret->ligne->id][$exep->enfant->arret->numero_arret]['nom'])) { $inscrits[$exep->enfant->arret->ligne->id][$exep->enfant->arret->numero_arret]['nom'] = $exep->enfant->arret; } } else { unset($inscrits[$exep->enfant->arret->ligne->id][$exep->enfant->arret->numero_arret][$exep->enfant_id]); } } } foreach ($inscrits as $ligne) { $temp = $ligne['nom']; unset($ligne['nom']); ksort($ligne, SORT_NUMERIC); $ligne['nom'] = $temp; } //dd($inscrits); //dd($inscrits); //dd($type.'_'.date('d/m/Y',strtotime($semaine[0]))); Excel::create('test', function ($file) use($inscrits, $semaine, $type) { $file->setFileName($type . '_' . date('d/m/Y', strtotime($semaine[0]))); foreach ($inscrits as $key => $lignes) { $file->sheet($lignes['nom']->nom, function ($sheet) use($lignes, $semaine, $type) { $data = [['', ucfirst(str_replace('_', ' ', $type)), 'Semaine ' . date('w', strtotime($semaine[0])), 'le ', date('d/m/Y', strtotime($semaine[0]))], ['', $lignes['nom']->nom, $lignes['nom']->communes], ['', 'Nombre d\'enfants', '', 'sur', $lignes['nom']->nb_place], ['', 'Nom', 'Prenom', 'Autoris.', '', '', 'Responsables']]; $l = 5; $total = 0; foreach ($lignes as $cle => $arrets) { if ($cle !== 'nom') { $data[] = ['>>', $arrets['nom']->numero_arret, $arrets['nom']->nom, $arrets['nom']->commune, count($arrets) - 1]; $sheet->cells('A' . $l . ':G' . $l, function ($cell) { $cell->setBackground('#ffff00'); $cell->setBorder('thin', 'none', 'thin', 'none'); $cell->setAlignment('center'); $cell->setFont(array('family' => 'Calibri', 'size' => '14', 'bold' => true)); }); $l++; $total += count($arrets) - 1; foreach ($arrets as $cle2 => $enfant) { if ($cle2 != 'nom') { //dd($enfant); $data[] = [' ', $enfant->enfant->nom, $enfant->enfant->prenom, '', $enfant->enfant->classe != null && $enfant->enfant->classe->cycle == 'Maternelle' ? 'M' : '', $enfant->enfant->rentre_seul ? 'OUI' : '', $enfant->enfant->responsable_bus]; $sheet->setBorder('A' . $l . ':F' . $l, 'thin', 'thin', 'thin', 'thin'); $l++; } } } } $data[2][2] = $total; $sheet->cells('A1:G4', function ($cell) { $cell->setBackground('#ffff00'); $cell->setFont(array('family' => 'Calibri', 'size' => '14', 'bold' => true)); }); $sheet->setBorder('E1', 'thin'); $sheet->setBorder('A4:G4', 'thin'); $sheet->setWidth(array('A' => 3, 'B' => 40, 'C' => 40, 'D' => 15, 'E' => 15, 'G' => 50)); $sheet->fromArray($data, null, 'A1', false, false); }); } })->export('xls'); } } } }
public function importerFichiers(Request $request) { ini_set('max_execution_time', 1000); $file = $request->file('importer'); $destination = __DIR__ . 'uploads'; $name = $file->getClientOriginalName(); $file->move($destination, $name); $nom = $destination . '/' . $name; $tabVacances = Feries::chargement(); $nombre_personnes = 0; Excel::selectSheets('Classes')->load($nom, function ($reader) { $liste_classes = $reader->limit(500)->get(); foreach ($liste_classes as $class) { $classe = new Classe(); $classe->niveau = $class['classe']; $classe->instituteur = $class['instituteur']; if (ucfirst($class['cycle']) == 'Elementaire' || ucfirst($class['cycle']) == 'Primaire') { $classe->cycle = 'Primaire'; } else { $classe->cycle = 'Maternelle'; } $classe->save(); } }); Excel::selectSheets('Lignes')->load($nom, function ($reader) { $liste_ligne = $reader->limit(500)->get(); foreach ($liste_ligne as $liste) { $arret = new Arret(); $arret->nom = $liste['arret']; $arret->numero_arret = $liste['numero']; $ligne = Ligne::where('nom', $liste['ligne'])->first(); if (empty($ligne)) { $ligne = new Ligne(); $ligne->nom = $liste['ligne']; $ligne->save(); } $arret->ligne_id = $ligne->id; $arret->save(); } }); $test = Excel::selectSheets('Sivusem')->load($nom, function ($sheet) use(&$data) { $enfants = $sheet->limit(500)->get(); foreach ($enfants as $fic) { if ($fic['nom'] != null || $fic['prenom'] != null) { $user = new Enfant(); if ($fic['nom'] == null) { // MODIF 2 $user->nom = "FAUX"; } else { $user->nom = $fic['nom']; } $user->prenom = $fic['prenom']; $classe = Classe::where('instituteur', $fic['instituteur'])->first(); if ($classe != null) { $user->classe_id = $classe->id; } $user->niveau_classe = $fic['classe']; if (strtolower($fic['garderie']) == 'oui') { $user->garderie = 1; } else { $user->garderie = 0; } if (strtolower($fic['transport']) == 'oui') { $user->prendre_bus = 1; if (strtolower($fic['autorisation']) == 'oui') { $user->rentre_seul = 1; } else { $user->rentre_seul = 0; } $arret = Arret::where('nom', $fic['arret'])->first(); if ($arret != null) { $user->arret_id = $arret->id; } } else { $user->prendre_bus = 0; } //$user->arret_id = $arret->id; if (strtolower($fic['cantine']) == 'oui') { $user->mange_cantine = 1; if (strtolower($fic['porc']) == 'non') { $user->exception_porc = false; } else { $user->exception_porc = true; } if (strtolower($fic['viande']) == 'non') { $user->exception_viande = false; } else { $user->exception_viande = true; } if ($fic['pai'] == null) { $user->exception_autre = ""; } else { $user->exception_autre = $fic['pai']; } } else { $user->mange_cantine = 0; } $user->save(); $cantine = new Reguliere(); $cantine->type = 'cantine'; $cantine->enfant_id = $user->id; $cantine->save(); $bus_matin = new Reguliere(); $bus_matin->type = 'bus_matin'; $bus_matin->enfant_id = $user->id; $bus_matin->save(); $bus_soir = new Reguliere(); $bus_soir->type = 'bus_soir'; $bus_soir->enfant_id = $user->id; $bus_soir->save(); //$parent1_exist = User::where('nom',$fic['nom1'])->where('prenom',$fic['prenom1'])->get(); //$parent2_exist = User::where('nom',$fic['nom2'])->where('prenom',$fic['prenom2'])->get(); $parent1_exist = User::where('email', $fic['adresse1'])->get(); $parent2_exist = User::where('email', $fic['adresse2'])->get(); for ($nombre = 0; $nombre < $fic['nb_parent']; $nombre++) { if ($nombre == 1) { if ($parent2_exist->count() == 0) { $parent = new User(); $parent->nom = $fic['nom2'] == NULL ? 'FAUX' : $fic['nom2']; $parent->prenom = $fic['prenom2']; if ($fic['adresse2'] != $fic['adresse1']) { $parent->email = $fic['adresse2']; } } } else { if ($parent1_exist->count() == 0) { $parent = new User(); $parent->nom = $fic['nom1'] == NULL ? 'FAUX' : $fic['nom1']; $parent->prenom = $fic['prenom1']; $parent->email = $fic['adresse1']; } } if ($parent1_exist->count() == 0 && $parent2_exist->count() == 0) { $parent->niveau = 0; $nb = 0; do { $id = Generator::generate_id($parent->nom, $parent->prenom, $nb); $nb++; } while (User::where('identifiant', $id)->count() != 0); $parent->identifiant = $id; $mdp = Generator::mdp(); $data[] = ['nom' => $parent->nom, 'prenom' => $parent->prenom, 'email' => $parent->email, 'identifiant' => $parent->identifiant, 'password' => $mdp]; $parent->password = bcrypt($mdp); $parent->save(); $user->users()->attach([$parent->id]); } else { if ($parent1_exist->count() != 0) { $user->users()->attach([$parent1_exist->first()->id]); } if ($parent2_exist->count() != 0) { $user->users()->attach([$parent2_exist->first()->id]); } } } } else { break; } } }); Excel::selectSheets('Cantine', 'Bus')->load($nom, function ($reader) use($tabVacances) { $cantines = $reader->limit(500)->get(); $ligne_vide = 0; for ($i = 0; $i < 2; $i++) { foreach ($cantines[$i] as $cantine) { if ($ligne_vide <= 1) { if ($cantine['nom'] == null && $cantine['prenom'] == null) { $ligne_vide++; } else { $enfant = Enfant::where('nom', $cantine['nom'] == null ? 'FAUX' : $cantine['nom'])->where('prenom', $cantine['prenom'])->first(); if ($i == 0) { if ($cantine['jour_debut'] != null) { // MODIF 3 $rentree = Feries::jour_rentree(date('Y', strtotime($cantine['jour_debut'])), $tabVacances); $debut_rentree = date('Y-m-d', strtotime($rentree)); $debut_inscrit = date('Y-m-d', strtotime($cantine['jour_debut'])); } if ($enfant == null) { dd($cantine, $cantine['nom']); } $reg = Reguliere::where('enfant_id', $enfant->id)->where('type', 'cantine')->first(); $jour = 1; $finSemaine = 5; $tab = []; while ($jour <= $finSemaine) { $day = Feries::Jours($jour); if ($cantine['jour_debut'] != null) { // MODIF 4 if ($rentree != $debut_rentree) { while ($debut_rentree < $debut_inscrit) { if (date('N', strtotime($debut_rentree)) == $jour) { if ($cantine[$day] != null) { $excep = new Exceptionnelle(); $excep->type = 'cantine'; $excep->enfant_id = $enfant->id; $excep->modificate_by = 0; $excep->jour = date('Y-m-d', strtotime($debut_rentree)); $excep->inscrit = 0; $excep->save(); } } $debut_rentree = date('Y-m-d', strtotime('+1 days', strtotime($debut_rentree))); } $debut_rentree = date('Y-m-d', strtotime($rentree)); } } if ($cantine[$day] != null) { $tab[] = $jour; } $jour++; } $reg->jours = implode($tab); $reg->save(); unset($tab); } else { if ($cantine['jour_debut'] != null) { // MODIF 5 $rentree = Feries::jour_rentree(date('Y', strtotime($cantine['jour_debut'])), $tabVacances); $debut_rentree = date('Y-m-d', strtotime($rentree)); $debut_inscrit = date('Y-m-d', strtotime($cantine['jour_debut'])); } //dd($rentree); if ($enfant == null) { dd($cantine); } $reg_matin = Reguliere::where('enfant_id', $enfant->id)->where('type', 'bus_matin')->first(); $reg_soir = Reguliere::where('enfant_id', $enfant->id)->where('type', 'bus_soir')->first(); $jour = 1; $finSemaine = 5; $tab_matin[] = ""; $tab_soir[] = ""; $enfant->responsable_bus = ""; while ($jour <= $finSemaine) { if ($jour == 1) { $enfant->responsable_bus .= $cantine['responsable' . $jour]; } else { $enfant->responsable_bus .= '/' . $cantine['responsable' . $jour]; } $day = Feries::Jours($jour); //dd($cantine); if ($cantine['jour_debut'] != null) { // MODIF 6 if ($rentree != $debut_rentree) { while ($debut_rentree < $debut_inscrit) { if (date('N', strtotime($debut_rentree)) == $jour) { if ($cantine[$day . '_matin'] != null) { $excep_matin = new Exceptionnelle(); $excep_soir = new Exceptionnelle(); $excep_matin->modificate_by = 0; $excep_soir->modificate_by = 0; $excep_matin->type = 'bus_matin'; $excep_soir->type = 'bus_soir'; $excep_matin->jour = date('Y-m-d', strtotime($debut_rentree)); $excep_soir->jour = date('Y-m-d', strtotime($debut_rentree)); $excep_matin->inscrit = 0; $excep_soir->inscrit = 0; $excep_matin->enfant_id = $enfant->id; $excep_soir->enfant_id = $enfant->id; $excep_matin->save(); $excep_soir->save(); } } $debut_rentree = date('Y-m-d', strtotime('+1 days', strtotime($debut_rentree))); } $debut_rentree = date('Y-m-d', strtotime($rentree)); } } if ($cantine[$day . '_matin'] != null) { $tab_matin[] = $jour; } if ($cantine[$day . '_soir'] != null) { $tab_soir[] = $jour; } $jour++; } $reg_matin->jours = implode($tab_matin); $reg_matin->save(); $reg_soir->jours = implode($tab_soir); $reg_soir->save(); unset($tab_matin); unset($tab_soir); } } } else { break; } } $ligne_vide = 0; } }); $test = Excel::create('Liste_Parents_Codes', function ($excel) use($data) { $excel->sheet('Codes', function ($sheet) use($data) { $sheet->fromArray($data); }); })->export('xls'); }
public function journalier($type) { $jour = Input::get('jour'); if ($jour == null) { $jour = date("Y-m-d"); } $inscrits = []; if ($type == 'garderie') { $inscrits = Enfant::where('garderie', true)->get(); $tab = Feries::chargement(); if (!empty($inscrits)) { if (Feries::est_vacances(date('Y-m-d', strtotime($jour)), $tab)) { // Fred : pourquoi est_vacances et pas est_ferié aussi? $message = "Pas d'inscription pendant les vacances."; return view('affichage.autres', compact('inscrits', 'message', 'jour', 'type')); } else { return view('affichage.autres', compact('inscrits', 'jour', 'type')); } } else { $message = "Pas d'inscription en cours."; return view('affichage.autres', compact('inscrits', 'message', 'jour', 'type')); } } elseif ($type == 'cantine') { // Fred : code pas garanti : copier/coller aproximatifs $regs = Reguliere::with(['Enfant', 'Enfant.Classe'])->where('jours', 'LIKE', '%' . date('w', strtotime($jour)) . '%')->where('type', $type)->get(); $exeps = Exceptionnelle::with(['Enfant', 'Enfant.Classe'])->where('jour', date('Y-m-d', strtotime($jour)))->where('type', $type)->get(); foreach ($regs as $reg) { $inscrits[$reg->enfant_id] = $reg; } foreach ($exeps as $exep) { if ($exep->inscrit === '1') { $inscrits[$exep->enfant_id] = $exep; } else { unset($inscrits[$exep->enfant_id]); } } $tab = Feries::chargement(); if (!empty($inscrits)) { if (Feries::est_vacances(date('Y-m-d', strtotime($jour)), $tab)) { // Fred : pourquoi est_vacances et pas est_ferié aussi? $message = "Pas d'inscription pendant les vacances."; return view('affichage.autres', compact('inscrits', 'message', 'jour', 'type')); } else { return view('affichage.autres', compact('inscrits', 'jour', 'type')); } } else { $message = "Pas d'inscription en cours."; return view('affichage.autres', compact('inscrits', 'message', 'jour', 'type')); } } else { $regs = Reguliere::with('enfant', 'enfant.classe', 'enfant.arret')->where('jours', 'LIKE', '%' . date('w', strtotime($jour)) . '%')->where('type', $type)->get(); $exeps = Exceptionnelle::with('enfant', 'enfant.classe', 'enfant.arret')->where('jour', date('Y-m-d', strtotime($jour)))->where('type', $type)->get(); foreach ($regs as $reg) { $inscrits[$reg->enfant_id] = $reg; } foreach ($exeps as $exep) { // if($exep->inscrit === 1){ // Fred : 16/11/15 ne passe pas le test si === 1 if ($exep->inscrit === '1') { $inscrits[$exep->enfant_id] = $exep; } else { unset($inscrits[$exep->enfant_id]); } } $tab = Feries::chargement(); if (!empty($inscrits)) { if (Feries::est_vacances(date('Y-m-d', strtotime($jour)), $tab)) { // Fred : pourquoi est_vacances et pas est_ferié aussi? $message = "Pas d'inscription pendant les vacances."; return view('affichage.autres', compact('inscrits', 'message', 'jour', 'type')); } else { // ajout Fred 16/11/15 $arrets = Arret::get(); return view('affichage.autres', compact('inscrits', 'jour', 'type', 'arrets')); } } else { $message = "Pas d'inscription en cours."; return view('affichage.autres', compact('inscrits', 'message', 'jour', 'type')); } } }