X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=sales%2Fcustomer_payments.php;h=d0a0ea8b04e0038429615fdd88c108e1af5f68b2;hb=03dbf580a48b9831dfb6fcbf8c34e1315c26a99e;hp=e73cccd1a5b6b745375200c1b9354b48f284d144;hpb=f75695448532371e64f0d3033b88389a62d41da3;p=fa-stable.git diff --git a/sales/customer_payments.php b/sales/customer_payments.php index e73cccd1..d0a0ea8b 100644 --- a/sales/customer_payments.php +++ b/sales/customer_payments.php @@ -76,8 +76,10 @@ if (list_updated('BranchID')) { $Ajax->activate('customer_id'); } -if (!isset($_POST['customer_id'])) - $_POST['customer_id'] = get_global_customer(false); +if (!isset($_POST['customer_id'])) { + $_SESSION['alloc']->person_id = $_POST['customer_id'] = get_global_customer(false); + $_SESSION['alloc']->read(); +} if (!isset($_POST['DateBanked'])) { $_POST['DateBanked'] = new_doc_date(); if (!is_date_in_fiscalyear($_POST['DateBanked'])) { @@ -97,8 +99,10 @@ if (isset($_GET['AddedID'])) { // hyperlink_params($path_to_root . "/sales/allocations/customer_allocate.php", _("&Allocate this Customer Payment"), "trans_no=$payment_no&trans_type=12"); + hyperlink_no_params($path_to_root . "/sales/inquiry/customer_allocation_inquiry.php?customer_id=", _("Select Another &Customer Transaction for Payment")); + hyperlink_no_params($path_to_root . "/sales/customer_payments.php", _("Enter Another &Customer Payment")); - + display_footer_exit(); } elseif (isset($_GET['UpdatedID'])) { @@ -112,8 +116,10 @@ elseif (isset($_GET['UpdatedID'])) { // hyperlink_params($path_to_root . "/sales/allocations/customer_allocate.php", _("&Allocate this Customer Payment"), "trans_no=$payment_no&trans_type=12"); + hyperlink_no_params($path_to_root . "/sales/inquiry/customer_inquiry.php?", _("Select Another Customer Payment for &Edition")); + hyperlink_no_params($path_to_root . "/sales/customer_payments.php", _("Enter Another &Customer Payment")); - + display_footer_exit(); } @@ -211,6 +217,8 @@ function can_process() set_focus('discount'); return false; } + if (!db_has_currency_rates(get_customer_currency($_POST['customer_id']), $_POST['DateBanked'], true)) + return false; $_SESSION['alloc']->amount = input_num('amount'); @@ -222,13 +230,6 @@ function can_process() //---------------------------------------------------------------------------------------------- -// validate inputs -if (isset($_POST['AddPaymentItem'])) { - - if (!can_process()) { - unset($_POST['AddPaymentItem']); - } -} if (isset($_POST['_customer_id_button'])) { // unset($_POST['branch_id']); $Ajax->activate('BranchID'); @@ -237,26 +238,9 @@ if (isset($_POST['_DateBanked_changed'])) { $Ajax->activate('_ex_rate'); } -//Chaitanya : 13-OCT-2011 - To support Edit feature -if (isset($_POST['ref']) && $_SESSION['alloc']->trans_no == 0) // added by Joe to fix the browser back button -{ - $tno = get_customer_trans_from_ref(ST_CUSTPAYMENT, $_POST['ref']); - if ($tno != false) - { - display_error( _("The entered reference is already in use.")); - display_footer_exit(); - } -} -$new = $_SESSION['alloc']->trans_no == 0; - -if (list_updated('customer_id') || ($new && list_updated('bank_account'))) { - $_SESSION['alloc']->read(); - $_POST['memo_'] = $_POST['amount'] = $_POST['discount'] = ''; - $Ajax->activate('alloc_tbl'); -} //---------------------------------------------------------------------------------------------- -if (isset($_POST['AddPaymentItem'])) { +if (get_post('AddPaymentItem') && can_process()) { $cust_currency = get_customer_currency($_POST['customer_id']); $bank_currency = get_bank_account_currency($_POST['bank_account']); @@ -268,6 +252,7 @@ if (isset($_POST['AddPaymentItem'])) { new_doc_date($_POST['DateBanked']); + $new_pmt = !$_SESSION['alloc']->trans_no; //Chaitanya : 13-OCT-2011 - To support Edit feature $payment_no = write_customer_payment($_SESSION['alloc']->trans_no, $_POST['customer_id'], $_POST['BranchID'], $_POST['bank_account'], $_POST['DateBanked'], $_POST['ref'], @@ -275,20 +260,18 @@ if (isset($_POST['AddPaymentItem'])) { $_SESSION['alloc']->trans_no = $payment_no; $_SESSION['alloc']->write(); - - unset($_POST); - unset($_SESSION); + unset($_SESSION['alloc']); //Chaitanya : 13-OCT-2011 - To support Edit feature //meta_forward($_SERVER['PHP_SELF'], "AddedID=$payment_no"); - meta_forward($_SERVER['PHP_SELF'], $new ? "AddedID=$payment_no" : "UpdatedID=$payment_no"); + meta_forward($_SERVER['PHP_SELF'], $new_pmt ? "AddedID=$payment_no" : "UpdatedID=$payment_no"); } //---------------------------------------------------------------------------------------------- function read_customer_data() { - global $Refs, $new; + global $Refs; $myrow = get_customer_habit($_POST['customer_id']); @@ -296,7 +279,7 @@ function read_customer_data() $_POST['pymt_discount'] = $myrow["pymt_discount"]; //Chaitanya : 13-OCT-2011 - To support Edit feature //If page is called first time and New entry fetch the nex reference number - if ($new && !isset($_POST['charge'])) + if (!$_SESSION['alloc']->trans_no && !isset($_POST['charge'])) $_POST['ref'] = $Refs->get_next(ST_CUSTPAYMENT); } @@ -306,10 +289,9 @@ $old_ref = 0; //Chaitanya : 13-OCT-2011 - To support Edit feature if (isset($_GET['trans_no']) && $_GET['trans_no'] > 0 ) +{ $_POST['trans_no'] = $_GET['trans_no']; -//Read data -if (isset($_POST['trans_no']) && $_POST['trans_no'] > 0 ) -{ + $new = 0; $myrow = get_customer_trans($_POST['trans_no'], ST_CUSTPAYMENT); $_POST['customer_id'] = $myrow["debtor_no"]; @@ -323,15 +305,26 @@ if (isset($_POST['trans_no']) && $_POST['trans_no'] > 0 ) $_POST["amount"] = price_format($myrow['Total'] - $myrow['ov_discount']); $_POST["discount"] = price_format($myrow['ov_discount']); $_POST["memo_"] = get_comments_string(ST_CUSTPAYMENT,$_POST['trans_no']); + + if (!isset($_POST['charge'])) // first page call + { + //Prepare allocation cart + if (isset($_POST['trans_no']) && $_POST['trans_no'] > 0 ) + $_SESSION['alloc'] = new allocation(ST_CUSTPAYMENT,$_POST['trans_no']); + else + { + $_SESSION['alloc'] = new allocation(ST_CUSTPAYMENT,0); + $Ajax->activate('alloc_tbl'); + } + } + } -else - $_POST['trans_no'] = 0; //---------------------------------------------------------------------------------------------- - +$new = !$_SESSION['alloc']->trans_no; start_form(); - hidden('trans_no', $_POST['trans_no']); + hidden('trans_no'); hidden('old_ref', $old_ref); start_outer_table(TABLESTYLE2, "width=60%", 5); @@ -344,18 +337,12 @@ start_form(); hidden('customer_id', $_POST['customer_id']); } - if (!isset($_POST['charge'])) // first page call - { - //Prepare allocation cart - if (isset($_POST['trans_no']) && $_POST['trans_no'] > 0 ) - $_SESSION['alloc'] = new allocation(ST_CUSTPAYMENT,$_POST['trans_no']); - else - { - $_SESSION['alloc'] = new allocation(ST_CUSTPAYMENT,0); - $Ajax->activate('alloc_tbl'); - } + if (list_updated('customer_id') || ($new && list_updated('bank_account'))) { + $_SESSION['alloc']->read(); + $_POST['memo_'] = $_POST['amount'] = $_POST['discount'] = ''; + $Ajax->activate('alloc_tbl'); } - + if (db_customer_has_branches($_POST['customer_id'])) { customer_branches_list_row(_("Branch:"), $_POST['customer_id'], 'BranchID', null, false, true, true); } else { @@ -365,64 +352,61 @@ start_form(); read_customer_data(); set_global_customer($_POST['customer_id']); - if (isset($_POST['HoldAccount']) && $_POST['HoldAccount'] != 0) { - end_outer_table(); - display_error(_("This customer account is on hold.")); - } else { - $display_discount_percent = percent_format($_POST['pymt_discount']*100) . "%"; + if (isset($_POST['HoldAccount']) && $_POST['HoldAccount'] != 0) + display_warning(_("This customer account is on hold.")); + $display_discount_percent = percent_format($_POST['pymt_discount']*100) . "%"; - table_section(2); - if (!list_updated('bank_account')) - $_POST['bank_account'] = get_default_customer_bank_account($_POST['customer_id']); - - //Chaitanya : 13-OCT-2011 - Is AJAX call really needed ??? - //bank_accounts_list_row(_("Into Bank Account:"), 'bank_account', null, true); - bank_accounts_list_row(_("Into Bank Account:"), 'bank_account', null, false); + table_section(2); + if (!list_updated('bank_account')) + $_POST['bank_account'] = get_default_customer_bank_account($_POST['customer_id']); - text_row(_("Reference:"), 'ref', null, 20, 40); + //Chaitanya : 13-OCT-2011 - Is AJAX call really needed ??? + //bank_accounts_list_row(_("Into Bank Account:"), 'bank_account', null, true); + bank_accounts_list_row(_("Into Bank Account:"), 'bank_account', null, false); - table_section(3); + text_row(_("Reference:"), 'ref', null, 20, 40); - date_row(_("Date of Deposit:"), 'DateBanked', '', true, 0, 0, 0, null, true); + table_section(3); - $comp_currency = get_company_currency(); - $cust_currency = get_customer_currency($_POST['customer_id']); - $bank_currency = get_bank_account_currency($_POST['bank_account']); + date_row(_("Date of Deposit:"), 'DateBanked', '', true, 0, 0, 0, null, true); - if ($cust_currency != $bank_currency) { - exchange_rate_display($bank_currency, $cust_currency, $_POST['DateBanked'], ($bank_currency == $comp_currency)); - } + $comp_currency = get_company_currency(); + $cust_currency = get_customer_currency($_POST['customer_id']); + $bank_currency = get_bank_account_currency($_POST['bank_account']); - amount_row(_("Bank Charge:"), 'charge'); + if ($cust_currency != $bank_currency) { + exchange_rate_display($bank_currency, $cust_currency, $_POST['DateBanked'], ($bank_currency == $comp_currency)); + } - end_outer_table(1); + amount_row(_("Bank Charge:"), 'charge'); - if ($cust_currency == $bank_currency) { - div_start('alloc_tbl'); - show_allocatable(false); - div_end(); - } + end_outer_table(1); - start_table(TABLESTYLE, "width=60%"); + if ($cust_currency == $bank_currency) { + div_start('alloc_tbl'); + show_allocatable(false); + div_end(); + } - label_row(_("Customer prompt payment discount :"), $display_discount_percent); - amount_row(_("Amount of Discount:"), 'discount'); + start_table(TABLESTYLE, "width=60%"); - amount_row(_("Amount:"), 'amount'); + label_row(_("Customer prompt payment discount :"), $display_discount_percent); + amount_row(_("Amount of Discount:"), 'discount'); - textarea_row(_("Memo:"), 'memo_', null, 22, 4); - end_table(1); + amount_row(_("Amount:"), 'amount'); - if ($cust_currency != $bank_currency) - display_note(_("Amount and discount are in customer's currency.")); + textarea_row(_("Memo:"), 'memo_', null, 22, 4); + end_table(1); - br(); + if ($cust_currency != $bank_currency) + display_note(_("Amount and discount are in customer's currency.")); - if (isset($_POST['trans_no']) && $_POST['trans_no'] > 0 ) - submit_center('AddPaymentItem', _("Update Payment"), true, '', 'default'); - else - submit_center('AddPaymentItem', _("Add Payment"), true, '', 'default'); - } + br(); + + if ($new) + submit_center('AddPaymentItem', _("Update Payment"), true, '', 'default'); + else + submit_center('AddPaymentItem', _("Add Payment"), true, '', 'default'); br();