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
|
/**
*Rempli l'entité debt de la BDD de la liste des adhérents qui n'ont pas payé leur cotisation et Suprime toutes les cotisations
*
*
* @Route("amount/reset/cotisation", name="reset_cotisation")
*
* @param ObjectManager $manager
*
*/
public function reset(ObjectManager $manager)
{
$debt = new Debt();
$repo = $this->getDoctrine()->getRepository(CategoryAdherent::class);
$cat = $repo->findAll();
$repo1 = $this->getDoctrine()->getRepository(Adherent::class);
$adherent = $repo1->findAll();
foreach($adherent as $ad)
{
//var_dump('<li>'.$ad->getFirstName().'</li>') ;
foreach( $ad->getAmounts() as $key => $a){
//var_dump($a->getAmount1());
$total = ($a->getAmount1() + $a->getAmount2() + $a->getAmount3() + $a->getAmount4());
var_dump($total);
foreach($cat as $cat){
$montant_total = $cat->getMontantcot();
$reste_du = $cat->getMontantcot() - $total;
if ($cat->getTitle() === $ad->getSubcategory() and isset($a)and $total < $montant_total){
//var_dump($montant_total);die;
$debt->setName($ad->getLastName());
$debt->setPrenom($ad->getFirstName());
$debt->setCategory($ad->getSubCategory());
$debt->setMail($ad->getEmail());
$debt->setTel($ad->getMobilePhone());
$debt->setAmount($reste_du);
$manager->persist($debt);
$manager->flush();
return $this->redirectToRoute('home');
}//else{ return $this->redirectToRoute("home");}
}
}
}
} |