Exemplo n.º 1
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create(CreateChild $request)
 {
     $username = $request->username;
     $password = Hash::make($request->password);
     $user_group = Auth::user()->user_group;
     $child = new Child();
     $child->username = $username;
     $child->password = $password;
     $child->user_group = $user_group;
     $child->save();
     return Redirect::back()->with('createChildMessage', 'success');
 }
 /**
  * Create a new event instance.
  *
  * @param $c_id
  * @param $nom_responsable
  * @param $nom_enfant
  * @param $date_inscription
  * @param $date_prochain_paiement
  * @param $pseudo_compte_famille
  * @param $responsable
  * @param $mot_de_pass_temporaire_compte_famille
  */
 public function __construct($c_id, $nom_responsable, $nom_enfant, $date_inscription, $date_prochain_paiement, $pseudo_compte_famille, $responsable, $mot_de_pass_temporaire_compte_famille)
 {
     $this->child_id = $c_id;
     $this->nom_responsable = $nom_responsable;
     $this->nom_enfant = $nom_enfant;
     $this->date_inscription = $date_inscription;
     $this->date_prochain_paiement = $date_prochain_paiement;
     $this->pseudo_compte_famille = $pseudo_compte_famille;
     $this->responsable = $responsable;
     $this->mot_de_pass_temporaire_compte_famille = $mot_de_pass_temporaire_compte_famille;
     $user = new User();
     $user->nom_responsable = $this->nom_responsable;
     $user->name = $this->nom_responsable;
     $user->type = 'famille';
     $user->email = $this->pseudo_compte_famille;
     $user->password = \Hash::make($this->mot_de_pass_temporaire_compte_famille);
     if ($this->responsable == 1) {
         $user->sexe = 'homme';
     } else {
         $user->sexe = 'femme';
     }
     $user->save();
     if ($user) {
         $child = Child::findOrFail($this->child_id);
         $child->f_id = $user->id;
         $child->save();
         $bill = Bill::where('child_id', $this->child_id)->first();
         $bill->f_id = $user->id;
         $bill->save();
         $info = ['responsable' => $this->nom_responsable, 'nom_enfant' => $this->nom_enfant, 'date_inscription' => $this->date_inscription, 'date_pro_paim' => $this->date_prochain_paiement, 'pseudo_email' => $this->pseudo_compte_famille, 'respons' => $this->responsable, 'pass' => $this->mot_de_pass_temporaire_compte_famille];
         Mail::queue('emails.test', $info, function ($message) {
             $message->to($this->pseudo_compte_famille, 'ok')->from('*****@*****.**')->subject('Bienvenue  !');
         });
     }
 }
Exemplo n.º 3
0
 public function run()
 {
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 60; $i++) {
         Child::create(['first_name' => $faker->firstNameMale, 'last_name' => $faker->lastName, 'room_id' => mt_rand(1, 5), 'daycare_id' => 1]);
     }
 }
Exemplo n.º 4
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $child = Child::findOrFail($id);
     if (Auth::user()->daycare->id !== $child->daycare_id) {
         //            return message()->error(Config::get('messages.general.processing_error'));
     }
     Child::destroy($id);
     //        return message()->success(Config::get('messages.child.delete_success'));
 }
Exemplo n.º 5
0
 public function index()
 {
     if (Auth::check()) {
         $children = Child::where('user_group', '=', Auth::user()->user_group)->get();
     }
     $users = User::all();
     $transactions = Transactions::all()->sortByDesc('created_at')->take(20);
     return view('home', compact('users', 'transactions', 'children'));
 }
