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