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