173 lines
4.9 KiB
JavaScript
173 lines
4.9 KiB
JavaScript
|
|
// Számlaszám ellenőrzése
|
|
$( "#invoiceNumber" ).on('input',function( event ) {
|
|
/*if ( event.which == 13 ) {
|
|
event.preventDefault();
|
|
}*/
|
|
console.log('Jájj genyó!');
|
|
var ctrl=document.getElementById("invoiceNumber");
|
|
var btn=document.getElementById("btnsave");
|
|
$.get('/invoices/checkinvoicenumber/'+ctrl.value,function(invoices){
|
|
// console.log(invoices);
|
|
if(invoices==='reserved')
|
|
{
|
|
btn.disabled=true;
|
|
ctrl.style.backgroundColor='red';
|
|
}
|
|
if(invoices==='free')
|
|
{
|
|
btn.disabled=false;
|
|
ctrl.style.backgroundColor='#2C3446';
|
|
}
|
|
|
|
})
|
|
/*$.ajax({
|
|
type: 'POST',
|
|
data: JSON.stringify(data),
|
|
|
|
contentType: "application/json",
|
|
dataType:'json',
|
|
url: '/checkinvoicenumber',
|
|
success: function(data) {
|
|
console.log('success');
|
|
console.log(JSON.stringify(data));
|
|
},
|
|
error: function(error) {
|
|
console.log("some error in fetching the notifications");
|
|
}
|
|
|
|
}).done (function (data) {
|
|
|
|
|
|
if (data.status === 200) {
|
|
|
|
console.log(data.data);
|
|
}
|
|
|
|
});*/
|
|
});
|
|
// Dropdown selection show
|
|
$(".dropdown-menu li a").on('click',function(){
|
|
$(this).parents(".dropdown").find('.btn').html($(this).text() + ' <span class="caret"></span>');
|
|
$(this).parents(".dropdown").find('.btn').val($(this).data('value'));
|
|
document.getElementById('currencyl').setAttribute('value',$(this).text());
|
|
|
|
/* var number = Number($("#nPrice").val().replace(/[^0-9,.-]+/g,"").replace(/[^0-9.-]+/g,"."));
|
|
var price=parseFloat(number);
|
|
// var inputValue = parseInt(price.replace(/\D/g, ''),10);
|
|
if ($(this).data('value')==='HUF')
|
|
{
|
|
$("#nPrice").val(price.toLocaleString('hu-HU'));
|
|
}
|
|
if ($(this).data('value')==='EUR')
|
|
{
|
|
$("#nPrice").val(price.toLocaleString('de-DE'));
|
|
}
|
|
if ($(this).data('value')==='USD')
|
|
{
|
|
$("#nPrice").val(price.toLocaleString('us-US'));
|
|
}
|
|
console.log($(this).data('value'))*/
|
|
});
|
|
$("#ed").on('input',function(){
|
|
var remDays=$('#ed').val();
|
|
var date = new Date($('#emDate').val());
|
|
|
|
var newdate = new Date(date);
|
|
|
|
newdate.setDate(newdate.getDate() + parseInt(remDays));
|
|
|
|
$('#datetimepicker2').data("DateTimePicker").date(newdate);
|
|
$('#datetimepicker2').data("DateTimePicker").minDate(date);
|
|
})
|
|
/*$("#nPrice").on('input',function(){
|
|
var price=$("#nPrice").val();
|
|
if (isPositiveInteger(price))
|
|
{
|
|
$(this).css({ 'background': '#2C3446' });
|
|
}else
|
|
{
|
|
$(this).css({ 'background': 'tomato' });
|
|
}
|
|
})*/
|
|
function thousands_separators(num)
|
|
{
|
|
var i=0;
|
|
var num_parts = num.toString().split(".");
|
|
num_parts[0] = num_parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, " ");
|
|
num_parts.forEach(function(element){
|
|
if (i>0)
|
|
{
|
|
element.replace(/./g, '')
|
|
}
|
|
i++;
|
|
})
|
|
return num_parts.join(".");
|
|
}
|
|
nPrice.addEventListener("keyup", myScript);
|
|
|
|
function myScript(event){
|
|
var priceString=nPrice.value.replace(/,/g, '.').replace(/\s/g, '');
|
|
//document.getElementById('container').innerHTML = Number(priceString);
|
|
nPrice.value=thousands_separators(priceString);
|
|
}
|
|
/*
|
|
$("#nPrice").focusout(function(){
|
|
var number = Number($("#nPrice").val().replace(/[^0-9,.-]+/g,"").replace(/[^0-9.-]+/g,"."));
|
|
var price=parseFloat(number);
|
|
// var inputValue = parseInt(price.replace(/\D/g, ''),10);
|
|
if ($('#currencyb').val()==='HUF')
|
|
{
|
|
$("#nPrice").val(price.toLocaleString('hu-HU'));
|
|
}
|
|
if ($('#currencyb').val()==='EUR')
|
|
{
|
|
$("#nPrice").val(price.toLocaleString('de-DE'));
|
|
}
|
|
if ($('#currencyb').val()==='USD')
|
|
{
|
|
$("#nPrice").val(price.toLocaleString('us-US'));
|
|
}
|
|
|
|
console.log(price);
|
|
});*/
|
|
|
|
/*
|
|
|
|
// When ready.
|
|
$(function() {
|
|
|
|
var $form = $( "#receiptsNew" );
|
|
var $input = $( "#nPrice" );
|
|
|
|
$input.on( "keyup", function( event ) {
|
|
|
|
|
|
// When user select text in the document, also abort.
|
|
var selection = window.getSelection().toString();
|
|
if ( selection !== '' ) {
|
|
return;
|
|
}
|
|
|
|
// When the arrow keys are pressed, abort.
|
|
if ( $.inArray( event.keyCode, [38,40,37,39] ) !== -1 ) {
|
|
return;
|
|
}
|
|
|
|
|
|
var $this = $( this );
|
|
|
|
// Get the value.
|
|
var input = $this.val();
|
|
|
|
//var input = input.replace(/[\s\_\-]|[^0-9.]+/g, "");
|
|
input = input ? parseFloat( input.replace(/\s/g, ''), 10 ) : 0;
|
|
|
|
$this.val( function() {
|
|
return ( input === 0 ) ? "" : input.toLocaleString( "hu-HU" );
|
|
} );
|
|
} );
|
|
|
|
|
|
});
|
|
*/ |