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");
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")."'> ";
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")."'> ";
23 $all_items = reserved_words::get_all();
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.
30 function combo_input($name, $selected_id, $sql, $valfield, $namefield,
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
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
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
61 'box_hint' => null, // box/selectors hints; null = std see below
62 'category' => false // category column name or false
64 // ------ merge options with defaults ----------
66 $opts = array_merge($opts, $options);
67 if (!is_array($opts['where'])) $opts['where'] = array($opts['where']);
69 $search_box = $opts['search_box']===true ? '_'.$name.'_edit' : $opts['search_box'];
70 $search_submit = $opts['search_submit']===true ? '_'.$name.'_button' : $opts['search_submit'];
71 $select_submit = $opts['select_submit']===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" : '';
78 if(!count($opts['search'])) {
79 $opts['search'] = array($by_id ? $valfield : $namefield);
81 if ($opts['sel_hint'] === null)
82 $opts['sel_hint'] = $by_id || $search_box==false ?
83 '' : _('Press Space tab for search pattern entry');
85 if ($opts['box_hint'] === null)
86 $opts['box_hint'] = $search_box && $search_submit != false ?
87 ($by_id ? _('Enter code fragment to search or * for all')
88 : _('Enter description fragment to search or * for all')) :'';
90 if ($selected_id == null) {
91 $selected_id = get_post($name, $opts['default']);
93 $txt = get_post($search_box);
97 if (isset($_POST[$select_submit])) {
98 if ($by_id) $txt = $_POST[$name];
101 $Ajax->activate('_page_body');
103 $Ajax->activate($name);
106 // search related sql modifications
108 $rel = "rel='$search_box'"; // set relation to list
109 if ($opts['search_submit']) {
110 if (isset($_POST[$search_submit])) {
111 $selected_id = ''; // ignore selected_id while search
113 $Ajax->activate('_page_body');
115 $Ajax->activate($name);
118 if ($spec_option === false && $selected_id==null)
121 $opts['where'][] = $valfield . "='". get_post($name, $spec_id)."'";
126 foreach($opts['search'] as $i=> $s)
127 $opts['search'][$i] = $s . " LIKE '%{$txt}%'";
128 $opts['where'][] = '('. implode($opts['search'], ' OR ') . ')';
133 if (count($opts['where'])) {
134 $where = strpos($sql, 'WHERE')==false ? ' WHERE ':' AND ';
135 $where .= '('. implode($opts['where'], ' AND ') . ')';
136 $group_pos = strpos($sql, 'GROUP BY');
138 $group = substr($sql, $group_pos);
139 $sql = substr($sql, 0, $group_pos) . $where.' '.$group;
144 if ($opts['order'] != false) {
145 if (!is_array($opts['order']))
146 $opts['order'] = array($opts['order']);
147 $sql .= ' ORDER BY '.implode(',',$opts['order']);
151 // ------ make selector ----------
152 $selector = $first_opt = '';
156 //if($name=='stock_id') display_error($sql);
157 if($result = db_query($sql)) {
158 while ($contact_row = db_fetch($result)) {
159 $value = $contact_row[0];
160 $descr = $opts['format']==null ? $contact_row[1] :
161 call_user_func($opts['format'], $contact_row);
163 if (get_post($search_submit) && ($txt === $value)) {
164 $selected_id = $value;
166 if ((string)($selected_id) === $value) {
170 if ($first_id === false) {
174 $cat = $contact_row[$opts['category']];
175 if ($opts['category'] !== false && $cat != $lastcat){
176 $selector .= "<optgroup label='".$cat."'>\n";
179 $selector .= "<option $sel value='$value'>$descr</option>\n";
181 db_free_result($result);
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"
193 if ($found === false) {
194 $selected_id = $first_id;
196 $_POST[$name] = $selected_id;
198 if ($by_id && $search_box != false) {
200 $Ajax->addUpdate($name, $search_box, $txt ? $txt : '');
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";
206 $Ajax->addUpdate($name, "_{$name}_sel", $selector);
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";
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";
219 // ------ make combo ----------
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;":'')
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";
236 default_focus(($search_box && $by_id) ? $search_box : $name);
238 if ($search_box && $opts['cells'])
239 echo ($edit_entry!='' ? "<td>$edit_entry</td>" : '')."<td>$selector</td>";
241 echo $edit_entry.$selector;
248 Returns true if selector $name is subject to update.
250 function list_updated($name)
252 return isset($_POST['_'.$name.'_update']) || isset($_POST['_'.$name.'_button']);
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.
259 function array_selector($name, $selected_id, $items, $options=null)
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
274 // ------ merge options with defaults ----------
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" : '';
282 if ($selected_id == null) {
283 $selected_id = get_post($name, $opts['default']);
286 if (isset($_POST[$select_submit])) {
288 $Ajax->activate('_page_body');
290 $Ajax->activate($name);
293 // ------ make selector ----------
294 $selector = $first_opt = '';
297 //if($name=='SelectStockFromList') display_error($sql);
298 foreach($items as $value=>$descr) {
300 if ((string)$selected_id === (string)$value) {
304 if ($first_id === false) {
308 $selector .= "<option $sel value='$value'>$descr</option>\n";
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"
320 if ($found === false) {
321 $selected_id = $first_id;
323 $_POST[$name] = $selected_id;
325 $aspect = $opts['edit_submit'] ? " aspect='editable'" : '';
326 $selector = "<select $disabled name='$name' class='combo' title='"
327 . $opts['sel_hint']."'$aspect >".$selector."</select>\n";
329 $Ajax->addUpdate($name, "_{$name}_sel", $selector);
331 $selector = "<span id='_{$name}_sel'>".$selector."</span>\n";
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";
339 default_focus($name);
344 //----------------------------------------------------------------------------------------------
346 function _format_add_curr($row)
348 static $company_currency;
350 if ($company_currency == null)
352 $company_currency = get_company_currency();
354 return $row[1] . ($row[2] == $company_currency ?
355 '' : (" - " . $row[2]));
358 function supplier_list($name, $selected_id=null, $spec_option=false, $submit_on_change=false)
362 $sql = "SELECT supplier_id, supp_name, curr_code FROM ".TB_PREF."suppliers ";
364 $mode = get_company_pref('no_supplier_list');
366 return combo_input($name, $selected_id, $sql, 'supplier_id', 'supp_name',
368 'format' => '_format_add_curr',
369 'search_box' => $mode!=0,
370 'edit_submit' => true,
372 'spec_option' => $spec_option === true ? _("All Suppliers") : $spec_option,
373 'spec_id' => $all_items,
374 'select_submit'=> $submit_on_change,
376 'sel_hint' => $mode ? _('Press Space tab to filter by name fragment') :
381 function supplier_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
384 echo "<td>$label</td><td>\n";
385 $str = supplier_list($name, $selected_id, $all_option, $submit_on_change);
390 function supplier_list_row($label, $name, $selected_id=null, $all_option = false, $submit_on_change=false)
392 echo "<tr><td>$label</td><td>";
393 $str = supplier_list($name, $selected_id, $all_option, $submit_on_change );
397 //----------------------------------------------------------------------------------------------
399 function customer_list($name, $selected_id=null, $spec_option=false, $submit_on_change=false)
403 $sql = "SELECT debtor_no, name, curr_code FROM ".TB_PREF."debtors_master ";
405 $mode = get_company_pref('no_customer_list');
407 return combo_input($name, $selected_id, $sql, 'debtor_no', 'name',
409 'format' => '_format_add_curr',
410 'search_box' => $mode!=0,
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
418 'sel_hint' => $mode ? _('Press Space tab to filter by name fragment; F4 - entry new customer') :
423 function customer_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
426 echo "<td>$label</td>\n";
428 $str = customer_list($name, $selected_id, $all_option, $submit_on_change);
433 function customer_list_row($label, $name, $selected_id=null, $all_option = false, $submit_on_change=false)
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";
441 //------------------------------------------------------------------------------------------------
443 function customer_branches_list($customer_id, $name, $selected_id=null,
444 $spec_option = true, $enabled=true, $submit_on_change=false)
448 $sql = "SELECT branch_code, br_name FROM ".TB_PREF."cust_branch
449 WHERE debtor_no='" . $customer_id . "' ";
451 $where = $enabled ? array("disable_trans = 0") : array();
452 return combo_input($name, $selected_id, $sql, 'branch_code', 'br_name',
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')
461 //------------------------------------------------------------------------------------------------
463 function customer_branches_list_cells($label,$customer_id, $name, $selected_id=null, $all_option = true, $enabled=true, $submit_on_change=false)
466 echo "<td>$label</td>\n";
468 $ret = customer_branches_list($customer_id, $name, $selected_id, $all_option, $enabled, $submit_on_change);
473 function customer_branches_list_row($label,$customer_id, $name, $selected_id=null, $all_option = true, $enabled=true, $submit_on_change=false)
476 $ret = customer_branches_list_cells($label, $customer_id, $name, $selected_id, $all_option, $enabled, $submit_on_change);
481 //------------------------------------------------------------------------------------------------
483 function locations_list($name, $selected_id=null, $all_option=false, $submit_on_change=false)
487 $sql = "SELECT loc_code, location_name FROM ".TB_PREF."locations";
489 return combo_input($name, $selected_id, $sql, 'loc_code', 'location_name',
491 'spec_option' => $all_option === true ? _("All Locations") : $all_option,
492 'spec_id' => $all_items,
493 'select_submit'=> $submit_on_change
497 function locations_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
500 echo "<td>$label</td>\n";
502 $str = locations_list($name, $selected_id, $all_option, $submit_on_change);
507 function locations_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
510 $str = locations_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
515 //-----------------------------------------------------------------------------------------------
517 function currencies_list($name, $selected_id=null, $submit_on_change=false)
519 $sql = "SELECT curr_abrev, currency FROM ".TB_PREF."currencies";
521 // default to the company currency
523 return combo_input($name, $selected_id, $sql, 'curr_abrev', 'currency',
525 'select_submit'=> $submit_on_change,
526 'default' => get_company_currency(),
531 function currencies_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
534 echo "<td>$label</td>\n";
536 $str = currencies_list($name, $selected_id, $submit_on_change);
541 function currencies_list_row($label, $name, $selected_id=null, $submit_on_change=false)
544 $str = currencies_list_cells($label, $name, $selected_id, $submit_on_change);
549 //---------------------------------------------------------------------------------------------------
551 function fiscalyears_list($name, $selected_id=null, $submit_on_change=false)
554 $sql = "SELECT * FROM ".TB_PREF."fiscal_year";
556 // default to the company current fiscal year
558 return combo_input($name, $selected_id, $sql, 'id', '',
561 'default' => get_company_pref('f_year'),
562 'format' => '_format_fiscalyears',
563 'select_submit'=> $submit_on_change,
568 function _format_fiscalyears($row)
570 return sql2date($row[1]) . " - " . sql2date($row[2])
571 . " " . ($row[3] ? _('Closed') : _('Active')) . "</option>\n";
574 function fiscalyears_list_cells($label, $name, $selected_id=null)
577 echo "<td>$label</td>\n";
579 $str = fiscalyears_list($name, $selected_id);
584 function fiscalyears_list_row($label, $name, $selected_id=null)
587 $str = fiscalyears_list_cells($label, $name, $selected_id);
591 //------------------------------------------------------------------------------------
593 function dimensions_list($name, $selected_id=null, $no_option=false, $showname=' ',
594 $submit_on_change=false, $showclosed=false, $showtype=1)
596 $sql = "SELECT id, CONCAT(reference,' ',name) as ref FROM ".TB_PREF."dimensions";
599 'order' => 'reference',
600 'spec_option'=>$no_option ? $showname : false,
602 'select_submit'=> $submit_on_change,
607 $options['where'][] = "closed=0";
609 $options['where'][] = "type_=$showtype";
611 return combo_input($name, $selected_id, $sql, 'id', 'ref', $options);
614 function dimensions_list_cells($label, $name, $selected_id=null, $no_option=false, $showname=null,
615 $showclosed=false, $showtype=0, $submit_on_change=false)
618 echo "<td>$label</td>\n";
620 $str = dimensions_list($name, $selected_id, $no_option, $showname, $submit_on_change, $showclosed, $showtype);
625 function dimensions_list_row($label, $name, $selected_id=null, $no_option=false, $showname=null,
626 $showclosed=false, $showtype=0, $submit_on_change=false)
629 $str = dimensions_list_cells($label, $name, $selected_id, $no_option, $showname,
630 $showclosed, $showtype, $submit_on_change);
635 //---------------------------------------------------------------------------------------------------
637 function stock_items_list($name, $selected_id=null, $all_option=false, $submit_on_change=false, $opts=array())
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";
644 return combo_input($name, $selected_id, $sql, 'stock_id', 's.description',
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,
654 'select_submit'=> $submit_on_change,
656 'order' => array('c.description','stock_id')
660 function _format_stock_items($row)
662 return (user_show_codes() ? ($row[0] . " - ") : "") . $row[1];
665 function stock_items_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
668 echo "<td>$label</td>\n";
669 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
670 array('cells'=>true));
674 function stock_items_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
677 $str = stock_items_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
682 //---------------------------------------------------------------------------------------------------
684 // Select item via foreign code.
686 function sales_items_list($name, $selected_id=null, $all_option=false,
687 $submit_on_change=false, $type='', $opts=array())
691 $sql = "SELECT i.item_code, i.description, c.description, count(*)>1 as kit
693 ".TB_PREF."item_codes i
695 ".TB_PREF."stock_category c
696 ON i.category_id=c.category_id";
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";
704 $sql .= " GROUP BY i.item_code";
706 return combo_input($name, $selected_id, $sql, 'i.item_code', 'c.description',
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,
716 'select_submit'=> $submit_on_change,
718 'order' => array('c.description','i.item_code')
722 function sales_items_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
725 echo "<td>$label</td>\n";
726 $str = sales_items_list($name, $selected_id, $all_option, $submit_on_change,
727 '', array('cells'=>true));
731 function sales_kits_list($name, $selected_id=null, $all_option=false, $submit_on_change=false)
733 $str = sales_items_list($name, $selected_id, $all_option, $submit_on_change,
734 'kits', array('cells'=>false));
738 function sales_local_items_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
742 echo "<td>$label</td>\n";
744 $str = sales_items_list($name, $selected_id, $all_option, $submit_on_change,
745 'local', array('cells'=>false));
749 //------------------------------------------------------------------------------------
751 function base_stock_items_list($where, $name, $selected_id=null,
752 $all_option=false, $submit_on_change=false)
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";
760 return combo_input($name, $selected_id, $sql, 'stock_id', 's.description',
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,
769 //------------------------------------------------------------------------------------
771 function stock_bom_items_list($name, $selected_id=null, $all_option=false, $submit_on_change=false)
774 return base_stock_items_list("s.mb_flag='M'",
775 $name, $selected_id, $all_option, $submit_on_change);
778 function stock_bom_items_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
781 echo "<td>$label</td>\n";
783 $str = stock_bom_items_list($name, $selected_id, $all_option, $submit_on_change);
788 function stock_bom_items_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
791 $str = stock_bom_items_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
796 //------------------------------------------------------------------------------------
798 function stock_manufactured_items_list($name, $selected_id=null,
799 $all_option=false, $submit_on_change=false)
801 return base_stock_items_list("s.mb_flag='M'",
802 $name, $selected_id, $all_option, $submit_on_change);
805 function stock_manufactured_items_list_cells($label, $name, $selected_id=null,
806 $all_option=false, $submit_on_change=false)
809 echo "<td>$label</td>\n";
811 $str = stock_manufactured_items_list($name, $selected_id, $all_option,
817 function stock_manufactured_items_list_row($label, $name, $selected_id=null,
818 $all_option=false, $submit_on_change=false)
822 echo "<td>$label</td>\n";
824 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
825 array('where'=>array("mb_flag = 'M'"),
826 'edit_submit' => true));
827 //$str = stock_manufactured_items_list_cells($label, $name, $selected_id,
828 // $all_option, $submit_on_change);
833 //------------------------------------------------------------------------------------
835 function stock_component_items_list($name, $parent_stock_id, $selected_id=null,
836 $all_option=false, $submit_on_change=false)
838 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
839 array('where'=>array("stock_id != '$parent_stock_id'")));
843 function stock_component_items_list_cells($label, $name, $parent_stock_id,
844 $selected_id=null, $all_option=false, $submit_on_change=false)
847 echo "<td>$label</td>\n";
848 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
849 array('where'=>array("stock_id != '$parent_stock_id'"), 'cells'=>true));
852 //------------------------------------------------------------------------------------
854 function stock_costable_items_list($name, $selected_id=null,
855 $all_option=false, $submit_on_change=false)
857 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
858 array('where'=>array("mb_flag!='D'")));
862 function stock_costable_items_list_cells($label, $name, $selected_id=null,
863 $all_option=false, $submit_on_change=false)
866 echo "<td>$label</td>\n";
867 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
868 array('where'=>array("mb_flag!='D'"), 'cells'=>true));
872 //------------------------------------------------------------------------------------
873 function stock_purchasable_items_list($name, $selected_id=null,
874 $all_option=false, $submit_on_change=false)
876 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
877 array('where'=>array("mb_flag!= 'M'"),
878 'edit_submit' => true));
882 function stock_purchasable_items_list_cells($label, $name, $selected_id=null,
883 $all_option=false, $submit_on_change=false)
886 echo "<td>$label</td>\n";
887 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
888 array('where'=>array("mb_flag!= 'M'"),
889 'edit_submit' => true,
894 function stock_purchasable_items_list_row($label, $name, $selected_id=null,
895 $all_option=false, $submit_on_change=false)
898 $ret = stock_purchasable_items_list_cells($label, $name, $selected_id=null,
899 $all_option, $submit_on_change);
904 //------------------------------------------------------------------------------------
906 function stock_item_types_list_row($label, $name, $selected_id=null, $enabled=true)
909 'M' => _("Manufactured"),
910 'B' => _("Purchased"),
916 echo "<td>$label</td>\n";
919 array_selector($name, $selected_id, $types,
921 'select_submit'=> true,
922 'disabled' => !$enabled) );
926 function stock_units_list_row($label, $name, $value=null, $enabled=true)
928 $result = get_all_item_units();
931 echo "<td>$label</td>\n";
934 while($unit = db_fetch($result))
935 $units[$unit['abbr']] = $unit['name'];
937 array_selector($name, $value, $units,
939 'select_submit'=> true,
940 'disabled' => !$enabled) );
945 //------------------------------------------------------------------------------------
947 function tax_types_list($name, $selected_id=null, $none_option=false, $submit_on_change=false)
949 $sql = "SELECT id, CONCAT(name, ' (',rate,'%)') as name FROM ".TB_PREF."tax_types";
951 return combo_input($name, $selected_id, $sql, 'id', 'name',
953 'spec_option' => $none_option,
954 'spec_id' => reserved_words::get_all_numeric(),
955 'select_submit'=> $submit_on_change,
960 function tax_types_list_cells($label, $name, $selected_id=null, $none_option=false,
961 $submit_on_change=false)
964 echo "<td>$label</td>\n";
966 $str = tax_types_list($name, $selected_id, $none_option, $submit_on_change);
971 function tax_types_list_row($label, $name, $selected_id=null, $none_option=false,
972 $submit_on_change=false)
975 $str = tax_types_list_cells($label, $name, $selected_id, $none_option, $submit_on_change);
980 //------------------------------------------------------------------------------------
982 function tax_groups_list($name, $selected_id=null,
983 $none_option=false, $submit_on_change=false)
985 $sql = "SELECT id, name FROM ".TB_PREF."tax_groups";
987 return combo_input($name, $selected_id, $sql, 'id', 'name',
990 'spec_option' => $none_option,
991 'spec_id' => reserved_words::get_all_numeric(),
992 'select_submit'=> $submit_on_change,
997 function tax_groups_list_cells($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false)
1000 echo "<td>$label</td>\n";
1002 $str = tax_groups_list($name, $selected_id, $none_option, $submit_on_change);
1007 function tax_groups_list_row($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false)
1010 $str = tax_groups_list_cells($label, $name, $selected_id, $none_option, $submit_on_change);
1015 //------------------------------------------------------------------------------------
1017 function item_tax_types_list($name, $selected_id=null)
1019 $sql ="SELECT id, name FROM ".TB_PREF."item_tax_types";
1020 combo_input($name, $selected_id, $sql, 'id', 'name', array('order' => 'id') );
1023 function item_tax_types_list_cells($label, $name, $selected_id=null)
1026 echo "<td>$label</td>\n";
1028 item_tax_types_list($name, $selected_id);
1032 function item_tax_types_list_row($label, $name, $selected_id=null)
1035 item_tax_types_list_cells($label, $name, $selected_id);
1039 //------------------------------------------------------------------------------------
1041 function shippers_list($name, $selected_id=null)
1043 $sql = "SELECT shipper_id, shipper_name FROM ".TB_PREF."shippers";
1044 combo_input($name, $selected_id, $sql, 'shipper_id', 'shipper_name', array());
1047 function shippers_list_cells($label, $name, $selected_id=null)
1050 echo "<td>$label</td>\n";
1052 shippers_list($name, $selected_id);
1056 function shippers_list_row($label, $name, $selected_id=null)
1059 shippers_list_cells($label, $name, $selected_id);
1063 //-------------------------------------------------------------------------------------
1065 function sales_persons_list($name, $selected_id=null)
1067 $sql = "SELECT salesman_code, salesman_name FROM ".TB_PREF."salesman";
1068 combo_input($name, $selected_id, $sql, 'salesman_code', 'salesman_name', array());
1071 function sales_persons_list_cells($label, $name, $selected_id=null)
1074 echo "<td>$label</td>\n";
1076 sales_persons_list($name, $selected_id);
1080 function sales_persons_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1083 sales_persons_list_cells($label, $name, $selected_id, $submit_on_change=false);
1087 //------------------------------------------------------------------------------------
1089 function sales_areas_list($name, $selected_id=null)
1091 $sql = "SELECT area_code, description FROM ".TB_PREF."areas";
1092 combo_input($name, $selected_id, $sql, 'area_code', 'description', array());
1095 function sales_areas_list_cells($label, $name, $selected_id=null)
1098 echo "<td>$label</td>\n";
1100 sales_areas_list($name, $selected_id);
1104 function sales_areas_list_row($label, $name, $selected_id=null)
1107 sales_areas_list_cells($label, $name, $selected_id);
1111 //------------------------------------------------------------------------------------
1113 function sales_groups_list($name, $selected_id=null, $special_option=false)
1115 $sql = "SELECT id, description FROM ".TB_PREF."groups";
1116 combo_input($name, $selected_id, $sql, 'id', 'description', array(
1117 'spec_option' => $special_option===true ? ' ' : $special_option,
1118 'order' => 'description', 'spec_id' => 0,
1122 function sales_groups_list_cells($label, $name, $selected_id=null, $special_option=false)
1125 echo "<td>$label</td>\n";
1127 sales_groups_list($name, $selected_id, $special_option);
1131 function sales_groups_list_row($label, $name, $selected_id=null, $special_option=false)
1134 sales_groups_list_cells($label, $name, $selected_id, $special_option);
1138 //------------------------------------------------------------------------------------
1140 function _format_template_items($row)
1142 return ($row[0] . " - " . _("Amount") . " ".$row[1]);
1145 function templates_list($name, $selected_id=null, $special_option=false)
1147 $sql = "SELECT sorder.order_no, Sum(line.unit_price*line.quantity*(1-line.discount_percent)) AS OrderValue
1148 FROM ".TB_PREF."sales_orders as sorder, ".TB_PREF."sales_order_details as line
1149 WHERE sorder.order_no = line.order_no AND sorder.type = 1 GROUP BY line.order_no";
1150 combo_input($name, $selected_id, $sql, 'order_no', 'OrderValue', array(
1151 'format' => '_format_template_items',
1152 'spec_option' => $special_option===true ? ' ' : $special_option,
1153 'order' => 'order_no', 'spec_id' => 0,
1157 function templates_list_cells($label, $name, $selected_id=null, $special_option=false)
1160 echo "<td>$label</td>\n";
1162 templates_list($name, $selected_id, $special_option);
1166 function templates_list_row($label, $name, $selected_id=null, $special_option=false)
1169 templates_list_cells($label, $name, $selected_id, $special_option);
1173 //------------------------------------------------------------------------------------
1175 function workorders_list($name, $selected_id=null)
1177 $sql = "SELECT id, wo_ref FROM ".TB_PREF."workorders WHERE closed=0";
1178 combo_input($name, $selected_id, $sql, 'id', 'wo_ref', array());
1181 function workorders_list_cells($label, $name, $selected_id=null)
1184 echo "<td>$label</td>\n";
1186 workorders_list($name, $selected_id);
1190 function workorders_list_row($label, $name, $selected_id=null)
1193 workorders_list_cells($label, $name, $selected_id);
1197 //------------------------------------------------------------------------------------
1199 function payment_terms_list($name, $selected_id=null)
1201 $sql = "SELECT terms_indicator, terms FROM ".TB_PREF."payment_terms";
1202 combo_input($name, $selected_id, $sql, 'terms_indicator', 'terms', array());
1205 function payment_terms_list_cells($label, $name, $selected_id=null)
1208 echo "<td>$label</td>\n";
1210 payment_terms_list($name, $selected_id);
1214 function payment_terms_list_row($label, $name, $selected_id=null)
1217 payment_terms_list_cells($label, $name, $selected_id);
1221 //------------------------------------------------------------------------------------
1223 function credit_status_list($name, $selected_id=null)
1225 $sql ="SELECT id, reason_description FROM ".TB_PREF."credit_status";
1226 combo_input($name, $selected_id, $sql, 'id', 'reason_description', array());
1229 function credit_status_list_cells($label, $name, $selected_id=null)
1232 echo "<td>$label</td>\n";
1234 credit_status_list($name, $selected_id);
1238 function credit_status_list_row($label, $name, $selected_id=null)
1241 credit_status_list_cells($label, $name, $selected_id);
1245 //-----------------------------------------------------------------------------------------------
1247 function sales_types_list($name, $selected_id=null, $submit_on_change=false, $special_option=false)
1249 $sql = "SELECT id, sales_type FROM ".TB_PREF."sales_types";
1251 return combo_input($name, $selected_id, $sql, 'id', 'sales_type',
1253 'spec_option' => $special_option===true ? _("All Sales Types") : $special_option,
1255 'select_submit'=> $submit_on_change,
1256 // 'async' => false,
1260 function sales_types_list_cells($label, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1263 echo "<td>$label</td>\n";
1265 $str = sales_types_list($name, $selected_id, $submit_on_change, $special_option);
1270 function sales_types_list_row($label, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1273 $str = sales_types_list_cells($label, $name, $selected_id, $submit_on_change, $special_option);
1278 //-----------------------------------------------------------------------------------------------
1280 function movement_types_list($name, $selected_id=null)
1282 $sql = "SELECT id, name FROM ".TB_PREF."movement_types";
1283 combo_input($name, $selected_id, $sql, 'id', 'name', array());
1286 function movement_types_list_cells($label, $name, $selected_id=null)
1289 echo "<td>$label</td>\n";
1291 movement_types_list($name, $selected_id);
1295 function movement_types_list_row($label, $name, $selected_id=null)
1298 movement_types_list_cells($label, $name, $selected_id);
1302 //-----------------------------------------------------------------------------------------------
1303 function _format_date($row)
1305 return sql2date($row['reconciled']);
1308 function bank_reconciliation_list($account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1310 $sql = "SELECT reconciled, reconciled FROM ".TB_PREF."bank_trans
1311 WHERE bank_act=".db_escape($account)." AND reconciled IS NOT NULL
1312 GROUP BY reconciled";
1313 combo_input($name, $selected_id, $sql, 'id', 'reconciled',
1315 'spec_option' => $special_option,
1316 'format' => '_format_date',
1318 'select_submit'=> $submit_on_change
1322 function bank_reconciliation_list_cells($label,$account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1325 echo "<td>$label</td>\n";
1327 bank_reconciliation_list($account, $name, $selected_id, $submit_on_change, $special_option);
1331 function bank_reconciliation_list_row($label, $account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1334 bank_reconciliation_list_cells($label, $account, $name, $selected_id, $submit_on_change, $special_option);
1338 //-----------------------------------------------------------------------------------------------
1340 function workcenter_list($name, $selected_id=null, $all_option=false)
1344 $sql = "SELECT id, name FROM ".TB_PREF."workcentres";
1346 return combo_input($name, $selected_id, $sql, 'id', 'name',
1348 'spec_option' =>$all_option===true ? _("All Suppliers") : $all_option,
1349 'spec_id' => $all_items,
1353 function workcenter_list_cells($label, $name, $selected_id=null, $all_option=false)
1355 default_focus($name);
1357 echo "<td>$label</td>\n";
1359 workcenter_list($name, $selected_id, $all_option);
1363 function workcenter_list_row($label, $name, $selected_id=null, $all_option=false)
1366 workcenter_list_cells($label, $name, $selected_id, $all_option);
1370 //-----------------------------------------------------------------------------------------------
1372 function bank_accounts_list($name, $selected_id=null, $submit_on_change=false)
1374 $sql = "SELECT ".TB_PREF."bank_accounts.id, bank_account_name, bank_curr_code
1375 FROM ".TB_PREF."bank_accounts";
1376 // , ".TB_PREF."chart_master
1377 // WHERE ".TB_PREF."bank_accounts.account_code=".TB_PREF."chart_master.account_code";
1379 return combo_input($name, $selected_id, $sql, 'id', 'bank_account_name',
1381 'format' => '_format_add_curr',
1382 'select_submit'=> $submit_on_change,
1387 function bank_accounts_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1390 echo "<td>$label</td>\n";
1392 $str = bank_accounts_list($name, $selected_id, $submit_on_change);
1397 function bank_accounts_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1400 $str = bank_accounts_list_cells($label, $name, $selected_id, $submit_on_change);
1404 //-----------------------------------------------------------------------------------------------
1406 function cash_accounts_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1408 $sql = "SELECT ".TB_PREF."bank_accounts.id, bank_account_name, bank_curr_code
1409 FROM ".TB_PREF."bank_accounts
1410 WHERE ".TB_PREF."bank_accounts.account_type=3";
1413 echo "<tr><td>$label</td>\n";
1415 $str = combo_input($name, $selected_id, $sql, 'id', 'bank_account_name',
1417 'format' => '_format_add_curr',
1418 'select_submit'=> $submit_on_change,
1421 echo "</td></tr>\n";
1424 //-----------------------------------------------------------------------------------------------
1426 function pos_list_row($label, $name, $selected_id=null, $spec_option=false, $submit_on_change=false)
1428 $sql = "SELECT id, pos_name FROM ".TB_PREF."sales_pos";
1430 default_focus($name);
1433 echo "<td>$label</td>\n";
1436 $str = combo_input($name, $selected_id, $sql, 'id', 'pos_name',
1438 'select_submit'=> $submit_on_change,
1440 'spec_option' =>$spec_option,
1443 echo "</td></tr>\n";
1447 //-----------------------------------------------------------------------------------------------
1449 function sale_payment_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1452 echo "<td>$label</td>\n";
1454 $str = yesno_list($name, $selected_id, _('Cash'), _('Delayed'), $submit_on_change);
1458 //-----------------------------------------------------------------------------------------------
1460 function class_list($name, $selected_id=null, $submit_on_change=false)
1462 $sql = "SELECT cid, class_name FROM ".TB_PREF."chart_class";
1464 return combo_input($name, $selected_id, $sql, 'cid', 'class_name',
1466 'select_submit'=> $submit_on_change,
1472 function class_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1475 echo "<td>$label</td>\n";
1477 $str = class_list($name, $selected_id, $submit_on_change);
1482 function class_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1485 $str = class_list_cells($label, $name, $selected_id, $submit_on_change);
1490 //-----------------------------------------------------------------------------------------------
1492 function stock_categories_list($name, $selected_id=null)
1494 $sql = "SELECT category_id, description FROM ".TB_PREF."stock_category";
1495 combo_input($name, $selected_id, $sql, 'category_id', 'description',
1496 array('order'=>'category_id'));
1499 function stock_categories_list_cells($label, $name, $selected_id=null)
1502 echo "<td>$label</td>\n";
1504 stock_categories_list($name, $selected_id);
1508 function stock_categories_list_row($label, $name, $selected_id=null)
1511 stock_categories_list_cells($label, $name, $selected_id);
1515 //-----------------------------------------------------------------------------------------------
1517 function gl_account_types_list($name, $selected_id=null, $all_option, $all_option_numeric)
1521 $sql = "SELECT id, name FROM ".TB_PREF."chart_types";
1523 combo_input($name, $selected_id, $sql, 'id', 'name',
1526 'spec_option' =>$all_option,
1527 'spec_id' => $all_option_numeric ? 0 : $all_items
1531 function gl_account_types_list_cells($label, $name, $selected_id=null, $all_option=false,
1532 $all_option_numeric=false)
1535 echo "<td>$label</td>\n";
1537 gl_account_types_list($name, $selected_id, $all_option, $all_option_numeric);
1541 function gl_account_types_list_row($label, $name, $selected_id=null, $all_option=false,
1542 $all_option_numeric=false)
1545 gl_account_types_list_cells($label, $name, $selected_id, $all_option,
1546 $all_option_numeric);
1550 //-----------------------------------------------------------------------------------------------
1551 function gl_all_accounts_list($name, $selected_id=null, $skip_bank_accounts=false,
1552 $cells=false, $all_option=false, $submit_on_change=false)
1554 if ($skip_bank_accounts)
1555 $sql = "SELECT chart.account_code, chart.account_name, type.name
1556 FROM (".TB_PREF."chart_master chart,".TB_PREF."chart_types type) "
1557 ."LEFT JOIN ".TB_PREF."bank_accounts acc "
1558 ."ON chart.account_code=acc.account_code
1559 WHERE acc.account_code IS NULL
1560 AND chart.account_type=type.id";
1562 $sql = "SELECT chart.account_code, chart.account_name, type.name
1563 FROM ".TB_PREF."chart_master chart,".TB_PREF."chart_types type
1564 WHERE chart.account_type=type.id";
1566 combo_input($name, $selected_id, $sql, 'chart.account_code', 'chart.account_name',
1568 'format' => '_format_account',
1569 'spec_option' => $all_option===true ? _("Use Item Sales Accounts") : $all_option,
1571 'order' => array('name','account_code'),
1572 'search_box' => $cells,
1573 'search_submit' => false,
1577 'select_submit'=> $submit_on_change,
1584 function _format_account($row)
1586 return $row[0] . " " . $row[1];
1589 function gl_all_accounts_list_cells($label, $name, $selected_id=null,
1590 $skip_bank_accounts=false, $cells=false, $all_option=false)
1593 echo "<td>$label</td>\n";
1595 gl_all_accounts_list($name, $selected_id,
1596 $skip_bank_accounts, $cells, $all_option);
1600 function gl_all_accounts_list_row($label, $name, $selected_id=null,
1601 $skip_bank_accounts=false, $cells=false, $all_option=false)
1604 gl_all_accounts_list_cells($label, $name, $selected_id,
1605 $skip_bank_accounts, $cells, $all_option);
1609 function yesno_list($name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1612 $items['0'] = strlen($name_no) ? $name_no : _("No");
1613 $items['1'] = strlen($name_yes) ? $name_yes : _("Yes");
1615 return array_selector($name, $selected_id, $items,
1617 'select_submit'=> $submit_on_change,
1618 'async' => false ) ); // FIX?
1621 function yesno_list_cells($label, $name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1624 echo "<td>$label</td>\n";
1626 $str = yesno_list($name, $selected_id, $name_yes, $name_no, $submit_on_change);
1631 function yesno_list_row($label, $name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1634 $str = yesno_list_cells($label, $name, $selected_id, $name_yes, $name_no, $submit_on_change);
1639 //------------------------------------------------------------------------------------------------
1641 function languages_list($name, $selected_id=null)
1643 global $installed_languages;
1646 foreach ($installed_languages as $lang)
1647 $items[$lang['code']] = $lang['name'];
1649 return array_selector($name, $selected_id, $items );
1652 function languages_list_cells($label, $name, $selected_id=null)
1655 echo "<td>$label</td>\n";
1657 languages_list($name, $selected_id);
1661 function languages_list_row($label, $name, $selected_id=null)
1664 languages_list_cells($label, $name, $selected_id);
1668 //------------------------------------------------------------------------------------------------
1670 function bank_account_types_list($name, $selected_id=null)
1672 $types = bank_account_types::get_all();
1675 foreach ($types as $type)
1677 $items[$type['id']] = $type['name'];
1680 return array_selector($name, $selected_id, $items );
1683 function bank_account_types_list_cells($label, $name, $selected_id=null)
1686 echo "<td>$label</td>\n";
1688 bank_account_types_list($name, $selected_id);
1692 function bank_account_types_list_row($label, $name, $selected_id=null)
1695 bank_account_types_list_cells($label, $name, $selected_id);
1699 //------------------------------------------------------------------------------------------------
1700 function payment_person_types_list($name, $selected_id=null, $submit_on_change=false)
1702 $types = payment_person_types::get_all();
1705 foreach ($types as $type)
1707 if (payment_person_types::has_items($type['id']))
1709 if ($type['id'] != payment_person_types::WorkOrder())
1710 $items[$type['id']] = $type['name'];
1714 return array_selector($name, $selected_id, $items,
1715 array( 'select_submit'=> $submit_on_change ) );
1718 function payment_person_types_list_cells($label, $name, $selected_id=null, $related=null)
1721 echo "<td>$label</td>\n";
1723 $str = payment_person_types_list($name, $selected_id, $related);
1728 function payment_person_types_list_row($label, $name, $selected_id=null, $related=null)
1731 $str = payment_person_types_list_cells($label, $name, $selected_id, $related);
1736 //------------------------------------------------------------------------------------------------
1738 function wo_types_list($name, $selected_id=null)
1740 $types = wo_types::get_all();
1743 foreach ($types as $type)
1744 $items[$type['id']] = $type['name'];
1746 return array_selector($name, $selected_id, $items,
1747 array( 'select_submit'=> true, 'async' => true ) );
1750 function wo_types_list_row($label, $name, $selected_id=null)
1752 echo "<tr><td>$label</td><td>\n";
1753 $str = wo_types_list($name, $selected_id);
1754 echo "</td></tr>\n";
1758 //------------------------------------------------------------------------------------------------
1760 function dateformats_list_row($label, $name, $value=null)
1762 global $dateformats;
1764 echo "<tr><td>$label</td>\n<td>";
1765 array_selector( $name, $value, $dateformats );
1766 echo "</td></tr>\n";
1769 function dateseps_list_row($label, $name, $value=null)
1773 echo "<tr><td>$label</td>\n<td>";
1774 array_selector( $name, $value, $dateseps );
1775 echo "</td></tr>\n";
1778 function thoseps_list_row($label, $name, $value=null)
1782 echo "<tr><td>$label</td>\n<td>";
1783 array_selector( $name, $value, $thoseps );
1784 echo "</td></tr>\n";
1787 function decseps_list_row($label, $name, $value=null)
1791 echo "<tr><td>$label</td>\n<td>";
1792 array_selector( $name, $value, $decseps );
1793 echo "</td></tr>\n";
1796 function themes_list_row($label, $name, $value=null)
1798 global $path_to_root;
1800 $path = $path_to_root.'/themes/';
1802 $themedir = opendir($path);
1803 while(false !== ($fname = readdir($themedir)))
1805 if($fname!='.' && $fname!='..' && $fname!='CVS' && is_dir($path.$fname))
1807 $themes[$fname] = $fname;
1812 echo "<tr><td>$label</td>\n<td>";
1813 array_selector( $name, $value, $themes );
1814 echo "</td></tr>\n";
1817 function pagesizes_list_row($label, $name, $value=null)
1822 foreach ($pagesizes as $pz)
1825 echo "<tr><td>$label</td>\n<td>";
1826 array_selector( $name, $value, $items );
1827 echo "</td></tr>\n";
1830 function security_headings_list_row($label, $name, $value=null)
1832 global $security_headings;
1834 echo "<tr><td>$label</td>\n<td>";
1835 array_selector( $name, $value, $security_headings );
1836 echo "</td></tr>\n";
1839 function systypes_list_cells($label, $name, $value=null, $submit_on_change=false)
1841 global $systypes_array;
1844 echo "<td>$label</td>\n";
1848 foreach ($systypes_array as $key=>$type)
1849 $items[$key] = $type['name'];
1851 $str = array_selector($name, $value, $items,
1853 'select_submit'=> $submit_on_change,
1861 function systypes_list_row($label, $name, $value=null, $submit_on_change=false)
1864 $str = systypes_list_cells($label, $name, $value, $submit_on_change);
1869 function cust_allocations_list_cells($label, $name, $selected=null)
1877 $all_items=>_("All Types"),
1878 '1'=> _("Sales Invoices"),
1879 '2'=> _("Overdue Invoices"),
1880 '3' => _("Payments"),
1881 '4' => _("Credit Notes"),
1882 '5' => _("Delivery Notes")
1884 $str = array_selector($name, $selected, $allocs);
1889 function supp_allocations_list_cell($name, $selected=null)
1895 $all_items=>_("All Types"),
1896 '1'=> _("Invoices"),
1897 '2'=> _("Overdue Invoices"),
1898 '3' => _("Payments"),
1899 '4' => _("Credit Notes"),
1900 '5' => _("Overdue Credit Notes")
1902 $str = array_selector($name, $selected, $allocs);
1907 function policy_list_cells($label, $name, $selected=null)
1912 $str = array_selector($name, $selected,
1913 array( '' => _("Automatically put balance on back order"),
1914 'CAN' => _("Cancel any quantites not delivered")) );
1919 function policy_list_row($label, $name, $selected=null)
1922 policy_list_cells($label, $name, $selected);
1926 function credit_type_list_cells($label, $name, $selected=null, $submit_on_change=false)
1931 $str = array_selector($name, $selected,
1932 array( 'Return' => _("Items Returned to Inventory Location"),
1933 'WriteOff' => _("Items Written Off")),
1934 array( 'select_submit'=> $submit_on_change ) );
1939 function credit_type_list_row($label, $name, $selected=null, $submit_on_change=false)
1942 $str = credit_type_list_cells($label, $name, $selected, $submit_on_change);
1947 function number_list($name, $selected, $from, $to, $no_option=false)
1950 for ($i = $from; $i <= $to; $i++)
1953 return array_selector($name, $selected, $items,
1954 array( 'spec_option' => $no_option,
1955 'spec_id' => reserved_words::get_all_numeric()) );
1958 function number_list_cells($label, $name, $selected, $from, $to, $no_option=false)
1963 number_list($name, $selected, $from, $to, $no_option);
1967 function number_list_row($label, $name, $selected, $from, $to, $no_option=false)
1970 number_list_cells($label, $name, $selected, $from, $to, $no_option);
1974 function print_profiles_list_row($label, $name, $selected_id=null, $spec_opt=false,
1975 $submit_on_change=true)
1977 $sql = "SELECT profile FROM ".TB_PREF."print_profiles"
1978 ." GROUP BY profile";
1979 $result = db_query($sql, 'cannot get all profile names');
1980 $profiles = array();
1981 while($myrow=db_fetch($result)) {
1982 $profiles[$myrow['profile']] = $myrow['profile'];
1987 echo "<td>$label</td>\n";
1990 array_selector($name, $selected_id, $profiles,
1991 array( 'select_submit'=> $submit_on_change,
1992 'spec_option'=>$spec_opt,
1996 echo "</td></tr>\n";
1999 function printers_list($name, $selected_id=null, $spec_opt=false, $submit_on_change=false)
2001 static $printers; // query only once for page display
2004 $sql = "SELECT id, name, description FROM ".TB_PREF."printers";
2005 $result = db_query($sql, 'cannot get all printers');
2006 $printers = array();
2007 while($myrow=db_fetch($result)) {
2008 $printers[$myrow['id']] = $myrow['name'].' - '.$myrow['description'];
2011 array_selector($name, $selected_id, $printers,
2012 array( 'select_submit'=> $submit_on_change,
2013 'spec_option'=>$spec_opt,
2018 //------------------------------------------------------------------------------------------------
2020 function quick_entries_list($name, $selected_id=null, $type=null, $submit_on_change=false)
2023 $sql = "SELECT id, description FROM ".TB_PREF."quick_entries";
2025 $sql .= " WHERE type=$type";
2027 combo_input($name, $selected_id, $sql, 'id', 'description',
2030 'order' => 'description',
2031 'select_submit'=> $submit_on_change,
2037 function quick_entries_list_cells($label, $name, $selected_id=null, $type, $submit_on_change=false)
2039 echo "<td>$label</td><td>\n";
2040 quick_entries_list($name, $selected_id, $type, $submit_on_change);
2044 function quick_entries_list_row($label, $name, $selected_id=null, $type, $submit_on_change=false)
2047 quick_entries_list_cells($label, $name, $selected_id, $type, $submit_on_change);
2052 function quick_actions_list_row($label, $name, $selected_id=null, $submit_on_change=false)
2054 global $quick_actions;
2056 echo "<tr><td>$label</td><td>";
2057 array_selector($name, $selected_id, $quick_actions,
2059 'select_submit'=> $submit_on_change
2061 echo "</td></tr>\n";
2064 function quick_entry_types_list_row($label, $name, $selected_id=null, $submit_on_change=false)
2066 global $quick_entry_types;
2068 echo "<tr><td>$label</td><td>";
2069 array_selector($name, $selected_id, $quick_entry_types,
2071 'select_submit'=> $submit_on_change
2073 echo "</td></tr>\n";
2077 function class_types_list_row($label, $name, $selected_id=null, $submit_on_change=false)
2079 global $class_types;
2081 echo "<tr><td>$label</td><td>";
2082 array_selector($name, $selected_id, $class_types,
2084 'select_submit'=> $submit_on_change
2086 echo "</td></tr>\n";