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,
372 $sql = "SELECT supplier_id, supp_name, curr_code, inactive FROM ".TB_PREF."suppliers ";
374 $mode = get_company_pref('no_supplier_list');
376 return combo_input($name, $selected_id, $sql, 'supplier_id', 'supp_name',
378 'format' => '_format_add_curr',
379 'search_box' => $mode!=0,
380 'edit_submit' => true,
382 'spec_option' => $spec_option === true ? _("All Suppliers") : $spec_option,
383 'spec_id' => $all_items,
384 'select_submit'=> $submit_on_change,
386 'sel_hint' => $mode ? _('Press Space tab to filter by name fragment') :
387 _('Select supplier'),
388 'show_inactive'=>$all
392 function supplier_list_cells($label, $name, $selected_id=null, $all_option=false,
393 $submit_on_change=false, $all=false)
396 echo "<td>$label</td><td>\n";
397 $str = supplier_list($name, $selected_id, $all_option, $submit_on_change, $all);
402 function supplier_list_row($label, $name, $selected_id=null, $all_option = false, $submit_on_change=false)
404 echo "<tr><td>$label</td><td>";
405 $str = supplier_list($name, $selected_id, $all_option, $submit_on_change );
409 //----------------------------------------------------------------------------------------------
411 function customer_list($name, $selected_id=null, $spec_option=false, $submit_on_change=false, $show_inactive=false)
415 $sql = "SELECT debtor_no, name, curr_code, inactive FROM ".TB_PREF."debtors_master ";
417 $mode = get_company_pref('no_customer_list');
419 return combo_input($name, $selected_id, $sql, 'debtor_no', 'name',
421 'format' => '_format_add_curr',
422 'search_box' => $mode!=0,
425 'spec_option' => $spec_option === true ? _("All Customers") : $spec_option,
426 'spec_id' => $all_items,
427 'select_submit'=> $submit_on_change,
428 'edit_submit' => true, // call editor on F4
430 'sel_hint' => $mode ? _('Press Space tab to filter by name fragment; F4 - entry new customer') :
431 _('Select customer'),
432 'show_inactive' => $show_inactive
436 function customer_list_cells($label, $name, $selected_id=null, $all_option=false,
437 $submit_on_change=false, $show_inactive=false)
440 echo "<td>$label</td>\n";
442 $str = customer_list($name, $selected_id, $all_option, $submit_on_change,
448 function customer_list_row($label, $name, $selected_id=null, $all_option = false,
449 $submit_on_change=false, $show_inactive=false)
451 echo "<tr><td>$label</td><td nowrap>";
452 $str = customer_list($name, $selected_id, $all_option, $submit_on_change,
454 echo "</td>\n</tr>\n";
458 //------------------------------------------------------------------------------------------------
460 function customer_branches_list($customer_id, $name, $selected_id=null,
461 $spec_option = true, $enabled=true, $submit_on_change=false)
465 $sql = "SELECT branch_code, br_name FROM ".TB_PREF."cust_branch
466 WHERE debtor_no='" . $customer_id . "' ";
468 $where = $enabled ? array("disable_trans = 0") : array();
469 return combo_input($name, $selected_id, $sql, 'branch_code', 'br_name',
472 'spec_option' => $spec_option === true ? _('All branches') : $spec_option,
473 'spec_id' => $all_items,
474 'select_submit'=> $submit_on_change,
475 'sel_hint' => _('Select customer branch')
478 //------------------------------------------------------------------------------------------------
480 function customer_branches_list_cells($label,$customer_id, $name, $selected_id=null, $all_option = true, $enabled=true, $submit_on_change=false)
483 echo "<td>$label</td>\n";
485 $ret = customer_branches_list($customer_id, $name, $selected_id, $all_option, $enabled, $submit_on_change);
490 function customer_branches_list_row($label,$customer_id, $name, $selected_id=null, $all_option = true, $enabled=true, $submit_on_change=false)
493 $ret = customer_branches_list_cells($label, $customer_id, $name, $selected_id, $all_option, $enabled, $submit_on_change);
498 //------------------------------------------------------------------------------------------------
500 function locations_list($name, $selected_id=null, $all_option=false, $submit_on_change=false)
504 $sql = "SELECT loc_code, location_name, inactive FROM ".TB_PREF."locations";
506 return combo_input($name, $selected_id, $sql, 'loc_code', 'location_name',
508 'spec_option' => $all_option === true ? _("All Locations") : $all_option,
509 'spec_id' => $all_items,
510 'select_submit'=> $submit_on_change
514 function locations_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
517 echo "<td>$label</td>\n";
519 $str = locations_list($name, $selected_id, $all_option, $submit_on_change);
524 function locations_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
527 $str = locations_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
532 //-----------------------------------------------------------------------------------------------
534 function currencies_list($name, $selected_id=null, $submit_on_change=false)
536 $sql = "SELECT curr_abrev, currency, inactive FROM ".TB_PREF."currencies";
538 // default to the company currency
540 return combo_input($name, $selected_id, $sql, 'curr_abrev', 'currency',
542 'select_submit'=> $submit_on_change,
543 'default' => get_company_currency(),
548 function currencies_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
551 echo "<td>$label</td>\n";
553 $str = currencies_list($name, $selected_id, $submit_on_change);
558 function currencies_list_row($label, $name, $selected_id=null, $submit_on_change=false)
561 $str = currencies_list_cells($label, $name, $selected_id, $submit_on_change);
566 //---------------------------------------------------------------------------------------------------
568 function fiscalyears_list($name, $selected_id=null, $submit_on_change=false)
571 $sql = "SELECT * FROM ".TB_PREF."fiscal_year";
573 // default to the company current fiscal year
575 return combo_input($name, $selected_id, $sql, 'id', '',
578 'default' => get_company_pref('f_year'),
579 'format' => '_format_fiscalyears',
580 'select_submit'=> $submit_on_change,
585 function _format_fiscalyears($row)
587 return sql2date($row[1]) . " - " . sql2date($row[2])
588 . " " . ($row[3] ? _('Closed') : _('Active')) . "</option>\n";
591 function fiscalyears_list_cells($label, $name, $selected_id=null)
594 echo "<td>$label</td>\n";
596 $str = fiscalyears_list($name, $selected_id);
601 function fiscalyears_list_row($label, $name, $selected_id=null)
604 $str = fiscalyears_list_cells($label, $name, $selected_id);
608 //------------------------------------------------------------------------------------
610 function dimensions_list($name, $selected_id=null, $no_option=false, $showname=' ',
611 $submit_on_change=false, $showclosed=false, $showtype=1)
613 $sql = "SELECT id, CONCAT(reference,' ',name) as ref FROM ".TB_PREF."dimensions";
616 'order' => 'reference',
617 'spec_option'=>$no_option ? $showname : false,
619 'select_submit'=> $submit_on_change,
624 $options['where'][] = "closed=0";
626 $options['where'][] = "type_=$showtype";
628 return combo_input($name, $selected_id, $sql, 'id', 'ref', $options);
631 function dimensions_list_cells($label, $name, $selected_id=null, $no_option=false, $showname=null,
632 $showclosed=false, $showtype=0, $submit_on_change=false)
635 echo "<td>$label</td>\n";
637 $str = dimensions_list($name, $selected_id, $no_option, $showname, $submit_on_change, $showclosed, $showtype);
642 function dimensions_list_row($label, $name, $selected_id=null, $no_option=false, $showname=null,
643 $showclosed=false, $showtype=0, $submit_on_change=false)
646 $str = dimensions_list_cells($label, $name, $selected_id, $no_option, $showname,
647 $showclosed, $showtype, $submit_on_change);
652 //---------------------------------------------------------------------------------------------------
654 function stock_items_list($name, $selected_id=null, $all_option=false,
655 $submit_on_change=false, $opts=array())
659 $sql = "SELECT stock_id, s.description, c.description, s.inactive
660 FROM ".TB_PREF."stock_master s,".TB_PREF."stock_category c WHERE s.category_id=c.category_id";
662 return combo_input($name, $selected_id, $sql, 'stock_id', 's.description',
665 'format' => '_format_stock_items',
666 'spec_option' => $all_option===true ? _("All Items") : $all_option,
667 'spec_id' => $all_items,
668 'search_box' => true,
669 'search' => array("stock_id", "c.description","s.description"),
670 'search_submit' => get_company_pref('no_item_list')!=0,
672 'select_submit'=> $submit_on_change,
674 'order' => array('c.description','stock_id')
678 function _format_stock_items($row)
680 return (user_show_codes() ? ($row[0] . " - ") : "") . $row[1];
683 function stock_items_list_cells($label, $name, $selected_id=null, $all_option=false,
684 $submit_on_change=false, $all=false)
687 echo "<td>$label</td>\n";
688 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
689 array('cells'=>true, 'show_inactive'=>$all));
693 function stock_items_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
696 $str = stock_items_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
701 //---------------------------------------------------------------------------------------------------
703 // Select item via foreign code.
705 function sales_items_list($name, $selected_id=null, $all_option=false,
706 $submit_on_change=false, $type='', $opts=array())
710 $sql = "SELECT i.item_code, i.description, c.description, count(*)>1 as kit,
713 ".TB_PREF."item_codes i
715 ".TB_PREF."stock_category c
716 ON i.category_id=c.category_id";
718 if ($type == 'local') { // exclude foreign codes
719 $sql .= " WHERE !i.is_foreign";
720 } elseif ($type == 'kits') { // sales kits
721 $sql .= " WHERE !i.is_foreign AND i.item_code!=i.stock_id";
723 $sql .= " AND !i.inactive";
724 $sql .= " GROUP BY i.item_code";
726 return combo_input($name, $selected_id, $sql, 'i.item_code', 'c.description',
729 'format' => '_format_stock_items',
730 'spec_option' => $all_option===true ? _("All Items") : $all_option,
731 'spec_id' => $all_items,
732 'search_box' => true,
733 'search' => array("i.item_code", "i.description"),
734 'search_submit' => get_company_pref('no_item_list')!=0,
736 'select_submit'=> $submit_on_change,
738 'order' => array('c.description','i.item_code')
742 function sales_items_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
745 echo "<td>$label</td>\n";
746 $str = sales_items_list($name, $selected_id, $all_option, $submit_on_change,
747 '', array('cells'=>true));
751 function sales_kits_list($name, $selected_id=null, $all_option=false, $submit_on_change=false)
753 $str = sales_items_list($name, $selected_id, $all_option, $submit_on_change,
754 'kits', array('cells'=>false));
758 function sales_local_items_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
762 echo "<td>$label</td>\n";
764 $str = sales_items_list($name, $selected_id, $all_option, $submit_on_change,
765 'local', array('cells'=>false));
769 //------------------------------------------------------------------------------------
771 function base_stock_items_list($where, $name, $selected_id=null,
772 $all_option=false, $submit_on_change=false)
776 $sql = "SELECT stock_id, s.description, c.description, s.inactive
777 FROM ".TB_PREF."stock_master s,".TB_PREF."stock_category c WHERE
778 s.category_id=c.category_id";
780 return combo_input($name, $selected_id, $sql, 'stock_id', 's.description',
782 'format' => '_format_stock_items',
783 'spec_option' => $all_option==true ? _("All Items") : $all_option,
784 'spec_id' => $all_items,
785 'select_submit'=> $submit_on_change,
789 //------------------------------------------------------------------------------------
791 function stock_bom_items_list($name, $selected_id=null, $all_option=false, $submit_on_change=false)
794 return base_stock_items_list("(s.mb_flag='M' OR s.mb_flag='K')",
795 $name, $selected_id, $all_option, $submit_on_change);
798 function stock_bom_items_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
801 echo "<td>$label</td>\n";
803 $str = stock_bom_items_list($name, $selected_id, $all_option, $submit_on_change);
808 function stock_bom_items_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
811 $str = stock_bom_items_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
816 //------------------------------------------------------------------------------------
818 function stock_manufactured_items_list($name, $selected_id=null,
819 $all_option=false, $submit_on_change=false)
821 return base_stock_items_list("s.mb_flag='M'",
822 $name, $selected_id, $all_option, $submit_on_change);
825 function stock_manufactured_items_list_cells($label, $name, $selected_id=null,
826 $all_option=false, $submit_on_change=false)
829 echo "<td>$label</td>\n";
831 $str = stock_manufactured_items_list($name, $selected_id, $all_option,
837 function stock_manufactured_items_list_row($label, $name, $selected_id=null,
838 $all_option=false, $submit_on_change=false)
841 $str = stock_manufactured_items_list_cells($label, $name, $selected_id,
842 $all_option, $submit_on_change);
846 //------------------------------------------------------------------------------------
848 function stock_component_items_list($name, $parent_stock_id, $selected_id=null,
849 $all_option=false, $submit_on_change=false)
851 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
852 array('where'=>array("stock_id != '$parent_stock_id'")));
856 function stock_component_items_list_cells($label, $name, $parent_stock_id,
857 $selected_id=null, $all_option=false, $submit_on_change=false)
860 echo "<td>$label</td>\n";
861 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
862 array('where'=>array("stock_id != '$parent_stock_id'"), 'cells'=>true));
865 //------------------------------------------------------------------------------------
867 function stock_costable_items_list($name, $selected_id=null,
868 $all_option=false, $submit_on_change=false)
870 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
871 array('where'=>array("mb_flag!='D'")));
875 function stock_costable_items_list_cells($label, $name, $selected_id=null,
876 $all_option=false, $submit_on_change=false)
879 echo "<td>$label</td>\n";
880 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
881 array('where'=>array("mb_flag!='D'"), 'cells'=>true));
885 //------------------------------------------------------------------------------------
886 function stock_purchasable_items_list($name, $selected_id=null,
887 $all_option=false, $submit_on_change=false, $all=false)
889 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
890 array('where'=>array("mb_flag!= 'M'"),
891 'edit_submit' => true,
892 'show_inactive'=>$all));
896 function stock_purchasable_items_list_cells($label, $name, $selected_id=null,
897 $all_option=false, $submit_on_change=false, $all=false)
900 echo "<td>$label</td>\n";
901 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
902 array('where'=>array("mb_flag!= 'M'"),
903 'edit_submit' => true,
908 function stock_purchasable_items_list_row($label, $name, $selected_id=null,
909 $all_option=false, $submit_on_change=false)
912 $ret = stock_purchasable_items_list_cells($label, $name, $selected_id=null,
913 $all_option, $submit_on_change);
918 //------------------------------------------------------------------------------------
920 function stock_item_types_list_row($label, $name, $selected_id=null, $enabled=true)
926 echo "<td>$label</td>\n";
929 array_selector($name, $selected_id, $stock_types,
931 'select_submit'=> true,
932 'disabled' => !$enabled) );
936 function stock_units_list_row($label, $name, $value=null, $enabled=true)
938 $result = get_all_item_units();
941 echo "<td>$label</td>\n";
944 while($unit = db_fetch($result))
945 $units[$unit['abbr']] = $unit['name'];
947 array_selector($name, $value, $units,
949 'select_submit'=> true,
950 'disabled' => !$enabled) );
955 //------------------------------------------------------------------------------------
957 function tax_types_list($name, $selected_id=null, $none_option=false, $submit_on_change=false)
959 $sql = "SELECT id, CONCAT(name, ' (',rate,'%)') as name FROM ".TB_PREF."tax_types";
961 return combo_input($name, $selected_id, $sql, 'id', 'name',
963 'spec_option' => $none_option,
964 'spec_id' => reserved_words::get_all_numeric(),
965 'select_submit'=> $submit_on_change,
970 function tax_types_list_cells($label, $name, $selected_id=null, $none_option=false,
971 $submit_on_change=false)
974 echo "<td>$label</td>\n";
976 $str = tax_types_list($name, $selected_id, $none_option, $submit_on_change);
981 function tax_types_list_row($label, $name, $selected_id=null, $none_option=false,
982 $submit_on_change=false)
985 $str = tax_types_list_cells($label, $name, $selected_id, $none_option, $submit_on_change);
990 //------------------------------------------------------------------------------------
992 function tax_groups_list($name, $selected_id=null,
993 $none_option=false, $submit_on_change=false)
995 $sql = "SELECT id, name FROM ".TB_PREF."tax_groups";
997 return combo_input($name, $selected_id, $sql, 'id', 'name',
1000 'spec_option' => $none_option,
1001 'spec_id' => reserved_words::get_all_numeric(),
1002 'select_submit'=> $submit_on_change,
1007 function tax_groups_list_cells($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false)
1010 echo "<td>$label</td>\n";
1012 $str = tax_groups_list($name, $selected_id, $none_option, $submit_on_change);
1017 function tax_groups_list_row($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false)
1020 $str = tax_groups_list_cells($label, $name, $selected_id, $none_option, $submit_on_change);
1025 //------------------------------------------------------------------------------------
1027 function item_tax_types_list($name, $selected_id=null)
1029 $sql ="SELECT id, name FROM ".TB_PREF."item_tax_types";
1030 combo_input($name, $selected_id, $sql, 'id', 'name', array('order' => 'id') );
1033 function item_tax_types_list_cells($label, $name, $selected_id=null)
1036 echo "<td>$label</td>\n";
1038 item_tax_types_list($name, $selected_id);
1042 function item_tax_types_list_row($label, $name, $selected_id=null)
1045 item_tax_types_list_cells($label, $name, $selected_id);
1049 //------------------------------------------------------------------------------------
1051 function shippers_list($name, $selected_id=null)
1053 $sql = "SELECT shipper_id, shipper_name, inactive FROM ".TB_PREF."shippers";
1054 combo_input($name, $selected_id, $sql, 'shipper_id', 'shipper_name', array());
1057 function shippers_list_cells($label, $name, $selected_id=null)
1060 echo "<td>$label</td>\n";
1062 shippers_list($name, $selected_id);
1066 function shippers_list_row($label, $name, $selected_id=null)
1069 shippers_list_cells($label, $name, $selected_id);
1073 //-------------------------------------------------------------------------------------
1075 function sales_persons_list($name, $selected_id=null)
1077 $sql = "SELECT salesman_code, salesman_name, inactive FROM ".TB_PREF."salesman";
1078 combo_input($name, $selected_id, $sql, 'salesman_code', 'salesman_name', array());
1081 function sales_persons_list_cells($label, $name, $selected_id=null)
1084 echo "<td>$label</td>\n";
1086 sales_persons_list($name, $selected_id);
1090 function sales_persons_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1093 sales_persons_list_cells($label, $name, $selected_id, $submit_on_change=false);
1097 //------------------------------------------------------------------------------------
1099 function sales_areas_list($name, $selected_id=null)
1101 $sql = "SELECT area_code, description, inactive FROM ".TB_PREF."areas";
1102 combo_input($name, $selected_id, $sql, 'area_code', 'description', array());
1105 function sales_areas_list_cells($label, $name, $selected_id=null)
1108 echo "<td>$label</td>\n";
1110 sales_areas_list($name, $selected_id);
1114 function sales_areas_list_row($label, $name, $selected_id=null)
1117 sales_areas_list_cells($label, $name, $selected_id);
1121 //------------------------------------------------------------------------------------
1123 function sales_groups_list($name, $selected_id=null, $special_option=false)
1125 $sql = "SELECT id, description, inactive FROM ".TB_PREF."groups";
1126 combo_input($name, $selected_id, $sql, 'id', 'description', array(
1127 'spec_option' => $special_option===true ? ' ' : $special_option,
1128 'order' => 'description', 'spec_id' => 0,
1132 function sales_groups_list_cells($label, $name, $selected_id=null, $special_option=false)
1135 echo "<td>$label</td>\n";
1137 sales_groups_list($name, $selected_id, $special_option);
1141 function sales_groups_list_row($label, $name, $selected_id=null, $special_option=false)
1144 sales_groups_list_cells($label, $name, $selected_id, $special_option);
1148 //------------------------------------------------------------------------------------
1150 function _format_template_items($row)
1152 return ($row[0] . " - " . _("Amount") . " ".$row[1]);
1155 function templates_list($name, $selected_id=null, $special_option=false)
1157 $sql = "SELECT sorder.order_no, Sum(line.unit_price*line.quantity*(1-line.discount_percent)) AS OrderValue
1158 FROM ".TB_PREF."sales_orders as sorder, ".TB_PREF."sales_order_details as line
1159 WHERE sorder.order_no = line.order_no AND sorder.type = 1 GROUP BY line.order_no";
1160 combo_input($name, $selected_id, $sql, 'order_no', 'OrderValue', array(
1161 'format' => '_format_template_items',
1162 'spec_option' => $special_option===true ? ' ' : $special_option,
1163 'order' => 'order_no', 'spec_id' => 0,
1167 function templates_list_cells($label, $name, $selected_id=null, $special_option=false)
1170 echo "<td>$label</td>\n";
1172 templates_list($name, $selected_id, $special_option);
1176 function templates_list_row($label, $name, $selected_id=null, $special_option=false)
1179 templates_list_cells($label, $name, $selected_id, $special_option);
1183 //------------------------------------------------------------------------------------
1185 function workorders_list($name, $selected_id=null)
1187 $sql = "SELECT id, wo_ref FROM ".TB_PREF."workorders WHERE closed=0";
1188 combo_input($name, $selected_id, $sql, 'id', 'wo_ref', array());
1191 function workorders_list_cells($label, $name, $selected_id=null)
1194 echo "<td>$label</td>\n";
1196 workorders_list($name, $selected_id);
1200 function workorders_list_row($label, $name, $selected_id=null)
1203 workorders_list_cells($label, $name, $selected_id);
1207 //------------------------------------------------------------------------------------
1209 function payment_terms_list($name, $selected_id=null)
1211 $sql = "SELECT terms_indicator, terms, inactive FROM ".TB_PREF."payment_terms";
1212 combo_input($name, $selected_id, $sql, 'terms_indicator', 'terms', array());
1215 function payment_terms_list_cells($label, $name, $selected_id=null)
1218 echo "<td>$label</td>\n";
1220 payment_terms_list($name, $selected_id);
1224 function payment_terms_list_row($label, $name, $selected_id=null)
1227 payment_terms_list_cells($label, $name, $selected_id);
1231 //------------------------------------------------------------------------------------
1233 function credit_status_list($name, $selected_id=null)
1235 $sql ="SELECT id, reason_description, inactive FROM ".TB_PREF."credit_status";
1236 combo_input($name, $selected_id, $sql, 'id', 'reason_description', array());
1239 function credit_status_list_cells($label, $name, $selected_id=null)
1242 echo "<td>$label</td>\n";
1244 credit_status_list($name, $selected_id);
1248 function credit_status_list_row($label, $name, $selected_id=null)
1251 credit_status_list_cells($label, $name, $selected_id);
1255 //-----------------------------------------------------------------------------------------------
1257 function sales_types_list($name, $selected_id=null, $submit_on_change=false, $special_option=false)
1259 $sql = "SELECT id, sales_type, inactive FROM ".TB_PREF."sales_types";
1261 return combo_input($name, $selected_id, $sql, 'id', 'sales_type',
1263 'spec_option' => $special_option===true ? _("All Sales Types") : $special_option,
1265 'select_submit'=> $submit_on_change,
1266 // 'async' => false,
1270 function sales_types_list_cells($label, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1273 echo "<td>$label</td>\n";
1275 $str = sales_types_list($name, $selected_id, $submit_on_change, $special_option);
1280 function sales_types_list_row($label, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1283 $str = sales_types_list_cells($label, $name, $selected_id, $submit_on_change, $special_option);
1288 //-----------------------------------------------------------------------------------------------
1290 function movement_types_list($name, $selected_id=null)
1292 $sql = "SELECT id, name FROM ".TB_PREF."movement_types";
1293 combo_input($name, $selected_id, $sql, 'id', 'name', array());
1296 function movement_types_list_cells($label, $name, $selected_id=null)
1299 echo "<td>$label</td>\n";
1301 movement_types_list($name, $selected_id);
1305 function movement_types_list_row($label, $name, $selected_id=null)
1308 movement_types_list_cells($label, $name, $selected_id);
1312 //-----------------------------------------------------------------------------------------------
1313 function _format_date($row)
1315 return sql2date($row['reconciled']);
1318 function bank_reconciliation_list($account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1320 $sql = "SELECT reconciled, reconciled FROM ".TB_PREF."bank_trans
1321 WHERE bank_act=".db_escape($account)." AND reconciled IS NOT NULL
1322 GROUP BY reconciled";
1323 combo_input($name, $selected_id, $sql, 'id', 'reconciled',
1325 'spec_option' => $special_option,
1326 'format' => '_format_date',
1328 'select_submit'=> $submit_on_change
1332 function bank_reconciliation_list_cells($label,$account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1335 echo "<td>$label</td>\n";
1337 bank_reconciliation_list($account, $name, $selected_id, $submit_on_change, $special_option);
1341 function bank_reconciliation_list_row($label, $account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1344 bank_reconciliation_list_cells($label, $account, $name, $selected_id, $submit_on_change, $special_option);
1348 //-----------------------------------------------------------------------------------------------
1350 function workcenter_list($name, $selected_id=null, $all_option=false)
1354 $sql = "SELECT id, name, inactive FROM ".TB_PREF."workcentres";
1356 return combo_input($name, $selected_id, $sql, 'id', 'name',
1358 'spec_option' =>$all_option===true ? _("All Suppliers") : $all_option,
1359 'spec_id' => $all_items,
1363 function workcenter_list_cells($label, $name, $selected_id=null, $all_option=false)
1365 default_focus($name);
1367 echo "<td>$label</td>\n";
1369 workcenter_list($name, $selected_id, $all_option);
1373 function workcenter_list_row($label, $name, $selected_id=null, $all_option=false)
1376 workcenter_list_cells($label, $name, $selected_id, $all_option);
1380 //-----------------------------------------------------------------------------------------------
1382 function bank_accounts_list($name, $selected_id=null, $submit_on_change=false)
1384 $sql = "SELECT ".TB_PREF."bank_accounts.id, bank_account_name, bank_curr_code, inactive
1385 FROM ".TB_PREF."bank_accounts";
1386 // , ".TB_PREF."chart_master
1387 // WHERE ".TB_PREF."bank_accounts.account_code=".TB_PREF."chart_master.account_code";
1389 return combo_input($name, $selected_id, $sql, 'id', 'bank_account_name',
1391 'format' => '_format_add_curr',
1392 'select_submit'=> $submit_on_change,
1397 function bank_accounts_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1400 echo "<td>$label</td>\n";
1402 $str = bank_accounts_list($name, $selected_id, $submit_on_change);
1407 function bank_accounts_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1410 $str = bank_accounts_list_cells($label, $name, $selected_id, $submit_on_change);
1414 //-----------------------------------------------------------------------------------------------
1416 function cash_accounts_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1418 $sql = "SELECT ".TB_PREF."bank_accounts.id, bank_account_name, bank_curr_code, inactive
1419 FROM ".TB_PREF."bank_accounts
1420 WHERE ".TB_PREF."bank_accounts.account_type=3";
1423 echo "<tr><td>$label</td>\n";
1425 $str = combo_input($name, $selected_id, $sql, 'id', 'bank_account_name',
1427 'format' => '_format_add_curr',
1428 'select_submit'=> $submit_on_change,
1431 echo "</td></tr>\n";
1434 //-----------------------------------------------------------------------------------------------
1436 function pos_list_row($label, $name, $selected_id=null, $spec_option=false, $submit_on_change=false)
1438 $sql = "SELECT id, pos_name, inactive FROM ".TB_PREF."sales_pos";
1440 default_focus($name);
1443 echo "<td>$label</td>\n";
1446 $str = combo_input($name, $selected_id, $sql, 'id', 'pos_name',
1448 'select_submit'=> $submit_on_change,
1450 'spec_option' =>$spec_option,
1453 echo "</td></tr>\n";
1457 //-----------------------------------------------------------------------------------------------
1459 function sale_payment_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1462 echo "<td>$label</td>\n";
1464 $str = yesno_list($name, $selected_id, _('Cash'), _('Delayed'), $submit_on_change);
1468 //-----------------------------------------------------------------------------------------------
1470 function class_list($name, $selected_id=null, $submit_on_change=false)
1472 $sql = "SELECT cid, class_name FROM ".TB_PREF."chart_class";
1474 return combo_input($name, $selected_id, $sql, 'cid', 'class_name',
1476 'select_submit'=> $submit_on_change,
1482 function class_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1485 echo "<td>$label</td>\n";
1487 $str = class_list($name, $selected_id, $submit_on_change);
1492 function class_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1495 $str = class_list_cells($label, $name, $selected_id, $submit_on_change);
1500 //-----------------------------------------------------------------------------------------------
1502 function stock_categories_list($name, $selected_id=null, $submit_on_change=false)
1504 $sql = "SELECT category_id, description, inactive FROM ".TB_PREF."stock_category";
1505 combo_input($name, $selected_id, $sql, 'category_id', 'description',
1506 array('order'=>'category_id',
1507 'select_submit'=> $submit_on_change,
1512 function stock_categories_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1515 echo "<td>$label</td>\n";
1517 stock_categories_list($name, $selected_id, $submit_on_change);
1521 function stock_categories_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1524 stock_categories_list_cells($label, $name, $selected_id, $submit_on_change);
1528 //-----------------------------------------------------------------------------------------------
1530 function gl_account_types_list($name, $selected_id=null, $all_option, $all_option_numeric)
1534 $sql = "SELECT id, name FROM ".TB_PREF."chart_types";
1536 combo_input($name, $selected_id, $sql, 'id', 'name',
1539 'spec_option' =>$all_option,
1540 'spec_id' => $all_option_numeric ? 0 : $all_items
1544 function gl_account_types_list_cells($label, $name, $selected_id=null, $all_option=false,
1545 $all_option_numeric=false)
1548 echo "<td>$label</td>\n";
1550 gl_account_types_list($name, $selected_id, $all_option, $all_option_numeric);
1554 function gl_account_types_list_row($label, $name, $selected_id=null, $all_option=false,
1555 $all_option_numeric=false)
1558 gl_account_types_list_cells($label, $name, $selected_id, $all_option,
1559 $all_option_numeric);
1563 //-----------------------------------------------------------------------------------------------
1564 function gl_all_accounts_list($name, $selected_id=null, $skip_bank_accounts=false,
1565 $cells=false, $all_option=false, $submit_on_change=false, $all=false)
1567 if ($skip_bank_accounts)
1568 $sql = "SELECT chart.account_code, chart.account_name, type.name, chart.inactive
1569 FROM (".TB_PREF."chart_master chart,".TB_PREF."chart_types type) "
1570 ."LEFT JOIN ".TB_PREF."bank_accounts acc "
1571 ."ON chart.account_code=acc.account_code
1572 WHERE acc.account_code IS NULL
1573 AND chart.account_type=type.id";
1575 $sql = "SELECT chart.account_code, chart.account_name, type.name, chart.inactive
1576 FROM ".TB_PREF."chart_master chart,".TB_PREF."chart_types type
1577 WHERE chart.account_type=type.id";
1579 combo_input($name, $selected_id, $sql, 'chart.account_code', 'chart.account_name',
1581 'format' => '_format_account',
1582 'spec_option' => $all_option===true ? _("Use Item Sales Accounts") : $all_option,
1584 'order' => array('name','account_code'),
1585 'search_box' => $cells,
1586 'search_submit' => false,
1590 'select_submit'=> $submit_on_change,
1593 'show_inactive' => $all
1598 function _format_account($row)
1600 return $row[0] . " " . $row[1];
1603 function gl_all_accounts_list_cells($label, $name, $selected_id=null,
1604 $skip_bank_accounts=false, $cells=false, $all_option=false,
1605 $submit_on_change=false, $all=false)
1608 echo "<td>$label</td>\n";
1610 gl_all_accounts_list($name, $selected_id,
1611 $skip_bank_accounts, $cells, $all_option, $submit_on_change, $all);
1615 function gl_all_accounts_list_row($label, $name, $selected_id=null,
1616 $skip_bank_accounts=false, $cells=false, $all_option=false)
1619 gl_all_accounts_list_cells($label, $name, $selected_id,
1620 $skip_bank_accounts, $cells, $all_option);
1624 function yesno_list($name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1627 $items['1'] = strlen($name_yes) ? $name_yes : _("Yes");
1628 $items['0'] = strlen($name_no) ? $name_no : _("No");
1630 return array_selector($name, $selected_id, $items,
1632 'select_submit'=> $submit_on_change,
1633 'async' => false ) ); // FIX?
1636 function yesno_list_cells($label, $name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1639 echo "<td>$label</td>\n";
1641 $str = yesno_list($name, $selected_id, $name_yes, $name_no, $submit_on_change);
1646 function yesno_list_row($label, $name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1649 $str = yesno_list_cells($label, $name, $selected_id, $name_yes, $name_no, $submit_on_change);
1654 //------------------------------------------------------------------------------------------------
1656 function languages_list($name, $selected_id=null)
1658 global $installed_languages;
1661 foreach ($installed_languages as $lang)
1662 $items[$lang['code']] = $lang['name'];
1664 return array_selector($name, $selected_id, $items );
1667 function languages_list_cells($label, $name, $selected_id=null)
1670 echo "<td>$label</td>\n";
1672 languages_list($name, $selected_id);
1676 function languages_list_row($label, $name, $selected_id=null)
1679 languages_list_cells($label, $name, $selected_id);
1683 //------------------------------------------------------------------------------------------------
1685 function bank_account_types_list($name, $selected_id=null)
1687 $types = bank_account_types::get_all();
1690 foreach ($types as $type)
1692 $items[$type['id']] = $type['name'];
1695 return array_selector($name, $selected_id, $items );
1698 function bank_account_types_list_cells($label, $name, $selected_id=null)
1701 echo "<td>$label</td>\n";
1703 bank_account_types_list($name, $selected_id);
1707 function bank_account_types_list_row($label, $name, $selected_id=null)
1710 bank_account_types_list_cells($label, $name, $selected_id);
1714 //------------------------------------------------------------------------------------------------
1715 function payment_person_types_list($name, $selected_id=null, $submit_on_change=false)
1717 $types = payment_person_types::get_all();
1720 foreach ($types as $type)
1722 if (payment_person_types::has_items($type['id']))
1724 $items[$type['id']] = $type['name'];
1728 return array_selector($name, $selected_id, $items,
1729 array( 'select_submit'=> $submit_on_change ) );
1732 function payment_person_types_list_cells($label, $name, $selected_id=null, $related=null)
1735 echo "<td>$label</td>\n";
1737 $str = payment_person_types_list($name, $selected_id, $related);
1742 function payment_person_types_list_row($label, $name, $selected_id=null, $related=null)
1745 $str = payment_person_types_list_cells($label, $name, $selected_id, $related);
1750 //------------------------------------------------------------------------------------------------
1752 function wo_types_list($name, $selected_id=null)
1754 $types = wo_types::get_all();
1757 foreach ($types as $type)
1758 $items[$type['id']] = $type['name'];
1760 return array_selector($name, $selected_id, $items,
1761 array( 'select_submit'=> true, 'async' => true ) );
1764 function wo_types_list_row($label, $name, $selected_id=null)
1766 echo "<tr><td>$label</td><td>\n";
1767 $str = wo_types_list($name, $selected_id);
1768 echo "</td></tr>\n";
1772 //------------------------------------------------------------------------------------------------
1774 function dateformats_list_row($label, $name, $value=null)
1776 global $dateformats;
1778 echo "<tr><td>$label</td>\n<td>";
1779 array_selector( $name, $value, $dateformats );
1780 echo "</td></tr>\n";
1783 function dateseps_list_row($label, $name, $value=null)
1787 echo "<tr><td>$label</td>\n<td>";
1788 array_selector( $name, $value, $dateseps );
1789 echo "</td></tr>\n";
1792 function thoseps_list_row($label, $name, $value=null)
1796 echo "<tr><td>$label</td>\n<td>";
1797 array_selector( $name, $value, $thoseps );
1798 echo "</td></tr>\n";
1801 function decseps_list_row($label, $name, $value=null)
1805 echo "<tr><td>$label</td>\n<td>";
1806 array_selector( $name, $value, $decseps );
1807 echo "</td></tr>\n";
1810 function themes_list_row($label, $name, $value=null)
1812 global $path_to_root;
1814 $path = $path_to_root.'/themes/';
1816 $themedir = opendir($path);
1817 while(false !== ($fname = readdir($themedir)))
1819 if($fname!='.' && $fname!='..' && $fname!='CVS' && is_dir($path.$fname))
1821 $themes[$fname] = $fname;
1826 echo "<tr><td>$label</td>\n<td>";
1827 array_selector( $name, $value, $themes );
1828 echo "</td></tr>\n";
1831 function pagesizes_list_row($label, $name, $value=null)
1836 foreach ($pagesizes as $pz)
1839 echo "<tr><td>$label</td>\n<td>";
1840 array_selector( $name, $value, $items );
1841 echo "</td></tr>\n";
1844 function security_headings_list_row($label, $name, $value=null)
1846 global $security_headings;
1848 echo "<tr><td>$label</td>\n<td>";
1849 array_selector( $name, $value, $security_headings );
1850 echo "</td></tr>\n";
1853 function systypes_list_cells($label, $name, $value=null, $submit_on_change=false)
1855 global $systypes_array;
1858 echo "<td>$label</td>\n";
1862 foreach ($systypes_array as $key=>$type)
1863 $items[$key] = $type['name'];
1865 $str = array_selector($name, $value, $items,
1867 'select_submit'=> $submit_on_change,
1875 function systypes_list_row($label, $name, $value=null, $submit_on_change=false)
1878 $str = systypes_list_cells($label, $name, $value, $submit_on_change);
1883 function cust_allocations_list_cells($label, $name, $selected=null)
1891 $all_items=>_("All Types"),
1892 '1'=> _("Sales Invoices"),
1893 '2'=> _("Overdue Invoices"),
1894 '3' => _("Payments"),
1895 '4' => _("Credit Notes"),
1896 '5' => _("Delivery Notes")
1898 $str = array_selector($name, $selected, $allocs);
1903 function supp_allocations_list_cell($name, $selected=null)
1909 $all_items=>_("All Types"),
1910 '1'=> _("Invoices"),
1911 '2'=> _("Overdue Invoices"),
1912 '3' => _("Payments"),
1913 '4' => _("Credit Notes"),
1914 '5' => _("Overdue Credit Notes")
1916 $str = array_selector($name, $selected, $allocs);
1921 function policy_list_cells($label, $name, $selected=null)
1926 $str = array_selector($name, $selected,
1927 array( '' => _("Automatically put balance on back order"),
1928 'CAN' => _("Cancel any quantites not delivered")) );
1933 function policy_list_row($label, $name, $selected=null)
1936 policy_list_cells($label, $name, $selected);
1940 function credit_type_list_cells($label, $name, $selected=null, $submit_on_change=false)
1945 $str = array_selector($name, $selected,
1946 array( 'Return' => _("Items Returned to Inventory Location"),
1947 'WriteOff' => _("Items Written Off")),
1948 array( 'select_submit'=> $submit_on_change ) );
1953 function credit_type_list_row($label, $name, $selected=null, $submit_on_change=false)
1956 $str = credit_type_list_cells($label, $name, $selected, $submit_on_change);
1961 function number_list($name, $selected, $from, $to, $no_option=false)
1964 for ($i = $from; $i <= $to; $i++)
1967 return array_selector($name, $selected, $items,
1968 array( 'spec_option' => $no_option,
1969 'spec_id' => reserved_words::get_all_numeric()) );
1972 function number_list_cells($label, $name, $selected, $from, $to, $no_option=false)
1977 number_list($name, $selected, $from, $to, $no_option);
1981 function number_list_row($label, $name, $selected, $from, $to, $no_option=false)
1984 number_list_cells($label, $name, $selected, $from, $to, $no_option);
1988 function print_profiles_list_row($label, $name, $selected_id=null, $spec_opt=false,
1989 $submit_on_change=true)
1991 $sql = "SELECT profile FROM ".TB_PREF."print_profiles"
1992 ." GROUP BY profile";
1993 $result = db_query($sql, 'cannot get all profile names');
1994 $profiles = array();
1995 while($myrow=db_fetch($result)) {
1996 $profiles[$myrow['profile']] = $myrow['profile'];
2001 echo "<td>$label</td>\n";
2004 array_selector($name, $selected_id, $profiles,
2005 array( 'select_submit'=> $submit_on_change,
2006 'spec_option'=>$spec_opt,
2010 echo "</td></tr>\n";
2013 function printers_list($name, $selected_id=null, $spec_opt=false, $submit_on_change=false)
2015 static $printers; // query only once for page display
2018 $sql = "SELECT id, name, description FROM ".TB_PREF."printers";
2019 $result = db_query($sql, 'cannot get all printers');
2020 $printers = array();
2021 while($myrow=db_fetch($result)) {
2022 $printers[$myrow['id']] = $myrow['name'].' - '.$myrow['description'];
2025 array_selector($name, $selected_id, $printers,
2026 array( 'select_submit'=> $submit_on_change,
2027 'spec_option'=>$spec_opt,
2032 //------------------------------------------------------------------------------------------------
2034 function quick_entries_list($name, $selected_id=null, $type=null, $submit_on_change=false)
2037 $sql = "SELECT id, description FROM ".TB_PREF."quick_entries";
2039 $sql .= " WHERE type=$type";
2041 combo_input($name, $selected_id, $sql, 'id', 'description',
2044 'order' => 'description',
2045 'select_submit'=> $submit_on_change,
2051 function quick_entries_list_cells($label, $name, $selected_id=null, $type, $submit_on_change=false)
2053 echo "<td>$label</td><td>\n";
2054 quick_entries_list($name, $selected_id, $type, $submit_on_change);
2058 function quick_entries_list_row($label, $name, $selected_id=null, $type, $submit_on_change=false)
2061 quick_entries_list_cells($label, $name, $selected_id, $type, $submit_on_change);
2066 function quick_actions_list_row($label, $name, $selected_id=null, $submit_on_change=false)
2068 global $quick_actions;
2070 echo "<tr><td>$label</td><td>";
2071 array_selector($name, $selected_id, $quick_actions,
2073 'select_submit'=> $submit_on_change
2075 echo "</td></tr>\n";
2078 function quick_entry_types_list_row($label, $name, $selected_id=null, $submit_on_change=false)
2080 global $quick_entry_types;
2082 echo "<tr><td>$label</td><td>";
2083 array_selector($name, $selected_id, $quick_entry_types,
2085 'select_submit'=> $submit_on_change
2087 echo "</td></tr>\n";
2090 function record_status_list_row($label, $name) {
2091 return yesno_list_row($label, $name, null, _('Inactive'), _('Active'));