Hi,
For Accounts I have a custom view.list.php that filters out all Accounts that have an assigned team of Global. But if a user searches then I want to show Global teamed Accounts also, for some reason now. when I search as a normal user any Account with a Team of Global is appearing twice in the listview. There are no duplicate accounts in the DB, I have checked.
Then when I log in as admin and do the same search Global Account do not show up twice.
Here is my custom viw.list.php
PHP Code:
require_once('include/MVC/View/views/view.list.php');
class AccountsViewList extends ViewList{
function AccountsViewList()
{
parent::ViewList();
}
/*
* Override listViewProcess with addition to where clause to exclude project templates
*/
function listViewProcess()
{
$this->processSearchForm();
//Chris Lynch 27-05-2010 to not show GLOBAL in default - only if searched on
// RETRIEVE ACCOUNTS WHERE THE TEAM IS NOT GLOBAL
if ($this->where == "")$this->where .= 'accounts.team_id != 1';
$this->lv->searchColumns = $this->searchForm->searchColumns;
if(!$this->headers)
return;
if(empty($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] == false)
{
$this->lv->setup($this->seed, 'include/ListView/ListViewGeneric.tpl', $this->where, $this->params);
$savedSearchName = empty($_REQUEST['saved_search_select_name']) ? '' : (' - ' . $_REQUEST['saved_search_select_name']);
echo get_form_header($GLOBALS['mod_strings']['LBL_LIST_FORM_TITLE'] . $savedSearchName, '', false);
echo $this->lv->display();
}
}
}
I also have the following two files in the custom accounts, these are used to sort my accounts by a field.
PHP Code:
<?php
require_once('modules/Accounts/Account.php');
class AccountsListView extends Account
{
function create_new_list_query($order_by, $where,$filter=array(),$params=array(), $show_deleted = 0,$join_type='', $return_array = false,$parentbean, $singleSelect = false)
{
$asc = explode('ASC',$order_by);
$desc = explode('DESC',$order_by);
$order_by = "pr_last_name_c ASC";
$ret_array = parent::create_new_list_query($order_by, $where,$filter,$params, $show_deleted,$join_type, $return_array,$parentbean, $singleSelect);
return $ret_array;
}
}
?>
and a Controller.php
PHP Code:
require_once('custom/modules/Accounts/accounts_sort.php');
class AccountsController extends SugarController
{
function action_listview()
{
$this->view_object_map['bean'] = $this->bean;
$this->view = 'list';
$GLOBALS['view'] = $this->view;
$this->bean = new AccountsListView();
}
}
Bookmarks