[ Index ]
 

Code source de vtiger CRM 5.0.2

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

title

Body

[fermer]

/modules/HelpDesk/ -> 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  
  12  global $theme;
  13  $theme_path="themes/".$theme."/";
  14  $image_path=$theme_path."images/";
  15  
  16  require_once ('modules/HelpDesk/HelpDesk.php');
  17  require_once ('include/database/PearDatabase.php');
  18  require_once ('Smarty_setup.php');
  19  require_once ("data/Tracker.php");
  20  require_once ('include/logging.php');
  21  require_once ('include/ListView/ListView.php');
  22  require_once ('include/ComboUtil.php');
  23  require_once('themes/'.$theme.'/layout_utils.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  
  30  global $app_strings;
  31  global $mod_strings;
  32  global $currentModule;
  33  
  34  $focus = new HelpDesk();
  35  $smarty = new vtigerCRM_Smarty;
  36  $category = getParentTab();
  37  $other_text = Array();
  38  
  39  if(!$_SESSION['lvs'][$currentModule])
  40  {
  41      unset($_SESSION['lvs']);
  42      $modObj = new ListViewSession();
  43      $modObj->sorder = $sorder;
  44      $modObj->sortby = $order_by;
  45      $_SESSION['lvs'][$currentModule] = get_object_vars($modObj);
  46  }
  47  
  48  if($_REQUEST['errormsg'] != '')
  49  {
  50          $errormsg = $_REQUEST['errormsg'];
  51          $smarty->assign("ERROR","The User does not have permission to Change/Delete ".$errormsg." ".$currentModule);
  52  }else
  53  {
  54          $smarty->assign("ERROR","");
  55  }
  56  $url_string = ''; // assigning http url string
  57  
  58  //<<<<<<<<<<<<<<<<<<< sorting - stored in session >>>>>>>>>>>>>>>>>>>>
  59  $sorder = $focus->getSortOrder();
  60  $order_by = $focus->getOrderBy();
  61  
  62  $_SESSION['HELPDESK_ORDER_BY'] = $order_by;
  63  $_SESSION['HELPDESK_SORT_ORDER'] = $sorder;
  64  //<<<<<<<<<<<<<<<<<<< sorting - stored in session >>>>>>>>>>>>>>>>>>>>
  65  
  66  
  67  
  68  if(isset($_REQUEST['query']) && $_REQUEST['query'] == 'true')
  69  {
  70      list($where, $ustring) = split("#@@#",getWhereCondition($currentModule));
  71      // we have a query
  72      $url_string .="&query=true".$ustring;
  73      $log->info("Here is the where clause for the list view: $where");
  74      $smarty->assign("SEARCH_URL",$url_string);
  75                  
  76  }
  77  
  78  //<<<<cutomview>>>>>>>
  79  $oCustomView = new CustomView("HelpDesk");
  80  $viewid = $oCustomView->getViewId($currentModule);
  81  $customviewcombo_html = $oCustomView->getCustomViewCombo($viewid);
  82  $viewnamedesc = $oCustomView->getCustomViewByCvid($viewid);
  83  //<<<<<customview>>>>>
  84  $smarty->assign("CHANGE_OWNER",getUserslist());
  85  $smarty->assign("CHANGE_GROUP_OWNER",getGroupslist());
  86  if($viewid != 0)
  87  {
  88          $CActionDtls = $oCustomView->getCustomActionDetails($viewid);
  89  }
  90  // Buttons and View options
  91  if(isPermitted('HelpDesk','Delete','') == 'yes')
  92      $other_text['del'] = $app_strings[LBL_MASS_DELETE];
  93  if(isPermitted('HelpDesk','EditView','') == 'yes')
  94  {
  95          $other_text['c_owner'] = $app_strings[LBL_CHANGE_OWNER];
  96  }
  97  if($viewnamedesc['viewname'] == 'All')
  98  {
  99      $smarty->assign("ALL", 'All');
 100  }
 101  $smarty->assign("CUSTOMVIEW_OPTION",$customviewcombo_html);
 102  $smarty->assign("VIEWID", $viewid);
 103  $smarty->assign("MOD", $mod_strings);
 104  $smarty->assign("APP", $app_strings);
 105  $smarty->assign("IMAGE_PATH",$image_path);
 106  $smarty->assign("MODULE",$currentModule);
 107  $smarty->assign("BUTTONS",$other_text);
 108  $smarty->assign("CATEGORY",$category);
 109  $smarty->assign("SINGLE_MOD",'HelpDesk');
 110  
 111  //Retreive the list from Database
 112  //<<<<<<<<<customview>>>>>>>>>
 113  if($viewid != "0")
 114  {
 115      $listquery = getListQuery("HelpDesk");
 116      $list_query = $oCustomView->getModifiedCvListQuery($viewid,$listquery,"HelpDesk");
 117  }
 118  else
 119  {
 120      $list_query = getListQuery("HelpDesk");
 121  }
 122  //<<<<<<<<customview>>>>>>>>>
 123  
 124  if(isset($where) && $where != '')
 125  {
 126      if(isset($_REQUEST['from_homepagedb']) && $_REQUEST['from_homepagedb'] == 'true')
 127                  $list_query .= ' and vtiger_troubletickets.status!="Closed" or vtiger_troubletickets.status is null and '.$where;
 128      $list_query .= ' and '.$where;
 129  }
 130  
 131  //sort by "assignedto" and default sort by "ticketid"(DESC)
 132  if(isset($order_by) && $order_by != '')
 133  {
 134      if($order_by == 'smownerid')
 135      {
 136          if( $adb->dbType == "pgsql")
 137               $list_query .= ' GROUP BY vtiger_users.user_name';
 138          $list_query .= ' ORDER BY vtiger_users.user_name '.$sorder;
 139      }
 140      else
 141      {
 142          $tablename = getTableNameForField('HelpDesk',$order_by);
 143          $tablename = (($tablename != '')?($tablename."."):'');
 144          if( $adb->dbType == "pgsql")
 145               $list_query .= ' GROUP BY '.$tablename.$order_by;
 146          
 147              $list_query .= ' ORDER BY '.$tablename.$order_by.' '.$sorder;
 148      }
 149  }
 150  else
 151  {
 152      if( $adb->dbType == "pgsql")
 153           $list_query .= ' GROUP BY vtiger_troubletickets.ticketid';
 154       $list_query .= ' ORDER BY vtiger_troubletickets.ticketid DESC';    
 155  }
 156  
 157  //Constructing the list view
 158  
 159  //Retreiving the no of rows
 160  $count_result = $adb->query( mkCountQuery( $list_query));
 161  $noofrows = $adb->query_result($count_result,0,"count");
 162  
 163  //Storing Listview session object
 164  if($_SESSION['lvs'][$currentModule])
 165  {
 166      setSessionVar($_SESSION['lvs'][$currentModule],$noofrows,$list_max_entries_per_page);
 167  }
 168  
 169  $start = $_SESSION['lvs'][$currentModule]['start'];
 170  
 171  //Retreive the Navigation array
 172  $navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page);
 173   //Postgres 8 fixes
 174   if( $adb->dbType == "pgsql")
 175       $list_query = fixPostgresQuery( $list_query, $log, 0);
 176  
 177  
 178  
 179  // Setting the record count string
 180  //modified by rdhital
 181  $start_rec = $navigation_array['start'];
 182  $end_rec = $navigation_array['end_val']; 
 183  //By Raju Ends
 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  //mass merge for word templates -- *Raj*17/11
 197  while($row = $adb->fetch_array($list_result))
 198  {
 199      $ids[] = $row["crmid"];
 200  }
 201  if(isset($ids))
 202  {
 203      $smarty->assign("ALLIDS", implode($ids,";"));
 204  }
 205  if(isPermitted("HelpDesk","Merge") == 'yes') 
 206  {
 207      $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('HelpDesk')\" type=\"submit\" name=\"Merge\" value=\" $app_strings[LBL_MERGE_BUTTON_LABEL]\"></td>");
 208      $wordTemplateResult = fetchWordTemplateList("HelpDesk");
 209      $tempCount = $adb->num_rows($wordTemplateResult);
 210      $tempVal = $adb->fetch_array($wordTemplateResult);
 211      for($templateCount=0;$templateCount<$tempCount;$templateCount++)
 212      {
 213          $optionString .="<option value=\"".$tempVal["templateid"]."\">" .$tempVal["filename"] ."</option>";
 214          $tempVal = $adb->fetch_array($wordTemplateResult);
 215      }
 216      $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>");
 217  }
 218  //mass merge for word templates
 219  
 220  $record_string= $app_strings[LBL_SHOWING]." " .$start_rec." - ".$end_rec." " .$app_strings[LBL_LIST_OF] ." ".$noofrows;
 221  
 222  //Retreive the List View Table Header
 223  if($viewid !='')
 224      $url_string .="&viewname=".$viewid;
 225  
 226  $listview_header = getListViewHeader($focus,"HelpDesk",$url_string,$sorder,$order_by,"",$oCustomView);
 227  $smarty->assign("LISTHEADER", $listview_header);
 228  
 229  $listview_header_search = getSearchListHeaderValues($focus,"HelpDesk",$url_string,$sorder,$order_by,"",$oCustomView);
 230  $smarty->assign("SEARCHLISTHEADER",$listview_header_search);
 231  
 232  $listview_entries = getListViewEntries($focus,"HelpDesk",$list_result,$navigation_array,"","","EditView","Delete",$oCustomView);
 233  $smarty->assign("LISTENTITY", $listview_entries);
 234  $smarty->assign("SELECT_SCRIPT", $view_script);
 235  $navigationOutput = getTableHeaderNavigation($navigation_array, $url_string,"HelpDesk","index",$viewid);
 236  $alphabetical = AlphabeticalSearch($currentModule,'index','ticket_title','true','basic',"","","","",$viewid);
 237  $fieldnames = getAdvSearchfields($module);
 238  $criteria = getcriteria_options();
 239  $smarty->assign("CRITERIA", $criteria);
 240  $smarty->assign("FIELDNAMES", $fieldnames);
 241  $smarty->assign("ALPHABETICAL", $alphabetical);
 242  $smarty->assign("NAVIGATION", $navigationOutput);
 243  $smarty->assign("RECORD_COUNTS", $record_string);
 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  ?>


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