mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
115 lines
3.7 KiB
PHP
115 lines
3.7 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\Logistica;
|
|
|
|
use App\Controllers\BaseController;
|
|
use App\Services\ImpresoraEtiquetaService;
|
|
use App\Services\LogisticaService;
|
|
use CodeIgniter\HTTP\RequestInterface;
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
|
use Psr\Log\LoggerInterface;
|
|
use Hermawan\DataTables\DataTable;
|
|
|
|
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 = "")
|
|
{
|
|
|
|
if (empty($search)) {
|
|
$result = [
|
|
'status' => false,
|
|
'message' => lang('Logistica.errors.noDataToFind'),
|
|
];
|
|
return $this->response->setJSON($result);
|
|
}
|
|
$result = LogisticaService::findPedidoOrISBN($search);
|
|
return $this->response->setJSON($result);
|
|
}
|
|
|
|
public function datatable_envios()
|
|
{
|
|
$model = model('App\Models\Logistica\EnvioModel');
|
|
$q = $model->getDatatableQuery();
|
|
|
|
|
|
$result = DataTable::of($q)
|
|
->edit(
|
|
"finalizado",
|
|
function ($row, $meta) {
|
|
if ($row->finalizado == 1)
|
|
return '<i class="ti ti-check"></i>';
|
|
else
|
|
return '<i class="ti ti-x"></i>';
|
|
}
|
|
)
|
|
->add("action", callback: function ($q) {
|
|
|
|
return '
|
|
<div class="btn-group btn-group-sm">
|
|
<a href="javascript:void(0);"><i class="ti ti-eye ti-sm btn-edit mx-2" data-id="' . $q->id . '"></i></a>
|
|
</div>
|
|
';
|
|
});
|
|
|
|
return $result->toJson(returnAsObject: true);
|
|
}
|
|
}
|