mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en el editar
This commit is contained in:
@ -30,6 +30,20 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
10 => "t6.estado",
|
||||
];
|
||||
|
||||
const SORTABLE_CLIENTE = [
|
||||
0 => "t1.id",
|
||||
1 => "t1.created_at",
|
||||
2 => "t7.codigo",
|
||||
3 => "t2.nombre",
|
||||
4 => "t3.first_name",
|
||||
5 => "t1.titulo",
|
||||
6 => "t5.nombre",
|
||||
8 => "t1.paginas",
|
||||
9 => "t1.tirada",
|
||||
10 => "t1.total_presupuesto",
|
||||
11 => "t6.estado",
|
||||
];
|
||||
|
||||
protected $allowedFields = [
|
||||
"cliente_id",
|
||||
"user_created_id",
|
||||
@ -313,6 +327,55 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
return $builder;
|
||||
}
|
||||
|
||||
function getListaPresupuestosCliente($search = [] , $clienteId){
|
||||
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.created_at AS fecha, t7.codigo as codigo, t2.nombre AS cliente,
|
||||
CONCAT(t3.first_name, ' ', t3.last_name) AS comercial, t1.titulo AS titulo,
|
||||
t5.nombre AS pais, t1.inc_rei AS inc_rei, t1.paginas AS paginas, t1.tirada AS tirada,
|
||||
t1.total_presupuesto AS total_presupuesto, t1.total_presupuesto AS total_presupuesto,
|
||||
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("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");
|
||||
|
||||
if($clienteId != 0)
|
||||
$builder->where("t1.cliente_id", $clienteId);
|
||||
|
||||
$builder->where("t1.is_deleted", 0);
|
||||
|
||||
if (empty($search))
|
||||
return $builder;
|
||||
else {
|
||||
$builder->groupStart();
|
||||
foreach ($search as $col_search) {
|
||||
if ($col_search[0] != 1)
|
||||
$builder->like(self::SORTABLE_CLIENTE[$col_search[0]], $col_search[2]);
|
||||
else {
|
||||
$dates = explode(" ", $col_search[2]);
|
||||
$builder->where(self::SORTABLE_CLIENTE[$col_search[0]] . ">=", $dates[0]);
|
||||
$builder->where(self::SORTABLE_CLIENTE[$col_search[0]] . "<=", $dates[1]);
|
||||
}
|
||||
}
|
||||
$builder->groupEnd();
|
||||
return $builder;
|
||||
}
|
||||
}
|
||||
|
||||
function confirmarPresupuesto($presupuesto_id)
|
||||
{
|
||||
$this->db
|
||||
->table($this->table . " t1")
|
||||
->where('t1.id', $presupuesto_id)
|
||||
->set('t1.estado', 2)
|
||||
->update();
|
||||
}
|
||||
|
||||
function insertarPresupuestoCliente($tirada, $data, $data_cabecera, $extra_info, $resumen_totales, $iva_reducido, $tiradas_alternativas)
|
||||
{
|
||||
|
||||
@ -389,7 +452,8 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
'total_descuentoPercent' => 0,
|
||||
|
||||
'total_precio_unidad' => round(($totalCostes + $totalMargenes)/$tirada, 4),
|
||||
'total_presupuesto' => round($totalCostes + $totalMargenes, 2),
|
||||
'total_presupuesto' => round($totalCostes + $totalMargenes, 2),
|
||||
'total_aceptado' => round($totalCostes + $totalMargenes, 2),
|
||||
|
||||
'total_factor' => round(($totalCostes + $totalMargenes-$resumen_totales['coste_envio']-$resumen_totales['margen_envio'])/$resumen_totales['sumForFactor'], 2),
|
||||
'total_factor_ponderado' => round(($totalCostes + $totalMargenes-$resumen_totales['coste_envio']-$resumen_totales['margen_envio'])/$resumen_totales['sumForFactorPonderado'], 2),
|
||||
@ -463,4 +527,6 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
$json = json_encode($values);
|
||||
return $json;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user