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/banking.inc");
13 include_once($path_to_root . "/includes/reserved.inc");
14 include_once($path_to_root . "/includes/types.inc");
15 include_once($path_to_root . "/includes/current_user.inc");
17 $_search_button = "<input %s type='submit' class='combo_submit' style='border:0;background:url($path_to_root/themes/"
18 ."%s/images/locate.png) no-repeat;%s' aspect='fallback' name='%s' value=' ' title='"._("Set filter")."'> ";
20 $_select_button = "<input %s type='submit' class='combo_select' style='border:0;background:url($path_to_root/themes/"
21 ."%s/images/button_ok.png) no-repeat;%s' aspect='fallback' name='%s' value=' ' title='"._("Select")."'> ";
23 $all_items = reserved_words::get_all();
25 //----------------------------------------------------------------------------
26 // Universal sql combo generator
27 // $sql must return selector values and selector texts in columns 0 & 1
28 // Options are merged with defaults.
30 function combo_input($name, $selected_id, $sql, $valfield, $namefield,
35 $opts = array( // default options
36 'where'=> array(), // additional constraints
37 'order' => $namefield, // list sort order
38 // special option parameters
39 'spec_option'=>false, // option text or false
40 'spec_id' => 0, // option id
41 // submit on select parameters
42 'default' => '', // default value when $_POST is not set
43 'select_submit' => false, //submit on select: true/false
44 'edit_submit' => false, // call editor on F4
45 'async' => true, // select update via ajax (true) vs _page_body reload
46 // search box parameters
48 'search_box' => false, // name or true/false
49 'type' => 0, // type of extended selector:
50 // 0 - with (optional) visible search box, search by id
51 // 1 - with hidden search box, search by option text
52 // 2 - TODO reverse: box with hidden selector available via enter; this
53 // would be convenient for optional ad hoc adding of new item
54 'search_submit' => true, //search submit button: true/false
55 'size' => 8, // size and max of box tag
57 'cells' => false, // combo displayed as 2 <td></td> cells
58 'search' => array(), // sql field names to search
59 'format' => null, // format functions for regular options
61 'box_hint' => null, // box/selectors hints; null = std see below
62 'category' => false, // category column name or false
63 'show_inactive' => false // show inactive records.
65 // ------ merge options with defaults ----------
67 $opts = array_merge($opts, $options);
68 if (!is_array($opts['where'])) $opts['where'] = array($opts['where']);
70 $search_box = $opts['search_box']===true ? '_'.$name.'_edit' : $opts['search_box'];
71 $search_submit = $opts['search_submit']]===true ? '_'.$name.'_button' : $opts['search_submit'];
72 $select_submit = $opts['select_submit']===true ? '_'.$name.'_update' : $opts['select_submit'];
73 $spec_id = $opts['spec_id'];
74 $spec_option = $opts['spec_option'];
75 $by_id = ($opts['type'] == 0);
76 $class = $by_id ? 'combo':'combo2';
77 $disabled = $opts['disabled'] ? "disabled" : '';
79 if(!count($opts['search'])) {
80 $opts['search'] = array($by_id ? $valfield : $namefield);
82 if ($opts['sel_hint'] === null)
83 $opts['sel_hint'] = $by_id || $search_box==false ?
84 '' : _('Press Space tab for search pattern entry');
86 if ($opts['box_hint'] === null)
87 $opts['box_hint'] = $search_box && $search_submit != false ?
88 ($by_id ? _('Enter code fragment to search or * for all')
89 : _('Enter description fragment to search or * for all')) :'';
91 if ($selected_id == null) {
92 $selected_id = get_post($name, $opts['default']);
94 $txt = get_post($search_box);
98 if (isset($_POST[$select_submit])) {
99 if ($by_id) $txt = $_POST[$name];
102 $Ajax->activate('_page_body');
104 $Ajax->activate($name);
107 // search related sql modifications
109 $rel = "rel='$search_box'"; // set relation to list
110 if ($opts['search_submit']) {
111 if (isset($_POST[$search_submit])) {
112 $selected_id = ''; // ignore selected_id while search
114 $Ajax->activate('_page_body');
116 $Ajax->activate($name);
119 if ($spec_option === false && $selected_id==null)
122 $opts['where'][] = $valfield . "='". get_post($name, $spec_id)."'";
127 foreach($opts['search'] as $i=> $s)
128 $opts['search'][$i] = $s . " LIKE '%{$txt}%'";
129 $opts['where'][] = '('. implode($opts['search'], ' OR ') . ')';
134 if (count($opts['where'])) {
135 $where = strpos($sql, 'WHERE')==false ? ' WHERE ':' AND ';
136 $where .= '('. implode($opts['where'], ' AND ') . ')';
137 $group_pos = strpos($sql, 'GROUP BY');
139 $group = substr($sql, $group_pos);
140 $sql = substr($sql, 0, $group_pos) . $where.' '.$group;
145 if ($opts['order'] != false) {
146 if (!is_array($opts['order']))
147 $opts['order'] = array($opts['order']);
148 $sql .= ' ORDER BY '.implode(',',$opts['order']);
152 // ------ make selector ----------
153 $selector = $first_opt = '';
157 //if($name=='stock_id') display_error($sql);
158 if($result = db_query($sql)) {
159 while ($contact_row = db_fetch($result)) {
160 $value = $contact_row[0];
161 $descr = $opts['format']==null ? $contact_row[1] :
162 call_user_func($opts['format'], $contact_row);
164 if (get_post($search_submit) && ($txt === $value)) {
165 $selected_id = $value;
167 if ((string)($selected_id) === $value) {
171 // show selected option even if inactive
172 if (!$opts['show_inactive'] && @$contact_row['inactive'] && $sel==='') {
175 $optclass = @$contact_row['inactive'] ? "class='inactive'" : '';
177 if ($first_id === false) {
181 $cat = $contact_row[$opts['category']];
182 if ($opts['category'] !== false && $cat != $lastcat){
183 $selector .= "<optgroup label='".$cat."'>\n";
186 $selector .= "<option $sel $optclass value='$value'>$descr</option>\n";
188 db_free_result($result);
191 // Prepend special option.
192 if ($spec_option !== false) { // if special option used - add it
193 $first_id = $spec_id;
194 $first_opt = $spec_option;
196 // if($first_id !== false) {
197 $sel = $found===false ? 'selected' : '';
198 $optclass = @$contact_row['inactive'] ? "class='inactive'" : '';
199 $selector = "<option $sel value='$first_id'>$first_opt</option>\n"
203 if ($found === false) {
204 $selected_id = $first_id;
206 $_POST[$name] = $selected_id;
208 if ($by_id && $search_box != false) {
210 $Ajax->addUpdate($name, $search_box, $txt ? $txt : '');
212 $aspect = $opts['edit_submit'] ? " aspect='editable'" : '';
213 $selector = "<select $disabled name='$name' class='$class' title='"
214 . $opts['sel_hint']."'$aspect $rel>".$selector."</select>\n";
216 $Ajax->addUpdate($name, "_{$name}_sel", $selector);
218 // because of bug which M$ cannot fix since IE 5.0
219 // we must embed whole selector in span tags to enable proper ajax update
220 $selector = "<span id='_{$name}_sel'>".$selector."</span>\n";
222 if ($select_submit != false) { // if submit on change is used - add select button
223 global $_select_button;
224 // button class selects form reload/ajax selector update
225 $selector .= sprintf($_select_button, $disabled, user_theme(),
226 (fallback_mode() ? '' : 'display:none;'),
227 $select_submit)."\n";
229 // ------ make combo ----------
232 if ($search_box != false) {
233 $edit_entry = "<input $disabled type='text' name='$search_box' id='$search_box' size='".
234 $opts['size']."' maxlength='".$opts['max'].
235 "' value='$txt' class='$class' rel='$name' autocomplete='off' title='"
236 .$opts['box_hint']."'"
237 .(!fallback_mode() && !$by_id ? " style=display:none;":'')
239 if ($search_submit != false) {
240 global $_search_button;
241 $edit_entry .= sprintf($_search_button, $disabled, user_theme(),
242 (fallback_mode() ? '' : 'display:none;'),
243 $search_submit)."\n";
246 default_focus(($search_box && $by_id) ? $search_box : $name);
248 if ($search_box && $opts['cells'])
249 echo ($edit_entry!='' ? "<td>$edit_entry</td>" : '')."<td>$selector</td>";
251 echo $edit_entry.$selector;
258 Returns true if selector $name is subject to update.
260 function list_updated($name)
262 return isset($_POST['_'.$name.'_update']) || isset($_POST['_'.$name.'_button']);
264 //----------------------------------------------------------------------------------------------
265 // Universal array combo generator
266 // $items is array of options 'value' => 'description'
267 // Options is reduced set of combo_selector options and is merged with defaults.
269 function array_selector($name, $selected_id, $items, $options=null)
273 $opts = array( // default options
274 'spec_option'=>false, // option text or false
275 'spec_id' => 0, // option id
276 'select_submit' => false, //submit on select: true/false
277 'edit_submit' => false, // call editor on F4
278 'async' => true, // select update via ajax (true) vs _page_body reload
279 'default' => '', // default value when $_POST is not set
280 // search box parameters
284 // ------ merge options with defaults ----------
286 $opts = array_merge($opts, $options);
287 $select_submit = $opts['select_submit']===true ? '_'.$name.'_update' : $opts['select_submit'];
288 $spec_id = $opts['spec_id'];
289 $spec_option = $opts['spec_option'];
290 $disabled = $opts['disabled'] ? "disabled" : '';
292 if ($selected_id == null) {
293 $selected_id = get_post($name, $opts['default']);
296 if (isset($_POST[$select_submit])) {
298 $Ajax->activate('_page_body');
300 $Ajax->activate($name);
303 // ------ make selector ----------
304 $selector = $first_opt = '';
307 //if($name=='SelectStockFromList') display_error($sql);
308 foreach($items as $value=>$descr) {
310 if ((string)$selected_id === (string)$value) {
314 if ($first_id === false) {
318 $selector .= "<option $sel value='$value'>$descr</option>\n";
321 // Prepend special option.
322 if ($spec_option !== false) { // if special option used - add it
323 $first_id = $spec_id;
324 $first_opt = $spec_option;
325 $sel = $found===false ? 'selected' : '';
326 $selector = "<option $sel value='$spec_id'>$spec_option</option>\n"
330 if ($found === false) {
331 $selected_id = $first_id;
333 $_POST[$name] = $selected_id;
335 $aspect = $opts['edit_submit'] ? " aspect='editable'" : '';
336 $selector = "<select $disabled name='$name' class='combo' title='"
337 . $opts['sel_hint']."'$aspect >".$selector."</select>\n";
339 $Ajax->addUpdate($name, "_{$name}_sel", $selector);
341 $selector = "<span id='_{$name}_sel'>".$selector."</span>\n";
343 if ($select_submit != false) { // if submit on change is used - add select button
344 global $_select_button;
345 $selector .= sprintf($_select_button, $disabled, user_theme(),
346 (fallback_mode() ? '' : 'display:none;'),
347 $select_submit)."\n";
349 default_focus($name);
354 //----------------------------------------------------------------------------------------------
356 function _format_add_curr($row)
358 static $company_currency;
360 if ($company_currency == null)
362 $company_currency = get_company_currency();
364 return $row[1] . ($row[2] == $company_currency ?
365 '' : (" - " . $row[2]));
368 function supplier_list($name, $selected_id=null, $spec_option=false, $submit_on_change=false,
373 $sql = "SELECT supplier_id, supp_name, curr_code, inactive FROM ".TB_PREF."suppliers ";
375 $mode = get_company_pref('no_supplier_list');
377 return combo_input($name, $selected_id, $sql, 'supplier_id', 'supp_name',
379 'format' => '_format_add_curr',
380 'search_box' => $mode!=0,
381 'edit_submit' => true,
383 'spec_option' => $spec_option === true ? _("All Suppliers") : $spec_option,
384 'spec_id' => $all_items,
385 'select_submit'=> $submit_on_change,
387 'sel_hint' => $mode ? _('Press Space tab to filter by name fragment') :
388 _('Select supplier'),
389 'show_inactive'=>$all
393 function supplier_list_cells($label, $name, $selected_id=null, $all_option=false,
394 $submit_on_change=false, $all=false)
397 echo "<td>$label</td><td>\n";
398 $str = supplier_list($name, $selected_id, $all_option, $submit_on_change, $all);
403 function supplier_list_row($label, $name, $selected_id=null, $all_option = false, $submit_on_change=false)
405 echo "<tr><td>$label</td><td>";
406 $str = supplier_list($name, $selected_id, $all_option, $submit_on_change );
410 //----------------------------------------------------------------------------------------------
412 function customer_list($name, $selected_id=null, $spec_option=false, $submit_on_change=false, $show_inactive=false)
416 $sql = "SELECT debtor_no, name, curr_code, inactive FROM ".TB_PREF."debtors_master ";
418 $mode = get_company_pref('no_customer_list');
420 return combo_input($name, $selected_id, $sql, 'debtor_no', 'name',
422 'format' => '_format_add_curr',
423 'search_box' => $mode!=0,
426 'spec_option' => $spec_option === true ? _("All Customers") : $spec_option,
427 'spec_id' => $all_items,
428 'select_submit'=> $submit_on_change,
429 'edit_submit' => true, // call editor on F4
431 'sel_hint' => $mode ? _('Press Space tab to filter by name fragment; F4 - entry new customer') :
432 _('Select customer'),
433 'show_inactive' => $show_inactive
437 function customer_list_cells($label, $name, $selected_id=null, $all_option=false,
438 $submit_on_change=false, $show_inactive=false)
441 echo "<td>$label</td>\n";
443 $str = customer_list($name, $selected_id, $all_option, $submit_on_change,
449 function customer_list_row($label, $name, $selected_id=null, $all_option = false,
450 $submit_on_change=false, $show_inactive=false)
452 echo "<tr><td>$label</td><td nowrap>";
453 $str = customer_list($name, $selected_id, $all_option, $submit_on_change,
455 echo "</td>\n</tr>\n";
459 //------------------------------------------------------------------------------------------------
461 function customer_branches_list($customer_id, $name, $selected_id=null,
462 $spec_option = true, $enabled=true, $submit_on_change=false)
466 $sql = "SELECT branch_code, br_name FROM ".TB_PREF."cust_branch
467 WHERE debtor_no='" . $customer_id . "' ";
469 $where = $enabled ? array("disable_trans = 0") : array();
470 return combo_input($name, $selected_id, $sql, 'branch_code', 'br_name',
473 'spec_option' => $spec_option === true ? _('All branches') : $spec_option,
474 'spec_id' => $all_items,
475 'select_submit'=> $submit_on_change,
476 'sel_hint' => _('Select customer branch')
479 //------------------------------------------------------------------------------------------------
481 function customer_branches_list_cells($label,$customer_id, $name, $selected_id=null, $all_option = true, $enabled=true, $submit_on_change=false)
484 echo "<td>$label</td>\n";
486 $ret = customer_branches_list($customer_id, $name, $selected_id, $all_option, $enabled, $submit_on_change);
491 function customer_branches_list_row($label,$customer_id, $name, $selected_id=null, $all_option = true, $enabled=true, $submit_on_change=false)
494 $ret = customer_branches_list_cells($label, $customer_id, $name, $selected_id, $all_option, $enabled, $submit_on_change);
499 //------------------------------------------------------------------------------------------------
501 function locations_list($name, $selected_id=null, $all_option=false, $submit_on_change=false)
505 $sql = "SELECT loc_code, location_name, inactive FROM ".TB_PREF."locations";
507 return combo_input($name, $selected_id, $sql, 'loc_code', 'location_name',
509 'spec_option' => $all_option === true ? _("All Locations") : $all_option,
510 'spec_id' => $all_items,
511 'select_submit'=> $submit_on_change
515 function locations_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
518 echo "<td>$label</td>\n";
520 $str = locations_list($name, $selected_id, $all_option, $submit_on_change);
525 function locations_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
528 $str = locations_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
533 //-----------------------------------------------------------------------------------------------
535 function currencies_list($name, $selected_id=null, $submit_on_change=false)
537 $sql = "SELECT curr_abrev, currency, inactive FROM ".TB_PREF."currencies";
539 // default to the company currency
541 return combo_input($name, $selected_id, $sql, 'curr_abrev', 'currency',
543 'select_submit'=> $submit_on_change,
544 'default' => get_company_currency(),
549 function currencies_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
552 echo "<td>$label</td>\n";
554 $str = currencies_list($name, $selected_id, $submit_on_change);
559 function currencies_list_row($label, $name, $selected_id=null, $submit_on_change=false)
562 $str = currencies_list_cells($label, $name, $selected_id, $submit_on_change);
567 //---------------------------------------------------------------------------------------------------
569 function fiscalyears_list($name, $selected_id=null, $submit_on_change=false)
572 $sql = "SELECT * FROM ".TB_PREF."fiscal_year";
574 // default to the company current fiscal year
576 return combo_input($name, $selected_id, $sql, 'id', '',
579 'default' => get_company_pref('f_year'),
580 'format' => '_format_fiscalyears',
581 'select_submit'=> $submit_on_change,
586 function _format_fiscalyears($row)
588 return sql2date($row[1]) . " - " . sql2date($row[2])
589 . " " . ($row[3] ? _('Closed') : _('Active')) . "</option>\n";
592 function fiscalyears_list_cells($label, $name, $selected_id=null)
595 echo "<td>$label</td>\n";
597 $str = fiscalyears_list($name, $selected_id);
602 function fiscalyears_list_row($label, $name, $selected_id=null)
605 $str = fiscalyears_list_cells($label, $name, $selected_id);
609 //------------------------------------------------------------------------------------
611 function dimensions_list($name, $selected_id=null, $no_option=false, $showname=' ',
612 $submit_on_change=false, $showclosed=false, $showtype=1)
614 $sql = "SELECT id, CONCAT(reference,' ',name) as ref FROM ".TB_PREF."dimensions";
617 'order' => 'reference',
618 'spec_option'=>$no_option ? $showname : false,
620 'select_submit'=> $submit_on_change,
625 $options['where'][] = "closed=0";
627 $options['where'][] = "type_=$showtype";
629 return combo_input($name, $selected_id, $sql, 'id', 'ref', $options);
632 function dimensions_list_cells($label, $name, $selected_id=null, $no_option=false, $showname=null,
633 $showclosed=false, $showtype=0, $submit_on_change=false)
636 echo "<td>$label</td>\n";
638 $str = dimensions_list($name, $selected_id, $no_option, $showname, $submit_on_change, $showclosed, $showtype);
643 function dimensions_list_row($label, $name, $selected_id=null, $no_option=false, $showname=null,
644 $showclosed=false, $showtype=0, $submit_on_change=false)
647 $str = dimensions_list_cells($label, $name, $selected_id, $no_option, $showname,
648 $showclosed, $showtype, $submit_on_change);
653 //---------------------------------------------------------------------------------------------------
655 function stock_items_list($name, $selected_id=null, $all_option=false,
656 $submit_on_change=false, $opts=array())
660 $sql = "SELECT stock_id, s.description, c.description, s.inactive
661 FROM ".TB_PREF."stock_master s,".TB_PREF."stock_category c WHERE s.category_id=c.category_id";
663 return combo_input($name, $selected_id, $sql, 'stock_id', 's.description',
666 'format' => '_format_stock_items',
667 'spec_option' => $all_option===true ? _("All Items") : $all_option,
668 'spec_id' => $all_items,
669 'search_box' => true,
670 'search' => array("stock_id", "c.description","s.description"),
671 'search_submit' => get_company_pref('no_item_list')!=0,
673 'select_submit'=> $submit_on_change,
675 'order' => array('c.description','stock_id')
679 function _format_stock_items($row)
681 return (user_show_codes() ? ($row[0] . " - ") : "") . $row[1];
684 function stock_items_list_cells($label, $name, $selected_id=null, $all_option=false,
685 $submit_on_change=false, $all=false)
688 echo "<td>$label</td>\n";
689 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
690 array('cells'=>true, 'show_inactive'=>$all));
694 function stock_items_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
697 $str = stock_items_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
702 //---------------------------------------------------------------------------------------------------
704 // Select item via foreign code.
706 function sales_items_list($name, $selected_id=null, $all_option=false,
707 $submit_on_change=false, $type='', $opts=array())
711 $sql = "SELECT i.item_code, i.description, c.description, count(*)>1 as kit,
714 ".TB_PREF."stock_master s,
715 ".TB_PREF."item_codes i
717 ".TB_PREF."stock_category c
718 ON i.category_id=c.category_id
719 WHERE i.stock_id=s.stock_id";
722 if ($type == 'local') { // exclude foreign codes
723 $sql .= " AND !i.is_foreign";
724 } elseif ($type == 'kits') { // sales kits
725 $sql .= " AND !i.is_foreign AND i.item_code!=i.stock_id";
727 $sql .= " AND !i.inactive AND !s.inactive AND !s.no_sale";
728 $sql .= " GROUP BY i.item_code";
730 return combo_input($name, $selected_id, $sql, 'i.item_code', 'c.description',
733 'format' => '_format_stock_items',
734 'spec_option' => $all_option===true ? _("All Items") : $all_option,
735 'spec_id' => $all_items,
736 'search_box' => true,
737 'search' => array("i.item_code", "i.description"),
738 'search_submit' => get_company_pref('no_item_list')!=0,
740 'select_submit'=> $submit_on_change,
742 'order' => array('c.description','i.item_code')
746 function sales_items_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
749 echo "<td>$label</td>\n";
750 $str = sales_items_list($name, $selected_id, $all_option, $submit_on_change,
751 '', array('cells'=>true));
755 function sales_kits_list($name, $selected_id=null, $all_option=false, $submit_on_change=false)
757 $str = sales_items_list($name, $selected_id, $all_option, $submit_on_change,
758 'kits', array('cells'=>false));
762 function sales_local_items_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
766 echo "<td>$label</td>\n";
768 $str = sales_items_list($name, $selected_id, $all_option, $submit_on_change,
769 'local', array('cells'=>false));
773 //------------------------------------------------------------------------------------
775 function stock_manufactured_items_list($name, $selected_id=null,
776 $all_option=false, $submit_on_change=false)
778 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
779 array('where'=>array("mb_flag= 'M'"),
780 'edit_submit' => true));
784 function stock_manufactured_items_list_cells($label, $name, $selected_id=null,
785 $all_option=false, $submit_on_change=false)
788 echo "<td>$label</td>\n";
790 $str = stock_manufactured_items_list($name, $selected_id, $all_option, $submit_on_change);
795 function stock_manufactured_items_list_row($label, $name, $selected_id=null,
796 $all_option=false, $submit_on_change=false)
799 $str = stock_manufactured_items_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
803 //------------------------------------------------------------------------------------
805 function stock_component_items_list($name, $parent_stock_id, $selected_id=null,
806 $all_option=false, $submit_on_change=false)
808 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
809 array('where'=>array("stock_id != '$parent_stock_id'")));
813 function stock_component_items_list_cells($label, $name, $parent_stock_id,
814 $selected_id=null, $all_option=false, $submit_on_change=false)
817 echo "<td>$label</td>\n";
818 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
819 array('where'=>array("stock_id != '$parent_stock_id'"), 'cells'=>true));
822 //------------------------------------------------------------------------------------
824 function stock_costable_items_list($name, $selected_id=null,
825 $all_option=false, $submit_on_change=false)
827 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
828 array('where'=>array("mb_flag!='D'")));
832 function stock_costable_items_list_cells($label, $name, $selected_id=null,
833 $all_option=false, $submit_on_change=false)
836 echo "<td>$label</td>\n";
837 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
838 array('where'=>array("mb_flag!='D'"), 'cells'=>true));
842 //------------------------------------------------------------------------------------
843 function stock_purchasable_items_list($name, $selected_id=null,
844 $all_option=false, $submit_on_change=false, $all=false)
846 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
847 array('where'=>array("mb_flag!= 'M'"),
848 'edit_submit' => true,
849 'show_inactive'=>$all));
853 function stock_purchasable_items_list_cells($label, $name, $selected_id=null,
854 $all_option=false, $submit_on_change=false, $all=false)
857 echo "<td>$label</td>\n";
858 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
859 array('where'=>array("mb_flag!= 'M'"),
860 'edit_submit' => true,
865 function stock_purchasable_items_list_row($label, $name, $selected_id=null,
866 $all_option=false, $submit_on_change=false)
869 $ret = stock_purchasable_items_list_cells($label, $name, $selected_id=null,
870 $all_option, $submit_on_change);
875 //------------------------------------------------------------------------------------
877 function stock_item_types_list_row($label, $name, $selected_id=null, $enabled=true)
883 echo "<td>$label</td>\n";
886 array_selector($name, $selected_id, $stock_types,
888 'select_submit'=> true,
889 'disabled' => !$enabled) );
893 function stock_units_list_row($label, $name, $value=null, $enabled=true)
895 $result = get_all_item_units();
898 echo "<td>$label</td>\n";
901 while($unit = db_fetch($result))
902 $units[$unit['abbr']] = $unit['name'];
904 array_selector($name, $value, $units, array( 'disabled' => !$enabled) );
909 //------------------------------------------------------------------------------------
911 function tax_types_list($name, $selected_id=null, $none_option=false, $submit_on_change=false)
913 $sql = "SELECT id, CONCAT(name, ' (',rate,'%)') as name FROM ".TB_PREF."tax_types";
915 return combo_input($name, $selected_id, $sql, 'id', 'name',
917 'spec_option' => $none_option,
918 'spec_id' => reserved_words::get_all_numeric(),
919 'select_submit'=> $submit_on_change,
924 function tax_types_list_cells($label, $name, $selected_id=null, $none_option=false,
925 $submit_on_change=false)
928 echo "<td>$label</td>\n";
930 $str = tax_types_list($name, $selected_id, $none_option, $submit_on_change);
935 function tax_types_list_row($label, $name, $selected_id=null, $none_option=false,
936 $submit_on_change=false)
939 $str = tax_types_list_cells($label, $name, $selected_id, $none_option, $submit_on_change);
944 //------------------------------------------------------------------------------------
946 function tax_groups_list($name, $selected_id=null,
947 $none_option=false, $submit_on_change=false)
949 $sql = "SELECT id, name FROM ".TB_PREF."tax_groups";
951 return combo_input($name, $selected_id, $sql, 'id', 'name',
954 'spec_option' => $none_option,
955 'spec_id' => reserved_words::get_all_numeric(),
956 'select_submit'=> $submit_on_change,
961 function tax_groups_list_cells($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false)
964 echo "<td>$label</td>\n";
966 $str = tax_groups_list($name, $selected_id, $none_option, $submit_on_change);
971 function tax_groups_list_row($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false)
974 $str = tax_groups_list_cells($label, $name, $selected_id, $none_option, $submit_on_change);
979 //------------------------------------------------------------------------------------
981 function item_tax_types_list($name, $selected_id=null)
983 $sql ="SELECT id, name FROM ".TB_PREF."item_tax_types";
984 combo_input($name, $selected_id, $sql, 'id', 'name', array('order' => 'id') );
987 function item_tax_types_list_cells($label, $name, $selected_id=null)
990 echo "<td>$label</td>\n";
992 item_tax_types_list($name, $selected_id);
996 function item_tax_types_list_row($label, $name, $selected_id=null)
999 item_tax_types_list_cells($label, $name, $selected_id);
1003 //------------------------------------------------------------------------------------
1005 function shippers_list($name, $selected_id=null)
1007 $sql = "SELECT shipper_id, shipper_name, inactive FROM ".TB_PREF."shippers";
1008 combo_input($name, $selected_id, $sql, 'shipper_id', 'shipper_name', array());
1011 function shippers_list_cells($label, $name, $selected_id=null)
1014 echo "<td>$label</td>\n";
1016 shippers_list($name, $selected_id);
1020 function shippers_list_row($label, $name, $selected_id=null)
1023 shippers_list_cells($label, $name, $selected_id);
1027 //-------------------------------------------------------------------------------------
1029 function sales_persons_list($name, $selected_id=null)
1031 $sql = "SELECT salesman_code, salesman_name, inactive FROM ".TB_PREF."salesman";
1032 combo_input($name, $selected_id, $sql, 'salesman_code', 'salesman_name', array());
1035 function sales_persons_list_cells($label, $name, $selected_id=null)
1038 echo "<td>$label</td>\n";
1040 sales_persons_list($name, $selected_id);
1044 function sales_persons_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1047 sales_persons_list_cells($label, $name, $selected_id, $submit_on_change=false);
1051 //------------------------------------------------------------------------------------
1053 function sales_areas_list($name, $selected_id=null)
1055 $sql = "SELECT area_code, description, inactive FROM ".TB_PREF."areas";
1056 combo_input($name, $selected_id, $sql, 'area_code', 'description', array());
1059 function sales_areas_list_cells($label, $name, $selected_id=null)
1062 echo "<td>$label</td>\n";
1064 sales_areas_list($name, $selected_id);
1068 function sales_areas_list_row($label, $name, $selected_id=null)
1071 sales_areas_list_cells($label, $name, $selected_id);
1075 //------------------------------------------------------------------------------------
1077 function sales_groups_list($name, $selected_id=null, $special_option=false)
1079 $sql = "SELECT id, description, inactive FROM ".TB_PREF."groups";
1080 combo_input($name, $selected_id, $sql, 'id', 'description', array(
1081 'spec_option' => $special_option===true ? ' ' : $special_option,
1082 'order' => 'description', 'spec_id' => 0,
1086 function sales_groups_list_cells($label, $name, $selected_id=null, $special_option=false)
1089 echo "<td>$label</td>\n";
1091 sales_groups_list($name, $selected_id, $special_option);
1095 function sales_groups_list_row($label, $name, $selected_id=null, $special_option=false)
1098 sales_groups_list_cells($label, $name, $selected_id, $special_option);
1102 //------------------------------------------------------------------------------------
1104 function _format_template_items($row)
1106 return ($row[0] . " - " . _("Amount") . " ".$row[1]);
1109 function templates_list($name, $selected_id=null, $special_option=false)
1111 $sql = "SELECT sorder.order_no, Sum(line.unit_price*line.quantity*(1-line.discount_percent)) AS OrderValue
1112 FROM ".TB_PREF."sales_orders as sorder, ".TB_PREF."sales_order_details as line
1113 WHERE sorder.order_no = line.order_no AND sorder.type = 1 GROUP BY line.order_no";
1114 combo_input($name, $selected_id, $sql, 'order_no', 'OrderValue', array(
1115 'format' => '_format_template_items',
1116 'spec_option' => $special_option===true ? ' ' : $special_option,
1117 'order' => 'order_no', 'spec_id' => 0,
1121 function templates_list_cells($label, $name, $selected_id=null, $special_option=false)
1124 echo "<td>$label</td>\n";
1126 templates_list($name, $selected_id, $special_option);
1130 function templates_list_row($label, $name, $selected_id=null, $special_option=false)
1133 templates_list_cells($label, $name, $selected_id, $special_option);
1137 //------------------------------------------------------------------------------------
1139 function workorders_list($name, $selected_id=null)
1141 $sql = "SELECT id, wo_ref FROM ".TB_PREF."workorders WHERE closed=0";
1142 combo_input($name, $selected_id, $sql, 'id', 'wo_ref', array());
1145 function workorders_list_cells($label, $name, $selected_id=null)
1148 echo "<td>$label</td>\n";
1150 workorders_list($name, $selected_id);
1154 function workorders_list_row($label, $name, $selected_id=null)
1157 workorders_list_cells($label, $name, $selected_id);
1161 //------------------------------------------------------------------------------------
1163 function payment_terms_list($name, $selected_id=null)
1165 $sql = "SELECT terms_indicator, terms, inactive FROM ".TB_PREF."payment_terms";
1166 combo_input($name, $selected_id, $sql, 'terms_indicator', 'terms', array());
1169 function payment_terms_list_cells($label, $name, $selected_id=null)
1172 echo "<td>$label</td>\n";
1174 payment_terms_list($name, $selected_id);
1178 function payment_terms_list_row($label, $name, $selected_id=null)
1181 payment_terms_list_cells($label, $name, $selected_id);
1185 //------------------------------------------------------------------------------------
1187 function credit_status_list($name, $selected_id=null)
1189 $sql ="SELECT id, reason_description, inactive FROM ".TB_PREF."credit_status";
1190 combo_input($name, $selected_id, $sql, 'id', 'reason_description', array());
1193 function credit_status_list_cells($label, $name, $selected_id=null)
1196 echo "<td>$label</td>\n";
1198 credit_status_list($name, $selected_id);
1202 function credit_status_list_row($label, $name, $selected_id=null)
1205 credit_status_list_cells($label, $name, $selected_id);
1209 //-----------------------------------------------------------------------------------------------
1211 function sales_types_list($name, $selected_id=null, $submit_on_change=false, $special_option=false)
1213 $sql = "SELECT id, sales_type, inactive FROM ".TB_PREF."sales_types";
1215 return combo_input($name, $selected_id, $sql, 'id', 'sales_type',
1217 'spec_option' => $special_option===true ? _("All Sales Types") : $special_option,
1219 'select_submit'=> $submit_on_change,
1220 // 'async' => false,
1224 function sales_types_list_cells($label, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1227 echo "<td>$label</td>\n";
1229 $str = sales_types_list($name, $selected_id, $submit_on_change, $special_option);
1234 function sales_types_list_row($label, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1237 $str = sales_types_list_cells($label, $name, $selected_id, $submit_on_change, $special_option);
1242 //-----------------------------------------------------------------------------------------------
1244 function movement_types_list($name, $selected_id=null)
1246 $sql = "SELECT id, name FROM ".TB_PREF."movement_types";
1247 combo_input($name, $selected_id, $sql, 'id', 'name', array());
1250 function movement_types_list_cells($label, $name, $selected_id=null)
1253 echo "<td>$label</td>\n";
1255 movement_types_list($name, $selected_id);
1259 function movement_types_list_row($label, $name, $selected_id=null)
1262 movement_types_list_cells($label, $name, $selected_id);
1266 //-----------------------------------------------------------------------------------------------
1267 function _format_date($row)
1269 return sql2date($row['reconciled']);
1272 function bank_reconciliation_list($account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1274 $sql = "SELECT reconciled, reconciled FROM ".TB_PREF."bank_trans
1275 WHERE bank_act=".db_escape($account)." AND reconciled IS NOT NULL
1276 GROUP BY reconciled";
1277 combo_input($name, $selected_id, $sql, 'id', 'reconciled',
1279 'spec_option' => $special_option,
1280 'format' => '_format_date',
1282 'select_submit'=> $submit_on_change
1286 function bank_reconciliation_list_cells($label,$account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1289 echo "<td>$label</td>\n";
1291 bank_reconciliation_list($account, $name, $selected_id, $submit_on_change, $special_option);
1295 function bank_reconciliation_list_row($label, $account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1298 bank_reconciliation_list_cells($label, $account, $name, $selected_id, $submit_on_change, $special_option);
1302 //-----------------------------------------------------------------------------------------------
1304 function workcenter_list($name, $selected_id=null, $all_option=false)
1308 $sql = "SELECT id, name, inactive FROM ".TB_PREF."workcentres";
1310 return combo_input($name, $selected_id, $sql, 'id', 'name',
1312 'spec_option' =>$all_option===true ? _("All Suppliers") : $all_option,
1313 'spec_id' => $all_items,
1317 function workcenter_list_cells($label, $name, $selected_id=null, $all_option=false)
1319 default_focus($name);
1321 echo "<td>$label</td>\n";
1323 workcenter_list($name, $selected_id, $all_option);
1327 function workcenter_list_row($label, $name, $selected_id=null, $all_option=false)
1330 workcenter_list_cells($label, $name, $selected_id, $all_option);
1334 //-----------------------------------------------------------------------------------------------
1336 function bank_accounts_list($name, $selected_id=null, $submit_on_change=false)
1338 $sql = "SELECT ".TB_PREF."bank_accounts.id, bank_account_name, bank_curr_code, inactive
1339 FROM ".TB_PREF."bank_accounts";
1340 // , ".TB_PREF."chart_master
1341 // WHERE ".TB_PREF."bank_accounts.account_code=".TB_PREF."chart_master.account_code";
1343 return combo_input($name, $selected_id, $sql, 'id', 'bank_account_name',
1345 'format' => '_format_add_curr',
1346 'select_submit'=> $submit_on_change,
1351 function bank_accounts_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1354 echo "<td>$label</td>\n";
1356 $str = bank_accounts_list($name, $selected_id, $submit_on_change);
1361 function bank_accounts_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1364 $str = bank_accounts_list_cells($label, $name, $selected_id, $submit_on_change);
1368 //-----------------------------------------------------------------------------------------------
1370 function cash_accounts_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1372 $sql = "SELECT ".TB_PREF."bank_accounts.id, bank_account_name, bank_curr_code, inactive
1373 FROM ".TB_PREF."bank_accounts
1374 WHERE ".TB_PREF."bank_accounts.account_type=3";
1377 echo "<tr><td>$label</td>\n";
1379 $str = combo_input($name, $selected_id, $sql, 'id', 'bank_account_name',
1381 'format' => '_format_add_curr',
1382 'select_submit'=> $submit_on_change,
1385 echo "</td></tr>\n";
1388 //-----------------------------------------------------------------------------------------------
1390 function pos_list_row($label, $name, $selected_id=null, $spec_option=false, $submit_on_change=false)
1392 $sql = "SELECT id, pos_name, inactive FROM ".TB_PREF."sales_pos";
1394 default_focus($name);
1397 echo "<td>$label</td>\n";
1400 $str = combo_input($name, $selected_id, $sql, 'id', 'pos_name',
1402 'select_submit'=> $submit_on_change,
1404 'spec_option' =>$spec_option,
1407 echo "</td></tr>\n";
1411 //-----------------------------------------------------------------------------------------------
1413 function sale_payment_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1416 echo "<td>$label</td>\n";
1418 $str = yesno_list($name, $selected_id, _('Cash'), _('Delayed'), $submit_on_change);
1422 //-----------------------------------------------------------------------------------------------
1424 function class_list($name, $selected_id=null, $submit_on_change=false)
1426 $sql = "SELECT cid, class_name FROM ".TB_PREF."chart_class";
1428 return combo_input($name, $selected_id, $sql, 'cid', 'class_name',
1430 'select_submit'=> $submit_on_change,
1436 function class_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1439 echo "<td>$label</td>\n";
1441 $str = class_list($name, $selected_id, $submit_on_change);
1446 function class_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1449 $str = class_list_cells($label, $name, $selected_id, $submit_on_change);
1454 //-----------------------------------------------------------------------------------------------
1456 function stock_categories_list($name, $selected_id=null, $submit_on_change=false)
1458 $sql = "SELECT category_id, description, inactive FROM ".TB_PREF."stock_category";
1459 combo_input($name, $selected_id, $sql, 'category_id', 'description',
1460 array('order'=>'category_id',
1461 'select_submit'=> $submit_on_change,
1466 function stock_categories_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1469 echo "<td>$label</td>\n";
1471 stock_categories_list($name, $selected_id, $submit_on_change);
1475 function stock_categories_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1478 stock_categories_list_cells($label, $name, $selected_id, $submit_on_change);
1482 //-----------------------------------------------------------------------------------------------
1484 function gl_account_types_list($name, $selected_id=null, $all_option, $all_option_numeric)
1488 $sql = "SELECT id, name FROM ".TB_PREF."chart_types";
1490 combo_input($name, $selected_id, $sql, 'id', 'name',
1493 'spec_option' =>$all_option,
1494 'spec_id' => $all_option_numeric ? 0 : $all_items
1498 function gl_account_types_list_cells($label, $name, $selected_id=null, $all_option=false,
1499 $all_option_numeric=false)
1502 echo "<td>$label</td>\n";
1504 gl_account_types_list($name, $selected_id, $all_option, $all_option_numeric);
1508 function gl_account_types_list_row($label, $name, $selected_id=null, $all_option=false,
1509 $all_option_numeric=false)
1512 gl_account_types_list_cells($label, $name, $selected_id, $all_option,
1513 $all_option_numeric);
1517 //-----------------------------------------------------------------------------------------------
1518 function gl_all_accounts_list($name, $selected_id=null, $skip_bank_accounts=false,
1519 $cells=false, $all_option=false, $submit_on_change=false, $all=false)
1521 if ($skip_bank_accounts)
1522 $sql = "SELECT chart.account_code, chart.account_name, type.name, chart.inactive
1523 FROM (".TB_PREF."chart_master chart,".TB_PREF."chart_types type) "
1524 ."LEFT JOIN ".TB_PREF."bank_accounts acc "
1525 ."ON chart.account_code=acc.account_code
1526 WHERE acc.account_code IS NULL
1527 AND chart.account_type=type.id";
1529 $sql = "SELECT chart.account_code, chart.account_name, type.name, chart.inactive
1530 FROM ".TB_PREF."chart_master chart,".TB_PREF."chart_types type
1531 WHERE chart.account_type=type.id";
1533 combo_input($name, $selected_id, $sql, 'chart.account_code', 'chart.account_name',
1535 'format' => '_format_account',
1536 'spec_option' => $all_option===true ? _("Use Item Sales Accounts") : $all_option,
1538 'order' => array('name','account_code'),
1539 'search_box' => $cells,
1540 'search_submit' => false,
1544 'select_submit'=> $submit_on_change,
1547 'show_inactive' => $all
1552 function _format_account($row)
1554 return $row[0] . " " . $row[1];
1557 function gl_all_accounts_list_cells($label, $name, $selected_id=null,
1558 $skip_bank_accounts=false, $cells=false, $all_option=false,
1559 $submit_on_change=false, $all=false)
1562 echo "<td>$label</td>\n";
1564 gl_all_accounts_list($name, $selected_id,
1565 $skip_bank_accounts, $cells, $all_option, $submit_on_change, $all);
1569 function gl_all_accounts_list_row($label, $name, $selected_id=null,
1570 $skip_bank_accounts=false, $cells=false, $all_option=false)
1573 gl_all_accounts_list_cells($label, $name, $selected_id,
1574 $skip_bank_accounts, $cells, $all_option);
1578 function yesno_list($name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1581 $items['0'] = strlen($name_no) ? $name_no : _("No");
1582 $items['1'] = strlen($name_yes) ? $name_yes : _("Yes");
1584 return array_selector($name, $selected_id, $items,
1586 'select_submit'=> $submit_on_change,
1587 'async' => false ) ); // FIX?
1590 function yesno_list_cells($label, $name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1593 echo "<td>$label</td>\n";
1595 $str = yesno_list($name, $selected_id, $name_yes, $name_no, $submit_on_change);
1600 function yesno_list_row($label, $name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1603 $str = yesno_list_cells($label, $name, $selected_id, $name_yes, $name_no, $submit_on_change);
1608 //------------------------------------------------------------------------------------------------
1610 function languages_list($name, $selected_id=null)
1612 global $installed_languages;
1615 foreach ($installed_languages as $lang)
1616 $items[$lang['code']] = $lang['name'];
1618 return array_selector($name, $selected_id, $items );
1621 function languages_list_cells($label, $name, $selected_id=null)
1624 echo "<td>$label</td>\n";
1626 languages_list($name, $selected_id);
1630 function languages_list_row($label, $name, $selected_id=null)
1633 languages_list_cells($label, $name, $selected_id);
1637 //------------------------------------------------------------------------------------------------
1639 function bank_account_types_list($name, $selected_id=null)
1641 $types = bank_account_types::get_all();
1644 foreach ($types as $type)
1646 $items[$type['id']] = $type['name'];
1649 return array_selector($name, $selected_id, $items );
1652 function bank_account_types_list_cells($label, $name, $selected_id=null)
1655 echo "<td>$label</td>\n";
1657 bank_account_types_list($name, $selected_id);
1661 function bank_account_types_list_row($label, $name, $selected_id=null)
1664 bank_account_types_list_cells($label, $name, $selected_id);
1668 //------------------------------------------------------------------------------------------------
1669 function payment_person_types_list($name, $selected_id=null, $submit_on_change=false)
1671 $types = payment_person_types::get_all();
1674 foreach ($types as $type)
1676 if (payment_person_types::has_items($type['id']))
1678 if ($type['id'] != payment_person_types::WorkOrder())
1679 $items[$type['id']] = $type['name'];
1683 return array_selector($name, $selected_id, $items,
1684 array( 'select_submit'=> $submit_on_change ) );
1687 function payment_person_types_list_cells($label, $name, $selected_id=null, $related=null)
1690 echo "<td>$label</td>\n";
1692 $str = payment_person_types_list($name, $selected_id, $related);
1697 function payment_person_types_list_row($label, $name, $selected_id=null, $related=null)
1700 $str = payment_person_types_list_cells($label, $name, $selected_id, $related);
1705 //------------------------------------------------------------------------------------------------
1707 function wo_types_list($name, $selected_id=null)
1709 $types = wo_types::get_all();
1712 foreach ($types as $type)
1713 $items[$type['id']] = $type['name'];
1715 return array_selector($name, $selected_id, $items,
1716 array( 'select_submit'=> true, 'async' => true ) );
1719 function wo_types_list_row($label, $name, $selected_id=null)
1721 echo "<tr><td>$label</td><td>\n";
1722 $str = wo_types_list($name, $selected_id);
1723 echo "</td></tr>\n";
1727 //------------------------------------------------------------------------------------------------
1729 function dateformats_list_row($label, $name, $value=null)
1731 global $dateformats;
1733 echo "<tr><td>$label</td>\n<td>";
1734 array_selector( $name, $value, $dateformats );
1735 echo "</td></tr>\n";
1738 function dateseps_list_row($label, $name, $value=null)
1742 echo "<tr><td>$label</td>\n<td>";
1743 array_selector( $name, $value, $dateseps );
1744 echo "</td></tr>\n";
1747 function thoseps_list_row($label, $name, $value=null)
1751 echo "<tr><td>$label</td>\n<td>";
1752 array_selector( $name, $value, $thoseps );
1753 echo "</td></tr>\n";
1756 function decseps_list_row($label, $name, $value=null)
1760 echo "<tr><td>$label</td>\n<td>";
1761 array_selector( $name, $value, $decseps );
1762 echo "</td></tr>\n";
1765 function themes_list_row($label, $name, $value=null)
1767 global $path_to_root;
1769 $path = $path_to_root.'/themes/';
1771 $themedir = opendir($path);
1772 while(false !== ($fname = readdir($themedir)))
1774 if($fname!='.' && $fname!='..' && $fname!='CVS' && is_dir($path.$fname))
1776 $themes[$fname] = $fname;
1781 echo "<tr><td>$label</td>\n<td>";
1782 array_selector( $name, $value, $themes );
1783 echo "</td></tr>\n";
1786 function pagesizes_list_row($label, $name, $value=null)
1791 foreach ($pagesizes as $pz)
1794 echo "<tr><td>$label</td>\n<td>";
1795 array_selector( $name, $value, $items );
1796 echo "</td></tr>\n";
1799 function security_headings_list_row($label, $name, $value=null)
1801 global $security_headings;
1803 echo "<tr><td>$label</td>\n<td>";
1804 array_selector( $name, $value, $security_headings );
1805 echo "</td></tr>\n";
1808 function systypes_list_cells($label, $name, $value=null, $submit_on_change=false)
1810 global $systypes_array;
1813 echo "<td>$label</td>\n";
1817 foreach ($systypes_array as $key=>$type)
1818 $items[$key] = $type['name'];
1820 $str = array_selector($name, $value, $items,
1822 'select_submit'=> $submit_on_change,
1830 function journal_types_list_cells($label, $name, $value=null, $submit_on_change=false)
1832 global $systypes_array;
1835 echo "<td>$label</td>\n";
1839 foreach ($systypes_array as $key=>$type)
1840 // exclude orders and dimensions
1841 if (!in_array($key, array(18,26,30,40)))
1842 $items[$key] = $type['name'];
1844 $str = array_selector($name, $value, $items,
1846 'spec_option'=> _("All"),
1848 'select_submit'=> $submit_on_change,
1856 function systypes_list_row($label, $name, $value=null, $submit_on_change=false)
1859 $str = systypes_list_cells($label, $name, $value, $submit_on_change);
1864 function cust_allocations_list_cells($label, $name, $selected=null)
1872 $all_items=>_("All Types"),
1873 '1'=> _("Sales Invoices"),
1874 '2'=> _("Overdue Invoices"),
1875 '3' => _("Payments"),
1876 '4' => _("Credit Notes"),
1877 '5' => _("Delivery Notes")
1879 $str = array_selector($name, $selected, $allocs);
1884 function supp_allocations_list_cell($name, $selected=null)
1890 $all_items=>_("All Types"),
1891 '1'=> _("Invoices"),
1892 '2'=> _("Overdue Invoices"),
1893 '3' => _("Payments"),
1894 '4' => _("Credit Notes"),
1895 '5' => _("Overdue Credit Notes")
1897 $str = array_selector($name, $selected, $allocs);
1902 function policy_list_cells($label, $name, $selected=null)
1907 $str = array_selector($name, $selected,
1908 array( '' => _("Automatically put balance on back order"),
1909 'CAN' => _("Cancel any quantites not delivered")) );
1914 function policy_list_row($label, $name, $selected=null)
1917 policy_list_cells($label, $name, $selected);
1921 function credit_type_list_cells($label, $name, $selected=null, $submit_on_change=false)
1926 $str = array_selector($name, $selected,
1927 array( 'Return' => _("Items Returned to Inventory Location"),
1928 'WriteOff' => _("Items Written Off")),
1929 array( 'select_submit'=> $submit_on_change ) );
1934 function credit_type_list_row($label, $name, $selected=null, $submit_on_change=false)
1937 $str = credit_type_list_cells($label, $name, $selected, $submit_on_change);
1942 function number_list($name, $selected, $from, $to, $no_option=false)
1945 for ($i = $from; $i <= $to; $i++)
1948 return array_selector($name, $selected, $items,
1949 array( 'spec_option' => $no_option,
1950 'spec_id' => reserved_words::get_all_numeric()) );
1953 function number_list_cells($label, $name, $selected, $from, $to, $no_option=false)
1958 number_list($name, $selected, $from, $to, $no_option);
1962 function number_list_row($label, $name, $selected, $from, $to, $no_option=false)
1965 number_list_cells($label, $name, $selected, $from, $to, $no_option);
1969 function print_profiles_list_row($label, $name, $selected_id=null, $spec_opt=false,
1970 $submit_on_change=true)
1972 $sql = "SELECT profile FROM ".TB_PREF."print_profiles"
1973 ." GROUP BY profile";
1974 $result = db_query($sql, 'cannot get all profile names');
1975 $profiles = array();
1976 while($myrow=db_fetch($result)) {
1977 $profiles[$myrow['profile']] = $myrow['profile'];
1982 echo "<td>$label</td>\n";
1985 array_selector($name, $selected_id, $profiles,
1986 array( 'select_submit'=> $submit_on_change,
1987 'spec_option'=>$spec_opt,
1991 echo "</td></tr>\n";
1994 function printers_list($name, $selected_id=null, $spec_opt=false, $submit_on_change=false)
1996 static $printers; // query only once for page display
1999 $sql = "SELECT id, name, description FROM ".TB_PREF."printers";
2000 $result = db_query($sql, 'cannot get all printers');
2001 $printers = array();
2002 while($myrow=db_fetch($result)) {
2003 $printers[$myrow['id']] = $myrow['name'].' - '.$myrow['description'];
2006 array_selector($name, $selected_id, $printers,
2007 array( 'select_submit'=> $submit_on_change,
2008 'spec_option'=>$spec_opt,
2013 //------------------------------------------------------------------------------------------------
2015 function quick_entries_list($name, $selected_id=null, $type=null, $submit_on_change=false)
2018 $sql = "SELECT id, description FROM ".TB_PREF."quick_entries";
2020 $sql .= " WHERE type=$type";
2022 combo_input($name, $selected_id, $sql, 'id', 'description',
2025 'order' => 'description',
2026 'select_submit'=> $submit_on_change,
2032 function quick_entries_list_cells($label, $name, $selected_id=null, $type, $submit_on_change=false)
2034 echo "<td>$label</td><td>\n";
2035 quick_entries_list($name, $selected_id, $type, $submit_on_change);
2039 function quick_entries_list_row($label, $name, $selected_id=null, $type, $submit_on_change=false)
2042 quick_entries_list_cells($label, $name, $selected_id, $type, $submit_on_change);
2047 function quick_actions_list_row($label, $name, $selected_id=null, $submit_on_change=false)
2049 global $quick_actions;
2051 echo "<tr><td>$label</td><td>";
2052 array_selector($name, $selected_id, $quick_actions,
2054 'select_submit'=> $submit_on_change
2056 echo "</td></tr>\n";
2059 function quick_entry_types_list_row($label, $name, $selected_id=null, $submit_on_change=false)
2061 global $quick_entry_types;
2063 echo "<tr><td>$label</td><td>";
2064 array_selector($name, $selected_id, $quick_entry_types,
2066 'select_submit'=> $submit_on_change
2068 echo "</td></tr>\n";
2071 function record_status_list_row($label, $name) {
2072 return yesno_list_row($label, $name, null, _('Inactive'), _('Active'));
2075 function class_types_list_row($label, $name, $selected_id=null, $submit_on_change=false)
2077 global $class_types;
2079 echo "<tr><td>$label</td><td>";
2080 array_selector($name, $selected_id, $class_types,
2082 'select_submit'=> $submit_on_change
2084 echo "</td></tr>\n";