Exemplo n.º 6
0
 /**
  * Return attendance of child for the last week
  *
  * @return mixed
  */
 private function lastWeek()
 {
     $checkins = $this->child->checkins()->where(function ($query) {
         $query->where('check_in', '>=', $this->startOfWeek)->whereAnd('check_in', '<=', $this->endOfWeek);
     })->get();
     $days = [];
     foreach ($checkins as $checkin) {
         $index = Carbon::createFromFormat('Y-m-d H:i:s', $checkin['check_in'])->toDateString();
         $check_in = Carbon::createFromFormat('Y-m-d H:i:s', $checkin['check_in']);
         if (is_null($checkin['check_out'])) {
             $date = Carbon::now(Auth::user()->daycare->timezone)->toDateTimeString();
             $check_out = Carbon::createFromFormat('Y-m-d H:i:s', $date);
         } else {
             $check_out = Carbon::createFromFormat('Y-m-d H:i:s', $checkin['check_out']);
         }
         $time = $check_out->diffInMinutes($check_in);
         $days[$index][] = $time;
     }
     foreach ($this->weekArray as $week_day) {
         $dayName = Carbon::createFromFormat('Y-m-d', $week_day)->format('l');
         $attendance[$dayName] = isset($days[$week_day]) ? $this->convertToHours($days[$week_day]) : '0 minutes';
     }
     return $attendance;
 }
Exemplo n.º 7
0
 /**
  * Generate a random token when creating a user
  */
 public static function boot()
 {
     parent::boot();
     static::created(function ($checkins) {
         $child = Child::find($checkins->child_id);
         $child->checked_in = 1;
         $child->checkin_id = $checkins->id;
         $child->save();
     });
     static::updated(function ($checkins) {
         $child = Child::find($checkins->child_id);
         $child->checked_in = 0;
         $child->checkin_id = null;
         $child->save();
     });
 }
Exemplo n.º 8
0
 public function checkChild($id)
 {
     $child = Child::findOrFail($id);
     return $child;
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     return \App\Child::findOrFail($id);
 }
 public function bike_report()
 {
     $csv = Export::newCSV(["family id", "child name", "age", "bike style", "bike size"]);
     $children = Child::where('bike_want', 'Y')->join('household', 'household.id', '=', 'child.household_id')->where('approved', 1)->get();
     foreach ($children as $child) {
         $csv->insertOne([$child->household_id, $child->name_last . ", " . $child->name_first, $child->age, $child->bike_style, $child->bike_size]);
     }
     $csv->output('GiftProjectBikeReport_' . date("YmdHis") . '.csv');
     flush();
     exit(0);
 }
Exemplo n.º 11
0
                        <div class="bloc_info"><img src="{{ asset('images/factures.png') }}" >
                            <span class="count">
                                <?php 
echo App\Bill::where('status', 0)->where('user_id', \Auth::user()->id)->CurrentYear()->count();
?>
                            </span><p>Factures non réglées</p></div>
                    </a></div>
            </section>
        </div>
                    <div class="col-md-4">
                        <section class="panel bloc">
                            <div class="panel-body">
                                <a href="#">
                                    <div class="bloc_info"><img src="{{ asset('images/anniversary.png') }}" >
                                        <?php 
$annv = \App\Child::where('user_id', \Auth::user()->id)->whereRaw('EXTRACT(month from date_naissance) = ?', [\Carbon\Carbon::now()->month])->whereRaw('EXTRACT(day from date_naissance) = ?', [\Carbon\Carbon::now()->day])->count();
?>
                                        <span class="count">{{ $annv }}</span><p>Anniversaires</p></div>
                                </a></div>
                        </section>
                    </div>




                </div>

<script src="{{ asset('js\codrops\Notification-Styles-Inspiration\js\modernizr.custom.js') }}"></script>
<script src="{{ asset('js\codrops\Notification-Styles-Inspiration\js\classie.js') }}"></script>
<script src="{{ asset('js\codrops\Notification-Styles-Inspiration\js\notificationFx.js') }}"></script>
@endif
Exemplo n.º 12
0
 public function pointage()
 {
     if (\Request::ajax()) {
         $tab = \Input::all();
         $title = $tab['title'];
         $start = $tab['start'];
         $end = $tab['end'];
         $color = $tab['color'];
         $allDay = $tab['allDay'];
         $child_id = $tab['child_id'];
         $event = new Attendance();
         $event->title = $title;
         $event->start = $start;
         $event->end = $end;
         $event->color = $color;
         $event->allDay = $allDay;
         $event->child_id = $child_id;
         $event->user_id = \Auth::user()->id;
         $event->save();
         $child = Child::findOrFail($child_id);
     }
 }
Exemplo n.º 13
0
 public function indexef()
 {
     $children = Child::where('f_id', \Auth::user()->id)->get();
     return view('classrooms.indexef', compact('children'));
 }
