diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php
index b9a084cf..44581391 100644
--- a/ci4/app/Config/Routes.php
+++ b/ci4/app/Config/Routes.php
@@ -215,6 +215,8 @@ $routes->group('papelesgenericos', ['namespace' => 'App\Controllers\Configuracio
$routes->post('datatable', 'Papelesgenericos::datatable', ['as' => 'dataTableOfPapelesGenericos']);
$routes->post('allmenuitems', 'Papelesgenericos::allItemsSelect', ['as' => 'select2ItemsOfPapelesGenericos']);
$routes->post('menuitems', 'Papelesgenericos::menuItems', ['as' => 'menuItemsOfPapelesGenericos']);
+ $routes->get('getpapelcliente', 'Papelesgenericos::getPapelCliente', ['as' => 'getPapelCliente']);
+ $routes->get('selectpapelespecial', 'Papelesgenericos::selectPapelEspecial', ['as' => 'selectPapelEspecial']);
});
$routes->resource('papelesgenericos', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Papelesgenericos', 'except' => 'show,new,create,update']);
diff --git a/ci4/app/Controllers/Clientes/Clientedirecciones.php b/ci4/app/Controllers/Clientes/Clientedirecciones.php
index 872eeeca..2979bd10 100755
--- a/ci4/app/Controllers/Clientes/Clientedirecciones.php
+++ b/ci4/app/Controllers/Clientes/Clientedirecciones.php
@@ -234,6 +234,10 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController
try {
$model = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
$resourceData = $model->getDireccion($id);
+ if(count($resourceData) > 0){
+ $resourceData[0]->direccionId = $id;
+ }
+
$response = (object)[
'error' => false,
'data' => $resourceData
diff --git a/ci4/app/Controllers/Configuracion/Papelesgenericos.php b/ci4/app/Controllers/Configuracion/Papelesgenericos.php
index af7cfa22..dfcef7ac 100755
--- a/ci4/app/Controllers/Configuracion/Papelesgenericos.php
+++ b/ci4/app/Controllers/Configuracion/Papelesgenericos.php
@@ -293,4 +293,50 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
return $this->failUnauthorized('Invalid request', 403);
}
}
+
+ public function getPapelCliente()
+ {
+ if ($this->request->isAJAX()) {
+
+ $tipo = goSanitize($this->request->getGet('tipo'))[0];
+ $selected_papel = goSanitize($this->request->getGet('papel'))[0] ?? null;
+ $cubierta = goSanitize($this->request->getGet('cubierta'))[0] ?? 0;
+ $menu = $this->model->getPapelCliente($tipo, $cubierta, $selected_papel, false);
+ $menu2 = $this->model->getPapelCliente($tipo, $cubierta, $selected_papel, true);
+
+ $newTokenHash = csrf_hash();
+ $csrfTokenName = csrf_token();
+ $data = [
+ 'papeles' => $menu,
+ 'papeles_especiales' => $menu2,
+ $csrfTokenName => $newTokenHash
+ ];
+ return $this->respond($data);
+ } else {
+ return $this->failUnauthorized('Invalid request', 403);
+ }
+ }
+
+
+ public function selectPapelEspecial()
+ {
+
+ if ($this->request->isAJAX()) {
+
+ $tipo = goSanitize($this->request->getGet('tipo'))[0];
+ $cubierta = goSanitize($this->request->getGet('cubierta'))[0] ?? 0;
+
+ $items = $this->model->getPapelCliente($tipo, $cubierta, null, true);
+ $items = array_map(function ($item) {
+ return [
+ 'id' => $item->id,
+ 'name' => $item->nombre
+ ];
+ }, $items);
+ return $this->response->setJSON($items);
+
+ } else {
+ return $this->failUnauthorized('Invalid request', 403);
+ }
+ }
}
diff --git a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php
index 58310480..5012bda2 100755
--- a/ci4/app/Controllers/Presupuestos/Presupuestocliente.php
+++ b/ci4/app/Controllers/Presupuestos/Presupuestocliente.php
@@ -303,12 +303,12 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$lomoRedondo = $cubierta['lomoRedondo'] ?? 0;
if ($papelInteriorDiferente) {
- $papel['negro'] = $modelPapelGenerico->getIdFromCode($interior['papelInterior']['negro']);
- $papel['color'] = $modelPapelGenerico->getIdFromCode($interior['papelInterior']['color']);
+ $papel['negro'] = $modelPapelGenerico->where('id', $interior['papelInterior']['negro'])->first()->toArray();
+ $papel['color'] = $modelPapelGenerico->where('id', $interior['papelInterior']['color'])->first()->toArray();
$gramaje['negro'] = intval($interior['gramajeInterior']['negro']);
$gramaje['color'] = intval($interior['gramajeInterior']['color']);
} else {
- $papel = $modelPapelGenerico->getIdFromCode($interior['papelInterior']);
+ $papel = $modelPapelGenerico->where('id', $interior['papelInterior'])->first()->toArray();
$gramaje = intval($interior['gramajeInterior']);
}
// Interior
@@ -464,7 +464,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
return $this->respond($return_data);
} catch (Exception $e) {
- return $this->failServerError($e->getMessage());
+ return $this->failServerError($e->getMessage() . ' - ' . $e->getFile() . ' - ' . $e->getLine());
}
} else {
return $this->failUnauthorized('Invalid request', 403);
@@ -673,12 +673,12 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$tipo_impresion_id = $this->getTipoImpresion($tipo, $cubierta['tipoCubierta']);
if ($papelInteriorDiferente) {
- $papel['negro'] = $modelPapelGenerico->getIdFromCode($interior['papelInterior']['negro']);
- $papel['color'] = $modelPapelGenerico->getIdFromCode($interior['papelInterior']['color']);
+ $papel['negro'] = $modelPapelGenerico->where('id', $interior['papelInterior']['negro'])->first()->toArray();
+ $papel['color'] = $modelPapelGenerico->where('id', $interior['papelInterior']['color'])->first()->toArray();
$gramaje['negro'] = intval($interior['gramajeInterior']['negro']);
$gramaje['color'] = intval($interior['gramajeInterior']['color']);
} else {
- $papel = $modelPapelGenerico->getIdFromCode($interior['papelInterior']);
+ $papel = $modelPapelGenerico->where('id', $interior['papelInterior'])->first()->toArray();
$gramaje = intval($interior['gramajeInterior']);
}
// Interior
@@ -1288,7 +1288,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
$coste = 0;
$margen = 0;
- if ($data > 0) {
+ if (count($data) > 0) {
$peso_envio = round(floatval($peso * $unidades / 1000.0)); // peso libro * unidades y se pasa a kilogramos
$tarifas_envio = $modelTarifaEnvio->getTarifaEnvio($data[0]->pais_id, $data[0]->cp, $peso_envio, $entregaPieCalle ? 'palets' : 'cajas');
for ($i = 0; $i < count($tarifas_envio); $i++) {
@@ -2300,13 +2300,16 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
if ($linea->tipo == 'lp_bn' || $linea->tipo == 'lp_bnhq' || $linea->tipo == 'lp_rot_bn') {
$return_data['interior']['negro']['tipo'] = $linea->tipo == 'lp_bn' || $linea->tipo == 'lp_rot_bn' ? 'negroEstandar' : 'negroPremium';
$return_data['interior']['negro']['papel'] = $modelPapelGenerico->getCodeFromId($linea->papel_id);
+ $return_data['interior']['negro']['papel']['id'] = $linea->papel_id;
$return_data['interior']['negro']['gramaje'] = $linea->gramaje;
} else if ($linea->tipo == 'lp_color' || $linea->tipo == 'lp_colorhq' || $linea->tipo == 'lp_rot_color') {
$return_data['interior']['color']['tipo'] = $linea->tipo == 'lp_color' || $linea->tipo == 'lp_rot_color' ? 'colorEstandar' : 'colorPremium';
$return_data['interior']['color']['papel'] = $modelPapelGenerico->getCodeFromId($linea->papel_id);
+ $return_data['interior']['color']['papel']['id'] = $linea->papel_id;
$return_data['interior']['color']['gramaje'] = $linea->gramaje;
} else if ($linea->tipo == 'lp_cubierta') {
$return_data['cubierta']['papel'] = $modelPapelGenerico->getCodeFromId($linea->papel_id);
+ $return_data['cubierta']['papel']['id'] = $linea->papel_id;
$return_data['cubierta']['gramaje'] = $linea->gramaje;
$return_data['cubierta']['paginas'] = $linea->paginas;
} else if ($linea->tipo == 'lp_sobrecubierta') {
diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php
index 6290d962..1fb887c2 100755
--- a/ci4/app/Language/es/Presupuestos.php
+++ b/ci4/app/Language/es/Presupuestos.php
@@ -256,6 +256,7 @@ return [
// Placeholders
'formatoLibro' => "Formato libro",
'selectCliente' => "Seleccione cliente",
+ 'selectPapel' => "Seleccione papel",
// Preview
diff --git a/ci4/app/Models/Configuracion/PapelGenericoModel.php b/ci4/app/Models/Configuracion/PapelGenericoModel.php
index 7cd2ca73..5f1ba92f 100755
--- a/ci4/app/Models/Configuracion/PapelGenericoModel.php
+++ b/ci4/app/Models/Configuracion/PapelGenericoModel.php
@@ -19,7 +19,7 @@ class PapelGenericoModel extends \App\Models\BaseModel
1 => "t1.code",
2 => "t1.code_ot",
3 => "t1.show_in_client",
- 3 => "t1.show_in_client_special",
+ 4 => "t1.show_in_client_special",
];
protected $allowedFields = ["nombre", "code", "code_ot", "show_in_client", "show_in_client_special", "deleted_at", "is_deleted"];
@@ -63,7 +63,8 @@ class PapelGenericoModel extends \App\Models\BaseModel
];
- public function getIdFromCode(string $code=""){
+ public function getIdFromCode(string $code = "")
+ {
$builder = $this->db
->table($this->table . " t1")
->select(
@@ -78,7 +79,8 @@ class PapelGenericoModel extends \App\Models\BaseModel
}
- public function getCodeFromId($id=0){
+ public function getCodeFromId($id = 0)
+ {
$builder = $this->db
->table($this->table . " t1")
->select(
@@ -113,16 +115,16 @@ class PapelGenericoModel extends \App\Models\BaseModel
return empty($search)
? $builder
: $builder
- ->groupStart()
- ->like("t1.id", $search)
- ->orLike("t1.nombre", $search)
- ->orLike("t1.code", $search)
- ->orLike("t1.code_ot", $search)
- ->orLike("t1.id", $search)
- ->orLike("t1.nombre", $search)
- ->orLike("t1.code", $search)
- ->orLike("t1.code_ot", $search)
- ->groupEnd();
+ ->groupStart()
+ ->like("t1.id", $search)
+ ->orLike("t1.nombre", $search)
+ ->orLike("t1.code", $search)
+ ->orLike("t1.code_ot", $search)
+ ->orLike("t1.id", $search)
+ ->orLike("t1.nombre", $search)
+ ->orLike("t1.code", $search)
+ ->orLike("t1.code_ot", $search)
+ ->groupEnd();
}
@@ -130,9 +132,9 @@ class PapelGenericoModel extends \App\Models\BaseModel
{
/*
1.-> Tipo impresion
- 2.-> Maquina
- 3.-> Papeles impresion asociados a esa maquina
- 4.-> papeles genericos que aparecen en esos papeles impresion
+ 2.-> Maquina
+ 3.-> Papeles impresion asociados a esa maquina
+ 4.-> papeles genericos que aparecen en esos papeles impresion
*/
$builder = $this->db
->table($this->table . " t1")
@@ -155,48 +157,48 @@ class PapelGenericoModel extends \App\Models\BaseModel
->where("t5.is_deleted", 0)
->where("t5.tipo", $tipo);
- if($is_cubierta==true){
-
- $builder->where("t2.cubierta", 1);
- $builder->where("t5.uso", 'cubierta');
- }
-
- if($is_sobrecubierta==true){
- $builder->where("t2.sobrecubierta", 1);
- $builder->where("t5.uso", 'sobrecubierta');
- }
+ if ($is_cubierta == true) {
- if($is_cubierta==false && $is_sobrecubierta==false){
- $builder->where("t5.uso", 'interior');
- }
+ $builder->where("t2.cubierta", 1);
+ $builder->where("t5.uso", 'cubierta');
+ }
- if($is_guardas==true){
- $builder->where("t2.guardas", 1);
- }
+ if ($is_sobrecubierta == true) {
+ $builder->where("t2.sobrecubierta", 1);
+ $builder->where("t5.uso", 'sobrecubierta');
+ }
- if($rotativa==true){
- $builder->where("t2.rotativa", 1);
- }
+ if ($is_cubierta == false && $is_sobrecubierta == false) {
+ $builder->where("t5.uso", 'interior');
+ }
- if($mostrar_cliente!=null){
- $builder->where("t1.show_in_client", $mostrar_cliente);
- }
+ if ($is_guardas == true) {
+ $builder->where("t2.guardas", 1);
+ }
+
+ if ($rotativa == true) {
+ $builder->where("t2.rotativa", 1);
+ }
+
+ if ($mostrar_cliente != null) {
+ $builder->where("t1.show_in_client", $mostrar_cliente);
+ }
$data = $builder->orderBy("t1.nombre", "asc")->get()->getResultObject();
//var_dump($this->db->getLastQuery());
return $data;
}
- public function getGramajeComparador(string $papel_generico_nombre="", $uso="", $ejemplares=0)
+ public function getGramajeComparador(string $papel_generico_nombre = "", $uso = "", $ejemplares = 0)
{
- if($uso == 'cubierta' || $uso == 'sobrecubierta')
+ if ($uso == 'cubierta' || $uso == 'sobrecubierta')
$tipo = 'colorhq';
else
- $tipo=$uso; // color y colorhq valen para los dos
- if($uso == 'bn')
- $tipo="negro";
- if($uso == 'bnhq')
- $tipo="negrohq";
+ $tipo = $uso; // color y colorhq valen para los dos
+ if ($uso == 'bn')
+ $tipo = "negro";
+ if ($uso == 'bnhq')
+ $tipo = "negrohq";
$builder = $this->db
->table($this->table . " t1")
@@ -207,7 +209,7 @@ class PapelGenericoModel extends \App\Models\BaseModel
->join("lg_maquina_papel_impresion t3", "t3.papel_impresion_id = t2.id", "left")
->join("lg_maquinas t4", "t3.maquina_id = t4.id", "left")
->join("lg_maquinas_tarifas_impresion t5", "t5.maquina_id = t4.id", "left")
-
+
->where("t1.is_deleted", 0)
->where("t2.is_deleted", 0)
->where("t2.isActivo", 1)
@@ -216,44 +218,43 @@ class PapelGenericoModel extends \App\Models\BaseModel
->where("t4.tipo", "impresion")
->where("t5.tipo", $tipo)
->where("t1.nombre", $papel_generico_nombre);
-
- $uso_tarifa = 'interior';
- if($uso == 'bn' || $uso == 'bnhq')
- $builder->where("t2.bn", 1);
- else if ($uso == 'color' || $uso == 'colorhq')
- $builder->where("t2.color", 1);
- else if ($uso == 'cubierta'){
- $uso_tarifa = 'cubierta';
- $builder->where("t2.cubierta", 1);
- }
- else if ($uso == 'sobrecubierta'){
- $uso_tarifa = 'sobrecubierta';
- $builder->where("t2.sobrecubierta", 1);
- }
+ $uso_tarifa = 'interior';
- $builder->where("t5.uso", $uso_tarifa);
+ if ($uso == 'bn' || $uso == 'bnhq')
+ $builder->where("t2.bn", 1);
+ else if ($uso == 'color' || $uso == 'colorhq')
+ $builder->where("t2.color", 1);
+ else if ($uso == 'cubierta') {
+ $uso_tarifa = 'cubierta';
+ $builder->where("t2.cubierta", 1);
+ } else if ($uso == 'sobrecubierta') {
+ $uso_tarifa = 'sobrecubierta';
+ $builder->where("t2.sobrecubierta", 1);
+ }
- $builder->where("t4.min <=", $ejemplares);
- $builder->where("t4.max >=", $ejemplares);
-
- $values = $builder->orderBy("t2.gramaje", "asc")->get()->getResultObject();
- $id = 1;
- foreach ($values as $value){
- $value->id = $id;
- $id++;
- }
- $values_array = array_map( function( $value ) {
- return $value->text;
- }, $values );
- $unique_values = array_unique($values_array);
- return array_values(array_intersect_key($values, $unique_values));
+ $builder->where("t5.uso", $uso_tarifa);
+
+ $builder->where("t4.min <=", $ejemplares);
+ $builder->where("t4.max >=", $ejemplares);
+
+ $values = $builder->orderBy("t2.gramaje", "asc")->get()->getResultObject();
+ $id = 1;
+ foreach ($values as $value) {
+ $value->id = $id;
+ $id++;
+ }
+ $values_array = array_map(function ($value) {
+ return $value->text;
+ }, $values);
+ $unique_values = array_unique($values_array);
+ return array_values(array_intersect_key($values, $unique_values));
}
//tipo: negro, negrohq, color, colorhq
//uso: interior, rotativa, cubierta, sobrecubierta
- public function getGramajeLineasPresupuesto($papel_generico_id=0, $tipo="", $uso="")
+ public function getGramajeLineasPresupuesto($papel_generico_id = 0, $tipo = "", $uso = "")
{
$builder = $this->db
->table($this->table . " t1")
@@ -264,7 +265,7 @@ class PapelGenericoModel extends \App\Models\BaseModel
->join("lg_maquina_papel_impresion t3", "t3.papel_impresion_id = t2.id", "left")
->join("lg_maquinas t4", "t3.maquina_id = t4.id", "left")
->join("lg_maquinas_tarifas_impresion t5", "t5.maquina_id = t4.id", "left")
-
+
->where("t1.is_deleted", 0)
->where("t2.is_deleted", 0)
->where("t2.isActivo", 1)
@@ -274,42 +275,135 @@ class PapelGenericoModel extends \App\Models\BaseModel
->where("t5.tipo", $tipo)
->where("t1.id", $papel_generico_id);
- $uso_tarifa = 'interior';
+ $uso_tarifa = 'interior';
- if ($uso == 'cubierta'){
- $uso_tarifa = 'cubierta';
- $builder->where("t2.cubierta", 1);
- }
- else if ($uso == 'sobrecubierta'){
- $uso_tarifa = 'sobrecubierta';
- $builder->where("t2.sobrecubierta", 1);
- }
- else{
- if($tipo == 'negro' || $tipo == 'negrohq')
- $builder->where("t2.bn", 1);
- else if ($tipo == 'color' || $tipo == 'colorhq')
- $builder->where("t2.color", 1);
- }
-
- if($uso=='rotativa')
- $builder->where("t2.rotativa", 1);
- else
- $builder->where("t2.rotativa", 0);
+ if ($uso == 'cubierta') {
+ $uso_tarifa = 'cubierta';
+ $builder->where("t2.cubierta", 1);
+ } else if ($uso == 'sobrecubierta') {
+ $uso_tarifa = 'sobrecubierta';
+ $builder->where("t2.sobrecubierta", 1);
+ } else {
+ if ($tipo == 'negro' || $tipo == 'negrohq')
+ $builder->where("t2.bn", 1);
+ else if ($tipo == 'color' || $tipo == 'colorhq')
+ $builder->where("t2.color", 1);
+ }
- $builder->where("t5.uso", $uso_tarifa);
-
-
- $values = $builder->orderBy("t2.gramaje", "asc")->get()->getResultObject();
- $id = 1;
- foreach ($values as $value){
- $value->id = $id;
- $id++;
- }
- $values_array = array_map( function( $value ) {
- return $value->text;
- }, $values );
- $unique_values = array_unique($values_array);
- return array_values(array_intersect_key($values, $unique_values));
+ if ($uso == 'rotativa')
+ $builder->where("t2.rotativa", 1);
+ else
+ $builder->where("t2.rotativa", 0);
+
+ $builder->where("t5.uso", $uso_tarifa);
+
+
+ $values = $builder->orderBy("t2.gramaje", "asc")->get()->getResultObject();
+ $id = 1;
+ foreach ($values as $value) {
+ $value->id = $id;
+ $id++;
+ }
+ $values_array = array_map(function ($value) {
+ return $value->text;
+ }, $values);
+ $unique_values = array_unique($values_array);
+ return array_values(array_intersect_key($values, $unique_values));
}
+
+
+ public function getPapelCliente($tipo, $is_cubierta = false, $selected_papel_id = null, $papel_especial = false)
+ {
+ /*
+ 1.-> Tipo impresion
+ 2.-> Maquina
+ 3.-> Papeles impresion asociados a esa maquina
+ 4.-> papeles genericos que aparecen en esos papeles impresion
+ */
+
+ if ($selected_papel_id != null) {
+ $builder = $this->db
+ ->table($this->table . " t1")
+ ->select(
+ "t2.gramaje as gramaje",
+ // for debug, t2.nombre AS nombre_papel_impresion, t4.nombre AS maquina_nombre, t5.uso AS tarifa_uso, t5.tipo AS tarifa_tipo"
+ )
+ ->join("lg_papel_impresion t2", "t2.papel_generico_id = t1.id", "inner")
+ ->join("lg_maquina_papel_impresion t3", "t3.papel_impresion_id = t2.id", "inner")
+ ->join("lg_maquinas t4", "t3.maquina_id = t4.id", "inner")
+ ->join("lg_maquinas_tarifas_impresion t5", "t5.maquina_id = t4.id", "inner")
+
+ ->where("t1.id", $selected_papel_id)
+ ->where("t1.is_deleted", 0)
+ ->where("t1.show_in_client", 1)
+ ->where("t2.is_deleted", 0)
+ ->where("t2.isActivo", 1)
+ ->where("t2.use_in_client", 1)
+ ->where("t3.active", 1)
+ ->where("t4.is_deleted", 0)
+ ->where("t4.tipo", "impresion")
+ ->where("t5.is_deleted", 0)
+ ->where("t5.tipo", $tipo)
+ ->distinct('t2.gramaje');
+ } else {
+ $builder = $this->db
+ ->table($this->table . " t1")
+ ->select(
+ "t1.id as id, t1.nombre AS nombre",
+ // for debug, t2.nombre AS nombre_papel_impresion, t4.nombre AS maquina_nombre, t5.uso AS tarifa_uso, t5.tipo AS tarifa_tipo"
+ )
+ ->join("lg_papel_impresion t2", "t2.papel_generico_id = t1.id", "inner")
+ ->join("lg_maquina_papel_impresion t3", "t3.papel_impresion_id = t2.id", "inner")
+ ->join("lg_maquinas t4", "t3.maquina_id = t4.id", "inner")
+ ->join("lg_maquinas_tarifas_impresion t5", "t5.maquina_id = t4.id", "inner")
+
+ ->where("t1.is_deleted", 0)
+ ->where("t1.show_in_client", 1)
+ ->where("t2.is_deleted", 0)
+ ->where("t2.isActivo", 1)
+ ->where("t2.use_in_client", 1)
+ ->where("t3.active", 1)
+ ->where("t4.is_deleted", 0)
+ ->where("t4.tipo", "impresion")
+ ->where("t5.is_deleted", 0)
+ ->where("t5.tipo", $tipo)
+ ->distinct('t1.id');
+ }
+ // Validación adicional para asegurar que t1.id esté presente en las combinaciones con t3.active = 1
+ $builder->whereIn("t1.id", function ($subQuery) {
+ $subQuery->select("t1_inner.id")
+ ->from("lg_papel_generico t1_inner")
+ ->join("lg_papel_impresion t2_inner", "t2_inner.papel_generico_id = t1_inner.id", "inner")
+ ->join("lg_maquina_papel_impresion t3_inner", "t3_inner.papel_impresion_id = t2_inner.id", "inner")
+ ->where("t3_inner.active", 1);
+ });
+
+ if ($is_cubierta == true) {
+ $builder->where("t2.cubierta", 1);
+ $builder->where("t5.uso", 'cubierta');
+ } else {
+ $builder->where("t5.uso", 'interior');
+ if ($tipo == 'negro' || $tipo == 'negrohq')
+ $builder->where("t2.bn", 1);
+ else if ($tipo == 'color' || $tipo == 'colorhq')
+ $builder->where("t2.color", 1);
+ }
+
+ if ($papel_especial == true) {
+ $builder->where("t1.show_in_client_special", 1);
+ }
+
+ if ($tipo == 'colorhq' || $tipo == 'negrohq') {
+ $builder->where("t2.rotativa", 0);
+ }
+
+
+ if ($selected_papel_id != null)
+ $data = $builder->orderBy("t2.gramaje", "asc")->get()->getResultObject();
+ else
+ $data = $builder->orderBy("t1.nombre", "asc")->get()->getResultObject();
+ //$query = $this->db->getLastQuery();
+ return $data;
+ }
}
diff --git a/ci4/app/Models/Configuracion/PapelImpresionModel.php b/ci4/app/Models/Configuracion/PapelImpresionModel.php
index 9f4f3669..d16a7232 100755
--- a/ci4/app/Models/Configuracion/PapelImpresionModel.php
+++ b/ci4/app/Models/Configuracion/PapelImpresionModel.php
@@ -143,7 +143,7 @@ class PapelImpresionModel extends \App\Models\BaseModel
*
* @return \CodeIgniter\Database\BaseBuilder
*/
- public function getResource(string $search = "", $generico_id=-1)
+ public function getResource(string $search = "", $generico_id = -1)
{
$builder = $this->db
->table($this->table . " t1")
@@ -155,12 +155,12 @@ class PapelImpresionModel extends \App\Models\BaseModel
t1.isActivo AS isActivo, t2.nombre AS papel_generico_id,
t1.use_in_client AS use_in_client"
);
-
+
$builder->join("lg_papel_generico t2", "t1.papel_generico_id = t2.id", "left");
$builder->where("t1.is_deleted", 0);
$builder->where("t1.isActivo", 1);
- if($generico_id>0){
- $builder->where("t1.papel_generico_id", $generico_id);
+ if ($generico_id > 0) {
+ $builder->where("t1.papel_generico_id", $generico_id);
}
return empty($search)
@@ -180,29 +180,29 @@ class PapelImpresionModel extends \App\Models\BaseModel
$builder = $this->db
->table($this->table . " t1")
->select(
- "'".$maquina_id."'". " as maquina_id, t1.id AS papel_impresion_id, '0' as active"
+ "'" . $maquina_id . "'" . " as maquina_id, t1.id AS papel_impresion_id, '0' as active"
);
-
+
$builder->where("t1.is_deleted", 0);
$builder->where("t1.isActivo", 1);
$isFirst = true;
$where_str = "";
//Si hay tarifas...
- if (!empty($tarifas)){
- foreach ($tarifas as $tarifa){
+ if (!empty($tarifas)) {
+ foreach ($tarifas as $tarifa) {
if (!$isFirst)
$where_str .= ' OR ';
- else{
+ else {
$isFirst = false;
}
if ($tarifa->uso == 'cubierta')
$where_str .= "`t1`.`cubierta`=1";
else if ($tarifa->uso == 'sobrecubierta')
$where_str .= "`t1`.`sobrecubierta`=1";
- else{
+ else {
if ($tarifa->tipo == 'negro' || $tarifa->tipo == 'negrohq')
- $where_str .= "`t1`.`bn`=1 ";
+ $where_str .= "`t1`.`bn`=1 ";
else
$where_str .= "`t1`.`color`=1 ";
}
@@ -210,11 +210,11 @@ class PapelImpresionModel extends \App\Models\BaseModel
$builder->where($where_str);
}
// si no hay tarifas no hay que devolver nada
- else{
+ else {
// Se pone una condicion que no se puede dar
$builder->where("t1.bn", 2);
}
-
+
return $builder;
}
@@ -227,43 +227,45 @@ class PapelImpresionModel extends \App\Models\BaseModel
*
* @return [type]
*/
- public function getIdPapelesImpresionForPresupuesto($papel_generico_id = null, $gramaje = null, $options=[]){
+ public function getIdPapelesImpresionForPresupuesto($papel_generico_id = null, $gramaje = null, $options = [])
+ {
$bn = array_key_exists('bn', $options) ? $options['bn'] : null;
- $color = array_key_exists('color', $options)? $options['color'] : null;
- $cubierta = array_key_exists('cubierta', $options)? $options['cubierta'] : null;
- $sobrecubierta = array_key_exists('sobrecubierta', $options)? $options['sobrecubierta'] : null;
- $guardas = array_key_exists('guardas', $options)? $options['guardas'] : null;
- $rotativa = array_key_exists('rotativa', $options)? $options['rotativa'] : null;
+ $color = array_key_exists('color', $options) ? $options['color'] : null;
+ $cubierta = array_key_exists('cubierta', $options) ? $options['cubierta'] : null;
+ $sobrecubierta = array_key_exists('sobrecubierta', $options) ? $options['sobrecubierta'] : null;
+ $guardas = array_key_exists('guardas', $options) ? $options['guardas'] : null;
+ $rotativa = array_key_exists('rotativa', $options) ? $options['rotativa'] : null;
$builder = $this->db
->table($this->table . " t1")
->distinct("t1.id")
->select(
"t1.id AS id, t1.nombre AS nombre, t1.papel_generico_id AS papel_generico_id,
- t1.gramaje as gramaje, t1.espesor AS espesor, t1.precio_tonelada AS precio_tonelada, t1.rotativa AS rotativa");
-
+ t1.gramaje as gramaje, t1.espesor AS espesor, t1.precio_tonelada AS precio_tonelada, t1.rotativa AS rotativa"
+ );
+
$builder->where("t1.is_deleted", 0);
$builder->where("t1.isActivo", 1);
$builder->where("t1.papel_generico_id", $papel_generico_id);
$builder->where("t1.gramaje", $gramaje);
-
- if(!is_null($bn)){
+
+ if (!is_null($bn)) {
$builder->where("t1.bn", $bn);
}
- if(!is_null($color)){
+ if (!is_null($color)) {
$builder->where("t1.color", $color);
}
- if(!is_null($cubierta)){
+ if (!is_null($cubierta)) {
$builder->where("t1.cubierta", $cubierta);
}
- if(!is_null($sobrecubierta)){
+ if (!is_null($sobrecubierta)) {
$builder->where("t1.sobrecubierta", $sobrecubierta);
}
- if(!is_null($guardas)){
+ if (!is_null($guardas)) {
$builder->where("t1.guardas", $guardas);
}
- if(!is_null($rotativa)){
+ if (!is_null($rotativa)) {
$builder->where("t1.rotativa", $rotativa);
}
@@ -272,7 +274,8 @@ class PapelImpresionModel extends \App\Models\BaseModel
//tipo: negro, negrohq, color, colorhq
//uso: interior, rotativa, cubierta, sobrecubierta
- public function getPapelesImpresionForMenu($papel_generico = null, $gramaje = null, $tipo = null, $uso=""){
+ public function getPapelesImpresionForMenu($papel_generico = null, $gramaje = null, $tipo = null, $uso = "")
+ {
$builder = $this->db
->table($this->table . " t1")
->distinct("t1.id")
@@ -281,8 +284,9 @@ class PapelImpresionModel extends \App\Models\BaseModel
->join("lg_maquinas t4", "t3.maquina_id = t4.id", "left")
->join("lg_maquinas_tarifas_impresion t5", "t4.id = t5.maquina_id", "left")
->select(
- "t1.id AS id, t1.nombre AS text");
-
+ "t1.id AS id, t1.nombre AS text"
+ );
+
$builder->where("t1.is_deleted", 0);
$builder->where("t1.isActivo", 1);
$builder->where("t2.is_deleted", 0);
@@ -291,7 +295,7 @@ class PapelImpresionModel extends \App\Models\BaseModel
$builder->where("t4.tipo", 'impresion');
$builder->where("t5.is_deleted", 0);
$builder->where("t5.tipo", $tipo);
-
+
$builder->where("t2.id", $papel_generico);
$builder->where("t1.gramaje", $gramaje);
@@ -301,32 +305,35 @@ class PapelImpresionModel extends \App\Models\BaseModel
$builder->where("t1.sobrecubierta", 1);
else if ($uso == 'guardas')
$builder->where("t1.guardas", 1);
- else{
- if($tipo == 'negro' || $tipo == 'negrohq')
+ else {
+ if ($tipo == 'negro' || $tipo == 'negrohq')
$builder->where("t1.bn", 1);
else if ($tipo == 'color' || $tipo == 'colorhq')
$builder->where("t1.color", 1);
}
- if($uso=='rotativa')
+ if ($uso == 'rotativa')
$builder->where("t1.rotativa", 1);
else
$builder->where("t1.rotativa", 0);
-
+
return $builder->orderBy("t1.id", "asc")->get()->getResultObject();
}
- public function getNombre($id){
+ public function getNombre($id)
+ {
$builder = $this->db
->table($this->table . " t1")
->select(
- "t1.nombre AS text");
-
+ "t1.nombre AS text"
+ );
+
$builder->where("t1.id", $id);
return $builder->orderBy("t1.id", "asc")->get()->getResultObject();
}
- public function getPapelGenericoCode($papel_id = 0){
+ public function getPapelGenericoCode($papel_id = 0)
+ {
$builder = $this->db
->table($this->table . " t1")
->select("t2.code AS code")
@@ -335,12 +342,13 @@ class PapelImpresionModel extends \App\Models\BaseModel
->where("t1.is_deleted", 0)
->where("t1.isActivo", 1)
->where("t2.is_deleted", 0);
-
+
$result = $builder->get()->getResultObject();
- if(count($result) > 0){
+ if (count($result) > 0) {
return $result[0]->code;
- }
- else
+ } else
return "";
}
+
+
}
diff --git a/ci4/app/Services/PresupuestoClienteService.php b/ci4/app/Services/PresupuestoClienteService.php
index 25a3a42c..ea59622c 100644
--- a/ci4/app/Services/PresupuestoClienteService.php
+++ b/ci4/app/Services/PresupuestoClienteService.php
@@ -25,19 +25,19 @@ class PresupuestoClienteService extends BaseService
$total_plana = -1;
$hay_plana = false;
if ($data['isColor']) {
- if ($data['datosPedido']->paginas == $data['paginas_color']){
- if(count($plana[1]) > 2)
- $total_plana += floatval($plana[1]['total_impresion']);
- else
- return -1;
- }
-
- elseif (count($plana) > 0) {
- if (count($plana[0]) > 2 && count($plana[1]) > 2) {
- $total_plana = 0.0;
- foreach ($plana as $linea) {
- if (count($linea) > 0)
- $total_plana += floatval($linea['total_impresion']);
+ if (count($plana) > 0) {
+ if ($data['datosPedido']->paginas == $data['paginas_color']) {
+ if (count($plana[1]) > 2)
+ $total_plana += floatval($plana[1]['total_impresion']);
+ else
+ return -1;
+ } else {
+ if (count($plana[0]) > 2 && count($plana[1]) > 2) {
+ $total_plana = 0.0;
+ foreach ($plana as $linea) {
+ if (count($linea) > 0)
+ $total_plana += floatval($linea['total_impresion']);
+ }
}
}
}
diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_disenioCubierta.php b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_disenioCubierta.php
index a489c6a6..5850e258 100644
--- a/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_disenioCubierta.php
+++ b/ci4/app/Views/themes/vuexy/form/presupuestos/cliente/items/_disenioCubierta.php
@@ -36,7 +36,7 @@

"
+ src="= site_url("assets/img/presupuestoCliente/tapa-dura-lomo-redondo.jpg") ?>"
alt="TapaDuraLomoRedondo">