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 'async' => true, // select update via ajax (true) vs _page_body reload
45 // search box parameters
47 'search_box' => false, // name or true/false
48 'type' => 0, // type of extended selector:
49 // 0 - with (optional) visible search box, search by id
50 // 1 - with hidden search box, search by option text
51 // 2 - TODO reverse: box with hidden selector available via enter; this
52 // would be convenient for optional ad hoc adding of new item
53 'search_submit' => true, //search submit button: true/false
54 'size' => 8, // size and max of box tag
56 'cells' => false, // combo displayed as 2 <td></td> cells
57 'search' => array(), // sql field names to search
58 'format' => null, // format functions for regular options
60 'box_hint' => null, // box/selectors hints; null = std see below
61 'category' => false, // category column name or false
62 'show_inactive' => false // show inactive records.
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 // show selected option even if inactive
171 if (!$opts['show_inactive'] && @$contact_row['inactive'] && $sel==='') {
174 $optclass = @$contact_row['inactive'] ? "class='inactive'" : '';
176 if ($first_id === false) {
180 $cat = $contact_row[$opts['category']];
181 if ($opts['category'] !== false && $cat != $lastcat){
182 $selector .= "<optgroup label='".$cat."'>\n";
185 $selector .= "<option $sel $optclass value='$value'>$descr</option>\n";
187 db_free_result($result);
190 // Prepend special option.
191 if ($spec_option !== false) { // if special option used - add it
192 $first_id = $spec_id;
193 $first_opt = $spec_option;
195 // if($first_id !== false) {
196 $sel = $found===false ? 'selected' : '';
197 $optclass = @$contact_row['inactive'] ? "class='inactive'" : '';
198 $selector = "<option $sel value='$first_id'>$first_opt</option>\n"
202 if ($found === false) {
203 $selected_id = $first_id;
205 $_POST[$name] = $selected_id;
207 if ($by_id && $search_box != false) {
209 $Ajax->addUpdate($name, $search_box, $txt ? $txt : '');
211 $selector = "<select $disabled name='$name' class='$class' title='"
212 . $opts['sel_hint']."' $rel>".$selector."</select>\n";
214 $Ajax->addUpdate($name, "_{$name}_sel", $selector);
216 // because of bug which M$ cannot fix since IE 5.0
217 // we must embed whole selector in span tags to enable proper ajax update
218 $selector = "<span id='_{$name}_sel'>".$selector."</span>\n";
220 if ($select_submit != false) { // if submit on change is used - add select button
221 global $_select_button;
222 // button class selects form reload/ajax selector update
223 $selector .= sprintf($_select_button, $disabled, user_theme(),
224 (fallback_mode() ? '' : 'display:none;'),
225 $select_submit)."\n";
227 // ------ make combo ----------
230 if ($search_box != false) {
231 $edit_entry = "<input $disabled type='text' name='$search_box' id='$search_box' size='".
232 $opts['size']."' maxlength='".$opts['max'].
233 "' value='$txt' class='$class' rel='$name' autocomplete='off' title='"
234 .$opts['box_hint']."'"
235 .(!fallback_mode() && !$by_id ? " style=display:none;":'')
237 if ($search_submit != false) {
238 global $_search_button;
239 $edit_entry .= sprintf($_search_button, $disabled, user_theme(),
240 (fallback_mode() ? '' : 'display:none;'),
241 $search_submit)."\n";
244 default_focus(($search_box && $by_id) ? $search_box : $name);
246 if ($search_box && $opts['cells'])
247 echo ($edit_entry!='' ? "<td>$edit_entry</td>" : '')."<td>$selector</td>";
249 echo $edit_entry.$selector;
256 Returns true if selector $name is subject to update.
258 function list_updated($name)
260 return isset($_POST['_'.$name.'_update']) || isset($_POST['_'.$name.'_button']);
262 //----------------------------------------------------------------------------------------------
263 // Universal array combo generator
264 // $items is array of options 'value' => 'description'
265 // Options is reduced set of combo_selector options and is merged with defaults.
267 function array_selector($name, $selected_id, $items, $options=null)
271 $opts = array( // default options
272 'spec_option'=>false, // option text or false
273 'spec_id' => 0, // option id
274 'select_submit' => false, //submit on select: true/false
275 'async' => true, // select update via ajax (true) vs _page_body reload
276 'default' => '', // default value when $_POST is not set
277 // search box parameters
281 // ------ merge options with defaults ----------
283 $opts = array_merge($opts, $options);
284 $select_submit = $opts['select_submit']===true ? '_'.$name.'_update' : $opts['select_submit'];
285 $spec_id = $opts['spec_id'];
286 $spec_option = $opts['spec_option'];
287 $disabled = $opts['disabled'] ? "disabled" : '';
289 if ($selected_id == null) {
290 $selected_id = get_post($name, $opts['default']);
293 if (isset($_POST[$select_submit])) {
295 $Ajax->activate('_page_body');
297 $Ajax->activate($name);
300 // ------ make selector ----------
301 $selector = $first_opt = '';
304 //if($name=='SelectStockFromList') display_error($sql);
305 foreach($items as $value=>$descr) {
307 if ((string)$selected_id === (string)$value) {
311 if ($first_id === false) {
315 $selector .= "<option $sel value='$value'>$descr</option>\n";
318 // Prepend special option.
319 if ($spec_option !== false) { // if special option used - add it
320 $first_id = $spec_id;
321 $first_opt = $spec_option;
322 $sel = $found===false ? 'selected' : '';
323 $selector = "<option $sel value='$spec_id'>$spec_option</option>\n"
327 if ($found === false) {
328 $selected_id = $first_id;
330 $_POST[$name] = $selected_id;
332 $selector = "<select $disabled name='$name' class='combo' title='"
333 . $opts['sel_hint']."'>".$selector."</select>\n";
335 $Ajax->addUpdate($name, "_{$name}_sel", $selector);
337 $selector = "<span id='_{$name}_sel'>".$selector."</span>\n";
339 if ($select_submit != false) { // if submit on change is used - add select button
340 global $_select_button;
341 $selector .= sprintf($_select_button, $disabled, user_theme(),
342 (fallback_mode() ? '' : 'display:none;'),
343 $select_submit)."\n";
345 default_focus($name);
350 //----------------------------------------------------------------------------------------------
352 function _format_add_curr($row)
354 static $company_currency;
356 if ($company_currency == null)
358 $company_currency = get_company_currency();
360 return $row[1] . ($row[2] == $company_currency ?
361 '' : (" - " . $row[2]));
364 function supplier_list($name, $selected_id=null, $spec_option=false, $submit_on_change=false,
369 $sql = "SELECT supplier_id, supp_name, curr_code, inactive FROM ".TB_PREF."suppliers ";
371 $mode = get_company_pref('no_supplier_list');
373 return combo_input($name, $selected_id, $sql, 'supplier_id', 'supp_name',
375 'format' => '_format_add_curr',
376 'search_box' => $mode!=0,
378 'spec_option' => $spec_option === true ? _("All Suppliers") : $spec_option,
379 'spec_id' => $all_items,
380 'select_submit'=> $submit_on_change,
382 'sel_hint' => $mode ? _('Press Space tab to filter by name fragment') :
383 _('Select supplier'),
384 'show_inactive'=>$all
388 function supplier_list_cells($label, $name, $selected_id=null, $all_option=false,
389 $submit_on_change=false, $all=false)
392 echo "<td>$label</td><td>\n";
393 $str = supplier_list($name, $selected_id, $all_option, $submit_on_change, $all);
398 function supplier_list_row($label, $name, $selected_id=null, $all_option = false, $submit_on_change=false)
400 echo "<tr><td>$label</td><td>";
401 $str = supplier_list($name, $selected_id, $all_option, $submit_on_change );
405 //----------------------------------------------------------------------------------------------
407 function customer_list($name, $selected_id=null, $spec_option=false, $submit_on_change=false, $show_inactive=false)
411 $sql = "SELECT debtor_no, name, curr_code, inactive FROM ".TB_PREF."debtors_master ";
413 $mode = get_company_pref('no_customer_list');
415 return combo_input($name, $selected_id, $sql, 'debtor_no', 'name',
417 'format' => '_format_add_curr',
418 'search_box' => $mode!=0,
421 'spec_option' => $spec_option === true ? _("All Customers") : $spec_option,
422 'spec_id' => $all_items,
423 'select_submit'=> $submit_on_change,
425 'sel_hint' => $mode ? _('Press Space tab to filter by name fragment; F2 - entry new customer') :
426 _('Select customer'),
427 'show_inactive' => $show_inactive
431 function customer_list_cells($label, $name, $selected_id=null, $all_option=false,
432 $submit_on_change=false, $show_inactive=false)
435 echo "<td>$label</td>\n";
437 $str = customer_list($name, $selected_id, $all_option, $submit_on_change,
443 function customer_list_row($label, $name, $selected_id=null, $all_option = false,
444 $submit_on_change=false, $show_inactive=false)
446 echo "<tr><td>$label</td><td nowrap>";
447 $str = customer_list($name, $selected_id, $all_option, $submit_on_change,
449 echo "</td>\n</tr>\n";
453 //------------------------------------------------------------------------------------------------
455 function customer_branches_list($customer_id, $name, $selected_id=null,
456 $spec_option = true, $enabled=true, $submit_on_change=false)
460 $sql = "SELECT branch_code, br_name FROM ".TB_PREF."cust_branch
461 WHERE debtor_no='" . $customer_id . "' ";
463 $where = $enabled ? array("disable_trans = 0") : array();
464 return combo_input($name, $selected_id, $sql, 'branch_code', 'br_name',
467 'spec_option' => $spec_option === true ? _('All branches') : $spec_option,
468 'spec_id' => $all_items,
469 'select_submit'=> $submit_on_change,
470 'sel_hint' => _('Select customer branch')
473 //------------------------------------------------------------------------------------------------
475 function customer_branches_list_cells($label,$customer_id, $name, $selected_id=null, $all_option = true, $enabled=true, $submit_on_change=false)
478 echo "<td>$label</td>\n";
480 $ret = customer_branches_list($customer_id, $name, $selected_id, $all_option, $enabled, $submit_on_change);
485 function customer_branches_list_row($label,$customer_id, $name, $selected_id=null, $all_option = true, $enabled=true, $submit_on_change=false)
488 $ret = customer_branches_list_cells($label, $customer_id, $name, $selected_id, $all_option, $enabled, $submit_on_change);
493 //------------------------------------------------------------------------------------------------
495 function locations_list($name, $selected_id=null, $all_option=false, $submit_on_change=false)
499 $sql = "SELECT loc_code, location_name, inactive FROM ".TB_PREF."locations";
501 return combo_input($name, $selected_id, $sql, 'loc_code', 'location_name',
503 'spec_option' => $all_option === true ? _("All Locations") : $all_option,
504 'spec_id' => $all_items,
505 'select_submit'=> $submit_on_change
509 function locations_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
512 echo "<td>$label</td>\n";
514 $str = locations_list($name, $selected_id, $all_option, $submit_on_change);
519 function locations_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
522 $str = locations_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
527 //-----------------------------------------------------------------------------------------------
529 function currencies_list($name, $selected_id=null, $submit_on_change=false)
531 $sql = "SELECT curr_abrev, currency, inactive FROM ".TB_PREF."currencies";
533 // default to the company currency
535 return combo_input($name, $selected_id, $sql, 'curr_abrev', 'currency',
537 'select_submit'=> $submit_on_change,
538 'default' => get_company_currency(),
543 function currencies_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
546 echo "<td>$label</td>\n";
548 $str = currencies_list($name, $selected_id, $submit_on_change);
553 function currencies_list_row($label, $name, $selected_id=null, $submit_on_change=false)
556 $str = currencies_list_cells($label, $name, $selected_id, $submit_on_change);
561 //---------------------------------------------------------------------------------------------------
563 function fiscalyears_list($name, $selected_id=null, $submit_on_change=false)
566 $sql = "SELECT * FROM ".TB_PREF."fiscal_year";
568 // default to the company current fiscal year
570 return combo_input($name, $selected_id, $sql, 'id', '',
573 'default' => get_company_pref('f_year'),
574 'format' => '_format_fiscalyears',
575 'select_submit'=> $submit_on_change,
580 function _format_fiscalyears($row)
582 return sql2date($row[1]) . " - " . sql2date($row[2])
583 . " " . ($row[3] ? _('Closed') : _('Active')) . "</option>\n";
586 function fiscalyears_list_cells($label, $name, $selected_id=null)
589 echo "<td>$label</td>\n";
591 $str = fiscalyears_list($name, $selected_id);
596 function fiscalyears_list_row($label, $name, $selected_id=null)
599 $str = fiscalyears_list_cells($label, $name, $selected_id);
603 //------------------------------------------------------------------------------------
605 function dimensions_list($name, $selected_id=null, $no_option=false, $showname=' ',
606 $submit_on_change=false, $showclosed=false, $showtype=1)
608 $sql = "SELECT id, CONCAT(reference,' ',name) as ref FROM ".TB_PREF."dimensions";
611 'order' => 'reference',
612 'spec_option'=>$no_option ? $showname : false,
614 'select_submit'=> $submit_on_change,
619 $options['where'][] = "closed=0";
621 $options['where'][] = "type_=$showtype";
623 return combo_input($name, $selected_id, $sql, 'id', 'ref', $options);
626 function dimensions_list_cells($label, $name, $selected_id=null, $no_option=false, $showname=null,
627 $showclosed=false, $showtype=0, $submit_on_change=false)
630 echo "<td>$label</td>\n";
632 $str = dimensions_list($name, $selected_id, $no_option, $showname, $submit_on_change, $showclosed, $showtype);
637 function dimensions_list_row($label, $name, $selected_id=null, $no_option=false, $showname=null,
638 $showclosed=false, $showtype=0, $submit_on_change=false)
641 $str = dimensions_list_cells($label, $name, $selected_id, $no_option, $showname,
642 $showclosed, $showtype, $submit_on_change);
647 //---------------------------------------------------------------------------------------------------
649 function stock_items_list($name, $selected_id=null, $all_option=false,
650 $submit_on_change=false, $opts=array())
654 $sql = "SELECT stock_id, s.description, c.description, s.inactive
655 FROM ".TB_PREF."stock_master s,".TB_PREF."stock_category c WHERE s.category_id=c.category_id";
657 return combo_input($name, $selected_id, $sql, 'stock_id', 's.description',
660 'format' => '_format_stock_items',
661 'spec_option' => $all_option===true ? _("All Items") : $all_option,
662 'spec_id' => $all_items,
663 'search_box' => true,
664 'search' => array("stock_id", "c.description","s.description"),
665 'search_submit' => get_company_pref('no_item_list')!=0,
667 'select_submit'=> $submit_on_change,
669 'order' => array('c.description','stock_id')
673 function _format_stock_items($row)
675 return (user_show_codes() ? ($row[0] . " - ") : "") . $row[1];
678 function stock_items_list_cells($label, $name, $selected_id=null, $all_option=false,
679 $submit_on_change=false, $all=false)
682 echo "<td>$label</td>\n";
683 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
684 array('cells'=>true, 'show_inactive'=>$all));
688 function stock_items_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
691 $str = stock_items_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
696 //---------------------------------------------------------------------------------------------------
698 // Select item via foreign code.
700 function sales_items_list($name, $selected_id=null, $all_option=false,
701 $submit_on_change=false, $type='', $opts=array())
705 $sql = "SELECT i.item_code, i.description, c.description, count(*)>1 as kit,
708 ".TB_PREF."stock_master s,
709 ".TB_PREF."item_codes i
711 ".TB_PREF."stock_category c
712 ON i.category_id=c.category_id
713 WHERE i.stock_id=s.stock_id";
716 if ($type == 'local') { // exclude foreign codes
717 $sql .= " AND !i.is_foreign";
718 } elseif ($type == 'kits') { // sales kits
719 $sql .= " AND !i.is_foreign AND i.item_code!=i.stock_id";
721 $sql .= " AND !i.inactive AND !s.inactive AND !s.no_sale";
722 $sql .= " GROUP BY i.item_code";
724 return combo_input($name, $selected_id, $sql, 'i.item_code', 'c.description',
727 'format' => '_format_stock_items',
728 'spec_option' => $all_option===true ? _("All Items") : $all_option,
729 'spec_id' => $all_items,
730 'search_box' => true,
731 'search' => array("i.item_code", "i.description"),
732 'search_submit' => get_company_pref('no_item_list')!=0,
734 'select_submit'=> $submit_on_change,
736 'order' => array('c.description','i.item_code')
740 function sales_items_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
743 echo "<td>$label</td>\n";
744 $str = sales_items_list($name, $selected_id, $all_option, $submit_on_change,
745 '', array('cells'=>true));
749 function sales_kits_list($name, $selected_id=null, $all_option=false, $submit_on_change=false)
751 $str = sales_items_list($name, $selected_id, $all_option, $submit_on_change,
752 'kits', array('cells'=>false));
756 function sales_local_items_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
760 echo "<td>$label</td>\n";
762 $str = sales_items_list($name, $selected_id, $all_option, $submit_on_change,
763 'local', array('cells'=>false));
767 //------------------------------------------------------------------------------------
769 function stock_manufactured_items_list($name, $selected_id=null,
770 $all_option=false, $submit_on_change=false)
772 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
773 array('where'=>array("mb_flag= 'M'")));
777 function stock_manufactured_items_list_cells($label, $name, $selected_id=null,
778 $all_option=false, $submit_on_change=false)
781 echo "<td>$label</td>\n";
783 $str = stock_manufactured_items_list($name, $selected_id, $all_option, $submit_on_change);
788 function stock_manufactured_items_list_row($label, $name, $selected_id=null,
789 $all_option=false, $submit_on_change=false)
792 $str = stock_manufactured_items_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
796 //------------------------------------------------------------------------------------
798 function stock_component_items_list($name, $parent_stock_id, $selected_id=null,
799 $all_option=false, $submit_on_change=false)
801 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
802 array('where'=>array("stock_id != '$parent_stock_id'")));
806 function stock_component_items_list_cells($label, $name, $parent_stock_id,
807 $selected_id=null, $all_option=false, $submit_on_change=false)
810 echo "<td>$label</td>\n";
811 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
812 array('where'=>array("stock_id != '$parent_stock_id'"), 'cells'=>true));
815 //------------------------------------------------------------------------------------
817 function stock_costable_items_list($name, $selected_id=null,
818 $all_option=false, $submit_on_change=false)
820 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
821 array('where'=>array("mb_flag!='D'")));
825 function stock_costable_items_list_cells($label, $name, $selected_id=null,
826 $all_option=false, $submit_on_change=false)
829 echo "<td>$label</td>\n";
830 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
831 array('where'=>array("mb_flag!='D'"), 'cells'=>true));
835 //------------------------------------------------------------------------------------
836 function stock_purchasable_items_list($name, $selected_id=null,
837 $all_option=false, $submit_on_change=false, $all=false)
839 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
840 array('where'=>array("mb_flag!= 'M'"),
841 'show_inactive'=>$all));
845 function stock_purchasable_items_list_cells($label, $name, $selected_id=null,
846 $all_option=false, $submit_on_change=false, $all=false)
849 echo "<td>$label</td>\n";
850 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
851 array('where'=>array("mb_flag!= 'M'"),
856 function stock_purchasable_items_list_row($label, $name, $selected_id=null,
857 $all_option=false, $submit_on_change=false)
860 $ret = stock_purchasable_items_list_cells($label, $name, $selected_id=null,
861 $all_option, $submit_on_change);
866 //------------------------------------------------------------------------------------
868 function stock_item_types_list_row($label, $name, $selected_id=null, $enabled=true)
874 echo "<td>$label</td>\n";
877 array_selector($name, $selected_id, $stock_types,
879 'select_submit'=> true,
880 'disabled' => !$enabled) );
884 function stock_units_list_row($label, $name, $value=null, $enabled=true)
886 $result = get_all_item_units();
889 echo "<td>$label</td>\n";
892 while($unit = db_fetch($result))
893 $units[$unit['abbr']] = $unit['name'];
895 array_selector($name, $value, $units, array( 'disabled' => !$enabled) );
900 //------------------------------------------------------------------------------------
902 function tax_types_list($name, $selected_id=null, $none_option=false, $submit_on_change=false)
904 $sql = "SELECT id, CONCAT(name, ' (',rate,'%)') as name FROM ".TB_PREF."tax_types";
906 return combo_input($name, $selected_id, $sql, 'id', 'name',
908 'spec_option' => $none_option,
909 'spec_id' => reserved_words::get_all_numeric(),
910 'select_submit'=> $submit_on_change,
915 function tax_types_list_cells($label, $name, $selected_id=null, $none_option=false,
916 $submit_on_change=false)
919 echo "<td>$label</td>\n";
921 $str = tax_types_list($name, $selected_id, $none_option, $submit_on_change);
926 function tax_types_list_row($label, $name, $selected_id=null, $none_option=false,
927 $submit_on_change=false)
930 $str = tax_types_list_cells($label, $name, $selected_id, $none_option, $submit_on_change);
935 //------------------------------------------------------------------------------------
937 function tax_groups_list($name, $selected_id=null,
938 $none_option=false, $submit_on_change=false)
940 $sql = "SELECT id, name FROM ".TB_PREF."tax_groups";
942 return combo_input($name, $selected_id, $sql, 'id', 'name',
945 'spec_option' => $none_option,
946 'spec_id' => reserved_words::get_all_numeric(),
947 'select_submit'=> $submit_on_change,
952 function tax_groups_list_cells($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false)
955 echo "<td>$label</td>\n";
957 $str = tax_groups_list($name, $selected_id, $none_option, $submit_on_change);
962 function tax_groups_list_row($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false)
965 $str = tax_groups_list_cells($label, $name, $selected_id, $none_option, $submit_on_change);
970 //------------------------------------------------------------------------------------
972 function item_tax_types_list($name, $selected_id=null)
974 $sql ="SELECT id, name FROM ".TB_PREF."item_tax_types";
975 combo_input($name, $selected_id, $sql, 'id', 'name', array('order' => 'id') );
978 function item_tax_types_list_cells($label, $name, $selected_id=null)
981 echo "<td>$label</td>\n";
983 item_tax_types_list($name, $selected_id);
987 function item_tax_types_list_row($label, $name, $selected_id=null)
990 item_tax_types_list_cells($label, $name, $selected_id);
994 //------------------------------------------------------------------------------------
996 function shippers_list($name, $selected_id=null)
998 $sql = "SELECT shipper_id, shipper_name, inactive FROM ".TB_PREF."shippers";
999 combo_input($name, $selected_id, $sql, 'shipper_id', 'shipper_name', array());
1002 function shippers_list_cells($label, $name, $selected_id=null)
1005 echo "<td>$label</td>\n";
1007 shippers_list($name, $selected_id);
1011 function shippers_list_row($label, $name, $selected_id=null)
1014 shippers_list_cells($label, $name, $selected_id);
1018 //-------------------------------------------------------------------------------------
1020 function sales_persons_list($name, $selected_id=null)
1022 $sql = "SELECT salesman_code, salesman_name, inactive FROM ".TB_PREF."salesman";
1023 combo_input($name, $selected_id, $sql, 'salesman_code', 'salesman_name', array());
1026 function sales_persons_list_cells($label, $name, $selected_id=null)
1029 echo "<td>$label</td>\n";
1031 sales_persons_list($name, $selected_id);
1035 function sales_persons_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1038 sales_persons_list_cells($label, $name, $selected_id, $submit_on_change=false);
1042 //------------------------------------------------------------------------------------
1044 function sales_areas_list($name, $selected_id=null)
1046 $sql = "SELECT area_code, description, inactive FROM ".TB_PREF."areas";
1047 combo_input($name, $selected_id, $sql, 'area_code', 'description', array());
1050 function sales_areas_list_cells($label, $name, $selected_id=null)
1053 echo "<td>$label</td>\n";
1055 sales_areas_list($name, $selected_id);
1059 function sales_areas_list_row($label, $name, $selected_id=null)
1062 sales_areas_list_cells($label, $name, $selected_id);
1066 //------------------------------------------------------------------------------------
1068 function sales_groups_list($name, $selected_id=null, $special_option=false)
1070 $sql = "SELECT id, description, inactive FROM ".TB_PREF."groups";
1071 combo_input($name, $selected_id, $sql, 'id', 'description', array(
1072 'spec_option' => $special_option===true ? ' ' : $special_option,
1073 'order' => 'description', 'spec_id' => 0,
1077 function sales_groups_list_cells($label, $name, $selected_id=null, $special_option=false)
1080 echo "<td>$label</td>\n";
1082 sales_groups_list($name, $selected_id, $special_option);
1086 function sales_groups_list_row($label, $name, $selected_id=null, $special_option=false)
1089 sales_groups_list_cells($label, $name, $selected_id, $special_option);
1093 //------------------------------------------------------------------------------------
1095 function _format_template_items($row)
1097 return ($row[0] . " - " . _("Amount") . " ".$row[1]);
1100 function templates_list($name, $selected_id=null, $special_option=false)
1102 $sql = "SELECT sorder.order_no, Sum(line.unit_price*line.quantity*(1-line.discount_percent)) AS OrderValue
1103 FROM ".TB_PREF."sales_orders as sorder, ".TB_PREF."sales_order_details as line
1104 WHERE sorder.order_no = line.order_no AND sorder.type = 1 GROUP BY line.order_no";
1105 combo_input($name, $selected_id, $sql, 'order_no', 'OrderValue', array(
1106 'format' => '_format_template_items',
1107 'spec_option' => $special_option===true ? ' ' : $special_option,
1108 'order' => 'order_no', 'spec_id' => 0,
1112 function templates_list_cells($label, $name, $selected_id=null, $special_option=false)
1115 echo "<td>$label</td>\n";
1117 templates_list($name, $selected_id, $special_option);
1121 function templates_list_row($label, $name, $selected_id=null, $special_option=false)
1124 templates_list_cells($label, $name, $selected_id, $special_option);
1128 //------------------------------------------------------------------------------------
1130 function workorders_list($name, $selected_id=null)
1132 $sql = "SELECT id, wo_ref FROM ".TB_PREF."workorders WHERE closed=0";
1133 combo_input($name, $selected_id, $sql, 'id', 'wo_ref', array());
1136 function workorders_list_cells($label, $name, $selected_id=null)
1139 echo "<td>$label</td>\n";
1141 workorders_list($name, $selected_id);
1145 function workorders_list_row($label, $name, $selected_id=null)
1148 workorders_list_cells($label, $name, $selected_id);
1152 //------------------------------------------------------------------------------------
1154 function payment_terms_list($name, $selected_id=null)
1156 $sql = "SELECT terms_indicator, terms, inactive FROM ".TB_PREF."payment_terms";
1157 combo_input($name, $selected_id, $sql, 'terms_indicator', 'terms', array());
1160 function payment_terms_list_cells($label, $name, $selected_id=null)
1163 echo "<td>$label</td>\n";
1165 payment_terms_list($name, $selected_id);
1169 function payment_terms_list_row($label, $name, $selected_id=null)
1172 payment_terms_list_cells($label, $name, $selected_id);
1176 //------------------------------------------------------------------------------------
1178 function credit_status_list($name, $selected_id=null)
1180 $sql ="SELECT id, reason_description, inactive FROM ".TB_PREF."credit_status";
1181 combo_input($name, $selected_id, $sql, 'id', 'reason_description', array());
1184 function credit_status_list_cells($label, $name, $selected_id=null)
1187 echo "<td>$label</td>\n";
1189 credit_status_list($name, $selected_id);
1193 function credit_status_list_row($label, $name, $selected_id=null)
1196 credit_status_list_cells($label, $name, $selected_id);
1200 //-----------------------------------------------------------------------------------------------
1202 function sales_types_list($name, $selected_id=null, $submit_on_change=false, $special_option=false)
1204 $sql = "SELECT id, sales_type, inactive FROM ".TB_PREF."sales_types";
1206 return combo_input($name, $selected_id, $sql, 'id', 'sales_type',
1208 'spec_option' => $special_option===true ? _("All Sales Types") : $special_option,
1210 'select_submit'=> $submit_on_change,
1211 // 'async' => false,
1215 function sales_types_list_cells($label, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1218 echo "<td>$label</td>\n";
1220 $str = sales_types_list($name, $selected_id, $submit_on_change, $special_option);
1225 function sales_types_list_row($label, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1228 $str = sales_types_list_cells($label, $name, $selected_id, $submit_on_change, $special_option);
1233 //-----------------------------------------------------------------------------------------------
1235 function movement_types_list($name, $selected_id=null)
1237 $sql = "SELECT id, name FROM ".TB_PREF."movement_types";
1238 combo_input($name, $selected_id, $sql, 'id', 'name', array());
1241 function movement_types_list_cells($label, $name, $selected_id=null)
1244 echo "<td>$label</td>\n";
1246 movement_types_list($name, $selected_id);
1250 function movement_types_list_row($label, $name, $selected_id=null)
1253 movement_types_list_cells($label, $name, $selected_id);
1257 //-----------------------------------------------------------------------------------------------
1258 function _format_date($row)
1260 return sql2date($row['reconciled']);
1263 function bank_reconciliation_list($account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1265 $sql = "SELECT reconciled, reconciled FROM ".TB_PREF."bank_trans
1266 WHERE bank_act=".db_escape($account)." AND reconciled IS NOT NULL
1267 GROUP BY reconciled";
1268 combo_input($name, $selected_id, $sql, 'id', 'reconciled',
1270 'spec_option' => $special_option,
1271 'format' => '_format_date',
1273 'select_submit'=> $submit_on_change
1277 function bank_reconciliation_list_cells($label,$account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1280 echo "<td>$label</td>\n";
1282 bank_reconciliation_list($account, $name, $selected_id, $submit_on_change, $special_option);
1286 function bank_reconciliation_list_row($label, $account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1289 bank_reconciliation_list_cells($label, $account, $name, $selected_id, $submit_on_change, $special_option);
1293 //-----------------------------------------------------------------------------------------------
1295 function workcenter_list($name, $selected_id=null, $all_option=false)
1299 $sql = "SELECT id, name, inactive FROM ".TB_PREF."workcentres";
1301 return combo_input($name, $selected_id, $sql, 'id', 'name',
1303 'spec_option' =>$all_option===true ? _("All Suppliers") : $all_option,
1304 'spec_id' => $all_items,
1308 function workcenter_list_cells($label, $name, $selected_id=null, $all_option=false)
1310 default_focus($name);
1312 echo "<td>$label</td>\n";
1314 workcenter_list($name, $selected_id, $all_option);
1318 function workcenter_list_row($label, $name, $selected_id=null, $all_option=false)
1321 workcenter_list_cells($label, $name, $selected_id, $all_option);
1325 //-----------------------------------------------------------------------------------------------
1327 function bank_accounts_list($name, $selected_id=null, $submit_on_change=false)
1329 $sql = "SELECT ".TB_PREF."bank_accounts.id, bank_account_name, bank_curr_code, inactive
1330 FROM ".TB_PREF."bank_accounts";
1331 // , ".TB_PREF."chart_master
1332 // WHERE ".TB_PREF."bank_accounts.account_code=".TB_PREF."chart_master.account_code";
1334 return combo_input($name, $selected_id, $sql, 'id', 'bank_account_name',
1336 'format' => '_format_add_curr',
1337 'select_submit'=> $submit_on_change,
1342 function bank_accounts_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1345 echo "<td>$label</td>\n";
1347 $str = bank_accounts_list($name, $selected_id, $submit_on_change);
1352 function bank_accounts_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1355 $str = bank_accounts_list_cells($label, $name, $selected_id, $submit_on_change);
1359 //-----------------------------------------------------------------------------------------------
1361 function cash_accounts_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1363 $sql = "SELECT ".TB_PREF."bank_accounts.id, bank_account_name, bank_curr_code, inactive
1364 FROM ".TB_PREF."bank_accounts
1365 WHERE ".TB_PREF."bank_accounts.account_type=3";
1368 echo "<tr><td>$label</td>\n";
1370 $str = combo_input($name, $selected_id, $sql, 'id', 'bank_account_name',
1372 'format' => '_format_add_curr',
1373 'select_submit'=> $submit_on_change,
1376 echo "</td></tr>\n";
1379 //-----------------------------------------------------------------------------------------------
1381 function pos_list_row($label, $name, $selected_id=null, $spec_option=false, $submit_on_change=false)
1383 $sql = "SELECT id, pos_name, inactive FROM ".TB_PREF."sales_pos";
1385 default_focus($name);
1388 echo "<td>$label</td>\n";
1391 $str = combo_input($name, $selected_id, $sql, 'id', 'pos_name',
1393 'select_submit'=> $submit_on_change,
1395 'spec_option' =>$spec_option,
1398 echo "</td></tr>\n";
1402 //-----------------------------------------------------------------------------------------------
1404 function sale_payment_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1407 echo "<td>$label</td>\n";
1409 $str = yesno_list($name, $selected_id, _('Cash'), _('Delayed'), $submit_on_change);
1413 //-----------------------------------------------------------------------------------------------
1415 function class_list($name, $selected_id=null, $submit_on_change=false)
1417 $sql = "SELECT cid, class_name FROM ".TB_PREF."chart_class";
1419 return combo_input($name, $selected_id, $sql, 'cid', 'class_name',
1421 'select_submit'=> $submit_on_change,
1427 function class_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1430 echo "<td>$label</td>\n";
1432 $str = class_list($name, $selected_id, $submit_on_change);
1437 function class_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1440 $str = class_list_cells($label, $name, $selected_id, $submit_on_change);
1445 //-----------------------------------------------------------------------------------------------
1447 function stock_categories_list($name, $selected_id=null, $submit_on_change=false)
1449 $sql = "SELECT category_id, description, inactive FROM ".TB_PREF."stock_category";
1450 combo_input($name, $selected_id, $sql, 'category_id', 'description',
1451 array('order'=>'category_id',
1452 'select_submit'=> $submit_on_change,
1457 function stock_categories_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1460 echo "<td>$label</td>\n";
1462 stock_categories_list($name, $selected_id, $submit_on_change);
1466 function stock_categories_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1469 stock_categories_list_cells($label, $name, $selected_id, $submit_on_change);
1473 //-----------------------------------------------------------------------------------------------
1475 function gl_account_types_list($name, $selected_id=null, $all_option, $all_option_numeric)
1479 $sql = "SELECT id, name FROM ".TB_PREF."chart_types";
1481 combo_input($name, $selected_id, $sql, 'id', 'name',
1484 'spec_option' =>$all_option,
1485 'spec_id' => $all_option_numeric ? 0 : $all_items
1489 function gl_account_types_list_cells($label, $name, $selected_id=null, $all_option=false,
1490 $all_option_numeric=false)
1493 echo "<td>$label</td>\n";
1495 gl_account_types_list($name, $selected_id, $all_option, $all_option_numeric);
1499 function gl_account_types_list_row($label, $name, $selected_id=null, $all_option=false,
1500 $all_option_numeric=false)
1503 gl_account_types_list_cells($label, $name, $selected_id, $all_option,
1504 $all_option_numeric);
1508 //-----------------------------------------------------------------------------------------------
1509 function gl_all_accounts_list($name, $selected_id=null, $skip_bank_accounts=false,
1510 $cells=false, $all_option=false, $submit_on_change=false, $all=false)
1512 if ($skip_bank_accounts)
1513 $sql = "SELECT chart.account_code, chart.account_name, type.name, chart.inactive
1514 FROM (".TB_PREF."chart_master chart,".TB_PREF."chart_types type) "
1515 ."LEFT JOIN ".TB_PREF."bank_accounts acc "
1516 ."ON chart.account_code=acc.account_code
1517 WHERE acc.account_code IS NULL
1518 AND chart.account_type=type.id";
1520 $sql = "SELECT chart.account_code, chart.account_name, type.name, chart.inactive
1521 FROM ".TB_PREF."chart_master chart,".TB_PREF."chart_types type
1522 WHERE chart.account_type=type.id";
1524 combo_input($name, $selected_id, $sql, 'chart.account_code', 'chart.account_name',
1526 'format' => '_format_account',
1527 'spec_option' => $all_option===true ? _("Use Item Sales Accounts") : $all_option,
1529 'order' => array('name','account_code'),
1530 'search_box' => $cells,
1531 'search_submit' => false,
1535 'select_submit'=> $submit_on_change,
1538 'show_inactive' => $all
1543 function _format_account($row)
1545 return $row[0] . " " . $row[1];
1548 function gl_all_accounts_list_cells($label, $name, $selected_id=null,
1549 $skip_bank_accounts=false, $cells=false, $all_option=false,
1550 $submit_on_change=false, $all=false)
1553 echo "<td>$label</td>\n";
1555 gl_all_accounts_list($name, $selected_id,
1556 $skip_bank_accounts, $cells, $all_option, $submit_on_change, $all);
1560 function gl_all_accounts_list_row($label, $name, $selected_id=null,
1561 $skip_bank_accounts=false, $cells=false, $all_option=false)
1564 gl_all_accounts_list_cells($label, $name, $selected_id,
1565 $skip_bank_accounts, $cells, $all_option);
1569 function yesno_list($name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1572 $items['0'] = strlen($name_no) ? $name_no : _("No");
1573 $items['1'] = strlen($name_yes) ? $name_yes : _("Yes");
1575 return array_selector($name, $selected_id, $items,
1577 'select_submit'=> $submit_on_change,
1578 'async' => false ) ); // FIX?
1581 function yesno_list_cells($label, $name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1584 echo "<td>$label</td>\n";
1586 $str = yesno_list($name, $selected_id, $name_yes, $name_no, $submit_on_change);
1591 function yesno_list_row($label, $name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1594 $str = yesno_list_cells($label, $name, $selected_id, $name_yes, $name_no, $submit_on_change);
1599 //------------------------------------------------------------------------------------------------
1601 function languages_list($name, $selected_id=null)
1603 global $installed_languages;
1606 foreach ($installed_languages as $lang)
1607 $items[$lang['code']] = $lang['name'];
1609 return array_selector($name, $selected_id, $items );
1612 function languages_list_cells($label, $name, $selected_id=null)
1615 echo "<td>$label</td>\n";
1617 languages_list($name, $selected_id);
1621 function languages_list_row($label, $name, $selected_id=null)
1624 languages_list_cells($label, $name, $selected_id);
1628 //------------------------------------------------------------------------------------------------
1630 function bank_account_types_list($name, $selected_id=null)
1632 $types = bank_account_types::get_all();
1635 foreach ($types as $type)
1637 $items[$type['id']] = $type['name'];
1640 return array_selector($name, $selected_id, $items );
1643 function bank_account_types_list_cells($label, $name, $selected_id=null)
1646 echo "<td>$label</td>\n";
1648 bank_account_types_list($name, $selected_id);
1652 function bank_account_types_list_row($label, $name, $selected_id=null)
1655 bank_account_types_list_cells($label, $name, $selected_id);
1659 //------------------------------------------------------------------------------------------------
1660 function payment_person_types_list($name, $selected_id=null, $submit_on_change=false)
1662 $types = payment_person_types::get_all();
1665 foreach ($types as $type)
1667 if (payment_person_types::has_items($type['id']))
1669 if ($type['id'] != payment_person_types::WorkOrder())
1670 $items[$type['id']] = $type['name'];
1674 return array_selector($name, $selected_id, $items,
1675 array( 'select_submit'=> $submit_on_change ) );
1678 function payment_person_types_list_cells($label, $name, $selected_id=null, $related=null)
1681 echo "<td>$label</td>\n";
1683 $str = payment_person_types_list($name, $selected_id, $related);
1688 function payment_person_types_list_row($label, $name, $selected_id=null, $related=null)
1691 $str = payment_person_types_list_cells($label, $name, $selected_id, $related);
1696 //------------------------------------------------------------------------------------------------
1698 function wo_types_list($name, $selected_id=null)
1700 $types = wo_types::get_all();
1703 foreach ($types as $type)
1704 $items[$type['id']] = $type['name'];
1706 return array_selector($name, $selected_id, $items,
1707 array( 'select_submit'=> true, 'async' => true ) );
1710 function wo_types_list_row($label, $name, $selected_id=null)
1712 echo "<tr><td>$label</td><td>\n";
1713 $str = wo_types_list($name, $selected_id);
1714 echo "</td></tr>\n";
1718 //------------------------------------------------------------------------------------------------
1720 function dateformats_list_row($label, $name, $value=null)
1722 global $dateformats;
1724 echo "<tr><td>$label</td>\n<td>";
1725 array_selector( $name, $value, $dateformats );
1726 echo "</td></tr>\n";
1729 function dateseps_list_row($label, $name, $value=null)
1733 echo "<tr><td>$label</td>\n<td>";
1734 array_selector( $name, $value, $dateseps );
1735 echo "</td></tr>\n";
1738 function thoseps_list_row($label, $name, $value=null)
1742 echo "<tr><td>$label</td>\n<td>";
1743 array_selector( $name, $value, $thoseps );
1744 echo "</td></tr>\n";
1747 function decseps_list_row($label, $name, $value=null)
1751 echo "<tr><td>$label</td>\n<td>";
1752 array_selector( $name, $value, $decseps );
1753 echo "</td></tr>\n";
1756 function themes_list_row($label, $name, $value=null)
1758 global $path_to_root;
1760 $path = $path_to_root.'/themes/';
1762 $themedir = opendir($path);
1763 while(false !== ($fname = readdir($themedir)))
1765 if($fname!='.' && $fname!='..' && $fname!='CVS' && is_dir($path.$fname))
1767 $themes[$fname] = $fname;
1772 echo "<tr><td>$label</td>\n<td>";
1773 array_selector( $name, $value, $themes );
1774 echo "</td></tr>\n";
1777 function pagesizes_list_row($label, $name, $value=null)
1782 foreach ($pagesizes as $pz)
1785 echo "<tr><td>$label</td>\n<td>";
1786 array_selector( $name, $value, $items );
1787 echo "</td></tr>\n";
1790 function security_headings_list_row($label, $name, $value=null)
1792 global $security_headings;
1794 echo "<tr><td>$label</td>\n<td>";
1795 array_selector( $name, $value, $security_headings );
1796 echo "</td></tr>\n";
1799 function systypes_list_cells($label, $name, $value=null, $submit_on_change=false)
1801 global $systypes_array;
1804 echo "<td>$label</td>\n";
1808 foreach ($systypes_array as $key=>$type)
1809 $items[$key] = $type['name'];
1811 $str = array_selector($name, $value, $items,
1813 'select_submit'=> $submit_on_change,
1821 function journal_types_list_cells($label, $name, $value=null, $submit_on_change=false)
1823 global $systypes_array;
1826 echo "<td>$label</td>\n";
1830 foreach ($systypes_array as $key=>$type)
1831 // exclude orders and dimensions
1832 if (!in_array($key, array(18,26,30,40)))
1833 $items[$key] = $type['name'];
1835 $str = array_selector($name, $value, $items,
1837 'spec_option'=> _("All"),
1839 'select_submit'=> $submit_on_change,
1847 function systypes_list_row($label, $name, $value=null, $submit_on_change=false)
1850 $str = systypes_list_cells($label, $name, $value, $submit_on_change);
1855 function cust_allocations_list_cells($label, $name, $selected=null)
1863 $all_items=>_("All Types"),
1864 '1'=> _("Sales Invoices"),
1865 '2'=> _("Overdue Invoices"),
1866 '3' => _("Payments"),
1867 '4' => _("Credit Notes"),
1868 '5' => _("Delivery Notes")
1870 $str = array_selector($name, $selected, $allocs);
1875 function supp_allocations_list_cell($name, $selected=null)
1881 $all_items=>_("All Types"),
1882 '1'=> _("Invoices"),
1883 '2'=> _("Overdue Invoices"),
1884 '3' => _("Payments"),
1885 '4' => _("Credit Notes"),
1886 '5' => _("Overdue Credit Notes")
1888 $str = array_selector($name, $selected, $allocs);
1893 function policy_list_cells($label, $name, $selected=null)
1898 $str = array_selector($name, $selected,
1899 array( '' => _("Automatically put balance on back order"),
1900 'CAN' => _("Cancel any quantites not delivered")) );
1905 function policy_list_row($label, $name, $selected=null)
1908 policy_list_cells($label, $name, $selected);
1912 function credit_type_list_cells($label, $name, $selected=null, $submit_on_change=false)
1917 $str = array_selector($name, $selected,
1918 array( 'Return' => _("Items Returned to Inventory Location"),
1919 'WriteOff' => _("Items Written Off")),
1920 array( 'select_submit'=> $submit_on_change ) );
1925 function credit_type_list_row($label, $name, $selected=null, $submit_on_change=false)
1928 $str = credit_type_list_cells($label, $name, $selected, $submit_on_change);
1933 function number_list($name, $selected, $from, $to, $no_option=false)
1936 for ($i = $from; $i <= $to; $i++)
1939 return array_selector($name, $selected, $items,
1940 array( 'spec_option' => $no_option,
1941 'spec_id' => reserved_words::get_all_numeric()) );
1944 function number_list_cells($label, $name, $selected, $from, $to, $no_option=false)
1949 number_list($name, $selected, $from, $to, $no_option);
1953 function number_list_row($label, $name, $selected, $from, $to, $no_option=false)
1956 number_list_cells($label, $name, $selected, $from, $to, $no_option);
1960 function print_profiles_list_row($label, $name, $selected_id=null, $spec_opt=false,
1961 $submit_on_change=true)
1963 $sql = "SELECT profile FROM ".TB_PREF."print_profiles"
1964 ." GROUP BY profile";
1965 $result = db_query($sql, 'cannot get all profile names');
1966 $profiles = array();
1967 while($myrow=db_fetch($result)) {
1968 $profiles[$myrow['profile']] = $myrow['profile'];
1973 echo "<td>$label</td>\n";
1976 array_selector($name, $selected_id, $profiles,
1977 array( 'select_submit'=> $submit_on_change,
1978 'spec_option'=>$spec_opt,
1982 echo "</td></tr>\n";
1985 function printers_list($name, $selected_id=null, $spec_opt=false, $submit_on_change=false)
1987 static $printers; // query only once for page display
1990 $sql = "SELECT id, name, description FROM ".TB_PREF."printers";
1991 $result = db_query($sql, 'cannot get all printers');
1992 $printers = array();
1993 while($myrow=db_fetch($result)) {
1994 $printers[$myrow['id']] = $myrow['name'].' - '.$myrow['description'];
1997 array_selector($name, $selected_id, $printers,
1998 array( 'select_submit'=> $submit_on_change,
1999 'spec_option'=>$spec_opt,
2004 //------------------------------------------------------------------------------------------------
2006 function quick_entries_list($name, $selected_id=null, $type=null, $submit_on_change=false)
2009 $sql = "SELECT id, description FROM ".TB_PREF."quick_entries";
2011 $sql .= " WHERE type=$type";
2013 combo_input($name, $selected_id, $sql, 'id', 'description',
2016 'order' => 'description',
2017 'select_submit'=> $submit_on_change,
2023 function quick_entries_list_cells($label, $name, $selected_id=null, $type, $submit_on_change=false)
2025 echo "<td>$label</td><td>\n";
2026 quick_entries_list($name, $selected_id, $type, $submit_on_change);
2030 function quick_entries_list_row($label, $name, $selected_id=null, $type, $submit_on_change=false)
2033 quick_entries_list_cells($label, $name, $selected_id, $type, $submit_on_change);
2038 function quick_actions_list_row($label, $name, $selected_id=null, $submit_on_change=false)
2040 global $quick_actions;
2042 echo "<tr><td>$label</td><td>";
2043 array_selector($name, $selected_id, $quick_actions,
2045 'select_submit'=> $submit_on_change
2047 echo "</td></tr>\n";
2050 function quick_entry_types_list_row($label, $name, $selected_id=null, $submit_on_change=false)
2052 global $quick_entry_types;
2054 echo "<tr><td>$label</td><td>";
2055 array_selector($name, $selected_id, $quick_entry_types,
2057 'select_submit'=> $submit_on_change
2059 echo "</td></tr>\n";
2062 function record_status_list_row($label, $name) {
2063 return yesno_list_row($label, $name, null, _('Inactive'), _('Active'));
2066 function class_types_list_row($label, $name, $selected_id=null, $submit_on_change=false)
2068 global $class_types;
2070 echo "<tr><td>$label</td><td>";
2071 array_selector($name, $selected_id, $class_types,
2073 'select_submit'=> $submit_on_change
2075 echo "</td></tr>\n";