src/Controller/Produit/Produit/PanierController.php line 328

Open in your IDE?
  1. <?php
  2. /*
  3. (c) Noel Kenfack <noel.kenfack@yahoo.fr> Février 2015
  4. */
  5. namespace App\Controller\Produit\Produit;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use App\Entity\Users\User\User;
  9. use App\Entity\Produit\Produit\Panier;
  10. use App\Entity\Users\User\Contacts;
  11. use App\Entity\Users\User\Billet;
  12. use App\Form\Users\User\BilleteditType;
  13. use App\Entity\Produit\Produit\Produitpanier;
  14. use App\Entity\Users\User\Notification;
  15. use General\ServiceBundle\AfPdf\PDF;
  16. use App\Service\Servicetext\GeneralServicetext;
  17. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  18. use App\Service\Email\Singleemail;
  19. use App\Entity\Produit\Produit\Souscategorie;
  20. use App\Entity\Produit\Service\Ville;
  21. use App\Entity\Produit\Service\Service;
  22. use Symfony\Component\HttpFoundation\Request;
  23. use App\Entity\Produit\Produit\Produit;
  24. use App\Entity\Produit\Service\Pays;
  25. class PanierController extends AbstractController
  26. {
  27. private $params;
  28. private $_servicemail;
  29. public function __construct(ParameterBagInterface $paramsSingleemail $servicemail)
  30. {
  31.     $this->params $params;
  32.     $this->_servicemail $servicemail;
  33. }
  34. public function trackbill()
  35. {
  36.     $em $this->getDoctrine()->getManager();
  37.     $liste_panier $em->getRepository(Panier::class)
  38.                        ->panierContact();
  39.     $current_command $em->getRepository(Panier::class)
  40.                        ->panierContactNonPayer();
  41.                        
  42.     return $this->render('Theme/Users/Adminuser/Panier/trackbill.html.twig',
  43.     array('liste_panier'=>$liste_panier,'current_command'=>$current_command));
  44. }
  45. public function contenupanier(Panier $panier)
  46. {
  47.     $em $this->getDoctrine()->getManager();
  48.     $liste_produit $em->getRepository(Produitpanier::class)
  49.                        ->myfindBy($panier->getId());
  50.     return $this->render('Theme/Users/Adminuser/Panier/contenupanier.html.twig',array('liste_produit'=>$liste_produit,'panier'=>$panier));
  51. }
  52. public function validationpaiement(Panier $panierGeneralServicetext $service)
  53. {
  54.     $em $this->getDoctrine()->getManager();    
  55.     if($panier->getPayer() == false and $panier->getContact() != null)
  56.     {
  57.         $pdf = new PDF('L','mm','A5');
  58.         $pdf->AliasNbPages();
  59.         $pdf->AddPage();
  60.         $pdf->SetFont('Times','',12);
  61.         
  62.         $pdf->setStruct($panier->getContact()->getStructname());
  63.         $pdf->setTypec($panier->getContact()->getType());
  64.         $pdf->setAdresse($panier->getContact()->getAdresse());
  65.         $pdf->setRegion($panier->getContact()->getVille().', '.$panier->getContact()->getPays()->getNom());
  66.         $pdf->setRespo($panier->getContact()->name(40));
  67.         $pdf->setNumdate('Facture ID: '.$panier->numFacture().' du: '.$panier->dateFacture());
  68.         $pdf->setCassename($this->getUser()->name(50));
  69.         $pdf->setCassefont($this->getUser()->getPoste());
  70.             $pdf->description();
  71.             //liste des produits
  72.             
  73.             $ligne 40;
  74.             $cout 0;
  75.             $qte 0;
  76.             $reduction 0;
  77.             
  78.             if($panier->getCollectionproduit() == null)
  79.             {
  80.                 foreach($panier->getProduitpaniers() as $propan)
  81.                 {
  82.                     $prixTttc = ($propan->getQuantite() * $propan->getProduit()->getNewprise()) + ($propan->getProduit()->getPrixlivraison() * $propan->getQuantite());
  83.                     if($propan->getProduit()->getSouscategorie()->getCategorie()->getRang() == 1)
  84.                     {
  85.                         $name $propan->getDomaine();
  86.                         $servicename 'Nom de domaine';
  87.                     }else{
  88.                         $name $propan->getProduit()->getNom();
  89.                         $servicename $propan->getProduit()->getSouscategorie()->getNom();
  90.                     }
  91.                     
  92.                     $prixuttc $propan->getProduit()->getNewprise() + $propan->getProduit()->getPrixlivraison();
  93.                     $pdf->addProduct($servicename$name$prixuttc$propan->getQuantite().',00 '.$propan->getProduit()->getRapport().''$prixTttc$ligne);
  94.                     $ligne $ligne 5;
  95.                     $cout $cout $prixTttc;
  96.                     $qte $qte $propan->getQuantite();
  97.                 }
  98.             }else{
  99.                 $renews $panier->getCollectionproduit()->getRenewplans();
  100.                 foreach($renews as $renewplan)
  101.                 {
  102.                     $propan $renewplan->getProduitpanier();
  103.                     $prixTttc = ($renewplan->getQuantite() * $propan->getProduit()->getNewprise()) + ($propan->getProduit()->getPrixlivraison() * $renewplan->getQuantite());
  104.                     if($propan->getProduit()->getSouscategorie()->getCategorie()->getRang() == 1)
  105.                     {
  106.                         $name $propan->getDomaine();
  107.                         $servicename 'Nom de domaine';
  108.                     }else{
  109.                         $name $propan->getProduit()->getNom();
  110.                         $servicename $propan->getProduit()->getSouscategorie()->getNom();
  111.                     }
  112.                     
  113.                     $prixuttc $propan->getProduit()->getNewprise() + $propan->getProduit()->getPrixlivraison();
  114.                     $pdf->addProduct($servicename$name$prixuttc$renewplan->getQuantite().',00 '.$propan->getProduit()->getRapport().''$prixTttc$ligne);
  115.                     $ligne $ligne 5;
  116.                     $cout $cout $prixTttc;
  117.                     $qte $qte $renewplan->getQuantite();
  118.                 }
  119.             }
  120.             
  121.             $devise $this->container->getParameter('devise');
  122.             if($panier->getCouponcard() != null)
  123.             {
  124.                 $reduction $panier->getCouponcard()->getMontant();
  125.             }
  126.             
  127.             $pdf->statistique($reduction.',00'.$devise,($cout $reduction).',00'.$devise);
  128.         
  129.         if(!file_exists ($panier->getUploadRootDir()))
  130.         {
  131.             mkdir($panier->getUploadRootDir(),0777,true);
  132.         }
  133.         $pdf->Output('F',$panier->getWebPath());
  134.         
  135.         
  136.         //Email Client
  137.         
  138.         $siteweb $this->params->get('siteweb');
  139.         $sitename $this->params->get('sitename');
  140.         $emailadmin $this->params->get('emailadmin');
  141.         if($service->email($panier->getUser()->getUsername()))
  142.         {
  143.             $response $this->_servicemail->sendNotifEmail(
  144.                 $panier->getUser()->name(25), //Nom du destinataire
  145.                 $panier->getUser()->getUsername(), //Email Destinataire
  146.                 $panier->getUser()->name(25).', Votre facture ID: '.$panier->numFacture().' est déjà  disponible !'//Objet de l'email
  147.                 $panier->getUser()->name(25).', Votre facture ID: '.$panier->numFacture().' est déjà  disponible !'//Grand Titre de l'email
  148.                 'Nous vous remercions pour votre commande.</br> Téléchargez votre facture en pièce jointe à ce courriel ! </br> Vous pouvez consulter cette dernière depuis votre espace client en cliquant sur le menu <<factures>>. </br> Suivez l\'état de vos produits/services chez '.$sitename.' directement sur votre espace client.',  //Contenu de l'email
  149.                 $siteweb.'/user/afh/panel/'.$panier->getUser()->getId()  //Lien à suivre
  150.             );
  151.         }
  152.         
  153.         
  154.         //Notification client.
  155.         $notification = new Notification($service);
  156.         $notification->setUser($panier->getUser());
  157.         $notification->setTitre($panier->getUser()->name(25).', Votre facture ID: '.$panier->numFacture().' est déjà  disponible !');
  158.         $notification->setDescription('Nous vous remercions pour votre commande. Vous pouvez consulter à la rubrique "factures" de votre espace client.');
  159.         $em->persist($notification);
  160.         
  161.         if($panier->getCollectionproduit() == null)
  162.         {
  163.             foreach($panier->getProduitpaniers() as $propan)
  164.             {
  165.                 $produit $propan->getProduit();
  166.                 $rapport $produit->getRapport();
  167.                 if(preg_match("/mois/i"$rapport))
  168.                 {
  169.                     $propan->setExpireon(new \Datetime($propan->getExpireon()->modify("+{$propan->getQuantite()} month")->format('Y-m-d')));
  170.                 }else if(preg_match("/an/i"$rapport))
  171.                 {
  172.                     $propan->setExpireon(new \Datetime($propan->getExpireon()->modify("+{$propan->getQuantite()} year")->format('Y-m-d')));
  173.                 }else{
  174.                     $propan->setExpireon(new \Datetime($propan->getExpireon()->modify("+{$propan->getQuantite()} month")->format('Y-m-d')));
  175.                 }
  176.             }
  177.         }else{
  178.             $renews $panier->getCollectionproduit()->getRenewplans();
  179.             foreach($renews as $renewplan)
  180.             {
  181.                 $propan $renewplan->getProduitpanier();
  182.                 $produit $propan->getProduit();
  183.                 $rapport $produit->getRapport();
  184.                 if(preg_match("/mois/i"$rapport))
  185.                 {
  186.                     $propan->setExpireon(new \Datetime($propan->getExpireon()->modify("+{$propan->getQuantite()} month")->format('Y-m-d')));
  187.                 }else if(preg_match("/an/i"$rapport))
  188.                 {
  189.                     $propan->setExpireon(new \Datetime($propan->getExpireon()->modify("+{$propan->getQuantite()} year")->format('Y-m-d')));
  190.                 }else{
  191.                     $propan->setExpireon(new \Datetime($propan->getExpireon()->modify("+{$propan->getQuantite()} month")->format('Y-m-d')));
  192.                 }
  193.             }
  194.         }
  195.         
  196.         $panier->setPayer(true);
  197.         $em->flush();
  198.         
  199.         $this->get('session')->getFlashBag()->add('information','Validation de la commande effectuée avec succès !');
  200.     }
  201.     return $this->redirect($this->generateUrl('users_adminuser_afh_track_bill'));
  202. }
  203. public function panierlivrer()
  204. {
  205.     $em $this->getDoctrine()->getManager();
  206.     $liste_panier $em->getRepository(Panier::class)
  207.                        ->findBy(array('payer'=>1,'livrer'=>1),array('date'=>'desc'));
  208.     return $this->render('Theme/Users/Adminuser/Panier/panierlivrer.html.twig',array('liste_panier'=>$liste_panier));
  209. }
  210. public function detailpanieruser(Panier $panier)
  211. {
  212.     $em $this->getDoctrine()->getManager();
  213.     $liste_produit $em->getRepository(Produitpanier::class)
  214.                        ->myfindBy($panier->getId());
  215.     $topcat $em->getRepository(Souscategorie::class)
  216.                      ->topsouscategorie(8);
  217.     return $this->render('Theme/Produit/Produit/Panier/detailpanieruser.html.twig',
  218.     array('liste_produit'=>$liste_produit,'panier'=>$panier,'topcat'=>$topcat));
  219. }
  220. public function modifierlieulivraison(Panier $panier)
  221. {
  222.     $em $this->getDoctrine()->getManager();
  223.     if(isset($_POST['ville']))
  224.     {
  225.         $ville $em->getRepository(Ville::class)
  226.                        ->findOneBy(array('nom'=>$_POST['ville']));
  227.             if($ville != null)
  228.             {
  229.                 $panier->setVille($ville);
  230.                 $em->flush();
  231.             }
  232.     }
  233.     return $this->redirect($this->generateUrl('produit_produit_reglement_commande_du_panier',array('id'=>$this->getUser()->getId())));
  234. }
  235. public function cardbill(Panier $panierGeneralServicetext $serviceRequest $request)
  236. {
  237.     $em $this->getDoctrine()->getManager();
  238.     if($panier->getSousmis() == false)
  239.     {
  240.         $this->get('session')->getFlashBag()->add('information','La commande que vous essayez de consulter est encore incomplète !');
  241.         return $this->redirect($this->generateUrl('users_user_acces_plateforme'));
  242.     }
  243.     
  244.     $liste_article $em->getRepository(Service::class)
  245.                         ->myFindType('modepaiement');
  246.     
  247.     $billet = new Billet($service);
  248.     $formbillet $this->createForm(BilleteditType::class, $billet);
  249.     if ($request->getMethod() == 'POST')
  250.     {
  251.         $formbillet->handleRequest($request);
  252.         if ($formbillet->isValid() and $panier != null){
  253.             $avisuser 0;
  254.             $billet->setUser($panier->getUser());
  255.             $billet->setPanier($panier);
  256.             if(isset($_POST['avisuser']))
  257.             {
  258.                 $avisuser $_POST['avisuser'];
  259.             }
  260.             $billet->setAvisuser($avisuser);
  261.             $billet->setTitre('Avis Commande '.$panier->numFacture());
  262.             $billet->setAvis(true);
  263.             $em->persist($billet);
  264.             $em->flush();
  265.             
  266.             $siteweb $this->params->get('siteweb');
  267.             $sitename $this->params->get('sitename');
  268.             $emailadmin $this->params->get('emailadmin');
  269.     
  270.             $mail = new Afmail();
  271.             
  272.             $response $this->_servicemail->sendNotifEmail(
  273.                 'Team '.$sitename//Nom du destinataire
  274.                 $emailadmin//Email Destinataire
  275.                 $panier->getUser()->name(25).', Vient d\'ajouter un avis sur '.$sitename//Objet de l'email
  276.                 $panier->getUser()->name(25).', Vient d\'ajouter un avis sur '.$sitename//Grand Titre de l'email
  277.                 'Rendez-vous sur '.$sitename.' pour consulter cet avis.',  //Contenu de l'email
  278.                 $siteweb.'/user/afh/panel/'.$panier->getUser()->getId()  //Lien à suivre
  279.             );
  280.         }else{
  281.             $this->get('session')->getFlashBag()->add('information','Une erreur a été rencontrée !');
  282.         }
  283.     }
  284.     
  285.     $liste_review $em->getRepository(Billet::class)
  286.                         ->findBy(array('panier'=>$panier,'avis'=>1), array('date'=>'desc'));
  287.     $produitpanier null;
  288.     foreach($panier->getProduitpaniers() as $prodpan)
  289.     {
  290.         $produitpanier $prodpan;
  291.         break;
  292.     }
  293.     return $this->render('Theme/Produit/Produit/Panier/cardbill.html.twig',
  294.     array('panier'=>$panier,'liste_article'=>$liste_article,'formbillet'=>$formbillet->createView(),
  295.     'liste_review'=>$liste_review,'produitpanier'=>$produitpanier));
  296. }
  297. public function clientreviews($page$id)
  298. {
  299.     $em $this->getDoctrine()->getManager();
  300.     $liste_billet $em->getRepository(Billet::class)
  301.                            ->myFindReview($page,11);
  302.                           
  303.     $repository $em->getRepository(Billet::class);
  304.     $openticket $repository->find($id);
  305.                            
  306.     $total $repository->getTotalAvisUtilisateur();
  307.     $somme $repository->getSommeAvisValide();
  308.                    
  309.     return $this->render('Theme/Users/User/Billet/clientreviews.html.twig',
  310.     array('liste_billet'=>$liste_billet,'page'=>$page,
  311.     'nombrepage' => ceil(count($liste_billet)/11),'total'=>$total,'somme'=>$somme,'openticket'=>$openticket));
  312. }
  313. public function ajoutdomaine()
  314. {
  315.     if(isset($_POST['id']))
  316.     {
  317.         $id $_POST['id'];
  318.     }else{
  319.         $id 0;
  320.     }
  321.     $em $this->getDoctrine()->getManager();
  322.     $produit $em->getRepository(Produit::class)
  323.                      ->find($id);
  324.     if($produit != null){
  325.         $idcard 0;
  326.         if(isset($_COOKIE["PIDCARD"]) and $_COOKIE["PIDCARD"] != 'empty')
  327.         {
  328.             $idcard $_COOKIE["PIDCARD"];
  329.         }
  330.         
  331.         $oldpanier $em->getRepository(Panier::class)
  332.                          ->findOneBy(array('id'=>$idcard,'sousmis'=>0));
  333.         if($oldpanier == null and $this->getUser() != null)
  334.         {
  335.             $oldpanier $em->getRepository(Panier::class)
  336.                          ->findOneBy(array('user'=>$this->getUser(),'sousmis'=>0));
  337.         }
  338.         
  339.         $domaine '-';
  340.         $statut '-';
  341.         if(isset($_POST['domaine']) and isset($_POST['statut']))
  342.         {
  343.             $domaine $_POST['domaine'];
  344.             $statut $_POST['statut'];
  345.         }
  346.         if($oldpanier == null)
  347.         {
  348.             $panier = new Panier();
  349.             $panier->setUser($this->getUser());
  350.             $em->persist($panier);
  351.             
  352.             $produitpanier = new Produitpanier();
  353.             $produitpanier->setPanier($panier);
  354.             $produitpanier->setDomaine($domaine);
  355.             $produitpanier->setEnregistrement($statut);
  356.             $produitpanier->setProduit($produit);
  357.             $em->persist($produitpanier);
  358.             $em->flush();
  359.             
  360.             // Stock les infos du cookie
  361.             $cookie_info = array(
  362.                 'name'  => 'PIDCARD',
  363.                 'value' => $panier->getId(),
  364.                 'time'  => time() + (3600 24 360)
  365.             );
  366.             
  367.             // Cree le cookie
  368.             setCookie($cookie_info['name'], $cookie_info['value'], $cookie_info['time'],'/');
  369.             setCookie('PIDCARDDUR',$cookie_info['time'], $cookie_info['time'],'/');
  370.         }else{
  371.             if(count($oldpanier->getProduitpaniers()) != 0)
  372.             {
  373.                 $listprod $oldpanier->getProduitpaniers();
  374.                 
  375.                 $trouve false;
  376.                 foreach($listprod as $prod)
  377.                 {
  378.                     if($prod->getProduit() == $produit  and $prod->getDomaine() == $domaine)
  379.                     {
  380.                         if($prod->getQuantite() < 5)
  381.                         {
  382.                             $prod->setQuantite($prod->getQuantite() + 1);
  383.                             $trouve true;
  384.                             break;
  385.                         }else{
  386.                             echo 0;
  387.                             exit;
  388.                             break;
  389.                         }
  390.                     }
  391.                 }
  392.                 
  393.                 if($trouve == false)
  394.                 {
  395.                     $produitpanier = new Produitpanier();
  396.                     $produitpanier->setPanier($oldpanier);
  397.                     $produitpanier->setDomaine($domaine);
  398.                     $produitpanier->setEnregistrement($statut);
  399.                     $produitpanier->setProduit($produit);
  400.                     $em->persist($produitpanier);
  401.                 }
  402.             }else{
  403.                 $produitpanier = new Produitpanier();
  404.                 $produitpanier->setPanier($oldpanier);
  405.                 $produitpanier->setDomaine($domaine);
  406.                 $produitpanier->setEnregistrement($statut);
  407.                 $produitpanier->setProduit($produit);
  408.                 $em->persist($produitpanier);
  409.             }
  410.             $em->flush();
  411.         }
  412.     echo 1;
  413.     exit;
  414.     }else{
  415.         echo 0;
  416.         exit;
  417.     }
  418. }
  419. public function parametrescommande(Panier $panier)
  420. {
  421.     $tarifht 0;
  422.     $tarifttc 0;
  423.     $em $this->getDoctrine()->getManager();
  424.     if(isset($_POST['montantht']) and isset($_POST['montantttc']))
  425.     {
  426.         $tarifht $_POST['montantht'];
  427.         $tarifttc $_POST['montantttc'];
  428.         $panier->setMontantht($tarifht);
  429.         $panier->setMontantttc($tarifttc);
  430.         $em->flush();
  431.     }
  432.     $namedns1 $this->params->get('namedns1');
  433.     $namedns2 $this->params->get('namedns2');
  434.     $registrat1 $this->params->get('registrat1');
  435.     $systemelg $this->params->get('systemelg');
  436.     $serveurmap $this->params->get('serveurmap');
  437.     $managerhosting $this->params->get('managerhosting');
  438.     $typesuivi $this->params->get('typesuivi');
  439.     
  440.     return $this->render('Theme/Produit/Produit/Panier/parametrescommande.html.twig',
  441.     array('panier'=>$panier,'namedns1'=>$namedns1,'namedns2'=>$namedns2,'registrat1'=>$registrat1,
  442.     'systemelg'=>$systemelg,'managerhosting'=>$managerhosting,'serveurmap'=>$serveurmap,'typesuivi'=>$typesuivi));
  443. }
  444. public function parameterprodpan(Panier $panierGeneralServicetext $service)
  445. {
  446.     $em $this->getDoctrine()->getManager();
  447.     if(isset($_POST['typeprod']) and $_POST['typeprod'] == 'domaine')
  448.     {
  449.         if(isset($_POST['prodpan']))
  450.         {
  451.             $prodpan2 $em->getRepository(Produitpanier::class)
  452.                           ->find($_POST['prodpan']);
  453.             if($prodpan2 != null and isset($_POST['registrat']) and isset($_POST['namedns1']) and isset($_POST['namedns2']) and isset($_POST['namedns3']) and isset($_POST['namedns4']))
  454.             {
  455.                 $prodpan2->setRegistrat($_POST['registrat']);
  456.                 $prodpan2->setNamedns1($_POST['namedns1']);
  457.                 $prodpan2->setNamedns2($_POST['namedns2']);
  458.                 $prodpan2->setNamedns3($_POST['namedns3']);
  459.                 $prodpan2->setNamedns4($_POST['namedns4']);
  460.                 
  461.                 if(isset($_POST['transfertkey']))
  462.                 {
  463.                     $prodpan2->setTransfertkey($_POST['transfertkey']);
  464.                 }
  465.                 $em->flush();
  466.                 return $this->redirect($this->generateUrl('produit_produit_manage_parametres_commande', array('id'=>$panier->getId())));
  467.             }
  468.         }
  469.     }else if(isset($_POST['typeprod']) and $_POST['typeprod'] == 'hosting')
  470.     {
  471.         if(isset($_POST['prodpan']))
  472.         {
  473.             $prodpan2 $em->getRepository(Produitpanier::class)
  474.                           ->find($_POST['prodpan']);
  475.             if($prodpan2 != null and isset($_POST['systemelg']) and isset($_POST['serveurmap']) and isset($_POST['nameinstance']) and isset($_POST['password']))
  476.             {
  477.                 $prodpan2->setSystemelg($_POST['systemelg']);
  478.                 $prodpan2->setServeurmap($_POST['serveurmap']);
  479.                 $prodpan2->setNameinstance($_POST['nameinstance']);
  480.                 if($_POST['password'] != '')
  481.                 {
  482.                 $prodpan2->setPassword($service->encrypt($_POST['password'],$this->container->getParameter('saltcookies')));
  483.                 }
  484.                 if(isset($_POST['revendeurmanager']))
  485.                 {
  486.                 $prodpan2->setRevendeurmanager($_POST['revendeurmanager']);
  487.                 }
  488.                 $em->flush();
  489.                 return $this->redirect($this->generateUrl('produit_produit_manage_parametres_commande', array('id'=>$panier->getId())));
  490.             }
  491.         }
  492.     }else if(isset($_POST['typeprod']) and $_POST['typeprod'] == 'ssl')
  493.     {
  494.         if(isset($_POST['prodpan']))
  495.         {
  496.             $prodpan2 $em->getRepository(Produitpanier::class)
  497.                            ->find($_POST['prodpan']);
  498.             if($prodpan2 != null and isset($_POST['sitewebname']))
  499.             {
  500.                 $prodpan2->setSitewebname($_POST['sitewebname']);
  501.                 $em->flush();
  502.                 return $this->redirect($this->generateUrl('produit_produit_manage_parametres_commande', array('id'=>$panier->getId())));
  503.             }
  504.         }
  505.     }else if(isset($_POST['typeprod']) and $_POST['typeprod'] == 'niveauservice')
  506.     {
  507.         if(isset($_POST['prodpan']))
  508.         {
  509.             $prodpan2 $em->getRepository(Produitpanier::class)
  510.                            ->find($_POST['prodpan']);
  511.             if($prodpan2 != null and isset($_POST['typesuivi']))
  512.             {
  513.                 $prodpan2->setTypesuivi($_POST['typesuivi']);
  514.                 $em->flush();
  515.                 return $this->redirect($this->generateUrl('produit_produit_manage_parametres_commande', array('id'=>$panier->getId())));
  516.             }
  517.         }
  518.     }
  519.     echo 0;
  520.     exit;
  521. }
  522. public function contactspanier(Panier $panierGeneralServicetext $service)
  523. {
  524.     $em $this->getDoctrine()->getManager();
  525.     $liste_pays $em->getRepository(Pays::class)
  526.                      ->myfindAll();
  527.     $liste_contact = new \Doctrine\Common\Collections\ArrayCollection();
  528.     if($this->getUser() != null)
  529.     {
  530.         $liste_contact $em->getRepository(Contacts::class)
  531.                             ->findBy(array('user'=>$this->getUser()));
  532.     }
  533.     return $this->render('Theme/Produit/Produit/Panier/contactspanier.html.twig',
  534.     array('panier'=>$panier,'liste_pays'=>$liste_pays,'liste_contact'=>$liste_contact));
  535. }
  536. public function savecontacts(Panier $panierGeneralServicetext $service)
  537. {
  538.     $em $this->getDoctrine()->getManager();    
  539.     $newaccount false;
  540.     if(isset($_POST['type']))
  541.     {
  542.         $type $_POST['type'];
  543.     }else{
  544.         echo 0;
  545.         exit;
  546.     }
  547.     
  548.     if(isset($_POST['pseudo']) and $service->chaineValide($_POST['pseudo'], 2100))
  549.     {
  550.         $pseudo $_POST['pseudo'];
  551.     }else{
  552.         echo 2;
  553.         exit;
  554.     }
  555.     
  556.     if(isset($_POST['structname']) and $service->chaineValide($_POST['structname'], 2100))
  557.     {
  558.         $structname $_POST['structname'];
  559.     }else{
  560.         echo 3;
  561.         exit;
  562.     }
  563.     
  564.     if(isset($_POST['nom']) and $service->chaineValide($_POST['nom'], 2100))
  565.     {
  566.         $nom $_POST['nom'];
  567.     }else{
  568.         echo 4;
  569.         exit;
  570.     }
  571.     
  572.     if(isset($_POST['prenom']) and $service->chaineValide($_POST['prenom'], 2100))
  573.     {
  574.         $prenom $_POST['prenom'];
  575.     }else{
  576.         echo 5;
  577.         exit;
  578.     }
  579.     
  580.     if(isset($_POST['pays']))
  581.     {
  582.         $pays $em->getRepository(Pays::class)
  583.                      ->find($_POST['pays']);
  584.         if($pays == null)
  585.         {
  586.             echo 6;
  587.             exit;
  588.         }
  589.     }else{
  590.         echo 6;
  591.         exit;
  592.     }
  593.     
  594.     if(isset($_POST['adresse']) and $service->chaineValide($_POST['adresse'], 2100))
  595.     {
  596.         $adresse $_POST['adresse'];
  597.     }else{
  598.         echo 7;
  599.         exit;
  600.     }
  601.     
  602.     if(isset($_POST['ville']) and $service->chaineValide($_POST['ville'], 2100))
  603.     {
  604.         $ville $_POST['ville'];
  605.     }else{
  606.         echo 8;
  607.         exit;
  608.     }
  609.     
  610.     if(isset($_POST['email']) and $service->email($_POST['email']))
  611.     {
  612.         $email $_POST['email'];
  613.     }else{
  614.         echo 9;
  615.         exit;
  616.     }
  617.     
  618.     if(isset($_POST['tel']) and $service->telephone($_POST['tel']))
  619.     {
  620.         $tel $_POST['tel'];
  621.     }else{
  622.         echo 10;
  623.         exit;
  624.     }
  625.     
  626.     if(isset($_POST['newcompte']) and $_POST['newcompte'] == true)
  627.     {
  628.         if(isset($_POST['password']) and $service->password($_POST['password']))
  629.         {
  630.             $password $_POST['password'];
  631.             $newaccount true;
  632.         }else{
  633.             echo 11;
  634.             exit;
  635.         }
  636.     }
  637.     
  638.     if($panier->getContact() != null)
  639.     {
  640.         $contact $panier->getContact();
  641.     }else{
  642.         $contact = new Contacts($service);
  643.     }
  644.     
  645.     $contact->setType($type);
  646.     $contact->setPseudo($pseudo);
  647.     $contact->setStructname($structname);
  648.     $contact->setNom($nom);
  649.     $contact->setPrenom($prenom);
  650.     $contact->setPays($pays);
  651.     $contact->setAdresse($adresse);
  652.     $contact->setVille($adresse);
  653.     $contact->setEmail($email);
  654.     $contact->setTel($tel);
  655.     $em->persist($contact);
  656.     $panier->setContact($contact);
  657.     $em->flush();
  658.     
  659.     if($newaccount == true and $this->getUser() == null)
  660.     {
  661.         $olduser $em->getRepository(User::class)
  662.                       ->findOneBy(array('username'=>$email));
  663.         if($olduser == null)
  664.         {            
  665.             $user = new User($service);
  666.             $user->setNom($nom);
  667.             $user->setPrenom($nom);
  668.             $user->setUsername($email);
  669.             $user->setPassword($password);
  670.             $user->setTel($tel);
  671.             $user->setPays($pays);
  672.             $em->persist($user);
  673.             $panier->setUser($user);
  674.             $contact->setUser($user);
  675.             $em->flush();
  676.             
  677.             $session $this->get('session');    
  678.             $session->set('pid_user_panier',$user->getId());
  679.             echo 1;
  680.             exit;
  681.         }else{
  682.             echo 12;
  683.             exit;
  684.         }
  685.     }else{
  686.         if($this->getUser() != null)
  687.         {
  688.             $panier->setUser($this->getUser());
  689.             $contact->setUser($this->getUser());
  690.             $em->flush();
  691.         }
  692.     }
  693.     echo 1;
  694.     exit;
  695. }
  696. public function paiementstep(Panier $panierGeneralServicetext $service$position$save)
  697. {
  698.     $em $this->getDoctrine()->getManager();
  699.     if($position == 'paiement')
  700.     {
  701.         if(isset($_POST['idpaiement']) and isset($_POST['idcontact']))
  702.         {
  703.             $article $em->getRepository(Service::class)
  704.                           ->find($_POST['idpaiement']);
  705.                           
  706.             $contact $em->getRepository(Contacts::class)
  707.                           ->find($_POST['idcontact']);
  708.             if($contact != null)
  709.             {
  710.                 $panier->setContact($contact);
  711.                 $em->flush();
  712.             }
  713.             
  714.             if($article != null)
  715.             {
  716.                 $panier->setService($article);
  717.                 $panier->setSousmis(true);
  718.                 if(isset($_COOKIE["PIDCARD"]) and isset($_COOKIE["PIDCARDDUR"]))
  719.                 {
  720.                     // Stock les infos du cookie
  721.                     $cookie_info = array(
  722.                         'name'  => "PIDCARD",
  723.                         'value' => "empty",
  724.                         'time'  => $_COOKIE["PIDCARDDUR"]
  725.                     );
  726.                     setCookie($cookie_info['name'], $cookie_info['value'], $cookie_info['time'],'/');
  727.                 }
  728.                 
  729.                 /*
  730.                 //Email Client
  731.         
  732.                 $siteweb = $this->container->getParameter('siteweb');
  733.                 $sitename = $this->container->getParameter('sitename');
  734.                 $emailadmin = $this->container->getParameter('emailadmin');
  735.                 if($panier->getUser() != null and $service->email($panier->getUser()->getUsername()))
  736.                 {
  737.                     $mail = new Afmail();
  738.                     $mail->setFrom($sitename.' <'.$emailadmin.'>'); 
  739.                     $mail->setSubject($panier->getUser()->name(25).', Votre commande ID: '.$panier->numFacture().' a été enregistrée avec succès !'); 
  740.                     $mail->setHTML($this->renderView('UsersUserBundle:User:envoiemail.html.twig', array('link'=>$siteweb.'/afh/card/bill/'.$panier->getId(),'nom'=>$panier->getUser()->name(25),'titre' => $panier->getUser()->name(25).', Votre commande ID: '.$panier->numFacture().' a été enregistrée avec succès !','contenu'=>'Votre commande sera validés dans de plus bref délais.</br> </br> Pour faciliter cette étape, procédez au transfert des frais de cette facture sur le compte choisi  ! </br></br> Vous pouvez à tout moment consulter l\'état de cette commande via le lien ci-dessous.')));
  741.                     $mail->setTextCharset('utf-8');
  742.                     $mail->setHTMLCharset('utf-8');
  743.                     $result = $mail->send(array($panier->getUser()->getUsername()));
  744.                 }
  745.                 
  746.                 
  747.                 //Notification client.
  748.                 $notification = new Notification($service);
  749.                 $notification->setUser($panier->getUser());
  750.                 $notification->setTitre($panier->getUser()->name(25).', Votre commande ID: '.$panier->numFacture().' a été enregistré avec succès !');
  751.                 $notification->setDescription('Votre commande sera validée dans de plus bref délais . </br> Pour faciliter cette étape, procédez au transfert des frais de cette facture sur le compte choisi.');
  752.                 $em->persist($notification);
  753.                 
  754.                 
  755.                 //Email Admin
  756.                 
  757.                 if($service->email($emailadmin))
  758.                 {
  759.                     $mail = new Afmail();
  760.                     $mail->setFrom($panier->getUser()->name(30).' <'.$panier->getUser()->getUsername().'>'); 
  761.                     $mail->setSubject($panier->getUser()->name(25).' a enregistré une nouvelle commande sur '.$sitename.' !'); 
  762.                     $mail->setHTML($this->renderView('UsersUserBundle:User:envoiemail.html.twig', array('link'=>$siteweb.'/packagewebsiteadmin/afh/track/bill','nom'=>'Team '.$sitename,'titre' => $panier->getUser()->name(25).' a enregistré une nouvelle commande sur '.$sitename.' !','contenu'=>'Cliquez sur le lien ci-dessous pour procéder à la validation de cette commande.')));
  763.                     $mail->setTextCharset('utf-8');
  764.                     $mail->setHTMLCharset('utf-8');
  765.                     $result = $mail->send(array($emailadmin));
  766.                 }
  767.                 
  768.                 */
  769.                 $em->flush();
  770.                 echo 1;
  771.                 exit;
  772.             }
  773.         }
  774.     }
  775.     echo 0;
  776.     exit;
  777. }
  778. public function downloadpanier(Panier $panier)
  779. {
  780.     $em $this->getDoctrine()->getManager();
  781.     if($panier->getPayer() == true)
  782.     {
  783.         $panier->setSousmis(true);
  784.         $em->flush();
  785.         $nameoffile '/../../../'.$panier->getWebPath();
  786.         return $this->redirect($nameoffile);
  787.     }else{
  788.         if($panier->getUser() != null)
  789.         {
  790.             $this->get('session')->getFlashBag()->add('information','Echec ! La facture de cette commande n\'est pas encore disponible.');
  791.             return $this->redirect($this->generateUrl('users_user_user_accueil', array('id'=>$panier->getUser()->getId(),'position'=>4)));
  792.         }else{
  793.             $this->get('session')->getFlashBag()->add('information','Echec ! La facture de cette commande n\'est pas encore disponible.');
  794.             return $this->redirect($this->generateUrl('users_user_acces_plateforme'));
  795.         }
  796.     }
  797. }
  798. }