mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
merge from main
This commit is contained in:
@ -11,7 +11,7 @@ class ChatDeparmentUserModel extends Model
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $useSoftDeletes = true;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
"chat_department_id",
|
||||
|
||||
@ -14,13 +14,14 @@ class ClienteModel extends \App\Models\BaseModel
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
0 => "t1.nombre",
|
||||
1 => "t1.alias",
|
||||
2 => "t1.cif",
|
||||
3 => "t1.email",
|
||||
4 => "t1.comercial_id",
|
||||
5 => "t1.forma_pago_id",
|
||||
6 => "t1.vencimiento",
|
||||
0 => "t1.id",
|
||||
1 => "t1.nombre",
|
||||
2 => "t1.alias",
|
||||
3 => "t1.cif",
|
||||
4 => "t1.email",
|
||||
5 => "t1.comercial_id",
|
||||
6 => "t1.forma_pago_id",
|
||||
7 => "t1.vencimiento",
|
||||
];
|
||||
|
||||
protected $allowedFields = [
|
||||
@ -63,7 +64,7 @@ class ClienteModel extends \App\Models\BaseModel
|
||||
];
|
||||
protected $returnType = "App\Entities\Clientes\ClienteEntity";
|
||||
|
||||
protected $deletedField = 'deleted_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
@ -245,7 +246,7 @@ class ClienteModel extends \App\Models\BaseModel
|
||||
"required" => "Clientes.validation.vencimiento.required",
|
||||
],
|
||||
];
|
||||
public function findAllWithAllRelations(string $selcols = "*", int $limit = null, int $offset = 0)
|
||||
public function findAllWithAllRelations($selcols = "*", int $limit = null, int $offset = 0)
|
||||
{
|
||||
$sql =
|
||||
"SELECT t1." .
|
||||
@ -279,35 +280,30 @@ class ClienteModel extends \App\Models\BaseModel
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResource(string $search = "")
|
||||
public function getResource($search = [])
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.nombre AS nombre, t1.alias AS alias, t1.cif AS cif, t1.email AS email, t1.vencimiento AS vencimiento, t5.first_name AS comercial, t7.nombre AS forma_pago_id"
|
||||
)
|
||||
->where("is_deleted", 0);;
|
||||
->where("is_deleted", 0);
|
||||
;
|
||||
$builder->join("users t5", "t1.comercial_id = t5.id", "left");
|
||||
$builder->join("formas_pago t7", "t1.forma_pago_id = t7.id", "left");
|
||||
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.nombre", $search)
|
||||
->orLike("t1.alias", $search)
|
||||
->orLike("t1.cif", $search)
|
||||
->orLike("t1.email", $search)
|
||||
->orLike("t1.soporte_id", $search)
|
||||
->orLike("t1.forma_pago_id", $search)
|
||||
->orLike("t1.vencimiento", $search)
|
||||
->orLike("t5.id", $search)
|
||||
->orLike("t5.first_name", $search)
|
||||
->orLike("t5.last_name", $search)
|
||||
->orLike("t7.id", $search)
|
||||
->orLike("t7.nombre", $search)
|
||||
->groupEnd();
|
||||
if (empty($search))
|
||||
return $builder;
|
||||
else {
|
||||
$builder->groupStart();
|
||||
foreach ($search as $col_search) {
|
||||
$column = self::SORTABLE[$col_search[0]];
|
||||
$value = $col_search[2];
|
||||
$builder->where("LOWER(CONVERT($column USING utf8)) COLLATE utf8_general_ci LIKE", "%" . strtolower($value) . "%");
|
||||
}
|
||||
$builder->groupEnd();
|
||||
return $builder;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -353,7 +349,7 @@ class ClienteModel extends \App\Models\BaseModel
|
||||
->join("pedidos", "pedidos.id = pedidos_linea.pedido_id", "left")
|
||||
->join("facturas_pedidos_lineas", "facturas_pedidos_lineas.pedido_linea_id = pedidos_linea.id", "left")
|
||||
->where("t1.id", $cliente_id);
|
||||
$data = $query->get()->getResultObject();
|
||||
$data = $query->get()->getResultObject();
|
||||
$facturas = [];
|
||||
$presupuestos = [];
|
||||
$pedidos = [];
|
||||
|
||||
@ -160,7 +160,7 @@ class ClientePlantillaPreciosLineasModel extends \App\Models\BaseModel
|
||||
else {
|
||||
$builder->groupStart();
|
||||
foreach ($search as $col_search) {
|
||||
if ($col_search[1] > 0 && $col_search[0] < 4)
|
||||
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]);
|
||||
|
||||
@ -16,9 +16,10 @@ class ClienteUsuariosModel extends ShieldUserModel
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
0 => "t1.first_name",
|
||||
1 => "t1.last_name",
|
||||
2 => "t2.secret",
|
||||
0 => "t1.id",
|
||||
1 => "t1.first_name",
|
||||
2 => "t1.last_name",
|
||||
3 => "t2.secret",
|
||||
];
|
||||
|
||||
protected $allowedFields = ["id", "first_name", "last_name", "email"];
|
||||
@ -83,6 +84,19 @@ class ClienteUsuariosModel extends ShieldUserModel
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function removeClienteFromUser($user_id = -1){
|
||||
|
||||
$this->db->table($this->table)->where('id', $user_id)->update(['cliente_id' => null]);
|
||||
}
|
||||
|
||||
|
||||
public function addUserToClient($user_id = -1, $cliente_id = -1){
|
||||
if($user_id < 1 || $cliente_id < 1){
|
||||
return;
|
||||
}
|
||||
$this->db->table($this->table)->where('id', $user_id)->update(['cliente_id' => $cliente_id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get resource data.
|
||||
*
|
||||
@ -100,15 +114,8 @@ class ClienteUsuariosModel extends ShieldUserModel
|
||||
);
|
||||
|
||||
$builder->join("auth_identities t2", "t1.id = t2.user_id", "left");
|
||||
$builder->where('t1.id', $cliente_id);
|
||||
$builder->where('t1.cliente_id', $cliente_id);
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.first_name", $search)
|
||||
->orLike("t1.last_name", $search)
|
||||
->orLike("t2.secret", $search)
|
||||
->groupEnd();
|
||||
return $builder;
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,22 +14,13 @@ class MaquinaModel extends \App\Models\BaseModel
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
//1 => "t1.id",
|
||||
0 => "t1.nombre",
|
||||
0 => "t1.id",
|
||||
1 => "t2.nombre",
|
||||
2 => "t1.tipo",
|
||||
3 => "t1.velocidad",
|
||||
4 => "t1.duracion_jornada",
|
||||
5 => "t1.ancho",
|
||||
6 => "t1.alto",
|
||||
7 => "t1.ancho_impresion",
|
||||
8 => "t1.alto_impresion",
|
||||
9 => "t1.orden_planning",
|
||||
10 => "t1.min",
|
||||
11 => "t1.max",
|
||||
|
||||
|
||||
];
|
||||
3 => "t1.ancho_impresion",
|
||||
4 => "t1.alto_impresion",
|
||||
5 => "t1.min",
|
||||
6 => "t1.max", ];
|
||||
|
||||
protected $allowedFields = [
|
||||
"nombre",
|
||||
@ -295,7 +286,7 @@ class MaquinaModel extends \App\Models\BaseModel
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResource(string $search = "")
|
||||
public function getResource($search = [])
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
@ -313,56 +304,18 @@ class MaquinaModel extends \App\Models\BaseModel
|
||||
//JJO
|
||||
$builder->where("t1.is_deleted", 0);
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.tipo", $search)
|
||||
->orLike("t1.velocidad", $search)
|
||||
->orLike("t1.ancho", $search)
|
||||
->orLike("t1.alto", $search)
|
||||
->orLike("t1.ancho_impresion", $search)
|
||||
->orLike("t1.alto_impresion", $search)
|
||||
->orLike("t1.alto_click", $search)
|
||||
->orLike("t1.min", $search)
|
||||
->orLike("t1.max", $search)
|
||||
->orLike("t1.duracion_jornada", $search)
|
||||
->orLike("t1.orden_planning", $search)
|
||||
->orLike("t1.precio_tinta_negro", $search)
|
||||
->orLike("t1.precio_tinta_color", $search)
|
||||
->orLike("t1.velocidad_corte", $search)
|
||||
->orLike("t1.precio_hora_corte", $search)
|
||||
->orLike("t1.metrosxminuto", $search)
|
||||
->orLike("t1.forzar_num_formas_horizontales_cubierta", $search)
|
||||
->orLike("t1.forzar_num_formas_verticales_cubierta", $search)
|
||||
->orLike("t1.observaciones", $search)
|
||||
->orLike("t2.id", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.tipo", $search)
|
||||
->orLike("t1.velocidad", $search)
|
||||
->orLike("t1.ancho", $search)
|
||||
->orLike("t1.alto", $search)
|
||||
->orLike("t1.ancho_impresion", $search)
|
||||
->orLike("t1.alto_impresion", $search)
|
||||
->orLike("t1.alto_click", $search)
|
||||
->orLike("t1.padre_id", $search)
|
||||
->orLike("t1.min", $search)
|
||||
->orLike("t1.max", $search)
|
||||
->orLike("t1.duracion_jornada", $search)
|
||||
->orLike("t1.orden_planning", $search)
|
||||
->orLike("t1.precio_tinta_negro", $search)
|
||||
->orLike("t1.precio_tinta_color", $search)
|
||||
->orLike("t1.velocidad_corte", $search)
|
||||
->orLike("t1.precio_hora_corte", $search)
|
||||
->orLike("t1.metrosxminuto", $search)
|
||||
->orLike("t1.forzar_num_formas_horizontales_cubierta", $search)
|
||||
->orLike("t1.forzar_num_formas_verticales_cubierta", $search)
|
||||
->orLike("t1.observaciones", $search)
|
||||
->orLike("t2.nombre", $search)
|
||||
->groupEnd();
|
||||
if (empty($search))
|
||||
return $builder;
|
||||
else {
|
||||
$builder->groupStart();
|
||||
foreach ($search as $col_search) {
|
||||
$column = self::SORTABLE[$col_search[0]];
|
||||
$value = $col_search[2];
|
||||
$builder->where("LOWER(CONVERT($column USING utf8)) COLLATE utf8_general_ci LIKE", "%" . strtolower($value) . "%");
|
||||
}
|
||||
$builder->groupEnd();
|
||||
return $builder;
|
||||
}
|
||||
}
|
||||
|
||||
public function getMaquinaImpresionForPresupuesto($is_rotativa, $tarifa_tipo, $uso_tarifa , $tirada, $papel_impresion_id = -1)
|
||||
|
||||
@ -94,6 +94,20 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getNombre($id = 0)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.nombre AS nombre"
|
||||
)
|
||||
->where("t1.id", $id)
|
||||
->where("t1.is_deleted", 0);
|
||||
$data = $builder->get()->getFirstRow();
|
||||
// se convierte a de stdClass a array
|
||||
$data = json_decode(json_encode($data), true);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get resource data.
|
||||
|
||||
@ -132,7 +132,7 @@ class BuscadorModel extends \App\Models\BaseModel
|
||||
t6.estado AS estado"
|
||||
);
|
||||
$builder->join("clientes t2", "t1.cliente_id = t2.id", "left");
|
||||
$builder->join("users t3", "t1.user_update_id = t3.id", "left");
|
||||
$builder->join("users t3", "t2.comercial_id = t3.id", "left");
|
||||
$builder->join("lg_paises t5", "t1.pais_id = t5.id", "left");
|
||||
$builder->join("presupuesto_estados t6", "t1.estado_id = t6.id", "left");
|
||||
$builder->join("tipos_presupuestos t7", "t1.tipo_impresion_id = t7.id", "left");
|
||||
|
||||
@ -434,6 +434,8 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
'merma_cubierta' => $extra_info['merma'],
|
||||
'paginasCuadernillo' => $data['paginasCuadernillo'],
|
||||
|
||||
'recoger_en_taller' => $data['entrega_taller'],
|
||||
|
||||
'comp_pos_paginas_color' => $data['interior']['pos_paginas_color'],
|
||||
'paginas_color_consecutivas' => $data['interior']['paginas_color_consecutivas'],
|
||||
'papel_interior_diferente' => $data['interior']['papelInteriorDiferente'],
|
||||
@ -443,10 +445,8 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
|
||||
'comparador_json_data' => $this->generateJson($data),
|
||||
|
||||
'acabado_cubierta_id' => $data['cubierta']['acabadosCubierta']['plastificado'],
|
||||
'barniz_cubierta_id' => $data['cubierta']['acabadosCubierta']['barniz'],
|
||||
'estampado_cubierta_id' => $data['cubierta']['acabadosCubierta']['estampado'],
|
||||
'acabado_sobrecubierta_id' => !$data['sobrecubierta'] ? 0 : $data['sobrecubierta']['acabados'],
|
||||
'acabado_cubierta_id' => $data['cubierta']['acabado'],
|
||||
'acabado_sobrecubierta_id' => !$data['sobrecubierta'] ? 0 : $data['sobrecubierta']['acabado'],
|
||||
|
||||
'comp_tipo_impresion' => $data['isHq'] ? ($data['isColor'] ? 'colorhq' : 'negrohq') : ($data['isColor'] ? 'color' : 'negro'),
|
||||
|
||||
|
||||
@ -25,6 +25,15 @@ class UserModel extends ShieldUserModel
|
||||
];
|
||||
}
|
||||
|
||||
const SORTABLE = [
|
||||
0 => "t1.id",
|
||||
1 => "t1.first_name",
|
||||
2 => "t1.last_name",
|
||||
3 => "t2.secret",
|
||||
4 => "t3.nombre",
|
||||
5 => "t1.last_active",
|
||||
];
|
||||
|
||||
protected $returnType = UsersEntity::class;
|
||||
|
||||
protected $useSoftDeletes = true;
|
||||
@ -36,6 +45,7 @@ class UserModel extends ShieldUserModel
|
||||
protected $validationRules = [
|
||||
"first_name" => "required|trim|max_length[150]",
|
||||
"last_name" => "required|trim|max_length[150]",
|
||||
"email" => "required|valid_email|max_length[150]",
|
||||
'new_pwd' => 'permit_empty|min_length[8]',
|
||||
'new_pwd_confirm' => 'permit_empty|required_with[new_pwd]|matches[new_pwd]',
|
||||
"comments" => "permit_empty|trim|max_length[512]"
|
||||
@ -59,9 +69,42 @@ class UserModel extends ShieldUserModel
|
||||
'comments' => [
|
||||
"max_length" => "Users.validation.last_name.max_length",
|
||||
],
|
||||
'email' => [
|
||||
"required" => "Users.validation.email.required",
|
||||
"valid_email" => "Users.validation.email.valid_email",
|
||||
"max_length" => "Users.validation.email.max_length"
|
||||
]
|
||||
|
||||
];
|
||||
|
||||
public function getResource($search = [])
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id as id, t1.first_name AS first_name, t1.last_name AS last_name,
|
||||
t2.secret AS email, t1.last_active AS last_active, t3.nombre AS cliente"
|
||||
);
|
||||
|
||||
$builder->join("auth_identities t2", "t1.id = t2.user_id", "left");
|
||||
$builder->join("clientes t3", "t1.cliente_id = t3.id", "left");
|
||||
|
||||
$builder->where('t1.deleted_at', null)->groupBy("t1.id");
|
||||
|
||||
if (empty($search))
|
||||
return $builder;
|
||||
else {
|
||||
$builder->groupStart();
|
||||
foreach ($search as $col_search) {
|
||||
$column = self::SORTABLE[$col_search[0]];
|
||||
$value = $col_search[2];
|
||||
$builder->where("LOWER(CONVERT($column USING utf8)) COLLATE utf8_general_ci LIKE", "%" . strtolower($value) . "%");
|
||||
}
|
||||
$builder->groupEnd();
|
||||
return $builder;
|
||||
}
|
||||
}
|
||||
|
||||
public function getComerciales()
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user