mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
finalizar envio ok
This commit is contained in:
@ -791,7 +791,7 @@ $routes->group('logistica', ['namespace' => 'App\Controllers\Logistica'], functi
|
||||
|
||||
$routes->get('print/label/test', 'LogisticaController::print_test_label');
|
||||
$routes->get('panel', 'LogisticaController::panel', ['as' => 'LogisticaPanel']);
|
||||
$routes->get('selectEnvios/(:any)', 'LogisticaController::selectorEnvios/$1', ['as' => 'selectEnvios']);
|
||||
$routes->get('envios', 'LogisticaController::gestionEnvios', ['as' => 'gestionEnvios']);
|
||||
$routes->get('buscar/(:any)', 'LogisticaController::searchPedidoOrISBN/$1', ['as' => 'buscarPedidoOrISBN']);
|
||||
$routes->get('datatableEnvios', 'LogisticaController::datatable_envios');
|
||||
$routes->get('datatableLineasEnvios/(:num)', 'LogisticaController::datatable_enviosEdit/$1');
|
||||
@ -803,6 +803,9 @@ $routes->group('logistica', ['namespace' => 'App\Controllers\Logistica'], functi
|
||||
$routes->post('updateLineaEnvio', 'LogisticaController::updateLineaEnvio');
|
||||
$routes->post('updateComentariosEnvio', 'LogisticaController::saveComments');
|
||||
$routes->post('updateCajasEnvio', 'LogisticaController::updateCajasEnvio');
|
||||
$routes->post('updateCodigoSeguimiento', 'LogisticaController::updateCodigoSeguimiento');
|
||||
$routes->post('updateProveedorEnvio', 'LogisticaController::updateProveedorEnvio');
|
||||
$routes->post('finalizarEnvio', 'LogisticaController::finalizarEnvio');
|
||||
});
|
||||
|
||||
/*
|
||||
|
||||
@ -19,6 +19,7 @@ $routes->group('compras', ['namespace' => 'App\Controllers\Compras'], function (
|
||||
$routes->get('delete/(:num)', 'Proveedores::delete/$1', ['as' => 'deleteProveedores']);
|
||||
$routes->post('allmenuitems', 'Proveedores::allItemsSelect', ['as' => 'select2ItemsOfProveedores']);
|
||||
$routes->post('menuitems', 'Proveedores::menuItems', ['as' => 'menuItemsOfProveedores']);
|
||||
$routes->get('getProveedores', 'Proveedores::getForSelect');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -383,4 +383,26 @@ class Proveedores extends \App\Controllers\BaseResourceController {
|
||||
}
|
||||
}
|
||||
|
||||
public function getForSelect(){
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
$tipo_id = $this->request->getGet("tipo_id");
|
||||
$query = $this->model->builder()->select(
|
||||
[
|
||||
"id",
|
||||
"nombre as name"
|
||||
]
|
||||
)->where('tipo_id', $tipo_id)->where('deleted_at', null)->orderBy("nombre", "asc");
|
||||
if ($this->request->getGet("q")) {
|
||||
$query->groupStart()
|
||||
->orLike("lg_proveedores.nombre", $this->request->getGet("q"))
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
return $this->response->setJSON($query->get()->getResultObject());
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ class LogisticaController extends BaseController
|
||||
|
||||
// Breadcrumbs
|
||||
$this->viewData['breadcrumb'] = [
|
||||
['title' => lang("App.menu_logistica"), 'route' => "javascript:void(0);", 'active' => false],
|
||||
['title' => lang("App.menu_logistica"), 'route' => route_to("LogisticaPanel"), 'active' => false],
|
||||
];
|
||||
|
||||
|
||||
@ -56,13 +56,12 @@ class LogisticaController extends BaseController
|
||||
return view(static::$viewPath . 'viewPanelLogistica', $viewData);
|
||||
}
|
||||
|
||||
public function selectorEnvios($tipoEnvio = null)
|
||||
public function gestionEnvios()
|
||||
{
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'boxTitle' => lang('Logistica.envioSimpleMultiple'),
|
||||
'boxTitle' => lang('Logistica.gestionEnvios'),
|
||||
'usingServerSideDataTable' => true,
|
||||
'tipoEnvio' => $tipoEnvio,
|
||||
];
|
||||
|
||||
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
|
||||
@ -164,6 +163,16 @@ class LogisticaController extends BaseController
|
||||
return redirect()->to(base_url('logistica/selectEnvios/simple'))->with('error', lang('Logistica.errors.noEnvio'));
|
||||
}
|
||||
|
||||
$modelProveedor = model('App\Models\Compras\ProveedorModel');
|
||||
$proveedor = $modelProveedor->select('id, nombre')
|
||||
->where('deleted_at', null)
|
||||
->where('id', $envioEntity->proveedor_id)
|
||||
->orderBy('nombre', 'asc')
|
||||
->first();
|
||||
if(!empty($proveedor)){
|
||||
$envioEntity->proveedor_nombre = $proveedor->nombre;
|
||||
}
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'boxTitle' => '<i class="ti ti-truck ti-xl"></i>' . ' ' . lang('Logistica.envio') . ' [' . $envioEntity->id . ']: ' . $envioEntity->direccion,
|
||||
@ -193,6 +202,19 @@ class LogisticaController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
public function finalizarEnvio()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$id = $this->request->getPost('id');
|
||||
|
||||
$result = LogisticaService::finalizarEnvio($id);
|
||||
return $this->response->setJSON($result);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function datatable_enviosEdit($idEnvio)
|
||||
{
|
||||
$model = model('App\Models\Logistica\EnvioLineaModel');
|
||||
@ -217,23 +239,16 @@ class LogisticaController extends BaseController
|
||||
function ($row, $meta) {
|
||||
return '<a href="' . base_url('presupuestoadmin/edit/' . $row->presupuesto) . '" target="_blank">' . $row->presupuesto . '</a>';
|
||||
}
|
||||
)
|
||||
->edit(
|
||||
"cajas",
|
||||
function ($row, $meta) {
|
||||
return '<input type="number" class="form-control input-lineas input-cajas text-center"
|
||||
data-id="'. $row->id.'" data-name="cajas" value="' . $row->cajas . '">';
|
||||
}
|
||||
)->edit(
|
||||
"unidadesEnvio",
|
||||
function ($row, $meta) {
|
||||
if($row->finalizado == 1){
|
||||
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 . '">';
|
||||
}
|
||||
)
|
||||
->edit('cajasRaw', function ($row) {
|
||||
return is_null($row->cajas) ? '__SIN__ASIGNAR__' : $row->cajas;
|
||||
});
|
||||
);
|
||||
|
||||
return $result->toJson(returnAsObject: true);
|
||||
}
|
||||
@ -296,6 +311,52 @@ class LogisticaController extends BaseController
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateCodigoSeguimiento()
|
||||
{
|
||||
$id = $this->request->getPost('id');
|
||||
$fieldValue = $this->request->getPost('codigo_seguimiento');
|
||||
|
||||
if (!$id) {
|
||||
return $this->response->setJSON([
|
||||
'status' => false,
|
||||
'message' => 'Datos inválidos'
|
||||
]);
|
||||
}
|
||||
|
||||
$model = model('App\Models\Logistica\EnvioModel');
|
||||
$updated = $model->update($id, [
|
||||
"codigo_seguimiento" => $fieldValue==""? null: $fieldValue,
|
||||
]);
|
||||
|
||||
return $this->response->setJSON([
|
||||
'status' => $updated,
|
||||
'message' => $updated ? 'Actualizado' : 'Error al actualizar'
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateProveedorEnvio()
|
||||
{
|
||||
$id = $this->request->getPost('id');
|
||||
$fieldValue = $this->request->getPost('proveedor_id');
|
||||
|
||||
if (!$id) {
|
||||
return $this->response->setJSON([
|
||||
'status' => false,
|
||||
'message' => 'Datos inválidos'
|
||||
]);
|
||||
}
|
||||
|
||||
$model = model('App\Models\Logistica\EnvioModel');
|
||||
$updated = $model->update($id, [
|
||||
"proveedor_id" => $fieldValue==""? null: $fieldValue,
|
||||
]);
|
||||
|
||||
return $this->response->setJSON([
|
||||
'status' => $updated,
|
||||
'message' => $updated ? 'Actualizado' : 'Error al actualizar'
|
||||
]);
|
||||
}
|
||||
|
||||
public function saveComments()
|
||||
{
|
||||
$id = $this->request->getPost('id');
|
||||
|
||||
@ -2,13 +2,11 @@
|
||||
return [
|
||||
'logistica' => 'Logística',
|
||||
'panel' => 'Panel',
|
||||
'envioSimple' => 'Envío simple',
|
||||
'envioMultiple' => 'Envío múltiple',
|
||||
'envioConjunto' => 'Envío conjunto',
|
||||
'gestionEnvios' => 'Gestión de Envíos de pedidos',
|
||||
'etiquetasTitulos' => 'Etiquetas de títulos',
|
||||
'etiquetasEnvio' => 'Etiquetas de envío',
|
||||
'envioFerros' => 'Envío de ferros',
|
||||
'cerrarOTauto' => 'Cerrar OT automáticamente',
|
||||
'envioFerros' => 'Gestión de Envíos de ferros/prototipos',
|
||||
'albaranes' => 'Albaranes',
|
||||
'envioSimpleMultiple' => 'Envío simple/múltiple',
|
||||
'nuevoEnvio' => 'Nuevo envío',
|
||||
'buscadorPedidosTitle' => 'Código Pedido o ISBN',
|
||||
@ -58,11 +56,20 @@ return [
|
||||
'peso' => 'Peso (kg): ',
|
||||
'unidadesTotalesFooter' => 'Unidades:',
|
||||
|
||||
'codigoSeguimiento' => 'Código de seguimiento',
|
||||
'empresaMensajería' => 'Empresa de mensajería',
|
||||
'finalizarEnvio' => 'Finalizar envío',
|
||||
'finalizarEnvioYOTs' => 'Finalizar envío y OTS',
|
||||
|
||||
'errors' => [
|
||||
'noEnvio' => 'No se ha encontrado el envio',
|
||||
'noEnvioLineas' => 'No se han encontrado líneas de envío',
|
||||
'noDataToFind' => 'No se ha introducido ningún dato para buscar',
|
||||
'notFound' => 'No se encuentra el pedido o ISBN, el pedido aún no se ha finalizado o no tiene envíos pendientes',
|
||||
'noAddresses' => 'El pedido no tiene direcciones de envío',
|
||||
],
|
||||
'success' => [
|
||||
'finalizado' => 'El envío se ha finalizado correctamente',
|
||||
],
|
||||
|
||||
];
|
||||
@ -46,13 +46,21 @@ class EnvioLineaModel extends Model
|
||||
WHERE e.finalizado = 1
|
||||
AND t_sub.pedido_id = t1.pedido_id
|
||||
AND e.direccion = d.direccion COLLATE utf8mb3_general_ci
|
||||
AND (
|
||||
t_sub.envio_id <> t1.envio_id
|
||||
OR (t_sub.envio_id = t1.envio_id AND (
|
||||
SELECT finalizado FROM envios WHERE id = t1.envio_id
|
||||
) = 1)
|
||||
)
|
||||
), 0) as unidadesEnviadas,
|
||||
IFNULL((
|
||||
SELECT ROUND(SUM(peso) / 1000, 1)
|
||||
FROM presupuesto_linea
|
||||
WHERE presupuesto_id = t3.id
|
||||
), 0) AS pesoUnidad"
|
||||
), 0) AS pesoUnidad,
|
||||
t2.finalizado as finalizado,"
|
||||
);
|
||||
$builder->join("envios t2", "t1.envio_id = t2.id", "left");
|
||||
$builder->join("presupuestos t3", "t1.presupuesto_id = t3.id", "left");
|
||||
|
||||
$builder->where("t1.envio_id", $envio_id);
|
||||
@ -60,5 +68,5 @@ class EnvioLineaModel extends Model
|
||||
return $builder;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
use App\Services\ProductionService;
|
||||
|
||||
use Config\Services;
|
||||
|
||||
@ -282,6 +283,73 @@ class LogisticaService
|
||||
'message' => lang('Logistica.errors.noAddresses'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function finalizarEnvio($envio_id)
|
||||
{
|
||||
// hay que comprobar que para todas las lineas de envio de este envio
|
||||
// se ha enviado toda la cantidad teniendo en cuenta otros envios
|
||||
$EnvioModel = model('App\Models\Logistica\EnvioModel');
|
||||
$EnvioLineasModel = model('App\Models\Logistica\EnvioLineaModel');
|
||||
|
||||
$envio = $EnvioModel->find($envio_id);
|
||||
if (empty($envio)) {
|
||||
return [
|
||||
'status' => false,
|
||||
'message' => lang('Logistica.errors.noEnvio'),
|
||||
];
|
||||
}
|
||||
$lineasEnvio = $EnvioLineasModel->where('envio_id', $envio_id)
|
||||
->findAll();
|
||||
if (empty($lineasEnvio)) {
|
||||
return [
|
||||
'status' => false,
|
||||
'message' => lang('Logistica.errors.noEnvioLineas'),
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($lineasEnvio as $linea) {
|
||||
|
||||
$pedido = model('App\Models\Pedidos\PedidoModel')->find($linea->pedido_id);
|
||||
if (empty($pedido)) {
|
||||
return [
|
||||
'status' => false,
|
||||
'message' => lang('Logistica.errors.notFound'),
|
||||
];
|
||||
}
|
||||
$cantidad_enviada = $EnvioLineasModel->select('SUM(envios_lineas.unidades_envio) as unidades_enviadas')
|
||||
->where('envios_lineas.pedido_id', $linea->pedido_id)
|
||||
->where('envios_lineas.envio_id !=', $envio_id)
|
||||
->where('envios.finalizado', 1)
|
||||
->join('envios', 'envios.id = envios_lineas.envio_id')
|
||||
->get()->getResult();
|
||||
|
||||
if (count($cantidad_enviada) == 0 ||
|
||||
empty($cantidad_enviada[0]->unidades_enviadas) ||
|
||||
$cantidad_enviada[0]->unidades_enviadas == null) {
|
||||
$cantidad_enviada = 0;
|
||||
} else {
|
||||
$cantidad_enviada = $cantidad_enviada[0]->unidades_enviadas;
|
||||
}
|
||||
|
||||
if ($cantidad_enviada + $linea->unidades_envio == $linea->unidades_total) {
|
||||
$otModel = model('App\Models\OrdenTrabajo\OrdenTrabajoModel');
|
||||
$ot = $otModel->where('pedido_id', $linea->pedido_id)
|
||||
->first();
|
||||
$ps = (new ProductionService())->init($ot->id);
|
||||
$ps->updateOrdenTrabajoDate([
|
||||
"name" => "envio_at",
|
||||
"envio_at" => date('Y-m-d H:i:s')
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$EnvioModel->update($envio_id, ['finalizado'=> 1]);
|
||||
|
||||
return [
|
||||
'status' => true,
|
||||
'message' => lang('Logistica.success.finalizado'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h4><?= $boxTitle ?></h4>
|
||||
<h4><?= $boxTitle ?> <span class="badge text-bg-success fw-lg">FINALIZADO</span></h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
|
||||
@ -112,41 +112,43 @@
|
||||
</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.addLineasEnvio") ?>
|
||||
</h4>
|
||||
<?php if ($envioEntity->finalizado == 0): ?>
|
||||
<div class="accordion accordion-bordered">
|
||||
<div class="card accordion-item active mb-5">
|
||||
<h4 class="accordion-header px-4 py-3">
|
||||
<?= lang("Logistica.addLineasEnvio") ?>
|
||||
</h4>
|
||||
|
||||
<div id="accordionaddLineasEnvioTip" class="accordion-collapse collapse show">
|
||||
<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 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 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>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<div class="accordion accordion-bordered">
|
||||
@ -168,13 +170,15 @@
|
||||
<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>
|
||||
<?php if ($envioEntity->finalizado == 0): ?>
|
||||
<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>
|
||||
<?php endif; ?>
|
||||
<div class="col-sm-2 px-3">
|
||||
<button id="btnGenerarAlbaran" name="btnGenerarAlbaran" tabindex="1"
|
||||
class="btn btn-success w-100">
|
||||
@ -244,35 +248,90 @@
|
||||
<input type="number" id="cajas" name="cajas" tabindex="1" maxlength="50"
|
||||
class="form-control" value="<?= old('cajas', $envioEntity->cajas) ?>">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="accordion accordion-bordered mt-3" id="accordioAlbaranes">
|
||||
<div class="accordion accordion-bordered mt-3 mb-5" id="accordioAlbaranes">
|
||||
|
||||
<div class="card accordion-item active">
|
||||
<h2 class="accordion-header" id="headingAlbaranes">
|
||||
<button type="button" class="accordion-button" data-bs-toggle="collapse"
|
||||
data-bs-target="#accordionAlbaranesTip" aria-expanded="false"
|
||||
aria-controls="accordionAlbaranesTip">
|
||||
<h3><?= lang("Pedidos.albaranes") ?></h3>
|
||||
</button>
|
||||
</h2>
|
||||
<div class="card accordion-item active">
|
||||
<h2 class="accordion-header" id="headingAlbaranes">
|
||||
<button type="button" class="accordion-button" data-bs-toggle="collapse"
|
||||
data-bs-target="#accordionAlbaranesTip" aria-expanded="false"
|
||||
aria-controls="accordionAlbaranesTip">
|
||||
<h3><?= lang("Pedidos.albaranes") ?></h3>
|
||||
</button>
|
||||
</h2>
|
||||
|
||||
<div id="accordionAlbaranesTip" class="accordion-collapse collapse show"
|
||||
data-bs-parent="#accordioAlbaranes">
|
||||
<div id="contenedorAlbaranes" class="accordion-body">
|
||||
<div id="accordionAlbaranesTip" class="accordion-collapse collapse show"
|
||||
data-bs-parent="#accordioAlbaranes">
|
||||
<div id="contenedorAlbaranes" class="accordion-body">
|
||||
|
||||
|
||||
</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.acciones") ?>
|
||||
</h4>
|
||||
|
||||
<div class="d-flex flex-row mb-3">
|
||||
<div class="col-sm-3 px-3">
|
||||
<label for="codigoSeguimiento" class="form-label">
|
||||
<?= lang("Logistica.codigoSeguimiento") ?>
|
||||
</label>
|
||||
<input type="text" id="codigoSeguimiento" name="codigo_seguimiento" tabindex="1"
|
||||
maxlength="100" class="form-control"
|
||||
<?= ($envioEntity->finalizado == 0) ? "" : "readonly" ?>
|
||||
value="<?= old('codigo_seguimiento', $envioEntity->codigo_seguimiento) ?>">
|
||||
</div>
|
||||
<div class="col-sm-3 px-3">
|
||||
<label for="empresaMensajeria" class="form-label">
|
||||
<?= lang("Logistica.empresaMensajería") ?>
|
||||
</label>
|
||||
<?php if ($envioEntity->finalizado == 0): ?>
|
||||
<select id="empresaMensajeria" name="empresa_mensajeria" tabindex="1" maxlength="50"
|
||||
class="form-control select2bs2" style="width: 100%;">
|
||||
<?php if ($envioEntity->proveedor_id): ?>
|
||||
<option value="<?= $envioEntity->proveedor_id ?>" "selected">
|
||||
<?= $envioEntity->proveedor_nombre ?>
|
||||
</option>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
<?php else: ?>
|
||||
<input type="text" id="empresaMensajeriaInput" name="empresa_mensajeria_input"
|
||||
tabindex="1" maxlength="100" class="form-control" readonly
|
||||
value="<?= old('empresa_mensajeria', $envioEntity->proveedor_nombre) ?>">
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php if ($envioEntity->finalizado == 0): ?>
|
||||
<div class="col-sm-3 px-3">
|
||||
<button id="finalizarEnvio" name="finalizar_envio" tabindex="1"
|
||||
class="btn btn-primary mt-4 w-100">
|
||||
<?= lang("Logistica.finalizarEnvio") ?>
|
||||
<ti class="ti ti-check"></ti>
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-sm-3 px-3">
|
||||
<button id="finalizarEnvioYOTs" name="finalizar_envio_ots" tabindex="1"
|
||||
class="btn btn-primary mt-4 w-100">
|
||||
<?= lang("Logistica.finalizarEnvioYOTs") ?>
|
||||
<ti class="ti ti-checks"></ti>
|
||||
</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -12,48 +12,24 @@
|
||||
</div>
|
||||
<div class="card-body">
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-4">
|
||||
<button type="button" style="height: 80px;" class="btn btn-primary w-100 "
|
||||
onclick="window.location.href='<?= route_to('selectEnvios', 'simple') ?>'"
|
||||
>
|
||||
<?= lang('Logistica.envioSimple') ?>
|
||||
</button>
|
||||
<div class="grid">
|
||||
<div class="item" onclick="location.href='<?= route_to('gestionEnvios') ?>'">
|
||||
<img src="<?= site_url("assets/img/logistica/envios.jpg") ?>" alt="Envíos">
|
||||
<div><span><?= lang("Logistica.gestionEnvios"); ?></span></div>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<button type="button" style="height: 80px;" class="btn btn-primary w-100 " >
|
||||
<?= lang('Logistica.envioMultiple') ?>
|
||||
</button>
|
||||
<div class="item">
|
||||
<img src="<?= site_url("assets/img/logistica/envios_ferros.png") ?>" alt="Envío de Ferros/Prototipos">
|
||||
<div><span><?= lang("Logistica.envioFerros"); ?></span></div>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<button type="button" style="height: 80px;" class="btn btn-primary w-100 " >
|
||||
<?= lang('Logistica.envioConjunto') ?>
|
||||
</button>
|
||||
<div class="item">
|
||||
<img src="<?= site_url("assets/img/logistica/impresionEtiquetas.jpg") ?>" alt="Etiquetas de títulos">
|
||||
<div><span><?= lang("Logistica.etiquetasTitulos"); ?></span></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col-4">
|
||||
<button type="button" style="height: 80px;" class="btn btn-primary w-100 " >
|
||||
<?= lang('Logistica.etiquetasTitulos') ?>
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<button type="button" style="height: 80px;" class="btn btn-primary w-100 " >
|
||||
<?= lang('Logistica.etiquetasEnvio') ?>
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<button type="button" style="height: 80px;" class="btn btn-primary w-100 " >
|
||||
<?= lang('Logistica.envioFerros') ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
<button type="button" style="height: 80px;" class="btn btn-primary w-100 " >
|
||||
<?= lang('Logistica.cerrarOTauto') ?>
|
||||
</button>
|
||||
<div class="item">
|
||||
<img src="<?= site_url("assets/img/logistica/albaranes.png") ?>" alt="Albaranes">
|
||||
<div><span><?= lang("Logistica.albaranes"); ?></span></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -63,6 +39,7 @@
|
||||
<?= $this->endSection(); ?>
|
||||
|
||||
<?= $this->section('css') ?>
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/logisticaPanel.css') ?>">
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
|
||||
@ -28,9 +28,18 @@ class EnvioEdit {
|
||||
this.btnGenerarAlbaran = $("#btnGenerarAlbaran");
|
||||
this.btnbtnSelectAll = $("#btnSelectAll");
|
||||
this.cajas = $("#cajas");
|
||||
this.codigoSeguimiento = $("#codigoSeguimiento");
|
||||
if($("#empresaMensajeriaInput").length) {
|
||||
this.proveedor = new ClassSelect($("#empresaMensajeria"), '/compras/proveedores/getProveedores', "", true, { 'tipo_id': 2 });
|
||||
}
|
||||
}
|
||||
|
||||
init() {
|
||||
|
||||
if($("#empresaMensajeriaInput").length) {
|
||||
this.proveedor.init();
|
||||
}
|
||||
|
||||
this.table = $('#tableLineasEnvio').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
@ -205,8 +214,158 @@ class EnvioEdit {
|
||||
const checkboxes = this.table.$('input[type="checkbox"]');
|
||||
const allChecked = checkboxes.length === checkboxes.filter(':checked').length;
|
||||
checkboxes.prop('checked', !allChecked);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
this.codigoSeguimiento.on('change', (e) => {
|
||||
const value = $(e.currentTarget).val();
|
||||
|
||||
$.post('/logistica/updateCodigoSeguimiento', {
|
||||
id: $('#id').val(),
|
||||
codigo_seguimiento: value
|
||||
}, function (response) {
|
||||
if (!response.status) {
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
text: response.message,
|
||||
icon: 'error',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
$(e.currentTarget).val(value.substring(0, 100));
|
||||
}
|
||||
}).fail(() => {
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
text: 'No se pudo actualizar el código de seguimiento.',
|
||||
icon: 'error',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
$(e.currentTarget).val(value.substring(0, 100));
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
this.proveedor.onChange((e) => {
|
||||
|
||||
const value = this.proveedor.getVal();
|
||||
$.post('/logistica/updateProveedorEnvio', {
|
||||
id: $('#id').val(),
|
||||
proveedor_id: value
|
||||
}, function (response) {
|
||||
if (!response.status) {
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
text: response.message,
|
||||
icon: 'error',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
this.proveedor.setVal(0);
|
||||
}
|
||||
}).fail(() => {
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
text: 'No se pudo actualizar el proveedor.',
|
||||
icon: 'error',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
this.proveedor.setVal(0);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
$('#finalizarEnvio').on('click', () => {
|
||||
|
||||
if(this.codigoSeguimiento.val().length <= 0 || this.proveedor.getVal() <= 0) {
|
||||
Swal.fire({
|
||||
title: 'Atención!',
|
||||
text: 'Debe seleccionar un proveedor y un código de seguimiento antes de finalizar el envío.',
|
||||
icon: 'info',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
Swal.fire({
|
||||
title: 'Finalizar envío',
|
||||
text: '¿Está seguro de que desea finalizar el envío?',
|
||||
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('/logistica/finalizarEnvio', {
|
||||
id: $('#id').val()
|
||||
}, function (response) {
|
||||
if (response.status) {
|
||||
Swal.fire({
|
||||
text: response.message,
|
||||
icon: 'success',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
text: response.message,
|
||||
icon: 'error',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
}
|
||||
}).fail(() => {
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
text: 'No se pudo finalizar el envío.',
|
||||
icon: 'error',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
this._getAlbaranes();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user