diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php
index f1ffb00e..44581391 100644
--- a/ci4/app/Config/Routes.php
+++ b/ci4/app/Config/Routes.php
@@ -216,6 +216,7 @@ $routes->group('papelesgenericos', ['namespace' => 'App\Controllers\Configuracio
$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 4df4e462..dfcef7ac 100755
--- a/ci4/app/Controllers/Configuracion/Papelesgenericos.php
+++ b/ci4/app/Controllers/Configuracion/Papelesgenericos.php
@@ -318,11 +318,6 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
}
-
- /******************************************
- *
- * AUQIIIIII
- */
public function selectPapelEspecial()
{
@@ -330,21 +325,16 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
$tipo = goSanitize($this->request->getGet('tipo'))[0];
$cubierta = goSanitize($this->request->getGet('cubierta'))[0] ?? 0;
- $items = $this->model->getPapelCliente($tipo, $cubierta, null, true);
-
- $query = $this->model->builder()->select(
- [
- "id",
- "nombre as name"
- ]
- )->where("deleted_at", null);
- if ($this->request->getGet("q")) {
- $query->groupStart()
- ->orLike("clientes.nombre", $this->request->getGet("q"))
- ->groupEnd();
- }
- return $this->response->setJSON($query->get()->getResultObject());
+ $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/Models/Configuracion/PapelGenericoModel.php b/ci4/app/Models/Configuracion/PapelGenericoModel.php
index a1362d15..5f1ba92f 100755
--- a/ci4/app/Models/Configuracion/PapelGenericoModel.php
+++ b/ci4/app/Models/Configuracion/PapelGenericoModel.php
@@ -324,52 +324,51 @@ class PapelGenericoModel extends \App\Models\BaseModel
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")
+ ->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{
+ ->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")
+ ->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');
+ ->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) {
@@ -400,7 +399,10 @@ class PapelGenericoModel extends \App\Models\BaseModel
}
- $data = $builder->orderBy("t1.nombre", "asc")->get()->getResultObject();
+ 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/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">