src/Controller/DefaultController.php line 671

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\HomeSlider;
  4. use App\Entity\Order;
  5. use App\Entity\OrderProduct;
  6. use App\Entity\Product;
  7. use App\Repository\HomePageRepository;
  8. use App\Repository\HomeSliderRepository;
  9. use App\Repository\OrderRepository;
  10. use App\Repository\ProductRepository;
  11. use App\Repository\SonataUserUserRepository;
  12. use App\Services\ApiConsumer;
  13. use App\Twig\Extension\MediaExtension;
  14. use App\Utils\EAS256CBC;
  15. use App\Utils\SeoUtils;
  16. use DateTime;
  17. use Doctrine\ORM\EntityManagerInterface;
  18. use PhpOffice\PhpSpreadsheet\Cell\DataType;
  19. use PhpOffice\PhpSpreadsheet\IOFactory;
  20. use PhpOffice\PhpSpreadsheet\Spreadsheet;
  21. use PhpOffice\PhpSpreadsheet\Shared\Date as ExcelDate;
  22. use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
  23. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  24. use Symfony\Component\HttpFoundation\JsonResponse;
  25. use Symfony\Component\HttpFoundation\Request;
  26. use Symfony\Component\HttpFoundation\Response;
  27. use Symfony\Component\HttpFoundation\StreamedResponse;
  28. use Symfony\Component\Routing\Annotation\Route;
  29. use Symfony\Component\Security\Core\Exception\AccessDeniedException;
  30. use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException;
  31. class DefaultController extends AbstractController
  32. {
  33.     protected readonly SeoUtils $seoUtils;
  34.     protected ApiConsumer            $apiConsumer;
  35.     protected EntityManagerInterface $em;
  36.     private static string            $default_task '5178';
  37.     public function __construct(SeoUtils $seoUtilsApiConsumer $apiConsumerEntityManagerInterface $em)
  38.     {
  39.         $this->seoUtils    $seoUtils;
  40.         $this->apiConsumer $apiConsumer;
  41.         $this->em          $em;
  42.     }
  43.     /**
  44.      * @Route("/{reactRouting}", name="homepage", requirements={"reactRouting"=".+"}, defaults={"reactRouting": null}, priority=-10)
  45.      */
  46.     public function indexAction(Request $request): Response
  47.     {
  48.         return $this->render('default/index.html.twig');
  49.     }
  50.     /**
  51.      * @Route("/data/Initial.json", name="data_home2")
  52.      */
  53.     public function dataHomeAction(Request $requestHomePageRepository $homePageRepositoryMediaExtension $media): \Symfony\Component\HttpFoundation\JsonResponse
  54.     {
  55.         $session $request->getSession();
  56.         if (!$session->has('user_password_hash')) {
  57.             return new JsonResponse([
  58.                                         'success' => false,
  59.                                         'message' => 'Debe iniciar sesión.'
  60.                                     ], Response::HTTP_UNAUTHORIZED); // 401
  61.         }
  62.         $page $homePageRepository->findOneBy([]);
  63.         $data[] = [
  64.             'bannerPrimary'   => [
  65.                 'id'         => 1,
  66.                 'imgDesktop' => $media->media($page->getBannerPrimaryDesktop()),
  67.                 'imgMobile'  => $media->media($page->getBannerPrimaryMobile()),
  68.                 'link'       => $page->getBannerPrimaryLink(),
  69.             ],
  70.             'bannerSecondary' => [
  71.                 'id'         => 2,
  72.                 'imgDesktop' => $media->media($page->getBannerSecondaryDesktop()),
  73.                 'imgMobile'  => $media->media($page->getBannerSecondaryMobile()),
  74.                 'link'       => $page->getBannerSecondaryLink(),
  75.             ],
  76.             'bannerTertiary'  => [
  77.                 'id'         => 3,
  78.                 'imgDesktop' => $media->media($page->getBannerTertiaryDesktop()),
  79.                 'imgMobile'  => $media->media($page->getBannerTertiaryMobile()),
  80.                 'link'       => $page->getBannerTertiaryLink(),
  81.             ],
  82.             'slides'          => array_values(array_map(
  83.                                                   fn(HomeSlider $item) => [
  84.                                                       'id'         => $item->getId(),
  85.                                                       'imgDesktop' => $media->media($item->getSlideDesktop()),
  86.                                                       'imgMobile'  => $media->media($item->getBannerMobile()),
  87.                                                       'link'       => $item->getLink(),
  88.                                                   ],
  89.                                                   array_filter(iterator_to_array($page->getSliders()), fn($item) => $item->isPublic())
  90.                                               )),
  91.         ];
  92.         return $this->json($data);
  93.     }
  94.     /**
  95.      * @Route("/data/batch.json", name="data_batch")
  96.      * @Route("/data/batch_json", name="data_batch2")
  97.      */
  98.     public function dataBatchAction(Request $requestOrderRepository $orderRepository): \Symfony\Component\HttpFoundation\JsonResponse
  99.     {
  100.         $id $request->query->get('id');
  101.         $session $request->getSession();
  102.         if (!$session->has('user_password_hash')) {
  103.             return new JsonResponse([
  104.                                         'success' => false,
  105.                                         'message' => 'Debe iniciar sesión.'
  106.                                     ], Response::HTTP_UNAUTHORIZED); // 401
  107.         }
  108.         $order $orderRepository->findOneBy(['ws_id' => (int)$id]);
  109.         $tracking $this->apiConsumer->getImportsTasksTracking($order->getId(), $order->getWsId(), $session->get('user_password_hash'));
  110.         $data[] =
  111.             [
  112.                 "id"              => $order->getId(),
  113.                 "idWeb"           => $order->getId(),
  114.                 "batchId"         => $order->getWsId(),
  115.                 "Cliente"         => '',
  116.                 "Estado"          => $tracking->estado,
  117.                 "detalleDeCarga"  => '0000',
  118.                 "FechaDeCarga"    => $tracking->start_process,
  119.                 "FechaDeProceso"  => $tracking->end_process,
  120.                 "FechaFinProceso" => $tracking->end_process,
  121.                 "detalle"         => $id,
  122.             ];
  123.         return $this->json($data);
  124.     }
  125.     /**
  126.      * @Route("/data/homeWork.json", name="data_homeWork")
  127.      * @Route("/data/homeWork_json", name="data_homeWork2")
  128.      */
  129.     public function dataHomeWorkAction(Request $request): \Symfony\Component\HttpFoundation\JsonResponse
  130.     {
  131.         $id $request->query->get('id');
  132.         $session $request->getSession();
  133.         if (!$session->has('user_password_hash')) {
  134.             return new JsonResponse([
  135.                                         'success' => false,
  136.                                         'message' => 'Debe iniciar sesión.'
  137.                                     ], Response::HTTP_UNAUTHORIZED); // 401
  138.         }
  139.         $tasks_ws $this->getTasksFormat($request$id);
  140.         $fields = [];
  141.         foreach ($tasks_ws as $tasks_w) {
  142.             $fields[] = $this->correctWorks($tasks_wtrue);
  143.         }
  144.         $field_last array_pop($fields);
  145.         $data = [];
  146.         $data[] =
  147.             [
  148.                 "id"             => $id,
  149.                 "IdWork"         => $id,
  150.                 "name"           => '',
  151.                 "modalContent"   => "Para armar el archivo de texto, crea filas con los datos separados por tabuladores y cada registro en una nueva línea, en el siguiente orden: " implode(", "$fields) . ' y ' $field_last,
  152.                 "exampleFile"    => $id $this->generateUrl('download_example', ['task_id' => $id]) : '',
  153.                 "exampleFileXls" => $id $this->generateUrl('download_example_xls', ['task_id' => $id]) : '',
  154.                 "example"        => [],
  155.             ];
  156.         return $this->json($data);
  157.     }
  158.     private function correctWorks($word$ucfirst false): string
  159.     {
  160.         $result = match ($word) {
  161.             'lot' => 'lote',
  162.             'hold' => 'Tratamiento',
  163.             default => $word,
  164.         };
  165.         return $ucfirst ucfirst($result) : $result;
  166.     }
  167.     /**
  168.      * @Route("/data/fileTranfer.json", name="data_file_tranfer")
  169.      * @Route("/data/fileTranfer_json", name="data_file_tranfer2")
  170.      */
  171.     public function dataFileTransferAction(Request $requestOrderRepository $orderRepository): \Symfony\Component\HttpFoundation\JsonResponse
  172.     {
  173.         $id $request->query->get('id');
  174.         $session $request->getSession();
  175.         if (!$session->has('user_password_hash')) {
  176.             return new JsonResponse([
  177.                                         'success' => false,
  178.                                         'message' => 'Debe iniciar sesión.'
  179.                                     ], Response::HTTP_UNAUTHORIZED); // 401
  180.         }
  181.         $works_ws  $this->apiConsumer->getImportsTasksList($id$session->get('user_password_hash'));
  182.         $orders_ws $this->apiConsumer->getPedidoSeguimiento($id$session->get('user_password_hash'));
  183.         $orders  = [];
  184.         $statuss = [];
  185.         foreach ($orders_ws as $order_ws) {
  186.             $order $orderRepository->findOneBy(['ws_id' => $order_ws->ob_oid]);
  187.             if ($order != null) {
  188.                 $data_merge = [
  189.                     'web_id'    => $order->getId(),
  190.                     'create_at' => $order->getCreateAt()->format('Y-m-d H:i:s'),
  191.                     'file'      => $order->getFileName() ?? '',
  192.                     'user'      => $order->getUser()->getUsername(),
  193.                     'client'    => $order->getUser()->getUsername(),
  194.                 ];
  195.                 $orders[]   = array_merge((array)$order_ws$data_merge);
  196.                 $statuss[]  = [
  197.                     'id'   => $order->getId(),
  198.                     'name' => $order_ws->Estado
  199.                 ];
  200.             }
  201.         }
  202.         $works = [];
  203.         foreach ($works_ws as $work) {
  204.             $works[] = [
  205.                 'id'     => $work->Id_Tarea,
  206.                 'IdWork' => $work->Id_Tarea,
  207.                 'name'   => $work->Descripcion,
  208.             ];
  209.         }
  210.         $order_list = [];
  211.         foreach ($orders as $order) {
  212.             $order        = (object)$order;
  213.             $order_list[] =
  214.                 [
  215.                     "id"             => $order->web_id,
  216.                     "idWeb"          => $order->web_id,
  217.                     "BatchId"        => $order->ob_oid,
  218.                     "Carga"          => $order->create_at,
  219.                     "Archivo"        => $order->file,
  220.                     "Usuario"        => $order->user,
  221.                     "Cliente"        => $order->client,
  222.                     "Estado"         => $order->Estado,
  223.                     "detalleDeCarga" => $order->Cita,
  224.                     "FechaDeCarga"   => $order->Fecha_Cita,
  225.                     "FechaDeProceso" => $order->Fecha_Cita,
  226.                     "detalle"        => 'None',
  227.                 ];
  228.         }
  229.         $data = [
  230.             [
  231.                 'stateList' => $statuss,
  232.                 'orderList' => $order_list,
  233.                 'homework'  => $works,
  234.             ]
  235.         ];
  236.         return $this->json($data);
  237.     }
  238.     /**
  239.      * @param Request                  $request
  240.      * @param ProductRepository        $productRepository
  241.      * @param SonataUserUserRepository $userRepository
  242.      * @param OrderRepository          $orderRepository
  243.      * @return JsonResponse
  244.      * @Route("/intranet/process_order", name="process_order")
  245.      */
  246.     public function processOrdenAction(Request $requestProductRepository $productRepositorySonataUserUserRepository $userRepositoryOrderRepository $orderRepository)
  247.     {
  248.         $session $request->getSession();
  249.         if (!$session->has('user_password_hash')) {
  250.             return new JsonResponse([
  251.                                         'success' => false,
  252.                                         'message' => 'Debe iniciar sesión.'
  253.                                     ], Response::HTTP_UNAUTHORIZED); // 401
  254.         }
  255.         $p              $request->request;
  256.         $data           json_decode($p->get('orderData'));
  257.         $data           $data->data ?? null;
  258.         $user_pass_hash $session->get('user_password_hash');
  259.         $response = [
  260.             "status"  => 'error',
  261.             "message" => 'No se pudo procesar el pedido',
  262.         ];
  263.         $user $userRepository->findOneBy(['user_pass_hash' => $user_pass_hash]);
  264.         if ($data) {
  265.             $order = new Order();
  266.             $order->setUser($user);
  267.             $order->setAccountId($data->accountId);
  268.             $order->setTasks(self::$default_task);
  269.             $errors = [];
  270.             if (!$data->info->name) {
  271.                 $errors['name'] = 'El nombre es obligatorio';
  272.             }
  273.             if (!$data->info->phone) {
  274.                 $errors['phone'] = 'El teléfono es obligatorio';
  275.             }
  276.             if (!$data->info->address) {
  277.                 $errors['phone'] = 'La dirección es obligatoria';
  278.             }
  279.             if (!$data->info->city) {
  280.                 $errors['city'] = 'La ciudad es obligatoria';
  281.             }
  282.             if (count($errors) < 0) {
  283.                 $response = [
  284.                     "status"  => 'error',
  285.                     "message" => 'Debes completar todos los campos obligatorios',
  286.                     "errors"  => $errors,
  287.                 ];
  288.                 return $this->json($response);
  289.             }
  290.             $order->setContactName($data->info->name);
  291.             $order->setContactPhone($data->info->phone);
  292.             $order->setContactAddress($data->info->address);
  293.             $order->setContactCity($data->info->city);
  294.             $this->em->persist($order);
  295.             $this->em->flush();
  296.             foreach ($data->list as $item) {
  297.                 $product $productRepository->findOneBy(['product_id' => $item->id]);
  298.                 if (!$product) {
  299.                     $product = new Product();
  300.                     $product->setProductId($item->id);
  301.                     $product->setName($item->name);
  302.                     $product->setPackaging($item->packagingType);
  303.                     $this->em->persist($product);
  304.                     $this->em->flush();
  305.                 }
  306.                 $order_prod = new OrderProduct();
  307.                 $order_prod->setOrder($order);
  308.                 $order_prod->setProduct($product);
  309.                 $order_prod->setBatch($item->selectBatch);
  310.                 $order_prod->setQuantity($item->total);
  311.                 $this->em->persist($order_prod);
  312.                 $this->em->flush();
  313.             }
  314.             $send $this->sendFileBase64($request$orderfalse);
  315.             if ($send) {
  316.                 $response = [
  317.                     "status"  => 'success',
  318.                     "message" => 'Pedido recibido correctamente',
  319.                 ];
  320.             }
  321.         }
  322.         return $this->json($response);
  323.     }
  324.     /**
  325.      * @param Request $request
  326.      * @return JsonResponse
  327.      * @Route("/intranet/process_order_file", name="process_order_file")
  328.      */
  329.     public function processOrdenFileAction(Request $requestProductRepository $productRepositorySonataUserUserRepository $userRepositoryOrderRepository $orderRepository)
  330.     {
  331.         $session $request->getSession();
  332.         if (!$session->has('user_password_hash')) {
  333.             return new JsonResponse([
  334.                                         'success' => false,
  335.                                         'message' => 'Debe iniciar sesión.'
  336.                                     ], Response::HTTP_UNAUTHORIZED); // 401
  337.         }
  338.         $user_pass_hash $session->get('user_password_hash');
  339.         $account_id     $request->request->get('accountId');
  340.         $id_home_work   $request->request->get('idHomeWork');
  341.         $file $request->files->get('file');
  342. //        $products = $this->apiConsumer->getclientInv($account_id, $session->get('user_password_hash'));
  343.         $allowedMimeTypes = [
  344.             'text/plain',                 // .txt
  345.             'application/vnd.ms-excel',   // .xls (antiguo formato de Excel)
  346.             'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'// .xlsx
  347.         ];
  348.         $mimeType $file->getMimeType();
  349.         if (!in_array($mimeType$allowedMimeTypes)) {
  350.             $response = [
  351.                 "status"  => 'error',
  352.                 "message" => 'El archivo debe ser en formato TXT o Excel',
  353.             ];
  354.             return $this->json($response);
  355.         }
  356.         if ($mimeType == 'text/plain') {
  357.             $lines file($fileFILE_IGNORE_NEW_LINES FILE_SKIP_EMPTY_LINES);
  358.         } else {
  359.             $spreadsheet IOFactory::load($file->getPathname());
  360.             $sheet       $spreadsheet->getActiveSheet();
  361.             $lines       = [];
  362.             // --- Rango de fechas dinámico: 5 años antes y 5 después de hoy ---
  363.             $today     = new \DateTime();
  364.             $startDate = (clone $today)->modify('-5 years');
  365.             $endDate   = (clone $today)->modify('+5 years');
  366.             $startSerial \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($startDate);
  367.             $endSerial   \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($endDate);
  368.             // --- Fin del rango dinámico ---
  369.             foreach ($sheet->getRowIterator() as $row) {
  370.                 $rowData = [];
  371.                 foreach ($row->getCellIterator() as $cell) {
  372.                     $value $cell->getValue();
  373.                     // Heurística para detectar y convertir fechas probables en el rango dinámico
  374.                     if (is_numeric($value) && $value >= $startSerial && $value <= $endSerial) {
  375.                         try {
  376.                             // Intentar convertir el serial de Excel a fecha
  377.                             $dateTime ExcelDate::excelToDateTimeObject($value);
  378.                             $value    $dateTime->format('d/m/Y');
  379.                         } catch (\Exception $e) {
  380.                             // Si falla, mantener el valor como string
  381.                             $value = (string)$value;
  382.                         }
  383.                     } else {
  384.                         // Para todos los demás valores, solo convertir a string
  385.                         $value = (string)$value;
  386.                     }
  387.                     $rowData[] = $value;
  388.                 }
  389.                 // Solo agregar la fila si tiene al menos un valor no vacío
  390.                 if (!empty(array_filter($rowData, function ($cell) {
  391.                     return trim($cell) !== '';
  392.                 }))) {
  393.                     $lines[] = $rowData;
  394.                 }
  395.             }
  396.         }
  397.         $user $userRepository->findOneBy(['user_pass_hash' => $user_pass_hash]);
  398.         $order = new Order();
  399.         $order->setUser($user);
  400.         $order->setAccountId($account_id);
  401.         $order->setTasks($id_home_work);
  402.         $order->setFileName($file->getClientOriginalName());
  403.         $this->em->persist($order);
  404.         $this->em->flush();
  405.         /*foreach ($lines as $line) {
  406.             if ($mimeType == 'text/plain') {
  407.                 $columns = explode("\t", $line); // Dividir la línea en columnas
  408.             } else {
  409.                 $columns = $line;
  410.             }
  411.             $fields       = [];
  412.             $tasks_format = $this->getTasksFormat($request, $id_home_work);
  413.             foreach ($columns as $key => $field) {
  414.                 if (isset($tasks_format[$key])) {
  415.                     $fields[$tasks_format[$key]] = trim($field);
  416.                 }
  417.             }
  418.             
  419. //            dump($fields);
  420.             $product = $productRepository->findOneBy(['product_id' => $fields['producto']]);
  421.             
  422.             if (!$product) {
  423.                 $prod_ws = array_filter($products, function ($item) use ($fields) {
  424.                     return trim($item->producto_cod) === trim($fields['producto']);
  425.                 });
  426.                 if (!isset($prod_ws[0])) {
  427. //                    dump("No se encontró el producto con código: " . $fields['producto']);
  428.                     continue;
  429.                 }
  430.                 $prod_ws = $prod_ws[0];
  431.                 $product = new Product();
  432.                 $product->setProductId($prod_ws->producto_cod);
  433.                 $product->setName($prod_ws->desc_prod);
  434.                 $product->setPackaging($prod_ws->Unim);
  435.                 $this->em->persist($product);
  436.                 $this->em->flush();
  437.             }
  438.             // Validar que los campos requeridos existan
  439.             if (!isset($fields['cantidad']) || !isset($fields['hold']) || !isset($fields['Dirección']) || !isset($fields['Ciudad'])) {
  440.                 continue;
  441.             }
  442.             $order_prod = new OrderProduct();
  443.             $order_prod->setOrder($order);
  444.             $order_prod->setProduct($product);
  445.             $order_prod->setQuantity((int)$fields['cantidad']);
  446.             $order_prod->setHold($fields['hold']);
  447.             $order_prod->setAddress($fields['Dirección']);
  448.             $order_prod->setCity($fields['Ciudad']);
  449.             $this->em->persist($order_prod);
  450.             $this->em->flush();
  451.             
  452. //            dump($order_prod);
  453.         }*/
  454.         if ($mimeType == 'text/plain') {
  455.             $base64 base64_encode(file_get_contents($file->getPathname()));
  456.         } else {
  457.             $content '';
  458.             foreach ($lines as $line) {
  459.                 $content .= implode("\t"$line) . "\n";
  460.             }
  461.             $base64 base64_encode($content);
  462.         }
  463.         $send $this->sendFileBase64($request$order$id_home_work$base64/*$mimeType == 'text/plain' ? $base64 : false*/);
  464.         if ($send) {
  465.             $response = [
  466.                 "status"  => 'success',
  467.                 "message" => 'Pedido recibido correctamente',
  468.             ];
  469.         } else {
  470.             $response = [
  471.                 "status"  => 'error',
  472.                 "message" => 'No se pudo procesar el pedido',
  473.             ];
  474.         }
  475.         return $this->json($response);
  476.     }
  477.     public function sendFileBase64($requestOrder $order$task false$base64 false)
  478.     {
  479.         $session $request->getSession();
  480.         if (!$session->has('user_password_hash')) {
  481.             return new JsonResponse([
  482.                                         'success' => false,
  483.                                         'message' => 'Debe iniciar sesión.'
  484.                                     ], Response::HTTP_UNAUTHORIZED); // 401
  485.         }
  486.         $user_pass_hash $session->get('user_password_hash');
  487.         $products $this->em->getRepository(OrderProduct::class)->findBy(['order' => $order->getId()]);
  488.         $web_task_id     self::$default_task;
  489.         $web_task_detail = [
  490.             'cod_cliente',
  491.             'producto_cod',
  492.             'Lote',
  493.             'Cant_Solicitada',
  494.             'Dirección',
  495.             'NroReferencia',
  496.         ];
  497.         if ($base64) {
  498.             $file_64 $base64;
  499.         } else {
  500.             $data = [];
  501.             foreach ($products as $prod) {
  502.                 $tmp = [];
  503.                 foreach ($task === false $web_task_detail $this->getTasksFormat($request$task) as $field) {
  504.                     $tmp[] = $this->resolverFieldName($prod$field);
  505.                 }
  506.                 $data[] = $tmp;
  507.             }
  508.             $content "";
  509.             foreach ($data as $row) {
  510.                 $content .= implode("\t"$row) . "\n";
  511.             }
  512.             $file_64 base64_encode($content);
  513.         }
  514. //        dump(base64_decode($file_64));
  515. //        exit;
  516.         $send $this->apiConsumer->getImportsTasksFile($user_pass_hash$task === false '76796070-0' $order->getAccountId(), $order->getId(), $task === false $web_task_id $task$file_64);
  517.         if ($send) {
  518.             $order->setStatus('Enviado');
  519.             $order->setWsId($send);
  520.             $this->em->persist($order);
  521.             $this->em->flush();
  522.             return true;
  523.         } else {
  524.             return false;
  525.         }
  526.     }
  527.     /**
  528.      * @Route("/data/product.json", name="data_products")
  529.      */
  530.     public function dataProductsAction(Request $request): \Symfony\Component\HttpFoundation\JsonResponse
  531.     {
  532.         $id $request->query->get('id');
  533.         $session $request->getSession();
  534.         if (!$session->has('user_password_hash')) {
  535.             return new JsonResponse([
  536.                                         'success' => false,
  537.                                         'message' => 'Debe iniciar sesión.'
  538.                                     ], Response::HTTP_UNAUTHORIZED); // 401
  539.         }
  540.         $products $this->apiConsumer->getclientInv($id$session->get('user_password_hash'));
  541.         $data     = [];
  542.         $data_tmp = [];
  543.         foreach ($products as $product) {
  544.             if (rtrim($product->Tratamiento) == '') {
  545.                 $data_tmp[$product->producto_cod][] =
  546.                     [
  547.                         "producto_cod" => $product->producto_cod,
  548.                         "desc_prod"    => $product->desc_prod,
  549.                         "Unim"         => $product->Unim,
  550.                         'Lote'         => $product->Lote,
  551.                         'Disponible'   => $product->Disponible,
  552.                         'Tratamiento'  => $product->Tratamiento,
  553.                     ];
  554.             }
  555.         }
  556.         foreach ($data_tmp as $product) {
  557.             $data_lote  = [];
  558.             $total_lote = [];
  559.             foreach ($product as $lote) {
  560.                 $data_lote[]  = [
  561.                     'batch'    => $lote['Lote'],
  562.                     'quantity' => $lote['Disponible'],
  563.                 ];
  564.                 $total_lote[] = (int)$lote['Disponible'];
  565.             }
  566.             $data[] =
  567.                 [
  568.                     "id"                => $product[0]['producto_cod'],
  569.                     "name"              => $product[0]['desc_prod'],
  570.                     "stored"            => array_sum($total_lote),
  571.                     "packagingType"     => $product[0]['Unim'],
  572.                     "packagingQuantity" => null,
  573.                     'batch'             => $data_lote
  574.                 ];
  575.         }
  576.         return $this->json($data);
  577.     }
  578.     /**
  579.      * @Route("/data/inventory.json", name="data_inventory")
  580.      * @Route("/data/inventory_json", name="data_inventory2")
  581.      */
  582.     public function dataInventoryAction(Request $request): \Symfony\Component\HttpFoundation\JsonResponse
  583.     {
  584.         $id $request->query->get('id');
  585.         $session $request->getSession();
  586.         if (!$session->has('user_password_hash')) {
  587.             return new JsonResponse([
  588.                                         'success' => false,
  589.                                         'message' => 'Debe iniciar sesión.'
  590.                                     ], Response::HTTP_UNAUTHORIZED); // 401
  591.         }
  592.         $products $this->apiConsumer->getclientInv($id$session->get('user_password_hash'));
  593.         $prod = [];
  594.         foreach ($products as $product) {
  595.             $prod[] =
  596.                 [
  597.                     "id"            => $product->producto_cod,
  598.                     "name"          => $product->desc_prod,
  599.                     "stored"        => $product->Total,
  600.                     "packagingType" => $product->Unim,
  601.                     "batch"         => $product->Lote,
  602.                     "Treatment"     => $product->Tratamiento,
  603.                 ];
  604.         }
  605.         $data = [
  606.             [
  607.                 'file' => $this->generateUrl('download_inventory', ['id' => $id]),
  608.                 'data' => $prod,
  609.             ]
  610.         ];
  611.         return $this->json($data);
  612.     }
  613.     /**
  614.      * @Route("/download/inventory", name="download_inventory")
  615.      */
  616.     public function downloadInventoryAction(Request $request): StreamedResponse
  617.     {
  618.         $id $request->query->get('id');
  619.         $session $request->getSession();
  620.         if (!$session->has('user_password_hash')) {
  621.             return new JsonResponse([
  622.                                         'success' => false,
  623.                                         'message' => 'Debe iniciar sesión.'
  624.                                     ], Response::HTTP_UNAUTHORIZED); // 401
  625.         }
  626.         $products $this->apiConsumer->getclientInv($id$session->get('user_password_hash'));
  627.         $spreadsheet = new Spreadsheet();
  628.         $sheet       $spreadsheet->getActiveSheet();
  629.         $sheet->setCellValue('A1''Código');
  630.         $sheet->setCellValue('B1''Nombre');
  631.         $sheet->setCellValue('C1''Lote');
  632.         $sheet->setCellValue('D1''Tratamiento');
  633.         $sheet->setCellValue('E1''Disponible');
  634.         $sheet->setCellValue('F1''Reservado');
  635.         $sheet->setCellValue('G1''En despacho');
  636.         $sheet->setCellValue('H1''En Preparación');
  637.         $sheet->setCellValue('I1''Merma');
  638.         $sheet->setCellValue('J1''Total');
  639.         $sheet->setCellValue('K1''Embalaje');
  640.         $row 2;
  641.         foreach ($products as $item) {
  642.             $sheet->setCellValueExplicit('A' $row$item->producto_codDataType::TYPE_STRING);
  643. //            $sheet->setCellValue('A' . $row, $item->producto_cod);
  644.             $sheet->setCellValueExplicit('B' $row$item->desc_prodDataType::TYPE_STRING);
  645.             $sheet->setCellValueExplicit('C' $row$item->LoteDataType::TYPE_STRING);
  646.             $sheet->setCellValueExplicit('D' $row$item->TratamientoDataType::TYPE_STRING);
  647.             $sheet->setCellValueExplicit('E' $row$item->DisponibleDataType::TYPE_STRING);
  648.             $sheet->setCellValueExplicit('F' $row$item->ReservadoDataType::TYPE_STRING);
  649.             $sheet->setCellValueExplicit('G' $row$item->En_DespachoDataType::TYPE_STRING);
  650.             $sheet->setCellValueExplicit('H' $row$item->En_PreparaciónDataType::TYPE_STRING);
  651.             $sheet->setCellValueExplicit('I' $row$item->MermaDataType::TYPE_STRING);
  652.             $sheet->setCellValueExplicit('J' $row$item->TotalDataType::TYPE_STRING);
  653.             $sheet->setCellValueExplicit('K' $row$item->UnimDataType::TYPE_STRING);
  654.             $row++;
  655.         }
  656.         $response = new StreamedResponse(function () use ($spreadsheet) {
  657.             $writer = new Xlsx($spreadsheet);
  658.             $writer->save('php://output');
  659.         });
  660.         // Configurar las cabeceras de la respuesta
  661.         $response->headers->set('Content-Type''application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  662.         $response->headers->set('Content-Disposition''attachment;filename="inventario_' date('d/m/Y H:i:s') . '.xlsx"');
  663.         $response->headers->set('Cache-Control''max-age=0');
  664.         return $response;
  665.     }
  666.     /**
  667.      * @Route("/data/account.json", name="data_account")
  668.      */
  669.     public function dataAccountAction(Request $request): \Symfony\Component\HttpFoundation\JsonResponse
  670.     {
  671.         $session $request->getSession();
  672.         if (!$session->has('user_password_hash')) {
  673.             return new JsonResponse([
  674.                                         'success' => false,
  675.                                         'message' => 'Debe iniciar sesión.'
  676.                                     ], Response::HTTP_UNAUTHORIZED); // 401
  677.         }
  678.         $accounts $this->apiConsumer->getclientList($session->get('user_password_hash'));
  679.         $data = [];
  680.         foreach ($accounts as $account) {
  681.             $data[] =
  682.                 [
  683.                     "id"      => $account->cod_cliente,
  684.                     "account" => $account->cliente_nombre,
  685.                 ];
  686.         }
  687.         return $this->json($data);
  688.     }
  689.     /**
  690.      * @Route("/data/user.json", name="data_users")
  691.      * @Route("/data/users_json", name="data_user2")
  692.      */
  693.     public function dataUserAction(Request $requestSonataUserUserRepository $userRepository)
  694.     {
  695.         $session $request->getSession();
  696.         if (!$session->has('user_password_hash')) {
  697.             return new JsonResponse([
  698.                                         'success' => false,
  699.                                         'message' => 'Debe iniciar sesión.'
  700.                                     ], Response::HTTP_UNAUTHORIZED); // 401
  701.         }
  702.         $user $userRepository->findOneBy(['user_pass_hash' => $session->get('user_password_hash')]);
  703.         $account $this->apiConsumer->getclientList($session->get('user_password_hash'))[0] ?? null;
  704. //        $validate = $this->apiConsumer->getClienteValidar($session->get('user_password_hash'))[0] ?? null;
  705.         $data =
  706.             [
  707.                 "id"           => $user->getId(),
  708.                 "name"         => /*$validate->Modulo_Name*/
  709.                     '',
  710.                 "token"        => $session->get('user_password_hash'),
  711.                 "year"         => 1900,
  712.                 "bill"         => true,
  713.                 "accountId"    => $account->cod_cliente,
  714.                 "userMsj"      => "",
  715.                 "adminMsj"     => "",
  716.                 "modalContent" => ('Para armar el archivo de texto, crea filas con los datos separados por tabuladores y cada registro en una nueva línea, en el siguiente orden: Código de Cliente, Código de Producto, Fecha, Código, Cantidad y Tipo de embalaje.'),
  717.                 'exampleFile'  => '',
  718.                 'example'      => [
  719.                     $this->getTasksFormat($requestnulltrue)
  720.                 ]
  721.             ];
  722.         return $this->json($data);
  723.     }
  724.     private function getTasks($cod_client$user_pass_hash)
  725.     {
  726. //        return $this->apiConsumer->getImportsTasksFormats('5178', $user_pass_hash) ?? null;
  727.         return $this->apiConsumer->getImportsTasksList($cod_client$user_pass_hash)[0] ?? null;
  728.     }
  729.     private function getTasksFormat(Request $request$task_id null$ucfirst false): array
  730.     {
  731.         $session $request->getSession();
  732.         if (!$session->has('user_password_hash')) {
  733.             return new JsonResponse([
  734.                                         'success' => false,
  735.                                         'message' => 'Debe iniciar sesión.'
  736.                                     ], Response::HTTP_UNAUTHORIZED); // 401
  737.         }
  738.         $user_pass_hash $session->get('user_password_hash');
  739.         if ($task_id == null) {
  740.             $task_id self::$default_task;
  741.         }
  742.         $tasks_format $this->apiConsumer->getImportsTasksFormats($task_id$user_pass_hash) ?? null;
  743.         $tasks_ar = [];
  744.         foreach ($tasks_format as $item) {
  745.             $tasks_ar[(int)$item->Posicion 1] = $ucfirst ucfirst($item->Descripcion) : $item->Descripcion;
  746.         }
  747.         ksort($tasks_ar);
  748.         return $tasks_ar;
  749.     }
  750.     private function resolverFieldName(OrderProduct $product$field): bool|int|string|null
  751.     {
  752.         return match (ltrim($field)) {
  753.             'fecha' => date('d/m/Y'),
  754.             'cod_cliente' => $product->getOrder()->getAccountId(),
  755.             'hold' => $product->getHold(),
  756.             'Ciudad' => $product->getCity(),
  757.             'producto''producto_cod' => $product->getProduct()->getProductId(),
  758.             'cantidad''Cant_Solicitada' => $product->getQuantity(),
  759.             'lot''Lote' => $product->getBatch() != $product->getBatch() : '*',
  760.             'Dirección' => $product->getOrder()->getContactAddress() ?: $product->getAddress(),
  761.             'NroReferencia' => $product->getOrder()->getId(),
  762.             default => false,
  763.         };
  764.     }
  765.     private function setFieldName(OrderProduct $product$field)
  766.     {
  767.         switch ($field) {
  768.             case'fecha':
  769.                 return date('d/m/Y');
  770.             case'producto':
  771.                 return $product->getProduct()->getProductId();
  772.             case'cantidad':
  773.                 return $product->getQuantity();
  774.             case'lot':
  775.                 return '*';
  776.             default;
  777.         }
  778.     }
  779.     #[Route('/download-example/{task_id}'name'download_example')]
  780.     public function downloadExampleTxt(Request $request$task_id): Response
  781.     {
  782.         $session $request->getSession();
  783.         if (!$session->has('user_password_hash')) {
  784.             return new JsonResponse([
  785.                                         'success' => false,
  786.                                         'message' => 'Debe iniciar sesión.'
  787.                                     ], Response::HTTP_UNAUTHORIZED); // 401
  788.         }
  789. //        $tasks_ws = $this->apiConsumer->getImportsTasksFormats($task_id, $session->get('user_password_hash'));
  790.         $tasks_ws $this->getTasksFormat($request$task_id);
  791.         $fields = [];
  792.         foreach ($tasks_ws as $tasks_w) {
  793.             $fields[] = $this->correctWorks($tasks_wtrue);
  794.         }
  795.         $content "";
  796.         foreach ([$fields] as $row) {
  797.             $content .= implode("\t"$row) . "\n";
  798.         }
  799.         // Crear la respuesta con encabezados adecuados
  800.         $response = new Response($content);
  801.         $response->headers->set('Content-Type''text/plain');
  802.         $response->headers->set('Content-Disposition''attachment; filename="ejemplo_pedido.txt"');
  803.         $response->headers->set('Content-Length'strlen($content));
  804.         return $response;
  805.     }
  806.     #[Route('/download-example-xls/{task_id}'name'download_example_xls')]
  807.     public function downloadExampleXls(Request $request$task_id): Response
  808.     {
  809.         $session $request->getSession();
  810.         if (!$session->has('user_password_hash')) {
  811.             return new JsonResponse([
  812.                                         'success' => false,
  813.                                         'message' => 'Debe iniciar sesión.'
  814.                                     ], Response::HTTP_UNAUTHORIZED); // 401
  815.         }
  816. //        $tasks_ws = $this->apiConsumer->getImportsTasksFormats($task_id, $session->get('user_password_hash'));
  817.         $tasks_ws $this->getTasksFormat($request$task_id);
  818.         $fields = [];
  819.         foreach ($tasks_ws as $tasks_w) {
  820.             $fields[] = $this->correctWorks($tasks_wtrue);
  821.         }
  822.         $spreadsheet = new Spreadsheet();
  823.         $sheet       $spreadsheet->getActiveSheet();
  824.         $letras range('A''Z');
  825.         foreach ($fields as $index => $field) {
  826.             $sheet->setCellValue($letras[$index] . '1'$field);
  827.         }
  828.         $response = new StreamedResponse(function () use ($spreadsheet) {
  829.             $writer = new Xlsx($spreadsheet);
  830.             $writer->save('php://output');
  831.         });
  832.         $response->headers->set('Content-Type''application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  833.         $response->headers->set('Content-Disposition''attachment;filename="ejemplo_archivo' '.xlsx"');
  834.         $response->headers->set('Cache-Control''max-age=0');
  835.         return $response;
  836.     }
  837.     /**
  838.      * @Route("/data/tracing.json", name="data_tracing")
  839.      * @Route("/data/tracing_json", name="data_tracing2")
  840.      */
  841.     public function dataTracingAction(Request $requestOrderRepository $orderRepository): \Symfony\Component\HttpFoundation\JsonResponse
  842.     {
  843.         $session $request->getSession();
  844.         if (!$session->has('user_password_hash')) {
  845.             return new JsonResponse([
  846.                                         'success' => false,
  847.                                         'message' => 'Debe iniciar sesión.'
  848.                                     ], Response::HTTP_UNAUTHORIZED); // 401
  849.         }
  850.         $hash $session->get('user_password_hash');
  851.         $id_client $request->query->get('id');
  852.         $tracing $this->apiConsumer->getPedidoSeguimiento($id_client$hash);
  853.         $data = [];
  854.         foreach ($tracing as $item) {
  855.             $data[] =
  856.                 [
  857.                     "id"           => $item->ob_oid,
  858.                     "om_rid"       => $item->om_rid,
  859.                     "date"         => $item->Crea_date,
  860.                     "orderId"      => $item->ob_oid,
  861.                     "create_date"  => $item->Crea_date,
  862.                     "status"       => $item->Estado,
  863.                     "guide_number" => $item->num_guia_despacho,
  864.                     "cita"         => $item->Cita,
  865.                     "fecha_cita"   => $item->Fecha_Cita,
  866.                 ];
  867.         }
  868.         return $this->json($data);
  869.     }
  870.     /**
  871.      * @Route("/data/order.json", name="data_order")
  872.      * @Route("/data/order_json", name="data_order2")
  873.      */
  874.     public function dataOrderAction(Request $requestOrderRepository $orderRepository): \Symfony\Component\HttpFoundation\JsonResponse
  875.     {
  876.         $session $request->getSession();
  877.         if (!$session->has('user_password_hash')) {
  878.             return new JsonResponse([
  879.                                         'success' => false,
  880.                                         'message' => 'Debe iniciar sesión.'
  881.                                     ], Response::HTTP_UNAUTHORIZED); // 401
  882.         }
  883.         $hash $session->get('user_password_hash');
  884.         if ($request->query->has('id')) {
  885.             $order_id $request->query->get('id');
  886.         } else {
  887.             $order_id $request->query->get('orderId');
  888.         }
  889.         $branch_id $request->query->get('branchId');
  890.         $tracings $this->apiConsumer->getPedidoSeguimiento($branch_id$hash);
  891.         $data_ws = [];
  892.         foreach ($tracings as $tracing) {
  893.             if ($tracing->om_rid == $order_id) {
  894.                 $data_ws = [
  895.                     'Crea_date'         => $tracing->Crea_date,
  896.                     'ob_oid'            => $tracing->ob_oid,
  897.                     'om_rid'            => $tracing->om_rid,
  898.                     'Tipo'              => $tracing->Tipo,
  899.                     'num_guia_despacho' => $tracing->num_guia_despacho,
  900.                     'Productos'         => $tracing->Productos,
  901.                     'Lineas'            => $tracing->Lineas,
  902.                     'Cant_Solicitada'   => $tracing->Cant_Solicitada,
  903.                     'Cant_Despachada'   => $tracing->Cant_Despachada,
  904.                     'Estado'            => $tracing->Estado,
  905.                     'Cita'              => $tracing->Cita,
  906.                     'Fecha_Cita'        => $tracing->Fecha_Cita,
  907.                     'Hora_Cita'         => $tracing->Hora_Cita,
  908.                     'Boleto'            => $tracing->Boleto,
  909.                     'Hora_Presentacion' => $tracing->Hora_Presentacion,
  910.                     'Hora_Ingreso'      => $tracing->Hora_Ingreso,
  911.                     'Hora_Salida'       => $tracing->Hora_Salida,
  912.                 ];
  913.             }
  914.         }
  915.         unset($tracings);
  916.         $tracings_prods $this->apiConsumer->getPedidoSeguimientoDetalle($branch_id$data_ws['ob_oid'], $hash);
  917.         $products = [];
  918.         if ($tracings_prods) {
  919.             foreach ($tracings_prods as $product) {
  920.                 $products[] = [
  921.                     'id'                  => $product->producto_cod,
  922.                     'name'                => $product->desc_prod,
  923.                     'quantity'            => (int)$product->Cant_Solicitada,
  924.                     'quantity_processed'  => (int)$product->Cant_en_Proceso,
  925.                     'quantity_dispatched' => (int)$product->Cant_Despachada,
  926.                     'batch'               => $product->Lote ?: 'Sin lote',
  927.                     'status'              => $product->Estado,
  928.                 ];
  929.             }
  930.         }
  931.         unset($tracings_prods);
  932.         $data = [];
  933.         $data[] =
  934.             [
  935.                 "id"                => $data_ws['ob_oid'],
  936.                 "om_rid"            => $data_ws['om_rid'],
  937.                 "date"              => $data_ws['Crea_date'],
  938.                 "Tipo"              => $data_ws['Tipo'],
  939.                 "num_guia_despacho" => $data_ws['num_guia_despacho'],
  940.                 "Productos"         => $data_ws['Productos'],
  941.                 "Lineas"            => $data_ws['Lineas'],
  942.                 "Cant_Solicitada"   => $data_ws['Cant_Solicitada'],
  943.                 "Cant_Despachada"   => $data_ws['Cant_Despachada'],
  944.                 "Cita"              => $data_ws['Cita'],
  945.                 "Fecha_Cita"        => $data_ws['Fecha_Cita'],
  946.                 "Hora_Cita"         => $data_ws['Hora_Cita'],
  947.                 "status"            => $data_ws['Estado'],
  948.                 "statusMsg"         => $data_ws['Estado'],
  949.                 "products"          => $products,
  950.             ];
  951.         return $this->json($data);
  952.     }
  953.     /**
  954.      * @Route("/data/bill.json", name="data_bill")
  955.      * @Route("/data/bill_json", name="data_bill2")
  956.      */
  957.     public function dataBillAction(Request $request): \Symfony\Component\HttpFoundation\JsonResponse
  958.     {
  959.         $session $request->getSession();
  960.         if (!$session->has('user_password_hash')) {
  961.             return new JsonResponse([
  962.                                         'success' => false,
  963.                                         'message' => 'Debe iniciar sesión.'
  964.                                     ], Response::HTTP_UNAUTHORIZED); // 401
  965.         }
  966.         $id_client $request->query->get('id');
  967.         $bills $this->apiConsumer->getFacturaResumen($session->get('user_password_hash'));
  968.         $data = [];
  969.         foreach ($bills as $item) {
  970.             $fecha = new \DateTime($item->F_Emis);
  971.             $data[] =
  972.                 [
  973.                     "id"            => $item->Factura,
  974.                     "date"          => $fecha->format('d/m/Y'),
  975.                     //                    "n_credito"     => $item->N_Credito ,
  976.                     "nota_venta"    => $item->NotaVenta,
  977.                     "cotizacion"    => $item->cotizacion,
  978.                     "f_impt"        => $item->F_Impt,
  979.                     "f_emis"        => $item->F_Emis,
  980.                     "f_venc"        => $item->F_Venc,
  981.                     "rut_recep"     => $item->RutRecep,
  982.                     "id_erp"        => $item->id_erp,
  983.                     "rzn_soc_recep" => $item->RznSocRecep,
  984.                     "lineas"        => $item->Lineas,
  985.                     "cve_des"       => $item->CveDes,
  986.                     "venta_item"    => $this->moneyFormat($item->Venta_Item),
  987.                     "desc"          => $this->moneyFormat($item->Desc),
  988.                     "mnt_exe"       => $this->moneyFormat($item->MntExe),
  989.                     "neto"          => $this->moneyFormat($item->Neto),
  990.                     "iva"           => $this->moneyFormat($item->IVA),
  991.                     "total"         => $this->moneyFormat($item->Total),
  992.                     "pendiente"     => $this->moneyFormat($item->Pendiente),
  993.                     "estado"        => $item->Estado,
  994.                     "dias_vencido"  => $item->Dias_Vencido,
  995.                     "file"          => $this->generateUrl('data_bill_pdf', ['folio' => $item->Factura]),
  996.                 ];
  997.         }
  998.         usort($data, function ($a$b) {
  999.             $dateA DateTime::createFromFormat('d/m/Y'$a['date']);
  1000.             $dateB DateTime::createFromFormat('d/m/Y'$b['date']);
  1001.             return $dateB <=> $dateA// Orden ascendente
  1002.         });
  1003.         return $this->json($data);
  1004.     }
  1005.     private function moneyFormat($value)
  1006.     {
  1007.         return '$' number_format((int)$value0null'.');
  1008.     }
  1009.     /**
  1010.      * @Route("/data/bill_pdf/{folio}", name="data_bill_pdf")
  1011.      */
  1012.     public function getFacturaFile(Request $request$folio)
  1013.     {
  1014.         $session $request->getSession();
  1015.         if (!$session->has('user_password_hash')) {
  1016.             return new JsonResponse([
  1017.                                         'success' => false,
  1018.                                         'message' => 'Debe iniciar sesión.'
  1019.                                     ], Response::HTTP_UNAUTHORIZED); // 401
  1020.         }
  1021.         $id_client $request->query->get('id');
  1022.         $id_client $request->query->get('id');
  1023.         $pdf_64 $this->apiConsumer->getFacturaPDF($session->get('user_password_hash'), $folio);
  1024.         $pdfContent base64_decode($pdf_64);
  1025.         if ($pdfContent === false) {
  1026.             return new Response("Error al decodificar el PDF."Response::HTTP_INTERNAL_SERVER_ERROR);
  1027.         }
  1028.         // Retornar el PDF directamente en la respuesta HTTP
  1029.         return new Response($pdfContent200, [
  1030.             'Content-Type'        => 'application/pdf',
  1031.             'Content-Disposition' => 'inline; filename="factura-' $folio '.pdf"',
  1032.         ]);
  1033.     }
  1034.     /**
  1035.      * @Route("/data/report.json", name="data_report")
  1036.      * @Route("/data/report_json", name="data_report2")
  1037.      */
  1038.     public function dataReportAction(Request $request): \Symfony\Component\HttpFoundation\JsonResponse
  1039.     {
  1040.         $session $request->getSession();
  1041.         if (!$session->has('user_password_hash')) {
  1042.             return new JsonResponse([
  1043.                                         'success' => false,
  1044.                                         'message' => 'Debe iniciar sesión.'
  1045.                                     ], Response::HTTP_UNAUTHORIZED); // 401
  1046.         }
  1047.         $id_client $request->query->get('id');
  1048.         $report $this->apiConsumer->getPowerBIList($session->get('user_password_hash'));
  1049.         $data = [];
  1050.         foreach ($report as $item) {
  1051.             $data[] =
  1052.                 [
  1053.                     "id_registro"   => $item->id_registro,
  1054.                     "create_date"   => $item->crea_date,
  1055.                     "create_oper"   => $item->crea_oper,
  1056.                     "id_usuario"    => $item->id_usuario,
  1057.                     "Descripc"      => $item->Descripc,
  1058.                     "Estado"        => $item->Estado,
  1059.                     "URLs"          => $item->URLs,
  1060.                     "OrderBy"       => $item->OrdenBy,
  1061.                     "Intervalo"     => $item->Intervalo,
  1062.                     "URLsParametro" => $item->URLsParametro,
  1063.                 ];
  1064.         }
  1065.         return $this->json($data);
  1066.     }
  1067. }