a44a115eafd7826f325196f52e583b82542d9692
[fa-stable.git] / includes / ui / ui_lists.inc
1 <?php
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");
16
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")."'> ";
19
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")."'> ";
22
23 $all_items = reserved_words::get_all();
24
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.
29
30 function combo_input($name, $selected_id, $sql, $valfield, $namefield,
31         $options=null)
32 {
33 global $Ajax;
34
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
47         'sel_hint' => null,
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
56         'max' => 50,
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
60         'disabled' => false,
61         'box_hint' => null, // box/selectors hints; null = std see below
62         'category' => false     // category column name or false
63 );
64 // ------ merge options with defaults ----------
65         if($options != null)
66                 $opts = array_merge($opts, $options);
67         if (!is_array($opts['where']))  $opts['where'] = array($opts['where']);
68
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']===true ? '_'.$name.'_update' : $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" : '';
77
78         if(!count($opts['search'])) {
79                 $opts['search'] = array($by_id ? $valfield : $namefield);
80         }
81         if ($opts['sel_hint'] === null) 
82                 $opts['sel_hint'] = $by_id || $search_box==false ?
83                         '' : _('Press Space tab for search pattern entry');
84
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')) :'';
89
90         if ($selected_id == null) {
91                 $selected_id = get_post($name, $opts['default']);
92         }
93         $txt = get_post($search_box);
94         $rel = '';
95         $limit = '';
96
97         if (isset($_POST[$select_submit])) {
98                 if ($by_id) $txt = $_POST[$name];
99
100                 if (!$opts['async'])
101                         $Ajax->activate('_page_body');
102                 else
103                         $Ajax->activate($name);
104         }
105         if ($search_box) {
106                 // search related sql modifications
107
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
112                 if (!$opts['async'])
113                         $Ajax->activate('_page_body');
114                 else
115                         $Ajax->activate($name);
116         }
117         if ($txt == '') {
118                 if ($spec_option === false && $selected_id==null)
119                   $limit = ' LIMIT 1';
120                 else
121                   $opts['where'][] = $valfield . "='". get_post($name, $spec_id)."'";
122         }
123         else
124                 if ($txt != '*') {
125
126                 foreach($opts['search'] as $i=> $s)
127                         $opts['search'][$i] = $s . " LIKE '%{$txt}%'";
128                 $opts['where'][] = '('. implode($opts['search'], ' OR ') . ')';
129                 }
130         }
131    }
132         // sql completion
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');
137                 if ($group_pos) {
138                         $group = substr($sql, $group_pos);
139                         $sql = substr($sql, 0, $group_pos) . $where.' '.$group;
140                 } else {
141                         $sql .= $where;
142                 }
143         }
144         if ($opts['order'] != false) {
145                 if (!is_array($opts['order']))
146                         $opts['order'] = array($opts['order']);
147                 $sql .= ' ORDER BY '.implode(',',$opts['order']);
148         }
149
150         $sql .= $limit;
151         // ------ make selector ----------
152         $selector = $first_opt = '';
153         $first_id = false;
154         $found = false;
155         $lastcat = null;
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);
162                         $sel = '';
163                         if (get_post($search_submit) && ($txt === $value)) {
164                                 $selected_id = $value;
165                         }
166                         if      ((string)($selected_id) === $value) {
167                                 $sel = 'selected';
168                                 $found = $value;
169                         }
170                         if ($first_id === false) {
171                                 $first_id = $value;
172                                 $first_opt = $descr;
173                         }
174                         $cat = $contact_row[$opts['category']];
175                         if ($opts['category'] !== false && $cat != $lastcat){
176                                 $selector .= "<optgroup label='".$cat."'>\n";
177                                 $lastcat = $cat;
178                         }
179                         $selector .= "<option $sel value='$value'>$descr</option>\n";
180                 }
181                 db_free_result($result);
182         }
183
184         // Prepend special option.
185         if ($spec_option !== false) { // if special option used - add it
186                 $first_id = $spec_id;
187                 $first_opt = $spec_option;
188                 $sel = $found===false ? 'selected' : '';
189                 $selector = "<option $sel value='$spec_id'>$spec_option</option>\n"
190                         . $selector;
191         }
192
193         if ($found === false) {
194                 $selected_id = $first_id;
195         }
196         $_POST[$name] = $selected_id;
197
198         if ($by_id && $search_box != false) {
199                 $txt = $found;
200                 $Ajax->addUpdate($name, $search_box, $txt ? $txt : '');
201         }
202         $aspect = $opts['edit_submit'] ? " aspect='editable'" : '';
203         $selector = "<select $disabled name='$name' class='$class' title='"
204                 . $opts['sel_hint']."'$aspect $rel>".$selector."</select>\n";
205
206         $Ajax->addUpdate($name, "_{$name}_sel", $selector);
207
208         // because of bug which M$ cannot fix since IE 5.0
209         // we must embed whole selector in span tags to enable proper ajax update
210         $selector = "<span id='_{$name}_sel'>".$selector."</span>\n";
211
212         if ($select_submit != false) { // if submit on change is used - add select button
213                 global $_select_button;
214         // button class selects form reload/ajax selector update
215                 $selector .= sprintf($_select_button, $disabled, user_theme(),
216                         (fallback_mode() ? '' : 'display:none;'),
217                         $select_submit)."\n";
218         }
219 // ------ make combo ----------
220
221         $edit_entry = '';
222         if ($search_box != false) {
223                 $edit_entry = "<input $disabled type='text' name='$search_box' id='$search_box' size='".
224                         $opts['size']."' maxlength='".$opts['max'].
225                         "' value='$txt' class='$class' rel='$name' autocomplete='off' title='"
226                         .$opts['box_hint']."'"
227                         .(!fallback_mode() && !$by_id ? " style=display:none;":'')
228                         .">\n";
229                 if ($search_submit != false) {
230                         global $_search_button;
231                         $edit_entry .= sprintf($_search_button, $disabled, user_theme(),
232                                 (fallback_mode() ? '' : 'display:none;'),
233                                 $search_submit)."\n";
234                 }
235         }
236         default_focus($name);
237         $str = $selector;
238         if ($search_box && $opts['cells'])
239                 echo ($edit_entry!='' ? "<td>$edit_entry</td>" : '')."<td>$selector</td>";
240         else
241                 echo $edit_entry.$selector;
242
243         return $str;
244 }
245
246 /*
247         Helper function.
248         Returns true if selector $name is subject to update.
249 */
250 function list_updated($name)
251 {
252         return isset($_POST['_'.$name.'_update']) || isset($_POST['_'.$name.'_button']);
253 }
254 //----------------------------------------------------------------------------------------------
255 //      Universal array combo generator
256 //      $items is array of options 'value' => 'description'
257 //      Options is reduced set of combo_selector options and is merged with defaults.
258
259 function array_selector($name, $selected_id, $items, $options=null)
260 {
261         global $Ajax;
262
263 $opts = array(          // default options
264         'spec_option'=>false,   // option text or false
265         'spec_id' => 0,         // option id
266         'select_submit' => false, //submit on select: true/false
267         'edit_submit' => false, // call editor on F4
268         'async' => true,        // select update via ajax (true) vs _page_body reload
269         'default' => '', // default value when $_POST is not set
270                 // search box parameters
271         'sel_hint' => null,
272         'disabled' => false
273 );
274 // ------ merge options with defaults ----------
275         if($options != null)
276                 $opts = array_merge($opts, $options);
277         $select_submit =  $opts['select_submit']===true ? '_'.$name.'_update' : $opts['select_submit'];
278         $spec_id = $opts['spec_id'];
279         $spec_option = $opts['spec_option'];
280         $disabled = $opts['disabled'] ? "disabled" : '';
281
282         if ($selected_id == null) {
283                 $selected_id = get_post($name, $opts['default']);
284         }
285
286         if (isset($_POST[$select_submit])) {
287                 if (!$opts['async'])
288                         $Ajax->activate('_page_body');
289                 else
290                         $Ajax->activate($name);
291         }
292
293         // ------ make selector ----------
294         $selector = $first_opt = '';
295         $first_id = false;
296         $found = false;
297 //if($name=='SelectStockFromList') display_error($sql);
298                 foreach($items as $value=>$descr) {
299                         $sel = '';
300                         if ($selected_id == $value) {
301                                 $sel = 'selected';
302                                 $found = $value;
303                         }
304                         if ($first_id === false) {
305                                 $first_id = $value;
306                                 $first_opt = $descr;
307                         }
308                         $selector .= "<option $sel value='$value'>$descr</option>\n";
309                 }
310
311         // Prepend special option.
312         if ($spec_option !== false) { // if special option used - add it
313                 $first_id = $spec_id;
314                 $first_opt = $spec_option;
315                 $sel = $found===false ? 'selected' : '';
316                 $selector = "<option $sel value='$spec_id'>$spec_option</option>\n"
317                         . $selector;
318         }
319
320         if ($found === false) {
321                 $_POST[$name] = $first_id;
322         }
323
324         $aspect = $opts['edit_submit'] ? " aspect='editable'" : '';
325         $selector = "<select $disabled name='$name' class='combo' title='"
326                 . $opts['sel_hint']."'$aspect >".$selector."</select>\n";
327
328         $Ajax->addUpdate($name, "_{$name}_sel", $selector);
329
330         $selector = "<span id='_{$name}_sel'>".$selector."</span>\n";
331
332         if ($select_submit != false) { // if submit on change is used - add select button
333                 global $_select_button;
334                 $selector .= sprintf($_select_button, $disabled, user_theme(),
335                         (fallback_mode() ? '' : 'display:none;'),
336                         $select_submit)."\n";
337         }
338         default_focus($name);
339         echo $selector;
340
341         return $selector;
342 }
343 //----------------------------------------------------------------------------------------------
344
345 function _format_add_curr($row)
346 {
347         static $company_currency;
348
349         if ($company_currency == null)
350         {
351                 $company_currency = get_company_currency();
352         }
353         return $row[1] . ($row[2] == $company_currency ?
354                 '' : ("&nbsp;-&nbsp;" . $row[2]));
355 }
356
357 function supplier_list($name, $selected_id=null, $spec_option=false, $submit_on_change=false)
358 {
359         global $all_items;
360
361         $sql = "SELECT supplier_id, supp_name, curr_code FROM ".TB_PREF."suppliers ";
362
363         $mode = get_company_pref('no_supplier_list');
364
365         return combo_input($name, $selected_id, $sql, 'supplier_id', 'supp_name',
366         array(
367                 'format' => '_format_add_curr',
368                 'search_box' => $mode!=0,
369                 'edit_submit' => true, 
370                 'type' => 1,
371                 'spec_option' => $spec_option === true ? _("All Suppliers") : $spec_option,
372                 'spec_id' => $all_items,
373                 'select_submit'=> $submit_on_change,
374                 'async' => false,
375                 'sel_hint' => $mode ? _('Press Space tab to filter by name fragment') :
376                 _('Select supplier')
377                 ));
378 }
379
380 function supplier_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
381 {
382         if ($label != null)
383                 echo "<td>$label</td><td>\n";
384         $str = supplier_list($name, $selected_id, $all_option, $submit_on_change);
385                 echo "</td>\n";
386         return $str;
387 }
388
389 function supplier_list_row($label, $name, $selected_id=null, $all_option = false, $submit_on_change=false)
390 {
391 echo "<tr><td>$label</td><td>";
392         $str = supplier_list($name, $selected_id, $all_option, $submit_on_change );
393 echo "</td></tr>\n";
394 return $str;
395 }
396 //----------------------------------------------------------------------------------------------
397
398 function customer_list($name, $selected_id=null, $spec_option=false, $submit_on_change=false)
399 {
400         global $all_items;
401
402         $sql = "SELECT debtor_no, name, curr_code FROM ".TB_PREF."debtors_master ";
403
404         $mode = get_company_pref('no_customer_list');
405
406 return combo_input($name, $selected_id, $sql, 'debtor_no', 'name',
407         array(
408             'format' => '_format_add_curr',
409                 'search_box' => $mode!=0,
410                 'type' => 1,
411                 'size' => 20,
412                 'spec_option' => $spec_option === true ? _("All Customers") : $spec_option,
413                 'spec_id' => $all_items,
414                 'select_submit'=> $submit_on_change,
415                 'edit_submit' => true, // call editor on F4
416                 'async' => false,
417                 'sel_hint' => $mode ? _('Press Space tab to filter by name fragment; F4 - entry new customer') :
418                 _('Select customer')
419         ) );
420 }
421
422 function customer_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
423 {
424         if ($label != null)
425                 echo "<td>$label</td>\n";
426         echo "<td nowrap>";
427         $str = customer_list($name, $selected_id, $all_option, $submit_on_change);
428         echo "</td>\n";
429         return $str;
430 }
431
432 function customer_list_row($label, $name, $selected_id=null, $all_option = false, $submit_on_change=false)
433 {
434         echo "<tr><td>$label</td><td nowrap>";
435         $str = customer_list($name, $selected_id, $all_option, $submit_on_change);
436         echo "</td>\n</tr>\n";
437         return $str;
438 }
439
440 //------------------------------------------------------------------------------------------------
441
442 function customer_branches_list($customer_id, $name, $selected_id=null,
443         $spec_option = true, $enabled=true, $submit_on_change=false)
444 {
445         global $all_items;
446
447         $sql = "SELECT branch_code, br_name FROM ".TB_PREF."cust_branch
448                 WHERE debtor_no='" . $customer_id . "' ";
449
450         $where = $enabled ? array("disable_trans = 0") : array();
451 return  combo_input($name, $selected_id, $sql, 'branch_code', 'br_name',
452         array(
453                 'where' => $where,
454                 'spec_option' => $spec_option === true ? _('All branches') : $spec_option,
455                 'spec_id' => $all_items,
456                 'select_submit'=> $submit_on_change,
457                 'sel_hint' => _('Select customer branch')
458         ) );
459 }
460 //------------------------------------------------------------------------------------------------
461
462 function customer_branches_list_cells($label,$customer_id, $name, $selected_id=null, $all_option = true, $enabled=true, $submit_on_change=false)
463 {
464         if ($label != null)
465                 echo "<td>$label</td>\n";
466         echo "<td>";
467         $ret = customer_branches_list($customer_id, $name, $selected_id, $all_option, $enabled, $submit_on_change);
468         echo "</td>\n";
469         return $ret;
470 }
471
472 function customer_branches_list_row($label,$customer_id, $name, $selected_id=null, $all_option = true, $enabled=true, $submit_on_change=false)
473 {
474         echo "<tr>";
475         $ret = customer_branches_list_cells($label, $customer_id, $name, $selected_id, $all_option, $enabled, $submit_on_change);
476         echo "</tr>";
477         return $ret;
478 }
479
480 //------------------------------------------------------------------------------------------------
481
482 function locations_list($name, $selected_id=null, $all_option=false, $submit_on_change=false)
483 {
484         global $all_items;
485
486         $sql = "SELECT loc_code, location_name FROM ".TB_PREF."locations";
487
488 return combo_input($name, $selected_id, $sql, 'loc_code', 'location_name',
489         array(
490                 'spec_option' => $all_option === true ? _("All Locations") : $all_option,
491                 'spec_id' => $all_items,
492                 'select_submit'=> $submit_on_change
493         ) );
494 }
495
496 function locations_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
497 {
498         if ($label != null)
499                 echo "<td>$label</td>\n";
500         echo "<td>";
501         $str = locations_list($name, $selected_id, $all_option, $submit_on_change);
502         echo "</td>\n";
503         return $str;
504 }
505
506 function locations_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
507 {
508         echo "<tr>";
509         $str = locations_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
510         echo "</tr>\n";
511         return $str;
512 }
513
514 //-----------------------------------------------------------------------------------------------
515
516 function currencies_list($name, $selected_id=null, $submit_on_change=false)
517 {
518         $sql = "SELECT curr_abrev, currency FROM ".TB_PREF."currencies";
519
520 // default to the company currency
521
522 return combo_input($name, $selected_id, $sql, 'curr_abrev', 'currency',
523         array(
524                 'select_submit'=> $submit_on_change,
525                 'default' => get_company_currency(),
526                 'async' => false                
527         ) );
528 }
529
530 function currencies_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
531 {
532         if ($label != null)
533                 echo "<td>$label</td>\n";
534         echo "<td>";
535         $str = currencies_list($name, $selected_id, $submit_on_change);
536         echo "</td>\n";
537         return $str;
538 }
539
540 function currencies_list_row($label, $name, $selected_id=null, $submit_on_change=false)
541 {
542         echo "<tr>\n";
543         $str = currencies_list_cells($label, $name, $selected_id, $submit_on_change);
544         echo "</tr>\n";
545         return $str;
546 }
547
548 //---------------------------------------------------------------------------------------------------
549
550 function fiscalyears_list($name, $selected_id=null, $submit_on_change=false)
551 {
552
553         $sql = "SELECT * FROM ".TB_PREF."fiscal_year";
554
555 // default to the company current fiscal year
556
557 return combo_input($name, $selected_id, $sql, 'id', '',
558         array(
559                 'order' => 'begin',
560                 'default' => get_company_pref('f_year'),
561                 'format' => '_format_fiscalyears',
562                 'select_submit'=> $submit_on_change,
563                 'async' => false
564         ) );
565 }
566
567 function _format_fiscalyears($row)
568 {
569         return sql2date($row[1]) . "&nbsp;-&nbsp;" . sql2date($row[2])
570         . "&nbsp;&nbsp;" . ($row[3] ? _('Closed') : _('Active')) . "</option>\n";
571 }
572
573 function fiscalyears_list_cells($label, $name, $selected_id=null)
574 {
575         if ($label != null)
576                 echo "<td>$label</td>\n";
577         echo "<td>";
578         $str = fiscalyears_list($name, $selected_id);
579         echo "</td>\n";
580         return $str;
581 }
582
583 function fiscalyears_list_row($label, $name, $selected_id=null)
584 {
585         echo "<tr>\n";
586         $str = fiscalyears_list_cells($label, $name, $selected_id);
587         echo "</tr>\n";
588         return $str;
589 }
590 //------------------------------------------------------------------------------------
591
592 function dimensions_list($name, $selected_id=null, $no_option=false, $showname=' ',
593         $submit_on_change=false, $showclosed=false, $showtype=1)
594 {
595 $sql = "SELECT id, CONCAT(reference,'  ',name) as ref FROM ".TB_PREF."dimensions";
596
597 $options = array(
598         'order' => 'reference',
599         'spec_option'=>$no_option ? $showname : false,
600         'spec_id' => 0,
601         'select_submit'=> $submit_on_change,
602         'async' => false,
603         );
604
605         if ($showclosed)
606                 $options['where'][] = "closed=0";
607         if($showtype)
608                 $options['where'][] = "type_=$showtype";
609
610         return combo_input($name, $selected_id, $sql, 'id', 'ref', $options);
611 }
612
613 function dimensions_list_cells($label, $name, $selected_id=null, $no_option=false, $showname=null,
614         $showclosed=false, $showtype=0, $submit_on_change=false)
615 {
616         if ($label != null)
617                 echo "<td>$label</td>\n";
618         echo "<td>";
619         $str = dimensions_list($name, $selected_id, $no_option, $showname, $submit_on_change, $showclosed, $showtype);
620         echo "</td>\n";
621         return $str;
622 }
623
624 function dimensions_list_row($label, $name, $selected_id=null, $no_option=false, $showname=null,
625         $showclosed=false, $showtype=0, $submit_on_change=false)
626 {
627         echo "<tr>\n";
628         $str = dimensions_list_cells($label, $name, $selected_id, $no_option, $showname,
629                 $showclosed, $showtype, $submit_on_change);
630         echo "</tr>\n";
631         return $str;
632 }
633
634 //---------------------------------------------------------------------------------------------------
635
636 function stock_items_list($name, $selected_id=null, $all_option=false, $submit_on_change=false, $opts=array())
637 {
638         global $all_items;
639
640         $sql = "SELECT stock_id, s.description, c.description
641                         FROM ".TB_PREF."stock_master s,".TB_PREF."stock_category c WHERE s.category_id=c.category_id";
642
643         return combo_input($name, $selected_id, $sql, 'stock_id', 's.description',
644         array_merge(
645           array(
646                 'format' => '_format_stock_items',
647                 'spec_option' => $all_option===true ?  _("All Items") : $all_option,
648                 'spec_id' => $all_items,
649                 'search_box' => true,
650                 'search' => array("stock_id", "c.description","s.description"),
651                 'search_submit' => get_company_pref('no_item_list')!=0,
652                 'size'=>10,
653                 'select_submit'=> $submit_on_change,
654                 'category' => 2,
655                 'order' => array('c.description','stock_id')
656           ), $opts) );
657 }
658
659 function _format_stock_items($row)
660 {
661         return (user_show_codes() ?  ($row[0] . "&nbsp;-&nbsp;") : "") . $row[1];
662 }
663
664 function stock_items_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
665 {
666         if ($label != null)
667                 echo "<td>$label</td>\n";
668         $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
669                 array('cells'=>true));
670         return $str;
671 }
672 /*
673 function stock_items_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
674 {
675         echo "<tr>\n";
676         $str = stock_items_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
677         echo "</tr>\n";
678         return $str;
679 }
680 */
681 //---------------------------------------------------------------------------------------------------
682 //
683 // Select item via foreign code.
684 //
685 function sales_items_list($name, $selected_id=null, $all_option=false, 
686         $submit_on_change=false, $type='', $opts=array())
687 {
688         global $all_items;
689         // all sales codes
690         $sql = "SELECT i.item_code, i.description, c.description, count(*)>1 as kit
691                         FROM
692                         ".TB_PREF."item_codes i
693                         LEFT JOIN
694                         ".TB_PREF."stock_category c
695                         ON i.category_id=c.category_id";
696
697         if ($type == 'local')   { // exclude foreign codes
698                 $sql .= " WHERE !i.is_foreign"; 
699         } elseif ($type == 'kits') { // sales kits
700                 $sql .= " WHERE !i.is_foreign AND i.item_code!=i.stock_id";
701         }
702                                 
703         $sql .= " GROUP BY i.item_code";
704
705         return combo_input($name, $selected_id, $sql, 'i.item_code', 'c.description',
706         array_merge(
707           array(
708                 'format' => '_format_stock_items',
709                 'spec_option' => $all_option===true ?  _("All Items") : $all_option,
710                 'spec_id' => $all_items,
711                 'search_box' => true,
712                 'search' => array("i.item_code", "c.description"),
713                 'search_submit' => get_company_pref('no_item_list')!=0,
714                 'size'=>15,
715                 'select_submit'=> $submit_on_change,
716                 'category' => 2,
717                 'order' => array('c.description','i.item_code')
718           ), $opts) );
719 }
720
721 function sales_items_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
722 {
723         if ($label != null)
724                 echo "<td>$label</td>\n";
725         $str = sales_items_list($name, $selected_id, $all_option, $submit_on_change,
726                 '', array('cells'=>true));
727         return $str;
728 }
729
730 function sales_kits_list($name, $selected_id=null, $all_option=false, $submit_on_change=false)
731 {
732         $str = sales_items_list($name, $selected_id, $all_option, $submit_on_change,
733                 'kits', array('cells'=>false));
734         return $str;
735 }
736
737 function sales_local_items_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
738 {
739         echo "<tr>";
740         if ($label != null)
741                 echo "<td>$label</td>\n";
742         echo "<td>";
743         $str = sales_items_list($name, $selected_id, $all_option, $submit_on_change,
744                 'local', array('cells'=>false));
745         echo "</td></tr>";
746         return $str;
747 }
748 //------------------------------------------------------------------------------------
749
750 function base_stock_items_list($where, $name, $selected_id=null,
751         $all_option=false, $submit_on_change=false)
752 {
753         global $all_items;
754
755         $sql = "SELECT stock_id, s.description, c.description
756                 FROM ".TB_PREF."stock_master s,".TB_PREF."stock_category c WHERE
757                 s.category_id=c.category_id";
758
759         return combo_input($name, $selected_id, $sql, 'stock_id', 's.description',
760         array(
761                 'format' => '_format_stock_items',
762                 'spec_option' => $all_option==true ?  _("All Items") : $all_option,
763                 'spec_id' => $all_items,
764                 'select_submit'=> $submit_on_change,
765                 'where' => $where,
766                 'category' => 2 ) );
767 }
768 //------------------------------------------------------------------------------------
769
770 function stock_bom_items_list($name, $selected_id=null, $all_option=false, $submit_on_change=false)
771 {
772
773         return base_stock_items_list("(s.mb_flag='M' OR s.mb_flag='K')",
774                 $name, $selected_id, $all_option, $submit_on_change);
775 }
776 /*
777 function stock_bom_items_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
778 {
779         if ($label != null)
780                 echo "<td>$label</td>\n";
781         echo "<td>";
782         $str = stock_bom_items_list($name, $selected_id, $all_option, $submit_on_change);
783         echo "</td>\n";
784         return $str;
785 }
786
787 function stock_bom_items_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
788 {
789         echo "<tr>\n";
790         $str = stock_bom_items_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
791         echo "</tr>\n";
792         return $str;
793 }
794 */
795 //------------------------------------------------------------------------------------
796
797 function stock_manufactured_items_list($name, $selected_id=null,
798         $all_option=false, $submit_on_change=false)
799 {
800         return base_stock_items_list("s.mb_flag='M'",
801                 $name, $selected_id, $all_option, $submit_on_change);
802 }
803
804 function stock_manufactured_items_list_cells($label, $name, $selected_id=null,
805                                 $all_option=false, $submit_on_change=false)
806 {
807         if ($label != null)
808                 echo "<td>$label</td>\n";
809         echo "<td>";
810         $str = stock_manufactured_items_list($name, $selected_id, $all_option,
811                                 $submit_on_change);
812         echo "</td>\n";
813         return $str;
814 }
815
816 function stock_manufactured_items_list_row($label, $name, $selected_id=null,
817                 $all_option=false, $submit_on_change=false)
818 {
819         echo "<tr>\n";
820         $str = stock_manufactured_items_list_cells($label, $name, $selected_id,
821                         $all_option, $submit_on_change);
822         echo "</tr>\n";
823         return $str;
824 }
825 //------------------------------------------------------------------------------------
826
827 function stock_component_items_list($name, $parent_stock_id, $selected_id=null,
828         $all_option=false, $submit_on_change=false)
829 {
830         $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
831                 array('where'=>array("stock_id != '$parent_stock_id'")));
832         return $str;
833 }
834
835 function stock_component_items_list_cells($label, $name, $parent_stock_id, 
836         $selected_id=null, $all_option=false, $submit_on_change=false)
837 {
838         if ($label != null)
839                 echo "<td>$label</td>\n";
840         $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
841                 array('where'=>array("stock_id != '$parent_stock_id'"), 'cells'=>true));
842         return $str;
843 }
844 //------------------------------------------------------------------------------------
845
846 function stock_costable_items_list($name, $selected_id=null,
847         $all_option=false, $submit_on_change=false)
848 {
849         $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
850                 array('where'=>array("mb_flag!='D'")));
851         return $str;
852 }
853
854 function stock_costable_items_list_cells($label, $name, $selected_id=null, 
855         $all_option=false, $submit_on_change=false)
856 {
857         if ($label != null)
858                 echo "<td>$label</td>\n";
859         $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
860                 array('where'=>array("mb_flag!='D'"), 'cells'=>true));
861         return $str;
862 }
863
864 //------------------------------------------------------------------------------------
865 function stock_purchasable_items_list($name, $selected_id=null, 
866         $all_option=false, $submit_on_change=false)
867 {
868         $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
869                 array('where'=>array("mb_flag!= 'M'"), 
870                         'edit_submit' => true));
871         return $str;
872 }
873
874 function stock_purchasable_items_list_cells($label, $name, $selected_id=null,
875                         $all_option=false, $submit_on_change=false)
876 {
877         if ($label != null)
878                 echo "<td>$label</td>\n";
879         $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
880                 array('where'=>array("mb_flag!= 'M'"), 
881                          'edit_submit' => true,
882                          'cells'=>true));
883         return $str;
884 }
885
886 function stock_purchasable_items_list_row($label, $name, $selected_id=null,
887                         $all_option=false, $submit_on_change=false)
888 {
889         echo "<tr>\n";
890         $ret = stock_purchasable_items_list_cells($label, $name, $selected_id=null,
891                 $all_option, $submit_on_change);
892         echo "</tr>\n";
893         return $ret;
894 }
895
896 //------------------------------------------------------------------------------------
897
898 function stock_item_types_list_row($label, $name, $selected_id=null, $enabled=true)
899 {
900         global $stock_types;
901
902         echo "<tr>";
903         if ($label != null)
904                 echo "<td>$label</td>\n";
905         echo "<td>";
906
907         array_selector($name, $selected_id, $stock_types, 
908                 array( 
909                         'select_submit'=> true, 
910                         'disabled' => !$enabled) );
911         echo "</td></tr>\n";
912 }
913
914 function stock_units_list_row($label, $name, $value=null, $enabled=true)
915 {
916         $result = get_all_item_units();
917         echo "<tr>";
918         if ($label != null)
919                 echo "<td>$label</td>\n";
920         echo "<td>";
921
922         while($unit = db_fetch($result))
923                 $units[$unit['abbr']] = $unit['name'];
924
925         array_selector($name, $value, $units, 
926                 array( 
927                         'select_submit'=> true, 
928                         'disabled' => !$enabled) );
929
930         echo "</td></tr>\n";
931 }
932
933 //------------------------------------------------------------------------------------
934
935 function tax_types_list($name, $selected_id=null, $none_option=false, $submit_on_change=false)
936 {
937         $sql = "SELECT id, CONCAT(name, ' (',rate,'%)') as name FROM ".TB_PREF."tax_types";
938
939         return combo_input($name, $selected_id, $sql, 'id', 'name',
940         array(
941                 'spec_option' => $none_option,
942                 'spec_id' => reserved_words::get_all_numeric(),
943                 'select_submit'=> $submit_on_change,
944                 'async' => false,
945         ) );
946 }
947
948 function tax_types_list_cells($label, $name, $selected_id=null, $none_option=false,
949         $submit_on_change=false)
950 {
951         if ($label != null)
952                 echo "<td>$label</td>\n";
953         echo "<td>";
954         $str = tax_types_list($name, $selected_id, $none_option, $submit_on_change);
955         echo "</td>\n";
956         return $str;
957 }
958
959 function tax_types_list_row($label, $name, $selected_id=null, $none_option=false,
960         $submit_on_change=false)
961 {
962         echo "<tr>\n";
963         $str = tax_types_list_cells($label, $name, $selected_id, $none_option, $submit_on_change);
964         echo "</tr>\n";
965         return $str;
966 }
967
968 //------------------------------------------------------------------------------------
969
970 function tax_groups_list($name, $selected_id=null,
971         $none_option=false, $submit_on_change=false)
972 {
973         $sql = "SELECT id, name FROM ".TB_PREF."tax_groups";
974
975         return combo_input($name, $selected_id, $sql, 'id', 'name',
976         array(
977                 'order' => 'id',
978                 'spec_option' => $none_option,
979                 'spec_id' => reserved_words::get_all_numeric(),
980                 'select_submit'=> $submit_on_change,
981                 'async' => false,
982         ) );
983 }
984
985 function tax_groups_list_cells($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false)
986 {
987         if ($label != null)
988                 echo "<td>$label</td>\n";
989         echo "<td>";
990         $str = tax_groups_list($name, $selected_id, $none_option, $submit_on_change);
991         echo "</td>\n";
992         return $str;
993 }
994
995 function tax_groups_list_row($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false)
996 {
997         echo "<tr>\n";
998         $str = tax_groups_list_cells($label, $name, $selected_id, $none_option, $submit_on_change);
999         echo "</tr>\n";
1000         return $str;
1001 }
1002
1003 //------------------------------------------------------------------------------------
1004
1005 function item_tax_types_list($name, $selected_id=null)
1006 {
1007         $sql ="SELECT id, name FROM ".TB_PREF."item_tax_types";
1008         combo_input($name, $selected_id, $sql, 'id', 'name', array('order' => 'id') );
1009 }
1010
1011 function item_tax_types_list_cells($label, $name, $selected_id=null)
1012 {
1013         if ($label != null)
1014                 echo "<td>$label</td>\n";
1015         echo "<td>";
1016         item_tax_types_list($name, $selected_id);
1017         echo "</td>\n";
1018 }
1019
1020 function item_tax_types_list_row($label, $name, $selected_id=null)
1021 {
1022         echo "<tr>\n";
1023         item_tax_types_list_cells($label, $name, $selected_id);
1024         echo "</tr>\n";
1025 }
1026
1027 //------------------------------------------------------------------------------------
1028
1029 function shippers_list($name, $selected_id=null)
1030 {
1031         $sql = "SELECT shipper_id, shipper_name FROM ".TB_PREF."shippers";
1032         combo_input($name, $selected_id, $sql, 'shipper_id', 'shipper_name', array());
1033 }
1034
1035 function shippers_list_cells($label, $name, $selected_id=null)
1036 {
1037         if ($label != null)
1038                 echo "<td>$label</td>\n";
1039         echo "<td>";
1040         shippers_list($name, $selected_id);
1041         echo "</td>\n";
1042 }
1043
1044 function shippers_list_row($label, $name, $selected_id=null)
1045 {
1046         echo "<tr>\n";
1047         shippers_list_cells($label, $name, $selected_id);
1048         echo "</tr>\n";
1049 }
1050
1051 //-------------------------------------------------------------------------------------
1052
1053 function sales_persons_list($name, $selected_id=null)
1054 {
1055         $sql = "SELECT salesman_code, salesman_name FROM ".TB_PREF."salesman";
1056         combo_input($name, $selected_id, $sql, 'salesman_code', 'salesman_name', array());
1057 }
1058
1059 function sales_persons_list_cells($label, $name, $selected_id=null)
1060 {
1061         if ($label != null)
1062                 echo "<td>$label</td>\n";
1063         echo "<td>\n";
1064         sales_persons_list($name, $selected_id);
1065         echo "</td>\n";
1066 }
1067
1068 function sales_persons_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1069 {
1070         echo "<tr>\n";
1071         sales_persons_list_cells($label, $name, $selected_id, $submit_on_change=false);
1072         echo "</tr>\n";
1073 }
1074
1075 //------------------------------------------------------------------------------------
1076
1077 function sales_areas_list($name, $selected_id=null)
1078 {
1079         $sql = "SELECT area_code, description FROM ".TB_PREF."areas";
1080         combo_input($name, $selected_id, $sql, 'area_code', 'description', array());
1081 }
1082
1083 function sales_areas_list_cells($label, $name, $selected_id=null)
1084 {
1085         if ($label != null)
1086                 echo "<td>$label</td>\n";
1087         echo "<td>";
1088         sales_areas_list($name, $selected_id);
1089         echo "</td>\n";
1090 }
1091
1092 function sales_areas_list_row($label, $name, $selected_id=null)
1093 {
1094         echo "<tr>\n";
1095         sales_areas_list_cells($label, $name, $selected_id);
1096         echo "</tr>\n";
1097 }
1098
1099 //------------------------------------------------------------------------------------
1100
1101 function sales_groups_list($name, $selected_id=null, $special_option=false)
1102 {
1103         $sql = "SELECT id, description FROM ".TB_PREF."groups";
1104         combo_input($name, $selected_id, $sql, 'id', 'description', array(
1105                 'spec_option' => $special_option===true ? ' ' : $special_option,
1106                 'order' => 'description', 'spec_id' => 0,
1107         ));
1108 }
1109
1110 function sales_groups_list_cells($label, $name, $selected_id=null, $special_option=false)
1111 {
1112         if ($label != null)
1113                 echo "<td>$label</td>\n";
1114         echo "<td>";
1115         sales_groups_list($name, $selected_id, $special_option);
1116         echo "</td>\n";
1117 }
1118
1119 function sales_groups_list_row($label, $name, $selected_id=null, $special_option=false)
1120 {
1121         echo "<tr>\n";
1122         sales_groups_list_cells($label, $name, $selected_id, $special_option);
1123         echo "</tr>\n";
1124 }
1125
1126 //------------------------------------------------------------------------------------
1127
1128 function _format_template_items($row)
1129 {
1130         return ($row[0] . "&nbsp;- &nbsp;" . _("Amount") . "&nbsp;".$row[1]);
1131 }
1132
1133 function templates_list($name, $selected_id=null, $special_option=false)
1134 {
1135         $sql = "SELECT sorder.order_no, Sum(line.unit_price*line.quantity*(1-line.discount_percent)) AS OrderValue
1136                 FROM ".TB_PREF."sales_orders as sorder, ".TB_PREF."sales_order_details as line
1137                 WHERE sorder.order_no = line.order_no AND sorder.type = 1 GROUP BY line.order_no";
1138         combo_input($name, $selected_id, $sql, 'order_no', 'OrderValue', array(
1139                 'format' => '_format_template_items',
1140                 'spec_option' => $special_option===true ? ' ' : $special_option,
1141                 'order' => 'order_no', 'spec_id' => 0,
1142         ));
1143 }
1144
1145 function templates_list_cells($label, $name, $selected_id=null, $special_option=false)
1146 {
1147         if ($label != null)
1148                 echo "<td>$label</td>\n";
1149         echo "<td>";
1150         templates_list($name, $selected_id, $special_option);
1151         echo "</td>\n";
1152 }
1153
1154 function templates_list_row($label, $name, $selected_id=null, $special_option=false)
1155 {
1156         echo "<tr>\n";
1157         templates_list_cells($label, $name, $selected_id, $special_option);
1158         echo "</tr>\n";
1159 }
1160
1161 //------------------------------------------------------------------------------------
1162
1163 function workorders_list($name, $selected_id=null)
1164 {
1165         $sql = "SELECT id, wo_ref FROM ".TB_PREF."workorders WHERE closed=0";
1166         combo_input($name, $selected_id, $sql, 'id', 'wo_ref', array());
1167 }
1168
1169 function workorders_list_cells($label, $name, $selected_id=null)
1170 {
1171         if ($label != null)
1172                 echo "<td>$label</td>\n";
1173         echo "<td>";
1174         workorders_list($name, $selected_id);
1175         echo "</td>\n";
1176 }
1177
1178 function workorders_list_row($label, $name, $selected_id=null)
1179 {
1180         echo "<tr>\n";
1181         workorders_list_cells($label, $name, $selected_id);
1182         echo "</tr>\n";
1183 }
1184
1185 //------------------------------------------------------------------------------------
1186
1187 function payment_terms_list($name, $selected_id=null)
1188 {
1189         $sql = "SELECT terms_indicator, terms FROM ".TB_PREF."payment_terms";
1190         combo_input($name, $selected_id, $sql, 'terms_indicator', 'terms', array());
1191 }
1192
1193 function payment_terms_list_cells($label, $name, $selected_id=null)
1194 {
1195         if ($label != null)
1196                 echo "<td>$label</td>\n";
1197         echo "<td>";
1198         payment_terms_list($name, $selected_id);
1199         echo "</td>\n";
1200 }
1201
1202 function payment_terms_list_row($label, $name, $selected_id=null)
1203 {
1204         echo "<tr>\n";
1205         payment_terms_list_cells($label, $name, $selected_id);
1206         echo "</tr>\n";
1207 }
1208
1209 //------------------------------------------------------------------------------------
1210
1211 function credit_status_list($name, $selected_id=null)
1212 {
1213         $sql ="SELECT id, reason_description FROM ".TB_PREF."credit_status";
1214         combo_input($name, $selected_id, $sql, 'id', 'reason_description', array());
1215 }
1216
1217 function credit_status_list_cells($label, $name, $selected_id=null)
1218 {
1219         if ($label != null)
1220                 echo "<td>$label</td>\n";
1221         echo "<td>";
1222         credit_status_list($name, $selected_id);
1223         echo "</td>\n";
1224 }
1225
1226 function credit_status_list_row($label, $name, $selected_id=null)
1227 {
1228         echo "<tr>\n";
1229         credit_status_list_cells($label, $name, $selected_id);
1230         echo "</tr>\n";
1231 }
1232
1233 //-----------------------------------------------------------------------------------------------
1234
1235 function sales_types_list($name, $selected_id=null, $submit_on_change=false, $special_option=false)
1236 {
1237         $sql = "SELECT id, sales_type FROM ".TB_PREF."sales_types";
1238
1239         return combo_input($name, $selected_id, $sql, 'id', 'sales_type',
1240         array(
1241                 'spec_option' => $special_option===true ? _("All Sales Types") : $special_option,
1242                 'spec_id' => 0,
1243                 'select_submit'=> $submit_on_change,
1244         //        'async' => false,
1245         ) );
1246 }
1247
1248 function sales_types_list_cells($label, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1249 {
1250         if ($label != null)
1251                 echo "<td>$label</td>\n";
1252         echo "<td>";
1253         $str = sales_types_list($name, $selected_id, $submit_on_change, $special_option);
1254         echo "</td>\n";
1255         return $str;
1256 }
1257
1258 function sales_types_list_row($label, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1259 {
1260         echo "<tr>\n";
1261         $str = sales_types_list_cells($label, $name, $selected_id, $submit_on_change, $special_option);
1262         echo "</tr>\n";
1263         return $str;
1264 }
1265
1266 //-----------------------------------------------------------------------------------------------
1267
1268 function movement_types_list($name, $selected_id=null)
1269 {
1270         $sql = "SELECT id, name FROM ".TB_PREF."movement_types";
1271         combo_input($name, $selected_id, $sql, 'id', 'name', array());
1272 }
1273
1274 function movement_types_list_cells($label, $name, $selected_id=null)
1275 {
1276         if ($label != null)
1277                 echo "<td>$label</td>\n";
1278         echo "<td>";
1279         movement_types_list($name, $selected_id);
1280         echo "</td>\n";
1281 }
1282
1283 function movement_types_list_row($label, $name, $selected_id=null)
1284 {
1285         echo "<tr>\n";
1286         movement_types_list_cells($label, $name, $selected_id);
1287         echo "</tr>\n";
1288 }
1289
1290 //-----------------------------------------------------------------------------------------------
1291 function _format_date($row)
1292 {
1293         return sql2date($row['reconciled']);
1294 }
1295
1296 function bank_reconciliation_list($account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1297 {
1298         $sql = "SELECT reconciled, reconciled FROM ".TB_PREF."bank_trans
1299                 WHERE bank_act=".db_escape($account)." AND reconciled IS NOT NULL
1300                 GROUP BY reconciled";
1301         combo_input($name, $selected_id, $sql, 'id', 'reconciled',
1302         array(
1303                 'spec_option' => $special_option,
1304                 'format' => '_format_date',
1305                 'spec_id' => '',
1306                 'select_submit'=> $submit_on_change
1307         ) );
1308 }
1309
1310 function bank_reconciliation_list_cells($label,$account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1311 {
1312         if ($label != null)
1313                 echo "<td>$label</td>\n";
1314         echo "<td>";
1315         bank_reconciliation_list($account, $name, $selected_id, $submit_on_change, $special_option);
1316         echo "</td>\n";
1317 }
1318 /*
1319 function bank_reconciliation_list_row($label, $account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1320 {
1321         echo "<tr>\n";
1322         bank_reconciliation_list_cells($label, $account, $name, $selected_id, $submit_on_change, $special_option);
1323         echo "</tr>\n";
1324 }
1325 */
1326 //-----------------------------------------------------------------------------------------------
1327
1328 function workcenter_list($name, $selected_id=null, $all_option=false)
1329 {
1330         global $all_items;
1331
1332         $sql = "SELECT id, name FROM ".TB_PREF."workcentres";
1333
1334         return combo_input($name, $selected_id, $sql, 'id', 'name',
1335         array(
1336                 'spec_option' =>$all_option===true ? _("All Suppliers") : $all_option,
1337                 'spec_id' => $all_items,
1338         ) );
1339 }
1340
1341 function workcenter_list_cells($label, $name, $selected_id=null, $all_option=false)
1342 {
1343         default_focus($name);
1344         if ($label != null)
1345                 echo "<td>$label</td>\n";
1346         echo "<td>";
1347         workcenter_list($name, $selected_id, $all_option);
1348         echo "</td>\n";
1349 }
1350
1351 function workcenter_list_row($label, $name, $selected_id=null, $all_option=false)
1352 {
1353         echo "<tr>\n";
1354         workcenter_list_cells($label, $name, $selected_id, $all_option);
1355         echo "</tr>\n";
1356 }
1357
1358 //-----------------------------------------------------------------------------------------------
1359
1360 function bank_accounts_list($name, $selected_id=null, $submit_on_change=false)
1361 {
1362         $sql = "SELECT ".TB_PREF."bank_accounts.id, bank_account_name, bank_curr_code
1363                 FROM ".TB_PREF."bank_accounts";
1364 //              , ".TB_PREF."chart_master
1365 //              WHERE ".TB_PREF."bank_accounts.account_code=".TB_PREF."chart_master.account_code";
1366
1367         return combo_input($name, $selected_id, $sql, 'id', 'bank_account_name',
1368         array(
1369                 'format' => '_format_add_curr',
1370                 'select_submit'=> $submit_on_change,
1371                 'async' => false
1372         ) );
1373 }
1374
1375 function bank_accounts_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1376 {
1377         if ($label != null)
1378                 echo "<td>$label</td>\n";
1379         echo "<td>";
1380         $str = bank_accounts_list($name, $selected_id, $submit_on_change);
1381         echo "</td>\n";
1382         return $str;
1383 }
1384
1385 function bank_accounts_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1386 {
1387         echo "<tr>\n";
1388         $str = bank_accounts_list_cells($label, $name, $selected_id, $submit_on_change);
1389         echo "</tr>\n";
1390         return $str;
1391 }
1392 //-----------------------------------------------------------------------------------------------
1393
1394 function cash_accounts_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1395 {
1396         $sql = "SELECT ".TB_PREF."bank_accounts.id, bank_account_name, bank_curr_code
1397                 FROM ".TB_PREF."bank_accounts
1398                 WHERE ".TB_PREF."bank_accounts.account_type=3";
1399
1400         if ($label != null)
1401                 echo "<tr><td>$label</td>\n";
1402         echo "<td>";
1403         $str = combo_input($name, $selected_id, $sql, 'id', 'bank_account_name',
1404         array(
1405                 'format' => '_format_add_curr',
1406                 'select_submit'=> $submit_on_change,
1407                 'async' => true
1408         ) );
1409         echo "</td></tr>\n";
1410         return $str;
1411 }
1412 //-----------------------------------------------------------------------------------------------
1413
1414 function pos_list_row($label, $name, $selected_id=null, $spec_option=false, $submit_on_change=false)
1415 {
1416         $sql = "SELECT id, pos_name FROM ".TB_PREF."sales_pos";
1417
1418         default_focus($name);
1419         echo '<tr>';
1420         if ($label != null)
1421                 echo "<td>$label</td>\n";
1422         echo "<td>";
1423
1424         $str = combo_input($name, $selected_id, $sql, 'id', 'pos_name',
1425         array(
1426                 'select_submit'=> $submit_on_change,
1427                 'async' => true,
1428                 'spec_option' =>$spec_option,
1429                 'spec_id' => -1,
1430         ) );
1431         echo "</td></tr>\n";
1432
1433         return $str;    
1434 }
1435 //-----------------------------------------------------------------------------------------------
1436
1437 function sale_payment_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1438 {
1439         if ($label != null)
1440                 echo "<td>$label</td>\n";
1441         echo "<td>";
1442         $str = yesno_list($name, $selected_id, _('Cash'), _('Delayed'), $submit_on_change);
1443         echo "</td>\n";
1444         return $str;
1445 }
1446 //-----------------------------------------------------------------------------------------------
1447
1448 function class_list($name, $selected_id=null, $submit_on_change=false)
1449 {
1450         $sql = "SELECT cid, class_name FROM ".TB_PREF."chart_class";
1451
1452         return combo_input($name, $selected_id, $sql, 'cid', 'class_name',
1453         array(
1454                 'select_submit'=> $submit_on_change,
1455                 'async' => false
1456         ) );
1457
1458 }
1459
1460 function class_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1461 {
1462         if ($label != null)
1463                 echo "<td>$label</td>\n";
1464         echo "<td>";
1465         $str = class_list($name, $selected_id, $submit_on_change);
1466         echo "</td>\n";
1467         return $str;
1468 }
1469
1470 function class_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1471 {
1472         echo "<tr>\n";
1473         $str = class_list_cells($label, $name, $selected_id, $submit_on_change);
1474         echo "</tr>\n";
1475         return $str;
1476 }
1477
1478 //-----------------------------------------------------------------------------------------------
1479
1480 function stock_categories_list($name, $selected_id=null, $submit_on_change=false)
1481 {
1482         $sql = "SELECT category_id, description FROM ".TB_PREF."stock_category";
1483         combo_input($name, $selected_id, $sql, 'category_id', 'description',
1484         array('order'=>'category_id',
1485                 'select_submit'=> $submit_on_change,
1486                 'async' => true
1487         ));
1488 }
1489
1490 function stock_categories_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1491 {
1492         if ($label != null)
1493                 echo "<td>$label</td>\n";
1494         echo "<td>";
1495         stock_categories_list($name, $selected_id, $submit_on_change);
1496         echo "</td>\n";
1497 }
1498
1499 function stock_categories_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1500 {
1501         echo "<tr>\n";
1502         stock_categories_list_cells($label, $name, $selected_id, $submit_on_change);
1503         echo "</tr>\n";
1504 }
1505
1506 //-----------------------------------------------------------------------------------------------
1507
1508 function gl_account_types_list($name, $selected_id=null, $all_option, $all_option_numeric)
1509 {
1510         global $all_items;
1511
1512         $sql = "SELECT id, name FROM ".TB_PREF."chart_types";
1513
1514         combo_input($name, $selected_id, $sql, 'id', 'name',
1515         array(
1516                 'order' => 'id',
1517                 'spec_option' =>$all_option,
1518                 'spec_id' => $all_option_numeric ? 0 : $all_items
1519         ) );
1520 }
1521
1522 function gl_account_types_list_cells($label, $name, $selected_id=null, $all_option=false,
1523         $all_option_numeric=false)
1524 {
1525         if ($label != null)
1526                 echo "<td>$label</td>\n";
1527         echo "<td>";
1528         gl_account_types_list($name, $selected_id, $all_option, $all_option_numeric);
1529         echo "</td>\n";
1530 }
1531
1532 function gl_account_types_list_row($label, $name, $selected_id=null, $all_option=false,
1533         $all_option_numeric=false)
1534 {
1535         echo "<tr>\n";
1536         gl_account_types_list_cells($label, $name, $selected_id, $all_option,
1537                 $all_option_numeric);
1538         echo "</tr>\n";
1539 }
1540
1541 //-----------------------------------------------------------------------------------------------
1542 function gl_all_accounts_list($name, $selected_id=null, $skip_bank_accounts=false,
1543         $cells=false, $all_option=false, $submit_on_change=false)
1544 {
1545         if ($skip_bank_accounts)
1546                 $sql = "SELECT chart.account_code, chart.account_name, type.name
1547                         FROM (".TB_PREF."chart_master chart,".TB_PREF."chart_types type) "
1548                         ."LEFT JOIN ".TB_PREF."bank_accounts acc "
1549                         ."ON chart.account_code=acc.account_code
1550                                 WHERE acc.account_code  IS NULL
1551                         AND chart.account_type=type.id";
1552         else
1553                 $sql = "SELECT chart.account_code, chart.account_name, type.name
1554                         FROM ".TB_PREF."chart_master chart,".TB_PREF."chart_types type
1555                         WHERE chart.account_type=type.id";
1556
1557         combo_input($name, $selected_id, $sql, 'chart.account_code', 'chart.account_name',
1558         array(
1559                 'format' => '_format_account',
1560                 'spec_option' => $all_option===true ?  _("Use Item Sales Accounts") : $all_option,
1561                 'spec_id' => '',
1562                 'order' => array('name','account_code'),
1563                 'search_box' => $cells,
1564                         'search_submit' => false,
1565                         'size' => 12,
1566                         'max' => 10,
1567                         'cells' => true,
1568                 'select_submit'=> $submit_on_change,
1569                 'async' => false,
1570                 'category' => 2
1571         ) );
1572
1573 }
1574
1575 function _format_account($row)
1576 {
1577                 return $row[0] .  "&nbsp;&nbsp;&nbsp;&nbsp;" . $row[1];
1578 }
1579
1580 function gl_all_accounts_list_cells($label, $name, $selected_id=null, 
1581         $skip_bank_accounts=false, $cells=false, $all_option=false)
1582 {
1583         if ($label != null)
1584                 echo "<td>$label</td>\n";
1585         echo "<td>";
1586         gl_all_accounts_list($name, $selected_id, 
1587                 $skip_bank_accounts, $cells, $all_option);
1588         echo "</td>\n";
1589 }
1590
1591 function gl_all_accounts_list_row($label, $name, $selected_id=null, 
1592         $skip_bank_accounts=false, $cells=false, $all_option=false)
1593 {
1594         echo "<tr>\n";
1595         gl_all_accounts_list_cells($label, $name, $selected_id, 
1596                 $skip_bank_accounts, $cells, $all_option);
1597         echo "</tr>\n";
1598 }
1599
1600 function yesno_list($name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1601 {
1602         $items = array();
1603         $items['1'] = strlen($name_yes) ? $name_yes : _("Yes");
1604         $items['0'] = strlen($name_no) ? $name_no : _("No");
1605
1606         return array_selector($name, $selected_id, $items, 
1607                 array( 
1608                         'select_submit'=> $submit_on_change,
1609                         'async' => false ) ); // FIX?
1610 }
1611
1612 function yesno_list_cells($label, $name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1613 {
1614         if ($label != null)
1615                 echo "<td>$label</td>\n";
1616         echo "<td>";
1617         $str = yesno_list($name, $selected_id, $name_yes, $name_no, $submit_on_change);
1618         echo "</td>\n";
1619         return $str;
1620 }
1621
1622 function yesno_list_row($label, $name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1623 {
1624         echo "<tr>\n";
1625         $str = yesno_list_cells($label, $name, $selected_id, $name_yes, $name_no, $submit_on_change);
1626         echo "</tr>\n";
1627         return $str;
1628 }
1629
1630 //------------------------------------------------------------------------------------------------
1631
1632 function languages_list($name, $selected_id=null)
1633 {
1634         global $installed_languages;
1635
1636         $items = array();
1637         foreach ($installed_languages as $lang)
1638                         $items[$lang['code']] = $lang['name'];
1639         
1640         return array_selector($name, $selected_id, $items );
1641 }
1642
1643 function languages_list_cells($label, $name, $selected_id=null)
1644 {
1645         if ($label != null)
1646                 echo "<td>$label</td>\n";
1647         echo "<td>";
1648         languages_list($name, $selected_id);
1649         echo "</td>\n";
1650 }
1651
1652 function languages_list_row($label, $name, $selected_id=null)
1653 {
1654         echo "<tr>\n";
1655         languages_list_cells($label, $name, $selected_id);
1656         echo "</tr>\n";
1657 }
1658
1659 //------------------------------------------------------------------------------------------------
1660
1661 function bank_account_types_list($name, $selected_id=null)
1662 {
1663         $types = bank_account_types::get_all();
1664
1665         $items = array();
1666         foreach ($types as $type)
1667         {
1668                         $items[$type['id']] = $type['name'];
1669         }
1670         
1671         return array_selector($name, $selected_id, $items );
1672 }
1673
1674 function bank_account_types_list_cells($label, $name, $selected_id=null)
1675 {
1676         if ($label != null)
1677                 echo "<td>$label</td>\n";
1678         echo "<td>";
1679         bank_account_types_list($name, $selected_id);
1680         echo "</td>\n";
1681 }
1682
1683 function bank_account_types_list_row($label, $name, $selected_id=null)
1684 {
1685         echo "<tr>\n";
1686         bank_account_types_list_cells($label, $name, $selected_id);
1687         echo "</tr>\n";
1688 }
1689
1690 //------------------------------------------------------------------------------------------------
1691 function payment_person_types_list($name, $selected_id=null, $submit_on_change=false)
1692 {
1693         $types = payment_person_types::get_all();
1694
1695         $items = array();
1696         foreach ($types as $type)
1697         {
1698                 if (payment_person_types::has_items($type['id']))
1699                 {
1700                         $items[$type['id']] = $type['name'];
1701                 }
1702         }
1703         
1704         return array_selector($name, $selected_id, $items, 
1705                 array( 'select_submit'=> $submit_on_change ) );
1706 }
1707
1708 function payment_person_types_list_cells($label, $name, $selected_id=null, $related=null)
1709 {
1710         if ($label != null)
1711                 echo "<td>$label</td>\n";
1712         echo "<td>";
1713         $str = payment_person_types_list($name, $selected_id, $related);
1714         echo "</td>\n";
1715         return $str;
1716 }
1717
1718 function payment_person_types_list_row($label, $name, $selected_id=null, $related=null)
1719 {
1720         echo "<tr>\n";
1721         $str = payment_person_types_list_cells($label, $name, $selected_id, $related);
1722         echo "</tr>\n";
1723         return $str;
1724 }
1725
1726 //------------------------------------------------------------------------------------------------
1727
1728 function wo_types_list($name, $selected_id=null)
1729 {
1730         $types = wo_types::get_all();
1731
1732         $items = array();
1733         foreach ($types as $type)
1734                 $items[$type['id']] = $type['name'];
1735         
1736         return array_selector($name, $selected_id, $items, 
1737                 array( 'select_submit'=> true, 'async' => true ) );
1738 }
1739
1740 function wo_types_list_row($label, $name, $selected_id=null)
1741 {
1742         echo "<tr><td>$label</td><td>\n";
1743         $str = wo_types_list($name, $selected_id);
1744         echo "</td></tr>\n";
1745         return $str;
1746 }
1747
1748 //------------------------------------------------------------------------------------------------
1749
1750 function dateformats_list_row($label, $name, $value=null)
1751 {
1752         global $dateformats;
1753
1754         echo "<tr><td>$label</td>\n<td>";
1755         array_selector( $name, $value, $dateformats );
1756         echo "</td></tr>\n";
1757 }
1758
1759 function dateseps_list_row($label, $name, $value=null)
1760 {
1761         global $dateseps;
1762
1763         echo "<tr><td>$label</td>\n<td>";
1764         array_selector( $name, $value, $dateseps );
1765         echo "</td></tr>\n";
1766 }
1767
1768 function thoseps_list_row($label, $name, $value=null)
1769 {
1770         global $thoseps;
1771
1772         echo "<tr><td>$label</td>\n<td>";
1773         array_selector( $name, $value, $thoseps );
1774         echo "</td></tr>\n";
1775 }
1776
1777 function decseps_list_row($label, $name, $value=null)
1778 {
1779         global $decseps;
1780
1781         echo "<tr><td>$label</td>\n<td>";
1782         array_selector( $name, $value, $decseps );
1783         echo "</td></tr>\n";
1784 }
1785
1786 function themes_list_row($label, $name, $value=null)
1787 {
1788         global $path_to_root;
1789
1790         $path = $path_to_root.'/themes/';
1791         $themes = array();
1792         $themedir = opendir($path);
1793         while(false !== ($fname = readdir($themedir)))
1794         {
1795                 if($fname!='.' && $fname!='..' && $fname!='CVS' && is_dir($path.$fname))
1796                 {
1797                         $themes[$fname] =  $fname;
1798                 }
1799         }
1800         ksort($themes);
1801
1802         echo "<tr><td>$label</td>\n<td>";
1803         array_selector( $name, $value, $themes );
1804         echo "</td></tr>\n";
1805 }
1806
1807 function pagesizes_list_row($label, $name, $value=null)
1808 {
1809         global $pagesizes;
1810
1811         $items = array();
1812         foreach ($pagesizes as $pz)
1813                 $items[$pz] = $pz;
1814
1815         echo "<tr><td>$label</td>\n<td>";
1816         array_selector( $name, $value, $items );
1817         echo "</td></tr>\n";
1818 }
1819
1820 function security_headings_list_row($label, $name, $value=null)
1821 {
1822         global $security_headings;
1823
1824         echo "<tr><td>$label</td>\n<td>";
1825         array_selector( $name, $value, $security_headings );
1826         echo "</td></tr>\n";
1827 }
1828
1829 function systypes_list_cells($label, $name, $value=null, $submit_on_change=false)
1830 {
1831         global $systypes_array;
1832
1833         if ($label != null)
1834                 echo "<td>$label</td>\n";
1835         echo "<td>";
1836
1837         $items = array();
1838         foreach ($systypes_array as $key=>$type)
1839                         $items[$key] = $type['name'];
1840         
1841         $str = array_selector($name, $value, $items, 
1842                 array( 
1843                         'select_submit'=> $submit_on_change,
1844                         'async' => false
1845                         )
1846         );
1847         echo "</td>\n";
1848         return $str;
1849 }
1850
1851 function systypes_list_row($label, $name, $value=null, $submit_on_change=false)
1852 {
1853         echo "<tr>\n";
1854         $str = systypes_list_cells($label, $name, $value, $submit_on_change);
1855         echo "</tr>\n";
1856         return $str;
1857 }
1858
1859 function cust_allocations_list_cells($label, $name, $selected=null)
1860 {
1861         global $all_items;
1862
1863         if ($label != null)
1864                 label_cell($label);
1865         echo "<td>\n";
1866         $allocs = array( 
1867                 $all_items=>_("All Types"),
1868                 '1'=> _("Sales Invoices"),
1869                 '2'=> _("Overdue Invoices"),
1870                 '3' => _("Payments"),
1871                 '4' => _("Credit Notes"),
1872                 '5' => _("Delivery Notes")
1873         );
1874         $str = array_selector($name, $selected, $allocs);
1875         echo "</td>\n";
1876         return $str;
1877 }
1878
1879 function supp_allocations_list_cell($name, $selected=null)
1880 {
1881         global $all_items;
1882
1883         echo "<td>\n";
1884         $allocs = array( 
1885                 $all_items=>_("All Types"),
1886                 '1'=> _("Invoices"),
1887                 '2'=> _("Overdue Invoices"),
1888                 '3' => _("Payments"),
1889                 '4' => _("Credit Notes"),
1890                 '5' => _("Overdue Credit Notes")
1891         );
1892         $str = array_selector($name, $selected, $allocs);
1893         echo "</td>\n";
1894         return $str;
1895 }
1896
1897 function policy_list_cells($label, $name, $selected=null)
1898 {
1899         if ($label != null)
1900                 label_cell($label);
1901         echo "<td>\n";
1902         $str = array_selector($name, $selected, 
1903                                 array( '' => _("Automatically put balance on back order"),
1904                                         'CAN' => _("Cancel any quantites not delivered")) );
1905         echo "</td>\n";
1906         return $str;
1907 }
1908
1909 function policy_list_row($label, $name, $selected=null)
1910 {
1911         echo "<tr>\n";
1912         policy_list_cells($label, $name, $selected);
1913         echo "</tr>\n";
1914 }
1915
1916 function credit_type_list_cells($label, $name, $selected=null, $submit_on_change=false)
1917 {
1918         if ($label != null)
1919                 label_cell($label);
1920         echo "<td>\n";
1921         $str = array_selector($name, $selected, 
1922                                 array( 'Return' => _("Items Returned to Inventory Location"),
1923                                         'WriteOff' => _("Items Written Off")),
1924                                 array( 'select_submit'=> $submit_on_change ) );
1925         echo "</td>\n";
1926         return $str;
1927 }
1928
1929 function credit_type_list_row($label, $name, $selected=null, $submit_on_change=false)
1930 {
1931         echo "<tr>\n";
1932         $str = credit_type_list_cells($label, $name, $selected, $submit_on_change);
1933         echo "</tr>\n";
1934         return $str;
1935 }
1936
1937 function number_list($name, $selected, $from, $to, $no_option=false)
1938 {
1939         $items = array();
1940         for ($i = $from; $i <= $to; $i++)
1941                 $items[$i] = "$i";
1942
1943         return array_selector($name, $selected, $items,
1944                                 array(  'spec_option' => $no_option,
1945                                                 'spec_id' => reserved_words::get_all_numeric()) );
1946 }
1947
1948 function number_list_cells($label, $name, $selected, $from, $to, $no_option=false)
1949 {
1950         if ($label != null)
1951                 label_cell($label);
1952         echo "<td>\n";
1953         number_list($name, $selected, $from, $to, $no_option);
1954         echo "</td>\n";
1955 }
1956
1957 function number_list_row($label, $name, $selected, $from, $to, $no_option=false)
1958 {
1959         echo "<tr>\n";
1960         number_list_cells($label, $name, $selected, $from, $to, $no_option);
1961         echo "</tr>\n";
1962 }
1963
1964 function print_profiles_list_row($label, $name, $selected_id=null, $spec_opt=false,
1965         $submit_on_change=true)
1966 {
1967         $sql = "SELECT profile FROM ".TB_PREF."print_profiles"
1968                 ." GROUP BY profile";
1969         $result = db_query($sql, 'cannot get all profile names');
1970         $profiles = array();
1971         while($myrow=db_fetch($result)) {
1972                 $profiles[$myrow['profile']] = $myrow['profile'];
1973         }
1974
1975         echo "<tr>";
1976         if ($label != null)
1977                 echo "<td>$label</td>\n";
1978         echo "<td>";
1979
1980         array_selector($name, $selected_id, $profiles, 
1981                 array( 'select_submit'=> $submit_on_change,
1982                         'spec_option'=>$spec_opt,
1983                         'spec_id' => ''
1984                  ));
1985
1986         echo "</td></tr>\n";
1987 }
1988
1989 function printers_list($name, $selected_id=null, $spec_opt=false, $submit_on_change=false)
1990 {
1991         static $printers; // query only once for page display
1992
1993         if (!$printers) {
1994                 $sql = "SELECT id, name, description FROM ".TB_PREF."printers"; 
1995                 $result = db_query($sql, 'cannot get all printers');
1996                 $printers = array();
1997                 while($myrow=db_fetch($result)) {
1998                         $printers[$myrow['id']] = $myrow['name'].'&nbsp;-&nbsp;'.$myrow['description'];
1999                 }
2000         }
2001         array_selector($name, $selected_id, $printers, 
2002                 array( 'select_submit'=> $submit_on_change,
2003                         'spec_option'=>$spec_opt,
2004                         'spec_id' => ''
2005                  ));
2006 }
2007
2008 //------------------------------------------------------------------------------------------------
2009
2010 function quick_entries_list($name, $selected_id=null, $type=null, $submit_on_change=false)
2011 {
2012         $where = false;
2013         $sql = "SELECT id, description FROM ".TB_PREF."quick_entries";
2014         if ($type != null)
2015                 $sql .= " WHERE type=$type";
2016
2017         combo_input($name, $selected_id, $sql, 'id', 'description',
2018                 array(
2019                         'spec_id' => '',
2020                         'order' => 'description',
2021                         'select_submit'=> $submit_on_change,
2022                         'async' => false
2023                 ) );
2024
2025 }
2026
2027 function quick_entries_list_cells($label, $name, $selected_id=null, $type, $submit_on_change=false)
2028 {
2029         echo "<td>$label</td><td>\n";
2030         quick_entries_list($name, $selected_id, $type, $submit_on_change);
2031         echo "</td>";
2032 }
2033
2034 function quick_entries_list_row($label, $name, $selected_id=null, $type, $submit_on_change=false)
2035 {
2036         echo "<tr>\n";
2037         quick_entries_list_cells($label, $name, $selected_id, $type, $submit_on_change);
2038         echo "</tr>\n";
2039 }
2040
2041
2042 function quick_actions_list_row($label, $name, $selected_id=null, $submit_on_change=false)
2043 {
2044         global $quick_actions;
2045         
2046         echo "<tr><td>$label</td><td>";
2047         array_selector($name, $selected_id, $quick_actions, 
2048                 array( 
2049                         'select_submit'=> $submit_on_change
2050                 ) );
2051         echo "</td></tr>\n";
2052 }
2053
2054 function quick_entry_types_list_row($label, $name, $selected_id=null, $submit_on_change=false)
2055 {
2056         global $quick_entry_types;
2057                 
2058         echo "<tr><td>$label</td><td>";
2059         array_selector($name, $selected_id, $quick_entry_types, 
2060                 array( 
2061                         'select_submit'=> $submit_on_change
2062                         ) );
2063         echo "</td></tr>\n";
2064 }
2065
2066
2067 ?>