trabajando en editar plantillas

This commit is contained in:
2024-12-04 12:34:10 +01:00
parent 3fb37af0f8
commit a7cda851f0
15 changed files with 1024 additions and 520 deletions

View File

@ -7,14 +7,16 @@ class ClientePlantillaPreciosLineasModel extends \App\Models\BaseModel
protected $table = "cliente_plantilla_precios_lineas";
const SORTABLE = [
0 => "t1.tipo",
1 => "t1.tipo_maquina",
2 => "t1.tipo_impresion",
3 => "t1.tiempo_min",
4 => "t1.tiempo_max",
5 => "t1.precio_hora",
6 => "t1.margen",
0 => "t1.id",
1 => "t1.tipo",
2 => "t1.tipo_maquina",
3 => "t1.tipo_impresion",
4 => "t1.tiempo_min",
5 => "t1.tiempo_max",
6 => "t1.precio_hora",
7 => "t1.margen",
8 => "CONCAT(t2.first_name, ' ', t2.last_name)",
9 => "t1.updated_at",
];
/**
@ -113,10 +115,20 @@ class ClientePlantillaPreciosLineasModel extends \App\Models\BaseModel
function delete_values($plantilla_id = 0){
$datetime = (new \CodeIgniter\I18n\Time("now"));
$date_value = $datetime->format('Y-m-d H:i:s');
$this->db
->table($this->table . " t1")
->where('t1.plantilla_id', $plantilla_id)
->set('is_deleted', 1)
->set('deleted_at', $date_value)
->update();
$this->db
->table('cliente_precios' . " t1")
->where('t1.plantilla_id', $plantilla_id)
->set('plantilla_id', null)
->update();
}
@ -127,14 +139,15 @@ class ClientePlantillaPreciosLineasModel extends \App\Models\BaseModel
*
* @return \CodeIgniter\Database\BaseBuilder
*/
public function getResource($plantilla_id = -1)
public function getResource($search = [], $plantilla_id = -1)
{
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.id as id, t1.tipo AS tipo, t1.tipo_maquina AS tipo_maquina, t1.tipo_impresion AS tipo_impresion,
t1.tiempo_min AS tiempo_min, t1.tiempo_max AS tiempo_max, t1.precio_hora AS precio_hora, t1.margen AS margen,
t1.user_updated_id AS user_updated_id, t1.updated_at AS updated_at, CONCAT(t2.first_name, ' ', t2.last_name) AS user_updated"
t1.user_updated_id AS user_updated_id, t1.updated_at AS updated_at, CONCAT(t2.first_name, ' ', t2.last_name) AS user_updated,
t1.id AS DT_RowId"
);
$builder->join("users t2", "t1.user_updated_id = t2.id", "left");
@ -142,8 +155,19 @@ class ClientePlantillaPreciosLineasModel extends \App\Models\BaseModel
$builder->where('t1.is_deleted', 0);
$builder->where('t1.plantilla_id', $plantilla_id);
return $builder;
if (empty($search))
return $builder;
else {
$builder->groupStart();
foreach ($search as $col_search) {
if ($col_search[0] > 0 && $col_search[0] < 4)
$builder->where(self::SORTABLE[$col_search[0]], $col_search[2]);
else
$builder->like(self::SORTABLE[$col_search[0]], $col_search[2]);
}
$builder->groupEnd();
return $builder;
}
}
public function checkIntervals($data = [], $id_linea = null, $plantilla_id = null){