Fixed an array_combine object issue.
[fa-stable.git] / includes / ui / ui_lists.inc
index 12ebceaef666c6434fc81170dbf772ddc0dac024..c603ead26d027375729832139fc12beebe36c382 100644 (file)
@@ -292,14 +292,13 @@ $opts = array(            // default options
        }
        default_focus(($search_box && $by_id) ? $search_box : $name);
 
-       if ($SysPrefs->use_popup_search)
+       $img = "";
+       if ($SysPrefs->use_popup_search && (!isset($opts['fixed_asset']) || !$opts['fixed_asset']))
        {
-               $img = "";
-               $img_title = "";
-               $link = "";
+               $img_title = "";
+               $link = "";
                $id = $name;
                if ($SysPrefs->use_popup_windows) {
-                       //_vd("type= $type");
                switch (strtolower($type)) {
                        case "stock":
                                $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=all&client_id=" . $id;
@@ -321,12 +320,13 @@ $opts = array(            // default options
                                $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=costable&client_id=" . $id;
                                $img_title = _("Search items");
                                break;
-                       case "kits":
-                               $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=kits&client_id=" . $id;
+                       case "component":
+                               $parent = $opts['parent'];
+                               $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=component&parent=".$parent."&client_id=" . $id;
                                $img_title = _("Search items");
                                break;
-                       case "assets":
-                               $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=assets&client_id=" . $id;
+                       case "kits":
+                               $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=kits&client_id=" . $id;
                                $img_title = _("Search items");
                                break;
                        case "customer":
@@ -359,20 +359,10 @@ $opts = array(            // default options
        if ($opts['editlink'])
                $selector .= ' '.$opts['editlink'];
 
-       if ($SysPrefs->use_popup_search)
-       {
-               if ($search_box && $opts['cells'])
-                       $str = ($edit_entry!='' ? "<td>$edit_entry</td>" : '')."<td>$selector$img</td>";
-               else
-                       $str = $edit_entry.$selector.$img;
-       }
+       if ($search_box && $opts['cells'])
+               $str = ($edit_entry!='' ? "<td>$edit_entry</td>" : '')."<td>$selector$img</td>";
        else
-       {
-               if ($search_box && $opts['cells'])
-                       $str = ($edit_entry!='' ? "<td>$edit_entry</td>" : '')."<td>$selector</td>";
-               else
-                       $str = $edit_entry.$selector;
-       }               
+               $str = $edit_entry.$selector.$img;
        return $str;
 }
 
@@ -697,16 +687,18 @@ function locations_list_row($label, $name, $selected_id=null, $all_option=false,
 
 //-----------------------------------------------------------------------------------------------
 
-function currencies_list($name, $selected_id=null, $submit_on_change=false)
+function currencies_list($name, $selected_id=null, $submit_on_change=false, $exclude_home_curr=false)
 {
        $sql = "SELECT curr_abrev, currency, inactive FROM ".TB_PREF."currencies";
+       if ($exclude_home_curr)
+               $sql .= " WHERE curr_abrev!='".get_company_currency()."'";
 
        // default to the company currency
        return combo_input($name, $selected_id, $sql, 'curr_abrev', 'currency',
                array(
                        'select_submit'=> $submit_on_change,
                        'default' => get_company_currency(),
-                       'async' => false                
+                       'async' => false
                ) );
 }
 
@@ -824,8 +816,6 @@ function stock_items_list($name, $selected_id=null, $all_option=false,
        if ($editkey)
                set_editor('item', $name, $editkey);
 
-       if (isset($opts['fixed_asset']) && $opts['fixed_asset'])
-               $type = 'assets';
        $ret = combo_input($name, $selected_id, $sql, 'stock_id', 's.description',
                array_merge(
                  array(
@@ -834,7 +824,7 @@ function stock_items_list($name, $selected_id=null, $all_option=false,
                        'spec_id' => ALL_TEXT,
                        'search_box' => true,
                        'search' => array("stock_id", "c.description","s.description"),
-                       'search_submit' => get_company_pref('no_item_list')!=0,
+                       'search_submit' => get_company_pref('no_item_list')!=0 && (!isset($opts['fixed_asset']) || !$opts['fixed_asset']),
                        'size'=>10,
                        'select_submit'=> $submit_on_change,
                        'category' => 2,
@@ -986,18 +976,20 @@ function stock_manufactured_items_list_row($label, $name, $selected_id=null,
 function stock_component_items_list($name, $parent_stock_id, $selected_id=null,
        $all_option=false, $submit_on_change=false, $editkey = false)
 {
+       $parent = db_escape($parent_stock_id);
        return stock_items_list($name, $selected_id, $all_option, $submit_on_change,
-               array('where'=>array("stock_id != ".db_escape($parent_stock_id))), $editkey);
+               array('where'=>array("stock_id != $parent"), 'parent'=> $parent_stock_id), $editkey, "component");
 }
 
+
 function stock_component_items_list_cells($label, $name, $parent_stock_id, 
        $selected_id=null, $all_option=false, $submit_on_change=false, $editkey = false)
 {
        if ($label != null)
                echo "<td>$label</td>\n";
+       $parent = db_escape($parent_stock_id);
        echo stock_items_list($name, $selected_id, $all_option, $submit_on_change,
-               array('where'=>array("stock_id != ".db_escape($parent_stock_id)), 'cells'=>true),
-               $editkey);
+               array('where'=>array("stock_id != '$parent_stock_id'"), 'cells'=>true, 'parent'=> $parent_stock_id), $editkey, "component");
 }
 //------------------------------------------------------------------------------------
 
@@ -2543,7 +2535,7 @@ function payment_services($name)
 {
        global $payment_services;
 
-       $services = array_combine(array_keys($payment_services), array_keys($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"),