[ Index ]
 

Code source de vtiger CRM 5.0.2

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

title

Body

[fermer]

/modules/Contacts/ -> 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   * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Contacts/ListView.php,v 1.25 2005/04/18 10:37:49 samk Exp $
  17   * Description:  TODO: To be written.
  18   * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  19   * All Rights Reserved.
  20   * Contributor(s): ______________________________________..
  21   ********************************************************************************/
  22  
  23  require_once ('Smarty_setup.php');
  24  require_once ("data/Tracker.php");
  25  require_once ('modules/Contacts/Contacts.php');
  26  require_once('themes/'.$theme.'/layout_utils.php');
  27  require_once ('include/logging.php');
  28  require_once ('include/ListView/ListView.php');
  29  require_once ('include/ComboUtil.php');
  30  require_once ('include/utils/utils.php');
  31  require_once ('modules/CustomView/CustomView.php');
  32  require_once ('include/database/Postgres8.php');
  33  require_once ('include/DatabaseUtil.php');
  34  
  35  global $app_strings;
  36  global $list_max_entries_per_page;
  37  
  38  $log = LoggerManager::getLogger('contact_list');
  39  
  40  global $currentModule,$theme;
  41  
  42  $focus = new Contacts();
  43  $smarty = new vtigerCRM_Smarty;
  44  $other_text = Array();
  45  
  46  if(!$_SESSION['lvs'][$currentModule])
  47  {
  48      unset($_SESSION['lvs']);
  49      $modObj = new ListViewSession();
  50      $modObj->sorder = $sorder;
  51      $modObj->sortby = $order_by;
  52      $_SESSION['lvs'][$currentModule] = get_object_vars($modObj);
  53  }
  54  
  55  if($_REQUEST['errormsg'] != '')
  56  {
  57          $errormsg = $_REQUEST['errormsg'];
  58          $smarty->assign("ERROR","The User does not have permission to Change/Delete ".$errormsg." ".$currentModule);
  59  }else
  60  {
  61          $smarty->assign("ERROR","");
  62  }
  63  //<<<<<<<<<<<<<<<<<<< sorting - stored in session >>>>>>>>>>>>>>>>>>>>
  64  $sorder = $focus->getSortOrder();
  65  $order_by = $focus->getOrderBy();
  66  
  67  $_SESSION['CONTACTS_ORDER_BY'] = $order_by;
  68  $_SESSION['CONTACTS_SORT_ORDER'] = $sorder;
  69  //<<<<<<<<<<<<<<<<<<< sorting - stored in session >>>>>>>>>>>>>>>>>>>>
  70  
  71  if (!isset($where)) $where = "";
  72  
  73  $url_string = ''; // assigning http url string
  74  
  75  if(isset($_REQUEST['query']) && $_REQUEST['query'] == 'true')
  76  {
  77      list($where, $ustring) = split("#@@#",getWhereCondition($currentModule));
  78      // we have a query
  79      $url_string .="&query=true".$ustring;
  80      $log->info("Here is the where clause for the list view: $where");
  81      $smarty->assign("SEARCH_URL",$url_string);
  82                  
  83  //Added for Custom Field Search
  84  /*$sql="select * from vtiger_field where vtiger_tablename='contactscf' order by vtiger_fieldlabel";
  85  $result=$adb->query($sql);
  86  for($i=0;$i<$adb->num_rows($result);$i++)
  87  {
  88          $column[$i]=$adb->query_result($result,$i,'columnname');
  89          $fieldlabel[$i]=$adb->query_result($result,$i,'fieldlabel');
  90          $uitype[$i]=$adb->query_result($result,$i,'uitype');
  91          if (isset($_REQUEST[$column[$i]])) $customfield[$i] = $_REQUEST[$column[$i]];
  92  
  93          if(isset($customfield[$i]) && $customfield[$i] != '')
  94          {
  95          if($uitype[$i] == 56)
  96              $str = " vtiger_contactscf.".$column[$i]." = 1";
  97          elseif($uitype[$i] == 15)//Added to handle the picklist customfield - after 4.2 patch2 
  98              $str = " vtiger_contactscf.".$column[$i]." = '".$customfield[$i]."'";
  99          else
 100                  $str = " vtiger_contactscf.".$column[$i]." like '$customfield[$i]%'";
 101                  array_push($where_clauses, $str);
 102          $url_string .="&".$column[$i]."=".$customfield[$i];
 103          }
 104  }
 105  //upto this added for Custom Field
 106  
 107  */
 108  }
 109  
 110  //<<<<cutomview>>>>>>>
 111  $oCustomView = new CustomView("Contacts");
 112  $viewid = $oCustomView->getViewId($currentModule);
 113  $customviewcombo_html = $oCustomView->getCustomViewCombo($viewid);
 114  $viewnamedesc = $oCustomView->getCustomViewByCvid($viewid);
 115  //<<<<<customview>>>>>
 116  $smarty->assign("CHANGE_OWNER",getUserslist());
 117  $smarty->assign("CHANGE_GROUP_OWNER",getGroupslist());
 118  // Buttons and View options
 119  if($viewid != 0)
 120  {
 121      $CActionDtls = $oCustomView->getCustomActionDetails($viewid);
 122  }
 123  if(isPermitted('Contacts','Delete','') == 'yes')
 124  {
 125      $other_text['del'] = $app_strings[LBL_MASS_DELETE];
 126  }
 127  if(isPermitted('Contacts','EditView','') == 'yes')
 128  {
 129          $other_text['c_owner'] = $app_strings[LBL_CHANGE_OWNER];
 130  }
 131  if(isPermitted('Emails','EditView','') == 'yes')
 132      $other_text['s_mail'] = $app_strings[LBL_SEND_MAIL_BUTTON];
 133  
 134  if(isset($CActionDtls))
 135  {
 136      $other_text['s_cmail'] = $app_strings[LBL_SEND_CUSTOM_MAIL_BUTTON];    
 137  }
 138  if($viewnamedesc['viewname'] == 'All')
 139  {
 140      $smarty->assign("ALL", 'All');
 141  }
 142  
 143  //Retreive the list from Database
 144  //<<<<<<<<<customview>>>>>>>>>
 145  if($viewid != "0")
 146  {
 147      $listquery = getListQuery("Contacts");
 148      $list_query = $oCustomView->getModifiedCvListQuery($viewid,$listquery,"Contacts");
 149  }else
 150  {
 151      $list_query = getListQuery("Contacts");
 152  }
 153  //<<<<<<<<customview>>>>>>>>>
 154  
 155  if(isset($where) && $where != '')
 156  {
 157      $list_query .= " AND ".$where;
 158  }
 159  
 160  if(isset($order_by) && $order_by != '')
 161  {
 162      if($order_by == 'smownerid')
 163          {
 164          if( $adb->dbType == "pgsql")
 165               $list_query .= ' GROUP BY user_name';    
 166                  $list_query .= ' ORDER BY user_name '.$sorder;
 167          }
 168          else
 169          {
 170          $tablename = getTableNameForField('Contacts',$order_by);
 171          $tablename = (($tablename != '')?($tablename."."):'');
 172          if( $adb->dbType == "pgsql")
 173               $list_query .= ' GROUP BY '.$tablename.$order_by;
 174          
 175                  $list_query .= ' ORDER BY '.$tablename.$order_by.' '.$sorder;
 176          }
 177  }
 178  
 179  //Constructing the list view
 180  
 181  $custom = get_form_header($current_module_strings['LBL_LIST_FORM_TITLE'],$other_text, false);
 182  $smarty->assign("MOD", $mod_strings);
 183  $smarty->assign("APP", $app_strings);
 184  $smarty->assign("IMAGE_PATH",$image_path);
 185  $smarty->assign("BUTTONS",$other_text);
 186  $category = getParentTab();
 187  $smarty->assign("CATEGORY",$category);
 188  $smarty->assign("CUSTOMVIEW_OPTION",$customviewcombo_html);
 189  $smarty->assign("VIEWID", $viewid);
 190  //Retreiving the no of rows
 191  $count_result = $adb->query( mkCountQuery( $list_query));
 192  $noofrows = $adb->query_result($count_result,0,"count");
 193  //Storing Listview session object
 194  if($_SESSION['lvs'][$currentModule])
 195  {
 196      setSessionVar($_SESSION['lvs'][$currentModule],$noofrows,$list_max_entries_per_page);
 197  }
 198  
 199  $start = $_SESSION['lvs'][$currentModule]['start'];
 200  
 201  //Retreive the Navigation array
 202  $navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page);
 203  //Postgres 8 fixes
 204   if( $adb->dbType == "pgsql")
 205       $list_query = fixPostgresQuery( $list_query, $log, 0);
 206  
 207  
 208  
 209  // Setting the record count string
 210  //modified by rdhital
 211  $start_rec = $navigation_array['start'];
 212  $end_rec = $navigation_array['end_val']; 
 213  //By Raju Ends
 214  
 215  //limiting the query
 216  if ($start_rec ==0) 
 217      $limit_start_rec = 0;
 218  else
 219      $limit_start_rec = $start_rec -1;
 220      
 221  if( $adb->dbType == "pgsql")
 222       $list_result = $adb->query($list_query. " OFFSET ".$limit_start_rec." LIMIT ".$list_max_entries_per_page);
 223  else
 224      $list_result = $adb->query($list_query. " LIMIT ".$limit_start_rec.",".$list_max_entries_per_page);
 225  
 226  //mass merge for word templates -- *Raj*17/11
 227  while($row = $adb->fetch_array($list_result))
 228  {
 229      $ids[] = $row["crmid"];
 230  }
 231  if(isset($ids))
 232  {
 233      $smarty->assign("ALLIDS", implode($ids,";"));
 234  }
 235  if(isPermitted("Contacts","Merge") == 'yes') 
 236  {
 237      $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('Contacts')\" type=\"submit\" name=\"Merge\" value=\" $app_strings[LBL_MERGE_BUTTON_LABEL]\"></td>");
 238      $wordTemplateResult = fetchWordTemplateList("Contacts");
 239      $tempCount = $adb->num_rows($wordTemplateResult);
 240      $tempVal = $adb->fetch_array($wordTemplateResult);
 241      for($templateCount=0;$templateCount<$tempCount;$templateCount++)
 242      {
 243          $optionString .="<option value=\"".$tempVal["templateid"]."\">" .$tempVal["filename"] ."</option>";
 244          $tempVal = $adb->fetch_array($wordTemplateResult);
 245      }
 246      $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>");
 247  }
 248  //mass merge for word templates
 249  
 250  $record_string= $app_strings[LBL_SHOWING]." " .$start_rec." - ".$end_rec." " .$app_strings[LBL_LIST_OF] ." ".$noofrows;
 251  
 252  //Retreive the List View Table Header
 253  if($viewid !='')
 254  $url_string .="&viewname=".$viewid;
 255  
 256  $listview_header = getListViewHeader($focus,"Contacts",$url_string,$sorder,$order_by,"",$oCustomView);
 257  $smarty->assign("LISTHEADER", $listview_header);
 258  
 259  $listview_header_search=getSearchListHeaderValues($focus,"Contacts",$url_string,$sorder,$order_by,"",$oCustomView);
 260  $smarty->assign("SEARCHLISTHEADER", $listview_header_search);
 261  
 262  
 263  $listview_entries = getListViewEntries($focus,"Contacts",$list_result,$navigation_array,"","","EditView","Delete",$oCustomView);
 264  $smarty->assign("LISTENTITY", $listview_entries);
 265  $smarty->assign("SELECT_SCRIPT", $view_script);
 266  
 267  $navigationOutput = getTableHeaderNavigation($navigation_array, $url_string,"Contacts","index",$viewid);
 268  $alphabetical = AlphabeticalSearch($currentModule,'index','lastname','true','basic',"","","","",$viewid);
 269  $fieldnames = getAdvSearchfields($module);
 270  $criteria = getcriteria_options();
 271  $smarty->assign("CRITERIA", $criteria);
 272  $smarty->assign("FIELDNAMES", $fieldnames);
 273  $smarty->assign("NAVIGATION", $navigationOutput);
 274  $smarty->assign("ALPHABETICAL", $alphabetical);
 275  $smarty->assign("RECORD_COUNTS", $record_string);
 276  $smarty->assign("MODULE", $currentModule);
 277  $smarty->assign("SINGLE_MOD", 'Contact');
 278  
 279  $check_button = Button_Check($module);
 280  $smarty->assign("CHECK", $check_button);
 281  
 282  if(isset($_REQUEST['ajax']) && $_REQUEST['ajax'] != '')
 283      $smarty->display("ListViewEntries.tpl");
 284  else    
 285      $smarty->display("ListView.tpl");
 286  
 287  ?>


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