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)
821 $str = stock_manufactured_items_list_cells($label, $name, $selected_id,
822 $all_option, $submit_on_change);
826 //------------------------------------------------------------------------------------
828 function stock_component_items_list($name, $parent_stock_id, $selected_id=null,
829 $all_option=false, $submit_on_change=false)
831 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
832 array('where'=>array("stock_id != '$parent_stock_id'")));
836 function stock_component_items_list_cells($label, $name, $parent_stock_id,
837 $selected_id=null, $all_option=false, $submit_on_change=false)
840 echo "<td>$label</td>\n";
841 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
842 array('where'=>array("stock_id != '$parent_stock_id'"), 'cells'=>true));
845 //------------------------------------------------------------------------------------
847 function stock_costable_items_list($name, $selected_id=null,
848 $all_option=false, $submit_on_change=false)
850 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
851 array('where'=>array("mb_flag!='D'")));
855 function stock_costable_items_list_cells($label, $name, $selected_id=null,
856 $all_option=false, $submit_on_change=false)
859 echo "<td>$label</td>\n";
860 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
861 array('where'=>array("mb_flag!='D'"), 'cells'=>true));
865 //------------------------------------------------------------------------------------
866 function stock_purchasable_items_list($name, $selected_id=null,
867 $all_option=false, $submit_on_change=false)
869 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
870 array('where'=>array("mb_flag!= 'M'"),
871 'edit_submit' => true));
875 function stock_purchasable_items_list_cells($label, $name, $selected_id=null,
876 $all_option=false, $submit_on_change=false)
879 echo "<td>$label</td>\n";
880 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
881 array('where'=>array("mb_flag!= 'M'"),
882 'edit_submit' => true,
887 function stock_purchasable_items_list_row($label, $name, $selected_id=null,
888 $all_option=false, $submit_on_change=false)
891 $ret = stock_purchasable_items_list_cells($label, $name, $selected_id=null,
892 $all_option, $submit_on_change);
897 //------------------------------------------------------------------------------------
899 function stock_item_types_list_row($label, $name, $selected_id=null, $enabled=true)
902 'M' => _("Manufactured"),
903 'B' => _("Purchased"),
909 echo "<td>$label</td>\n";
912 array_selector($name, $selected_id, $types,
914 'select_submit'=> true,
915 'disabled' => !$enabled) );
919 function stock_units_list_row($label, $name, $value=null, $enabled=true)
921 $result = get_all_item_units();
924 echo "<td>$label</td>\n";
927 while($unit = db_fetch($result))
928 $units[$unit['abbr']] = $unit['name'];
930 array_selector($name, $value, $units,
932 'select_submit'=> true,
933 'disabled' => !$enabled) );
938 //------------------------------------------------------------------------------------
940 function tax_types_list($name, $selected_id=null, $none_option=false, $submit_on_change=false)
942 $sql = "SELECT id, CONCAT(name, ' (',rate,'%)') as name FROM ".TB_PREF."tax_types";
944 return combo_input($name, $selected_id, $sql, 'id', 'name',
946 'spec_option' => $none_option,
947 'spec_id' => reserved_words::get_all_numeric(),
948 'select_submit'=> $submit_on_change,
953 function tax_types_list_cells($label, $name, $selected_id=null, $none_option=false,
954 $submit_on_change=false)
957 echo "<td>$label</td>\n";
959 $str = tax_types_list($name, $selected_id, $none_option, $submit_on_change);
964 function tax_types_list_row($label, $name, $selected_id=null, $none_option=false,
965 $submit_on_change=false)
968 $str = tax_types_list_cells($label, $name, $selected_id, $none_option, $submit_on_change);
973 //------------------------------------------------------------------------------------
975 function tax_groups_list($name, $selected_id=null,
976 $none_option=false, $submit_on_change=false)
978 $sql = "SELECT id, name FROM ".TB_PREF."tax_groups";
980 return combo_input($name, $selected_id, $sql, 'id', 'name',
983 'spec_option' => $none_option,
984 'spec_id' => reserved_words::get_all_numeric(),
985 'select_submit'=> $submit_on_change,
990 function tax_groups_list_cells($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false)
993 echo "<td>$label</td>\n";
995 $str = tax_groups_list($name, $selected_id, $none_option, $submit_on_change);
1000 function tax_groups_list_row($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false)
1003 $str = tax_groups_list_cells($label, $name, $selected_id, $none_option, $submit_on_change);
1008 //------------------------------------------------------------------------------------
1010 function item_tax_types_list($name, $selected_id=null)
1012 $sql ="SELECT id, name FROM ".TB_PREF."item_tax_types";
1013 combo_input($name, $selected_id, $sql, 'id', 'name', array('order' => 'id') );
1016 function item_tax_types_list_cells($label, $name, $selected_id=null)
1019 echo "<td>$label</td>\n";
1021 item_tax_types_list($name, $selected_id);
1025 function item_tax_types_list_row($label, $name, $selected_id=null)
1028 item_tax_types_list_cells($label, $name, $selected_id);
1032 //------------------------------------------------------------------------------------
1034 function shippers_list($name, $selected_id=null)
1036 $sql = "SELECT shipper_id, shipper_name FROM ".TB_PREF."shippers";
1037 combo_input($name, $selected_id, $sql, 'shipper_id', 'shipper_name', array());
1040 function shippers_list_cells($label, $name, $selected_id=null)
1043 echo "<td>$label</td>\n";
1045 shippers_list($name, $selected_id);
1049 function shippers_list_row($label, $name, $selected_id=null)
1052 shippers_list_cells($label, $name, $selected_id);
1056 //-------------------------------------------------------------------------------------
1058 function sales_persons_list($name, $selected_id=null)
1060 $sql = "SELECT salesman_code, salesman_name FROM ".TB_PREF."salesman";
1061 combo_input($name, $selected_id, $sql, 'salesman_code', 'salesman_name', array());
1064 function sales_persons_list_cells($label, $name, $selected_id=null)
1067 echo "<td>$label</td>\n";
1069 sales_persons_list($name, $selected_id);
1073 function sales_persons_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1076 sales_persons_list_cells($label, $name, $selected_id, $submit_on_change=false);
1080 //------------------------------------------------------------------------------------
1082 function sales_areas_list($name, $selected_id=null)
1084 $sql = "SELECT area_code, description FROM ".TB_PREF."areas";
1085 combo_input($name, $selected_id, $sql, 'area_code', 'description', array());
1088 function sales_areas_list_cells($label, $name, $selected_id=null)
1091 echo "<td>$label</td>\n";
1093 sales_areas_list($name, $selected_id);
1097 function sales_areas_list_row($label, $name, $selected_id=null)
1100 sales_areas_list_cells($label, $name, $selected_id);
1104 //------------------------------------------------------------------------------------
1106 function sales_groups_list($name, $selected_id=null, $special_option=false)
1108 $sql = "SELECT id, description FROM ".TB_PREF."groups";
1109 combo_input($name, $selected_id, $sql, 'id', 'description', array(
1110 'spec_option' => $special_option===true ? ' ' : $special_option,
1111 'order' => 'description', 'spec_id' => 0,
1115 function sales_groups_list_cells($label, $name, $selected_id=null, $special_option=false)
1118 echo "<td>$label</td>\n";
1120 sales_groups_list($name, $selected_id, $special_option);
1124 function sales_groups_list_row($label, $name, $selected_id=null, $special_option=false)
1127 sales_groups_list_cells($label, $name, $selected_id, $special_option);
1131 //------------------------------------------------------------------------------------
1133 function _format_template_items($row)
1135 return ($row[0] . " - " . _("Amount") . " ".$row[1]);
1138 function templates_list($name, $selected_id=null, $special_option=false)
1140 $sql = "SELECT sorder.order_no, Sum(line.unit_price*line.quantity*(1-line.discount_percent)) AS OrderValue
1141 FROM ".TB_PREF."sales_orders as sorder, ".TB_PREF."sales_order_details as line
1142 WHERE sorder.order_no = line.order_no AND sorder.type = 1 GROUP BY line.order_no";
1143 combo_input($name, $selected_id, $sql, 'order_no', 'OrderValue', array(
1144 'format' => '_format_template_items',
1145 'spec_option' => $special_option===true ? ' ' : $special_option,
1146 'order' => 'order_no', 'spec_id' => 0,
1150 function templates_list_cells($label, $name, $selected_id=null, $special_option=false)
1153 echo "<td>$label</td>\n";
1155 templates_list($name, $selected_id, $special_option);
1159 function templates_list_row($label, $name, $selected_id=null, $special_option=false)
1162 templates_list_cells($label, $name, $selected_id, $special_option);
1166 //------------------------------------------------------------------------------------
1168 function workorders_list($name, $selected_id=null)
1170 $sql = "SELECT id, wo_ref FROM ".TB_PREF."workorders WHERE closed=0";
1171 combo_input($name, $selected_id, $sql, 'id', 'wo_ref', array());
1174 function workorders_list_cells($label, $name, $selected_id=null)
1177 echo "<td>$label</td>\n";
1179 workorders_list($name, $selected_id);
1183 function workorders_list_row($label, $name, $selected_id=null)
1186 workorders_list_cells($label, $name, $selected_id);
1190 //------------------------------------------------------------------------------------
1192 function payment_terms_list($name, $selected_id=null)
1194 $sql = "SELECT terms_indicator, terms FROM ".TB_PREF."payment_terms";
1195 combo_input($name, $selected_id, $sql, 'terms_indicator', 'terms', array());
1198 function payment_terms_list_cells($label, $name, $selected_id=null)
1201 echo "<td>$label</td>\n";
1203 payment_terms_list($name, $selected_id);
1207 function payment_terms_list_row($label, $name, $selected_id=null)
1210 payment_terms_list_cells($label, $name, $selected_id);
1214 //------------------------------------------------------------------------------------
1216 function credit_status_list($name, $selected_id=null)
1218 $sql ="SELECT id, reason_description FROM ".TB_PREF."credit_status";
1219 combo_input($name, $selected_id, $sql, 'id', 'reason_description', array());
1222 function credit_status_list_cells($label, $name, $selected_id=null)
1225 echo "<td>$label</td>\n";
1227 credit_status_list($name, $selected_id);
1231 function credit_status_list_row($label, $name, $selected_id=null)
1234 credit_status_list_cells($label, $name, $selected_id);
1238 //-----------------------------------------------------------------------------------------------
1240 function sales_types_list($name, $selected_id=null, $submit_on_change=false, $special_option=false)
1242 $sql = "SELECT id, sales_type FROM ".TB_PREF."sales_types";
1244 return combo_input($name, $selected_id, $sql, 'id', 'sales_type',
1246 'spec_option' => $special_option===true ? _("All Sales Types") : $special_option,
1248 'select_submit'=> $submit_on_change,
1249 // 'async' => false,
1253 function sales_types_list_cells($label, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1256 echo "<td>$label</td>\n";
1258 $str = sales_types_list($name, $selected_id, $submit_on_change, $special_option);
1263 function sales_types_list_row($label, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1266 $str = sales_types_list_cells($label, $name, $selected_id, $submit_on_change, $special_option);
1271 //-----------------------------------------------------------------------------------------------
1273 function movement_types_list($name, $selected_id=null)
1275 $sql = "SELECT id, name FROM ".TB_PREF."movement_types";
1276 combo_input($name, $selected_id, $sql, 'id', 'name', array());
1279 function movement_types_list_cells($label, $name, $selected_id=null)
1282 echo "<td>$label</td>\n";
1284 movement_types_list($name, $selected_id);
1288 function movement_types_list_row($label, $name, $selected_id=null)
1291 movement_types_list_cells($label, $name, $selected_id);
1295 //-----------------------------------------------------------------------------------------------
1296 function _format_date($row)
1298 return sql2date($row['reconciled']);
1301 function bank_reconciliation_list($account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1303 $sql = "SELECT reconciled, reconciled FROM ".TB_PREF."bank_trans
1304 WHERE bank_act=".db_escape($account)." AND reconciled IS NOT NULL
1305 GROUP BY reconciled";
1306 combo_input($name, $selected_id, $sql, 'id', 'reconciled',
1308 'spec_option' => $special_option,
1309 'format' => '_format_date',
1311 'select_submit'=> $submit_on_change
1315 function bank_reconciliation_list_cells($label,$account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1318 echo "<td>$label</td>\n";
1320 bank_reconciliation_list($account, $name, $selected_id, $submit_on_change, $special_option);
1324 function bank_reconciliation_list_row($label, $account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1327 bank_reconciliation_list_cells($label, $account, $name, $selected_id, $submit_on_change, $special_option);
1331 //-----------------------------------------------------------------------------------------------
1333 function workcenter_list($name, $selected_id=null, $all_option=false)
1337 $sql = "SELECT id, name FROM ".TB_PREF."workcentres";
1339 return combo_input($name, $selected_id, $sql, 'id', 'name',
1341 'spec_option' =>$all_option===true ? _("All Suppliers") : $all_option,
1342 'spec_id' => $all_items,
1346 function workcenter_list_cells($label, $name, $selected_id=null, $all_option=false)
1348 default_focus($name);
1350 echo "<td>$label</td>\n";
1352 workcenter_list($name, $selected_id, $all_option);
1356 function workcenter_list_row($label, $name, $selected_id=null, $all_option=false)
1359 workcenter_list_cells($label, $name, $selected_id, $all_option);
1363 //-----------------------------------------------------------------------------------------------
1365 function bank_accounts_list($name, $selected_id=null, $submit_on_change=false)
1367 $sql = "SELECT ".TB_PREF."bank_accounts.id, bank_account_name, bank_curr_code
1368 FROM ".TB_PREF."bank_accounts";
1369 // , ".TB_PREF."chart_master
1370 // WHERE ".TB_PREF."bank_accounts.account_code=".TB_PREF."chart_master.account_code";
1372 return combo_input($name, $selected_id, $sql, 'id', 'bank_account_name',
1374 'format' => '_format_add_curr',
1375 'select_submit'=> $submit_on_change,
1380 function bank_accounts_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1383 echo "<td>$label</td>\n";
1385 $str = bank_accounts_list($name, $selected_id, $submit_on_change);
1390 function bank_accounts_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1393 $str = bank_accounts_list_cells($label, $name, $selected_id, $submit_on_change);
1397 //-----------------------------------------------------------------------------------------------
1399 function cash_accounts_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1401 $sql = "SELECT ".TB_PREF."bank_accounts.id, bank_account_name, bank_curr_code
1402 FROM ".TB_PREF."bank_accounts
1403 WHERE ".TB_PREF."bank_accounts.account_type=3";
1406 echo "<tr><td>$label</td>\n";
1408 $str = combo_input($name, $selected_id, $sql, 'id', 'bank_account_name',
1410 'format' => '_format_add_curr',
1411 'select_submit'=> $submit_on_change,
1414 echo "</td></tr>\n";
1417 //-----------------------------------------------------------------------------------------------
1419 function pos_list_row($label, $name, $selected_id=null, $spec_option=false, $submit_on_change=false)
1421 $sql = "SELECT id, pos_name FROM ".TB_PREF."sales_pos";
1423 default_focus($name);
1426 echo "<td>$label</td>\n";
1429 $str = combo_input($name, $selected_id, $sql, 'id', 'pos_name',
1431 'select_submit'=> $submit_on_change,
1433 'spec_option' =>$spec_option,
1436 echo "</td></tr>\n";
1440 //-----------------------------------------------------------------------------------------------
1442 function sale_payment_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1445 echo "<td>$label</td>\n";
1447 $str = yesno_list($name, $selected_id, _('Cash'), _('Delayed'), $submit_on_change);
1451 //-----------------------------------------------------------------------------------------------
1453 function class_list($name, $selected_id=null, $submit_on_change=false)
1455 $sql = "SELECT cid, class_name FROM ".TB_PREF."chart_class";
1457 return combo_input($name, $selected_id, $sql, 'cid', 'class_name',
1459 'select_submit'=> $submit_on_change,
1465 function class_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1468 echo "<td>$label</td>\n";
1470 $str = class_list($name, $selected_id, $submit_on_change);
1475 function class_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1478 $str = class_list_cells($label, $name, $selected_id, $submit_on_change);
1483 //-----------------------------------------------------------------------------------------------
1485 function stock_categories_list($name, $selected_id=null)
1487 $sql = "SELECT category_id, description FROM ".TB_PREF."stock_category";
1488 combo_input($name, $selected_id, $sql, 'category_id', 'description',
1489 array('order'=>'category_id'));
1492 function stock_categories_list_cells($label, $name, $selected_id=null)
1495 echo "<td>$label</td>\n";
1497 stock_categories_list($name, $selected_id);
1501 function stock_categories_list_row($label, $name, $selected_id=null)
1504 stock_categories_list_cells($label, $name, $selected_id);
1508 //-----------------------------------------------------------------------------------------------
1510 function gl_account_types_list($name, $selected_id=null, $all_option, $all_option_numeric)
1514 $sql = "SELECT id, name FROM ".TB_PREF."chart_types";
1516 combo_input($name, $selected_id, $sql, 'id', 'name',
1519 'spec_option' =>$all_option,
1520 'spec_id' => $all_option_numeric ? 0 : $all_items
1524 function gl_account_types_list_cells($label, $name, $selected_id=null, $all_option=false,
1525 $all_option_numeric=false)
1528 echo "<td>$label</td>\n";
1530 gl_account_types_list($name, $selected_id, $all_option, $all_option_numeric);
1534 function gl_account_types_list_row($label, $name, $selected_id=null, $all_option=false,
1535 $all_option_numeric=false)
1538 gl_account_types_list_cells($label, $name, $selected_id, $all_option,
1539 $all_option_numeric);
1543 //-----------------------------------------------------------------------------------------------
1544 function gl_all_accounts_list($name, $selected_id=null, $skip_bank_accounts=false,
1545 $cells=false, $all_option=false, $submit_on_change=false)
1547 if ($skip_bank_accounts)
1548 $sql = "SELECT chart.account_code, chart.account_name, type.name
1549 FROM (".TB_PREF."chart_master chart,".TB_PREF."chart_types type) "
1550 ."LEFT JOIN ".TB_PREF."bank_accounts acc "
1551 ."ON chart.account_code=acc.account_code
1552 WHERE acc.account_code IS NULL
1553 AND chart.account_type=type.id";
1555 $sql = "SELECT chart.account_code, chart.account_name, type.name
1556 FROM ".TB_PREF."chart_master chart,".TB_PREF."chart_types type
1557 WHERE chart.account_type=type.id";
1559 combo_input($name, $selected_id, $sql, 'chart.account_code', 'chart.account_name',
1561 'format' => '_format_account',
1562 'spec_option' => $all_option===true ? _("Use Item Sales Accounts") : $all_option,
1564 'order' => array('name','account_code'),
1565 'search_box' => $cells,
1566 'search_submit' => false,
1570 'select_submit'=> $submit_on_change,
1577 function _format_account($row)
1579 return $row[0] . " " . $row[1];
1582 function gl_all_accounts_list_cells($label, $name, $selected_id=null,
1583 $skip_bank_accounts=false, $cells=false, $all_option=false)
1586 echo "<td>$label</td>\n";
1588 gl_all_accounts_list($name, $selected_id,
1589 $skip_bank_accounts, $cells, $all_option);
1593 function gl_all_accounts_list_row($label, $name, $selected_id=null,
1594 $skip_bank_accounts=false, $cells=false, $all_option=false)
1597 gl_all_accounts_list_cells($label, $name, $selected_id,
1598 $skip_bank_accounts, $cells, $all_option);
1602 function yesno_list($name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1605 $items['0'] = strlen($name_no) ? $name_no : _("No");
1606 $items['1'] = strlen($name_yes) ? $name_yes : _("Yes");
1608 return array_selector($name, $selected_id, $items,
1610 'select_submit'=> $submit_on_change,
1611 'async' => false ) ); // FIX?
1614 function yesno_list_cells($label, $name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1617 echo "<td>$label</td>\n";
1619 $str = yesno_list($name, $selected_id, $name_yes, $name_no, $submit_on_change);
1624 function yesno_list_row($label, $name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1627 $str = yesno_list_cells($label, $name, $selected_id, $name_yes, $name_no, $submit_on_change);
1632 //------------------------------------------------------------------------------------------------
1634 function languages_list($name, $selected_id=null)
1636 global $installed_languages;
1639 foreach ($installed_languages as $lang)
1640 $items[$lang['code']] = $lang['name'];
1642 return array_selector($name, $selected_id, $items );
1645 function languages_list_cells($label, $name, $selected_id=null)
1648 echo "<td>$label</td>\n";
1650 languages_list($name, $selected_id);
1654 function languages_list_row($label, $name, $selected_id=null)
1657 languages_list_cells($label, $name, $selected_id);
1661 //------------------------------------------------------------------------------------------------
1663 function bank_account_types_list($name, $selected_id=null)
1665 $types = bank_account_types::get_all();
1668 foreach ($types as $type)
1670 $items[$type['id']] = $type['name'];
1673 return array_selector($name, $selected_id, $items );
1676 function bank_account_types_list_cells($label, $name, $selected_id=null)
1679 echo "<td>$label</td>\n";
1681 bank_account_types_list($name, $selected_id);
1685 function bank_account_types_list_row($label, $name, $selected_id=null)
1688 bank_account_types_list_cells($label, $name, $selected_id);
1692 //------------------------------------------------------------------------------------------------
1693 function payment_person_types_list($name, $selected_id=null, $submit_on_change=false)
1695 $types = payment_person_types::get_all();
1698 foreach ($types as $type)
1700 if (payment_person_types::has_items($type['id']))
1702 if ($type['id'] != payment_person_types::WorkOrder())
1703 $items[$type['id']] = $type['name'];
1707 return array_selector($name, $selected_id, $items,
1708 array( 'select_submit'=> $submit_on_change ) );
1711 function payment_person_types_list_cells($label, $name, $selected_id=null, $related=null)
1714 echo "<td>$label</td>\n";
1716 $str = payment_person_types_list($name, $selected_id, $related);
1721 function payment_person_types_list_row($label, $name, $selected_id=null, $related=null)
1724 $str = payment_person_types_list_cells($label, $name, $selected_id, $related);
1729 //------------------------------------------------------------------------------------------------
1731 function wo_types_list($name, $selected_id=null)
1733 $types = wo_types::get_all();
1736 foreach ($types as $type)
1737 $items[$type['id']] = $type['name'];
1739 return array_selector($name, $selected_id, $items,
1740 array( 'select_submit'=> true, 'async' => true ) );
1743 function wo_types_list_row($label, $name, $selected_id=null)
1745 echo "<tr><td>$label</td><td>\n";
1746 $str = wo_types_list($name, $selected_id);
1747 echo "</td></tr>\n";
1751 //------------------------------------------------------------------------------------------------
1753 function dateformats_list_row($label, $name, $value=null)
1755 global $dateformats;
1757 echo "<tr><td>$label</td>\n<td>";
1758 array_selector( $name, $value, $dateformats );
1759 echo "</td></tr>\n";
1762 function dateseps_list_row($label, $name, $value=null)
1766 echo "<tr><td>$label</td>\n<td>";
1767 array_selector( $name, $value, $dateseps );
1768 echo "</td></tr>\n";
1771 function thoseps_list_row($label, $name, $value=null)
1775 echo "<tr><td>$label</td>\n<td>";
1776 array_selector( $name, $value, $thoseps );
1777 echo "</td></tr>\n";
1780 function decseps_list_row($label, $name, $value=null)
1784 echo "<tr><td>$label</td>\n<td>";
1785 array_selector( $name, $value, $decseps );
1786 echo "</td></tr>\n";
1789 function themes_list_row($label, $name, $value=null)
1791 global $path_to_root;
1793 $path = $path_to_root.'/themes/';
1795 $themedir = opendir($path);
1796 while(false !== ($fname = readdir($themedir)))
1798 if($fname!='.' && $fname!='..' && $fname!='CVS' && is_dir($path.$fname))
1800 $themes[$fname] = $fname;
1805 echo "<tr><td>$label</td>\n<td>";
1806 array_selector( $name, $value, $themes );
1807 echo "</td></tr>\n";
1810 function pagesizes_list_row($label, $name, $value=null)
1815 foreach ($pagesizes as $pz)
1818 echo "<tr><td>$label</td>\n<td>";
1819 array_selector( $name, $value, $items );
1820 echo "</td></tr>\n";
1823 function security_headings_list_row($label, $name, $value=null)
1825 global $security_headings;
1827 echo "<tr><td>$label</td>\n<td>";
1828 array_selector( $name, $value, $security_headings );
1829 echo "</td></tr>\n";
1832 function systypes_list_cells($label, $name, $value=null, $submit_on_change=false)
1834 global $systypes_array;
1837 echo "<td>$label</td>\n";
1841 foreach ($systypes_array as $key=>$type)
1842 $items[$key] = $type['name'];
1844 $str = array_selector($name, $value, $items,
1846 'select_submit'=> $submit_on_change,
1854 function systypes_list_row($label, $name, $value=null, $submit_on_change=false)
1857 $str = systypes_list_cells($label, $name, $value, $submit_on_change);
1862 function cust_allocations_list_cells($label, $name, $selected=null)
1870 $all_items=>_("All Types"),
1871 '1'=> _("Sales Invoices"),
1872 '2'=> _("Overdue Invoices"),
1873 '3' => _("Payments"),
1874 '4' => _("Credit Notes"),
1875 '5' => _("Delivery Notes")
1877 $str = array_selector($name, $selected, $allocs);
1882 function supp_allocations_list_cell($name, $selected=null)
1888 $all_items=>_("All Types"),
1889 '1'=> _("Invoices"),
1890 '2'=> _("Overdue Invoices"),
1891 '3' => _("Payments"),
1892 '4' => _("Credit Notes"),
1893 '5' => _("Overdue Credit Notes")
1895 $str = array_selector($name, $selected, $allocs);
1900 function policy_list_cells($label, $name, $selected=null)
1905 $str = array_selector($name, $selected,
1906 array( '' => _("Automatically put balance on back order"),
1907 'CAN' => _("Cancel any quantites not delivered")) );
1912 function policy_list_row($label, $name, $selected=null)
1915 policy_list_cells($label, $name, $selected);
1919 function credit_type_list_cells($label, $name, $selected=null, $submit_on_change=false)
1924 $str = array_selector($name, $selected,
1925 array( 'Return' => _("Items Returned to Inventory Location"),
1926 'WriteOff' => _("Items Written Off")),
1927 array( 'select_submit'=> $submit_on_change ) );
1932 function credit_type_list_row($label, $name, $selected=null, $submit_on_change=false)
1935 $str = credit_type_list_cells($label, $name, $selected, $submit_on_change);
1940 function number_list($name, $selected, $from, $to, $no_option=false)
1943 for ($i = $from; $i <= $to; $i++)
1946 return array_selector($name, $selected, $items,
1947 array( 'spec_option' => $no_option,
1948 'spec_id' => reserved_words::get_all_numeric()) );
1951 function number_list_cells($label, $name, $selected, $from, $to, $no_option=false)
1956 number_list($name, $selected, $from, $to, $no_option);
1960 function number_list_row($label, $name, $selected, $from, $to, $no_option=false)
1963 number_list_cells($label, $name, $selected, $from, $to, $no_option);
1967 function print_profiles_list_row($label, $name, $selected_id=null, $spec_opt=false,
1968 $submit_on_change=true)
1970 $sql = "SELECT profile FROM ".TB_PREF."print_profiles"
1971 ." GROUP BY profile";
1972 $result = db_query($sql, 'cannot get all profile names');
1973 $profiles = array();
1974 while($myrow=db_fetch($result)) {
1975 $profiles[$myrow['profile']] = $myrow['profile'];
1980 echo "<td>$label</td>\n";
1983 array_selector($name, $selected_id, $profiles,
1984 array( 'select_submit'=> $submit_on_change,
1985 'spec_option'=>$spec_opt,
1989 echo "</td></tr>\n";
1992 function printers_list($name, $selected_id=null, $spec_opt=false, $submit_on_change=false)
1994 static $printers; // query only once for page display
1997 $sql = "SELECT id, name, description FROM ".TB_PREF."printers";
1998 $result = db_query($sql, 'cannot get all printers');
1999 $printers = array();
2000 while($myrow=db_fetch($result)) {
2001 $printers[$myrow['id']] = $myrow['name'].' - '.$myrow['description'];
2004 array_selector($name, $selected_id, $printers,
2005 array( 'select_submit'=> $submit_on_change,
2006 'spec_option'=>$spec_opt,
2011 //------------------------------------------------------------------------------------------------
2013 function quick_entries_list($name, $selected_id=null, $type=null, $submit_on_change=false)
2016 $sql = "SELECT id, description FROM ".TB_PREF."quick_entries";
2018 $sql .= " WHERE type=$type";
2020 combo_input($name, $selected_id, $sql, 'id', 'description',
2023 'order' => 'description',
2024 'select_submit'=> $submit_on_change,
2030 function quick_entries_list_cells($label, $name, $selected_id=null, $type, $submit_on_change=false)
2032 echo "<td>$label</td><td>\n";
2033 quick_entries_list($name, $selected_id, $type, $submit_on_change);
2037 function quick_entries_list_row($label, $name, $selected_id=null, $type, $submit_on_change=false)
2040 quick_entries_list_cells($label, $name, $selected_id, $type, $submit_on_change);
2045 function quick_actions_list_row($label, $name, $selected_id=null, $submit_on_change=false)
2047 global $quick_actions;
2049 echo "<tr><td>$label</td><td>";
2050 array_selector($name, $selected_id, $quick_actions,
2052 'select_submit'=> $submit_on_change
2054 echo "</td></tr>\n";
2057 function quick_entry_types_list_row($label, $name, $selected_id=null, $submit_on_change=false)
2059 global $quick_entry_types;
2061 echo "<tr><td>$label</td><td>";
2062 array_selector($name, $selected_id, $quick_entry_types,
2064 'select_submit'=> $submit_on_change
2066 echo "</td></tr>\n";
2070 function class_types_list_row($label, $name, $selected_id=null, $submit_on_change=false)
2072 global $class_types;
2074 echo "<tr><td>$label</td><td>";
2075 array_selector($name, $selected_id, $class_types,
2077 'select_submit'=> $submit_on_change
2079 echo "</td></tr>\n";