mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en la tabla de las lineas
This commit is contained in:
@ -847,6 +847,10 @@ $routes->group('etiquetasTitulos', ['namespace' => 'App\Controllers\Logistica'],
|
||||
$routes->get('otList', 'EtiquetasTitulosController::findOTs');
|
||||
$routes->get('addList', 'EtiquetasTitulosController::findAddresses');
|
||||
$routes->post('newEtiquetaTitulos', 'EtiquetasTitulosController::addEtiqueta');
|
||||
$routes->get('datatable', 'EtiquetasTitulosController::datatable');
|
||||
$routes->post('delete', 'EtiquetasTitulosController::deleteEtiqueta');
|
||||
$routes->get('edit/(:num)', 'EtiquetasTitulosController::edit/$1');
|
||||
$routes->get('datatableLineas/(:num)', 'EtiquetasTitulosController::datatableLineasEtiquetas/$1');
|
||||
});
|
||||
|
||||
/*
|
||||
|
||||
@ -17,13 +17,14 @@ class EtiquetasTitulosController extends BaseController
|
||||
protected string $locale;
|
||||
protected array $viewData;
|
||||
|
||||
protected static $controllerSlug = 'logistica';
|
||||
protected static $controllerSlug = 'etiquetas_titulos';
|
||||
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->model = model('App\Models\Etiquetas\EtiquetasTitulosModel');
|
||||
|
||||
$this->viewData['pageTitle'] = lang('Logistica.logistica');
|
||||
|
||||
@ -109,4 +110,141 @@ class EtiquetasTitulosController extends BaseController
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteEtiqueta($id = null)
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$id = $this->request->getPost('id') ?? null;
|
||||
|
||||
if ($id == null) {
|
||||
return [
|
||||
'status' => false,
|
||||
'message' => lang('Logistica.errorMissingData')
|
||||
];
|
||||
}
|
||||
|
||||
$modelLineas = model('App\Models\Etiquetas\EtiquetasTitulosLineasModel');
|
||||
$ids = $modelLineas->where('etiqueta_titulos_id', $id)->findColumn('id');
|
||||
if($ids){
|
||||
$modelLineas->delete($ids);
|
||||
}
|
||||
$model = model('App\Models\Etiquetas\EtiquetasTitulosModel');
|
||||
$id = $model->where('id', $id)->findColumn('id');
|
||||
if($id){
|
||||
$model->delete($id);
|
||||
}
|
||||
$result = [
|
||||
'status' => true,
|
||||
'message' => lang('Logistica.success.jhn<successDeleteEtiqueta'),
|
||||
];
|
||||
|
||||
return $this->response->setJSON($result);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function edit($id = null)
|
||||
{
|
||||
|
||||
if (empty($id)) {
|
||||
return redirect()->to(base_url('logistica/selectEnvios/simple'))->with('error', lang('Logistica.errors.noEnvio'));
|
||||
}
|
||||
$model = model('App\Models\Etiquetas\EtiquetasTitulosModel');
|
||||
$etiquetaEntity = $model->select('etiquetas_titulos.*, clientes.nombre as cliente')
|
||||
->join('clientes', 'clientes.id = etiquetas_titulos.cliente_id', 'left')
|
||||
->where('etiquetas_titulos.id', $id)
|
||||
->first();
|
||||
if (empty($etiquetaEntity)) {
|
||||
return redirect()->to(base_url('logistica/etiquetasLogistica'))->with('error', lang('Logistica.errors.noEnvio'));
|
||||
}
|
||||
|
||||
|
||||
$modelImpresora = model('App\Models\Configuracion\ImpresoraEtiquetaModel');
|
||||
$impresoras = $modelImpresora->select('id, name')
|
||||
->where('deleted_at', null)
|
||||
->where('tipo', 1)
|
||||
->orderBy('name', 'asc')
|
||||
->findAll();
|
||||
$etiquetaEntity->impresoras = $impresoras;
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'boxTitle' => '<i class="ti ti-ticket ti-xl"></i>' . ' ' . lang('Logistica.EtiquetasTitulos') . ' [' . $etiquetaEntity->id . ']: ' . $etiquetaEntity->direccion,
|
||||
'usingServerSideDataTable' => true,
|
||||
'etiquetaEntity' => $etiquetaEntity,
|
||||
];
|
||||
|
||||
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
|
||||
|
||||
return view(static::$viewPath . 'viewEtiquetasTitulosEdit', $viewData);
|
||||
}
|
||||
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
$q = $this->model->getEtiquetasTitulos();
|
||||
|
||||
if (!empty($otsFilter)) {
|
||||
$q->groupStart();
|
||||
$q->like('etl.ot_id', $otsFilter);
|
||||
$q->groupEnd();
|
||||
}
|
||||
|
||||
$result = DataTable::of($q)
|
||||
->add("action", callback: function ($q) {
|
||||
return '
|
||||
<div class="btn-group btn-group-sm">
|
||||
<a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="' . $q->id . '"></i></a>
|
||||
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete" data-id="' . $q->id . '"></i></a>
|
||||
</div>
|
||||
';
|
||||
});
|
||||
|
||||
return $result->toJson(returnAsObject: true);
|
||||
}
|
||||
|
||||
public function datatableLineasEtiquetas($id = null){
|
||||
|
||||
$model = model('App\Models\Etiquetas\EtiquetasTitulosLineasModel');
|
||||
|
||||
$id = $this->request->getGet('id') ?? null;
|
||||
$direccion = $this->request->getGet('direccion') ?? null;
|
||||
|
||||
$q = $model->getDatatableQuery($id, $direccion);
|
||||
|
||||
|
||||
$result = DataTable::of($q)
|
||||
->add(
|
||||
"rowSelected",
|
||||
callback: function ($q) {
|
||||
return '<input type="checkbox" class="form-check-input checkbox-linea-envio" name="row_selected[]" value="' . $q->id . '">';
|
||||
}
|
||||
);
|
||||
/*->edit(
|
||||
"pedido",
|
||||
function ($row, $meta) {
|
||||
return '<a href="' . base_url('pedidos/edit/' . $row->pedido) . '" target="_blank">' . $row->pedido . '</a>';
|
||||
}
|
||||
)
|
||||
->edit(
|
||||
"presupuesto",
|
||||
function ($row, $meta) {
|
||||
return '<a href="' . base_url('presupuestoadmin/edit/' . $row->presupuesto) . '" target="_blank">' . $row->presupuesto . '</a>';
|
||||
}
|
||||
)->edit(
|
||||
"unidadesEnvio",
|
||||
function ($row, $meta) {
|
||||
if($row->finalizado == 1 || $row->tipo_envio == 'ferro_prototipo'){
|
||||
return $row->unidadesEnvio;
|
||||
}
|
||||
return '<input type="number" class="form-control input-lineas input-unidades text-center"
|
||||
data-id="'. $row->id.'" data-name="unidades_envio" value="' . $row->unidadesEnvio . '">';
|
||||
}
|
||||
);*/
|
||||
|
||||
return $result->toJson(returnAsObject: true);
|
||||
}
|
||||
}
|
||||
@ -66,10 +66,18 @@ return [
|
||||
'finalizarEnvioYOTs' => 'Finalizar envío y OTS',
|
||||
|
||||
|
||||
'EtiquetasTitulos' => 'Etiquetas de títulos',
|
||||
'id' => 'ID',
|
||||
'otId' => 'OT ID',
|
||||
'num_caja' => 'Nº Caja',
|
||||
'unidadesTotalesOt' => 'Unidades totales OT',
|
||||
'numeroCajas' => 'Nº Cajas',
|
||||
'unidadesEnCaja' => 'Unidades en caja',
|
||||
'listadoEtiquetas' => 'Listado de etiquetas',
|
||||
'nuevaEtiqueta' => 'Nueva etiqueta',
|
||||
'cliente' => 'Cliente',
|
||||
'comentariosEtiqueta' => 'Comentarios etiqueta',
|
||||
'addLineaEtiqueta' => 'Añadir líneas a la etiqueta',
|
||||
|
||||
|
||||
'errors' => [
|
||||
@ -84,6 +92,7 @@ return [
|
||||
'success' => [
|
||||
'finalizado' => 'El envío se ha finalizado correctamente',
|
||||
'finalizadoOTs' => 'El envío se ha finalizado correctamente.\nSe han creado las OTs siguientes OTs: {ots}',
|
||||
'successDeleteEtiqueta' => 'Etiqueta eliminada correctamente',
|
||||
],
|
||||
|
||||
];
|
||||
@ -32,4 +32,50 @@ class EtiquetasTitulosLineasModel extends Model
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
|
||||
protected $beforeDelete = ['addUserDeleted'];
|
||||
|
||||
protected function addUserDeleted(array $data)
|
||||
{
|
||||
$userId = auth()->user()->id;
|
||||
|
||||
if (!isset($data['data'])) {
|
||||
$data['data'] = [];
|
||||
}
|
||||
|
||||
if (!empty($data['id'])) {
|
||||
$builder = $this->builder();
|
||||
$builder->whereIn($this->primaryKey, (array) $data['id'])
|
||||
->update(['user_deleted_at' => $userId]);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getDatatableQuery($etiqueta_id, $direccion = null){
|
||||
|
||||
$direccionNormalizada = str_replace(' ', '', strtolower(trim($direccion)));
|
||||
$direccionSQL = $this->db->escape($direccionNormalizada);
|
||||
|
||||
|
||||
|
||||
$builder = $this->db->table('etiquetas_titulos_lineas etl')
|
||||
->select('etl.ot_id as ot, pr.titulo as titulo, etl.unidades as unidades, etl.numero_caja as numero_caja,
|
||||
pd.cantidad as unidadesTotal, etl.id as id, etl.unidades as unidadesRaw,
|
||||
(SELECT ROUND(SUM(peso)/1000, 2)
|
||||
FROM presupuesto_linea
|
||||
WHERE presupuesto_id = pr.id) AS pesoUnidad')
|
||||
->join('etiquetas_titulos et', 'et.id = etl.etiqueta_titulos_id')
|
||||
->join('ordenes_trabajo ot', 'ot.id = etl.ot_id')
|
||||
->join('pedidos p', 'p.id = ot.pedido_id')
|
||||
->join('pedidos_linea pl', 'pl.pedido_id = p.id')
|
||||
->join('presupuestos pr', 'pr.id = pl.presupuesto_id')
|
||||
->join('presupuesto_linea plinea', 'pr.id = plinea.presupuesto_id')
|
||||
->join('presupuesto_direcciones pd', 'pd.presupuesto_id = pr.id')
|
||||
->where('etl.deleted_at IS NULL')
|
||||
->where('et.id', $etiqueta_id)
|
||||
->where("REPLACE(LOWER(TRIM(pd.direccion)), ' ', '') = $direccionSQL", null, false)
|
||||
->groupBy('etl.numero_caja');
|
||||
|
||||
return $builder;
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,4 +32,34 @@ class EtiquetasTitulosModel extends Model
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
|
||||
|
||||
protected $beforeDelete = ['addUserDeleted'];
|
||||
|
||||
protected function addUserDeleted(array $data)
|
||||
{
|
||||
$userId = auth()->user()->id;
|
||||
|
||||
if (!isset($data['data'])) {
|
||||
$data['data'] = [];
|
||||
}
|
||||
|
||||
if (!empty($data['id'])) {
|
||||
$builder = $this->builder();
|
||||
$builder->whereIn($this->primaryKey, (array) $data['id'])
|
||||
->update(['user_deleted_at' => $userId]);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getEtiquetasTitulos()
|
||||
{
|
||||
return $this->db->table('etiquetas_titulos et')
|
||||
->select('et.id, GROUP_CONCAT(DISTINCT etl.ot_id ORDER BY etl.ot_id ASC SEPARATOR ", ") as lista_ots')
|
||||
->select('COUNT(DISTINCT etl.numero_caja) as cajas, et.att, et.direccion')
|
||||
->join('etiquetas_titulos_lineas etl', 'etl.etiqueta_titulos_id = et.id')
|
||||
->where('et.deleted_at IS NULL')
|
||||
->where('etl.deleted_at IS NULL')
|
||||
->groupBy('et.id, et.att, et.direccion');
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,231 @@
|
||||
<?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
|
||||
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
|
||||
|
||||
|
||||
<?= $this->section('content'); ?>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h4><?= $boxTitle ?>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
|
||||
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
|
||||
|
||||
<input type="hidden" id="id" name="id" value="<?= $etiquetaEntity->id ?>">
|
||||
|
||||
<div class="accordion accordion-bordered">
|
||||
<div class="card accordion-item active mb-5">
|
||||
<h4 class="accordion-header px-4 py-3">
|
||||
<?= lang("Logistica.datosEnvio") ?>
|
||||
</h4>
|
||||
|
||||
<div id="accordionDatosEnvioTip" class="accordion-collapse collapse show">
|
||||
<div class="accordion-body px-4 py-3">
|
||||
<div class="d-flex flex-row mb-3">
|
||||
|
||||
<div class="col-sm-3 px-3">
|
||||
<label for="att" class="form-label">
|
||||
<?= lang("Logistica.cliente") ?>
|
||||
</label>
|
||||
<input readonly id="cliente" name="cliente" tabindex="1" maxlength="50"
|
||||
class="form-control" value="<?= old('att', $etiquetaEntity->cliente) ?>">
|
||||
</div>
|
||||
|
||||
<div class="col-sm-4 px-3">
|
||||
<label for="att" class="form-label">
|
||||
<?= lang("Logistica.att") ?>
|
||||
</label>
|
||||
<input readonly id="att" name="att" tabindex="1" maxlength="50"
|
||||
class="form-control" value="<?= old('att', $etiquetaEntity->att) ?>">
|
||||
</div>
|
||||
|
||||
<div class="col-sm-5 px-3">
|
||||
<label for="direccion" class="form-label">
|
||||
<?= lang("Logistica.direccion") ?>
|
||||
</label>
|
||||
<input readonly id="direccion" name="direccion" tabindex="1" maxlength="50"
|
||||
class="form-control"
|
||||
value="<?= old('direccion', $etiquetaEntity->direccion) ?>">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="d-flex flex-row mb-3">
|
||||
<div class="col-sm-9 px-3">
|
||||
<label for="comentarios" class="form-label">
|
||||
<?= lang("Logistica.comentariosEtiqueta") ?>
|
||||
</label>
|
||||
<input id="comentarios" name="comentarios" tabindex="1" maxlength="50"
|
||||
class="form-control"
|
||||
value="<?= old('comentarios', $etiquetaEntity->comentarios) ?>">
|
||||
</div>
|
||||
|
||||
<div class="col-sm-3 px-3">
|
||||
<button id="guardarComentarios" name="guardar_comentarios" tabindex="1"
|
||||
class="btn btn-primary mt-4 w-100">
|
||||
<?= lang("Logistica.guardar") ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="accordion accordion-bordered">
|
||||
<div class="card accordion-item active mb-5">
|
||||
<h4 class="accordion-header px-4 py-3">
|
||||
<?= lang("Logistica.addLineaEtiqueta") ?>
|
||||
</h4>
|
||||
|
||||
<div id="accordionaddLineasEnvioTip" class="accordion-collapse collapse show">
|
||||
|
||||
<div class="d-flex flex-row mb-3">
|
||||
<div class="col-sm-12 px-3">
|
||||
<p><?= lang('Logistica.addLineasText') ?></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex flex-row mb-3">
|
||||
<div class="col-sm-6 px-3">
|
||||
<label for="buscadorPedidos" class="form-label">
|
||||
<?= lang("Logistica.buscadorPedidosTitle2") ?>
|
||||
</label>
|
||||
<select id="buscadorPedidos" name="buscador_pedidos" tabindex="1" maxlength="50"
|
||||
class="form-control select2bs2" style="width: 100%;">
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-sm-2 px-3">
|
||||
<button id="btnAddLinea" name="btnBuscar" tabindex="1"
|
||||
class="btn btn-primary mt-4 w-100">
|
||||
<?= lang("Logistica.add") ?>
|
||||
<ti class="ti ti-circle-plus"></ti>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="accordion accordion-bordered">
|
||||
<div class="card accordion-item active mb-5">
|
||||
<h4 class="accordion-header px-4 py-3">
|
||||
<?= lang("Logistica.lineasEnvio") ?>
|
||||
</h4>
|
||||
|
||||
<div id="accordionDatosEnvioTip" class="accordion-collapse collapse show">
|
||||
<div class="accordion-body px-4 py-3">
|
||||
<div class="d-flex flex-row">
|
||||
<p><?= lang('Logistica.buttonsActions') ?></p>
|
||||
</div>
|
||||
<div class="d-flex flex-row mb-3 align-items-end">
|
||||
<div class="col-sm-2 px-3">
|
||||
<button id="btnSelectAll" name="btnSelectAll" tabindex="1"
|
||||
class="btn btn-primary w-100">
|
||||
<?= lang("Logistica.selectAll") ?>
|
||||
<i class="ti ti-select"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-sm-2 px-3">
|
||||
<button id="btnEliminarLineas" name="btnEliminarLineas" tabindex="1"
|
||||
class="btn btn-danger w-100">
|
||||
<?= lang("Logistica.eliminar") ?>
|
||||
<i class="ti ti-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-2 px-3 d-flex flex-column justify-content-end">
|
||||
<div class="d-flex flex-column justify-content-end h-100">
|
||||
<label for="impresoraEtiquetas" class="form-label">
|
||||
<?= lang("Logistica.impresoraEtiquetas") ?>
|
||||
</label>
|
||||
<select id="impresoraEtiquetas" name="impresora_etiquetas" tabindex="1"
|
||||
maxlength="50" class="form-control select2bs2" style="width: 100%;">
|
||||
<?php foreach ($etiquetaEntity->impresoras as $impresora): ?>
|
||||
<option value="<?= $impresora->id ?>">
|
||||
<?= $impresora->name ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
|
||||
<table id="tableLineasEtiqueta" class="table table-striped table-hover w-100">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th><?= lang("Logistica.otId") ?></th>
|
||||
<th><?= lang("Logistica.titulo") ?></th>
|
||||
<th><?= lang("Logistica.num_caja") ?></th>
|
||||
<th class="text-center" style="width: 10%;">
|
||||
<?= lang("Logistica.unidadesEnCaja") ?>
|
||||
</th>
|
||||
<th class="text-center" style="width: 10%;">
|
||||
<?= lang("Logistica.unidadesTotalesOt") ?>
|
||||
</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th colspan="9">
|
||||
<div class="text-end">
|
||||
<?= lang("Logistica.unidadesTotalesFooter") ?>
|
||||
<span id="footer-unidades-envio"></span>
|
||||
</div>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="9">
|
||||
<div class="text-end">
|
||||
<?= lang("Logistica.peso") ?>
|
||||
<span id="footer-peso"></span>
|
||||
</div>
|
||||
</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
<?= $this->section('css') ?>
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.css') ?>" />
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/rowreorder/1.4.1/css/rowReorder.dataTables.min.css">
|
||||
<link rel="stylesheet" href="https://code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">
|
||||
<link rel="stylesheet" href="<?= site_url("/themes/vuexy/vendor/libs/flatpickr/flatpickr.css") ?>">
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
<?= $this->section('additionalExternalJs') ?>
|
||||
<script src="https://code.jquery.com/ui/1.13.2/jquery-ui.min.js"></script>
|
||||
<script src="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.js') ?>"></script>
|
||||
<script src="https://cdn.datatables.net/rowgroup/1.3.1/js/dataTables.rowGroup.min.js"></script>
|
||||
<script type="module" src="<?= site_url("assets/js/safekat/pages/logistica/etiquetaEdit.js") ?>"></script>
|
||||
<?= $this->endSection() ?>
|
||||
@ -67,15 +67,15 @@
|
||||
<div class="accordion-body px-4 py-3">
|
||||
|
||||
<div class="row">
|
||||
<table id="tableOfEnvios" class="table table-striped table-hover w-100">
|
||||
<table id="tableOfEquiquetas" class="table table-striped table-hover w-100">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= lang('Logistica.id') ?? 'ID Envío' ?></th>
|
||||
<th><?= lang('Logistica.numeroOts') ?? 'Nº OTs' ?></th>
|
||||
<th><?= lang('Logistica.numeroCajas') ?? 'Nº Cajas' ?></th>
|
||||
<th style="max-width: 8%;"><?= lang('Logistica.id') ?? 'ID Envío' ?></th>
|
||||
<th style="max-width: 10%;"><?= lang('Logistica.numeroOts') ?? 'Nº OTs' ?></th>
|
||||
<th style="max-width: 8%;"><?= lang('Logistica.numeroCajas') ?? 'Nº Cajas' ?></th>
|
||||
<th><?= lang('Logistica.att') ?? 'Att' ?></th>
|
||||
<th><?= lang('Logistica.direccion') ?? 'Dirección' ?></th>
|
||||
<th><?= lang('Logistica.acciones') ?? 'Acciones' ?></th>
|
||||
<th style="max-width: 120px;"><?= lang('Logistica.acciones') ?? 'Acciones' ?></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><input type="text" class="form-control envio-filter" name="id"></th>
|
||||
|
||||
112
httpdocs/assets/js/safekat/pages/logistica/etiquetaEdit.js
Normal file
112
httpdocs/assets/js/safekat/pages/logistica/etiquetaEdit.js
Normal file
@ -0,0 +1,112 @@
|
||||
import ClassSelect from '../../components/select2.js';
|
||||
import Ajax from '../../components/ajax.js';
|
||||
import AlbaranComponent from '../../components/albaranComponent.js';
|
||||
|
||||
class EtiquetaEdit {
|
||||
|
||||
constructor() {
|
||||
|
||||
this.tableCols = [
|
||||
{ data: "rowSelected" },
|
||||
{ data: "ot" },
|
||||
{ data: "titulo" },
|
||||
{ data: "numero_caja" },
|
||||
{ data: "unidades" },
|
||||
{ data: "unidadesTotal" },
|
||||
{ data: "id" },
|
||||
{ data: "pesoUnidad" },
|
||||
{ data: "unidadesRaw" }
|
||||
];
|
||||
|
||||
this.table = null;
|
||||
|
||||
this.direccion = $('#direccion');
|
||||
}
|
||||
|
||||
init() {
|
||||
this.initDatatable();
|
||||
}
|
||||
|
||||
initDatatable() {
|
||||
|
||||
this.table = $('#tableLineasEtiqueta').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
autoWidth: true,
|
||||
responsive: true,
|
||||
scrollX: true,
|
||||
orderCellsTop: true,
|
||||
orderable: false,
|
||||
order: [[7, 'asc']],
|
||||
lengthMenu: [5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500],
|
||||
pageLength: 50,
|
||||
"dom": 'lrtip',
|
||||
"ajax": {
|
||||
"url": "/etiquetasTitulos/datatableLineas/" + $('#id').val(),
|
||||
"data": function (d) {
|
||||
d.direccion = $('#direccion').val();
|
||||
d.id = $('#id').val();
|
||||
},
|
||||
},
|
||||
"columns": this.tableCols,
|
||||
"language": {
|
||||
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||
},
|
||||
footerCallback: function (row, data, start, end, display) {
|
||||
let totalUnidades = 0;
|
||||
let totalPeso = 0;
|
||||
|
||||
data.forEach(row => {
|
||||
const unidades = parseFloat(row.unidadesEnvioRaw) || 0;
|
||||
const pesoUnidad = parseFloat(row.pesoUnidad) || 0;
|
||||
totalUnidades += unidades;
|
||||
totalPeso += unidades * pesoUnidad;
|
||||
});
|
||||
|
||||
// Mostrar en spans personalizados del <tfoot>
|
||||
$('#footer-unidades-envio').text(totalUnidades);
|
||||
$('#footer-peso').text(totalPeso.toFixed(2));
|
||||
},
|
||||
"columnDefs": [
|
||||
{
|
||||
"targets": [0],
|
||||
"className": "text-center",
|
||||
"orderable": false,
|
||||
"searchable": false,
|
||||
},
|
||||
{
|
||||
"targets": [1, 2, 4, 5, 6],
|
||||
"className": "text-center",
|
||||
},
|
||||
{
|
||||
targets: [6, 7, 8],
|
||||
visible: false
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
/*const dropdown = document.querySelector(".dropdown-language");
|
||||
const activeItem = dropdown.querySelector(".dropdown-menu .dropdown-item");
|
||||
let locale = 'es';
|
||||
if (activeItem) {
|
||||
locale = activeItem.getAttribute("data-language");
|
||||
}
|
||||
|
||||
new Ajax('/translate/getTranslation', { locale: locale, translationFile: [] }, {},
|
||||
function (translations) {
|
||||
window.language = JSON.parse(translations);
|
||||
new EtiquetaEdit().init();
|
||||
},
|
||||
function (error) {
|
||||
console.log("Error getting translations:", error);
|
||||
}
|
||||
).post();
|
||||
*/
|
||||
new EtiquetaEdit().init();
|
||||
});
|
||||
|
||||
export default EtiquetaEdit;
|
||||
@ -2,6 +2,8 @@ import ClassSelect from '../../components/select2.js';
|
||||
|
||||
$(() => {
|
||||
|
||||
let otsFilter = '';
|
||||
|
||||
const selectOts = new ClassSelect($('#buscadorPedidos'), '/etiquetasTitulos/otList', "", true);
|
||||
selectOts.init();
|
||||
|
||||
@ -26,7 +28,7 @@ $(() => {
|
||||
selectDirecciones.item.on('change', () => {
|
||||
$('.add-etiqueta').removeClass('d-none');
|
||||
})
|
||||
|
||||
|
||||
$('#btnAddEtiqueta').on('click', () => {
|
||||
|
||||
Swal.fire({
|
||||
@ -59,7 +61,9 @@ $(() => {
|
||||
data,
|
||||
function (response) {
|
||||
if (response.status) {
|
||||
// OK
|
||||
tableEtiquetas.ajax.reload();
|
||||
// open the new etiqueta in a new tab
|
||||
window.open(`${window.location.origin}/etiquetasTitulos/edit/${response.etiqueta}`, '_blank');
|
||||
} else {
|
||||
popErrorAlert('Error en la respuesta');
|
||||
}
|
||||
@ -70,4 +74,104 @@ $(() => {
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
const tableEtiquetas = $('#tableOfEquiquetas').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
autoWidth: true,
|
||||
responsive: true,
|
||||
scrollX: true,
|
||||
orderCellsTop: true,
|
||||
lengthMenu: [5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500],
|
||||
pageLength: 50,
|
||||
"dom": 'lBrtip',
|
||||
"ajax": {
|
||||
"url": "/etiquetasTitulos/datatable",
|
||||
"data": function (d) {
|
||||
d.otsFilter = otsFilter;
|
||||
}
|
||||
},
|
||||
"columns": [
|
||||
{ "data": "id" },
|
||||
{ "data": "lista_ots" },
|
||||
{ "data": "cajas" },
|
||||
{ "data": "att" },
|
||||
{ "data": "direccion" },
|
||||
{ "data": "action" }
|
||||
|
||||
],
|
||||
"language": {
|
||||
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||
},
|
||||
"columnDefs": [
|
||||
{
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
targets: [5]
|
||||
},
|
||||
],
|
||||
"order": [[0, "desc"]],
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-edit', function (e) {
|
||||
window.location.href = '/etiquetasTitulos/edit/' + $(this).attr('data-id');
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-delete', function (e) {
|
||||
Swal.fire({
|
||||
title: '¿Está seguro de eliminar la etiqueta?',
|
||||
text: "No podrá revertir esta acción",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Sí',
|
||||
cancelButtonText: 'Cancelar',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-danger me-1',
|
||||
cancelButton: 'btn btn-secondary'
|
||||
},
|
||||
buttonsStyling: false
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$.post(
|
||||
'/etiquetasTitulos/delete',
|
||||
{
|
||||
id: $(this).attr('data-id')
|
||||
},
|
||||
function (response) {
|
||||
if (response.status) {
|
||||
tableEtiquetas.ajax.reload();
|
||||
popSuccessAlert(response.message);
|
||||
} else {
|
||||
popErrorAlert('Error borrando la etiqueta');
|
||||
}
|
||||
}
|
||||
).fail(function (xhr, status, error) {
|
||||
popErrorAlert(error);
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
$(document).on("keyup", ".envio-filter", (event) => {
|
||||
let columnName = $(event.currentTarget).attr("name");
|
||||
let columnIndex = $('#tableOfEquiquetas').DataTable().columns().eq(0).filter(function (index) {
|
||||
return $('#tableOfEquiquetas').DataTable().column(index).dataSrc() === columnName;
|
||||
})[0];
|
||||
$('#tableOfEquiquetas').DataTable().column(columnIndex).search($(event.currentTarget).val()).draw()
|
||||
})
|
||||
|
||||
|
||||
$(document).on("keyup", ".envio-filter-ots", (event) => {
|
||||
otsFilter = $(event.currentTarget).val();
|
||||
$('#tableOfEquiquetas').DataTable().ajax.reload();
|
||||
})
|
||||
|
||||
$(document).on("change", ".envio-filter-select", (event) => {
|
||||
let columnName = $(event.currentTarget).attr("name");
|
||||
let columnIndex = $('#tableOfEquiquetas').DataTable().columns().eq(0).filter(function (index) {
|
||||
return $('#tableOfEquiquetas').DataTable().column(index).dataSrc() === columnName;
|
||||
})[0];
|
||||
$('#tableOfEquiquetas').DataTable().column(columnIndex).search($(event.currentTarget).val()).draw();
|
||||
});
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user