mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'main' into feat/imposiciones/sk-40
This commit is contained in:
@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\API;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class ItemModel extends Model
|
||||
{
|
||||
protected $table = 'items';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = ['title','price'];
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
protected bool $updateOnlyChanged = true;
|
||||
|
||||
protected array $casts = [];
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = false;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
}
|
||||
@ -12,17 +12,6 @@ class PaisModel extends \App\Models\BaseModel
|
||||
*/
|
||||
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\PaisEntity";
|
||||
@ -91,38 +80,24 @@ class PaisModel extends \App\Models\BaseModel
|
||||
/**
|
||||
* Get resource data.
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResource(string $search = "")
|
||||
public function getDatatableQuery()
|
||||
{
|
||||
$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"
|
||||
"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();
|
||||
return $builder;
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ class FacturaLineaModel extends \App\Models\BaseModel {
|
||||
t1.pedido_linea_impresion_id AS pedido_linea_impresion_id, t1.pedido_maquetacion_id AS pedido_maquetacion_id,
|
||||
t1.descripcion AS descripcion, t1.cantidad as cantidad, t1.iva AS iva,
|
||||
t1.base AS base, t1.total_iva AS total_iva, t1.total AS total, t1.data AS data, t2.pedido_id AS pedido_id,
|
||||
t3.total_aceptado AS total_aceptado, t4.tirada_flexible AS tirada_flexible, t4.descuento_tirada_flexible AS descuento_tirada_flexible,
|
||||
t3.total_aceptado_revisado AS total_aceptado, t4.tirada_flexible AS tirada_flexible, t4.descuento_tirada_flexible AS descuento_tirada_flexible,
|
||||
t6.cantidad AS cantidad_albaran"
|
||||
)
|
||||
->join("pedidos_linea t2", "t2.id = t1.pedido_linea_impresion_id", "left")
|
||||
|
||||
@ -145,6 +145,27 @@ class FacturaModel extends \App\Models\BaseModel
|
||||
return $builder;
|
||||
}
|
||||
|
||||
|
||||
public function presupuestoHasFacturaValidada($presupuesto_id = null)
|
||||
{
|
||||
if ($presupuesto_id == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = $this->db->table($this->table . " t1")
|
||||
->select("t1.id")
|
||||
->join("facturas_lineas t2", "t2.factura_id = t1.id", "left")
|
||||
->join("pedidos_linea t3", "t2.pedido_linea_impresion_id = t3.id", "left")
|
||||
->where("t3.presupuesto_id", $presupuesto_id)
|
||||
->where("t1.deleted_at IS NULL")
|
||||
->where("t2.deleted_at IS NULL")
|
||||
->where("t1.estado", "validada")
|
||||
->get()
|
||||
->getResultObject();
|
||||
|
||||
return !empty($result);
|
||||
}
|
||||
|
||||
public function getSumatoriosFacturacionCliente($cliente_id = -1){
|
||||
|
||||
if($cliente_id == -1){
|
||||
|
||||
@ -36,6 +36,8 @@ class PedidoLineaModel extends \App\Models\BaseModel
|
||||
"user_updated_id",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
"cantidad",
|
||||
"descripcion",
|
||||
];
|
||||
protected $returnType = "App\Entities\Pedidos\PedidoLineaEntity";
|
||||
|
||||
|
||||
@ -37,6 +37,7 @@ class PedidoModel extends \App\Models\BaseModel
|
||||
"total_precio",
|
||||
"total_tirada",
|
||||
"estado",
|
||||
"inaplazable",
|
||||
"user_created_id",
|
||||
"user_updated_id",
|
||||
"user_validated_id",
|
||||
@ -44,6 +45,11 @@ class PedidoModel extends \App\Models\BaseModel
|
||||
"fecha_impresion",
|
||||
"fecha_encuadernado",
|
||||
"fecha_entrega_externo",
|
||||
"fecha_entrega_real_change_user_id",
|
||||
"fecha_impresion_change_user_id",
|
||||
"fecha_encuadernado_change_user_id",
|
||||
"fecha_entrega_externo_change_user_id",
|
||||
"inaplazable_change_user_id",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
"validated_at",
|
||||
@ -111,15 +117,28 @@ class PedidoModel extends \App\Models\BaseModel
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t2.presupuesto_id"
|
||||
"t2.presupuesto_id, t3.total_aceptado, t2.descripcion, t2.cantidad"
|
||||
);
|
||||
$builder->where("t1.id", $pedido_id);
|
||||
$builder->join("pedidos_linea t2", "t2.pedido_id = t1.id", "left");
|
||||
$builder->join("presupuestos t3", "t2.presupuesto_id = t3.id", "left");
|
||||
$model_presupuesto = model("App\Models\Presupuestos\PresupuestoModel");
|
||||
$lineasPresupuesto = [];
|
||||
|
||||
foreach ($builder->get()->getResultObject() as $row) {
|
||||
array_push($lineasPresupuesto, $model_presupuesto->generarLineaPedido($row->presupuesto_id)[0]);
|
||||
if($row->descripcion == null){
|
||||
array_push($lineasPresupuesto, $model_presupuesto->generarLineaPedido($row->presupuesto_id)[0]);
|
||||
}
|
||||
else{
|
||||
$presupuesto = (object) [
|
||||
'numero' => $row->presupuesto_id,
|
||||
'unidades' => $row->cantidad,
|
||||
'total' => $row->total_aceptado,
|
||||
'concepto' => $row->descripcion,
|
||||
];
|
||||
array_push($lineasPresupuesto, $presupuesto);
|
||||
}
|
||||
|
||||
}
|
||||
$builder->groupBy("t1.id");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user