/**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('classes', function (Blueprint $table) {
         $table->increments('id');
         $table->string('niveau');
         $table->string('instituteur');
         $table->string('cycle');
         $table->timestamps();
     });
     $classe = new Classe();
     $classe->niveau = 'instituteur';
     $classe->instituteur = '';
     $classe->cycle = 'adulte';
     $classe->save();
     $classe = new Classe();
     $classe->niveau = 'personnel';
     $classe->instituteur = '';
     $classe->cycle = 'adulte';
     $classe->save();
 }
示例#2
0
 public function classesOutstanding()
 {
     $subtitle = "Showing Classes with Outstanding Payments";
     $classes = Classe::orderBy('created_at', 'desc')->get();
     foreach ($classes as $key => $class) {
         if ($class->paymentStatus() == 'Payments Complete') {
             $classes->forget($key);
         }
     }
     return view('classes.admin', compact('classes', 'subtitle'));
 }
示例#3
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $classes_available = Classe::Upcoming()->where('date', '<', Carbon::now()->next(Carbon::MONDAY))->count();
     return view('welcome', compact('classes_available'));
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $arrets = Arret::lists('nom', 'id');
     $enfant = Enfant::findOrFail($id);
     $classes = Classe::lists('niveau', 'id');
     $instituteur = Classe::lists('instituteur', 'id');
     return view('enfants.form', compact('enfant', 'classes', 'instituteur', 'arrets'));
 }
			<div class="col-lg-5">
				{!! Form::text('prenom', null,['class' => 'form-control', 'placeholder' => 'Prenom', 'id' => 'prenom']) !!}
				{!! $errors->first('prenom', '<small class="help-block"> :message </small>') !!}
			</div>
		</div>
		<div class="form-group {!! $errors->has('naissance') ? 'has-error' : '' !!} " >
			<label for="naissance" class="col-lg-2 control-label">Date de naissance</label>
			<div class="col-lg-5">
				<div class="col-lg-3">{!! Form::selectRange('jour', 1, 31, null, ['class' => 'form-control', 'id' => 'jour' ]) !!}</div>
				<div class="col-lg-3">{!! Form::selectRange('mois', 1, 12, null, ['class' => 'form-control']) !!}</div>
				<div class="col-lg-5">{!! Form::selectYear('annee',1900,date('Y'), date('Y'), ['class' => 'form-control']) !!}</div>
			</div>
		</div>
		<?php 
use App\Classe;
$classes = Classe::lists('niveau', 'id');
?>
		<div class="form-group {!! $errors->has('classe_id') ? 'has-error' : '' !!} " >
			<label for="classe_id" class="col-lg-2 control-label">Classe</label>
			<div class="col-lg-5">
				{!! Form::select('classe_id', $classes, null, ['id' => 'classe_id', 'class' => 'form-control']) !!}
				{!! $errors->first('classe', '<small class="help-block"> :message </small>') !!}
			</div>
		</div>
		<div class="form-group {!! $errors->has('sexe') ? 'has-error' : '' !!} " >
			<label for="sexe" class="col-lg-2 control-label">Sexe</label>
			<div class="col-lg-5">
				<select class="form-control" id="sexe" name="sexe" >
					<option value="H" {{ $personne->sexe == 'H' ? 'selected' : '' }} >Garcon</option>
					<option value="F" {{ $personne->sexe == 'F' ? 'selected' : '' }} >Fille</option>
				</select>
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $classe = Classe::findOrFail($id);
     $classe->delete();
     return redirect(route('niveau.index'));
 }
 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');
 }
示例#8
0
 public function removeFromClassAdmin($classe_id, $user_id)
 {
     $user = User::findOrFail($user_id);
     $class = Classe::findOrFail($classe_id);
     $this->doRemoveFromClass($class, $user);
     $tags = ["first_name" => $user->first_name, "last_name" => $user->last_name, "class_title" => $class->title, "class_date" => $class->date, "class_end_date" => $class->end_date, "location" => $class->location->name];
     EmailHelper::sendEmail(EmailHelper::REMOVE_ATTENDEE, $tags, $user->email);
     return Redirect::back()->with("good", "Successfully removed from class.");
 }