fix store ot

This commit is contained in:
amazuecos
2025-03-26 23:29:19 +01:00
parent 09e8af15cc
commit e44421fb4d
7 changed files with 466 additions and 44 deletions

View File

@ -9,8 +9,8 @@ use CodeIgniter\Model;
class OrdenTrabajoDate extends Model
{
protected $table = 'orden_trabajo_dates';
protected $primaryKey = 'orden_trabajo_id';
protected $useAutoIncrement = false;
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = OrdenTrabajoDateEntity::class;
protected $useSoftDeletes = true;
protected $protectFields = true;
@ -62,8 +62,8 @@ class OrdenTrabajoDate extends Model
protected $allowCallbacks = true;
protected $beforeInsert = [];
protected $afterInsert = ["updateOrdenTrabajoUser"];
protected $beforeUpdate = ["updateOrdenTrabajoUser"];
protected $afterUpdate = [];
protected $beforeUpdate = [];
protected $afterUpdate = ["updateOrdenTrabajoUser"];
protected $beforeFind = [];
protected $afterFind = [];
protected $beforeDelete = [];
@ -106,7 +106,7 @@ class OrdenTrabajoDate extends Model
$mapping = [
"fecha_encuadernado_at" => "encuadernacion_user_id",
// "fecha_externo_at" => "null",
"fecha_impresion_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",
@ -124,9 +124,12 @@ class OrdenTrabajoDate extends Model
foreach ($data as $key => $value) {
if(isset($mapping[$key])){
if($value){
$otUser->update($data["orden_trabajo_id"],[$mapping[$key] => $auth_user_id]);
$otUser->where('orden_trabajo_id',$data['orden_trabajo_id'])
->set([$mapping[$key] => $auth_user_id])
->update();
}
}
}
return $data;
}
}