mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
tabajando
This commit is contained in:
@ -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
|
||||
// se ha enviado toda la cantidad teniendo en cuenta otros envios
|
||||
$EnvioModel = model('App\Models\Logistica\EnvioModel');
|
||||
$EnvioLineasModel = model('App\Models\Logistica\EnvioLineaModel');
|
||||
|
||||
$ots = [];
|
||||
|
||||
$envio = $EnvioModel->find($envio_id);
|
||||
if (empty($envio)) {
|
||||
return [
|
||||
@ -325,9 +327,11 @@ class LogisticaService
|
||||
->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) {
|
||||
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;
|
||||
@ -339,17 +343,30 @@ class LogisticaService
|
||||
->first();
|
||||
$ps = (new ProductionService())->init($ot->id);
|
||||
$ps->updateOrdenTrabajoDate([
|
||||
"name" => "envio_at",
|
||||
"envio_at" => date('Y-m-d H:i:s')
|
||||
"name" => "envio_at",
|
||||
"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,
|
||||
'message' => lang('Logistica.success.finalizado'),
|
||||
];
|
||||
|
||||
if ($finalizar_ot) {
|
||||
$data_return['ots'] = $ots;
|
||||
}
|
||||
return $data_return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user