mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
dates users ot
This commit is contained in:
@ -25,6 +25,7 @@ use CodeIgniter\Database\BaseResult;
|
||||
use CodeIgniter\Database\Exceptions\DatabaseException;
|
||||
use CodeIgniter\HTTP\Files\UploadedFile;
|
||||
use CodeIgniter\I18n\Time;
|
||||
use Config\OrdenTrabajo;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
@ -46,22 +47,7 @@ class ProductionService extends BaseService
|
||||
protected string $defaultMaquinaCorteName = 'HT-1000';
|
||||
protected MaquinaEntity $defaultMaquinaCorte;
|
||||
protected MaquinaModel $maquinaModel;
|
||||
protected array $MAPPING_DATE_USER = [
|
||||
"fecha_encuadernado_at" => "encuadernacion_user_id",
|
||||
// "fecha_externo_at" => "null",
|
||||
"fecha_impresion_at" => null,
|
||||
"pendiente_ferro_at" => "pendiente_ferro_user_id",
|
||||
"ferro_en_cliente_at" => "ferro_en_cliente_user_id",
|
||||
"ferro_ok_at" => "ferro_ok_user_id",
|
||||
"interior_bn_at" => "interior_bn_user_id",
|
||||
"interior_color_at" => "interior_color_user_id",
|
||||
"preparacion_interiores_at" => "preparacion_interior_user_id",
|
||||
"cubierta_at" => "cubierta_user_id",
|
||||
"plastificado_at" => "plastificado_user_id",
|
||||
"corte_at" => "corte_user_id",
|
||||
"embalaje_at" => "embalaje_user_id",
|
||||
"entrada_manipulado_at" => "entrada_manipulado_user_id"
|
||||
];
|
||||
protected OrdenTrabajo $ordenTrabajoConfig;
|
||||
|
||||
/**
|
||||
* Pedido Entity
|
||||
@ -84,6 +70,7 @@ class ProductionService extends BaseService
|
||||
$this->otUser = model(OrdenTrabajoUser::class);
|
||||
$this->userModel = model(UserModel::class);
|
||||
$this->otFileModel = model(OrdenTrabajoFileModel::class);
|
||||
$this->ordenTrabajoConfig = config('OrdenTrabajo');
|
||||
}
|
||||
public function init(int $orden_trabajo_id): self
|
||||
{
|
||||
@ -627,6 +614,7 @@ class ProductionService extends BaseService
|
||||
"pedido" => $this->pedido,
|
||||
"presupuesto" => $this->presupuesto,
|
||||
"dates" => $this->ot->dates(),
|
||||
"user_dates" => $this->userDates(),
|
||||
"tasks" => $this->ot->tareas(),
|
||||
"acabados" => $this->presupuesto->acabados(),
|
||||
"preimpresiones" => $this->presupuesto->preimpresiones(),
|
||||
@ -757,8 +745,8 @@ class ProductionService extends BaseService
|
||||
->update($data);
|
||||
$this->otDate->updateUserDateMap($this->ot->id, $data);
|
||||
$ot_users = $this->ot->users();
|
||||
if (isset($this->MAPPING_DATE_USER[$data["name"]])) {
|
||||
$user_id = $ot_users->{$this->MAPPING_DATE_USER[$data["name"]]};
|
||||
if (isset($this->ordenTrabajoConfig->DATE_USER_MAPPING[$data["name"]])) {
|
||||
$user_id = $ot_users->{$this->ordenTrabajoConfig->DATE_USER_MAPPING[$data["name"]]};
|
||||
$user = $this->userModel->find($user_id);
|
||||
if ($user_id) {
|
||||
$result = ["user" => null, "status" => false];
|
||||
@ -1034,4 +1022,18 @@ class ProductionService extends BaseService
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
public function userDates() : array
|
||||
{
|
||||
$userDates = [];
|
||||
foreach ($this->ordenTrabajoConfig->DATE_USER_MAPPING as $key => $value) {
|
||||
$otUserEntity = $this->otUser->where("orden_trabajo_id",$this->ot->id)->first();
|
||||
$userEntity = $otUserEntity->userBy($value);
|
||||
if($userEntity){
|
||||
$userDates[$key] = $userEntity->full_name;
|
||||
}else{
|
||||
$userDates[$key] = null;
|
||||
}
|
||||
}
|
||||
return $userDates;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user