autonumeric

This commit is contained in:
amazuecos
2025-02-05 04:17:52 +01:00
parent b67b41148b
commit 23a6e4e8e5
10 changed files with 224 additions and 46 deletions

View File

@ -276,12 +276,16 @@
{
name: "paginas_min",
attr: {
type: "number"
type: "text",
name : "paginas_min",
class :"autonumeric"
}
},{
name: "paginas_max",
attr: {
type: "number"
type: "text",
name : "paginas_max",
class :"autonumeric"
}
},{
name: "margen",
@ -302,6 +306,20 @@
} );
editor3.on('open',(event)=>{
$("input.autonumeric").each(function () {
let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)
if(autoNumericInstance){
autoNumericInstance.remove()
}
new AutoNumeric(this, {
decimalCharacter: ",",
digitGroupSeparator: ".",
unformatOnSubmit : true,
});
})
})
// Definición de la tabla
theTable3 = $('#tableOfPapelimpresionmargenes').DataTable({
@ -332,13 +350,14 @@
async: true,
}),
columns : [
{ 'data': 'paginas_min' },
{ 'data': 'paginas_max' },
{ 'data': 'paginas_min' , render : (d) => `<span class="autonumeric">${d}</span>` },
{ 'data': 'paginas_max' , render : (d) => `<span class="autonumeric">${d}</span>`},
{ 'data': 'margen' },
{ data: actionBtns3,
className: 'row-edit dt-center'}
],
columnDefs: [
{
orderable: false,
searchable: false,
@ -356,7 +375,13 @@
} ]
});
theTable3.on('draw',() => {
AutoNumeric.multiple("span.autonumeric", {
digitGroupSeparator: ".",
decimalCharacter: ",",
unformatOnSubmit: true
});
})
// Activate an inline edit on click of a table cell
$(document).on('click', '.btn-edit3', function(e) {
editor3.inline(
@ -371,9 +396,22 @@
);
} );
// Obtención del id para editar
editor3.on( 'preSubmit', function ( e, d, type ) {
if (d.data) {
Object.keys(d.data).forEach(function (key) {
// Find all elements with class .autonumeric
$("input.autonumeric").each(function () {
let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)
if (autoNumericInstance) {
// Get raw value and update the corresponding field
let rawValue = autoNumericInstance.getNumericString();
d.data[key][this.name] = rawValue; // Ensure the correct name attribute is used
}
});
});
}
if ( type === 'create'){
d.data[0]['papel_impresion_id'] = id;
}

View File

@ -117,11 +117,22 @@
name: "proveedor_id",
type: "select",
}, {
name: "tirada_min"
name: "tirada_min",
attr: {
type: "text",
name : "tirada_min",
class :"autonumeric"
}
}, {
name: "precio_max"
}, {
name: "tirada_max"
name: "tirada_max",
attr: {
type: "text",
name : "tirada_max",
class :"autonumeric"
}
}, {
name: "precio_min"
},{
@ -145,8 +156,35 @@
// Generación de la lista de proveedores (id, nombre) para encuadernación
const suppliersList = <?php echo json_encode($proveedores); ?>;
editor.field( 'proveedor_id' ).update( suppliersList );
editor.on('open',(event)=>{
$("input.autonumeric").each(function () {
let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)
if(autoNumericInstance){
autoNumericInstance.remove()
}
new AutoNumeric(this, {
decimalCharacter: ",",
decimalPlaces : 0,
digitGroupSeparator: ".",
unformatOnSubmit : true,
});
})
})
editor.on( 'preSubmit', function ( e, d, type ) {
if (d.data) {
Object.keys(d.data).forEach(function (key) {
// Find all elements with class .autonumeric
$("input.autonumeric").each(function () {
let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)
if (autoNumericInstance) {
// Get raw value and update the corresponding field
let rawValue = autoNumericInstance.getNumericString();
d.data[key][this.name] = rawValue; // Ensure the correct name attribute is used
}
});
});
}
if ( type === 'create'){
d.data[0]['tarifa_acabado_id'] = id;
}
@ -275,9 +313,9 @@
return value['label'];
},
},
{ 'data': 'tirada_min' },
{ 'data': 'tirada_min',render : (d) => `<span class="autonumeric">${d}</span>` },
{ 'data': 'precio_max' },
{ 'data': 'tirada_max' },
{ 'data': 'tirada_max',render : (d) => `<span class="autonumeric">${d}</span>` },
{ 'data': 'precio_min' },
{ 'data': 'margen' },
{
@ -323,7 +361,14 @@
}
);
} );
theTable.on('draw',() => {
AutoNumeric.multiple("span.autonumeric", {
digitGroupSeparator: ".",
decimalCharacter: ",",
decimalPlaces : 0,
unformatOnSubmit: true
});
})
// Delete row
$(document).on('click', '.btn-delete', function(e) {

View File

@ -370,8 +370,7 @@ id = -1;
searching: false,
paging: true,
info: false,
dom: '<"mt-4"><"float-end"B><"float-start"l>
<t><"mt-4 mb-3"p>',
dom: '<"mt-4"><"float-end"B><"float-start"l><t><"mt-4 mb-3"p>',
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('dataTableOfTarifaEncuadernacionLineasHoras') ?>',
data: function ( d ) {
@ -504,11 +503,21 @@ id = -1;
"type": "select"
},
{
name: "paginas_libro_min"
name: "paginas_libro_min",
attr: {
type: "text",
name : "paginas_libro_min",
class :"autonumeric"
}
}, {
name: "precio_min"
}, {
name: "paginas_libro_max"
name: "paginas_libro_max",
attr: {
type: "text",
name : "paginas_libro_max",
class :"autonumeric"
}
}, {
name: "precio_max"
}, {
@ -531,8 +540,36 @@ id = -1;
// Generación de la lista de proveedores (id, nombre) para encuadernación
const dimensionesList = <?php echo json_encode($dimensiones); ?>;
editor.field( 'dimensiones_id' ).update( dimensionesList );
editor.on('open',(event)=>{
$("input.autonumeric").each(function () {
let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)
if(autoNumericInstance){
autoNumericInstance.remove()
}
new AutoNumeric(this, {
alwaysAllowDecimalCharacter: true,
decimalCharacter: ",",
decimalPlaces : 0,
digitGroupSeparator: ".",
unformatOnSubmit : true,
});
})
})
editor.on( 'preSubmit', function ( e, d, type ) {
if (d.data) {
Object.keys(d.data).forEach(function (key) {
// Find all elements with class .autonumeric
$("input.autonumeric").each(function () {
let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)
if (autoNumericInstance) {
// Get raw value and update the corresponding field
let rawValue = autoNumericInstance.getNumericString();
d.data[key][this.name] = rawValue; // Ensure the correct name attribute is used
}
});
});
}
if ( type === 'create'){
d.data[0]['tirada_encuadernacion_id'] = selected_tirada_id;
}
@ -570,8 +607,7 @@ id = -1;
searching: false,
paging: true,
info: false,
dom: '<"mt-4"><"float-end"B><"float-start"l>
<t><"mt-4 mb-3"p>',
dom: '<"mt-4"><"float-end"B><"float-start"l><t><"mt-4 mb-3"p>',
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('dataTableOfTarifaEncuadernacionLineas') ?>',
data: function ( d ) {
@ -589,9 +625,9 @@ id = -1;
return value['label'];
},
},
{ 'data': 'paginas_libro_min' },
{ 'data': 'paginas_libro_min',render : (d) => `<span class="autonumeric">${d}</span>` },
{ 'data': 'precio_max' },
{ 'data': 'paginas_libro_max' },
{ 'data': 'paginas_libro_max',render : (d) => `<span class="autonumeric">${d}</span>` },
{ 'data': 'precio_min' },
{ 'data': 'total_min' },
{ 'data': 'margen' },
@ -664,7 +700,14 @@ id = -1;
}
);
} );
theTable.on('draw',() => {
AutoNumeric.multiple("span.autonumeric", {
digitGroupSeparator: ".",
decimalCharacter: ",",
decimalPlaces : 0,
unformatOnSubmit: true
});
})
// Delete row
function remove_lineas(dataId, row){
@ -776,8 +819,7 @@ id = -1;
paging: true,
select: true,
info: false,
dom: '<"mt-4"><"float-end"B><"float-start"l>
<t><"mt-4 mb-3"p>',
dom: '<"mt-4"><"float-end"B><"float-start"l><t><"mt-4 mb-3"p>',
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('dataTableOfTarifaEncuadernacionTiradas') ?>',
data: {

View File

@ -115,11 +115,21 @@
table : "#tableOfTarifamanipuladolineas",
idSrc: 'id',
fields: [ {
name: "tirada_min"
name: "tirada_min",
attr: {
type: "text",
name : "tirada_min",
class :"autonumeric"
}
}, {
name: "precio_max"
}, {
name: "tirada_max"
name: "tirada_max",
attr: {
type: "text",
name : "tirada_max",
class :"autonumeric"
}
}, {
name: "precio_min"
}, {
@ -137,7 +147,36 @@
]
} );
editor.on('open',(event)=>{
$("input.autonumeric").each(function () {
let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)
if(autoNumericInstance){
autoNumericInstance.remove()
}
new AutoNumeric(this, {
decimalCharacter: ",",
decimalPlaces : 0,
digitGroupSeparator: ".",
unformatOnSubmit : true,
});
})
})
editor.on( 'preSubmit', function ( e, d, type ) {
if (d.data) {
Object.keys(d.data).forEach(function (key) {
// Find all elements with class .autonumeric
$("input.autonumeric").each(function () {
let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)
if (autoNumericInstance) {
// Get raw value and update the corresponding field
let rawValue = autoNumericInstance.getNumericString();
d.data[key][this.name] = rawValue; // Ensure the correct name attribute is used
}
});
});
}
if ( type === 'create'){
d.data[0]['tarifa_manipulado_id'] = id;
}
@ -184,9 +223,9 @@
async: true,
}),
columns: [
{ 'data': 'tirada_min' },
{ 'data': 'precio_max' },
{ 'data': 'tirada_max' },
{ 'data': 'tirada_min',render : (d) => `<span class="autonumeric">${d}</span>` },
{ 'data': 'precio_max', },
{ 'data': 'tirada_max',render : (d) => `<span class="autonumeric">${d}</span>` },
{ 'data': 'precio_min' },
{ 'data': 'margen' },
{
@ -245,7 +284,14 @@
);
} );
theTable.on('draw',() => {
AutoNumeric.multiple("span.autonumeric", {
digitGroupSeparator: ".",
decimalCharacter: ",",
decimalPlaces : 0,
unformatOnSubmit: true
});
})
// Delete row
$('#tableOfTarifamanipuladolineas').on( 'click', 'tbody span.remove', function (e) {

View File

@ -85,6 +85,8 @@ $picture = "/assets/img/default-user.png";
<!-- Helpers -->
<script src="<?= site_url('themes/vuexy/vendor/js/helpers.js') ?>"></script>
<script src="<?= site_url('themes/vuexy/js/config.js') ?>"></script>
<script src="<?= site_url('themes/vuexy/vendor/libs/autoNumeric/autoNumeric.min.js') ?>"></script>
</head>