/home/techb158/exp.abdallabala.com/ui/lib
Edit: /home/techb158/exp.abdallabala.com/ui/lib/quotes.js (9537B)
$(document).ready(function () {
$('.amount').autoNumeric('init');
var _url = $("#_url").val();
$('#invoice_items').on('change', 'select', function(){
// $('#taxtotal').html('dd');
var taxrate = $('#stax').val().replace(',', '.');
// $(this).val(taxrate);
});
var item_remove = $('#item-remove');
item_remove.hide();
function update_address(){
var cid = $('#cid').val();
if(cid != ''){
$.post(_url + 'contacts/render-address/', {
cid: cid
})
.done(function (data) {
var adrs = $("#address");
adrs.html(data);
});
}
}
update_address();
$('#cid').select2({
theme: "bootstrap",
language: {
noResults: function () {
return $("#_lan_no_results_found").val();
}
}
})
.on("change", function(e) {
// mostly used event, fired to the original element when the value changes
// log("change val=" + e.val);
// alert(e.val);
update_address();
});
item_remove.on('click', function(){
$("#invoice_items tr.info").fadeOut(300, function(){
$(this).remove();
calculateTotal();
});
});
var $modal = $('#ajax-modal');
$('#item-add').on('click', function(){
// create the backdrop and wait for next modal to be triggered
$('body').modalmanager('loading');
$modal.load( _url + 'ps/modal-list/', '', function(){
$modal.modal();
});
});
/*
/ @since v 2.0
*/
$('#contact_add').on('click', function(e){
e.preventDefault();
// create the backdrop and wait for next modal to be triggered
$('body').modalmanager('loading');
$modal.load( _url + 'contacts/modal_add/', '', function(){
$modal.modal();
$("#ajax-modal .country").select2({
theme: "bootstrap"
});
});
});
$('#blank-add').on('click', function(){
$("#invoice_items").find('tbody')
.append(
'
| | | | | |
'
);
});
$('#invoice_items').on('click', '.item_name', function(){
$("tr").removeClass("info");
$(this).closest('tr').addClass("info");
item_remove.show();
});
$modal.on('click', '.update', function(){
var tableControl= document.getElementById('items_table');
$modal.modal('loading');
$('input:checkbox:checked', tableControl).each(function() {
var item_code = $(this).closest('tr').find('td:eq(1)').text();
var item_name = $(this).closest('tr').find('td:eq(2)').text();
var item_price = $(this).closest('tr').find('td:eq(3)').text();
// obj.push(innertext);
$("#invoice_items").find('tbody')
.append(
'
| ' + item_code + ' | | | | | |
'
);
});
// console.debug(obj); // Write it to the console
// calculateTotal();
$modal.modal('hide');
});
$modal.on('click', '.contact_submit', function(e){
e.preventDefault();
// var tableControl= document.getElementById('items_table');
$modal.modal('loading');
// $modal.modal('loading');
var _url = $("#_url").val();
$.post(_url + 'contacts/add-post/', {
account: $('#account').val(),
address: $('#m_address').val(),
city: $('#city').val(),
state: $('#state').val(),
zip: $('#zip').val(),
country: $('#country').val(),
phone: $('#phone').val(),
email: $('#email').val()
})
.done(function (data) {
var _url = $("#_url").val();
if ($.isNumeric(data)) {
// location.reload();
window.location = _url + 'quotes/new/1/' + data + '/';
}
else {
$modal
.modal('loading')
.find('.modal-body')
.prepend('
' + data +
'' +
'
');
$("#cid").select2('data', {id: newID, text: newText});
}
});
});
$("#add_discount").click(function (e) {
e.preventDefault();
var s_discount_amount = $('#discount_amount');
var c_discount = s_discount_amount.val();
var c_discount_type = $('#discount_type').val();
var p_checked = "";
var f_checked = "";
if( c_discount_type == "p" ){
p_checked = 'checked="checked"';
}else{
f_checked = 'checked="checked"';
}
bootbox.dialog({
title: $("#_lan_set_discount").val(),
message: '
',
buttons: {
success: {
label: $("#_lan_btn_save").val(),
className: "btn-success",
callback: function () {
var discount_amount = $('#set_discount').val();
var discount_type = $("input[name='set_discount_type']:checked").val();
$('#discount_amount').val(discount_amount);
$('#discount_type').val(discount_type);
//calculateTotal();
//updateTax();
//updateTotal();
}
}
}
}
);
});
//var callbacks = $.Callbacks();
//callbacks.add( updateTotal );
//callbacks.fire( alert('done') );
$(".progress").hide();
$("#emsg").hide();
$("#submit").click(function (e) {
e.preventDefault();
$('#ibox_form').block({ message: null });
var _url = $("#_url").val();
$.post(_url + 'quotes/add-post/', $('#invform').serialize(), function(data){
var _url = $("#_url").val();
if ($.isNumeric(data)) {
window.location = _url + 'quotes/edit/' + data + '/';
}
else {
$('#ibox_form').unblock();
var body = $("html, body");
body.animate({scrollTop:0}, '1000', 'swing');
$("#emsgbody").html(data);
$("#emsg").show("slow");
}
});
});
//function doStuff() {
// $('.amount').autoNumeric('init');
// // alert('dd');
//}
//setInterval(doStuff, 5000);
});