?
Current Path : /home1/savoy/public_html/savoyglobal.net/sec/draft/application/views/ |
Linux gator3171.hostgator.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 |
Current File : /home1/savoy/public_html/savoyglobal.net/sec/draft/application/views/commonfunctions.php |
<script type="text/javascript"> function post(id, model_function, page) { $.ajax({ type: "GET", dataType: "json", url: "<?= site_url('accounting/post_data/') ?>/" + id, success: function(msg) { alert('Posted Successfully'); $.fn.colorbox.close(); viewdata('accounting', 'viewinaccountingsearch', model_function, page, '1'); } }); } function view_alert() { var divid="inner_content"; $("#"+divid).empty().html('<CENTER><img src="<?= base_url() ?>assets/img/loading.gif" class="loading"/></CENTER>'); $("#"+divid).load("<?= site_url() ?>/"+'settings'+'/'+'show_alert'+'/'+'display_alert'); } function checkamount(id) { var val= $('#' + id).val(); if (val <= 0) { alert('Amount should be greater than zero.'); $('#' + id).val(""); } } function view_student_alert(page,batch_id) { $("#alert_student_fee").empty().html('<CENTER><img src="<?= base_url() ?>assets/img/loading.gif" class="loading"/></CENTER>'); $("#alert_student_fee").load("<?= site_url() ?>/master/student_fee_alert/"+page+"/"+batch_id); } function viewdata(controller,controllerfunction,modelfunction,page,pagenum) { if(arguments[5]) { var divid=arguments[5]; } else { var divid="inner_content"; } $("#"+divid).empty().html('<CENTER><img src="<?= base_url() ?>assets/img/loading.gif" class="loading"/></CENTER>'); $("#"+divid).load("<?= site_url() ?>/"+controller+'/'+controllerfunction+'/'+modelfunction+'/'+page+'/'+pagenum); } function addformdisplay(page,directory) { $("#inner_content").empty().html('<CENTER><img src="<?= base_url() ?>assets/img/loading.gif" class="loading"/></CENTER>'); $("#inner_content").load("<?= site_url('master/addformdisplay/') ?>/" +page+'/'+directory); } function editformdata(controller,controllerfunction,id,table,field,page) { $("#inner_content").empty().html('<CENTER><img src="<?= base_url() ?>assets/img/loading.gif" class="loading"/></CENTER>'); $("#inner_content").load("<?= site_url() ?>/"+controller+'/'+controllerfunction+'/'+id+'/'+table+'/'+field+'/'+page); } // function process_thisunpost(id){ // $("#inner_content").empty().html('<CENTER><img src="<?= base_url() ?>/assets/img/loading.gif" class="loading"/></CENTER>'); // $("#inner_content").load("<?= site_url('accounting/post_unposted_postdated_cheque/') ?>" +"/" + id); // } function displayformdata(controller,controllerfunction,id,table,field,page) { $("#inner_content").empty().html('<CENTER><img src="<?= base_url() ?>assets/img/loading.gif" class="loading"/></CENTER>'); $("#inner_content").load("<?= site_url() ?>/"+controller+'/'+controllerfunction+'/'+id+'/'+table+'/'+field+'/'+page); } function gotopage(controller,controllerfunction,id,table,field,page,returnpage) { $("#inner_content").empty().html('<CENTER><img src="<?= base_url() ?>assets/img/loading.gif" class="loading"/></CENTER>'); $("#inner_content").load("<?= site_url() ?>/"+controller+'/'+controllerfunction+'/'+id+'/'+table+'/'+field+'/'+page+'/'+returnpage); } function displayformdata1(controller,controllerfunction,id,table,field,page,returnpage) { $("#uploaddiv").empty().html('<CENTER><img src="<?= base_url() ?>assets/img/loading.gif" class="loading"/></CENTER>'); $("#uploaddiv").load("<?= site_url() ?>/"+controller+'/'+controllerfunction+'/'+id+'/'+table+'/'+field+'/'+page+'/'+returnpage); $(".inliexample2").colorbox({width:"90%",height:"90%", inline:true, href:"#uploaddiv"}); } function display_alert(controller,controllerfunction,id,table,field,page) { $("#alert_show").empty().html('<CENTER><img src="<?= base_url() ?>assets/img/loading.gif" class="loading"/></CENTER>'); $("#alert_show").load("<?= site_url() ?>/"+controller+'/'+controllerfunction+'/'+id+'/'+table+'/'+field+'/'+page); } function viewformdata(controller,controllerfunction,id) { $("#inner_content").empty().html('<CENTER><img src="<?= base_url() ?>assets/img/loading.gif" class="loading"/></CENTER>'); $("#inner_content").load("<?= site_url() ?>/" +controller+'/'+controllerfunction+'/'+id); } function deletedata(deltable,id,delfield,controller,controllerfunction,modelfunction,page,table,field,value) { var clicked = function(){ if(value) { var val=value; } else { var val= id; } if(table != "" && field != "") { $.ajax({ type: "POST", dataType:"json", url: "<?= site_url('master/checkexistencearray/') ?>/" +table+'/'+field+'/'+val, success: function(msg){ if(msg!=0) { alert("Record cannot be deleted due to associated data"); } else { $.ajax({ type: "POST", dataType:"json", url: "<?= site_url('master/deletedata/') ?>/"+deltable+"/"+id+"/"+delfield, success: function(msg) { viewdata(controller,controllerfunction,modelfunction,page,'1'); } }); alert('Record Deleted Successfully!!!'); } } }); } else { $.ajax({ type: "GET", dataType:"json", url: "<?= site_url('master/deletedata/') ?>/"+deltable+"/"+id+"/"+delfield, success: function(msg){ alert('Record Deleted Successfully!!!'); viewdata(controller,controllerfunction,modelfunction,page,'1'); } }); } }; if(confirmDelete()) { clicked(); } } function confirmDelete() { if (confirm("Are you sure you want to delete")) return 1; else return 0; } function addformdata1(formid) { if(callvalidate(formid)) { return true; }else{ return false; } } function addformdata(formid) { if(arguments[1]) { var divid=arguments[1]; } else { var divid="inner_content"; } if(callvalidate(formid)) { $('.customForm,.validate').ajaxForm({ beforeSubmit:function(){ $('button[type="submit"]').attr('disabled', 'disabled'); return true; }, success: function(data) { $("#"+divid).html(data); $('html, body, #'+divid).animate({scrollTop:0}, 'slow'); $('#table-example').dataTable(); } }); return false; } else { return false; } } function callvalidate(formid) { $("#"+formid).validate(); return $("#"+formid).valid(); } function suggestemployee(divid) { $("#"+divid).autocomplete("<?= site_url() ?>/master/autosuggestemployee/", { width: 250, selectFirst: false }); } function suggestStudent(divid) { $(divid).autocomplete("<?= site_url() ?>/master/autosuggeststudent/", { width: 250, selectFirst: false }); } function suggestStudentDetails(div){ $('#stud_details').css('display','none'); $(div).autocomplete("<?= site_url() ?>/master/autosuggeststudent/", { width: 250, selectFirst: false, onCallBack: function(id,index) { if(id!="") { $.ajax({ type: "POST", dataType:"json", url: "<?= site_url('master/getStudentDetails/') ?>/"+id, success: function(data) { $('#stud_details').css('display','block'); $('#stud_gender').val(data.gender); $('#stud_reg').val(data.reg_no); } }); } else { $('#stud_details').css('display','none'); $('#stud_gender,#stud_reg').val(''); } } }); } function set_fiscal_year_current(fiscal_year_id) { $.ajax({ type: "POST", dataType: "json", url: "<?= site_url('master/checkexistencearray/') ?>/finance_fiscal_year/fiscal_year_id" + '/' + fiscal_year_id, success: function(msg) { $.ajax({ type: "POST", dataType: "json", url: "<?= site_url('accounting/set_fiscal_year_current/') ?>/" + fiscal_year_id, success: function() { viewdata('accounting', 'viewinaccountingsearch', 'search_fiscal_year', 'view_fiscal_year', '1'); } }); } }); } function checkexistence(table,field,value) { $("#success-panel").empty().html('<CENTER><img src="<?= base_url() ?>assets/img/loading.gif" class="loading"/></CENTER>'); $("#success-panel").load("<?= site_url('master/checkexistence/') ?>/" +table+'/'+field+'/'+value,function(data){ if(data==1) { $("input#"+field).val(""); $("select#"+field).val(""); $("#"+field).css('border','solid 1px red'); $("#"+field).focus(); $("#success-panel").fadeIn(900,0); $("#success-panel").html("Duplicate Entry Recorded"); $("#success-panel").fadeOut(2000,0); } else { $("#"+field).css('border','solid 1px gray'); } }); } function checkdata(id, className, comment) { var numItems = $('.' + className).length var i = 1; var flag = 1; for (i = 1; i <= numItems; i++) { if ($('input#' + id + '_id' + i).val() == "") { flag = 0; $('input#' + id + i).val(""); } } if (flag == 0) { alert(comment) return false; } else return true } function checkdatavalidity(jid, field, comment) { if (jid == "") { alert(comment) $('input#' + field).val(""); return false; } else { return true; } } function empty_text(tag) { $('#'+tag).val(""); } function remove_alert(id) { var clicked = function(){ $.fallr('hide'); $.ajax({ type: "GET", dataType:"json", url: "<?= site_url('settings/remove_alert/') ?>/"+'alert'+"/"+id+"/alert_id", success: function(msg){ viewdata('settings','viewinsettingssearch','search_alert','view_alert','1'); } }); }; $.fallr('show', { buttons : { button1 : {text: 'Yes', danger: true, onclick: clicked}, button2 : {text: 'Cancel', onclick: function(){$.fallr('hide')}} }, content : '<p>Are you sure you want to remove ?</p>', icon : 'error' }); } function calculteAllallowancetotal(val,mode,count,emp_id){ var basicsalary=$("input#basic_salary_"+emp_id).val(); if(!basicsalary) { alert("Please set basic salary") $('input#amount_'+emp_id+'_'+count).val(''); } else { if(mode==0) { val=parseFloat(basicsalary)*parseFloat(val)*0.01; } $('input#alltotal_'+emp_id+'_'+count).val(val); var allowcount=$("input#allowcount_"+emp_id).val(); var deduction=$("input#deduction_"+emp_id).val(); var sumallow=0; for(var i=1;i<allowcount;i++) { var allowamount=$("input#alltotal_"+emp_id+i).val(); if(allowamount) sumallow+=parseFloat(allowamount); } $('input#allowance_'+emp_id).val(sumallow); var commission=$("input#commission_").val(); var grosssalary=parseFloat(sumallow)+parseFloat(basicsalary); var netsalary=parseFloat(grosssalary)-parseFloat(deduction); var payamount=parseFloat(netsalary)+parseFloat(commission); $('input#grosssalary_'+emp_id).val(grosssalary); $('input#netsalary_'+emp_id).val(netsalary); $('input#payamount_'+emp_id).val(payamount); } } function calculteallowancetotal(val,mode,count) { var basicsalary=$("input#basic_salary").val(); if(!basicsalary) { alert("Please set basic salary") $('input#amount_'+count).val(''); } else { if(mode==0) { val=parseFloat(basicsalary)*parseFloat(val)*0.01; } $('input#alltotal_'+count).val(val); var allowcount=$("input#allowcount").val(); var deduction=$("input#deduction").val(); var sumallow=0; for(var i=1;i<allowcount;i++) { var allowamount=$("input#alltotal_"+i).val(); if(allowamount) sumallow+=parseFloat(allowamount); } $('input#allowance').val(sumallow); var commission=$("input#commission").val(); var grosssalary=parseFloat(sumallow)+parseFloat(basicsalary); var netsalary=parseFloat(grosssalary)-parseFloat(deduction); var payamount=parseFloat(netsalary)+parseFloat(commission); $('input#grosssalary').val(grosssalary); $('input#netsalary').val(netsalary); $('input#payamount').val(payamount); } } function calcultedeductiontotal(val,mode,count) { var basicsalary=$("input#basic_salary").val(); if(!basicsalary) { alert("Please set basic salary"); $("input#amount_"+count).val(''); } else { if(mode==0) { val=parseFloat(basicsalary)*parseFloat(val)*0.01; } $("input#dedtotal_"+count).val(val); var dedcount=$("input#dedcount").val(); var allowance=$("input#allowance").val(); var sumded=0; for(var i=1;i<dedcount;i++) { var dedamount=$("input#dedtotal_"+i).val(); if(dedamount) sumded+=parseFloat(dedamount); } $('input#deduction').val(sumded); var commission=$("input#commission").val(); var grosssalary=parseFloat(allowance)+parseFloat(basicsalary); var netsalary=parseFloat(grosssalary)-parseFloat(sumded); var payamount=parseFloat(netsalary)+parseFloat(commission); $('input#grosssalary').val(grosssalary); $('input#netsalary').val(netsalary); $('input#payamount').val(payamount); } } function calculteAlldeductiontotal(val,mode,count,emp_id) { var basicsalary=$("input#basic_salary_"+emp_id).val(); if(!basicsalary) { alert("Please set basic salary"); $("input#amount_"+emp_id+'_'+count).val(''); } else { if(mode==0) { val=parseFloat(basicsalary)*parseFloat(val)*0.01; } $("input#dedtotal_"+emp_id+"_"+count).val(val); var dedcount=$("input#dedcount_"+emp_id).val(); var allowance=$("input#allowance_"+emp_id).val(); var sumded=0; for(var i=1;i<dedcount;i++) { var dedamount=$("input#dedtotal_"+emp_id+"_"+i).val(); if(dedamount) sumded+=parseFloat(dedamount); } $('input#deduction_'+emp_id).val(sumded); var commission=$("input#commission_"+emp_id).val(); var grosssalary=parseFloat(allowance)+parseFloat(basicsalary); var netsalary=parseFloat(grosssalary)-parseFloat(sumded); var payamount=parseFloat(netsalary)+parseFloat(commission); $('input#grosssalary_'+emp_id).val(grosssalary); $('input#netsalary_'+emp_id).val(netsalary); $('input#payamount_'+emp_id).val(payamount); } } function changebasicsalary(val) { var allowance=$("input#allowance").val(); var deduction=$("input#deduction").val(); var grosssalary=parseFloat(allowance)+parseFloat(val); var netsalary=parseFloat(grosssalary)-parseFloat(deduction); $('input#grosssalary').val(grosssalary); $('input#netsalary').val(netsalary); } function calculateAllpayamount(commission_amount,emp_id) { var netsalary=$("input#netsalary_"+emp_id).val(); var payamount=parseFloat(netsalary)+parseFloat(commission_amount); $('input#payamount_'+emp_id).val(payamount); } function calculatepayamount(commission_amount) { var netsalary=$("input#netsalary").val(); var payamount=parseFloat(netsalary)+parseFloat(commission_amount); $('input#payamount').val(payamount); } function empty_div(divid) { $('#' + divid).val(""); } // function change_leave_status(status,id) // { // $.ajax({ // type: "GET", // dataType:"json", // url: "<?= site_url('hr/leave_approval/') ?>/"+id+"/"+status, // success: function(msg){ // viewdata('hr','viewinhrsearch','search_leave_application','view_leave_application','1'); // } // }); // } function leave_approval(id) { $.fallr('show', { buttons : { button1 : {text: 'Approve', danger: false, onclick: function() { $.fallr('hide'); change_leave_status('Approved',id); }}, button2 : {text: 'Reject', danger: true, onclick: function(){ $.fallr('hide'); change_leave_status('Reject',id); }}, button3 : {text: 'Cancel', onclick: function(){$.fallr('hide')}} }, content : '<p>Are you sure you want to Approve ?</p>', icon : 'Confirm-like' }); } function showPreloader(divid) { $("#"+divid).empty().html('<CENTER><img src="<?= base_url() ?>assets/img/loading.gif" class="loading"/></CENTER>'); } function hidePreloader(divid) { $("#"+divid).empty().html(''); } function suggestmainaccount(divattr) { $(divattr).autocomplete("<?= site_url() ?>/master/autosuggestmainaccount/", { width: 250, selectFirst: false }); } function checkfiscalyear() { $.ajax({ type: "POST", url: "<?= site_url('accounting/checkaccountisset_fiscalyear/') ?>", success: function(msg) { if (msg == 0) { $("#viewmsg").fadeIn(900, 0); $("#viewmsg").html("<div style=\"padding-top: 3px;border:1px solid red;text-align:center; width:400px;height:20px;margin-left:30%\" ><font color=\"red\" >Set the fiscal year to process payment OR Fiscal Year is Closed</font></div>"); $('button[type=submit]#button1').attr('disabled', 'disabled'); } else if (msg == -1) { $("#viewmsg").fadeIn(900, 0); $("#viewmsg").html("<div style=\"padding-top: 3px;border:1px solid red;text-align:center; width:400px;height:20px;margin-left:30%\" ><font color=\"red\" >Set the currency to process payment</font></div>"); $('button[type=submit]#button1').attr('disabled', 'disabled'); } else { $("#viewmsg").css('display', 'none'); } } }); } function suggestaccount(divid) { $(divid).autocomplete("<?= site_url() ?>/master/autosuggestaccount/", { width: 250, selectFirst: false }); } function suggestchartaccount(divid) { $(divid).autocomplete("<?= site_url() ?>/master/autosuggestchartaccount/", { width: 250, selectFirst: false }); } function suggest_bank_account(divid) { $(divid).autocomplete("<?= site_url() ?>/master/autosuggestbankaccount/", { width: 250, selectFirst: false }); } function select_payment_mode(val, divid,transaction_type) { $("#" + divid).empty().html('<CENTER><img src="<?= base_url() ?>assets/img/loading.gif" class="loading"/></CENTER>'); $("#" + divid).load("<?= site_url() ?>/" + 'accounting' + '/' + 'show_payment_type' + '/' + val+"/"+transaction_type,function(data){ if(val > 1) $('#div_payment_details').show('slow'); else $('#div_payment_details').hide('slow'); }); } function validateRow() { var flag = 0; var rowTotal = $('table tr.addAccount ').length; var i = 1; for (i = 1; i <= rowTotal; i++) { var debit = $('#debit' + i).val(); var credit = $('#credit' + i).val(); debit = (debit < 1) ? '0' : debit; credit = (credit < 1) ? '0' : credit; if ((debit >= 1 && credit >= 1) || (debit == credit)) { flag = 1; alert('Enter any one (credit or debit) at a time'); return false; } if ($('#account_id' + i).val() == "") { $('#account' + i).val(""); alert('Enter valid Account'); flag = 1; return false; } } if (flag == 0) { return true } } function validateAmount(obj) { var RowIndex = $(obj).parents('table tbody tr.addAccount ').index() + 1; var debit = $('#debit' + RowIndex).val(); var credit = $('#credit' + RowIndex).val(); debit = (debit < 1) ? '0' : debit; credit = (credit < 1) ? '0' : credit; obj.value=(obj.id == 'debit' + RowIndex) ? parseFloat(debit).toFixed(2):parseFloat(credit).toFixed(2); if ((debit >= 1 && credit >= 1) || (debit == credit)) { if ($('#debit' + RowIndex).val() != '' && $('#credit' + RowIndex).val() != '') alert('enter any one(credit or debit) at a time'); obj.value = '0'.toFixed(2); } getSum(); } function getSum() { var rowTotal = $('table tr.addAccount ').length; var sumDebit = 0; var sumCredit = 0; var i = 1; for (i = 1; i <= rowTotal; i++) { var debit = $('#debit' + i).val(); var credit = $('#credit' + i).val(); debit = (debit < 1) ? '0' : debit; credit = (credit < 1) ? '0' : credit; sumDebit += parseFloat(debit); sumCredit += parseFloat(credit); } $('#sumdebit').val(sumDebit.toFixed(2)); $('#sumcredit').val(sumCredit.toFixed(2)); } function insertpayment() { var debit = document.getElementById('sumdebit').value; var credit = document.getElementById('sumcredit').value; var flag=1; if ( debit != credit ) { alert('Total credit and Debit Does not match'); flag=0; return false; } else if (credit <= 0 || debit <= 0) { alert('Add atleast one debit and credit account'); flag=0; return false; } if(!validateRow()) { flag=0; return false; } if(flag==1){ addformdata('validateform') } return flag; } function check_unique_cheque(transaction_type,cheque_no_prev){ if(transaction_type=="PV"){ var cheque_no=$('#cheque_no').val(); if(cheque_no!=""){ $.ajax({ type: "POST", dataType:"json", url: "<?= site_url() ?>/accounting/check_unique_cheque_no/"+cheque_no+"/"+cheque_no_prev, success: function(msg){ if(msg>0){ $('#cheque_no').val(''); $("#cheque_no_info").fadeIn(900,0); $("#cheque_no_info").html('Cheque already issued'); $("#cheque_no_info").fadeOut(2000,0); } } }); } } } function generateReport(url){ $('form').attr('action', '<?= site_url() ?>/'+url); $('form').submit; } function generate_pdf(url){ $('#report_div').html(''); if(callvalidate('validateform')){ $.ajax({ type: "POST", url: '<?= site_url() ?>/'+url, data: $('form').serialize(), success: function(msg){ if(msg==0){ alert("No result Found"); }else{ $('#report_div').html(msg); } } }); } } </script>