fetchByAssoc($GLOBALS['db']->query("select user_name from users where id='".$_SESSION['authenticated_user_id']."'")); $user_name=$r['user_name']; $arr_fields=array("name","code","product_category_name","product_category_id","flag","manufacturer_name","manufacturer_id","product_active","commission_rate","qty_per_unit","purchase_price","sales_start_date","sales_end_date","end_of_line","production"); /*if(!$_REQUEST['EcmProducts_ECMPRODUCT_offset'] && !$_REQUEST['EcmProducts_ECMPRODUCT_ORDER_BY']){ foreach($arr_fields as $a){ if($_REQUEST['searchFormTab']=="advanced_search")$_SESSION[$user_name."_PREFERENCES"]['global']['EcmProductsQ'][$a.'_advanced']=$_REQUEST[$a.'_advanced']=$_GET[$a.'_advanced']; if($_REQUEST['searchFormTab']=="basic_search")$_SESSION[$user_name."_PREFERENCES"]['global']['EcmProductsQ'][$a.'_basic']=$_REQUEST[$a.'_basic']=$_GET[$a.'_basic']; } } else{ foreach($arr_fields as $a){ if($_REQUEST['searchFormTab']=="advanced_search"){ $_REQUEST[$a.'_advanced']=$_SESSION[$user_name."_PREFERENCES"]['global']['EcmProductsQ'][$a.'_advanced']; $_GET[$a.'_advanced']=$_SESSION[$user_name."_PREFERENCES"]['global']['EcmProductsQ'][$a.'_advanced']; } if($_REQUEST['searchFormTab']=="basic_search"){ $_REQUEST[$a.'_basic']=$_SESSION[$user_name."_PREFERENCES"]['global']['EcmProductsQ'][$a.'_basic']; $_GET[$a.'_basic']=$_SESSION[$user_name."_PREFERENCES"]['global']['EcmProductsQ'][$a.'_basic']; } } }*/ if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); if($_REQUEST['pricebook_id'])$_SESSION['add_to_pricebook_id']=$_REQUEST['pricebook_id']; require_once ('XTemplate/xtpl.php'); require_once ("data/Tracker.php"); require_once ('modules/EcmProducts/EcmProduct.php'); require_once ('themes/'.$theme.'/layout_utils.php'); require_once ('log4php/LoggerManager.php'); require_once('include/ListView/ListViewSmarty.php'); require_once('include/ListView/ListView.php'); require_once('modules/Currencies/Currency.php'); if(file_exists('custom/modules/EcmProducts/metadata/listviewdefs.php')){ require_once('custom/modules/EcmProducts/metadata/listviewdefs.php'); } else{ require_once('modules/EcmProducts/metadata/listviewdefs.php'); } require_once('modules/SavedSearch/SavedSearch.php'); require_once('include/SearchForm/SearchForm.php'); $header_text = ''; global $app_strings; global $mod_strings; global $app_list_strings; global $current_language; $current_module_strings = return_module_language($current_language, 'EcmProducts'); global $urlPrefix; global $currentModule; global $theme; global $current_user; global $focus_list; require_once('include/QuickSearchDefaults.php'); $qsd = new QuickSearchDefaults(); $currentModule="EcmProducts"; echo "\n
\n"; echo get_module_title($mod_strings['LBL_MODULE_ID'], $mod_strings['LBL_MODULE_NAME'], true); echo "\n
\n"; if(!empty($_REQUEST['clear_query']) && $_REQUEST['clear_query'] == 'true')$current_user->setPreference('ListViewDisplayColumns', array(), 0, $currentModule); $savedDisplayColumns = $current_user->getPreference('ListViewDisplayColumns', $currentModule); $json = getJSONobj(); $seedEcmProduct = new EcmProduct(); $searchForm = new SearchForm('EcmProducts', $seedEcmProduct,"ListViewAddToPricebook"); $lv = new ListViewSmarty(); $displayColumns = array(); foreach($listViewDefs['EcmProducts'] as $col => $params) { if(!empty($params['default']) && $params['default'])$displayColumns[$col] = $params; } $params = array('massupdate' => true); $params['action']="ListViewAddToPriceBook"; if(!empty($_REQUEST['orderBy'])) { $params['orderBy'] = $_REQUEST['orderBy']; $params['overrideOrder'] = true; if(!empty($_REQUEST['sortOrder'])) $params['sortOrder'] = $_REQUEST['sortOrder']; } $lv->displayColumns = $displayColumns; if (!isset($where)) $where = ""; require_once('modules/MySettings/StoreQuery.php'); $storeQuery = new StoreQuery(); if(!isset($_REQUEST['query'])){ $storeQuery->loadQuery($currentModule); $storeQuery->populateRequest(); } else{ $storeQuery->saveFromRequest($currentModule); } if(isset($_REQUEST['query'])){ $current_user->setPreference('ListViewDisplayColumns', $displayColumns, 0, $currentModule); $searchForm->populateFromRequest(); foreach($searchForm->searchFields as $k=>$v){ $searchForm->searchFields[$k]['value']=$_SESSION[$user_name."_PREFERENCES"]['global']['EcmProductsQ'][$k.'_advanced']; } $where_clauses = $searchForm->generateSearchWhere(true, "EcmProduct"); if (count($where_clauses) > 0 ){ foreach($where_clauses as $wh){ if(!eregi("ecmproducts.assigned_user_id",$wh) && !eregi("ecmproducts.product_category_name",$wh) && !eregi("ecmproducts.product_active",$wh) && !eregi("ecmproducts.end_of_line",$wh))$wwh[]=$wh; } $where_clauses=array(); $where_clauses=$wwh; } if(count($searchForm->searchFields['assigned_user_id']['value'])>0){ $w_clauses=array(); foreach($searchForm->searchFields['assigned_user_id']['value'] as $auid){ $w_clauses[]="ecmproducts.assigned_user_id='".$auid."'"; } $where_clauses[]="(".implode(" or ",$w_clauses).")"; } if($_REQUEST['searchFormTab']=="advanced_search"){ if($_GET['end_of_line_advanced']!="" && ($_GET['end_of_line_advanced']==1 || $_GET['end_of_line_advanced']=="no")){ if($_GET['end_of_line_advanced']=="no")$where_clauses[]="ecmproducts.end_of_line='0'"; else $where_clauses[]="ecmproducts.end_of_line='1'"; } if($_GET['flag_advanced']!="" && ($_GET['flag_advanced']==1 || $_GET['flag_advanced']=="no")){ if($_GET['flag_advanced']=="no")$where_clauses[]="ecmproducts.flag='0'"; else $where_clauses[]="ecmproducts.flag='1'"; } if($_GET['production_advanced']!="" && ($_GET['production_advanced']==1 || $_GET['production_advanced']=="no")){ if($_GET['production_advanced']=="no")$where_clauses[]="ecmproducts.production='0'"; else $where_clauses[]="ecmproducts.production='1'"; } if($_GET['manufacturer_id_advanced'])$where_clauses[]="ecmproducts.manufacturer_id='".$_GET['manufacturer_id_advanced']."'"; if($_GET['product_category_id_advanced'])$where_clauses[]="ecmproducts.product_category_id='".$_GET['product_category_id_advanced']."'"; if($_GET['product_category_name_advanced'])$where_clauses[]="ecmproducts.product_category_name like '".$_GET['product_category_name_advanced']."%'"; if($_GET['product_active_advanced']==0 && $_GET['product_active_advanced']!="")$where_clauses[]="ecmproducts.product_active='0'"; if($_GET['product_active_advanced']==1 && $_GET['product_active_advanced']!="")$where_clauses[]="ecmproducts.product_active='1'"; if($_GET['code_advanced'])$where_clauses[]="ecmproducts.code like '%".$_GET['code_advanced']."%'"; if($_GET['name_advanced'])$where_clauses[]="ecmproducts.name like '%".$_GET['name_advanced']."%'"; } if($_REQUEST['searchFormTab']=="basic_search"){ if($_GET['flag_basic']!="" && ($_GET['flag_basic']==1 || $_GET['flag_basic']=="no")){ if($_GET['flag_basic']=="no")$where_clauses[]="ecmproducts.flag='0'"; else $where_clauses[]="ecmproducts.flag='1'"; } if($_GET['production_basic']!="" && ($_GET['production_basic']==1 || $_GET['production_basic']==0))$where_clauses[]="ecmproducts.production='".$_GET['production_basic']."'"; if($_GET['manufacturer_id_basic'])$where_clauses[]="ecmproducts.manufacturer_id='".$_GET['manufacturer_id_basic']."'"; if($_GET['product_category_id_basic'])$where_clauses[]="ecmproducts.product_category_id='".$_GET['product_category_id_basic']."'"; if($_GET['product_category_name_basic'])$where_clauses[]="ecmproducts.product_category_name like '".$_GET['product_category_name_basic']."%'"; if($_GET['product_active_basic']==0 && $_GET['product_active_basic']!="")$where_clauses[]="ecmproducts.product_active='0'"; if($_GET['product_active_basic']==1 && $_GET['product_active_basic']!="")$where_clauses[]="ecmproducts.product_active='1'"; if($_GET['code_basic'])$where_clauses[]="ecmproducts.code like '%".$_GET['code_basic']."%'"; if($_GET['name_basic'])$where_clauses[]="ecmproducts.name like '%".$_GET['name_basic']."%'"; } if($_SESSION['add_to_pricebook_id']){ $w=$GLOBALS['db']->query("select ecmproduct_id from ecmpricebooks_ecmproducts where ecmpricebook_id='".$_SESSION['add_to_pricebook_id']."' and deleted='0'"); while($r=$GLOBALS['db']->fetchByAssoc($w)){ $where_clauses[]="ecmproducts.id!='".$r['ecmproduct_id']."'"; } } if (count($where_clauses) > 0 )$where = implode(' and ', $where_clauses); $GLOBALS['log']->info("Here is the where clause for the list view: $where"); } $searchForm->lv=$lv; if(!isset($_REQUEST['search_form']) || $_REQUEST['search_form'] != 'false') { $searchForm->setup($searchdefs, $searchFields, 'include/SearchForm/tpls/SearchFormGeneric.tpl', "advanced", $listViewDefs); if(isset($_REQUEST['searchFormTab']) && $_REQUEST['searchFormTab'] == 'advanced_search') { $searchForm->displayAdvanced(true); } elseif(isset($_REQUEST['searchFormTab']) && $_REQUEST['searchFormTab'] == 'saved_views'){ $searchForm->displaySavedViews($listViewDefs, $lv); } else { $searchForm->displayBasic(true); } } //print_r($searchForm->searchFields); echo $qsd->GetQSScripts(); $ListView = new ListView(); $ListView->show_mass_update = false; $ListView->show_mass_update_form = false; $ListView->multiSelect=false; $ListView->show_export_button = false; $ListView->show_delete_button = false; $ListView->show_select_menu = false; $ListView->initNewXTemplate('modules/EcmProducts/ListView1.html',$current_module_strings); $ListView->setHeaderTitle($current_module_strings['LBL_LIST_FORM_TITLE']); $ListView->setQuery($where, "", "ecmproducts.name asc", "ECMPRODUCT"); $ListView->processListView($seedEcmProduct, "main", "ECMPRODUCT"); $savedSearch = new SavedSearch(); $json = getJSONobj(); $savedSearchSelects = $json->encode(array($GLOBALS['app_strings']['LBL_SAVED_SEARCH_SHORTCUT'] . '