mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
98 lines
3.3 KiB
PHP
98 lines
3.3 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\Logistica;
|
|
|
|
use App\Controllers\BaseController;
|
|
use App\Services\ImpresoraEtiquetaService;
|
|
use CodeIgniter\HTTP\RequestInterface;
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
class LogisticaController extends BaseController
|
|
{
|
|
|
|
protected ImpresoraEtiquetaService $impresoraEtiquetaService;
|
|
protected string $locale;
|
|
protected array $viewData;
|
|
|
|
protected static $controllerSlug = 'logistica';
|
|
protected static $viewPath = 'themes/vuexy/form/logistica/';
|
|
|
|
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
|
{
|
|
$this->impresoraEtiquetaService = service('impresora_etiqueta');
|
|
$this->locale = session()->get('lang');
|
|
|
|
$this->viewData['pageTitle'] = lang('Logistica.logistica');
|
|
|
|
// Breadcrumbs
|
|
$this->viewData['breadcrumb'] = [
|
|
['title' => lang("App.menu_logistica"), 'route' => "javascript:void(0);", 'active' => false],
|
|
];
|
|
|
|
|
|
parent::initController($request, $response, $logger);
|
|
}
|
|
public function print_test_label()
|
|
{
|
|
$etiquetaData = $this->impresoraEtiquetaService->test();
|
|
$responseMessage = $etiquetaData["status"] ? "OK" : "ERROR";
|
|
return $this->response->setJSON(["message" => $responseMessage, "data" => $etiquetaData, "status" => $etiquetaData["status"]]);
|
|
}
|
|
|
|
public function panel()
|
|
{
|
|
$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);
|
|
}
|
|
|
|
public function selectorEnvios($tipoEnvio = null)
|
|
{
|
|
$viewData = [
|
|
'currentModule' => static::$controllerSlug,
|
|
'boxTitle' => lang('Logistica.envioSimpleMultiple'),
|
|
'usingServerSideDataTable' => true,
|
|
'tipoEnvio' => $tipoEnvio,
|
|
];
|
|
|
|
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
|
|
|
|
return view(static::$viewPath . 'viewLogisticaSelectEnvios', $viewData);
|
|
}
|
|
|
|
public function searchPedidoOrISBN($search = ""){
|
|
|
|
$modelPedido = model('App\Models\Pedidos\PedidoModel');
|
|
|
|
$search = trim($search);
|
|
$searchClean = str_replace('-', '', $search);
|
|
$modelPedido = model('App\Models\Pedidos\PedidoModel');
|
|
|
|
// Builder con joins
|
|
$builder = $modelPedido->builder();
|
|
$builder->select('pedidos.*');
|
|
$builder->join('pedidos_linea', 'pedidos_linea.pedido_id = pedidos.id', 'left');
|
|
$builder->join('presupuestos', 'presupuestos.id = pedidos_linea.presupuesto_id', 'left');
|
|
|
|
// Agrupar condiciones: por ID exacto o por ISBN sin guiones
|
|
$builder->groupStart()
|
|
->where('pedidos.id', $search)
|
|
->orWhere("REPLACE(presupuestos.isbn, '-', '')", $searchClean)
|
|
->groupEnd();
|
|
|
|
$result = $builder->get()->getResult();
|
|
$response = [
|
|
'status' => true,
|
|
'data' => $result,
|
|
];
|
|
}
|
|
}
|