mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando2
This commit is contained in:
@ -37,6 +37,7 @@ $routes->group('configuracion', ['namespace' => 'App\Controllers\Configuracion']
|
||||
$routes->post('menuitems', 'Papelesgenericos::menuItems', ['as' => 'menuItemsOfPapelesGenericos']);
|
||||
$routes->get('getpapelcliente', 'Papelesgenericos::getPapelCliente', ['as' => 'getPapelCliente']);
|
||||
$routes->get('selectpapelespecial', 'Papelesgenericos::selectPapelEspecial', ['as' => 'selectPapelEspecial']);
|
||||
$routes->get('gettipopapel', 'Papelesgenericos::getTipoPapelCliente');
|
||||
});
|
||||
|
||||
/* Papeles impresion */
|
||||
|
||||
@ -301,6 +301,53 @@ class Papelesgenericos extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getTipoPapelCliente(){
|
||||
|
||||
if($this->request->isAJAX()) {
|
||||
|
||||
$data_input = $this->request->getGet();
|
||||
$result = $this->papelService->getTiposPalelGenerico((object)$data_input);
|
||||
/*
|
||||
|
||||
$tirada = goSanitize($this->request->getGet('tirada'))[0] ?? null;
|
||||
$POD = null;
|
||||
if ($tirada != null) {
|
||||
$POD_value = model('App\Models\Configuracion\ConfigVariableModel')->getVariable('POD')->value;
|
||||
if (intval($tirada) <= intval($POD_value)) {
|
||||
$POD = true;
|
||||
} else {
|
||||
$POD = false;
|
||||
}
|
||||
}
|
||||
$tipo = goSanitize($this->request->getGet('tipo'))[0];
|
||||
$selected_papel = goSanitize($this->request->getGet('papel'))[0] ?? null;
|
||||
$cubierta = goSanitize($this->request->getGet('cubierta'))[0] ?? 0;
|
||||
$tapa_dura = goSanitize($this->request->getGet('tapa_dura'))[0] ?? null;
|
||||
$sobrecubierta = goSanitize($this->request->getGet('sobrecubierta'))[0] ?? 0;
|
||||
$guardas = goSanitize($this->request->getGet('guardas'))[0] ?? 0;
|
||||
|
||||
$ancho = floatval($this->request->getGet('ancho') ?? 0);
|
||||
$alto = floatval($this->request->getGet('alto') ?? 0);
|
||||
$solapas = floatval($this->request->getGet('solapas') ?? 0);
|
||||
$lomo = floatval($this->request->getGet('lomo') ?? 0);
|
||||
|
||||
$anchoLibro = $ancho;
|
||||
|
||||
if(intval($cubierta) == 1 || intval($sobrecubierta) == 1){
|
||||
$anchoLibro = 2 * $ancho + 2 * $solapas + $lomo;
|
||||
}
|
||||
|
||||
$menu = $this->model->getPapelCliente($tipo, $cubierta, $sobrecubierta, $guardas, $selected_papel, $tapa_dura, false, $POD, $anchoLibro, $alto, $tirada);
|
||||
*/
|
||||
|
||||
return $this->respond($result);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getPapelCliente()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
@ -18,5 +18,57 @@ class TipoPapelGenericoModel extends \App\Models\BaseModel
|
||||
];
|
||||
protected $returnType = "App\Entities\Configuracion\TipoPapelGenerico";
|
||||
|
||||
public function getTiposPapel($data)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id as id, t1.clave 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_generico t2", "t2.tipo_papel_generico_id = t1.id", "inner")
|
||||
->join("lg_papel_impresion t3", "t3.papel_generico_id = t2.id", "inner")
|
||||
->join("lg_maquina_papel_impresion t4", "t4.papel_impresion_id = t3.id", "inner")
|
||||
->join("lg_maquinas t5", "t4.maquina_id = t5.id", "inner")
|
||||
->join("lg_maquinas_tarifas_impresion t6", "t6.maquina_id = t5.id", "inner")
|
||||
|
||||
->where("t2.is_deleted", 0)
|
||||
->where("t2.show_in_client", 1)
|
||||
->where("t3.is_deleted", 0)
|
||||
->where("t3.isActivo", 1)
|
||||
->where("t3.use_in_client", 1)
|
||||
->where("t4.active", 1)
|
||||
->where("t5.is_deleted", 0)
|
||||
->where("t5.min <= ", $data['tirada'] ?? 0)
|
||||
->where("t5.max >= ", $data['tirada'] ?? 0)
|
||||
->where("t5.tipo", "impresion")
|
||||
->where("t6.is_deleted", 0)
|
||||
->where("t6.tipo", $data['tipo'] ?? null)
|
||||
->distinct('t1.id');
|
||||
|
||||
// Validación adicional para asegurar que t1.id esté presente en las combinaciones con t3.active = 1
|
||||
$builder->whereIn("t2.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);
|
||||
});
|
||||
|
||||
$builder->groupStart()
|
||||
->groupStart()
|
||||
->where("t5.ancho_impresion >", $data['ancho'] ?? 0)
|
||||
->where("t5.alto_impresion >", $data['alto'] ?? 0)
|
||||
->groupEnd()
|
||||
->orGroupStart()
|
||||
->where("t5.ancho_impresion >", $data['alto'] ?? 0)
|
||||
->where("t5.alto_impresion >", $data['ancho'] ?? 0)
|
||||
->groupEnd()
|
||||
->orGroupStart()
|
||||
->where("t5.ancho_impresion >", $data['alto'] ?? 0)
|
||||
->where("t5.is_rotativa", 1)
|
||||
->groupEnd()
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -4,14 +4,17 @@ namespace App\Services;
|
||||
|
||||
use CodeIgniter\Config\BaseService;
|
||||
use App\Models\Configuracion\TipoPapelGenericoModel;
|
||||
use App\Models\Configuracion\PapelGenericoModel;
|
||||
|
||||
class PapelService extends BaseService
|
||||
{
|
||||
protected TipoPapelGenericoModel $tipoPapelGenericoModel;
|
||||
protected PapelGenericoModel $papelGenericoModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->tipoPapelGenericoModel = model(TipoPapelGenericoModel::class);
|
||||
$this->papelGenericoModel = model(PapelGenericoModel::class);
|
||||
}
|
||||
|
||||
public function getTipoPapelGenerico()
|
||||
@ -24,4 +27,27 @@ class PapelService extends BaseService
|
||||
|
||||
return $tipoPapelGenericoList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtencion de los tipos de papel genérico dependiendo del uso
|
||||
* @param object $data
|
||||
* @return array
|
||||
*/
|
||||
public function getTiposPalelGenerico($data){
|
||||
|
||||
if(!isset($data) || empty($data)){
|
||||
return [];
|
||||
}
|
||||
|
||||
return $this->papelGenericoModel->where('tipo_papel_generico_id !=', null)->findAll();
|
||||
/*
|
||||
$values = $this->papelGenericoModel->where('uso', $uso)->findAll();
|
||||
$tipoPapelGenericoList = [];
|
||||
foreach ($values as $value) {
|
||||
$tipoPapelGenericoList[$value->id] = lang('PapelGenerico.' . $value->clave);
|
||||
}
|
||||
|
||||
return $tipoPapelGenericoList;
|
||||
*/
|
||||
}
|
||||
}
|
||||
@ -111,6 +111,29 @@ class DisenioInterior {
|
||||
this.disenioInterior.on('click', this.#handleDisenioInterior.bind(this));
|
||||
this.disenioInterior_color.on('click', this.#handleDisenioInterior.bind(this));
|
||||
|
||||
// test
|
||||
$(document).on('keydown', function (e) {
|
||||
if (e.ctrlKey && e.key === '.') {
|
||||
e.preventDefault(); // Evita comportamiento por defecto si es necesario
|
||||
console.log('Se pulsó Control + .');
|
||||
new Ajax('/configuracion/papelesgenericos/gettipopapel',
|
||||
{
|
||||
[self.csrf_token]: self.csrf_hash,
|
||||
tirada: $('#tirada').val(),
|
||||
tipo: () => self.getTipoImpresion(),
|
||||
ancho: self.presupuestoCliente.datosGenerales.getDimensionLibro().ancho,
|
||||
alto: self.presupuestoCliente.datosGenerales.getDimensionLibro().alto,
|
||||
solapas: 0,
|
||||
lomo: 0,
|
||||
cubierta: 0,
|
||||
},
|
||||
{},
|
||||
(response) => { console.log(response); },
|
||||
(response) => { console.error(response); }
|
||||
).get();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user