function get_allocations_for_transaction($type, $trans_no) { clear_allocations(); $debtor = get_customer_trans($trans_no, $type); $_SESSION['alloc'] = new allocation($trans_no, $type, $debtor["debtor_no"], $debtor["DebtorName"], $debtor["Total"], sql2date($debtor["tran_date"])); /* Now populate the array of possible (and previous actual) allocations for this customer */ /*First get the transactions that have outstanding balances ie Total-alloc >0 */ $trans_items = get_allocatable_to_cust_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_cust_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"]); } }
} div_end(); end_form(); } //-------------------------------------------------------------------------------- if (isset($_POST['Process'])) { if (check_allocations()) { $_SESSION['alloc']->write(); clear_allocations(); $_POST['Cancel'] = 1; } } //-------------------------------------------------------------------------------- if (isset($_POST['Cancel'])) { clear_allocations(); meta_forward($path_to_root . "/sales/allocations/customer_allocation_main.php"); } //-------------------------------------------------------------------------------- if (isset($_GET['trans_no']) && isset($_GET['trans_type'])) { clear_allocations(); $_SESSION['alloc'] = new allocation($_GET['trans_type'], $_GET['trans_no'], @$_GET['debtor_no'], PT_CUSTOMER); } if (get_post('UpdateDisplay')) { $_SESSION['alloc']->read(); $Ajax->activate('alloc_tbl'); } if (isset($_SESSION['alloc'])) { edit_allocations_for_transaction($_SESSION['alloc']->type, $_SESSION['alloc']->trans_no); } //-------------------------------------------------------------------------------- end_page();