From 4872e498a56ef3d8bb758444f618f30f31f01919 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 2 Apr 2025 15:53:30 +0200 Subject: [PATCH] Modificado el controlador --- .../Logistica/Logisticacontroller.php | 71 +++++-------------- 1 file changed, 16 insertions(+), 55 deletions(-) diff --git a/ci4/app/Controllers/Logistica/Logisticacontroller.php b/ci4/app/Controllers/Logistica/Logisticacontroller.php index 9ada7ecf..25f5819d 100644 --- a/ci4/app/Controllers/Logistica/Logisticacontroller.php +++ b/ci4/app/Controllers/Logistica/Logisticacontroller.php @@ -2,69 +2,30 @@ namespace App\Controllers\Logistica; -use App\Models\Sistema\SettingsModel; -use CodeIgniter\Controller; +use App\Controllers\BaseController; +use App\Services\ImpresoraEtiquetaService; +use CodeIgniter\HTTP\RequestInterface; +use CodeIgniter\HTTP\ResponseInterface; +use Psr\Log\LoggerInterface; - -use App\Models\Collection; - -class Logisticacontroller extends \App\Controllers\BaseResourceController +class LogisticaController extends BaseController { - protected $modelName = TicketModel::class; - protected $format = 'json'; + protected ImpresoraEtiquetaService $impresoraEtiquetaService; + protected string $locale; + protected array $viewData; - protected static $singularObjectNameCc = 'logistica'; - protected static $singularObjectName = 'Logistica'; - protected static $pluralObjectName = 'Logistica'; - protected static $controllerSlug = 'logistica'; - - protected static $viewPath = 'themes/vuexy/form/logistica/'; - - protected $indexRoute = 'panel'; - - - public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) + public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { - $this->viewData['pageTitle'] = lang('Logistica.logistica'); - - // Breadcrumbs - $this->viewData['breadcrumb'] = [ - ['title' => lang("App.menu_logistica"), 'route' => "javascript:void(0);", 'active' => false], - ]; + $this->impresoraEtiquetaService = service('impresora_etiqueta'); + $this->locale = session()->get('lang'); parent::initController($request, $response, $logger); } - - public function index() + public function print_test_label() { - //checkPermission('tickets.menu'); - - /*$viewData = [ - 'currentModule' => static::$controllerSlug, - 'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Tickets.tickets')]), - 'usingServerSideDataTable' => true, - 'userType' => auth()->user()->can('tickets.edit') ? 1 : 0, - ]; - - $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class - - return view(static::$viewPath . 'viewTicketList', $viewData);*/ - } - - public function panel() - { - //checkPermission('tickets.menu'); - - $viewData = [ - 'currentModule' => static::$controllerSlug, - 'boxTitle' => lang('Logistica.panel'), - 'pageSubTitle' => 'Panel', - 'usingServerSideDataTable' => true, - ]; - - $viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class - - return view(static::$viewPath . 'viewPanelLogistica', $viewData); + $etiquetaData = $this->impresoraEtiquetaService->test(); + $responseMessage = $etiquetaData["status"] ? "OK" : "ERROR"; + return $this->response->setJSON(["message" => $responseMessage, "data" => $etiquetaData, "status" => $etiquetaData["status"]]); } }