3 include_once($path_to_root . "/includes/ui.inc");
4 include_once($path_to_root . "/includes/ui/items_cart.inc");
6 //--------------------------------------------------------------------------------
8 function display_order_header(&$order)
11 start_table("width=90% $table_style2"); // outer table
12 echo "<tr><td valign=top width=33%>";
14 echo "<table>"; // inner table
16 bank_accounts_list_row(_("From:"), 'bank_account', null, true);
18 date_row(_("Date:"), 'date_');
20 echo "</table>"; // inner table
22 echo "</td><td width=33%>";
24 echo "<table>"; // inner table
26 if (!isset($_POST['PayType']))
28 if (isset($_GET['PayType']))
29 $_POST['PayType'] = $_GET['PayType'];
31 $_POST['PayType'] = "";
33 if (!isset($_POST['person_id']))
35 if (isset($_GET['PayPerson']))
36 $_POST['person_id'] = $_GET['PayPerson'];
38 $_POST['person_id'] = "";
40 payment_person_types_list_row(_("Pay To:"), 'PayType', $_POST['PayType'], 'person_id');
42 switch ($_POST['PayType'])
44 case payment_person_types::misc() :
45 text_row_ex(_("To the Order of:"), 'person_id', 40, 50);
47 case payment_person_types::WorkOrder() :
48 workorders_list_row(_("Work Order:"), 'person_id', null);
50 case payment_person_types::supplier() :
51 supplier_list_row(_("Supplier:"), 'person_id', null, false, true);
53 case payment_person_types::customer() :
54 customer_list_row(_("Customer:"), 'person_id', null, false, true);
56 if (db_customer_has_branches($_POST['person_id']))
58 customer_branches_list_row(_("Branch:"), $_POST['person_id'], 'PersonDetailID', null, false, true, true);
62 hidden('BranchID', reserved_words::get_any_numeric());
65 //case payment_person_types::Project() :
66 // dimensions_list_row(_("Dimension:"), 'person_id', $_POST['person_id'], false, null, true);
70 //$homeCurrency = get_company_currency();
71 $person_currency = payment_person_types::person_currency($_POST['PayType'], $_POST['person_id']);
72 $bank_currency = get_bank_account_currency($_POST['bank_account']);
74 if ($bank_currency != "" && $bank_currency != $person_currency)
76 exchange_rate_display($bank_currency, $person_currency, $_POST['date_']);
79 echo "</table>"; // inner table
83 echo "<table>"; // inner table
85 bank_trans_types_list_row(_("Payment Type:"), 'type', null);
87 ref_row(_("Reference:"), 'ref', references::get_next(systypes::bank_payment()));
89 echo "</table>"; // inner table
93 end_table(1); // outer table
96 //---------------------------------------------------------------------------------
98 function display_gl_items($title, &$order)
100 global $table_style, $path_to_root;
102 $dim = get_company_pref('use_dimension');
103 $colspan = ($dim == 2 ? 4 : ($dim == 1 ? 3 : 2));
104 display_heading($title);
106 start_table("$table_style colspan=7 width=95%");
109 $th = array(_("Account Code"), _("Account Description"), _("Dimension")." 1",
110 _("Dimension")." 2", _("Amount"), _("Memo"));
112 $th = array(_("Account Code"), _("Account Description"), _("Dimension"),
113 _("Amount"), _("Memo"));
115 $th = array(_("Account Code"), _("Account Description"),
116 _("Amount"), _("Memo"));
118 $k = 0; //row colour counter
120 foreach ($order->gl_items as $item)
122 if (!isset($_GET['Edit']) || $_GET['Edit'] != $item->index)
124 alt_table_row_color($k);
126 label_cell($item->code_id);
127 label_cell($item->description);
129 label_cell(get_dimension_string($item->dimension_id, true));
131 label_cell(get_dimension_string($item->dimension2_id, true));
132 amount_cell($item->amount);
133 label_cell($item->reference);
135 edit_link_cell("Edit=$item->index");
136 delete_link_cell("Delete=$item->index");
141 gl_edit_item_controls($order, $dim, $item->index);
145 if (!isset($_GET['Edit']))
146 gl_edit_item_controls($order, $dim);
148 if ($order->count_gl_items())
149 label_row(_("Total"), number_format2(abs($order->gl_items_total()), user_price_dec()),"colspan=" . $colspan . " align=right", "align=right");
154 //---------------------------------------------------------------------------------
156 function gl_edit_item_controls(&$order, $dim, $Index=null)
160 if (isset($_GET['Edit']) and $Index!=null)
162 if (!isset($_POST['code_id']))
163 $_POST['code_id'] = $order->gl_items[$Index]->code_id;
164 if (!isset($_POST['dimension_id']))
165 $_POST['dimension_id'] = $order->gl_items[$Index]->dimension_id;
166 if (!isset($_POST['dimension2_id']))
167 $_POST['dimension2_id'] = $order->gl_items[$Index]->dimension2_id;
168 if (!isset($_POST['amount']) OR ($_POST['amount']==""))
169 $_POST['amount'] = $order->gl_items[$Index]->amount;
170 if (!isset($_POST['description']) OR ($_POST['description']==""))
171 $_POST['description'] = $order->gl_items[$Index]->description;
172 if (!isset($_POST['LineMemo']) OR ($_POST['LineMemo']==""))
173 $_POST['LineMemo'] = $order->gl_items[$Index]->reference;
175 hidden('Index', $order->gl_items[$Index]->index);
176 hidden('code_id', $order->gl_items[$Index]->code_id);
177 label_cell($_POST['code_id']);
178 label_cell($order->gl_items[$Index]->description);
180 dimensions_list_cells(null, 'dimension_id', $_POST['dimension_id'], true, " ", false, 1);
182 dimensions_list_cells(null, 'dimension2_id', $_POST['dimension2_id'], true, " ", false, 2);
186 $_POST['amount'] = 0;
187 $_POST['dimension_id'] = 0;
188 $_POST['dimension2_id'] = 0;
189 $_POST['LineMemo'] = "";
191 if ($_POST['PayType'] == payment_person_types::customer())
193 $acc = get_branch_accounts($_POST['PersonDetailID']);
194 $_POST['code_id'] = $acc['receivables_account'];
196 elseif ($_POST['PayType'] == payment_person_types::supplier())
198 $acc = get_supplier_accounts($_POST['person_id']);
199 $_POST['code_id'] = $acc['payable_account'];
201 elseif ($_POST['PayType'] == payment_person_types::WorkOrder())
202 $_POST['code_id'] = get_company_pref('default_assembly_act');
204 $_POST['code_id'] = get_company_pref('default_cogs_act');
205 text_cells(null, "CodeID2", $_POST['code_id'], 12, 10, "", "", "onkeyup='recalcAccounts()' onblur='return setAccount(0, false)'");
206 gl_all_accounts_list_cells(null, 'code_id', $_POST['code_id'], true, false, "return setAccount(1, false)");
208 dimensions_list_cells(null, 'dimension_id', null, true, " ", false, 1);
210 dimensions_list_cells(null, 'dimension2_id', null, true, " ", false, 2);
213 hidden('dimension_id', 0);
215 hidden('dimension2_id', 0);
217 amount_cells(null, 'amount');
218 text_cells_ex(null, 'LineMemo', 35, 50);
220 if (isset($_GET['Edit']))
222 submit_cells('UpdateItem', _("Update"));
223 submit_cells('CancelItemChanges', _("Cancel"));
226 submit_cells('AddItem', _("Add Item"), "colspan=2");
232 //---------------------------------------------------------------------------------
234 function gl_options_controls()
236 echo "<br><table align='center'>";
238 textarea_row(_("Memo"), 'memo_', null, 50, 3);
244 //---------------------------------------------------------------------------------