src/Controller/APIIctus/ApiIctusCommandeController.php line 244

Open in your IDE?
  1. <?php
  2. namespace App\Controller\APIIctus;
  3. use App\Entity\User;
  4. use Psr\Log\LoggerInterface;
  5. use App\Entity\IctusCommande;
  6. use App\Services\FactureService;
  7. use App\Services\MailerServices;
  8. use App\Entity\IctusCommandeLine;
  9. use App\Entity\IctusTypePaiement;
  10. use App\Services\IctocoinService;
  11. use App\Repository\UserRepository;
  12. use App\Service\NotificationsService;
  13. use App\Services\NotificationService;
  14. use App\Entity\IctusHistoriquePaiement;
  15. use Doctrine\ORM\EntityManagerInterface;
  16. use App\Repository\TypepaiementRepository;
  17. use App\Repository\IctusCommandeRepository;
  18. use App\Repository\IctusPharmacieRepository;
  19. use Symfony\Component\HttpFoundation\Request;
  20. use Symfony\Component\Mailer\MailerInterface;
  21. use Symfony\Component\HttpFoundation\Response;
  22. use App\Repository\IctusEtatPaiementRepository;
  23. use App\Repository\IctusTypePaiementRepository;
  24. use Symfony\Component\Routing\Annotation\Route;
  25. use App\Repository\IctusMobileAppareilRepository;
  26. use Symfony\Component\HttpFoundation\JsonResponse;
  27. use App\Services\api\NotificationTwoPackagesService;
  28. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  29. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  30. /**
  31.  * @Route("/api_ictus/commande/patient/", name="api_ictus_commande_patient_")
  32.  */
  33. class ApiIctusCommandeController extends AbstractController
  34. {
  35.     private $em;
  36.     public function __construct(EntityManagerInterface $em)
  37.     {
  38.         $this->em $em;
  39.     }
  40.     /**
  41.      * @Route("liste/cmd/{user}", name="liste_cmd", methods={"GET"})
  42.      */
  43.     public function cmdListe(IctusCommandeRepository $commandeRepositoryUser $user): Response
  44.     {
  45.         $response = [
  46.             "error"   => true,
  47.             "message" => "Erreur lors de la recuperation des commandes"
  48.         ];
  49.         if ($user) {
  50.             $commandes    $commandeRepository->findBy(['user' => $user], ['createdAt' => 'DESC']);
  51.             $dataCmd      = [];
  52.             $allDataCommandes   = [];
  53.             foreach ($commandes as $cmd) {
  54.                 $paiementOnline null;
  55.                 $fraisPaiement null;
  56.                 if ($cmd->getTypePaiement()->getId() != 1) {
  57.                     $fraisPaiement 0;
  58.                     if ($cmd->getTypePaiement()->getId() == 4) {
  59.                         $fraisPaiement $this->pourcentageVanillaPay($cmd->getTotalCommande());
  60.                     }
  61.                     $paiementOnline = [
  62.                         'fraisVannilaPay' => $fraisPaiement,
  63.                         'montantPaiement' => $cmd->getTotalCommande() + $fraisPaiement,
  64.                         'apiUrlPaiement' => $this->generateUrl('api_ictus_paiement_payer_commande', ['commande' => $cmd->getId()], UrlGeneratorInterface::ABSOLUTE_URL)
  65.                     ];
  66.                 }
  67.                 $adresse $cmd->getPharmacie()->getAdresse() . ", " $cmd->getPharmacie()->getQuartier()->getName() . ", " $cmd->getPharmacie()->getQuartier()->getVille()->getName();
  68.                 $pharmacie = [
  69.                     'id'         => $cmd->getPharmacie()->getId(),
  70.                     'designation' => $cmd->getPharmacie()->getDesignation(),
  71.                     'adresse'    => $adresse
  72.                 ];
  73.                 $dataCmd = [
  74.                     'id'           => $cmd->getId(),
  75.                     'reference'    => "ICTCMD_MG_" $cmd->getPharmacie()->getId() . "_" $cmd->getReference(),
  76.                     'date'         => $cmd->getCreatedAt()->format('Y-m-d'),
  77.                     'paiement'     => $cmd->getTypePaiement()->getDesignation(),
  78.                     'livraison'    => $cmd->getTypeLivraison()->getDesignation(),
  79.                     'some_total'   => $cmd->getTotalCommande(),
  80.                     'total_produit'=> $cmd->getTotalProduit(),
  81.                     'isValid'      => $cmd->isIsValide(),
  82.                     'etat_recuperation'=> $cmd->isIsRecuperer()
  83.                 ];
  84.                 $allDataCommandes[] = [
  85.                     'commande' => $dataCmd,
  86.                     'paiement' => $paiementOnline,
  87.                     'pharmacie'=> $pharmacie
  88.                 ];
  89.             }
  90.             $response = [
  91.                 "success" => "Success",
  92.                 "allDataCommandes" => $allDataCommandes
  93.             ];
  94.         }
  95.         return new JsonResponse($response);
  96.     }
  97.     private function pourcentageVanillaPay($val)
  98.     {
  99.         $pourcentage 0;
  100.         switch (true) {
  101.             case ($val && $val <= 10000):
  102.                 $pourcentage 2;
  103.                 break;
  104.             case ($val 10000 && $val <= 20000):
  105.                 $pourcentage 1.75;
  106.                 break;
  107.             case ($val 20000 && $val <= 30000):
  108.                 $pourcentage 1.25;
  109.                 break;
  110.             case ($val 30000 && $val <= 50000):
  111.                 $pourcentage 1.5;
  112.                 break;
  113.             case ($val 50000 && $val <= 80000):
  114.                 $pourcentage 1.75;
  115.                 break;
  116.             case ($val 80000 && $val <= 120000):
  117.                 $pourcentage 1.5;
  118.                 break;
  119.             case ($val 120000 && $val <= 170000):
  120.                 $pourcentage 1.40;
  121.                 break;
  122.             case ($val 170000):
  123.                 $pourcentage 1.30;
  124.                 break;
  125.             default:
  126.                 $pourcentage 0;
  127.                 break;
  128.         }
  129.         return $val * (($pourcentage 100) / (- ($pourcentage 100)));
  130.     }
  131.     /**
  132.      * @Route("entente/{id}", name="listes", methods={"GET"})
  133.      */
  134.     public function cmdEntante(IctusCommandeRepository $commandeRepositoryUser $user): Response
  135.     {
  136.         $commandes $commandeRepository->findByMultipleIsValide(false$user->getIctusPharmacie());
  137.         $dataCmd = [];
  138.         foreach ($commandes as $cmd) {
  139.             $dataCmd[]       = [
  140.                 'id'         => $cmd->getId(),
  141.                 'reference'  => "ICTCMD_MG_" $cmd->getPharmacie()->getId() . "_" $cmd->getReference(),
  142.                 'date'       => $cmd->getCreatedAt()->format('d-m-Y'),
  143.                 'paiement'   => $cmd->getTypePaiement()->getDesignation(),
  144.                 'livraison'  => $cmd->getTypeLivraison()->getDesignation(),
  145.                 'montant'    => $cmd->getTotalCommande(),
  146.                 'totalProduit' => $cmd->getTotalProduit(),
  147.                 'isValid'     => $cmd->isIsValide(),
  148.                 'idPcie'      => $cmd->getPharmacie()->getId()
  149.             ];
  150.         }
  151.         return new JsonResponse($dataCmd);
  152.     }
  153.     /**
  154.      * @Route("valid/{id}", name="listes_valide", methods={"GET"})
  155.      */
  156.     public function cmdvalid(IctusCommandeRepository $commandeRepositoryUser $user): Response
  157.     {
  158.         $commandes $commandeRepository->findByMultipleIsValide(true$user->getIctusPharmacie());
  159.         $dataCmd = [];
  160.         foreach ($commandes as $cmd) {
  161.             $dataCmd[]       = [
  162.                 'id'         => $cmd->getId(),
  163.                 'reference'  => "ICTCMD_MG_" $cmd->getPharmacie()->getId() . "_" $cmd->getReference(),
  164.                 'date'       => $cmd->getCreatedAt()->format('d-m-Y'),
  165.                 'paiement'   => $cmd->getTypePaiement()->getDesignation(),
  166.                 'livraison'  => $cmd->getTypeLivraison()->getDesignation(),
  167.                 'montant'    => $cmd->getTotalCommande(),
  168.                 'totalProduit' => $cmd->getTotalProduit(),
  169.                 'isValid'     => $cmd->isIsValide(),
  170.                 'idPcie'      => $cmd->getPharmacie()->getId()
  171.             ];
  172.         }
  173.         return new JsonResponse($dataCmd);
  174.     }
  175.     /**
  176.      * @Route("detail/{id}", name="detail", methods={"GET"})
  177.      */
  178.     public function detail(IctusCommande $commande): Response
  179.     {
  180.         $dataCmd_produit = [];
  181.         $patient $commande->getUser();
  182.         $dataCmd_patient = [
  183.             'patientId'  => $patient->getId(),
  184.             'nomComplet' => $patient->getNomComplet(),
  185.             'telephone'  => $patient->getPhone(),
  186.             'mail'       => $patient->getEmail()
  187.         ];
  188.         $dataCmd = [];
  189.         foreach ($commande->getIctusCommandeLines() as $line) {
  190.             $total $line->getPrixunitaire() * $line->getQuantite();
  191.             $temp = [
  192.                 'id'           => $line->getId(),
  193.                 'designation'  => $line->getDesignation(),
  194.                 'pu'           => $line->getPrixunitaire(),
  195.                 'quantite'     => $line->getQuantite(),
  196.                 'total'        => $total,
  197.                 'isValid'      => $line->isIsValide()
  198.             ];
  199.             array_push($dataCmd_produit$temp);
  200.         }
  201.         $dataCmd = [
  202.             'id'          => $commande->getId(),
  203.             'reference'   => "ICTCMD_MG_" $commande->getPharmacie()->getId() . "_" $commande->getReference(),
  204.             'date'        => $commande->getCreatedAt()->format('d-m-Y'),
  205.             'paiement'    => $commande->getTypePaiement()->getDesignation(),
  206.             'livraison'   => $commande->getTypeLivraison()->getDesignation(),
  207.             'montant'     => $commande->getTotalCommande(),
  208.             'totalProduit' => $commande->getTotalProduit(),
  209.             'isValid'     => $commande->isIsValide(),
  210.             'isLivre'     => $commande->isIsLivrer(),
  211.             'etatpaiement' => $commande->getEtatpaiement()->getId(),
  212.             'designationPaiement'     => $commande->getEtatpaiement()->getDesignation(),
  213.             'typepepaiement'          => $commande->getTypePaiement()->getId(),
  214.             'designationtypepaiement' => $commande->getTypePaiement()->getDesignation(),
  215.             'detailCmd' => $dataCmd_produit,
  216.             'patient'   => $dataCmd_patient
  217.         ];
  218.         return new JsonResponse($dataCmd);
  219.     }
  220.     /**
  221.      * @Route("validation/{id}", name="validation_cmd", methods={"GET"})
  222.      */
  223.     public function editValidCmd(
  224.         IctusCommande $commande
  225.         IctocoinService $ictocoinService,
  226.          MailerServices $mailerServices
  227.          MailerInterface $mi,
  228.         FactureService $factureService,
  229.         NotificationTwoPackagesService $notificationPatientService,
  230.         IctusMobileAppareilRepository $mobileAppareilRepo
  231.     ): Response
  232.     {
  233.         $response = [
  234.             "error" => true,
  235.             "message" => "Erreur de la modification"
  236.         ];
  237.         if (!is_null($commande)) {
  238.             if ($commande->isIsValide() == false || $commande->isIsValide() == null) {
  239.                 $commande->setIsValide(true);
  240.                 //Itcoin et send email
  241.                 $factureService->editPatient($commande);
  242.                 $raison 'Profit Ictuspharma sur la commande du ' date("d M Y") . ', Référence :/cmd {{' $commande->getId() . '}}';
  243.                 $ictocoinService->debiter($commande->getPharmacie(), $commande->getTotalCommande(), $raison);
  244.                 $to           $commande->getUser()->getEmail();
  245.                 $from         "siteweb@ictuspharma.com";
  246.                 $subject      "VALIDATION COMMANDE";
  247.                 $templateMail 'emails/validationCommande.html.twig';
  248.                 $paramsMail = [
  249.                     'link'    => "https://ictuspharm.com/commande/historique/non-payer",
  250.                     'numeroCommande' => "ICT_CMD_" $commande->getId(),
  251.                     'pharmacy' => $commande->getPharmacie()->getDesignation()
  252.                 ];
  253.                 $mailerServices->send($mi$to$from$subject$templateMail$paramsMail);
  254.                 //FIn 
  255.                 $response = [
  256.                     "error" => false,
  257.                     "message" => "La commande a été validée avec succès."
  258.                 ];
  259.                 $notificationPatientService->pushNotification($commande$mobileAppareilRepo$subject);
  260.             } else {
  261.                 $commande->setIsValide(false);
  262.                 $response = [
  263.                     "error" => false,
  264.                     "message" => "Commande non valide"
  265.                 ];
  266.                 $notificationPatientService->pushNotification($commande$mobileAppareilRepo"Commande non valide");
  267.             }
  268.             $this->em->flush();
  269.         }
  270.         return new JsonResponse($response);
  271.     }
  272.     /**
  273.      * @Route("livrer/{id}", name="livrer_cmd", methods={"GET"})
  274.      */
  275.     public function validationLivraison(IctusCommande $commande): Response
  276.     {
  277.         $response = [
  278.             "error" => true,
  279.             "message" => "Erreur de la modification"
  280.         ];
  281.         if (!is_null($commande)) {
  282.             if ($commande->isIsLivrer() == false || $commande->isIsLivrer() == null) {
  283.                 $commande->setIsLivrer(true);
  284.                 $response = [
  285.                     "error" => false,
  286.                     "message" => "La commande a été livrée avec succès."
  287.                 ];
  288.             } else {
  289.                 $commande->setIsLivrer(false);
  290.                 $response = [
  291.                     "error" => false,
  292.                     "message" => "Commande non livrée"
  293.                 ];
  294.             }
  295.             $this->em->flush();
  296.         }
  297.         return new JsonResponse($response);
  298.     }
  299.     /**
  300.      * @Route("etat-paiement", name="list_paiements", methods={"GET"})
  301.      */
  302.     public function recupEtatPaiement(IctusEtatPaiementRepository $ictusEtatPaiementRepository): Response
  303.     {
  304.         $etats    $ictusEtatPaiementRepository->findAllAsc();
  305.         $dataEtats = [];
  306.         foreach ($etats as $etat) {
  307.             $dataEtats[]     = [
  308.                 'id'         => $etat->getId(),
  309.                 'designation' => $etat->getDesignation()
  310.             ];
  311.         }
  312.         return $this->json($dataEtats);
  313.     }
  314.     /**
  315.      * @Route("type-paiement", name="list_type_paiements", methods={"GET"})
  316.      */
  317.     public function recupTypePaiement(IctusTypePaiementRepository $ictusTypePaiementRepository): Response
  318.     {
  319.         $etats    $ictusTypePaiementRepository->findAllAsc();
  320.         $dataEtats = [];
  321.         foreach ($etats as $etat) {
  322.             $dataEtats[]     = [
  323.                 'id'         => $etat->getId(),
  324.                 'designation' => $etat->getDesignation()
  325.             ];
  326.         }
  327.         return $this->json($dataEtats);
  328.     }
  329.     /**
  330.      * @Route("edit-paiement/{id}", name="edit_paiement_cmd", methods={"POST"})
  331.      */
  332.     public function editEtatpaiement(IctusCommande $commandeRequest $requestIctusEtatPaiementRepository $etatPaiementrepoIctusTypePaiementRepository $tpRepo): Response
  333.     {
  334.         $response = [
  335.             "error" => true,
  336.             "message" => "Erreur de la modification"
  337.         ];
  338.         if (!is_null($commande)) {
  339.             if ($request->get("etatpaiement") != null) {
  340.                 $etatPaiement $etatPaiementrepo->findOneById($request->get("etatpaiement"));
  341.                 //Creation historique 
  342.                 $typePaiement $tpRepo->findOneById($request->get('typepepaiement'));
  343.                 $historique = new IctusHistoriquePaiement();
  344.                 $historique->setMontant($request->get('montant'))->setCommande($commande);
  345.                 if ($typePaiement instanceof IctusTypePaiement) {
  346.                     $historique->setIctusTypePaiement($typePaiement);
  347.                 }
  348.                 $this->em->persist($historique);
  349.                 //Fin creation historique
  350.                 if (!is_null($etatPaiement)) {
  351.                     $commande->setEtatpaiement($etatPaiement);
  352.                     $response = [
  353.                         "error" => false,
  354.                         "message" => "Etat paiement a été modifiée avec succès."
  355.                     ];
  356.                 } else {
  357.                     $response = [
  358.                         "error" => false,
  359.                         "message" => "Etat paiement non trouvé"
  360.                     ];
  361.                 }
  362.                 $this->em->flush();
  363.             } else {
  364.                 $response = [
  365.                     "error" => false,
  366.                     "message" => "Etat paiement null"
  367.                 ];
  368.             }
  369.         }
  370.         return new JsonResponse($response);
  371.     }
  372.     /**
  373.      * @Route("detail-qrCode/{code}/{codeSecret}/{idUser}", name="detail_qr_code", methods={"GET"})
  374.      */
  375.     public function detailQrCode(IctusCommandeRepository $ictusCommandeRepositoryUserRepository $userRepository$code$codeSecret$idUser): Response
  376.     {
  377.         $user             $userRepository->findOneById($idUser);
  378.         $pharmacie        null;
  379.         if (!is_null($user)) {
  380.             $pharmacie        $user->getIctusPharmacie();
  381.         }
  382.         if (!is_null($pharmacie)) {
  383.             $pharmacie $pharmacie->getId();
  384.         }
  385.         $commande         =  $ictusCommandeRepository->findOneBy([
  386.             'code'        => $code,
  387.             'codeSecret'  => $codeSecret,
  388.             'pharmacie'   => $pharmacie
  389.         ]);
  390.         $dataCmd_produit  = [];
  391.         $dataCmd          = [];
  392.         $patient          $commande->getUser();
  393.         $dataCmd_patient  = [
  394.             'patientId'  => $patient->getId(),
  395.             'nomComplet' => $patient->getNomComplet(),
  396.             'nomComplet' => $patient->getNomComplet(),
  397.             'telephone'  => $patient->getPhone(),
  398.             'mail'       => $patient->getEmail()
  399.         ];
  400.         foreach ($commande->getIctusCommandeLines() as $line) {
  401.             $total $line->getPrixunitaire() * $line->getQuantite();
  402.             $temp = [
  403.                 'id'           => $line->getId(),
  404.                 'designation'  => $line->getDesignation(),
  405.                 'pu'           => $line->getPrixunitaire(),
  406.                 'quantite'     => $line->getQuantite(),
  407.                 'total'        => $total
  408.             ];
  409.             array_push($dataCmd_produit$temp);
  410.         }
  411.         $dataCmd = [
  412.             'id'          => $commande->getId(),
  413.             'reference'   => "ICTCMD_MG_" $commande->getPharmacie()->getId() . "_" $commande->getReference(),
  414.             'date'        => $commande->getCreatedAt()->format('d-m-Y'),
  415.             'paiement'    => $commande->getTypePaiement()->getDesignation(),
  416.             'livraison'   => $commande->getTypeLivraison()->getDesignation(),
  417.             'montant'     => $commande->getTotalCommande(),
  418.             'totalProduit' => $commande->getTotalProduit(),
  419.             'isValid'     => $commande->isIsValide(),
  420.             'isLivre'     => $commande->isIsLivrer(),
  421.             'etatpaiement' => $commande->getEtatpaiement()->getId(),
  422.             'designationPaiement'     => $commande->getEtatpaiement()->getDesignation(),
  423.             'typepepaiement'          => $commande->getTypePaiement()->getId(),
  424.             'designationtypepaiement' => $commande->getTypePaiement()->getDesignation(),
  425.             'detailCmd' => $dataCmd_produit,
  426.             'patient'   => $dataCmd_patient
  427.         ];
  428.         return new JsonResponse($dataCmd);
  429.     }
  430.     /**
  431.      * @Route("edit-comandeproduit/{id}", methods={"POST"})
  432.      */
  433.     public function editCommadeProduit(IctusCommandeLine $commandeLileRequest $request)
  434.     {
  435.         $response = [
  436.             "error" => true,
  437.             "message" => "Erreur de la modification"
  438.         ];
  439.         if (!is_null($commandeLile)) {
  440.             if (!is_null($request->get('quantite'))) {
  441.                 $commandeLile->setQuantite($request->get('quantite'));
  442.             }
  443.             if (!is_null($request->get('pu'))) {
  444.                 $commandeLile->setPrixunitaire($request->get('pu'));
  445.             }
  446.             if (!is_null($request->get('isValid'))) {
  447.                 if ($commandeLile->isIsValide() == false || $commandeLile->isIsValide() == null) {
  448.                     $commandeLile->setIsValide(true);
  449.                 } else {
  450.                     $commandeLile->setIsValide(false);
  451.                 }
  452.             }
  453.             $response = [
  454.                 "error"   => false,
  455.                 "message" => "Modification avec succees"
  456.             ];
  457.             $this->em->flush();
  458.         } else {
  459.             $response = [
  460.                 "error"   => false,
  461.                 "message" => "Produit non trouvé"
  462.             ];
  463.         }
  464.         return new JsonResponse($response);
  465.     }
  466.     /**
  467.      * @Route("envoie-notification-cmdnonvalid", methods={"GET"})
  468.      */
  469.     public function sendNotificationCmdNonValide(IctusCommandeRepository $ictusCommandeRepositoryNotificationService $notificationServiceIctusMobileAppareilRepository $mobileAppareilRepo)
  470.     {
  471.         $response = [
  472.             "error" => true,
  473.             "message" => "Erreur de la modification"
  474.         ];
  475.         $commandes $ictusCommandeRepository->findAllNonValide();
  476.         if (!is_null($commandes)) {
  477.             //Envoie notification dans dans android Pcie
  478.             foreach ($commandes as $cmd) {
  479.                 $user_pcie       $cmd->getPharmacie()->getUsers()[0];
  480.                 $mobileAppareils $mobileAppareilRepo->findAllToArray($user_pcie);
  481.                 $array_cfm_token array_unique((array_column($mobileAppareils"cfm_tokem"))); //array_column trasform tableau associative en array simple
  482.                 //$fcmToken      = $user_pcie->getFcmToken();
  483.                 if (count($array_cfm_token) > 0) {
  484.                     $data = [
  485.                         'id_commande'  => intval($cmd->getId()),
  486.                         'id_pharmacie' => intval($cmd->getPharmacie()->getId()),
  487.                         'reference'    => $cmd->getReference()
  488.                     ];
  489.                     foreach ($array_cfm_token as $token) {
  490.                         if ($token != ""
  491.                         $notificationService->sendNotification($token'Commande pas encore validée''Référence commande ICTCMD_MG_' intval($cmd->getPharmacie()->getId()) . '_' $cmd->getReference(), $data);
  492.                     }
  493.                 }
  494.             }
  495.             //Fin envoie notification
  496.             $response = [
  497.                 "error" => false,
  498.                 "message" => "OKOK"
  499.             ];
  500.         }
  501.         return new JsonResponse($response);
  502.     }
  503.     //*******************************************************
  504.      //************************COMPTE PATIENT****************** 
  505.      //* *****************************************************
  506.     /**
  507.      * @Route("detail-cmd-patient/{id}", name="detail_commade_patient", methods={"GET"})
  508.      */
  509.     public function detailCommande(IctusCommande $commande): Response
  510.     {
  511.         $response = [
  512.             "error" => true,
  513.             "message" => "Erreur de la modification"
  514.         ];
  515.         $allDataCommandes = [];
  516.         if ($commande) {
  517.             //COMMANDE
  518.             $dataCommande = [
  519.                 'id'                => $commande->getId(),
  520.                 'reference'         => "ICTCMD_MG_".$commande->getPharmacie()->getId()."_"$commande->getReference(),
  521.                 'date_livraison'    => $commande->getDateLivraison() ? $commande->getDateLivraison()->format("d-m-Y"):"null",
  522.                 'date_creation'     => $commande->getCreatedAt()->format('d-M-Y H:i'),
  523.                 'etat_paiement'     => $commande->getEtatpaiement()->getDesignation(),
  524.                 'etat_commande'     => $commande->isIsValide(),
  525.                 'etat_livraison'    => $commande->isIsRecuperer(),
  526.                 'code_recuperation' => $commande->getCode().$commande->getCodeSecret(),
  527.                 'some_total'        => $commande->getTotalCommande(),
  528.                 'total_produit'     => $commande->getTotalProduit(),
  529.                 'type_paiement'     => $commande->getTypePaiement()->getDesignation()
  530.             ];
  531.             //FIN
  532.             //PCIE
  533.             $pcie     $commande->getPharmacie();
  534.             $dataPcie = [];
  535.             if($pcie){
  536.                 $dataPcie[] = [
  537.                     'id'          => $pcie->getId(),
  538.                     'designation' => $pcie->getDesignation(),
  539.                     'logo'        => $pcie->getLogo(),
  540.                     'adresse'     => $pcie->getAdresse(),
  541.                     'ville'       => $pcie->getQuartier()->getVille()->getName(),
  542.                     'quartier'    => $pcie->getQuartier()->getName()
  543.                 ];
  544.             }
  545.             //FIN PCIE
  546.             //LIVRAISON
  547.             $livraison          $commande->getTypeLivraison();
  548.             $dataTypeLivraison  = [];
  549.             if($livraison){
  550.                 $dataTypeLivraison = [];
  551.                 if($livraison){
  552.                     $dataTypeLivraison[] = [
  553.                         'id'          => $livraison->getId(),
  554.                         'designation' => $livraison->getDesignation()
  555.                     ];
  556.                 }
  557.             }
  558.             //Fin livraison
  559.             //PAIEMENT
  560.             $paiement $commande->getTypePaiement();
  561.             $dataPaiement  = [];
  562.             if($paiement){
  563.                 $dataPaiement = [];
  564.                 if($paiement){
  565.                     $dataPaiement[] = [
  566.                         'id'          => $paiement->getId(),
  567.                         'designation' => $paiement->getDesignation()
  568.                     ];
  569.                 }
  570.             }
  571.             //FIN
  572.             //Produit
  573.             $produits $commande->getIctusCommandeLines();
  574.             $dataProduit = [];
  575.             if(count($produits) > 0){
  576.                 foreach ($produits as  $produit) {
  577.                     $dataProduit[]= [
  578.                         'stockid'        => $produit->getId(),
  579.                         'isOrdonnance'   => $produit->getOrdonnance() ? true false,
  580.                         'nomproduit'     => $produit->getDesignation(),
  581.                         'prixunitforme'  => $produit->getPrixunitaire(),
  582.                         'quantity_panier' => $produit->getQuantite(),
  583.                         'prixTotal'      => $produit->getQuantite() * $produit->getPrixunitaire()
  584.                     ];
  585.                 }
  586.             }
  587.             //Fin Produit
  588.             $allDataCommandes = [
  589.                 'commande' => $dataCommande,
  590.                 'pharmacie'=> $dataPcie,
  591.                 'paiement' => $dataPaiement,
  592.                 'livraison'=> $dataTypeLivraison,
  593.                 'produit'  => $dataProduit
  594.             ];
  595.             $response = [
  596.                 "success" => "Success",
  597.                 "allDataCommandes" => $allDataCommandes
  598.             ];
  599.         }
  600.         
  601.         return new JsonResponse($response);
  602.     }
  603.     /**
  604.      * @Route("recuperee/{id}", name="recuperee", methods={"POST"})
  605.      */
  606.     public function recupererCommande(IctusCommande $commande):Response
  607.     {
  608.         $response = [
  609.             "error" => true,
  610.             "message" => "Erreur de la modification"
  611.         ];
  612.         if($commande){
  613.             $commande->setIsRecuperer(true);
  614.             $this->em->flush();
  615.             $response = [
  616.                 "success" => "Success",
  617.                 "message" => "Commande récupérée avec succès"
  618.             ];
  619.         }
  620.         return new JsonResponse($response);
  621.     }
  622. }