5 include($path_to_root . "/includes/session.inc");
7 page(_("Quick Entries"));
9 include($path_to_root . "/gl/includes/gl_db.inc");
11 include($path_to_root . "/includes/ui.inc");
13 simple_page_mode(true);
14 simple_page_mode2(true);
16 function simple_page_mode2($numeric_id = true)
18 global $Ajax, $Mode2, $selected_id2;
20 $default = $numeric_id ? -1 : '';
21 $selected_id2 = get_post('selected_id2', $default);
22 foreach (array('ADD_ITEM2', 'UPDATE_ITEM2', 'RESET2') as $m) {
23 if (isset($_POST[$m])) {
24 $Ajax->activate('_page_body');
26 $selected_id2 = $default;
30 foreach (array('BEd', 'BDel') as $m) {
31 foreach ($_POST as $p => $pvar) {
32 if (strpos($p, $m) === 0) {
33 // $selected_id2 = strtr(substr($p, strlen($m)), array('%2E'=>'.'));
34 unset($_POST['_focus']); // focus on first form entry
35 $selected_id2 = quoted_printable_decode(substr($p, strlen($m)));
36 $Ajax->activate('_page_body');
45 function submit_add_or_update_center2($add=true, $title=false, $async=false)
49 submit('ADD_ITEM2', _("Add new"), true, $title, $async);
51 submit('UPDATE_ITEM2', _("Update"), true, $title, $async);
52 submit('RESET2', _("Cancel"), true, $title, $async);
57 //-----------------------------------------------------------------------------------
59 function can_process()
62 if (strlen($_POST['description']) == 0)
64 display_error( _("The Quick Entry description cannot be empty."));
65 set_focus('description');
72 //-----------------------------------------------------------------------------------
74 if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
80 if ($selected_id != -1)
82 update_quick_entry($selected_id, $_POST['description'], $_POST['deposit'], $_POST['bank_only']);
83 display_notification(_('Selected quick entry has been updated'));
87 add_quick_entry($_POST['description'], $_POST['deposit'], $_POST['bank_only']);
88 display_notification(_('New quick entry has been added'));
94 if ($Mode2=='ADD_ITEM2' || $Mode2=='UPDATE_ITEM2')
96 if ($selected_id2 != -1)
98 update_quick_entry_line($selected_id2, $selected_id, $_POST['account'], $_POST['tax_acc'], $_POST['pct'], input_num('amount', 0),
99 $_POST['dimension_id'], $_POST['dimension2_id']);
100 display_notification(_('Selected quick entry line has been updated'));
104 add_quick_entry_line($selected_id, $_POST['account'], $_POST['tax_acc'], $_POST['pct'], input_num('amount', 0),
105 $_POST['dimension_id'], $_POST['dimension2_id']);
106 display_notification(_('New quick entry line has been added'));
111 //-----------------------------------------------------------------------------------
113 if ($Mode == 'Delete')
115 if (!has_quick_entry_lines($selected_id))
117 delete_quick_entry($selected_id);
118 display_notification(_('Selected quick entry has been deleted'));
123 display_error( _("The Quick Entry has Quick Entry Lines. Cannot be deleted."));
124 set_focus('description');
128 if ($Mode2 == 'BDel')
130 delete_quick_entry_line($selected_id2);
131 display_notification(_('Selected quick entry line has been deleted'));
134 //-----------------------------------------------------------------------------------
135 if ($Mode == 'RESET')
138 $_POST['description'] = $_POST['deposit'] = $_POST['bank_only'] = '';
140 if ($Mode2 == 'RESET2')
143 $_POST['account'] = $_POST['tax_acc'] = $_POST['pct'] = $_POST['amount'] = $_POST['dimension_id'] = $_POST['dimension2_id'] = '';
145 //-----------------------------------------------------------------------------------
147 $result = get_quick_entries();
149 start_table($table_style);
150 $th = array(_("Description"), _("Deposit"), _("Bank Only"), "", "");
154 while ($myrow = db_fetch($result))
156 alt_table_row_color($k);
157 $deposit_text = ($myrow["deposit"] == 0 ? _("No") : _("Yes"));
158 $bank_text = ($myrow["bank_only"] == 0 ? _("No") : _("Yes"));
159 label_cell($myrow['description']);
160 label_cell($deposit_text);
161 label_cell($bank_text);
162 edit_button_cell("Edit".$myrow["id"], _("Edit"));
163 edit_button_cell("Delete".$myrow["id"], _("Delete"));
169 //-----------------------------------------------------------------------------------
173 start_table($table_style2);
175 if ($selected_id != -1)
177 //if ($Mode == 'Edit')
179 //editing an existing status code
180 $myrow = get_quick_entry($selected_id);
182 $_POST['id'] = $myrow["id"];
183 $_POST['description'] = $myrow["description"];
184 $_POST['deposit'] = $myrow["deposit"];
185 $_POST['bank_only'] = $myrow["bank_only"];
186 hidden('selected_id', $selected_id);
190 text_row_ex(_("Description:"), 'description', 50, 60);
192 yesno_list_row(_("Deposit:"), 'deposit', null, "", "", false);
194 yesno_list_row(_("Bank Only:"), 'bank_only', null, "", "", false);
198 submit_add_or_update_center($selected_id == -1, '', true);
202 if ($selected_id != -1)
204 display_heading(_("Quick Entry Lines") . " - " . $_POST['description']);
205 $result = get_quick_entry_lines($selected_id);
207 start_table($table_style2);
208 $dim = get_company_pref('use_dimension');
210 $th = array(_("Account"), _("Use Tax"), _("Percent"), _("Amount"), _("Dimension"), _("Dimension")." 2", "", "");
212 $th = array(_("Account"), _("Use Tax"), _("Percent"), _("Amount"), _("Dimension"), "", "");
214 $th = array(_("Account"), _("Use Tax"), _("Percent"), _("Amount"), "", "");
217 while ($myrow = db_fetch($result))
219 alt_table_row_color($k);
220 label_cell($myrow['account']." ".$myrow['account_name']);
221 $tax_text = ($myrow['tax_acc'] == 0 ? _("No") : _("Yes"));
222 label_cell($tax_text);
223 $pct_text = ($myrow['pct'] == 0 ? _("No") : _("Yes"));
224 label_cell($pct_text);
225 amount_cell($myrow['amount']);
227 label_cell(get_dimension_string($myrow['dimension_id'], true));
229 label_cell(get_dimension_string($myrow['dimension2_id'], true));
230 edit_button_cell("BEd".$myrow["id"], _("Edit"));
231 edit_button_cell("BDel".$myrow["id"], _("Delete"));
235 hidden('selected_id', $selected_id);
236 hidden('selected_id2', $selected_id2);
237 hidden('description', $_POST['description']);
238 hidden('deposit', $_POST['deposit']);
239 hidden('bank_only', $_POST['bank_only']);
243 start_table($table_style2);
245 if ($selected_id2 != -1)
249 //editing an existing status code
250 $myrow = get_quick_entry_line($selected_id2);
252 $_POST['id'] = $myrow["id"];
253 $_POST['account'] = $myrow["account"];
254 $_POST['tax_acc'] = $myrow["tax_acc"];
255 $_POST['pct'] = $myrow["pct"];
256 $_POST['amount'] = $myrow["amount"];
257 $_POST['dimension_id'] = $myrow["dimension_id"];
258 $_POST['dimension2_id'] = $myrow["dimension2_id"];
262 gl_all_accounts_list_row(_("Account"), 'account', null, true);
263 yesno_list_row(_("Use Tax:"), 'tax_acc', null, "", "", false);
264 yesno_list_row(_("Use Percent:"), 'pct', null, "", "", false);
265 amount_row(_("Amount"), 'amount', null);
267 dimensions_list_row(_("Dimension"), 'dimension_id', null, true, " ", false, 1);
269 dimensions_list_row(_("Dimension")." 2", 'dimension2_id', null, true, " ", false, 2);
273 hidden('dimension2_id', 0);
275 hidden('dimension_id', 0);
276 hidden('selected_id', $selected_id);
277 hidden('selected_id2', $selected_id2);
278 hidden('description', $_POST['description']);
279 hidden('deposit', $_POST['deposit']);
280 hidden('bank_only', $_POST['bank_only']);
282 submit_add_or_update_center2($selected_id2 == -1, '', true);
286 //------------------------------------------------------------------------------------