[ Index ]
 

Code source de vtiger CRM 5.0.2

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

title

Body

[fermer]

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

   1  <?php
   2  /*********************************************************************************
   3  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
   4   * ("License"); You may not use this file except in compliance with the License
   5   * The Original Code is:  vtiger CRM Open Source
   6   * The Initial Developer of the Original Code is vtiger.
   7   * Portions created by vtiger are Copyright (C) vtiger.
   8   * All Rights Reserved.
   9  *
  10   ********************************************************************************/
  11  require_once ('modules/Campaigns/Campaigns.php');
  12  require_once ('include/database/PearDatabase.php');
  13  require_once ('Smarty_setup.php');
  14  require_once ("data/Tracker.php");
  15  require_once ('include/logging.php');
  16  require_once ('include/ListView/ListView.php');
  17  require_once ('include/ComboUtil.php');
  18  require_once('themes/'.$theme.'/layout_utils.php');
  19  require_once ('include/utils/utils.php');
  20  require_once ('modules/CustomView/CustomView.php');
  21  require_once ('include/database/Postgres8.php');
  22  require_once ('include/DatabaseUtil.php');
  23  
  24  global $app_strings,$mod_strings,$current_language;
  25  $current_module_strings = return_module_language($current_language, 'Campaigns');
  26  
  27  global $currentModule,$theme;
  28  $theme_path="themes/".$theme."/";
  29  $image_path=$theme_path."images/";
  30  
  31  $focus = new Campaigns();
  32  $category = getParentTab();
  33  $smarty = new vtigerCRM_Smarty;
  34  $other_text = Array();
  35  $url_string = ''; // assigning http url string
  36  
  37  if(!$_SESSION['lvs'][$currentModule])
  38  {
  39      unset($_SESSION['lvs']);
  40      $modObj = new ListViewSession();
  41      $modObj->sorder = $sorder;
  42      $modObj->sortby = $order_by;
  43      $_SESSION['lvs'][$currentModule] = get_object_vars($modObj);
  44  }
  45  
  46  if($_REQUEST['errormsg'] != '')
  47  {
  48          $errormsg = $_REQUEST['errormsg'];
  49          $smarty->assign("ERROR","The User does not have permission to Change/Delete ".$errormsg." ".$currentModule);
  50  }else
  51  {
  52          $smarty->assign("ERROR","");
  53  }
  54  
  55  //<<<<<<<<<<<<<<<<<<< sorting - stored in session >>>>>>>>>>>>>>>>>>>>
  56  $sorder = $focus->getSortOrder();
  57  $order_by = $focus->getOrderBy();
  58  
  59  $_SESSION['CAMPAIGN_ORDER_BY'] = $order_by;
  60  $_SESSION['CAMPAIGN_SORT_ORDER'] = $sorder;
  61  //<<<<<<<<<<<<<<<<<<< sorting - stored in session >>>>>>>>>>>>>>>>>>>>
  62  
  63  
  64  
  65  if(isset($_REQUEST['query']) && $_REQUEST['query'] == 'true')
  66  {
  67      list($where, $ustring) = split("#@@#",getWhereCondition($currentModule));
  68      // we have a query
  69      $url_string .="&query=true".$ustring;
  70      $log->info("Here is the where clause for the list view: $where");
  71      $smarty->assign("SEARCH_URL",$url_string);
  72  }
  73  
  74  //<<<<cutomview>>>>>>>
  75  $oCustomView = new CustomView("Campaigns");
  76  $viewid = $oCustomView->getViewId($currentModule);
  77  $customviewcombo_html = $oCustomView->getCustomViewCombo($viewid);
  78  $viewnamedesc = $oCustomView->getCustomViewByCvid($viewid);
  79  $smarty->assign("CHANGE_OWNER",getUserslist());
  80  $smarty->assign("CHANGE_GROUP_OWNER",getGroupslist());
  81  //<<<<<customview>>>>>
  82  
  83  if($viewid != 0)
  84  {
  85          $CActionDtls = $oCustomView->getCustomActionDetails($viewid);
  86  }
  87  // Buttons and View options
  88  if(isPermitted('Campaigns','Delete','') == 'yes')
  89  {
  90          $other_text ['del']=$app_strings[LBL_MASS_DELETE];
  91  }
  92  if(isPermitted('Campaigns','EditView','') == 'yes')
  93  {
  94          $other_text['c_owner'] = $app_strings[LBL_CHANGE_OWNER];
  95  }
  96  if($viewnamedesc['viewname'] == 'All')
  97  {
  98      $smarty->assign("ALL", 'All');
  99  }
 100  
 101  $customview= get_form_header($current_module_strings['LBL_LIST_FORM_TITLE'],$other_text, false);
 102  $smarty->assign("CUSTOMVIEW_OPTION",$customviewcombo_html);
 103  $smarty->assign("VIEWID", $viewid);
 104  $smarty->assign("MOD", $mod_strings);
 105  $smarty->assign("APP", $app_strings);
 106  $smarty->assign("IMAGE_PATH",$image_path);
 107  $smarty->assign("MODULE",$currentModule);
 108  $smarty->assign("BUTTONS",$other_text);
 109  $smarty->assign("CATEGORY",$category);
 110  $smarty->assign("SINGLE_MOD",'Campaign');
 111  
 112  //Retreive the list from Database
 113  //<<<<<<<<<customview>>>>>>>>>
 114  if($viewid != "0")
 115  {
 116      $listquery = getListQuery("Campaigns");
 117      $list_query = $oCustomView->getModifiedCvListQuery($viewid,$listquery,"Campaigns");
 118  }
 119  else
 120  {
 121      $list_query = getListQuery("Campaigns");
 122  }
 123  //<<<<<<<<customview>>>>>>>>>
 124  
 125  if(isset($where) && $where != '')
 126  {
 127      $list_query .= ' and '.$where;
 128  }
 129  
 130  //sort by "assignedto" and default sort by "ticketid"(DESC)
 131  if(isset($order_by) && $order_by != '')
 132  {
 133      if($order_by == 'smownerid')
 134      {
 135          if( $adb->dbType == "pgsql")
 136               $list_query .= ' GROUP BY vtiger_users.user_name';
 137          $list_query .= ' ORDER BY vtiger_users.user_name '.$sorder;
 138      }
 139      else
 140      {
 141          $tablename = getTableNameForField('Campaigns',$order_by);
 142          $tablename = (($tablename != '')?($tablename."."):'');
 143          if( $adb->dbType == "pgsql")
 144               $list_query .= ' GROUP BY '.$tablename.$order_by;
 145          
 146              $list_query .= ' ORDER BY '.$tablename.$order_by.' '.$sorder;
 147      }
 148  }
 149  else
 150  {
 151      if( $adb->dbType == "pgsql")
 152           $list_query .= ' GROUP BY vtiger_campaign.campaignid';
 153       $list_query .= ' ORDER BY vtiger_campaign.campaignid DESC';    
 154  }
 155  
 156  //Constructing the list view
 157  
 158  //Retreiving the no of rows
 159  $count_result = $adb->query( mkCountQuery( $list_query));
 160  $noofrows = $adb->query_result($count_result,0,"count");
 161  
 162  //Storing Listview session object
 163  if($_SESSION['lvs'][$currentModule])
 164  {
 165      setSessionVar($_SESSION['lvs'][$currentModule],$noofrows,$list_max_entries_per_page);
 166  }
 167  
 168  $start = $_SESSION['lvs'][$currentModule]['start'];
 169  
 170  //Retreive the Navigation array
 171  $navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page);
 172  
 173  // Setting the record count string
 174  //modified by rdhital
 175  $start_rec = $navigation_array['start'];
 176  $end_rec = $navigation_array['end_val']; 
 177  //By Raju Ends
 178  
 179  
 180   //Postgres 8 fixes
 181   if( $adb->dbType == "pgsql")
 182       $list_query = fixPostgresQuery( $list_query, $log, 0);
 183  
 184  
 185  //limiting the query
 186  if ($start_rec ==0) 
 187      $limit_start_rec = 0;
 188  else
 189      $limit_start_rec = $start_rec -1;
 190  
 191   if( $adb->dbType == "pgsql")
 192       $list_result = $adb->query($list_query. " OFFSET ".$limit_start_rec." LIMIT ".$list_max_entries_per_page);
 193   else
 194       $list_result = $adb->query($list_query. " LIMIT ".$limit_start_rec.",".$list_max_entries_per_page);    
 195      
 196  $list_result = $adb->query($list_query. " limit ".$limit_start_rec.",".$list_max_entries_per_page);
 197  
 198  //mass merge for word templates -- *Raj*17/11
 199  while($row = $adb->fetch_array($list_result))
 200  {
 201      $ids[] = $row["crmid"];
 202  }
 203  if(isset($ids))
 204  {
 205      $smarty->assign("ALLIDS", implode($ids,";"));
 206  }
 207  
 208  $record_string= $app_strings[LBL_SHOWING]." " .$start_rec." - ".$end_rec." " .$app_strings[LBL_LIST_OF] ." ".$noofrows;
 209  
 210  //Retreive the List View Table Header
 211  if($viewid !='')
 212      $url_string .="&viewname=".$viewid;
 213  
 214  $listview_header = getListViewHeader($focus,"Campaigns",$url_string,$sorder,$order_by,"",$oCustomView);
 215  $smarty->assign("LISTHEADER", $listview_header);
 216  
 217  $listview_header_search = getSearchListHeaderValues($focus,"Campaigns",$url_string,$sorder,$order_by,"",$oCustomView);
 218  $smarty->assign("SEARCHLISTHEADER",$listview_header_search);
 219  
 220  $listview_entries = getListViewEntries($focus,"Campaigns",$list_result,$navigation_array,"","","EditView","Delete",$oCustomView);
 221  $smarty->assign("LISTENTITY", $listview_entries);
 222  $smarty->assign("SELECT_SCRIPT", $view_script);
 223  $navigationOutput = getTableHeaderNavigation($navigation_array, $url_string,"Campaigns","index",$viewid);
 224  $alphabetical = AlphabeticalSearch($currentModule,'index','campaignname','true','basic',"","","","",$viewid);
 225  $fieldnames = getAdvSearchfields($module);
 226  $criteria = getcriteria_options();
 227  $smarty->assign("CRITERIA", $criteria);
 228  $smarty->assign("FIELDNAMES", $fieldnames);
 229  $smarty->assign("ALPHABETICAL", $alphabetical);
 230  
 231  $smarty->assign("NAVIGATION", $navigationOutput);
 232  $smarty->assign("RECORD_COUNTS", $record_string);
 233  
 234  $check_button = Button_Check($module);
 235  $smarty->assign("CHECK", $check_button);
 236  
 237  if(isset($_REQUEST['ajax']) && $_REQUEST['ajax'] != '')
 238      $smarty->display("ListViewEntries.tpl");
 239  else    
 240      $smarty->display("ListView.tpl");
 241  ?>


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