1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
| public function modifierUnePrestationOkAction(Request $request)
{
$objUser = $this->get('security.context')->getToken()->getUser();
$em = $this->getDoctrine()->getManager();
$notifs = $em->getRepository('WNgetBundle:Notification')->getNotifications($objUser);
$nbNotifs = count($notifs);
$id = $request->get('id');
$nomDemande = $request->get('nomDemande');
$prestation = $em->getRepository("WNgetBundle:Depenses")->findOneBy(array("id" => $id ));
$petitDejOld = $prestation->getPetitDej();
$nuiteOld = $prestation->getNuite();
$dejOld = $prestation->getDej();
$dinerOld = $prestation->getDiner();
$autresOld = $prestation->getAutres();
$totalOld = $prestation->getTotal();
$totPtiDej = $prestation->getDeplacement()->getTotalPetitDej();
$totNuite = $prestation->getDeplacement()->getTotalNuite();
$totDej = $prestation->getDeplacement()->getTotalDej();
$totDiner = $prestation->getDeplacement()->getTotalDiner();
$totAutres = $prestation->getDeplacement()->getTotalAutres();
$totals = $prestation->getDeplacement()->getTotals();
$debut = $request->get('debutInt');
$debutInt = new \DateTime($debut);
$fin = $request->get('finInt');
$finInt = new \DateTime($fin);
$petitDej = $request->get('petitDej');
$nuite = $request->get('nuite');
$dej = $request->get('dej');
$diner = $request->get('diner');
$autres = $request->get('autres');
$totPtiDej = $totPtiDej + $petitDej - $petitDejOld;
$totNuite = $totNuite + $nuite - $nuiteOld;
$totDej = $totDej + $dej - $dejOld;
$totDiner = $totDiner + $diner - $dinerOld;
$totAutres = $totAutres + $autres - $autresOld;
$total = $petitDej + $nuite + $dej + $diner + $autres;
$totals = $totals + $total - $totalOld;
$prestation ->setPrestation($request->get('prestation'))
->setType('hamZa')
->setDateDebut($debutInt)
->setDateFin($finInt)
->setClient($request->get('cient'))
->setNumRapInt($request->get('numRap'))
->setPetitDejeuner($petitDej)
->setNuit($nuite)
->setDejeuner($dej)
->setDiner($diner)
->setAutresFrais($autres)
->setLibelleAutresFrais($request->get('libAutres'))
->setTotal($total);
$em->persist($prestation);
$em->flush();
$depl = $em->getRepository("WNgetBundle:Deplacement")->findOneBy(array("titreDeplacement" => $nomDemande ));
$depences = $em->getRepository("WNgetBundle:Depenses")->findBy(array("deplacement" => $depl ));
return $this->render('WNgetBundle:Deplacement:verifierInfos.html.twig',array(
'notifs' => $notifs,
'user' => $objUser,
'nbNotifs' => $nbNotifs,
'nomDemande' => $nomDemande,
'depences' => $depences,
'depl' => $depl,
));
} |