2 /**********************************************************************
3 Copyright (C) FrontAccounting, LLC.
4 Released under the terms of the GNU General Public License, GPL,
5 as published by the Free Software Foundation, either version 3
6 of the License, or (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
12 include_once($path_to_root . "/includes/banking.inc");
13 include_once($path_to_root . "/includes/reserved.inc");
14 include_once($path_to_root . "/includes/types.inc");
15 include_once($path_to_root . "/includes/current_user.inc");
17 $_search_button = "<input %s type='submit' class='combo_submit' style='border:0;background:url($path_to_root/themes/"
18 ."%s/images/locate.png) no-repeat;%s' aspect='fallback' name='%s' value=' ' title='"._("Set filter")."'> ";
20 $_select_button = "<input %s type='submit' class='combo_select' style='border:0;background:url($path_to_root/themes/"
21 ."%s/images/button_ok.png) no-repeat;%s' aspect='fallback' name='%s' value=' ' title='"._("Select")."'> ";
23 $all_items = reserved_words::get_all();
25 //----------------------------------------------------------------------------
26 // Universal sql combo generator
27 // $sql must return selector values and selector texts in columns 0 & 1
28 // Options are merged with defaults.
30 function combo_input($name, $selected_id, $sql, $valfield, $namefield,
35 $opts = array( // default options
36 'where'=> array(), // additional constraints
37 'order' => $namefield, // list sort order
38 // special option parameters
39 'spec_option'=>false, // option text or false
40 'spec_id' => 0, // option id
41 // submit on select parameters
42 'default' => '', // default value when $_POST is not set
43 'select_submit' => false, //submit on select: true/false
44 'edit_submit' => false, // call editor on F4
45 'async' => true, // select update via ajax (true) vs _page_body reload
46 // search box parameters
48 'search_box' => false, // name or true/false
49 'type' => 0, // type of extended selector:
50 // 0 - with (optional) visible search box, search by id
51 // 1 - with hidden search box, search by option text
52 // 2 - TODO reverse: box with hidden selector available via enter; this
53 // would be convenient for optional ad hoc adding of new item
54 'search_submit' => true, //search submit button: true/false
55 'size' => 8, // size and max of box tag
57 'cells' => false, // combo displayed as 2 <td></td> cells
58 'search' => array(), // sql field names to search
59 'format' => null, // format functions for regular options
61 'box_hint' => null, // box/selectors hints; null = std see below
62 'category' => false // category column name or false
64 // ------ merge options with defaults ----------
66 $opts = array_merge($opts, $options);
67 if (!is_array($opts['where'])) $opts['where'] = array($opts['where']);
69 $search_box = $opts['search_box']===true ? '_'.$name.'_edit' : $opts['search_box'];
70 $search_submit = $opts['search_submit']===true ? '_'.$name.'_button' : $opts['search_submit'];
71 $select_submit = $opts['select_submit']===true ? '_'.$name.'_update' : $opts['select_submit'];
72 $spec_id = $opts['spec_id'];
73 $spec_option = $opts['spec_option'];
74 $by_id = ($opts['type'] == 0);
75 $class = $by_id ? 'combo':'combo2';
76 $disabled = $opts['disabled'] ? "disabled" : '';
78 if(!count($opts['search'])) {
79 $opts['search'] = array($by_id ? $valfield : $namefield);
81 if ($opts['sel_hint'] === null)
82 $opts['sel_hint'] = $by_id || $search_box==false ?
83 '' : _('Press Space tab for search pattern entry');
85 if ($opts['box_hint'] === null)
86 $opts['box_hint'] = $search_box && $search_submit != false ?
87 ($by_id ? _('Enter code fragment to search or * for all')
88 : _('Enter description fragment to search or * for all')) :'';
90 if ($selected_id == null) {
91 $selected_id = get_post($name, $opts['default']);
93 $txt = get_post($search_box);
97 if (isset($_POST[$select_submit])) {
98 if ($by_id) $txt = $_POST[$name];
101 $Ajax->activate('_page_body');
103 $Ajax->activate($name);
106 // search related sql modifications
108 $rel = "rel='$search_box'"; // set relation to list
109 if ($opts['search_submit']) {
110 if (isset($_POST[$search_submit])) {
111 $selected_id = ''; // ignore selected_id while search
113 $Ajax->activate('_page_body');
115 $Ajax->activate($name);
118 if ($spec_option === false && $selected_id==null)
121 $opts['where'][] = $valfield . "='". get_post($name, $spec_id)."'";
126 foreach($opts['search'] as $i=> $s)
127 $opts['search'][$i] = $s . " LIKE '%{$txt}%'";
128 $opts['where'][] = '('. implode($opts['search'], ' OR ') . ')';
133 if (count($opts['where'])) {
134 $where = strpos($sql, 'WHERE')==false ? ' WHERE ':' AND ';
135 $where .= '('. implode($opts['where'], ' AND ') . ')';
136 $group_pos = strpos($sql, 'GROUP BY');
138 $group = substr($sql, $group_pos);
139 $sql = substr($sql, 0, $group_pos) . $where.' '.$group;
144 if ($opts['order'] != false) {
145 if (!is_array($opts['order']))
146 $opts['order'] = array($opts['order']);
147 $sql .= ' ORDER BY '.implode(',',$opts['order']);
151 // ------ make selector ----------
152 $selector = $first_opt = '';
156 //if($name=='stock_id') display_error($sql);
157 if($result = db_query($sql)) {
158 while ($contact_row = db_fetch($result)) {
159 $value = $contact_row[0];
160 $descr = $opts['format']==null ? $contact_row[1] :
161 call_user_func($opts['format'], $contact_row);
163 if (get_post($search_submit) && ($txt === $value)) {
164 $selected_id = $value;
166 if ((string)($selected_id) === $value) {
170 if ($first_id === false) {
174 $cat = $contact_row[$opts['category']];
175 if ($opts['category'] !== false && $cat != $lastcat){
176 $selector .= "<optgroup label='".$cat."'>\n";
179 $selector .= "<option $sel value='$value'>$descr</option>\n";
181 db_free_result($result);
184 // Prepend special option.
185 if ($spec_option !== false) { // if special option used - add it
186 $first_id = $spec_id;
187 $first_opt = $spec_option;
188 $sel = $found===false ? 'selected' : '';
189 $selector = "<option $sel value='$spec_id'>$spec_option</option>\n"
193 if ($found === false) {
194 $selected_id = $first_id;
196 $_POST[$name] = $selected_id;
198 if ($by_id && $search_box != false) {
200 $Ajax->addUpdate($name, $search_box, $txt ? $txt : '');
202 $aspect = $opts['edit_submit'] ? " aspect='editable'" : '';
203 $selector = "<select $disabled name='$name' class='$class' title='"
204 . $opts['sel_hint']."'$aspect $rel>".$selector."</select>\n";
206 $Ajax->addUpdate($name, "_{$name}_sel", $selector);
208 // because of bug which M$ cannot fix since IE 5.0
209 // we must embed whole selector in span tags to enable proper ajax update
210 $selector = "<span id='_{$name}_sel'>".$selector."</span>\n";
212 if ($select_submit != false) { // if submit on change is used - add select button
213 global $_select_button;
214 // button class selects form reload/ajax selector update
215 $selector .= sprintf($_select_button, $disabled, user_theme(),
216 (fallback_mode() ? '' : 'display:none;'),
217 $select_submit)."\n";
219 // ------ make combo ----------
222 if ($search_box != false) {
223 $edit_entry = "<input $disabled type='text' name='$search_box' id='$search_box' size='".
224 $opts['size']."' maxlength='".$opts['max'].
225 "' value='$txt' class='$class' rel='$name' autocomplete='off' title='"
226 .$opts['box_hint']."'"
227 .(!fallback_mode() && !$by_id ? " style=display:none;":'')
229 if ($search_submit != false) {
230 global $_search_button;
231 $edit_entry .= sprintf($_search_button, $disabled, user_theme(),
232 (fallback_mode() ? '' : 'display:none;'),
233 $search_submit)."\n";
236 default_focus($name);
238 if ($search_box && $opts['cells'])
239 echo ($edit_entry!='' ? "<td>$edit_entry</td>" : '')."<td>$selector</td>";
241 echo $edit_entry.$selector;
248 Returns true if selector $name is subject to update.
250 function list_updated($name)
252 return isset($_POST['_'.$name.'_update']) || isset($_POST['_'.$name.'_button']);
254 //----------------------------------------------------------------------------------------------
255 // Universal array combo generator
256 // $items is array of options 'value' => 'description'
257 // Options is reduced set of combo_selector options and is merged with defaults.
259 function array_selector($name, $selected_id, $items, $options=null)
263 $opts = array( // default options
264 'spec_option'=>false, // option text or false
265 'spec_id' => 0, // option id
266 'select_submit' => false, //submit on select: true/false
267 'edit_submit' => false, // call editor on F4
268 'async' => true, // select update via ajax (true) vs _page_body reload
269 'default' => '', // default value when $_POST is not set
270 // search box parameters
274 // ------ merge options with defaults ----------
276 $opts = array_merge($opts, $options);
277 $select_submit = $opts['select_submit']===true ? '_'.$name.'_update' : $opts['select_submit'];
278 $spec_id = $opts['spec_id'];
279 $spec_option = $opts['spec_option'];
280 $disabled = $opts['disabled'] ? "disabled" : '';
282 if ($selected_id == null) {
283 $selected_id = get_post($name, $opts['default']);
286 if (isset($_POST[$select_submit])) {
288 $Ajax->activate('_page_body');
290 $Ajax->activate($name);
293 // ------ make selector ----------
294 $selector = $first_opt = '';
297 //if($name=='SelectStockFromList') display_error($sql);
298 foreach($items as $value=>$descr) {
300 if ($selected_id == $value) {
304 if ($first_id === false) {
308 $selector .= "<option $sel value='$value'>$descr</option>\n";
311 // Prepend special option.
312 if ($spec_option !== false) { // if special option used - add it
313 $first_id = $spec_id;
314 $first_opt = $spec_option;
315 $sel = $found===false ? 'selected' : '';
316 $selector = "<option $sel value='$spec_id'>$spec_option</option>\n"
320 if ($found === false) {
321 $_POST[$name] = $first_id;
324 $aspect = $opts['edit_submit'] ? " aspect='editable'" : '';
325 $selector = "<select $disabled name='$name' class='combo' title='"
326 . $opts['sel_hint']."'$aspect >".$selector."</select>\n";
328 $Ajax->addUpdate($name, "_{$name}_sel", $selector);
330 $selector = "<span id='_{$name}_sel'>".$selector."</span>\n";
332 if ($select_submit != false) { // if submit on change is used - add select button
333 global $_select_button;
334 $selector .= sprintf($_select_button, $disabled, user_theme(),
335 (fallback_mode() ? '' : 'display:none;'),
336 $select_submit)."\n";
338 default_focus($name);
343 //----------------------------------------------------------------------------------------------
345 function _format_add_curr($row)
347 static $company_currency;
349 if ($company_currency == null)
351 $company_currency = get_company_currency();
353 return $row[1] . ($row[2] == $company_currency ?
354 '' : (" - " . $row[2]));
357 function supplier_list($name, $selected_id=null, $spec_option=false, $submit_on_change=false)
361 $sql = "SELECT supplier_id, supp_name, curr_code FROM ".TB_PREF."suppliers ";
363 $mode = get_company_pref('no_supplier_list');
365 return combo_input($name, $selected_id, $sql, 'supplier_id', 'supp_name',
367 'format' => '_format_add_curr',
368 'search_box' => $mode!=0,
369 'edit_submit' => true,
371 'spec_option' => $spec_option === true ? _("All Suppliers") : $spec_option,
372 'spec_id' => $all_items,
373 'select_submit'=> $submit_on_change,
375 'sel_hint' => $mode ? _('Press Space tab to filter by name fragment') :
380 function supplier_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
383 echo "<td>$label</td><td>\n";
384 $str = supplier_list($name, $selected_id, $all_option, $submit_on_change);
389 function supplier_list_row($label, $name, $selected_id=null, $all_option = false, $submit_on_change=false)
391 echo "<tr><td>$label</td><td>";
392 $str = supplier_list($name, $selected_id, $all_option, $submit_on_change );
396 //----------------------------------------------------------------------------------------------
398 function customer_list($name, $selected_id=null, $spec_option=false, $submit_on_change=false)
402 $sql = "SELECT debtor_no, name, curr_code FROM ".TB_PREF."debtors_master ";
404 $mode = get_company_pref('no_customer_list');
406 return combo_input($name, $selected_id, $sql, 'debtor_no', 'name',
408 'format' => '_format_add_curr',
409 'search_box' => $mode!=0,
412 'spec_option' => $spec_option === true ? _("All Customers") : $spec_option,
413 'spec_id' => $all_items,
414 'select_submit'=> $submit_on_change,
415 'edit_submit' => true, // call editor on F4
417 'sel_hint' => $mode ? _('Press Space tab to filter by name fragment; F4 - entry new customer') :
422 function customer_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
425 echo "<td>$label</td>\n";
427 $str = customer_list($name, $selected_id, $all_option, $submit_on_change);
432 function customer_list_row($label, $name, $selected_id=null, $all_option = false, $submit_on_change=false)
434 echo "<tr><td>$label</td><td nowrap>";
435 $str = customer_list($name, $selected_id, $all_option, $submit_on_change);
436 echo "</td>\n</tr>\n";
440 //------------------------------------------------------------------------------------------------
442 function customer_branches_list($customer_id, $name, $selected_id=null,
443 $spec_option = true, $enabled=true, $submit_on_change=false)
447 $sql = "SELECT branch_code, br_name FROM ".TB_PREF."cust_branch
448 WHERE debtor_no='" . $customer_id . "' ";
450 $where = $enabled ? array("disable_trans = 0") : array();
451 return combo_input($name, $selected_id, $sql, 'branch_code', 'br_name',
454 'spec_option' => $spec_option === true ? _('All branches') : $spec_option,
455 'spec_id' => $all_items,
456 'select_submit'=> $submit_on_change,
457 'sel_hint' => _('Select customer branch')
460 //------------------------------------------------------------------------------------------------
462 function customer_branches_list_cells($label,$customer_id, $name, $selected_id=null, $all_option = true, $enabled=true, $submit_on_change=false)
465 echo "<td>$label</td>\n";
467 $ret = customer_branches_list($customer_id, $name, $selected_id, $all_option, $enabled, $submit_on_change);
472 function customer_branches_list_row($label,$customer_id, $name, $selected_id=null, $all_option = true, $enabled=true, $submit_on_change=false)
475 $ret = customer_branches_list_cells($label, $customer_id, $name, $selected_id, $all_option, $enabled, $submit_on_change);
480 //------------------------------------------------------------------------------------------------
482 function locations_list($name, $selected_id=null, $all_option=false, $submit_on_change=false)
486 $sql = "SELECT loc_code, location_name FROM ".TB_PREF."locations";
488 return combo_input($name, $selected_id, $sql, 'loc_code', 'location_name',
490 'spec_option' => $all_option === true ? _("All Locations") : $all_option,
491 'spec_id' => $all_items,
492 'select_submit'=> $submit_on_change
496 function locations_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
499 echo "<td>$label</td>\n";
501 $str = locations_list($name, $selected_id, $all_option, $submit_on_change);
506 function locations_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
509 $str = locations_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
514 //-----------------------------------------------------------------------------------------------
516 function currencies_list($name, $selected_id=null, $submit_on_change=false)
518 $sql = "SELECT curr_abrev, currency FROM ".TB_PREF."currencies";
520 // default to the company currency
522 return combo_input($name, $selected_id, $sql, 'curr_abrev', 'currency',
524 'select_submit'=> $submit_on_change,
525 'default' => get_company_currency(),
530 function currencies_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
533 echo "<td>$label</td>\n";
535 $str = currencies_list($name, $selected_id, $submit_on_change);
540 function currencies_list_row($label, $name, $selected_id=null, $submit_on_change=false)
543 $str = currencies_list_cells($label, $name, $selected_id, $submit_on_change);
548 //---------------------------------------------------------------------------------------------------
550 function fiscalyears_list($name, $selected_id=null, $submit_on_change=false)
553 $sql = "SELECT * FROM ".TB_PREF."fiscal_year";
555 // default to the company current fiscal year
557 return combo_input($name, $selected_id, $sql, 'id', '',
560 'default' => get_company_pref('f_year'),
561 'format' => '_format_fiscalyears',
562 'select_submit'=> $submit_on_change,
567 function _format_fiscalyears($row)
569 return sql2date($row[1]) . " - " . sql2date($row[2])
570 . " " . ($row[3] ? _('Closed') : _('Active')) . "</option>\n";
573 function fiscalyears_list_cells($label, $name, $selected_id=null)
576 echo "<td>$label</td>\n";
578 $str = fiscalyears_list($name, $selected_id);
583 function fiscalyears_list_row($label, $name, $selected_id=null)
586 $str = fiscalyears_list_cells($label, $name, $selected_id);
590 //------------------------------------------------------------------------------------
592 function dimensions_list($name, $selected_id=null, $no_option=false, $showname=' ',
593 $submit_on_change=false, $showclosed=false, $showtype=1)
595 $sql = "SELECT id, CONCAT(reference,' ',name) as ref FROM ".TB_PREF."dimensions";
598 'order' => 'reference',
599 'spec_option'=>$no_option ? $showname : false,
601 'select_submit'=> $submit_on_change,
606 $options['where'][] = "closed=0";
608 $options['where'][] = "type_=$showtype";
610 return combo_input($name, $selected_id, $sql, 'id', 'ref', $options);
613 function dimensions_list_cells($label, $name, $selected_id=null, $no_option=false, $showname=null,
614 $showclosed=false, $showtype=0, $submit_on_change=false)
617 echo "<td>$label</td>\n";
619 $str = dimensions_list($name, $selected_id, $no_option, $showname, $submit_on_change, $showclosed, $showtype);
624 function dimensions_list_row($label, $name, $selected_id=null, $no_option=false, $showname=null,
625 $showclosed=false, $showtype=0, $submit_on_change=false)
628 $str = dimensions_list_cells($label, $name, $selected_id, $no_option, $showname,
629 $showclosed, $showtype, $submit_on_change);
634 //---------------------------------------------------------------------------------------------------
636 function stock_items_list($name, $selected_id=null, $all_option=false, $submit_on_change=false, $opts=array())
640 $sql = "SELECT stock_id, s.description, c.description
641 FROM ".TB_PREF."stock_master s,".TB_PREF."stock_category c WHERE s.category_id=c.category_id";
643 return combo_input($name, $selected_id, $sql, 'stock_id', 's.description',
646 'format' => '_format_stock_items',
647 'spec_option' => $all_option===true ? _("All Items") : $all_option,
648 'spec_id' => $all_items,
649 'search_box' => true,
650 'search' => array("stock_id", "c.description","s.description"),
651 'search_submit' => get_company_pref('no_item_list')!=0,
653 'select_submit'=> $submit_on_change,
655 'order' => array('c.description','stock_id')
659 function _format_stock_items($row)
661 return (user_show_codes() ? ($row[0] . " - ") : "") . $row[1];
664 function stock_items_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
667 echo "<td>$label</td>\n";
668 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
669 array('cells'=>true));
673 function stock_items_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
676 $str = stock_items_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
681 //---------------------------------------------------------------------------------------------------
683 // Select item via foreign code.
685 function sales_items_list($name, $selected_id=null, $all_option=false,
686 $submit_on_change=false, $type='', $opts=array())
690 $sql = "SELECT i.item_code, i.description, c.description, count(*)>1 as kit
692 ".TB_PREF."item_codes i
694 ".TB_PREF."stock_category c
695 ON i.category_id=c.category_id";
697 if ($type == 'local') { // exclude foreign codes
698 $sql .= " WHERE !i.is_foreign";
699 } elseif ($type == 'kits') { // sales kits
700 $sql .= " WHERE !i.is_foreign AND i.item_code!=i.stock_id";
703 $sql .= " GROUP BY i.item_code";
705 return combo_input($name, $selected_id, $sql, 'i.item_code', 'c.description',
708 'format' => '_format_stock_items',
709 'spec_option' => $all_option===true ? _("All Items") : $all_option,
710 'spec_id' => $all_items,
711 'search_box' => true,
712 'search' => array("i.item_code", "c.description"),
713 'search_submit' => get_company_pref('no_item_list')!=0,
715 'select_submit'=> $submit_on_change,
717 'order' => array('c.description','i.item_code')
721 function sales_items_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
724 echo "<td>$label</td>\n";
725 $str = sales_items_list($name, $selected_id, $all_option, $submit_on_change,
726 '', array('cells'=>true));
730 function sales_kits_list($name, $selected_id=null, $all_option=false, $submit_on_change=false)
732 $str = sales_items_list($name, $selected_id, $all_option, $submit_on_change,
733 'kits', array('cells'=>false));
737 function sales_local_items_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
741 echo "<td>$label</td>\n";
743 $str = sales_items_list($name, $selected_id, $all_option, $submit_on_change,
744 'local', array('cells'=>false));
748 //------------------------------------------------------------------------------------
750 function base_stock_items_list($where, $name, $selected_id=null,
751 $all_option=false, $submit_on_change=false)
755 $sql = "SELECT stock_id, s.description, c.description
756 FROM ".TB_PREF."stock_master s,".TB_PREF."stock_category c WHERE
757 s.category_id=c.category_id";
759 return combo_input($name, $selected_id, $sql, 'stock_id', 's.description',
761 'format' => '_format_stock_items',
762 'spec_option' => $all_option==true ? _("All Items") : $all_option,
763 'spec_id' => $all_items,
764 'select_submit'=> $submit_on_change,
768 //------------------------------------------------------------------------------------
770 function stock_bom_items_list($name, $selected_id=null, $all_option=false, $submit_on_change=false)
773 return base_stock_items_list("(s.mb_flag='M' OR s.mb_flag='K')",
774 $name, $selected_id, $all_option, $submit_on_change);
777 function stock_bom_items_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
780 echo "<td>$label</td>\n";
782 $str = stock_bom_items_list($name, $selected_id, $all_option, $submit_on_change);
787 function stock_bom_items_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
790 $str = stock_bom_items_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
795 //------------------------------------------------------------------------------------
797 function stock_manufactured_items_list($name, $selected_id=null,
798 $all_option=false, $submit_on_change=false)
800 return base_stock_items_list("s.mb_flag='M'",
801 $name, $selected_id, $all_option, $submit_on_change);
804 function stock_manufactured_items_list_cells($label, $name, $selected_id=null,
805 $all_option=false, $submit_on_change=false)
808 echo "<td>$label</td>\n";
810 $str = stock_manufactured_items_list($name, $selected_id, $all_option,
816 function stock_manufactured_items_list_row($label, $name, $selected_id=null,
817 $all_option=false, $submit_on_change=false)
820 $str = stock_manufactured_items_list_cells($label, $name, $selected_id,
821 $all_option, $submit_on_change);
825 //------------------------------------------------------------------------------------
827 function stock_component_items_list($name, $parent_stock_id, $selected_id=null,
828 $all_option=false, $submit_on_change=false)
830 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
831 array('where'=>array("stock_id != '$parent_stock_id'")));
835 function stock_component_items_list_cells($label, $name, $parent_stock_id,
836 $selected_id=null, $all_option=false, $submit_on_change=false)
839 echo "<td>$label</td>\n";
840 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
841 array('where'=>array("stock_id != '$parent_stock_id'"), 'cells'=>true));
844 //------------------------------------------------------------------------------------
846 function stock_costable_items_list($name, $selected_id=null,
847 $all_option=false, $submit_on_change=false)
849 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
850 array('where'=>array("mb_flag!='D'")));
854 function stock_costable_items_list_cells($label, $name, $selected_id=null,
855 $all_option=false, $submit_on_change=false)
858 echo "<td>$label</td>\n";
859 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
860 array('where'=>array("mb_flag!='D'"), 'cells'=>true));
864 //------------------------------------------------------------------------------------
865 function stock_purchasable_items_list($name, $selected_id=null,
866 $all_option=false, $submit_on_change=false)
868 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
869 array('where'=>array("mb_flag!= 'M'"),
870 'edit_submit' => true));
874 function stock_purchasable_items_list_cells($label, $name, $selected_id=null,
875 $all_option=false, $submit_on_change=false)
878 echo "<td>$label</td>\n";
879 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
880 array('where'=>array("mb_flag!= 'M'"),
881 'edit_submit' => true,
886 function stock_purchasable_items_list_row($label, $name, $selected_id=null,
887 $all_option=false, $submit_on_change=false)
890 $ret = stock_purchasable_items_list_cells($label, $name, $selected_id=null,
891 $all_option, $submit_on_change);
896 //------------------------------------------------------------------------------------
898 function stock_item_types_list_row($label, $name, $selected_id=null, $enabled=true)
901 'M' => _("Manufactured"),
902 'B' => _("Purchased"),
908 echo "<td>$label</td>\n";
911 array_selector($name, $selected_id, $types,
913 'select_submit'=> true,
914 'disabled' => !$enabled) );
918 function stock_units_list_row($label, $name, $value=null, $enabled=true)
920 $result = get_all_item_units();
923 echo "<td>$label</td>\n";
926 while($unit = db_fetch($result))
927 $units[$unit['abbr']] = $unit['name'];
929 array_selector($name, $value, $units,
931 'select_submit'=> true,
932 'disabled' => !$enabled) );
937 //------------------------------------------------------------------------------------
939 function tax_types_list($name, $selected_id=null, $none_option=false, $submit_on_change=false)
941 $sql = "SELECT id, CONCAT(name, ' (',rate,'%)') as name FROM ".TB_PREF."tax_types";
943 return combo_input($name, $selected_id, $sql, 'id', 'name',
945 'spec_option' => $none_option,
946 'spec_id' => reserved_words::get_all_numeric(),
947 'select_submit'=> $submit_on_change,
952 function tax_types_list_cells($label, $name, $selected_id=null, $none_option=false,
953 $submit_on_change=false)
956 echo "<td>$label</td>\n";
958 $str = tax_types_list($name, $selected_id, $none_option, $submit_on_change);
963 function tax_types_list_row($label, $name, $selected_id=null, $none_option=false,
964 $submit_on_change=false)
967 $str = tax_types_list_cells($label, $name, $selected_id, $none_option, $submit_on_change);
972 //------------------------------------------------------------------------------------
974 function tax_groups_list($name, $selected_id=null,
975 $none_option=false, $submit_on_change=false)
977 $sql = "SELECT id, name FROM ".TB_PREF."tax_groups";
979 return combo_input($name, $selected_id, $sql, 'id', 'name',
982 'spec_option' => $none_option,
983 'spec_id' => reserved_words::get_all_numeric(),
984 'select_submit'=> $submit_on_change,
989 function tax_groups_list_cells($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false)
992 echo "<td>$label</td>\n";
994 $str = tax_groups_list($name, $selected_id, $none_option, $submit_on_change);
999 function tax_groups_list_row($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false)
1002 $str = tax_groups_list_cells($label, $name, $selected_id, $none_option, $submit_on_change);
1007 //------------------------------------------------------------------------------------
1009 function item_tax_types_list($name, $selected_id=null)
1011 $sql ="SELECT id, name FROM ".TB_PREF."item_tax_types";
1012 combo_input($name, $selected_id, $sql, 'id', 'name', array('order' => 'id') );
1015 function item_tax_types_list_cells($label, $name, $selected_id=null)
1018 echo "<td>$label</td>\n";
1020 item_tax_types_list($name, $selected_id);
1024 function item_tax_types_list_row($label, $name, $selected_id=null)
1027 item_tax_types_list_cells($label, $name, $selected_id);
1031 //------------------------------------------------------------------------------------
1033 function shippers_list($name, $selected_id=null)
1035 $sql = "SELECT shipper_id, shipper_name FROM ".TB_PREF."shippers";
1036 combo_input($name, $selected_id, $sql, 'shipper_id', 'shipper_name', array());
1039 function shippers_list_cells($label, $name, $selected_id=null)
1042 echo "<td>$label</td>\n";
1044 shippers_list($name, $selected_id);
1048 function shippers_list_row($label, $name, $selected_id=null)
1051 shippers_list_cells($label, $name, $selected_id);
1055 //-------------------------------------------------------------------------------------
1057 function sales_persons_list($name, $selected_id=null)
1059 $sql = "SELECT salesman_code, salesman_name FROM ".TB_PREF."salesman";
1060 combo_input($name, $selected_id, $sql, 'salesman_code', 'salesman_name', array());
1063 function sales_persons_list_cells($label, $name, $selected_id=null)
1066 echo "<td>$label</td>\n";
1068 sales_persons_list($name, $selected_id);
1072 function sales_persons_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1075 sales_persons_list_cells($label, $name, $selected_id, $submit_on_change=false);
1079 //------------------------------------------------------------------------------------
1081 function sales_areas_list($name, $selected_id=null)
1083 $sql = "SELECT area_code, description FROM ".TB_PREF."areas";
1084 combo_input($name, $selected_id, $sql, 'area_code', 'description', array());
1087 function sales_areas_list_cells($label, $name, $selected_id=null)
1090 echo "<td>$label</td>\n";
1092 sales_areas_list($name, $selected_id);
1096 function sales_areas_list_row($label, $name, $selected_id=null)
1099 sales_areas_list_cells($label, $name, $selected_id);
1103 //------------------------------------------------------------------------------------
1105 function sales_groups_list($name, $selected_id=null, $special_option=false)
1107 $sql = "SELECT id, description FROM ".TB_PREF."groups";
1108 combo_input($name, $selected_id, $sql, 'id', 'description', array(
1109 'spec_option' => $special_option===true ? ' ' : $special_option,
1110 'order' => 'description', 'spec_id' => 0,
1114 function sales_groups_list_cells($label, $name, $selected_id=null, $special_option=false)
1117 echo "<td>$label</td>\n";
1119 sales_groups_list($name, $selected_id, $special_option);
1123 function sales_groups_list_row($label, $name, $selected_id=null, $special_option=false)
1126 sales_groups_list_cells($label, $name, $selected_id, $special_option);
1130 //------------------------------------------------------------------------------------
1132 function _format_template_items($row)
1134 return ($row[0] . " - " . _("Amount") . " ".$row[1]);
1137 function templates_list($name, $selected_id=null, $special_option=false)
1139 $sql = "SELECT sorder.order_no, Sum(line.unit_price*line.quantity*(1-line.discount_percent)) AS OrderValue
1140 FROM ".TB_PREF."sales_orders as sorder, ".TB_PREF."sales_order_details as line
1141 WHERE sorder.order_no = line.order_no AND sorder.type = 1 GROUP BY line.order_no";
1142 combo_input($name, $selected_id, $sql, 'order_no', 'OrderValue', array(
1143 'format' => '_format_template_items',
1144 'spec_option' => $special_option===true ? ' ' : $special_option,
1145 'order' => 'order_no', 'spec_id' => 0,
1149 function templates_list_cells($label, $name, $selected_id=null, $special_option=false)
1152 echo "<td>$label</td>\n";
1154 templates_list($name, $selected_id, $special_option);
1158 function templates_list_row($label, $name, $selected_id=null, $special_option=false)
1161 templates_list_cells($label, $name, $selected_id, $special_option);
1165 //------------------------------------------------------------------------------------
1167 function workorders_list($name, $selected_id=null)
1169 $sql = "SELECT id, wo_ref FROM ".TB_PREF."workorders WHERE closed=0";
1170 combo_input($name, $selected_id, $sql, 'id', 'wo_ref', array());
1173 function workorders_list_cells($label, $name, $selected_id=null)
1176 echo "<td>$label</td>\n";
1178 workorders_list($name, $selected_id);
1182 function workorders_list_row($label, $name, $selected_id=null)
1185 workorders_list_cells($label, $name, $selected_id);
1189 //------------------------------------------------------------------------------------
1191 function payment_terms_list($name, $selected_id=null)
1193 $sql = "SELECT terms_indicator, terms FROM ".TB_PREF."payment_terms";
1194 combo_input($name, $selected_id, $sql, 'terms_indicator', 'terms', array());
1197 function payment_terms_list_cells($label, $name, $selected_id=null)
1200 echo "<td>$label</td>\n";
1202 payment_terms_list($name, $selected_id);
1206 function payment_terms_list_row($label, $name, $selected_id=null)
1209 payment_terms_list_cells($label, $name, $selected_id);
1213 //------------------------------------------------------------------------------------
1215 function credit_status_list($name, $selected_id=null)
1217 $sql ="SELECT id, reason_description FROM ".TB_PREF."credit_status";
1218 combo_input($name, $selected_id, $sql, 'id', 'reason_description', array());
1221 function credit_status_list_cells($label, $name, $selected_id=null)
1224 echo "<td>$label</td>\n";
1226 credit_status_list($name, $selected_id);
1230 function credit_status_list_row($label, $name, $selected_id=null)
1233 credit_status_list_cells($label, $name, $selected_id);
1237 //-----------------------------------------------------------------------------------------------
1239 function sales_types_list($name, $selected_id=null, $submit_on_change=false, $special_option=false)
1241 $sql = "SELECT id, sales_type FROM ".TB_PREF."sales_types";
1243 return combo_input($name, $selected_id, $sql, 'id', 'sales_type',
1245 'spec_option' => $special_option===true ? _("All Sales Types") : $special_option,
1247 'select_submit'=> $submit_on_change,
1248 // 'async' => false,
1252 function sales_types_list_cells($label, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1255 echo "<td>$label</td>\n";
1257 $str = sales_types_list($name, $selected_id, $submit_on_change, $special_option);
1262 function sales_types_list_row($label, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1265 $str = sales_types_list_cells($label, $name, $selected_id, $submit_on_change, $special_option);
1270 //-----------------------------------------------------------------------------------------------
1272 function movement_types_list($name, $selected_id=null)
1274 $sql = "SELECT id, name FROM ".TB_PREF."movement_types";
1275 combo_input($name, $selected_id, $sql, 'id', 'name', array());
1278 function movement_types_list_cells($label, $name, $selected_id=null)
1281 echo "<td>$label</td>\n";
1283 movement_types_list($name, $selected_id);
1287 function movement_types_list_row($label, $name, $selected_id=null)
1290 movement_types_list_cells($label, $name, $selected_id);
1294 //-----------------------------------------------------------------------------------------------
1295 function _format_date($row)
1297 return sql2date($row['reconciled']);
1300 function bank_reconciliation_list($account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1302 $sql = "SELECT reconciled, reconciled FROM ".TB_PREF."bank_trans
1303 WHERE bank_act=".db_escape($account)." AND reconciled IS NOT NULL
1304 GROUP BY reconciled";
1305 combo_input($name, $selected_id, $sql, 'id', 'reconciled',
1307 'spec_option' => $special_option,
1308 'format' => '_format_date',
1310 'select_submit'=> $submit_on_change
1314 function bank_reconciliation_list_cells($label,$account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1317 echo "<td>$label</td>\n";
1319 bank_reconciliation_list($account, $name, $selected_id, $submit_on_change, $special_option);
1323 function bank_reconciliation_list_row($label, $account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1326 bank_reconciliation_list_cells($label, $account, $name, $selected_id, $submit_on_change, $special_option);
1330 //-----------------------------------------------------------------------------------------------
1332 function workcenter_list($name, $selected_id=null, $all_option=false)
1336 $sql = "SELECT id, name FROM ".TB_PREF."workcentres";
1338 return combo_input($name, $selected_id, $sql, 'id', 'name',
1340 'spec_option' =>$all_option===true ? _("All Suppliers") : $all_option,
1341 'spec_id' => $all_items,
1345 function workcenter_list_cells($label, $name, $selected_id=null, $all_option=false)
1347 default_focus($name);
1349 echo "<td>$label</td>\n";
1351 workcenter_list($name, $selected_id, $all_option);
1355 function workcenter_list_row($label, $name, $selected_id=null, $all_option=false)
1358 workcenter_list_cells($label, $name, $selected_id, $all_option);
1362 //-----------------------------------------------------------------------------------------------
1364 function bank_accounts_list($name, $selected_id=null, $submit_on_change=false)
1366 $sql = "SELECT ".TB_PREF."bank_accounts.id, bank_account_name, bank_curr_code
1367 FROM ".TB_PREF."bank_accounts";
1368 // , ".TB_PREF."chart_master
1369 // WHERE ".TB_PREF."bank_accounts.account_code=".TB_PREF."chart_master.account_code";
1371 return combo_input($name, $selected_id, $sql, 'id', 'bank_account_name',
1373 'format' => '_format_add_curr',
1374 'select_submit'=> $submit_on_change,
1379 function bank_accounts_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1382 echo "<td>$label</td>\n";
1384 $str = bank_accounts_list($name, $selected_id, $submit_on_change);
1389 function bank_accounts_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1392 $str = bank_accounts_list_cells($label, $name, $selected_id, $submit_on_change);
1396 //-----------------------------------------------------------------------------------------------
1398 function cash_accounts_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1400 $sql = "SELECT ".TB_PREF."bank_accounts.id, bank_account_name, bank_curr_code
1401 FROM ".TB_PREF."bank_accounts
1402 WHERE ".TB_PREF."bank_accounts.account_type=3";
1405 echo "<tr><td>$label</td>\n";
1407 $str = combo_input($name, $selected_id, $sql, 'id', 'bank_account_name',
1409 'format' => '_format_add_curr',
1410 'select_submit'=> $submit_on_change,
1413 echo "</td></tr>\n";
1416 //-----------------------------------------------------------------------------------------------
1418 function pos_list_row($label, $name, $selected_id=null, $spec_option=false, $submit_on_change=false)
1420 $sql = "SELECT id, pos_name FROM ".TB_PREF."sales_pos";
1422 default_focus($name);
1425 echo "<td>$label</td>\n";
1428 $str = combo_input($name, $selected_id, $sql, 'id', 'pos_name',
1430 'select_submit'=> $submit_on_change,
1432 'spec_option' =>$spec_option,
1435 echo "</td></tr>\n";
1439 //-----------------------------------------------------------------------------------------------
1441 function sale_payment_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1444 echo "<td>$label</td>\n";
1446 $str = yesno_list($name, $selected_id, _('Cash'), _('Delayed'), $submit_on_change);
1450 //-----------------------------------------------------------------------------------------------
1452 function class_list($name, $selected_id=null, $submit_on_change=false)
1454 $sql = "SELECT cid, class_name FROM ".TB_PREF."chart_class";
1456 return combo_input($name, $selected_id, $sql, 'cid', 'class_name',
1458 'select_submit'=> $submit_on_change,
1464 function class_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1467 echo "<td>$label</td>\n";
1469 $str = class_list($name, $selected_id, $submit_on_change);
1474 function class_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1477 $str = class_list_cells($label, $name, $selected_id, $submit_on_change);
1482 //-----------------------------------------------------------------------------------------------
1484 function stock_categories_list($name, $selected_id=null)
1486 $sql = "SELECT category_id, description FROM ".TB_PREF."stock_category";
1487 combo_input($name, $selected_id, $sql, 'category_id', 'description',
1488 array('order'=>'category_id'));
1491 function stock_categories_list_cells($label, $name, $selected_id=null)
1494 echo "<td>$label</td>\n";
1496 stock_categories_list($name, $selected_id);
1500 function stock_categories_list_row($label, $name, $selected_id=null)
1503 stock_categories_list_cells($label, $name, $selected_id);
1507 //-----------------------------------------------------------------------------------------------
1509 function gl_account_types_list($name, $selected_id=null, $all_option, $all_option_numeric)
1513 $sql = "SELECT id, name FROM ".TB_PREF."chart_types";
1515 combo_input($name, $selected_id, $sql, 'id', 'name',
1518 'spec_option' =>$all_option,
1519 'spec_id' => $all_option_numeric ? 0 : $all_items
1523 function gl_account_types_list_cells($label, $name, $selected_id=null, $all_option=false,
1524 $all_option_numeric=false)
1527 echo "<td>$label</td>\n";
1529 gl_account_types_list($name, $selected_id, $all_option, $all_option_numeric);
1533 function gl_account_types_list_row($label, $name, $selected_id=null, $all_option=false,
1534 $all_option_numeric=false)
1537 gl_account_types_list_cells($label, $name, $selected_id, $all_option,
1538 $all_option_numeric);
1542 //-----------------------------------------------------------------------------------------------
1543 function gl_all_accounts_list($name, $selected_id=null, $skip_bank_accounts=false,
1544 $cells=false, $all_option=false, $submit_on_change=false)
1546 if ($skip_bank_accounts)
1547 $sql = "SELECT chart.account_code, chart.account_name, type.name
1548 FROM (".TB_PREF."chart_master chart,".TB_PREF."chart_types type) "
1549 ."LEFT JOIN ".TB_PREF."bank_accounts acc "
1550 ."ON chart.account_code=acc.account_code
1551 WHERE acc.account_code IS NULL
1552 AND chart.account_type=type.id";
1554 $sql = "SELECT chart.account_code, chart.account_name, type.name
1555 FROM ".TB_PREF."chart_master chart,".TB_PREF."chart_types type
1556 WHERE chart.account_type=type.id";
1558 combo_input($name, $selected_id, $sql, 'chart.account_code', 'chart.account_name',
1560 'format' => '_format_account',
1561 'spec_option' => $all_option===true ? _("Use Item Sales Accounts") : $all_option,
1563 'order' => array('name','account_code'),
1564 'search_box' => $cells,
1565 'search_submit' => false,
1569 'select_submit'=> $submit_on_change,
1576 function _format_account($row)
1578 return $row[0] . " " . $row[1];
1581 function gl_all_accounts_list_cells($label, $name, $selected_id=null,
1582 $skip_bank_accounts=false, $cells=false, $all_option=false)
1585 echo "<td>$label</td>\n";
1587 gl_all_accounts_list($name, $selected_id,
1588 $skip_bank_accounts, $cells, $all_option);
1592 function gl_all_accounts_list_row($label, $name, $selected_id=null,
1593 $skip_bank_accounts=false, $cells=false, $all_option=false)
1596 gl_all_accounts_list_cells($label, $name, $selected_id,
1597 $skip_bank_accounts, $cells, $all_option);
1601 function yesno_list($name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1604 $items['1'] = strlen($name_yes) ? $name_yes : _("Yes");
1605 $items['0'] = strlen($name_no) ? $name_no : _("No");
1607 return array_selector($name, $selected_id, $items,
1609 'select_submit'=> $submit_on_change,
1610 'async' => false ) ); // FIX?
1613 function yesno_list_cells($label, $name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1616 echo "<td>$label</td>\n";
1618 $str = yesno_list($name, $selected_id, $name_yes, $name_no, $submit_on_change);
1623 function yesno_list_row($label, $name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1626 $str = yesno_list_cells($label, $name, $selected_id, $name_yes, $name_no, $submit_on_change);
1631 //------------------------------------------------------------------------------------------------
1633 function languages_list($name, $selected_id=null)
1635 global $installed_languages;
1638 foreach ($installed_languages as $lang)
1639 $items[$lang['code']] = $lang['name'];
1641 return array_selector($name, $selected_id, $items );
1644 function languages_list_cells($label, $name, $selected_id=null)
1647 echo "<td>$label</td>\n";
1649 languages_list($name, $selected_id);
1653 function languages_list_row($label, $name, $selected_id=null)
1656 languages_list_cells($label, $name, $selected_id);
1660 //------------------------------------------------------------------------------------------------
1662 function bank_account_types_list($name, $selected_id=null)
1664 $types = bank_account_types::get_all();
1667 foreach ($types as $type)
1669 $items[$type['id']] = $type['name'];
1672 return array_selector($name, $selected_id, $items );
1675 function bank_account_types_list_cells($label, $name, $selected_id=null)
1678 echo "<td>$label</td>\n";
1680 bank_account_types_list($name, $selected_id);
1684 function bank_account_types_list_row($label, $name, $selected_id=null)
1687 bank_account_types_list_cells($label, $name, $selected_id);
1691 //------------------------------------------------------------------------------------------------
1692 function payment_person_types_list($name, $selected_id=null, $submit_on_change=false)
1694 $types = payment_person_types::get_all();
1697 foreach ($types as $type)
1699 if (payment_person_types::has_items($type['id']))
1701 $items[$type['id']] = $type['name'];
1705 return array_selector($name, $selected_id, $items,
1706 array( 'select_submit'=> $submit_on_change ) );
1709 function payment_person_types_list_cells($label, $name, $selected_id=null, $related=null)
1712 echo "<td>$label</td>\n";
1714 $str = payment_person_types_list($name, $selected_id, $related);
1719 function payment_person_types_list_row($label, $name, $selected_id=null, $related=null)
1722 $str = payment_person_types_list_cells($label, $name, $selected_id, $related);
1727 //------------------------------------------------------------------------------------------------
1729 function wo_types_list($name, $selected_id=null)
1731 $types = wo_types::get_all();
1734 foreach ($types as $type)
1735 $items[$type['id']] = $type['name'];
1737 return array_selector($name, $selected_id, $items,
1738 array( 'select_submit'=> true, 'async' => true ) );
1741 function wo_types_list_row($label, $name, $selected_id=null)
1743 echo "<tr><td>$label</td><td>\n";
1744 $str = wo_types_list($name, $selected_id);
1745 echo "</td></tr>\n";
1749 //------------------------------------------------------------------------------------------------
1751 function dateformats_list_row($label, $name, $value=null)
1753 global $dateformats;
1755 echo "<tr><td>$label</td>\n<td>";
1756 array_selector( $name, $value, $dateformats );
1757 echo "</td></tr>\n";
1760 function dateseps_list_row($label, $name, $value=null)
1764 echo "<tr><td>$label</td>\n<td>";
1765 array_selector( $name, $value, $dateseps );
1766 echo "</td></tr>\n";
1769 function thoseps_list_row($label, $name, $value=null)
1773 echo "<tr><td>$label</td>\n<td>";
1774 array_selector( $name, $value, $thoseps );
1775 echo "</td></tr>\n";
1778 function decseps_list_row($label, $name, $value=null)
1782 echo "<tr><td>$label</td>\n<td>";
1783 array_selector( $name, $value, $decseps );
1784 echo "</td></tr>\n";
1787 function themes_list_row($label, $name, $value=null)
1789 global $path_to_root;
1791 $path = $path_to_root.'/themes/';
1793 $themedir = opendir($path);
1794 while(false !== ($fname = readdir($themedir)))
1796 if($fname!='.' && $fname!='..' && $fname!='CVS' && is_dir($path.$fname))
1798 $themes[$fname] = $fname;
1803 echo "<tr><td>$label</td>\n<td>";
1804 array_selector( $name, $value, $themes );
1805 echo "</td></tr>\n";
1808 function pagesizes_list_row($label, $name, $value=null)
1813 foreach ($pagesizes as $pz)
1816 echo "<tr><td>$label</td>\n<td>";
1817 array_selector( $name, $value, $items );
1818 echo "</td></tr>\n";
1821 function security_headings_list_row($label, $name, $value=null)
1823 global $security_headings;
1825 echo "<tr><td>$label</td>\n<td>";
1826 array_selector( $name, $value, $security_headings );
1827 echo "</td></tr>\n";
1830 function systypes_list_cells($label, $name, $value=null, $submit_on_change=false)
1832 global $systypes_array;
1835 echo "<td>$label</td>\n";
1839 foreach ($systypes_array as $key=>$type)
1840 $items[$key] = $type['name'];
1842 $str = array_selector($name, $value, $items,
1844 'select_submit'=> $submit_on_change,
1852 function systypes_list_row($label, $name, $value=null, $submit_on_change=false)
1855 $str = systypes_list_cells($label, $name, $value, $submit_on_change);
1860 function cust_allocations_list_cells($label, $name, $selected=null)
1868 $all_items=>_("All Types"),
1869 '1'=> _("Sales Invoices"),
1870 '2'=> _("Overdue Invoices"),
1871 '3' => _("Payments"),
1872 '4' => _("Credit Notes"),
1873 '5' => _("Delivery Notes")
1875 $str = array_selector($name, $selected, $allocs);
1880 function supp_allocations_list_cell($name, $selected=null)
1886 $all_items=>_("All Types"),
1887 '1'=> _("Invoices"),
1888 '2'=> _("Overdue Invoices"),
1889 '3' => _("Payments"),
1890 '4' => _("Credit Notes"),
1891 '5' => _("Overdue Credit Notes")
1893 $str = array_selector($name, $selected, $allocs);
1898 function policy_list_cells($label, $name, $selected=null)
1903 $str = array_selector($name, $selected,
1904 array( '' => _("Automatically put balance on back order"),
1905 'CAN' => _("Cancel any quantites not delivered")) );
1910 function policy_list_row($label, $name, $selected=null)
1913 policy_list_cells($label, $name, $selected);
1917 function credit_type_list_cells($label, $name, $selected=null, $submit_on_change=false)
1922 $str = array_selector($name, $selected,
1923 array( 'Return' => _("Items Returned to Inventory Location"),
1924 'WriteOff' => _("Items Written Off")),
1925 array( 'select_submit'=> $submit_on_change ) );
1930 function credit_type_list_row($label, $name, $selected=null, $submit_on_change=false)
1933 $str = credit_type_list_cells($label, $name, $selected, $submit_on_change);
1938 function number_list($name, $selected, $from, $to, $no_option=false)
1941 for ($i = $from; $i <= $to; $i++)
1944 return array_selector($name, $selected, $items,
1945 array( 'spec_option' => $no_option,
1946 'spec_id' => reserved_words::get_all_numeric()) );
1949 function number_list_cells($label, $name, $selected, $from, $to, $no_option=false)
1954 number_list($name, $selected, $from, $to, $no_option);
1958 function number_list_row($label, $name, $selected, $from, $to, $no_option=false)
1961 number_list_cells($label, $name, $selected, $from, $to, $no_option);
1965 function print_profiles_list_row($label, $name, $selected_id=null, $spec_opt=false,
1966 $submit_on_change=true)
1968 $sql = "SELECT profile FROM ".TB_PREF."print_profiles"
1969 ." GROUP BY profile";
1970 $result = db_query($sql, 'cannot get all profile names');
1971 $profiles = array();
1972 while($myrow=db_fetch($result)) {
1973 $profiles[$myrow['profile']] = $myrow['profile'];
1978 echo "<td>$label</td>\n";
1981 array_selector($name, $selected_id, $profiles,
1982 array( 'select_submit'=> $submit_on_change,
1983 'spec_option'=>$spec_opt,
1987 echo "</td></tr>\n";
1990 function printers_list($name, $selected_id=null, $spec_opt=false, $submit_on_change=false)
1992 static $printers; // query only once for page display
1995 $sql = "SELECT id, name, description FROM ".TB_PREF."printers";
1996 $result = db_query($sql, 'cannot get all printers');
1997 $printers = array();
1998 while($myrow=db_fetch($result)) {
1999 $printers[$myrow['id']] = $myrow['name'].' - '.$myrow['description'];
2002 array_selector($name, $selected_id, $printers,
2003 array( 'select_submit'=> $submit_on_change,
2004 'spec_option'=>$spec_opt,
2009 //------------------------------------------------------------------------------------------------
2011 function quick_entries_list($name, $selected_id=null, $type=null, $submit_on_change=false)
2014 $sql = "SELECT id, description FROM ".TB_PREF."quick_entries";
2016 $sql .= " WHERE type=$type";
2018 combo_input($name, $selected_id, $sql, 'id', 'description',
2021 'order' => 'description',
2022 'select_submit'=> $submit_on_change,
2028 function quick_entries_list_cells($label, $name, $selected_id=null, $type, $submit_on_change=false)
2030 echo "<td>$label</td><td>\n";
2031 quick_entries_list($name, $selected_id, $type, $submit_on_change);
2035 function quick_entries_list_row($label, $name, $selected_id=null, $type, $submit_on_change=false)
2038 quick_entries_list_cells($label, $name, $selected_id, $type, $submit_on_change);
2043 function quick_actions_list_row($label, $name, $selected_id=null, $submit_on_change=false)
2045 global $quick_actions;
2047 echo "<tr><td>$label</td><td>";
2048 array_selector($name, $selected_id, $quick_actions,
2050 'select_submit'=> $submit_on_change
2052 echo "</td></tr>\n";
2055 function quick_entry_types_list_row($label, $name, $selected_id=null, $submit_on_change=false)
2057 global $quick_entry_types;
2059 echo "<tr><td>$label</td><td>";
2060 array_selector($name, $selected_id, $quick_entry_types,
2062 'select_submit'=> $submit_on_change
2064 echo "</td></tr>\n";