src/Controller/FO/FOController.php line 31

Open in your IDE?
  1. <?php
  2. namespace App\Controller\FO;
  3. use App\Entity\FO\CompteBancaire;
  4. use App\Entity\FO\Societe;
  5. use App\Entity\GestionComerciale\Commande;
  6. use App\Entity\MarketPlace\CompteMarketPlace;
  7. use App\Entity\Widget\WidgetWidgetColonneUtilisateur;
  8. use App\Security\Voter\EntityVoter;
  9. use App\Service\Fabrication\OqtonService;
  10. use Doctrine\ORM\EntityManagerInterface;
  11. use Knp\Snappy\Pdf;
  12. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  13. use Symfony\Component\HttpFoundation\Request;
  14. use Symfony\Component\HttpFoundation\Response;
  15. use Symfony\Component\Routing\Annotation\Route;
  16. use Symfony\Component\Validator\Validation;
  17. use Symfony\Component\Validator\Validator\ValidatorInterface;
  18. use Symfony\Contracts\Translation\TranslatorInterface;
  19. class FOController extends AbstractController
  20. {
  21.     /**
  22.      * @Route("/", name="dtcfo_homepage")
  23.      */
  24.     public function homeAction(Request $requestEntityManagerInterface $em,OqtonService $oqtonService)
  25.     {
  26.         return $this->redirectToRoute('dtc_commande_liste');
  27.         //TEST4toto(Oqcam Nests)tututoto(Oqcam Create Orders)tututoto(Oqcam Nest Status)tutu
  28.         /*
  29.         $partage = "share";
  30.         $share = $oqtonService->connectToSmbShare($partage);
  31.         $liste = $oqtonService->listerDossier($share,"");
  32.         echo $liste;
  33.         echo "<hr/>";
  34.         */
  35.         /*
  36.         $partage = "Oqcam Nest Status";
  37.         $share = $oqtonService->connectToSmbShare($partage);
  38.         foreach ($share->dir('/') as $file) {
  39.             if($file->isDirectory()) echo "<div>DIR::(".$partage.") file_name:".$file->getName()."<div>";
  40.             else echo "<div>FILE::(".$partage.") file_name:".$file->getName()."<div>";
  41.             if(1!=1 and !$file->isDirectory() && substr($file->getName(), -4, 4) === 'json' && substr($file->getName(), 0, 5) != "order") {
  42.                 echo $file->getName()."<br/>";
  43.             }
  44.         }
  45.         echo "<hr/>";
  46.         $partage = "Oqcam Nests";
  47.         $share = $oqtonService->connectToSmbShare($partage);
  48.         foreach ($share->dir('/') as $file) {
  49.             if($file->isDirectory()) echo "<div>DIR::(".$partage.") file_name:".$file->getName()."<div>";
  50.             else echo "<div>FILE::(".$partage.") file_name:".$file->getName()."<div>";
  51.             if(1!=1 and !$file->isDirectory() && substr($file->getName(), -4, 4) === 'json' && substr($file->getName(), 0, 5) != "order") {
  52.                 echo $file->getName()."<br/>";
  53.             }
  54.         }
  55.         echo "<hr/>";
  56.         */
  57.         $user                $this->getUser();
  58.         $repo_widget_colonne $em->getRepository(WidgetWidgetColonneUtilisateur::class);
  59.         $widgets_colonne_1   $repo_widget_colonne->getWidgetsColonneUser($user1);
  60.         $widgets_colonne_2   $repo_widget_colonne->getWidgetsColonneUser($user2);
  61.         $widgets_colonne_3   $repo_widget_colonne->getWidgetsColonneUser($user3);
  62.         $repo_commande $em->getRepository(Commande::class);
  63.         $fin           = new \Datetime();
  64.         $debut         = new \Datetime();
  65.         $debut->modify('-30 days');
  66.         //echo "<div><br/>MOIS GLISSANT</div>";
  67.         //echo "<div>DEB : ".$debut->format("d/m/Y")."</div>";
  68.         //echo "<div>FIN : ".$fin->format("d/m/Y")."</div>";
  69.         $caMoisGlissant $repo_commande->getCa($debut$fin);
  70.         $mode_simplifie     $request->query->get('ms');
  71.         $comptesMarketPlace $em->getRepository(CompteMarketPlace::class)->findBy([
  72.                                                                                        "marketPlace"     => 1,
  73.                                                                                        "statut"          => true,
  74.                                                                                        'dateSuppression' => null,
  75.                                                                                    ]);
  76.         $societe $em->getRepository(Societe::class)->find(1);
  77.         if ((is_object($user) && is_object($user->getType()) && $user->getType()->getId() == 3) or $mode_simplifie == 1) {
  78.             return $this->render('FO/FO/home-simplifie.html.twig', [
  79.                 "societe"            => $societe,
  80.                 "widgets_colone_1"   => $widgets_colonne_1,
  81.                 "widgets_colone_2"   => $widgets_colonne_2,
  82.                 "widgets_colone_3"   => $widgets_colonne_3,
  83.                 "caMoisGlissant"     => $caMoisGlissant,
  84.                 'comptesMarketPlace' => $comptesMarketPlace,
  85.             ]);
  86.         }
  87.         return $this->render('FO/FO/home.html.twig', [
  88.             "societe"            => $societe,
  89.             "widgets_colone_1"   => $widgets_colonne_1,
  90.             "widgets_colone_2"   => $widgets_colonne_2,
  91.             "widgets_colone_3"   => $widgets_colonne_3,
  92.             "caMoisGlissant"     => $caMoisGlissant,
  93.             'comptesMarketPlace' => $comptesMarketPlace,
  94.         ]);
  95.     }
  96.     /**
  97.      * @Route("/test", name="dtcfo_test")
  98.      */
  99.     public function testAction(Request $requestEntityManagerInterface $emPdf $snappy)
  100.     {
  101.         $societe    $em->getRepository(Societe::class)->find(1);
  102.         $chemin_pdf 'PDF/Rapport-cloture/Rapport-cloture-toto.pdf';
  103.         if (file_exists($chemin_pdf)) {
  104.             unlink($chemin_pdf);
  105.         }
  106.         //$snappy->setOption('header-html',$header);
  107.         //$snappy->setOption('footer-html',$footer);
  108.         $snappy->setOption('margin-bottom'"0");
  109.         $snappy->setOption('margin-top'"0");
  110.         $snappy->setOption('margin-left'"0");
  111.         $snappy->setOption('margin-right'"0");
  112.         $snappy->generateFromHtml(
  113.             $this->renderView(
  114.                 'Transporteurs/RapportCloture/bordereau_depot_delivengo_pdf.html.twig',
  115.                 []
  116.             ),
  117.             $chemin_pdf
  118.         );
  119.         return $this->render('FO/PDF/conteneur_pdf.html.twig', [
  120.             'chemin_pdf' => '/'.$chemin_pdf,
  121.             'visualiser' => 'visualiser',
  122.         ]);
  123.     }
  124.     /**
  125.      * @Route("/qz/sign", name="dtc_sign_message_qz")
  126.      */
  127.     public function signMessageQzAction(Request $request) {
  128.         $req="";
  129.         $KEY __DIR__.'/../../Tools/Qz/private-key.pem';
  130.         $get $request->query->all();
  131.         if(isset($get['request'])) $req $get['request']; //GET method
  132.         $privateKey openssl_get_privatekey(file_get_contents($KEY));
  133.         $signature null;
  134.         openssl_sign($req$signature$privateKey"sha512"); // Use "sha1" for QZ Tray 2.0 and older
  135.         if ($signature) {
  136.             header("Content-type: text/plain");
  137.             return new Response(base64_encode($signature));
  138.             exit(0);
  139.         }
  140.         return new Response'<h1>Error signing message</h1>');
  141.         exit(1);
  142.     }
  143. }