mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
orden trabajo files methods
This commit is contained in:
@ -143,6 +143,7 @@ class ProductionService extends BaseService
|
||||
];
|
||||
$id = $this->otModel->insert($data);
|
||||
$this->init($id);
|
||||
$this->updatePedidoEspera();
|
||||
$this->storeOrdenTrabajoUsers();
|
||||
$this->storeOrdenTrabajoDates();
|
||||
$this->storeAllTareas();
|
||||
@ -965,4 +966,33 @@ class ProductionService extends BaseService
|
||||
throw new Exception('No se ha especificado una orden de trabajo. Usa $this->producctionService->init($orden_trabajo_id)');
|
||||
}
|
||||
}
|
||||
public function deleteOtFiles(?array $existingFiles): bool
|
||||
{
|
||||
helper('filesystem');
|
||||
if ($this->ot) {
|
||||
$otFiles = $this->ot->files();
|
||||
|
||||
foreach ($otFiles as $key => $file) {
|
||||
$file_path = $file->file_path;
|
||||
if ($existingFiles) {
|
||||
if (!in_array($file->name, $existingFiles)) {
|
||||
$this->otFileModel->delete($file->id);
|
||||
unlink($file_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
throw new Exception('No se ha especificado una orden de trabajo. Usa $this->producctionService->init($orden_trabajo_id)');
|
||||
}
|
||||
}
|
||||
protected function updatePedidoEspera(): bool
|
||||
{
|
||||
$status = false;
|
||||
$presupuestoFiles = $this->presupuesto->files();
|
||||
if (count($presupuestoFiles) == 0) {
|
||||
$status = $this->otModel->update($this->ot->id, ['pedido_espera' => true]);
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user