[ Index ]
 

Code source de vtiger CRM 5.0.2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/modules/Accounts/ -> ListView.php (source)

   1  <?php
   2  /*********************************************************************************
   3   * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
   4   * ("License"); You may not use this file except in compliance with the
   5   * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
   6   * Software distributed under the License is distributed on an  "AS IS"  basis,
   7   * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
   8   * the specific language governing rights and limitations under the License.
   9   * The Original Code is:  SugarCRM Open Source
  10   * The Initial Developer of the Original Code is SugarCRM, Inc.
  11   * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
  12   * All Rights Reserved.
  13   * Contributor(s): ______________________________________.
  14   ********************************************************************************/
  15  
  16  require_once ('Smarty_setup.php');
  17  require_once ("data/Tracker.php");
  18  require_once ('modules/Accounts/Accounts.php');
  19  require_once('themes/'.$theme.'/layout_utils.php');
  20  require_once ('include/logging.php');
  21  require_once ('include/ListView/ListView.php');
  22  require_once ('include/database/PearDatabase.php');
  23  require_once ('include/ComboUtil.php');
  24  require_once ('include/utils/utils.php');
  25  require_once ('modules/CustomView/CustomView.php');
  26  require_once ('include/database/Postgres8.php');
  27  require_once ('include/DatabaseUtil.php');
  28  
  29  global $app_strings;
  30  global $list_max_entries_per_page;
  31  
  32  $log = LoggerManager::getLogger('account_list');
  33  
  34  global $currentModule;
  35  global $theme;
  36  
  37  $category = getParentTab();
  38  
  39  // focus_list is the means of passing data to a ListView.
  40  global $focus_list;
  41  
  42  if (!isset($where)) $where = "";
  43  
  44  $url_string = '';
  45  
  46  $focus = new Accounts();
  47  $smarty = new vtigerCRM_Smarty;
  48  $other_text = Array();
  49  
  50  if(!$_SESSION['lvs'][$currentModule])
  51  {
  52      unset($_SESSION['lvs']);
  53      $modObj = new ListViewSession();
  54      $modObj->sorder = $sorder;
  55      $modObj->sortby = $order_by;
  56      $_SESSION['lvs'][$currentModule] = get_object_vars($modObj);
  57  }
  58  
  59  if($_REQUEST['errormsg'] != '')
  60  {
  61          $errormsg = $_REQUEST['errormsg'];
  62          $smarty->assign("ERROR","The User does not have permission to Change/Delete ".$errormsg." ".$currentModule);
  63  }else
  64  {
  65          $smarty->assign("ERROR","");
  66  }
  67                      
  68  //<<<<<<< sort ordering >>>>>>>>>>>>>
  69  $sorder = $focus->getSortOrder();
  70  $order_by = $focus->getOrderBy();
  71  
  72  $_SESSION['ACCOUNTS_ORDER_BY'] = $order_by;
  73  $_SESSION['ACCOUNTS_SORT_ORDER'] = $sorder;
  74  //<<<<<<< sort ordering >>>>>>>>>>>>>
  75  
  76  //<<<<cutomview>>>>>>>
  77  $oCustomView = new CustomView($currentModule);
  78  $viewid = $oCustomView->getViewId($currentModule);
  79  $customviewcombo_html = $oCustomView->getCustomViewCombo($viewid);
  80  $viewnamedesc = $oCustomView->getCustomViewByCvid($viewid);
  81  //<<<<<customview>>>>>
  82  $smarty->assign("CHANGE_OWNER",getUserslist());
  83  $smarty->assign("CHANGE_GROUP_OWNER",getGroupslist());
  84  if(isset($_REQUEST['query']) && $_REQUEST['query'] == 'true')
  85  {
  86      list($where, $ustring) = split("#@@#",getWhereCondition($currentModule));
  87      // we have a query
  88      $url_string .="&query=true".$ustring;
  89      $log->info("Here is the where clause for the list view: $where");
  90      $smarty->assign("SEARCH_URL",$url_string);
  91                  
  92  }
  93  if($viewid != 0)
  94  {
  95      $CActionDtls = $oCustomView->getCustomActionDetails($viewid);
  96  }
  97  if(isPermitted('Accounts','Delete','') == 'yes')
  98  {
  99      $other_text['del'] = $app_strings[LBL_MASS_DELETE];
 100  }
 101  if(isPermitted('Accounts','EditView','') == 'yes')
 102  {
 103              $other_text['c_owner'] = $app_strings[LBL_CHANGE_OWNER];
 104  }
 105  if(isPermitted('Emails','EditView','') == 'yes')
 106  {
 107      $other_text['s_mail'] = $app_strings[LBL_SEND_MAIL_BUTTON];
 108  }        
 109  if(isset($CActionDtls))
 110  {
 111      $other_text['s_cmail'] = $app_strings[LBL_SEND_CUSTOM_MAIL_BUTTON];
 112  }
 113  
 114  if($viewnamedesc['viewname'] == 'All')
 115  {
 116      $smarty->assign("ALL", 'All');
 117  }
 118  
 119  global $theme;
 120  $theme_path="themes/".$theme."/";
 121  $image_path=$theme_path."images/";
 122  $smarty->assign("MOD", $mod_strings);
 123  $smarty->assign("APP", $app_strings);
 124  $smarty->assign("IMAGE_PATH",$image_path);
 125  $smarty->assign("CUSTOMVIEW_OPTION",$customviewcombo_html);
 126  $smarty->assign("VIEWID", $viewid);
 127  $smarty->assign("BUTTONS",$other_text);
 128  $smarty->assign("MODULE",$currentModule);
 129  $smarty->assign("SINGLE_MOD",'Account');
 130  
 131  
 132  //Retreive the list from Database
 133  //<<<<<<<<<customview>>>>>>>>>
 134  if($viewid != "0")
 135  {
 136      $listquery = getListQuery("Accounts");
 137      $query = $oCustomView->getModifiedCvListQuery($viewid,$listquery,"Accounts");
 138  }else
 139  {
 140      $query = getListQuery("Accounts");
 141  }
 142  //<<<<<<<<customview>>>>>>>>>
 143  
 144  if(isset($where) && $where != '')
 145  {
 146      $query .= ' and '.$where;
 147  }
 148  
 149  $view_script = "<script language='javascript'>
 150  	function set_selected()
 151      {
 152          len=document.massdelete.viewname.length;
 153          for(i=0;i<len;i++)
 154          {
 155              if(document.massdelete.viewname[i].value == '$viewid')
 156                  document.massdelete.viewname[i].selected = true;
 157          }
 158      }
 159      set_selected();
 160      </script>";
 161  
 162  if(isset($order_by) && $order_by != '')
 163  {    
 164      if($order_by == 'smownerid')
 165          {
 166          if( $adb->dbType == "pgsql")
 167               $query .= ' GROUP BY user_name';
 168                  $query .= ' ORDER BY user_name '.$sorder;
 169          }
 170          else
 171          {
 172          $tablename = getTableNameForField('Accounts',$order_by);
 173          $tablename = (($tablename != '')?($tablename."."):'');
 174          if( $adb->dbType == "pgsql")
 175               $query .= ' GROUP BY '.$tablename.$order_by;    
 176          
 177                  $query .= ' ORDER BY '.$tablename.$order_by.' '.$sorder;
 178          }
 179  }
 180  
 181  //Retreiving the no of rows
 182  
 183  $count_result = $adb->query( mkCountQuery( $query));
 184  $noofrows = $adb->query_result($count_result,0,"count");
 185  
 186  //Storing Listview session object
 187  if($_SESSION['lvs'][$currentModule])
 188  {
 189      setSessionVar($_SESSION['lvs'][$currentModule],$noofrows,$list_max_entries_per_page);
 190  }
 191  
 192  $start = $_SESSION['lvs'][$currentModule]['start'];
 193  
 194  
 195  //Retreive the Navigation array
 196  $navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page);
 197   //Postgres 8 fixes
 198   if( $adb->dbType == "pgsql")
 199       $query = fixPostgresQuery( $query, $log, 0);
 200  
 201  // Setting the record count string
 202  //modified by rdhital
 203  $start_rec = $navigation_array['start'];
 204  $end_rec = $navigation_array['end_val']; 
 205  //By Raju Ends
 206  
 207  //limiting the query
 208  if ($start_rec ==0) 
 209      $limit_start_rec = 0;
 210  else
 211      $limit_start_rec = $start_rec -1;
 212      
 213   if( $adb->dbType == "pgsql")
 214       $list_result = $adb->query($query. " OFFSET ".$limit_start_rec." LIMIT ".$list_max_entries_per_page);
 215   else
 216       $list_result = $adb->query($query. " LIMIT ".$limit_start_rec.",".$list_max_entries_per_page);
 217  
 218  //mass merge for word templates -- *Raj*17/11
 219  while($row = $adb->fetch_array($list_result))
 220  {
 221      $ids[] = $row["crmid"];
 222  }
 223  if(isset($ids))
 224  {
 225      $smarty->assign("ALLIDS", implode($ids,";"));
 226  }
 227  if(isPermitted("Accounts","Merge") == 'yes') 
 228  {
 229      $smarty->assign("MERGEBUTTON","<td><input title=\"$app_strings[LBL_MERGE_BUTTON_TITLE]\" accessKey=\"$app_strings[LBL_MERGE_BUTTON_KEY]\" class=\"crmbutton small create\" onclick=\"return massMerge('Accounts')\" type=\"submit\" name=\"Merge\" value=\" $app_strings[LBL_MERGE_BUTTON_LABEL]\"></td>");
 230      $wordTemplateResult = fetchWordTemplateList("Accounts");
 231      $tempCount = $adb->num_rows($wordTemplateResult);
 232      $tempVal = $adb->fetch_array($wordTemplateResult);
 233      for($templateCount=0;$templateCount<$tempCount;$templateCount++)
 234      {
 235          $optionString .="<option value=\"".$tempVal["templateid"]."\">" .$tempVal["filename"] ."</option>";
 236          $tempVal = $adb->fetch_array($wordTemplateResult);
 237      }
 238      $smarty->assign("WORDTEMPLATEOPTIONS","<td>".$app_strings['LBL_SELECT_TEMPLATE_TO_MAIL_MERGE']."</td><td style=\"padding-left:5px;padding-right:5px\"><select class=\"small\" name=\"mergefile\">".$optionString."</select></td>");
 239  }
 240  //mass merge for word templates
 241  
 242  $record_string= $app_strings[LBL_SHOWING]." " .$start_rec." - ".$end_rec." " .$app_strings[LBL_LIST_OF] ." ".$noofrows;
 243  
 244  //Retreive the List View Table Header
 245  if($viewid !='')
 246  $url_string .= "&viewname=".$viewid;
 247  
 248  $listview_header = getListViewHeader($focus,"Accounts",$url_string,$sorder,$order_by,"",$oCustomView);
 249  $smarty->assign("LISTHEADER", $listview_header);
 250  
 251  $listview_header_search=getSearchListHeaderValues($focus,"Accounts",$url_string,$sorder,$order_by,"",$oCustomView);
 252  $smarty->assign("SEARCHLISTHEADER", $listview_header_search);
 253  
 254  
 255  
 256  $listview_entries = getListViewEntries($focus,"Accounts",$list_result,$navigation_array,"","","EditView","Delete",$oCustomView);
 257  $smarty->assign("LISTENTITY", $listview_entries);
 258  $smarty->assign("SELECT_SCRIPT", $view_script);
 259  $smarty->assign("CATEGORY",$category);
 260  
 261  $navigationOutput = getTableHeaderNavigation($navigation_array, $url_string,"Accounts","index",$viewid);
 262  $alphabetical = AlphabeticalSearch($currentModule,'index','accountname','true','basic',"","","","",$viewid);
 263  $fieldnames = getAdvSearchfields($module);
 264  $criteria = getcriteria_options();
 265  $smarty->assign("CRITERIA", $criteria);
 266  $smarty->assign("FIELDNAMES", $fieldnames);
 267  $smarty->assign("ALPHABETICAL", $alphabetical);
 268  $smarty->assign("NAVIGATION", $navigationOutput);
 269  $smarty->assign("RECORD_COUNTS", $record_string);
 270  
 271  $check_button = Button_Check($module);
 272  $smarty->assign("CHECK", $check_button);
 273  
 274  if(isset($_REQUEST['ajax']) && $_REQUEST['ajax'] != '')
 275      $smarty->display("ListViewEntries.tpl");
 276  else    
 277      $smarty->display("ListView.tpl");
 278  
 279  ?>


Généré le : Sun Feb 25 10:22:19 2007 par Balluche grâce à PHPXref 0.7