src/Controller/Widget/WidgetCumpController.php line 41

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Widget;
  3. use App\Entity\FO\Cron;
  4. use App\Entity\FO\TacheCron;
  5. use App\Entity\GestionComerciale\Commande;
  6. use App\Form\Clients\ClientType;
  7. use App\Service\Articles\ArticleService;
  8. use Doctrine\ORM\EntityManagerInterface;
  9. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  10. use Symfony\Component\HttpFoundation\JsonResponse;
  11. use Symfony\Component\HttpFoundation\Request;
  12. use Symfony\Component\Process\Process;
  13. use Symfony\Component\Routing\Annotation\Route;
  14. class WidgetCumpController extends AbstractController
  15. {
  16.     //lancerProcessCump
  17.     //git 2
  18.     /**
  19.      * @Route("/cump/{id}/pourcentage-traitement", name="dtc_calcul_cump_pourcentage_traitement")
  20.      */
  21.     public function pourcentageTraitementAction(Request $requestCron $cronArticleService $service)
  22.     {
  23.         $pourcentageTraitement $service->pourcentageTraitementCalculCump($cron);
  24.         $response = new JsonResponse();
  25.         $response->setData([
  26.                                'pourcentageTraitement' => $pourcentageTraitement,
  27.                            ]);
  28.         return $response;
  29.     }
  30.     /**
  31.      * @Route("", name="")
  32.      */
  33.     public function widgetCumpAction(Request $request$parametres = [], EntityManagerInterface $em)
  34.     {
  35.         $repo_commande $em->getRepository(Commande::class);
  36.         $fin           = new \Datetime();
  37.         $repo_cron       $em->getRepository(Cron::class);
  38.         $repo_tache_cron $em->getRepository(TacheCron::class);
  39.         $tache           $repo_tache_cron->find(10);
  40.         $get             $request->query->all();
  41.         $derniersCron    $repo_cron->findBy(['tacheCron' => $tache], ['date' => 'DESC'], 10);
  42.         //print_r($parametres);
  43.         $cron_lancer      false;
  44.         $cron_calcul_cump false;
  45.         if (count($derniersCron) > 0) {
  46.             if (is_object($derniersCron[0]) && $derniersCron[0]->getDateFin() == null) {
  47.                 $cron_calcul_cump true;
  48.             } else {
  49.             }
  50.         }
  51.         if (array_key_exists('calculcump'$parametres) && $parametres["calculcump"] == "1") {
  52.             if ($cron_calcul_cump) {
  53.                 /*
  54.                 $this->addFlash(
  55.                     'warning',
  56.                    $translator->trans('Impossible de lancer le calcul du cump, un calcul est déja en cours')
  57.                 );
  58.                 */
  59.             } else {
  60.                 /*
  61.                 $this->addFlash(
  62.                     'notice',
  63.                    $translator->trans('Demande de calcul de cump en cours')
  64.                 );
  65.                 */
  66.                 if (array_key_exists('tous'$parametres) && $parametres["tous"] == "1") {
  67.                     $process  = new Process(['php''bin/console''genererCpumpArticle''0']);
  68.                 } else {
  69.                     $process  = new Process(['php''bin/console''genererCpumpArticle']);
  70.                 }
  71.                 $process->setWorkingDirectory($this->getParameter('kernel.project_dir'));
  72.                 $process->setOptions(['create_new_console' => true]);
  73.                 $process->start();
  74.                 $cron_calcul_cump true;
  75.                 $derniersCron     $repo_cron->findBy(['tacheCron' => $tache], ['date' => 'DESC'], 10);
  76.                 $cron_lancer      true;
  77.             }
  78.             //return $this->redirectToRoute('dtcfo_homepage',array());
  79.         }
  80.         return $this->render('Widget/Widget/cump.html.twig', [
  81.             "cron_calcul_cump" => $cron_calcul_cump,
  82.             "derniersCron"     => $derniersCron,
  83.             "cron_lancer"      => $cron_lancer,
  84.         ]);
  85.     }
  86. }