Exemplo n.º 14
0
 /**
  * Child Forms
  * @param  int $id 
  * @return \]lluminate\Http\Response
  */
 public function completedForms($id)
 {
     $parent = Auth::user();
     $child = \App\Child::findOrFail($id);
     $guardians = $parent->guardians;
     return view('register.forms', compact('parent', 'child', 'guardians'));
 }
Exemplo n.º 15
0
 public function showef($id)
 {
     $data = '';
     foreach (Auth::user()->enfants as $enfant) {
         $data .= $enfant->id . ',';
     }
     $data = explode(',', substr($data, 0, -1));
     foreach ($data as $d) {
         if ($d == $id) {
             $child = Child::findOrFail($id);
             return view('bills.showef', compact('child'));
         }
     }
     return response('Unauthorized.', 401);
 }
Exemplo n.º 16
0
 public function exportPdf($ids = null)
 {
     $ids = explode(',', substr($ids, 0, -1));
     $ids = array_unique($ids);
     $model = Bill::whereIn('id', $ids)->where('user_id', \Auth::user()->id)->get(['id', 'child_id', 'start', 'somme', 'status']);
     Excel::create('La liste des Factures', function ($excel) use($model, $ids) {
         $excel->sheet('La liste des Factures', function ($sheet) use($model, $ids) {
             foreach ($model as $bill) {
                 $bill->date = $bill->start->toDateString();
                 if ($bill->status == 0) {
                     $bill->status = 'Non Réglée';
                 } else {
                     $bill->status = 'Réglée';
                 }
                 $bill->child_id = Child::where('id', $bill->child_id)->first()->nom_enfant;
                 unset($bill->start);
             }
             $sheet->setWidth('A', 15);
             $sheet->setWidth('B', 15);
             $sheet->setWidth('C', 15);
             $sheet->setWidth('D', 15);
             $sheet->setWidth('E', 15);
             $sheet->fromModel($model);
             $sheet->setAllBorders('thin');
             $sheet->setFontFamily('OpenSans');
             $sheet->setFontSize(13);
             $sheet->setFontBold(false);
             $sheet->setAllBorders('thin');
             for ($i = 1; $i <= count($ids) + 1; $i++) {
                 $sheet->row($i, function ($rows) {
                     $rows->setFontColor('#556b7b');
                     $rows->setAlignment('center');
                 });
             }
             $sheet->cells('A1:E1', function ($cells) {
                 $cells->setBackground('#e9f1f3');
                 $cells->setFontColor('#556b7b');
                 $cells->setFont(array('family' => 'OpenSans', 'size' => '15', 'bold' => true));
             });
             $sheet->row(1, array('Num De Facture', 'Nom de l\'élève', 'Somme', 'Statut', 'Date'));
         });
     })->export('pdf');
 }
Exemplo n.º 17
0
 public function __construct($id)
 {
     $this->child = Child::findorFail($id);
 }
