function create_cart($type, $trans_no) { global $Refs; if (isset($_SESSION['pay_items'])) { unset($_SESSION['pay_items']); } $cart = new items_cart($type); $cart->order_id = $trans_no; if ($trans_no) { $bank_trans = db_fetch(get_bank_trans($type, $trans_no)); $_POST['bank_account'] = $bank_trans["bank_act"]; $_POST['PayType'] = $bank_trans["person_type_id"]; if ($bank_trans["person_type_id"] == PT_CUSTOMER) { $trans = get_customer_trans($trans_no, $type); $_POST['person_id'] = $trans["debtor_no"]; $_POST['PersonDetailID'] = $trans["branch_code"]; } elseif ($bank_trans["person_type_id"] == PT_SUPPLIER) { $trans = get_supp_trans($trans_no, $type); $_POST['person_id'] = $trans["supplier_id"]; } elseif ($bank_trans["person_type_id"] == PT_MISC) { $_POST['person_id'] = $bank_trans["person_id"]; } elseif ($bank_trans["person_type_id"] == PT_QUICKENTRY) { $_POST['person_id'] = $bank_trans["person_id"]; } else { $_POST['person_id'] = $bank_trans["person_id"]; } $cart->memo_ = get_comments_string($type, $trans_no); $cart->tran_date = sql2date($bank_trans['trans_date']); $cart->reference = $Refs->get($type, $trans_no); $cart->original_amount = $bank_trans['amount']; $result = get_gl_trans($type, $trans_no); if ($result) { while ($row = db_fetch($result)) { if (is_bank_account($row['account'])) { // date exchange rate is currenly not stored in bank transaction, // so we have to restore it from original gl amounts $ex_rate = $bank_trans['amount'] / $row['amount']; } else { $date = $row['tran_date']; $cart->add_gl_item($row['account'], $row['dimension_id'], $row['dimension2_id'], $row['amount'], $row['memo_']); } } } // apply exchange rate foreach ($cart->gl_items as $line_no => $line) { $cart->gl_items[$line_no]->amount *= $ex_rate; } } else { $cart->reference = $Refs->get_next($cart->trans_type); $cart->tran_date = new_doc_date(); if (!is_date_in_fiscalyear($cart->tran_date)) { $cart->tran_date = end_fiscalyear(); } } $_POST['memo_'] = $cart->memo_; $_POST['ref'] = $cart->reference; $_POST['date_'] = $cart->tran_date; $_SESSION['pay_items'] =& $cart; }
<?php $page_security = 'SA_SUPPTRANSVIEW'; $path_to_root = "../.."; include $path_to_root . "/includes/session.inc"; include_once $path_to_root . "/includes/ui.inc"; include_once $path_to_root . "/purchasing/includes/purchasing_db.inc"; $js = ""; if ($use_popup_windows) { $js .= get_js_open_window(900, 500); } page(_($help_context = "View Payment to Supplier"), true, false, "", $js); if (isset($_GET["trans_no"])) { $trans_no = $_GET["trans_no"]; } $receipt = get_supp_trans($trans_no, ST_SUPPAYMENT); $company_currency = get_company_currency(); $show_currencies = false; $show_both_amounts = false; if ($receipt['bank_curr_code'] != $company_currency || $receipt['curr_code'] != $company_currency) { $show_currencies = true; } if ($receipt['bank_curr_code'] != $receipt['curr_code']) { $show_currencies = true; $show_both_amounts = true; } echo "<center>"; display_heading(_("Payment to Supplier") . " #{$trans_no}"); echo "<br>"; start_table(TABLESTYLE2, "width=80%"); start_row();
$Ajax->activate('_ex_rate'); } if (list_updated('supplier_id')) { $_POST['amount'] = price_format(0); $_SESSION['alloc']->person_id = get_post('supplier_id'); $Ajax->activate('amount'); } elseif (list_updated('bank_account')) { $Ajax->activate('alloc_tbl'); } //---------------------------------------------------------------------------------------- if (!isset($_POST['bank_account'])) { // first page call $_SESSION['alloc'] = new allocation(ST_SUPPAYMENT, 0, get_post('supplier_id')); if (isset($_GET['PInvoice'])) { // get date and supplier $inv = get_supp_trans($_GET['PInvoice'], ST_SUPPINVOICE); $dflt_act = get_default_bank_account($inv['curr_code']); $_POST['bank_account'] = $dflt_act['id']; if ($inv) { $_SESSION['alloc']->person_id = $_POST['supplier_id'] = $inv['supplier_id']; $_SESSION['alloc']->read(); $_POST['DatePaid'] = sql2date($inv['tran_date']); $_POST['memo_'] = $inv['supp_reference']; foreach ($_SESSION['alloc']->allocs as $line => $trans) { if ($trans->type == ST_SUPPINVOICE && $trans->type_no == $_GET['PInvoice']) { $un_allocated = abs($trans->amount) - $trans->amount_allocated; $_SESSION['alloc']->amount = $_SESSION['alloc']->allocs[$line]->current_allocated = $un_allocated; $_POST['amount'] = $_POST['amount' . $line] = price_format($un_allocated); break; } }
function create_cart($type = 0, $trans_no = 0) { global $Refs; if (isset($_SESSION['disbursement_items'])) { unset($_SESSION['disbursement_items']); } $cart = new items_cart($type); $cart->order_id = $trans_no; if ($trans_no) { $result = get_gl_trans($type, $trans_no); $_POST['PayType'] = $res["person_type_id"]; if ($res["person_type_id"] == PT_CUSTOMER) { $trans = get_customer_trans($trans_no, $type); $_POST['person_id'] = $trans["debtor_no"]; $_POST['PersonDetailID'] = $trans["branch_code"]; } elseif ($res["person_type_id"] == PT_SUPPLIER) { $trans = get_supp_trans($trans_no, $type); $_POST['person_id'] = $trans["supplier_id"]; } elseif ($res["person_type_id"] == PT_MISC) { $_POST['person_id'] = $res["person_id"]; } elseif ($res["person_type_id"] == PT_QUICKENTRY) { $_POST['person_id'] = $res["person_id"]; } else { $_POST['person_id'] = $res["person_id"]; } if ($result) { while ($row = db_fetch($result)) { if ($row['amount'] == 0) { continue; } $date = $row['tran_date']; $cart->add_gl_item($row['account'], $row['dimension_id'], $row['dimension2_id'], $row['amount'], $row['memo_']); } } $cart->memo_ = get_comments_string($type, $trans_no); $cart->tran_date = sql2date($date); if ($type == ST_DISBURSEMENT) { $voucher_type = 'Check Voucher'; $cart->reference = $Refs->get(ST_DISBURSEMENT, $trans_no); } if ($type == ST_SUPPAYMENT) { $cart->reference = $Refs->get_next(ST_DISBURSEMENT); } $_POST['ref_original'] = $cart->reference; // Store for comparison when updating } else { $cart->reference = $Refs->get_next(ST_DISBURSEMENT); $cart->tran_date = new_doc_date(); if (!is_date_in_fiscalyear($cart->tran_date)) { $cart->tran_date = end_fiscalyear(); } $_POST['ref_original'] = -1; } $_POST['memo_'] = $cart->memo_; $_POST['ref'] = $cart->reference; $_POST['date_'] = $cart->tran_date; $_POST['cv_no'] = $cart->custom_no; /**========MOODLEARNING=======*/ $_POST['address'] = $cart->address; $_POST['check_num'] = $cart->check_num; $_POST['PayType'] = $cart->person_id; $_POST['person_id'] = $cart->person_detail_id; $_POST['settled_amount'] = $cart->settled_amount; $_SESSION['disbursement_items'] =& $cart; }
<?php $page_security = 1; $path_to_root = "../.."; include $path_to_root . "/includes/session.inc"; include_once $path_to_root . "/includes/ui.inc"; include_once $path_to_root . "/purchasing/includes/purchasing_db.inc"; $js = ""; if ($use_popup_windows) { $js .= get_js_open_window(900, 500); } page(tr("View Payment to Supplier"), true, false, "", $js); if (isset($_GET["trans_no"])) { $trans_no = $_GET["trans_no"]; } $receipt = get_supp_trans($trans_no, 22); $company_currency = get_company_currency(); $show_currencies = false; $show_both_amounts = false; if ($receipt['bank_curr_code'] != $company_currency || $receipt['SupplierCurrCode'] != $company_currency) { $show_currencies = true; } if ($receipt['bank_curr_code'] != $receipt['SupplierCurrCode']) { $show_currencies = true; $show_both_amounts = true; } echo "<center>"; display_heading(tr("Payment to Supplier") . " #{$trans_no}"); echo "<br>"; start_table("{$table_style2} width=80%"); start_row();
function get_allocations_for_transaction($type, $trans_no) { clear_allocations(); $supptrans = get_supp_trans($trans_no, $type); $_SESSION['alloc'] = new allocation($trans_no, $type, $supptrans["supplier_id"], $supptrans["supplier_name"], $supptrans["Total"], sql2date($supptrans["tran_date"])); /* Now populate the array of possible (and previous actual) allocations for this supplier */ /*First get the transactions that have outstanding balances ie Total-alloc >0 */ $trans_items = get_allocatable_to_supp_transactions($_SESSION['alloc']->person_id); while ($myrow = db_fetch($trans_items)) { $_SESSION['alloc']->add_item($myrow["type"], $myrow["trans_no"], sql2date($myrow["tran_date"]), sql2date($myrow["due_date"]), $myrow["Total"], $myrow["alloc"], 0); // this allocation } /* Now get trans that might have previously been allocated to by this trans NB existing entries where still some of the trans outstanding entered from above logic will be overwritten with the prev alloc detail below */ $trans_items = get_allocatable_to_supp_transactions($_SESSION['alloc']->person_id, $trans_no, $type); while ($myrow = db_fetch($trans_items)) { $_SESSION['alloc']->add_or_update_item($myrow["type"], $myrow["trans_no"], sql2date($myrow["tran_date"]), sql2date($myrow["due_date"]), $myrow["Total"], $myrow["alloc"] - $myrow["amt"], $myrow["amt"]); } }