Changed balance_sheet operation in class table to class type for sign convert in...
[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         $str = stock_manufactured_items_list_cells($label, $name, $selected_id,
822                         $all_option, $submit_on_change);
823         echo "</tr>\n";
824         return $str;
825 }
826 //------------------------------------------------------------------------------------
827
828 function stock_component_items_list($name, $parent_stock_id, $selected_id=null,
829         $all_option=false, $submit_on_change=false)
830 {
831         $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
832                 array('where'=>array("stock_id != '$parent_stock_id'")));
833         return $str;
834 }
835
836 function stock_component_items_list_cells($label, $name, $parent_stock_id, 
837         $selected_id=null, $all_option=false, $submit_on_change=false)
838 {
839         if ($label != null)
840                 echo "<td>$label</td>\n";
841         $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
842                 array('where'=>array("stock_id != '$parent_stock_id'"), 'cells'=>true));
843         return $str;
844 }
845 //------------------------------------------------------------------------------------
846
847 function stock_costable_items_list($name, $selected_id=null,
848         $all_option=false, $submit_on_change=false)
849 {
850         $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
851                 array('where'=>array("mb_flag!='D'")));
852         return $str;
853 }
854
855 function stock_costable_items_list_cells($label, $name, $selected_id=null, 
856         $all_option=false, $submit_on_change=false)
857 {
858         if ($label != null)
859                 echo "<td>$label</td>\n";
860         $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
861                 array('where'=>array("mb_flag!='D'"), 'cells'=>true));
862         return $str;
863 }
864
865 //------------------------------------------------------------------------------------
866 function stock_purchasable_items_list($name, $selected_id=null, 
867         $all_option=false, $submit_on_change=false)
868 {
869         $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
870                 array('where'=>array("mb_flag!= 'M'"), 
871                         'edit_submit' => true));
872         return $str;
873 }
874
875 function stock_purchasable_items_list_cells($label, $name, $selected_id=null,
876                         $all_option=false, $submit_on_change=false)
877 {
878         if ($label != null)
879                 echo "<td>$label</td>\n";
880         $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
881                 array('where'=>array("mb_flag!= 'M'"), 
882                          'edit_submit' => true,
883                          'cells'=>true));
884         return $str;
885 }
886
887 function stock_purchasable_items_list_row($label, $name, $selected_id=null,
888                         $all_option=false, $submit_on_change=false)
889 {
890         echo "<tr>\n";
891         $ret = stock_purchasable_items_list_cells($label, $name, $selected_id=null,
892                 $all_option, $submit_on_change);
893         echo "</tr>\n";
894         return $ret;
895 }
896
897 //------------------------------------------------------------------------------------
898
899 function stock_item_types_list_row($label, $name, $selected_id=null, $enabled=true)
900 {
901         $types = array(
902                 'M' => _("Manufactured"),
903                 'B' => _("Purchased"),
904                 'D' => _("Service")
905         );
906
907         echo "<tr>";
908         if ($label != null)
909                 echo "<td>$label</td>\n";
910         echo "<td>";
911
912         array_selector($name, $selected_id, $types, 
913                 array( 
914                         'select_submit'=> true, 
915                         'disabled' => !$enabled) );
916         echo "</td></tr>\n";
917 }
918
919 function stock_units_list_row($label, $name, $value=null, $enabled=true)
920 {
921         $result = get_all_item_units();
922         echo "<tr>";
923         if ($label != null)
924                 echo "<td>$label</td>\n";
925         echo "<td>";
926
927         while($unit = db_fetch($result))
928                 $units[$unit['abbr']] = $unit['name'];
929
930         array_selector($name, $value, $units, 
931                 array( 
932                         'select_submit'=> true, 
933                         'disabled' => !$enabled) );
934
935         echo "</td></tr>\n";
936 }
937
938 //------------------------------------------------------------------------------------
939
940 function tax_types_list($name, $selected_id=null, $none_option=false, $submit_on_change=false)
941 {
942         $sql = "SELECT id, CONCAT(name, ' (',rate,'%)') as name FROM ".TB_PREF."tax_types";
943
944         return combo_input($name, $selected_id, $sql, 'id', 'name',
945         array(
946                 'spec_option' => $none_option,
947                 'spec_id' => reserved_words::get_all_numeric(),
948                 'select_submit'=> $submit_on_change,
949                 'async' => false,
950         ) );
951 }
952
953 function tax_types_list_cells($label, $name, $selected_id=null, $none_option=false,
954         $submit_on_change=false)
955 {
956         if ($label != null)
957                 echo "<td>$label</td>\n";
958         echo "<td>";
959         $str = tax_types_list($name, $selected_id, $none_option, $submit_on_change);
960         echo "</td>\n";
961         return $str;
962 }
963
964 function tax_types_list_row($label, $name, $selected_id=null, $none_option=false,
965         $submit_on_change=false)
966 {
967         echo "<tr>\n";
968         $str = tax_types_list_cells($label, $name, $selected_id, $none_option, $submit_on_change);
969         echo "</tr>\n";
970         return $str;
971 }
972
973 //------------------------------------------------------------------------------------
974
975 function tax_groups_list($name, $selected_id=null,
976         $none_option=false, $submit_on_change=false)
977 {
978         $sql = "SELECT id, name FROM ".TB_PREF."tax_groups";
979
980         return combo_input($name, $selected_id, $sql, 'id', 'name',
981         array(
982                 'order' => 'id',
983                 'spec_option' => $none_option,
984                 'spec_id' => reserved_words::get_all_numeric(),
985                 'select_submit'=> $submit_on_change,
986                 'async' => false,
987         ) );
988 }
989
990 function tax_groups_list_cells($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false)
991 {
992         if ($label != null)
993                 echo "<td>$label</td>\n";
994         echo "<td>";
995         $str = tax_groups_list($name, $selected_id, $none_option, $submit_on_change);
996         echo "</td>\n";
997         return $str;
998 }
999
1000 function tax_groups_list_row($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false)
1001 {
1002         echo "<tr>\n";
1003         $str = tax_groups_list_cells($label, $name, $selected_id, $none_option, $submit_on_change);
1004         echo "</tr>\n";
1005         return $str;
1006 }
1007
1008 //------------------------------------------------------------------------------------
1009
1010 function item_tax_types_list($name, $selected_id=null)
1011 {
1012         $sql ="SELECT id, name FROM ".TB_PREF."item_tax_types";
1013         combo_input($name, $selected_id, $sql, 'id', 'name', array('order' => 'id') );
1014 }
1015
1016 function item_tax_types_list_cells($label, $name, $selected_id=null)
1017 {
1018         if ($label != null)
1019                 echo "<td>$label</td>\n";
1020         echo "<td>";
1021         item_tax_types_list($name, $selected_id);
1022         echo "</td>\n";
1023 }
1024
1025 function item_tax_types_list_row($label, $name, $selected_id=null)
1026 {
1027         echo "<tr>\n";
1028         item_tax_types_list_cells($label, $name, $selected_id);
1029         echo "</tr>\n";
1030 }
1031
1032 //------------------------------------------------------------------------------------
1033
1034 function shippers_list($name, $selected_id=null)
1035 {
1036         $sql = "SELECT shipper_id, shipper_name FROM ".TB_PREF."shippers";
1037         combo_input($name, $selected_id, $sql, 'shipper_id', 'shipper_name', array());
1038 }
1039
1040 function shippers_list_cells($label, $name, $selected_id=null)
1041 {
1042         if ($label != null)
1043                 echo "<td>$label</td>\n";
1044         echo "<td>";
1045         shippers_list($name, $selected_id);
1046         echo "</td>\n";
1047 }
1048
1049 function shippers_list_row($label, $name, $selected_id=null)
1050 {
1051         echo "<tr>\n";
1052         shippers_list_cells($label, $name, $selected_id);
1053         echo "</tr>\n";
1054 }
1055
1056 //-------------------------------------------------------------------------------------
1057
1058 function sales_persons_list($name, $selected_id=null)
1059 {
1060         $sql = "SELECT salesman_code, salesman_name FROM ".TB_PREF."salesman";
1061         combo_input($name, $selected_id, $sql, 'salesman_code', 'salesman_name', array());
1062 }
1063
1064 function sales_persons_list_cells($label, $name, $selected_id=null)
1065 {
1066         if ($label != null)
1067                 echo "<td>$label</td>\n";
1068         echo "<td>\n";
1069         sales_persons_list($name, $selected_id);
1070         echo "</td>\n";
1071 }
1072
1073 function sales_persons_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1074 {
1075         echo "<tr>\n";
1076         sales_persons_list_cells($label, $name, $selected_id, $submit_on_change=false);
1077         echo "</tr>\n";
1078 }
1079
1080 //------------------------------------------------------------------------------------
1081
1082 function sales_areas_list($name, $selected_id=null)
1083 {
1084         $sql = "SELECT area_code, description FROM ".TB_PREF."areas";
1085         combo_input($name, $selected_id, $sql, 'area_code', 'description', array());
1086 }
1087
1088 function sales_areas_list_cells($label, $name, $selected_id=null)
1089 {
1090         if ($label != null)
1091                 echo "<td>$label</td>\n";
1092         echo "<td>";
1093         sales_areas_list($name, $selected_id);
1094         echo "</td>\n";
1095 }
1096
1097 function sales_areas_list_row($label, $name, $selected_id=null)
1098 {
1099         echo "<tr>\n";
1100         sales_areas_list_cells($label, $name, $selected_id);
1101         echo "</tr>\n";
1102 }
1103
1104 //------------------------------------------------------------------------------------
1105
1106 function sales_groups_list($name, $selected_id=null, $special_option=false)
1107 {
1108         $sql = "SELECT id, description FROM ".TB_PREF."groups";
1109         combo_input($name, $selected_id, $sql, 'id', 'description', array(
1110                 'spec_option' => $special_option===true ? ' ' : $special_option,
1111                 'order' => 'description', 'spec_id' => 0,
1112         ));
1113 }
1114
1115 function sales_groups_list_cells($label, $name, $selected_id=null, $special_option=false)
1116 {
1117         if ($label != null)
1118                 echo "<td>$label</td>\n";
1119         echo "<td>";
1120         sales_groups_list($name, $selected_id, $special_option);
1121         echo "</td>\n";
1122 }
1123
1124 function sales_groups_list_row($label, $name, $selected_id=null, $special_option=false)
1125 {
1126         echo "<tr>\n";
1127         sales_groups_list_cells($label, $name, $selected_id, $special_option);
1128         echo "</tr>\n";
1129 }
1130
1131 //------------------------------------------------------------------------------------
1132
1133 function _format_template_items($row)
1134 {
1135         return ($row[0] . "&nbsp;- &nbsp;" . _("Amount") . "&nbsp;".$row[1]);
1136 }
1137
1138 function templates_list($name, $selected_id=null, $special_option=false)
1139 {
1140         $sql = "SELECT sorder.order_no, Sum(line.unit_price*line.quantity*(1-line.discount_percent)) AS OrderValue
1141                 FROM ".TB_PREF."sales_orders as sorder, ".TB_PREF."sales_order_details as line
1142                 WHERE sorder.order_no = line.order_no AND sorder.type = 1 GROUP BY line.order_no";
1143         combo_input($name, $selected_id, $sql, 'order_no', 'OrderValue', array(
1144                 'format' => '_format_template_items',
1145                 'spec_option' => $special_option===true ? ' ' : $special_option,
1146                 'order' => 'order_no', 'spec_id' => 0,
1147         ));
1148 }
1149
1150 function templates_list_cells($label, $name, $selected_id=null, $special_option=false)
1151 {
1152         if ($label != null)
1153                 echo "<td>$label</td>\n";
1154         echo "<td>";
1155         templates_list($name, $selected_id, $special_option);
1156         echo "</td>\n";
1157 }
1158
1159 function templates_list_row($label, $name, $selected_id=null, $special_option=false)
1160 {
1161         echo "<tr>\n";
1162         templates_list_cells($label, $name, $selected_id, $special_option);
1163         echo "</tr>\n";
1164 }
1165
1166 //------------------------------------------------------------------------------------
1167
1168 function workorders_list($name, $selected_id=null)
1169 {
1170         $sql = "SELECT id, wo_ref FROM ".TB_PREF."workorders WHERE closed=0";
1171         combo_input($name, $selected_id, $sql, 'id', 'wo_ref', array());
1172 }
1173
1174 function workorders_list_cells($label, $name, $selected_id=null)
1175 {
1176         if ($label != null)
1177                 echo "<td>$label</td>\n";
1178         echo "<td>";
1179         workorders_list($name, $selected_id);
1180         echo "</td>\n";
1181 }
1182
1183 function workorders_list_row($label, $name, $selected_id=null)
1184 {
1185         echo "<tr>\n";
1186         workorders_list_cells($label, $name, $selected_id);
1187         echo "</tr>\n";
1188 }
1189
1190 //------------------------------------------------------------------------------------
1191
1192 function payment_terms_list($name, $selected_id=null)
1193 {
1194         $sql = "SELECT terms_indicator, terms FROM ".TB_PREF."payment_terms";
1195         combo_input($name, $selected_id, $sql, 'terms_indicator', 'terms', array());
1196 }
1197
1198 function payment_terms_list_cells($label, $name, $selected_id=null)
1199 {
1200         if ($label != null)
1201                 echo "<td>$label</td>\n";
1202         echo "<td>";
1203         payment_terms_list($name, $selected_id);
1204         echo "</td>\n";
1205 }
1206
1207 function payment_terms_list_row($label, $name, $selected_id=null)
1208 {
1209         echo "<tr>\n";
1210         payment_terms_list_cells($label, $name, $selected_id);
1211         echo "</tr>\n";
1212 }
1213
1214 //------------------------------------------------------------------------------------
1215
1216 function credit_status_list($name, $selected_id=null)
1217 {
1218         $sql ="SELECT id, reason_description FROM ".TB_PREF."credit_status";
1219         combo_input($name, $selected_id, $sql, 'id', 'reason_description', array());
1220 }
1221
1222 function credit_status_list_cells($label, $name, $selected_id=null)
1223 {
1224         if ($label != null)
1225                 echo "<td>$label</td>\n";
1226         echo "<td>";
1227         credit_status_list($name, $selected_id);
1228         echo "</td>\n";
1229 }
1230
1231 function credit_status_list_row($label, $name, $selected_id=null)
1232 {
1233         echo "<tr>\n";
1234         credit_status_list_cells($label, $name, $selected_id);
1235         echo "</tr>\n";
1236 }
1237
1238 //-----------------------------------------------------------------------------------------------
1239
1240 function sales_types_list($name, $selected_id=null, $submit_on_change=false, $special_option=false)
1241 {
1242         $sql = "SELECT id, sales_type FROM ".TB_PREF."sales_types";
1243
1244         return combo_input($name, $selected_id, $sql, 'id', 'sales_type',
1245         array(
1246                 'spec_option' => $special_option===true ? _("All Sales Types") : $special_option,
1247                 'spec_id' => 0,
1248                 'select_submit'=> $submit_on_change,
1249         //        'async' => false,
1250         ) );
1251 }
1252
1253 function sales_types_list_cells($label, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1254 {
1255         if ($label != null)
1256                 echo "<td>$label</td>\n";
1257         echo "<td>";
1258         $str = sales_types_list($name, $selected_id, $submit_on_change, $special_option);
1259         echo "</td>\n";
1260         return $str;
1261 }
1262
1263 function sales_types_list_row($label, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1264 {
1265         echo "<tr>\n";
1266         $str = sales_types_list_cells($label, $name, $selected_id, $submit_on_change, $special_option);
1267         echo "</tr>\n";
1268         return $str;
1269 }
1270
1271 //-----------------------------------------------------------------------------------------------
1272
1273 function movement_types_list($name, $selected_id=null)
1274 {
1275         $sql = "SELECT id, name FROM ".TB_PREF."movement_types";
1276         combo_input($name, $selected_id, $sql, 'id', 'name', array());
1277 }
1278
1279 function movement_types_list_cells($label, $name, $selected_id=null)
1280 {
1281         if ($label != null)
1282                 echo "<td>$label</td>\n";
1283         echo "<td>";
1284         movement_types_list($name, $selected_id);
1285         echo "</td>\n";
1286 }
1287
1288 function movement_types_list_row($label, $name, $selected_id=null)
1289 {
1290         echo "<tr>\n";
1291         movement_types_list_cells($label, $name, $selected_id);
1292         echo "</tr>\n";
1293 }
1294
1295 //-----------------------------------------------------------------------------------------------
1296 function _format_date($row)
1297 {
1298         return sql2date($row['reconciled']);
1299 }
1300
1301 function bank_reconciliation_list($account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1302 {
1303         $sql = "SELECT reconciled, reconciled FROM ".TB_PREF."bank_trans
1304                 WHERE bank_act=".db_escape($account)." AND reconciled IS NOT NULL
1305                 GROUP BY reconciled";
1306         combo_input($name, $selected_id, $sql, 'id', 'reconciled',
1307         array(
1308                 'spec_option' => $special_option,
1309                 'format' => '_format_date',
1310                 'spec_id' => '',
1311                 'select_submit'=> $submit_on_change
1312         ) );
1313 }
1314
1315 function bank_reconciliation_list_cells($label,$account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1316 {
1317         if ($label != null)
1318                 echo "<td>$label</td>\n";
1319         echo "<td>";
1320         bank_reconciliation_list($account, $name, $selected_id, $submit_on_change, $special_option);
1321         echo "</td>\n";
1322 }
1323 /*
1324 function bank_reconciliation_list_row($label, $account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1325 {
1326         echo "<tr>\n";
1327         bank_reconciliation_list_cells($label, $account, $name, $selected_id, $submit_on_change, $special_option);
1328         echo "</tr>\n";
1329 }
1330 */
1331 //-----------------------------------------------------------------------------------------------
1332
1333 function workcenter_list($name, $selected_id=null, $all_option=false)
1334 {
1335         global $all_items;
1336
1337         $sql = "SELECT id, name FROM ".TB_PREF."workcentres";
1338
1339         return combo_input($name, $selected_id, $sql, 'id', 'name',
1340         array(
1341                 'spec_option' =>$all_option===true ? _("All Suppliers") : $all_option,
1342                 'spec_id' => $all_items,
1343         ) );
1344 }
1345
1346 function workcenter_list_cells($label, $name, $selected_id=null, $all_option=false)
1347 {
1348         default_focus($name);
1349         if ($label != null)
1350                 echo "<td>$label</td>\n";
1351         echo "<td>";
1352         workcenter_list($name, $selected_id, $all_option);
1353         echo "</td>\n";
1354 }
1355
1356 function workcenter_list_row($label, $name, $selected_id=null, $all_option=false)
1357 {
1358         echo "<tr>\n";
1359         workcenter_list_cells($label, $name, $selected_id, $all_option);
1360         echo "</tr>\n";
1361 }
1362
1363 //-----------------------------------------------------------------------------------------------
1364
1365 function bank_accounts_list($name, $selected_id=null, $submit_on_change=false)
1366 {
1367         $sql = "SELECT ".TB_PREF."bank_accounts.id, bank_account_name, bank_curr_code
1368                 FROM ".TB_PREF."bank_accounts";
1369 //              , ".TB_PREF."chart_master
1370 //              WHERE ".TB_PREF."bank_accounts.account_code=".TB_PREF."chart_master.account_code";
1371
1372         return combo_input($name, $selected_id, $sql, 'id', 'bank_account_name',
1373         array(
1374                 'format' => '_format_add_curr',
1375                 'select_submit'=> $submit_on_change,
1376                 'async' => false
1377         ) );
1378 }
1379
1380 function bank_accounts_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1381 {
1382         if ($label != null)
1383                 echo "<td>$label</td>\n";
1384         echo "<td>";
1385         $str = bank_accounts_list($name, $selected_id, $submit_on_change);
1386         echo "</td>\n";
1387         return $str;
1388 }
1389
1390 function bank_accounts_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1391 {
1392         echo "<tr>\n";
1393         $str = bank_accounts_list_cells($label, $name, $selected_id, $submit_on_change);
1394         echo "</tr>\n";
1395         return $str;
1396 }
1397 //-----------------------------------------------------------------------------------------------
1398
1399 function cash_accounts_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1400 {
1401         $sql = "SELECT ".TB_PREF."bank_accounts.id, bank_account_name, bank_curr_code
1402                 FROM ".TB_PREF."bank_accounts
1403                 WHERE ".TB_PREF."bank_accounts.account_type=3";
1404
1405         if ($label != null)
1406                 echo "<tr><td>$label</td>\n";
1407         echo "<td>";
1408         $str = combo_input($name, $selected_id, $sql, 'id', 'bank_account_name',
1409         array(
1410                 'format' => '_format_add_curr',
1411                 'select_submit'=> $submit_on_change,
1412                 'async' => true
1413         ) );
1414         echo "</td></tr>\n";
1415         return $str;
1416 }
1417 //-----------------------------------------------------------------------------------------------
1418
1419 function pos_list_row($label, $name, $selected_id=null, $spec_option=false, $submit_on_change=false)
1420 {
1421         $sql = "SELECT id, pos_name FROM ".TB_PREF."sales_pos";
1422
1423         default_focus($name);
1424         echo '<tr>';
1425         if ($label != null)
1426                 echo "<td>$label</td>\n";
1427         echo "<td>";
1428
1429         $str = combo_input($name, $selected_id, $sql, 'id', 'pos_name',
1430         array(
1431                 'select_submit'=> $submit_on_change,
1432                 'async' => true,
1433                 'spec_option' =>$spec_option,
1434                 'spec_id' => -1,
1435         ) );
1436         echo "</td></tr>\n";
1437
1438         return $str;    
1439 }
1440 //-----------------------------------------------------------------------------------------------
1441
1442 function sale_payment_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1443 {
1444         if ($label != null)
1445                 echo "<td>$label</td>\n";
1446         echo "<td>";
1447         $str = yesno_list($name, $selected_id, _('Cash'), _('Delayed'), $submit_on_change);
1448         echo "</td>\n";
1449         return $str;
1450 }
1451 //-----------------------------------------------------------------------------------------------
1452
1453 function class_list($name, $selected_id=null, $submit_on_change=false)
1454 {
1455         $sql = "SELECT cid, class_name FROM ".TB_PREF."chart_class";
1456
1457         return combo_input($name, $selected_id, $sql, 'cid', 'class_name',
1458         array(
1459                 'select_submit'=> $submit_on_change,
1460                 'async' => false
1461         ) );
1462
1463 }
1464
1465 function class_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1466 {
1467         if ($label != null)
1468                 echo "<td>$label</td>\n";
1469         echo "<td>";
1470         $str = class_list($name, $selected_id, $submit_on_change);
1471         echo "</td>\n";
1472         return $str;
1473 }
1474
1475 function class_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1476 {
1477         echo "<tr>\n";
1478         $str = class_list_cells($label, $name, $selected_id, $submit_on_change);
1479         echo "</tr>\n";
1480         return $str;
1481 }
1482
1483 //-----------------------------------------------------------------------------------------------
1484
1485 function stock_categories_list($name, $selected_id=null)
1486 {
1487         $sql = "SELECT category_id, description FROM ".TB_PREF."stock_category";
1488         combo_input($name, $selected_id, $sql, 'category_id', 'description',
1489         array('order'=>'category_id'));
1490 }
1491
1492 function stock_categories_list_cells($label, $name, $selected_id=null)
1493 {
1494         if ($label != null)
1495                 echo "<td>$label</td>\n";
1496         echo "<td>";
1497         stock_categories_list($name, $selected_id);
1498         echo "</td>\n";
1499 }
1500
1501 function stock_categories_list_row($label, $name, $selected_id=null)
1502 {
1503         echo "<tr>\n";
1504         stock_categories_list_cells($label, $name, $selected_id);
1505         echo "</tr>\n";
1506 }
1507
1508 //-----------------------------------------------------------------------------------------------
1509
1510 function gl_account_types_list($name, $selected_id=null, $all_option, $all_option_numeric)
1511 {
1512         global $all_items;
1513
1514         $sql = "SELECT id, name FROM ".TB_PREF."chart_types";
1515
1516         combo_input($name, $selected_id, $sql, 'id', 'name',
1517         array(
1518                 'order' => 'id',
1519                 'spec_option' =>$all_option,
1520                 'spec_id' => $all_option_numeric ? 0 : $all_items
1521         ) );
1522 }
1523
1524 function gl_account_types_list_cells($label, $name, $selected_id=null, $all_option=false,
1525         $all_option_numeric=false)
1526 {
1527         if ($label != null)
1528                 echo "<td>$label</td>\n";
1529         echo "<td>";
1530         gl_account_types_list($name, $selected_id, $all_option, $all_option_numeric);
1531         echo "</td>\n";
1532 }
1533
1534 function gl_account_types_list_row($label, $name, $selected_id=null, $all_option=false,
1535         $all_option_numeric=false)
1536 {
1537         echo "<tr>\n";
1538         gl_account_types_list_cells($label, $name, $selected_id, $all_option,
1539                 $all_option_numeric);
1540         echo "</tr>\n";
1541 }
1542
1543 //-----------------------------------------------------------------------------------------------
1544 function gl_all_accounts_list($name, $selected_id=null, $skip_bank_accounts=false,
1545         $cells=false, $all_option=false, $submit_on_change=false)
1546 {
1547         if ($skip_bank_accounts)
1548                 $sql = "SELECT chart.account_code, chart.account_name, type.name
1549                         FROM (".TB_PREF."chart_master chart,".TB_PREF."chart_types type) "
1550                         ."LEFT JOIN ".TB_PREF."bank_accounts acc "
1551                         ."ON chart.account_code=acc.account_code
1552                                 WHERE acc.account_code  IS NULL
1553                         AND chart.account_type=type.id";
1554         else
1555                 $sql = "SELECT chart.account_code, chart.account_name, type.name
1556                         FROM ".TB_PREF."chart_master chart,".TB_PREF."chart_types type
1557                         WHERE chart.account_type=type.id";
1558
1559         combo_input($name, $selected_id, $sql, 'chart.account_code', 'chart.account_name',
1560         array(
1561                 'format' => '_format_account',
1562                 'spec_option' => $all_option===true ?  _("Use Item Sales Accounts") : $all_option,
1563                 'spec_id' => '',
1564                 'order' => array('name','account_code'),
1565                 'search_box' => $cells,
1566                         'search_submit' => false,
1567                         'size' => 12,
1568                         'max' => 10,
1569                         'cells' => true,
1570                 'select_submit'=> $submit_on_change,
1571                 'async' => false,
1572                 'category' => 2
1573         ) );
1574
1575 }
1576
1577 function _format_account($row)
1578 {
1579                 return $row[0] .  "&nbsp;&nbsp;&nbsp;&nbsp;" . $row[1];
1580 }
1581
1582 function gl_all_accounts_list_cells($label, $name, $selected_id=null, 
1583         $skip_bank_accounts=false, $cells=false, $all_option=false)
1584 {
1585         if ($label != null)
1586                 echo "<td>$label</td>\n";
1587         echo "<td>";
1588         gl_all_accounts_list($name, $selected_id, 
1589                 $skip_bank_accounts, $cells, $all_option);
1590         echo "</td>\n";
1591 }
1592
1593 function gl_all_accounts_list_row($label, $name, $selected_id=null, 
1594         $skip_bank_accounts=false, $cells=false, $all_option=false)
1595 {
1596         echo "<tr>\n";
1597         gl_all_accounts_list_cells($label, $name, $selected_id, 
1598                 $skip_bank_accounts, $cells, $all_option);
1599         echo "</tr>\n";
1600 }
1601
1602 function yesno_list($name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1603 {
1604         $items = array();
1605         $items['0'] = strlen($name_no) ? $name_no : _("No");
1606         $items['1'] = strlen($name_yes) ? $name_yes : _("Yes");
1607
1608         return array_selector($name, $selected_id, $items, 
1609                 array( 
1610                         'select_submit'=> $submit_on_change,
1611                         'async' => false ) ); // FIX?
1612 }
1613
1614 function yesno_list_cells($label, $name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1615 {
1616         if ($label != null)
1617                 echo "<td>$label</td>\n";
1618         echo "<td>";
1619         $str = yesno_list($name, $selected_id, $name_yes, $name_no, $submit_on_change);
1620         echo "</td>\n";
1621         return $str;
1622 }
1623
1624 function yesno_list_row($label, $name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1625 {
1626         echo "<tr>\n";
1627         $str = yesno_list_cells($label, $name, $selected_id, $name_yes, $name_no, $submit_on_change);
1628         echo "</tr>\n";
1629         return $str;
1630 }
1631
1632 //------------------------------------------------------------------------------------------------
1633
1634 function languages_list($name, $selected_id=null)
1635 {
1636         global $installed_languages;
1637
1638         $items = array();
1639         foreach ($installed_languages as $lang)
1640                         $items[$lang['code']] = $lang['name'];
1641         
1642         return array_selector($name, $selected_id, $items );
1643 }
1644
1645 function languages_list_cells($label, $name, $selected_id=null)
1646 {
1647         if ($label != null)
1648                 echo "<td>$label</td>\n";
1649         echo "<td>";
1650         languages_list($name, $selected_id);
1651         echo "</td>\n";
1652 }
1653
1654 function languages_list_row($label, $name, $selected_id=null)
1655 {
1656         echo "<tr>\n";
1657         languages_list_cells($label, $name, $selected_id);
1658         echo "</tr>\n";
1659 }
1660
1661 //------------------------------------------------------------------------------------------------
1662
1663 function bank_account_types_list($name, $selected_id=null)
1664 {
1665         $types = bank_account_types::get_all();
1666
1667         $items = array();
1668         foreach ($types as $type)
1669         {
1670                         $items[$type['id']] = $type['name'];
1671         }
1672         
1673         return array_selector($name, $selected_id, $items );
1674 }
1675
1676 function bank_account_types_list_cells($label, $name, $selected_id=null)
1677 {
1678         if ($label != null)
1679                 echo "<td>$label</td>\n";
1680         echo "<td>";
1681         bank_account_types_list($name, $selected_id);
1682         echo "</td>\n";
1683 }
1684
1685 function bank_account_types_list_row($label, $name, $selected_id=null)
1686 {
1687         echo "<tr>\n";
1688         bank_account_types_list_cells($label, $name, $selected_id);
1689         echo "</tr>\n";
1690 }
1691
1692 //------------------------------------------------------------------------------------------------
1693 function payment_person_types_list($name, $selected_id=null, $submit_on_change=false)
1694 {
1695         $types = payment_person_types::get_all();
1696
1697         $items = array();
1698         foreach ($types as $type)
1699         {
1700                 if (payment_person_types::has_items($type['id']))
1701                 {
1702                         if ($type['id'] != payment_person_types::WorkOrder())
1703                                 $items[$type['id']] = $type['name'];
1704                 }
1705         }
1706         
1707         return array_selector($name, $selected_id, $items, 
1708                 array( 'select_submit'=> $submit_on_change ) );
1709 }
1710
1711 function payment_person_types_list_cells($label, $name, $selected_id=null, $related=null)
1712 {
1713         if ($label != null)
1714                 echo "<td>$label</td>\n";
1715         echo "<td>";
1716         $str = payment_person_types_list($name, $selected_id, $related);
1717         echo "</td>\n";
1718         return $str;
1719 }
1720
1721 function payment_person_types_list_row($label, $name, $selected_id=null, $related=null)
1722 {
1723         echo "<tr>\n";
1724         $str = payment_person_types_list_cells($label, $name, $selected_id, $related);
1725         echo "</tr>\n";
1726         return $str;
1727 }
1728
1729 //------------------------------------------------------------------------------------------------
1730
1731 function wo_types_list($name, $selected_id=null)
1732 {
1733         $types = wo_types::get_all();
1734
1735         $items = array();
1736         foreach ($types as $type)
1737                 $items[$type['id']] = $type['name'];
1738         
1739         return array_selector($name, $selected_id, $items, 
1740                 array( 'select_submit'=> true, 'async' => true ) );
1741 }
1742
1743 function wo_types_list_row($label, $name, $selected_id=null)
1744 {
1745         echo "<tr><td>$label</td><td>\n";
1746         $str = wo_types_list($name, $selected_id);
1747         echo "</td></tr>\n";
1748         return $str;
1749 }
1750
1751 //------------------------------------------------------------------------------------------------
1752
1753 function dateformats_list_row($label, $name, $value=null)
1754 {
1755         global $dateformats;
1756
1757         echo "<tr><td>$label</td>\n<td>";
1758         array_selector( $name, $value, $dateformats );
1759         echo "</td></tr>\n";
1760 }
1761
1762 function dateseps_list_row($label, $name, $value=null)
1763 {
1764         global $dateseps;
1765
1766         echo "<tr><td>$label</td>\n<td>";
1767         array_selector( $name, $value, $dateseps );
1768         echo "</td></tr>\n";
1769 }
1770
1771 function thoseps_list_row($label, $name, $value=null)
1772 {
1773         global $thoseps;
1774
1775         echo "<tr><td>$label</td>\n<td>";
1776         array_selector( $name, $value, $thoseps );
1777         echo "</td></tr>\n";
1778 }
1779
1780 function decseps_list_row($label, $name, $value=null)
1781 {
1782         global $decseps;
1783
1784         echo "<tr><td>$label</td>\n<td>";
1785         array_selector( $name, $value, $decseps );
1786         echo "</td></tr>\n";
1787 }
1788
1789 function themes_list_row($label, $name, $value=null)
1790 {
1791         global $path_to_root;
1792
1793         $path = $path_to_root.'/themes/';
1794         $themes = array();
1795         $themedir = opendir($path);
1796         while(false !== ($fname = readdir($themedir)))
1797         {
1798                 if($fname!='.' && $fname!='..' && $fname!='CVS' && is_dir($path.$fname))
1799                 {
1800                         $themes[$fname] =  $fname;
1801                 }
1802         }
1803         ksort($themes);
1804
1805         echo "<tr><td>$label</td>\n<td>";
1806         array_selector( $name, $value, $themes );
1807         echo "</td></tr>\n";
1808 }
1809
1810 function pagesizes_list_row($label, $name, $value=null)
1811 {
1812         global $pagesizes;
1813
1814         $items = array();
1815         foreach ($pagesizes as $pz)
1816                 $items[$pz] = $pz;
1817
1818         echo "<tr><td>$label</td>\n<td>";
1819         array_selector( $name, $value, $items );
1820         echo "</td></tr>\n";
1821 }
1822
1823 function security_headings_list_row($label, $name, $value=null)
1824 {
1825         global $security_headings;
1826
1827         echo "<tr><td>$label</td>\n<td>";
1828         array_selector( $name, $value, $security_headings );
1829         echo "</td></tr>\n";
1830 }
1831
1832 function systypes_list_cells($label, $name, $value=null, $submit_on_change=false)
1833 {
1834         global $systypes_array;
1835
1836         if ($label != null)
1837                 echo "<td>$label</td>\n";
1838         echo "<td>";
1839
1840         $items = array();
1841         foreach ($systypes_array as $key=>$type)
1842                         $items[$key] = $type['name'];
1843         
1844         $str = array_selector($name, $value, $items, 
1845                 array( 
1846                         'select_submit'=> $submit_on_change,
1847                         'async' => false
1848                         )
1849         );
1850         echo "</td>\n";
1851         return $str;
1852 }
1853
1854 function systypes_list_row($label, $name, $value=null, $submit_on_change=false)
1855 {
1856         echo "<tr>\n";
1857         $str = systypes_list_cells($label, $name, $value, $submit_on_change);
1858         echo "</tr>\n";
1859         return $str;
1860 }
1861
1862 function cust_allocations_list_cells($label, $name, $selected=null)
1863 {
1864         global $all_items;
1865
1866         if ($label != null)
1867                 label_cell($label);
1868         echo "<td>\n";
1869         $allocs = array( 
1870                 $all_items=>_("All Types"),
1871                 '1'=> _("Sales Invoices"),
1872                 '2'=> _("Overdue Invoices"),
1873                 '3' => _("Payments"),
1874                 '4' => _("Credit Notes"),
1875                 '5' => _("Delivery Notes")
1876         );
1877         $str = array_selector($name, $selected, $allocs);
1878         echo "</td>\n";
1879         return $str;
1880 }
1881
1882 function supp_allocations_list_cell($name, $selected=null)
1883 {
1884         global $all_items;
1885
1886         echo "<td>\n";
1887         $allocs = array( 
1888                 $all_items=>_("All Types"),
1889                 '1'=> _("Invoices"),
1890                 '2'=> _("Overdue Invoices"),
1891                 '3' => _("Payments"),
1892                 '4' => _("Credit Notes"),
1893                 '5' => _("Overdue Credit Notes")
1894         );
1895         $str = array_selector($name, $selected, $allocs);
1896         echo "</td>\n";
1897         return $str;
1898 }
1899
1900 function policy_list_cells($label, $name, $selected=null)
1901 {
1902         if ($label != null)
1903                 label_cell($label);
1904         echo "<td>\n";
1905         $str = array_selector($name, $selected, 
1906                                 array( '' => _("Automatically put balance on back order"),
1907                                         'CAN' => _("Cancel any quantites not delivered")) );
1908         echo "</td>\n";
1909         return $str;
1910 }
1911
1912 function policy_list_row($label, $name, $selected=null)
1913 {
1914         echo "<tr>\n";
1915         policy_list_cells($label, $name, $selected);
1916         echo "</tr>\n";
1917 }
1918
1919 function credit_type_list_cells($label, $name, $selected=null, $submit_on_change=false)
1920 {
1921         if ($label != null)
1922                 label_cell($label);
1923         echo "<td>\n";
1924         $str = array_selector($name, $selected, 
1925                                 array( 'Return' => _("Items Returned to Inventory Location"),
1926                                         'WriteOff' => _("Items Written Off")),
1927                                 array( 'select_submit'=> $submit_on_change ) );
1928         echo "</td>\n";
1929         return $str;
1930 }
1931
1932 function credit_type_list_row($label, $name, $selected=null, $submit_on_change=false)
1933 {
1934         echo "<tr>\n";
1935         $str = credit_type_list_cells($label, $name, $selected, $submit_on_change);
1936         echo "</tr>\n";
1937         return $str;
1938 }
1939
1940 function number_list($name, $selected, $from, $to, $no_option=false)
1941 {
1942         $items = array();
1943         for ($i = $from; $i <= $to; $i++)
1944                 $items[$i] = "$i";
1945
1946         return array_selector($name, $selected, $items,
1947                                 array(  'spec_option' => $no_option,
1948                                                 'spec_id' => reserved_words::get_all_numeric()) );
1949 }
1950
1951 function number_list_cells($label, $name, $selected, $from, $to, $no_option=false)
1952 {
1953         if ($label != null)
1954                 label_cell($label);
1955         echo "<td>\n";
1956         number_list($name, $selected, $from, $to, $no_option);
1957         echo "</td>\n";
1958 }
1959
1960 function number_list_row($label, $name, $selected, $from, $to, $no_option=false)
1961 {
1962         echo "<tr>\n";
1963         number_list_cells($label, $name, $selected, $from, $to, $no_option);
1964         echo "</tr>\n";
1965 }
1966
1967 function print_profiles_list_row($label, $name, $selected_id=null, $spec_opt=false,
1968         $submit_on_change=true)
1969 {
1970         $sql = "SELECT profile FROM ".TB_PREF."print_profiles"
1971                 ." GROUP BY profile";
1972         $result = db_query($sql, 'cannot get all profile names');
1973         $profiles = array();
1974         while($myrow=db_fetch($result)) {
1975                 $profiles[$myrow['profile']] = $myrow['profile'];
1976         }
1977
1978         echo "<tr>";
1979         if ($label != null)
1980                 echo "<td>$label</td>\n";
1981         echo "<td>";
1982
1983         array_selector($name, $selected_id, $profiles, 
1984                 array( 'select_submit'=> $submit_on_change,
1985                         'spec_option'=>$spec_opt,
1986                         'spec_id' => ''
1987                  ));
1988
1989         echo "</td></tr>\n";
1990 }
1991
1992 function printers_list($name, $selected_id=null, $spec_opt=false, $submit_on_change=false)
1993 {
1994         static $printers; // query only once for page display
1995
1996         if (!$printers) {
1997                 $sql = "SELECT id, name, description FROM ".TB_PREF."printers"; 
1998                 $result = db_query($sql, 'cannot get all printers');
1999                 $printers = array();
2000                 while($myrow=db_fetch($result)) {
2001                         $printers[$myrow['id']] = $myrow['name'].'&nbsp;-&nbsp;'.$myrow['description'];
2002                 }
2003         }
2004         array_selector($name, $selected_id, $printers, 
2005                 array( 'select_submit'=> $submit_on_change,
2006                         'spec_option'=>$spec_opt,
2007                         'spec_id' => ''
2008                  ));
2009 }
2010
2011 //------------------------------------------------------------------------------------------------
2012
2013 function quick_entries_list($name, $selected_id=null, $type=null, $submit_on_change=false)
2014 {
2015         $where = false;
2016         $sql = "SELECT id, description FROM ".TB_PREF."quick_entries";
2017         if ($type != null)
2018                 $sql .= " WHERE type=$type";
2019
2020         combo_input($name, $selected_id, $sql, 'id', 'description',
2021                 array(
2022                         'spec_id' => '',
2023                         'order' => 'description',
2024                         'select_submit'=> $submit_on_change,
2025                         'async' => false
2026                 ) );
2027
2028 }
2029
2030 function quick_entries_list_cells($label, $name, $selected_id=null, $type, $submit_on_change=false)
2031 {
2032         echo "<td>$label</td><td>\n";
2033         quick_entries_list($name, $selected_id, $type, $submit_on_change);
2034         echo "</td>";
2035 }
2036
2037 function quick_entries_list_row($label, $name, $selected_id=null, $type, $submit_on_change=false)
2038 {
2039         echo "<tr>\n";
2040         quick_entries_list_cells($label, $name, $selected_id, $type, $submit_on_change);
2041         echo "</tr>\n";
2042 }
2043
2044
2045 function quick_actions_list_row($label, $name, $selected_id=null, $submit_on_change=false)
2046 {
2047         global $quick_actions;
2048         
2049         echo "<tr><td>$label</td><td>";
2050         array_selector($name, $selected_id, $quick_actions, 
2051                 array( 
2052                         'select_submit'=> $submit_on_change
2053                 ) );
2054         echo "</td></tr>\n";
2055 }
2056
2057 function quick_entry_types_list_row($label, $name, $selected_id=null, $submit_on_change=false)
2058 {
2059         global $quick_entry_types;
2060                 
2061         echo "<tr><td>$label</td><td>";
2062         array_selector($name, $selected_id, $quick_entry_types, 
2063                 array( 
2064                         'select_submit'=> $submit_on_change
2065                         ) );
2066         echo "</td></tr>\n";
2067 }
2068
2069
2070 function class_types_list_row($label, $name, $selected_id=null, $submit_on_change=false)
2071 {
2072         global $class_types;
2073         
2074         echo "<tr><td>$label</td><td>";
2075         array_selector($name, $selected_id, $class_types, 
2076                 array( 
2077                         'select_submit'=> $submit_on_change
2078                 ) );
2079         echo "</td></tr>\n";
2080 }
2081
2082
2083 ?>