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