2 /**********************************************************************
3 Copyright (C) FrontAccounting, LLC.
4 Released under the terms of the GNU General Public License, GPL,
5 as published by the Free Software Foundation, either version 3
6 of the License, or (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
12 include_once $path_to_root.'/includes/db/class.reflines_db.inc';
13 include_once $path_to_root.'/includes/ui/class.crud_view.inc';
15 class fa_reflines extends simple_crud_view {
17 function __construct()
19 parent::__construct('refs', new reflines_db(), array('clone' => false));
21 $this->fields = array(
31 function list_view($Mode)
33 global $systypes_array;
35 start_table(TABLESTYLE);
37 $th = array(_("Transaction type"), _("Prefix"),
38 _("Pattern"), _("Default"), _("Memo"), "", "");
40 inactive_control_column($th);
45 $data = $this->data_set->get_all(check_value('show_inactive') ? null : '!inactive', array('trans_type', 'prefix'));
47 if (!$data) return false;
49 while ($rec = db_fetch($data))
51 alt_table_row_color($k);
53 label_cell($systypes_array[$rec['trans_type']]);
54 label_cell($rec['prefix']);
55 label_cell($rec['pattern']);
56 label_cell($rec['default'] ? _("Yes") : _("No"));
57 label_cell($rec['description']);
59 if (check_value('show_inactive') && $rec['default'])
62 inactive_control_cell($rec["id"], $rec["inactive"], 'reflines', 'id');
63 if ($this->options['update'])
64 echo $this->tool_button('Edit', $rec['id']);
65 if ($this->options['delete']) {
66 echo $this->tool_button('Delete', $rec['id']);
70 inactive_control_row($th);
72 $this->_record_controls(true);
77 function editor_view($Mode)
79 global $systypes_array;
81 $selected_id = $this->selected_id;
84 $fresh = $selected_id == $this->_none || !$this->data_set->is_used(get_post($this->name.'prefix'), get_post($this->name.'trans_type'));
86 start_table(TABLESTYLE2);
90 systypes_list_row(_("Transaction Type:"), $this->name.'trans_type');
91 $prefix = text_input($this->name.'prefix', null, 5, 30);
93 label_row(_("Transaction Type:"), $systypes_array[get_post($this->name.'trans_type')]);
94 hidden($this->name.'trans_type');
95 $prefix = get_post($this->name.'prefix') . hidden($this->name.'prefix');
98 label_row(_("Reference Pattern:"), $prefix . text_input($this->name.'pattern', null, 30, 60));
100 if (get_post($this->name.'default'))
101 { label_row(_("Default for This Type:"), _("Yes")); hidden($this->name.'default', 1); }
103 check_row(_("Set as Default for This Type:"), $this->name.'default');
105 text_row_ex(_("Memo:"), $this->name.'description', 30, 60);
108 hidden($this->name.'selected_id', $selected_id);
109 $this->_record_controls();
112 function show($Mode=null)