mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
falta terminar albaranes
This commit is contained in:
85
ci4/app/Models/Albaranes/AlbaranLineaModel.php
Normal file
85
ci4/app/Models/Albaranes/AlbaranLineaModel.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Albaranes;
|
||||
|
||||
class AlbaranLineaModel extends \App\Models\BaseModel
|
||||
{
|
||||
protected $table = "albaranes_lineas";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
protected $primaryKey = 'id';
|
||||
protected $returnType = 'App\Entities\Albaranes\AlbaranLineaEntity';
|
||||
protected $allowedFields = [
|
||||
'albaran_id',
|
||||
'pedido_linea_id',
|
||||
'titulo',
|
||||
'isbn',
|
||||
'ref_cliente',
|
||||
'cantidad',
|
||||
'precio_unidad',
|
||||
'total',
|
||||
'iva_reducido',
|
||||
'user_created_id',
|
||||
'user_updated_id',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
];
|
||||
|
||||
protected $useSoftDeletes = true;
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
/**
|
||||
* Get resource data for creating PDFs.
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResourceForPdf($albaran_id = -1)
|
||||
{
|
||||
$builder = $this->db
|
||||
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.albaran_id AS albaran_id, t1.titulo AS titulo, t1.isbn AS isbn,
|
||||
t1.ref_cliente AS ref_cliente, t1.cantidad AS cantidad, t1.cajas AS cajas,
|
||||
t1.ejemplares_por_caja AS ejemplares_por_caja, t1.precio_unidad AS precio_unidad,
|
||||
t1.total AS total, pedidos.id AS pedido"
|
||||
)
|
||||
->join("pedidos_linea", "t1.pedido_linea_id = pedidos_linea.id", "left")
|
||||
->join("pedidos", "pedidos_linea.pedido_id = pedidos.id", "left");
|
||||
|
||||
$builder->where("t1.deleted_at IS NULL");
|
||||
$builder->where("t1.albaran_id", $albaran_id);
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
public function getDatatableQuery($albaran_id = null){
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id, t1.titulo as titulo, t1.isbn as isbn, t1.ref_cliente as ref_cliente,
|
||||
t1.cantidad as unidades, t1.precio_unidad as precio_unidad, t1.iva_reducido as iva_reducido,
|
||||
t1.total as total, pedidos.id AS pedido"
|
||||
)
|
||||
->join("pedidos_linea", "t1.pedido_linea_id = pedidos_linea.id", "left")
|
||||
->join("pedidos", "pedidos_linea.pedido_id = pedidos.id", "left");
|
||||
|
||||
$builder->where("t1.deleted_at IS NULL");
|
||||
$builder->where("t1.albaran_id", $albaran_id);
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user