+function crm_category_types_list($name, $selected_id=null, $filter=array(), $submit_on_change=true)
+{
+
+ $sql = "SELECT id, name, type, inactive FROM ".TB_PREF."crm_categories";
+
+ $multi = false;
+ $groups = false;
+ $where = array();
+ if (@$filter['class']) {
+ $where[] = 'type='.db_escape($filter['class']);
+ } else
+ $groups = 'type';
+ if (@$filter['subclass']) $where[] = 'action='.db_escape($filter['subclass']);
+ if (@$filter['entity']) $where[] = 'entity_id='.db_escape($filter['entity']);
+ if (@$filter['multi']) { // contact category selector for person
+ $multi = true;
+ }
+
+ return combo_input($name, $selected_id, $sql, 'id', 'name',
+ array(
+ 'multi' => $multi,
+ 'height' => $multi ? 5:1,
+ 'category' => $groups,
+ 'select_submit'=> $submit_on_change,
+ 'async' => true,
+ 'where' => $where
+ ));
+}
+
+function crm_category_types_list_row($label, $name, $selected_id=null, $filter=array(), $submit_on_change=true)
+{
+ echo "<tr><td class='label'>$label</td><td>";
+ echo crm_category_types_list($name, $selected_id, $filter, $submit_on_change);
+ echo "</td></tr>\n";
+}
+
+function payment_type_list_row($label, $name, $selected_id=null, $submit_on_change=false)
+{
+ global $pterm_types;
+
+ echo "<tr><td class='label'>$label</td><td>";
+ echo array_selector($name, $selected_id, $pterm_types,
+ array(
+ 'select_submit'=> $submit_on_change
+ ) );
+ echo "</td></tr>\n";
+}
+
+function coa_list_row($label, $name, $value=null)
+{
+ global $path_to_root, $installed_extensions;
+
+ $path = $path_to_root.'/sql/';
+ $coas = array();
+ $sqldir = opendir($path);
+ while (false !== ($fname = readdir($sqldir)))
+ {
+ if (is_file($path.$fname) && substr($fname,-4)=='.sql' && @($fname[2] == '_'))
+ {
+ $ext = array_search_value($fname, $installed_extensions, 'sql');
+ if ($ext!=null) {
+ $descr = $ext['name'];
+ } elseif ($fname == 'en_US-new.sql') { // two standard COAs
+ $descr = _("Standard new company American COA (4 digit)");
+ } elseif ($fname == 'en_US-demo.sql') {
+ $descr = _("Standard American COA (4 digit) with demo data");
+ } else
+ $descr = $fname;
+
+ $coas[$fname] = $descr;
+ }
+ }
+ ksort($coas);
+
+ echo "<tr><td class='label'>$label</td>\n<td>";
+ echo array_selector( $name, $value, $coas );
+ echo "</td></tr>\n";
+}
+
+function payment_services($name)
+{
+ global $payment_services;
+
+ $services = (object)array_combine(array_keys($payment_services), array_keys($payment_services));
+
+ return array_selector($name, null, $services, array(
+ 'spec_option'=> _("No payment Link"),
+ 'spec_id' => '',
+ ));
+}
+
+function tax_algorithm_list($name, $value=null, $submit_on_change = false)
+{
+ global $tax_algorithms;
+
+ return array_selector($name, $value, $tax_algorithms,
+ array(
+ 'select_submit'=> $submit_on_change,
+ 'async' => true,
+ )
+ );
+}
+
+function tax_algorithm_list_cells($label, $name, $value=null, $submit_on_change=false)
+{
+ if ($label != null)
+ echo "<td>$label</td>\n";
+ echo "<td>";
+ echo tax_algorithm_list($name, $value, $submit_on_change);
+ echo "</td>\n";
+}
+
+function tax_algorithm_list_row($label, $name, $value=null, $submit_on_change=false)
+{
+ echo "<tr><td class='label'>$label</td>";
+ tax_algorithm_list_cells(null, $name, $value, $submit_on_change);
+ echo "</tr>\n";
+}
+
+function refline_list($name, $type, $value=null, $spec_option=false)
+{
+ $sql = "SELECT id, prefix, inactive FROM ".TB_PREF."reflines";
+
+ $where = array();
+
+ if (isset($type))
+ $where = array('`trans_type`='.db_escape($type));
+
+ return combo_input($name, $value, $sql, 'id', 'prefix',
+ array(
+ 'order'=>array('prefix'),
+ 'spec_option' => $spec_option,
+ 'spec_id' => '',
+ 'type' => 2,
+ 'where' => $where,
+ 'select_submit' => true,
+ )
+ );
+}
+
+function refline_list_row($label, $name, $type, $selected_id=null, $spec_option=false)
+{
+ echo "<tr>";
+ if ($label != null)
+ echo "<td class='label'>$label</td>\n";
+ echo "<td>";
+
+ echo refline_list($name, $type, $selected_id, $spec_option);
+ echo "</td></tr>\n";
+}
+
+
+//----------------------------------------------------------------------------------------------
+
+function subledger_list($name, $account, $selected_id=null)
+{
+
+ $type = is_subledger_account($account);
+ if (!$type)
+ return '';
+
+ if($type > 0)
+ $sql = "SELECT DISTINCT d.debtor_no as id, debtor_ref as name
+ FROM "
+ .TB_PREF."debtors_master d,"
+ .TB_PREF."cust_branch c
+ WHERE d.debtor_no=c.debtor_no AND c.receivables_account=".db_escape($account);
+ else
+ $sql = "SELECT supplier_id as id, supp_ref as name
+ FROM "
+ .TB_PREF."suppliers s
+ WHERE s.payable_account=".db_escape($account);
+
+ $mode = get_company_pref('no_customer_list');
+
+ return combo_input($name, $selected_id, $sql, 'id', 'name',
+ array(
+ 'type' => 1,
+ 'size' => 20,
+ 'async' => false,
+ ) );
+}
+
+function subledger_list_cells($label, $name, $account, $selected_id=null)
+{
+ if ($label != null)
+ echo "<td>$label</td>\n";
+ echo "<td nowrap>";
+ echo subledger_list($name, $account, $selected_id);
+ echo "</td>\n";
+}
+
+function subledger_list_row($label, $name, $selected_id=null, $all_option = false,
+ $submit_on_change=false, $show_inactive=false, $editkey = false)
+{
+ echo "<tr><td class='label'>$label</td><td nowrap>";
+ echo subledger_list($name, $account, $selected_id);
+ echo "</td>\n</tr>\n";
+}
+
+function accounts_type_list_row($label, $name, $selected_id=null)
+{
+ echo "<tr>";
+ if ($label != null)
+ echo "<td class='label'>$label</td>\n";
+ echo "<td>";
+ $sel = array(_("Numeric"), _("Alpha Numeric"), _("ALPHA NUMERIC"));
+ echo array_selector($name, $selected_id, $sel);
+ echo "</td></tr>\n";
+}
+
+function users_list_cells($label, $name, $selected_id=null, $submit_on_change=false, $spec_opt=true)
+{
+ $where = false;
+ $sql = " SELECT user_id, real_name FROM ".TB_PREF."users";
+
+ if ($label != null)
+ echo "<td>$label</td>\n";
+ echo "<td>";
+
+ echo combo_input($name, $selected_id, $sql, 'user_id', 'real_name',
+ array(
+ 'spec_option' => $spec_opt===true ?_("All users") : $spec_opt,
+ 'spec_id' => '',
+ 'order' => 'real_name',
+ 'select_submit'=> $submit_on_change,
+ 'async' => false
+ ) );
+ echo "</td>";
+
+}
+
+function collations_list_row($label, $name, $selected_id=null)
+{
+ global $supported_collations;
+
+ echo "<tr>";
+ if ($label != null)
+ echo "<td class='label'>$label</td>\n";
+ echo "<td>";
+
+ echo array_selector($name, $selected_id, $supported_collations,
+ array('select_submit'=> false) );
+ echo "</td></tr>\n";
+}