src/Controller/DashboardController.php line 58

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
  7. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  8. use Symfony\Component\EventDispatcher\GenericEvent;
  9. use Symfony\Component\HttpFoundation\Request;
  10. use Symfony\Component\HttpFoundation\JsonResponse;
  11. use Symfony\Component\Form\FormBuilder;
  12. use Symfony\Component\Form\Extension\Core\Type\TextType;
  13. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  14. use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
  15. use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  16. use Doctrine\ORM\Tools\Pagination\Paginator;
  17. use App\Events;
  18. use App\Entity\User;
  19. use App\Entity\Note;
  20. use App\Entity\ModeleBlanks;
  21. use App\Entity\Resin;
  22. use App\Entity\Fins;
  23. use App\Entity\Fibre;
  24. use App\Entity\Logo;
  25. use App\Entity\Plug;
  26. use App\Entity\FabricationPlanche;
  27. use App\Entity\Commande;
  28. use App\Entity\Planche;
  29. use App\Repository\UserRepository;
  30. use Symfony\Component\Security\Core\Security;
  31. class DashboardController extends Controller
  32. {
  33.     private $security;
  34.     public function __construct(Security $security)
  35.     {
  36.         $this->security $security;
  37.     }
  38.     /**
  39.      * @Route("/online", name="homepage")
  40.      * Accueil Dashboard
  41.      */
  42.     public function index()
  43.     {
  44.         $user $this->security->getUser();
  45.         $role $user->getRoles();
  46.         $brandsid $user->getBrandsid();
  47. $royalties $user->getRoyalties();
  48.         //dump($brandsid);
  49.         if ($role[0] == "ROLE_ADMIN" && $brandsid == "0") {
  50.             $em $this->getDoctrine()->getManager();
  51.             $statut 'inProgress';
  52.             // Affichage des commandes en attente
  53.             $order $em
  54.                 ->getRepository(FabricationPlanche::Class)
  55.                 ->findByStatut($statut);
  56.             // Mise a jour des statuts SANS ORDER STATUS et un PRODUCT STATUS Finished
  57.             // Affichage notes par demande d'achats
  58.             $note $em
  59.                 ->getRepository(Note::Class)
  60.                 ->findBy(array('type' => 'DemandeAchat'));
  61.             // Affichage des commandes en attente
  62.             $day_one = new \DateTime;
  63.             $res_day_one $day_one->format('Y-m-d');
  64.             $jour_ date("l"strtotime("now"));
  65.             // LAMINATION
  66.             $Date_lundi_lamination date("Y-m-d"strtotime("Monday this week"));
  67.             $Date_mardi_lamination date("Y-m-d"strtotime("tuesday this week"));
  68.             $Date_mercredi_lamination date("Y-m-d"strtotime("wednesday this week"));
  69.             $Date_jeudi_lamination date("Y-m-d"strtotime("thursday this week"));
  70.             $Date_vendredi_lamination date("Y-m-d"strtotime("friday this week"));
  71.             // SHAPE
  72.             $Date_lundi_shape date("Y-m-d"strtotime("Monday next week"));
  73.             $Date_mardi_shape date("Y-m-d"strtotime("tuesday next week"));
  74.             $Date_mercredi_shape date("Y-m-d"strtotime("wednesday next week"));
  75.             $Date_jeudi_shape date("Y-m-d"strtotime("thursday next week"));
  76.             $Date_vendredi_shape date("Y-m-d"strtotime("friday next week"));
  77.             $Date_late date("Y-m-d"strtotime("friday last week"));
  78.             $lundi_lam $em
  79.                 ->getRepository(FabricationPlanche::Class)
  80.                 ->findDay($Date_lundi_lamination);
  81.             $mardi_lam $em
  82.                 ->getRepository(FabricationPlanche::Class)
  83.                 ->findDay($Date_mardi_lamination);
  84.             $mercredi_lam $em
  85.                 ->getRepository(FabricationPlanche::Class)
  86.                 ->findDay($Date_mercredi_lamination);
  87.             $jeudi_lam $em
  88.                 ->getRepository(FabricationPlanche::Class)
  89.                 ->findDay($Date_jeudi_lamination);
  90.             $vendredi_lam $em
  91.                 ->getRepository(FabricationPlanche::Class)
  92.                 ->findDay($Date_vendredi_lamination);
  93.             $lundi_shape $em
  94.                 ->getRepository(FabricationPlanche::Class)
  95.                 ->findDay($Date_lundi_shape);
  96.             $mardi_shape $em
  97.                 ->getRepository(FabricationPlanche::Class)
  98.                 ->findDay($Date_mardi_shape);
  99.             $mercredi_shape $em
  100.                 ->getRepository(FabricationPlanche::Class)
  101.                 ->findDay($Date_mercredi_shape);
  102.             $jeudi_shape $em
  103.                 ->getRepository(FabricationPlanche::Class)
  104.                 ->findDay($Date_jeudi_shape);
  105.             $vendredi_shape $em
  106.                 ->getRepository(FabricationPlanche::Class)
  107.                 ->findDay($Date_vendredi_shape);
  108.             $late $em
  109.                 ->getRepository(FabricationPlanche::Class)
  110.                 ->findDayLate($Date_late);
  111.             $modelsBlanks $em
  112.                 ->getRepository(ModeleBlanks::Class)
  113.                 ->findStock();
  114.             $resin $em
  115.                 ->getRepository(Resin::Class)
  116.                 ->findStock();
  117.             $fins $em
  118.                 ->getRepository(Fins::Class)
  119.                 ->findStock();
  120.             $fibre $em
  121.                 ->getRepository(Fibre::Class)
  122.                 ->findStock();
  123.             $logo $em
  124.                 ->getRepository(Logo::Class)
  125.                 ->findStock();
  126.             $plug $em
  127.                 ->getRepository(Plug::Class)
  128.                 ->findStock();
  129.             /*------------------------ STATS DES PLANCHES PAR THOMAS ---------*/
  130.             $statDay $em
  131.                 ->getRepository(FabricationPlanche::Class)
  132.                 ->findNumDayPlanning();
  133.             $statWeek $em
  134.                 ->getRepository(FabricationPlanche::Class)
  135.                 ->findNumWeekPlanning();
  136.             $statMonth $em
  137.                 ->getRepository(FabricationPlanche::Class)
  138.                 ->findNumMonthPlanning();
  139.             //-----------------------------------------------------------------------
  140.             //-------------------------- NOMBRE DE PLANCHE EN COMMANDE
  141.             $sql "SELECT COUNT(fabrication_planche.id) AS 'NUMBERS_BOARDS'
  142.                 FROM `fabrication_planche`
  143.                 WHERE (date_maj BETWEEN NOW() - INTERVAL 1 YEAR AND NOW())
  144.                 AND `status_fabrication` = 'inProgress'
  145.                 AND `etat_avancement` = 'waiting'";
  146.             $manager $this->getDoctrine()->getManager();
  147.             $conn $manager->getConnection();
  148.             $result $conn->query($sql)->fetchAll();
  149.             $statBoardYearOrder $result[0]['NUMBERS_BOARDS'];
  150.             //-----------------------------------------------------------------------
  151.             //-------------------------- NOMBRE DANS LES TUYAUX
  152.             $sql "SELECT COUNT(fabrication_planche.id) AS 'NUMBERS_BOARDS'
  153.                 FROM `fabrication_planche`
  154.                 WHERE (date_maj BETWEEN NOW() - INTERVAL 4 YEAR AND NOW())
  155.                 AND `status_fabrication` = 'InProgress' ";
  156.             $manager $this->getDoctrine()->getManager();
  157.             $conn $manager->getConnection();
  158.             $result $conn->query($sql)->fetchAll();
  159.             $statBoardinProduct $result[0]['NUMBERS_BOARDS'];
  160.             //-----------------------------------------------------------------------
  161.             //-------------------------- NOMBRE DANS LES TUYAUX  Draft
  162.             $sql "SELECT COUNT(fabrication_planche.id) AS 'NUMBERS_BOARDS'
  163.                 FROM `fabrication_planche`
  164.                 WHERE (date_maj BETWEEN NOW() - INTERVAL 2 YEAR AND NOW())
  165.                 AND `etat_avancement` = 'Draft'";
  166.             $manager $this->getDoctrine()->getManager();
  167.             $conn $manager->getConnection();
  168.             $result $conn->query($sql)->fetchAll();
  169.             $statBoardinDraft $result[0]['NUMBERS_BOARDS'];
  170.             //-----------------------------------------------------------------------
  171.             //-------------------------- NOMBRE DANS LES TUYAUX  Standby
  172.             $sql "SELECT COUNT(fabrication_planche.id) AS 'NUMBERS_BOARDS'
  173.                 FROM `fabrication_planche`
  174.                 WHERE (date_maj BETWEEN NOW() - INTERVAL 4 YEAR AND NOW())
  175.                 AND `etat_avancement` = 'Standby'";
  176.             $manager $this->getDoctrine()->getManager();
  177.             $conn $manager->getConnection();
  178.             $result $conn->query($sql)->fetchAll();
  179.             $statBoardinStandby $result[0]['NUMBERS_BOARDS'];
  180.             //-----------------------------------------------------------------------
  181.             //-------------------------- NOMBRE DANS LES TUYAUX  Cave
  182.             $sql "SELECT COUNT(etat_avancement) AS 'NUMBERS_BOARDS'
  183.                 FROM `V_stats`
  184.                 WHERE (date_maj BETWEEN NOW() - INTERVAL 2 YEAR AND NOW())
  185.                 AND `etat_avancement` = 'cave'";
  186.             $manager $this->getDoctrine()->getManager();
  187.             $conn $manager->getConnection();
  188.             $result $conn->query($sql)->fetchAll();
  189.             $statBoardinCave $result[0]['NUMBERS_BOARDS'];
  190.             //-----------------------------------------------------------------------
  191.             //-------------------------- NOMBRE DE PLANCHE DEPUIS LE DEBUT DE L'ANNEE
  192.             $sql "SELECT COUNT(fabrication_planche.id) AS 'NUMBERS_BOARDS'
  193.                 FROM `fabrication_planche`
  194.                 WHERE YEAR( `date_maj`) = YEAR(NOW())
  195.                 AND `status_fabrication` LIKE '%ed'";
  196.             $manager $this->getDoctrine()->getManager();
  197.             $conn $manager->getConnection();
  198.             $result $conn->query($sql)->fetchAll();
  199.             $statBoardYearLeft $result[0]['NUMBERS_BOARDS'];
  200.             //-----------------------------------------------------------------------
  201.             //-------------------------- NOMBRE DE PLANCHE PAR MOIS DEPUIS 3 ANS
  202.             /*$sql = "SELECT COUNT(fabrication_planche.id) AS 'NUMBERS_BOARDS',
  203.                     EXTRACT(YEAR_MONTH FROM `date_maj`) AS 'DATES'
  204.                     FROM `fabrication_planche`
  205.                     WHERE (date_maj BETWEEN NOW() - INTERVAL 2 YEAR AND NOW())
  206.                     AND `status_fabrication` LIKE '%ed'
  207.                     GROUP BY DATES";*/
  208.           /*  $sql = "SELECT COUNT(fabrication_planche.id) AS 'NUMBERS_BOARDS',
  209.                 EXTRACT(YEAR_MONTH FROM `date_maj`) AS 'DATES'
  210.                 FROM `fabrication_planche`
  211.                 WHERE (date_maj BETWEEN '2021-01-01' AND '2024-12-31')
  212.                 AND `status_fabrication` LIKE '%ed'
  213.                 GROUP BY DATES";*/
  214.             $sql "SELECT COUNT(fabrication_planche.id) AS 'NUMBERS_BOARDS', 
  215.             EXTRACT(YEAR_MONTH FROM `date_maj`) AS 'DATES' FROM `fabrication_planche` 
  216.             WHERE (date_maj BETWEEN CONCAT(YEAR(CURDATE()) - 2, '-01-01') AND CONCAT(YEAR(CURDATE()), '-12-31'))
  217.             AND `status_fabrication` LIKE 'finished' 
  218.             GROUP BY DATES";
  219.             $manager $this->getDoctrine()->getManager();
  220.             $conn $manager->getConnection();
  221.             $result $conn->query($sql)->fetchAll();
  222. //
  223. //            dump($result);
  224. //
  225. //            exit;
  226.             // CONTROLE SI IL Y A UN CHIFFRE ET SI EXISTE
  227.             for ($z 0$z 36$z++) {
  228.                 if (!isset($result[$z]['NUMBERS_BOARDS'])) {
  229.                     $result[$z]['NUMBERS_BOARDS'] = "0";
  230.                 }
  231.                 if ($result[$z]['NUMBERS_BOARDS'] == "") {
  232.                     $result[$z]['NUMBERS_BOARDS'] = "0";
  233.                 }
  234.             }
  235.             $statYear "
  236.     { year: 'Jan', value1: " $result[0]['NUMBERS_BOARDS'] . ", value2: " $result[12]['NUMBERS_BOARDS'] . ", value3: " $result[24]['NUMBERS_BOARDS'] . " },
  237.     { year: 'Feb', value1: " $result[1]['NUMBERS_BOARDS'] . ", value2: " $result[13]['NUMBERS_BOARDS'] . ", value3: " $result[25]['NUMBERS_BOARDS'] . " },
  238.     { year: 'Mar', value1: " $result[2]['NUMBERS_BOARDS'] . ", value2: " $result[14]['NUMBERS_BOARDS'] . ", value3: " $result[26]['NUMBERS_BOARDS'] . " },
  239.     { year: 'Apr', value1: " $result[3]['NUMBERS_BOARDS'] . ", value2: " $result[15]['NUMBERS_BOARDS'] . ", value3: " $result[27]['NUMBERS_BOARDS'] . " },
  240.     { year: 'May', value1: " $result[4]['NUMBERS_BOARDS'] . ", value2: " $result[16]['NUMBERS_BOARDS'] . ", value3: " $result[28]['NUMBERS_BOARDS'] . " },
  241.     { year: 'Jun', value1: " $result[5]['NUMBERS_BOARDS'] . ", value2: " $result[17]['NUMBERS_BOARDS'] . ", value3: " $result[29]['NUMBERS_BOARDS'] . " },
  242.     { year: 'Jul', value1: " $result[6]['NUMBERS_BOARDS'] . ", value2: " $result[18]['NUMBERS_BOARDS'] . ", value3: " $result[30]['NUMBERS_BOARDS'] . " },
  243.     { year: 'Aug', value1: " $result[7]['NUMBERS_BOARDS'] . ", value2: " $result[19]['NUMBERS_BOARDS'] . ", value3: " $result[31]['NUMBERS_BOARDS'] . " },
  244.     { year: 'Sep', value1: " $result[8]['NUMBERS_BOARDS'] . ", value2: " $result[20]['NUMBERS_BOARDS'] . ", value3: " $result[32]['NUMBERS_BOARDS'] . " },
  245.     { year: 'Oct', value1: " $result[9]['NUMBERS_BOARDS'] . ", value2: " $result[21]['NUMBERS_BOARDS'] . ", value3: " $result[32]['NUMBERS_BOARDS'] . " },
  246.     { year: 'Nov', value1: " $result[10]['NUMBERS_BOARDS'] . ", value2: " $result[22]['NUMBERS_BOARDS'] . ", value3: " $result[34]['NUMBERS_BOARDS'] . " },
  247.     { year: 'Dec', value1: " $result[11]['NUMBERS_BOARDS'] . ", value2: " $result[23]['NUMBERS_BOARDS'] . ", value3: " $result[35]['NUMBERS_BOARDS'] . " }";
  248.             //-----------------------------------------------------------------------
  249.             //-------------------------- NOMBRE DE PLANCHE FINIES DANS LA SEMAINE
  250.             $sql "SELECT COUNT('id') AS 'NUMBERS_BOARDS',
  251.                 DAYNAME(date_maj) AS 'DAYS'
  252.                 FROM `V_stats`
  253.                 WHERE WEEK(date_maj) = WEEK(NOW())
  254.                 AND YEAR(date_maj) = YEAR(NOW())
  255.                 AND `status_fabrication` LIKE '%ed'
  256.                 GROUP BY DAYOFWEEK(date_maj)";
  257.             $manager $this->getDoctrine()->getManager();
  258.             $conn $manager->getConnection();
  259.             $result $conn->query($sql)->fetchAll();
  260.             // CONTROLE SI IL Y A UN CHIFFRE ET SI EXISTE
  261.             for ($z 0$z 36$z++) {
  262.                 if (!isset($result[$z]['NUMBERS_BOARDS'])) {
  263.                     $result[$z]['NUMBERS_BOARDS'] = "0";
  264.                 }
  265.                 if ($result[$z]['NUMBERS_BOARDS'] == "") {
  266.                     $result[$z]['NUMBERS_BOARDS'] = "0";
  267.                 }
  268.             }
  269.             $statDayWeek "
  270.     { day: 'Monday', value1: " $result[0]['NUMBERS_BOARDS'] . ", value2: " $result[12]['NUMBERS_BOARDS'] . ", value3: " $result[24]['NUMBERS_BOARDS'] . " },
  271.     { day: 'Tuesday', value1: " $result[1]['NUMBERS_BOARDS'] . ", value2: " $result[13]['NUMBERS_BOARDS'] . ", value3: " $result[25]['NUMBERS_BOARDS'] . " },
  272.     { day: 'Wednesday', value1: " $result[2]['NUMBERS_BOARDS'] . ", value2: " $result[14]['NUMBERS_BOARDS'] . ", value3: " $result[26]['NUMBERS_BOARDS'] . " },
  273.     { day: 'Thursday', value1: " $result[3]['NUMBERS_BOARDS'] . ", value2: " $result[15]['NUMBERS_BOARDS'] . ", value3: " $result[27]['NUMBERS_BOARDS'] . " },
  274.     { day: 'Friday', value1: " $result[4]['NUMBERS_BOARDS'] . ", value2: " $result[16]['NUMBERS_BOARDS'] . ", value3: " $result[28]['NUMBERS_BOARDS'] . " },
  275.     { day: 'Saturday', value1: " $result[5]['NUMBERS_BOARDS'] . ", value2: " $result[17]['NUMBERS_BOARDS'] . ", value3: " $result[29]['NUMBERS_BOARDS'] . " },
  276.     { day: 'Sunday', value1: " $result[6]['NUMBERS_BOARDS'] . ", value2: " $result[18]['NUMBERS_BOARDS'] . ", value3: " $result[30]['NUMBERS_BOARDS'] . " }";
  277.             /*------------------------ FIN STATS DES PLANCHES ---------*/
  278.             return $this->render('newdashboard.html.twig', array('order' => $order'note' => $note'modelsBlanks' => $modelsBlanks'resin' => $resin'fins' => $fins'fibre' => $fibre'logo' => $logo'plug' => $plug,
  279.                 'lundi' => $lundi_lam'mardi' => $mardi_lam'mercredi' => $mercredi_lam'jeudi' => $jeudi_lam'vendredi' => $vendredi_lam,
  280.                 'lundiShape' => $lundi_shape'mardiShape' => $mardi_shape'mercrediShape' => $mercredi_shape'jeudiShape' => $jeudi_shape'vendrediShape' => $vendredi_shape,
  281.                 'jour' => $jour_'late' => $late,
  282.                 'statDay' => $statDay,
  283.                 'statWeek' => $statWeek,
  284.                 'statMonth' => $statMonth,
  285.                 'statBoardinProduct' => $statBoardinProduct,
  286.                 'statBoardinDraft' => $statBoardinDraft,
  287.                 'statBoardinCave' => $statBoardinCave,    
  288.                 'statBoardinStandby' => $statBoardinStandby,
  289.                 'statBoardYearOrder' => $statBoardYearOrder,
  290.                 'statBoardYearLeft' => $statBoardYearLeft,
  291.                 'statYear' => $statYear,
  292.                 'statDayWeek' => $statDayWeek,
  293.                 'brandsid' => $brandsid
  294.             ));
  295.         } elseif ($brandsid != "0") {
  296.             $em $this->getDoctrine()->getManager();
  297.             $bid $em
  298.                 ->getRepository(\App\Entity\Marque::Class)
  299.                 ->findOneBy(['nom' => $brandsid]);
  300.             $statut 'inProgress';
  301.             // Affichage des commandes en attente
  302.             $order $em
  303.                 ->getRepository(FabricationPlanche::Class)
  304.                 ->findByStatut($statut);
  305.            // exit;
  306.             // Mise a jour des statuts SANS ORDER STATUS et un PRODUCT STATUS Finished
  307.             // Affichage notes par demande d'achats
  308.             $note $em
  309.                 ->getRepository(Note::Class)
  310.                 ->findBy(array('type' => 'DemandeAchat'));
  311.             // Affichage des commandes en attente
  312.             $day_one = new \DateTime;
  313.             $res_day_one $day_one->format('Y-m-d');
  314.             $jour_ date("l"strtotime("now"));
  315.             // LAMINATION
  316.             $Date_lundi_lamination date("Y-m-d"strtotime("Monday this week"));
  317.             $Date_mardi_lamination date("Y-m-d"strtotime("tuesday this week"));
  318.             $Date_mercredi_lamination date("Y-m-d"strtotime("wednesday this week"));
  319.             $Date_jeudi_lamination date("Y-m-d"strtotime("thursday this week"));
  320.             $Date_vendredi_lamination date("Y-m-d"strtotime("friday this week"));
  321.             // SHAPE
  322.             $Date_lundi_shape date("Y-m-d"strtotime("Monday next week"));
  323.             $Date_mardi_shape date("Y-m-d"strtotime("tuesday next week"));
  324.             $Date_mercredi_shape date("Y-m-d"strtotime("wednesday next week"));
  325.             $Date_jeudi_shape date("Y-m-d"strtotime("thursday next week"));
  326.             $Date_vendredi_shape date("Y-m-d"strtotime("friday next week"));
  327.             $Date_late date("Y-m-d"strtotime("friday last week"));
  328.             $lundi_lam $em
  329.                 ->getRepository(FabricationPlanche::Class)
  330.                 ->findDay($Date_lundi_lamination);
  331.             $mardi_lam $em
  332.                 ->getRepository(FabricationPlanche::Class)
  333.                 ->findDay($Date_mardi_lamination);
  334.             $mercredi_lam $em
  335.                 ->getRepository(FabricationPlanche::Class)
  336.                 ->findDay($Date_mercredi_lamination);
  337.             $jeudi_lam $em
  338.                 ->getRepository(FabricationPlanche::Class)
  339.                 ->findDay($Date_jeudi_lamination);
  340.             $vendredi_lam $em
  341.                 ->getRepository(FabricationPlanche::Class)
  342.                 ->findDay($Date_vendredi_lamination);
  343.             $lundi_shape $em
  344.                 ->getRepository(FabricationPlanche::Class)
  345.                 ->findDay($Date_lundi_shape);
  346.             $mardi_shape $em
  347.                 ->getRepository(FabricationPlanche::Class)
  348.                 ->findDay($Date_mardi_shape);
  349.             $mercredi_shape $em
  350.                 ->getRepository(FabricationPlanche::Class)
  351.                 ->findDay($Date_mercredi_shape);
  352.             $jeudi_shape $em
  353.                 ->getRepository(FabricationPlanche::Class)
  354.                 ->findDay($Date_jeudi_shape);
  355.             $vendredi_shape $em
  356.                 ->getRepository(FabricationPlanche::Class)
  357.                 ->findDay($Date_vendredi_shape);
  358.             $late $em
  359.                 ->getRepository(FabricationPlanche::Class)
  360.                 ->findDayLate($Date_late);
  361.             $modelsBlanks $em
  362.                 ->getRepository(ModeleBlanks::Class)
  363.                 ->findStock();
  364.             $resin $em
  365.                 ->getRepository(Resin::Class)
  366.                 ->findStock();
  367.             $fins $em
  368.                 ->getRepository(Fins::Class)
  369.                 ->findStock();
  370.             $fibre $em
  371.                 ->getRepository(Fibre::Class)
  372.                 ->findStock();
  373.             $logo $em
  374.                 ->getRepository(Logo::Class)
  375.                 ->findStock();
  376.             $plug $em
  377.                 ->getRepository(Plug::Class)
  378.                 ->findStock();
  379.             /*------------------------ STATS DES PLANCHES PAR THOMAS ---------*/
  380.             $statDay $em
  381.                 ->getRepository(FabricationPlanche::Class)
  382.                 ->findNumDayPlanning();
  383.             $statWeek $em
  384.                 ->getRepository(FabricationPlanche::Class)
  385.                 ->findNumWeekPlanning();
  386.             $statMonth $em
  387.                 ->getRepository(FabricationPlanche::Class)
  388.                 ->findNumMonthPlanning();
  389.             //-----------------------------------------------------------------------
  390.             //-------------------------- NOMBRE DE PLANCHE EN COMMANDE
  391.             $sql "SELECT COUNT(fabrication_planche.id) AS 'NUMBERS_BOARDS'
  392.                 FROM `fabrication_planche`
  393.                 WHERE (date_maj BETWEEN NOW() - INTERVAL 1 YEAR AND NOW())
  394.                 AND `status_fabrication` = 'inProgress'
  395.                 AND `etat_avancement` = 'waiting'";
  396.             $manager $this->getDoctrine()->getManager();
  397.             $conn $manager->getConnection();
  398.             $result $conn->query($sql)->fetchAll();
  399.             $statBoardYearOrder $result[0]['NUMBERS_BOARDS'];
  400.             //-----------------------------------------------------------------------
  401.             //-------------------------- NOMBRE DANS LES TUYAUX
  402.             $sql "SELECT COUNT(fabrication_planche.id) AS 'NUMBERS_BOARDS'
  403.                 FROM `fabrication_planche`
  404.                 WHERE (date_maj BETWEEN NOW() - INTERVAL 2 YEAR AND NOW())
  405.                 AND `status_fabrication` = 'InProgress'";
  406.             $manager $this->getDoctrine()->getManager();
  407.             $conn $manager->getConnection();
  408.             $result $conn->query($sql)->fetchAll();
  409.             $statBoardinProduct $result[0]['NUMBERS_BOARDS'];
  410.             //-----------------------------------------------------------------------
  411.             //-------------------------- NOMBRE DANS LES TUYAUX  Draft
  412.             $sql "SELECT COUNT(fabrication_planche.id) AS 'NUMBERS_BOARDS'
  413.                 FROM `fabrication_planche`
  414.                 WHERE (date_maj BETWEEN NOW() - INTERVAL 2 YEAR AND NOW())
  415.                 AND `etat_avancement` = 'Draft'";
  416.             $manager $this->getDoctrine()->getManager();
  417.             $conn $manager->getConnection();
  418.             $result $conn->query($sql)->fetchAll();
  419.             $statBoardinDraft $result[0]['NUMBERS_BOARDS'];
  420.             //-----------------------------------------------------------------------
  421.             //-------------------------- NOMBRE DANS LES TUYAUX  Standby
  422.             $sql "SELECT COUNT(fabrication_planche.id) AS 'NUMBERS_BOARDS'
  423.                 FROM `fabrication_planche`
  424.                 WHERE (date_maj BETWEEN NOW() - INTERVAL 2 YEAR AND NOW())
  425.                 AND `etat_avancement` = 'Standby'";
  426.             $manager $this->getDoctrine()->getManager();
  427.             $conn $manager->getConnection();
  428.             $result $conn->query($sql)->fetchAll();
  429.             $statBoardinStandby $result[0]['NUMBERS_BOARDS'];
  430.             //-----------------------------------------------------------------------
  431.             //-------------------------- NOMBRE DE PLANCHE DEPUIS LE DEBUT DE L'ANNEE
  432.             $sql "SELECT COUNT(fabrication_planche.id) AS 'NUMBERS_BOARDS'
  433.                 FROM `fabrication_planche`
  434.                 WHERE YEAR( `date_maj`) = YEAR(NOW())
  435.                 AND `status_fabrication` LIKE '%ed'";
  436.             $manager $this->getDoctrine()->getManager();
  437.             $conn $manager->getConnection();
  438.             $result $conn->query($sql)->fetchAll();
  439.             $statBoardYearLeft $result[0]['NUMBERS_BOARDS'];
  440.             //-----------------------------------------------------------------------
  441.             //-------------------------- NOMBRE DE PLANCHE PAR MOIS DEPUIS 3 ANS
  442.             /*$sql = "SELECT COUNT(fabrication_planche.id) AS 'NUMBERS_BOARDS',
  443.                     EXTRACT(YEAR_MONTH FROM `date_maj`) AS 'DATES'
  444.                     FROM `fabrication_planche`
  445.                     WHERE (date_maj BETWEEN NOW() - INTERVAL 2 YEAR AND NOW())
  446.                     AND `status_fabrication` LIKE '%ed'
  447.                     GROUP BY DATES";*/
  448. //
  449. //            $sql = "SELECT COUNT(fabrication_planche.id) AS 'NUMBERS_BOARDS',
  450. //                EXTRACT(YEAR_MONTH FROM `date_maj`) AS 'DATES'
  451. //                FROM `fabrication_planche`
  452. //                WHERE (date_maj BETWEEN '2018-01-01' AND '2020-12-31')
  453. //                AND `status_fabrication` LIKE '%ed'
  454. //                GROUP BY DATES";
  455.             $brid  $bid->getId();
  456. //
  457.             $sql "SELECT COUNT(fabrication_planche.id) AS 'NUMBERS_BOARDS',
  458.                     EXTRACT(YEAR_MONTH FROM `date_maj`) AS 'DATES' FROM fabrication_planche
  459.                     JOIN planche ON planche.id = fabrication_planche.planche_id
  460.                     JOIN modele ON modele.id = planche.modele_id
  461.                     JOIN marque ON marque.id = modele.marque_id
  462.                     Where marque_id = '$brid'
  463.                     AND (date_maj BETWEEN '2019-01-01' AND '2028-12-31') AND `status_fabrication` LIKE '%ed' GROUP BY DATES";
  464. //
  465.            // dump($sql);
  466.             $manager $this->getDoctrine()->getManager();
  467.             $conn $manager->getConnection();
  468.             $result $conn->query($sql)->fetchAll();
  469.            // dd($result);
  470. //            $sDay = $em
  471. //                ->getRepository(FabricationPlanche::Class)
  472. //                ->findNumDayPlanning();
  473. //
  474. //
  475. //            dump($sDay);
  476. //
  477. //            exit;
  478.             // CONTROLE SI IL Y A UN CHIFFRE ET SI EXISTE
  479.             for ($z 0$z 36$z++) {
  480.                 if (!isset($result[$z]['NUMBERS_BOARDS'])) {
  481.                     $result[$z]['NUMBERS_BOARDS'] = "0";
  482.                 }
  483.                 if ($result[$z]['NUMBERS_BOARDS'] == "") {
  484.                     $result[$z]['NUMBERS_BOARDS'] = "0";
  485.                 }
  486.             }
  487.             $statYear "
  488.     { year: 'Jan', value1: " $result[0]['NUMBERS_BOARDS'] . ", value2: " $result[12]['NUMBERS_BOARDS'] . ", value3: " $result[24]['NUMBERS_BOARDS'] . " },
  489.     { year: 'Feb', value1: " $result[1]['NUMBERS_BOARDS'] . ", value2: " $result[13]['NUMBERS_BOARDS'] . ", value3: " $result[25]['NUMBERS_BOARDS'] . " },
  490.     { year: 'Mar', value1: " $result[2]['NUMBERS_BOARDS'] . ", value2: " $result[14]['NUMBERS_BOARDS'] . ", value3: " $result[26]['NUMBERS_BOARDS'] . " },
  491.     { year: 'Apr', value1: " $result[3]['NUMBERS_BOARDS'] . ", value2: " $result[15]['NUMBERS_BOARDS'] . ", value3: " $result[27]['NUMBERS_BOARDS'] . " },
  492.     { year: 'May', value1: " $result[4]['NUMBERS_BOARDS'] . ", value2: " $result[16]['NUMBERS_BOARDS'] . ", value3: " $result[28]['NUMBERS_BOARDS'] . " },
  493.     { year: 'Jun', value1: " $result[5]['NUMBERS_BOARDS'] . ", value2: " $result[17]['NUMBERS_BOARDS'] . ", value3: " $result[29]['NUMBERS_BOARDS'] . " },
  494.     { year: 'Jul', value1: " $result[6]['NUMBERS_BOARDS'] . ", value2: " $result[18]['NUMBERS_BOARDS'] . ", value3: " $result[30]['NUMBERS_BOARDS'] . " },
  495.     { year: 'Aug', value1: " $result[7]['NUMBERS_BOARDS'] . ", value2: " $result[19]['NUMBERS_BOARDS'] . ", value3: " $result[31]['NUMBERS_BOARDS'] . " },
  496.     { year: 'Sep', value1: " $result[8]['NUMBERS_BOARDS'] . ", value2: " $result[20]['NUMBERS_BOARDS'] . ", value3: " $result[32]['NUMBERS_BOARDS'] . " },
  497.     { year: 'Oct', value1: " $result[9]['NUMBERS_BOARDS'] . ", value2: " $result[21]['NUMBERS_BOARDS'] . ", value3: " $result[32]['NUMBERS_BOARDS'] . " },
  498.     { year: 'Nov', value1: " $result[10]['NUMBERS_BOARDS'] . ", value2: " $result[22]['NUMBERS_BOARDS'] . ", value3: " $result[34]['NUMBERS_BOARDS'] . " },
  499.     { year: 'Dec', value1: " $result[11]['NUMBERS_BOARDS'] . ", value2: " $result[23]['NUMBERS_BOARDS'] . ", value3: " $result[35]['NUMBERS_BOARDS'] . " }";
  500.             //-----------------------------------------------------------------------
  501.             //-------------------------- NOMBRE DE PLANCHE FINIES DANS LA SEMAINE
  502.             $sql "SELECT COUNT('id') AS 'NUMBERS_BOARDS',
  503.                 DAYNAME(date_maj) AS 'DAYS'
  504.                 FROM `V_stats`
  505.                 WHERE WEEK(date_maj) = WEEK(NOW())
  506.                 AND YEAR(date_maj) = YEAR(NOW())
  507.                 AND `status_fabrication` LIKE '%ed'
  508.                 GROUP BY DAYOFWEEK(date_maj)";
  509.             $manager $this->getDoctrine()->getManager();
  510.             $conn $manager->getConnection();
  511.             $result $conn->query($sql)->fetchAll();
  512.             // CONTROLE SI IL Y A UN CHIFFRE ET SI EXISTE
  513.             for ($z 0$z 36$z++) {
  514.                 if (!isset($result[$z]['NUMBERS_BOARDS'])) {
  515.                     $result[$z]['NUMBERS_BOARDS'] = "0";
  516.                 }
  517.                 if ($result[$z]['NUMBERS_BOARDS'] == "") {
  518.                     $result[$z]['NUMBERS_BOARDS'] = "0";
  519.                 }
  520.             }
  521.             $statDayWeek "
  522.     { day: 'Monday', value1: " $result[0]['NUMBERS_BOARDS'] . ", value2: " $result[12]['NUMBERS_BOARDS'] . ", value3: " $result[24]['NUMBERS_BOARDS'] . " },
  523.     { day: 'Tuesday', value1: " $result[1]['NUMBERS_BOARDS'] . ", value2: " $result[13]['NUMBERS_BOARDS'] . ", value3: " $result[25]['NUMBERS_BOARDS'] . " },
  524.     { day: 'Wednesday', value1: " $result[2]['NUMBERS_BOARDS'] . ", value2: " $result[14]['NUMBERS_BOARDS'] . ", value3: " $result[26]['NUMBERS_BOARDS'] . " },
  525.     { day: 'Thursday', value1: " $result[3]['NUMBERS_BOARDS'] . ", value2: " $result[15]['NUMBERS_BOARDS'] . ", value3: " $result[27]['NUMBERS_BOARDS'] . " },
  526.     { day: 'Friday', value1: " $result[4]['NUMBERS_BOARDS'] . ", value2: " $result[16]['NUMBERS_BOARDS'] . ", value3: " $result[28]['NUMBERS_BOARDS'] . " },
  527.     { day: 'Saturday', value1: " $result[5]['NUMBERS_BOARDS'] . ", value2: " $result[17]['NUMBERS_BOARDS'] . ", value3: " $result[29]['NUMBERS_BOARDS'] . " },
  528.     { day: 'Sunday', value1: " $result[6]['NUMBERS_BOARDS'] . ", value2: " $result[18]['NUMBERS_BOARDS'] . ", value3: " $result[30]['NUMBERS_BOARDS'] . " }";
  529.             /*------------------------ FIN STATS DES PLANCHES ---------*/
  530.             return $this->render('newdashboardforbrand.html.twig', array('order' => $order'note' => $note'modelsBlanks' => $modelsBlanks'resin' => $resin'fins' => $fins'fibre' => $fibre'logo' => $logo'plug' => $plug,
  531.                 'lundi' => $lundi_lam'mardi' => $mardi_lam'mercredi' => $mercredi_lam'jeudi' => $jeudi_lam'vendredi' => $vendredi_lam,
  532.                 'lundiShape' => $lundi_shape'mardiShape' => $mardi_shape'mercrediShape' => $mercredi_shape'jeudiShape' => $jeudi_shape'vendrediShape' => $vendredi_shape,
  533.                 'jour' => $jour_'late' => $late,
  534.                 'statDay' => $statDay,
  535.                 'statWeek' => $statWeek,
  536.                 'statMonth' => $statMonth,
  537.                 'statBoardinProduct' => $statBoardinProduct,
  538.                 'statBoardinDraft' => $statBoardinDraft,
  539.                 'statBoardinStandby' => $statBoardinStandby,
  540.                 'statBoardYearOrder' => $statBoardYearOrder,
  541.                 'statBoardYearLeft' => $statBoardYearLeft,
  542.                 'statYear' => $statYear,
  543.                 'statDayWeek' => $statDayWeek,
  544.                 'brandsid' => $brandsid,
  545.                 'royalties' => $royalties
  546.             ));
  547.         } else {
  548.             return $this->redirectToRoute('homepage_customer');
  549.         }
  550.     }
  551.     /**
  552.      * @Route("online/pass", name="change_pass")
  553.      * Change Pass
  554.      */
  555.     public function change_pass(Request $requestUserPasswordEncoderInterface $passwordEncoderEventDispatcherInterface $eventDispatcher)
  556.     {
  557.         // Récupération de l'entité user dans le formulaire
  558.         $em $this->getDoctrine()->getManager();
  559.         $user $em->getRepository(User::class)->find($this->getUser()->getId());
  560.         // Création d'un formulaire
  561.         $form $this->createFormBuilder($user)
  562.             ->add('password'RepeatedType::class, array(
  563.                 'type' => PasswordType::class,
  564.                 'invalid_message' => 'The password fields must match.',
  565.                 'options' => array('attr' => array('class' => 'password-field')),
  566.                 'required' => true,
  567.                 'first_options' => array('label' => 'Password'),
  568.                 'second_options' => array('label' => 'Repeat Password'),
  569.             ))
  570.             ->getForm();
  571.         // Formulaire soumis à validation
  572.         $form->handleRequest($request);
  573.         // Apres validation du formulaire - redirection effectuée
  574.         if ($form->isSubmitted() && $form->isValid()) {
  575.             $em->flush();
  576.             //On déclenche l'event message
  577.             $event = new GenericEvent($user);
  578.             $eventDispatcher->dispatch(Events::USER_REGISTERED$event);
  579.             // On enregistre cette fois-ci le mdp hashé
  580.             $password $passwordEncoder->encodePassword($user$user->getPassword());
  581.             $user->setPassword($password);
  582.             // Enregistrement dans la bdd
  583.             $em->flush();
  584.             //echo "<script>alert(\"The password has been changed\")</script>";
  585.             // Redirection vers la page admin
  586.             return $this->redirectToRoute('logout');
  587.         }
  588.         return $this->render('pass.html.twig', array('form' => $form->createView()));
  589.     }
  590.     /**
  591.      * @Route("/admin", name="admin_redirect")
  592.      * Redirection url
  593.      */
  594.     public function admin_redirect()
  595.     {
  596.         return $this->redirectToRoute('admin');
  597.     }
  598.     /**
  599.      * @Route("/admin/voir/{page}", name="admin")
  600.      * Accueil AdminDashboard
  601.      */
  602.     public function admin(Request $request$page 1$max_results 10)
  603.     {
  604.         // Formulaire de requetage
  605.         $search NULL;
  606.         $formulaire $this->createFormBuilder()
  607.             ->add('search'TextType::class, array('attr' => array('placeholder' => 'Fullname')))
  608.             ->add('send'SubmitType::class, array('label' => 'Search'))
  609.             ->getForm();
  610.         $formulaire->handleRequest($request);
  611.         // Apres validation du formulaire - redirection effectuée
  612.         if ($formulaire->isSubmitted() && $formulaire->isValid()) {
  613.             $search $formulaire['search']->getData();
  614.             return $this->redirectToRoute('admin_search', array('search' => $search));
  615.         }
  616.         // Recherche de tous les utilisateurs
  617.         $users $this->getDoctrine()
  618.             ->getRepository(User::Class)
  619.             ->findAll_($page$max_results);
  620.         // Pagination
  621.         $pg = array(
  622.             'page' => $page,
  623.             'route' => 'admin',
  624.             'pages_count' => ceil(count($users) / $max_results),
  625.             'route_params' => array()
  626.         );
  627.         // Passage en parametre TWIG des variables ('tableau des utilisateurs, pagination, formulaire et également du mode recherche inactive')
  628.         return $this->render('Admin/admin.html.twig', array('users' => $users'pg' => $pg'formulaire' => $formulaire->createView(), 'mode' => false));
  629.     }
  630.     /**
  631.      * @Route("/admin/req", name="admin_search_redirect")
  632.      */
  633.     public function admin_search_redirect()
  634.     {
  635.         // Si l'utilisateur rentre req sans rien derrière dans l'URL, redirection vers la page admin accueil
  636.         return $this->redirectToRoute('admin');
  637.     }
  638.     /**
  639.      * @Route("/admin/req/{search}", name="admin_search")
  640.      */
  641.     public function admin_search(Request $request$search)
  642.     {
  643.         // Initialisation tableau user vide -
  644.         $users = array();
  645.         $repository $this->getDoctrine()
  646.             ->getManager()
  647.             ->getRepository(User::Class);
  648.         // Requete recherche en fonction du nom - résultat
  649.         $user $repository->findByFullname($search);
  650.         // Si on ne trouve pas de résultat, on retourne rien
  651.         if (null !== $user)
  652.             $users $user;
  653.         // Formulaire de requetage
  654.         $search NULL;
  655.         $formulaire $this->createFormBuilder()
  656.             ->add('search'TextType::class, array('attr' => array('placeholder' => 'Fullname')))
  657.             ->add('send'SubmitType::class, array('label' => 'Search'))
  658.             ->getForm();
  659.         $formulaire->handleRequest($request);
  660.         // Apres validation du formulaire - redirection effectuée sur la même page
  661.         if ($formulaire->isSubmitted() && $formulaire->isValid()) {
  662.             $search $formulaire['search']->getData();
  663.             return $this->redirectToRoute('admin_search', array('search' => $search));
  664.         }
  665.         // Passage en parametre TWIG des variables ('tableau des utilisateurs, pagination, formulaire et également du mode recherche active')
  666.         return $this->render('Admin/admin.html.twig', array('users' => $users'pg' => '1''formulaire' => $formulaire->createView(), 'mode' => true));
  667.     }
  668.     /**
  669.      * @Route("/online/step/tab", name="step_modif")
  670.      */
  671.     public function step_modif(Request $request)
  672.     {
  673.         if ($request->isXmlHttpRequest()) {
  674.             // recuperation des données
  675.             $step $request->request->get('step');
  676.             $tab_val $request->request->get('tab_val');
  677.             // entité manager
  678.             $em $this->getDoctrine()->getManager();
  679.             foreach ($tab_val as $value) {
  680.                 $q $em
  681.                     ->getRepository(FabricationPlanche::Class)
  682.                     ->findOneBy(array('id' => $value));
  683.                 $o $em
  684.                     ->getRepository(Commande::Class)
  685.                     ->findOneBy(array('id' => $value));
  686.                 if ($step == 'finished') {
  687.                     $q->setEtatAvancement(' ');
  688.                     $q->setStatusFab($step);
  689.                     $q->setDateMaj(new \DateTime);
  690.                     //-----------------------------------------------------------------------
  691.                     //-------------------------- INFOS SUR LA PLANCHE NUMERO STATUT
  692.                     $sql "SELECT num_serie, modele, marque, statut, email
  693.                             FROM `V_stats`
  694.                             WHERE `id` = " $value "";
  695.                     $manager $this->getDoctrine()->getManager();
  696.                     $conn $manager->getConnection();
  697.                     $result $conn->query($sql)->fetchAll();
  698.                     $INFOnum_serie $result[0]['num_serie'];
  699.                     $INFOnum_modele $result[0]['modele'];
  700.                     $INFOnum_marque $result[0]['marque'];
  701.                     $INFOstatut $result[0]['statut'];
  702.                     $INFOemail $result[0]['email'];
  703.                     //-----------------------------------------------------------------------
  704.                     //-------------------------- FIN
  705.                     // SendEmail - Création d'un e-mail type
  706.                     $passage_ligne "\r\n";
  707.                     $body_txt "Hello " $o->getPersonne()->getFirstname() . " " $o->getPersonne()->getLastname() . " ! \n\n ======================================== \n\n Your surfboard is ready. You can pick-up it at :\n\n ZAC des fourneaux, 3 Rue Albert Denis, 17690 Angoulins FRANCE \n\n OR if you 've selected the shipping option, please confirm by email your exact address.\n\n
  708.               UWL SHAPERS CLUB, \n\nHave a nice day !\n\n";
  709.                     $body_html "<html><head></head><body><p>Hello " $o->getPersonne()->getFirstname() . " " $o->getPersonne()->getLastname() . ",</p><p>Your surfboard is ready.</p><p> You can pickup it at :</p><p>ZAC des fourneaux, 3 Rue Albert Denis, 17690 Angoulins FRANCE</p><p>Tel.+33 5 46 27 00 27 // Email. contact@uwl-surfboards.com </p><p>OR if you 've selected the shipping option, please confirm by email your exact address.</p><p></p><p>
  710.               UWL SHAPER CLUB</p></i>
  711.               <p>Have a nice day !</p><p><b>www.uwl-intranet.com</b></p></body></html>";
  712.                     $body_txt2 "Hello the crew, the  board of " $o->getPersonne()->getFirstname() . " " $o->getPersonne()->getLastname() . "  is ready ! \n\n ========================================  \n\n STATUS : " $INFOstatut " \n\n BRAND : " $INFOnum_marque " \n\n MODEL : " $INFOnum_modele " \n\n SERIAL NUMBER : " $INFOnum_serie "\n\n
  713.               UWL SHAPERS CLUB, \n\nHave a nice day !\n\n";
  714.                     $body_html2 "<html><head></head><body><p>Hello the crew,</p><p>The board of " $o->getPersonne()->getFirstname() . " " $o->getPersonne()->getLastname() . " is ready.</p><p> STATUS : " $INFOstatut " </p><p> BRAND : " $INFOnum_marque " </p><p> MODEL : " $INFOnum_modele " </p><p> SERIAL NUMBER : " $INFOnum_serie "</p><p> LINK : <a href='http://www.uwl-intranet.com/online/order/view/" $value "'>http://www.uwl-intranet.com/online/order/view/" $value "</a></p><p>
  715.               UWL SHAPER CLUB</p></i>
  716.               <p>Have a nice day !</p><p><b>www.uwl-intranet.com</b></p></body></html>";
  717.                     //=====Création de la boundary
  718.                     $boundary "-----=" md5(rand());
  719.                     //==========
  720.                     //=====Définition du sujet.
  721.                     $subject "[UWL SHAPERS CLUB] Hello " $o->getPersonne()->getFirstname() . " " $o->getPersonne()->getLastname() . " | Your surfboard is ready.";
  722.                     $subject2 "[UWL SHAPERS CLUB] The board  of " $o->getPersonne()->getFirstname() . " " $o->getPersonne()->getLastname() . " is done.";
  723.                     //==========
  724.                     //=====Création du header de l'e-mail.
  725.                     $header "From: \"uwl-intranet\" <contact@uwl-surfboards.com>" $passage_ligne;
  726.                     $header .= "Reply-to: \"uwl-intranet\" <contact@uwl-surfboards.com>" $passage_ligne;
  727.                     $header .= "MIME-Version: 1.0" $passage_ligne;
  728.                     $header .= "Content-Type: multipart/alternative;" $passage_ligne " boundary=\"$boundary\"" $passage_ligne;
  729.                     //==========
  730.                     //=====Création du message.
  731.                     $message $passage_ligne "--" $boundary $passage_ligne;
  732.                     //=====Ajout du message au format texte.
  733.                     $message .= "Content-Type: text/plain; charset=\"ISO-8859-1\"" $passage_ligne;
  734.                     $message .= "Content-Transfer-Encoding: 8bit" $passage_ligne;
  735.                     $message .= $passage_ligne $body_txt $passage_ligne;
  736.                     //==========
  737.                     $message .= $passage_ligne "--" $boundary $passage_ligne;
  738.                     //=====Ajout du message au format HTML
  739.                     $message .= "Content-Type: text/html; charset=\"ISO-8859-1\"" $passage_ligne;
  740.                     $message .= "Content-Transfer-Encoding: 8bit" $passage_ligne;
  741.                     $message .= $passage_ligne $body_html $passage_ligne;
  742.                     //==========
  743.                     $message .= $passage_ligne "--" $boundary "--" $passage_ligne;
  744.                     $message .= $passage_ligne "--" $boundary "--" $passage_ligne;
  745.                     //==========
  746.                     //== MESSAGE 2
  747.                     //=====Création du message 2.
  748.                     $message2 $passage_ligne "--" $boundary $passage_ligne;
  749.                     //=====Ajout du message 2 au format texte.
  750.                     $message2 .= "Content-Type: text/plain; charset=\"ISO-8859-1\"" $passage_ligne;
  751.                     $message2 .= "Content-Transfer-Encoding: 8bit" $passage_ligne;
  752.                     $message2 .= $passage_ligne $body_txt2 $passage_ligne;
  753.                     //==========
  754.                     $message2 .= $passage_ligne "--" $boundary $passage_ligne;
  755.                     //=====Ajout du message 2 au format HTML
  756.                     $message2 .= "Content-Type: text/html; charset=\"ISO-8859-1\"" $passage_ligne;
  757.                     $message2 .= "Content-Transfer-Encoding: 8bit" $passage_ligne;
  758.                     $message2 .= $passage_ligne $body_html2 $passage_ligne;
  759.                     //==========
  760.                     $message2 .= $passage_ligne "--" $boundary "--" $passage_ligne;
  761.                     $message2 .= $passage_ligne "--" $boundary "--" $passage_ligne;
  762.                     //==========
  763.                     $req_user $em
  764.                         ->getRepository(User::Class)
  765.                         ->findOneBy(array('id' => $o->getPersonne()));
  766.                     
  767.                     try {
  768.                         //$to = $req_user->getUsername();
  769.                         $to $INFOemail;
  770.                         $to2 "contact@uwl-surfboards.com";
  771.                         mail($to2$subject2$message2$header);
  772.                         if ($INFOstatut != "Surfshop" OR $INFOstatut != "Subcontractor") {
  773.                             mail($to$subject$message$header);
  774.                             // ENVOIE DES SMS
  775.                             $TelSms $o->getPersonne()->getCellularnumber();
  776.                             if (strlen($TelSms) <= 10) {
  777.                                 $TelSms "0" $TelSms;
  778.                             }
  779.                            $sms "http://www.itooki-sms.com/http.php?email=thomas@uwl-surfboards.com&pass=D2CT7F4&numero=" $TelSms "&message=Hello%20your%20surfboards%20is%20ready.%20UWL%20SHAPERS%20CLUB";
  780.                             $resultatsms implode(""file($sms));
  781.                         } // FIN SI C'EST UN SHOP
  782.                     } catch (Exception $e) {
  783.                         redirectToRoute('homepage');
  784.                     }
  785.                 } else if ($step == 'delivered') {
  786.                     $q->setEtatAvancement(' ');
  787.                     $q->setStatusFab($step);
  788.                 } else {
  789.                     $q->setEtatAvancement($step);
  790.                 }
  791.                 $em->persist($q);
  792.                 $em->flush();
  793.             }
  794.             // retour reponse en json
  795.             return new JsonResponse($o);
  796.         }
  797.         return new Response("Erreur : Requete incorrecte"400);
  798.     }
  799. }