mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Añadida funcion clientes desde ozar
This commit is contained in:
@ -15,38 +15,40 @@ class ClienteModel extends \App\Models\GoBaseModel
|
||||
const SORTABLE = [
|
||||
0 => "t1.nombre",
|
||||
1 => "t1.alias",
|
||||
2 => "t1.email",
|
||||
3 => "t1.salesman_id",
|
||||
4 => "t1.forma_pago_id",
|
||||
5 => "t1.vencimiento",
|
||||
2 => "t1.cif",
|
||||
3 => "t1.email",
|
||||
4 => "t1.comercial_id",
|
||||
5 => "t1.forma_pago_id",
|
||||
6 => "t1.vencimiento",
|
||||
];
|
||||
|
||||
protected $allowedFields = [
|
||||
"nombre",
|
||||
"alias",
|
||||
"cif",
|
||||
"direccion",
|
||||
"ciudad",
|
||||
"comunidad_autonoma_id",
|
||||
"provincia",
|
||||
"provincia_id",
|
||||
"cp",
|
||||
"pais_id",
|
||||
"telefono",
|
||||
"email",
|
||||
"salesman_id",
|
||||
"comercial_id",
|
||||
"soporte_id",
|
||||
"forma_pago_id",
|
||||
"vencimiento",
|
||||
"fechaVencimiento",
|
||||
"fecha_vencimiento",
|
||||
"margen",
|
||||
"margen_pod",
|
||||
"descuento",
|
||||
"limite_credito",
|
||||
"limite_credito_user_id",
|
||||
"limite_credito_change_at",
|
||||
"creditoSolunion",
|
||||
"creditoAsegurado",
|
||||
"credito_solunion",
|
||||
"credito_asegurado",
|
||||
"ccc",
|
||||
"ccc_customer",
|
||||
"ccc_cliente",
|
||||
"num_cuenta",
|
||||
"disponible_fe",
|
||||
"message_tracking",
|
||||
@ -61,262 +63,253 @@ class ClienteModel extends \App\Models\GoBaseModel
|
||||
"ps_customer_id",
|
||||
"lineasEnvioFactura",
|
||||
"comentarios",
|
||||
"is_deleted",
|
||||
"deleted_at",
|
||||
"user_created_id",
|
||||
"user_update_id",
|
||||
];
|
||||
protected $returnType = "App\Entities\Clientes\ClienteEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $createdField = "created_at";
|
||||
|
||||
protected $updatedField = "updated_at";
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
protected $validationRules = [
|
||||
"alias" => [
|
||||
"label" => "Cliente.alias",
|
||||
"label" => "Clientes.alias",
|
||||
"rules" => "trim|required|max_length[255]",
|
||||
],
|
||||
"ccc" => [
|
||||
"label" => "Cliente.ccc",
|
||||
"label" => "Clientes.ccc",
|
||||
"rules" => "trim|max_length[100]",
|
||||
],
|
||||
"ccc_customer" => [
|
||||
"label" => "Cliente.cccCustomer",
|
||||
"ccc_cliente" => [
|
||||
"label" => "Clientes.cccCliente",
|
||||
"rules" => "trim|max_length[100]",
|
||||
],
|
||||
"cif" => [
|
||||
"label" => "Clientes.cif",
|
||||
"rules" => "trim|required|max_length[50]",
|
||||
],
|
||||
"ciudad" => [
|
||||
"label" => "Cliente.ciudad",
|
||||
"label" => "Clientes.ciudad",
|
||||
"rules" => "trim|max_length[100]",
|
||||
],
|
||||
"comentarios" => [
|
||||
"label" => "Cliente.comentarios",
|
||||
"label" => "Clientes.comentarios",
|
||||
"rules" => "trim|max_length[16313]",
|
||||
],
|
||||
"comentarios_produccion" => [
|
||||
"label" => "Cliente.comentariosProduccion",
|
||||
"label" => "Clientes.comentariosProduccion",
|
||||
"rules" => "trim|max_length[16313]",
|
||||
],
|
||||
"comentarios_tirada_flexible" => [
|
||||
"label" => "Cliente.comentariosTiradaFlexible",
|
||||
"label" => "Clientes.comentariosTiradaFlexible",
|
||||
"rules" => "trim|required|max_length[16313]",
|
||||
],
|
||||
"cp" => [
|
||||
"label" => "Cliente.cp",
|
||||
"label" => "Clientes.cp",
|
||||
"rules" => "trim|max_length[10]",
|
||||
],
|
||||
"creditoSolunion" => [
|
||||
"label" => "Cliente.creditosolunion",
|
||||
"credito_solunion" => [
|
||||
"label" => "Clientes.creditoSolunion",
|
||||
"rules" => "trim|max_length[100]",
|
||||
],
|
||||
"descuento" => [
|
||||
"label" => "Cliente.descuento",
|
||||
"label" => "Clientes.descuento",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"descuento_tirada_flexible" => [
|
||||
"label" => "Cliente.descuentoTiradaFlexible",
|
||||
"label" => "Clientes.descuentoTiradaFlexible",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"direccion" => [
|
||||
"label" => "Cliente.direccion",
|
||||
"label" => "Clientes.direccion",
|
||||
"rules" => "trim|max_length[300]",
|
||||
],
|
||||
"email" => [
|
||||
"label" => "Cliente.email",
|
||||
"label" => "Clientes.email",
|
||||
"rules" => "trim|max_length[150]|valid_email|permit_empty",
|
||||
],
|
||||
"fechaVencimiento" => [
|
||||
"label" => "Cliente.fechavencimiento",
|
||||
"fecha_vencimiento" => [
|
||||
"label" => "Clientes.fechaVencimiento",
|
||||
"rules" => "trim|max_length[100]",
|
||||
],
|
||||
"is_deleted" => [
|
||||
"label" => "Clientes.isDeleted",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
"limite_credito" => [
|
||||
"label" => "Cliente.limiteCredito",
|
||||
"label" => "Clientes.limiteCredito",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"limite_credito_change_at" => [
|
||||
"label" => "Cliente.limiteCreditoChangeAt",
|
||||
"label" => "Clientes.limiteCreditoChangeAt",
|
||||
"rules" => "required|valid_date",
|
||||
],
|
||||
"limite_credito_user_id" => [
|
||||
"label" => "Cliente.limiteCreditoUserId",
|
||||
"label" => "Clientes.limiteCreditoUserId",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
"margen" => [
|
||||
"label" => "Cliente.margen",
|
||||
"label" => "Clientes.margen",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"margen_plantilla_id" => [
|
||||
"label" => "Cliente.margenPlantillaId",
|
||||
"label" => "Clientes.margenPlantillaId",
|
||||
"rules" => "integer|permit_empty",
|
||||
],
|
||||
"margen_pod" => [
|
||||
"label" => "Cliente.margenPod",
|
||||
"label" => "Clientes.margenPod",
|
||||
"rules" => "decimal|permit_empty",
|
||||
],
|
||||
"nombre" => [
|
||||
"label" => "Cliente.nombre",
|
||||
"label" => "Clientes.nombre",
|
||||
"rules" => "trim|required|max_length[255]",
|
||||
],
|
||||
"num_cuenta" => [
|
||||
"label" => "Cliente.numCuenta",
|
||||
"label" => "Clientes.numCuenta",
|
||||
"rules" => "trim|max_length[10]",
|
||||
],
|
||||
"provincia" => [
|
||||
"label" => "Cliente.provincia",
|
||||
"rules" => "trim|max_length[100]",
|
||||
],
|
||||
"ps_customer_id" => [
|
||||
"label" => "Cliente.psCustomerId",
|
||||
"label" => "Clientes.psCustomerId",
|
||||
"rules" => "integer|permit_empty",
|
||||
],
|
||||
"salesman_id" => [
|
||||
"label" => "Cliente.salesmanId",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
"saturacion" => [
|
||||
"label" => "Cliente.saturacion",
|
||||
"label" => "Clientes.saturacion",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"soporte_id" => [
|
||||
"label" => "Cliente.soporteId",
|
||||
"rules" => "integer|permit_empty",
|
||||
],
|
||||
"telefono" => [
|
||||
"label" => "Cliente.telefono",
|
||||
"label" => "Clientes.telefono",
|
||||
"rules" => "trim|max_length[60]",
|
||||
],
|
||||
"tienda_id" => [
|
||||
"label" => "Cliente.tiendaId",
|
||||
"label" => "Clientes.tiendaId",
|
||||
"rules" => "integer|permit_empty",
|
||||
],
|
||||
"user_created_id" => [
|
||||
"label" => "Cliente.userCreatedId",
|
||||
"label" => "Clientes.userCreatedId",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
"user_update_id" => [
|
||||
"label" => "Cliente.userUpdateId",
|
||||
"label" => "Clientes.userUpdateId",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
"vencimiento" => [
|
||||
"label" => "Cliente.vencimiento",
|
||||
"label" => "Clientes.vencimiento",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"alias" => [
|
||||
"max_length" => "Cliente.validation.alias.max_length",
|
||||
"required" => "Cliente.validation.alias.required",
|
||||
"max_length" => "Clientes.validation.alias.max_length",
|
||||
"required" => "Clientes.validation.alias.required",
|
||||
],
|
||||
"ccc" => [
|
||||
"max_length" => "Cliente.validation.ccc.max_length",
|
||||
"max_length" => "Clientes.validation.ccc.max_length",
|
||||
],
|
||||
"ccc_customer" => [
|
||||
"max_length" => "Cliente.validation.ccc_customer.max_length",
|
||||
"ccc_cliente" => [
|
||||
"max_length" => "Clientes.validation.ccc_cliente.max_length",
|
||||
],
|
||||
"cif" => [
|
||||
"max_length" => "Clientes.validation.cif.max_length",
|
||||
"required" => "Clientes.validation.cif.required",
|
||||
],
|
||||
"ciudad" => [
|
||||
"max_length" => "Cliente.validation.ciudad.max_length",
|
||||
"max_length" => "Clientes.validation.ciudad.max_length",
|
||||
],
|
||||
"comentarios" => [
|
||||
"max_length" => "Cliente.validation.comentarios.max_length",
|
||||
"max_length" => "Clientes.validation.comentarios.max_length",
|
||||
],
|
||||
"comentarios_produccion" => [
|
||||
"max_length" => "Cliente.validation.comentarios_produccion.max_length",
|
||||
"max_length" => "Clientes.validation.comentarios_produccion.max_length",
|
||||
],
|
||||
"comentarios_tirada_flexible" => [
|
||||
"max_length" => "Cliente.validation.comentarios_tirada_flexible.max_length",
|
||||
"required" => "Cliente.validation.comentarios_tirada_flexible.required",
|
||||
"max_length" => "Clientes.validation.comentarios_tirada_flexible.max_length",
|
||||
"required" => "Clientes.validation.comentarios_tirada_flexible.required",
|
||||
],
|
||||
"cp" => [
|
||||
"max_length" => "Cliente.validation.cp.max_length",
|
||||
"max_length" => "Clientes.validation.cp.max_length",
|
||||
],
|
||||
"creditoSolunion" => [
|
||||
"max_length" => "Cliente.validation.creditoSolunion.max_length",
|
||||
"credito_solunion" => [
|
||||
"max_length" => "Clientes.validation.credito_solunion.max_length",
|
||||
],
|
||||
"descuento" => [
|
||||
"decimal" => "Cliente.validation.descuento.decimal",
|
||||
"required" => "Cliente.validation.descuento.required",
|
||||
"decimal" => "Clientes.validation.descuento.decimal",
|
||||
"required" => "Clientes.validation.descuento.required",
|
||||
],
|
||||
"descuento_tirada_flexible" => [
|
||||
"decimal" => "Cliente.validation.descuento_tirada_flexible.decimal",
|
||||
"required" => "Cliente.validation.descuento_tirada_flexible.required",
|
||||
"decimal" => "Clientes.validation.descuento_tirada_flexible.decimal",
|
||||
"required" => "Clientes.validation.descuento_tirada_flexible.required",
|
||||
],
|
||||
"direccion" => [
|
||||
"max_length" => "Cliente.validation.direccion.max_length",
|
||||
"max_length" => "Clientes.validation.direccion.max_length",
|
||||
],
|
||||
"email" => [
|
||||
"max_length" => "Cliente.validation.email.max_length",
|
||||
"valid_email" => "Cliente.validation.email.valid_email",
|
||||
"max_length" => "Clientes.validation.email.max_length",
|
||||
"valid_email" => "Clientes.validation.email.valid_email",
|
||||
],
|
||||
"fechaVencimiento" => [
|
||||
"max_length" => "Cliente.validation.fechaVencimiento.max_length",
|
||||
"fecha_vencimiento" => [
|
||||
"max_length" => "Clientes.validation.fecha_vencimiento.max_length",
|
||||
],
|
||||
"is_deleted" => [
|
||||
"integer" => "Clientes.validation.is_deleted.integer",
|
||||
"required" => "Clientes.validation.is_deleted.required",
|
||||
],
|
||||
"limite_credito" => [
|
||||
"decimal" => "Cliente.validation.limite_credito.decimal",
|
||||
"required" => "Cliente.validation.limite_credito.required",
|
||||
"decimal" => "Clientes.validation.limite_credito.decimal",
|
||||
"required" => "Clientes.validation.limite_credito.required",
|
||||
],
|
||||
"limite_credito_change_at" => [
|
||||
"required" => "Cliente.validation.limite_credito_change_at.required",
|
||||
"valid_date" => "Cliente.validation.limite_credito_change_at.valid_date",
|
||||
"required" => "Clientes.validation.limite_credito_change_at.required",
|
||||
"valid_date" => "Clientes.validation.limite_credito_change_at.valid_date",
|
||||
],
|
||||
"limite_credito_user_id" => [
|
||||
"integer" => "Cliente.validation.limite_credito_user_id.integer",
|
||||
"required" => "Cliente.validation.limite_credito_user_id.required",
|
||||
"integer" => "Clientes.validation.limite_credito_user_id.integer",
|
||||
"required" => "Clientes.validation.limite_credito_user_id.required",
|
||||
],
|
||||
"margen" => [
|
||||
"decimal" => "Cliente.validation.margen.decimal",
|
||||
"required" => "Cliente.validation.margen.required",
|
||||
"decimal" => "Clientes.validation.margen.decimal",
|
||||
"required" => "Clientes.validation.margen.required",
|
||||
],
|
||||
"margen_plantilla_id" => [
|
||||
"integer" => "Cliente.validation.margen_plantilla_id.integer",
|
||||
"integer" => "Clientes.validation.margen_plantilla_id.integer",
|
||||
],
|
||||
"margen_pod" => [
|
||||
"decimal" => "Cliente.validation.margen_pod.decimal",
|
||||
"decimal" => "Clientes.validation.margen_pod.decimal",
|
||||
],
|
||||
"nombre" => [
|
||||
"max_length" => "Cliente.validation.nombre.max_length",
|
||||
"required" => "Cliente.validation.nombre.required",
|
||||
"max_length" => "Clientes.validation.nombre.max_length",
|
||||
"required" => "Clientes.validation.nombre.required",
|
||||
],
|
||||
"num_cuenta" => [
|
||||
"max_length" => "Cliente.validation.num_cuenta.max_length",
|
||||
],
|
||||
"provincia" => [
|
||||
"max_length" => "Cliente.validation.provincia.max_length",
|
||||
"max_length" => "Clientes.validation.num_cuenta.max_length",
|
||||
],
|
||||
"ps_customer_id" => [
|
||||
"integer" => "Cliente.validation.ps_customer_id.integer",
|
||||
],
|
||||
"salesman_id" => [
|
||||
"integer" => "Cliente.validation.salesman_id.integer",
|
||||
"required" => "Cliente.validation.salesman_id.required",
|
||||
"integer" => "Clientes.validation.ps_customer_id.integer",
|
||||
],
|
||||
"saturacion" => [
|
||||
"decimal" => "Cliente.validation.saturacion.decimal",
|
||||
"required" => "Cliente.validation.saturacion.required",
|
||||
],
|
||||
"soporte_id" => [
|
||||
"integer" => "Cliente.validation.soporte_id.integer",
|
||||
"decimal" => "Clientes.validation.saturacion.decimal",
|
||||
"required" => "Clientes.validation.saturacion.required",
|
||||
],
|
||||
"telefono" => [
|
||||
"max_length" => "Cliente.validation.telefono.max_length",
|
||||
"max_length" => "Clientes.validation.telefono.max_length",
|
||||
],
|
||||
"tienda_id" => [
|
||||
"integer" => "Cliente.validation.tienda_id.integer",
|
||||
"integer" => "Clientes.validation.tienda_id.integer",
|
||||
],
|
||||
"user_created_id" => [
|
||||
"integer" => "Cliente.validation.user_created_id.integer",
|
||||
"required" => "Cliente.validation.user_created_id.required",
|
||||
"integer" => "Clientes.validation.user_created_id.integer",
|
||||
"required" => "Clientes.validation.user_created_id.required",
|
||||
],
|
||||
"user_update_id" => [
|
||||
"integer" => "Cliente.validation.user_update_id.integer",
|
||||
"required" => "Cliente.validation.user_update_id.required",
|
||||
"integer" => "Clientes.validation.user_update_id.integer",
|
||||
"required" => "Clientes.validation.user_update_id.required",
|
||||
],
|
||||
"vencimiento" => [
|
||||
"integer" => "Cliente.validation.vencimiento.integer",
|
||||
"required" => "Cliente.validation.vencimiento.required",
|
||||
"integer" => "Clientes.validation.vencimiento.integer",
|
||||
"required" => "Clientes.validation.vencimiento.required",
|
||||
],
|
||||
];
|
||||
public function findAllWithAllRelations(string $selcols = "*", int $limit = null, int $offset = 0)
|
||||
@ -324,9 +317,9 @@ class ClienteModel extends \App\Models\GoBaseModel
|
||||
$sql =
|
||||
"SELECT t1." .
|
||||
$selcols .
|
||||
", t2.nombre AS pais, t3.nombre AS forma_pago FROM " .
|
||||
", t2.nombre AS comunidad_autonoma_id, t3.nombre AS provincia, t4.nombre AS pais_id, t5.first_name AS comercial, t6.last_name AS soporte, t7.nombre AS forma_pago_id FROM " .
|
||||
$this->table .
|
||||
" t1 LEFT JOIN lg_paises t2 ON t1.pais_id = t2.id LEFT JOIN lg_formas_pago t3 ON t1.forma_pago_id = t3.id";
|
||||
" t1 LEFT JOIN lg_comunidades_autonomas t2 ON t1.comunidad_autonoma_id = t2.id LEFT JOIN lg_provincias t3 ON t1.provincia_id = t3.id LEFT JOIN lg_paises t4 ON t1.pais_id = t4.id LEFT JOIN auth_user t5 ON t1.comercial_id = t5.id_user LEFT JOIN auth_user t6 ON t1.soporte_id = t6.id_user LEFT JOIN lg_formas_pago t7 ON t1.forma_pago_id = t7.id";
|
||||
if (!is_null($limit) && intval($limit) > 0) {
|
||||
$sql .= " LIMIT " . intval($limit);
|
||||
}
|
||||
@ -352,10 +345,12 @@ class ClienteModel extends \App\Models\GoBaseModel
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.nombre AS nombre, t1.alias AS alias, t1.direccion AS direccion, t1.ciudad AS ciudad, t1.comunidad_autonoma_id AS comunidad_autonoma_id, t1.provincia AS provincia, t1.cp AS cp, t1.telefono AS telefono, t1.email AS email, t1.salesman_id AS salesman_id, t1.soporte_id AS soporte_id, t1.vencimiento AS vencimiento, t1.fechaVencimiento AS fechaVencimiento, t1.margen AS margen, t1.margen_pod AS margen_pod, t1.descuento AS descuento, t1.limite_credito AS limite_credito, t1.limite_credito_user_id AS limite_credito_user_id, t1.limite_credito_change_at AS limite_credito_change_at, t1.creditoSolunion AS creditoSolunion, t1.creditoAsegurado AS creditoAsegurado, t1.ccc AS ccc, t1.ccc_customer AS ccc_customer, t1.num_cuenta AS num_cuenta, t1.disponible_fe AS disponible_fe, t1.message_tracking AS message_tracking, t1.message_production_start AS message_production_start, t1.tirada_flexible AS tirada_flexible, t1.descuento_tirada_flexible AS descuento_tirada_flexible, t1.comentarios_tirada_flexible AS comentarios_tirada_flexible, t1.saturacion AS saturacion, t1.tienda_id AS tienda_id, t1.margen_plantilla_id AS margen_plantilla_id, t1.comentarios_produccion AS comentarios_produccion, t1.ps_customer_id AS ps_customer_id, t1.lineasEnvioFactura AS lineasEnvioFactura, t1.comentarios AS comentarios, t1.created_at AS created_at, t1.updated_at AS updated_at, t1.user_created_id AS user_created_id, t1.user_update_id AS user_update_id, t2.nombre AS pais, t3.nombre AS forma_pago"
|
||||
);
|
||||
$builder->join("lg_paises t2", "t1.pais_id = t2.id", "left");
|
||||
$builder->join("lg_formas_pago t3", "t1.forma_pago_id = t3.id", "left");
|
||||
"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);;
|
||||
$builder->join("auth_user t5", "t1.comercial_id = t5.id_user", "left");
|
||||
$builder->join("lg_formas_pago t7", "t1.forma_pago_id = t7.id", "left");
|
||||
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
@ -363,11 +358,16 @@ class ClienteModel extends \App\Models\GoBaseModel
|
||||
->groupStart()
|
||||
->like("t1.nombre", $search)
|
||||
->orLike("t1.alias", $search)
|
||||
->orLike("t1.cif", $search)
|
||||
->orLike("t1.email", $search)
|
||||
->orLike("t1.salesman_id", $search)
|
||||
->orLike("t1.soporte_id", $search)
|
||||
->orLike("t1.forma_pago_id", $search)
|
||||
->orLike("t1.vencimiento", $search)
|
||||
->orLike("t1.fechaVencimiento", $search)
|
||||
|
||||
->orLike("t5.id_user", $search)
|
||||
->orLike("t5.first_name", $search)
|
||||
->orLike("t5.last_name", $search)
|
||||
->orLike("t7.id", $search)
|
||||
->orLike("t7.nombre", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
|
||||
97
ci4/app/Models/Configuracion/ComunidadAutonomaModel.php
Normal file
97
ci4/app/Models/Configuracion/ComunidadAutonomaModel.php
Normal file
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
class ComunidadAutonomaModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "lg_comunidades_autonomas";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
1 => "t1.id",
|
||||
2 => "t1.nombre",
|
||||
3 => "t1.pais_id",
|
||||
4 => "t1.created_at",
|
||||
5 => "t1.updated_at",
|
||||
6 => "t2.id",
|
||||
];
|
||||
|
||||
protected $allowedFields = ["nombre", "pais_id"];
|
||||
protected $returnType = "App\Entities\Configuracion\ComunidadAutonomaEntity";
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
protected $validationRules = [
|
||||
"nombre" => [
|
||||
"label" => "ComunidadesAutonomas.nombre",
|
||||
"rules" => "trim|required|max_length[100]",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"nombre" => [
|
||||
"max_length" => "ComunidadesAutonomas.validation.nombre.max_length",
|
||||
"required" => "ComunidadesAutonomas.validation.nombre.required",
|
||||
],
|
||||
];
|
||||
|
||||
public function findAllWithPaises(string $selcols = "*", int $limit = null, int $offset = 0)
|
||||
{
|
||||
$sql =
|
||||
"SELECT t1." .
|
||||
$selcols .
|
||||
", t2.id AS pais FROM " .
|
||||
$this->table .
|
||||
" t1 LEFT JOIN lg_paises t2 ON t1.pais_id = t2.id";
|
||||
if (!is_null($limit) && intval($limit) > 0) {
|
||||
$sql .= " LIMIT " . $limit;
|
||||
}
|
||||
|
||||
if (!is_null($offset) && intval($offset) > 0) {
|
||||
$sql .= " OFFSET " . $offset;
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
$result = $query->getResultObject();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get resource data.
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResource(string $search = "")
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.nombre AS nombre, t1.created_at AS created_at, t1.updated_at AS updated_at, t2.id AS pais"
|
||||
);
|
||||
$builder->join("lg_paises t2", "t1.pais_id = t2.id", "left");
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.created_at", $search)
|
||||
->orLike("t1.updated_at", $search)
|
||||
->orLike("t2.id", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.pais_id", $search)
|
||||
->orLike("t1.created_at", $search)
|
||||
->orLike("t1.updated_at", $search)
|
||||
->orLike("t2.id", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
68
ci4/app/Models/Configuracion/FormaPagoModel.php
Normal file
68
ci4/app/Models/Configuracion/FormaPagoModel.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
class FormaPagoModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "lg_formas_pago";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
1 => "t1.id",
|
||||
2 => "t1.nombre",
|
||||
3 => "t1.created_at",
|
||||
4 => "t1.updated_at",
|
||||
];
|
||||
|
||||
protected $allowedFields = ["nombre"];
|
||||
protected $returnType = "App\Entities\Configuracion\FormaPagoEntity";
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
protected $validationRules = [
|
||||
"nombre" => [
|
||||
"label" => "FormasPagoes.nombre",
|
||||
"rules" => "trim|required|max_length[255]",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"nombre" => [
|
||||
"max_length" => "FormasPagoes.validation.nombre.max_length",
|
||||
"required" => "FormasPagoes.validation.nombre.required",
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Get resource data.
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResource(string $search = "")
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select("t1.id AS id, t1.nombre AS nombre, t1.created_at AS created_at, t1.updated_at AS updated_at");
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.created_at", $search)
|
||||
->orLike("t1.updated_at", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.created_at", $search)
|
||||
->orLike("t1.updated_at", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
@ -12,8 +12,20 @@ class PaisModel extends \App\Models\GoBaseModel
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
1 => "t1.id",
|
||||
2 => "t1.nombre",
|
||||
3 => "t1.code",
|
||||
4 => "t1.code3",
|
||||
5 => "t1.moneda",
|
||||
6 => "t1.url_erp",
|
||||
7 => "t1.user_erp",
|
||||
8 => "t1.key_erp",
|
||||
9 => "t1.show_erp",
|
||||
];
|
||||
|
||||
protected $allowedFields = ["nombre", "code", "code3", "moneda", "url_erp", "user_erp", "key_erp", "show_erp"];
|
||||
protected $returnType = "App\Entities\Configuracion\Pais";
|
||||
protected $returnType = "App\Entities\Configuracion\PaisEntity";
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
@ -75,4 +87,42 @@ class PaisModel extends \App\Models\GoBaseModel
|
||||
"max_length" => "Paises.validation.user_erp.max_length",
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Get resource data.
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResource(string $search = "")
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.nombre AS nombre, t1.code AS code, t1.code3 AS code3, t1.moneda AS moneda, t1.url_erp AS url_erp, t1.user_erp AS user_erp, t1.key_erp AS key_erp, t1.show_erp AS show_erp"
|
||||
);
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.code", $search)
|
||||
->orLike("t1.code3", $search)
|
||||
->orLike("t1.moneda", $search)
|
||||
->orLike("t1.url_erp", $search)
|
||||
->orLike("t1.user_erp", $search)
|
||||
->orLike("t1.key_erp", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.code", $search)
|
||||
->orLike("t1.code3", $search)
|
||||
->orLike("t1.moneda", $search)
|
||||
->orLike("t1.url_erp", $search)
|
||||
->orLike("t1.user_erp", $search)
|
||||
->orLike("t1.key_erp", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
|
||||
109
ci4/app/Models/Configuracion/ProvinciaModel.php
Normal file
109
ci4/app/Models/Configuracion/ProvinciaModel.php
Normal file
@ -0,0 +1,109 @@
|
||||
<?php
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
class ProvinciaModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "lg_provincias";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
1 => "t1.id",
|
||||
2 => "t1.code",
|
||||
3 => "t1.nombre",
|
||||
4 => "t1.pais_id",
|
||||
5 => "t1.created_at",
|
||||
6 => "t1.updated_at",
|
||||
7 => "t2.nombre",
|
||||
];
|
||||
|
||||
protected $allowedFields = ["code", "nombre", "pais_id"];
|
||||
protected $returnType = "App\Entities\Configuracion\ProvinciaEntity";
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
protected $validationRules = [
|
||||
"code" => [
|
||||
"label" => "Provincias.code",
|
||||
"rules" => "trim|required|max_length[2]|is_unique[lg_provincias.code,id,{id}]",
|
||||
],
|
||||
"nombre" => [
|
||||
"label" => "Provincias.nombre",
|
||||
"rules" => "trim|required|max_length[255]",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"code" => [
|
||||
"is_unique" => "Provincias.validation.code.is_unique",
|
||||
"max_length" => "Provincias.validation.code.max_length",
|
||||
"required" => "Provincias.validation.code.required",
|
||||
],
|
||||
"nombre" => [
|
||||
"max_length" => "Provincias.validation.nombre.max_length",
|
||||
"required" => "Provincias.validation.nombre.required",
|
||||
],
|
||||
];
|
||||
|
||||
public function findAllWithPaises(string $selcols = "*", int $limit = null, int $offset = 0)
|
||||
{
|
||||
$sql =
|
||||
"SELECT t1." .
|
||||
$selcols .
|
||||
", t2.nombre AS pais FROM " .
|
||||
$this->table .
|
||||
" t1 LEFT JOIN lg_paises t2 ON t1.pais_id = t2.id";
|
||||
if (!is_null($limit) && intval($limit) > 0) {
|
||||
$sql .= " LIMIT " . $limit;
|
||||
}
|
||||
|
||||
if (!is_null($offset) && intval($offset) > 0) {
|
||||
$sql .= " OFFSET " . $offset;
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
$result = $query->getResultObject();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get resource data.
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResource(string $search = "")
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.code AS code, t1.nombre AS nombre, t1.created_at AS created_at, t1.updated_at AS updated_at, t2.nombre AS pais"
|
||||
);
|
||||
$builder->join("lg_paises t2", "t1.pais_id = t2.id", "left");
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.code", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.created_at", $search)
|
||||
->orLike("t1.updated_at", $search)
|
||||
->orLike("t2.id", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->orLike("t1.code", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.pais_id", $search)
|
||||
->orLike("t1.created_at", $search)
|
||||
->orLike("t1.updated_at", $search)
|
||||
->orLike("t2.nombre", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user