/home/techb158/exp.abdallabala.com/ui/lib
NameSizeModeActions
ace/-0755rm
c3/-0755rm
chart/-0755rm
contacts/-0755rm
css/-0755rm
dashboard/-0755rm
dp/-0755rm
dropzone/-0755rm
dt/-0755rm
fc/-0755rm
fonts/-0755rm
footable/-0755rm
ibilling/-0755rm
icons/-0755rm
imgcrop/-0755rm
imgs/-0755rm
invoices/-0755rm
js/-0755rm
jslib/-0755rm
moment/-0755rm
multi-select/-0755rm
orders/-0755rm
popover/-0755rm
prism/-0755rm
redactor/-0755rm
s2/-0755rm
select/-0755rm
settings/-0755rm
sn/-0755rm
spectrum/-0755rm
terminal/-0755rm
tinymce/-0755rm
toggle/-0755rm
transactions/-0755rm
validator/-0755rm
.DS_Store102440644editdlrm
add-contact.js61050644editdlrm
app.js144100644editdlrm
blockui.js199120644editdlrm
clipboard.min.js101120644editdlrm
deposit.js64630644editdlrm
edit-invoice-v2.js172420644editdlrm
edit_invoice_v2n.js112360644editdlrm
expense.js38250644editdlrm
ibilling.js6250440644editdlrm
index.html1120644editdlrm
invoice.js157390644editdlrm
invoice_add_v2.js113600644editdlrm
jquery.steps.min.js136340644editdlrm
locale.js4010644editdlrm
login.js14610644editdlrm
modal.css46960644editdlrm
modal.js266340644editdlrm
numeric.js636160644editdlrm
profile.js145530644editdlrm
progress.js61670644editdlrm
quicksearch.js54620644editdlrm
quote-edit.js104330644editdlrm
quotes.js95370644editdlrm
require.js155240644editdlrm
tr-manage.js26150644editdlrm
transfer.js17020644editdlrm
tr_filter.js36070644editdlrm
typeahead.bundle.min.js397490644editdlrm
Edit: /home/techb158/exp.abdallabala.com/ui/lib/invoice.js (15739B)
$(document).ready(function () { $('#notes').redactor( { minHeight: 200, // pixels plugins: ['fontcolor'] } ); var _url = $("#_url").val(); function updateTax() { var sub_total = parseFloat($("#sub_total").html().replace(',', '.')); var discount = parseFloat($("#discount_amount_total").html().replace(',', '.')); var sub_total_after_discount = sub_total - discount; var ltbal = parseFloat($('#stax').val().replace(',', '.')); var tbal = (sub_total_after_discount*ltbal)/100; var ftbal = parseFloat(tbal).toFixed(2); var _dec_point = $("#_dec_point").val(); if(_dec_point == ','){ ftbal = ftbal.replace(".", ","); } else{ ftbal = ftbal.replace(",", "."); } $('#taxtotal').html(ftbal); } function updateTotal() { var s_discount_amount = $('#discount_amount'); var c_discount = s_discount_amount.val().replace(',', '.'); if(c_discount == ''){ c_discount = '0'; } var c_discount_type = $('#discount_type').val(); var d_a_t = $("#discount_amount_total"); var s_t = $("#sub_total"); var is_pt = $("#is_pt"); if( c_discount_type == "p" ){ var ut_st = parseFloat(s_t.html().replace(',', '.')); var ut_c = parseFloat(c_discount); var ut_pt = (ut_st * ut_c)/100; var ut_pt_f = parseFloat(ut_pt).toFixed(2); d_a_t.html(ut_pt_f); if(c_discount != "0"){ is_pt.html("(" + s_discount_amount.val() + "%)"); } }else{ d_a_t.html(c_discount); is_pt.html(""); } // =================================== var total = 0; var d_a_t_val = parseFloat(d_a_t.html().replace(',', '.')); var d_a_t_val_to = parseFloat(d_a_t_val).toFixed(2); var sub_total = parseFloat(s_t.html().replace(',', '.')); var tax_total = parseFloat($("#taxtotal").html().replace(',', '.')); // var disc_amount = parseFloat(c_discount.replace(',', '.')); if( !isNaN( sub_total ) ) { total = sub_total - d_a_t_val_to + tax_total; } ftbal = parseFloat(total).toFixed(2).replace(',', '.'); var _dec_point = $("#_dec_point").val(); if(_dec_point == ','){ ftbal = ftbal.replace(".", ","); } $('#total').html(ftbal); } $('#tid').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); var tid = this.value; if(tid != ''){ var _url = $("#_url").val(); $.post(_url + 'tax/rate/', { tid: tid }) .done(function (data) { // $('.taxed').val(data); // $('#stax').val(data).replace(',', '.'); // @since v2 $('#stax').val(data); calculateTotal(); updateTax(); }); } else{ $('#stax').val('0.00'); calculateTotal(); updateTax(); updateTotal(); } }); $('#invoice_items').on('change', 'select', function(){ // $('#taxtotal').html('dd'); var taxrate = $('#stax').val().replace(',', '.'); // $(this).val(taxrate); updateTax(); updateTotal(); }); var item_remove = $('#item-remove'); item_remove.hide(); function calculateTotal() { var sum = 0, tbl = $('#invoice_items'); tbl.find('.lvtotal').each(function( index, elem ) { var val = parseFloat($(elem).val().replace(',', '.')); if( !isNaN( val ) ) { sum += val; } }); $('.qty').keyup(function(){ var u_qty = $(this).val(); var u_price = $(this).closest('tr').find(".item_price").val().replace(',', '.'); if( !isNaN( u_qty ) ) { var n_ltotal = u_qty*u_price; n_ltotal = n_ltotal.toFixed(2); var _dec_point = $("#_dec_point").val(); if(_dec_point == ','){ n_ltotal = String(n_ltotal); n_ltotal = n_ltotal.replace(".", ","); } $(this).closest('tr').find(".lvtotal").val(n_ltotal); calculateTotal(); } $('.amount').autoNumeric('init'); }); $('.item_price').keyup(function(){ var u_qty = $(this).closest('tr').find(".qty").val().replace(',', '.'); var u_price = $(this).val().replace(',', '.'); if( !isNaN( u_price ) ) { var n_ltotal = u_qty*u_price; n_ltotal = n_ltotal.toFixed(2); var _dec_point = $("#_dec_point").val(); if(_dec_point == ','){ n_ltotal = String(n_ltotal); n_ltotal = n_ltotal.replace(".", ","); } $(this).closest('tr').find(".lvtotal").val(n_ltotal); calculateTotal(); } }); // tbl.find('input.total').html(sum.toFixed(2)); var _dec_point = $("#_dec_point").val(); if(_dec_point == ','){ sum = sum.toFixed(2); sum = sum.replace(".", ","); } $("#sub_total").html(sum); //calculate tax updateTax(); updateTotal(); } function update_address(){ var _url = $("#_url").val(); 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( ' ' ); calculateTotal(); }); $('#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'); $modal.modal('loading'); //$modal // .modal('loading') // .find('.modal-body') // .prepend('
' + // 'Updated!' + // '
'); // var obj = new Array(); $('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'); var _url = $("#_url").val(); $.post(_url + 'contacts/add-post/', { account: $('#account').val(), company: $('#company').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(); var is_recurring = $('#is_recurring').val(); if(is_recurring == 'yes'){ window.location = _url + 'invoices/add/recurring/' + data + '/'; } else{ window.location = _url + 'invoices/add/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 + 'invoices/add-post/', $('#invform').serialize(), function(data){ var sbutton = $("#submit"); var _url = $("#_url").val(); if ($.isNumeric(data)) { window.location = _url + 'invoices/view/' + 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); });