mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
terminando servicios manipulados y preimpresion
This commit is contained in:
@ -83,7 +83,7 @@
|
||||
</table>
|
||||
<div class="row mb-3 px-4">
|
||||
<div class="col-md-12 col-lg-4 py-4">
|
||||
<select id="add_servicio_acabado_list" class="proveedor_enc select2bs2" style="width: 100%;">
|
||||
<select id="add_servicio_acabado_list" class="select2bs2" style="width: 100%;">
|
||||
<option></option>
|
||||
<?php foreach ($serviciosAcabado as $item) : ?>
|
||||
<option value="<?= $item->value ?>" >
|
||||
@ -101,18 +101,38 @@
|
||||
|
||||
|
||||
<div class="tab-pane fade" id="servicios-preimpresion" role="tabpanel">
|
||||
<div id="serv-preimpresion-alert">
|
||||
</div>
|
||||
<div id="serv-preimpresion-error">
|
||||
</div>
|
||||
<table id="tableOfServiciosPreimpresion" class="table table-striped table-hover" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= lang('Presupuestos.id') ?></th>
|
||||
<th><?= lang('Tarifapreimpresion.tarifapreimpresion') ?></th>
|
||||
<th><?= lang('Presupuestos.precioUnidad') ?></th>
|
||||
<th><?= lang('Presupuestos.precioTotal') ?></th>
|
||||
<th><?= lang('Presupuestos.precio') ?></th>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="row mb-3 px-4">
|
||||
<div class="col-md-12 col-lg-4 py-4">
|
||||
<select id="add_servicio_preimpresion_list" class="select2bs2" style="width: 100%;">
|
||||
<option></option>
|
||||
<?php foreach ($serviciosPreimpresion as $item) : ?>
|
||||
<option value="<?= $item->value ?>" >
|
||||
<?= $item->label ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-4 px-2 py-4">
|
||||
<button id="insertar_serv_preimpresion" type="button" class="btn btn-secondary waves-effect waves-light float-start"><?= lang("Presupuestos.insertar")?></button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="servicios-encuadernacion" role="tabpanel">
|
||||
@ -143,7 +163,7 @@
|
||||
</table>
|
||||
<div class="row mb-3 px-4">
|
||||
<div class="col-md-12 col-lg-4 py-4">
|
||||
<select id="add_servicio_enc_list" class="proveedor_enc select2bs2" style="width: 100%;">
|
||||
<select id="add_servicio_enc_list" class="select2bs2" style="width: 100%;">
|
||||
<option></option>
|
||||
<?php foreach ($serviciosEncuadernacion as $item) : ?>
|
||||
<option value="<?= $item->value ?>" >
|
||||
@ -161,9 +181,14 @@
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="servicios-manipulado" role="tabpanel">
|
||||
<div id="serv-manipulado-alert">
|
||||
</div>
|
||||
<div id="serv-manipulado-error">
|
||||
</div>
|
||||
<table id="tableOfServiciosManipulado" class="table table-striped table-hover" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= lang('Presupuestos.id') ?></th>
|
||||
<th><?= lang('Tarifamanipulado.tarifamanipulado') ?></th>
|
||||
<th><?= lang('Presupuestos.precioUnidad') ?></th>
|
||||
<th><?= lang('Presupuestos.precioTotal') ?></th>
|
||||
@ -173,6 +198,22 @@
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="row mb-3 px-4">
|
||||
<div class="col-md-12 col-lg-4 py-4">
|
||||
<select id="add_servicio_manipulado_list" class="select2bs2" style="width: 100%;">
|
||||
<option></option>
|
||||
<?php foreach ($serviciosManipulado as $item) : ?>
|
||||
<option value="<?= $item->value ?>" >
|
||||
<?= $item->label ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-4 px-2 py-4">
|
||||
<button id="insertar_serv_manipulado" type="button" class="btn btn-secondary waves-effect waves-light float-start"><?= lang("Presupuestos.insertar")?></button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -198,6 +239,9 @@
|
||||
|
||||
$('.nav-servicios button').on('shown.bs.tab', function(){
|
||||
$("#tableOfServiciosEncuadernacion").DataTable().columns.adjust();
|
||||
$("#tableOfServiciosPreimpresion").DataTable().columns.adjust();
|
||||
$("#tableOfServiciosManipulado").DataTable().columns.adjust();
|
||||
$("#tableOfServiciosAcabado").DataTable().columns.adjust();
|
||||
})
|
||||
|
||||
|
||||
@ -215,6 +259,12 @@
|
||||
else if($(this).closest('table').attr('id').includes('tableOfServiciosAcabado')){
|
||||
table = "tableOfServiciosAcabado";
|
||||
}
|
||||
else if($(this).closest('table').attr('id').includes('tableOfServiciosManipulado')){
|
||||
table = "tableOfServiciosManipulado";
|
||||
}
|
||||
else if($(this).closest('table').attr('id').includes('tableOfServiciosPreimpresion')){
|
||||
table = "tableOfServiciosPreimpresion";
|
||||
}
|
||||
else{
|
||||
table = "";
|
||||
}
|
||||
@ -229,14 +279,18 @@
|
||||
|
||||
check_serv_enc_error()
|
||||
check_serv_acabado_error()
|
||||
check_serv_preimpresion_error()
|
||||
check_serv_manipulado_error()
|
||||
|
||||
});
|
||||
|
||||
function save_servicios(){
|
||||
|
||||
var datosAcabado = get_datos_acabado()
|
||||
|
||||
var datosEnc = get_datos_encuadernacion()
|
||||
var datosManipulado = get_datos_manipulado()
|
||||
var datosPreimpresion = get_datos_preimpresion()
|
||||
|
||||
const domain = window.location.origin
|
||||
|
||||
fetch(domain + "/presupuestos/presupuestoencuadernaciones/edit/" + id , {
|
||||
@ -253,23 +307,54 @@
|
||||
.then(data => {
|
||||
yeniden(data.<?= csrf_token() ?>);
|
||||
})
|
||||
.then(
|
||||
fetch(domain + "/presupuestos/presupuestoacabados/edit/" + id , {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
datos: datosAcabado,
|
||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
|
||||
}),
|
||||
headers: {
|
||||
"Content-type": "application/json; charset=UTF-8"
|
||||
}
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
yeniden(data.<?= csrf_token() ?>);
|
||||
})
|
||||
|
||||
)
|
||||
.then(
|
||||
fetch(domain + "/presupuestos/presupuestomanipulados/edit/" + id , {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
datos: datosAcabado,
|
||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
|
||||
}),
|
||||
headers: {
|
||||
"Content-type": "application/json; charset=UTF-8"
|
||||
}
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
yeniden(data.<?= csrf_token() ?>);
|
||||
})
|
||||
)
|
||||
.then(
|
||||
fetch(domain + "/presupuestos/presupuestoacabados/edit/" + id , {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
datos: datosManipulado,
|
||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
|
||||
}),
|
||||
headers: {
|
||||
"Content-type": "application/json; charset=UTF-8"
|
||||
}
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
yeniden(data.<?= csrf_token() ?>);
|
||||
})
|
||||
)
|
||||
.then(
|
||||
fetch(domain + "/presupuestos/presupuestopreimpresiones/edit/" + id , {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
datos: datosPreimpresion,
|
||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
|
||||
}),
|
||||
headers: {
|
||||
"Content-type": "application/json; charset=UTF-8"
|
||||
}
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
yeniden(data.<?= csrf_token() ?>);
|
||||
})
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
@ -341,7 +426,6 @@
|
||||
}
|
||||
|
||||
function get_tarifas_acabado(tarifa_id = -1){
|
||||
const dimension = getDimensionLibro();
|
||||
|
||||
if(parseInt($('#tirada').val())>0){
|
||||
var tirada = parseInt($('#tirada').val())
|
||||
@ -396,7 +480,7 @@
|
||||
popErrorAlert("Ese servicio ya existe", 'serv-acabado-alert')
|
||||
}
|
||||
}
|
||||
check_serv_enc_error()
|
||||
check_serv_acabado_error()
|
||||
})
|
||||
|
||||
function get_datos_acabado(){
|
||||
@ -434,9 +518,6 @@
|
||||
<!-------------------------------------------------------------->
|
||||
<?= $this->section("additionalInlineJs") ?>
|
||||
|
||||
// Generación de la lista de servicios de acabado (id, nombre)
|
||||
const encuadernadosList = <?php echo json_encode($serviciosEncuadernacion); ?>;
|
||||
|
||||
var tableServiciosEnc = new DataTable('#tableOfServiciosEncuadernacion',{
|
||||
scrollX: true,
|
||||
searching: false,
|
||||
@ -735,137 +816,150 @@
|
||||
<!-- Código JS comportamiento tabla servicios manipulados. -->
|
||||
<!-------------------------------------------------------------->
|
||||
<?= $this->section("additionalInlineJs") ?>
|
||||
/*
|
||||
const lastColNr3 = $('#tableOfServiciosManipulado').find("tr:first th").length - 1;
|
||||
|
||||
editor3 = new $.fn.dataTable.Editor( {
|
||||
ajax: {
|
||||
url: "<?= route_to('editorOfPresupuestoManipulados') ?>",
|
||||
headers: {
|
||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
|
||||
},
|
||||
},
|
||||
table : "#tableOfServiciosManipulado",
|
||||
idSrc: 'id',
|
||||
fields: [ {
|
||||
"name": "tarifa_manipulado_id",
|
||||
"type": "select"
|
||||
}, {
|
||||
"name": "precio_unidad"
|
||||
}, {
|
||||
"name": "precio_total"
|
||||
}, {
|
||||
"name": "presupuesto_id",
|
||||
"type": "hidden"
|
||||
},
|
||||
]
|
||||
} );
|
||||
|
||||
// Generación de la lista de servicios de acabado (id, nombre)
|
||||
const manipuladosList = <?php echo json_encode($serviciosManipulado); ?>;
|
||||
editor3.field( 'tarifa_manipulado_id' ).update( manipuladosList );
|
||||
|
||||
editor3.on( 'preSubmit', function ( e, d, type ) {
|
||||
if ( type === 'create'){
|
||||
d.data[0]['presupuesto_id'] = id;
|
||||
}
|
||||
else if(type === 'edit' ) {
|
||||
for (v in d.data){
|
||||
d.data[v]['presupuesto_id'] = id;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
editor3.on( 'postSubmit', function ( e, json, data, action ) {
|
||||
yeniden(json.<?= csrf_token() ?>);
|
||||
});
|
||||
|
||||
editor3.on( 'submitSuccess', function ( e, json, data, action ) {
|
||||
theTable3.clearPipeline();
|
||||
theTable3.draw();
|
||||
});
|
||||
|
||||
// Activate an inline edit on click of a table cell
|
||||
$('#tableOfServiciosManipulado').on( 'click', 'tbody span.edit', function (e) {
|
||||
editor3.inline(
|
||||
theTable3.cells(this.parentNode.parentNode, '*').nodes(),
|
||||
{
|
||||
cancelHtml: '<a href="javascript:void(0);"><i class="ti ti-x"></i></a>',
|
||||
cancelTrigger: 'span.cancel',
|
||||
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>',
|
||||
submitTrigger: 'span.edit',
|
||||
submit: 'allIfChanged'
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
|
||||
// Delete row
|
||||
|
||||
|
||||
var theTable3 = $('#tableOfServiciosManipulado').DataTable( {
|
||||
draw: 3,
|
||||
serverSide: false,
|
||||
processing: true,
|
||||
autoWidth: true,
|
||||
responsive: true,
|
||||
lengthMenu: [ 5, 10, 25],
|
||||
order: [[ 0, "asc" ], [ 1, "asc" ]],
|
||||
pageLength: 10,
|
||||
lengthChange: true,
|
||||
var tableServiciosManipulado = new DataTable('#tableOfServiciosManipulado',{
|
||||
scrollX: true,
|
||||
searching: false,
|
||||
paging: true,
|
||||
paging: false,
|
||||
info: false,
|
||||
dom: '<"mt-4"><"float-start"l><t><"mt-4 mb-3"p>',
|
||||
ajax : $.fn.dataTable.pipeline( {
|
||||
url: '<?= route_to('dataTableOfPresupuestoManipulados') ?>',
|
||||
data: {
|
||||
id_presupuesto: id,
|
||||
},
|
||||
method: 'POST',
|
||||
headers: {'X-Requested-With': 'XMLHttpRequest'},
|
||||
async: true,
|
||||
}),
|
||||
columns: [
|
||||
{'data': 'tarifa_manipulado_id',
|
||||
render: function(data, type, row, meta) {
|
||||
var value = manipuladosList.find(element => element.value === data);
|
||||
return value['label'];
|
||||
},
|
||||
},
|
||||
{ 'data': 'precio_unidad' },
|
||||
{ 'data': 'precio_total' },
|
||||
{
|
||||
data: actionBtns,
|
||||
className: 'row-edit dt-center'
|
||||
}
|
||||
],
|
||||
columnDefs: [
|
||||
{
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
targets: [lastColNr3]
|
||||
},
|
||||
{
|
||||
"orderData": [ 0, 1 ],
|
||||
"targets": 0
|
||||
},
|
||||
|
||||
],
|
||||
ordering: false,
|
||||
responsive: true,
|
||||
select: false,
|
||||
language: {
|
||||
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
|
||||
},
|
||||
buttons: [ {
|
||||
className: 'btn btn-primary float-end me-sm-3 me-1',
|
||||
extend: "createInline",
|
||||
editor: editor3,
|
||||
formOptions: {
|
||||
submitTrigger: -1,
|
||||
submitHtml: '<i class="ti ti-device-floppy"/>'
|
||||
|
||||
});
|
||||
|
||||
function init_servicio_manipulado(){
|
||||
const serviciosmanipuladoList = <?php echo json_encode($serviciosManipuladoList); ?>;
|
||||
|
||||
$('#add_servicio_manipulado_list').select2({
|
||||
allowClear: false,
|
||||
minimumResultsForSearch: -1,
|
||||
placeholder: '<?= lang("Presupuestos.servicioManipuladoList") ?>'
|
||||
})
|
||||
|
||||
serviciosmanipuladoList.forEach((element) =>{
|
||||
|
||||
tableServiciosManipulado.row.add([
|
||||
element.tarifa_manipulado_id,
|
||||
element.nombre,
|
||||
'<span id="precio_unidad_' + element.tarifa_manipulado_id + '">' + parseFloat(element.precio_unidad).toFixed(2) + '</span>',
|
||||
'<input id="precio_total_' + element.tarifa_manipulado_id +'" value="' + parseFloat(element.precio_total).toFixed(2) + '"></input>',
|
||||
'<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-serv mx-2" data-id="' + element.tarifa_manipulado_id +'"></i></a>'
|
||||
]).draw(false)
|
||||
|
||||
})
|
||||
check_serv_manipulado_error()
|
||||
}
|
||||
|
||||
function check_serv_manipulado_error(){
|
||||
|
||||
var htmlString = '';
|
||||
|
||||
$('#tableOfServiciosManipulado tr').each(function(){
|
||||
if($(this).find('td').eq(2).text() == '0.00'){
|
||||
htmlString = `
|
||||
<div class="alert alert-danger d-flex align-items-baseline" role="alert">
|
||||
<span class="alert-icon alert-icon-lg text-primary me-2">
|
||||
<i class="ti ti-ban ti-sm"></i>
|
||||
</span>
|
||||
<div class="d-flex flex-column ps-1">
|
||||
<h5 class="alert-heading mb-2"><?= lang("Presupuestos.errores.error_servicios_anadidos") ?></h5>
|
||||
</div>
|
||||
</div>`;
|
||||
}
|
||||
} ]
|
||||
} );
|
||||
*/
|
||||
})
|
||||
$('#serv-manipulado-error').html(htmlString)
|
||||
}
|
||||
|
||||
function get_tarifas_manipulado(tarifa_id = -1){
|
||||
|
||||
if(parseInt($('#tirada').val())>0){
|
||||
var tirada = parseInt($('#tirada').val())
|
||||
}
|
||||
else{
|
||||
var tirada = 0
|
||||
}
|
||||
|
||||
var datos = {
|
||||
tarifa_manipulado_id : tarifa_id,
|
||||
tirada: tirada,
|
||||
POD: POD,
|
||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
|
||||
};
|
||||
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '<?=route_to('dataTableOfPresupuestoManipulados') ?>',
|
||||
data: datos,
|
||||
success: function (data) {
|
||||
|
||||
data.values.forEach((row) => {
|
||||
|
||||
tableServiciosManipulado.row.add([
|
||||
row.tarifa_id,
|
||||
row.tarifa_nombre,
|
||||
'<span id="precio_unidad_' + row.tarifa_id + '">' + parseFloat(row.precio_unidad).toFixed(2) + '</span>',
|
||||
'<input id="precio_total_' + row.tarifa_id +'" value="' + parseFloat(row.total).toFixed(2) + '"></input>',
|
||||
'<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-serv mx-2" data-id="' + row.tarifa_id +'"></i></a>'
|
||||
]).draw(false)
|
||||
});
|
||||
|
||||
check_serv_manipulado_error()
|
||||
yeniden(data.<?= csrf_token() ?>);
|
||||
return true;
|
||||
},
|
||||
error: function(e){
|
||||
return false;
|
||||
}
|
||||
})
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#insertar_serv_manipulado').on('click', function(){
|
||||
const tarifa_text = $('#add_servicio_manipulado_list').select2('data')[0].text.trim()
|
||||
|
||||
if( $('#add_servicio_manipulado_list').select2('data')[0].text.trim().length > 0){
|
||||
if($('#tableOfServiciosManipulado tr > td:contains(' + tarifa_text + ')').length == 0)
|
||||
get_tarifas_manipulado($('#add_servicio_manipulado_list').select2('data')[0].id);
|
||||
else{
|
||||
popErrorAlert("Ese servicio ya existe", 'serv-manipulado-alert')
|
||||
}
|
||||
}
|
||||
check_serv_manipulado_error()
|
||||
})
|
||||
|
||||
function get_datos_manipulado(){
|
||||
|
||||
var datosManipulado = []
|
||||
$("#tableOfServiciosManipulado tr").each(function (index,tr) {
|
||||
var values = {}
|
||||
$(this).find("td").each(function (index2) {
|
||||
|
||||
switch (index2) {
|
||||
case 0:
|
||||
values['tarifa_id'] = $(this).text()
|
||||
break
|
||||
case 2:
|
||||
values['precio_unidad'] = $(this).text()
|
||||
break
|
||||
case 3:
|
||||
values['precio_total'] = $(this).children(":first").val()
|
||||
break
|
||||
}
|
||||
})
|
||||
if(Object.keys(values).length>0)
|
||||
datosManipulado.push(values)
|
||||
})
|
||||
|
||||
return datosManipulado
|
||||
}
|
||||
|
||||
init_servicio_manipulado()
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
@ -873,135 +967,135 @@
|
||||
<!-- Código JS comportamiento tabla servicios preimpresion. -->
|
||||
<!-------------------------------------------------------------->
|
||||
<?= $this->section("additionalInlineJs") ?>
|
||||
/*
|
||||
const lastColNr4 = $('#tableOfServiciosPreimpresion').find("tr:first th").length - 1;
|
||||
|
||||
editor4 = new $.fn.dataTable.Editor( {
|
||||
ajax: {
|
||||
url: "<?= route_to('editorOfPresupuestoPreimpresiones') ?>",
|
||||
headers: {
|
||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
|
||||
},
|
||||
},
|
||||
table : "#tableOfServiciosPreimpresion",
|
||||
idSrc: 'id',
|
||||
fields: [ {
|
||||
"name": "tarifa_preimpresion_id",
|
||||
"type": "select"
|
||||
}, {
|
||||
"name": "precio_unidad"
|
||||
}, {
|
||||
"name": "precio_total"
|
||||
}, {
|
||||
"name": "presupuesto_id",
|
||||
"type": "hidden"
|
||||
},
|
||||
]
|
||||
} );
|
||||
|
||||
// Generación de la lista de servicios de acabado (id, nombre)
|
||||
const preimpresionesList = <?php echo json_encode($serviciosPreimpresion); ?>;
|
||||
editor4.field( 'tarifa_preimpresion_id' ).update( preimpresionesList );
|
||||
|
||||
editor4.on( 'preSubmit', function ( e, d, type ) {
|
||||
if ( type === 'create'){
|
||||
d.data[0]['presupuesto_id'] = id;
|
||||
}
|
||||
else if(type === 'edit' ) {
|
||||
for (v in d.data){
|
||||
d.data[v]['presupuesto_id'] = id;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
editor4.on( 'postSubmit', function ( e, json, data, action ) {
|
||||
yeniden(json.<?= csrf_token() ?>);
|
||||
});
|
||||
|
||||
editor4.on( 'submitSuccess', function ( e, json, data, action ) {
|
||||
theTable4.clearPipeline();
|
||||
theTable4.draw();
|
||||
});
|
||||
|
||||
// Activate an inline edit on click of a table cell
|
||||
$('#tableOfServiciosPreimpresion').on( 'click', 'tbody span.edit', function (e) {
|
||||
editor4.inline(
|
||||
theTable4.cells(this.parentNode.parentNode, '*').nodes(),
|
||||
{
|
||||
cancelHtml: '<a href="javascript:void(0);"><i class="ti ti-x"></i></a>',
|
||||
cancelTrigger: 'span.cancel',
|
||||
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>',
|
||||
submitTrigger: 'span.edit',
|
||||
submit: 'allIfChanged'
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
|
||||
// Delete row
|
||||
|
||||
|
||||
var theTable4 = $('#tableOfServiciosPreimpresion').DataTable( {
|
||||
draw: 4,
|
||||
serverSide: false,
|
||||
processing: true,
|
||||
autoWidth: true,
|
||||
responsive: true,
|
||||
lengthMenu: [ 5, 10, 25],
|
||||
order: [[ 0, "asc" ], [ 1, "asc" ]],
|
||||
pageLength: 10,
|
||||
lengthChange: true,
|
||||
var tableServiciosPreimpresion = new DataTable('#tableOfServiciosPreimpresion',{
|
||||
scrollX: true,
|
||||
searching: false,
|
||||
paging: true,
|
||||
paging: false,
|
||||
info: false,
|
||||
dom: '<"mt-4"><"float-start"l><t><"mt-4 mb-3"p>',
|
||||
ajax : $.fn.dataTable.pipeline( {
|
||||
url: '<?= route_to('dataTableOfPresupuestoPreimpresiones') ?>',
|
||||
data: {
|
||||
id_presupuesto: id,
|
||||
},
|
||||
method: 'POST',
|
||||
headers: {'X-Requested-With': 'XMLHttpRequest'},
|
||||
async: true,
|
||||
}),
|
||||
columns: [
|
||||
{'data': 'tarifa_preimpresion_id',
|
||||
render: function(data, type, row, meta) {
|
||||
var value = preimpresionesList.find(element => element.value === data);
|
||||
return value['label'];
|
||||
},
|
||||
},
|
||||
{ 'data': 'precio_unidad' },
|
||||
{ 'data': 'precio_total' },
|
||||
{
|
||||
data: actionBtns,
|
||||
className: 'row-edit dt-center'
|
||||
}
|
||||
],
|
||||
columnDefs: [
|
||||
{
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
targets: [lastColNr4]
|
||||
},
|
||||
{
|
||||
"orderData": [ 0, 1 ],
|
||||
"targets": 0
|
||||
},
|
||||
|
||||
],
|
||||
ordering: false,
|
||||
responsive: true,
|
||||
select: false,
|
||||
language: {
|
||||
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
|
||||
},
|
||||
buttons: [ {
|
||||
className: 'btn btn-primary float-end me-sm-3 me-1',
|
||||
extend: "createInline",
|
||||
editor: editor4,
|
||||
formOptions: {
|
||||
submitTrigger: -1,
|
||||
submitHtml: '<i class="ti ti-device-floppy"/>'
|
||||
|
||||
});
|
||||
|
||||
function init_servicio_preimpresion(){
|
||||
const serviciospreimpresionList = <?php echo json_encode($serviciosPreimpresionList); ?>;
|
||||
|
||||
$('#add_servicio_preimpresion_list').select2({
|
||||
allowClear: false,
|
||||
minimumResultsForSearch: -1,
|
||||
placeholder: '<?= lang("Presupuestos.servicioPreimpresionList") ?>'
|
||||
})
|
||||
|
||||
serviciospreimpresionList.forEach((element) =>{
|
||||
|
||||
tableServiciosPreimpresion.row.add([
|
||||
element.tarifa_preimpresion_id,
|
||||
element.nombre,
|
||||
'<input id="precio_' + element.tarifa_preimpresion_id +'" value="' + parseFloat(element.precio).toFixed(2) + '"></input>',
|
||||
'<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-serv mx-2" data-id="' + element.tarifa_preimpresion_id +'"></i></a>'
|
||||
]).draw(false)
|
||||
|
||||
})
|
||||
check_serv_preimpresion_error()
|
||||
}
|
||||
|
||||
function check_serv_preimpresion_error(){
|
||||
|
||||
var htmlString = '';
|
||||
|
||||
$('#tableOfServiciosPreimpresion tr').each(function(){
|
||||
|
||||
if(parseFloat($(this).find('td:eq(2) input').val()) == '0'){
|
||||
htmlString = `
|
||||
<div class="alert alert-danger d-flex align-items-baseline" role="alert">
|
||||
<span class="alert-icon alert-icon-lg text-primary me-2">
|
||||
<i class="ti ti-ban ti-sm"></i>
|
||||
</span>
|
||||
<div class="d-flex flex-column ps-1">
|
||||
<h5 class="alert-heading mb-2"><?= lang("Presupuestos.errores.error_servicios_anadidos") ?></h5>
|
||||
</div>
|
||||
</div>`;
|
||||
}
|
||||
} ]
|
||||
} );
|
||||
*/
|
||||
})
|
||||
$('#serv-preimpresion-error').html(htmlString)
|
||||
}
|
||||
|
||||
function get_tarifas_preimpresion(tarifa_id = -1){
|
||||
|
||||
var datos = {
|
||||
tarifa_preimpresion_id : tarifa_id,
|
||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
|
||||
};
|
||||
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '<?=route_to('dataTableOfPresupuestoPreimpresiones') ?>',
|
||||
data: datos,
|
||||
success: function (data) {
|
||||
|
||||
data.values.forEach((row) => {
|
||||
|
||||
tableServiciosPreimpresion.row.add([
|
||||
row.tarifa_id,
|
||||
row.tarifa_nombre,
|
||||
'<input id="precio_' + row.tarifa_id +'" value="' + parseFloat(row.precio).toFixed(2) + '"></input>',
|
||||
'<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-serv mx-2" data-id="' + row.tarifa_id +'"></i></a>'
|
||||
]).draw(false)
|
||||
});
|
||||
|
||||
check_serv_preimpresion_error()
|
||||
yeniden(data.<?= csrf_token() ?>);
|
||||
return true;
|
||||
},
|
||||
error: function(e){
|
||||
return false;
|
||||
}
|
||||
})
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#insertar_serv_preimpresion').on('click', function(){
|
||||
const tarifa_text = $('#add_servicio_preimpresion_list').select2('data')[0].text.trim()
|
||||
|
||||
if( $('#add_servicio_preimpresion_list').select2('data')[0].text.trim().length > 0){
|
||||
if($('#tableOfServiciosPreimpresion tr > td:contains(' + tarifa_text + ')').length == 0)
|
||||
get_tarifas_preimpresion($('#add_servicio_preimpresion_list').select2('data')[0].id);
|
||||
else{
|
||||
popErrorAlert("Ese servicio ya existe", 'serv-preimpresion-alert')
|
||||
}
|
||||
}
|
||||
check_serv_preimpresion_error()
|
||||
})
|
||||
|
||||
function get_datos_preimpresion(){
|
||||
|
||||
var datosPreimpresion = []
|
||||
$("#tableOfServiciosPreimpresion tr").each(function (index,tr) {
|
||||
var values = {}
|
||||
$(this).find("td").each(function (index2) {
|
||||
|
||||
switch (index2) {
|
||||
case 0:
|
||||
values['tarifa_id'] = $(this).text()
|
||||
break
|
||||
case 2:
|
||||
values['precio_total'] = $(this).children(":first").val()
|
||||
break
|
||||
}
|
||||
})
|
||||
if(Object.keys(values).length>0)
|
||||
datosPreimpresion.push(values)
|
||||
})
|
||||
|
||||
return datosPreimpresion
|
||||
}
|
||||
|
||||
init_servicio_preimpresion()
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
@ -21,13 +21,13 @@
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
id="precio_pagina"
|
||||
name="precio_pagina"
|
||||
id="precio"
|
||||
name="precio"
|
||||
required
|
||||
maxLength="31"
|
||||
step="0.01"
|
||||
class="form-control"
|
||||
value="<?= old('precio', $tarifapreimpresionEntity->precio_pagina) ?>"
|
||||
value="<?= old('precio', $tarifapreimpresionEntity->precio) ?>"
|
||||
>
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
<?= empty($item->nombre) || strlen($item->nombre) < 51 ? esc($item->nombre) : character_limiter(esc($item->nombre), 50) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->precio_pagina) ?>
|
||||
<?= esc($item->precio) ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?= esc($item->precio_min) ?>
|
||||
|
||||
Reference in New Issue
Block a user