mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Revert "Merge branch 'feat/add-chat-presupuesto-cliente' into 'main'"
This reverts merge request !352
This commit is contained in:
@ -80,7 +80,7 @@ class BuscadorModel extends \App\Models\BaseModel
|
||||
"comparador_json_data",
|
||||
"is_deleted",
|
||||
"comp_tipo_impresion",
|
||||
"pos_paginas_color",
|
||||
"comp_pos_paginas_color",
|
||||
"total_coste_papel",
|
||||
"total_margen_papel",
|
||||
"total_margenPercent_papel",
|
||||
|
||||
@ -1,115 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Presupuestos;
|
||||
|
||||
use CodeIgniter\Database\BaseBuilder;
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class ErrorPresupuesto extends Model
|
||||
{
|
||||
protected $table = 'presupuesto_errores';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'object';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
"presupuesto_id",
|
||||
"presupuesto_user_id",
|
||||
"error",
|
||||
"datos_presupuesto",
|
||||
"visto",
|
||||
"last_user_id",
|
||||
"comment",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
"deleted_at",
|
||||
];
|
||||
|
||||
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 = [];
|
||||
|
||||
public function insertError(int $presupuesto_id, int $presupuesto_user_id, string $error, mixed $datos)
|
||||
{
|
||||
$this->insert([
|
||||
"presupuesto_id" => $presupuesto_id,
|
||||
"presupuesto_user_id" => $presupuesto_user_id,
|
||||
"error" => $error,
|
||||
"datos_presupuesto" => json_encode($datos)
|
||||
]);
|
||||
}
|
||||
public function updateComment(int $error_presupuesto_id, string $comment): bool
|
||||
{
|
||||
$updated = $this->update($error_presupuesto_id, [
|
||||
"comment" => $comment
|
||||
]);
|
||||
return $updated;
|
||||
}
|
||||
public function getErrorPresupuestoForm(int $error_presupuesto_id) : array
|
||||
{
|
||||
$query = $this->builder()
|
||||
->select([
|
||||
"presupuesto_errores.id",
|
||||
"CONCAT(t1.first_name,' ',t1.last_name) as presupuestoUser",
|
||||
"CONCAT(t2.first_name,' ',t2.last_name) as lastUser",
|
||||
"presupuesto_errores.created_at",
|
||||
"presupuesto_errores.datos_presupuesto",
|
||||
"presupuesto_errores.error",
|
||||
"presupuesto_errores.visto",
|
||||
"presupuesto_errores.comment"
|
||||
])
|
||||
->join("users t1", "t1.id = presupuesto_errores.presupuesto_user_id", "left")
|
||||
->join("users t2", "t2.id = presupuesto_errores.last_user_id", "left")
|
||||
->where("presupuesto_errores.deleted_at", null)
|
||||
->where("presupuesto_errores.id",$error_presupuesto_id);
|
||||
return $query->get()->getResultObject();
|
||||
}
|
||||
public function getQueryDatatable(): BaseBuilder
|
||||
{
|
||||
$query = $this->builder()
|
||||
->select([
|
||||
"presupuesto_errores.id",
|
||||
"presupuestos.id as presupuestoId",
|
||||
"CONCAT(t1.first_name,' ',t1.last_name) as presupuestoUser",
|
||||
"CONCAT(t2.first_name,' ',t2.last_name) as lastUser",
|
||||
"presupuesto_errores.created_at",
|
||||
"presupuesto_errores.datos_presupuesto",
|
||||
"presupuesto_errores.error",
|
||||
"presupuesto_errores.visto",
|
||||
"presupuesto_errores.comment",
|
||||
|
||||
])
|
||||
->join("users t1", "t1.id = presupuesto_errores.presupuesto_user_id", "left")
|
||||
->join("users t2", "t2.id = presupuesto_errores.last_user_id", "left")
|
||||
->join("presupuestos", "presupuestos.id = presupuesto_errores.presupuesto_id", "left")
|
||||
->where("presupuesto_errores.deleted_at", null);
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
@ -123,21 +123,4 @@ class PresupuestoDireccionesModel extends \App\Models\BaseModel
|
||||
return $builder;
|
||||
}
|
||||
|
||||
public function getDireccion($id = -1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.att AS att,
|
||||
t1.email AS email, t1.direccion AS direccion, t1.pais_id AS pais_id, t3.nombre AS pais,
|
||||
t1.municipio AS municipio, t1.provincia AS provincia, t1.cp AS cp, t1.telefono AS telefono"
|
||||
);
|
||||
|
||||
$builder->where('t1.id', $id);
|
||||
$builder->join("lg_paises t3", "t1.pais_id = t3.id", "left");
|
||||
|
||||
|
||||
return $builder->get()->getResultObject();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -96,9 +96,7 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
"comparador_json_data",
|
||||
"is_deleted",
|
||||
"comp_tipo_impresion",
|
||||
"pos_paginas_color",
|
||||
"paginas_color_consecutivas",
|
||||
"papel_interior_diferente",
|
||||
"comp_pos_paginas_color",
|
||||
"total_coste_papel",
|
||||
"total_margen_papel",
|
||||
"total_margenPercent_papel",
|
||||
@ -123,15 +121,8 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
'iva_reducido',
|
||||
'excluir_rotativa',
|
||||
"acabado_cubierta_id",
|
||||
"barniz_cubierta_id",
|
||||
"estampado_cubierta_id",
|
||||
"acabado_sobrecubierta_id",
|
||||
"is_duplicado",
|
||||
'paginas_color_consecutivas',
|
||||
'papel_interior_diferente',
|
||||
'paginasCuadernillo',
|
||||
'lomo_redondo',
|
||||
'cabezada',
|
||||
"is_duplicado"
|
||||
];
|
||||
protected $returnType = "App\Entities\Presupuestos\PresupuestoEntity";
|
||||
|
||||
@ -404,47 +395,35 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
'cliente_id' => $data['clienteId'],
|
||||
'tipo_impresion_id' => $data['tipo_impresion_id'],
|
||||
'pais_id' => 1,
|
||||
'retractilado' => in_array("RETR", $data['cubierta']['acabadosCubierta']) ? 1 : 0,
|
||||
'retractilado' => in_array(3, $data['servicios']) ? 1 : 0,
|
||||
'retractilado5' => in_array(5, $data['servicios']) ? 1 : 0,
|
||||
'guardas' => in_array(62, $data['servicios']) ? 1 : 0,
|
||||
'faja_color' => in_array(16, $data['servicios']) ? 1 : 0,
|
||||
'ferro' => in_array(24, $data['servicios']) ? 1 : 0,
|
||||
'prototipo' => $data['prototipo'] ? 1 : 0,
|
||||
'prototipo' => in_array(9, $data['servicios']) ? 1 : 0,
|
||||
'papel_formato_id' => is_null($papel_formato_id) ? 0 : $papel_formato_id->id,
|
||||
'papel_formato_personalizado' => !$papel_formato_id ? 1 : 0,
|
||||
'papel_formato_ancho' => !$papel_formato_id ? $data['tamanio']['ancho'] : null,
|
||||
'papel_formato_alto' => !$papel_formato_id ? $data['tamanio']['alto'] : null,
|
||||
'titulo' => $data_cabecera['titulo'],
|
||||
'autor' => $data_cabecera['autor'],
|
||||
'ISBN' => $data_cabecera['isbn'],
|
||||
'coleccion' => $data_cabecera['coleccion'],
|
||||
'referencia_cliente' => $data_cabecera['referenciaCliente'],
|
||||
'paginas' => $data['interior']['paginas'],
|
||||
'tirada' => $tirada,
|
||||
'solapas' => $data['cubierta']['solapasCubierta'] == 0 ? 0 : 1,
|
||||
'lomo_redondo' => $data['cubierta']['lomoRedondo'] == 0 ? 0 : 1,
|
||||
'cabezada' => $data['cubierta']['cabezada'] == 0 ? 0 : 1,
|
||||
'solapas_ancho' => $data['cubierta']['solapasCubierta'] == 0 ? $data['cubierta']['solapasCubierta'] : 0,
|
||||
'solapas_sobrecubierta' => !$data['sobrecubierta'] ? 0 : 1,
|
||||
'solapas_ancho_sobrecubierta' => !$data['sobrecubierta'] ? 0 : $data['sobrecubierta']['solapas'],
|
||||
'solapas' => $data['cubierta']['solapasCubierta'] > 0 ? 1 : 0,
|
||||
'solapas_ancho' => $data['cubierta']['solapasCubierta'] > 0 ? $data['cubierta']['solapasCubierta'] : 0,
|
||||
'solapas_sobrecubierta' => is_null($data['sobrecubierta']) ? 0 : 1,
|
||||
'solapas_ancho_sobrecubierta' => is_null($data['sobrecubierta']) ? 0 : $data['sobrecubierta']['solapas'],
|
||||
'cosido' => $is_cosido,
|
||||
'merma' => $extra_info['merma'],
|
||||
'merma_cubierta' => $extra_info['merma'],
|
||||
'paginasCuadernillo' => $data['paginasCuadernillo'],
|
||||
|
||||
'comp_pos_paginas_color' => $data['interior']['pos_paginas_color'],
|
||||
'paginas_color_consecutivas' => $data['interior']['paginas_color_consecutivas'],
|
||||
'papel_interior_diferente' => $data['interior']['papelInteriorDiferente'],
|
||||
|
||||
'lomo_cubierta' => $extra_info['lomo_cubierta'],
|
||||
'lomo_sobrecubierta' => $extra_info['lomo_sobrecubierta'],
|
||||
|
||||
'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['acabadoCubierta'],
|
||||
'acabado_sobrecubierta_id' => is_null($data['sobrecubierta']) ? 0 : $data['sobrecubierta']['acabado'],
|
||||
|
||||
'comp_tipo_impresion' => $data['isHq'] ? ($data['isColor'] ? 'colorhq' : 'negrohq') : ($data['isColor'] ? 'color' : 'negro'),
|
||||
|
||||
@ -465,7 +444,7 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
'total_margenPercent_servicios' => round($resumen_totales['porcentajeMargenServicios'], 2),
|
||||
'total_coste_envios' => round($resumen_totales['coste_envio'], 2),
|
||||
'total_margen_envios' => round($resumen_totales['margen_envio'], 2),
|
||||
'total_costes' => round($totalCostes, 2),
|
||||
'total_costes' => round($totalCostes, 2),
|
||||
'total_margenes' => round($totalMargenes, 2),
|
||||
|
||||
'total_antes_descuento' => round($totalCostes + $totalMargenes, 2),
|
||||
@ -503,45 +482,29 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
if (is_array($data)) {
|
||||
// -- INTERIOR --
|
||||
// Si hay negro
|
||||
if (intval($data['interior']['paginas']) > intval($data['interior']['paginas_color'])) {
|
||||
if ($data['interior']['paginas'] > $data['interior']['paginas_color']) {
|
||||
|
||||
if ($data['isHq'])
|
||||
$key = 'bnhq';
|
||||
else
|
||||
$key = 'bn';
|
||||
if (array_key_exists('id', $data['interior']['papel_generico'])) {
|
||||
$papel_id = intval($data['interior']['papel_generico']['id']);
|
||||
$gramaje = intval($data['interior']['gramaje']);
|
||||
} else {
|
||||
$papel_id = intval($data['interior']['papel_generico']['negro']['id']);
|
||||
$gramaje = intval($data['interior']['gramaje']['negro']);
|
||||
}
|
||||
|
||||
|
||||
$values[$key] = array(
|
||||
'paginas' => intval($data['interior']['paginas']) - intval(intval($data['interior']['paginas_color'])),
|
||||
'papel_id' => $papel_id,
|
||||
'gramaje' => $gramaje,
|
||||
'paginas' => intval($data['interior']['paginas']) - intval($data['interior']['paginas_color']),
|
||||
'papel_id' => intval($data['interior']['papel_generico']['id']),
|
||||
'gramaje' => intval($data['interior']['gramaje']),
|
||||
);
|
||||
}
|
||||
// Si hay color
|
||||
if (intval($data['interior']['paginas_color']) > 0) {
|
||||
if ($data['interior']['paginas_color'] > 0) {
|
||||
|
||||
if ($data['isHq'])
|
||||
$key = 'colorhq';
|
||||
else
|
||||
$key = 'color';
|
||||
if (array_key_exists('id', $data['interior']['papel_generico'])) {
|
||||
$papel_id = intval($data['interior']['papel_generico']['id']);
|
||||
$gramaje = intval($data['interior']['gramaje']);
|
||||
} else {
|
||||
$papel_id = intval($data['interior']['papel_generico']['color']['id']);
|
||||
$gramaje = intval($data['interior']['gramaje']['color']);
|
||||
}
|
||||
$values[$key] = array(
|
||||
'paginas' => intval(intval($data['interior']['paginas_color'])),
|
||||
'papel_id' => $papel_id,
|
||||
'gramaje' => $gramaje,
|
||||
'paginas' => intval($data['interior']['paginas_color']),
|
||||
'papel_id' => intval($data['interior']['papel_generico']['id']),
|
||||
'gramaje' => intval($data['interior']['gramaje']),
|
||||
);
|
||||
}
|
||||
|
||||
@ -553,7 +516,7 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
);
|
||||
|
||||
// -- SOBRECUBIERTA --
|
||||
if ($data['sobrecubierta']) {
|
||||
if (!is_null($data['sobrecubierta'])) {
|
||||
$values['sobrecubierta'] = array(
|
||||
'papel_id' => intval($data['sobrecubierta']['papel']),
|
||||
'gramaje' => intval($data['sobrecubierta']['gramaje']),
|
||||
@ -579,7 +542,7 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS numero, t1.tipo_impresion_id as tipo, t1.tirada AS unidades, t1.total_aceptado as total, t1.paginas AS paginas,
|
||||
"t1.id AS numero, t1.tipo_impresion_id as tipo, t1.tirada AS unidades, t1.total_aceptado as total, t1.paginas AS paginas,
|
||||
t1.titulo AS titulo, t1.autor AS autor, t1.isbn AS isbn,
|
||||
t1.papel_formato_id AS papel_formato_id, t1.papel_formato_personalizado AS papel_formato_personalizado,
|
||||
t1.papel_formato_ancho AS papel_formato_ancho, t1.papel_formato_alto AS papel_formato_alto,
|
||||
@ -587,7 +550,7 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
t3.codigo AS codigo_encuadernacion,
|
||||
t1.solapas AS solapas_cubierta, CAST(t1.solapas_ancho AS INT) AS solapas_ancho_cubierta,
|
||||
t1.solapas_sobrecubierta AS solapas_sobrecubierta, CAST(t1.solapas_ancho_sobrecubierta AS INT) AS solapas_ancho_sobrecubierta,"
|
||||
);
|
||||
);
|
||||
$builder->join("lg_papel_formato t2", "t1.papel_formato_id = t2.id", "left");
|
||||
$builder->join("tipos_presupuestos t3", "t1.tipo_impresion_id = t3.id", "left");
|
||||
$builder->where("t1.is_deleted", 0);
|
||||
@ -622,7 +585,7 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
);
|
||||
$presupuesto->concepto .= $this->generarConceptoLineasPresupuestoLibro($lineas, $presupuesto);
|
||||
|
||||
$presupuesto = (object) [
|
||||
$presupuesto = (object)[
|
||||
'numero' => $presupuesto->numero,
|
||||
'unidades' => $presupuesto->unidades,
|
||||
'total' => $presupuesto->total,
|
||||
@ -671,8 +634,8 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
->join('presupuesto_manipulados', 'presupuesto_manipulados.presupuesto_id = presupuestos.id', 'left')
|
||||
->join('lg_tarifa_manipulado', 'lg_tarifa_manipulado.id = presupuesto_manipulados.tarifa_manipulado_id', 'left')
|
||||
->where('presupuestos.id', $presupuesto_id);
|
||||
|
||||
$queryExtras = $this->db->table($this->table)
|
||||
|
||||
$queryExtras = $this->db->table($this->table)
|
||||
->select(
|
||||
[
|
||||
'lg_tarifa_preimpresion.id',
|
||||
@ -682,7 +645,7 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
)
|
||||
->join('presupuesto_serviciosExtra', 'presupuesto_serviciosExtra.presupuesto_id = presupuestos.id', 'left')
|
||||
->join('lg_tarifa_preimpresion', 'lg_tarifa_preimpresion.id = presupuesto_serviciosExtra.tarifa_extra_id', 'left')
|
||||
->where('presupuestos.id', $presupuesto_id);
|
||||
->where('presupuestos.id', $presupuesto_id);
|
||||
|
||||
$servicios['acabado'] = $queryAcabado->get()->getResultObject();
|
||||
$servicios['manipulado'] = $queryManipulado->get()->getResultObject();
|
||||
@ -820,5 +783,5 @@ class PresupuestoModel extends \App\Models\BaseModel
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -15,10 +15,11 @@ class PresupuestoServiciosExtraModel extends \App\Models\BaseModel
|
||||
|
||||
const SORTABLE = [
|
||||
0 => "t2.nombre",
|
||||
1 => "t1.precio",
|
||||
1 => "t1.precio_unidad",
|
||||
2 => "t1.precio_total"
|
||||
];
|
||||
|
||||
protected $allowedFields = ["presupuesto_id", "tarifa_extra_id", "precio", "margen"];
|
||||
protected $allowedFields = ["presupuesto_id", "tarifa_extra_id", "precio_total", "precio_unidad", "margen"];
|
||||
protected $returnType = "App\Entities\Presupuestos\PresupuestoServiciosExtraEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
|
||||
Reference in New Issue
Block a user