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 start_table("$table_style colspan=7 width=95%");
47 $th = array(_("Account Code"), _("Account Description"), _("Dimension")." 1",
48 _("Dimension")." 2", _("Debit"), _("Credit"), _("Memo"));
50 $th = array(_("Account Code"), _("Account Description"), _("Dimension"),
51 _("Debit"), _("Credit"), _("Memo"));
53 $th = array(_("Account Code"), _("Account Description"),
54 _("Debit"), _("Credit"), _("Memo"));
56 if (count($order->gl_items)) $th[] = '';
62 foreach ($order->gl_items as $item)
64 if (!isset($_GET['Edit']) || $_GET['Edit'] != $item->index)
66 alt_table_row_color($k);
68 label_cells($item->code_id, $item->description);
70 label_cell(get_dimension_string($item->dimension_id, true));
72 label_cell(get_dimension_string($item->dimension2_id, true));
73 if ($item->amount > 0)
75 amount_cell(abs($item->amount));
81 amount_cell(abs($item->amount));
83 label_cell($item->reference);
84 edit_link_cell("Edit=$item->index");
85 delete_link_cell("Delete=$item->index");
90 gl_edit_item_controls($order, $dim, $item->index);
94 if (!isset($_GET['Edit']))
95 gl_edit_item_controls($order, $dim);
97 if ($order->count_gl_items())
99 $colspan = ($dim == 2 ? "4" : ($dim == 1 ? "3" : "2"));
101 label_cell(_("Total"), "align=right colspan=" . $colspan);
102 amount_cell($order->gl_items_total_debit());
103 amount_cell(abs($order->gl_items_total_credit()));
110 //---------------------------------------------------------------------------------
112 function gl_edit_item_controls(&$order, $dim, $Index=null)
116 if (isset($_GET['Edit']) && $Index != null)
118 $item = $order->gl_items[$Index];
119 if (!isset($_POST['code_id']))
120 $_POST['code_id'] = $item->code_id;
121 if (!isset($_POST['dimension_id']))
122 $_POST['dimension_id'] = $item->dimension_id;
123 if (!isset($_POST['dimension2_id']))
124 $_POST['dimension2_id'] = $item->dimension2_id;
126 if ((!isset($_POST['AmountDebit']) || ($_POST['AmountDebit']=="")) && $item->amount > 0)
127 $_POST['AmountDebit'] = price_format($item->amount);
129 if ((!isset($_POST['AmountCredit']) || ($_POST['AmountCredit']=="")) && $item->amount <= 0)
130 $_POST['AmountCredit'] = price_format(abs($item->amount));
132 if (!isset($_POST['description']) || ($_POST['description'] == ""))
133 $_POST['description'] = $item->description;
134 if (!isset($_POST['LineMemo']) || ($_POST['LineMemo'] == ""))
135 $_POST['LineMemo'] = $item->reference;
137 hidden('Index', $item->index);
138 hidden('code_id', $item->code_id);
139 label_cell($_POST['code_id']);
140 label_cell($item->description);
142 dimensions_list_cells(null, 'dimension_id', $_POST['dimension_id'], true, " ", false, 1);
144 dimensions_list_cells(null, 'dimension2_id', $_POST['dimension2_id'], true, " ", false, 2);
148 $_POST['AmountDebit'] = ''; //price_format(0);
149 $_POST['AmountCredit'] = ''; //price_format(0);
150 $_POST['dimension_id'] = 0;
151 $_POST['dimension2_id'] = 0;
152 $_POST['LineMemo'] = "";
153 $_POST['CodeID2'] = "";
154 $_POST['code_id'] = "";
156 text_cells(null, "CodeID2", "", 12, 10, "", "", "class='combo' rel='code_id'");
157 $skip_bank = ($_SESSION["wa_current_user"]->access != 2);
158 gl_all_accounts_list_cells(null, 'code_id', null, $skip_bank, false, "class='combo' rel='CodeID2'");
160 dimensions_list_cells(null, 'dimension_id', null, true, " ", false, 1);
162 dimensions_list_cells(null, 'dimension2_id', null, true, " ", false, 2);
165 hidden('dimension_id', 0);
167 hidden('dimension2_id', 0);
169 small_amount_cells(null, 'AmountDebit');
170 small_amount_cells(null, 'AmountCredit');
171 text_cells_ex(null, 'LineMemo', 35, 50);
173 if (isset($_GET['Edit']))
175 submit_cells('UpdateItem', _("Update"));
176 submit_cells('CancelItemChanges', _("Cancel"));
179 submit_cells('AddItem', _("Add item"), "colspan=2");
185 //---------------------------------------------------------------------------------
187 function gl_options_controls()
189 echo "<br><table align='center'>";
191 textarea_row(_("Memo"), 'memo_', null, 50, 3);
197 //---------------------------------------------------------------------------------