mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
hecho lo de proximos envios
This commit is contained in:
@ -765,6 +765,7 @@ $routes->group('produccion', ['namespace' => 'App\Controllers\Produccion'], func
|
||||
$routes->get('tareas/datatable/(:num)', 'Ordentrabajo::tareas_datatable/$1', ['as' => 'datatableTareasOrdenTrabajo']);
|
||||
$routes->get('maquinas/ots/datatable/(:num)','Ordentrabajo::datatable_maquina_ordenes_trabajo/$1');
|
||||
$routes->get('maquinas/ots/(:num)','Ordentrabajo::get_maquina_ots/$1');
|
||||
|
||||
/**======================
|
||||
* UPDATES
|
||||
*========================**/
|
||||
@ -872,6 +873,7 @@ $routes->group('logistica', ['namespace' => 'App\Controllers\Logistica'], functi
|
||||
$routes->get('selectDireccionForEnvio', 'LogisticaController::selectDireccionForEnvio');
|
||||
$routes->post('imprimirEtiquetas', 'LogisticaController::imprimirEtiquetas');
|
||||
$routes->post('ficharEmbalaje', 'LogisticaController::ficharEmbalaje');
|
||||
$routes->get('datatableProximosEnvios/(:num)', 'LogisticaController::datatable_proximosEnvios/$1');
|
||||
|
||||
$routes->get('listAlbaranes', 'LogisticaController::listAlbaranes', ['as' => 'albaranesList']);
|
||||
});
|
||||
|
||||
@ -98,7 +98,8 @@ class LogisticaController extends BaseController
|
||||
return view(static::$viewPath . 'viewImpresionEtiquetas', $viewData);
|
||||
}
|
||||
|
||||
public function listAlbaranes(){
|
||||
public function listAlbaranes()
|
||||
{
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'boxTitle' => lang('Albaran.albaranes'),
|
||||
@ -117,7 +118,7 @@ class LogisticaController extends BaseController
|
||||
|
||||
$tipo_envio = $this->request->getGet('tipo_envio') ?? 'estandar';
|
||||
|
||||
if($tipo_envio == 'ferro_prototipo'){
|
||||
if ($tipo_envio == 'ferro_prototipo') {
|
||||
$query = LogisticaService::findForNewEnvioFerro();
|
||||
} else {
|
||||
$query = LogisticaService::findForNewEnvio();
|
||||
@ -140,16 +141,17 @@ class LogisticaController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
public function selectDireccionForEnvio(){
|
||||
public function selectDireccionForEnvio()
|
||||
{
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
$ot = $this->request->getGet('ot_id');
|
||||
if($ot == null || $ot == 0){
|
||||
if ($ot == null || $ot == 0) {
|
||||
return [];
|
||||
}
|
||||
$searchVal = $this->request->getGet("q") ?? "";
|
||||
$result = LogisticaService::findDireccionesNewEnvio($ot, $searchVal);
|
||||
|
||||
|
||||
return $this->response->setJSON($result);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
@ -187,12 +189,12 @@ class LogisticaController extends BaseController
|
||||
public function imprimirEtiquetas()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$envio_id = $this->request->getPost('envio_id');
|
||||
$envio_id = $this->request->getPost('envio_id');
|
||||
$ids = $this->request->getPost('envio_lineas');
|
||||
$cajas = $this->request->getPost('cajas');
|
||||
$printer_id = $this->request->getPost('printer_id');
|
||||
|
||||
if($cajas == null || $cajas == 0){
|
||||
if ($cajas == null || $cajas == 0) {
|
||||
return $this->response->setJSON([
|
||||
'status' => false,
|
||||
'message' => 'Cajas no válidas'
|
||||
@ -204,7 +206,7 @@ class LogisticaController extends BaseController
|
||||
->join('clientes', 'clientes.id = envios.cliente_id', 'left')
|
||||
->where('envios.id', $envio_id)
|
||||
->first();
|
||||
if($envio == null){
|
||||
if ($envio == null) {
|
||||
return $this->response->setJSON([
|
||||
'status' => false,
|
||||
'message' => 'Envio no válido'
|
||||
@ -215,7 +217,7 @@ class LogisticaController extends BaseController
|
||||
$lineas = $model->select('envios_lineas.*, presupuestos.titulo as titulo, presupuestos.referencia_cliente as referencia_cliente')
|
||||
->join('presupuestos', 'presupuestos.id = envios_lineas.presupuesto_id', 'left')
|
||||
->whereIn('envios_lineas.id', $ids)->findAll();
|
||||
if($lineas == null){
|
||||
if ($lineas == null) {
|
||||
return $this->response->setJSON([
|
||||
'status' => false,
|
||||
'message' => 'Lineas no válidas'
|
||||
@ -228,7 +230,7 @@ class LogisticaController extends BaseController
|
||||
->where('id', $printer_id)
|
||||
->orderBy('name', 'asc')
|
||||
->first();
|
||||
if($impresora == null){
|
||||
if ($impresora == null) {
|
||||
return $this->response->setJSON([
|
||||
'status' => false,
|
||||
'message' => 'Impresora no válida'
|
||||
@ -332,14 +334,14 @@ class LogisticaController extends BaseController
|
||||
if (empty($envioEntity)) {
|
||||
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)){
|
||||
if (!empty($proveedor)) {
|
||||
$envioEntity->proveedor_nombre = $proveedor->nombre;
|
||||
}
|
||||
|
||||
@ -386,7 +388,7 @@ class LogisticaController extends BaseController
|
||||
|
||||
$id = $this->request->getPost('id') ?? null;
|
||||
$finalizar_ots = $this->request->getPost('finalizar_ots') ?? false;
|
||||
|
||||
|
||||
$result = LogisticaService::finalizarEnvio($id, $finalizar_ots);
|
||||
return $this->response->setJSON($result);
|
||||
} else {
|
||||
@ -439,17 +441,35 @@ class LogisticaController extends BaseController
|
||||
)->edit(
|
||||
"unidadesEnvio",
|
||||
function ($row, $meta) {
|
||||
if($row->finalizado == 1 || $row->tipo_envio == 'ferro_prototipo'){
|
||||
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 . '">';
|
||||
data-id="' . $row->id . '" data-name="unidades_envio" value="' . $row->unidadesEnvio . '">';
|
||||
}
|
||||
);
|
||||
|
||||
return $result->toJson(returnAsObject: true);
|
||||
}
|
||||
|
||||
public function datatable_proximosEnvios($envio_id = null)
|
||||
{
|
||||
$q = LogisticaService::findNextEnvios($envio_id);
|
||||
|
||||
$result = DataTable::of($q)
|
||||
->edit(
|
||||
"ot",
|
||||
function ($row, $meta) {
|
||||
return '<a href="' . base_url('produccion/ordentrabajo/edit/' . $row->ot) . '" target="_blank">' . $row->ot . '</a>';
|
||||
}
|
||||
);
|
||||
|
||||
$result = $result->toJson(returnAsObject: true);
|
||||
$query = model('App\Models\Logistica\EnvioModel')->db->getLastQuery();
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
public function setCajaLinea()
|
||||
{
|
||||
|
||||
@ -490,7 +510,7 @@ class LogisticaController extends BaseController
|
||||
$fieldName = $this->request->getPost('name');
|
||||
$fieldValue = $this->request->getPost('value');
|
||||
|
||||
if (!$id || !$fieldName || ($fieldName=='unidades_envio' && !$fieldValue)) {
|
||||
if (!$id || !$fieldName || ($fieldName == 'unidades_envio' && !$fieldValue)) {
|
||||
return $this->response->setJSON([
|
||||
'status' => false,
|
||||
'message' => 'Datos inválidos'
|
||||
@ -499,7 +519,7 @@ class LogisticaController extends BaseController
|
||||
|
||||
$model = model('App\Models\Logistica\EnvioLineaModel');
|
||||
$updated = $model->update($id, [
|
||||
"" . $fieldName => $fieldValue==""? null: $fieldValue,
|
||||
"" . $fieldName => $fieldValue == "" ? null : $fieldValue,
|
||||
]);
|
||||
|
||||
return $this->response->setJSON([
|
||||
@ -522,7 +542,7 @@ class LogisticaController extends BaseController
|
||||
|
||||
$model = model('App\Models\Logistica\EnvioModel');
|
||||
$updated = $model->update($id, [
|
||||
"codigo_seguimiento" => $fieldValue==""? null: $fieldValue,
|
||||
"codigo_seguimiento" => $fieldValue == "" ? null : $fieldValue,
|
||||
]);
|
||||
|
||||
return $this->response->setJSON([
|
||||
@ -545,7 +565,7 @@ class LogisticaController extends BaseController
|
||||
|
||||
$model = model('App\Models\Logistica\EnvioModel');
|
||||
$updated = $model->update($id, [
|
||||
"proveedor_id" => $fieldValue==""? null: $fieldValue,
|
||||
"proveedor_id" => $fieldValue == "" ? null : $fieldValue,
|
||||
]);
|
||||
|
||||
return $this->response->setJSON([
|
||||
|
||||
@ -60,6 +60,7 @@ return [
|
||||
'selectAll' => 'Seleccionar todo',
|
||||
'peso' => 'Peso (kg): ',
|
||||
'unidadesTotalesFooter' => 'Unidades:',
|
||||
'fechaEncuadernado' => 'Fecha encuadernado',
|
||||
|
||||
'codigoSeguimiento' => 'Código de seguimiento',
|
||||
'empresaMensajería' => 'Empresa de mensajería',
|
||||
|
||||
@ -143,4 +143,25 @@ class OrdenTrabajoModel extends Model
|
||||
->groupBy('orden_trabajo_tareas.id');
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function queryProximosEnvios()
|
||||
{
|
||||
$query = $this->builder()
|
||||
->select([
|
||||
'ordenes_trabajo.id as ot',
|
||||
'orden_trabajo_dates.encuadernacion_at as fechaEncuadernado',
|
||||
])
|
||||
->join('pedidos', 'pedidos.id = ordenes_trabajo.pedido_id', 'left')
|
||||
->join('pedidos_linea', 'pedidos.id = pedidos_linea.pedido_id', 'left')
|
||||
->join('presupuestos', 'presupuestos.id = pedidos_linea.presupuesto_id', 'left')
|
||||
->join('presupuesto_direcciones', 'presupuestos.id = presupuesto_direcciones.presupuesto_id', 'left')
|
||||
->join('orden_trabajo_dates', 'orden_trabajo_dates.orden_trabajo_id = ordenes_trabajo.id', 'left')
|
||||
->where('ordenes_trabajo.deleted_at', null)
|
||||
->where('orden_trabajo_dates.encuadernacion_at !=', null)
|
||||
|
||||
//->where('orden_trabajo_dates.fecha_encuadernado_at >=', 0)
|
||||
//->where('ordenes_trabajo.fecha_entrega_warning >=', date("Y-m-d H:i:s"))
|
||||
->groupBy('ordenes_trabajo.id');
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,6 +79,79 @@ class LogisticaService
|
||||
return $builder;
|
||||
}
|
||||
|
||||
public static function findNextEnvios(int $envio_id)
|
||||
{
|
||||
$db = \Config\Database::connect();
|
||||
|
||||
// 1. Dirección del envío actual
|
||||
$envio = $db->table('envios')->select('direccion')->where('id', $envio_id)->get()->getRow();
|
||||
if (!$envio) {
|
||||
return $db->table('(SELECT NULL AS id, NULL AS name) AS empty')->where('1 = 0');
|
||||
}
|
||||
|
||||
$direccionNormalizada = str_replace(' ', '', strtolower(trim($envio->direccion)));
|
||||
$direccionSQL = $db->escape($direccionNormalizada);
|
||||
|
||||
// 2. Obtener presupuestos con esa dirección
|
||||
$presupuestosConEsaDireccion = $db->table('presupuesto_direcciones')
|
||||
->select('presupuesto_id')
|
||||
->where("REPLACE(LOWER(TRIM(direccion)), ' ', '') = $direccionSQL", null, false)
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
$presupuestoIds = array_column($presupuestosConEsaDireccion, 'presupuesto_id');
|
||||
if (empty($presupuestoIds)) {
|
||||
return $db->table('(SELECT NULL AS id, NULL AS name) AS empty')->where('1 = 0');
|
||||
}
|
||||
|
||||
$hoy = date('Y-m-d');
|
||||
$sieteDiasDespues = date('Y-m-d', strtotime('+7 days'));
|
||||
|
||||
// 3. Subconsulta principal
|
||||
$subBuilder = $db->table('pedidos_linea pl')
|
||||
->select("
|
||||
ot.id AS ot,
|
||||
DATE(p.fecha_encuadernado) as fechaEncuadernado,
|
||||
(
|
||||
SELECT IFNULL(SUM(el.unidades_envio), 0)
|
||||
FROM envios_lineas el
|
||||
JOIN envios e ON e.id = el.envio_id
|
||||
WHERE el.pedido_id = p.id
|
||||
AND el.presupuesto_id = pr.id
|
||||
AND REPLACE(LOWER(TRIM(e.direccion)), ' ', '') = $direccionSQL
|
||||
AND (e.finalizado = 1 OR e.id = $envio_id)
|
||||
) AS unidades_enviadas,
|
||||
pd.cantidad AS cantidad
|
||||
")
|
||||
->join('pedidos p', 'p.id = pl.pedido_id')
|
||||
->join('presupuestos pr', 'pr.id = pl.presupuesto_id')
|
||||
->join('presupuesto_direcciones pd', 'pd.presupuesto_id = pr.id')
|
||||
->join('ordenes_trabajo ot', 'ot.pedido_id = p.id')
|
||||
->join('orden_trabajo_dates ot_dates', 'ot_dates.orden_trabajo_id = ot.id')
|
||||
->whereIn('pr.id', $presupuestoIds)
|
||||
->whereIn('p.estado', ['finalizado', 'produccion'])
|
||||
->where('p.fecha_encuadernado IS NOT NULL')
|
||||
->where('DATE(p.fecha_encuadernado) >=', $hoy)
|
||||
->where('DATE(p.fecha_encuadernado) <=', $sieteDiasDespues)
|
||||
->where("NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM envios_lineas el
|
||||
WHERE el.envio_id = $envio_id
|
||||
AND el.pedido_id = p.id
|
||||
AND el.presupuesto_id = pr.id
|
||||
GROUP BY el.pedido_id, el.presupuesto_id
|
||||
HAVING SUM(el.unidades_envio) >= pd.cantidad
|
||||
)", null, false)
|
||||
->groupBy('pl.id');
|
||||
|
||||
// 4. Envolver y filtrar por unidades pendientes
|
||||
$builder = $db->table("({$subBuilder->getCompiledSelect(false)}) AS sub");
|
||||
$builder->select('ot, fechaEncuadernado');
|
||||
$builder->where('cantidad > unidades_enviadas');
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
|
||||
public static function findForNewEnvio()
|
||||
{
|
||||
|
||||
@ -130,7 +130,7 @@
|
||||
</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") ?>
|
||||
@ -149,258 +149,277 @@
|
||||
|
||||
<div class="col-sm-4 px-3">
|
||||
|
||||
<div id="proximosEnvios" class="card overflow-hidden" style="height: 100px; ">
|
||||
<div>Java</div>
|
||||
<div>PHP</div>
|
||||
<div>Lua</div>
|
||||
<div>SQL</div>
|
||||
<div>Java</div>
|
||||
<div>PHP</div>
|
||||
<div>Lua</div>
|
||||
<div>SQL</div>
|
||||
<div>Java</div>
|
||||
<div>PHP</div>
|
||||
<div>Lua</div>
|
||||
<div>SQL</div>
|
||||
<div>Java</div>
|
||||
<div>PHP</div>
|
||||
<div>Lua</div>
|
||||
<div>SQL</div>
|
||||
<!-- ... -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="accordion accordion-bordered mt-3 mb-5" id="accordioAlbaranes">
|
||||
|
||||
<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 class="card accordion-item">
|
||||
<h2 class="accordion-header" id="headingAlbaranes">
|
||||
<button type="button" class="accordion-button" data-bs-toggle="collapse"
|
||||
data-bs-target="#proximosEnviosTip" aria-expanded="false"
|
||||
aria-controls="proximosEnviosTip">
|
||||
<h4>Proximos envíos (1 semana)</h4>
|
||||
</button>
|
||||
</h2>
|
||||
<div id="proximosEnviosTip" class="accordion-collapse collapse"
|
||||
data-bs-parent="#accordioAlbaranes">
|
||||
<div id="" class="accordion-body">
|
||||
|
||||
<table id="tableProximosEnvios"
|
||||
class="table table-striped table-hover w-100">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= lang("Logistica.ordenTrabajo") ?></th>
|
||||
<th><?= lang("Logistica.fechaEncuadernado") ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<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>
|
||||
<?php if ($envioEntity->finalizado == 0 && $envioEntity->tipo_envio == 'estandar'): ?>
|
||||
<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">
|
||||
<?= lang("Logistica.generarAlbaran") ?>
|
||||
<i class="ti ti-file-check"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-sm-2 px-3">
|
||||
<button id="ficharEmbalaje" name="fichar_embalaje" tabindex="1"
|
||||
class="btn btn-primary mt-4 w-100 btn-finalizar">
|
||||
<?= lang("Logistica.ficharEmbalaje") ?>
|
||||
<ti class="ti ti-check"></ti>
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-sm-2 px-3">
|
||||
<button id="btnImprimirEtiquetas" name="btnImprimirEtiquetas" tabindex="1"
|
||||
class="btn btn-info w-100">
|
||||
<?= lang("Logistica.imprimirEtiquetas") ?>
|
||||
<i class="ti ti-printer"></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 ($envioEntity->impresoras as $impresora): ?>
|
||||
<option value="<?= $impresora->id ?>">
|
||||
<?= $impresora->name ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
|
||||
<table id="tableLineasEnvio" class="table table-striped table-hover w-100">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th><?= lang("Logistica.ordenTrabajo") ?></th>
|
||||
<th><?= lang("Logistica.pedido") ?></th>
|
||||
<th><?= lang("Logistica.presupuesto") ?></th>
|
||||
<th><?= lang("Logistica.titulo") ?></th>
|
||||
<th class="text-center" style="width: 10%;">
|
||||
<?= lang("Logistica.unidadesEnvio") ?>
|
||||
</th>
|
||||
<th class="text-center" style="width: 10%;">
|
||||
<?= lang("Logistica.unidadesEnviadas") ?>
|
||||
</th>
|
||||
<th class="text-center" style="width: 10%;">
|
||||
<?= lang("Logistica.unidadesTotales") ?>
|
||||
</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th colspan="11">
|
||||
<div class="text-end">
|
||||
<?= lang("Logistica.unidadesTotalesFooter") ?>
|
||||
<span id="footer-unidades-envio"></span>
|
||||
</div>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="11">
|
||||
<div class="text-end">
|
||||
<?= lang("Logistica.peso") ?>
|
||||
<span id="footer-peso"></span>
|
||||
</div>
|
||||
</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
</table>
|
||||
|
||||
<div class="col-sm-2 px-3">
|
||||
<label for="cajas" class="form-label">
|
||||
<?= lang("Logistica.cajas") ?>
|
||||
</label>
|
||||
<input type="number" id="cajas" name="cajas" tabindex="1" maxlength="50"
|
||||
class="form-control" value="<?= old('cajas', $envioEntity->cajas) ?>">
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<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 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") ?>
|
||||
<?= lang("Logistica.lineasEnvio") ?>
|
||||
</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="<?= esc(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 btn-finalizar">
|
||||
<?= lang("Logistica.finalizarEnvio") ?>
|
||||
<ti class="ti ti-check"></ti>
|
||||
</button>
|
||||
<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>
|
||||
<?php if ($envioEntity->tipo_envio == 'estandar'): ?>
|
||||
<div class="col-sm-3 px-3">
|
||||
<button id="finalizarEnvioYOTs" name="finalizar_envio_ots" tabindex="1"
|
||||
class="btn btn-primary mt-4 w-100 btn-finalizar">
|
||||
<?= lang("Logistica.finalizarEnvioYOTs") ?>
|
||||
<ti class="ti ti-checks"></ti>
|
||||
<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>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php if ($envioEntity->finalizado == 0 && $envioEntity->tipo_envio == 'estandar'): ?>
|
||||
<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">
|
||||
<?= lang("Logistica.generarAlbaran") ?>
|
||||
<i class="ti ti-file-check"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-sm-2 px-3">
|
||||
<button id="ficharEmbalaje" name="fichar_embalaje" tabindex="1"
|
||||
class="btn btn-primary mt-4 w-100 btn-finalizar">
|
||||
<?= lang("Logistica.ficharEmbalaje") ?>
|
||||
<ti class="ti ti-check"></ti>
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-sm-2 px-3">
|
||||
<button id="btnImprimirEtiquetas" name="btnImprimirEtiquetas"
|
||||
tabindex="1" class="btn btn-info w-100">
|
||||
<?= lang("Logistica.imprimirEtiquetas") ?>
|
||||
<i class="ti ti-printer"></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 ($envioEntity->impresoras as $impresora): ?>
|
||||
<option value="<?= $impresora->id ?>">
|
||||
<?= $impresora->name ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
|
||||
<table id="tableLineasEnvio" class="table table-striped table-hover w-100">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th><?= lang("Logistica.ordenTrabajo") ?></th>
|
||||
<th><?= lang("Logistica.pedido") ?></th>
|
||||
<th><?= lang("Logistica.presupuesto") ?></th>
|
||||
<th><?= lang("Logistica.titulo") ?></th>
|
||||
<th class="text-center" style="width: 10%;">
|
||||
<?= lang("Logistica.unidadesEnvio") ?>
|
||||
</th>
|
||||
<th class="text-center" style="width: 10%;">
|
||||
<?= lang("Logistica.unidadesEnviadas") ?>
|
||||
</th>
|
||||
<th class="text-center" style="width: 10%;">
|
||||
<?= lang("Logistica.unidadesTotales") ?>
|
||||
</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th colspan="11">
|
||||
<div class="text-end">
|
||||
<?= lang("Logistica.unidadesTotalesFooter") ?>
|
||||
<span id="footer-unidades-envio"></span>
|
||||
</div>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="11">
|
||||
<div class="text-end">
|
||||
<?= lang("Logistica.peso") ?>
|
||||
<span id="footer-peso"></span>
|
||||
</div>
|
||||
</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
</table>
|
||||
|
||||
<div class="col-sm-2 px-3">
|
||||
<label for="cajas" class="form-label">
|
||||
<?= lang("Logistica.cajas") ?>
|
||||
</label>
|
||||
<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 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 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="<?= esc(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 btn-finalizar">
|
||||
<?= lang("Logistica.finalizarEnvio") ?>
|
||||
<ti class="ti ti-check"></ti>
|
||||
</button>
|
||||
</div>
|
||||
<?php if ($envioEntity->tipo_envio == 'estandar'): ?>
|
||||
<div class="col-sm-3 px-3">
|
||||
<button id="finalizarEnvioYOTs" name="finalizar_envio_ots" tabindex="1"
|
||||
class="btn btn-primary mt-4 w-100 btn-finalizar">
|
||||
<?= lang("Logistica.finalizarEnvioYOTs") ?>
|
||||
<ti class="ti ti-checks"></ti>
|
||||
</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?= $this->endSection() ?>
|
||||
<?= $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") ?>">
|
||||
<link rel="stylesheet"
|
||||
href="<?= site_url("/themes/vuexy/vendor/libs/perfect-scrollbar/perfect-scrollbar.css") ?>" />
|
||||
<?= $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") ?>">
|
||||
<link rel="stylesheet"
|
||||
href="<?= site_url("/themes/vuexy/vendor/libs/perfect-scrollbar/perfect-scrollbar.css") ?>" />
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
<?= $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="<?= site_url('themes/vuexy/vendor/libs/perfect-scrollbar/perfect-scrollbar.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/envioEdit.js") ?>"></script>
|
||||
<?= $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="<?= site_url('themes/vuexy/vendor/libs/perfect-scrollbar/perfect-scrollbar.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/envioEdit.js") ?>"></script>
|
||||
<?= $this->endSection() ?>
|
||||
@ -20,6 +20,7 @@ class EnvioEdit {
|
||||
];
|
||||
|
||||
this.table = null;
|
||||
this.tableProximosEnvios = null;
|
||||
|
||||
this.buscarPedidos = new ClassSelect($("#buscadorPedidos"), '/logistica/selectAddLinea', "", true, { 'envio': $("#id").val() });
|
||||
|
||||
@ -43,12 +44,6 @@ class EnvioEdit {
|
||||
this.proveedor.init();
|
||||
}
|
||||
|
||||
if ($("#proximosEnvios").length) {
|
||||
new PerfectScrollbar(document.getElementById('proximosEnvios'), {
|
||||
wheelPropagation: false
|
||||
});
|
||||
}
|
||||
|
||||
this.table = $('#tableLineasEnvio').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
@ -101,6 +96,46 @@ class EnvioEdit {
|
||||
]
|
||||
});
|
||||
|
||||
this.tableProximosEnvios = $('#tableProximosEnvios').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
autoWidth: true,
|
||||
responsive: true,
|
||||
scrollX: true,
|
||||
orderCellsTop: true,
|
||||
orderable: false,
|
||||
order: [[1, 'asc']],
|
||||
lengthMenu: [5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500],
|
||||
pageLength: 5,
|
||||
"dom": 'tp',
|
||||
"ajax": {
|
||||
"url": "/logistica/datatableProximosEnvios/" + $('#id').val(),
|
||||
},
|
||||
"columns": [
|
||||
{data: 'ot'},
|
||||
{data: 'fechaEncuadernado'}
|
||||
],
|
||||
"language": {
|
||||
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||
},
|
||||
"columnDefs": [
|
||||
{
|
||||
"targets": [0, 1],
|
||||
"className": "text-center",
|
||||
},
|
||||
],
|
||||
drawCallback: function(){
|
||||
$(this.api().table().container()).find('table').css('width', '100%');
|
||||
this.api().columns.adjust();
|
||||
}
|
||||
});
|
||||
|
||||
$('#proximosEnviosTip' + this.id).on('shown.bs.collapse', () => {
|
||||
if (this.tableProximosEnvios) {
|
||||
this.tableProximosEnvios.columns.adjust().draw(false);
|
||||
}
|
||||
});
|
||||
|
||||
$('#btnImprimirEtiquetas').on('click', () => {
|
||||
const table = this.table;
|
||||
const selectedRows = table.rows({ page: 'current' }).nodes().filter((node) => {
|
||||
|
||||
Reference in New Issue
Block a user