mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabaando en comparador sobre cubierta
This commit is contained in:
@ -18,7 +18,7 @@ class Test extends BaseController
|
|||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
echo '<pre>';
|
echo '<pre>';
|
||||||
\var_dump($this->get_precio_tarifa(18,300,10,150,210,-1,30));
|
($this->getPapelesSobrecubierta());
|
||||||
echo '</pre>';
|
echo '</pre>';
|
||||||
/*
|
/*
|
||||||
|
|
||||||
@ -179,6 +179,13 @@ class Test extends BaseController
|
|||||||
var_dump($data);
|
var_dump($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPapelesSobrecubierta(){
|
||||||
|
$model = model('App\Models\Configuracion\PapelGenericoModel');
|
||||||
|
$data = $model->getPapelForComparador('colorhq', false, true, false);
|
||||||
|
|
||||||
|
var_dump($data);
|
||||||
|
}
|
||||||
|
|
||||||
public function getPapelesGuardas(){
|
public function getPapelesGuardas(){
|
||||||
$model = model('App\Models\Configuracion\PapelGenericoModel');
|
$model = model('App\Models\Configuracion\PapelGenericoModel');
|
||||||
$data = $model->getPapelForComparador('color', false, false, false, true);
|
$data = $model->getPapelForComparador('color', false, false, false, true);
|
||||||
|
|||||||
@ -127,21 +127,11 @@ class PapelGenericoModel extends \App\Models\GoBaseModel
|
|||||||
$builder->where("t2.cubierta", 1);
|
$builder->where("t2.cubierta", 1);
|
||||||
$builder->where("t5.uso", 'cubierta');
|
$builder->where("t5.uso", 'cubierta');
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
if(!$is_guardas){
|
|
||||||
$builder->where("t2.cubierta", 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($is_sobrecubierta==true){
|
if($is_sobrecubierta==true){
|
||||||
$builder->where("t2.sobrecubierta", 1);
|
$builder->where("t2.sobrecubierta", 1);
|
||||||
$builder->where("t5.uso", 'sobrecubierta');
|
$builder->where("t5.uso", 'sobrecubierta');
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
if(!$is_guardas){
|
|
||||||
$builder->where("t2.sobrecubierta", 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($is_cubierta==false && $is_sobrecubierta==false){
|
if($is_cubierta==false && $is_sobrecubierta==false){
|
||||||
$builder->where("t5.uso", 'interior');
|
$builder->where("t5.uso", 'interior');
|
||||||
|
|||||||
@ -215,6 +215,41 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12 col-lg-2 px-4">
|
||||||
|
<p><?= lang('PapelImpresion.sobrecubierta') ?></p>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-12 col-lg-2 px-4">
|
||||||
|
<select id="compSobrecubierta" name="comp_sobrecubierta" class="form-control select2bs2 comp_sobrecubierta_items" style="width: 100%;">
|
||||||
|
<option value="0">
|
||||||
|
<p><?= lang('Presupuestos.no') ?></p>
|
||||||
|
</option>
|
||||||
|
<option value="1">
|
||||||
|
<p><?= lang('Presupuestos.si') ?></p>
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-12 col-lg-6 px-4">
|
||||||
|
<select id="compPapelSobrecubierta" name="comp_papel_sobrecubierta" class="form-control select2bs2 comp_sobrecubierta_items" disabled style="width: 100%;">
|
||||||
|
<?php if (isset($papelGenericoSobrecubiertaList) && is_array($papelGenericoSobrecubiertaList) && !empty($papelGenericoSobrecubiertaList)) :
|
||||||
|
foreach ($papelGenericoSobrecubiertaList as $k => $v) : ?>
|
||||||
|
<option value="<?= $v->id ?>">
|
||||||
|
<?= $v->nombre ?>
|
||||||
|
</option>
|
||||||
|
<?php endforeach;
|
||||||
|
endif; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-12 col-lg-2 px-4">
|
||||||
|
<select id="compGramajeSobrecubierta" name="comp_gramaje_sobrecubierta" class="form-control select2bs2 comp_sobrecubierta_items" disabled style="width: 100%;">
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<hr class="my-1">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<?php if($tipo_impresion_id == 1 || $tipo_impresion_id == 3 || $tipo_impresion_id == 5 || $tipo_impresion_id == 7): ?>
|
<?php if($tipo_impresion_id == 1 || $tipo_impresion_id == 3 || $tipo_impresion_id == 5 || $tipo_impresion_id == 7): ?>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12 col-lg-2 px-4">
|
<div class="col-md-12 col-lg-2 px-4">
|
||||||
@ -441,7 +476,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="dt-result dt-result-text" colspan="14"><?= lang('Presupuestos.total') ?> <?= lang("Presupuestos.compInteriorPlana") ?>:</td>
|
<td class="dt-result dt-result-text" colspan="14"><?= lang('Presupuestos.total') ?> <?= lang("Presupuestos.compCubiertaSobrecubierta") ?>:</td>
|
||||||
<td id="total_comp_cubierta" class="dt-result dt-result-value" colspan="2"> 0.00 </td>
|
<td id="total_comp_cubierta" class="dt-result dt-result-value" colspan="2"> 0.00 </td>
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
@ -682,9 +717,19 @@
|
|||||||
allowClear: false,
|
allowClear: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#compPapelSobrecubierta').select2({
|
||||||
|
allowClear: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#compGramajeSobrecubierta').select2({
|
||||||
|
allowClear: false,
|
||||||
|
minimumResultsForSearch: Infinity,
|
||||||
|
});
|
||||||
|
|
||||||
$('#encuadernacion').select2({
|
$('#encuadernacion').select2({
|
||||||
allowClear: false,
|
allowClear: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
<?php if($tipo_impresion_id == 1 || $tipo_impresion_id == 3 || $tipo_impresion_id == 5 || $tipo_impresion_id == 7): ?>
|
<?php if($tipo_impresion_id == 1 || $tipo_impresion_id == 3 || $tipo_impresion_id == 5 || $tipo_impresion_id == 7): ?>
|
||||||
$('#compCarasCubierta').select2({
|
$('#compCarasCubierta').select2({
|
||||||
@ -711,6 +756,19 @@
|
|||||||
computarPaginasColor($('#compPosPaginasColor').val());
|
computarPaginasColor($('#compPosPaginasColor').val());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$('#compSobrecubierta').on('change', function(){
|
||||||
|
if ($('#compSobrecubierta').val()==1){
|
||||||
|
value = false
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
value = 'disabled'
|
||||||
|
$('#compPapelSobrecubierta').val(0)
|
||||||
|
$('#compGramajeSobrecubierta').val('')
|
||||||
|
}
|
||||||
|
$('#compPapelSobrecubierta').prop('disabled', value);
|
||||||
|
$('#compGramajeSobrecubierta').prop('disabled', value);
|
||||||
|
})
|
||||||
|
|
||||||
function init_lineas_comparador(){
|
function init_lineas_comparador(){
|
||||||
var comp_data = <?php echo json_encode($comp_data); ?>
|
var comp_data = <?php echo json_encode($comp_data); ?>
|
||||||
|
|
||||||
@ -1292,6 +1350,82 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$('.comp_sobrecubierta_items').on('change', function (){
|
||||||
|
|
||||||
|
checkComparadorSobrecubierta()
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
function checkComparadorSobrecubierta(actualizarLinea = false){
|
||||||
|
|
||||||
|
if ($('#compSobrecubierta option:selected').val() == 1 &&
|
||||||
|
$('#compPapelSobrecubierta').select2('data').length > 0 &&
|
||||||
|
$('#compGramajeSobrecubierta').select2('data').length > 0 ){
|
||||||
|
|
||||||
|
const dimension = getDimensionLibro();
|
||||||
|
|
||||||
|
let datos = {
|
||||||
|
tipo_impresion_id: <?php echo $tipo_impresion_id ?>,
|
||||||
|
type: 'sobrecubierta',
|
||||||
|
paginas: 4,
|
||||||
|
tirada: parseInt($('#tirada').val()),
|
||||||
|
merma: parseInt($('#mermacubierta').val()),
|
||||||
|
color: 1,
|
||||||
|
ancho: dimension.ancho,
|
||||||
|
alto: dimension.alto,
|
||||||
|
lomo: getLomoLineasPresupuesto(),
|
||||||
|
lomo_cubierta: getLomoCubiertaLineasPresupuesto(),
|
||||||
|
solapas: $('#solapas').is(':checked')?1:0,
|
||||||
|
solapas_ancho: parseInt($('#solapas_ancho').val()),
|
||||||
|
papel_generico_id: $('#compPapelSobrecubierta').select2('data')[0].id,
|
||||||
|
papel_generico: $('#compPapelSobrecubierta').select2('data')[0].text.trim(),
|
||||||
|
gramaje: $('#compGramajeSobrecubierta').select2('data')[0].text.trim() ,
|
||||||
|
cliente_id: $('#clienteId').find(":selected").val(),
|
||||||
|
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
|
||||||
|
};
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: "/cosidotapablanda/datatable",
|
||||||
|
data: datos,
|
||||||
|
success: function (data) {
|
||||||
|
console.log(data)
|
||||||
|
|
||||||
|
clearSobrecubierta();
|
||||||
|
|
||||||
|
if(data.lineas.length >0){
|
||||||
|
|
||||||
|
fillCubierta(data);
|
||||||
|
selectCubiertaLineas();
|
||||||
|
$('#title_cubierta').html('<?= lang("Presupuestos.cubierta") ?>' + ' (' + tableCompCubierta.rows().count() + ')');
|
||||||
|
$('#insertarCubiertaBtn').removeClass('d-none')
|
||||||
|
if(actualizarLinea){
|
||||||
|
var rows = $("#tableCompCubierta").DataTable().rows( '.selected' ).data().toArray();
|
||||||
|
for(row of rows){
|
||||||
|
fill_lp_cubierta(row, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$('#title_cubierta').html('<?= lang("Presupuestos.cubierta") ?>');
|
||||||
|
$('#insertarCubiertaBtn').addClass('d-none')
|
||||||
|
$('#total_comp_cubierta').html('0.00')
|
||||||
|
|
||||||
|
}
|
||||||
|
yeniden(data.<?= csrf_token() ?>);
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
error: function(e){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
else{
|
||||||
|
clearCubierta();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$('.comp_negro_items').on('change', function (e) {
|
$('.comp_negro_items').on('change', function (e) {
|
||||||
@ -1649,6 +1783,49 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#compPapelSobrecubierta').on('select2:select', function (e){
|
||||||
|
if($('#compPapelSobrecubierta').select2('data')[0].id=='0'){
|
||||||
|
$('#compGramajeSobrecubierta').val('').change();
|
||||||
|
$('#compGramajeSobrecubierta').prop('disabled', true);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$('#insertarCubiertaBtn').addClass('d-none')
|
||||||
|
$('#total_comp_cubierta').html('0.00')
|
||||||
|
$('#compGramajeSobrecubierta').empty().trigger("change");
|
||||||
|
$('#compGramajeSobrecubierta').val('').trigger('change');
|
||||||
|
$('#compGramajeSobrecubierta').prop('disabled', false);
|
||||||
|
$('#compPapelSobrecubierta').find('option[value="0"]').remove();
|
||||||
|
$('#compGramajeSobrecubierta').select2({
|
||||||
|
allowClear: false,
|
||||||
|
minimumResultsForSearch: Infinity,
|
||||||
|
ajax: {
|
||||||
|
url: '<?= route_to("menuItemsOfCosidotapablanda") ?>',
|
||||||
|
type: 'post',
|
||||||
|
dataType: 'json',
|
||||||
|
|
||||||
|
data: function (params) {
|
||||||
|
return {
|
||||||
|
tipo: 'gramaje',
|
||||||
|
uso: 'sobrecubierta',
|
||||||
|
tirada: parseInt($('#tirada').val()),
|
||||||
|
merma: parseInt($('#mermacubierta').val()),
|
||||||
|
datos: $('#compPapelSobrecubierta').select2('data')[0].text.trim() ,
|
||||||
|
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
|
||||||
|
};
|
||||||
|
},
|
||||||
|
delay: 60,
|
||||||
|
processResults: function (response) {
|
||||||
|
yeniden(response.<?= csrf_token() ?>);
|
||||||
|
return {
|
||||||
|
results: response.menu
|
||||||
|
};
|
||||||
|
},
|
||||||
|
cache: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
function checkDatosPedidoForComp() {
|
function checkDatosPedidoForComp() {
|
||||||
|
|
||||||
|
|||||||
@ -3491,7 +3491,23 @@ function getLomoLineasPresupuesto(){
|
|||||||
try{
|
try{
|
||||||
tableLineasPresupuesto.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
tableLineasPresupuesto.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
||||||
var rowData = this.data();
|
var rowData = this.data();
|
||||||
lomoTotal += parseFloat(rowData.lomo)
|
if(rowData.row_id != 'lp_cubierta' && rowData.tipo != 'lp_sobrecubierta')
|
||||||
|
lomoTotal += parseFloat(rowData.lomo)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
catch(error){
|
||||||
|
lomoTotal = 0
|
||||||
|
}
|
||||||
|
return lomoTotal
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLomoCubiertaLineasPresupuesto(){
|
||||||
|
let lomoTotal = 0
|
||||||
|
try{
|
||||||
|
tableLineasPresupuesto.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
|
||||||
|
var rowData = this.data();
|
||||||
|
if(rowData.row_id == 'lp_cubierta')
|
||||||
|
return parseFloat(rowData.lomo)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
catch(error){
|
catch(error){
|
||||||
|
|||||||
@ -329,10 +329,29 @@ function clearIntLineas(is_color) {
|
|||||||
|
|
||||||
function clearCubierta() {
|
function clearCubierta() {
|
||||||
|
|
||||||
$('#tableCompCubierta').DataTable().clear().draw();
|
var tabla = $('#tableCompCubierta').DataTable();
|
||||||
$('#insertarCubiertaBtn').css('display', 'none');
|
tabla
|
||||||
|
.rows(function (idx, data, node) {
|
||||||
|
return data['tipo'] === 'cubierta';
|
||||||
|
})
|
||||||
|
.remove()
|
||||||
|
.draw();
|
||||||
|
if(tabla.rows().count()==0)
|
||||||
|
$('#insertarCubiertaBtn').css('display', 'none');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clearSobrecubierta() {
|
||||||
|
|
||||||
|
var tabla = $('#tableCompCubierta').DataTable();
|
||||||
|
tabla
|
||||||
|
.rows(function (idx, data, node) {
|
||||||
|
return data['tipo'] === 'sobrecubierta';
|
||||||
|
})
|
||||||
|
.remove()
|
||||||
|
.draw();
|
||||||
|
if(tabla.rows().count()==0)
|
||||||
|
$('#insertarCubiertaBtn').css('display', 'none');
|
||||||
|
}
|
||||||
|
|
||||||
function clearGuardas() {
|
function clearGuardas() {
|
||||||
|
|
||||||
@ -397,13 +416,33 @@ function selectCubiertaLineas() {
|
|||||||
|
|
||||||
$("#tableCompCubierta").DataTable().rows('.selected').deselect();
|
$("#tableCompCubierta").DataTable().rows('.selected').deselect();
|
||||||
|
|
||||||
let value_total = 0.00;
|
cubierta_selected = false;
|
||||||
|
sobrecubierta_selected = false;
|
||||||
|
|
||||||
if ($("#tableCompCubierta").DataTable().rows().count() > 0) {
|
if ($("#tableCompCubierta").DataTable().rows().count() > 0) {
|
||||||
|
|
||||||
$("#tableCompCubierta").DataTable().row(0).nodes().to$().toggleClass('selected');
|
$("#tableCompCubierta").DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
value_total = parseFloat($("#tableCompCubierta").DataTable().rows(0).data()[0]['total'])
|
if (!cubierta_selected && $('#tableCompCubierta').DataTable().cell(rowIdx, 0).data() === 'cubierta') {
|
||||||
};
|
$("#tableCompCubierta").DataTable().row(rowIdx).nodes().to$().toggleClass('selected');
|
||||||
|
cubierta_selected = true;
|
||||||
|
}
|
||||||
|
if (!sobrecubierta_selected && $('#tableCompCubierta').DataTable().cell(rowIdx, 0).data() === 'sobrecubierta') {
|
||||||
|
$("#tableCompCubierta").DataTable().row(rowIdx).nodes().to$().toggleClass('selected');
|
||||||
|
sobrecubierta_selected = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var table = $("#tableCompCubierta").DataTable();
|
||||||
|
var rows = table.rows('.selected').indexes();
|
||||||
|
var data = table.rows(rows).data();
|
||||||
|
|
||||||
|
var value_total = 0.00;
|
||||||
|
|
||||||
|
for (let i = 0; i < data.length; i++) {
|
||||||
|
|
||||||
|
value_total += parseFloat(data[i]['total'])
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$('#total_comp_cubierta').html(value_total.toFixed(2));
|
$('#total_comp_cubierta').html(value_total.toFixed(2));
|
||||||
|
|||||||
Reference in New Issue
Block a user