mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
paginas por cuadernillo añadido a presupuesto comercial
This commit is contained in:
@ -173,7 +173,7 @@ theTable = $('#tableOfPresupuestos').DataTable({
|
||||
}
|
||||
],
|
||||
stateSave: false,
|
||||
order: [[1, 'asc']],
|
||||
order: [[1, 'desc']],
|
||||
language: {
|
||||
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||
},
|
||||
|
||||
@ -518,7 +518,7 @@ function init_servicio_encuadernado(){
|
||||
const tarifa_id = element.tarifa_encuadernado_id
|
||||
var proveedor_nombre = element.proveedor===null? window.Presupuestos.no_disponible: element.proveedor
|
||||
|
||||
tableServiciosEnc.row.add([
|
||||
var linea = [
|
||||
element.tarifa_encuadernado_id,
|
||||
element.nombre,
|
||||
'<select id="proveedor_enc_' + element.tarifa_encuadernado_id + '" class="proveedor_enc select2bs2" style="width: 100%;">' +
|
||||
@ -527,11 +527,14 @@ function init_servicio_encuadernado(){
|
||||
'</option>' +
|
||||
'</select>',
|
||||
'<span id="precio_unidad_encuadernado_' + element.tarifa_encuadernado_id + '">' + parseFloat(element.precio_unidad).toFixed(2) + '</span>',
|
||||
(element.hasOwnProperty('paginas_por_cuadernillo') && element.paginas_por_cuadernillo!=null)?selectForCuadernillos(element.tarifa_encuadernado_id, element.paginas_por_cuadernillo):'',
|
||||
'<span id="tiempo_encuadernado_' + element.tarifa_encuadernado_id + '">' + convertirTiempo(element.tiempo) + '</span>',
|
||||
'<input class="update-totales-servicios" id="precio_total_encuadernado_' + element.tarifa_encuadernado_id +'" value="' + parseFloat(element.precio_total).toFixed(2) + '"></input>',
|
||||
'<span style="display: none;" class="update-totales" id="enc_margen_' + element.tarifa_encuadernado_id + '">' + parseFloat(element.margen).toFixed(2) + '</span>',
|
||||
'<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete-serv mx-2" data-id="' + element.tarifa_encuadernado_id +'"></i></a>'
|
||||
]).draw(false)
|
||||
]
|
||||
|
||||
tableServiciosEnc.row.add(linea).draw(false)
|
||||
|
||||
$('#precio_total_encuadernado_' + element.tarifa_encuadernado_id).on('change', function(){
|
||||
updatePresupuesto({
|
||||
@ -583,12 +586,38 @@ function init_servicio_encuadernado(){
|
||||
cache: true
|
||||
}
|
||||
});
|
||||
$('#proveedor_enc_' + element.tarifa_encuadernado_id).on('change', proveedor_enc_event)
|
||||
$('#proveedor_enc_' + element.tarifa_encuadernado_id).on('change', select_enc_event)
|
||||
|
||||
if(element.hasOwnProperty('paginas_por_cuadernillo') && element.paginas_por_cuadernillo!=null){
|
||||
|
||||
$('#cuadernillos_' + element.tarifa_encuadernado_id).select2({
|
||||
allowClear: false,
|
||||
minimumResultsForSearch: -1,
|
||||
});
|
||||
|
||||
$('#cuadernillos_' + element.tarifa_encuadernado_id).on('change', select_enc_event)
|
||||
}
|
||||
|
||||
});
|
||||
check_serv_enc_error()
|
||||
|
||||
}
|
||||
|
||||
function selectForCuadernillos(tarifa_id, select_value){
|
||||
const value_list = [32, 28, 24, 20, 16];
|
||||
var string =
|
||||
'<select id="cuadernillos_' + tarifa_id + '" class="cuadernillo_enc select2bs2" style="width: 50%;">';
|
||||
|
||||
for (let i = 0; i < value_list.length; i++) {
|
||||
string +=
|
||||
'<option value="' + value_list[i] + '" ' + (value_list[i]==select_value?'selected':'') +'>' +
|
||||
value_list[i] +
|
||||
'</option>';
|
||||
}
|
||||
string += '</select>';
|
||||
return string;
|
||||
}
|
||||
|
||||
function convertirTiempo(horas){
|
||||
if(horas != null){
|
||||
if(parseFloat(horas)>0){
|
||||
@ -602,28 +631,45 @@ function convertirTiempo(horas){
|
||||
else{
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
function proveedor_enc_event(){
|
||||
function select_enc_event(){
|
||||
|
||||
const dimension = getDimensionLibro();
|
||||
|
||||
if(parseInt($('#tirada').val())>0){
|
||||
var tirada = parseInt($('#tirada').val())
|
||||
var tirada = parseInt($('#tirada').val()) + parseInt($('#merma').val())
|
||||
}
|
||||
else{
|
||||
var tirada = 0
|
||||
}
|
||||
|
||||
var tarifa_id = null;
|
||||
if(this.id.includes('proveedor_enc')){
|
||||
tarifa_id = this.id.split('_')[2];
|
||||
}
|
||||
else{
|
||||
tarifa_id = this.id.split('_')[1];
|
||||
}
|
||||
// se checkea si el elemento #cuadernillos_ + tarifa_id existe
|
||||
var paginas_por_cuadernillo = null;
|
||||
if($('#cuadernillos_' + tarifa_id).length){
|
||||
paginas_por_cuadernillo = parseInt($('#cuadernillos_' + tarifa_id).select2('data')[0].id);
|
||||
}
|
||||
|
||||
var datos = {
|
||||
tarifa_encuadernacion_id: this.id.split('_')[2],
|
||||
tarifa_encuadernacion_id: tarifa_id,
|
||||
paginas: parseInt($('#paginas').val())>0?parseInt($('#paginas').val()):0,
|
||||
tirada: tirada,
|
||||
ancho: dimension.ancho,
|
||||
alto: dimension.alto,
|
||||
proveedor_id: parseInt($('#' + this.id).select2('data')[0].id),
|
||||
paginas_por_cuadernillo: paginas_por_cuadernillo,
|
||||
proveedor_id: parseInt($('#proveedor_enc_' + tarifa_id).select2('data')[0].id),
|
||||
POD: parseInt($('#POD').val())
|
||||
};
|
||||
datos = Object.assign(datos, window.token_ajax);
|
||||
@ -677,7 +723,7 @@ async function get_tarifas_enc(tipo=null, tarifa_id = -1){
|
||||
const dimension = getDimensionLibro();
|
||||
|
||||
if(parseInt($('#tirada').val())>0){
|
||||
var tirada = parseInt($('#tirada').val())
|
||||
var tirada = parseInt($('#tirada').val()) + parseInt($('#merma').val())
|
||||
}
|
||||
else{
|
||||
var tirada = 0
|
||||
@ -719,6 +765,7 @@ async function get_tarifas_enc(tipo=null, tarifa_id = -1){
|
||||
'</option>' +
|
||||
'</select>',
|
||||
'<span id="precio_unidad_encuadernado_' + row.tarifa_id + '">' + parseFloat(row.precio_unidad).toFixed(2) + '</span>',
|
||||
(row.hasOwnProperty('paginas_por_cuadernillo') && row.paginas_por_cuadernillo!=null)?selectForCuadernillos(row.tarifa_id, 32):'',
|
||||
'<span id="tiempo_encuadernado_' + row.tarifa_id + '">' + convertirTiempo(row.tiempo) + '</span>',
|
||||
'<input class="update-totales-servicios" id="precio_total_encuadernado_' + row.tarifa_id +'" value="' + parseFloat(row.total).toFixed(2) + '"></input>',
|
||||
'<span style="display: none;" class="update-totales" id="enc_margen_' + row.tarifa_id + '">' + parseFloat(row.margen).toFixed(2) + '</span>',
|
||||
@ -745,7 +792,7 @@ async function get_tarifas_enc(tipo=null, tarifa_id = -1){
|
||||
data: function (params) {
|
||||
|
||||
if( parseInt( $('#tirada').val() )>0){
|
||||
var tirada = parseInt($('#tirada').val())
|
||||
var tirada = parseInt($('#tirada').val()) + parseInt($('#merma').val())
|
||||
}
|
||||
else{
|
||||
var tirada = 0
|
||||
@ -755,8 +802,8 @@ async function get_tarifas_enc(tipo=null, tarifa_id = -1){
|
||||
tarifa_id: row.tarifa_id,
|
||||
paginas: parseInt($('#paginas').val())>0?parseInt($('#paginas').val()):0,
|
||||
tirada: tirada,
|
||||
ancho: ancho_libro,
|
||||
alto: alto_libro,
|
||||
ancho: dimension.ancho,
|
||||
alto: dimension.alto,
|
||||
searchtxt: params.term, // search term
|
||||
}
|
||||
return_data = Object.assign(return_data, window.token_ajax);
|
||||
@ -773,9 +820,17 @@ async function get_tarifas_enc(tipo=null, tarifa_id = -1){
|
||||
}
|
||||
});
|
||||
|
||||
$('#proveedor_enc_' + row.tarifa_id).on('change', proveedor_enc_event)
|
||||
|
||||
$('#proveedor_enc_' + row.tarifa_id).on('change', select_enc_event)
|
||||
|
||||
|
||||
if(row.hasOwnProperty('paginas_por_cuadernillo') && row.paginas_por_cuadernillo!=null){
|
||||
$('#cuadernillos_' + row.tarifa_id).select2({
|
||||
allowClear: false,
|
||||
minimumResultsForSearch: -1,
|
||||
});
|
||||
|
||||
$('#cuadernillos_' + row.tarifa_id).on('change', select_enc_event)
|
||||
}
|
||||
});
|
||||
check_serv_enc_error()
|
||||
yeniden(data[window.csrf_token]);
|
||||
@ -821,16 +876,21 @@ function get_datos_encuadernacion(){
|
||||
case 3:
|
||||
values['precio_unidad'] = $(this).text()
|
||||
break
|
||||
case 4:
|
||||
case 4:
|
||||
values['paginas_por_cuadernillo'] = $(this).children(":first").val()
|
||||
// Si el valor es "undefined" se pone a null
|
||||
if(values['paginas_por_cuadernillo'] == "undefined")
|
||||
values['paginas_por_cuadernillo'] = null
|
||||
case 5:
|
||||
values['tiempo'] = $(this).text()
|
||||
// se pasa el string hh:mm:ss a horas
|
||||
if(values['tiempo'] != null)
|
||||
values['tiempo'] = parseInt(values['tiempo'].split(':')[0]) + parseInt(values['tiempo'].split(':')[1])/60 + parseInt(values['tiempo'].split(':')[2])/3600
|
||||
break
|
||||
case 5:
|
||||
case 6:
|
||||
values['precio_total'] = $(this).children(":first").val()
|
||||
break
|
||||
case 6:
|
||||
case 7:
|
||||
values['margen'] = $(this).text()
|
||||
break
|
||||
}
|
||||
@ -1709,7 +1769,7 @@ async function actualizar_servicios(update_preimpresion=false){
|
||||
$('#precio_unidad_encuadernado_' + line[0].tarifa_id).text(parseFloat(line[0].precio_unidad).toFixed(2))
|
||||
$('#precio_total_encuadernado_' + line[0].tarifa_id).val(parseFloat(line[0].total).toFixed(2))
|
||||
$('#enc_margen_' + line[0].tarifa_id).val(parseFloat(line[0].margen).toFixed(2))
|
||||
$('#proveedor_enc_' + line[0].tarifa_id).on('change', proveedor_enc_event)
|
||||
$('#proveedor_enc_' + line[0].tarifa_id).on('change', select_enc_event)
|
||||
});
|
||||
check_serv_enc_error()
|
||||
yeniden(data[window.csrf_token]);
|
||||
|
||||
@ -167,6 +167,7 @@
|
||||
<th><?= lang('Presupuestos.tarifa') ?></th>
|
||||
<th><?= lang('Proveedores.proveedor') ?></th>
|
||||
<th><?= lang('Presupuestos.precioUnidad') ?></th>
|
||||
<th><?= lang('Presupuestos.paginasCuadernillo') ?></th>
|
||||
<th><?= lang('Presupuestos.tiempo') ?></th>
|
||||
<th><?= lang('Presupuestos.precioTotal') ?></th>
|
||||
<th></th>
|
||||
|
||||
Reference in New Issue
Block a user