5 include($path_to_root . "/includes/db_pager.inc");
6 include_once($path_to_root . "/includes/session.inc");
8 include_once($path_to_root . "/includes/date_functions.inc");
10 include_once($path_to_root . "/includes/ui.inc");
11 include_once($path_to_root . "/includes/banking.inc");
13 include_once($path_to_root . "/sales/includes/sales_db.inc");
15 if ($use_popup_windows)
16 $js .= get_js_open_window(900, 500);
17 page(_("Supplier Allocations"), false, false, "", $js);
19 //--------------------------------------------------------------------------------
20 if ($ret = context_restore()) {
21 if(isset($ret['supplier_id']))
22 $_POST['supplier_id'] = $ret['supplier_id'];
24 if (isset($_POST['_supplier_id_editor'])) {
25 context_call($path_to_root.'/purchasing/manage/suppliers.php?supplier_id='.$_POST['supplier_id'] );
28 //--------------------------------------------------------------------------------
32 /* show all outstanding receipts and credits to be allocated */
33 /*Clear any previous allocation records */
34 if (isset($_SESSION['alloc']))
36 unset($_SESSION['alloc']->allocs);
37 unset($_SESSION['alloc']);
39 if (!isset($_POST['supplier_id']))
40 $_POST['supplier_id'] = get_global_supplier();
42 echo "<center>" . _("Select a Supplier: ") . " ";
43 supplier_list('supplier_id', $_POST['supplier_id'], true, true);
45 check(_("Show Settled Items:"), 'ShowSettled', null, true);
46 echo "</center><br><br>";
48 set_global_supplier($_POST['supplier_id']);
50 if (isset($_POST['supplier_id']) && ($_POST['supplier_id'] == reserved_words::get_all()))
52 unset($_POST['supplier_id']);
56 if (check_value('ShowSettled'))
59 if (isset($_POST['supplier_id']))
60 $supplier_id = $_POST['supplier_id'];
62 //--------------------------------------------------------------------------------
63 function systype_name($dummy, $type)
65 return systypes::name($type);
68 function trans_view($trans)
70 return get_trans_view_str($trans["type"], $trans["trans_no"]);
73 function alloc_link($row)
75 return pager_link(_("Allocate"),
76 "/purchasing/allocations/supplier_allocate.php?trans_no="
77 .$row["trans_no"] . "&trans_type=" . $row["type"] );
80 function amount_left($row)
82 return -$row["Total"]-$row["alloc"];
85 function amount_total($row)
87 return -$row["Total"];
90 function check_settled($row)
92 return $row['settled'] == 1;
96 $sql = get_allocatable_from_supp_sql($supplier_id, $settled);
99 _("Transaction Type") => array('fun'=>'systype_name'),
100 _("#") => array('fun'=>'trans_view'),
102 _("Date") => array('type'=>'date', 'ord'=>'asc'),
103 _("Supplier") => array('ord'=>''),
104 _("Currency") => array('align'=>'center'),
105 _("Total") => 'amount',
106 _("Left to Allocate") => array('align'=>'right','insert'=>true, 'fun'=>'amount_left'),
107 array('insert'=>true, 'fun'=>'alloc_link')
110 if (isset($_POST['customer_id'])) {
111 $cols[_("Supplier")] = 'skip';
112 $cols[_("Currency")] = 'skip';
115 $table =& new_db_pager('alloc_tbl', $sql, $cols);
116 $table->set_marker('check_settled', _("Marked items are settled."), 'settledbg', 'settledfg');
118 if (get_post('_ShowSettled_update') || get_post('_supplier_id_update') ) {
119 $table->set_sql($sql);
120 $table->set_columns($cols);
124 display_db_pager($table);