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 start_table("$table_style2 width=90%");
13 echo "<tr><td valign=top width=50%>"; // outer table
17 date_cells(_("Date:"), 'date_');
18 ref_cells(_("Reference:"), 'ref', '', references::get_next(0));
23 echo "</td><td width=50%>"; // outer table
27 check_row(_("Reverse Transaction:"), 'Reverse', null);
31 echo "</td></tr>"; // outer table
35 //---------------------------------------------------------------------------------
37 function display_gl_items($title, &$order)
39 global $table_style, $path_to_root;
41 display_heading($title);
43 $dim = get_company_pref('use_dimension');
45 div_start('items_table');
46 start_table("$table_style colspan=7 width=95%");
48 $th = array(_("Account Code"), _("Account Description"), _("Dimension")." 1",
49 _("Dimension")." 2", _("Debit"), _("Credit"), _("Memo"));
51 $th = array(_("Account Code"), _("Account Description"), _("Dimension"),
52 _("Debit"), _("Credit"), _("Memo"));
54 $th = array(_("Account Code"), _("Account Description"),
55 _("Debit"), _("Credit"), _("Memo"));
57 if (count($order->gl_items)) $th[] = '';
63 $id = find_submit('Edit');
64 foreach ($order->gl_items as $item)
66 if ($id != $item->index)
68 alt_table_row_color($k);
70 label_cells($item->code_id, $item->description);
72 label_cell(get_dimension_string($item->dimension_id, true));
74 label_cell(get_dimension_string($item->dimension2_id, true));
75 if ($item->amount > 0)
77 amount_cell(abs($item->amount));
83 amount_cell(abs($item->amount));
85 label_cell($item->reference);
87 edit_button_cell("Edit$item->index", _("Edit"),
88 _('Edit journal line'));
89 edit_button_cell("Delete$item->index", _("Delete"),
90 _('Remove line from journal'));
95 gl_edit_item_controls($order, $dim, $item->index);
100 gl_edit_item_controls($order, $dim);
102 if ($order->count_gl_items())
104 $colspan = ($dim == 2 ? "4" : ($dim == 1 ? "3" : "2"));
106 label_cell(_("Total"), "align=right colspan=" . $colspan);
107 amount_cell($order->gl_items_total_debit());
108 amount_cell(abs($order->gl_items_total_credit()));
116 //---------------------------------------------------------------------------------
118 function gl_edit_item_controls(&$order, $dim, $Index=null)
123 $id = find_submit('Edit');
124 if ($Index != -1 && $Index == $id)
126 $item = $order->gl_items[$Index];
127 $_POST['code_id'] = $item->code_id;
128 $_POST['dimension_id'] = $item->dimension_id;
129 $_POST['dimension2_id'] = $item->dimension2_id;
130 $_POST['AmountDebit'] = price_format($item->amount);
131 $_POST['AmountCredit'] = price_format(abs($item->amount));
132 $_POST['description'] = $item->description;
133 $_POST['LineMemo'] = $item->reference;
135 hidden('Index', $item->index);
136 hidden('code_id', $item->code_id);
137 label_cell($_POST['code_id']);
138 label_cell($item->description);
140 dimensions_list_cells(null, 'dimension_id', null, true, " ", false, 1);
142 dimensions_list_cells(null, 'dimension2_id', null, true, " ", false, 2);
143 $Ajax->activate('items_table');
147 $_POST['AmountDebit'] = ''; //price_format(0);
148 $_POST['AmountCredit'] = ''; //price_format(0);
149 $_POST['dimension_id'] = 0;
150 $_POST['dimension2_id'] = 0;
151 $_POST['LineMemo'] = "";
152 $_POST['_code_id_edit'] = "";
153 $_POST['code_id'] = "";
154 if(isset($_POST['_code_id_update'])) {
155 $Ajax->activate('code_id');
158 $skip_bank = ($_SESSION["wa_current_user"]->access != 2);
159 gl_all_accounts_list('code_id', null, $skip_bank, false, true);
161 dimensions_list_cells(null, 'dimension_id', null, true, " ", false, 1);
163 dimensions_list_cells(null, 'dimension2_id', null, true, " ", false, 2);
166 hidden('dimension_id', 0);
168 hidden('dimension2_id', 0);
170 small_amount_cells(null, 'AmountDebit');
171 small_amount_cells(null, 'AmountCredit');
172 text_cells_ex(null, 'LineMemo', 35, 50);
176 edit_button_cell('UpdateItem', _("Update"),
177 _('Confirm changes'));
178 edit_button_cell('CancelItemChanges', _("Cancel"),
179 _('Cancel changes'));
183 submit_cells('AddItem', _("Add Item"), "colspan=2",
184 _('Add new line to journal'), true);
189 //---------------------------------------------------------------------------------
191 function gl_options_controls()
193 echo "<br><table align='center'>";
195 textarea_row(_("Memo"), 'memo_', null, 50, 3);
201 //---------------------------------------------------------------------------------