Exemplo n.º 18
0
    public function getYearAndMonth()
    {
        if (\Request::ajax()) {
            $year = \Input::get('year');
            $month = \Input::get('month');
            $monthtext = \Input::get('monthtext');
            //Absences selon le tri ajax
            $count_absence = Attendance::whereRaw('EXTRACT(month from start) = ?', [$month])->whereRaw('EXTRACT(year from start) = ?', [$year])->where('user_id', \Auth::user()->id)->count();
            $count_abs_normale = Attendance::whereRaw('EXTRACT(month from start) = ?', [$month])->whereRaw('EXTRACT(year from start) = ?', [$year])->where('user_id', \Auth::user()->id)->where('title', 'Normal')->count();
            $count_abs_maladie = Attendance::whereRaw('EXTRACT(month from start) = ?', [$month])->whereRaw('EXTRACT(year from start) = ?', [$year])->where('title', 'Maladie')->where('user_id', \Auth::user()->id)->count();
            /* statistics new subscribers selon le tri ajax */
            $ns_number = Child::whereRaw('EXTRACT(month from created_at) = ?', [$month])->whereRaw('EXTRACT(year from created_at) = ?', [$year])->where('user_id', \Auth::user()->id)->count();
            $garcons = Child::whereRaw('EXTRACT(month from created_at) = ?', [$month])->whereRaw('EXTRACT(year from created_at) = ?', [$year])->where('user_id', \Auth::user()->id)->where('sexe', 'Garçon')->count();
            $filles = Child::whereRaw('EXTRACT(month from created_at) = ?', [$month])->whereRaw('EXTRACT(year from created_at) = ?', [$year])->where('user_id', \Auth::user()->id)->where('sexe', 'fille')->count();
            /* bills par le trix ajax  */
            $count_bills = Bill::whereRaw('EXTRACT(month from start) = ?', [$month])->whereRaw('EXTRACT(year from start) = ?', [$year])->where('user_id', \Auth::user()->id)->count();
            $regled_bills = Bill::whereRaw('EXTRACT(month from start) = ?', [$month])->whereRaw('EXTRACT(year from start) = ?', [$year])->where('user_id', \Auth::user()->id)->where('status', 1)->count();
            $non_regled_bills = Bill::whereRaw('EXTRACT(month from start) = ?', [$month])->whereRaw('EXTRACT(year from start) = ?', [$year])->where('user_id', \Auth::user()->id)->where('status', 0)->count();
            // for counting bills
            $somme = Bill::whereRaw('EXTRACT(year from start) = ?', [$year])->whereRaw('EXTRACT(month from start) = ?', [$month])->where('user_id', \Auth::user()->id)->sum('somme');
            $encaisse = Bill::whereRaw('EXTRACT(year from start) = ?', [$year])->whereRaw('EXTRACT(month from start) = ?', [$month])->where('user_id', \Auth::user()->id)->where('status', 1)->sum('somme');
            $reste = Bill::whereRaw('EXTRACT(year from start) = ?', [$year])->whereRaw('EXTRACT(month from start) = ?', [$month])->where('user_id', \Auth::user()->id)->where('status', 0)->sum('somme');
            echo ' <div class="row partie-up"> <div class="col-md-4">
            <section class="panel bloc">
                <div class="panel-body">
                    <a href="' . action('StatisticsController@monthly_absence', [$year, $month]) . '">
                        <div class="bloc_statistique"><img src="images/pointages.png" ><span class="count">
                        ' . $count_absence . '</span><p>Cas d\'absence Ce Mois</p></div>
                        <div class="bloc_statistique_details">
                            <div class="bloc_statistique_d1">
                                <span class="count">' . $count_abs_normale . '</span><p>Justifiées</p>
                            </div>
                            <div class="bloc_statistique_d2">
                                <span class="count">' . $count_abs_maladie . '</span><p>Non Justifiées</p>
                            </div>

                        </div>
                    </a>

                </div>
            </section>
        </div>
        <div class="col-md-4">
            <section class="panel bloc">
                <div class="panel-body">
                    <a href="' . action('StatisticsController@new_subscribers', [$year, $month]) . '">
                        <div class="bloc_statistique"><img src="images/inscription.png" >
                        <span class="count">' . $ns_number . '</span><p>Nouvelles inscriptions Ce Mois</p></div>
                        <div class="bloc_statistique_details">
                            <div class="bloc_statistique_d1">
                                <span class="count">' . $garcons . ' </span><p>Garçons</p>
                            </div>
                            <div class="bloc_statistique_d2">
                                <span class="count">' . $filles . '</span><p>Filles</p>
                            </div>
                        </div>
                    </a>


                </div>
            </section>
        </div>
        <div class="col-md-4">
            <section class="panel bloc">
                <div class="panel-body">
                    <a href="' . action('StatisticsController@monthly_bills', [$year, $month]) . '">
                        <div class="bloc_statistique"><img src="images/factures.png" ><span class="count">
                        ' . $count_bills . '</span><p>Factures générées Ce Mois</p></div>
                        <div class="bloc_statistique_details">
                            <div class="bloc_statistique_d1">
                                <span class="count">' . $regled_bills . '</span><p>Réglées</p>
                            </div>
                            <div class="bloc_statistique_d2">
                                <span class="count">' . $non_regled_bills . '</span><p>Non réglées</p>
                            </div>

                        </div>
                    </a>


                </div>
            </section>
        </div>
        </div>
       <div class="row partie-down">
        <div class="col-md-4">
            <section class="panel bloc">
                <div class="panel-body">
                    <a href="#">
                        <div class="bloc_statistique"><img src="images/statistiques.png" >
                        <span class="count">' . $somme . ' </span><p>Dhs total estimé Ce Mois</p></div>
                        <div class="bloc_statistique_details">
                            <div class="bloc_statistique_d1">
                                <span class="count">' . $encaisse . '</span><p>Dhs encaissé</p>
                            </div>
                            <div class="bloc_statistique_d2">
                                <span class="count">' . $reste . ' </span><p>Dhs qui reste</p>
                            </div>

                        </div>
                    </a>

                </div>
            </section>
        </div>
    </div>
        ';
        }
    }
 /**
  * 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é! ");
     }
 }
Exemplo n.º 20
0
 /**
  * @param $ids
  */
 public function exportPdf($ids = null)
 {
     $ids = explode(',', substr($ids, 0, -1));
     $ids = array_unique($ids);
     $model = Child::whereIn('id', $ids)->where('user_id', \Auth::user()->id)->get(['id', 'nom_enfant', 'created_at']);
     Excel::create('La liste des Elèves', function ($excel) use($model, $ids) {
         $excel->sheet('La liste des Elèves', function ($sheet) use($model, $ids) {
             foreach ($model as $child) {
                 $child->time = $child->created_at->toDateString();
                 $count = Bill::where('user_id', \Auth::user()->id)->where('child_id', $child->id)->where('status', 0)->count();
                 if ($count == 0) {
                     $child->status = 'Réglée';
                 } else {
                     $child->status = 'Non Réglée';
                 }
                 foreach ($child->classrooms as $cr) {
                     $child->classe = $cr->nom_classe;
                 }
                 unset($child->created_at);
                 unset($child->id);
             }
             // $sheet->setWidth('D',20);
             $sheet->fromModel($model);
             $sheet->setAllBorders('thin');
             $sheet->setFontFamily('OpenSans');
             $sheet->setFontSize(13);
             $sheet->setFontBold(false);
             for ($i = 1; $i <= count($ids) + 1; $i++) {
                 $sheet->setHeight($i, 25);
                 $sheet->row($i, function ($rows) {
                     $rows->setFontColor('#556b7b');
                     $rows->setAlignment('center');
                 });
                 $sheet->cells('A' . $i . ':' . 'D' . $i, function ($cells) {
                     $cells->setValignment('middle');
                     $cells->setFontColor('#556b7b');
                     $cells->setFont(array('family' => 'OpenSans', 'size' => '13', 'bold' => false));
                 });
             }
             // normal header
             $sheet->cells('A1:D1', function ($cells) {
                 $cells->setBackground('#e9f1f3');
                 $cells->setFontColor('#556b7b');
                 $cells->setFont(array('family' => 'OpenSans', 'size' => '15', 'bold' => true));
             });
             $sheet->row(1, array('Nom Elève', 'Date d\'inscription', 'Statut de Paiement', 'Classe'));
         });
     })->export('pdf');
 }
