[ Index ]
 

Code source de vtiger CRM 5.0.2

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

title

Body

[fermer]

/modules/Potentials/ -> 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/Potentials/Potentials.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/ComboUtil.php');
  23  require_once ('include/utils/utils.php');
  24  require_once ('modules/CustomView/CustomView.php');
  25  require_once ('include/database/Postgres8.php');
  26  require_once ('include/DatabaseUtil.php');
  27  
  28  
  29  global $app_strings,$list_max_entries_per_page;
  30  
  31  $log = LoggerManager::getLogger('potential_list');
  32  
  33  global $currentModule,$theme;
  34  
  35  $category = getParentTab();
  36  
  37  if (!isset($where)) $where = "";
  38  
  39  $url_string = ''; // assigning http url string
  40  
  41  $focus = new Potentials();
  42  $smarty = new vtigerCRM_Smarty();
  43  $other_text = Array();
  44  
  45  if(!$_SESSION['lvs'][$currentModule])
  46  {
  47      unset($_SESSION['lvs']);
  48      $modObj = new ListViewSession();
  49      $modObj->sorder = $sorder;
  50      $modObj->sortby = $order_by;
  51      $_SESSION['lvs'][$currentModule] = get_object_vars($modObj);
  52  }
  53  
  54  if($_REQUEST['errormsg'] != '')
  55  {
  56          $errormsg = $_REQUEST['errormsg'];
  57          $smarty->assign("ERROR","The User does not have permission to Change/Delete ".$errormsg." ".$currentModule);
  58  }else
  59  {
  60          $smarty->assign("ERROR","");
  61  }
  62  //<<<<<<<<<<<<<<<<<<< sorting - stored in session >>>>>>>>>>>>>>>>>>>>
  63  $sorder = $focus->getSortOrder();
  64  $order_by = $focus->getOrderBy();
  65  
  66  $_SESSION['POTENTIALS_ORDER_BY'] = $order_by;
  67  $_SESSION['POTENTIALS_SORT_ORDER'] = $sorder;
  68  //<<<<<<<<<<<<<<<<<<< sorting - stored in session >>>>>>>>>>>>>>>>>>>>
  69  
  70  if(isset($_REQUEST['query']) && $_REQUEST['query'] == 'true')
  71  {
  72      list($where, $ustring) = split("#@@#",getWhereCondition($currentModule));
  73      // we have a query
  74      $url_string .="&query=true".$ustring;
  75      $log->info("Here is the where clause for the list view: $where");
  76      $smarty->assign("SEARCH_URL",$url_string);
  77                  
  78      //Added for Custom Field Search
  79  /*    $sql="select * from vtiger_field where vtiger_tablename='potentialscf' order by vtiger_fieldlabel";
  80      $result=$adb->query($sql);
  81      for($i=0;$i<$adb->num_rows($result);$i++)
  82      {
  83          $column[$i]=$adb->query_result($result,$i,'columnname');
  84          $fieldlabel[$i]=$adb->query_result($result,$i,'fieldlabel');
  85          $uitype[$i]=$adb->query_result($result,$i,'uitype');
  86          if (isset($_REQUEST[$column[$i]])) $customfield[$i] = $_REQUEST[$column[$i]];
  87  
  88          if(isset($customfield[$i]) && $customfield[$i] != '')
  89          {
  90              if($uitype[$i] == 56)
  91                  $str = " vtiger_potentialscf.".$column[$i]." = 1";
  92              elseif($uitype[$i] == 15)//Added to handle the picklist customfield - after 4.2 patch2
  93                  $str = " vtiger_potentialscf.".$column[$i]." = '".$customfield[$i]."'";
  94              else
  95                  $str = " vtiger_potentialscf.".$column[$i]." like '$customfield[$i]%'";
  96              array_push($where_clauses, $str);
  97              $url_string .="&".$column[$i]."=".$customfield[$i];
  98          }
  99      }
 100  
 101  */
 102  }
 103  
 104  //<<<<cutomview>>>>>>>
 105  $oCustomView = new CustomView("Potentials");
 106  $viewid = $oCustomView->getViewId($currentModule);
 107  $customviewcombo_html = $oCustomView->getCustomViewCombo($viewid);
 108  $viewnamedesc = $oCustomView->getCustomViewByCvid($viewid);
 109  //<<<<<customview>>>>>
 110  $smarty->assign("CHANGE_OWNER",getUserslist());
 111  $smarty->assign("CHANGE_GROUP_OWNER",getGroupslist());
 112  if(isPermitted('Potentials','Delete','') == 'yes')
 113  {
 114      $other_text['del'] = $app_strings[LBL_MASS_DELETE];
 115  }
 116  if(isPermitted('Potentials','EditView','') == 'yes')
 117  {
 118          $other_text['c_owner'] = $app_strings[LBL_CHANGE_OWNER];
 119  }
 120  
 121  if($viewnamedesc['viewname'] == 'All')
 122  {
 123      $smarty->assign("ALL", 'All');
 124  }
 125  
 126  //Retreive the list from Database
 127  //<<<<<<<<<customview>>>>>>>>>
 128  if($viewid != "0")
 129  {
 130      $listquery = getListQuery("Potentials");
 131      $list_query = $oCustomView->getModifiedCvListQuery($viewid,$listquery,"Accounts");
 132  }else
 133  {
 134      $list_query = getListQuery("Potentials");
 135  }
 136  //<<<<<<<<customview>>>>>>>>>
 137  
 138  if(isset($where) && $where != '')
 139  {
 140      if(isset($_REQUEST['from_dashboard']) && $_REQUEST['from_dashboard'] == 'true')
 141          $list_query .= " AND vtiger_potential.sales_stage = 'Closed Won' AND ".$where;
 142      else
 143          $list_query .= " AND ".$where;
 144  }
 145  
 146  if(isset($order_by) && $order_by != '')
 147  {
 148      if($order_by == 'smownerid')
 149          {
 150          if( $adb->dbType == "pgsql")
 151               $list_query .= ' GROUP BY user_name';
 152                  $list_query .= ' ORDER BY user_name '.$sorder;
 153          }
 154          else
 155          {
 156          $tablename = getTableNameForField('Potentials',$order_by);
 157          $tablename = (($tablename != '')?($tablename."."):'');
 158  
 159          if( $adb->dbType == "pgsql")
 160               $list_query .= ' GROUP BY '.$tablename.$order_by;
 161  
 162                  $list_query .= ' ORDER BY '.$tablename.$order_by.' '.$sorder;
 163          }
 164  
 165  }
 166  
 167  //Constructing the list view
 168  
 169  $smarty->assign("MOD", $mod_strings);
 170  $smarty->assign("APP", $app_strings);
 171  $smarty->assign("IMAGE_PATH",$image_path);
 172  $smarty->assign("CUSTOMVIEW_OPTION",$customviewcombo_html);
 173  $smarty->assign("VIEWID", $viewid);
 174  $smarty->assign("MODULE",$currentModule);
 175  $smarty->assign("SINGLE_MOD",'Opportunity');
 176  $smarty->assign("BUTTONS",$other_text);
 177  $smarty->assign("CATEGORY",$category);
 178  
 179  
 180  //Retreiving the no of rows
 181  $count_result = $adb->query( mkCountQuery( $list_query));
 182  $noofrows = $adb->query_result($count_result,0,"count");
 183  
 184  //Storing Listview session object
 185  if($_SESSION['lvs'][$currentModule])
 186  {
 187      setSessionVar($_SESSION['lvs'][$currentModule],$noofrows,$list_max_entries_per_page);
 188  }
 189  
 190  $start = $_SESSION['lvs'][$currentModule]['start'];
 191  
 192  //Retreive the Navigation array
 193  $navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page);
 194  //Postgres 8 fixes
 195  if( $adb->dbType == "pgsql")
 196      $list_query = fixPostgresQuery( $list_query, $log, 0);
 197  
 198  
 199  // Setting the record count string
 200  //modified by rdhital
 201  $start_rec = $navigation_array['start'];
 202  $end_rec = $navigation_array['end_val']; 
 203  //By Raju Ends
 204  
 205  //limiting the query
 206  if ($start_rec ==0) 
 207      $limit_start_rec = 0;
 208  else
 209      $limit_start_rec = $start_rec -1;
 210      
 211  if( $adb->dbType == "pgsql")
 212       $list_result = $adb->query($list_query. " OFFSET ".$limit_start_rec." LIMIT ".$list_max_entries_per_page);
 213   else
 214       $list_result = $adb->query($list_query. " LIMIT ".$limit_start_rec.",".$list_max_entries_per_page);
 215  
 216  $record_string= $app_strings[LBL_SHOWING]." " .$start_rec." - ".$end_rec." " .$app_strings[LBL_LIST_OF] ." ".$noofrows;
 217  
 218  //Retreive the List View Table Header
 219  if($viewid !='')
 220  $url_string .="&viewname=".$viewid;
 221  
 222  $listview_header = getListViewHeader($focus,"Potentials",$url_string,$sorder,$order_by,"",$oCustomView);
 223  $smarty->assign("LISTHEADER", $listview_header);
 224  
 225  $listview_header_search=getSearchListHeaderValues($focus,"Potentials",$url_string,$sorder,$order_by,"",$oCustomView);
 226  $smarty->assign("SEARCHLISTHEADER", $listview_header_search);
 227  
 228  
 229  $listview_entries = getListViewEntries($focus,"Potentials",$list_result,$navigation_array,"","","EditView","Delete",$oCustomView);
 230  $smarty->assign("LISTHEADER", $listview_header);
 231  $smarty->assign("LISTENTITY", $listview_entries);
 232  
 233  
 234  $navigationOutput = getTableHeaderNavigation($navigation_array, $url_string,"Potentials","index",$viewid);
 235  $alphabetical = AlphabeticalSearch($currentModule,'index','potentialname','true','basic',"","","","",$viewid);
 236  $fieldnames = getAdvSearchfields($module);
 237  $criteria = getcriteria_options();
 238  $smarty->assign("CRITERIA", $criteria);
 239  $smarty->assign("FIELDNAMES", $fieldnames);
 240  $smarty->assign("ALPHABETICAL", $alphabetical);
 241  $smarty->assign("NAVIGATION", $navigationOutput);
 242  $smarty->assign("RECORD_COUNTS", $record_string);
 243  $smarty->assign("SELECT_SCRIPT", $view_script);
 244  
 245  $check_button = Button_Check($module);
 246  $smarty->assign("CHECK", $check_button);
 247  
 248  if(isset($_REQUEST['ajax']) && $_REQUEST['ajax'] != '')
 249      $smarty->display("ListViewEntries.tpl");
 250  else    
 251      $smarty->display("ListView.tpl");
 252  
 253  ?>


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