コード例 #1
0
 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']);
 }
コード例 #2
0
ファイル: Feries.php プロジェクト: InfoTeamUPS/projetTarabel
 public static function deux_mois($debut)
 {
     $nb_mois = 0;
     $date_en_cours = $debut;
     $mois_en_cours = Feries::Mois(date('n', strtotime($date_en_cours)));
     if ($mois_en_cours == 'Aout') {
         $mois_en_cours = 'Septembre';
     }
     while ($nb_mois < 2) {
         $mois_stock = Feries::Mois(date('n', strtotime('+7days', strtotime($date_en_cours))));
         if ($mois_stock != $mois_en_cours) {
             $nb_mois++;
             $mois_en_cours = $mois_stock;
         }
         $date_en_cours = date('Y-m-d', strtotime('+7days', strtotime($date_en_cours)));
     }
     $chiffre_jour = date('N', strtotime($date_en_cours));
     $diff = -$chiffre_jour + 1;
     $date_deux_mois = date('Y-m-d', strtotime($diff . 'days', strtotime($date_en_cours)));
     return $date_deux_mois;
 }
コード例 #3
0
 public function facturation(Request $request)
 {
     $data = $request->all();
     $mois = date('Y-m-d', strtotime($data['mois']));
     $fin = date('Y-m-d', strtotime('+2 month', strtotime($mois)));
     $facturations = Facturation::with('enfant', 'enfant.classe')->whereBetween('semaine', [$mois, $fin])->orderBy('enfant_id')->get();
     //dd($facturations, $mois, $fin);
     Excel::load('fichiers/facturation.xlsx', function ($file) use($mois, $fin, $facturations, $data) {
         $file->setFileName('facturation_' . Feries::Mois(date('n', strtotime('+10day' . $mois))) . '_' . Feries::Mois(date('n', strtotime('+1month' . $mois))));
         $file->setActiveSheetIndex(0)->setCellValue('E3', date('d/m/Y', strtotime($mois)));
         $file->setActiveSheetIndex(0)->setCellValue('E4', date('d/m/Y', strtotime($fin)));
         $file->setActiveSheetIndex(0)->setCellValue('E6', $data['prix_elementaire']);
         $file->setActiveSheetIndex(0)->setCellValue('D6', $data['prix_maternelle']);
         $ligne = 10;
         $id = 0;
         $total = 0;
         $colonne = 'G';
         foreach ($facturations as $facturation) {
             if ($id != $facturation->enfant_id) {
                 if ($total != 0) {
                     $file->setActiveSheetIndex(0)->setCellValue('E' . $ligne, $total);
                     if ($last->enfant->classe->cycle == 'Maternelle') {
                         $file->setActiveSheetIndex(0)->setCellValue('F' . $ligne, $total * $data['prix_maternelle']);
                         //dd($facturation, $total, 'F'.$ligne,  $data['prix_maternelle']);
                     } else {
                         $file->setActiveSheetIndex(0)->setCellValue('F' . $ligne, $total * $data['prix_elementaire']);
                     }
                     $total = 0;
                 }
                 $ligne++;
                 //$maDate = $mois;
                 $colonne = 'G';
                 $file->setActiveSheetIndex(0)->setCellValue('A' . $ligne, $facturation->enfant->classe->niveau);
                 $file->setActiveSheetIndex(0)->setCellValue('B' . $ligne, $facturation->enfant->classe->instituteur);
                 $file->setActiveSheetIndex(0)->setCellValue('C' . $ligne, $facturation->enfant->nom);
                 $file->setActiveSheetIndex(0)->setCellValue('D' . $ligne, $facturation->enfant->prenom);
                 $id = $facturation->enfant_id;
                 //ici prix
             }
             $maDate = $mois;
             while ($maDate < $facturation->semaine) {
                 $maDate = date('Y-m-d', strtotime('+7day' . $maDate));
                 $colonne = chr(ord($colonne) + 3);
             }
             $total += $facturation->fixe + $facturation->non_fixe;
             $file->setActiveSheetIndex(0)->setCellValue($colonne . $ligne, $facturation->fixe + $facturation->non_fixe);
             $file->setActiveSheetIndex(0)->setCellValue(chr(ord($colonne) + 1) . $ligne, 0);
             $file->setActiveSheetIndex(0)->setCellValue(chr(ord($colonne) + 2) . $ligne, $facturation->abscence_signalee);
             $colonne = 'G';
             $last = $facturation;
         }
         $file->setActiveSheetIndex(0)->setCellValue('E' . $ligne, $total);
         if (isset($last)) {
             if ($last->enfant->classe->cycle == 'maternelle') {
                 $file->setActiveSheetIndex(0)->setCellValue('F' . $ligne, $total * $data['prix_maternelle']);
             } else {
                 $file->setActiveSheetIndex(0)->setCellValue('F' . $ligne, $total * $data['prix_elementaire']);
             }
         }
     })->export('xls');
 }
コード例 #4
0
	<div class="jumbotron">
		{!! Form::open(['url' => url('facturation'), 'class' => 'form-horizontal']) !!}
		<fieldset>
		<legend>Facturation</legend>
		<div class="form-group {!! $errors->has('mois') ? 'has-error' : '' !!} " >
			<label for="mois" class="col-lg-2 control-label">Mois de facturation</label>
			<div class="col-lg-5">
				<select name="mois" id="mois" class="form-control">
					<?php 
use App\Library\Feries;
foreach ($mois as $month) {
    $debutMois = Feries::Mois(date('n', strtotime($month["debut"])));
    if ($debutMois == 'Aout') {
        $debutMois = 'Septembre';
    }
    $finMois = Feries::Mois(date('n', strtotime('+1month', strtotime($month["debut"]))));
    echo '<option value="' . $month['debut'] . '">Mois : ' . $debutMois . ' - ' . $finMois . '</option>';
}
?>
				</select>
			</div>
		</div>
		<div class="form-group {!! $errors->has('prix_elementaire') ? 'has-error' : '' !!} " >
			<label for="prix_elementaire" class="col-lg-2 control-label">Prix d'un repas élémentaire</label>
			<div class="col-lg-5">
				{!! Form::text('prix_elementaire', null,['class' => 'form-control', 'placeholder' => 'ex : 2.34', 'id' => 'prix_elementaire']) !!}
				{!! $errors->first('prix_elementaire', '<small class="help-block"> :message </small>') !!}
			</div>
		</div>
		<div class="form-group {!! $errors->has('prix_maternelle') ? 'has-error' : '' !!} " >
			<label for="prix_maternelle" class="col-lg-2 control-label">Prix d'un repas maternelle</label>
コード例 #5
0
 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');
 }
コード例 #6
0
 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'));
         }
     }
 }