Exemplo n.º 21
0
 public function search()
 {
     $child = Child::where('nom_enfant', 'LIKE', '%' . \Input::get('terms') . '%')->where('user_id', \Auth::user()->id)->get();
     $family = Family::where('nom_pere', 'LIKE', '%' . \Input::get('terms') . '%')->where('user_id', \Auth::user()->id)->orWhere('nom_mere', 'LIKE', '%' . \Input::get('terms') . '%')->get();
     return view('families.search')->with(['child' => $child, 'family' => $family]);
 }
Exemplo n.º 22
0
 /**
  * Return a child's upcoming absences
  *
  * @param $child_id
  * @return mixed
  */
 public function upcomingAbsences($child_id)
 {
     $child = Child::findOrFail($child_id);
     if ($child->daycare_id === Auth::user()->daycare->id) {
         $absences = Absence::upcomingAbsences($child->id)->get();
         return $absences;
     }
 }
Exemplo n.º 23
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     if (Carbon::now()->toDateString() == Carbon::now()->startOfMonth()->toDateString()) {
         $users = User::where('type', 'ecole')->get();
         foreach ($users as $user) {
             $sc = SchoolYear::where('user_id', $user->id)->where('current', 1)->first();
             if ($sc->type == 'Semis' && Carbon::now()->between($sc->startch1, $sc->endch2)) {
                 foreach ($user->children as $child) {
                     foreach ($child->bills as $bill) {
                         $getChild = Bill::where('child_id', $bill->child_id)->where('reduction', 0)->where('school_year_id', $sc->id)->where('nbrMois', 1)->orderBy('id', 'desc')->first();
                         if ($getChild) {
                             $facture = new Bill();
                             $facture->start = $getChild->end->toDateString();
                             $facture->end = $getChild->end->addMonth()->toDateString();
                             $facture->status = 0;
                             $facture->user_id = $getChild->user_id;
                             $enfant = Child::where('user_id', $getChild->user_id)->where('id', $getChild->child_id)->first();
                             $taman = '';
                             $transportStatus = $enfant->transport;
                             foreach ($enfant->levels as $level) {
                                 $getPriceOfLevel = PriceBill::where('niveau', $level->id)->where('user_id', $getChild->user_id)->first();
                                 $taman = $getPriceOfLevel->prix;
                             }
                             $transportStatus == 0 ? $facture->somme = $taman : ($facture->somme = $taman + Transport::where('user_id', $getChild->user_id)->first()->somme);
                             $facture->nbrMois = $getChild->nbrMois;
                             $facture->reductionPrix = null;
                             $facture->school_year_id = $getChild->school_year_id;
                             $facture->reduction = 0;
                             $facture->child_id = $getChild->child_id;
                             $facture->f_id = $getChild->f_id;
                             $facture->save();
                             break;
                         }
                     }
                 }
             } elseif ($sc->type == 'Trim' && Carbon::now()->between($sc->startch1, $sc->endch3)) {
                 foreach ($user->children as $child) {
                     foreach ($child->bills as $bill) {
                         $getChild = Bill::where('child_id', $bill->child_id)->where('reduction', 0)->where('school_year_id', $sc->id)->where('nbrMois', 1)->orderBy('id', 'desc')->first();
                         if ($getChild) {
                             $facture = new Bill();
                             $facture->start = $getChild->end->toDateString();
                             $facture->end = $getChild->end->addMonth()->toDateString();
                             $facture->status = 0;
                             $facture->user_id = $getChild->user_id;
                             $enfant = Child::where('user_id', $getChild->user_id)->where('id', $getChild->child_id)->first();
                             $taman = '';
                             $transportStatus = $enfant->transport;
                             foreach ($enfant->levels as $level) {
                                 $getPriceOfLevel = PriceBill::where('niveau', $level->id)->where('user_id', $getChild->user_id)->first();
                                 $taman = $getPriceOfLevel->prix;
                             }
                             $transportStatus == 0 ? $facture->somme = $taman : ($facture->somme = $taman + Transport::where('user_id', $getChild->user_id)->first()->somme);
                             $facture->nbrMois = $getChild->nbrMois;
                             $facture->reductionPrix = null;
                             $facture->school_year_id = $getChild->school_year_id;
                             $facture->reduction = 0;
                             $facture->child_id = $getChild->child_id;
                             $facture->f_id = $getChild->f_id;
                             $facture->save();
                             break;
                         }
                     }
                 }
             }
         }
         /*  $enfants =  Child::has('bills')->get();
                 foreach($enfants as $e)
                 {
                     foreach($e->bills as $b)
                     {
                        $d = Bill::where('child_id',$b->child_id)->orderBy('id','desc')->first();
                        $bill = new Bill();
                         $bill->start =$d->end->toDateString();
                         $nextMonth7 =$d->end->addMonth()->toDateString();
                         if(Carbon::parse($nextMonth7)->month == 7)
                         {
                             $bill->end = Carbon::parse($nextMonth7)->addMonths(2)->toDateString();
                         }else{
                             $bill->end = $nextMonth7;
                         }
                         $bill->status = 0;
                         $bill->user_id = $d->user_id;
                         $bill->somme =  $d->somme;
                         $bill->child_id =$d->child_id;
                         $bill->f_id = $d->f_id;
                         $bill->save();
                         break;
         
         
                     }
                 }*/
     }
 }