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/types.inc");
14 include_once($path_to_root . "/includes/current_user.inc");
16 $_search_button = "<input %s type='submit' class='combo_submit' style='border:0;background:url($path_to_root/themes/"
17 ."%s/images/locate.png) no-repeat;%s' aspect='fallback' name='%s' value=' ' title='"._("Set filter")."'> ";
19 $_select_button = "<input %s type='submit' class='combo_select' style='border:0;background:url($path_to_root/themes/"
20 ."%s/images/button_ok.png) no-repeat;%s' aspect='fallback' name='%s' value=' ' title='"._("Select")."'> ";
22 $all_items = ALL_TEXT;
24 //----------------------------------------------------------------------------
25 // Universal sql combo generator
26 // $sql must return selector values and selector texts in columns 0 & 1
27 // Options are merged with defaults.
29 function combo_input($name, $selected_id, $sql, $valfield, $namefield,
34 $opts = array( // default options
35 'where'=> array(), // additional constraints
36 'order' => $namefield, // list sort order
37 // special option parameters
38 'spec_option'=>false, // option text or false
39 'spec_id' => 0, // option id
40 // submit on select parameters
41 'default' => '', // default value when $_POST is not set
42 'select_submit' => false, //submit on select: true/false
43 'async' => true, // select update via ajax (true) vs _page_body reload
44 // search box parameters
46 'search_box' => false, // name or true/false
47 'type' => 0, // type of extended selector:
48 // 0 - with (optional) visible search box, search by id
49 // 1 - with hidden search box, search by option text
50 // 2 - TODO reverse: box with hidden selector available via enter; this
51 // would be convenient for optional ad hoc adding of new item
52 'search_submit' => true, //search submit button: true/false
53 'size' => 8, // size and max of box tag
55 'height' => false, // number of lines in select box
56 'cells' => false, // combo displayed as 2 <td></td> cells
57 'search' => array(), // sql field names to search
58 'format' => null, // format functions for regular options
60 'box_hint' => null, // box/selectors hints; null = std see below
61 'category' => false, // category column name or false
62 'show_inactive' => false // show inactive records.
64 // ------ merge options with defaults ----------
66 $opts = array_merge($opts, $options);
67 if (!is_array($opts['where'])) $opts['where'] = array($opts['where']);
69 $search_box = $opts['search_box']===true ? '_'.$name.'_edit' : $opts['search_box'];
70 $search_submit = $opts['search_submit']===true ? '_'.$name.'_button' : $opts['search_submit'];
71 $select_submit = $opts['select_submit'];
72 $spec_id = $opts['spec_id'];
73 $spec_option = $opts['spec_option'];
74 $by_id = ($opts['type'] == 0);
75 $class = $by_id ? 'combo':'combo2';
76 $disabled = $opts['disabled'] ? "disabled" : '';
78 if(!count($opts['search'])) {
79 $opts['search'] = array($by_id ? $valfield : $namefield);
81 if ($opts['sel_hint'] === null)
82 $opts['sel_hint'] = $by_id || $search_box==false ?
83 '' : _('Press Space tab for search pattern entry');
85 if ($opts['box_hint'] === null)
86 $opts['box_hint'] = $search_box && $search_submit != false ?
87 ($by_id ? _('Enter code fragment to search or * for all')
88 : _('Enter description fragment to search or * for all')) :'';
90 if ($selected_id == null) {
91 $selected_id = get_post($name, $opts['default']);
93 $txt = get_post($search_box);
97 if (isset($_POST['_'.$name.'_update'])) {
98 if ($by_id) $txt = $_POST[$name];
101 $Ajax->activate('_page_body');
103 $Ajax->activate($name);
106 // search related sql modifications
108 $rel = "rel='$search_box'"; // set relation to list
109 if ($opts['search_submit']) {
110 if (isset($_POST[$search_submit])) {
111 $selected_id = ''; // ignore selected_id while search
113 $Ajax->activate('_page_body');
115 $Ajax->activate($name);
118 if ($spec_option === false && $selected_id==null)
121 $opts['where'][] = $valfield . "='". get_post($name, $spec_id)."'";
126 foreach($opts['search'] as $i=> $s)
127 $opts['search'][$i] = $s . " LIKE '%{$txt}%'";
128 $opts['where'][] = '('. implode($opts['search'], ' OR ') . ')';
133 if (count($opts['where'])) {
134 $where = strpos($sql, 'WHERE')==false ? ' WHERE ':' AND ';
135 $where .= '('. implode($opts['where'], ' AND ') . ')';
136 $group_pos = strpos($sql, 'GROUP BY');
138 $group = substr($sql, $group_pos);
139 $sql = substr($sql, 0, $group_pos) . $where.' '.$group;
144 if ($opts['order'] != false) {
145 if (!is_array($opts['order']))
146 $opts['order'] = array($opts['order']);
147 $sql .= ' ORDER BY '.implode(',',$opts['order']);
151 // ------ make selector ----------
152 $selector = $first_opt = '';
156 //if($name=='stock_id') display_error($sql);
157 if($result = db_query($sql)) {
158 while ($contact_row = db_fetch($result)) {
159 $value = $contact_row[0];
160 $descr = $opts['format']==null ? $contact_row[1] :
161 call_user_func($opts['format'], $contact_row);
163 if (get_post($search_submit) && ($txt === $value)) {
164 $selected_id = $value;
166 if ((string)($selected_id) === $value) {
170 // show selected option even if inactive
171 if (!$opts['show_inactive'] && @$contact_row['inactive'] && $sel==='') {
174 $optclass = @$contact_row['inactive'] ? "class='inactive'" : '';
176 if ($first_id === false) {
180 $cat = $contact_row[$opts['category']];
181 if ($opts['category'] !== false && $cat != $lastcat){
182 $selector .= "<optgroup label='".$cat."'>\n";
185 $selector .= "<option $sel $optclass value='$value'>$descr</option>\n";
187 db_free_result($result);
190 // Prepend special option.
191 if ($spec_option !== false) { // if special option used - add it
192 $first_id = $spec_id;
193 $first_opt = $spec_option;
195 // if($first_id !== false) {
196 $sel = $found===false ? 'selected' : '';
197 $optclass = @$contact_row['inactive'] ? "class='inactive'" : '';
198 $selector = "<option $sel value='$first_id'>$first_opt</option>\n"
202 if ($found === false) {
203 $selected_id = $first_id;
205 $_POST[$name] = $selected_id;
207 if ($by_id && $search_box != false) {
209 $Ajax->addUpdate($name, $search_box, $txt ? $txt : '');
211 $selector = "<select ".(strpos($name,'[]')!==false ? "multiple" : '')
212 . ($opts['height']!==false ? ' size="'.$opts['height'].'"' : '')
213 . "$disabled name='$name' class='$class' title='"
214 . $opts['sel_hint']."' $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 '_'.$name.'_update')."\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 'async' => true, // select update via ajax (true) vs _page_body reload
278 'default' => '', // default value when $_POST is not set
279 // search box parameters
283 // ------ merge options with defaults ----------
285 $opts = array_merge($opts, $options);
286 $select_submit = $opts['select_submit'];
287 $spec_id = $opts['spec_id'];
288 $spec_option = $opts['spec_option'];
289 $disabled = $opts['disabled'] ? "disabled" : '';
291 if ($selected_id == null) {
292 $selected_id = get_post($name, $opts['default']);
295 if (isset($_POST[ '_'.$name.'_update'])) {
297 $Ajax->activate('_page_body');
299 $Ajax->activate($name);
302 // ------ make selector ----------
303 $selector = $first_opt = '';
306 //if($name=='SelectStockFromList') display_error($sql);
307 foreach($items as $value=>$descr) {
309 if ((string)$selected_id === (string)$value) {
313 if ($first_id === false) {
317 $selector .= "<option $sel value='$value'>$descr</option>\n";
320 // Prepend special option.
321 if ($spec_option !== false) { // if special option used - add it
322 $first_id = $spec_id;
323 $first_opt = $spec_option;
324 $sel = $found===false ? 'selected' : '';
325 $selector = "<option $sel value='$spec_id'>$spec_option</option>\n"
329 if ($found === false) {
330 $selected_id = $first_id;
332 $_POST[$name] = $selected_id;
334 $selector = "<select $disabled name='$name' class='combo' title='"
335 . $opts['sel_hint']."'>".$selector."</select>\n";
337 $Ajax->addUpdate($name, "_{$name}_sel", $selector);
339 $selector = "<span id='_{$name}_sel'>".$selector."</span>\n";
341 if ($select_submit != false) { // if submit on change is used - add select button
342 global $_select_button;
343 $selector .= sprintf($_select_button, $disabled, user_theme(),
344 (fallback_mode() ? '' : 'display:none;'),
345 '_'.$name.'_update')."\n";
347 default_focus($name);
352 //----------------------------------------------------------------------------------------------
354 function _format_add_curr($row)
356 static $company_currency;
358 if ($company_currency == null)
360 $company_currency = get_company_currency();
362 return $row[1] . ($row[2] == $company_currency ?
363 '' : (" - " . $row[2]));
366 function supplier_list($name, $selected_id=null, $spec_option=false, $submit_on_change=false,
367 $all=false, $editkey = false)
371 $sql = "SELECT supplier_id, supp_ref, curr_code, inactive FROM ".TB_PREF."suppliers ";
373 $mode = get_company_pref('no_supplier_list');
376 set_editor('supplier', $name, $editkey);
378 return combo_input($name, $selected_id, $sql, 'supplier_id', 'supp_name',
380 'format' => '_format_add_curr',
381 'order' => array('supp_ref'),
382 'search_box' => $mode!=0,
384 'spec_option' => $spec_option === true ? _("All Suppliers") : $spec_option,
385 'spec_id' => $all_items,
386 'select_submit'=> $submit_on_change,
388 'sel_hint' => $mode ? _('Press Space tab to filter by name fragment') :
389 _('Select supplier'),
390 'show_inactive'=>$all
394 function supplier_list_cells($label, $name, $selected_id=null, $all_option=false,
395 $submit_on_change=false, $all=false, $editkey = false)
398 echo "<td>$label</td><td>\n";
399 $str = supplier_list($name, $selected_id, $all_option, $submit_on_change,
405 function supplier_list_row($label, $name, $selected_id=null, $all_option = false,
406 $submit_on_change=false, $all=false, $editkey = false)
408 echo "<tr><td>$label</td><td>";
409 $str = supplier_list($name, $selected_id, $all_option, $submit_on_change,
414 //----------------------------------------------------------------------------------------------
416 function customer_list($name, $selected_id=null, $spec_option=false, $submit_on_change=false,
417 $show_inactive=false, $editkey = false)
421 $sql = "SELECT debtor_no, debtor_ref, curr_code, inactive FROM ".TB_PREF."debtors_master ";
423 $mode = get_company_pref('no_customer_list');
426 set_editor('customer', $name, $editkey);
428 return combo_input($name, $selected_id, $sql, 'debtor_no', 'name',
430 'format' => '_format_add_curr',
431 'order' => array('debtor_ref'),
432 'search_box' => $mode!=0,
435 'spec_option' => $spec_option === true ? _("All Customers") : $spec_option,
436 'spec_id' => $all_items,
437 'select_submit'=> $submit_on_change,
439 'sel_hint' => $mode ? _('Press Space tab to filter by name fragment; F2 - entry new customer') :
440 _('Select customer'),
441 'show_inactive' => $show_inactive
445 function customer_list_cells($label, $name, $selected_id=null, $all_option=false,
446 $submit_on_change=false, $show_inactive=false, $editkey = false)
449 echo "<td>$label</td>\n";
451 $str = customer_list($name, $selected_id, $all_option, $submit_on_change,
452 $show_inactive, $editkey);
457 function customer_list_row($label, $name, $selected_id=null, $all_option = false,
458 $submit_on_change=false, $show_inactive=false, $editkey = false)
460 echo "<tr><td>$label</td><td nowrap>";
461 $str = customer_list($name, $selected_id, $all_option, $submit_on_change,
462 $show_inactive, $editkey);
463 echo "</td>\n</tr>\n";
467 //------------------------------------------------------------------------------------------------
469 function customer_branches_list($customer_id, $name, $selected_id=null,
470 $spec_option = true, $enabled=true, $submit_on_change=false, $editkey = false)
474 $sql = "SELECT branch_code, branch_ref FROM ".TB_PREF."cust_branch
475 WHERE debtor_no='" . $customer_id . "' ";
478 set_editor('branch', $name, $editkey);
480 $where = $enabled ? array("disable_trans = 0") : array();
481 return combo_input($name, $selected_id, $sql, 'branch_code', 'br_name',
484 'order' => array('branch_ref'),
485 'spec_option' => $spec_option === true ? _('All branches') : $spec_option,
486 'spec_id' => $all_items,
487 'select_submit'=> $submit_on_change,
488 'sel_hint' => _('Select customer branch')
491 //------------------------------------------------------------------------------------------------
493 function customer_branches_list_cells($label,$customer_id, $name, $selected_id=null,
494 $all_option = true, $enabled=true, $submit_on_change=false, $editkey = false)
497 echo "<td>$label</td>\n";
499 $ret = customer_branches_list($customer_id, $name, $selected_id, $all_option, $enabled,
500 $submit_on_change, $editkey);
505 function customer_branches_list_row($label, $customer_id, $name, $selected_id=null,
506 $all_option = true, $enabled=true, $submit_on_change=false, $editkey = false)
509 $ret = customer_branches_list_cells($label, $customer_id, $name, $selected_id,
510 $all_option, $enabled, $submit_on_change, $editkey);
515 //------------------------------------------------------------------------------------------------
517 function locations_list($name, $selected_id=null, $all_option=false, $submit_on_change=false)
521 $sql = "SELECT loc_code, location_name, inactive FROM ".TB_PREF."locations";
523 return combo_input($name, $selected_id, $sql, 'loc_code', 'location_name',
525 'spec_option' => $all_option === true ? _("All Locations") : $all_option,
526 'spec_id' => $all_items,
527 'select_submit'=> $submit_on_change
531 function locations_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
534 echo "<td>$label</td>\n";
536 $str = locations_list($name, $selected_id, $all_option, $submit_on_change);
541 function locations_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
544 $str = locations_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
549 //-----------------------------------------------------------------------------------------------
551 function currencies_list($name, $selected_id=null, $submit_on_change=false)
553 $sql = "SELECT curr_abrev, currency, inactive FROM ".TB_PREF."currencies";
555 // default to the company currency
557 return combo_input($name, $selected_id, $sql, 'curr_abrev', 'currency',
559 'select_submit'=> $submit_on_change,
560 'default' => get_company_currency(),
565 function currencies_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
568 echo "<td>$label</td>\n";
570 $str = currencies_list($name, $selected_id, $submit_on_change);
575 function currencies_list_row($label, $name, $selected_id=null, $submit_on_change=false)
578 $str = currencies_list_cells($label, $name, $selected_id, $submit_on_change);
583 //---------------------------------------------------------------------------------------------------
585 function fiscalyears_list($name, $selected_id=null, $submit_on_change=false)
588 $sql = "SELECT * FROM ".TB_PREF."fiscal_year";
590 // default to the company current fiscal year
592 return combo_input($name, $selected_id, $sql, 'id', '',
595 'default' => get_company_pref('f_year'),
596 'format' => '_format_fiscalyears',
597 'select_submit'=> $submit_on_change,
602 function _format_fiscalyears($row)
604 return sql2date($row[1]) . " - " . sql2date($row[2])
605 . " " . ($row[3] ? _('Closed') : _('Active')) . "</option>\n";
608 function fiscalyears_list_cells($label, $name, $selected_id=null)
611 echo "<td>$label</td>\n";
613 $str = fiscalyears_list($name, $selected_id);
618 function fiscalyears_list_row($label, $name, $selected_id=null)
621 $str = fiscalyears_list_cells($label, $name, $selected_id);
625 //------------------------------------------------------------------------------------
627 function dimensions_list($name, $selected_id=null, $no_option=false, $showname=' ',
628 $submit_on_change=false, $showclosed=false, $showtype=1)
630 $sql = "SELECT id, CONCAT(reference,' ',name) as ref FROM ".TB_PREF."dimensions";
633 'order' => 'reference',
634 'spec_option'=>$no_option ? $showname : false,
636 'select_submit'=> $submit_on_change,
641 $options['where'][] = "closed=0";
643 $options['where'][] = "type_=$showtype";
645 return combo_input($name, $selected_id, $sql, 'id', 'ref', $options);
648 function dimensions_list_cells($label, $name, $selected_id=null, $no_option=false, $showname=null,
649 $showclosed=false, $showtype=0, $submit_on_change=false)
652 echo "<td>$label</td>\n";
654 $str = dimensions_list($name, $selected_id, $no_option, $showname, $submit_on_change, $showclosed, $showtype);
659 function dimensions_list_row($label, $name, $selected_id=null, $no_option=false, $showname=null,
660 $showclosed=false, $showtype=0, $submit_on_change=false)
663 $str = dimensions_list_cells($label, $name, $selected_id, $no_option, $showname,
664 $showclosed, $showtype, $submit_on_change);
669 //---------------------------------------------------------------------------------------------------
671 function stock_items_list($name, $selected_id=null, $all_option=false,
672 $submit_on_change=false, $opts=array(), $editkey = false)
676 $sql = "SELECT stock_id, s.description, c.description, s.inactive
677 FROM ".TB_PREF."stock_master s,".TB_PREF."stock_category c WHERE s.category_id=c.category_id";
680 set_editor('item', $name, $editkey);
682 return combo_input($name, $selected_id, $sql, 'stock_id', 's.description',
685 'format' => '_format_stock_items',
686 'spec_option' => $all_option===true ? _("All Items") : $all_option,
687 'spec_id' => $all_items,
688 'search_box' => true,
689 'search' => array("stock_id", "c.description","s.description"),
690 'search_submit' => get_company_pref('no_item_list')!=0,
692 'select_submit'=> $submit_on_change,
694 'order' => array('c.description','stock_id')
698 function _format_stock_items($row)
700 return (user_show_codes() ? ($row[0] . " - ") : "") . $row[1];
703 function stock_items_list_cells($label, $name, $selected_id=null, $all_option=false,
704 $submit_on_change=false, $all=false, $editkey = false)
707 echo "<td>$label</td>\n";
708 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
709 array('cells'=>true, 'show_inactive'=>$all), $editkey);
713 function stock_items_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
716 $str = stock_items_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
721 //---------------------------------------------------------------------------------------------------
723 // Select item via foreign code.
725 function sales_items_list($name, $selected_id=null, $all_option=false,
726 $submit_on_change=false, $type='', $opts=array())
730 $sql = "SELECT i.item_code, i.description, c.description, count(*)>1 as kit,
733 ".TB_PREF."stock_master s,
734 ".TB_PREF."item_codes i
736 ".TB_PREF."stock_category c
737 ON i.category_id=c.category_id
738 WHERE i.stock_id=s.stock_id";
741 if ($type == 'local') { // exclude foreign codes
742 $sql .= " AND !i.is_foreign";
743 } elseif ($type == 'kits') { // sales kits
744 $sql .= " AND !i.is_foreign AND i.item_code!=i.stock_id";
746 $sql .= " AND !i.inactive AND !s.inactive AND !s.no_sale";
747 $sql .= " GROUP BY i.item_code";
749 return combo_input($name, $selected_id, $sql, 'i.item_code', 'c.description',
752 'format' => '_format_stock_items',
753 'spec_option' => $all_option===true ? _("All Items") : $all_option,
754 'spec_id' => $all_items,
755 'search_box' => true,
756 'search' => array("i.item_code", "i.description"),
757 'search_submit' => get_company_pref('no_item_list')!=0,
759 'select_submit'=> $submit_on_change,
761 'order' => array('c.description','i.item_code')
765 function sales_items_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
768 echo "<td>$label</td>\n";
769 $str = sales_items_list($name, $selected_id, $all_option, $submit_on_change,
770 '', array('cells'=>true));
774 function sales_kits_list($name, $selected_id=null, $all_option=false, $submit_on_change=false)
776 $str = sales_items_list($name, $selected_id, $all_option, $submit_on_change,
777 'kits', array('cells'=>false));
781 function sales_local_items_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
785 echo "<td>$label</td>\n";
787 $str = sales_items_list($name, $selected_id, $all_option, $submit_on_change,
788 'local', array('cells'=>false));
792 //------------------------------------------------------------------------------------
794 function stock_manufactured_items_list($name, $selected_id=null,
795 $all_option=false, $submit_on_change=false)
797 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
798 array('where'=>array("mb_flag= 'M'")));
802 function stock_manufactured_items_list_cells($label, $name, $selected_id=null,
803 $all_option=false, $submit_on_change=false)
806 echo "<td>$label</td>\n";
808 $str = stock_manufactured_items_list($name, $selected_id, $all_option, $submit_on_change);
813 function stock_manufactured_items_list_row($label, $name, $selected_id=null,
814 $all_option=false, $submit_on_change=false)
817 $str = stock_manufactured_items_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
821 //------------------------------------------------------------------------------------
823 function stock_component_items_list($name, $parent_stock_id, $selected_id=null,
824 $all_option=false, $submit_on_change=false, $editkey = false)
826 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
827 array('where'=>array("stock_id != '$parent_stock_id'")), $editkey);
831 function stock_component_items_list_cells($label, $name, $parent_stock_id,
832 $selected_id=null, $all_option=false, $submit_on_change=false, $editkey = false)
835 echo "<td>$label</td>\n";
836 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
837 array('where'=>array("stock_id != '$parent_stock_id'"), 'cells'=>true),
841 //------------------------------------------------------------------------------------
843 function stock_costable_items_list($name, $selected_id=null,
844 $all_option=false, $submit_on_change=false)
846 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
847 array('where'=>array("mb_flag!='D'")));
851 function stock_costable_items_list_cells($label, $name, $selected_id=null,
852 $all_option=false, $submit_on_change=false)
855 echo "<td>$label</td>\n";
856 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
857 array('where'=>array("mb_flag!='D'"), 'cells'=>true));
861 //------------------------------------------------------------------------------------
862 function stock_purchasable_items_list($name, $selected_id=null,
863 $all_option=false, $submit_on_change=false, $all=false, $editkey=false)
865 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
866 array('where'=>array("mb_flag!= 'M'"),
867 'show_inactive'=>$all), $editkey);
871 function stock_purchasable_items_list_cells($label, $name, $selected_id=null,
872 $all_option=false, $submit_on_change=false, $editkey=false)
875 echo "<td>$label</td>\n";
876 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
877 array('where'=>array("mb_flag!= 'M'"),
878 'cells'=>true), $editkey);
882 function stock_purchasable_items_list_row($label, $name, $selected_id=null,
883 $all_option=false, $submit_on_change=false, $editkey=false)
886 $ret = stock_purchasable_items_list_cells($label, $name, $selected_id=null,
887 $all_option, $submit_on_change, $editkey);
892 //------------------------------------------------------------------------------------
894 function stock_item_types_list_row($label, $name, $selected_id=null, $enabled=true)
900 echo "<td>$label</td>\n";
903 array_selector($name, $selected_id, $stock_types,
905 'select_submit'=> true,
906 'disabled' => !$enabled) );
910 function stock_units_list_row($label, $name, $value=null, $enabled=true)
912 $result = get_all_item_units();
915 echo "<td>$label</td>\n";
918 while($unit = db_fetch($result))
919 $units[$unit['abbr']] = $unit['name'];
921 array_selector($name, $value, $units, array( 'disabled' => !$enabled) );
926 //------------------------------------------------------------------------------------
928 function tax_types_list($name, $selected_id=null, $none_option=false, $submit_on_change=false)
930 $sql = "SELECT id, CONCAT(name, ' (',rate,'%)') as name FROM ".TB_PREF."tax_types";
932 return combo_input($name, $selected_id, $sql, 'id', 'name',
934 'spec_option' => $none_option,
935 'spec_id' => ALL_NUMERIC,
936 'select_submit'=> $submit_on_change,
941 function tax_types_list_cells($label, $name, $selected_id=null, $none_option=false,
942 $submit_on_change=false)
945 echo "<td>$label</td>\n";
947 $str = tax_types_list($name, $selected_id, $none_option, $submit_on_change);
952 function tax_types_list_row($label, $name, $selected_id=null, $none_option=false,
953 $submit_on_change=false)
956 $str = tax_types_list_cells($label, $name, $selected_id, $none_option, $submit_on_change);
961 //------------------------------------------------------------------------------------
963 function tax_groups_list($name, $selected_id=null,
964 $none_option=false, $submit_on_change=false)
966 $sql = "SELECT id, name FROM ".TB_PREF."tax_groups";
968 return combo_input($name, $selected_id, $sql, 'id', 'name',
971 'spec_option' => $none_option,
972 'spec_id' => ALL_NUMERIC,
973 'select_submit'=> $submit_on_change,
978 function tax_groups_list_cells($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false)
981 echo "<td>$label</td>\n";
983 $str = tax_groups_list($name, $selected_id, $none_option, $submit_on_change);
988 function tax_groups_list_row($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false)
991 $str = tax_groups_list_cells($label, $name, $selected_id, $none_option, $submit_on_change);
996 //------------------------------------------------------------------------------------
998 function item_tax_types_list($name, $selected_id=null)
1000 $sql ="SELECT id, name FROM ".TB_PREF."item_tax_types";
1001 combo_input($name, $selected_id, $sql, 'id', 'name', array('order' => 'id') );
1004 function item_tax_types_list_cells($label, $name, $selected_id=null)
1007 echo "<td>$label</td>\n";
1009 item_tax_types_list($name, $selected_id);
1013 function item_tax_types_list_row($label, $name, $selected_id=null)
1016 item_tax_types_list_cells($label, $name, $selected_id);
1020 //------------------------------------------------------------------------------------
1022 function shippers_list($name, $selected_id=null)
1024 $sql = "SELECT shipper_id, shipper_name, inactive FROM ".TB_PREF."shippers";
1025 combo_input($name, $selected_id, $sql, 'shipper_id', 'shipper_name',
1026 array('order'=>array('shipper_name')));
1029 function shippers_list_cells($label, $name, $selected_id=null)
1032 echo "<td>$label</td>\n";
1034 shippers_list($name, $selected_id);
1038 function shippers_list_row($label, $name, $selected_id=null)
1041 shippers_list_cells($label, $name, $selected_id);
1045 //-------------------------------------------------------------------------------------
1047 function sales_persons_list($name, $selected_id=null)
1049 $sql = "SELECT salesman_code, salesman_name, inactive FROM ".TB_PREF."salesman";
1050 combo_input($name, $selected_id, $sql, 'salesman_code', 'salesman_name',
1051 array('order'=>array('salesman_name')));
1054 function sales_persons_list_cells($label, $name, $selected_id=null)
1057 echo "<td>$label</td>\n";
1059 sales_persons_list($name, $selected_id);
1063 function sales_persons_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1066 sales_persons_list_cells($label, $name, $selected_id, $submit_on_change=false);
1070 //------------------------------------------------------------------------------------
1072 function sales_areas_list($name, $selected_id=null)
1074 $sql = "SELECT area_code, description, inactive FROM ".TB_PREF."areas";
1075 combo_input($name, $selected_id, $sql, 'area_code', 'description', array());
1078 function sales_areas_list_cells($label, $name, $selected_id=null)
1081 echo "<td>$label</td>\n";
1083 sales_areas_list($name, $selected_id);
1087 function sales_areas_list_row($label, $name, $selected_id=null)
1090 sales_areas_list_cells($label, $name, $selected_id);
1094 //------------------------------------------------------------------------------------
1096 function sales_groups_list($name, $selected_id=null, $special_option=false)
1098 $sql = "SELECT id, description, inactive FROM ".TB_PREF."groups";
1099 combo_input($name, $selected_id, $sql, 'id', 'description', array(
1100 'spec_option' => $special_option===true ? ' ' : $special_option,
1101 'order' => 'description', 'spec_id' => 0,
1105 function sales_groups_list_cells($label, $name, $selected_id=null, $special_option=false)
1108 echo "<td>$label</td>\n";
1110 sales_groups_list($name, $selected_id, $special_option);
1114 function sales_groups_list_row($label, $name, $selected_id=null, $special_option=false)
1117 sales_groups_list_cells($label, $name, $selected_id, $special_option);
1121 //------------------------------------------------------------------------------------
1123 function _format_template_items($row)
1125 return ($row[0] . " - " . _("Amount") . " ".$row[1]);
1128 function templates_list($name, $selected_id=null, $special_option=false)
1130 $sql = "SELECT sorder.order_no, Sum(line.unit_price*line.quantity*(1-line.discount_percent)) AS OrderValue
1131 FROM ".TB_PREF."sales_orders as sorder, ".TB_PREF."sales_order_details as line
1132 WHERE sorder.order_no = line.order_no AND sorder.type = 1 GROUP BY line.order_no";
1133 combo_input($name, $selected_id, $sql, 'order_no', 'OrderValue', array(
1134 'format' => '_format_template_items',
1135 'spec_option' => $special_option===true ? ' ' : $special_option,
1136 'order' => 'order_no', 'spec_id' => 0,
1140 function templates_list_cells($label, $name, $selected_id=null, $special_option=false)
1143 echo "<td>$label</td>\n";
1145 templates_list($name, $selected_id, $special_option);
1149 function templates_list_row($label, $name, $selected_id=null, $special_option=false)
1152 templates_list_cells($label, $name, $selected_id, $special_option);
1156 //------------------------------------------------------------------------------------
1158 function workorders_list($name, $selected_id=null)
1160 $sql = "SELECT id, wo_ref FROM ".TB_PREF."workorders WHERE closed=0";
1161 combo_input($name, $selected_id, $sql, 'id', 'wo_ref', array());
1164 function workorders_list_cells($label, $name, $selected_id=null)
1167 echo "<td>$label</td>\n";
1169 workorders_list($name, $selected_id);
1173 function workorders_list_row($label, $name, $selected_id=null)
1176 workorders_list_cells($label, $name, $selected_id);
1180 //------------------------------------------------------------------------------------
1182 function payment_terms_list($name, $selected_id=null)
1184 $sql = "SELECT terms_indicator, terms, inactive FROM ".TB_PREF."payment_terms";
1185 combo_input($name, $selected_id, $sql, 'terms_indicator', 'terms', array());
1188 function payment_terms_list_cells($label, $name, $selected_id=null)
1191 echo "<td>$label</td>\n";
1193 payment_terms_list($name, $selected_id);
1197 function payment_terms_list_row($label, $name, $selected_id=null)
1200 payment_terms_list_cells($label, $name, $selected_id);
1204 //------------------------------------------------------------------------------------
1206 function credit_status_list($name, $selected_id=null)
1208 $sql ="SELECT id, reason_description, inactive FROM ".TB_PREF."credit_status";
1209 combo_input($name, $selected_id, $sql, 'id', 'reason_description', array());
1212 function credit_status_list_cells($label, $name, $selected_id=null)
1215 echo "<td>$label</td>\n";
1217 credit_status_list($name, $selected_id);
1221 function credit_status_list_row($label, $name, $selected_id=null)
1224 credit_status_list_cells($label, $name, $selected_id);
1228 //-----------------------------------------------------------------------------------------------
1230 function sales_types_list($name, $selected_id=null, $submit_on_change=false, $special_option=false)
1232 $sql = "SELECT id, sales_type, inactive FROM ".TB_PREF."sales_types";
1234 return combo_input($name, $selected_id, $sql, 'id', 'sales_type',
1236 'spec_option' => $special_option===true ? _("All Sales Types") : $special_option,
1238 'select_submit'=> $submit_on_change,
1239 // 'async' => false,
1243 function sales_types_list_cells($label, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1246 echo "<td>$label</td>\n";
1248 $str = sales_types_list($name, $selected_id, $submit_on_change, $special_option);
1253 function sales_types_list_row($label, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1256 $str = sales_types_list_cells($label, $name, $selected_id, $submit_on_change, $special_option);
1261 //-----------------------------------------------------------------------------------------------
1263 function movement_types_list($name, $selected_id=null)
1265 $sql = "SELECT id, name FROM ".TB_PREF."movement_types";
1266 combo_input($name, $selected_id, $sql, 'id', 'name', array());
1269 function movement_types_list_cells($label, $name, $selected_id=null)
1272 echo "<td>$label</td>\n";
1274 movement_types_list($name, $selected_id);
1278 function movement_types_list_row($label, $name, $selected_id=null)
1281 movement_types_list_cells($label, $name, $selected_id);
1285 //-----------------------------------------------------------------------------------------------
1286 function _format_date($row)
1288 return sql2date($row['reconciled']);
1291 function bank_reconciliation_list($account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1293 $sql = "SELECT reconciled, reconciled FROM ".TB_PREF."bank_trans
1294 WHERE bank_act=".db_escape($account)." AND reconciled IS NOT NULL
1295 GROUP BY reconciled";
1296 combo_input($name, $selected_id, $sql, 'id', 'reconciled',
1298 'spec_option' => $special_option,
1299 'format' => '_format_date',
1301 'select_submit'=> $submit_on_change
1305 function bank_reconciliation_list_cells($label,$account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1308 echo "<td>$label</td>\n";
1310 bank_reconciliation_list($account, $name, $selected_id, $submit_on_change, $special_option);
1314 function bank_reconciliation_list_row($label, $account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1317 bank_reconciliation_list_cells($label, $account, $name, $selected_id, $submit_on_change, $special_option);
1321 //-----------------------------------------------------------------------------------------------
1323 function workcenter_list($name, $selected_id=null, $all_option=false)
1327 $sql = "SELECT id, name, inactive FROM ".TB_PREF."workcentres";
1329 return combo_input($name, $selected_id, $sql, 'id', 'name',
1331 'spec_option' =>$all_option===true ? _("All Suppliers") : $all_option,
1332 'spec_id' => $all_items,
1336 function workcenter_list_cells($label, $name, $selected_id=null, $all_option=false)
1338 default_focus($name);
1340 echo "<td>$label</td>\n";
1342 workcenter_list($name, $selected_id, $all_option);
1346 function workcenter_list_row($label, $name, $selected_id=null, $all_option=false)
1349 workcenter_list_cells($label, $name, $selected_id, $all_option);
1353 //-----------------------------------------------------------------------------------------------
1355 function bank_accounts_list($name, $selected_id=null, $submit_on_change=false)
1357 $sql = "SELECT ".TB_PREF."bank_accounts.id, bank_account_name, bank_curr_code, inactive
1358 FROM ".TB_PREF."bank_accounts";
1359 // , ".TB_PREF."chart_master
1360 // WHERE ".TB_PREF."bank_accounts.account_code=".TB_PREF."chart_master.account_code";
1362 return combo_input($name, $selected_id, $sql, 'id', 'bank_account_name',
1364 'format' => '_format_add_curr',
1365 'select_submit'=> $submit_on_change,
1370 function bank_accounts_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1373 echo "<td>$label</td>\n";
1375 $str = bank_accounts_list($name, $selected_id, $submit_on_change);
1380 function bank_accounts_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1383 $str = bank_accounts_list_cells($label, $name, $selected_id, $submit_on_change);
1387 //-----------------------------------------------------------------------------------------------
1389 function cash_accounts_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1391 $sql = "SELECT ".TB_PREF."bank_accounts.id, bank_account_name, bank_curr_code, inactive
1392 FROM ".TB_PREF."bank_accounts
1393 WHERE ".TB_PREF."bank_accounts.account_type=3";
1396 echo "<tr><td>$label</td>\n";
1398 $str = combo_input($name, $selected_id, $sql, 'id', 'bank_account_name',
1400 'format' => '_format_add_curr',
1401 'select_submit'=> $submit_on_change,
1404 echo "</td></tr>\n";
1407 //-----------------------------------------------------------------------------------------------
1409 function pos_list_row($label, $name, $selected_id=null, $spec_option=false, $submit_on_change=false)
1411 $sql = "SELECT id, pos_name, inactive FROM ".TB_PREF."sales_pos";
1413 default_focus($name);
1416 echo "<td>$label</td>\n";
1419 $str = combo_input($name, $selected_id, $sql, 'id', 'pos_name',
1421 'select_submit'=> $submit_on_change,
1423 'spec_option' =>$spec_option,
1425 'order'=> array('pos_name')
1427 echo "</td></tr>\n";
1431 //-----------------------------------------------------------------------------------------------
1433 function sale_payment_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1436 echo "<td>$label</td>\n";
1438 $str = yesno_list($name, $selected_id, _('Cash'), _('Delayed'), $submit_on_change);
1442 //-----------------------------------------------------------------------------------------------
1444 function class_list($name, $selected_id=null, $submit_on_change=false)
1446 $sql = "SELECT cid, class_name FROM ".TB_PREF."chart_class";
1448 return combo_input($name, $selected_id, $sql, 'cid', 'class_name',
1450 'select_submit'=> $submit_on_change,
1456 function class_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1459 echo "<td>$label</td>\n";
1461 $str = class_list($name, $selected_id, $submit_on_change);
1466 function class_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1469 $str = class_list_cells($label, $name, $selected_id, $submit_on_change);
1474 //-----------------------------------------------------------------------------------------------
1476 function stock_categories_list($name, $selected_id=null, $submit_on_change=false)
1478 $sql = "SELECT category_id, description, inactive FROM ".TB_PREF."stock_category";
1479 combo_input($name, $selected_id, $sql, 'category_id', 'description',
1480 array('order'=>'category_id',
1481 'select_submit'=> $submit_on_change,
1486 function stock_categories_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1489 echo "<td>$label</td>\n";
1491 stock_categories_list($name, $selected_id, $submit_on_change);
1495 function stock_categories_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1498 stock_categories_list_cells($label, $name, $selected_id, $submit_on_change);
1502 //-----------------------------------------------------------------------------------------------
1504 function gl_account_types_list($name, $selected_id=null, $all_option, $all_option_numeric)
1508 $sql = "SELECT id, name FROM ".TB_PREF."chart_types";
1510 combo_input($name, $selected_id, $sql, 'id', 'name',
1513 'spec_option' =>$all_option,
1514 'spec_id' => $all_option_numeric ? 0 : $all_items
1518 function gl_account_types_list_cells($label, $name, $selected_id=null, $all_option=false,
1519 $all_option_numeric=false)
1522 echo "<td>$label</td>\n";
1524 gl_account_types_list($name, $selected_id, $all_option, $all_option_numeric);
1528 function gl_account_types_list_row($label, $name, $selected_id=null, $all_option=false,
1529 $all_option_numeric=false)
1532 gl_account_types_list_cells($label, $name, $selected_id, $all_option,
1533 $all_option_numeric);
1537 //-----------------------------------------------------------------------------------------------
1538 function gl_all_accounts_list($name, $selected_id=null, $skip_bank_accounts=false,
1539 $cells=false, $all_option=false, $submit_on_change=false, $all=false)
1541 if ($skip_bank_accounts)
1542 $sql = "SELECT chart.account_code, chart.account_name, type.name, chart.inactive, type.id
1543 FROM (".TB_PREF."chart_master chart,".TB_PREF."chart_types type) "
1544 ."LEFT JOIN ".TB_PREF."bank_accounts acc "
1545 ."ON chart.account_code=acc.account_code
1546 WHERE acc.account_code IS NULL
1547 AND chart.account_type=type.id";
1549 $sql = "SELECT chart.account_code, chart.account_name, type.name, chart.inactive, type.id
1550 FROM ".TB_PREF."chart_master chart,".TB_PREF."chart_types type
1551 WHERE chart.account_type=type.id";
1553 combo_input($name, $selected_id, $sql, 'chart.account_code', 'chart.account_name',
1555 'format' => '_format_account',
1556 'spec_option' => $all_option===true ? _("Use Item Sales Accounts") : $all_option,
1558 'order' => array('type.id','account_code'),
1559 'search_box' => $cells,
1560 'search_submit' => false,
1564 'select_submit'=> $submit_on_change,
1567 'show_inactive' => $all
1572 function _format_account($row)
1574 return $row[0] . " " . $row[1];
1577 function gl_all_accounts_list_cells($label, $name, $selected_id=null,
1578 $skip_bank_accounts=false, $cells=false, $all_option=false,
1579 $submit_on_change=false, $all=false)
1582 echo "<td>$label</td>\n";
1584 gl_all_accounts_list($name, $selected_id,
1585 $skip_bank_accounts, $cells, $all_option, $submit_on_change, $all);
1589 function gl_all_accounts_list_row($label, $name, $selected_id=null,
1590 $skip_bank_accounts=false, $cells=false, $all_option=false)
1593 gl_all_accounts_list_cells($label, $name, $selected_id,
1594 $skip_bank_accounts, $cells, $all_option);
1598 function yesno_list($name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1601 $items['0'] = strlen($name_no) ? $name_no : _("No");
1602 $items['1'] = strlen($name_yes) ? $name_yes : _("Yes");
1604 return array_selector($name, $selected_id, $items,
1606 'select_submit'=> $submit_on_change,
1607 'async' => false ) ); // FIX?
1610 function yesno_list_cells($label, $name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1613 echo "<td>$label</td>\n";
1615 $str = yesno_list($name, $selected_id, $name_yes, $name_no, $submit_on_change);
1620 function yesno_list_row($label, $name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1623 $str = yesno_list_cells($label, $name, $selected_id, $name_yes, $name_no, $submit_on_change);
1628 //------------------------------------------------------------------------------------------------
1630 function languages_list($name, $selected_id=null)
1632 global $installed_languages;
1635 foreach ($installed_languages as $lang)
1636 $items[$lang['code']] = $lang['name'];
1638 return array_selector($name, $selected_id, $items );
1641 function languages_list_cells($label, $name, $selected_id=null)
1644 echo "<td>$label</td>\n";
1646 languages_list($name, $selected_id);
1650 function languages_list_row($label, $name, $selected_id=null)
1653 languages_list_cells($label, $name, $selected_id);
1657 //------------------------------------------------------------------------------------------------
1659 function bank_account_types_list($name, $selected_id=null)
1661 global $bank_account_types;
1663 return array_selector($name, $selected_id, $bank_account_types);
1666 function bank_account_types_list_cells($label, $name, $selected_id=null)
1669 echo "<td>$label</td>\n";
1671 bank_account_types_list($name, $selected_id);
1675 function bank_account_types_list_row($label, $name, $selected_id=null)
1678 bank_account_types_list_cells($label, $name, $selected_id);
1682 //------------------------------------------------------------------------------------------------
1683 function payment_person_types_list($name, $selected_id=null, $submit_on_change=false)
1685 global $payment_person_types;
1688 foreach ($payment_person_types as $key=>$type)
1690 if ($key != PT_WORKORDER)
1691 $items[$key] = $type;
1693 return array_selector($name, $selected_id, $items,
1694 array( 'select_submit'=> $submit_on_change ) );
1697 function payment_person_types_list_cells($label, $name, $selected_id=null, $related=null)
1700 echo "<td>$label</td>\n";
1702 $str = payment_person_types_list($name, $selected_id, $related);
1707 function payment_person_types_list_row($label, $name, $selected_id=null, $related=null)
1710 $str = payment_person_types_list_cells($label, $name, $selected_id, $related);
1715 //------------------------------------------------------------------------------------------------
1717 function wo_types_list($name, $selected_id=null)
1719 global $wo_types_array;
1721 return array_selector($name, $selected_id, $wo_types_array,
1722 array( 'select_submit'=> true, 'async' => true ) );
1725 function wo_types_list_row($label, $name, $selected_id=null)
1727 echo "<tr><td>$label</td><td>\n";
1728 $str = wo_types_list($name, $selected_id);
1729 echo "</td></tr>\n";
1733 //------------------------------------------------------------------------------------------------
1735 function dateformats_list_row($label, $name, $value=null)
1737 global $dateformats;
1739 echo "<tr><td>$label</td>\n<td>";
1740 array_selector( $name, $value, $dateformats );
1741 echo "</td></tr>\n";
1744 function dateseps_list_row($label, $name, $value=null)
1748 echo "<tr><td>$label</td>\n<td>";
1749 array_selector( $name, $value, $dateseps );
1750 echo "</td></tr>\n";
1753 function thoseps_list_row($label, $name, $value=null)
1757 echo "<tr><td>$label</td>\n<td>";
1758 array_selector( $name, $value, $thoseps );
1759 echo "</td></tr>\n";
1762 function decseps_list_row($label, $name, $value=null)
1766 echo "<tr><td>$label</td>\n<td>";
1767 array_selector( $name, $value, $decseps );
1768 echo "</td></tr>\n";
1771 function themes_list_row($label, $name, $value=null)
1773 global $path_to_root;
1775 $path = $path_to_root.'/themes/';
1777 $themedir = opendir($path);
1778 while(false !== ($fname = readdir($themedir)))
1780 if($fname!='.' && $fname!='..' && $fname!='CVS' && is_dir($path.$fname))
1782 $themes[$fname] = $fname;
1787 echo "<tr><td>$label</td>\n<td>";
1788 array_selector( $name, $value, $themes );
1789 echo "</td></tr>\n";
1792 function pagesizes_list_row($label, $name, $value=null)
1797 foreach ($pagesizes as $pz)
1800 echo "<tr><td>$label</td>\n<td>";
1801 array_selector( $name, $value, $items );
1802 echo "</td></tr>\n";
1805 function systypes_list_cells($label, $name, $value=null, $submit_on_change=false)
1807 global $systypes_array;
1810 echo "<td>$label</td>\n";
1813 $str = array_selector($name, $value, $systypes_array,
1815 'select_submit'=> $submit_on_change,
1823 function journal_types_list_cells($label, $name, $value=null, $submit_on_change=false)
1825 global $systypes_array;
1828 echo "<td>$label</td>\n";
1831 $items = $systypes_array;
1833 // exclude quotes, orders and dimensions
1834 foreach (array(ST_PURCHORDER, ST_WORKORDER, ST_SALESORDER, ST_DIMENSION,
1835 ST_SALESQUOTE) as $excl)
1836 unset($items[$excl]);
1838 $str = array_selector($name, $value, $items,
1840 'spec_option'=> _("All"),
1842 'select_submit'=> $submit_on_change,
1850 function systypes_list_row($label, $name, $value=null, $submit_on_change=false)
1853 $str = systypes_list_cells($label, $name, $value, $submit_on_change);
1858 function cust_allocations_list_cells($label, $name, $selected=null)
1866 $all_items=>_("All Types"),
1867 '1'=> _("Sales Invoices"),
1868 '2'=> _("Overdue Invoices"),
1869 '3' => _("Payments"),
1870 '4' => _("Credit Notes"),
1871 '5' => _("Delivery Notes")
1873 $str = array_selector($name, $selected, $allocs);
1878 function supp_allocations_list_cell($name, $selected=null)
1884 $all_items=>_("All Types"),
1885 '1'=> _("Invoices"),
1886 '2'=> _("Overdue Invoices"),
1887 '3' => _("Payments"),
1888 '4' => _("Credit Notes"),
1889 '5' => _("Overdue Credit Notes")
1891 $str = array_selector($name, $selected, $allocs);
1896 function policy_list_cells($label, $name, $selected=null)
1901 $str = array_selector($name, $selected,
1902 array( '' => _("Automatically put balance on back order"),
1903 'CAN' => _("Cancel any quantites not delivered")) );
1908 function policy_list_row($label, $name, $selected=null)
1911 policy_list_cells($label, $name, $selected);
1915 function credit_type_list_cells($label, $name, $selected=null, $submit_on_change=false)
1920 $str = array_selector($name, $selected,
1921 array( 'Return' => _("Items Returned to Inventory Location"),
1922 'WriteOff' => _("Items Written Off")),
1923 array( 'select_submit'=> $submit_on_change ) );
1928 function credit_type_list_row($label, $name, $selected=null, $submit_on_change=false)
1931 $str = credit_type_list_cells($label, $name, $selected, $submit_on_change);
1936 function number_list($name, $selected, $from, $to, $no_option=false)
1939 for ($i = $from; $i <= $to; $i++)
1942 return array_selector($name, $selected, $items,
1943 array( 'spec_option' => $no_option,
1944 'spec_id' => ALL_NUMERIC) );
1947 function number_list_cells($label, $name, $selected, $from, $to, $no_option=false)
1952 number_list($name, $selected, $from, $to, $no_option);
1956 function number_list_row($label, $name, $selected, $from, $to, $no_option=false)
1959 number_list_cells($label, $name, $selected, $from, $to, $no_option);
1963 function print_profiles_list_row($label, $name, $selected_id=null, $spec_opt=false,
1964 $submit_on_change=true)
1966 $sql = "SELECT profile FROM ".TB_PREF."print_profiles"
1967 ." GROUP BY profile";
1968 $result = db_query($sql, 'cannot get all profile names');
1969 $profiles = array();
1970 while($myrow=db_fetch($result)) {
1971 $profiles[$myrow['profile']] = $myrow['profile'];
1976 echo "<td>$label</td>\n";
1979 array_selector($name, $selected_id, $profiles,
1980 array( 'select_submit'=> $submit_on_change,
1981 'spec_option'=>$spec_opt,
1985 echo "</td></tr>\n";
1988 function printers_list($name, $selected_id=null, $spec_opt=false, $submit_on_change=false)
1990 static $printers; // query only once for page display
1993 $sql = "SELECT id, name, description FROM ".TB_PREF."printers";
1994 $result = db_query($sql, 'cannot get all printers');
1995 $printers = array();
1996 while($myrow=db_fetch($result)) {
1997 $printers[$myrow['id']] = $myrow['name'].' - '.$myrow['description'];
2000 array_selector($name, $selected_id, $printers,
2001 array( 'select_submit'=> $submit_on_change,
2002 'spec_option'=>$spec_opt,
2007 //------------------------------------------------------------------------------------------------
2009 function quick_entries_list($name, $selected_id=null, $type=null, $submit_on_change=false)
2012 $sql = "SELECT id, description FROM ".TB_PREF."quick_entries";
2014 $sql .= " WHERE type=$type";
2016 combo_input($name, $selected_id, $sql, 'id', 'description',
2019 'order' => 'description',
2020 'select_submit'=> $submit_on_change,
2026 function quick_entries_list_cells($label, $name, $selected_id=null, $type, $submit_on_change=false)
2028 echo "<td>$label</td><td>\n";
2029 quick_entries_list($name, $selected_id, $type, $submit_on_change);
2033 function quick_entries_list_row($label, $name, $selected_id=null, $type, $submit_on_change=false)
2036 quick_entries_list_cells($label, $name, $selected_id, $type, $submit_on_change);
2041 function quick_actions_list_row($label, $name, $selected_id=null, $submit_on_change=false)
2043 global $quick_actions;
2045 echo "<tr><td>$label</td><td>";
2046 array_selector($name, $selected_id, $quick_actions,
2048 'select_submit'=> $submit_on_change
2050 echo "</td></tr>\n";
2053 function quick_entry_types_list_row($label, $name, $selected_id=null, $submit_on_change=false)
2055 global $quick_entry_types;
2057 echo "<tr><td>$label</td><td>";
2058 array_selector($name, $selected_id, $quick_entry_types,
2060 'select_submit'=> $submit_on_change
2062 echo "</td></tr>\n";
2065 function record_status_list_row($label, $name) {
2066 return yesno_list_row($label, $name, null, _('Inactive'), _('Active'));
2069 function class_types_list_row($label, $name, $selected_id=null, $submit_on_change=false)
2071 global $class_types;
2073 echo "<tr><td>$label</td><td>";
2074 array_selector($name, $selected_id, $class_types,
2076 'select_submit'=> $submit_on_change
2078 echo "</td></tr>\n";
2081 //------------------------------------------------------------------------------------------------
2083 function security_roles_list($name, $selected_id=null, $new_item=false, $submit_on_change=false,
2084 $show_inactive = false)
2088 $sql = "SELECT id, role, inactive FROM ".TB_PREF."security_roles";
2090 return combo_input($name, $selected_id, $sql, 'id', 'description',
2092 'spec_option'=>$new_item ? _("New role") : false,
2094 'select_submit'=> $submit_on_change,
2095 'show_inactive' => $show_inactive
2099 function security_roles_list_cells($label, $name, $selected_id=null, $new_item=false, $submit_on_change=false,
2100 $show_inactive = false)
2103 echo "<td>$label</td>\n";
2105 $str = security_roles_list($name, $selected_id, $new_item, $submit_on_change, $show_inactive);
2110 function security_roles_list_row($label, $name, $selected_id=null, $new_item=false, $submit_on_change=false,
2111 $show_inactive = false)
2114 $str = security_roles_list_cells($label, $name, $selected_id, $new_item, $submit_on_change, $show_inactive);
2119 function tab_list_row($label, $name, $selected_id=null)
2123 echo "<td>$label</td><td>\n";
2127 array_selector($name, $selected_id, $tabs);
2129 echo "</td></tr>\n";
2132 //---------------------------------------------------------------------------------------------
2133 // List of sets of active extensions
2135 function extset_list($name, $value=null, $submit_on_change=false)
2137 global $db_connections;
2140 foreach ($db_connections as $comp)
2141 $items[] = sprintf(_("Activated for '%s'"), $comp['name']);
2142 array_selector( $name, $value, $items,
2144 'spec_option'=> _("Installed on system"),
2146 'select_submit'=> $submit_on_change,