Example #1
0
 public function getBranchWhenClassid()
 {
     if (\Request::ajax()) {
         $classe_id = \Input::get('classe_id');
         $classe = Classroom::where('id', $classe_id)->first();
         foreach ($classe->branches->unique() as $branch) {
             echo '<option value="' . $branch->id . '">' . $branch->nom_branche . '</option>';
         }
     }
 }
Example #2
0
                            <td>
                                <?php 
$classroom = \App\Classroom::where('id', $plan->classroom_id)->first();
foreach ($classroom->lesNiveaux as $niveau) {
    echo $niveau->niveau;
}
foreach ($classroom->levels as $niveau) {
    echo $niveau->niveau;
}
?>

                            </td>
                            <td>
                                <?php 
$classroom = \App\Classroom::where('id', $plan->classroom_id)->first();
if ($classroom->branches->isEmpty()) {
    echo '--';
} else {
    foreach ($classroom->branches as $br) {
        if ($br->nom_branche) {
            echo $br->nom_branche;
        } else {
            echo '--';
        }
    }
}
?>
                            </td>
                        </tr>
                        @endif
Example #3
0
 public function trierparsalle()
 {
     if (\Request::ajax()) {
         $room_id = \Input::get('room_id');
         $plans = Timesheet::where('user_id', \Auth::user()->id)->CurrentYear()->where('matter_id', '!=', 0)->get();
         foreach ($plans as $plan) {
             $salle = Timesheet::where("classroom_id", $plan->classroom_id)->where("time", $plan->time)->where("user_id", \Auth::user()->id)->where("color", "#525252")->where("dayname", $plan->dayname)->CurrentYear()->first();
             if ($salle && $salle->room_id == $room_id) {
                 echo '<tr>';
                 echo '    <td> ' . Classroom::where('id', $plan->classroom_id)->CurrentYear()->first()->nom_classe . '</td>';
                 echo '  <td>
                                 ' . Matter::where('id', $plan->matter_id)->first()->nom_matiere . '
                             </td>';
                 echo '   <td>';
                 foreach (Matter::where('id', $plan->matter_id)->first()->lesteachers->unique() as $item) {
                     echo $item->nom_teacher;
                 }
                 echo '</td>';
                 echo '<td>';
                 echo $plan->dayname;
                 echo '</td>';
                 echo '<td>';
                 echo substr(Carbon::parse($plan->time)->toTimeString(), 0, -3);
                 echo '</td>';
                 echo '<td>';
                 $salle = Timesheet::where("classroom_id", $plan->classroom_id)->where("time", $plan->time)->where("user_id", \Auth::user()->id)->where("color", "#525252")->CurrentYear()->where("dayname", $plan->dayname)->first();
                 if ($salle) {
                     echo \Auth::user()->rooms()->where('id', $salle->room_id)->first()->nom_salle;
                 }
                 echo '</td>';
                 echo '<td>';
                 $classroom = Classroom::where('id', $plan->classroom_id)->CurrentYear()->first();
                 foreach ($classroom->lesNiveaux as $niveau) {
                     echo $niveau->niveau;
                 }
                 foreach ($classroom->levels as $niveau) {
                     echo $niveau->niveau;
                 }
                 echo '</td>';
                 echo '<td>';
                 $classroom = Classroom::where('id', $plan->classroom_id)->CurrentYear()->first();
                 if ($classroom->branches->isEmpty()) {
                     echo '--';
                 } else {
                     foreach ($classroom->branches as $br) {
                         echo $br->nom_branche;
                     }
                 }
                 echo '</td>';
                 echo ' </tr>';
             }
         }
     }
 }
 public function gestion()
 {
     $matter_count = Matter::where('user_id', \Auth::user()->id)->count();
     $branch_count = \Auth::user()->branches()->where('school_year_id', \App\SchoolYear::getSchoolYearId())->count();
     $level_count = \Auth::user()->leslevels()->where('school_year_id', \App\SchoolYear::getSchoolYearId())->count();
     $cr_count = Classroom::where('user_id', \Auth::user()->id)->CurrentYear()->count();
     $room_count = Room::where('user_id', \Auth::user()->id)->count();
     return view('statistics.gestion', compact('matter_count', 'branch_count', 'level_count', 'cr_count', 'room_count'));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(FormValidationChildFamilyRequest $request)
 {
     $cr = Classroom::where('user_id', \Auth::user()->id)->where('id', $request->classe)->first();
     if ($cr->children()->where('school_year_id', $request->id_ann_scol)->count() > $cr->capacite_classe) {
         return redirect()->back()->withErrors("la classe est saturée");
     }
     // promotion Exceptional check
     if (PromotionExceptional::checkExceptionalPromotion()) {
         if (PromotionExceptional::checkExcTimeOfPromotionIfExpired()) {
             if (PromotionExceptional::checkExcPriceandReturnIt() == 'no') {
                 return redirect()->back()->withErrors("la promotion Exceptionnelle est active mais aucun prix n'est défini")->withInput();
             } else {
                 $prix_exc = PromotionExceptional::checkExcPriceandReturnIt();
             }
         } else {
             return redirect()->back()->withErrors("la promotion Exceptionnelle est active mais la durée est expirée");
         }
     }
     // promotion advanced check
     $prix_advance = '';
     if (PromotionAdvance::checkAdvancePromotion()) {
         if ($request->nbr_month > 1) {
             if (PromotionAdvance::checkAdvIfPriceIsSet($request->nbr_month) !== false) {
                 $prix_advance = PromotionAdvance::checkAdvIfPriceIsSet($request->nbr_month);
             } else {
                 return redirect()->back()->withErrors("Aucun prix n'est\n                    défini pour cette Promotion de " . $request->nbr_month . ' Mois');
             }
         }
     }
     $niveau_global = \Auth::user()->grades()->where('id', $request->grade)->first()->name;
     // famille for family profile
     $famille = Family::where('user_id', \Auth::user()->id)->where('email_responsable', $request->email_responsable)->first();
     if (!$famille) {
         $family = new Family();
         $family->nom_pere = ucfirst($request->nom_pere);
         $family->nom_mere = ucfirst($request->nom_mere);
         $family->email_responsable = $request->email_responsable;
         $family->adresse = $request->adresse;
         $family->numero_fixe = $request->numero_fixe;
         $family->numero_portable = $request->numero_portable;
         $family->cin = strtoupper($request->cin);
         $family->responsable = $request->responsable;
         $family->user_id = \Auth::user()->id;
         $family->school_year_id = $request->id_ann_scol;
         $family->save();
         if ($family->id) {
             $father = Family::findOrFail($family->id);
             $child = new Child();
             $child->date_naissance = Carbon::parse($request->date_naissance);
             $child->transport = $request->transport;
             $child->sexe = $request->sexe;
             $child->nom_enfant = ucfirst($request->nom_enfant);
             $child->age_enfant = $child->date_naissance->diffInYears(Carbon::now());
             $child->nationalite = \DB::table('countries')->where('id', $request->nationalite)->first()->nom_fr_fr;
             $child->user_id = \Auth::user()->id;
             $child->school_year_id = $request->id_ann_scol;
             $image = \Input::file('photo');
             if (!$image && empty($image)) {
                 $filename = '';
             } else {
                 $filename = $image->getClientOriginalName();
                 $path = public_path('uploads/' . $filename);
                 Image::make($image->getRealPath())->resize(313, 300)->save($path);
             }
             $child->photo = $filename;
             $child->family_id = $family->id;
             $child->save();
             if ($child->id) {
                 $ch = Child::find($child->id);
                 if ($niveau_global == 'Lycée') {
                     $ch->branches()->attach([$request->branche]);
                 }
                 if ($niveau_global == 'Maternelle' || $niveau_global == 'Primaire' || $niveau_global == 'Collège' || $niveau_global == 'Lycée' || $niveau_global == 'Crèche') {
                     $ch->levels()->attach([$request->niveau]);
                 }
                 /*if($niveau_global == 'Crèche')
                   {
                       $ch->classrooms()->attach([$request->classe]);
                   }*/
                 //classe
                 $cr = Classroom::where('user_id', \Auth::user()->id)->where('id', $request->classe)->first();
                 $cr->children()->attach([$child->id]);
                 $bill = new Bill();
                 $bill->status = 0;
                 // if no promotion is active
                 if (!PromotionAdvance::checkAdvancePromotion() && !PromotionExceptional::checkExceptionalPromotion()) {
                     if (isset($request->reduction) && !empty($request->reduction) && !is_null($request->reduction)) {
                         $bill->start = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->toDateString();
                         $bill->end = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->addMonths($request->nbr_month)->toDateString();
                         $bill->somme = PriceBill::countWhenNoPromotionButReduction($request->nbr_month, PriceBill::assignPrice($request->niveau, $request->transport), $request->reduction);
                         $bill->reductionPrix = $request->reduction;
                         $bill->reduction = 1;
                         $bill->school_year_id = SchoolYear::getSchoolYearId();
                         $bill->nbrMois = $request->nbr_month;
                     } else {
                         $bill->start = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->toDateString();
                         $bill->end = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->addMonths($request->nbr_month)->toDateString();
                         $bill->somme = PriceBill::countWhenNoPromotion($request->nbr_month, PriceBill::assignPrice($request->niveau, $request->transport));
                         $bill->reduction = 0;
                         $bill->school_year_id = $request->id_ann_scol;
                         $bill->nbrMois = $request->nbr_month;
                     }
                 }
                 if (PromotionAdvance::checkAdvancePromotion()) {
                     if ($request->nbr_month >= 3) {
                         $bill->start = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->toDateString();
                         $bill->end = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->addMonths($request->nbr_month)->toDateString();
                         $bill->somme = PromotionAdvance::countAccordingTo($prix_advance, PriceBill::assignPrice($request->niveau, $request->transport), $request->nbr_month);
                         $bill->reduction = 1;
                         $bill->reductionPrix = $prix_advance;
                         $bill->school_year_id = $request->id_ann_scol;
                         $bill->nbrMois = $request->nbr_month;
                     }
                     if ($request->nbr_month == 1) {
                         if (isset($request->reduction) && !empty($request->reduction) && !is_null($request->reduction)) {
                             $bill->start = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->toDateString();
                             $bill->end = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->addMonths($request->nbr_month)->toDateString();
                             $bill->somme = PriceBill::countWhenNoPromotionButReduction($request->nbr_month, PriceBill::assignPrice($request->niveau, $request->transport), $request->reduction);
                             $bill->reductionPrix = $request->reduction;
                             $bill->reduction = 1;
                             $bill->school_year_id = SchoolYear::getSchoolYearId();
                             $bill->nbrMois = $request->nbr_month;
                         } else {
                             $bill->start = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->toDateString();
                             $bill->end = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->addMonths($request->nbr_month)->toDateString();
                             $bill->somme = PriceBill::countWhenNoPromotion($request->nbr_month, PriceBill::assignPrice($request->niveau, $request->transport));
                             $bill->reduction = 0;
                             $bill->school_year_id = $request->id_ann_scol;
                             $bill->nbrMois = $request->nbr_month;
                         }
                     }
                 }
                 if (PromotionExceptional::checkExceptionalPromotion()) {
                     $bill->start = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->toDateString();
                     $bill->end = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->addMonths($request->nbr_month)->toDateString();
                     $bill->somme = PromotionExceptional::countAccordingTo($request->nbr_month, PriceBill::assignPrice($request->niveau, $request->transport), $prix_exc);
                     $bill->reductionPrix = $prix_exc;
                     $bill->reduction = 1;
                     $bill->school_year_id = $request->id_ann_scol;
                     $bill->nbrMois = $request->nbr_month;
                 }
                 $bill->child_id = $child->id;
                 $bill->user_id = \Auth::user()->id;
                 $bill->save();
                 $enfant = Child::findOrFail($child->id);
                 if ($father->responsable == 0) {
                     $resp = $father->nom_mere;
                 } else {
                     $resp = $father->nom_pere;
                 }
                 event(new SendEmailToRespAfterRegistrationEvent($child->id, $resp, $enfant->nom_enfant, $enfant->created_at->toDateString(), $enfant->created_at->addMonth()->toDateString(), $father->email_responsable, $father->responsable, str_random(6)));
             }
         }
         return redirect()->back()->with('success', "l'élève et les parents ont bien été ajoutés! ");
     } else {
         // if the parent already in the database
         $child = new Child();
         $child->date_naissance = Carbon::parse($request->date_naissance);
         $child->nom_enfant = $request->nom_enfant;
         $child->sexe = $request->sexe;
         $child->age_enfant = $child->date_naissance->diffInYears(Carbon::now());
         $child->nationalite = \DB::table('countries')->where('id', $request->nationalite)->first()->nom_fr_fr;
         $child->school_year_id = $request->id_ann_scol;
         $child->transport = $request->transport;
         $child->user_id = \Auth::user()->id;
         $image = \Input::file('photo');
         if (!$image && empty($image)) {
             $filename = '';
         } else {
             $filename = $image->getClientOriginalName();
             $path = public_path('uploads/' . $filename);
             Image::make($image->getRealPath())->resize(313, 300)->save($path);
         }
         $child->photo = $filename;
         $child->family_id = $famille->id;
         $resp = Family::findOrFail($famille->id);
         $user = User::where('email', $resp->email_responsable)->first();
         if ($user) {
             $child->f_id = $user->id;
             $child->save();
             if ($child->id) {
                 $ch = Child::find($child->id);
                 if ($niveau_global == 'Lycée') {
                     $ch->branches()->attach([$request->branche]);
                 }
                 if ($niveau_global == 'Maternelle' || $niveau_global == 'Primaire' || $niveau_global == 'Collège' || $niveau_global == 'Lycée' || $niveau_global == 'Crèche') {
                     $ch->levels()->attach([$request->niveau]);
                 }
                 if ($niveau_global == 'Crèche') {
                     $ch->classrooms()->attach([$request->classe]);
                 }
                 $cr = Classroom::where('user_id', \Auth::user()->id)->where('id', $request->classe)->first();
                 $cr->children()->attach([$child->id]);
                 $bill = new Bill();
                 $bill->status = 0;
                 if (!PromotionAdvance::checkAdvancePromotion() && !PromotionExceptional::checkExceptionalPromotion()) {
                     if (isset($request->reduction) && !empty($request->reduction) && !is_null($request->reduction)) {
                         $bill->start = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->toDateString();
                         $bill->end = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->addMonths($request->nbr_month)->toDateString();
                         $bill->somme = PriceBill::countWhenNoPromotionButReduction($request->nbr_month, PriceBill::assignPrice($request->niveau, $request->transport), $request->reduction);
                         $bill->reductionPrix = $request->reduction;
                         $bill->reduction = 1;
                         $bill->school_year_id = $request->id_ann_scol;
                         $bill->nbrMois = $request->nbr_month;
                     } else {
                         $bill->start = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->toDateString();
                         $bill->end = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->addMonths($request->nbr_month)->toDateString();
                         $bill->somme = PriceBill::countWhenNoPromotion($request->nbr_month, PriceBill::assignPrice($request->niveau, $request->transport));
                         $bill->reduction = 0;
                         $bill->school_year_id = $request->id_ann_scol;
                         $bill->nbrMois = $request->nbr_month;
                     }
                 }
                 if (PromotionAdvance::checkAdvancePromotion()) {
                     if ($request->nbr_month >= 3) {
                         $bill->start = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->toDateString();
                         $bill->end = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->addMonths($request->nbr_month)->toDateString();
                         $bill->somme = PromotionAdvance::countAccordingTo($prix_advance, PriceBill::assignPrice($request->niveau, $request->transport), $request->nbr_month);
                         $bill->reduction = 1;
                         $bill->reductionPrix = $prix_advance;
                         $bill->school_year_id = $request->id_ann_scol;
                         $bill->nbrMois = $request->nbr_month;
                     }
                     if ($request->nbr_month == 1) {
                         if (isset($request->reduction) && !empty($request->reduction) && !is_null($request->reduction)) {
                             $bill->start = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->toDateString();
                             $bill->end = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->addMonths($request->nbr_month)->toDateString();
                             $bill->somme = PriceBill::countWhenNoPromotionButReduction($request->nbr_month, PriceBill::assignPrice($request->niveau, $request->transport), $request->reduction);
                             $bill->reductionPrix = $request->reduction;
                             $bill->reduction = 1;
                             $bill->school_year_id = $request->id_ann_scol;
                             $bill->nbrMois = $request->nbr_month;
                         } else {
                             $bill->start = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->toDateString();
                             $bill->end = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->addMonths($request->nbr_month)->toDateString();
                             $bill->somme = PriceBill::countWhenNoPromotion($request->nbr_month, PriceBill::assignPrice($request->niveau, $request->transport));
                             $bill->reduction = 0;
                             $bill->school_year_id = $request->id_ann_scol;
                             $bill->nbrMois = $request->nbr_month;
                         }
                     }
                 }
                 if (PromotionExceptional::checkExceptionalPromotion()) {
                     $bill->start = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->toDateString();
                     $bill->end = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->addMonths($request->nbr_month)->toDateString();
                     $bill->somme = PromotionExceptional::countAccordingTo($request->nbr_month, PriceBill::assignPrice($request->niveau, $request->transport), $prix_exc);
                     $bill->reductionPrix = $prix_exc;
                     $bill->reduction = 1;
                     $bill->school_year_id = $request->id_ann_scol;
                     $bill->nbrMois = $request->nbr_month;
                 }
                 $bill->child_id = $child->id;
                 $bill->f_id = $user->id;
                 $bill->user_id = \Auth::user()->id;
                 $bill->save();
             }
         }
         return redirect()->back()->with('success', "l'élève a bien été ajouté! ");
     }
 }
    public function trierparbranche()
    {
        if (\Request::ajax()) {
            $br = \Input::get('branche');
            $branches = Classroom::where('user_id', \Auth::user()->id)->where('branche', $br)->get();
            foreach ($branches as $ts) {
                echo '   <tr>
                            <td><div class="minimal single-row">
                                    <div class="checkbox_liste ">
                                        <input type="checkbox"  value="' . $ts->id . '" name="select[]">

                                    </div>
                                </div></td>
                            <td>' . $ts->nom_classe . '</td>
                            <td>' . $ts->branche . '</td>
                            <td>
                                <a href="' . action('TimesheetsController@delete', [$ts]) . '" class="actions_icons delete-ts">
                                    <i class="fa fa-trash-o liste_icons"></i></a>
                                <a href="#"><i class="fa fa-archive liste_icons"></i>
                                </a>
                            </td>
                            <td><a href="' . action('TimesheetsController@edit', [$ts]) . '">
                                    <div  class="btn_details">Détails</div></a></td>

                        </tr>';
            }
        }
    }
Example #7
0
 public function addchild(Request $request, $id = null)
 {
     if (\Request::isMethod('get')) {
         $family = Family::where('user_id', \Auth::user()->id)->where('id', $id)->first();
         return view('families.addchild', compact('family'));
     } elseif (\Request::isMethod('post')) {
         // promotion Exceptional check
         if (PromotionExceptional::checkExceptionalPromotion()) {
             if (PromotionExceptional::checkExcTimeOfPromotionIfExpired()) {
                 if (PromotionExceptional::checkExcPriceandReturnIt() == 'no') {
                     return redirect()->back()->withErrors("la promotion Exceptionnelle est active mais aucun prix n'est défini")->withInput();
                 } else {
                     $prix_exc = PromotionExceptional::checkExcPriceandReturnIt();
                 }
             } else {
                 return redirect()->back()->withErrors("la promotion Exceptionnelle est active mais la durée est expirée");
             }
         }
         // promotion advanced check
         $prix_advance = '';
         if (PromotionAdvance::checkAdvancePromotion()) {
             if ($request->nbr_month > 1) {
                 if (PromotionAdvance::checkAdvIfPriceIsSet($request->nbr_month) !== false) {
                     $prix_advance = PromotionAdvance::checkAdvIfPriceIsSet($request->nbr_month);
                 } else {
                     return redirect()->back()->withErrors("Aucun prix n'est\n                    défini pour cette Promotion de " . $request->nbr_month . ' Mois');
                 }
             }
         }
         $validator = Validator::make([$request->all(), 'nom_enfant' => $request->nom_enfant, 'date_naissance' => $request->date_naissance, 'photo' => $request->photo, 'classe' => $request->classe, 'branche' => $request->branche, 'niveau' => $request->niveau], ['nom_enfant' => 'required', 'date_naissance' => 'required', 'photo' => 'image', 'niveau' => 'integer', 'classe' => 'integer', 'grade' => 'integer'], ['photo.image' => "L'image doit etre de type valide JPEG\\PNG", 'nom_enfant.required' => 'Le Nom de L\'enfant est obligatoire', 'date_naissance.required' => 'La Date de Naissance est Obligatoire', 'classe.integer' => "vous devez choisir une classe", 'niveau.integer' => "vous devez choisir un niveau", 'grade.integer' => "Vous devez chosir un niveau global"]);
         // if the parent already in the database
         if ($validator->passes()) {
             $niveau_global = \Auth::user()->grades()->where('id', $request->grade)->first()->name;
             $child = new Child();
             $child->date_naissance = Carbon::parse($request->date_naissance);
             $child->nom_enfant = $request->nom_enfant;
             $child->sexe = $request->sexe;
             $child->age_enfant = $child->date_naissance->diffInYears(Carbon::now());
             $child->nationalite = \DB::table('countries')->where('id', $request->nationalite)->first()->nom_fr_fr;
             $child->school_year_id = SchoolYear::getSchoolYearId();
             $child->transport = $request->transport;
             $child->user_id = \Auth::user()->id;
             $image = \Input::file('photo');
             if (!$image && empty($image)) {
                 $filename = '';
             } else {
                 $filename = $image->getClientOriginalName();
                 $path = public_path('uploads/' . $filename);
                 Image::make($image->getRealPath())->resize(313, 300)->save($path);
             }
             $child->photo = $filename;
             $child->family_id = $request->familyid;
             $resp = Family::findOrFail($request->familyid);
             $user = User::where('email', $resp->email_responsable)->first();
             if ($user) {
                 $child->f_id = $user->id;
                 $child->save();
                 if ($child->id) {
                     $ch = Child::find($child->id);
                     if ($niveau_global == 'Lycée') {
                         $ch->branches()->attach([$request->branche]);
                     }
                     if ($niveau_global == 'Maternelle' || $niveau_global == 'Primaire' || $niveau_global == 'Collège' || $niveau_global == 'Lycée' || $niveau_global == 'Crèche') {
                         $ch->levels()->attach([$request->niveau]);
                     }
                     /*  if($niveau_global == 'Crèche')
                         {
                             $ch->classrooms()->attach([$request->classe]);
                         }*/
                     $cr = Classroom::where('user_id', \Auth::user()->id)->where('id', $request->classe)->first();
                     $cr->children()->attach([$child->id]);
                     $bill = new Bill();
                     $bill->status = 0;
                     if (!PromotionAdvance::checkAdvancePromotion() && !PromotionExceptional::checkExceptionalPromotion()) {
                         if (isset($request->reduction) && !empty($request->reduction) && !is_null($request->reduction)) {
                             $bill->start = SchoolYear::find(SchoolYear::getSchoolYearId())->startch1->firstOfMonth()->toDateString();
                             $bill->end = SchoolYear::find(SchoolYear::getSchoolYearId())->startch1->firstOfMonth()->addMonths($request->nbr_month)->toDateString();
                             $bill->somme = PriceBill::countWhenNoPromotionButReduction($request->nbr_month, PriceBill::assignPrice($request->niveau, $request->transport), $request->reduction);
                             $bill->reductionPrix = $request->reduction;
                             $bill->reduction = 1;
                             $bill->school_year_id = \Auth::user()->schoolyears()->where('current', 1)->first()->id;
                             $bill->nbrMois = $request->nbr_month;
                         } else {
                             $bill->start = SchoolYear::find(SchoolYear::getSchoolYearId())->startch1->firstOfMonth()->toDateString();
                             $bill->end = SchoolYear::find(SchoolYear::getSchoolYearId())->startch1->firstOfMonth()->addMonths($request->nbr_month)->toDateString();
                             $bill->somme = PriceBill::countWhenNoPromotion($request->nbr_month, PriceBill::assignPrice($request->niveau, $request->transport));
                             $bill->reduction = 0;
                             $bill->school_year_id = \Auth::user()->schoolyears()->where('current', 1)->first()->id;
                             $bill->nbrMois = $request->nbr_month;
                         }
                     }
                     if (PromotionAdvance::checkAdvancePromotion()) {
                         if ($request->nbr_month >= 3) {
                             $bill->start = SchoolYear::find(SchoolYear::getSchoolYearId())->startch1->firstOfMonth()->toDateString();
                             $bill->end = SchoolYear::find(SchoolYear::getSchoolYearId())->startch1->firstOfMonth()->addMonths($request->nbr_month)->toDateString();
                             $bill->somme = PromotionAdvance::countAccordingTo($prix_advance, PriceBill::assignPrice($request->niveau, $request->transport), $request->nbr_month);
                             $bill->reduction = 1;
                             $bill->reductionPrix = $prix_advance;
                             $bill->school_year_id = \Auth::user()->schoolyears()->where('current', 1)->first()->id;
                             $bill->nbrMois = $request->nbr_month;
                         }
                         if ($request->nbr_month == 1) {
                             if (isset($request->reduction) && !empty($request->reduction) && !is_null($request->reduction)) {
                                 $bill->start = SchoolYear::find(SchoolYear::getSchoolYearId())->startch1->firstOfMonth()->toDateString();
                                 $bill->end = SchoolYear::find(SchoolYear::getSchoolYearId())->startch1->firstOfMonth()->addMonths($request->nbr_month)->toDateString();
                                 $bill->somme = PriceBill::countWhenNoPromotionButReduction($request->nbr_month, PriceBill::assignPrice($request->niveau, $request->transport), $request->reduction);
                                 $bill->reductionPrix = $request->reduction;
                                 $bill->reduction = 1;
                                 $bill->school_year_id = \Auth::user()->schoolyears()->where('current', 1)->first()->id;
                                 $bill->nbrMois = $request->nbr_month;
                             } else {
                                 $bill->start = SchoolYear::find(SchoolYear::getSchoolYearId())->startch1->firstOfMonth()->toDateString();
                                 $bill->end = SchoolYear::find(SchoolYear::getSchoolYearId())->startch1->firstOfMonth()->addMonths($request->nbr_month)->toDateString();
                                 $bill->somme = PriceBill::countWhenNoPromotion($request->nbr_month, PriceBill::assignPrice($request->niveau, $request->transport));
                                 $bill->reduction = 0;
                                 $bill->school_year_id = \Auth::user()->schoolyears()->where('current', 1)->first()->id;
                                 $bill->nbrMois = $request->nbr_month;
                             }
                         }
                     }
                     if (PromotionExceptional::checkExceptionalPromotion()) {
                         $bill->start = SchoolYear::find(SchoolYear::getSchoolYearId())->startch1->firstOfMonth()->toDateString();
                         $bill->end = SchoolYear::find(SchoolYear::getSchoolYearId())->startch1->firstOfMonth()->addMonths($request->nbr_month)->toDateString();
                         $bill->somme = PromotionExceptional::countAccordingTo($request->nbr_month, PriceBill::assignPrice($request->niveau, $request->transport), $prix_exc);
                         $bill->reductionPrix = $prix_exc;
                         $bill->reduction = 1;
                         $bill->school_year_id = \Auth::user()->schoolyears()->where('current', 1)->first()->id;
                         $bill->nbrMois = $request->nbr_month;
                     }
                     $bill->child_id = $child->id;
                     $bill->f_id = $user->id;
                     $bill->user_id = \Auth::user()->id;
                     $bill->save();
                 }
             }
             return redirect()->back()->with('success', "l'élève a bien été ajouté! ");
         } else {
             return redirect()->back()->withErrors($validator);
         }
     }
 }
 public function addMatterandProfToCr($id)
 {
     if (\Request::isMethod('get')) {
         $cr = Classroom::where('user_id', \Auth::user()->id)->where('id', $id)->first();
         return view('classrooms.addMatterandProfToCr', compact('cr'));
     }
 }
Example #9
0
    public function getmatieres()
    {
        if (\Request::ajax()) {
            $value = \Input::get('value');
            $cr = Classroom::where('user_id', \Auth::user()->id)->where('id', $value)->first();
            foreach ($cr->matters as $m) {
                echo '   <div class="form_champ">
                    <label for="cname" class="control-label col-lg-3">' . $m->nom_matiere . '</label>
                    <input type="hidden" value="' . $m->id . '" name="matiere[]">
                    <div class="form_ajout">
                        <select  name="teacher[]" class="form_ajout_input prof">
                        ';
                foreach ($m->teachers as $t) {
                    echo '<option value="' . $t->id . ',' . $m->id . '">' . $t->nom_teacher . '</option>';
                }
                echo '</select>

                    </div>
                </div>';
            }
        }
    }