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)
12 $qes = has_quick_entries(-1, 0);
13 start_table("$table_style2 width=90%");
15 echo "<tr><td valign=top width=30%>"; // outer table
17 echo "<tr><td valign=top width=50%>"; // outer table
21 date_cells(_("Date:"), 'date_');
22 ref_cells(_("Reference:"), 'ref', '', references::get_next(0));
28 echo "</td><td width=20%>"; // outer table
30 echo "</td><td width=50%>"; // outer table
34 check_cells(_("Reverse Transaction:"), 'Reverse', null);
39 echo "</td><td width=50%>"; // outer table
42 quick_entries_list_cells(_("Quick Entry:"), 'person_id', null, -1, 0);
43 amount_cells(_("Total Amount"), 'totamount', null, null, " ".submit('go', _("Go"), false, false, true));
49 echo "</td></tr>"; // outer table
53 //---------------------------------------------------------------------------------
55 function display_gl_items($title, &$order)
57 global $table_style, $path_to_root;
59 display_heading($title);
61 $dim = get_company_pref('use_dimension');
63 div_start('items_table');
64 start_table("$table_style colspan=7 width=95%");
66 $th = array(_("Account Code"), _("Account Description"), _("Dimension")." 1",
67 _("Dimension")." 2", _("Debit"), _("Credit"), _("Memo"));
69 $th = array(_("Account Code"), _("Account Description"), _("Dimension"),
70 _("Debit"), _("Credit"), _("Memo"));
72 $th = array(_("Account Code"), _("Account Description"),
73 _("Debit"), _("Credit"), _("Memo"));
75 if (count($order->gl_items)) $th[] = '';
81 $id = find_submit('Edit');
82 foreach ($order->gl_items as $item)
84 if ($id != $item->index)
86 alt_table_row_color($k);
88 label_cells($item->code_id, $item->description);
90 label_cell(get_dimension_string($item->dimension_id, true));
92 label_cell(get_dimension_string($item->dimension2_id, true));
93 if ($item->amount > 0)
95 amount_cell(abs($item->amount));
101 amount_cell(abs($item->amount));
103 label_cell($item->reference);
105 edit_button_cell("Edit$item->index", _("Edit"),
106 _('Edit journal line'));
107 edit_button_cell("Delete$item->index", _("Delete"),
108 _('Remove line from journal'));
113 gl_edit_item_controls($order, $dim, $item->index);
118 gl_edit_item_controls($order, $dim);
120 if ($order->count_gl_items())
122 $colspan = ($dim == 2 ? "4" : ($dim == 1 ? "3" : "2"));
124 label_cell(_("Total"), "align=right colspan=" . $colspan);
125 amount_cell($order->gl_items_total_debit());
126 amount_cell(abs($order->gl_items_total_credit()));
134 //---------------------------------------------------------------------------------
136 function gl_edit_item_controls(&$order, $dim, $Index=null)
141 $id = find_submit('Edit');
142 if ($Index != -1 && $Index == $id)
144 $item = $order->gl_items[$Index];
145 $_POST['code_id'] = $item->code_id;
146 $_POST['dimension_id'] = $item->dimension_id;
147 $_POST['dimension2_id'] = $item->dimension2_id;
148 if ($item->amount > 0)
150 $_POST['AmountDebit'] = price_format($item->amount);
151 $_POST['AmountCredit'] = "";
155 $_POST['AmountDebit'] = "";
156 $_POST['AmountCredit'] = price_format(abs($item->amount));
158 $_POST['description'] = $item->description;
159 $_POST['LineMemo'] = $item->reference;
161 hidden('Index', $item->index);
162 hidden('code_id', $item->code_id);
163 label_cell($_POST['code_id']);
164 label_cell($item->description);
166 dimensions_list_cells(null, 'dimension_id', null, true, " ", false, 1);
168 dimensions_list_cells(null, 'dimension2_id', null, true, " ", false, 2);
169 $Ajax->activate('items_table');
173 $_POST['AmountDebit'] = ''; //price_format(0);
174 $_POST['AmountCredit'] = ''; //price_format(0);
175 $_POST['dimension_id'] = 0;
176 $_POST['dimension2_id'] = 0;
177 $_POST['LineMemo'] = "";
178 $_POST['_code_id_edit'] = "";
179 $_POST['code_id'] = "";
180 if(isset($_POST['_code_id_update'])) {
181 $Ajax->activate('code_id');
184 $skip_bank = ($_SESSION["wa_current_user"]->access != 2);
185 gl_all_accounts_list('code_id', null, $skip_bank, false, true);
187 dimensions_list_cells(null, 'dimension_id', null, true, " ", false, 1);
189 dimensions_list_cells(null, 'dimension2_id', null, true, " ", false, 2);
192 hidden('dimension_id', 0);
194 hidden('dimension2_id', 0);
196 small_amount_cells(null, 'AmountDebit');
197 small_amount_cells(null, 'AmountCredit');
198 text_cells_ex(null, 'LineMemo', 35, 50);
202 edit_button_cell('UpdateItem', _("Update"),
203 _('Confirm changes'));
204 edit_button_cell('CancelItemChanges', _("Cancel"),
205 _('Cancel changes'));
209 submit_cells('AddItem', _("Add Item"), "colspan=2",
210 _('Add new line to journal'), true);
215 //---------------------------------------------------------------------------------
217 function gl_options_controls()
219 echo "<br><table align='center'>";
221 textarea_row(_("Memo"), 'memo_', null, 50, 3);
227 //---------------------------------------------------------------------------------