3 function display_bank_header(&$order)
5 global $table_style2, $Ajax;
6 $payment = $order->trans_type == systypes::bank_payment();
8 div_start('pmt_header');
9 start_table("width=90% $table_style2"); // outer table
10 echo "<tr><td valign=top width=33%>";
12 echo "<table>"; // inner table
14 bank_accounts_list_row( $payment ? _("From:") : _("To:"), 'bank_account', null, true);
16 date_row(_("Date:"), 'date_', '', null, 0, 0, 0, null, true);
18 echo "</table>"; // inner table
20 echo "</td><td width=33%>";
22 echo "<table>"; // inner table
24 if (!isset($_POST['PayType']))
26 if (isset($_GET['PayType']))
27 $_POST['PayType'] = $_GET['PayType'];
29 $_POST['PayType'] = "";
31 if (!isset($_POST['person_id']))
33 if (isset($_GET['PayPerson']))
34 $_POST['person_id'] = $_GET['PayPerson'];
36 $_POST['person_id'] = "";
38 if (isset($_POST['_PayType_update'])) {
39 $_POST['person_id'] = '';
40 $Ajax->activate('pmt_header');
41 $Ajax->activate('code_id');
43 payment_person_types_list_row( $payment ? _("Pay To:"):_("From:"),
44 'PayType', $_POST['PayType'], true);
45 switch ($_POST['PayType'])
47 case payment_person_types::misc() :
48 text_row_ex($payment ?_("To the Order of:"):_("Name:"),
51 case payment_person_types::WorkOrder() :
52 workorders_list_row(_("Work Order:"), 'person_id', null);
54 case payment_person_types::supplier() :
55 supplier_list_row(_("Supplier:"), 'person_id', null, false, true);
57 case payment_person_types::customer() :
58 customer_list_row(_("Customer:"), 'person_id', null, false, true);
60 if (db_customer_has_branches($_POST['person_id']))
62 customer_branches_list_row(_("Branch:"), $_POST['person_id'], 'PersonDetailID', null, false, true, true);
66 $_POST['PersonDetailID'] = reserved_words::get_any_numeric();
67 hidden('PersonDetailID');
70 //case payment_person_types::Project() :
71 // dimensions_list_row(_("Dimension:"), 'person_id', $_POST['person_id'], false, null, true);
75 $person_currency = payment_person_types::person_currency($_POST['PayType'], $_POST['person_id']);
76 $bank_currency = get_bank_account_currency($_POST['bank_account']);
78 exchange_rate_display($bank_currency, $person_currency, $_POST['date_']);
80 echo "</table>"; // inner table
84 echo "<table>"; // inner table
86 bank_trans_types_list_row(_("Type:"), 'type', null);
88 if (isset($_GET['NewPayment']))
89 ref_row(_("Reference:"), 'ref', '', references::get_next(systypes::bank_payment()));
91 ref_row(_("Reference:"), 'ref', '', references::get_next(systypes::bank_deposit()));
93 echo "</table>"; // inner table
97 end_table(1); // outer table
100 //---------------------------------------------------------------------------------
102 function display_gl_items($title, &$order)
104 global $table_style, $path_to_root;
106 $dim = get_company_pref('use_dimension');
107 $colspan = ($dim == 2 ? 4 : ($dim == 1 ? 3 : 2));
108 display_heading($title);
110 div_start('items_table');
111 start_table("$table_style colspan=7 width=95%");
114 $th = array(_("Account Code"), _("Account Description"), _("Dimension")." 1",
115 _("Dimension")." 2", _("Amount"), _("Memo"));
117 $th = array(_("Account Code"), _("Account Description"), _("Dimension"),
118 _("Amount"), _("Memo"));
120 $th = array(_("Account Code"), _("Account Description"),
121 _("Amount"), _("Memo"));
123 if (count($order->gl_items)) $th[] = '';
126 $k = 0; //row colour counter
128 $id = find_submit('Edit');
129 foreach ($order->gl_items as $item)
131 if ($id != $item->index)
133 alt_table_row_color($k);
135 label_cell($item->code_id);
136 label_cell($item->description);
138 label_cell(get_dimension_string($item->dimension_id, true));
140 label_cell(get_dimension_string($item->dimension2_id, true));
141 amount_cell(abs($item->amount));
142 label_cell($item->reference);
144 edit_button_cell("Edit$item->index", _("Edit"),
145 _('Edit document line'));
146 edit_button_cell("Delete$item->index", _("Delete"),
147 _('Remove line from document'));
152 gl_edit_item_controls($order, $dim, $item->index);
157 gl_edit_item_controls($order, $dim);
159 if ($order->count_gl_items())
160 label_row(_("Total"), number_format2(abs($order->gl_items_total()), user_price_dec()),"colspan=" . $colspan . " align=right", "align=right");
166 //---------------------------------------------------------------------------------
168 function gl_edit_item_controls(&$order, $dim, $Index=null)
171 $payment = $order->trans_type == systypes::bank_payment();
174 $id = find_submit('Edit');
175 if ($Index != -1 && $Index == $id)
177 $item = $order->gl_items[$Index];
178 $_POST['code_id'] = $item->code_id;
179 $_POST['dimension_id'] = $item->dimension_id;
180 $_POST['dimension2_id'] = $item->dimension2_id;
181 $_POST['amount'] = price_format(abs($item->amount));
182 $_POST['description'] = $item->description;
183 $_POST['LineMemo'] = $item->reference;
185 hidden('Index', $item->index);
186 hidden('code_id', $item->code_id);
187 label_cell($_POST['code_id']);
188 label_cell($item->description);
190 dimensions_list_cells(null, 'dimension_id', null, true, " ", false, 1);
192 dimensions_list_cells(null, 'dimension2_id', null, true, " ", false, 2);
193 $Ajax->activate('items_table');
197 $_POST['amount'] = price_format(0);
198 $_POST['dimension_id'] = 0;
199 $_POST['dimension2_id'] = 0;
200 $_POST['LineMemo'] = "";
201 if(isset($_POST['_code_id_update'])) {
202 $Ajax->activate('code_id');
205 if ($_POST['PayType'] == payment_person_types::customer())
207 $acc = get_branch_accounts($_POST['PersonDetailID']);
208 $_POST['code_id'] = $acc['receivables_account'];
210 elseif ($_POST['PayType'] == payment_person_types::supplier())
212 $acc = get_supplier_accounts($_POST['person_id']);
213 $_POST['code_id'] = $acc['payable_account'];
215 elseif ($_POST['PayType'] == payment_person_types::WorkOrder())
216 $_POST['code_id'] = get_company_pref('default_assembly_act');
219 get_company_pref($payment ? 'default_cogs_act':'default_inv_sales_act');
221 gl_all_accounts_list('code_id', null, true, false, true);
223 dimensions_list_cells(null, 'dimension_id', null, true, " ", false, 1);
225 dimensions_list_cells(null, 'dimension2_id', null, true, " ", false, 2);
228 hidden('dimension_id', 0);
230 hidden('dimension2_id', 0);
232 amount_cells(null, 'amount');
233 text_cells_ex(null, 'LineMemo', 35, 50);
237 edit_button_cell('UpdateItem', _("Update"),
238 _('Confirm changes'));
239 edit_button_cell('CancelItemChanges', _("Cancel"),
240 _('Cancel changes'));
245 submit_cells('AddItem', _("Add Item"), "colspan=2",
246 _('Add new item to document'), true);
253 //---------------------------------------------------------------------------------
255 function gl_options_controls()
257 echo "<br><table align='center'>";
259 textarea_row(_("Memo"), 'memo_', null, 50, 3);
265 //---------------------------------------------------------------------------------