src/Controller/DefaultController.php line 41

Open in your IDE?
  1. <?php
  2. // src/Controller/DefaultController.php
  3. namespace App\Controller;
  4. use App\Entity\HistoryUpdate;
  5. use App\Entity\Products;
  6. use App\Entity\Tickets;
  7. use App\Entity\StocksHistory;
  8. use App\Service\HttpService;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\Routing\Annotation\Route;
  11. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  12. use App\Entity\PointsOfSale;
  13. use Doctrine\ORM\EntityManagerInterface;
  14. class DefaultController extends AbstractController
  15. {
  16.     private $httpService;
  17.     private $em;
  18.     public function __construct(HttpService  $httpService,EntityManagerInterface $em)
  19.     {
  20.         $this->httpService $httpService;
  21.         $this->em $em;
  22.     }
  23.     /**
  24.      * @Route("/")
  25.      */
  26.     public function index(): Response
  27.     {
  28.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  29.         $message $this->httpService->getHappyMessage();
  30.         $user $this->getUser();
  31.         return $this->render('default/index.html.twig', [
  32.             'message' => $message,
  33.             'user'=> $user
  34.         ]);
  35.     }
  36.     /**
  37.      * @Route("/home")
  38.      */
  39.     public function home(): Response
  40.     {
  41.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  42.         $user $this->getUser();
  43.         $message $this->httpService->getHappyMessage();
  44.         return $this->render('default/index.html.twig', [
  45.             'message' => $message,
  46.             'user'=> $user
  47.         ]);
  48.     }
  49.      /**
  50.      * @Route("/history", name="update_history")
  51.      */
  52.     public function history(): Response
  53.     {
  54.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  55.         $historyUpdates $this->em->getRepository('App\Entity\HistoryUpdate')->findBy(array(), array('id' => 'DESC'), 300);
  56.         //var_dump($historyUpdate);die;
  57.         return $this->render('default/history.html.twig', [
  58.             'historyUpdates' => $historyUpdates,
  59.         ]);
  60.     }
  61.     /**
  62.      * @Route("/ticket-history/{PointsOfSale}/{annee}", name="ticket_history")
  63.      */
  64.     public function tickets($PointsOfSalenull$annee'2022'): Response
  65.     {
  66.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  67.         $pointsOfSale =null;
  68.         if($PointsOfSale){
  69.             $pointsOfSale $this->em->getRepository('App\Entity\PointsOfSale')->findOneBy([
  70.                 'idCashmag' => $PointsOfSale
  71.             ]);
  72.         }
  73.         $allPointOfSales $this->em->getRepository('App\Entity\PointsOfSale')->findAll();
  74.        
  75.         $allHistoryUpdate $this->em->getRepository('App\Entity\HistoryUpdate')->findBy([
  76.             'entityName' => "TicketHistory"
  77.         ]);
  78.         $alereadyDone =[];
  79.         foreach($allHistoryUpdate as $HistoryUpdate){
  80.             $comment json_decode($HistoryUpdate->getComment());
  81.             if($comment){
  82.                 if(isset($comment->mois) AND $comment->idPointofSale == $PointsOfSale){
  83.                     $alereadyDone[]=$comment->mois;
  84.                 }
  85.             }
  86.         }
  87.         //var_dump($alereadyDone); die;
  88.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  89.         //$historyUpdates = $this->em->getRepository('App\Entity\HistoryUpdate')->findBy(array(), array('id' => 'DESC'), 30, 0);
  90.         //var_dump($historyUpdate);die;
  91.         return $this->render('default/ticket.html.twig', [
  92.             'allPointOfSales' => $allPointOfSales,
  93.             'pointsOfSale' => $pointsOfSale,
  94.             'alereadyDone' => $alereadyDone
  95.         ]);
  96.     }
  97.     /**
  98.      * @Route("/product-stock-history", name="point_vente_stock_history")
  99.      */
  100.     public function pointVenteStockHistory(): Response
  101.     {
  102.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  103.         $allPointOfSales $this->em->getRepository('App\Entity\PointsOfSale')->findAll();
  104.         $allHistoryUpdate $this->em->getRepository('App\Entity\HistoryUpdate')->findBy([
  105.             'entityName' => "StocksHistory"
  106.         ]);
  107.         $alereadyDone =[];
  108.         $dateMAJ = [];
  109.         foreach($allHistoryUpdate as $HistoryUpdate){
  110.             $comment json_decode($HistoryUpdate->getComment());
  111.             if($comment){
  112.                 $alereadyDone[]=$comment->idPointofSale;
  113.                 $dateMAJ[$comment->idPointofSale] = $HistoryUpdate->getEndDate();
  114.             }
  115.         }
  116.         return $this->render('default/point-vente.html.twig', [
  117.             'allPointOfSales' => $allPointOfSales,
  118.             'alereadyDone' => $alereadyDone,
  119.             'dateMAJ'=> $dateMAJ
  120.         ]);
  121.     }
  122.     /**
  123.      * @Route("/point-de-vente", name="point_de_vente")
  124.      */
  125.     public function pointDeVente(): Response
  126.     {
  127.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  128.         $historyUpdate = new HistoryUpdate();
  129.         $historyUpdate->setEntityName('PointsOfSale');
  130.         $historyUpdate->setComment('Import Manuelle');
  131.         $historyUpdate->setStartDate(new \DateTime());
  132.         $this->em->persist($historyUpdate);
  133.         $this->em->flush();
  134.         try{
  135.             //do stuff here
  136.             $reponse $this->httpService->getListPointOfSales();
  137.             foreach($reponse['list'] as $pointDeVente){
  138.                 $pointsOfSale $this->em->getRepository('App\Entity\PointsOfSale')->findOneBy([
  139.                     'idCashmag' => $pointDeVente['id']
  140.                 ]);
  141.                 if($pointsOfSale == null){
  142.                     $pointsOfSale = new PointsOfSale();
  143.                     $pointsOfSale->setIdCashmag($pointDeVente['id']);
  144.                     $pointsOfSale->setIdCountry($pointDeVente['id_country']);
  145.                     $pointsOfSale->setName($pointDeVente['name']);
  146.                     $pointsOfSale->setNameWebshop($pointDeVente['name_webshop']);
  147.                     $pointsOfSale->setAddress($pointDeVente['address']);
  148.                     $pointsOfSale->setCity($pointDeVente['city']);
  149.                     $pointsOfSale->setCompanyIdentification($pointDeVente['company_identification']);
  150.                     $pointsOfSale->setEnableCredit($pointDeVente['enable_credit']);
  151.                     $pointsOfSale->setEnableOrder($pointDeVente['enable_order']);
  152.                     $pointsOfSale->setHasAlcool($pointDeVente['has_alcool']);
  153.                     $pointsOfSale->setLegalForm($pointDeVente['legal_form']);
  154.                     $pointsOfSale->setPhone($pointDeVente['phone']);
  155.                     $pointsOfSale->setPhone2($pointDeVente['phone_2']);
  156.                     $pointsOfSale->setPostal($pointDeVente['postal']);
  157.                     $pointsOfSale->setWebshopDisplayMode($pointDeVente['webshop_display_mode']);
  158.                     $pointsOfSale->setWebsite($pointDeVente['website']);
  159.                     $this->em->persist($pointsOfSale);
  160.                     $this->em->flush();
  161.                 }
  162.             }
  163.             $historyUpdate->setEndDate(new \DateTime());
  164.             $this->em->persist($historyUpdate);
  165.             $this->em->flush();
  166.         }
  167.         catch(\Exception $e){
  168.             //error_log($e->getMessage());
  169.             $historyUpdate->setEndDate(new \DateTime());
  170.             $historyUpdate->setComment($e->getMessage());
  171.             $this->em->persist($historyUpdate);
  172.             $this->em->flush();
  173.         }
  174.         
  175.         $this->addFlash('success''Liste des points de vente mise à jour!');
  176.         $message $this->httpService->getHappyMessage();
  177.         return $this->render('default/index.html.twig', [
  178.             'message' => $message,
  179.         ]);
  180.     }
  181.     /**
  182.      * @Route("/remplis-produits", name="fill_products")
  183.      */
  184.     public function products(): Response
  185.     {
  186.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  187.         $historyUpdate = new HistoryUpdate();
  188.         $historyUpdate->setEntityName('Products');
  189.         $historyUpdate->setComment('Import Manuelle');
  190.         $historyUpdate->setStartDate(new \DateTime());
  191.         $this->em->persist($historyUpdate);
  192.         $this->em->flush();
  193.         //$historyUpdate->getId();
  194.         try{
  195.             //do stuff here
  196.             $allPointOfSales $this->em->getRepository('App\Entity\PointsOfSale')->findAll();
  197.             foreach($allPointOfSales as $pointOfSales){
  198.                 $idPointofSale $pointOfSales->getIdCashmag();
  199.                 $listproducts $this->httpService->getListproductsByPointOfSales($idPointofSale);
  200.                 //var_dump( $listproducts); die;
  201.                 foreach($listproducts['list'] as $product){
  202.                     $Products $this->em->getRepository('App\Entity\Products')->findOneBy([
  203.                         'idCashmag' => $product['id']
  204.                     ]);
  205.                     if($Products == null){
  206.                         $dobReconverted null;//\DateTime::createFromFormat('Y-m-d H:i:s', $product['date']); 
  207.                         $Products = new Products();
  208.                         $Products->setIdCashmag($product['id']);
  209.                         $Products->setShortName(mb_convert_encoding($product['short_name'], 'HTML-ENTITIES''UTF-8'));
  210.                         $Products->setName(mb_convert_encoding($product['name'], 'HTML-ENTITIES''UTF-8'));
  211.                         $Products->setOrderName($product['order_name']);
  212.                         $Products->setVolume($product['volume']);
  213.                         $Products->setWeight($product['weight']);
  214.                         $Products->setPrices(json_encode($product['prices']));
  215.                         $Products->setCostPrice($product['cost_price']);
  216.                         $Products->setMinimumStock($product['minimum_stock']);
  217.                         $Products->setEnableComment($product['enable_comment']);
  218.                         $Products->setExpiration($dobReconverted);// erreur changer entity en bool et ajouter date 
  219.                         $Products->setFidelityPoints($product['fidelity_points']);
  220.                         $Products->setPoints($product['points']);
  221.                         $Products->setOptionalSelection($product['optional_selection']);
  222.                         $Products->setDescription($product['description']);
  223.                         $Products->setBlocked($product['blocked']);
  224.                         $Products->setFreePrice($product['free_price']);
  225.                         $Products->setProductType($product['product_type']);
  226.                         $Products->setBarcodes(json_encode($product['barcodes']));
  227.                         $Products->setArchive($product['archive']);
  228.                         $this->em->persist($Products);
  229.                         $this->em->flush();
  230.                     }
  231.                 }
  232.             }
  233.             $historyUpdate->setEndDate(new \DateTime());
  234.             $this->em->persist($historyUpdate);
  235.             $this->em->flush();
  236.         }
  237.         catch(\Exception $e){
  238.             //error_log($e->getMessage());
  239.             $historyUpdate->setEndDate(new \DateTime());
  240.             $historyUpdate->setComment($e->getMessage());
  241.             $this->em->persist($historyUpdate);
  242.             $this->em->flush();
  243.         }
  244.         $this->addFlash('success''Liste des Produits mise à jour!');
  245.         $message $this->httpService->getHappyMessage();
  246.         return $this->render('default/index.html.twig', [
  247.             'message' => $message,
  248.         ]);
  249.     }
  250.     /**
  251.      * @Route("/stock-history-produits", name="fill_stock_history_products")
  252.      */
  253.     public function productsStockHistory(): Response
  254.     {
  255.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  256.         $historyUpdate = new HistoryUpdate();
  257.         $historyUpdate->setEntityName('StocksHistory');
  258.         $historyUpdate->setComment('Import Manuelle');
  259.         $historyUpdate->setStartDate(new \DateTime());
  260.         $this->em->persist($historyUpdate);
  261.         $this->em->flush();
  262.         //$historyUpdate->getId();
  263.         try{
  264.             $allPointOfSales $this->em->getRepository('App\Entity\PointsOfSale')->findAll();
  265.             foreach($allPointOfSales as $pointOfSales){
  266.                 $idPointofSale $pointOfSales->getIdCashmag();
  267.                 $listproducts $this->httpService->getListproductsByPointOfSales($idPointofSale);
  268.                 //var_dump( $listproducts); die;
  269.                 foreach($listproducts['list'] as $product){
  270.                     $Products $this->em->getRepository('App\Entity\Products')->findOneBy([
  271.                         'idCashmag' => $product['id']
  272.                     ]);
  273.                     if($Products == null){
  274.                         $dobReconverted null;//\DateTime::createFromFormat('Y-m-d H:i:s', $product['date']); 
  275.                         $Products = new Products();
  276.                         $Products->setIdCashmag($product['id']);
  277.                         $Products->setShortName(mb_convert_encoding($product['short_name'], 'HTML-ENTITIES''UTF-8'));
  278.                         $Products->setName(mb_convert_encoding($product['name'], 'HTML-ENTITIES''UTF-8'));
  279.                         $Products->setOrderName($product['order_name']);
  280.                         $Products->setVolume($product['volume']);
  281.                         $Products->setWeight($product['weight']);
  282.                         $Products->setPrices(json_encode($product['prices']));
  283.                         $Products->setCostPrice($product['cost_price']);
  284.                         $Products->setMinimumStock($product['minimum_stock']);
  285.                         $Products->setEnableComment($product['enable_comment']);
  286.                         $Products->setExpiration($dobReconverted);// erreur changer entity en bool et ajouter date 
  287.                         $Products->setFidelityPoints($product['fidelity_points']);
  288.                         $Products->setPoints($product['points']);
  289.                         $Products->setOptionalSelection($product['optional_selection']);
  290.                         $Products->setDescription($product['description']);
  291.                         $Products->setBlocked($product['blocked']);
  292.                         $Products->setFreePrice($product['free_price']);
  293.                         $Products->setProductType($product['product_type']);
  294.                         $Products->setBarcodes(json_encode($product['barcodes']));
  295.                         $Products->setArchive($product['archive']);
  296.                         $this->em->persist($Products);
  297.                         $this->em->flush();
  298.                     }
  299.                     ///////////////////remplissage stock Hitory///////////////////
  300.                     //$listHistoryproducts = $this->httpService->getStockHystoryProductsByPointOfSales(180192, 9102645);
  301.                     $listHistoryproducts $this->httpService->getStockHystoryProductsByPointOfSales($idPointofSale$product['id']);
  302.                     $listHistoryproducts $listHistoryproducts["list"];
  303.                     usort($listHistoryproducts, function($a$b) {
  304.                         return $a['date'] <=> $b['date'];//by date ASC
  305.                     });
  306.                     //var_dump($listHistoryproducts); die;
  307.                     foreach($listHistoryproducts as $historyproduct){
  308.                         $existe $this->em->getRepository('App\Entity\StocksHistory')->findOneBy([
  309.                             'idCashmag' => $historyproduct['id']
  310.                         ]);
  311.                         if($existe == null){
  312.                             $stocksHistory = new StocksHistory();
  313.                             $stocksHistory->setIdCashmag($historyproduct['id']);
  314.                             $stocksHistory->setIdPointOfSale($idPointofSale);
  315.                             $stocksHistory->setIdProduct($historyproduct['id_product']);//id produit cashmag
  316.                             $stocksHistory->setNewQuantityDecimal($historyproduct['new_quantity_decimal']);
  317.                             $stocksHistory->setQuantityDecimal($historyproduct['quantity_decimal']);
  318.                             $stocksHistory->setParts($historyproduct['parts']);
  319.                             $stocksHistory->setArchive($historyproduct['archive']);
  320.                             $stocksHistory->setType($historyproduct['type']);
  321.                             $stocksHistory->setDate(\DateTime::createFromFormat('Y-m-d H:i:s'$historyproduct['date']));
  322.                             $stocksHistory->setComment($historyproduct['comment']);
  323.                             if($historyproduct['stock_date'] != "0000-00-00 00:00:00"){
  324.                                 $stocksHistory->setStockDate(\DateTime::createFromFormat('Y-m-d H:i:s'$historyproduct['stock_date']));
  325.                             }
  326.                         
  327.                             if (array_key_exists('type_text'$historyproduct))
  328.                             {
  329.                                 $stocksHistory->setTypeText($historyproduct['type_text']);
  330.                             }
  331.                             $this->em->persist($stocksHistory);
  332.                         }
  333.                     }
  334.                     $this->em->flush();
  335.                 }
  336.             }
  337.             $historyUpdate->setEndDate(new \DateTime());
  338.             $this->em->persist($historyUpdate);
  339.             $this->em->flush();
  340.         }
  341.         catch(\Exception $e){
  342.             //error_log($e->getMessage());
  343.             $historyUpdate->setEndDate(new \DateTime());
  344.             $historyUpdate->setComment($e->getMessage());
  345.             $this->em->persist($historyUpdate);
  346.             $this->em->flush();
  347.         }
  348.         $this->addFlash('success''Liste Historique des Produits par point de vente mise à jour!');
  349.         $message $this->httpService->getHappyMessage();
  350.         return $this->render('default/index.html.twig', [
  351.             'message' => $message,
  352.         ]);
  353.     }
  354.     /**
  355.      * @Route("/stock-history-point-of-sale", name="fill_stock_history_point_of_sale")
  356.      */
  357.     public function pointOfSaleStockHistory(): Response
  358.     {
  359.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  360.         $historyUpdate = new HistoryUpdate();
  361.         $historyUpdate->setEntityName('StocksHistory');
  362.         $historyUpdate->setComment('Import Manuelle');
  363.         $historyUpdate->setStartDate(new \DateTime());
  364.         $this->em->persist($historyUpdate);
  365.         $this->em->flush();
  366.         //$historyUpdate->getId();
  367.         try{
  368.             $allPointOfSales $this->em->getRepository('App\Entity\PointsOfSale')->findAll();
  369.             foreach($allPointOfSales as $pointOfSales){
  370.                 $idPointofSale $pointOfSales->getIdCashmag();
  371.                 $limit 5000;
  372.                 $offset 0;
  373.                 $i 1;
  374.                 do{
  375.                     ///////////////////remplissage stock Hitory///////////////////
  376.                     //$listHistoryproducts = $this->httpService->getStockHystoryProductsByPointOfSales(180192, 9102645);
  377.                     $listHistoryproducts $this->httpService->getStockHystoryByPointOfSales($idPointofSale$limit$offset);
  378.                     //var_dump($listHistoryproducts); die;
  379.                     $listHistoryproducts $listHistoryproducts["list"];
  380.                     usort($listHistoryproducts, function($a$b) {
  381.                         return $a['date'] <=> $b['date'];//by date ASC
  382.                     });
  383.                     //var_dump($listHistoryproducts); die;
  384.                     foreach($listHistoryproducts as $historyproduct){
  385.                         $existe $this->em->getRepository('App\Entity\StocksHistory')->findOneBy([
  386.                             'idCashmag' => $historyproduct['id']
  387.                         ]);
  388.                         if($existe == null){
  389.                             $stocksHistory = new StocksHistory();
  390.                             $stocksHistory->setIdCashmag($historyproduct['id']);
  391.                             $stocksHistory->setIdPointOfSale($idPointofSale);
  392.                             $stocksHistory->setIdProduct($historyproduct['id_product']);//id produit cashmag
  393.                             $stocksHistory->setNewQuantityDecimal($historyproduct['new_quantity_decimal']);
  394.                             $stocksHistory->setQuantityDecimal($historyproduct['quantity_decimal']);
  395.                             $stocksHistory->setParts($historyproduct['parts']);
  396.                             $stocksHistory->setArchive($historyproduct['archive']);
  397.                             $stocksHistory->setType($historyproduct['type']);
  398.                             $stocksHistory->setDate(\DateTime::createFromFormat('Y-m-d H:i:s'$historyproduct['date']));
  399.                             $stocksHistory->setComment($historyproduct['comment']);
  400.                             if($historyproduct['stock_date'] != "0000-00-00 00:00:00"){
  401.                                 $stocksHistory->setStockDate(\DateTime::createFromFormat('Y-m-d H:i:s'$historyproduct['stock_date']));
  402.                             }
  403.                         
  404.                             if (array_key_exists('type_text'$historyproduct))
  405.                             {
  406.                                 $stocksHistory->setTypeText($historyproduct['type_text']);
  407.                             }
  408.                             $this->em->persist($stocksHistory);
  409.                         }
  410.                     }
  411.                     $this->em->flush();
  412.                     $i++;
  413.                     $offset $limit $i;
  414.                 }while (count($listHistoryproducts) > 0);
  415.                 //error_log($e->getMessage());
  416.                 $historyUpdate->setEndDate(new \DateTime());
  417.                 $history= [];
  418.                 $history["Offset"] = $offset;
  419.                 $history["idPointofSale"] = $idPointofSale;
  420.                 $history["type"] = "MANUAL";
  421.                 $historyUpdate->setComment(json_encode($history));
  422.                 $this->em->persist($historyUpdate);
  423.                 $this->em->flush();
  424.                 $this->addFlash('success''Liste Historique des Produits pour point de vente  '.$idPointofSale.'  mise à jour!');
  425.                 return $this->render('default/index.html.twig', [
  426.                     'message' => 'Liste Historique des Produits pour point de vente  '.$idPointofSale.'  mise à jour!',
  427.                 ]);
  428.             }
  429.             $historyUpdate->setEndDate(new \DateTime());
  430.             $this->em->persist($historyUpdate);
  431.             $this->em->flush();
  432.         }
  433.         catch(\Exception $e){
  434.             //error_log($e->getMessage());
  435.             $historyUpdate->setEndDate(new \DateTime());
  436.             $historyUpdate->setComment($e->getMessage());
  437.             $this->em->persist($historyUpdate);
  438.             $this->em->flush();
  439.         }
  440.         $this->addFlash('success''Liste Historique des Produits par point de vente mise à jour!');
  441.         $message $this->httpService->getHappyMessage();
  442.         return $this->render('default/index.html.twig', [
  443.             'message' => $message,
  444.         ]);
  445.     }
  446.      /**
  447.      * @Route("/history-ticket/{{annee}}/{{mois}}/{{idPointofSale}}", name="fill_tickets_history")
  448.      */
  449.     public function ticketskHistory($annee$mois$idPointofSale): Response
  450.     {
  451.         ini_set("memory_limit""-1");
  452.         set_time_limit(0);
  453.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  454.         $historyUpdate = new HistoryUpdate();
  455.         $historyUpdate->setEntityName('TicketHistory');
  456.         $historyUpdate->setComment('Import Manuelle');
  457.         $historyUpdate->setStartDate(new \DateTime());
  458.         $this->em->persist($historyUpdate);
  459.         $this->em->flush();
  460.         //$historyUpdate->getId();
  461.         try{
  462.             $dateDebutText ="$annee-$mois-01 00:00:00";
  463.             $dateDebut \DateTime::createFromFormat('Y-m-d H:i:s'$dateDebutText);
  464.             $dateFin \DateTime::createFromFormat('Y-m-d H:i:s'$dateDebutText)->modify('+1 month')->modify('-1 seconds');
  465.             $PointOfSale $this->em->getRepository('App\Entity\PointsOfSale')->findOneBy([
  466.                 'idCashmag' => $idPointofSale
  467.             ]);
  468.             $limit 1000;
  469.             $offset 0;
  470.             $i 1;
  471.             do{
  472.                 $listtickets $this->httpService->getTicketsHistoryByPointOfSales($idPointofSale$dateDebut$dateFin$limit$offset);
  473.                 //var_dump( $listtickets); die;
  474.                 foreach($listtickets['list'] as $ticket){
  475.                     $Tickets $this->em->getRepository('App\Entity\Tickets')->findOneBy([
  476.                         'idCashmag' => $ticket['id']
  477.                     ]);
  478.                     if($Tickets == null){
  479.                         $dobReconverted null;//\DateTime::createFromFormat('Y-m-d H:i:s', $ticket['date']); 
  480.                         $Tickets = new Tickets();
  481.                         $Tickets->setIdCashmag($ticket['id']);
  482.                         $Tickets->setComment(mb_convert_encoding($ticket['comment'], 'HTML-ENTITIES''UTF-8'));
  483.                         if($ticket['date'] != "0000-00-00 00:00:00"){
  484.                             $Tickets->setDate(\DateTime::createFromFormat('Y-m-d H:i:s'$ticket['date']));
  485.                         }
  486.                         $Tickets->setRNote(mb_convert_encoding($ticket['r_note'], 'HTML-ENTITIES''UTF-8'));
  487.                         $Tickets->setRTicket(mb_convert_encoding($ticket['r_ticket'], 'HTML-ENTITIES''UTF-8'));
  488.                         $Tickets->setRInvoice(mb_convert_encoding($ticket['r_invoice'], 'HTML-ENTITIES''UTF-8'));
  489.                         $Tickets->setPayments(json_encode($ticket['payments']));//json
  490.                         $Tickets->setDetails(json_encode($ticket['details']));//json
  491.                         //$Tickets->setIdTaxes($ticket['cost_price']);
  492.                         $Tickets->setIdPointOfSale($idPointofSale);
  493.                         $Tickets->setPointValue($ticket['point_value']);
  494.                         $Tickets->setPictureLink($ticket['picture_link']);
  495.                         $Tickets->setPictureBase64($ticket['picture_base64']);
  496.                         $Tickets->setShortSignature($ticket['short_signature']);
  497.                         $Tickets->setIdOrder($ticket['id_order']);
  498.                         $Tickets->setReversal($ticket['reversal']);
  499.                         $Tickets->setReverse($ticket['reverse']);
  500.                         $Tickets->setTotalCa($ticket['total_ca']);
  501.                         $Tickets->setTotalHt($ticket['total_ht']);
  502.                         $Tickets->setTotalTtc($ticket['total_ttc']);
  503.                         $Tickets->setNLines($ticket['n_lines']);
  504.                         $Tickets->setTypeDocument($ticket['type_document']);
  505.                         $Tickets->setTypeOperation($ticket['type_operation']);
  506.                         $Tickets->setSoftwareVersion($ticket['software_version']);
  507.                         $Tickets->setNTable($ticket['n_table']);
  508.                         $Tickets->setNPeople($ticket['n_people']);
  509.                         $Tickets->setNInvoice($ticket['n_invoice']);
  510.                         $Tickets->setNTicket($ticket['n_ticket']);
  511.                         $Tickets->setNNote($ticket['n_note']);
  512.                         $Tickets->setOperatorData(json_encode($ticket['operator']));
  513.                         $Tickets->setClientData(json_encode($ticket['client']));//json
  514.                         $Tickets->setSaleMethodeData(json_encode($ticket['sale_method']));//json
  515.                         $Tickets->setServiceData(json_encode($ticket['service']));//json
  516.                         $Tickets->setAttributesData(json_encode($ticket['attributes']));//json
  517.                         $Tickets->setTaxesData(json_encode($ticket['taxes']));//json
  518.                         $Tickets->setCodeDevice($ticket['code_device']);
  519.                         $Tickets->setCreditAmount($ticket['credit_amount']);
  520.                         $Tickets->setReference($ticket['reference']);
  521.                         $Tickets->setUrl($ticket['url']);
  522.                         $Tickets->setDateText($ticket['date_text']);
  523.                         $Tickets->setCurrencyCode($ticket['currency_code']);
  524.                         $this->em->persist($Tickets);
  525.                     }
  526.                     
  527.                 }
  528.                 $this->em->flush();
  529.                 $i++;
  530.                 $offset $limit $i;
  531.             }while (count($listtickets['list']) > 0);
  532.             $historyUpdate->setEndDate(new \DateTime());
  533.             $history= [];
  534.             $history["Offset"] = $offset;
  535.             $history["mois"] = "$annee-$mois";
  536.             $history["idPointofSale"] = $idPointofSale;
  537.             $history["type"] = "MANUAL";
  538.             $historyUpdate->setComment(json_encode($history));
  539.             $this->em->persist($historyUpdate);
  540.             $this->em->flush();
  541.             $pointOfSaleName $PointOfSale->getName();
  542.             $this->addFlash('success'"Liste Historique des Ticket point de vente $pointOfSaleName date  $annee-$mois mise à jour!");
  543.             $message $this->httpService->getHappyMessage();
  544.             return $this->render('default/index.html.twig', [
  545.                 'message' => $message,
  546.             ]);
  547.         }
  548.         catch(\Exception $e){
  549.             //error_log($e->getMessage());
  550.             $historyUpdate->setEndDate(new \DateTime());
  551.             $historyUpdate->setComment($e->getMessage());
  552.             $this->em->persist($historyUpdate);
  553.             $this->em->flush();
  554.         }
  555.     }
  556.     
  557.         /**
  558.      * @Route("/profile")
  559.      */
  560.     public function profile(): Response
  561.     {
  562.         $number random_int(0100);
  563.         return $this->render('default/index.html.twig', [
  564.             'number' => $number,
  565.         ]);
  566.     }
  567.     
  568. }