src/Controller/RegistroController.php line 555

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Eventos;
  4. use App\Entity\Estilistas;
  5. use App\Entity\Clientes;
  6. use App\Entity\Productos;
  7. use App\Entity\SoldProducts;
  8. use App\Entity\Notifications;
  9. use App\Form\UserType;
  10. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  11. use Symfony\Component\HttpFoundation\Response;
  12. use Symfony\Component\HttpFoundation\Request;
  13. use Symfony\Component\Asset\Package;
  14. use Doctrine\ORM\EntityManagerInterface;
  15. use Symfony\Component\HttpFoundation\JsonResponse;
  16. use Symfony\Component\Routing\Annotation\Route;
  17. use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
  18. use Symfony\Component\Validator\Constraints\DateTime;
  19. use Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy;
  20. use Symfony\Component\HttpFoundation\RedirectResponse;
  21. class RegistroController extends AbstractController
  22. {
  23.     private function getLanguage()
  24.     {
  25.       
  26.       $language "es";
  27.       if (isset($_COOKIE['lang']))
  28.       {
  29.         $language $_COOKIE['lang'];
  30.       }
  31.       $package = new Package(new EmptyVersionStrategy());
  32.       $urlLang $package->getUrl('language/'.$language.'.json');
  33.       $lang json_decode(file_get_contents($urlLang));
  34.       return $lang;
  35.     }
  36.     function activeWorkers($em)
  37.     {
  38.       $wokerName = [];
  39.       $user $this->getUser();
  40.       if (method_exists($user'getCompany')) { $company$user->getCompany()->getId(); }
  41.       else{ $company $user->getId(); } 
  42.       // $em = $this->getDoctrine()->getManager();
  43.       $workers $em->getRepository(Estilistas::class)->findBy(['enabled'=> true'company'=>$company]);
  44.       foreach ($workers as $worker
  45.       {
  46.         $wokerName[] = [ 
  47.           'id'          => $worker->getId(),
  48.           'nombre'      => $worker->getNombre(),
  49.           'apellidos'   => $worker->getApellidos()
  50.         ]; 
  51.       }
  52.       return $wokerName;
  53.     }
  54.     /**
  55.      * @Route("/registro", name="registro")
  56.      */
  57.     public function registro(Request $requestUserPasswordEncoderInterface $encoder): Response
  58.     //crear usuario
  59.       $user = new User();
  60.       $form $this->createForm(UserType::class, $user);
  61.       $form->handleRequest($request);
  62.       if ($form->isSubmitted() && $form->isValid())
  63.       {
  64.         $em $this->getDoctrine()->getManager();
  65.         $user->setRoles(['ROLE_ADMIN']);
  66.         $user->setPassword($encoder->encodePassword($user$form['password']->getData()));
  67.         $em->persist($user);
  68.         $em->flush();
  69.         $this->addFlash('exito''Data uploaded');
  70.         return $this->redirectToRoute('registro');
  71.       }
  72.         return $this->render('registro/index.html.twig', [
  73.             'formulario' => $form->createView(),
  74.         ]);
  75.     }
  76.     /**
  77.     * @Route("/access_registros", name="accessRegistros", options={"expose"=true})
  78.     */
  79.     public function accessRegistros(Request $requestEntityManagerInterface $em): Response
  80.     {
  81.       $user $this->getUser();
  82.       if (method_exists($user'getCompany')) { $company$user->getCompany(); }
  83.       else{ $company $user; } 
  84.       $lang self::getLanguage();
  85.       $workers self::activeWorkers($em);
  86.       if ($content $request->request->all()) 
  87.       {
  88.         if (!array_key_exists('workerName'$content)) 
  89.         {
  90.           $this->addFlash(
  91.             'error',
  92.             $lang->login->tellMeHowAreYou
  93.           );
  94.           return $this->render('registro/index.html.twig', [
  95.               'lang' => $lang,
  96.               'workers'=> $workers
  97.           ]);
  98.         }
  99.         $pass hash('sha256'$content['password']);
  100.         $fullName explode(","$content['workerName']);
  101.         $name $fullName[0];
  102.         $surname $fullName[1];
  103.         $id $fullName[2];
  104.         $codeConfirmed false;
  105.         $isAdmin false;
  106.         $worker $em->getRepository(Estilistas::class)->findOneBy(['id'=>$id]);
  107.         if ($worker
  108.         {
  109.           if ($worker->getCode() === $pass) {
  110.             $codeConfirmed true;
  111.             if ( in_array("ROLE_ADMIN"$worker->getRoles()) ) //$realPass->getAdminPass() == true
  112.             {
  113.               $isAdmin true;
  114.             }
  115.           }
  116.           if ($codeConfirmed) {
  117.             if ($isAdmin) {
  118.               return $this->redirectToRoute('registros', ['id'=>$worker->getId()]);
  119.             }else{
  120.               return $this->redirectToRoute('registrosWorker', ['id'=>$worker->getId()] );
  121.             }
  122.           }else{
  123.             $this->addFlash(
  124.               'error',
  125.               $lang->login->userNotActive
  126.             );
  127.             return $this->render('registro/index.html.twig', [
  128.               'lang' => $lang,
  129.               'workers'=> $workers
  130.           ]);
  131.           }
  132.           // if ($realPass->getNombre() == $name) 
  133.           // {
  134.           //   if ($realPass->getEnabled() == true) 
  135.           //   {
  136.           //     if ( in_array("ROLE_ADMIN", $realPass->getRoles()) ) //$realPass->getAdminPass() == true
  137.           //     {
  138.           //       return $this->redirectToRoute('registros', ['id'=>$realPass->getId()]);
  139.           //     }
  140.           //     else
  141.           //     {
  142.           //       return $this->redirectToRoute('registrosWorker', ['id'=>$realPass->getId()] );
  143.           //     }
  144.           //   }
  145.           //   else
  146.           //   {
  147.           //     $this->addFlash(
  148.           //         'error',
  149.           //         $lang->login->userNotActive
  150.           //       );
  151.           //       return $this->render('registro/index.html.twig', [
  152.           //         'lang' => $lang,
  153.           //         'workers'=> $workers
  154.           //     ]);
  155.           //   }
  156.           // }
  157.           // else
  158.           // {
  159.           //   $this->addFlash(
  160.           //     'error',
  161.           //     $lang->login->passIncorrect
  162.           //   );
  163.           //   return $this->render('registro/index.html.twig', [
  164.           //       'lang' => $lang,
  165.           //       'workers'=> $workers
  166.           //   ]);
  167.           // }
  168.         }
  169.         else 
  170.         {
  171.           $this->addFlash(
  172.             'error',
  173.             $lang->login->passIncorrect
  174.           );
  175.           return $this->render('registro/index.html.twig', [
  176.             'lang' => $lang,
  177.             'workers'=> $workers
  178.           ]);
  179.           // $response = new JsonResponse('error');
  180.         }
  181.       }
  182.       else
  183.       {
  184.         return $this->render('registro/index.html.twig', [
  185.           'data'=> new \DateTime(),
  186.           'lang' => $lang,
  187.           'workers'=> $workers
  188.         ]);
  189.       }
  190.       return $response;
  191.     }
  192.     /**
  193.     * @Route("/registros/{id}", name="registros")
  194.     */
  195.     public function resgitros($idRequest $requestEntityManagerInterface $em): Response
  196.     {
  197.       $user $this->getUser();
  198.       if ($user) {
  199.         if (method_exists($user'getCompany')) { $company$user->getCompany()->getId(); }
  200.         else{ $company $user->getId(); } 
  201.         $lang self::getLanguage();
  202.         $month $lang->setting->months;
  203.         foreach ($month as $mes)
  204.         {
  205.           $meses[] = $mes;
  206.         }
  207.         $workers = [];
  208.         $stylist $em->getRepository(Estilistas::class)->findBy(['company'=>$company'showed'=>1]);
  209.         if($stylist){
  210.           foreach ($stylist as $employee
  211.           { 
  212.             $workers[] = [
  213.               'id'      => $employee->getId(),
  214.               'name'    => $employee->getNombre(),
  215.               'surName' => $employee->getApellidos(),
  216.             ];
  217.           }
  218.         }
  219.   
  220.         $now = new \DateTime('Europe/london');
  221.         $fisrtDay = new \DateTime('first day of this month');
  222.         $mesesHastaAhora $now->format('m');
  223.   
  224.         return $this->render('registro/registros.html.twig', [
  225.           'dateStart'     => $fisrtDay,
  226.           'dateEnd'       => $now,
  227.           'months'        => $meses,
  228.           'lang'          => $lang,
  229.           'workers'       => $workers,
  230.           'userAccess'    => $id,
  231.           'notifications' => $notifications=[]
  232.         ]);
  233.       }else{
  234.         return $this->redirectToRoute('app_login');
  235.       }
  236.     }
  237.     /**
  238.      * @Route("/balance_serv", name="balanceServ", options={"expose"=true})
  239.      */
  240.     public function balanceServ(Request $requestEntityManagerInterface $em): Response
  241.     {
  242.       if ($request->isXmlHttpRequest())
  243.       {
  244.         $langself::getLanguage();
  245.         $user $this->getUser();
  246.         if (method_exists($user'getCompany')) { $company$user->getCompany()->getId(); }
  247.         else{ $company $user->getId(); }
  248.         $dateFrom = new \DateTime($request->request->get('desde'));
  249.         $dateTo = new \DateTime($request->request->get('hasta'));
  250.         $desde $dateFrom->format('Y-m-d').' 00:00:00';
  251.         $hasta $dateTo->format('Y-m-d').' 23:59:59';
  252.         $response = [];
  253.         $workers $em->getRepository(Estilistas::class)->findBy(['company'=>$company]);
  254.         foreach ($workers as $worker)
  255.         {
  256.           $detailsId = [];
  257.           $totalCash =0;
  258.           $totalCard =0;
  259.           $totalGiftCard =0;
  260.           $total =0;
  261.           $totalForward 0;
  262.           $elTotal 0;
  263.     
  264.           $result $em->getRepository(Eventos::class)->getRegistro($desde$hasta$worker->getId(), '#1c7430');
  265.           if (!empty($result))
  266.           {
  267.             $isResulttrue;
  268.             $paidBy='';
  269.             foreach ($result as $balanceWorker)
  270.             {
  271.               $servicios explode("-"$balanceWorker['servicios']);
  272.               $tamanio $servicios[0];
  273.               $services $servicios[1];
  274.               $total $balanceWorker['total'];
  275.   
  276.               $detailsId[] = [
  277.                 'id'          => $balanceWorker['id'],
  278.                 'customer'    =>$balanceWorker['kunde'],
  279.                 'description' =>$balanceWorker['descripcion'],
  280.                 'date'        =>$balanceWorker['start']->format('d/m/y'),
  281.                 'name'        =>$balanceWorker['nombre'],
  282.                 'payment'     =>$balanceWorker['payment'],
  283.                 'total'       =>$balanceWorker['total'],
  284.                 'cash'        => $balanceWorker['cash'],
  285.                 'card'        => $balanceWorker['card'],
  286.                 'giftCard'    => $balanceWorker['giftCard']
  287.               ];
  288.                 
  289.               if ($balanceWorker['payment'] == 1)
  290.               {
  291.                 $totalCash += $total;
  292.               }
  293.               elseif ($balanceWorker['payment'] == 2)
  294.               {
  295.                 $totalCard += $total;
  296.               }
  297.               elseif ($balanceWorker['payment'] == 3)
  298.               {
  299.                 if (!is_null($balanceWorker['cash'])) { $totalCash += $balanceWorker['cash']; $paidBy.='1';}
  300.                 if (!is_null($balanceWorker['card'])) { $totalCard += $balanceWorker['card']; $paidBy.='2';}
  301.                 if (!is_null($balanceWorker['giftCard'])) { $totalGiftCard += $balanceWorker['giftCard']; $paidBy.='3';}
  302.               }
  303.             }            
  304.           }
  305.           else
  306.           {
  307.             $isResultfalse;
  308.           }
  309.           $elTotal += $totalCash $totalCard $totalGiftCard;
  310.           $analiticTotal $elTotal $totalForward
  311.           if ($isResult) {
  312.             $response[]= [
  313.               'totalCash'         => $totalCash,
  314.               'totalCard'         => $totalCard,
  315.               'totalGiftCard'     => $totalGiftCard,
  316.               'totalDone'         => $elTotal,
  317.               'paidBy'            => $paidBy,
  318.               'estilista'         => $worker->getNombre(),
  319.               'detailsId'         => $detailsId,
  320.               'enabled'           => $worker->getEnabled()
  321.             ];
  322.           }else{
  323.             $response[]= [
  324.               'totalCash'         => 0,
  325.               'totalCard'         => 0,
  326.               'totalGiftCard'     => 0,
  327.               'totalDone'         => 0,
  328.               'paidBy'            => '',
  329.               'estilista'         => $worker->getNombre(),
  330.               'detailsId'         => $detailsId,
  331.               'enabled'           => $worker->getEnabled()
  332.             ];
  333.           }
  334.         }
  335.       }
  336.       else
  337.       {
  338.         $response = ['error'=>'no results found'];
  339.       }
  340.       return new JsonResponse(['response'=>$response'lang'=>$lang]);
  341.     }
  342.     /**
  343.      * @Route("/balance_booking", name="balanceBooking", options={"expose"=true})
  344.      */
  345.     public function balanceBooking(Request $requestEntityManagerInterface $em): Response
  346.     {
  347.       if ($request->isXmlHttpRequest())
  348.       {
  349.         $langself::getLanguage();
  350.         $user $this->getUser();
  351.         if (method_exists($user'getCompany')) { $company$user->getCompany()->getId(); }
  352.         else{ $company $user->getId(); } 
  353.         $langself::getLanguage();
  354.         $user $this->getUser();
  355.         if (method_exists($user'getCompany')) { $company$user->getCompany()->getId(); }
  356.         else{ $company $user->getId(); } 
  357.         $dateFrom = new \DateTime($request->request->get('desde'));
  358.         $dateTo = new \DateTime($request->request->get('hasta'));
  359.         $desde $dateFrom->format('Y-m-d').' 00:00:00';
  360.         $hasta $dateTo->format('Y-m-d').' 23:59:59';
  361.         // $state = $request->request->get('status');
  362.         // $estado = explode(',', $state);
  363.         $response = [];
  364.         $workers $em->getRepository(Estilistas::class)->findBy(['company'=>$company]);
  365.         foreach ($workers as $worker)
  366.         {
  367.           $detailsId = [];
  368.           $totalCash =0;
  369.           $totalCard =0;
  370.           $totalGiftCard =0;
  371.           $total =0;
  372.           $totalForward 0;
  373.           $elTotal 0;
  374.     
  375.           $result $em->getRepository(Eventos::class)->getRegistro($desde$hasta$worker->getId(), '#000000');
  376.           if (!empty($result))
  377.           {
  378.             $isResulttrue;
  379.             $paidBy='';
  380.             foreach ($result as $balanceWorker)
  381.             {
  382.               $servicios explode("-"$balanceWorker['servicios']);
  383.               $tamanio $servicios[0];
  384.               $services $servicios[1];
  385.               $total $balanceWorker['total'];
  386.   
  387.               $detailsId[] = [
  388.                 'id'          => $balanceWorker['id'],
  389.                 'customer'    => $balanceWorker['kunde'],
  390.                 'description' => $balanceWorker['descripcion'],
  391.                 'date'        => $balanceWorker['start']->format('d-M-Y'),
  392.                 'name'        => $balanceWorker['nombre'],
  393.                 'payment'     => $balanceWorker['payment'],
  394.                 'total'       => $balanceWorker['total'],
  395.                 'cash'        => $balanceWorker['cash'],
  396.                 'card'        => $balanceWorker['card'],
  397.                 'giftCard'    => $balanceWorker['giftCard']
  398.               ];
  399.   
  400.               $totalForward += $total;
  401.             }            
  402.           }
  403.           else
  404.           {
  405.             $isResultfalse;
  406.           }
  407.           $elTotal += $totalCash $totalCard $totalGiftCard;
  408.           $analiticTotal $elTotal $totalForward;
  409.           if ($isResult) {
  410.             $response[]= [
  411.               'totalForward'      => $totalForward,
  412.               'estilista'         => $worker->getNombre(),
  413.               'detailsId'         => $detailsId,
  414.               'enabled'           => $worker->getEnabled()
  415.             ];
  416.           }else{
  417.             $response[]= [
  418.               'totalForward'      => 0,
  419.               'estilista'         => $worker->getNombre(),
  420.               'detailsId'         => $detailsId,
  421.               'enabled'           => $worker->getEnabled()
  422.             ];
  423.           }
  424.         }
  425.       }
  426.       else
  427.       {
  428.         $response = ['error'=>'no results found'];
  429.       }
  430.       return new JsonResponse(['response'=>$response'lang'=>$lang]);
  431.     }
  432.     /**
  433.      * @Route("/balance_prod", name="balanceProd", options={"expose"=true})
  434.      */
  435.     public function balanceProd(Request $requestEntityManagerInterface $em): Response
  436.     {
  437.       if ($request->isXmlHttpRequest())
  438.       {
  439.         $langself::getLanguage();
  440.         $user $this->getUser();
  441.         if (method_exists($user'getCompany')) { $company$user->getCompany()->getId(); }
  442.         else{ $company $user->getId(); } 
  443.         $dateFrom = new \DateTime($request->request->get('desde'));
  444.         $dateTo = new \DateTime($request->request->get('hasta'));
  445.         $desde $dateFrom->format('Y-m-d').' 00:00:00';
  446.         $hasta $dateTo->format('Y-m-d').' 23:59:59';
  447.         // $state = $request->request->get('status');
  448.         // $stado = explode(',', $state);
  449.         $response = [];
  450.         $workers $em->getRepository(Estilistas::class)->findBy(['company'=>$company]);
  451.         foreach ($workers as $worker)
  452.         {
  453.           $totalProducts 0;
  454.           $detailsProd = [];
  455.           $products $em->getRepository(SoldProducts::class)->getProducts($desde$hasta$worker->getId());
  456.           if ($products
  457.           {
  458.             $isResulttrue;
  459.             foreach ($products as $prod
  460.             {
  461.               for ($i=0$i count($prod['productosId']); $i++) 
  462.               {
  463.                 $prueba $prod['productosId'][$i];
  464.                 $prodSplit explode('-'$prod['productosId'][$i]);
  465.                 $product $em->getRepository(Productos::class)->findOneBy(['id'=>$prodSplit[0]]);
  466.                 if ($product
  467.                 {
  468.                   $total $product->getPrecioVp() * $prodSplit[1];
  469.                   $detailsProd[] = [
  470.                     $product->getId(),
  471.                     $product->getCodigoProducto(),
  472.                     $product->getNombre(),
  473.                     $product->getMarca(),
  474.                     number_format($product->getPrecioVp(), 2),
  475.                     $prodSplit[1],
  476.                     number_format($total2),
  477.                     $prod['paymentMethod'],
  478.                     $prod['date']->format('d/m/y H:i'),
  479.                     number_format($prod['total'], 2)
  480.                   ];
  481.                 }
  482.                 // else
  483.                 // {
  484.                 //   $detailsProd[] = 'no data';
  485.                 // }
  486.               
  487.               $totalProducts $totalProducts $prod['total'];
  488.             }
  489.           }
  490.           else{
  491.             $isResultfalse;
  492.           }
  493.           if ($isResult) {
  494.             $response[]= [
  495.               'totalProducts'     => number_format($totalProducts2),
  496.               'estilista'         => $worker->getNombre(),
  497.               'detailsProd'       => $detailsProd,
  498.               'enabled'           => $worker->getEnabled()
  499.             ];
  500.           }else{
  501.             $response[]= [
  502.               'totalProducts'     => 0,
  503.               'estilista'         => $worker->getNombre(),
  504.               'detailsProd'       => $detailsProd,
  505.               'enabled'           => $worker->getEnabled()
  506.             ];
  507.           }
  508.         }
  509.       }
  510.       else
  511.       {
  512.         $response = ['error'=>'no results found'];
  513.       }
  514.       return new JsonResponse(['response'=>$response'lang'=>$lang]);
  515.     }
  516.     /**
  517.      * @Route("/balance_analitic", name="balanceAnalitic", options={"expose"=true})
  518.      */
  519.     public function balanceAnalitic(Request $requestEntityManagerInterface $em): Response
  520.     {
  521.       if ($request->isXmlHttpRequest())
  522.       {
  523.         $langself::getLanguage();
  524.         $user $this->getUser();
  525.         if (method_exists($user'getCompany')) { $company$user->getCompany()->getId(); }
  526.         else{ $company $user->getId(); } 
  527.         $dateFrom = new \DateTime($request->request->get('desde'));
  528.         $dateTo = new \DateTime($request->request->get('hasta'));
  529.         $desde $dateFrom->format('Y-m-d').' 00:00:00';
  530.         $hasta $dateTo->format('Y-m-d').' 23:59:59';
  531.         // $state = $request->request->get('status');
  532.         // $stado = explode(',', $state);
  533.         $response = [];
  534.         $workers $em->getRepository(Estilistas::class)->findBy(['company'=>$company]);
  535.         foreach ($workers as $worker)
  536.         {
  537.           $totalProducts 0;
  538.           $detailsProd = [];
  539.           $products $em->getRepository(SoldProducts::class)->getProducts($desde$hasta$worker->getId());
  540.           if ($products
  541.           {
  542.             foreach ($products as $prod
  543.             {
  544.               for ($i=0$i count($prod['productosId']); $i++) 
  545.               {
  546.                 $prodSplit explode('-'$prod['productosId'][$i]);
  547.                 $product $em->getRepository(Productos::class)->findOneBy(['id'=>$prodSplit[0]]);
  548.                 if ($product
  549.                 {
  550.                   $detailsProd[] = [
  551.                     $product->getId(),
  552.                     $product->getCodigoProducto(),
  553.                     $product->getNombre(),
  554.                     $product->getMarca(),
  555.                     $product->getPrecioVp(),
  556.                   ];
  557.                 }
  558.                 else
  559.                 {
  560.                   $detailsProd[] = 'no data';
  561.                 }
  562.               } 
  563.               $totalProducts $totalProducts $prod['total'];
  564.             }
  565.           }
  566.           $detailsId = [];
  567.           $totalCash =0;
  568.           $totalCard =0;
  569.           $totalGiftCard =0;
  570.           $total =0;
  571.           $totalForward 0;
  572.           $elTotal 0;
  573.           $result $em->getRepository(Eventos::class)->getAllRegistro($desde$hasta$worker->getId());
  574.           if (!empty($result))
  575.           {
  576.             $isResulttrue;
  577.             $paidBy='';
  578.             foreach ($result as $balanceWorker)
  579.             {
  580.               $servicios explode("-"$balanceWorker['servicios']);
  581.               $tamanio $servicios[0];
  582.               $services $servicios[1];
  583.               $total $balanceWorker['total'];
  584.   
  585.               $detailsId[] = [
  586.                 'id'          => $balanceWorker['id'],
  587.                 'customer'    =>$balanceWorker['kunde'],
  588.                 'description' =>$balanceWorker['descripcion'],
  589.                 'date'        =>$balanceWorker['start']->format('d-M-Y'),
  590.                 'name'        =>$balanceWorker['nombre'],
  591.                 'payment'     =>$balanceWorker['payment'],
  592.                 'total'       =>$balanceWorker['total']
  593.               ];
  594.   
  595.               if (!is_null($balanceWorker['payment']))
  596.               {
  597.                 if ($balanceWorker['payment'] == 1)
  598.                 {
  599.                   $totalCash += $total;
  600.                 }
  601.                 elseif ($balanceWorker['payment'] == 2)
  602.                 {
  603.                   $totalCard += $total;
  604.                 }
  605.                 elseif ($balanceWorker['payment'] == 3)
  606.                 {
  607.                   if (!is_null($balanceWorker['cash'])) { $totalCash += $balanceWorker['cash']; $paidBy.='1';}
  608.                   if (!is_null($balanceWorker['card'])) { $totalCard += $balanceWorker['card']; $paidBy.='2';}
  609.                   if (!is_null($balanceWorker['giftCard'])) { $totalGiftCard += $balanceWorker['giftCard']; $paidBy.='3';}
  610.                 }
  611.               }
  612.               else
  613.               {
  614.                 $totalForward += $total;
  615.               }
  616.   
  617.             }            
  618.           }
  619.           else
  620.           {
  621.             $isResultfalse;
  622.           }
  623.           $elTotal += $totalCash $totalCard $totalGiftCard;
  624.           $analiticTotal $elTotal $totalForward ;//+ $totalProducts;
  625.           if ($isResult) {
  626.             $response[]= [
  627.               'totalCash'         => number_format($totalCash2),
  628.               'totalCard'         => number_format($totalCard2),
  629.               'totalGiftCard'     => number_format($totalGiftCard2),
  630.               'totalProducts'     => number_format($totalProducts2),
  631.               'totalDone'         => number_format($elTotal2),
  632.               'analiticTotal'     => $analiticTotal,
  633.               'totalForward'      => number_format($totalForward2),
  634.               'paidBy'            => $paidBy,
  635.               'estilista'         => $worker->getNombre(),
  636.               'detailsId'         => $detailsId,
  637.               'detailsProd'       => $detailsProd,
  638.               'enabled'           => $worker->getEnabled()
  639.             ];
  640.           }else{
  641.             $response[]= [
  642.               'totalCash'         => 0,
  643.               'totalCard'         => 0,
  644.               'totalGiftCard'     => 0,
  645.               'totalProducts'     => number_format($totalProducts2),
  646.               'totalDone'         => 0,
  647.               'analiticTotal'     => 0,
  648.               'totalForward'      => 0,
  649.               'paidBy'            => '',
  650.               'estilista'         => $worker->getNombre(),
  651.               'detailsId'         => $detailsId,
  652.               'detailsProd'       => $detailsProd,
  653.               'enabled'           => $worker->getEnabled()
  654.             ];
  655.           }
  656.         }        
  657.       }
  658.       else
  659.       {
  660.         $response = ['error'=>'no results found'];
  661.       }
  662.       return new JsonResponse(['response'=>$response'lang'=>$lang]);
  663.     }
  664.     // /**
  665.     //  * @Route("/balance", name="balance", options={"expose"=true})
  666.     //  */
  667.     // public function balance(Request $request, EntityManagerInterface $em): Response
  668.     // {
  669.     //   if ($request->isXmlHttpRequest())
  670.     //   {
  671.     //     $lang= self::getLanguage();
  672.     //     $user = $this->getUser();
  673.     //     if (method_exists($user, 'getCompany')) { $company= $user->getCompany()->getId(); }
  674.     //     else{ $company = $user->getId(); } 
  675.     //     $dateFrom = new \DateTime($request->request->get('desde'));
  676.     //     $dateTo = new \DateTime($request->request->get('hasta'));
  677.     //     $desde = $dateFrom->format('Y-m-d').' 00:00:00';
  678.     //     $hasta = $dateTo->format('Y-m-d').' 23:59:59';
  679.     //     $state = $request->request->get('status');
  680.     //     $stado = explode(',', $state);
  681.     //     $response = [];
  682.     //     $workers = $em->getRepository(Estilistas::class)->findBy(['company'=>$company]);
  683.     //     foreach ($workers as $worker)
  684.     //     {
  685.     //       $totalProducts = 0;
  686.     //       $detailsProd = [];
  687.     //       $products = $em->getRepository(SoldProducts::class)->getProducts($desde, $hasta, $worker->getId());
  688.     //       if ($products) 
  689.     //       {
  690.     //         foreach ($products as $prod) 
  691.     //         {
  692.     //           $idProd = explode('-', $prod['idProductos']);
  693.     //           for ($i=0; $i < count($idProd); $i++) 
  694.     //           {
  695.     //             $product = $em->getRepository(Productos::class)->findOneBy(['id'=>$idProd[$i]]);
  696.     //             if ($product) 
  697.     //             {
  698.     //               $detailsProd[] = [
  699.     //                 $product->getId(),
  700.     //                 $product->getCodigoProducto(),
  701.     //                 $product->getNombre(),
  702.     //                 $product->getMarca(),
  703.     //                 $product->getPrecioVp(),
  704.     //               ];
  705.     //             }
  706.     //             else
  707.     //             {
  708.     //               $detailsProd[] = 'no data';
  709.     //             }
  710.     //           } 
  711.     //           $totalProducts = $totalProducts + $prod['total'];
  712.     //         }
  713.     //       }
  714.     //       $detailsId = [];
  715.     //       $totalCash =0;
  716.     //       $totalCard =0;
  717.     //       $totalGiftCard =0;
  718.     //       $total =0;
  719.     //       $totalForward = 0;
  720.     //       $elTotal = 0;
  721.     //       foreach ($stado as $status) 
  722.     //       {
  723.     //         $result = $em->getRepository(Eventos::class)->getRegistro($desde, $hasta, $worker->getId(), $status);
  724.     //         if (!empty($result))
  725.     //         {
  726.     //           $isResult= true;
  727.     //           $paidBy='';
  728.     //           foreach ($result as $balanceWorker)
  729.     //           {
  730.     //             $servicios = explode("-", $balanceWorker['servicios']);
  731.     //             $tamanio = $servicios[0];
  732.     //             $services = $servicios[1];
  733.     //             $total = $balanceWorker['total'];
  734.   
  735.     //             $detailsId[] = [
  736.     //               'id'          => $balanceWorker['id'],
  737.     //               'customer'    =>$balanceWorker['kunde'],
  738.     //               'description' =>$balanceWorker['descripcion'],
  739.     //               'date'        =>$balanceWorker['start']->format('d-M-Y'),
  740.     //               'name'        =>$balanceWorker['nombre'],
  741.     //               'payment'     =>$balanceWorker['payment'],
  742.     //               'total'       =>$balanceWorker['total']
  743.     //             ];
  744.   
  745.     //             if (array_key_exists(2, $servicios)) //si existe forma de pago
  746.     //             {
  747.     //               $formaPago = $servicios[2];
  748.     //             }
  749.     //             else{ $formaPago = 0; }
  750.   
  751.     //             if ($status == '#1c7430')
  752.     //             {
  753.     //               if ($balanceWorker['payment'] == 1)
  754.     //               {
  755.     //                 $totalCash += $total;
  756.     //               }
  757.     //               elseif ($balanceWorker['payment'] == 2)
  758.     //               {
  759.     //                 $totalCard += $total;
  760.     //               }
  761.     //               elseif ($balanceWorker['payment'] == 3)
  762.     //               {
  763.     //                 if (!is_null($balanceWorker['cash'])) { $totalCash += $balanceWorker['cash']; $paidBy.='1';}
  764.     //                 if (!is_null($balanceWorker['card'])) { $totalCard += $balanceWorker['card']; $paidBy.='2';}
  765.     //                 if (!is_null($balanceWorker['giftCard'])) { $totalGiftCard += $balanceWorker['giftCard']; $paidBy.='3';}
  766.     //                 // $totalNoRegistrado += $total;
  767.     //               }
  768.                   
  769.     //             }
  770.     //             else
  771.     //             {
  772.     //               $totalForward += $total;
  773.     //             }
  774.   
  775.     //           }
  776.               
  777.     //           // si checka los pagados o no
  778.     //           // if ($totalCash == 0 && $totalCard == 0 && $totalGiftCard == 0)
  779.     //           // {
  780.     //           //   $elTotal += $totalForward;
  781.     //           // }
  782.     //           // else
  783.     //           // {
  784.     //           //   $elTotal += $totalCash + $totalCard + $totalGiftCard;
  785.     //           // }
  786.   
  787.     //           // $elTotal += $totalCash + $totalCard + $totalGiftCard + $totalForward;
  788.             
  789.     //         }
  790.     //         else
  791.     //         {
  792.     //           $isResult= false;
  793.     //         }
  794.     //       }
  795.     //       $elTotal += $totalCash + $totalCard + $totalGiftCard;
  796.     //       $analiticTotal = $elTotal + $totalForward; 
  797.     //       if ($isResult) {
  798.     //         $response[]= [
  799.     //           'totalCash'         => $totalCash,
  800.     //           'totalCard'         => $totalCard,
  801.     //           'totalGiftCard'     => $totalGiftCard,
  802.     //           'totalProducts'     => $totalProducts,
  803.     //           'totalDone'         => $elTotal,
  804.     //           'analiticTotal'     => $analiticTotal,
  805.     //           'totalForward'      => $totalForward,
  806.     //           'paidBy'            => $paidBy,
  807.     //           'estilista'         => $worker->getNombre(),
  808.     //           'status'            => $status,
  809.     //           'detailsId'         => $detailsId,
  810.     //           'detailsProd'       => $detailsProd,
  811.     //           'enabled'           => $worker->getEnabled()
  812.     //         ];
  813.     //       }else{
  814.     //         $response[]= [
  815.     //           'totalCash'         => 0,
  816.     //           'totalCard'         => 0,
  817.     //           'totalGiftCard'     => 0,
  818.     //           'totalProducts'     => 0,
  819.     //           'totalDone'         => 0,
  820.     //           'analiticTotal'     => 0,
  821.     //           'totalForward'      => 0,
  822.     //           'paidBy'            => '',
  823.     //           'estilista'         => $worker->getNombre(),
  824.     //           'status'            => $status,
  825.     //           'detailsId'         => $detailsId,
  826.     //           'detailsProd'       => $detailsProd,
  827.     //           'enabled'           => $worker->getEnabled()
  828.     //         ];
  829.     //       }
  830.     //     }
  831.     //   }
  832.     //   else
  833.     //   {
  834.     //     $response = ['error'=>'no results found'];
  835.     //   }
  836.     //   return new JsonResponse(['response'=>$response, 'lang'=>$lang]);
  837.     // }
  838.     /**
  839.      * @Route("/acceso_balance", name="accesoBalance")
  840.      */
  841.     public function accesoBalance(Request $requestUserPasswordEncoderInterface $encoder): Response
  842.     {
  843.       $lang self::getLanguage();
  844.       return $this->render('registro/accesoBalance.html.twig', [
  845.           'formulario' => $form->createView(),
  846.           'lang' => $lang
  847.       ]);
  848.     }
  849.     // /**
  850.     //  * @Route("/get_profits/{id}", name="getProfits")
  851.     //  */
  852.     // public function getProfits($id, Request $request): Response
  853.     // {
  854.     //   $lang = self::getLanguage();
  855.     //   return $this->render('registro/profits.html.twig', [
  856.     //   //     'formulario' => $form->createView(),
  857.     //     'lang' => $lang,
  858.     //     'userAccess'    => $id,
  859.     //   ]);
  860.     // }
  861.     /**
  862.      * @Route("/vista_anual", name="vistaAnual", options={"expose"=true})
  863.      */
  864.     public function vistaAnual(Request $requestEntityManagerInterface $em): Response
  865.     {
  866.       if ($request->isXmlHttpRequest()) {
  867.         $lang self::getLanguage();
  868.         $user $this->getUser();
  869.         if (method_exists($user'getCompany')) { $company$user->getCompany(); }
  870.         else{ $company $user; } 
  871.         $year $request->request->get('year');
  872.         $max 1000;
  873.         if($company->getMax()){
  874.           if ($company->getMax() > $max) {
  875.             $max $company->getMax();
  876.           }
  877.         }else{
  878.           $company->setMax($max);
  879.           $em->flush();
  880.         }
  881.         $now = new \DateTime('Europe/London');
  882.         $anio $now->format('Y');
  883.         $anual=[];
  884.         $quantityYear=[];
  885.         if ($year != '' || $year != null)
  886.         {
  887.           $anio $year;
  888.         }
  889.   
  890.         for ($i=1$i <= 12$i++)
  891.         {
  892.           $desde $anio.'-'.$i.'-01 00:00:00';
  893.           $hasta $anio.'-'.$i.'-31 23:59:59';
  894.           $mensual $em->getRepository(Eventos::class)->getMothly($desde$hasta$company->getId());
  895.           //Codigo de test
  896.           // if (!$mensual) {
  897.           //   for ($x=1; $x <=12 ; $x++) { 
  898.           //     $mensual = [];
  899.           //     $aleatorio = mt_rand(3500, 20000);
  900.           //     $mensual[] = ['total'=> $aleatorio];
  901.           //   }
  902.           // }
  903.           //
  904.           $total=0;
  905.           $amount=0;
  906.           foreach ($mensual as $mes)
  907.           {
  908.             $porcent = ($mes['total']*100) / $max;
  909.             $result $porcent;
  910.             $total += $result;
  911.             $amount +=$mes['total']; 
  912.           }
  913.           if ($total $max) {
  914.             $company->setMax($total);
  915.             $em->flush();
  916.           }
  917.           $anual[] = $total;
  918.           $quantityYear[]= $amount;
  919.         }
  920.   
  921.         $actual $now->format('Y-m');
  922.         $from $actual.'-01 00:00:00';
  923.         $to $actual.'-31 23:59:59';
  924.         $nuevosClientes 0;
  925.         $newKunder $em->getRepository(Clientes::class)->getNewCostumers($from$to$company->getId());
  926.         foreach ($newKunder as $value)
  927.         {
  928.           $nuevosClientes++;
  929.         }
  930.         $response = new JsonResponse(['anual'=>$anual'max'=>$max'anio'=>$anio'newKunder'=>$nuevosClientes'amount'=>$quantityYear'new'=>$lang->setting->balance->newCustomers]);
  931.   
  932.         return $response
  933.       }
  934.       else{
  935.         throw new Exception("Error Processing Request"1);
  936.       }
  937.     }
  938.     // /**
  939.     //  * @Route("/db_import", name="dbImport")
  940.     //  */
  941.     // public function dbImport(Request $request, UserPasswordEncoderInterface $encoder, EntityManagerInterface $em): Response
  942.     // {
  943.     //   $server = "localhost";
  944.     //   $user = "sirox";
  945.     //   $pass = "Vidaeterna22";
  946.     //   $database = "tpv";
  947.     //   $conexion = mysqli_connect($server, $user, $pass, $database);
  948.     //
  949.     //   $query = mysqli_query($conexion, "SELECT * FROM eventos");
  950.     //   if (mysqli_num_rows($query))
  951.     //   {
  952.     //     while($listaEventos = mysqli_fetch_array($query))
  953.     //     {
  954.     //       // LETRAS NORUEGAS
  955.     //       $cambio1 = mb_convert_encoding($listaEventos['comentario'], "HTML-ENTITIES", "UTF-8");
  956.     //       $cambio2 = str_replace('&#2013265925;', 'å', $cambio1);
  957.     //       $cambio3 = str_replace('&#2013266168;', 'ø', $cambio2);
  958.     //       $cambio4 = str_replace('&#2013265926;', 'æ', $cambio3);
  959.     //       // $cambio4 = str_replace('&#2013265926;', 'Å', $cambio3);
  960.     //       $cambio5 = str_replace('&#2013265944;', 'Ø', $cambio4);
  961.     //       // $cambio6 = str_replace('&#2013265926;', 'Æ', $cambio3);
  962.     //       $cambio6 = str_replace('&#2013265921;', 'ø', $cambio5);
  963.     //
  964.     //
  965.     //       // NOMBRE DE CLIENTES
  966.     //       $query3 = mysqli_query($conexion, "SELECT * FROM clientes WHERE id = ".$listaEventos['id_cliente']);
  967.     //       if (mysqli_num_rows($query3))
  968.     //       {
  969.     //         while ($cliente = mysqli_fetch_array($query3))
  970.     //         {
  971.     //           $nombeCliente = $cliente['nombre'];
  972.     //         }
  973.     //       }
  974.     //
  975.     //
  976.     //
  977.     //
  978.     //       // DESCIPCION DE LOS SERVICIOS
  979.     //       $service = "";
  980.     //       $servicios1 = explode("-", $listaEventos['id_servicio']);
  981.     //       if (array_key_exists(1, $servicios1))
  982.     //       {
  983.     //         $servicios2 = explode(" / ", $servicios1[1]);
  984.     //       }
  985.     //       else{ $servicios2 = ['7','']; }
  986.     //       //
  987.     //       // // $service = var_dump($servicios2);
  988.     //       //
  989.     //       for ($i=0; $i <count($servicios2)-1 ; $i++) //Sacamos los nombres de los servicios asociados al evento
  990.     //       {
  991.     //         $query2 = mysqli_query($conexion, "SELECT * FROM servicios WHERE id = ".$servicios2[$i]);
  992.     //         if (mysqli_num_rows($query2))
  993.     //         {
  994.     //           while($serv = mysqli_fetch_array($query2))
  995.     //           {
  996.     //             $service .= $serv['servicio']." / ";
  997.     //           }
  998.     //         }
  999.     //       }
  1000.     //       //   // $serviceName = $em->getRepository(Servicios::class)->findOneBy(['id'=>$servicios2[$i]]); // MODIFICAR !!
  1001.     //       //   // if (!is_null($serviceName) )
  1002.     //       //   // {
  1003.     //       //   // }
  1004.     //
  1005.     //
  1006.     //
  1007.     //       $response[] = [
  1008.     //         'id'=>$listaEventos['id'],
  1009.     //         'start'=>$listaEventos['start'],
  1010.     //         'end'=>$listaEventos['end'],
  1011.     //         'color'=>$listaEventos['color'],
  1012.     //         'textColor'=>$listaEventos['textColor'],
  1013.     //         'total'=>$listaEventos['total'],
  1014.     //         'comentario'=>$cambio6,
  1015.     //         'id_cliente'=>$listaEventos['id_cliente'],
  1016.     //         'id_servicio'=>$listaEventos['id_servicio'],
  1017.     //         'id_producto'=>$listaEventos['id_producto'],
  1018.     //         'id_estilista'=>$listaEventos['id_estilista'],
  1019.     //         'nombreCliente'=>$nombeCliente,
  1020.     //         'descripcion'=>$service
  1021.     //         ];
  1022.     //     }
  1023.     //   }
  1024.     //
  1025.     //   foreach ($response as $value)
  1026.     //   {
  1027.     //     if ($value['id_cliente'] == 0)
  1028.     //     {
  1029.     //       $value['id_cliente'] = 1;
  1030.     //     }
  1031.     //     $estilista = $em->getRepository(Estilistas::class)->findOneBy(['id'=>$value['id_estilista']]);
  1032.     //     $cliente = $em->getRepository(Clientes::class)->findOneBy(['id'=>$value['id_cliente']]);
  1033.     //
  1034.     //     $eventos = new Eventos();
  1035.     //     $eventos->setStart(new \DateTime($value['start']));
  1036.     //     $eventos->setEnd(new \DateTime($value['end']));
  1037.     //     $eventos->setColor($value['color']);
  1038.     //     $eventos->setTextColor($value['textColor']);
  1039.     //     $eventos->setTotal($value['total']);
  1040.     //     $eventos->setComentario($value['comentario']);
  1041.     //     $eventos->setServicios($value['id_servicio']);
  1042.     //     $eventos->setProductos($value['id_producto']);
  1043.     //     $eventos->setEstilistas($estilista);
  1044.     //     $eventos->setClientes($cliente);
  1045.     //     $eventos->setDescripcion($value['descripcion']);
  1046.     //     $eventos->setKunde($value['nombreCliente']);
  1047.     //
  1048.     //     $em->persist($eventos);
  1049.     //   }
  1050.     //
  1051.     //   $em->flush();
  1052.     //   return new JsonResponse(['msg'=>'Data uploaded']);
  1053.     //
  1054.     // }
  1055.         //############-----REGISTROS WORKER-----##############
  1056.     /**
  1057.     * @Route("/registros_worker/{id}", name="registrosWorker")
  1058.     */
  1059.     public function resgitrosWorker($idRequest $requestEntityManagerInterface $em): Response
  1060.     {
  1061.       $lang self::getLanguage();
  1062.       // $fisrtDay = new \DateTime('first day of this month');
  1063.       // $lastDay = new \DateTime('last day of this month');
  1064.       // $now = new \DateTime('Europe/London');
  1065.       // $date = $now->format('Y-m');
  1066.       // $fecha = $now->format('M - Y');
  1067.       // $desde = $date.'-01 00:00:00';
  1068.       // $hasta = $date.'-31 23:59:59';
  1069.       // $status = '#1c7430';
  1070.       // $resultado=[];
  1071.       // $response =[];
  1072.       // $total=0;
  1073.       // $sueldo = 0;
  1074.       // $comision = 0;
  1075.       $worker $em->getRepository(Estilistas::class)->findOneBy(['id'=>$id]);
  1076.       // $eventos = $em->getRepository(Eventos::class)->getRegistro($desde, $hasta, $worker->getId(), $status);
  1077.       // foreach ($eventos as $totally)
  1078.       // {
  1079.       //   $total += $totally['total'];
  1080.       // }
  1081.       // $resultado = [
  1082.       //   'total'       => $total,
  1083.       //   'porcent'     => $worker->getPorcent(),
  1084.       //   'salary'      => $worker->getSalary(),
  1085.       //   'salaryHour'  => $worker->getSalaryHour()
  1086.       // ];
  1087.       // if ($resultado['porcent'] != 0) {
  1088.       //   $comision = $resultado['total'] * $resultado['porcent'] / 100;
  1089.       // }
  1090.       // if ($resultado['salary'] != 0) {
  1091.       //   $sueldo = $resultado['salary'];
  1092.       // }
  1093.       // POR COMISION
  1094.       // if ($resultado['salary'] == 0 && $resultado['salaryHour'] == 0)
  1095.       // {
  1096.       //   $comision = $resultado['total'] * $resultado['porcent'] / 100;
  1097.       // }
  1098.       // POR HORAS
  1099.       // elseif ($resultado['salary'] == 0 && $resultado['porcent'] == 0)
  1100.       // {
  1101.       // }
  1102.       // SUELDO FIJO
  1103.       // elseif ($resultado['porcent'] == 0 && $resultado['salaryHour'] == 0)
  1104.       // {
  1105.       //   $sueldo = $resultado['salary'];
  1106.       // }
  1107.       // // SUELDO FIJO + COMISIÓN
  1108.       // elseif ($resultado['salaryHour'] == 0)
  1109.       // {
  1110.       //   $sueldo = $resultado['salary'];
  1111.       //   $comision = $resultado['total'] * $resultado['porcent'] / 100;
  1112.       //   // $sueldo = $salary + $comision;
  1113.       // }
  1114.       // $response = [
  1115.       //   'total'     => $resultado['total'],
  1116.       //   'porcent'   => $resultado['porcent'],
  1117.       //   'fijo'      => $sueldo,
  1118.       //   'comision'  => $comision
  1119.       // ];
  1120.       
  1121.       return $this->render('registro/registrosWorker.html.twig', [
  1122.         'lang'          => $lang,
  1123.         'id'            => $worker->getId(),
  1124.         // 'fecha'         => $fecha,
  1125.         // 'firstDay'      => $fisrtDay, 
  1126.         // 'lastDay'       => $lastDay,
  1127.         'nombre'        => $worker->getNombre(),
  1128.         'apellidos'     => $worker->getApellidos(),
  1129.         // 'response'      => $response,
  1130.         'workers'       => self::activeWorkers($em)
  1131.       ]);
  1132.     }
  1133.     /**
  1134.      * @Route("/registros_worker_by_date", name="registrosWorkerByDate", options={"expose"=true})
  1135.      */
  1136.     public function registrosWorkerByDate(Request $requestEntityManagerInterface $em): Response
  1137.     {
  1138.       $response = new JsonResponse('nope');
  1139.       if ($request->isXMLHttpRequest()) 
  1140.       {
  1141.         $lang self::getLanguage();
  1142.         $status '#1c7430';
  1143.         $date $request->request->get('date');
  1144.         $from = new \DateTime($date.'-01');
  1145.         $lastDay date('t'strtotime("$date-01"));
  1146.         $to = new \DateTime($date.'-'.$lastDay);
  1147.         $desde $from->format('Y-m-d').' 00:00:00';
  1148.         $hasta $to->format('Y-m-d').' 23:59:59';
  1149.   
  1150.         $now = new \DateTime("now");
  1151.         $result=[];
  1152.         $response =[];
  1153.         $total=0;
  1154.         $sueldo 0;
  1155.         $comision 0;
  1156.         $comisionProd 0;
  1157.         $totalProd 0;
  1158.         $worker $em->getRepository(Estilistas::class)->findOneBy(['id'=>$request->request->get('id')]);
  1159.         $products $em->getRepository(SoldProducts::class)->getProducts($desde$hasta$worker->getId());
  1160.         $eventos $em->getRepository(Eventos::class)->getRegistro($desde$hasta$worker->getId(), $status);
  1161.         foreach ($eventos as $totally)
  1162.         {
  1163.           $total += $totally['total'];
  1164.         }
  1165.         $resultado = [
  1166.           'total'       => $total,
  1167.           'porcent'     => $worker->getPorcent(),
  1168.           'salary'      => $worker->getSalary(),
  1169.           'salaryHour'  => $worker->getSalaryHour()
  1170.         ];
  1171.   
  1172.         
  1173.          // POR COMISION
  1174.          if ($resultado['salary'] == && $resultado['salaryHour'] == 0)
  1175.          {
  1176.            $sueldo $resultado['total'] * $resultado['porcent'] / 100;
  1177.            $comision $sueldo;
  1178.          }
  1179.          // POR HORAS
  1180.          elseif ($resultado['salary'] == && $resultado['porcent'] == 0)
  1181.          {
  1182.            
  1183.          }
  1184.          // SUELDO FIJO
  1185.          elseif ($resultado['porcent'] == && $resultado['salaryHour'] == 0)
  1186.          {
  1187.            $sueldo $resultado['salary'];
  1188.          }
  1189.          // SUELDO FIJO + COMISIÓN
  1190.          elseif ($resultado['salaryHour'] == 0)
  1191.          {
  1192.            $salary $resultado['salary'];
  1193.            $comision $resultado['total'] * $resultado['porcent'] / 100;
  1194.            $sueldo $salary $comision;
  1195.          }
  1196.         // if ($resultado['porcent'] != 0) {
  1197.         //   $comision = $resultado['total'] * $resultado['porcent'] / 100;
  1198.         // }
  1199.         // if ($resultado['salary'] != 0) {
  1200.         //   $sueldo = $resultado['salary'];
  1201.         // }
  1202.         // POR COMISION
  1203.         // if ($resultado['salary'] == 0 && $resultado['salaryHour'] == 0)
  1204.         // {
  1205.         //   $comision = $resultado['total'] * $resultado['porcent'] / 100;
  1206.         // }
  1207.         // POR HORAS
  1208.         // elseif ($resultado['salary'] == 0 && $resultado['porcent'] == 0)
  1209.         // {
  1210.   
  1211.         // }
  1212.         // SUELDO FIJO
  1213.         // elseif ($resultado['porcent'] == 0 && $resultado['salaryHour'] == 0)
  1214.         // {
  1215.         //   $sueldo = $resultado['salary'];
  1216.         // }
  1217.         // // SUELDO FIJO + COMISIÓN
  1218.         // elseif ($resultado['salaryHour'] == 0)
  1219.         // {
  1220.         //   $sueldo = $resultado['salary'];
  1221.         //   $comision = $resultado['total'] * $resultado['porcent'] / 100;
  1222.         //   // $sueldo = $salary + $comision;
  1223.         // }
  1224.         if ($products){
  1225.           $comisionProd 0;
  1226.           foreach ($products as $product) {
  1227.             $comisionProd $comisionProd $product['total'];
  1228.             $totalProd $totalProd $product['total'];
  1229.           }
  1230.           $comisionProd $comisionProd $worker->getProductPercent() / 100;
  1231.           // $resultado['products'] = [
  1232.           //   'percent'   => $worker->getProductPercent(),
  1233.           //   'total'     => $comisionProd,
  1234.           //   'comision'  => $comisionProd * $worker->getProductPercent() / 100
  1235.           // ];
  1236.         }
  1237.   
  1238.         $response = [
  1239.           'total'         => $resultado['total'],
  1240.           'porcent'       => $resultado['porcent'],
  1241.           'fijo'          => $resultado['salary'],
  1242.           'comision'      => $comision,
  1243.           'comisionProd'  => $comisionProd,
  1244.           'totalProd'     => $totalProd,
  1245.           'percentProd'   => $worker->getProductPercent()
  1246.         ];
  1247.       }
  1248.       return new JsonResponse(['data'=>$response'lang'=>$lang]);
  1249.     }
  1250. }
  1251. // namespace App\Controller;
  1252. // use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  1253. // use Symfony\Component\HttpFoundation\Response;
  1254. // use Symfony\Component\Routing\Annotation\Route;
  1255. // class RegistroController extends AbstractController
  1256. // {
  1257. //     #[Route('/registro', name: 'app_registro')]
  1258. //     public function index(): Response
  1259. //     {
  1260. //         return $this->render('registro/index.html.twig', [
  1261. //             'controller_name' => 'RegistroController',
  1262. //         ]);
  1263. //     }
  1264. // }