mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
problema muestra genericos que no
This commit is contained in:
@ -215,6 +215,7 @@ $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('getpapelgenericocliente', 'Papelesgenericos::getPapelGenericoCliente', ['as' => 'getPapelGenericoCliente']);
|
||||
});
|
||||
$routes->resource('papelesgenericos', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Papelesgenericos', 'except' => 'show,new,create,update']);
|
||||
|
||||
@ -228,6 +229,7 @@ $routes->group('papelesimpresion', ['namespace' => 'App\Controllers\Configuracio
|
||||
$routes->post('datatable', 'Papelesimpresion::datatable', ['as' => 'dataTableOfPapelesImpresion']);
|
||||
$routes->post('allmenuitems', 'Papelesimpresion::allItemsSelect', ['as' => 'select2ItemsOfPapelesImpresion']);
|
||||
$routes->post('menuitems', 'Papelesimpresion::menuItems', ['as' => 'menuItemsOfPapelesImpresion']);
|
||||
$routes->get('getgramajecliente', 'Papelesimpresion::getGramajesCliente', ['as' => 'getGramajePresupuestoCliente']);
|
||||
});
|
||||
$routes->resource('papelesimpresion', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Papelesimpresion', 'except' => 'show,new,create,update']);
|
||||
|
||||
|
||||
@ -293,4 +293,25 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function getPapelGenericoCliente()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$tipo = goSanitize($this->request->getGet('tipo'))[0];
|
||||
$cubierta = goSanitize($this->request->getGet('text'))[0];
|
||||
$papel_especial = goSanitize($this->request->getGet('papel_especial'))[0] ?? 0;
|
||||
$menu = $this->model->getPapelGenericoCliente($tipo, $cubierta, $papel_especial);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'papeles' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -444,4 +444,26 @@ class Papelesimpresion extends \App\Controllers\BaseResourceController
|
||||
$ma_pa_model->updateRows($active_values);
|
||||
}
|
||||
}
|
||||
|
||||
public function getGramajesCliente(){
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$papel_generico_id = goSanitize($this->request->getGet('papel'))[0];
|
||||
$tipo = goSanitize($this->request->getGet('tipo'))[0];
|
||||
$cubierta = goSanitize($this->request->getGet('text'))[0];
|
||||
$papel_especial = goSanitize($this->request->getGet('papel_especial'))[0] ?? 0;
|
||||
$menu = $this->model->getGramajePresupuestoCliente($papel_generico_id, $tipo, $cubierta, $papel_especial);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$data = [
|
||||
'gramajes' => $menu,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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(
|
||||
@ -155,30 +157,30 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
||||
->where("t5.is_deleted", 0)
|
||||
->where("t5.tipo", $tipo);
|
||||
|
||||
if($is_cubierta==true){
|
||||
if ($is_cubierta == true) {
|
||||
|
||||
$builder->where("t2.cubierta", 1);
|
||||
$builder->where("t5.uso", 'cubierta');
|
||||
}
|
||||
|
||||
if($is_sobrecubierta==true){
|
||||
if ($is_sobrecubierta == true) {
|
||||
$builder->where("t2.sobrecubierta", 1);
|
||||
$builder->where("t5.uso", 'sobrecubierta');
|
||||
}
|
||||
|
||||
if($is_cubierta==false && $is_sobrecubierta==false){
|
||||
if ($is_cubierta == false && $is_sobrecubierta == false) {
|
||||
$builder->where("t5.uso", 'interior');
|
||||
}
|
||||
|
||||
if($is_guardas==true){
|
||||
if ($is_guardas == true) {
|
||||
$builder->where("t2.guardas", 1);
|
||||
}
|
||||
|
||||
if($rotativa==true){
|
||||
if ($rotativa == true) {
|
||||
$builder->where("t2.rotativa", 1);
|
||||
}
|
||||
|
||||
if($mostrar_cliente!=null){
|
||||
if ($mostrar_cliente != null) {
|
||||
$builder->where("t1.show_in_client", $mostrar_cliente);
|
||||
}
|
||||
|
||||
@ -187,16 +189,16 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
||||
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")
|
||||
@ -219,15 +221,14 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
||||
|
||||
$uso_tarifa = 'interior';
|
||||
|
||||
if($uso == 'bn' || $uso == 'bnhq')
|
||||
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'){
|
||||
else if ($uso == 'cubierta') {
|
||||
$uso_tarifa = 'cubierta';
|
||||
$builder->where("t2.cubierta", 1);
|
||||
}
|
||||
else if ($uso == 'sobrecubierta'){
|
||||
} else if ($uso == 'sobrecubierta') {
|
||||
$uso_tarifa = 'sobrecubierta';
|
||||
$builder->where("t2.sobrecubierta", 1);
|
||||
}
|
||||
@ -239,13 +240,13 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
||||
|
||||
$values = $builder->orderBy("t2.gramaje", "asc")->get()->getResultObject();
|
||||
$id = 1;
|
||||
foreach ($values as $value){
|
||||
foreach ($values as $value) {
|
||||
$value->id = $id;
|
||||
$id++;
|
||||
}
|
||||
$values_array = array_map( function( $value ) {
|
||||
$values_array = array_map(function ($value) {
|
||||
return $value->text;
|
||||
}, $values );
|
||||
}, $values);
|
||||
$unique_values = array_unique($values_array);
|
||||
return array_values(array_intersect_key($values, $unique_values));
|
||||
|
||||
@ -253,7 +254,7 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
||||
|
||||
//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")
|
||||
@ -276,22 +277,20 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
||||
|
||||
$uso_tarifa = 'interior';
|
||||
|
||||
if ($uso == 'cubierta'){
|
||||
if ($uso == 'cubierta') {
|
||||
$uso_tarifa = 'cubierta';
|
||||
$builder->where("t2.cubierta", 1);
|
||||
}
|
||||
else if ($uso == 'sobrecubierta'){
|
||||
} else if ($uso == 'sobrecubierta') {
|
||||
$uso_tarifa = 'sobrecubierta';
|
||||
$builder->where("t2.sobrecubierta", 1);
|
||||
}
|
||||
else{
|
||||
if($tipo == 'negro' || $tipo == 'negrohq')
|
||||
} 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')
|
||||
if ($uso == 'rotativa')
|
||||
$builder->where("t2.rotativa", 1);
|
||||
else
|
||||
$builder->where("t2.rotativa", 0);
|
||||
@ -301,15 +300,69 @@ class PapelGenericoModel extends \App\Models\BaseModel
|
||||
|
||||
$values = $builder->orderBy("t2.gramaje", "asc")->get()->getResultObject();
|
||||
$id = 1;
|
||||
foreach ($values as $value){
|
||||
foreach ($values as $value) {
|
||||
$value->id = $id;
|
||||
$id++;
|
||||
}
|
||||
$values_array = array_map( function( $value ) {
|
||||
$values_array = array_map(function ($value) {
|
||||
return $value->text;
|
||||
}, $values );
|
||||
}, $values);
|
||||
$unique_values = array_unique($values_array);
|
||||
return array_values(array_intersect_key($values, $unique_values));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getPapelGenericoCliente($tipo, $is_cubierta = false, $papel_especial = false)
|
||||
{
|
||||
/*
|
||||
1.-> Tipo 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")
|
||||
->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');
|
||||
|
||||
$builder->groupStart()
|
||||
->where("t2.id IS NOT NULL") // Validar relación con `t2`
|
||||
->orWhere("t4.id IS NOT NULL") // Validar relación con `t4`
|
||||
->groupEnd();
|
||||
|
||||
if ($is_cubierta == true) {
|
||||
|
||||
$builder->where("t2.cubierta", 1);
|
||||
$builder->where("t5.uso", 'cubierta');
|
||||
} else {
|
||||
$builder->where("t5.uso", 'interior');
|
||||
}
|
||||
|
||||
if ($papel_especial == true) {
|
||||
$builder->where("t1.show_in_client_special", 1);
|
||||
}
|
||||
|
||||
$data = $builder->orderBy("t1.nombre", "asc")->get()->getResultObject();
|
||||
//var_dump($this->db->getLastQuery());
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
@ -145,7 +145,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")
|
||||
@ -161,7 +161,7 @@ class PapelImpresionModel extends \App\Models\BaseModel
|
||||
$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){
|
||||
if ($generico_id > 0) {
|
||||
$builder->where("t1.papel_generico_id", $generico_id);
|
||||
}
|
||||
|
||||
@ -182,7 +182,7 @@ 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);
|
||||
@ -191,18 +191,18 @@ class PapelImpresionModel extends \App\Models\BaseModel
|
||||
$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 ";
|
||||
else
|
||||
@ -212,7 +212,7 @@ 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);
|
||||
}
|
||||
@ -229,20 +229,22 @@ 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);
|
||||
@ -250,22 +252,22 @@ class PapelImpresionModel extends \App\Models\BaseModel
|
||||
$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);
|
||||
}
|
||||
|
||||
@ -274,7 +276,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")
|
||||
@ -283,7 +286,8 @@ 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);
|
||||
@ -303,13 +307,13 @@ 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);
|
||||
@ -317,18 +321,21 @@ class PapelImpresionModel extends \App\Models\BaseModel
|
||||
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")
|
||||
@ -339,10 +346,61 @@ class PapelImpresionModel extends \App\Models\BaseModel
|
||||
->where("t2.is_deleted", 0);
|
||||
|
||||
$result = $builder->get()->getResultObject();
|
||||
if(count($result) > 0){
|
||||
if (count($result) > 0) {
|
||||
return $result[0]->code;
|
||||
}
|
||||
else
|
||||
} else
|
||||
return "";
|
||||
}
|
||||
|
||||
public function getGramajePresupuestoCliente($papel_generico_id = -1, $tipo = 'interior', $cubierta = 0, $papel_especial = 0)
|
||||
{
|
||||
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.gramaje AS text"
|
||||
)
|
||||
->join("lg_papel_generico t2", "t2.id = t1.papel_generico_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.isActivo", 1)
|
||||
->where("t1.use_in_client", 1)
|
||||
->where("t2.id", $papel_generico_id)
|
||||
->where("t2.show_in_client", 1)
|
||||
->where("t2.is_deleted", 0)
|
||||
->where("t3.active", 1)
|
||||
->where("t4.is_deleted", 0)
|
||||
->where("t4.tipo", "impresion")
|
||||
->where("t5.is_deleted", 0)
|
||||
->where("t5.tipo", $tipo)
|
||||
->distinct("t1.gramaje");
|
||||
|
||||
if($papel_especial){
|
||||
$builder->where('t2.show_in_client_special');
|
||||
}
|
||||
$uso_tarifa = 'interior';
|
||||
|
||||
if ($cubierta) {
|
||||
$uso_tarifa = 'cubierta';
|
||||
$builder->where("t1.cubierta", 1);
|
||||
} else {
|
||||
if ($tipo == 'negro' || $tipo == 'negrohq')
|
||||
$builder->where("t1.bn", 1);
|
||||
else if ($tipo == 'color' || $tipo == 'colorhq')
|
||||
$builder->where("t1.color", 1);
|
||||
}
|
||||
|
||||
$builder->where("t5.uso", $uso_tarifa);
|
||||
|
||||
|
||||
$values = $builder->orderBy("t1.gramaje", "asc")->get()->getResultObject();
|
||||
foreach ($values as $value) {
|
||||
$value->id = $value->text;
|
||||
}
|
||||
//$query=$this->db->getLastQuery();
|
||||
return $values;
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,41 +42,13 @@
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-sm-8 mb-3 d-flex flex-column align-items-center">
|
||||
<div id="textoPapelInterior" class="col-sm-8 mb-3 d-flex flex-column align-items-center d-none">
|
||||
<h3 class="mb-1 fw-bold"> Papel interior </h3>
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
|
||||
<div id="divPapelInterior" name="div_papel_interior" class="row col-sm-10 mb-5 justify-content-center">
|
||||
|
||||
<div id="offsetBlanco" cod="OFF1" class="calcular-presupuesto d-flex flex-column align-items-center justify-content-center papel-interior imagen-selector image-container">
|
||||
<img class="image-presupuesto" src="<?= site_url("assets/img/presupuestoCliente/offset-blanco.png") ?>" alt="offsetBlanco">
|
||||
<label for="titulo" class="form-label">
|
||||
Offset Blanco
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div id="offsetAhuesado" cod="OFF2" class="calcular-presupuesto d-flex flex-column align-items-center justify-content-center papel-interior imagen-selector image-container">
|
||||
<img class="image-presupuesto" src="<?= site_url("assets/img/presupuestoCliente/offset-ahuesado.png") ?>" alt="offsetAhuesado">
|
||||
<label for="titulo" class="form-label">
|
||||
Offset Ahuesado
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div id="offsetAhuesadoVolumen" cod="OFF4" class="calcular-presupuesto d-flex flex-column align-items-center justify-content-center papel-interior imagen-selector image-container">
|
||||
<img class="image-presupuesto" src="<?= site_url("assets/img/presupuestoCliente/offset-ahuesado-volumen.png") ?>" alt="offsetAhuesadoVolumen">
|
||||
<label for="titulo" class="form-label">
|
||||
Offset Ahuesado Volumen
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div id="estucadoMate" cod="EST2" class="calcular-presupuesto d-flex flex-column align-items-center justify-content-center papel-interior imagen-selector image-container">
|
||||
<img class="image-presupuesto" src="<?= site_url("assets/img/presupuestoCliente/estucado-mate.png") ?>" alt="estucadoMate">
|
||||
<label for="titulo" class="form-label">
|
||||
Estucado Mate
|
||||
</label>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="divGramajeInterior" name="div_gramaje_interior" class="row col-sm-10 mb-3 justify-content-center d-none">
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
<?= view("themes/_commonPartialsBs/_modalInput") ?>
|
||||
<?= view("themes/vuexy/components/modals/modalDireccion") ?>
|
||||
|
||||
<div class="container-xxl flex-grow-1 container-p-y">
|
||||
<div id="mainContainer" class="container-xxl flex-grow-1 container-p-y">
|
||||
|
||||
<div class="col-12">
|
||||
|
||||
|
||||
8
httpdocs/assets/js/safekat/common/common.js
Normal file
8
httpdocs/assets/js/safekat/common/common.js
Normal file
@ -0,0 +1,8 @@
|
||||
export function getToken()
|
||||
{
|
||||
const scriptUrl = new URL(import.meta.url);
|
||||
const params = new URLSearchParams(scriptUrl.search);
|
||||
|
||||
const paramsObject = Object.fromEntries(params.entries());
|
||||
return paramsObject.token;
|
||||
}
|
||||
@ -1,14 +1,22 @@
|
||||
import { getToken } from '../../common/common.js';
|
||||
import Ajax from '../../components/ajax.js';
|
||||
|
||||
class DisenioInterior {
|
||||
|
||||
constructor(domItem, wizardForm, validatorStepper) {
|
||||
|
||||
this.domItem = domItem;
|
||||
|
||||
this.csrf_token = getToken();
|
||||
this.csrf_hash = $('#mainContainer').find('input[name="' + this.csrf_token + '"]').val();
|
||||
|
||||
this.wizardStep = wizardForm.querySelector('#interior-libro');
|
||||
this.validatorStepper = validatorStepper;
|
||||
this.allowNext = true;
|
||||
|
||||
this.disenioInterior = this.domItem.find(".disenio-interior");
|
||||
this.divPapelInterior = this.domItem.find("#divPapelInterior");
|
||||
this.textoPapelInterior = this.domItem.find("#textoPapelInterior");
|
||||
this.divPapelInteriorColor = this.domItem.find("#divPapelInteriorColor");
|
||||
this.divGramajeInterior = this.domItem.find("#divGramajeInterior");
|
||||
this.papelInterior = this.domItem.find(".papel-interior");
|
||||
@ -18,11 +26,6 @@ class DisenioInterior {
|
||||
this.colorEstandar = this.domItem.find("#colorEstandar");
|
||||
this.colorPremium = this.domItem.find("#colorPremium");
|
||||
|
||||
this.offsetBlanco = this.domItem.find("#offsetBlanco");
|
||||
this.offsetAhuesado = this.domItem.find("#offsetAhuesado");
|
||||
this.offsetAhuesadoVolumen = this.domItem.find("#offsetAhuesadoVolumen");
|
||||
this.estucadoMate = this.domItem.find("#estucadoMate");
|
||||
|
||||
this.gramaje = this.domItem.find(".check-interior-gramaje");
|
||||
this.gramaje70 = this.domItem.find("#interiorGramaje70");
|
||||
this.gramaje80 = this.domItem.find("#interiorGramaje80");
|
||||
@ -41,11 +44,6 @@ class DisenioInterior {
|
||||
this.colorEstandar_color = this.domItem.find("#colorEstandarColor");
|
||||
this.colorPremium_color = this.domItem.find("#colorPremiumColor");
|
||||
|
||||
this.offsetBlanco_color = this.domItem.find("#offsetBlancoColor");
|
||||
this.offsetAhuesado_color = this.domItem.find("#offsetAhuesadoColor");
|
||||
this.offsetAhuesadoVolumen_color = this.domItem.find("#offsetAhuesadoVolumenColor");
|
||||
this.estucadoMate_color = this.domItem.find("#estucadoMateColor");
|
||||
|
||||
this.gramaje_color = this.domItem.find(".check-interior-color-gramaje");
|
||||
this.gramaje70_color = this.domItem.find("#interiorGramaje70Color");
|
||||
this.gramaje80_color = this.domItem.find("#interiorGramaje80Color");
|
||||
@ -66,6 +64,7 @@ class DisenioInterior {
|
||||
|
||||
this.initValidation();
|
||||
|
||||
|
||||
// Creamos un nuevo observador que detecta cambios en los atributos
|
||||
this.observer = new MutationObserver(mutations => {
|
||||
mutations.forEach(mutation => {
|
||||
@ -87,7 +86,6 @@ class DisenioInterior {
|
||||
|
||||
// Eventos
|
||||
this.disenioInterior.on('click', this.#handleDisenioInterior.bind(this));
|
||||
this.papelInterior.on('click', this.#handlePapelInterior.bind(this));
|
||||
this.disenioInterior_color.on('click', this.#handleDisenioInterior.bind(this));
|
||||
this.papelInterior_color.on('click', this.#handlePapelInterior.bind(this));
|
||||
|
||||
@ -96,16 +94,8 @@ class DisenioInterior {
|
||||
this.observer.observe(this.negroPremium[0], { attributes: true });
|
||||
this.observer.observe(this.colorEstandar[0], { attributes: true });
|
||||
this.observer.observe(this.colorPremium[0], { attributes: true });
|
||||
this.observer.observe(this.offsetBlanco[0], { attributes: true });
|
||||
this.observer.observe(this.offsetAhuesado[0], { attributes: true });
|
||||
this.observer.observe(this.offsetAhuesadoVolumen[0], { attributes: true });
|
||||
this.observer.observe(this.estucadoMate[0], { attributes: true });
|
||||
this.observer.observe(this.colorEstandar_color[0], { attributes: true });
|
||||
this.observer.observe(this.colorPremium_color[0], { attributes: true });
|
||||
this.observer.observe(this.offsetBlanco_color[0], { attributes: true });
|
||||
this.observer.observe(this.offsetAhuesado_color[0], { attributes: true });
|
||||
this.observer.observe(this.offsetAhuesadoVolumen_color[0], { attributes: true });
|
||||
this.observer.observe(this.estucadoMate_color[0], { attributes: true });
|
||||
|
||||
this.checksGramaje.each(function () {
|
||||
|
||||
@ -114,10 +104,69 @@ class DisenioInterior {
|
||||
self.#handleClickGramaje(customOptionEL);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
updatePapeles(papeles) {
|
||||
|
||||
const context = this;
|
||||
let tipo = 'negro';
|
||||
if (this.colorEstandar.hasClass('selected'))
|
||||
tipo = 'color';
|
||||
else if (this.negroPremium.hasClass('selected'))
|
||||
tipo = 'negrohq';
|
||||
else if (this.colorPremium.hasClass('selected'))
|
||||
tipo = 'colorhq';
|
||||
|
||||
new Ajax('/papelesgenericos/getpapelgenericocliente',
|
||||
{
|
||||
[this.csrf_token]: this.csrf_hash,
|
||||
tipo: tipo,
|
||||
cubierta: 0,
|
||||
},
|
||||
{},
|
||||
this.fillPapeles.bind(context),
|
||||
(response) => { console.log(response); }
|
||||
).get();
|
||||
}
|
||||
|
||||
fillPapeles(response) {
|
||||
|
||||
|
||||
this.divPapelInterior.empty()
|
||||
|
||||
if(response.papeles.length > 0){
|
||||
this.textoPapelInterior.removeClass('d-none');
|
||||
}
|
||||
else{
|
||||
this.textoPapelInterior.addClass("d-none");
|
||||
}
|
||||
|
||||
response.papeles.forEach(papel => {
|
||||
var container = $('<div>', {
|
||||
class: 'custom-selector d-flex flex-column align-items-center justify-content-center'
|
||||
});
|
||||
|
||||
var radioButton = $('<input>', {
|
||||
type: 'radio', // Tipo de input
|
||||
name: 'calcular-presupuesto papel-interior',
|
||||
id: papel.id, // ID único
|
||||
value: 'option1' // Valor del radio button
|
||||
});
|
||||
|
||||
// Crear una etiqueta para el radio button
|
||||
var label = $('<label>', {
|
||||
for: papel.id,
|
||||
text: papel.nombre
|
||||
});
|
||||
|
||||
radioButton.on('click', this.#handlePapelInterior.bind(this));
|
||||
|
||||
container.append(radioButton).append(label);
|
||||
$('#divPapelInterior').append(container);
|
||||
});
|
||||
}
|
||||
|
||||
cargarDatos(datos, papelInteriorDiferente) {
|
||||
|
||||
if (papelInteriorDiferente) {
|
||||
@ -151,8 +200,6 @@ class DisenioInterior {
|
||||
$(`#divGramajeInteriorColor .gramaje-interior-color input[data-value="${datos.color.gramaje}"]`).trigger('click');
|
||||
}, 0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
if (datos.color) {
|
||||
@ -182,9 +229,8 @@ class DisenioInterior {
|
||||
$(`#divGramajeInterior .gramaje-interior input[data-value="${datos.negro.gramaje}"]`).trigger('click');
|
||||
}, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.updatePapeles();
|
||||
|
||||
}
|
||||
|
||||
@ -403,7 +449,7 @@ class DisenioInterior {
|
||||
this.rl_tipo_interior.removeClass('d-none');
|
||||
|
||||
const HQ = this.getIsHq();
|
||||
const color = $("#paginasColor").val()>0?true:false;
|
||||
const color = $("#paginasColor").val() > 0 ? true : false;
|
||||
const papelInterior = this.getPapel(true);
|
||||
const gramajeInterior = this.getGramaje();
|
||||
if (HQ != null && papelInterior != null && gramajeInterior != null) {
|
||||
@ -537,13 +583,40 @@ class DisenioInterior {
|
||||
|
||||
// Para recalcular el presupuesto
|
||||
element.trigger('change');
|
||||
|
||||
this.updatePapeles();
|
||||
}
|
||||
|
||||
|
||||
#handlePapelInterior(event) {
|
||||
const context = this;
|
||||
|
||||
// Accede al ID del elemento que disparó el evento
|
||||
const element = $(event.target);
|
||||
const papel = element[0].id;
|
||||
|
||||
let tipo = 'negro';
|
||||
if (this.colorEstandar.hasClass('selected'))
|
||||
tipo = 'color';
|
||||
else if (this.negroPremium.hasClass('selected'))
|
||||
tipo = 'negrohq';
|
||||
else if (this.colorPremium.hasClass('selected'))
|
||||
tipo = 'colorhq';
|
||||
|
||||
new Ajax('/papelesimpresion/getgramajecliente',
|
||||
{
|
||||
[this.csrf_token]: this.csrf_hash,
|
||||
papel: papel,
|
||||
tipo: tipo,
|
||||
cubierta: 0,
|
||||
},
|
||||
{},
|
||||
this.fillGramajes.bind(context),
|
||||
(response) => { console.log(response); }
|
||||
).get();
|
||||
|
||||
|
||||
/*
|
||||
let class2Find = '.papel-interior';
|
||||
if (element[0].closest('.image-container').id.includes('Color'))
|
||||
class2Find = '.papel-interior-color';
|
||||
@ -569,13 +642,56 @@ class DisenioInterior {
|
||||
}
|
||||
|
||||
// Para recalcular el presupuesto
|
||||
element.trigger('change');
|
||||
element.trigger('change');*/
|
||||
}
|
||||
|
||||
fillGramajes(response) {
|
||||
|
||||
|
||||
this.divGramajeInterior.empty()
|
||||
let showGramaje = false;
|
||||
|
||||
if(response.gramajes.length <= 0){
|
||||
return;
|
||||
}
|
||||
|
||||
response.gramajes.forEach(gramaje => {
|
||||
var container = $('<div>', {
|
||||
class: 'custom-selector d-flex flex-column align-items-center justify-content-center gramaje-interior'
|
||||
});
|
||||
|
||||
var radioButton = $('<input>', {
|
||||
type: 'radio', // Tipo de input
|
||||
name: 'calcular-presupuesto',
|
||||
id: 'gramaje_' + gramaje.id, // ID único
|
||||
value: 'option1' // Valor del radio button
|
||||
});
|
||||
|
||||
// Crear una etiqueta para el radio button
|
||||
var label = $('<label>', {
|
||||
for: "gramaje_" + gramaje.id,
|
||||
text: gramaje.text
|
||||
});
|
||||
|
||||
|
||||
container.append(radioButton).append(label);
|
||||
$('#divGramajeInterior').append(container);
|
||||
|
||||
showGramaje = true;
|
||||
});
|
||||
|
||||
if ($("#divGramajeInterior").hasClass("d-none") && showGramaje) {
|
||||
$("#divGramajeInterior").removeClass("d-none");
|
||||
}
|
||||
else if (!showGramaje) {
|
||||
$("#divGramajeInterior").addClass("d-none");
|
||||
}
|
||||
}
|
||||
|
||||
#handleUpdateGramaje() {
|
||||
|
||||
let showGramaje = false;
|
||||
|
||||
/*
|
||||
$(".check-interior-gramaje ").prop("checked", false);
|
||||
$(".check-interior-color-gramaje ").prop("checked", false);
|
||||
|
||||
@ -688,7 +804,7 @@ class DisenioInterior {
|
||||
}
|
||||
else if (!showGramaje) {
|
||||
$("#divGramajeInterior").addClass("d-none");
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -17,14 +17,17 @@
|
||||
|
||||
/* Pseudo-elemento que muestra el tick */
|
||||
.image-container.selected::after {
|
||||
content: '✔'; /* Símbolo de tick */
|
||||
content: '✔';
|
||||
/* Símbolo de tick */
|
||||
position: absolute;
|
||||
top: calc(50% + 5px);
|
||||
left: calc(100%/2 + 65px); /* Mueve 75px a la derecha fuera del contenedor */
|
||||
left: calc(100%/2 + 65px);
|
||||
/* Mueve 75px a la derecha fuera del contenedor */
|
||||
font-size: 50px;
|
||||
font-weight: bold;
|
||||
color: green;
|
||||
background-color: rgba(255, 255, 255, 0); /* Fondo transparente */
|
||||
background-color: rgba(255, 255, 255, 0);
|
||||
/* Fondo transparente */
|
||||
border-radius: 100%;
|
||||
padding: 5px;
|
||||
}
|
||||
@ -474,14 +477,72 @@
|
||||
}
|
||||
}
|
||||
|
||||
.texto-resumen-lateral{
|
||||
.texto-resumen-lateral {
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
.num-input{
|
||||
.num-input {
|
||||
min-width: 100px;
|
||||
}
|
||||
|
||||
.div-num-input{
|
||||
.div-num-input {
|
||||
min-width: 105px;
|
||||
}
|
||||
|
||||
|
||||
.custom-selector{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
position: relative;
|
||||
max-width: 300px;
|
||||
}
|
||||
|
||||
/* Asegurar el tamaño uniforme del contenedor */
|
||||
.custom-selector {
|
||||
display: flex !important;
|
||||
flex-direction: column !important;
|
||||
justify-content: center !important;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
margin-bottom: 5px;
|
||||
position: relative;
|
||||
width: 250px; /* Fija el ancho */
|
||||
height: 80px; /* Fija el alto */
|
||||
padding: 0.5em;
|
||||
box-sizing: border-box; /* Incluir padding en el tamaño total */
|
||||
border: 3px solid transparent; /* Evitar deformaciones por borde */
|
||||
}
|
||||
|
||||
/* Ocultar los radio buttons */
|
||||
.custom-selector input[type="radio"] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Estilo para el label */
|
||||
.custom-selector label {
|
||||
position: relative;
|
||||
color: black;
|
||||
font-family: "Poppins", sans-serif;
|
||||
cursor: pointer;
|
||||
display: grid;
|
||||
align-items: center;
|
||||
width: 100%; /* Llenar todo el contenedor */
|
||||
height: 100%; /* Llenar todo el contenedor */
|
||||
flex: 1; /* Tomar el espacio disponible */
|
||||
gap: 0.8em;
|
||||
border: 1px solid #dbdade;
|
||||
padding: 0.5em 1em;
|
||||
border-radius: 0.5em;
|
||||
text-align: center; /* Texto alineado a la izquierda */
|
||||
}
|
||||
|
||||
|
||||
/* Cambiar el estilo del label cuando está seleccionado */
|
||||
.custom-selector input[type="radio"]:checked + label {
|
||||
background-color: #7367f0;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user