Hi, I have a small problem:
I have my table in my BD called numeracion
, in which is the field numeracion
in it I have the numbers of the tickets or invoices;
id_numercion numeracion id_estado
---------- ---------- ----------
1 1 1
2 2 1
3 3 1
This is the QUERY FORMED WITH THE DIFFERENT TABLES as you see there is a beginning and an end
Well that's the table, in my JQuery
I get the highest numbering, for example the 3
but that number grows up to 500
,
What I want is that by pulling the number in this case the 3
put it in my div
as 003
and when it reaches 10
put it as 010
This is my ajax in jQuery
function traer_numeracion(id_recibo) {
// console.log(id_recibo);
$.ajax({
type: 'POST',
url: baseurl + 'Venta/traer_numero',
data: {id_recibo: id_recibo},
cache: false,
dataType: "JSON",
success: function (data)
{
var numero = data[0]['numeracion']
if (numero == null || numero == "") {
//si el valor esta vacio me pone el valor por defecto que es 1
$('#numero_recibo').html("Nº " + data[0]['serie'] + '-' + data[0]['numero_inicio']);
$('#id_numeracion').val(data[0]['id_serie']);
$('#numeracion_data').val(data[0]['numero_inicio']);
} else {
console.log(numero.length);
numero = parseInt(numero) + 1;
$('#numero_recibo').html("Nº " + data[0]['serie'] + '-' + numero);
$('#id_numeracion').val(data[0]['id_serie']);
$('#numeracion_data').val(numero);
}
},
error: function (result) {
}
});
}