2 /**********************************************************************
3 Copyright (C) FrontAccounting, LLC.
4 Released under the terms of the GNU General Public License, GPL,
5 as published by the Free Software Foundation, either version 3
6 of the License, or (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
12 include_once($path_to_root . "/includes/banking.inc");
13 include_once($path_to_root . "/includes/reserved.inc");
14 include_once($path_to_root . "/includes/types.inc");
15 include_once($path_to_root . "/includes/current_user.inc");
17 $_search_button = "<input %s type='submit' class='combo_submit' style='border:0;background:url($path_to_root/themes/"
18 ."%s/images/locate.png) no-repeat;%s' aspect='fallback' name='%s' value=' ' title='"._("Set filter")."'> ";
20 $_select_button = "<input %s type='submit' class='combo_select' style='border:0;background:url($path_to_root/themes/"
21 ."%s/images/button_ok.png) no-repeat;%s' aspect='fallback' name='%s' value=' ' title='"._("Select")."'> ";
23 $all_items = reserved_words::get_all();
25 //----------------------------------------------------------------------------
26 // Universal sql combo generator
27 // $sql must return selector values and selector texts in columns 0 & 1
28 // Options are merged with defaults.
30 function combo_input($name, $selected_id, $sql, $valfield, $namefield,
35 $opts = array( // default options
36 'where'=> array(), // additional constraints
37 'order' => $namefield, // list sort order
38 // special option parameters
39 'spec_option'=>false, // option text or false
40 'spec_id' => 0, // option id
41 // submit on select parameters
42 'default' => '', // default value when $_POST is not set
43 'select_submit' => false, //submit on select: true/false
44 'edit_submit' => false, // call editor on F4
45 'async' => true, // select update via ajax (true) vs _page_body reload
46 // search box parameters
48 'search_box' => false, // name or true/false
49 'type' => 0, // type of extended selector:
50 // 0 - with (optional) visible search box, search by id
51 // 1 - with hidden search box, search by option text
52 // 2 - TODO reverse: box with hidden selector available via enter; this
53 // would be convenient for optional ad hoc adding of new item
54 'search_submit' => true, //search submit button: true/false
55 'size' => 8, // size and max of box tag
57 'cells' => false, // combo displayed as 2 <td></td> cells
58 'search' => array(), // sql field names to search
59 'format' => null, // format functions for regular options
61 'box_hint' => null, // box/selectors hints; null = std see below
62 'category' => false // category column name or false
64 // ------ merge options with defaults ----------
66 $opts = array_merge($opts, $options);
67 if (!is_array($opts['where'])) $opts['where'] = array($opts['where']);
69 $search_box = $opts['search_box']===true ? '_'.$name.'_edit' : $opts['search_box'];
70 $search_submit = $opts['search_submit']===true ? '_'.$name.'_button' : $opts['search_submit'];
71 $select_submit = $opts['select_submit']===true ? '_'.$name.'_update' : $opts['select_submit'];
72 $spec_id = $opts['spec_id'];
73 $spec_option = $opts['spec_option'];
74 $by_id = ($opts['type'] == 0);
75 $class = $by_id ? 'combo':'combo2';
76 $disabled = $opts['disabled'] ? "disabled" : '';
78 if(!count($opts['search'])) {
79 $opts['search'] = array($by_id ? $valfield : $namefield);
81 if ($opts['sel_hint'] === null)
82 $opts['sel_hint'] = $by_id || $search_box==false ?
83 '' : _('Press Space tab for search pattern entry');
85 if ($opts['box_hint'] === null)
86 $opts['box_hint'] = $search_box && $search_submit != false ?
87 ($by_id ? _('Enter code fragment to search or * for all')
88 : _('Enter description fragment to search or * for all')) :'';
90 if ($selected_id == null) {
91 $selected_id = get_post($name, $opts['default']);
93 $txt = get_post($search_box);
97 if (isset($_POST[$select_submit])) {
98 if ($by_id) $txt = $_POST[$name];
101 $Ajax->activate('_page_body');
103 $Ajax->activate($name);
106 // search related sql modifications
108 $rel = "rel='$search_box'"; // set relation to list
109 if ($opts['search_submit']) {
110 if (isset($_POST[$search_submit])) {
111 $selected_id = ''; // ignore selected_id while search
113 $Ajax->activate('_page_body');
115 $Ajax->activate($name);
118 if ($spec_option === false && $selected_id==null)
121 $opts['where'][] = $valfield . "='". get_post($name, $spec_id)."'";
126 foreach($opts['search'] as $i=> $s)
127 $opts['search'][$i] = $s . " LIKE '%{$txt}%'";
128 $opts['where'][] = '('. implode($opts['search'], ' OR ') . ')';
133 if (count($opts['where'])) {
134 $where = strpos($sql, 'WHERE')==false ? ' WHERE ':' AND ';
135 $where .= '('. implode($opts['where'], ' AND ') . ')';
136 $group_pos = strpos($sql, 'GROUP BY');
138 $group = substr($sql, $group_pos);
139 $sql = substr($sql, 0, $group_pos) . $where.' '.$group;
144 if ($opts['order'] != false) {
145 if (!is_array($opts['order']))
146 $opts['order'] = array($opts['order']);
147 $sql .= ' ORDER BY '.implode(',',$opts['order']);
151 // ------ make selector ----------
152 $selector = $first_opt = '';
156 //if($name=='stock_id') display_error($sql);
157 if($result = db_query($sql)) {
158 while ($contact_row = db_fetch($result)) {
159 $value = $contact_row[0];
160 $descr = $opts['format']==null ? $contact_row[1] :
161 call_user_func($opts['format'], $contact_row);
163 if (get_post($search_submit) && ($txt === $value)) {
164 $selected_id = $value;
166 if ((string)($selected_id) === $value) {
170 if ($first_id === false) {
174 $cat = $contact_row[$opts['category']];
175 if ($opts['category'] !== false && $cat != $lastcat){
176 $selector .= "<optgroup label='".$cat."'>\n";
179 $selector .= "<option $sel value='$value'>$descr</option>\n";
181 db_free_result($result);
184 // Prepend special option.
185 if ($spec_option !== false) { // if special option used - add it
186 $first_id = $spec_id;
187 $first_opt = $spec_option;
188 $sel = $found===false ? 'selected' : '';
189 $selector = "<option $sel value='$spec_id'>$spec_option</option>\n"
193 if ($found === false) {
194 $selected_id = $first_id;
196 $_POST[$name] = $selected_id;
198 if ($by_id && $search_box != false) {
200 $Ajax->addUpdate($name, $search_box, $txt ? $txt : '');
202 $aspect = $opts['edit_submit'] ? " aspect='editable'" : '';
203 $selector = "<select $disabled name='$name' class='$class' title='"
204 . $opts['sel_hint']."'$aspect $rel>".$selector."</select>\n";
206 $Ajax->addUpdate($name, "_{$name}_sel", $selector);
208 // because of bug which M$ cannot fix since IE 5.0
209 // we must embed whole selector in span tags to enable proper ajax update
210 $selector = "<span id='_{$name}_sel'>".$selector."</span>\n";
212 if ($select_submit != false) { // if submit on change is used - add select button
213 global $_select_button;
214 // button class selects form reload/ajax selector update
215 $selector .= sprintf($_select_button, $disabled, user_theme(),
216 (fallback_mode() ? '' : 'display:none;'),
217 $select_submit)."\n";
219 // ------ make combo ----------
222 if ($search_box != false) {
223 $edit_entry = "<input $disabled type='text' name='$search_box' id='$search_box' size='".
224 $opts['size']."' maxlength='".$opts['max'].
225 "' value='$txt' class='$class' rel='$name' autocomplete='off' title='"
226 .$opts['box_hint']."'"
227 .(!fallback_mode() && !$by_id ? " style=display:none;":'')
229 if ($search_submit != false) {
230 global $_search_button;
231 $edit_entry .= sprintf($_search_button, $disabled, user_theme(),
232 (fallback_mode() ? '' : 'display:none;'),
233 $search_submit)."\n";
236 default_focus(($search_box && $by_id) ? $search_box : $name);
238 if ($search_box && $opts['cells'])
239 echo ($edit_entry!='' ? "<td>$edit_entry</td>" : '')."<td>$selector</td>";
241 echo $edit_entry.$selector;
248 Returns true if selector $name is subject to update.
250 function list_updated($name)
252 return isset($_POST['_'.$name.'_update']) || isset($_POST['_'.$name.'_button']);
254 //----------------------------------------------------------------------------------------------
255 // Universal array combo generator
256 // $items is array of options 'value' => 'description'
257 // Options is reduced set of combo_selector options and is merged with defaults.
259 function array_selector($name, $selected_id, $items, $options=null)
263 $opts = array( // default options
264 'spec_option'=>false, // option text or false
265 'spec_id' => 0, // option id
266 'select_submit' => false, //submit on select: true/false
267 'edit_submit' => false, // call editor on F4
268 'async' => true, // select update via ajax (true) vs _page_body reload
269 'default' => '', // default value when $_POST is not set
270 // search box parameters
274 // ------ merge options with defaults ----------
276 $opts = array_merge($opts, $options);
277 $select_submit = $opts['select_submit']===true ? '_'.$name.'_update' : $opts['select_submit'];
278 $spec_id = $opts['spec_id'];
279 $spec_option = $opts['spec_option'];
280 $disabled = $opts['disabled'] ? "disabled" : '';
282 if ($selected_id == null) {
283 $selected_id = get_post($name, $opts['default']);
286 if (isset($_POST[$select_submit])) {
288 $Ajax->activate('_page_body');
290 $Ajax->activate($name);
293 // ------ make selector ----------
294 $selector = $first_opt = '';
297 //if($name=='SelectStockFromList') display_error($sql);
298 foreach($items as $value=>$descr) {
300 if ((string)$selected_id === (string)$value) {
304 if ($first_id === false) {
308 $selector .= "<option $sel value='$value'>$descr</option>\n";
311 // Prepend special option.
312 if ($spec_option !== false) { // if special option used - add it
313 $first_id = $spec_id;
314 $first_opt = $spec_option;
315 $sel = $found===false ? 'selected' : '';
316 $selector = "<option $sel value='$spec_id'>$spec_option</option>\n"
320 if ($found === false) {
321 $selected_id = $first_id;
323 $_POST[$name] = $selected_id;
325 $aspect = $opts['edit_submit'] ? " aspect='editable'" : '';
326 $selector = "<select $disabled name='$name' class='combo' title='"
327 . $opts['sel_hint']."'$aspect >".$selector."</select>\n";
329 $Ajax->addUpdate($name, "_{$name}_sel", $selector);
331 $selector = "<span id='_{$name}_sel'>".$selector."</span>\n";
333 if ($select_submit != false) { // if submit on change is used - add select button
334 global $_select_button;
335 $selector .= sprintf($_select_button, $disabled, user_theme(),
336 (fallback_mode() ? '' : 'display:none;'),
337 $select_submit)."\n";
339 default_focus($name);
344 //----------------------------------------------------------------------------------------------
346 function _format_add_curr($row)
348 static $company_currency;
350 if ($company_currency == null)
352 $company_currency = get_company_currency();
354 return $row[1] . ($row[2] == $company_currency ?
355 '' : (" - " . $row[2]));
358 function supplier_list($name, $selected_id=null, $spec_option=false, $submit_on_change=false)
362 $sql = "SELECT supplier_id, supp_name, curr_code FROM ".TB_PREF."suppliers ";
364 $mode = get_company_pref('no_supplier_list');
366 return combo_input($name, $selected_id, $sql, 'supplier_id', 'supp_name',
368 'format' => '_format_add_curr',
369 'search_box' => $mode!=0,
370 'edit_submit' => true,
372 'spec_option' => $spec_option === true ? _("All Suppliers") : $spec_option,
373 'spec_id' => $all_items,
374 'select_submit'=> $submit_on_change,
376 'sel_hint' => $mode ? _('Press Space tab to filter by name fragment') :
381 function supplier_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
384 echo "<td>$label</td><td>\n";
385 $str = supplier_list($name, $selected_id, $all_option, $submit_on_change);
390 function supplier_list_row($label, $name, $selected_id=null, $all_option = false, $submit_on_change=false)
392 echo "<tr><td>$label</td><td>";
393 $str = supplier_list($name, $selected_id, $all_option, $submit_on_change );
397 //----------------------------------------------------------------------------------------------
399 function customer_list($name, $selected_id=null, $spec_option=false, $submit_on_change=false)
403 $sql = "SELECT debtor_no, name, curr_code FROM ".TB_PREF."debtors_master ";
405 $mode = get_company_pref('no_customer_list');
407 return combo_input($name, $selected_id, $sql, 'debtor_no', 'name',
409 'format' => '_format_add_curr',
410 'search_box' => $mode!=0,
413 'spec_option' => $spec_option === true ? _("All Customers") : $spec_option,
414 'spec_id' => $all_items,
415 'select_submit'=> $submit_on_change,
416 'edit_submit' => true, // call editor on F4
418 'sel_hint' => $mode ? _('Press Space tab to filter by name fragment; F4 - entry new customer') :
423 function customer_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
426 echo "<td>$label</td>\n";
428 $str = customer_list($name, $selected_id, $all_option, $submit_on_change);
433 function customer_list_row($label, $name, $selected_id=null, $all_option = false, $submit_on_change=false)
435 echo "<tr><td>$label</td><td nowrap>";
436 $str = customer_list($name, $selected_id, $all_option, $submit_on_change);
437 echo "</td>\n</tr>\n";
441 //------------------------------------------------------------------------------------------------
443 function customer_branches_list($customer_id, $name, $selected_id=null,
444 $spec_option = true, $enabled=true, $submit_on_change=false)
448 $sql = "SELECT branch_code, br_name FROM ".TB_PREF."cust_branch
449 WHERE debtor_no='" . $customer_id . "' ";
451 $where = $enabled ? array("disable_trans = 0") : array();
452 return combo_input($name, $selected_id, $sql, 'branch_code', 'br_name',
455 'spec_option' => $spec_option === true ? _('All branches') : $spec_option,
456 'spec_id' => $all_items,
457 'select_submit'=> $submit_on_change,
458 'sel_hint' => _('Select customer branch')
461 //------------------------------------------------------------------------------------------------
463 function customer_branches_list_cells($label,$customer_id, $name, $selected_id=null, $all_option = true, $enabled=true, $submit_on_change=false)
466 echo "<td>$label</td>\n";
468 $ret = customer_branches_list($customer_id, $name, $selected_id, $all_option, $enabled, $submit_on_change);
473 function customer_branches_list_row($label,$customer_id, $name, $selected_id=null, $all_option = true, $enabled=true, $submit_on_change=false)
476 $ret = customer_branches_list_cells($label, $customer_id, $name, $selected_id, $all_option, $enabled, $submit_on_change);
481 //------------------------------------------------------------------------------------------------
483 function locations_list($name, $selected_id=null, $all_option=false, $submit_on_change=false)
487 $sql = "SELECT loc_code, location_name FROM ".TB_PREF."locations";
489 return combo_input($name, $selected_id, $sql, 'loc_code', 'location_name',
491 'spec_option' => $all_option === true ? _("All Locations") : $all_option,
492 'spec_id' => $all_items,
493 'select_submit'=> $submit_on_change
497 function locations_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
500 echo "<td>$label</td>\n";
502 $str = locations_list($name, $selected_id, $all_option, $submit_on_change);
507 function locations_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
510 $str = locations_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
515 //-----------------------------------------------------------------------------------------------
517 function currencies_list($name, $selected_id=null, $submit_on_change=false)
519 $sql = "SELECT curr_abrev, currency FROM ".TB_PREF."currencies";
521 // default to the company currency
523 return combo_input($name, $selected_id, $sql, 'curr_abrev', 'currency',
525 'select_submit'=> $submit_on_change,
526 'default' => get_company_currency(),
531 function currencies_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
534 echo "<td>$label</td>\n";
536 $str = currencies_list($name, $selected_id, $submit_on_change);
541 function currencies_list_row($label, $name, $selected_id=null, $submit_on_change=false)
544 $str = currencies_list_cells($label, $name, $selected_id, $submit_on_change);
549 //---------------------------------------------------------------------------------------------------
551 function fiscalyears_list($name, $selected_id=null, $submit_on_change=false)
554 $sql = "SELECT * FROM ".TB_PREF."fiscal_year";
556 // default to the company current fiscal year
558 return combo_input($name, $selected_id, $sql, 'id', '',
561 'default' => get_company_pref('f_year'),
562 'format' => '_format_fiscalyears',
563 'select_submit'=> $submit_on_change,
568 function _format_fiscalyears($row)
570 return sql2date($row[1]) . " - " . sql2date($row[2])
571 . " " . ($row[3] ? _('Closed') : _('Active')) . "</option>\n";
574 function fiscalyears_list_cells($label, $name, $selected_id=null)
577 echo "<td>$label</td>\n";
579 $str = fiscalyears_list($name, $selected_id);
584 function fiscalyears_list_row($label, $name, $selected_id=null)
587 $str = fiscalyears_list_cells($label, $name, $selected_id);
591 //------------------------------------------------------------------------------------
593 function dimensions_list($name, $selected_id=null, $no_option=false, $showname=' ',
594 $submit_on_change=false, $showclosed=false, $showtype=1)
596 $sql = "SELECT id, CONCAT(reference,' ',name) as ref FROM ".TB_PREF."dimensions";
599 'order' => 'reference',
600 'spec_option'=>$no_option ? $showname : false,
602 'select_submit'=> $submit_on_change,
607 $options['where'][] = "closed=0";
609 $options['where'][] = "type_=$showtype";
611 return combo_input($name, $selected_id, $sql, 'id', 'ref', $options);
614 function dimensions_list_cells($label, $name, $selected_id=null, $no_option=false, $showname=null,
615 $showclosed=false, $showtype=0, $submit_on_change=false)
618 echo "<td>$label</td>\n";
620 $str = dimensions_list($name, $selected_id, $no_option, $showname, $submit_on_change, $showclosed, $showtype);
625 function dimensions_list_row($label, $name, $selected_id=null, $no_option=false, $showname=null,
626 $showclosed=false, $showtype=0, $submit_on_change=false)
629 $str = dimensions_list_cells($label, $name, $selected_id, $no_option, $showname,
630 $showclosed, $showtype, $submit_on_change);
635 //---------------------------------------------------------------------------------------------------
637 function stock_items_list($name, $selected_id=null, $all_option=false, $submit_on_change=false, $opts=array())
641 $sql = "SELECT stock_id, s.description, c.description
642 FROM ".TB_PREF."stock_master s,".TB_PREF."stock_category c WHERE s.category_id=c.category_id";
644 return combo_input($name, $selected_id, $sql, 'stock_id', 's.description',
647 'format' => '_format_stock_items',
648 'spec_option' => $all_option===true ? _("All Items") : $all_option,
649 'spec_id' => $all_items,
650 'search_box' => true,
651 'search' => array("stock_id", "c.description","s.description"),
652 'search_submit' => get_company_pref('no_item_list')!=0,
654 'select_submit'=> $submit_on_change,
656 'order' => array('c.description','stock_id')
660 function _format_stock_items($row)
662 return (user_show_codes() ? ($row[0] . " - ") : "") . $row[1];
665 function stock_items_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
668 echo "<td>$label</td>\n";
669 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
670 array('cells'=>true));
674 function stock_items_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
677 $str = stock_items_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
682 //---------------------------------------------------------------------------------------------------
684 // Select item via foreign code.
686 function sales_items_list($name, $selected_id=null, $all_option=false,
687 $submit_on_change=false, $type='', $opts=array())
691 $sql = "SELECT i.item_code, i.description, c.description, count(*)>1 as kit
693 ".TB_PREF."item_codes i
695 ".TB_PREF."stock_category c
696 ON i.category_id=c.category_id";
698 if ($type == 'local') { // exclude foreign codes
699 $sql .= " WHERE !i.is_foreign";
700 } elseif ($type == 'kits') { // sales kits
701 $sql .= " WHERE !i.is_foreign AND i.item_code!=i.stock_id";
704 $sql .= " GROUP BY i.item_code";
706 return combo_input($name, $selected_id, $sql, 'i.item_code', 'c.description',
709 'format' => '_format_stock_items',
710 'spec_option' => $all_option===true ? _("All Items") : $all_option,
711 'spec_id' => $all_items,
712 'search_box' => true,
713 'search' => array("i.item_code", "i.description"),
714 'search_submit' => get_company_pref('no_item_list')!=0,
716 'select_submit'=> $submit_on_change,
718 'order' => array('c.description','i.item_code')
722 function sales_items_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
725 echo "<td>$label</td>\n";
726 $str = sales_items_list($name, $selected_id, $all_option, $submit_on_change,
727 '', array('cells'=>true));
731 function sales_kits_list($name, $selected_id=null, $all_option=false, $submit_on_change=false)
733 $str = sales_items_list($name, $selected_id, $all_option, $submit_on_change,
734 'kits', array('cells'=>false));
738 function sales_local_items_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false)
742 echo "<td>$label</td>\n";
744 $str = sales_items_list($name, $selected_id, $all_option, $submit_on_change,
745 'local', array('cells'=>false));
749 //------------------------------------------------------------------------------------
751 function stock_manufactured_items_list($name, $selected_id=null,
752 $all_option=false, $submit_on_change=false)
754 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
755 array('where'=>array("mb_flag= 'M'"),
756 'edit_submit' => true));
760 function stock_manufactured_items_list_cells($label, $name, $selected_id=null,
761 $all_option=false, $submit_on_change=false)
764 echo "<td>$label</td>\n";
766 $str = stock_manufactured_items_list($name, $selected_id, $all_option, $submit_on_change);
771 function stock_manufactured_items_list_row($label, $name, $selected_id=null,
772 $all_option=false, $submit_on_change=false)
775 $str = stock_manufactured_items_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
779 //------------------------------------------------------------------------------------
781 function stock_component_items_list($name, $parent_stock_id, $selected_id=null,
782 $all_option=false, $submit_on_change=false)
784 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
785 array('where'=>array("stock_id != '$parent_stock_id'")));
789 function stock_component_items_list_cells($label, $name, $parent_stock_id,
790 $selected_id=null, $all_option=false, $submit_on_change=false)
793 echo "<td>$label</td>\n";
794 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
795 array('where'=>array("stock_id != '$parent_stock_id'"), 'cells'=>true));
798 //------------------------------------------------------------------------------------
800 function stock_costable_items_list($name, $selected_id=null,
801 $all_option=false, $submit_on_change=false)
803 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
804 array('where'=>array("mb_flag!='D'")));
808 function stock_costable_items_list_cells($label, $name, $selected_id=null,
809 $all_option=false, $submit_on_change=false)
812 echo "<td>$label</td>\n";
813 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
814 array('where'=>array("mb_flag!='D'"), 'cells'=>true));
818 //------------------------------------------------------------------------------------
819 function stock_purchasable_items_list($name, $selected_id=null,
820 $all_option=false, $submit_on_change=false)
822 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
823 array('where'=>array("mb_flag!= 'M'"),
824 'edit_submit' => true));
828 function stock_purchasable_items_list_cells($label, $name, $selected_id=null,
829 $all_option=false, $submit_on_change=false)
832 echo "<td>$label</td>\n";
833 $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
834 array('where'=>array("mb_flag!= 'M'"),
835 'edit_submit' => true,
840 function stock_purchasable_items_list_row($label, $name, $selected_id=null,
841 $all_option=false, $submit_on_change=false)
844 $ret = stock_purchasable_items_list_cells($label, $name, $selected_id=null,
845 $all_option, $submit_on_change);
850 //------------------------------------------------------------------------------------
852 function stock_item_types_list_row($label, $name, $selected_id=null, $enabled=true)
855 'M' => _("Manufactured"),
856 'B' => _("Purchased"),
862 echo "<td>$label</td>\n";
865 array_selector($name, $selected_id, $types,
867 'select_submit'=> true,
868 'disabled' => !$enabled) );
872 function stock_units_list_row($label, $name, $value=null, $enabled=true)
874 $result = get_all_item_units();
877 echo "<td>$label</td>\n";
880 while($unit = db_fetch($result))
881 $units[$unit['abbr']] = $unit['name'];
883 array_selector($name, $value, $units, array( 'disabled' => !$enabled) );
888 //------------------------------------------------------------------------------------
890 function tax_types_list($name, $selected_id=null, $none_option=false, $submit_on_change=false)
892 $sql = "SELECT id, CONCAT(name, ' (',rate,'%)') as name FROM ".TB_PREF."tax_types";
894 return combo_input($name, $selected_id, $sql, 'id', 'name',
896 'spec_option' => $none_option,
897 'spec_id' => reserved_words::get_all_numeric(),
898 'select_submit'=> $submit_on_change,
903 function tax_types_list_cells($label, $name, $selected_id=null, $none_option=false,
904 $submit_on_change=false)
907 echo "<td>$label</td>\n";
909 $str = tax_types_list($name, $selected_id, $none_option, $submit_on_change);
914 function tax_types_list_row($label, $name, $selected_id=null, $none_option=false,
915 $submit_on_change=false)
918 $str = tax_types_list_cells($label, $name, $selected_id, $none_option, $submit_on_change);
923 //------------------------------------------------------------------------------------
925 function tax_groups_list($name, $selected_id=null,
926 $none_option=false, $submit_on_change=false)
928 $sql = "SELECT id, name FROM ".TB_PREF."tax_groups";
930 return combo_input($name, $selected_id, $sql, 'id', 'name',
933 'spec_option' => $none_option,
934 'spec_id' => reserved_words::get_all_numeric(),
935 'select_submit'=> $submit_on_change,
940 function tax_groups_list_cells($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false)
943 echo "<td>$label</td>\n";
945 $str = tax_groups_list($name, $selected_id, $none_option, $submit_on_change);
950 function tax_groups_list_row($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false)
953 $str = tax_groups_list_cells($label, $name, $selected_id, $none_option, $submit_on_change);
958 //------------------------------------------------------------------------------------
960 function item_tax_types_list($name, $selected_id=null)
962 $sql ="SELECT id, name FROM ".TB_PREF."item_tax_types";
963 combo_input($name, $selected_id, $sql, 'id', 'name', array('order' => 'id') );
966 function item_tax_types_list_cells($label, $name, $selected_id=null)
969 echo "<td>$label</td>\n";
971 item_tax_types_list($name, $selected_id);
975 function item_tax_types_list_row($label, $name, $selected_id=null)
978 item_tax_types_list_cells($label, $name, $selected_id);
982 //------------------------------------------------------------------------------------
984 function shippers_list($name, $selected_id=null)
986 $sql = "SELECT shipper_id, shipper_name FROM ".TB_PREF."shippers";
987 combo_input($name, $selected_id, $sql, 'shipper_id', 'shipper_name', array());
990 function shippers_list_cells($label, $name, $selected_id=null)
993 echo "<td>$label</td>\n";
995 shippers_list($name, $selected_id);
999 function shippers_list_row($label, $name, $selected_id=null)
1002 shippers_list_cells($label, $name, $selected_id);
1006 //-------------------------------------------------------------------------------------
1008 function sales_persons_list($name, $selected_id=null)
1010 $sql = "SELECT salesman_code, salesman_name FROM ".TB_PREF."salesman";
1011 combo_input($name, $selected_id, $sql, 'salesman_code', 'salesman_name', array());
1014 function sales_persons_list_cells($label, $name, $selected_id=null)
1017 echo "<td>$label</td>\n";
1019 sales_persons_list($name, $selected_id);
1023 function sales_persons_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1026 sales_persons_list_cells($label, $name, $selected_id, $submit_on_change=false);
1030 //------------------------------------------------------------------------------------
1032 function sales_areas_list($name, $selected_id=null)
1034 $sql = "SELECT area_code, description FROM ".TB_PREF."areas";
1035 combo_input($name, $selected_id, $sql, 'area_code', 'description', array());
1038 function sales_areas_list_cells($label, $name, $selected_id=null)
1041 echo "<td>$label</td>\n";
1043 sales_areas_list($name, $selected_id);
1047 function sales_areas_list_row($label, $name, $selected_id=null)
1050 sales_areas_list_cells($label, $name, $selected_id);
1054 //------------------------------------------------------------------------------------
1056 function sales_groups_list($name, $selected_id=null, $special_option=false)
1058 $sql = "SELECT id, description FROM ".TB_PREF."groups";
1059 combo_input($name, $selected_id, $sql, 'id', 'description', array(
1060 'spec_option' => $special_option===true ? ' ' : $special_option,
1061 'order' => 'description', 'spec_id' => 0,
1065 function sales_groups_list_cells($label, $name, $selected_id=null, $special_option=false)
1068 echo "<td>$label</td>\n";
1070 sales_groups_list($name, $selected_id, $special_option);
1074 function sales_groups_list_row($label, $name, $selected_id=null, $special_option=false)
1077 sales_groups_list_cells($label, $name, $selected_id, $special_option);
1081 //------------------------------------------------------------------------------------
1083 function _format_template_items($row)
1085 return ($row[0] . " - " . _("Amount") . " ".$row[1]);
1088 function templates_list($name, $selected_id=null, $special_option=false)
1090 $sql = "SELECT sorder.order_no, Sum(line.unit_price*line.quantity*(1-line.discount_percent)) AS OrderValue
1091 FROM ".TB_PREF."sales_orders as sorder, ".TB_PREF."sales_order_details as line
1092 WHERE sorder.order_no = line.order_no AND sorder.type = 1 GROUP BY line.order_no";
1093 combo_input($name, $selected_id, $sql, 'order_no', 'OrderValue', array(
1094 'format' => '_format_template_items',
1095 'spec_option' => $special_option===true ? ' ' : $special_option,
1096 'order' => 'order_no', 'spec_id' => 0,
1100 function templates_list_cells($label, $name, $selected_id=null, $special_option=false)
1103 echo "<td>$label</td>\n";
1105 templates_list($name, $selected_id, $special_option);
1109 function templates_list_row($label, $name, $selected_id=null, $special_option=false)
1112 templates_list_cells($label, $name, $selected_id, $special_option);
1116 //------------------------------------------------------------------------------------
1118 function workorders_list($name, $selected_id=null)
1120 $sql = "SELECT id, wo_ref FROM ".TB_PREF."workorders WHERE closed=0";
1121 combo_input($name, $selected_id, $sql, 'id', 'wo_ref', array());
1124 function workorders_list_cells($label, $name, $selected_id=null)
1127 echo "<td>$label</td>\n";
1129 workorders_list($name, $selected_id);
1133 function workorders_list_row($label, $name, $selected_id=null)
1136 workorders_list_cells($label, $name, $selected_id);
1140 //------------------------------------------------------------------------------------
1142 function payment_terms_list($name, $selected_id=null)
1144 $sql = "SELECT terms_indicator, terms FROM ".TB_PREF."payment_terms";
1145 combo_input($name, $selected_id, $sql, 'terms_indicator', 'terms', array());
1148 function payment_terms_list_cells($label, $name, $selected_id=null)
1151 echo "<td>$label</td>\n";
1153 payment_terms_list($name, $selected_id);
1157 function payment_terms_list_row($label, $name, $selected_id=null)
1160 payment_terms_list_cells($label, $name, $selected_id);
1164 //------------------------------------------------------------------------------------
1166 function credit_status_list($name, $selected_id=null)
1168 $sql ="SELECT id, reason_description FROM ".TB_PREF."credit_status";
1169 combo_input($name, $selected_id, $sql, 'id', 'reason_description', array());
1172 function credit_status_list_cells($label, $name, $selected_id=null)
1175 echo "<td>$label</td>\n";
1177 credit_status_list($name, $selected_id);
1181 function credit_status_list_row($label, $name, $selected_id=null)
1184 credit_status_list_cells($label, $name, $selected_id);
1188 //-----------------------------------------------------------------------------------------------
1190 function sales_types_list($name, $selected_id=null, $submit_on_change=false, $special_option=false)
1192 $sql = "SELECT id, sales_type FROM ".TB_PREF."sales_types";
1194 return combo_input($name, $selected_id, $sql, 'id', 'sales_type',
1196 'spec_option' => $special_option===true ? _("All Sales Types") : $special_option,
1198 'select_submit'=> $submit_on_change,
1199 // 'async' => false,
1203 function sales_types_list_cells($label, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1206 echo "<td>$label</td>\n";
1208 $str = sales_types_list($name, $selected_id, $submit_on_change, $special_option);
1213 function sales_types_list_row($label, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1216 $str = sales_types_list_cells($label, $name, $selected_id, $submit_on_change, $special_option);
1221 //-----------------------------------------------------------------------------------------------
1223 function movement_types_list($name, $selected_id=null)
1225 $sql = "SELECT id, name FROM ".TB_PREF."movement_types";
1226 combo_input($name, $selected_id, $sql, 'id', 'name', array());
1229 function movement_types_list_cells($label, $name, $selected_id=null)
1232 echo "<td>$label</td>\n";
1234 movement_types_list($name, $selected_id);
1238 function movement_types_list_row($label, $name, $selected_id=null)
1241 movement_types_list_cells($label, $name, $selected_id);
1245 //-----------------------------------------------------------------------------------------------
1246 function _format_date($row)
1248 return sql2date($row['reconciled']);
1251 function bank_reconciliation_list($account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1253 $sql = "SELECT reconciled, reconciled FROM ".TB_PREF."bank_trans
1254 WHERE bank_act=".db_escape($account)." AND reconciled IS NOT NULL
1255 GROUP BY reconciled";
1256 combo_input($name, $selected_id, $sql, 'id', 'reconciled',
1258 'spec_option' => $special_option,
1259 'format' => '_format_date',
1261 'select_submit'=> $submit_on_change
1265 function bank_reconciliation_list_cells($label,$account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1268 echo "<td>$label</td>\n";
1270 bank_reconciliation_list($account, $name, $selected_id, $submit_on_change, $special_option);
1274 function bank_reconciliation_list_row($label, $account, $name, $selected_id=null, $submit_on_change=false, $special_option=false)
1277 bank_reconciliation_list_cells($label, $account, $name, $selected_id, $submit_on_change, $special_option);
1281 //-----------------------------------------------------------------------------------------------
1283 function workcenter_list($name, $selected_id=null, $all_option=false)
1287 $sql = "SELECT id, name FROM ".TB_PREF."workcentres";
1289 return combo_input($name, $selected_id, $sql, 'id', 'name',
1291 'spec_option' =>$all_option===true ? _("All Suppliers") : $all_option,
1292 'spec_id' => $all_items,
1296 function workcenter_list_cells($label, $name, $selected_id=null, $all_option=false)
1298 default_focus($name);
1300 echo "<td>$label</td>\n";
1302 workcenter_list($name, $selected_id, $all_option);
1306 function workcenter_list_row($label, $name, $selected_id=null, $all_option=false)
1309 workcenter_list_cells($label, $name, $selected_id, $all_option);
1313 //-----------------------------------------------------------------------------------------------
1315 function bank_accounts_list($name, $selected_id=null, $submit_on_change=false)
1317 $sql = "SELECT ".TB_PREF."bank_accounts.id, bank_account_name, bank_curr_code
1318 FROM ".TB_PREF."bank_accounts";
1319 // , ".TB_PREF."chart_master
1320 // WHERE ".TB_PREF."bank_accounts.account_code=".TB_PREF."chart_master.account_code";
1322 return combo_input($name, $selected_id, $sql, 'id', 'bank_account_name',
1324 'format' => '_format_add_curr',
1325 'select_submit'=> $submit_on_change,
1330 function bank_accounts_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1333 echo "<td>$label</td>\n";
1335 $str = bank_accounts_list($name, $selected_id, $submit_on_change);
1340 function bank_accounts_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1343 $str = bank_accounts_list_cells($label, $name, $selected_id, $submit_on_change);
1347 //-----------------------------------------------------------------------------------------------
1349 function cash_accounts_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1351 $sql = "SELECT ".TB_PREF."bank_accounts.id, bank_account_name, bank_curr_code
1352 FROM ".TB_PREF."bank_accounts
1353 WHERE ".TB_PREF."bank_accounts.account_type=3";
1356 echo "<tr><td>$label</td>\n";
1358 $str = combo_input($name, $selected_id, $sql, 'id', 'bank_account_name',
1360 'format' => '_format_add_curr',
1361 'select_submit'=> $submit_on_change,
1364 echo "</td></tr>\n";
1367 //-----------------------------------------------------------------------------------------------
1369 function pos_list_row($label, $name, $selected_id=null, $spec_option=false, $submit_on_change=false)
1371 $sql = "SELECT id, pos_name FROM ".TB_PREF."sales_pos";
1373 default_focus($name);
1376 echo "<td>$label</td>\n";
1379 $str = combo_input($name, $selected_id, $sql, 'id', 'pos_name',
1381 'select_submit'=> $submit_on_change,
1383 'spec_option' =>$spec_option,
1386 echo "</td></tr>\n";
1390 //-----------------------------------------------------------------------------------------------
1392 function sale_payment_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1395 echo "<td>$label</td>\n";
1397 $str = yesno_list($name, $selected_id, _('Cash'), _('Delayed'), $submit_on_change);
1401 //-----------------------------------------------------------------------------------------------
1403 function class_list($name, $selected_id=null, $submit_on_change=false)
1405 $sql = "SELECT cid, class_name FROM ".TB_PREF."chart_class";
1407 return combo_input($name, $selected_id, $sql, 'cid', 'class_name',
1409 'select_submit'=> $submit_on_change,
1415 function class_list_cells($label, $name, $selected_id=null, $submit_on_change=false)
1418 echo "<td>$label</td>\n";
1420 $str = class_list($name, $selected_id, $submit_on_change);
1425 function class_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1428 $str = class_list_cells($label, $name, $selected_id, $submit_on_change);
1433 //-----------------------------------------------------------------------------------------------
1435 function stock_categories_list($name, $selected_id=null)
1437 $sql = "SELECT category_id, description FROM ".TB_PREF."stock_category";
1438 combo_input($name, $selected_id, $sql, 'category_id', 'description',
1439 array('order'=>'category_id'));
1442 function stock_categories_list_cells($label, $name, $selected_id=null)
1445 echo "<td>$label</td>\n";
1447 stock_categories_list($name, $selected_id);
1451 function stock_categories_list_row($label, $name, $selected_id=null)
1454 stock_categories_list_cells($label, $name, $selected_id);
1458 //-----------------------------------------------------------------------------------------------
1460 function gl_account_types_list($name, $selected_id=null, $all_option, $all_option_numeric)
1464 $sql = "SELECT id, name FROM ".TB_PREF."chart_types";
1466 combo_input($name, $selected_id, $sql, 'id', 'name',
1469 'spec_option' =>$all_option,
1470 'spec_id' => $all_option_numeric ? 0 : $all_items
1474 function gl_account_types_list_cells($label, $name, $selected_id=null, $all_option=false,
1475 $all_option_numeric=false)
1478 echo "<td>$label</td>\n";
1480 gl_account_types_list($name, $selected_id, $all_option, $all_option_numeric);
1484 function gl_account_types_list_row($label, $name, $selected_id=null, $all_option=false,
1485 $all_option_numeric=false)
1488 gl_account_types_list_cells($label, $name, $selected_id, $all_option,
1489 $all_option_numeric);
1493 //-----------------------------------------------------------------------------------------------
1494 function gl_all_accounts_list($name, $selected_id=null, $skip_bank_accounts=false,
1495 $cells=false, $all_option=false, $submit_on_change=false)
1497 if ($skip_bank_accounts)
1498 $sql = "SELECT chart.account_code, chart.account_name, type.name
1499 FROM (".TB_PREF."chart_master chart,".TB_PREF."chart_types type) "
1500 ."LEFT JOIN ".TB_PREF."bank_accounts acc "
1501 ."ON chart.account_code=acc.account_code
1502 WHERE acc.account_code IS NULL
1503 AND chart.account_type=type.id";
1505 $sql = "SELECT chart.account_code, chart.account_name, type.name
1506 FROM ".TB_PREF."chart_master chart,".TB_PREF."chart_types type
1507 WHERE chart.account_type=type.id";
1509 combo_input($name, $selected_id, $sql, 'chart.account_code', 'chart.account_name',
1511 'format' => '_format_account',
1512 'spec_option' => $all_option===true ? _("Use Item Sales Accounts") : $all_option,
1514 'order' => array('name','account_code'),
1515 'search_box' => $cells,
1516 'search_submit' => false,
1520 'select_submit'=> $submit_on_change,
1527 function _format_account($row)
1529 return $row[0] . " " . $row[1];
1532 function gl_all_accounts_list_cells($label, $name, $selected_id=null,
1533 $skip_bank_accounts=false, $cells=false, $all_option=false)
1536 echo "<td>$label</td>\n";
1538 gl_all_accounts_list($name, $selected_id,
1539 $skip_bank_accounts, $cells, $all_option);
1543 function gl_all_accounts_list_row($label, $name, $selected_id=null,
1544 $skip_bank_accounts=false, $cells=false, $all_option=false)
1547 gl_all_accounts_list_cells($label, $name, $selected_id,
1548 $skip_bank_accounts, $cells, $all_option);
1552 function yesno_list($name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1555 $items['0'] = strlen($name_no) ? $name_no : _("No");
1556 $items['1'] = strlen($name_yes) ? $name_yes : _("Yes");
1558 return array_selector($name, $selected_id, $items,
1560 'select_submit'=> $submit_on_change,
1561 'async' => false ) ); // FIX?
1564 function yesno_list_cells($label, $name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1567 echo "<td>$label</td>\n";
1569 $str = yesno_list($name, $selected_id, $name_yes, $name_no, $submit_on_change);
1574 function yesno_list_row($label, $name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false)
1577 $str = yesno_list_cells($label, $name, $selected_id, $name_yes, $name_no, $submit_on_change);
1582 //------------------------------------------------------------------------------------------------
1584 function languages_list($name, $selected_id=null)
1586 global $installed_languages;
1589 foreach ($installed_languages as $lang)
1590 $items[$lang['code']] = $lang['name'];
1592 return array_selector($name, $selected_id, $items );
1595 function languages_list_cells($label, $name, $selected_id=null)
1598 echo "<td>$label</td>\n";
1600 languages_list($name, $selected_id);
1604 function languages_list_row($label, $name, $selected_id=null)
1607 languages_list_cells($label, $name, $selected_id);
1611 //------------------------------------------------------------------------------------------------
1613 function bank_account_types_list($name, $selected_id=null)
1615 $types = bank_account_types::get_all();
1618 foreach ($types as $type)
1620 $items[$type['id']] = $type['name'];
1623 return array_selector($name, $selected_id, $items );
1626 function bank_account_types_list_cells($label, $name, $selected_id=null)
1629 echo "<td>$label</td>\n";
1631 bank_account_types_list($name, $selected_id);
1635 function bank_account_types_list_row($label, $name, $selected_id=null)
1638 bank_account_types_list_cells($label, $name, $selected_id);
1642 //------------------------------------------------------------------------------------------------
1643 function payment_person_types_list($name, $selected_id=null, $submit_on_change=false)
1645 $types = payment_person_types::get_all();
1648 foreach ($types as $type)
1650 if (payment_person_types::has_items($type['id']))
1652 if ($type['id'] != payment_person_types::WorkOrder())
1653 $items[$type['id']] = $type['name'];
1657 return array_selector($name, $selected_id, $items,
1658 array( 'select_submit'=> $submit_on_change ) );
1661 function payment_person_types_list_cells($label, $name, $selected_id=null, $related=null)
1664 echo "<td>$label</td>\n";
1666 $str = payment_person_types_list($name, $selected_id, $related);
1671 function payment_person_types_list_row($label, $name, $selected_id=null, $related=null)
1674 $str = payment_person_types_list_cells($label, $name, $selected_id, $related);
1679 //------------------------------------------------------------------------------------------------
1681 function wo_types_list($name, $selected_id=null)
1683 $types = wo_types::get_all();
1686 foreach ($types as $type)
1687 $items[$type['id']] = $type['name'];
1689 return array_selector($name, $selected_id, $items,
1690 array( 'select_submit'=> true, 'async' => true ) );
1693 function wo_types_list_row($label, $name, $selected_id=null)
1695 echo "<tr><td>$label</td><td>\n";
1696 $str = wo_types_list($name, $selected_id);
1697 echo "</td></tr>\n";
1701 //------------------------------------------------------------------------------------------------
1703 function dateformats_list_row($label, $name, $value=null)
1705 global $dateformats;
1707 echo "<tr><td>$label</td>\n<td>";
1708 array_selector( $name, $value, $dateformats );
1709 echo "</td></tr>\n";
1712 function dateseps_list_row($label, $name, $value=null)
1716 echo "<tr><td>$label</td>\n<td>";
1717 array_selector( $name, $value, $dateseps );
1718 echo "</td></tr>\n";
1721 function thoseps_list_row($label, $name, $value=null)
1725 echo "<tr><td>$label</td>\n<td>";
1726 array_selector( $name, $value, $thoseps );
1727 echo "</td></tr>\n";
1730 function decseps_list_row($label, $name, $value=null)
1734 echo "<tr><td>$label</td>\n<td>";
1735 array_selector( $name, $value, $decseps );
1736 echo "</td></tr>\n";
1739 function themes_list_row($label, $name, $value=null)
1741 global $path_to_root;
1743 $path = $path_to_root.'/themes/';
1745 $themedir = opendir($path);
1746 while(false !== ($fname = readdir($themedir)))
1748 if($fname!='.' && $fname!='..' && $fname!='CVS' && is_dir($path.$fname))
1750 $themes[$fname] = $fname;
1755 echo "<tr><td>$label</td>\n<td>";
1756 array_selector( $name, $value, $themes );
1757 echo "</td></tr>\n";
1760 function pagesizes_list_row($label, $name, $value=null)
1765 foreach ($pagesizes as $pz)
1768 echo "<tr><td>$label</td>\n<td>";
1769 array_selector( $name, $value, $items );
1770 echo "</td></tr>\n";
1773 function security_headings_list_row($label, $name, $value=null)
1775 global $security_headings;
1777 echo "<tr><td>$label</td>\n<td>";
1778 array_selector( $name, $value, $security_headings );
1779 echo "</td></tr>\n";
1782 function systypes_list_cells($label, $name, $value=null, $submit_on_change=false)
1784 global $systypes_array;
1787 echo "<td>$label</td>\n";
1791 foreach ($systypes_array as $key=>$type)
1792 $items[$key] = $type['name'];
1794 $str = array_selector($name, $value, $items,
1796 'select_submit'=> $submit_on_change,
1804 function systypes_list_row($label, $name, $value=null, $submit_on_change=false)
1807 $str = systypes_list_cells($label, $name, $value, $submit_on_change);
1812 function cust_allocations_list_cells($label, $name, $selected=null)
1820 $all_items=>_("All Types"),
1821 '1'=> _("Sales Invoices"),
1822 '2'=> _("Overdue Invoices"),
1823 '3' => _("Payments"),
1824 '4' => _("Credit Notes"),
1825 '5' => _("Delivery Notes")
1827 $str = array_selector($name, $selected, $allocs);
1832 function supp_allocations_list_cell($name, $selected=null)
1838 $all_items=>_("All Types"),
1839 '1'=> _("Invoices"),
1840 '2'=> _("Overdue Invoices"),
1841 '3' => _("Payments"),
1842 '4' => _("Credit Notes"),
1843 '5' => _("Overdue Credit Notes")
1845 $str = array_selector($name, $selected, $allocs);
1850 function policy_list_cells($label, $name, $selected=null)
1855 $str = array_selector($name, $selected,
1856 array( '' => _("Automatically put balance on back order"),
1857 'CAN' => _("Cancel any quantites not delivered")) );
1862 function policy_list_row($label, $name, $selected=null)
1865 policy_list_cells($label, $name, $selected);
1869 function credit_type_list_cells($label, $name, $selected=null, $submit_on_change=false)
1874 $str = array_selector($name, $selected,
1875 array( 'Return' => _("Items Returned to Inventory Location"),
1876 'WriteOff' => _("Items Written Off")),
1877 array( 'select_submit'=> $submit_on_change ) );
1882 function credit_type_list_row($label, $name, $selected=null, $submit_on_change=false)
1885 $str = credit_type_list_cells($label, $name, $selected, $submit_on_change);
1890 function number_list($name, $selected, $from, $to, $no_option=false)
1893 for ($i = $from; $i <= $to; $i++)
1896 return array_selector($name, $selected, $items,
1897 array( 'spec_option' => $no_option,
1898 'spec_id' => reserved_words::get_all_numeric()) );
1901 function number_list_cells($label, $name, $selected, $from, $to, $no_option=false)
1906 number_list($name, $selected, $from, $to, $no_option);
1910 function number_list_row($label, $name, $selected, $from, $to, $no_option=false)
1913 number_list_cells($label, $name, $selected, $from, $to, $no_option);
1917 function print_profiles_list_row($label, $name, $selected_id=null, $spec_opt=false,
1918 $submit_on_change=true)
1920 $sql = "SELECT profile FROM ".TB_PREF."print_profiles"
1921 ." GROUP BY profile";
1922 $result = db_query($sql, 'cannot get all profile names');
1923 $profiles = array();
1924 while($myrow=db_fetch($result)) {
1925 $profiles[$myrow['profile']] = $myrow['profile'];
1930 echo "<td>$label</td>\n";
1933 array_selector($name, $selected_id, $profiles,
1934 array( 'select_submit'=> $submit_on_change,
1935 'spec_option'=>$spec_opt,
1939 echo "</td></tr>\n";
1942 function printers_list($name, $selected_id=null, $spec_opt=false, $submit_on_change=false)
1944 static $printers; // query only once for page display
1947 $sql = "SELECT id, name, description FROM ".TB_PREF."printers";
1948 $result = db_query($sql, 'cannot get all printers');
1949 $printers = array();
1950 while($myrow=db_fetch($result)) {
1951 $printers[$myrow['id']] = $myrow['name'].' - '.$myrow['description'];
1954 array_selector($name, $selected_id, $printers,
1955 array( 'select_submit'=> $submit_on_change,
1956 'spec_option'=>$spec_opt,
1961 //------------------------------------------------------------------------------------------------
1963 function quick_entries_list($name, $selected_id=null, $type=null, $submit_on_change=false)
1966 $sql = "SELECT id, description FROM ".TB_PREF."quick_entries";
1968 $sql .= " WHERE type=$type";
1970 combo_input($name, $selected_id, $sql, 'id', 'description',
1973 'order' => 'description',
1974 'select_submit'=> $submit_on_change,
1980 function quick_entries_list_cells($label, $name, $selected_id=null, $type, $submit_on_change=false)
1982 echo "<td>$label</td><td>\n";
1983 quick_entries_list($name, $selected_id, $type, $submit_on_change);
1987 function quick_entries_list_row($label, $name, $selected_id=null, $type, $submit_on_change=false)
1990 quick_entries_list_cells($label, $name, $selected_id, $type, $submit_on_change);
1995 function quick_actions_list_row($label, $name, $selected_id=null, $submit_on_change=false)
1997 global $quick_actions;
1999 echo "<tr><td>$label</td><td>";
2000 array_selector($name, $selected_id, $quick_actions,
2002 'select_submit'=> $submit_on_change
2004 echo "</td></tr>\n";
2007 function quick_entry_types_list_row($label, $name, $selected_id=null, $submit_on_change=false)
2009 global $quick_entry_types;
2011 echo "<tr><td>$label</td><td>";
2012 array_selector($name, $selected_id, $quick_entry_types,
2014 'select_submit'=> $submit_on_change
2016 echo "</td></tr>\n";
2020 function class_types_list_row($label, $name, $selected_id=null, $submit_on_change=false)
2022 global $class_types;
2024 echo "<tr><td>$label</td><td>";
2025 array_selector($name, $selected_id, $class_types,
2027 'select_submit'=> $submit_on_change
2029 echo "</td></tr>\n";