mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
cambios
This commit is contained in:
@ -809,6 +809,7 @@ $routes->group('logistica', ['namespace' => 'App\Controllers\Logistica'], functi
|
|||||||
$routes->post('generateEnvio', 'LogisticaController::generarEnvio');
|
$routes->post('generateEnvio', 'LogisticaController::generarEnvio');
|
||||||
$routes->get('selectPedidosForEnvio', 'LogisticaController::findPedidosNewEnvio');
|
$routes->get('selectPedidosForEnvio', 'LogisticaController::findPedidosNewEnvio');
|
||||||
$routes->get('selectDireccionForEnvio', 'LogisticaController::selectDireccionForEnvio');
|
$routes->get('selectDireccionForEnvio', 'LogisticaController::selectDireccionForEnvio');
|
||||||
|
$routes->post('imprimirEtiquetas', 'LogisticaController::imprimirEtiquetas');
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -137,6 +137,21 @@ class LogisticaController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function imprimirEtiquetas()
|
||||||
|
{
|
||||||
|
if ($this->request->isAJAX()) {
|
||||||
|
$envio_id = $this->request->getPost('envio_id');
|
||||||
|
$ids = $this->request->getPost('envio_lineas');
|
||||||
|
$cajas = $this->request->getPost('cajas');
|
||||||
|
|
||||||
|
$result = ['status' => true];//LogisticaService::imprimirEtiquetas($ids);
|
||||||
|
return $this->response->setJSON($result);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function selectAddEnvioLinea()
|
public function selectAddEnvioLinea()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@ -436,6 +436,62 @@ class LogisticaService
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function imprimirEtiquetas($envio_id, $ids)
|
||||||
|
{
|
||||||
|
$array = [
|
||||||
|
"printer" => "LABPRINT-1",
|
||||||
|
"header" => [
|
||||||
|
"_FORMAT" => "E:PEDIDO.ZPL",
|
||||||
|
"_QUANTITY" => 1,
|
||||||
|
"_PRINBTERNAME" => "Printer 1",
|
||||||
|
"_JOBNAME" => "LBL101"
|
||||||
|
],
|
||||||
|
"labels" => [
|
||||||
|
/* Ejemplo etiqueta
|
||||||
|
[
|
||||||
|
"cliente" => "Cliente Potencial",
|
||||||
|
"titulo" => "[1234] TEST OLIVEROS",
|
||||||
|
"cantidad" => 100,
|
||||||
|
"tirada" => 50,
|
||||||
|
"cajas" => 1,
|
||||||
|
"ean" => null,
|
||||||
|
"nombre" => "___Nombre___",
|
||||||
|
"direccion" => "C/ test n10, Madrid, 12345, España",
|
||||||
|
"notas" => "Nota....",
|
||||||
|
"refcliente" => "Refclient:1234",
|
||||||
|
"npedido" => "1234"
|
||||||
|
]
|
||||||
|
*/
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
$EnvioModel = model('App\Models\Logistica\EnvioModel');
|
||||||
|
$EnvioLineasModel = model('App\Models\Logistica\EnvioLineaModel');
|
||||||
|
|
||||||
|
$envios = $EnvioModel->whereIn('id', $ids)->findAll();
|
||||||
|
if (empty($envios)) {
|
||||||
|
return [
|
||||||
|
'status' => false,
|
||||||
|
'message' => lang('Logistica.errors.noEnvio'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($envios as $envio) {
|
||||||
|
$lineasEnvio = $EnvioLineasModel->where('envio_id', $envio->id)->findAll();
|
||||||
|
if (empty($lineasEnvio)) {
|
||||||
|
return [
|
||||||
|
'status' => false,
|
||||||
|
'message' => lang('Logistica.errors.noEnvioLineas'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'status' => true,
|
||||||
|
'data' => $envios,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static function finalizarEnvio($envio_id, $finalizar_ot = false)
|
public static function finalizarEnvio($envio_id, $finalizar_ot = false)
|
||||||
|
|||||||
@ -92,6 +92,63 @@ class EnvioEdit {
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#btnImprimirEtiquetas').on('click', () => {
|
||||||
|
const table = this.table;
|
||||||
|
const selectedRows = table.rows({ page: 'current' }).nodes().filter((node) => {
|
||||||
|
const checkbox = $(node).find('.checkbox-linea-envio');
|
||||||
|
return checkbox.is(':checked');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const ids = selectedRows.map((node) => {
|
||||||
|
const rowData = table.row(node).data();
|
||||||
|
return rowData.id;
|
||||||
|
}).toArray();
|
||||||
|
if (ids.length <= 0) {
|
||||||
|
Swal.fire({
|
||||||
|
title: 'Atención!',
|
||||||
|
text: 'Debe seleccionar al menos una línea de envío para imprimir etiquetas.',
|
||||||
|
icon: 'info',
|
||||||
|
confirmButtonColor: '#3085d6',
|
||||||
|
confirmButtonText: 'Ok',
|
||||||
|
customClass: {
|
||||||
|
confirmButton: 'btn btn-primary me-1',
|
||||||
|
},
|
||||||
|
buttonsStyling: false
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const idEnvio = $('#id').val();
|
||||||
|
let num_cajas = this.cajas.val();
|
||||||
|
if(ids.length != table.rows().count()){
|
||||||
|
// se preguntará el numero de cajas en un swal con un input para obtener el valor
|
||||||
|
Swal.fire({
|
||||||
|
title: 'Atención!',
|
||||||
|
text: 'No se ha seleccionado todas las líneas de envío. Ingrese el número de cajas a imprimir.',
|
||||||
|
icon: 'info',
|
||||||
|
input: 'text',
|
||||||
|
inputLabel: 'Número de cajas',
|
||||||
|
inputValue: num_cajas,
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonColor: '#3085d6',
|
||||||
|
confirmButtonText: 'Imprimir etiquetas',
|
||||||
|
cancelButtonText: 'Cancelar',
|
||||||
|
customClass: {
|
||||||
|
confirmButton: 'btn btn-primary me-1',
|
||||||
|
cancelButton: 'btn btn-secondary'
|
||||||
|
},
|
||||||
|
buttonsStyling: false
|
||||||
|
}).then((result) => {
|
||||||
|
if (result.isConfirmed) {
|
||||||
|
num_cajas = result.value;
|
||||||
|
this._imprimirEtiquetas(idEnvio, ids, num_cajas);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
this._imprimirEtiquetas(idEnvio, ids, num_cajas);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
this.cajas.on('change', (e) => {
|
this.cajas.on('change', (e) => {
|
||||||
const value = $(e.currentTarget).val();
|
const value = $(e.currentTarget).val();
|
||||||
if (value < 0) {
|
if (value < 0) {
|
||||||
@ -429,6 +486,58 @@ class EnvioEdit {
|
|||||||
this._getAlbaranes();
|
this._getAlbaranes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_imprimirEtiquetas(envio_id, ids, num_cajas) {
|
||||||
|
|
||||||
|
$.post('/logistica/imprimirEtiquetas', {
|
||||||
|
|
||||||
|
envio_id: envio_id,
|
||||||
|
envio_lineas: ids,
|
||||||
|
cajas: num_cajas
|
||||||
|
}, function (response) {
|
||||||
|
if (response.status) {
|
||||||
|
Swal.fire({
|
||||||
|
title: 'Etiquetas generadas',
|
||||||
|
text: 'Las etiquetas se han generado correctamente.',
|
||||||
|
icon: 'success',
|
||||||
|
confirmButtonColor: '#3085d6',
|
||||||
|
confirmButtonText: 'Ok',
|
||||||
|
customClass: {
|
||||||
|
confirmButton: 'btn btn-primary me-1',
|
||||||
|
},
|
||||||
|
buttonsStyling: false
|
||||||
|
}).then(() => {
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
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 generar las etiquetas.',
|
||||||
|
icon: 'error',
|
||||||
|
confirmButtonColor: '#3085d6',
|
||||||
|
confirmButtonText: 'Ok',
|
||||||
|
customClass: {
|
||||||
|
confirmButton: 'btn btn-primary me-1',
|
||||||
|
},
|
||||||
|
buttonsStyling: false
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
_checkDatosFinalizar() {
|
_checkDatosFinalizar() {
|
||||||
|
|
||||||
if (this.codigoSeguimiento.val().length <= 0 || this.proveedor.getVal() <= 0) {
|
if (this.codigoSeguimiento.val().length <= 0 || this.proveedor.getVal() <= 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user