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
63 'show_inactive' => false // show inactive records.
65 // ------ merge options with defaults ----------
67 $opts = array_merge($opts, $options);
68 if (!is_array($opts['where'])) $opts['where'] = array($opts['where']);
70 $search_box = $opts['search_box']===true ? '_'.$name.'_edit' : $opts['search_box'];
71 $search_submit = $opts['search_submit']===true ? '_'.$name.'_button' : $opts['search_submit'];
72 $select_submit = $opts['select_submit']===true ? '_'.$name.'_update' : $opts['select_submit'];
73 $spec_id = $opts['spec_id'];
74 $spec_option = $opts['spec_option'];
75 $by_id = ($opts['type'] == 0);
76 $class = $by_id ? 'combo':'combo2';
77 $disabled = $opts['disabled'] ? "disabled" : '';
79 if(!count($opts['search'])) {
80 $opts['search'] = array($by_id ? $valfield : $namefield);
82 if ($opts['sel_hint'] === null)
83 $opts['sel_hint'] = $by_id || $search_box==false ?
84 '' : _('Press Space tab for search pattern entry');
86 if ($opts['box_hint'] === null)
87 $opts['box_hint'] = $search_box && $search_submit != false ?
88 ($by_id ? _('Enter code fragment to search or * for all')
89 : _('Enter description fragment to search or * for all')) :'';
91 if ($selected_id == null) {
92 $selected_id = get_post($name, $opts['default']);
94 $txt = get_post($search_box);
98 if (isset($_POST[$select_submit])) {
99 if ($by_id) $txt = $_POST[$name];
102 $Ajax->activate('_page_body');
104 $Ajax->activate($name);
107 // search related sql modifications
109 $rel = "rel='$search_box'"; // set relation to list
110 if ($opts['search_submit']) {
111 if (isset($_POST[$search_submit])) {
112 $selected_id = ''; // ignore selected_id while search
114 $Ajax->activate('_page_body');
116 $Ajax->activate($name);
119 if ($spec_option === false && $selected_id==null)
122 $opts['where'][] = $valfield . "='". get_post($name, $spec_id)."'";
127 foreach($opts['search'] as $i=> $s)
128 $opts['search'][$i] = $s . " LIKE '%{$txt}%'";
129 $opts['where'][] = '('. implode($opts['search'], ' OR ') . ')';
134 if (count($opts['where'])) {
135 $where = strpos($sql, 'WHERE')==false ? ' WHERE ':' AND ';
136 $where .= '('. implode($opts['where'], ' AND ') . ')';
137 $group_pos = strpos($sql, 'GROUP BY');
139 $group = substr($sql, $group_pos);
140 $sql = substr($sql, 0, $group_pos) . $where.' '.$group;
145 if ($opts['order'] != false) {
146 if (!is_array($opts['order']))
147 $opts['order'] = array($opts['order']);
148 $sql .= ' ORDER BY '.implode(',',$opts['order']);
152 // ------ make selector ----------
153 $selector = $first_opt = '';
157 //if($name=='stock_id') display_error($sql);
158 if($result = db_query($sql)) {
159 while ($contact_row = db_fetch($result)) {
160 $value = $contact_row[0];
161 $descr = $opts['format']==null ? $contact_row[1] :
162 call_user_func($opts['format'], $contact_row);
164 if (get_post($search_submit) && ($txt === $value)) {
165 $selected_id = $value;
167 if ((string)($selected_id) === $value) {
171 // show selected option even if inactive
172 if (!$opts['show_inactive'] && @$contact_row['inactive'] && $sel==='') {
175 $optclass = @$contact_row['inactive'] ? "class='inactive'" : '';
177 if ($first_id === false) {
181 $cat = $contact_row[$opts['category']];
182 if ($opts['category'] !== false && $cat != $lastcat){
183 $selector .= "<optgroup label='".$cat."'>\n";
186 $selector .= "<option $sel $optclass value='$value'>$descr</option>\n";
188 db_free_result($result);
191 // Prepend special option.
192 if ($spec_option !== false) { // if special option used - add it
193 $first_id = $spec_id;
194 $first_opt = $spec_option;
196 // if($first_id !== false) {
197 $sel = $found===false ? 'selected' : '';
198 $optclass = @$contact_row['inactive'] ? "class='inactive'" : '';
199 $selector = "<option $sel value='$first_id'>$first_opt</option>\n"
203 if ($found === false) {
204 $selected_id = $first_id;
206 $_POST[$name] = $selected_id;
208 if ($by_id && $search_box != false) {
210 $Ajax->addUpdate($name, $search_box, $txt ? $txt : '');
212 $aspect = $opts['edit_submit'] ? " aspect='editable'" : '';
213 $selector = "<select $disabled name='$name' class='$class' title='"
214 . $opts['sel_hint']."'$aspect $rel>".$selector."</select>\n";
216 $Ajax->addUpdate($name, "_{$name}_sel", $selector);
218 // because of bug which M$ cannot fix since IE 5.0
219 // we must embed whole selector in span tags to enable proper ajax update
220 $selector = "<span id='_{$name}_sel'>".$selector."</span>\n";
222 if ($select_submit != false) { // if submit on change is used - add select button
223 global $_select_button;
224 // button class selects form reload/ajax selector update
225 $selector .= sprintf($_select_button, $disabled, user_theme(),
226 (fallback_mode() ? '' : 'display:none;'),
227 $select_submit)."\n";
229 // ------ make combo ----------
232 if ($search_box != false) {
233 $edit_entry = "<input $disabled type='text' name='$search_box' id='$search_box' size='".
234 $opts['size']."' maxlength='".$opts['max'].
235 "' value='$txt' class='$class' rel='$name' autocomplete='off' title='"
236 .$opts['box_hint']."'"
237 .(!fallback_mode() && !$by_id ? " style=display:none;":'')
239 if ($search_submit != false) {
240 global $_search_button;
241 $edit_entry .= sprintf($_search_button, $disabled, user_theme(),
242 (fallback_mode() ? '' : 'display:none;'),
243 $search_submit)."\n";
246 default_focus($search_box ? $search_box : $name);
248 if ($search_box && $opts['cells'])
249 echo ($edit_entry!='' ? "<td>$edit_entry</td>" : '')."<td>$selector</td>";
251 echo $edit_entry.$selector;
258 Returns true if selector $name is subject to update.
260 function list_updated($name)
262 return isset($_POST['_'.$name.'_update']) || isset($_POST['_'.$name.'_button']);
264 //----------------------------------------------------------------------------------------------
265 // Universal array combo generator
266 // $items is array of options 'value' => 'description'
267 // Options is reduced set of combo_selector options and is merged with defaults.
269 function array_selector($name, $selected_id, $items, $options=null)
273 $opts = array( // default options
274 'spec_option'=>false, // option text or false
275 'spec_id' => 0, // option id
276 'select_submit' => false, //submit on select: true/false
277 'edit_submit' => false, // call editor on F4
278 'async' => true, // select update via ajax (true) vs _page_body reload
279 'default' => '', // default value when $_POST is not set
280 // search box parameters
284 // ------ merge options with defaults ----------
286 $opts = array_merge($opts, $options);
287 $select_submit = $opts['select_submit']===true ? '_'.$name.'_update' : $opts['select_submit'];
288 $spec_id = $opts['spec_id'];
289 $spec_option = $opts['spec_option'];
290 $disabled = $opts['disabled'] ? "disabled" : '';
292 if ($selected_id == null) {
293 $selected_id = get_post($name, $opts['default']);
296 if (isset($_POST[$select_submit])) {
298 $Ajax->activate('_page_body');
300 $Ajax->activate($name);
303 // ------ make selector ----------
304 $selector = $first_opt = '';
307 //if($name=='SelectStockFromList') display_error($sql);
308 foreach($items as $value=>$descr) {
310 if ($selected_id == $value) {
314 if ($first_id === false) {
318 $selector .= "<option $sel value='$value'>$descr</option>\n";
321 // Prepend special option.
322 if ($spec_option !== false) { // if special option used - add it
323 $first_id = $spec_id;
324 $first_opt = $spec_option;
325 $sel = $found===false ? 'selected' : '';
326 $selector = "<option $sel value='$spec_id'>$spec_option</option>\n"
330 if ($found === false) {
331 $_POST[$name] = $first_id;
334 $aspect = $opts['edit_submit'] ? " aspect='editable'" : '';
335 $selector = "<select $disabled name='$name' class='combo' title='"
336 . $opts['sel_hint']."'$aspect >".$selector."</select>\n";
338 $Ajax->addUpdate($name, "_{$name}_sel", $selector);
340 $selector = "<span id='_{$name}_sel'>".$selector."</span>\n";
342 if ($select_submit != false) { // if submit on change is used - add select button
343 global $_select_button;
344 $selector .= sprintf($_select_button, $disabled, user_theme(),
345 (fallback_mode() ? '' : 'display:none;'),
346 $select_submit)."\n";
348 default_focus($name);
353 //----------------------------------------------------------------------------------------------
355 function _format_add_curr($row)
357 static $company_currency;
359 if ($company_currency == null)
361 $company_currency = get_company_currency();
363 return $row[1] . ($row[2] == $company_currency ?
364 '' : (" - " . $row[2]));
367 function supplier_list($name, $selected_id=null, $spec_option=false, $submit_on_change=false)
371 $sql = "SELECT supplier_id, supp_name, curr_code, inactive FROM ".TB_PREF."suppliers ";
373 $mode = get_company_pref('no_supplier_list');
375 return combo_input($name, $selected_id, $sql, 'supplier_id', 'supp_name',
377 'format' => '_format_add_curr',
378 'search_box' => $mode!=0,
379 'edit_submit' => true,
381 'spec_option' => $spec_option === true ? _("All Suppliers") : $spec_option,
382 'spec_id' => $all_items,
383 'select_submit'=> $submit_on_change,
385 'sel_hint' => $mode ? _('Press Space tab to filter by name fragment') :
390 function supplier_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
393 echo "<td>$label</td><td>\n";
394 $str = supplier_list($name, $selected_id, $all_option, $submit_on_change);
399 function supplier_list_row($label, $name, $selected_id=null, $all_option = false, $submit_on_change=false)
401 echo "<tr><td>$label</td><td>";
402 $str = supplier_list($name, $selected_id, $all_option, $submit_on_change );
406 //----------------------------------------------------------------------------------------------
408 function customer_list($name, $selected_id=null, $spec_option=false, $submit_on_change=false, $show_inactive=false)
412 $sql = "SELECT debtor_no, name, curr_code, inactive FROM ".TB_PREF."debtors_master ";
414 $mode = get_company_pref('no_customer_list');
416 return combo_input($name, $selected_id, $sql, 'debtor_no', 'name',
418 'format' => '_format_add_curr',
419 'search_box' => $mode!=0,
422 'spec_option' => $spec_option === true ? _("All Customers") : $spec_option,
423 'spec_id' => $all_items,
424 'select_submit'=> $submit_on_change,
425 'edit_submit' => true, // call editor on F4
427 'sel_hint' => $mode ? _('Press Space tab to filter by name fragment; F4 - entry new customer') :
428 _('Select customer'),
429 'show_inactive' => $show_inactive
433 function customer_list_cells($label, $name, $selected_id=null, $all_option=false,
434 $submit_on_change=false, $show_inactive=false)
437 echo "<td>$label</td>\n";
439 $str = customer_list($name, $selected_id, $all_option, $submit_on_change,
445 function customer_list_row($label, $name, $selected_id=null, $all_option = false,
446 $submit_on_change=false, $show_inactive=false)
448 echo "<tr><td>$label</td><td nowrap>";
449 $str = customer_list($name, $selected_id, $all_option, $submit_on_change,
451 echo "</td>\n</tr>\n";
455 //------------------------------------------------------------------------------------------------
457 function customer_branches_list($customer_id, $name, $selected_id=null,
458 $spec_option = true, $enabled=true, $submit_on_change=false)
462 $sql = "SELECT branch_code, br_name FROM ".TB_PREF."cust_branch
463 WHERE debtor_no='" . $customer_id . "' ";
465 $where = $enabled ? array("disable_trans = 0") : array();
466 return combo_input($name, $selected_id, $sql, 'branch_code', 'br_name',
469 'spec_option' => $spec_option === true ? _('All branches') : $spec_option,
470 'spec_id' => $all_items,
471 'select_submit'=> $submit_on_change,
472 'sel_hint' => _('Select customer branch')
475 //------------------------------------------------------------------------------------------------
477 function customer_branches_list_cells($label,$customer_id, $name, $selected_id=null, $all_option = true, $enabled=true, $submit_on_change=false)
480 echo "<td>$label</td>\n";
482 $ret = customer_branches_list($customer_id, $name, $selected_id, $all_option, $enabled, $submit_on_change);
487 function customer_branches_list_row($label,$customer_id, $name, $selected_id=null, $all_option = true, $enabled=true, $submit_on_change=false)
490 $ret = customer_branches_list_cells($label, $customer_id, $name, $selected_id, $all_option, $enabled, $submit_on_change);
495 //------------------------------------------------------------------------------------------------
497 function locations_list($name, $selected_id=null, $all_option=false, $submit_on_change=false)
501 $sql = "SELECT loc_code, location_name, inactive FROM ".TB_PREF."locations";
503 return combo_input($name, $selected_id, $sql, 'loc_code', 'location_name',
505 'spec_option' => $all_option === true ? _("All Locations") : $all_option,
506 'spec_id' => $all_items,
507 'select_submit'=> $submit_on_change
511 function locations_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
514 echo "<td>$label</td>\n";
516 $str = locations_list($name, $selected_id, $all_option, $submit_on_change);
521 function locations_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
524 $str = locations_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
529 //-----------------------------------------------------------------------------------------------
531 function currencies_list($name, $selected_id=null, $submit_on_change=false)
533 $sql = "SELECT curr_abrev, currency, inactive FROM ".TB_PREF."currencies";
535 // default to the company currency
537 return combo_input($name, $selected_id, $sql, 'curr_abrev', 'currency',
539 'select_submit'=> $submit_on_change,
540 'default' => get_company_currency(),
545 function currencies_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
548 echo "<td>$label</td>\n";
550 $str = currencies_list($name, $selected_id, $submit_on_change);
555 function currencies_list_row($label, $name, $selected_id=null, $submit_on_change=false)
558 $str = currencies_list_cells($label, $name, $selected_id, $submit_on_change);
563 //---------------------------------------------------------------------------------------------------
565 function fiscalyears_list($name, $selected_id=null, $submit_on_change=false)
568 $sql = "SELECT * FROM ".TB_PREF."fiscal_year";
570 // default to the company current fiscal year
572 return combo_input($name, $selected_id, $sql, 'id', '',
575 'default' => get_company_pref('f_year'),
576 'format' => '_format_fiscalyears',
577 'select_submit'=> $submit_on_change,
582 function _format_fiscalyears($row)
584 return sql2date($row[1]) . " - " . sql2date($row[2])
585 . " " . ($row[3] ? _('Closed') : _('Active')) . "</option>\n";
588 function fiscalyears_list_cells($label, $name, $selected_id=null)
591 echo "<td>$label</td>\n";
593 $str = fiscalyears_list($name, $selected_id);
598 function fiscalyears_list_row($label, $name, $selected_id=null)
601 $str = fiscalyears_list_cells($label, $name, $selected_id);
605 //------------------------------------------------------------------------------------
607 function dimensions_list($name, $selected_id=null, $no_option=false, $showname=' ',
608 $submit_on_change=false, $showclosed=false, $showtype=1)
610 $sql = "SELECT id, CONCAT(reference,' ',name) as ref FROM ".TB_PREF."dimensions";
613 'order' => 'reference',
614 'spec_option'=>$no_option ? $showname : false,
616 'select_submit'=> $submit_on_change,
621 $options['where'][] = "closed=0";
623 $options['where'][] = "type_=$showtype";
625 return combo_input($name, $selected_id, $sql, 'id', 'ref', $options);
628 function dimensions_list_cells($label, $name, $selected_id=null, $no_option=false, $showname=null,
629 $showclosed=false, $showtype=0, $submit_on_change=false)
632 echo "<td>$label</td>\n";
634 $str = dimensions_list($name, $selected_id, $no_option, $showname, $submit_on_change, $showclosed, $showtype);
639 function dimensions_list_row($label, $name, $selected_id=null, $no_option=false, $showname=null,
640 $showclosed=false, $showtype=0, $submit_on_change=false)
643 $str = dimensions_list_cells($label, $name, $selected_id, $no_option, $showname,
644 $showclosed, $showtype, $submit_on_change);
649 //---------------------------------------------------------------------------------------------------
651 function stock_items_list($name, $selected_id=null, $all_option=false, $submit_on_change=false, $opts=array())
655 $sql = "SELECT stock_id, s.description, c.description, inactive
656 FROM ".TB_PREF."stock_master s,".TB_PREF."stock_category c WHERE s.category_id=c.category_id";
658 return combo_input($name, $selected_id, $sql, 'stock_id', 's.description',
661 'format' => '_format_stock_items',
662 'spec_option' => $all_option===true ? _("All Items") : $all_option,
663 'spec_id' => $all_items,
664 'search_box' => true,
665 'search' => array("stock_id", "c.description","s.description"),
666 'search_submit' => get_company_pref('no_item_list')!=0,
668 'select_submit'=> $submit_on_change,
670 'order' => array('c.description','stock_id')
674 function _format_stock_items($row)
676 return (user_show_codes() ? ($row[0] . " - ") : "") . $row[1];
679 function stock_items_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
682 echo "<td>$label</td>\n";
683 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
684 array('cells'=>true));
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."item_codes i
710 ".TB_PREF."stock_category c
711 ON i.category_id=c.category_id";
713 if ($type == 'local') { // exclude foreign codes
714 $sql .= " WHERE !i.is_foreign";
715 } elseif ($type == 'kits') { // sales kits
716 $sql .= " WHERE !i.is_foreign AND i.item_code!=i.stock_id";
719 $sql .= " GROUP BY i.item_code";
721 return combo_input($name, $selected_id, $sql, 'i.item_code', 'c.description',
724 'format' => '_format_stock_items',
725 'spec_option' => $all_option===true ? _("All Items") : $all_option,
726 'spec_id' => $all_items,
727 'search_box' => true,
728 'search' => array("i.item_code", "i.description"),
729 'search_submit' => get_company_pref('no_item_list')!=0,
731 'select_submit'=> $submit_on_change,
733 'order' => array('c.description','i.item_code')
737 function sales_items_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
740 echo "<td>$label</td>\n";
741 $str = sales_items_list($name, $selected_id, $all_option, $submit_on_change,
742 '', array('cells'=>true));
746 function sales_kits_list($name, $selected_id=null, $all_option=false, $submit_on_change=false)
748 $str = sales_items_list($name, $selected_id, $all_option, $submit_on_change,
749 'kits', array('cells'=>false));
753 function sales_local_items_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
757 echo "<td>$label</td>\n";
759 $str = sales_items_list($name, $selected_id, $all_option, $submit_on_change,
760 'local', array('cells'=>false));
764 //------------------------------------------------------------------------------------
766 function base_stock_items_list($where, $name, $selected_id=null,
767 $all_option=false, $submit_on_change=false)
771 $sql = "SELECT stock_id, s.description, c.description, inactive
772 FROM ".TB_PREF."stock_master s,".TB_PREF."stock_category c WHERE
773 s.category_id=c.category_id";
775 return combo_input($name, $selected_id, $sql, 'stock_id', 's.description',
777 'format' => '_format_stock_items',
778 'spec_option' => $all_option==true ? _("All Items") : $all_option,
779 'spec_id' => $all_items,
780 'select_submit'=> $submit_on_change,
784 //------------------------------------------------------------------------------------
786 function stock_bom_items_list($name, $selected_id=null, $all_option=false, $submit_on_change=false)
789 return base_stock_items_list("(s.mb_flag='M' OR s.mb_flag='K')",
790 $name, $selected_id, $all_option, $submit_on_change);
793 function stock_bom_items_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
796 echo "<td>$label</td>\n";
798 $str = stock_bom_items_list($name, $selected_id, $all_option, $submit_on_change);
803 function stock_bom_items_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
806 $str = stock_bom_items_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
811 //------------------------------------------------------------------------------------
813 function stock_manufactured_items_list($name, $selected_id=null,
814 $all_option=false, $submit_on_change=false)
816 return base_stock_items_list("s.mb_flag='M'",
817 $name, $selected_id, $all_option, $submit_on_change);
820 function stock_manufactured_items_list_cells($label, $name, $selected_id=null,
821 $all_option=false, $submit_on_change=false)
824 echo "<td>$label</td>\n";
826 $str = stock_manufactured_items_list($name, $selected_id, $all_option,
832 function stock_manufactured_items_list_row($label, $name, $selected_id=null,
833 $all_option=false, $submit_on_change=false)
836 $str = stock_manufactured_items_list_cells($label, $name, $selected_id,
837 $all_option, $submit_on_change);
841 //------------------------------------------------------------------------------------
843 function stock_component_items_list($name, $parent_stock_id, $selected_id=null,
844 $all_option=false, $submit_on_change=false)
846 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
847 array('where'=>array("stock_id != '$parent_stock_id'")));
851 function stock_component_items_list_cells($label, $name, $parent_stock_id,
852 $selected_id=null, $all_option=false, $submit_on_change=false)
855 echo "<td>$label</td>\n";
856 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
857 array('where'=>array("stock_id != '$parent_stock_id'"), 'cells'=>true));
860 //------------------------------------------------------------------------------------
862 function stock_costable_items_list($name, $selected_id=null,
863 $all_option=false, $submit_on_change=false)
865 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
866 array('where'=>array("mb_flag!='D'")));
870 function stock_costable_items_list_cells($label, $name, $selected_id=null,
871 $all_option=false, $submit_on_change=false)
874 echo "<td>$label</td>\n";
875 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
876 array('where'=>array("mb_flag!='D'"), 'cells'=>true));
880 //------------------------------------------------------------------------------------
881 function stock_purchasable_items_list($name, $selected_id=null,
882 $all_option=false, $submit_on_change=false)
884 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
885 array('where'=>array("mb_flag!= 'M'"),
886 'edit_submit' => true));
890 function stock_purchasable_items_list_cells($label, $name, $selected_id=null,
891 $all_option=false, $submit_on_change=false)
894 echo "<td>$label</td>\n";
895 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
896 array('where'=>array("mb_flag!= 'M'"),
897 'edit_submit' => true,
902 function stock_purchasable_items_list_row($label, $name, $selected_id=null,
903 $all_option=false, $submit_on_change=false)
906 $ret = stock_purchasable_items_list_cells($label, $name, $selected_id=null,
907 $all_option, $submit_on_change);
912 //------------------------------------------------------------------------------------
914 function stock_item_types_list_row($label, $name, $selected_id=null, $enabled=true)
920 echo "<td>$label</td>\n";
923 array_selector($name, $selected_id, $stock_types,
925 'select_submit'=> true,
926 'disabled' => !$enabled) );
930 function stock_units_list_row($label, $name, $value=null, $enabled=true)
932 $result = get_all_item_units();
935 echo "<td>$label</td>\n";
938 while($unit = db_fetch($result))
939 $units[$unit['abbr']] = $unit['name'];
941 array_selector($name, $value, $units,
943 'select_submit'=> true,
944 'disabled' => !$enabled) );
949 //------------------------------------------------------------------------------------
951 function tax_types_list($name, $selected_id=null, $none_option=false, $submit_on_change=false)
953 $sql = "SELECT id, CONCAT(name, ' (',rate,'%)') as name FROM ".TB_PREF."tax_types";
955 return combo_input($name, $selected_id, $sql, 'id', 'name',
957 'spec_option' => $none_option,
958 'spec_id' => reserved_words::get_all_numeric(),
959 'select_submit'=> $submit_on_change,
964 function tax_types_list_cells($label, $name, $selected_id=null, $none_option=false,
965 $submit_on_change=false)
968 echo "<td>$label</td>\n";
970 $str = tax_types_list($name, $selected_id, $none_option, $submit_on_change);
975 function tax_types_list_row($label, $name, $selected_id=null, $none_option=false,
976 $submit_on_change=false)
979 $str = tax_types_list_cells($label, $name, $selected_id, $none_option, $submit_on_change);
984 //------------------------------------------------------------------------------------
986 function tax_groups_list($name, $selected_id=null,
987 $none_option=false, $submit_on_change=false)
989 $sql = "SELECT id, name FROM ".TB_PREF."tax_groups";
991 return combo_input($name, $selected_id, $sql, 'id', 'name',
994 'spec_option' => $none_option,
995 'spec_id' => reserved_words::get_all_numeric(),
996 'select_submit'=> $submit_on_change,
1001 function tax_groups_list_cells($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false)
1004 echo "<td>$label</td>\n";
1006 $str = tax_groups_list($name, $selected_id, $none_option, $submit_on_change);
1011 function tax_groups_list_row($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false)
1014 $str = tax_groups_list_cells($label, $name, $selected_id, $none_option, $submit_on_change);
1019 //------------------------------------------------------------------------------------
1021 function item_tax_types_list($name, $selected_id=null)
1023 $sql ="SELECT id, name FROM ".TB_PREF."item_tax_types";
1024 combo_input($name, $selected_id, $sql, 'id', 'name', array('order' => 'id') );
1027 function item_tax_types_list_cells($label, $name, $selected_id=null)
1030 echo "<td>$label</td>\n";
1032 item_tax_types_list($name, $selected_id);
1036 function item_tax_types_list_row($label, $name, $selected_id=null)
1039 item_tax_types_list_cells($label, $name, $selected_id);
1043 //------------------------------------------------------------------------------------
1045 function shippers_list($name, $selected_id=null)
1047 $sql = "SELECT shipper_id, shipper_name, inactive FROM ".TB_PREF."shippers";
1048 combo_input($name, $selected_id, $sql, 'shipper_id', 'shipper_name', array());
1051 function shippers_list_cells($label, $name, $selected_id=null)
1054 echo "<td>$label</td>\n";
1056 shippers_list($name, $selected_id);
1060 function shippers_list_row($label, $name, $selected_id=null)
1063 shippers_list_cells($label, $name, $selected_id);
1067 //-------------------------------------------------------------------------------------
1069 function sales_persons_list($name, $selected_id=null)
1071 $sql = "SELECT salesman_code, salesman_name, inactive FROM ".TB_PREF."salesman";
1072 combo_input($name, $selected_id, $sql, 'salesman_code', 'salesman_name', array());
1075 function sales_persons_list_cells($label, $name, $selected_id=null)
1078 echo "<td>$label</td>\n";
1080 sales_persons_list($name, $selected_id);
1084 function sales_persons_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1087 sales_persons_list_cells($label, $name, $selected_id, $submit_on_change=false);
1091 //------------------------------------------------------------------------------------
1093 function sales_areas_list($name, $selected_id=null)
1095 $sql = "SELECT area_code, description, inactive FROM ".TB_PREF."areas";
1096 combo_input($name, $selected_id, $sql, 'area_code', 'description', array());
1099 function sales_areas_list_cells($label, $name, $selected_id=null)
1102 echo "<td>$label</td>\n";
1104 sales_areas_list($name, $selected_id);
1108 function sales_areas_list_row($label, $name, $selected_id=null)
1111 sales_areas_list_cells($label, $name, $selected_id);
1115 //------------------------------------------------------------------------------------
1117 function sales_groups_list($name, $selected_id=null, $special_option=false)
1119 $sql = "SELECT id, description, inactive FROM ".TB_PREF."groups";
1120 combo_input($name, $selected_id, $sql, 'id', 'description', array(
1121 'spec_option' => $special_option===true ? ' ' : $special_option,
1122 'order' => 'description', 'spec_id' => 0,
1126 function sales_groups_list_cells($label, $name, $selected_id=null, $special_option=false)
1129 echo "<td>$label</td>\n";
1131 sales_groups_list($name, $selected_id, $special_option);
1135 function sales_groups_list_row($label, $name, $selected_id=null, $special_option=false)
1138 sales_groups_list_cells($label, $name, $selected_id, $special_option);
1142 //------------------------------------------------------------------------------------
1144 function _format_template_items($row)
1146 return ($row[0] . " - " . _("Amount") . " ".$row[1]);
1149 function templates_list($name, $selected_id=null, $special_option=false)
1151 $sql = "SELECT sorder.order_no, Sum(line.unit_price*line.quantity*(1-line.discount_percent)) AS OrderValue
1152 FROM ".TB_PREF."sales_orders as sorder, ".TB_PREF."sales_order_details as line
1153 WHERE sorder.order_no = line.order_no AND sorder.type = 1 GROUP BY line.order_no";
1154 combo_input($name, $selected_id, $sql, 'order_no', 'OrderValue', array(
1155 'format' => '_format_template_items',
1156 'spec_option' => $special_option===true ? ' ' : $special_option,
1157 'order' => 'order_no', 'spec_id' => 0,
1161 function templates_list_cells($label, $name, $selected_id=null, $special_option=false)
1164 echo "<td>$label</td>\n";
1166 templates_list($name, $selected_id, $special_option);
1170 function templates_list_row($label, $name, $selected_id=null, $special_option=false)
1173 templates_list_cells($label, $name, $selected_id, $special_option);
1177 //------------------------------------------------------------------------------------
1179 function workorders_list($name, $selected_id=null)
1181 $sql = "SELECT id, wo_ref FROM ".TB_PREF."workorders WHERE closed=0";
1182 combo_input($name, $selected_id, $sql, 'id', 'wo_ref', array());
1185 function workorders_list_cells($label, $name, $selected_id=null)
1188 echo "<td>$label</td>\n";
1190 workorders_list($name, $selected_id);
1194 function workorders_list_row($label, $name, $selected_id=null)
1197 workorders_list_cells($label, $name, $selected_id);
1201 //------------------------------------------------------------------------------------
1203 function payment_terms_list($name, $selected_id=null)
1205 $sql = "SELECT terms_indicator, terms, inactive FROM ".TB_PREF."payment_terms";
1206 combo_input($name, $selected_id, $sql, 'terms_indicator', 'terms', array());
1209 function payment_terms_list_cells($label, $name, $selected_id=null)
1212 echo "<td>$label</td>\n";
1214 payment_terms_list($name, $selected_id);
1218 function payment_terms_list_row($label, $name, $selected_id=null)
1221 payment_terms_list_cells($label, $name, $selected_id);
1225 //------------------------------------------------------------------------------------
1227 function credit_status_list($name, $selected_id=null)
1229 $sql ="SELECT id, reason_description, inactive FROM ".TB_PREF."credit_status";
1230 combo_input($name, $selected_id, $sql, 'id', 'reason_description', array());
1233 function credit_status_list_cells($label, $name, $selected_id=null)
1236 echo "<td>$label</td>\n";
1238 credit_status_list($name, $selected_id);
1242 function credit_status_list_row($label, $name, $selected_id=null)
1245 credit_status_list_cells($label, $name, $selected_id);
1249 //-----------------------------------------------------------------------------------------------
1251 function sales_types_list($name, $selected_id=null, $submit_on_change=false, $special_option=false)
1253 $sql = "SELECT id, sales_type, inactive FROM ".TB_PREF."sales_types";
1255 return combo_input($name, $selected_id, $sql, 'id', 'sales_type',
1257 'spec_option' => $special_option===true ? _("All Sales Types") : $special_option,
1259 'select_submit'=> $submit_on_change,
1260 // 'async' => false,
1264 function sales_types_list_cells($label, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1267 echo "<td>$label</td>\n";
1269 $str = sales_types_list($name, $selected_id, $submit_on_change, $special_option);
1274 function sales_types_list_row($label, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1277 $str = sales_types_list_cells($label, $name, $selected_id, $submit_on_change, $special_option);
1282 //-----------------------------------------------------------------------------------------------
1284 function movement_types_list($name, $selected_id=null)
1286 $sql = "SELECT id, name FROM ".TB_PREF."movement_types";
1287 combo_input($name, $selected_id, $sql, 'id', 'name', array());
1290 function movement_types_list_cells($label, $name, $selected_id=null)
1293 echo "<td>$label</td>\n";
1295 movement_types_list($name, $selected_id);
1299 function movement_types_list_row($label, $name, $selected_id=null)
1302 movement_types_list_cells($label, $name, $selected_id);
1306 //-----------------------------------------------------------------------------------------------
1307 function _format_date($row)
1309 return sql2date($row['reconciled']);
1312 function bank_reconciliation_list($account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1314 $sql = "SELECT reconciled, reconciled FROM ".TB_PREF."bank_trans
1315 WHERE bank_act=".db_escape($account)." AND reconciled IS NOT NULL
1316 GROUP BY reconciled";
1317 combo_input($name, $selected_id, $sql, 'id', 'reconciled',
1319 'spec_option' => $special_option,
1320 'format' => '_format_date',
1322 'select_submit'=> $submit_on_change
1326 function bank_reconciliation_list_cells($label,$account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1329 echo "<td>$label</td>\n";
1331 bank_reconciliation_list($account, $name, $selected_id, $submit_on_change, $special_option);
1335 function bank_reconciliation_list_row($label, $account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1338 bank_reconciliation_list_cells($label, $account, $name, $selected_id, $submit_on_change, $special_option);
1342 //-----------------------------------------------------------------------------------------------
1344 function workcenter_list($name, $selected_id=null, $all_option=false)
1348 $sql = "SELECT id, name, inactive FROM ".TB_PREF."workcentres";
1350 return combo_input($name, $selected_id, $sql, 'id', 'name',
1352 'spec_option' =>$all_option===true ? _("All Suppliers") : $all_option,
1353 'spec_id' => $all_items,
1357 function workcenter_list_cells($label, $name, $selected_id=null, $all_option=false)
1359 default_focus($name);
1361 echo "<td>$label</td>\n";
1363 workcenter_list($name, $selected_id, $all_option);
1367 function workcenter_list_row($label, $name, $selected_id=null, $all_option=false)
1370 workcenter_list_cells($label, $name, $selected_id, $all_option);
1374 //-----------------------------------------------------------------------------------------------
1376 function bank_accounts_list($name, $selected_id=null, $submit_on_change=false)
1378 $sql = "SELECT ".TB_PREF."bank_accounts.id, bank_account_name, bank_curr_code, inactive
1379 FROM ".TB_PREF."bank_accounts";
1380 // , ".TB_PREF."chart_master
1381 // WHERE ".TB_PREF."bank_accounts.account_code=".TB_PREF."chart_master.account_code";
1383 return combo_input($name, $selected_id, $sql, 'id', 'bank_account_name',
1385 'format' => '_format_add_curr',
1386 'select_submit'=> $submit_on_change,
1391 function bank_accounts_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1394 echo "<td>$label</td>\n";
1396 $str = bank_accounts_list($name, $selected_id, $submit_on_change);
1401 function bank_accounts_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1404 $str = bank_accounts_list_cells($label, $name, $selected_id, $submit_on_change);
1408 //-----------------------------------------------------------------------------------------------
1410 function cash_accounts_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1412 $sql = "SELECT ".TB_PREF."bank_accounts.id, bank_account_name, bank_curr_code, inactive
1413 FROM ".TB_PREF."bank_accounts
1414 WHERE ".TB_PREF."bank_accounts.account_type=3";
1417 echo "<tr><td>$label</td>\n";
1419 $str = combo_input($name, $selected_id, $sql, 'id', 'bank_account_name',
1421 'format' => '_format_add_curr',
1422 'select_submit'=> $submit_on_change,
1425 echo "</td></tr>\n";
1428 //-----------------------------------------------------------------------------------------------
1430 function pos_list_row($label, $name, $selected_id=null, $spec_option=false, $submit_on_change=false)
1432 $sql = "SELECT id, pos_name, inactive FROM ".TB_PREF."sales_pos";
1434 default_focus($name);
1437 echo "<td>$label</td>\n";
1440 $str = combo_input($name, $selected_id, $sql, 'id', 'pos_name',
1442 'select_submit'=> $submit_on_change,
1444 'spec_option' =>$spec_option,
1447 echo "</td></tr>\n";
1451 //-----------------------------------------------------------------------------------------------
1453 function sale_payment_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1456 echo "<td>$label</td>\n";
1458 $str = yesno_list($name, $selected_id, _('Cash'), _('Delayed'), $submit_on_change);
1462 //-----------------------------------------------------------------------------------------------
1464 function class_list($name, $selected_id=null, $submit_on_change=false)
1466 $sql = "SELECT cid, class_name FROM ".TB_PREF."chart_class";
1468 return combo_input($name, $selected_id, $sql, 'cid', 'class_name',
1470 'select_submit'=> $submit_on_change,
1476 function class_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1479 echo "<td>$label</td>\n";
1481 $str = class_list($name, $selected_id, $submit_on_change);
1486 function class_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1489 $str = class_list_cells($label, $name, $selected_id, $submit_on_change);
1494 //-----------------------------------------------------------------------------------------------
1496 function stock_categories_list($name, $selected_id=null, $submit_on_change=false)
1498 $sql = "SELECT category_id, description, inactive FROM ".TB_PREF."stock_category";
1499 combo_input($name, $selected_id, $sql, 'category_id', 'description',
1500 array('order'=>'category_id',
1501 'select_submit'=> $submit_on_change,
1506 function stock_categories_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1509 echo "<td>$label</td>\n";
1511 stock_categories_list($name, $selected_id, $submit_on_change);
1515 function stock_categories_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1518 stock_categories_list_cells($label, $name, $selected_id, $submit_on_change);
1522 //-----------------------------------------------------------------------------------------------
1524 function gl_account_types_list($name, $selected_id=null, $all_option, $all_option_numeric)
1528 $sql = "SELECT id, name FROM ".TB_PREF."chart_types";
1530 combo_input($name, $selected_id, $sql, 'id', 'name',
1533 'spec_option' =>$all_option,
1534 'spec_id' => $all_option_numeric ? 0 : $all_items
1538 function gl_account_types_list_cells($label, $name, $selected_id=null, $all_option=false,
1539 $all_option_numeric=false)
1542 echo "<td>$label</td>\n";
1544 gl_account_types_list($name, $selected_id, $all_option, $all_option_numeric);
1548 function gl_account_types_list_row($label, $name, $selected_id=null, $all_option=false,
1549 $all_option_numeric=false)
1552 gl_account_types_list_cells($label, $name, $selected_id, $all_option,
1553 $all_option_numeric);
1557 //-----------------------------------------------------------------------------------------------
1558 function gl_all_accounts_list($name, $selected_id=null, $skip_bank_accounts=false,
1559 $cells=false, $all_option=false, $submit_on_change=false)
1561 if ($skip_bank_accounts)
1562 $sql = "SELECT chart.account_code, chart.account_name, type.name, inactive
1563 FROM (".TB_PREF."chart_master chart,".TB_PREF."chart_types type) "
1564 ."LEFT JOIN ".TB_PREF."bank_accounts acc "
1565 ."ON chart.account_code=acc.account_code
1566 WHERE acc.account_code IS NULL
1567 AND chart.account_type=type.id";
1569 $sql = "SELECT chart.account_code, chart.account_name, type.name, inactive
1570 FROM ".TB_PREF."chart_master chart,".TB_PREF."chart_types type
1571 WHERE chart.account_type=type.id";
1573 combo_input($name, $selected_id, $sql, 'chart.account_code', 'chart.account_name',
1575 'format' => '_format_account',
1576 'spec_option' => $all_option===true ? _("Use Item Sales Accounts") : $all_option,
1578 'order' => array('name','account_code'),
1579 'search_box' => $cells,
1580 'search_submit' => false,
1584 'select_submit'=> $submit_on_change,
1591 function _format_account($row)
1593 return $row[0] . " " . $row[1];
1596 function gl_all_accounts_list_cells($label, $name, $selected_id=null,
1597 $skip_bank_accounts=false, $cells=false, $all_option=false)
1600 echo "<td>$label</td>\n";
1602 gl_all_accounts_list($name, $selected_id,
1603 $skip_bank_accounts, $cells, $all_option);
1607 function gl_all_accounts_list_row($label, $name, $selected_id=null,
1608 $skip_bank_accounts=false, $cells=false, $all_option=false)
1611 gl_all_accounts_list_cells($label, $name, $selected_id,
1612 $skip_bank_accounts, $cells, $all_option);
1616 function yesno_list($name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1619 $items['1'] = strlen($name_yes) ? $name_yes : _("Yes");
1620 $items['0'] = strlen($name_no) ? $name_no : _("No");
1622 return array_selector($name, $selected_id, $items,
1624 'select_submit'=> $submit_on_change,
1625 'async' => false ) ); // FIX?
1628 function yesno_list_cells($label, $name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1631 echo "<td>$label</td>\n";
1633 $str = yesno_list($name, $selected_id, $name_yes, $name_no, $submit_on_change);
1638 function yesno_list_row($label, $name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1641 $str = yesno_list_cells($label, $name, $selected_id, $name_yes, $name_no, $submit_on_change);
1646 //------------------------------------------------------------------------------------------------
1648 function languages_list($name, $selected_id=null)
1650 global $installed_languages;
1653 foreach ($installed_languages as $lang)
1654 $items[$lang['code']] = $lang['name'];
1656 return array_selector($name, $selected_id, $items );
1659 function languages_list_cells($label, $name, $selected_id=null)
1662 echo "<td>$label</td>\n";
1664 languages_list($name, $selected_id);
1668 function languages_list_row($label, $name, $selected_id=null)
1671 languages_list_cells($label, $name, $selected_id);
1675 //------------------------------------------------------------------------------------------------
1677 function bank_account_types_list($name, $selected_id=null)
1679 $types = bank_account_types::get_all();
1682 foreach ($types as $type)
1684 $items[$type['id']] = $type['name'];
1687 return array_selector($name, $selected_id, $items );
1690 function bank_account_types_list_cells($label, $name, $selected_id=null)
1693 echo "<td>$label</td>\n";
1695 bank_account_types_list($name, $selected_id);
1699 function bank_account_types_list_row($label, $name, $selected_id=null)
1702 bank_account_types_list_cells($label, $name, $selected_id);
1706 //------------------------------------------------------------------------------------------------
1707 function payment_person_types_list($name, $selected_id=null, $submit_on_change=false)
1709 $types = payment_person_types::get_all();
1712 foreach ($types as $type)
1714 if (payment_person_types::has_items($type['id']))
1716 $items[$type['id']] = $type['name'];
1720 return array_selector($name, $selected_id, $items,
1721 array( 'select_submit'=> $submit_on_change ) );
1724 function payment_person_types_list_cells($label, $name, $selected_id=null, $related=null)
1727 echo "<td>$label</td>\n";
1729 $str = payment_person_types_list($name, $selected_id, $related);
1734 function payment_person_types_list_row($label, $name, $selected_id=null, $related=null)
1737 $str = payment_person_types_list_cells($label, $name, $selected_id, $related);
1742 //------------------------------------------------------------------------------------------------
1744 function wo_types_list($name, $selected_id=null)
1746 $types = wo_types::get_all();
1749 foreach ($types as $type)
1750 $items[$type['id']] = $type['name'];
1752 return array_selector($name, $selected_id, $items,
1753 array( 'select_submit'=> true, 'async' => true ) );
1756 function wo_types_list_row($label, $name, $selected_id=null)
1758 echo "<tr><td>$label</td><td>\n";
1759 $str = wo_types_list($name, $selected_id);
1760 echo "</td></tr>\n";
1764 //------------------------------------------------------------------------------------------------
1766 function dateformats_list_row($label, $name, $value=null)
1768 global $dateformats;
1770 echo "<tr><td>$label</td>\n<td>";
1771 array_selector( $name, $value, $dateformats );
1772 echo "</td></tr>\n";
1775 function dateseps_list_row($label, $name, $value=null)
1779 echo "<tr><td>$label</td>\n<td>";
1780 array_selector( $name, $value, $dateseps );
1781 echo "</td></tr>\n";
1784 function thoseps_list_row($label, $name, $value=null)
1788 echo "<tr><td>$label</td>\n<td>";
1789 array_selector( $name, $value, $thoseps );
1790 echo "</td></tr>\n";
1793 function decseps_list_row($label, $name, $value=null)
1797 echo "<tr><td>$label</td>\n<td>";
1798 array_selector( $name, $value, $decseps );
1799 echo "</td></tr>\n";
1802 function themes_list_row($label, $name, $value=null)
1804 global $path_to_root;
1806 $path = $path_to_root.'/themes/';
1808 $themedir = opendir($path);
1809 while(false !== ($fname = readdir($themedir)))
1811 if($fname!='.' && $fname!='..' && $fname!='CVS' && is_dir($path.$fname))
1813 $themes[$fname] = $fname;
1818 echo "<tr><td>$label</td>\n<td>";
1819 array_selector( $name, $value, $themes );
1820 echo "</td></tr>\n";
1823 function pagesizes_list_row($label, $name, $value=null)
1828 foreach ($pagesizes as $pz)
1831 echo "<tr><td>$label</td>\n<td>";
1832 array_selector( $name, $value, $items );
1833 echo "</td></tr>\n";
1836 function security_headings_list_row($label, $name, $value=null)
1838 global $security_headings;
1840 echo "<tr><td>$label</td>\n<td>";
1841 array_selector( $name, $value, $security_headings );
1842 echo "</td></tr>\n";
1845 function systypes_list_cells($label, $name, $value=null, $submit_on_change=false)
1847 global $systypes_array;
1850 echo "<td>$label</td>\n";
1854 foreach ($systypes_array as $key=>$type)
1855 $items[$key] = $type['name'];
1857 $str = array_selector($name, $value, $items,
1859 'select_submit'=> $submit_on_change,
1867 function systypes_list_row($label, $name, $value=null, $submit_on_change=false)
1870 $str = systypes_list_cells($label, $name, $value, $submit_on_change);
1875 function cust_allocations_list_cells($label, $name, $selected=null)
1883 $all_items=>_("All Types"),
1884 '1'=> _("Sales Invoices"),
1885 '2'=> _("Overdue Invoices"),
1886 '3' => _("Payments"),
1887 '4' => _("Credit Notes"),
1888 '5' => _("Delivery Notes")
1890 $str = array_selector($name, $selected, $allocs);
1895 function supp_allocations_list_cell($name, $selected=null)
1901 $all_items=>_("All Types"),
1902 '1'=> _("Invoices"),
1903 '2'=> _("Overdue Invoices"),
1904 '3' => _("Payments"),
1905 '4' => _("Credit Notes"),
1906 '5' => _("Overdue Credit Notes")
1908 $str = array_selector($name, $selected, $allocs);
1913 function policy_list_cells($label, $name, $selected=null)
1918 $str = array_selector($name, $selected,
1919 array( '' => _("Automatically put balance on back order"),
1920 'CAN' => _("Cancel any quantites not delivered")) );
1925 function policy_list_row($label, $name, $selected=null)
1928 policy_list_cells($label, $name, $selected);
1932 function credit_type_list_cells($label, $name, $selected=null, $submit_on_change=false)
1937 $str = array_selector($name, $selected,
1938 array( 'Return' => _("Items Returned to Inventory Location"),
1939 'WriteOff' => _("Items Written Off")),
1940 array( 'select_submit'=> $submit_on_change ) );
1945 function credit_type_list_row($label, $name, $selected=null, $submit_on_change=false)
1948 $str = credit_type_list_cells($label, $name, $selected, $submit_on_change);
1953 function number_list($name, $selected, $from, $to, $no_option=false)
1956 for ($i = $from; $i <= $to; $i++)
1959 return array_selector($name, $selected, $items,
1960 array( 'spec_option' => $no_option,
1961 'spec_id' => reserved_words::get_all_numeric()) );
1964 function number_list_cells($label, $name, $selected, $from, $to, $no_option=false)
1969 number_list($name, $selected, $from, $to, $no_option);
1973 function number_list_row($label, $name, $selected, $from, $to, $no_option=false)
1976 number_list_cells($label, $name, $selected, $from, $to, $no_option);
1980 function print_profiles_list_row($label, $name, $selected_id=null, $spec_opt=false,
1981 $submit_on_change=true)
1983 $sql = "SELECT profile FROM ".TB_PREF."print_profiles"
1984 ." GROUP BY profile";
1985 $result = db_query($sql, 'cannot get all profile names');
1986 $profiles = array();
1987 while($myrow=db_fetch($result)) {
1988 $profiles[$myrow['profile']] = $myrow['profile'];
1993 echo "<td>$label</td>\n";
1996 array_selector($name, $selected_id, $profiles,
1997 array( 'select_submit'=> $submit_on_change,
1998 'spec_option'=>$spec_opt,
2002 echo "</td></tr>\n";
2005 function printers_list($name, $selected_id=null, $spec_opt=false, $submit_on_change=false)
2007 static $printers; // query only once for page display
2010 $sql = "SELECT id, name, description FROM ".TB_PREF."printers";
2011 $result = db_query($sql, 'cannot get all printers');
2012 $printers = array();
2013 while($myrow=db_fetch($result)) {
2014 $printers[$myrow['id']] = $myrow['name'].' - '.$myrow['description'];
2017 array_selector($name, $selected_id, $printers,
2018 array( 'select_submit'=> $submit_on_change,
2019 'spec_option'=>$spec_opt,
2024 //------------------------------------------------------------------------------------------------
2026 function quick_entries_list($name, $selected_id=null, $type=null, $submit_on_change=false)
2029 $sql = "SELECT id, description FROM ".TB_PREF."quick_entries";
2031 $sql .= " WHERE type=$type";
2033 combo_input($name, $selected_id, $sql, 'id', 'description',
2036 'order' => 'description',
2037 'select_submit'=> $submit_on_change,
2043 function quick_entries_list_cells($label, $name, $selected_id=null, $type, $submit_on_change=false)
2045 echo "<td>$label</td><td>\n";
2046 quick_entries_list($name, $selected_id, $type, $submit_on_change);
2050 function quick_entries_list_row($label, $name, $selected_id=null, $type, $submit_on_change=false)
2053 quick_entries_list_cells($label, $name, $selected_id, $type, $submit_on_change);
2058 function quick_actions_list_row($label, $name, $selected_id=null, $submit_on_change=false)
2060 global $quick_actions;
2062 echo "<tr><td>$label</td><td>";
2063 array_selector($name, $selected_id, $quick_actions,
2065 'select_submit'=> $submit_on_change
2067 echo "</td></tr>\n";
2070 function quick_entry_types_list_row($label, $name, $selected_id=null, $submit_on_change=false)
2072 global $quick_entry_types;
2074 echo "<tr><td>$label</td><td>";
2075 array_selector($name, $selected_id, $quick_entry_types,
2077 'select_submit'=> $submit_on_change
2079 echo "</td></tr>\n";
2082 function record_status_list_row($label, $name) {
2083 return yesno_list_row($label, $name, null, _('Inactive'), _('Active'));