mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
tabajando
This commit is contained in:
@ -206,7 +206,8 @@ class LogisticaController extends BaseController
|
|||||||
{
|
{
|
||||||
if ($this->request->isAJAX()) {
|
if ($this->request->isAJAX()) {
|
||||||
|
|
||||||
$id = $this->request->getPost('id');
|
$id = $this->request->getPost('id') ?? null;
|
||||||
|
$finalizar_ots = $this->request->getPost('finalizar_ots') ?? false;
|
||||||
|
|
||||||
$result = LogisticaService::finalizarEnvio($id);
|
$result = LogisticaService::finalizarEnvio($id);
|
||||||
return $this->response->setJSON($result);
|
return $this->response->setJSON($result);
|
||||||
@ -215,6 +216,20 @@ class LogisticaController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function finalizarEnvioYOts()
|
||||||
|
{
|
||||||
|
if ($this->request->isAJAX()) {
|
||||||
|
|
||||||
|
$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 {
|
||||||
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function datatable_enviosEdit($idEnvio)
|
public function datatable_enviosEdit($idEnvio)
|
||||||
{
|
{
|
||||||
$model = model('App\Models\Logistica\EnvioLineaModel');
|
$model = model('App\Models\Logistica\EnvioLineaModel');
|
||||||
|
|||||||
@ -286,13 +286,15 @@ class LogisticaService
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function finalizarEnvio($envio_id)
|
public static function finalizarEnvio($envio_id, $finalizar_ot = false)
|
||||||
{
|
{
|
||||||
// hay que comprobar que para todas las lineas de envio de este envio
|
// hay que comprobar que para todas las lineas de envio de este envio
|
||||||
// se ha enviado toda la cantidad teniendo en cuenta otros envios
|
// se ha enviado toda la cantidad teniendo en cuenta otros envios
|
||||||
$EnvioModel = model('App\Models\Logistica\EnvioModel');
|
$EnvioModel = model('App\Models\Logistica\EnvioModel');
|
||||||
$EnvioLineasModel = model('App\Models\Logistica\EnvioLineaModel');
|
$EnvioLineasModel = model('App\Models\Logistica\EnvioLineaModel');
|
||||||
|
|
||||||
|
$ots = [];
|
||||||
|
|
||||||
$envio = $EnvioModel->find($envio_id);
|
$envio = $EnvioModel->find($envio_id);
|
||||||
if (empty($envio)) {
|
if (empty($envio)) {
|
||||||
return [
|
return [
|
||||||
@ -325,9 +327,11 @@ class LogisticaService
|
|||||||
->join('envios', 'envios.id = envios_lineas.envio_id')
|
->join('envios', 'envios.id = envios_lineas.envio_id')
|
||||||
->get()->getResult();
|
->get()->getResult();
|
||||||
|
|
||||||
if (count($cantidad_enviada) == 0 ||
|
if (
|
||||||
empty($cantidad_enviada[0]->unidades_enviadas) ||
|
count($cantidad_enviada) == 0 ||
|
||||||
$cantidad_enviada[0]->unidades_enviadas == null) {
|
empty($cantidad_enviada[0]->unidades_enviadas) ||
|
||||||
|
$cantidad_enviada[0]->unidades_enviadas == null
|
||||||
|
) {
|
||||||
$cantidad_enviada = 0;
|
$cantidad_enviada = 0;
|
||||||
} else {
|
} else {
|
||||||
$cantidad_enviada = $cantidad_enviada[0]->unidades_enviadas;
|
$cantidad_enviada = $cantidad_enviada[0]->unidades_enviadas;
|
||||||
@ -339,17 +343,30 @@ class LogisticaService
|
|||||||
->first();
|
->first();
|
||||||
$ps = (new ProductionService())->init($ot->id);
|
$ps = (new ProductionService())->init($ot->id);
|
||||||
$ps->updateOrdenTrabajoDate([
|
$ps->updateOrdenTrabajoDate([
|
||||||
"name" => "envio_at",
|
"name" => "envio_at",
|
||||||
"envio_at" => date('Y-m-d H:i:s')
|
"envio_at" => date('Y-m-d H:i:s')
|
||||||
]);
|
]);
|
||||||
|
if ($finalizar_ot) {
|
||||||
|
$ps->updateOrdenTrabajo(
|
||||||
|
[
|
||||||
|
"estado" => 'F'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
array_push($ots, $ot->id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$EnvioModel->update($envio_id, ['finalizado'=> 1]);
|
$EnvioModel->update($envio_id, ['finalizado' => 1]);
|
||||||
|
|
||||||
return [
|
$data_return = [
|
||||||
'status' => true,
|
'status' => true,
|
||||||
'message' => lang('Logistica.success.finalizado'),
|
'message' => lang('Logistica.success.finalizado'),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if ($finalizar_ot) {
|
||||||
|
$data_return['ots'] = $ots;
|
||||||
|
}
|
||||||
|
return $data_return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -314,14 +314,14 @@
|
|||||||
<?php if ($envioEntity->finalizado == 0): ?>
|
<?php if ($envioEntity->finalizado == 0): ?>
|
||||||
<div class="col-sm-3 px-3">
|
<div class="col-sm-3 px-3">
|
||||||
<button id="finalizarEnvio" name="finalizar_envio" tabindex="1"
|
<button id="finalizarEnvio" name="finalizar_envio" tabindex="1"
|
||||||
class="btn btn-primary mt-4 w-100">
|
class="btn btn-primary mt-4 w-100 btn-finalizar">
|
||||||
<?= lang("Logistica.finalizarEnvio") ?>
|
<?= lang("Logistica.finalizarEnvio") ?>
|
||||||
<ti class="ti ti-check"></ti>
|
<ti class="ti ti-check"></ti>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-3 px-3">
|
<div class="col-sm-3 px-3">
|
||||||
<button id="finalizarEnvioYOTs" name="finalizar_envio_ots" tabindex="1"
|
<button id="finalizarEnvioYOTs" name="finalizar_envio_ots" tabindex="1"
|
||||||
class="btn btn-primary mt-4 w-100">
|
class="btn btn-primary mt-4 w-100 btn-finalizar">
|
||||||
<?= lang("Logistica.finalizarEnvioYOTs") ?>
|
<?= lang("Logistica.finalizarEnvioYOTs") ?>
|
||||||
<ti class="ti ti-checks"></ti>
|
<ti class="ti ti-checks"></ti>
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@ -292,8 +292,15 @@ class EnvioEdit {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#finalizarEnvio').on('click', () => {
|
$('.btn-finalizar').on('click', (e) => {
|
||||||
|
let data = {
|
||||||
|
id : $('#id').val();
|
||||||
|
};
|
||||||
|
let url = '/logistica/finalizarEnvio';
|
||||||
|
if(e.currentTarget.id() != "finalizarEnvio"){
|
||||||
|
let url = '/logistica/finalizarEnvioYOts';
|
||||||
|
data.finalizar_ots = true;
|
||||||
|
}
|
||||||
if(this.codigoSeguimiento.val().length <= 0 || this.proveedor.getVal() <= 0) {
|
if(this.codigoSeguimiento.val().length <= 0 || this.proveedor.getVal() <= 0) {
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
title: 'Atención!',
|
title: 'Atención!',
|
||||||
@ -308,7 +315,7 @@ class EnvioEdit {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
////////////////////
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
title: 'Finalizar envío',
|
title: 'Finalizar envío',
|
||||||
text: '¿Está seguro de que desea finalizar el envío?',
|
text: '¿Está seguro de que desea finalizar el envío?',
|
||||||
|
|||||||
Reference in New Issue
Block a user