예제 #1
0
 /**
  * @Post("editetiquette")
  * @return Redirect
  */
 public function posteditetiquette(Request $request)
 {
     $one = Etiquette::find($request->get('id'));
     $one->nom = $request->nom;
     $one->prenom = $request->prenom;
     $one->cin = $request->cin;
     $one->save();
     return redirect('/etiquettes');
 }
 /**
  * @Post("/editoperationper")
  *
  */
 public function posteditoperationper(Request $request)
 {
     $et = Operationper::find($request->get('id'));
     $user = User::find(Auth::user()->id);
     // ****************************************************
     if ($et->type_dr == "depense" and $et->mode_paiement == "poche") {
         $user->solde_poche = $user->solde_poche + $request->montant * $et->cpt;
         $user->solde_totale = $user->solde_totale + $request->montant * $et->cpt;
         $user->save();
     }
     if ($et->type_dr == "revenue" and $et->mode_paiement == "bank") {
         $user->soldebancaire = $user->soldebancaire - $request->montant * $et->cpt;
         $user->solde_totale = $user->solde_totale - $request->montant * $et->cpt;
         $user->save();
     }
     if ($et->type_dr == "depense" and $et->mode_paiement == "bank") {
         $user->soldebancaire = $user->soldebancaire + $request->montant * $et->cpt;
         $user->solde_totale = $user->solde_totale + $request->montant * $et->cpt;
         $user->save();
     }
     if ($et->type_dr == "revenue" and $et->mode_paiement == "poche") {
         $user->solde_poche = $user->solde_poche - $request->montant * $et->cpt;
         $user->solde_totale = $user->solde_totale - $request->montant * $et->cpt;
         $user->save();
     }
     // *******************************************************
     $et->frequence = $request->frequence;
     $et->nom = $request->nom;
     $et->type_dr = $request->type_dr;
     $et->montant = $request->montant;
     $et->mode_paiement = $request->mode_paiement;
     $et->description = $request->description;
     $et->etiquette_id = $request->etiquette;
     $et->categorie_id = $request->categorie;
     $et->date_d = $request->date_d;
     $et->date_f = $request->date_f;
     // *******************************************************
     if ($et->type_dr == "depense" and $et->mode_paiement == "poche") {
         $user->solde_poche = $user->solde_poche - $request->montant * $et->cpt;
         $user->solde_totale = $user->solde_totale - $request->montant * $et->cpt;
         $user->save();
     }
     if ($et->type_dr == "revenue" and $et->mode_paiement == "bank") {
         $user->soldebancaire = $user->soldebancaire + $request->montant * $et->cpt;
         $user->solde_totale = $user->solde_totale + $request->montant * $et->cpt;
         $user->save();
     }
     if ($et->type_dr == "depense" and $et->mode_paiement == "bank") {
         $user->soldebancaire = $user->soldebancaire - $request->montant * $et->cpt;
         $user->solde_totale = $user->solde_totale - $request->montant * $et->cpt;
         $user->save();
     }
     if ($et->type_dr == "revenue" and $et->mode_paiement == "poche") {
         $user->solde_poche = $user->solde_poche + $request->montant * $et->cpt;
         $user->solde_totale = $user->solde_totale + $request->montant * $et->cpt;
         $user->save();
     }
     // *******************************************************
     $et->save();
     return redirect('/operationpers')->with(['etiquette' => Etiquette::all(), 'categorie' => Categorie::all(), 'operationpers' => Operationper::where('user_id', \Auth::user()->id)->with('etiquette', 'categorie')->get()]);
 }