X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fui%2Fui_lists.inc;h=0ddf0c34f6dad80ce61af1721c539cf6cfe73697;hb=21ba0553185531c12f16efef9010033d5dd62cdc;hp=e4f14c1ad83dd14c1e821c3958f42e518dd9905a;hpb=ef5124a450ba7d94f4e10ca07730ada038261aa9;p=fa-stable.git diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc index e4f14c1a..0ddf0c34 100644 --- a/includes/ui/ui_lists.inc +++ b/includes/ui/ui_lists.inc @@ -89,21 +89,20 @@ $opts = array( // default options $opts['sel_hint'] = $by_id || $search_box==false ? '' : _('Press Space tab for search pattern entry'); - if ($opts['box_hint'] === null) // dodaƦ hint dla pustego **** + if ($opts['box_hint'] === null) $opts['box_hint'] = $search_box && $search_submit != false ? ($by_id ? _('Enter code fragment to search or * for all') : _('Enter description fragment to search or * for all')) :''; if ($selected_id == null) { - $selected_id = get_post($name, $opts['default']); + $selected_id = get_post($name, (string)$opts['default']); } if(!is_array($selected_id)) - $selected_id = array($selected_id); // code is generalized for multiple selection support + $selected_id = array((string)$selected_id); // code is generalized for multiple selection support $txt = get_post($search_box); $rel = ''; $limit = ''; - if (isset($_POST['_'.$name.'_update'])) { // select list or search box change if ($by_id) $txt = $_POST[$name]; @@ -145,6 +144,7 @@ $opts = array( // default options } } } + // sql completion if (count($opts['where'])) { $where = strpos($sql, 'WHERE')==false ? ' WHERE ':' AND '; @@ -181,12 +181,13 @@ $opts = array( // default options if (get_post($search_button) && ($txt == $value)) { $selected_id[] = $value; } - if (in_array($value, $selected_id)) { + + if (in_array((string)$value, $selected_id, true)) { $sel = 'selected'; $found = $value; $edit = $opts['editable'] && $contact_row['editable'] && (@$_POST[$search_box] == $value) - ? $descr : false; + ? $contact_row[1] : false; // get non-formatted description if ($edit) break; // selected field is editable - abandon list construction } @@ -228,7 +229,7 @@ $opts = array( // default options $_POST[$name] = $multi ? $selected_id : $selected_id[0]; - $selector = "\n"; @@ -240,7 +241,7 @@ $opts = array( // default options ."\n"; set_focus($name.'_text'); // prevent lost focus - } else if (isset($_POST['_'.$name.'_edit'])) + } else if (get_post($search_submit ? $search_submit : "_{$name}_button")) set_focus($name); // prevent lost focus if (!$opts['editable']) $txt = $found; @@ -327,7 +328,7 @@ $opts = array( // default options $selected_id = get_post($name, $opts['default']); } if(!is_array($selected_id)) - $selected_id = array($selected_id); // code is generalized for multiple selection support + $selected_id = array((string)$selected_id); // code is generalized for multiple selection support if (isset($_POST[ '_'.$name.'_update'])) { if (!$opts['async']) @@ -343,7 +344,7 @@ $opts = array( // default options //if($name=='SelectStockFromList') display_error($sql); foreach($items as $value=>$descr) { $sel = ''; - if (in_array((string)$value, $selected_id)) { + if (in_array((string)$value, $selected_id, true)) { $sel = 'selected'; $found = $value; } @@ -354,6 +355,10 @@ $opts = array( // default options $selector .= "\n"; } + if ($first_id!==false) { + $sel = ($found===$first_id) || ($found===false && ($spec_option===false)) ? "selected='selected'" : ''; + $selector = sprintf($first_opt, $sel).$selector; + } // Prepend special option. if ($spec_option !== false) { // if special option used - add it $first_id = $spec_id; @@ -367,7 +372,8 @@ $opts = array( // default options $selected_id = array($first_id); } $_POST[$name] = $multi ? $selected_id : $selected_id[0]; - $selector = "\n"; @@ -441,7 +447,7 @@ function supplier_list_cells($label, $name, $selected_id=null, $all_option=false function supplier_list_row($label, $name, $selected_id=null, $all_option = false, $submit_on_change=false, $all=false, $editkey = false) { - echo "$label"; + echo "$label"; echo supplier_list($name, $selected_id, $all_option, $submit_on_change, $all, $editkey); echo "\n"; @@ -491,7 +497,7 @@ function customer_list_cells($label, $name, $selected_id=null, $all_option=false function customer_list_row($label, $name, $selected_id=null, $all_option = false, $submit_on_change=false, $show_inactive=false, $editkey = false) { - echo "$label"; + echo "$label"; echo customer_list($name, $selected_id, $all_option, $submit_on_change, $show_inactive, $editkey); echo "\n\n"; @@ -537,8 +543,8 @@ function customer_branches_list_cells($label,$customer_id, $name, $selected_id=n function customer_branches_list_row($label, $customer_id, $name, $selected_id=null, $all_option = true, $enabled=true, $submit_on_change=false, $editkey = false) { - echo ""; - customer_branches_list_cells($label, $customer_id, $name, $selected_id, + echo "$label"; + customer_branches_list_cells(null, $customer_id, $name, $selected_id, $all_option, $enabled, $submit_on_change, $editkey); echo ""; } @@ -570,8 +576,8 @@ function locations_list_cells($label, $name, $selected_id=null, $all_option=fals function locations_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false) { - echo ""; - locations_list_cells($label, $name, $selected_id, $all_option, $submit_on_change); + echo "$label"; + locations_list_cells(null, $name, $selected_id, $all_option, $submit_on_change); echo "\n"; } @@ -601,8 +607,8 @@ function currencies_list_cells($label, $name, $selected_id=null, $submit_on_chan function currencies_list_row($label, $name, $selected_id=null, $submit_on_change=false) { - echo "\n"; - currencies_list_cells($label, $name, $selected_id, $submit_on_change); + echo "$label"; + currencies_list_cells(null, $name, $selected_id, $submit_on_change); echo "\n"; } @@ -642,8 +648,8 @@ function fiscalyears_list_cells($label, $name, $selected_id=null) function fiscalyears_list_row($label, $name, $selected_id=null) { - echo "\n"; - fiscalyears_list_cells($label, $name, $selected_id); + echo "$label"; + fiscalyears_list_cells(null, $name, $selected_id); echo "\n"; } //------------------------------------------------------------------------------------ @@ -682,8 +688,8 @@ function dimensions_list_cells($label, $name, $selected_id=null, $no_option=fals function dimensions_list_row($label, $name, $selected_id=null, $no_option=false, $showname=null, $showclosed=false, $showtype=0, $submit_on_change=false) { - echo "\n"; - dimensions_list_cells($label, $name, $selected_id, $no_option, $showname, + echo "$label"; + dimensions_list_cells(null, $name, $selected_id, $no_option, $showname, $showclosed, $showtype, $submit_on_change); echo "\n"; } @@ -695,7 +701,7 @@ function stock_items_list($name, $selected_id=null, $all_option=false, { global $all_items; - $sql = "SELECT stock_id, s.description, c.description, s.inactive + $sql = "SELECT stock_id, s.description, c.description, s.inactive, s.editable FROM ".TB_PREF."stock_master s,".TB_PREF."stock_category c WHERE s.category_id=c.category_id"; if ($editkey) @@ -802,7 +808,7 @@ function sales_local_items_list_row($label, $name, $selected_id=null, $all_optio { echo ""; if ($label != null) - echo "$label\n"; + echo "$label\n"; echo ""; echo sales_items_list($name, $selected_id, $all_option, $submit_on_change, 'local', array('cells'=>false, 'editable' => false)); @@ -830,8 +836,8 @@ function stock_manufactured_items_list_cells($label, $name, $selected_id=null, function stock_manufactured_items_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false) { - echo "\n"; - stock_manufactured_items_list_cells($label, $name, $selected_id, $all_option, $submit_on_change); + echo "$label"; + stock_manufactured_items_list_cells(null, $name, $selected_id, $all_option, $submit_on_change); echo "\n"; } //------------------------------------------------------------------------------------ @@ -878,7 +884,9 @@ function stock_purchasable_items_list($name, $selected_id=null, array('where'=>array("mb_flag!= 'M'"), 'show_inactive'=>$all), $editkey); } - +// +// This helper is used in PO/GRN/PI entry and supports editable descriptions. +// function stock_purchasable_items_list_cells($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false, $editkey=false) { @@ -886,18 +894,19 @@ function stock_purchasable_items_list_cells($label, $name, $selected_id=null, echo "$label\n"; echo stock_items_list($name, $selected_id, $all_option, $submit_on_change, array('where'=>array("mb_flag!= 'M'"), + 'editable' => 30, 'cells'=>true), $editkey); } - +/* function stock_purchasable_items_list_row($label, $name, $selected_id=null, $all_option=false, $submit_on_change=false, $editkey=false) { - echo "\n"; - stock_purchasable_items_list_cells($label, $name, $selected_id=null, + echo "$label"; + stock_purchasable_items_list_cells(null, $name, $selected_id=null, $all_option, $submit_on_change, $editkey); echo "\n"; } - +*/ //------------------------------------------------------------------------------------ function stock_item_types_list_row($label, $name, $selected_id=null, $enabled=true) @@ -906,7 +915,7 @@ function stock_item_types_list_row($label, $name, $selected_id=null, $enabled=tr echo ""; if ($label != null) - echo "$label\n"; + echo "$label\n"; echo ""; echo array_selector($name, $selected_id, $stock_types, @@ -921,7 +930,7 @@ function stock_units_list_row($label, $name, $value=null, $enabled=true) $result = get_all_item_units(); echo ""; if ($label != null) - echo "$label\n"; + echo "$label\n"; echo ""; while($unit = db_fetch($result)) @@ -960,8 +969,8 @@ function tax_types_list_cells($label, $name, $selected_id=null, $none_option=fal function tax_types_list_row($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false) { - echo "\n"; - tax_types_list_cells($label, $name, $selected_id, $none_option, $submit_on_change); + echo "$label"; + tax_types_list_cells(null, $name, $selected_id, $none_option, $submit_on_change); echo "\n"; } @@ -993,8 +1002,8 @@ function tax_groups_list_cells($label, $name, $selected_id=null, $none_option=fa function tax_groups_list_row($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false) { - echo "\n"; - tax_groups_list_cells($label, $name, $selected_id, $none_option, $submit_on_change); + echo "$label"; + tax_groups_list_cells(null, $name, $selected_id, $none_option, $submit_on_change); echo "\n"; } @@ -1017,8 +1026,8 @@ function item_tax_types_list_cells($label, $name, $selected_id=null) function item_tax_types_list_row($label, $name, $selected_id=null) { - echo "\n"; - item_tax_types_list_cells($label, $name, $selected_id); + echo "$label"; + item_tax_types_list_cells(null, $name, $selected_id); echo "\n"; } @@ -1042,8 +1051,8 @@ function shippers_list_cells($label, $name, $selected_id=null) function shippers_list_row($label, $name, $selected_id=null) { - echo "\n"; - shippers_list_cells($label, $name, $selected_id); + echo "$label"; + shippers_list_cells(null, $name, $selected_id); echo "\n"; } @@ -1069,8 +1078,8 @@ function sales_persons_list_cells($label, $name, $selected_id=null, $spec_opt=fa function sales_persons_list_row($label, $name, $selected_id=null, $spec_opt=false) { - echo "\n"; - sales_persons_list_cells($label, $name, $selected_id, $spec_opt); + echo "$label"; + sales_persons_list_cells(null, $name, $selected_id, $spec_opt); echo "\n"; } @@ -1093,8 +1102,8 @@ function sales_areas_list_cells($label, $name, $selected_id=null) function sales_areas_list_row($label, $name, $selected_id=null) { - echo "\n"; - sales_areas_list_cells($label, $name, $selected_id); + echo "$label"; + sales_areas_list_cells(null, $name, $selected_id); echo "\n"; } @@ -1120,8 +1129,8 @@ function sales_groups_list_cells($label, $name, $selected_id=null, $special_opti function sales_groups_list_row($label, $name, $selected_id=null, $special_option=false) { - echo "\n"; - sales_groups_list_cells($label, $name, $selected_id, $special_option); + echo "$label"; + sales_groups_list_cells(null, $name, $selected_id, $special_option); echo "\n"; } @@ -1155,8 +1164,8 @@ function templates_list_cells($label, $name, $selected_id=null, $special_option= function templates_list_row($label, $name, $selected_id=null, $special_option=false) { - echo "\n"; - templates_list_cells($label, $name, $selected_id, $special_option); + echo "$label"; + templates_list_cells(null, $name, $selected_id, $special_option); echo "\n"; } @@ -1179,8 +1188,8 @@ function workorders_list_cells($label, $name, $selected_id=null) function workorders_list_row($label, $name, $selected_id=null) { - echo "\n"; - workorders_list_cells($label, $name, $selected_id); + echo "$label"; + workorders_list_cells(null, $name, $selected_id); echo "\n"; } @@ -1203,8 +1212,8 @@ function payment_terms_list_cells($label, $name, $selected_id=null) function payment_terms_list_row($label, $name, $selected_id=null) { - echo "\n"; - payment_terms_list_cells($label, $name, $selected_id); + echo "$label"; + payment_terms_list_cells(null, $name, $selected_id); echo "\n"; } @@ -1227,8 +1236,8 @@ function credit_status_list_cells($label, $name, $selected_id=null) function credit_status_list_row($label, $name, $selected_id=null) { - echo "\n"; - credit_status_list_cells($label, $name, $selected_id); + echo "$label"; + credit_status_list_cells(null, $name, $selected_id); echo "\n"; } @@ -1258,8 +1267,8 @@ function sales_types_list_cells($label, $name, $selected_id=null, $submit_on_cha function sales_types_list_row($label, $name, $selected_id=null, $submit_on_change=false, $special_option=false) { - echo "\n"; - sales_types_list_cells($label, $name, $selected_id, $submit_on_change, $special_option); + echo "$label"; + sales_types_list_cells(null, $name, $selected_id, $submit_on_change, $special_option); echo "\n"; } @@ -1282,8 +1291,8 @@ function movement_types_list_cells($label, $name, $selected_id=null) function movement_types_list_row($label, $name, $selected_id=null) { - echo "\n"; - movement_types_list_cells($label, $name, $selected_id); + echo "$label"; + movement_types_list_cells(null, $name, $selected_id); echo "\n"; } @@ -1350,8 +1359,8 @@ function workcenter_list_cells($label, $name, $selected_id=null, $all_option=fal function workcenter_list_row($label, $name, $selected_id=null, $all_option=false) { - echo "\n"; - workcenter_list_cells($label, $name, $selected_id, $all_option); + echo "$label"; + workcenter_list_cells(null, $name, $selected_id, $all_option); echo "\n"; } @@ -1381,8 +1390,8 @@ function bank_accounts_list_cells($label, $name, $selected_id=null, $submit_on_c function bank_accounts_list_row($label, $name, $selected_id=null, $submit_on_change=false) { - echo "\n"; - bank_accounts_list_cells($label, $name, $selected_id, $submit_on_change); + echo "$label"; + bank_accounts_list_cells(null, $name, $selected_id, $submit_on_change); echo "\n"; } //----------------------------------------------------------------------------------------------- @@ -1394,7 +1403,7 @@ function cash_accounts_list_row($label, $name, $selected_id=null, $submit_on_cha WHERE ".TB_PREF."bank_accounts.account_type=3"; if ($label != null) - echo "$label\n"; + echo "$label\n"; echo ""; echo combo_input($name, $selected_id, $sql, 'id', 'bank_account_name', array( @@ -1413,7 +1422,7 @@ function pos_list_row($label, $name, $selected_id=null, $spec_option=false, $sub default_focus($name); echo ''; if ($label != null) - echo "$label\n"; + echo "$label\n"; echo ""; echo combo_input($name, $selected_id, $sql, 'id', 'pos_name', @@ -1453,7 +1462,7 @@ function sale_payment_list($name, $selected_id=null, $submit_on_change=true) function sale_payment_list_cells($label, $name, $selected_id=null, $submit_on_change=true) { if ($label != null) - echo "$label\n"; + echo "$label\n"; echo ""; echo sale_payment_list($name, $selected_id, $submit_on_change); @@ -1485,8 +1494,8 @@ function class_list_cells($label, $name, $selected_id=null, $submit_on_change=fa function class_list_row($label, $name, $selected_id=null, $submit_on_change=false) { - echo "\n"; - class_list_cells($label, $name, $selected_id, $submit_on_change); + echo "$label"; + class_list_cells(null, $name, $selected_id, $submit_on_change); echo "\n"; } @@ -1514,14 +1523,14 @@ function stock_categories_list_cells($label, $name, $selected_id=null, $spec_opt function stock_categories_list_row($label, $name, $selected_id=null, $spec_opt=false, $submit_on_change=false) { - echo "\n"; - stock_categories_list_cells($label, $name, $selected_id, $spec_opt, $submit_on_change); + echo "$label"; + stock_categories_list_cells(null, $name, $selected_id, $spec_opt, $submit_on_change); echo "\n"; } //----------------------------------------------------------------------------------------------- -function gl_account_types_list($name, $selected_id=null, $all_option=false, $all_option_numeric=true) +function gl_account_types_list($name, $selected_id=null, $all_option=false, $all=true) { global $all_items; @@ -1529,28 +1538,26 @@ function gl_account_types_list($name, $selected_id=null, $all_option=false, $all return combo_input($name, $selected_id, $sql, 'id', 'name', array( - 'order' => 'id', + 'order' => array('class_id', 'id', 'parent'), 'spec_option' =>$all_option, - 'spec_id' => $all_option_numeric ? 0 : $all_items + 'spec_id' => $all_items ) ); } -function gl_account_types_list_cells($label, $name, $selected_id=null, $all_option=false, - $all_option_numeric=false) +function gl_account_types_list_cells($label, $name, $selected_id=null, $all_option=false, $all=false) { if ($label != null) echo "$label\n"; echo ""; - echo gl_account_types_list($name, $selected_id, $all_option, $all_option_numeric); + echo gl_account_types_list($name, $selected_id, $all_option, $all); echo "\n"; } -function gl_account_types_list_row($label, $name, $selected_id=null, $all_option=false, - $all_option_numeric=false) +function gl_account_types_list_row($label, $name, $selected_id=null, $all_option=false, $all=false) { - echo "\n"; - gl_account_types_list_cells($label, $name, $selected_id, $all_option, - $all_option_numeric); + echo "$label"; + gl_account_types_list_cells(null, $name, $selected_id, $all_option, + $all); echo "\n"; } @@ -1575,7 +1582,7 @@ function gl_all_accounts_list($name, $selected_id=null, $skip_bank_accounts=fals 'format' => '_format_account', 'spec_option' => $all_option===true ? _("Use Item Sales Accounts") : $all_option, 'spec_id' => '', - 'order' => array('type.id','account_code'), + 'order' => array('type.class_id','type.id','account_code'), 'search_box' => $cells, 'search_submit' => false, 'size' => 12, @@ -1609,8 +1616,8 @@ function gl_all_accounts_list_cells($label, $name, $selected_id=null, function gl_all_accounts_list_row($label, $name, $selected_id=null, $skip_bank_accounts=false, $cells=false, $all_option=false) { - echo "\n"; - gl_all_accounts_list_cells($label, $name, $selected_id, + echo "$label"; + gl_all_accounts_list_cells(null, $name, $selected_id, $skip_bank_accounts, $cells, $all_option); echo "\n"; } @@ -1638,37 +1645,38 @@ function yesno_list_cells($label, $name, $selected_id=null, $name_yes="", $name_ function yesno_list_row($label, $name, $selected_id=null, $name_yes="", $name_no="", $submit_on_change=false) { - echo "\n"; - yesno_list_cells($label, $name, $selected_id, $name_yes, $name_no, $submit_on_change); + echo "$label"; + yesno_list_cells(null, $name, $selected_id, $name_yes, $name_no, $submit_on_change); echo "\n"; } //------------------------------------------------------------------------------------------------ -function languages_list($name, $selected_id=null) +function languages_list($name, $selected_id=null, $all_option=false) { global $installed_languages; $items = array(); + if ($all_option) + $items[''] = $all_option; foreach ($installed_languages as $lang) $items[$lang['code']] = $lang['name']; - return array_selector($name, $selected_id, $items); } -function languages_list_cells($label, $name, $selected_id=null) +function languages_list_cells($label, $name, $selected_id=null, $all_option=false) { if ($label != null) echo "$label\n"; echo ""; - echo languages_list($name, $selected_id); + echo languages_list($name, $selected_id, $all_option); echo "\n"; } -function languages_list_row($label, $name, $selected_id=null) +function languages_list_row($label, $name, $selected_id=null, $all_option=false) { - echo "\n"; - languages_list_cells($label, $name, $selected_id); + echo "$label"; + languages_list_cells(null, $name, $selected_id, $all_option); echo "\n"; } @@ -1692,8 +1700,8 @@ function bank_account_types_list_cells($label, $name, $selected_id=null) function bank_account_types_list_row($label, $name, $selected_id=null) { - echo "\n"; - bank_account_types_list_cells($label, $name, $selected_id); + echo "$label"; + bank_account_types_list_cells(null, $name, $selected_id); echo "\n"; } @@ -1723,8 +1731,8 @@ function payment_person_types_list_cells($label, $name, $selected_id=null, $rela function payment_person_types_list_row($label, $name, $selected_id=null, $related=null) { - echo "\n"; - payment_person_types_list_cells($label, $name, $selected_id, $related); + echo "$label"; + payment_person_types_list_cells(null, $name, $selected_id, $related); echo "\n"; } @@ -1740,7 +1748,7 @@ function wo_types_list($name, $selected_id=null) function wo_types_list_row($label, $name, $selected_id=null) { - echo "$label\n"; + echo "$label\n"; echo wo_types_list($name, $selected_id); echo "\n"; } @@ -1751,7 +1759,7 @@ function dateformats_list_row($label, $name, $value=null) { global $dateformats; - echo "$label\n"; + echo "$label\n"; echo array_selector( $name, $value, $dateformats ); echo "\n"; } @@ -1760,7 +1768,7 @@ function dateseps_list_row($label, $name, $value=null) { global $dateseps; - echo "$label\n"; + echo "$label\n"; echo array_selector( $name, $value, $dateseps ); echo "\n"; } @@ -1769,7 +1777,7 @@ function thoseps_list_row($label, $name, $value=null) { global $thoseps; - echo "$label\n"; + echo "$label\n"; echo array_selector( $name, $value, $thoseps ); echo "\n"; } @@ -1778,7 +1786,7 @@ function decseps_list_row($label, $name, $value=null) { global $decseps; - echo "$label\n"; + echo "$label\n"; echo array_selector( $name, $value, $decseps ); echo "\n"; } @@ -1799,7 +1807,7 @@ function themes_list_row($label, $name, $value=null) } ksort($themes); - echo "$label\n"; + echo "$label\n"; echo array_selector( $name, $value, $themes ); echo "\n"; } @@ -1812,7 +1820,7 @@ function pagesizes_list_row($label, $name, $value=null) foreach ($pagesizes as $pz) $items[$pz] = $pz; - echo "$label\n"; + echo "$label\n"; echo array_selector( $name, $value, $items ); echo "\n"; } @@ -1842,8 +1850,8 @@ function systypes_list_cells($label, $name, $value=null, $submit_on_change=false function systypes_list_row($label, $name, $value=null, $submit_on_change=false) { - echo "\n"; - systypes_list_cells($label, $name, $value, false, $submit_on_change); + echo "$label"; + systypes_list_cells(null, $name, $value, $submit_on_change); echo "\n"; } @@ -1922,8 +1930,8 @@ function policy_list_cells($label, $name, $selected=null) function policy_list_row($label, $name, $selected=null) { - echo "\n"; - policy_list_cells($label, $name, $selected); + echo "$label"; + policy_list_cells(null, $name, $selected); echo "\n"; } @@ -1941,8 +1949,8 @@ function credit_type_list_cells($label, $name, $selected=null, $submit_on_change function credit_type_list_row($label, $name, $selected=null, $submit_on_change=false) { - echo "\n"; - credit_type_list_cells($label, $name, $selected, $submit_on_change); + echo "$label"; + credit_type_list_cells(null, $name, $selected, $submit_on_change); echo "\n"; } @@ -1968,8 +1976,8 @@ function number_list_cells($label, $name, $selected, $from, $to, $no_option=fals function number_list_row($label, $name, $selected, $from, $to, $no_option=false) { - echo "\n"; - echo number_list_cells($label, $name, $selected, $from, $to, $no_option); + echo "$label"; + echo number_list_cells(null, $name, $selected, $from, $to, $no_option); echo "\n"; } @@ -1986,7 +1994,7 @@ function print_profiles_list_row($label, $name, $selected_id=null, $spec_opt=fal echo ""; if ($label != null) - echo "$label\n"; + echo "$label\n"; echo ""; echo array_selector($name, $selected_id, $profiles, @@ -2038,15 +2046,17 @@ function quick_entries_list($name, $selected_id=null, $type=null, $submit_on_cha function quick_entries_list_cells($label, $name, $selected_id=null, $type, $submit_on_change=false) { - echo "$label\n"; + if ($label != null) + echo "$label\n"; + echo ""; echo quick_entries_list($name, $selected_id, $type, $submit_on_change); echo ""; } function quick_entries_list_row($label, $name, $selected_id=null, $type, $submit_on_change=false) { - echo "\n"; - quick_entries_list_cells($label, $name, $selected_id, $type, $submit_on_change); + echo "$label"; + quick_entries_list_cells(null, $name, $selected_id, $type, $submit_on_change); echo "\n"; } @@ -2055,7 +2065,7 @@ function quick_actions_list_row($label, $name, $selected_id=null, $submit_on_cha { global $quick_actions; - echo "$label"; + echo "$label"; echo array_selector($name, $selected_id, $quick_actions, array( 'select_submit'=> $submit_on_change @@ -2067,7 +2077,7 @@ function quick_entry_types_list_row($label, $name, $selected_id=null, $submit_on { global $quick_entry_types; - echo "$label"; + echo "$label"; echo array_selector($name, $selected_id, $quick_entry_types, array( 'select_submit'=> $submit_on_change @@ -2083,7 +2093,7 @@ function class_types_list_row($label, $name, $selected_id=null, $submit_on_chang { global $class_types; - echo "$label"; + echo "$label"; echo array_selector($name, $selected_id, $class_types, array( 'select_submit'=> $submit_on_change @@ -2122,8 +2132,8 @@ function security_roles_list_cells($label, $name, $selected_id=null, $new_item=f function security_roles_list_row($label, $name, $selected_id=null, $new_item=false, $submit_on_change=false, $show_inactive = false) { - echo ""; - security_roles_list_cells($label, $name, $selected_id, $new_item, $submit_on_change, $show_inactive); + echo "$label"; + security_roles_list_cells(null, $name, $selected_id, $new_item, $submit_on_change, $show_inactive); echo "\n"; } @@ -2142,7 +2152,7 @@ function tab_list_row($label, $name, $selected_id=null, $all = false) } } echo "\n"; - echo "$label\n"; + echo "$label\n"; echo array_selector($name, $selected_id, $tabs); echo "\n"; } @@ -2184,8 +2194,8 @@ function tag_list_cells($label, $name, $height, $type, $mult=false, $all=false, function tag_list_row($label, $name, $height, $type, $mult=false, $all=false, $spec_opt = false) { - echo "\n"; - tag_list_cells($label, $name, $height, $type, $mult, $all, $spec_opt); + echo "$label"; + tag_list_cells(null, $name, $height, $type, $mult, $all, $spec_opt); echo "\n"; } @@ -2208,4 +2218,40 @@ function extset_list($name, $value=null, $submit_on_change=false) )); } +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 "$label"; + echo crm_category_types_list($name, $selected_id, $filter, $submit_on_change); + echo "\n"; +} + ?> \ No newline at end of file