mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en lineas presupuesto eventos
This commit is contained in:
@ -585,6 +585,9 @@ $routes->group('presupuestoadmin', ['namespace' => 'App\Controllers\Presupuestos
|
||||
$routes->post('comparadorguardas', 'Presupuestoadmin::obtenerComparadorGuardas');
|
||||
$routes->get('papelgenerico', 'Presupuestoadmin::getPapelGenerico');
|
||||
$routes->get('papelgramaje', 'Presupuestoadmin::getGramaje');
|
||||
$routes->get('papelimpresion', 'Presupuestoadmin::getPapelImpresion');
|
||||
$routes->get('maquinas', 'Presupuestoadmin::getMaquinas');
|
||||
$routes->post('getlinea', 'Presupuestoadmin::getLineaPresupuesto');
|
||||
});
|
||||
$routes->resource('presupuestoadmin', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Presupuestoadmin', 'except' => 'show,new,create,update']);
|
||||
|
||||
|
||||
@ -481,6 +481,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
$data['lsc'] = $presupuesto->lomo_sobrecubierta;
|
||||
$data['tipo_impresion'] = $presupuesto->tipo_impresion_id;
|
||||
$data['cosido'] = $presupuesto->cosido;
|
||||
$data['POD'] = $this->getPOD();
|
||||
|
||||
$data['datosGenerales']['id'] = $presupuesto->id;
|
||||
$data['datosGenerales']['state'] = intval($presupuesto->estado_id);
|
||||
@ -623,8 +624,8 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
$papel_generico = $this->request->getPost('papel_generico');
|
||||
$gramaje = $this->request->getPost('gramaje');
|
||||
$paginas_color = $this->request->getPost('paginas_color');
|
||||
$isColor = $this->request->getPost('isColor');
|
||||
$isHq = $this->request->getPost('isHq');
|
||||
$isColor = $this->request->getPost('isColor')?1:0;
|
||||
$isHq = $this->request->getPost('isHq')?1:0;
|
||||
$tipo_impresion_id = $this->request->getPost('tipo_impresion_id');
|
||||
$uso = $this->request->getPost('uso');
|
||||
|
||||
@ -867,7 +868,28 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
endif;
|
||||
endforeach;
|
||||
|
||||
}
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResource("", $tipo_impresion_id)->countAllResults(),
|
||||
$this->model->getResource($search, $tipo_impresion_id)->countAllResults()
|
||||
));
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getLineaPresupuesto()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$reqData = $this->request->getPost();
|
||||
|
||||
$type = $reqData['type'] ?? null;
|
||||
// por defecto, se deja cosido tapa blanda por ahora JJO
|
||||
$tipo_impresion_id = $reqData['tipo_impresion_id'] ?? 4;
|
||||
|
||||
$isColor = $reqData['color'] ?? false;
|
||||
$isHq = $reqData['hq'] ?? false;
|
||||
@ -1000,13 +1022,7 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
];
|
||||
|
||||
return $this->respond($data);
|
||||
}
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResource("", $tipo_impresion_id)->countAllResults(),
|
||||
$this->model->getResource($search, $tipo_impresion_id)->countAllResults()
|
||||
));
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
@ -1502,6 +1518,132 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
|
||||
|
||||
public function getPapelImpresion()
|
||||
{
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$papel_generico_id = $this->request->getGet('papel_generico');
|
||||
$gramaje = $this->request->getGet('gramaje');
|
||||
|
||||
$tipo_impresion_id = $this->request->getGet("tipo_impresion");
|
||||
$tapa_dura = model('App\Models\Configuracion\TipoPresupuestoModel')->get_isTapaDura(intval($tipo_impresion_id));
|
||||
|
||||
$tipo = $this->request->getGet("tipo");
|
||||
|
||||
$uso = $this->request->getGet("uso") ?? 'interior';
|
||||
|
||||
$model = model('App\Models\Configuracion\PapelImpresionModel');
|
||||
$query = $model->getPapelesImpresionForMenu(
|
||||
$papel_generico_id,
|
||||
$gramaje,
|
||||
$tipo,
|
||||
$uso,
|
||||
$tapa_dura,
|
||||
false
|
||||
);
|
||||
if ($this->request->getGet("q")) {
|
||||
$query->groupStart()
|
||||
->orLike("lg_papel_impresion.nombre", $this->request->getGet("q"))
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
return $this->response->setJSON($query->orderBy("t1.nombre", "asc")->get()->getResultObject());
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getMaquinas()
|
||||
{
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$ancho = $this->request->getGet('ancho');
|
||||
$alto = $this->request->getGet('alto');
|
||||
$tirada = $this->request->getGet('tirada');
|
||||
$merma = $this->request->getGet('merma');
|
||||
$tipo_impresion_id = $this->request->getGet('tipo_impresion');
|
||||
$isCosido = (new TipoPresupuestoModel())->get_isCosido($tipo_impresion_id);
|
||||
$papel_impresion_id = $this->request->getGet('papel_impresion');
|
||||
$tarifa_tipo = $this->request->getGet("tarifa_tipo"); // negro, color, negrohq, colorhq
|
||||
$uso_tarifa = $this->request->getGet("uso_tarifa") ?? 'interior'; // interior, cubierta, sobrecubierta
|
||||
$is_rotativa = $this->request->getGet('is_rotativa') ?? 0;
|
||||
$lomo_redondo = $this->request->getGet('lomo_redondo');
|
||||
$lomo = $this->request->getGet('lomo');
|
||||
$solapas = $this->request->getGet('solapas');
|
||||
$solapas_ancho = $this->request->getGet('solapas_ancho');
|
||||
|
||||
$model = model('App\Models\Configuracion\MaquinaModel');
|
||||
$query = $model->getMaquinaImpresionForPresupuesto(
|
||||
$is_rotativa,
|
||||
$tarifa_tipo,
|
||||
$uso_tarifa,
|
||||
intval($tirada) + intval($merma),
|
||||
$papel_impresion_id
|
||||
);
|
||||
if ($this->request->getGet("q")) {
|
||||
$query->groupStart()
|
||||
->orLike("lg_maquinas.nombre", $this->request->getGet("q"))
|
||||
->groupEnd();
|
||||
}
|
||||
$data = $query->orderBy("t1.nombre", "asc")->get()->getResultObject();
|
||||
|
||||
$query = $model->db->getLastQuery();
|
||||
$datosPedido = ((object) array(
|
||||
'ancho' => $ancho,
|
||||
'alto' => $alto,
|
||||
'isCosido' => $isCosido,
|
||||
'lomo' => $lomo,
|
||||
'solapas' => $solapas,
|
||||
'solapas_ancho' => $solapas_ancho,
|
||||
));
|
||||
|
||||
for ($i = 0; $i < count($data); $i++) {
|
||||
|
||||
if ($is_rotativa) {
|
||||
|
||||
$has_error = true;
|
||||
for ($f = 0; $f < 2; $f++) {
|
||||
|
||||
$parametrosRotativa = (object) array(
|
||||
'a_favor_fibra' => $f,
|
||||
);
|
||||
$values = [];
|
||||
[$values['ancho'], $values['alto']] = PresupuestoService::calculoDimForma($datosPedido, $parametrosRotativa);
|
||||
|
||||
$factor_anchura = round($data[$i]->ancho_impresion / $values['ancho'], 2);
|
||||
|
||||
if (floor($factor_anchura) != 0) {
|
||||
$has_error = false;
|
||||
}
|
||||
}
|
||||
if ($has_error) {
|
||||
unset($data[$i]);
|
||||
}
|
||||
} else {
|
||||
|
||||
if ($uso_tarifa != 'interior') {
|
||||
$datosPedido->anchoExteriores = PresupuestoService::getAnchoTotalExteriores($uso_tarifa, $tipo_impresion_id, $datosPedido, $data[$i]->maquina_id, $lomo_redondo);
|
||||
$datosPedido->altoExteriores = PresupuestoService::getAltoTotalExteriores($uso_tarifa, $tipo_impresion_id, $datosPedido);
|
||||
}
|
||||
|
||||
$ancho_calculo = ($uso_tarifa == 'cubierta' || $uso_tarifa == 'sobrecubierta') ? $datosPedido->anchoExteriores : $datosPedido->ancho;
|
||||
$alto_calculo = ($uso_tarifa == 'cubierta' || $uso_tarifa == 'sobrecubierta') ? $datosPedido->altoExteriores : $datosPedido->alto;
|
||||
$formas = PresupuestoService::getNumFormasPlana($uso_tarifa, $data[$i], $ancho_calculo, $alto_calculo, $datosPedido->isCosido);
|
||||
if ($formas['num_formas']['posicion_formas'] == 'n/a') {
|
||||
unset($data[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->response->setJSON($data);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected function getServiciosPreimpresion()
|
||||
|
||||
@ -330,7 +330,7 @@ class MaquinaModel extends \App\Models\BaseModel
|
||||
->table($this->table . " t1")
|
||||
->distinct('t1.id')
|
||||
->select(
|
||||
"t1.id AS maquina_id, t1.nombre AS maquina, t1.ancho_impresion AS ancho_impresion,
|
||||
"t1.id AS id, t1.id AS maquina_id, t1.nombre AS maquina, t1.nombre AS nombre, t1.ancho_impresion AS ancho_impresion,
|
||||
t1.alto_impresion AS alto_impresion, t1.ancho AS ancho, t1.alto AS alto,
|
||||
t1.is_rotativa AS is_rotativa, t1.is_inkjet AS is_inkjet, t1.alto_click AS alto_click, t1.velocidad AS velocidad,
|
||||
t1.precio_tinta_negro AS precio_tinta_negro, t1.precio_tinta_color AS precio_tinta_color, t1.precio_tinta_cg AS precio_tinta_cg,
|
||||
@ -361,7 +361,7 @@ class MaquinaModel extends \App\Models\BaseModel
|
||||
$builder->where("t2.uso", $uso_tarifa);
|
||||
}
|
||||
|
||||
return $builder->orderBy("t1.id", "asc")->get()->getResultObject();
|
||||
return $builder;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -279,8 +279,15 @@ 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 = "",
|
||||
$tapaDura = false,
|
||||
$forInkjet = false
|
||||
) {
|
||||
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->distinct("t1.id")
|
||||
@ -289,7 +296,7 @@ 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 nombre"
|
||||
);
|
||||
|
||||
$builder->where("t1.is_deleted", 0);
|
||||
@ -304,24 +311,31 @@ class PapelImpresionModel extends \App\Models\BaseModel
|
||||
$builder->where("t2.id", $papel_generico);
|
||||
$builder->where("t1.gramaje", $gramaje);
|
||||
|
||||
if ($uso == 'cubierta')
|
||||
if ($uso == 'cubierta') {
|
||||
if ($tapaDura)
|
||||
$builder->where("t1.use_for_tapa_dura", 1);
|
||||
$builder->where("t1.cubierta", 1);
|
||||
else if ($uso == 'sobrecubierta')
|
||||
} else if ($uso == 'sobrecubierta')
|
||||
$builder->where("t1.sobrecubierta", 1);
|
||||
else if ($uso == 'guardas')
|
||||
$builder->where("t1.guardas", 1);
|
||||
else {
|
||||
$builder->where("t1.interior", 1);
|
||||
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("t4.is_rotativa", 1);
|
||||
} else
|
||||
$builder->where("t1.rotativa", 0);
|
||||
|
||||
return $builder->orderBy("t1.id", "asc")->get()->getResultObject();
|
||||
if ($forInkjet)
|
||||
$builder->where("t1.inkjet", 1);
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
public function getNombre($id)
|
||||
|
||||
@ -1687,7 +1687,7 @@ class PresupuestoService extends BaseService
|
||||
uso_tarifa: $uso,
|
||||
tirada: $datosPedido->tirada + $datosPedido->merma,
|
||||
papel_impresion_id: $papel->id,
|
||||
);
|
||||
)->orderBy("t1.id", "asc")->get()->getResultObject();
|
||||
|
||||
$data['uso'] = $uso;
|
||||
$data['tipo'] = $tipo;
|
||||
@ -1775,7 +1775,7 @@ class PresupuestoService extends BaseService
|
||||
uso_tarifa: ($uso == 'guardas') ? 'interior' : $uso,
|
||||
tirada: $datosPedido->tirada + $datosPedido->merma,
|
||||
papel_impresion_id: $papel->id,
|
||||
);
|
||||
)->orderBy("t1.id", "asc")->get()->getResultObject();
|
||||
|
||||
// Se recorren las máquinas y se calcula el coste de linea por cada una
|
||||
foreach ($maquinas as $maquina) {
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
|
||||
<input type="hidden" name="tipo_impresion_id" id="tipo_impresion_id" class="form-control"
|
||||
value="<?= $tipo_impresion_id ?>"></input>
|
||||
<input type="hidden" name="lomo" id="lomo" class="form-control" value=""></input>
|
||||
<input type="hidden" name="lomo_cubierta" id="lomo_cubierta" class="form-control" value=""></input>
|
||||
<input type="hidden" name="lomo_sobrecubierta" id="lomo_sobrecubierta" class="form-control"
|
||||
value="<?= is_null($presupuestoEntity->lomo_sobrecubierta)?0:$presupuestoEntity->lomo_sobrecubierta ?>"></input>
|
||||
|
||||
@ -4,15 +4,16 @@
|
||||
* @param {String} url
|
||||
* @param {String} placeholder
|
||||
*/
|
||||
let ClassSelect = function (domItem, url, placeholder, allowClear = false, params = {}) {
|
||||
let ClassSelect = function (domItem, url, placeholder, allowClear = false, params = {}, dropdownParent = "") {
|
||||
this.url = url;
|
||||
this.item = domItem;
|
||||
this.params = params;
|
||||
this.dropdownParent = dropdownParent;
|
||||
|
||||
this.config = {
|
||||
placeholder: placeholder,
|
||||
allowClear: allowClear,
|
||||
dropdownParent: domItem.parent(),
|
||||
dropdownParent: dropdownParent!=""?dropdownParent:domItem.parent(),
|
||||
language: "es",
|
||||
ajax: {
|
||||
url: () => {
|
||||
|
||||
@ -4,6 +4,7 @@ import Ajax from '../../components/ajax.js';
|
||||
import DatosGenerales from './sections/datosGenerales.js';
|
||||
import DatosLibro from './sections/datosLibro.js';
|
||||
import Comparador from './sections/comparador.js';
|
||||
import LineasPresupuesto from './sections/lineasPresupuesto.js';
|
||||
|
||||
class PresupuestoAdminEdit {
|
||||
|
||||
@ -19,6 +20,7 @@ class PresupuestoAdminEdit {
|
||||
this.cosido = $("#isCosido");
|
||||
this.tipo_impresion = $("#tipo_impresion_id");
|
||||
this.cosido = $("#isCosido");
|
||||
this.POD = $("#POD");
|
||||
|
||||
this.datosGenerales = new DatosGenerales(this.domItem.find('#accordionDatosPresupuestoTip'));
|
||||
this.datosLibro = new DatosLibro(this.domItem.find('#accordionDatosLibroTip'),
|
||||
@ -28,6 +30,10 @@ class PresupuestoAdminEdit {
|
||||
checkPaginasPresupuesto: this.checkPaginasPresupuesto,
|
||||
});
|
||||
this.comparador = new Comparador(this.domItem.find('#accordionDatosPresupuestoClienteTip'));
|
||||
this.lineasPresupuesto = new LineasPresupuesto(this.domItem.find('#accordionLineasPresupuestoTip'),
|
||||
{
|
||||
getDimensionLibro: this.getDimensionLibro,
|
||||
});
|
||||
|
||||
this.calcularPresupuesto = false;
|
||||
}
|
||||
@ -42,6 +48,7 @@ class PresupuestoAdminEdit {
|
||||
this.datosGenerales.init();
|
||||
this.datosLibro.init();
|
||||
this.comparador.init();
|
||||
this.lineasPresupuesto.init();
|
||||
|
||||
if (window.location.href.includes("edit")) {
|
||||
|
||||
@ -74,6 +81,7 @@ class PresupuestoAdminEdit {
|
||||
self.lsc.val(parseFloat(response.data.lsc).toFixed(2));
|
||||
self.cosido.val(response.data.cosido);
|
||||
self.tipo_impresion.val(response.data.tipo_impresion);
|
||||
self.POD.val(response.data.POD);
|
||||
|
||||
self.calcularPresupuesto = false;
|
||||
|
||||
@ -164,8 +172,11 @@ class PresupuestoAdminEdit {
|
||||
alto = parseFloat($('#papelFormatoAlto').val());
|
||||
}
|
||||
else {
|
||||
ancho = parseFloat($('#papelFormatoId').getText().trim().split(" x ")[0]);
|
||||
alto = parseFloat($('#papelFormatoId').getText().trim().split(" x ")[1]);
|
||||
const selectedText = $('#papelFormatoId').find('option:selected').text();
|
||||
if (selectedText.length > 0) {
|
||||
ancho = parseFloat(selectedText.trim().split(" x ")[0]);
|
||||
alto = parseFloat(selectedText.trim().split(" x ")[1]);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@ -961,8 +961,8 @@ class Comparador {
|
||||
cliente_id: $('#clienteId').select2('data')[0].id,
|
||||
papel_generico: papel_generico,
|
||||
gramaje: gramaje,
|
||||
isColor: this.tipo_impresion.val().includes('color'),
|
||||
isHq: this.tipo_impresion.val().includes('hq'),
|
||||
isColor: this.tipo_impresion.val().includes('color')?1:0,
|
||||
isHq: this.tipo_impresion.val().includes('hq')?1:0,
|
||||
paginas_color: paginasColor
|
||||
}
|
||||
|
||||
@ -970,8 +970,10 @@ class Comparador {
|
||||
datos.datosPedido.lomo = this.getLomoLineasPresupuesto('interior');
|
||||
datos.datosPedido.solapas = $('#solapas').prop('checked') ? 1 : 0;
|
||||
datos.datosPedido.solapas_ancho = $('#solapas').prop('checked') ? parseInt($('#solapas_ancho').val()) : 0;
|
||||
if (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3){
|
||||
datos.lomoRedondo = this.lomoRedondo.val();
|
||||
}
|
||||
}
|
||||
else if (uso == 'sobrecubierta') {
|
||||
datos.datosPedido.lomo = this.getLomoLineasPresupuesto() + this.getLomoLineasPresupuesto('cubierta');
|
||||
datos.datosPedido.solapas = $('#solapas_sobrecubierta').prop('checked') ? 1 : 0;
|
||||
@ -1039,8 +1041,8 @@ class Comparador {
|
||||
}
|
||||
else {
|
||||
|
||||
const isHq = this.tipo_impresion.val().includes('hq');
|
||||
const isColor = this.tipo_impresion.val().includes('color');
|
||||
const isHq = this.tipo_impresion.val().includes('hq')?1:0;
|
||||
const isColor = this.tipo_impresion.val().includes('color')?1:0;
|
||||
|
||||
datosComp.data['tipo_maquina'] = 'plana';
|
||||
datosComp.data[this.csrf_token] = this.csrf_hash;
|
||||
|
||||
@ -289,15 +289,16 @@ class DatosLibro {
|
||||
|
||||
calcular_mermas(){
|
||||
|
||||
const tirada = parseInt($('#tirada').val())
|
||||
var merma = 0
|
||||
htmlString = ''
|
||||
const tirada = parseInt($('#tirada').val());
|
||||
const POD = parseInt($('#POD').val());
|
||||
let merma = 0;
|
||||
let htmlString = '';
|
||||
|
||||
if(tirada> parseInt($('#POD').val())){
|
||||
merma = tirada*0.1<=30 ? tirada*0.1 : 30
|
||||
if(tirada> POD){
|
||||
merma = tirada*0.1<=POD ? tirada*0.1 : POD;
|
||||
}
|
||||
else{
|
||||
merma_lineas = []
|
||||
let merma_lineas = []
|
||||
tableLineasPresupuesto.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
||||
var rowData = this.data();
|
||||
if(rowData.row_id != 'lp_guardas' && rowData.row_id != 'lp_cubierta' && rowData.row_id != 'lp_sobrecubierta'){
|
||||
@ -342,6 +343,7 @@ class DatosLibro {
|
||||
|
||||
this.paginas.val(datos.paginas);
|
||||
this.tirada.val(datos.tirada);
|
||||
this.calcular_mermas();
|
||||
if (datos.papelFormatoPersonalizado) {
|
||||
this.tamanioPersonalizado.prop('checked', true);
|
||||
$(".tamanio-personalizado").removeClass('d-none');
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user