3 include_once($path_to_root . "/includes/banking.inc");
5 define("DEFVAL", "--");
6 $search_button = "<input type='submit' class='inputsubmit' style='border:0;background:url($path_to_root/themes/default/images/locate.png) no-repeat;' name='%s' value='?' title='"._("Search")."'> ";
7 //$search_button = "<input type='submit' class='inputsubmit' name='%s' value='?'> ";
9 $all_items = reserved_words::get_all();
11 // TDB for all list functions : if there is no data, display a link to the releveant
12 // page to add an item, eg. for locations, if no locations, link to Add Location
14 function supplier_list($name, $selected_id, $all_option=false, $submit_on_change=false)
18 if ($selected_id == null)
19 $selected_id = ((!isset($_POST[$name]) || $_POST[$name] == "") ? "" : $_POST[$name]);
20 $no_supplier_list = get_company_pref('no_supplier_list');
21 if ($no_supplier_list)
23 global $search_button;
24 $edit_name = $name."_edit";
25 $edit_button = $name."_button";
27 $val = (isset($_POST[$edit_name]) && $_POST[$edit_name] != "" ? $_POST[$edit_name] : "");
28 if (isset($_POST[$edit_button]))
30 $selected_id = $_POST[$name] = "";
33 if ($selected_id != "")
36 $supplier_sql = "SELECT supplier_id, supp_name, curr_code FROM ".TB_PREF."suppliers WHERE supplier_id=$selected_id";
37 $supplier_result = db_query($supplier_sql);
41 if ($val != "" && $val != DEFVAL)
43 $supplier_sql = "SELECT supplier_id, supp_name, curr_code FROM ".TB_PREF."suppliers WHERE supp_name LIKE '%{$val}%' ORDER BY supp_name";
44 $supplier_result = db_query($supplier_sql);
47 $supplier_result = false;
50 echo "<input type='text' name='$edit_name' size='8' maxlength='50' value='$val' onblur='this.form.$edit_button.click();'> ";
52 echo sprintf($search_button, $edit_button);
56 $supplier_sql = "SELECT supplier_id, supp_name, curr_code FROM ".TB_PREF."suppliers ORDER BY supp_name";
57 $supplier_result = db_query($supplier_sql);
60 if ($submit_on_change==true)
61 echo "<select name='$name' onchange='this.form.submit();'>";
63 echo "<select name='$name'>";
65 $company_currency = get_company_currency();
67 if ($all_option == true)
69 if ($selected_id == $all_items)
71 echo "<option selected value='$all_items'>" . _("All Suppliers") . "</option>\n";
75 echo "<option value='$all_items'>" . _("All Suppliers") . "</option>\n";
77 if ($selected_id == "")
79 $selected_id = $all_items;
83 while ($supplier_row = db_fetch_row($supplier_result))
85 if ($selected_id==$supplier_row[0])
87 echo "<option selected value='" . $supplier_row[0] . "'>";
91 echo "<option value='" . $supplier_row[0] . "'>";
93 echo $supplier_row[1];
95 if ($supplier_row[2] != $company_currency)
96 echo " - " . $supplier_row[2];
98 if ($selected_id == "")
100 $selected_id = $supplier_row[0];
101 $_POST[$name] = $selected_id;
107 db_free_result($supplier_result);
110 function supplier_list_cells($label, $name, $selected_id, $all_option=false, $submit_on_change=false)
113 echo "<td>$label</td>\n";
115 supplier_list($name, $selected_id, $all_option, $submit_on_change);
119 function supplier_list_row($label, $name, $selected_id, $all_option=false, $submit_on_change=false)
122 supplier_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
126 //----------------------------------------------------------------------------------------------
128 function customer_list($name, $selected_id, $all_option=false, $submit_on_change=false)
132 if ($selected_id == null)
133 $selected_id = ((!isset($_POST[$name]) || $_POST[$name] == "") ? "" : $_POST[$name]);
134 $no_customer_list = get_company_pref('no_customer_list');
135 if ($no_customer_list)
137 global $search_button;
138 $edit_name = $name."_edit";
139 $edit_button = $name."_button";
141 $val = (isset($_POST[$edit_name]) && $_POST[$edit_name] != "" ? $_POST[$edit_name] : "");
142 if (isset($_POST[$edit_button]))
144 $selected_id = $_POST[$name] = "";
145 $_POST['branch_id'] = "";
148 if ($selected_id != "")
151 $customer_sql = "SELECT debtor_no, name, curr_code FROM ".TB_PREF."debtors_master WHERE debtor_no=$selected_id";
152 $customer_result = db_query($customer_sql);
156 if ($val != "" && $val != DEFVAL)
158 $customer_sql = "SELECT debtor_no, name, curr_code FROM ".TB_PREF."debtors_master WHERE name LIKE '%{$val}%' ORDER BY name";
159 $customer_result = db_query($customer_sql);
162 $customer_result = false;
165 echo "<input type='text' name='$edit_name' size='8' maxlength='50' value='$val' onblur='this.form.$edit_button.click();'> ";
167 echo sprintf($search_button, $edit_button);
171 $customer_sql = "SELECT debtor_no, name, curr_code FROM ".TB_PREF."debtors_master ORDER BY name";
172 $customer_result = db_query($customer_sql);
174 if ($submit_on_change==true)
175 echo "<select name='$name' onchange='this.form.submit();'>";
177 echo "<select name='$name'>";
179 $company_currency = get_company_currency();
181 if (($all_option == true))
183 if ($selected_id == $all_items)
185 echo "<option selected value='$all_items'>" . _("All Customers") . "</option>\n";
189 echo "<option value='$all_items'>" . _("All Customers") . "</option>\n";
191 if ($selected_id == "")
193 $selected_id = $all_items;
196 while ($customer_row = db_fetch_row($customer_result))
198 if ($selected_id == $customer_row[0])
200 echo "<option selected value='" . $customer_row[0] . "'>";
204 echo "<option value='" . $customer_row[0] . "'>";
207 echo $customer_row[1];
208 if ($customer_row[2] != $company_currency)
209 echo " - " . $customer_row[2];
212 // if no initial selection - set the first item
213 // do we want to do this for all lists ???? probably
214 if ($selected_id == "")
216 $selected_id = $customer_row[0];
217 $_POST[$name] = $selected_id;
222 db_free_result($customer_result);
225 function customer_list_cells($label, $name, $selected_id, $all_option = false, $submit_on_change=false)
228 echo "<td>$label</td>\n";
230 customer_list($name, $selected_id, $all_option, $submit_on_change);
234 function customer_list_row($label, $name, $selected_id, $all_option = false, $submit_on_change=false)
237 customer_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
241 //------------------------------------------------------------------------------------------------
243 function customer_branches_list($customer_id, $name, $selected_id,
244 $all_option = true, $enabled=true, $submit_on_change=false)
248 if ($submit_on_change==true)
249 echo "<select name='$name' onchange='this.form.submit();'>";
251 echo "<select name='$name'>";
253 $sql = "SELECT branch_code, br_name FROM ".TB_PREF."cust_branch
254 WHERE debtor_no='" . $customer_id . "'";
256 $sql .= " AND disable_trans = 0";
257 $result = db_query($sql);
259 if ($selected_id == null)
260 $selected_id = (!isset($_POST[$name]) ? "" : $_POST[$name]);
261 if ($all_option == true)
264 if ($selected_id == $all_items)
266 echo "value='$all_items'>" . _("All Branches") . "</option>\n";
268 if ($selected_id == "")
270 $selected_id = $all_items;
274 while ($row = db_fetch_row($result))
276 if ($selected_id == $row[0])
278 echo "<option selected value='" . $row[0] . "'>";
282 echo "<option value='" . $row[0] . "'>";
284 echo $row[1] . "</option>\n";
286 if ($selected_id == "")
288 $selected_id = $row[0];
289 $_POST[$name] = $selected_id;
294 db_free_result($result);
297 function customer_branches_list_cells($label,$customer_id, $name, $selected_id, $all_option = true, $enabled=true, $submit_on_change=false)
300 echo "<td>$label</td>\n";
302 customer_branches_list($customer_id, $name, $selected_id, $all_option, $enabled, $submit_on_change);
306 function customer_branches_list_row($label,$customer_id, $name, $selected_id, $all_option = true, $enabled=true, $submit_on_change=false)
309 customer_branches_list_cells($label, $customer_id, $name, $selected_id, $all_option, $enabled, $submit_on_change);
313 //------------------------------------------------------------------------------------------------
315 function locations_list($name, $selected_id, $all_option=false, $submit_on_change=false)
319 if ($submit_on_change == true)
320 echo "<select name='$name' onchange='this.form.submit();'>";
322 echo "<select name='$name'>";
324 // if ($selected_id =="" AND isset($_SESSION['UserStockLocation']) AND $_SESSION['UserStockLocation'] !="") {
325 // $selected_id = $_SESSION['UserStockLocation'];
328 $sql = "SELECT loc_code, location_name FROM ".TB_PREF."locations";
329 $result = db_query($sql);
331 if ($selected_id == null)
332 $selected_id = (!isset($_POST[$name]) ? "" : $_POST[$name]);
333 if ($all_option == true)
336 if ($selected_id == $all_items)
338 echo " value='$all_items'>" . _("All Locations") . "</option>\n";
340 if ($selected_id == "")
342 $selected_id = $all_items;
346 while ($row = db_fetch_row($result))
348 if ($selected_id == $row[0])
350 echo "<option selected value='" . $row[0] . "'>";
354 echo "<option value='" . $row[0] . "'>";
356 echo $row[1] . "</option>\n";
358 if ($selected_id == "")
360 $selected_id = $row[0];
361 $_POST[$name] = $selected_id;
367 db_free_result($result);
370 function locations_list_cells($label, $name, $selected_id, $all_option=false, $submit_on_change=false)
373 echo "<td>$label</td>\n";
375 locations_list($name, $selected_id, $all_option, $submit_on_change);
379 function locations_list_row($label, $name, $selected_id, $all_option=false, $submit_on_change=false)
382 locations_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
386 //-----------------------------------------------------------------------------------------------
388 function currencies_list($name, &$selected_id, $submit_on_change=false)
390 if ($submit_on_change==true)
391 echo "<select name='$name' onchange='this.form.submit();'>";
393 echo "<select name='$name'>";
395 $company_currency = get_company_currency();
397 $sql = "SELECT curr_abrev, currency FROM ".TB_PREF."currencies";
398 $result = db_query($sql);
400 if ($selected_id == null)
401 $selected_id = (!isset($_POST[$name]) ? "" : $_POST[$name]);
402 while ($row = db_fetch_row($result))
404 // default to the company currency
405 if ($selected_id == "" && ($row[0] == $company_currency))
407 $selected_id = $row[0];
408 $_POST[$name] = $selected_id;
411 if ($selected_id == $row[0])
413 echo "<option selected value='" . $row[0] . "'>";
417 echo "<option value='" . $row[0] . "'>";
419 echo $row[0] . " - " . $row[1] . "</option>\n";
423 db_free_result($result);
426 function currencies_list_cells($label, $name, $selected_id)
429 echo "<td>$label</td>\n";
431 currencies_list($name, $selected_id);
435 function currencies_list_row($label, $name, $selected_id)
438 currencies_list_cells($label, $name, $selected_id);
442 //---------------------------------------------------------------------------------------------------
444 function fiscalyears_list($name, &$selected_id, $submit_on_change=false)
446 if ($submit_on_change == true)
447 echo "<select name='$name' onchange='this.form.submit();'>";
449 echo "<select name='$name'>";
451 $company_year = get_company_pref('f_year');
453 $sql = "SELECT * FROM ".TB_PREF."fiscal_year ORDER BY begin";
454 $result = db_query($sql);
456 if ($selected_id == null)
457 $selected_id = (!isset($_POST[$name]) ? "" : $_POST[$name]);
458 while ($row = db_fetch_row($result))
460 // default to the company current fiscal year
461 if ($selected_id == "" && ($row[0] == $company_year))
463 $selected_id = $row[0];
464 $_POST[$name] = $selected_id;
467 if ($selected_id == $row[0])
469 echo "<option selected value='" . $row[0] . "'>";
473 echo "<option value='" . $row[0] . "'>";
479 $row[1] = sql2date($row[1]);
480 $row[2] = sql2date($row[2]);
481 echo $row[1] . " - " . $row[2] . " " . $how . "</option>\n";
485 db_free_result($result);
488 function fiscalyears_list_cells($label, $name, $selected_id)
491 echo "<td>$label</td>\n";
493 fiscalyears_list($name, $selected_id);
497 function fiscalyears_list_row($label, $name, $selected_id)
500 fiscalyears_list_cells($label, $name, $selected_id);
504 //---------------------------------------------------------------------------------------------------
506 function simple_codeandname_list($sql, $name, &$selected_id,
507 $all_option=false, $all_option_name=null, $all_option_numeric=false,
508 $submit_on_change=false, $returnzero=false)
512 if ($submit_on_change == true)
513 echo "<select name='$name' onchange='this.form.submit();'>";
515 echo "<select name='$name'>";
517 if ($selected_id == null)
518 $selected_id = (!isset($_POST[$name]) ? "" : $_POST[$name]);
519 if ($all_option == true)
523 elseif ($all_option_numeric)
524 $reserved_word = reserved_words::get_all_numeric();
526 $reserved_word = $all_items;
528 if ($selected_id == $reserved_word)
530 echo "<option selected value='$reserved_word'>$all_option_name</option>\n";
534 echo "<option value='$reserved_word'>$all_option_name</option>\n";
536 if ($selected_id == "")
538 $selected_id = $reserved_word;
542 $result = db_query($sql);
544 while ($row = db_fetch_row($result))
546 if ($selected_id == $row[0])
548 echo "<option selected value='" . $row[0] . "'>";
550 echo "<option value='" . $row[0] . "'>";
552 echo $row[1] . "</option>\n";
554 if (!$returnzero && $selected_id == "")
556 $selected_id = $row[0];
557 $_POST[$name] = $selected_id;
562 db_free_result($result);
565 //------------------------------------------------------------------------------------
567 function dimensions_list($name, &$selected_id, $no_option=false, $showname=null,
568 $submit_on_change=false, $showclosed=false, $showtype=1)
570 $sql = "SELECT id, CONCAT(reference,' ',name) FROM ".TB_PREF."dimensions";
571 if ($showclosed || $showtype)
576 if ($showclosed && $showtype)
577 $sql .= " AND type_=$showtype";
579 $sql .= " type_=$showtype";
581 $sql .= " ORDER BY reference";
582 simple_codeandname_list($sql, $name, $selected_id, $no_option, $showname,
583 true, $submit_on_change, true);
586 function dimensions_list_cells($label, $name, $selected_id, $no_option=false, $showname=null,
587 $showclosed=false, $showtype=0)
590 echo "<td>$label</td>\n";
592 dimensions_list($name, $selected_id, $no_option, $showname, false, $showclosed, $showtype);
596 function dimensions_list_row($label, $name, $selected_id, $no_option=false, $showname=null,
597 $showclosed=false, $showtype=0)
600 dimensions_list_cells($label, $name, $selected_id, $no_option, $showname,
601 $showclosed, $showtype);
605 //---------------------------------------------------------------------------------------------------
607 function stock_items_list($name, $selected_id, $all_option=false, $submit_on_change=false, $extra="")
611 if ($selected_id == null)
612 $selected_id = (!isset($_POST[$name]) ? "" : $_POST[$name]);
613 $no_item_list = get_company_pref('no_item_list');
616 global $search_button;
617 $edit_name = $name."_edit";
618 $edit_button = $name."_button";
620 $val = (isset($_POST[$edit_name]) && $_POST[$edit_name] != "" ? $_POST[$edit_name] : "");
622 if (isset($_POST[$edit_button]))
624 $selected_id = $_POST[$name] = "";
627 if ($selected_id != "")
630 $sql = "SELECT stock_id, ".TB_PREF."stock_master.description, ".TB_PREF."stock_category.description
631 FROM ".TB_PREF."stock_master,".TB_PREF."stock_category WHERE ".TB_PREF."stock_master.category_id=".TB_PREF."stock_category.category_id
632 AND stock_id='$selected_id'";
633 $result = db_query($sql);
637 if ($val != "" && $val != DEFVAL)
639 $sql = "SELECT stock_id, ".TB_PREF."stock_master.description, ".TB_PREF."stock_category.description
640 FROM ".TB_PREF."stock_master,".TB_PREF."stock_category WHERE "
641 .TB_PREF."stock_master.category_id=".TB_PREF."stock_category.category_id AND
642 (stock_id LIKE '%{$val}%' OR ".TB_PREF."stock_category.description LIKE '%{$val}%' OR "
643 .TB_PREF."stock_master.description LIKE '%{$val}%')";
644 $result = db_query($sql);
650 echo "<input type='text' name='$edit_name' size='8' maxlength='50' value='$val' onblur='this.form.$edit_button.click();'> ";
652 echo sprintf($search_button, $edit_button);
656 $sql = "SELECT stock_id, ".TB_PREF."stock_master.description, ".TB_PREF."stock_category.description
657 FROM ".TB_PREF."stock_master,".TB_PREF."stock_category WHERE ".TB_PREF."stock_master.category_id=".TB_PREF."stock_category.category_id";
658 $result = db_query($sql);
661 if ($submit_on_change==true)
662 echo "<select name='$name' onchange='this.form.submit();'>";
663 else if ($extra != "")
664 echo "<select name='$name' $extra>";
666 echo "<select name='$name'>";
668 if (($all_option == true))
670 if ($selected_id == $all_items)
672 echo "<option selected value='$all_items'>" . _("All Items") . "</option>\n";
676 echo "<option value='$all_items'>" . _("All Items") . "</option>\n";
678 if ($selected_id == "")
680 $selected_id = $all_items;
684 while ($row = db_fetch_row($result))
686 if ($selected_id == $row[0])
688 echo "<option selected value='" . $row[0] . "'>";
692 echo "<option value='" . $row[0] . "'>";
694 echo (user_show_codes()?$row[0] . " - ":"") . $row[2] . " - " . $row[1] . "</option>\n";
696 // if no initial selection - set the first item
697 // do we want to do this for all lists ???? probably
698 if ($selected_id == "")
700 $selected_id = $row[0];
701 $_POST[$name] = $selected_id;
705 db_free_result($result);
708 function stock_items_list_cells($label, $name, $selected_id, $all_option=false, $submit_on_change=false, $extra="")
711 echo "<td>$label</td>\n";
713 stock_items_list($name, $selected_id, $all_option, $submit_on_change, $extra);
717 function stock_items_list_row($label, $name, $selected_id, $all_option=false, $submit_on_change=false)
720 stock_items_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
724 //------------------------------------------------------------------------------------
726 function stock_bom_items_list($name, $selected_id, $all_option=false, $submit_on_change=false)
730 if ($submit_on_change==true)
731 echo "<select name='$name' onchange='this.form.submit();'>";
733 echo "<select name='$name'>";
735 $sql = "SELECT stock_id, ".TB_PREF."stock_master.description, ".TB_PREF."stock_category.description
736 FROM ".TB_PREF."stock_master,".TB_PREF."stock_category WHERE ".TB_PREF."stock_master.category_id=".TB_PREF."stock_category.category_id
737 AND (".TB_PREF."stock_master.mb_flag='M' OR ".TB_PREF."stock_master.mb_flag='K')";
738 $result = db_query($sql);
740 if ($selected_id == null)
741 $selected_id = (!isset($_POST[$name]) ? "" : $_POST[$name]);
742 if (($all_option == true))
744 if ($selected_id == $all_items)
746 echo "<option selected value='$all_items'>" . _("All Items") . "</option>\n";
750 echo "<option value='$all_items'>" . _("All Items") . "</option>\n";
752 if ($selected_id == "")
754 $selected_id = $all_items;
758 while ($row = db_fetch_row($result))
760 if ($selected_id==$row[0])
762 echo "<option selected value='" . $row[0] . "'>";
766 echo "<option value='" . $row[0] . "'>";
768 echo (user_show_codes()?$row[0] . " - ":"") . $row[2] . " - " . $row[1] . "</option>\n";
770 if ($selected_id == "")
772 $selected_id = $row[0];
773 $_POST[$name] = $selected_id;
778 db_free_result($result);
781 function stock_bom_items_list_cells($label, $name, $selected_id, $all_option=false, $submit_on_change=false)
784 echo "<td>$label</td>\n";
786 stock_bom_items_list($name, $selected_id, $all_option, $submit_on_change);
790 function stock_bom_items_list_row($label, $name, $selected_id, $all_option=false, $submit_on_change=false)
793 stock_bom_items_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
797 //------------------------------------------------------------------------------------
799 function base_stock_items_list($sql, $name, &$selected_id,
800 $all_option=false, $all_option_name="", $submit_on_change=false, $extra="")
804 if ($submit_on_change==true)
805 echo "<select name='$name' onchange='this.form.submit();'>";
806 else if ($extra != "")
807 echo "<select name='$name' $extra>";
809 echo "<select name='$name'>";
811 $result = db_query($sql);
813 if ($selected_id == null)
814 $selected_id = (!isset($_POST[$name]) ? "" : $_POST[$name]);
815 if ($all_option == true)
817 if ($selected_id == $all_items)
819 echo "<option selected value='$all_items'>$all_option_name</option>\n";
823 echo "<option value='$all_items'>$all_option_name</option>\n";
825 if ($selected_id == "")
827 $selected_id = $all_items;
831 while ($row = db_fetch_row($result))
833 if ($selected_id == $row[0])
835 echo "<option selected value='" . $row[0] . "'>";
839 echo "<option value='" . $row[0] . "'>";
841 echo (user_show_codes()?$row[0] . " - ":"") . $row[2] . " - " . $row[1] . "</option>\n";
843 if ($selected_id == "")
845 $selected_id = $row[0];
846 $_POST[$name] = $selected_id;
851 db_free_result($result);
854 //------------------------------------------------------------------------------------
856 function stock_manufactured_items_list($name, &$selected_id,
857 $all_option=false, $submit_on_change=false)
859 $sql = "SELECT stock_id, ".TB_PREF."stock_master.description, ".TB_PREF."stock_category.description
860 FROM ".TB_PREF."stock_master,".TB_PREF."stock_category WHERE ".TB_PREF."stock_master.category_id=".TB_PREF."stock_category.category_id
861 AND (".TB_PREF."stock_master.mb_flag='M')";
863 base_stock_items_list($sql, $name, $selected_id, $all_option, _("All Items"),
867 function stock_manufactured_items_list_cells($label, $name, $selected_id, $all_option=false, $submit_on_change=false)
870 echo "<td>$label</td>\n";
872 stock_manufactured_items_list($name, $selected_id, $all_option, $submit_on_change);
876 function stock_manufactured_items_list_row($label, $name, $selected_id, $all_option=false, $submit_on_change=false)
879 stock_manufactured_items_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
883 //------------------------------------------------------------------------------------
885 function stock_component_items_list($name, $parent_stock_id, &$selected_id,
886 $all_option=false, $submit_on_change=false)
888 $sql = "SELECT stock_id, ".TB_PREF."stock_master.description, ".TB_PREF."stock_category.description
889 FROM ".TB_PREF."stock_master,".TB_PREF."stock_category WHERE
890 ".TB_PREF."stock_master.category_id=".TB_PREF."stock_category.category_id
891 AND stock_id != '$parent_stock_id'";
893 base_stock_items_list($sql, $name, $selected_id,
894 $all_option, _("All Items"), $submit_on_change);
897 //------------------------------------------------------------------------------------
899 function stock_purchasable_items_list($name, &$selected_id, $all_option=false, $submit_on_change=false, $extra="")
903 if ($selected_id == null)
904 $selected_id = (!isset($_POST[$name]) ? "" : $_POST[$name]);
905 $no_item_list = get_company_pref('no_item_list');
908 $edit_name = $name."_edit";
909 $edit_button = $name."_button";
911 $val = (isset($_POST[$edit_name]) && $_POST[$edit_name] != "" ? $_POST[$edit_name] : "");
912 if (isset($_POST[$edit_button]))
914 $selected_id = $_POST[$name] = "";
917 if ($selected_id != "")
920 $sql = "SELECT stock_id, ".TB_PREF."stock_master.description, ".TB_PREF."stock_category.description
921 FROM ".TB_PREF."stock_master,".TB_PREF."stock_category WHERE ".TB_PREF."stock_master.category_id=".TB_PREF."stock_category.category_id
922 AND mb_flag !='M' AND stock_id='$selected_id'";
923 $result = db_query($sql);
927 if ($val != "" && $val != DEFVAL)
929 $sql = "SELECT stock_id, ".TB_PREF."stock_master.description, ".TB_PREF."stock_category.description
930 FROM ".TB_PREF."stock_master,".TB_PREF."stock_category WHERE "
931 .TB_PREF."stock_master.category_id=".TB_PREF."stock_category.category_id AND mb_flag !='M' AND
932 (stock_id LIKE '%{$val}%' OR ".TB_PREF."stock_category.description LIKE '%{$val}%' OR "
933 .TB_PREF."stock_master.description LIKE '%{$val}%')";
934 $result = db_query($sql);
940 echo "<input type='text' name='$edit_name' size='8' maxlength='50' value='$val' > ";
942 echo "<input type='submit' class='inputsubmit' name='$edit_button' value='?'> ";
946 $sql = "SELECT stock_id, ".TB_PREF."stock_master.description, ".TB_PREF."stock_category.description
947 FROM ".TB_PREF."stock_master,".TB_PREF."stock_category WHERE ".TB_PREF."stock_master.category_id="
948 .TB_PREF."stock_category.category_id AND mb_flag !='M'";
949 $result = db_query($sql);
952 if ($submit_on_change==true)
953 echo "<select name='$name' onchange='this.form.submit();'>";
954 else if ($extra != "")
955 echo "<select name='$name' $extra>";
957 echo "<select name='$name'>";
959 if ($all_option == true)
961 if ($selected_id == $all_items)
963 echo "<option selected value='$all_items'>"._("All Items")."</option>\n";
967 echo "<option value='$all_items'>"._("All Items")."</option>\n";
969 if ($selected_id == "")
971 $selected_id = $all_items;
975 while ($row = db_fetch_row($result))
977 if ($selected_id == $row[0])
979 echo "<option selected value='" . $row[0] . "'>";
983 echo "<option value='" . $row[0] . "'>";
985 echo (user_show_codes()?$row[0] . " - ":"") . $row[2] . " - " . $row[1] . "</option>\n";
987 if ($selected_id == "")
989 $selected_id = $row[0];
990 $_POST[$name] = $selected_id;
995 db_free_result($result);
998 function stock_purchasable_items_list_cells($label, $name, &$selected_id, $all_option=false, $submit_on_change=false, $extra = "")
1001 echo "<td>$label</td>\n";
1003 stock_purchasable_items_list($name, $selected_id, $all_option, $submit_on_change, $extra);
1007 function stock_purchasable_items_list_row($label, $name, &$selected_id, $all_option=false, $submit_on_change=false)
1010 stock_purchasable_items_list_cells($label, $name, $selected_id, $all_option, $submit_on_change);
1014 //------------------------------------------------------------------------------------
1016 function stock_costable_items_list($name, &$selected_id,
1017 $all_option=false, $submit_on_change=false)
1019 $sql = "SELECT stock_id, ".TB_PREF."stock_master.description, ".TB_PREF."stock_category.description
1020 FROM ".TB_PREF."stock_master,".TB_PREF."stock_category WHERE ".TB_PREF."stock_master.category_id=".TB_PREF."stock_category.category_id
1023 base_stock_items_list($sql, $name, $selected_id,
1024 $all_option, _("All Items"), $submit_on_change);
1027 //------------------------------------------------------------------------------------
1029 function stock_item_types_list_row($label, $name, $selected_id, $enabled=true)
1033 echo "<td>$label</td>\n";
1036 echo "<select name='$name' onchange='this.form.submit();'>\n";
1038 echo "<select disabled name='$name'>\n";
1039 if ($selected_id == null)
1040 $selected_id = (!isset($_POST[$name]) ? "" : $_POST[$name]);
1041 if ($selected_id == "")
1042 $_POST[$name] = $selected_id = "B";
1043 echo "<option " . ($selected_id == 'M'?" selected ":"") . " value='M'>" . _("Manufactured"). "</option>\n";
1044 echo "<option " . ($selected_id == 'B'?" selected ":"") . " value='B'>" . _("Purchased"). "</option>\n";
1045 echo "<option " . ($selected_id == 'D'?" selected ":"") . " value='D'>" . _("Service"). "</option>\n";
1046 echo "</select></td></tr>\n";
1049 function stock_units_list_row($label, $name, $value, $enabled=true)
1051 global $stock_units;
1053 echo "<tr><td>$label</td>\n";
1055 echo "<td><select name='$name'>";
1057 echo "<td><select disabled name='$name'>";
1060 $value = (!isset($_POST[$name]) ? "" : $_POST[$name]);
1061 foreach ($stock_units as $unit)
1064 $_POST[$name] = $value = $unit;
1067 echo "<option selected value='$unit'>$unit</option>\n";
1071 echo "<option value='$unit'>$unit</option>\n";
1074 echo "</select></td></tr>\n";
1077 //------------------------------------------------------------------------------------
1079 function tax_types_list($name, $selected_id,
1080 $none_option=false, $none_option_name=null, $submit_on_change=false)
1082 simple_codeandname_list("SELECT id, name FROM ".TB_PREF."tax_types",
1083 $name, $selected_id, $none_option, $none_option_name, true, $submit_on_change);
1086 function tax_types_list_cells($label, $name, $selected_id, $none_option=false,
1087 $none_option_name=null, $submit_on_change=false)
1090 echo "<td>$label</td>\n";
1092 tax_types_list($name, $selected_id, $none_option, $none_option_name, $submit_on_change);
1096 function tax_types_list_row($label, $name, $selected_id, $none_option=false,
1097 $none_option_name=null, $submit_on_change=false)
1100 tax_types_list_cells($label, $name, $selected_id, $none_option, $none_option_name, $submit_on_change);
1104 //------------------------------------------------------------------------------------
1106 function tax_groups_list($name, $selected_id,
1107 $none_option=false, $none_option_name=null, $submit_on_change=false)
1109 simple_codeandname_list("SELECT id, name FROM ".TB_PREF."tax_groups ORDER BY id",
1110 $name, $selected_id, $none_option, $none_option_name, true, $submit_on_change);
1113 function tax_groups_list_cells($label, $name, $selected_id, $submit_on_change=false)
1116 echo "<td>$label</td>\n";
1118 tax_groups_list($name, $selected_id, false, null, $submit_on_change);
1122 function tax_groups_list_row($label, $name, $selected_id, $submit_on_change=false)
1125 tax_groups_list_cells($label, $name, $selected_id, false, null, $submit_on_change);
1129 //------------------------------------------------------------------------------------
1131 function item_tax_types_list($name, $selected_id)
1133 simple_codeandname_list("SELECT id, name FROM ".TB_PREF."item_tax_types ORDER BY id",
1134 $name, $selected_id);
1137 function item_tax_types_list_cells($label, $name, $selected_id)
1140 echo "<td>$label</td>\n";
1142 item_tax_types_list($name, $selected_id);
1146 function item_tax_types_list_row($label, $name, $selected_id)
1149 item_tax_types_list_cells($label, $name, $selected_id);
1153 //------------------------------------------------------------------------------------
1155 function shippers_list($name, $selected_id)
1157 simple_codeandname_list("SELECT shipper_id, shipper_name FROM ".TB_PREF."shippers",
1158 $name, $selected_id);
1161 function shippers_list_cells($label, $name, $selected_id)
1164 echo "<td>$label</td>\n";
1166 shippers_list($name, $selected_id);
1170 function shippers_list_row($label, $name, $selected_id)
1173 shippers_list_cells($label, $name, $selected_id);
1177 //-------------------------------------------------------------------------------------
1179 function sales_persons_list($name, $selected_id)
1181 simple_codeandname_list("SELECT salesman_code, salesman_name FROM ".TB_PREF."salesman",
1182 $name, $selected_id);
1185 function sales_persons_list_cells($label, $name, $selected_id)
1188 echo "<td>$label</td>\n";
1190 sales_persons_list($name, $selected_id);
1194 function sales_persons_list_row($label, $name, $selected_id)
1197 sales_persons_list_cells($label, $name, $selected_id);
1201 //------------------------------------------------------------------------------------
1203 function sales_areas_list($name, $selected_id)
1205 simple_codeandname_list("SELECT area_code, description FROM ".TB_PREF."areas",
1206 $name, $selected_id);
1209 function sales_areas_list_cells($label, $name, $selected_id)
1212 echo "<td>$label</td>\n";
1214 sales_areas_list($name, $selected_id);
1218 function sales_areas_list_row($label, $name, $selected_id)
1221 sales_areas_list_cells($label, $name, $selected_id);
1225 //------------------------------------------------------------------------------------
1227 function workorders_list($name, $selected_id)
1229 simple_codeandname_list("SELECT id, wo_ref FROM ".TB_PREF."workorders WHERE closed=0",
1230 $name, $selected_id);
1233 function workorders_list_cells($label, $name, $selected_id)
1236 echo "<td>$label</td>\n";
1238 workorders_list($name, $selected_id);
1242 function workorders_list_row($label, $name, $selected_id)
1245 workorders_list_cells($label, $name, $selected_id);
1249 //------------------------------------------------------------------------------------
1251 function payment_terms_list($name, $selected_id)
1253 simple_codeandname_list("SELECT terms_indicator, terms FROM ".TB_PREF."payment_terms",
1254 $name, $selected_id);
1257 function payment_terms_list_cells($label, $name, $selected_id)
1260 echo "<td>$label</td>\n";
1262 payment_terms_list($name, $selected_id);
1266 function payment_terms_list_row($label, $name, $selected_id)
1269 payment_terms_list_cells($label, $name, $selected_id);
1273 //------------------------------------------------------------------------------------
1275 function credit_status_list($name, $selected_id)
1277 simple_codeandname_list("SELECT id, reason_description FROM ".TB_PREF."credit_status",
1278 $name, $selected_id);
1281 function credit_status_list_cells($label, $name, $selected_id)
1284 echo "<td>$label</td>\n";
1286 credit_status_list($name, $selected_id);
1290 function credit_status_list_row($label, $name, $selected_id)
1293 credit_status_list_cells($label, $name, $selected_id);
1297 //-----------------------------------------------------------------------------------------------
1299 function sales_types_list($name, $selected_id)
1301 simple_codeandname_list("SELECT id, sales_type FROM ".TB_PREF."sales_types",
1302 $name, $selected_id);
1305 function sales_types_list_cells($label, $name, $selected_id)
1308 echo "<td>$label</td>\n";
1310 sales_types_list($name, $selected_id);
1314 function sales_types_list_row($label, $name, $selected_id)
1317 sales_types_list_cells($label, $name, $selected_id);
1321 //-----------------------------------------------------------------------------------------------
1323 function movement_types_list($name, $selected_id)
1325 simple_codeandname_list("SELECT id, name FROM ".TB_PREF."movement_types",
1326 $name, $selected_id);
1329 function movement_types_list_cells($label, $name, $selected_id)
1332 echo "<td>$label</td>\n";
1334 movement_types_list($name, $selected_id);
1338 function movement_types_list_row($label, $name, $selected_id)
1341 movement_types_list_cells($label, $name, $selected_id);
1345 //-----------------------------------------------------------------------------------------------
1347 function bank_trans_types_list($name, $selected_id)
1349 simple_codeandname_list("SELECT id, name FROM ".TB_PREF."bank_trans_types",
1350 $name, $selected_id);
1353 function bank_trans_types_list_cells($label, $name, $selected_id)
1356 echo "<td>$label</td>\n";
1358 bank_trans_types_list($name, $selected_id);
1362 function bank_trans_types_list_row($label, $name, $selected_id)
1365 bank_trans_types_list_cells($label, $name, $selected_id);
1369 //-----------------------------------------------------------------------------------------------
1371 function workcenter_list($name, $selected_id, $all_option=false)
1374 echo "<select name='$name'>";
1376 $sql = "SELECT id, name FROM ".TB_PREF."workcentres";
1377 $result = db_query($sql);
1379 if ($selected_id == null)
1380 $selected_id = (!isset($_POST[$name]) ? "" : $_POST[$name]);
1381 if ($all_option == true)
1383 if ($selected_id == $all_items)
1385 echo "<option selected value='$all_items'>" . _("All Work Centres") . "</option>\n";
1389 echo "<option value='$all_items'>" . _("All Work Centres") . "</option>\n";
1393 while ($row = db_fetch_row($result))
1395 if ($selected_id == $row[0])
1397 echo "<option selected value='" . $row[0] . "'>";
1401 echo "<option value='" . $row[0] . "'>";
1403 echo $row[1] . "</option>\n";
1407 db_free_result($result);
1410 function workcenter_list_cells($label, $name, $selected_id, $all_option=false)
1413 echo "<td>$label</td>\n";
1415 workcenter_list($name, $selected_id, $all_option);
1419 function workcenter_list_row($label, $name, $selected_id, $all_option=false)
1422 workcenter_list_cells($label, $name, $selected_id, $all_option);
1426 //-----------------------------------------------------------------------------------------------
1428 function bank_accounts_list($name, $selected_id, $submit_on_change=false)
1430 if ($submit_on_change==true)
1431 echo "<select name='$name' onchange='this.form.submit();'>";
1433 echo "<select name='$name'>";
1435 $company_currency = get_company_currency();
1437 $sql = "SELECT ".TB_PREF."bank_accounts.account_code, bank_account_name, bank_curr_code
1438 FROM ".TB_PREF."bank_accounts, ".TB_PREF."chart_master
1439 WHERE ".TB_PREF."bank_accounts.account_code=".TB_PREF."chart_master.account_code";
1440 $result = db_query($sql);
1442 if ($selected_id == null)
1443 $selected_id = (!isset($_POST[$name]) ? "" : $_POST[$name]);
1444 while ($row = db_fetch_row($result))
1446 if ($selected_id == $row[0])
1448 echo "<option selected value='" . $row[0] . "'>";
1452 echo "<option value='" . $row[0] . "'>";
1455 if ($company_currency != $row[2])
1456 echo " - " . $row[2];
1458 if ($selected_id == "")
1460 $selected_id = $row[0];
1461 $_POST[$name] = $selected_id;
1466 db_free_result($result);
1469 function bank_accounts_list_cells($label, $name, $selected_id, $submit_on_change=false)
1472 echo "<td>$label</td>\n";
1474 bank_accounts_list($name, $selected_id, $submit_on_change);
1478 function bank_accounts_list_row($label, $name, $selected_id, $submit_on_change=false)
1481 bank_accounts_list_cells($label, $name, $selected_id, $submit_on_change);
1485 //-----------------------------------------------------------------------------------------------
1487 function class_list($name, $selected_id, $submit_on_change=false)
1489 if ($submit_on_change==true)
1490 echo "<select name='$name' onchange='this.form.submit();'>";
1492 echo "<select name='$name'>";
1494 $sql = "SELECT cid, class_name FROM ".TB_PREF."chart_class";
1495 $result = db_query($sql);
1497 if ($selected_id == null)
1498 $selected_id = (!isset($_POST[$name]) ? "" : $_POST[$name]);
1499 while ($row = db_fetch_row($result))
1501 if ($selected_id == $row[0])
1503 echo "<option selected value='" . $row[0] . "'>";
1507 echo "<option value='" . $row[0] . "'>";
1509 echo $row[1] . "</option>\n";
1510 if ($selected_id == "")
1512 $selected_id = $row[0];
1513 $_POST[$name] = $selected_id;
1518 db_free_result($result);
1521 function class_list_cells($label, $name, $selected_id, $submit_on_change=false)
1524 echo "<td>$label</td>\n";
1526 class_list($name, $selected_id, $submit_on_change);
1530 function class_list_row($label, $name, $selected_id, $submit_on_change=false)
1533 class_list_cells($label, $name, $selected_id, $submit_on_change);
1537 //-----------------------------------------------------------------------------------------------
1539 function stock_categories_list($name, $selected_id)
1541 simple_codeandname_list("SELECT category_id, description FROM ".TB_PREF."stock_category
1542 ORDER BY category_id", $name, $selected_id);
1545 function stock_categories_list_cells($label, $name, $selected_id)
1548 echo "<td>$label</td>\n";
1550 stock_categories_list($name, $selected_id);
1554 function stock_categories_list_row($label, $name, $selected_id)
1557 stock_categories_list_cells($label, $name, $selected_id);
1561 //-----------------------------------------------------------------------------------------------
1563 function gl_account_types_list($name, $selected_id, $all_option, $all_option_name,
1564 $all_option_numeric)
1566 simple_codeandname_list("SELECT id, name FROM ".TB_PREF."chart_types ORDER BY id",
1567 $name, $selected_id, $all_option, $all_option_name, $all_option_numeric);
1570 function gl_account_types_list_cells($label, $name, $selected_id, $all_option=false, $all_option_name=null,
1571 $all_option_numeric=false)
1574 echo "<td>$label</td>\n";
1576 gl_account_types_list($name, $selected_id, $all_option, $all_option_name, $all_option_numeric);
1580 function gl_account_types_list_row($label, $name, $selected_id, $all_option=false, $all_option_name=null,
1581 $all_option_numeric=false)
1584 gl_account_types_list_cells($label, $name, $selected_id, $all_option,
1585 $all_option_name, $all_option_numeric);
1589 //-----------------------------------------------------------------------------------------------
1591 function gl_all_accounts_list($name, $selected_id, $skip_bank_accounts=false,
1592 $show_group=false, $onchange="")
1594 echo "<select name='$name'";
1595 if ($onchange != "")
1596 echo " onchange='$onchange'";
1599 if ($skip_bank_accounts)
1600 $sql = "SELECT ".TB_PREF."chart_master.account_code, ".TB_PREF."chart_master.account_name, ".TB_PREF."chart_types.name
1601 FROM (".TB_PREF."chart_master,".TB_PREF."chart_types) LEFT JOIN ".TB_PREF."bank_accounts ON ".TB_PREF."chart_master.account_code=".TB_PREF."bank_accounts.account_code
1602 WHERE ".TB_PREF."bank_accounts.account_code IS NULL
1603 AND ".TB_PREF."chart_master.account_type=".TB_PREF."chart_types.id
1604 ORDER BY account_code;";
1606 $sql = "SELECT account_code, account_name,".TB_PREF."chart_types.name
1607 FROM ".TB_PREF."chart_master, ".TB_PREF."chart_types
1608 WHERE ".TB_PREF."chart_master.account_type=".TB_PREF."chart_types.id
1609 ORDER BY account_code";
1611 if ($selected_id == null)
1612 $selected_id = (!isset($_POST[$name]) ? "" : $_POST[$name]);
1613 $result = db_query($sql, "query chart master");
1615 while ($row = db_fetch_row($result))
1617 if ($selected_id == $row[0])
1619 echo "<option selected value='" . $row[0] . "'>";
1623 echo "<option value='" . $row[0] . "'>";
1625 //echo str_pad($row[0],6,'0', STR_PAD_LEFT) . " " . $row[2] . " " . $row[1];
1627 echo $row[0] . " " . $row[2] . " " . $row[1] . "</option>\n";
1629 echo $row[0] . " " . $row[1] . "</option>\n";
1631 if ($selected_id == "")
1633 $selected_id = $row[0];
1634 $_POST[$name] = $selected_id;
1639 db_free_result($result);
1642 function gl_all_accounts_list_cells($label, $name, $selected_id, $skip_bank_accounts=false,
1643 $show_group=false, $onchange="")
1646 echo "<td>$label</td>\n";
1648 gl_all_accounts_list($name, $selected_id, $skip_bank_accounts, $show_group, $onchange);
1652 function gl_all_accounts_list_row($label, $name, $selected_id, $skip_bank_accounts=false,
1653 $show_group=false, $onchange="")
1656 gl_all_accounts_list_cells($label, $name, $selected_id, $skip_bank_accounts,
1657 $show_group, $onchange);
1661 function yesno_list($name, $selected_id, $name_yes="", $name_no="", $submit_on_change=false)
1663 if ($submit_on_change == true)
1664 echo "<select name='$name' onchange='this.form.submit();'>";
1666 echo "<select name='$name'>";
1668 if (strlen($name_yes) == 0)
1672 if (strlen($name_no) == 0)
1677 if ($selected_id == null)
1678 $selected_id = (!isset($_POST[$name]) ? 0 : $_POST[$name]);
1679 if ($selected_id == 0)
1680 echo "<option value=1>";
1682 echo "<option selected value=1>";
1683 if (!isset($name_yes))
1684 echo _("Yes") . "</option>\n";
1686 echo $name_yes . "</option>\n";
1687 if ($selected_id == 0)
1688 echo "<option selected value=0>";
1690 echo "<option value=0>";
1691 if (!isset($name_no))
1692 echo _("No") . "</option>\n";
1694 echo $name_no . "</option>\n";
1698 function yesno_list_cells($label, $name, $selected_id, $name_yes="", $name_no="", $submit_on_change=false)
1701 echo "<td>$label</td>\n";
1703 yesno_list($name, $selected_id, $name_yes, $name_no, $submit_on_change);
1707 function yesno_list_row($label, $name, $selected_id, $name_yes="", $name_no="", $submit_on_change=false)
1710 yesno_list_cells($label, $name, $selected_id, $name_yes, $name_no, $submit_on_change);
1714 //------------------------------------------------------------------------------------------------
1716 function languages_list($name, &$selected_id)
1718 global $installed_languages;
1720 echo "<select name='$name'>";
1722 if ($selected_id == null)
1723 $selected_id = (!isset($_POST[$name]) ? "" : $_POST[$name]);
1724 foreach ($installed_languages as $lang)
1727 if ($selected_id == $lang['code'])
1729 echo "value='" . $lang['code'] . "'>" . $lang['name'] . "</option>\n";
1733 function languages_list_cells($label, $name, $selected_id)
1736 echo "<td>$label</td>\n";
1738 languages_list($name, $selected_id);
1742 function languages_list_row($label, $name, $selected_id)
1745 languages_list_cells($label, $name, $selected_id);
1749 //------------------------------------------------------------------------------------------------
1751 function bank_account_types_list($name, &$selected_id)
1753 $bank_account_types = bank_account_types::get_all();
1755 echo "<select name='$name'>";
1757 if ($selected_id == null)
1758 $selected_id = (!isset($_POST[$name]) ? "" : $_POST[$name]);
1759 foreach ($bank_account_types as $type)
1762 if ($selected_id == "" || $selected_id == $type['id'])
1764 echo "value='" . $type['id'] . "'>" . $type['name'] . "</option>\n";
1768 function bank_account_types_list_cells($label, $name, $selected_id)
1771 echo "<td>$label</td>\n";
1773 bank_account_types_list($name, $selected_id);
1777 function bank_account_types_list_row($label, $name, $selected_id)
1780 bank_account_types_list_cells($label, $name, $selected_id);
1784 //------------------------------------------------------------------------------------------------
1786 function payment_person_types_list($name, $selected_id, $related=null)
1788 $types = payment_person_types::get_all();
1790 echo "<select name='$name'";
1792 echo " onchange='this.form.$related.value=\"\"; this.form.submit();' ";
1795 if ($selected_id == null)
1796 $selected_id = (!isset($_POST[$name]) ? "" : $_POST[$name]);
1797 foreach ($types as $type)
1799 if (payment_person_types::has_items($type['id']))
1801 if ($selected_id == "")
1802 $_POST[$name] = $selected_id = $type['id'];
1804 if ($selected_id == $type['id'])
1806 echo "value='" . $type['id'] . "'>" . $type['name'] . "</option>\n";
1811 function payment_person_types_list_cells($label, $name, $selected_id, $related=null)
1814 echo "<td>$label</td>\n";
1816 payment_person_types_list($name, $selected_id, $related);
1820 function payment_person_types_list_row($label, $name, $selected_id, $related=null)
1823 payment_person_types_list_cells($label, $name, $selected_id, $related);
1827 //------------------------------------------------------------------------------------------------
1829 function wo_types_list($name, &$selected_id)
1831 $types = wo_types::get_all();
1833 echo "<select name='$name' onchange='this.form.submit();'>";
1835 if ($selected_id == null)
1836 $selected_id = (!isset($_POST[$name]) ? "" : $_POST[$name]);
1837 foreach ($types as $type)
1840 if ($selected_id == $type['id'])
1842 echo "value='" . $type['id'] . "'>" . $type['name'] . "</option>\n";
1847 function wo_types_list_row($label, $name, &$selected_id)
1849 echo "<tr><td>$label</td><td>\n";
1850 wo_types_list($name, $selected_id);
1851 echo "</td></tr>\n";
1854 //------------------------------------------------------------------------------------------------
1856 function dateformats_list_row($label, $name, $value)
1858 global $dateformats;
1860 echo "<tr><td>$label</td>\n";
1861 echo "<td><select name='$name'>";
1864 $value = (!isset($_POST[$name]) ? 0 : $_POST[$name]);
1866 foreach ($dateformats as $df)
1869 if ($value==$counter)
1871 echo "<option selected value='$counter'>$df</option>\n";
1875 echo "<option value='$counter'>$df</option>\n";
1879 echo "</select></td></tr>\n";
1882 function dateseps_list_row($label, $name, $value)
1886 echo "<tr><td>$label</td>\n";
1887 echo "<td><select name='$name'>";
1890 $value = (!isset($_POST[$name]) ? 0 : $_POST[$name]);
1892 foreach ($dateseps as $ds)
1895 if ($value==$counter)
1897 echo "<option selected value='$counter'>$ds</option>\n";
1901 echo "<option value='$counter'>$ds</option>\n";
1905 echo "</select></td></tr>\n";
1908 function thoseps_list_row($label, $name, $value)
1912 echo "<tr><td>$label</td>\n";
1913 echo "<td><select name='$name'>";
1916 $value = (!isset($_POST[$name]) ? 0 : $_POST[$name]);
1918 foreach ($thoseps as $ts)
1921 if ($value==$counter)
1923 echo "<option selected value='$counter'>$ts</option>\n";
1927 echo "<option value='$counter'>$ts</option>\n";
1931 echo "</select></td></tr>\n";
1934 function decseps_list_row($label, $name, $value)
1938 echo "<tr><td>$label</td>\n";
1939 echo "<td><select name='$name'>";
1942 $value = (!isset($_POST[$name]) ? 0 : $_POST[$name]);
1944 foreach ($decseps as $ds)
1947 if ($value==$counter)
1949 echo "<option selected value='$counter'>$ds</option>\n";
1953 echo "<option value='$counter'>$ds</option>\n";
1957 echo "</select></td></tr>\n";
1960 function themes_list_row($label, $name, $value)
1964 echo "<tr><td>$label</td>\n";
1965 echo "<td><select name='$name'>";
1968 $value = (!isset($_POST[$name]) ? "" : $_POST[$name]);
1969 foreach ($themes as $th)
1974 echo "<option selected value='$th'>$th</option>\n";
1978 echo "<option value='$th'>$th</option>\n";
1981 echo "</select></td></tr>\n";
1984 function pagesizes_list_row($label, $name, $value)
1988 echo "<tr><td>$label</td>\n";
1989 echo "<td><select name='$name'>";
1992 $value = (!isset($_POST[$name]) ? "" : $_POST[$name]);
1993 foreach ($pagesizes as $pz)
1998 echo "<option selected value='$pz'>$pz</option>\n";
2002 echo "<option value='$pz'>$pz</option>\n";
2005 echo "</select></td></tr>\n";
2008 function security_headings_list_row($label, $name, $value)
2010 global $security_headings;
2012 echo "<tr><td>$label</td>\n";
2013 echo "<td><select name='$name'>";
2016 $value = (!isset($_POST[$name]) ? 0 : (int)$_POST[$name]);
2018 foreach ($security_headings as $sh)
2021 if ($value==$counter)
2023 echo "<option selected value='$counter'>$sh</option>\n";
2027 echo "<option value='$counter'>$sh</option>\n";
2031 echo "</select></td></tr>\n";
2034 function systypes_list_cells($label, $name, $value, $submit_on_change=false)
2036 global $systypes_array;
2039 echo "<td>$label</td>\n";
2040 echo "<td><select name='$name'";
2041 if ($submit_on_change)
2042 echo " onchange='this.form.submit();'>";
2046 $value = (!isset($_POST[$name]) ? "" : $_POST[$name]);
2047 foreach ($systypes_array as $key=>$type)
2052 echo "<option selected value='$key'>".$type['name']."</option>\n";
2056 echo "<option value='$key'>".$type['name']."</option>\n";
2059 echo "</select></td>\n";
2062 function systypes_list_row($label, $name, $value, $submit_on_change=false)
2065 systypes_list_cells($label, $name, $value, $submit_on_change);
2069 function cust_allocations_list_cells($label, $name, $selected)
2074 if ($selected == null)
2075 $selected = (!isset($_POST[$name]) ? "" : $_POST[$name]);
2076 echo "<td><select name='$name'>";
2077 echo "<option " . ($selected == $all_items ? " selected " : "") . " value='$all_items'>" . _("All Types"). "</option>\n";
2078 echo "<option " . ($selected == '1'?" selected ":"") . " value='1'>" . _("Sales Invoices"). "</option>\n";
2079 echo "<option " . ($selected == '2'?" selected ":"") . " value='2'>" . _("Overdue Invoices"). "</option>\n";
2080 echo "<option " . ($selected == '3'?" selected ":"") . " value='3'>" . _("Payments"). "</option>\n";
2081 echo "<option " . ($selected == '4'?" selected ":"") . " value='4'>" . _("Credit Notes"). "</option>\n";
2082 echo "</select></td>\n";
2085 function supp_allocations_list_cells($name, $selected)
2088 if ($selected == null)
2089 $selected = (!isset($_POST[$name]) ? "" : $_POST[$name]);
2090 echo "<td><select name='$name'>";
2091 echo "<option " . ($selected == $all_items ? " selected " : "") . " value='$all_items'>" . _("All Types"). "</option>\n";
2092 echo "<option " . ($selected == '1'?" selected ":"") . " value='1'>" . _("Invoices"). "</option>\n";
2093 echo "<option " . ($selected == '2'?" selected ":"") . " value='2'>" . _("Overdue Invoices"). "</option>\n";
2094 echo "<option " . ($selected == '3'?" selected ":"") . " value='3'>" . _("Payments"). "</option>\n";
2095 echo "<option " . ($selected == '4'?" selected ":"") . " value='4'>" . _("Credit Notes"). "</option>\n";
2096 echo "<option " . ($selected == '5'?" selected ":"") . " value='5'>" . _("Overdue Credit Notes"). "</option>\n";
2097 echo "</select></td>\n";
2100 function policy_list_cells($label, $name, $selected)
2102 if ($selected == null)
2104 $selected = (!isset($_POST[$name]) ? "" : $_POST[$name]);
2105 if ($selected == "")
2106 $_POST[$name] = $selected;
2110 echo "<td><select name='$name'>";
2111 echo "<option " . ($selected == ''?" selected ":"") . " value=''>" . _("Automatically put balance on back order"). "</option>\n";
2112 echo "<option " . ($selected == 'CAN'?" selected ":"") . " value='CAN'>" . _("Cancel any quantites not delivered"). "</option>\n";
2113 echo "</select></td>\n";
2116 function policy_list_row($label, $name, $selected)
2119 policy_list_cells($label, $name, $selected);
2123 function credit_type_list_cells($label, $name, $selected, $submit_on_change=false)
2125 if ($selected == null)
2127 $selected = (!isset($_POST[$name]) ? "Return" : $_POST[$name]);
2128 if ($selected == "Return")
2129 $_POST[$name] = $selected;
2133 echo "<td><select name='$name'";
2134 if ($submit_on_change)
2135 echo " onchange='this.form.submit();'>";
2138 echo "<option " . ($selected == 'Return'?" selected ":"") . " value='Return'>" . _("Items Returned to Inventory Location"). "</option>\n";
2139 echo "<option " . ($selected == 'WriteOff'?" selected ":"") . " value='WriteOff'>" . _("Items Written Off"). "</option>\n";
2140 echo "</select></td>\n";
2143 function credit_type_list_row($label, $name, $selected, $submit_on_change=false)
2146 credit_type_list_cells($label, $name, $selected, $submit_on_change);
2150 function number_list($name, $selected, $from, $to, $firstlabel="")
2152 if ($selected == null)
2154 $selected = (!isset($_POST[$name]) ? $from : $_POST[$name]);
2155 if ($selected == $from)
2156 $_POST[$name] = $selected;
2158 echo "<select name='$name'>";
2159 for ($i = $from; $i <= $to; $i++)
2161 if ($i == 0 && $firstlabel != "")
2162 $label = $firstlabel;
2165 if ($selected == $i)
2167 echo "<option selected value='$i'>$label</option>\n";
2171 echo "<option value='$i'>$label</option>\n";
2177 function number_list_cells($label, $name, $selected, $from, $to)
2182 number_list($name, $selected, $from, $to);
2186 function number_list_row($label, $name, $selected, $from, $to)
2189 number_list_cells($label, $name, $selected, $from, $to);