[ Index ]
 

Code source de vtiger CRM 5.0.2

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

title

Body

[fermer]

/modules/Invoice/ -> 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/Invoice/Invoice.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,$list_max_entries_per_page,$currentModule,$theme;
  30  
  31  $log = LoggerManager::getLogger('order_list');
  32  
  33  if (!isset($where)) $where = "";
  34  
  35  $url_string = '';
  36  
  37  $focus = new Invoice();
  38  $smarty = new vtigerCRM_Smarty;
  39  $other_text = Array();
  40  
  41  if(!$_SESSION['lvs'][$currentModule])
  42  {
  43      unset($_SESSION['lvs']);
  44      $modObj = new ListViewSession();
  45      $modObj->sorder = $sorder;
  46      $modObj->sortby = $order_by;
  47      $_SESSION['lvs'][$currentModule] = get_object_vars($modObj);
  48  }
  49  
  50  if($_REQUEST['errormsg'] != '')
  51  {
  52          $errormsg = $_REQUEST['errormsg'];
  53          $smarty->assign("ERROR","The User does not have permission to Change/Delete ".$errormsg." ".$currentModule);
  54  }else
  55  {
  56          $smarty->assign("ERROR","");
  57  }
  58  //<<<<<<<<<<<<<<<<<<< sorting - stored in session >>>>>>>>>>>>>>>>>>>>
  59  $sorder = $focus->getSortOrder();
  60  $order_by = $focus->getOrderBy();
  61  
  62  $_SESSION['INVOICE_ORDER_BY'] = $order_by;
  63  $_SESSION['INVOICE_SORT_ORDER'] = $sorder;
  64  //<<<<<<<<<<<<<<<<<<< sorting - stored in session >>>>>>>>>>>>>>>>>>>>
  65  
  66  if(isset($_REQUEST['query']) && $_REQUEST['query'] == 'true')
  67  {
  68      list($where, $ustring) = split("#@@#",getWhereCondition($currentModule));
  69      // we have a query
  70      $url_string .="&query=true".$ustring;
  71      $log->info("Here is the where clause for the list view: $where");
  72      $smarty->assign("SEARCH_URL",$url_string);
  73                  
  74  }
  75  
  76  //<<<<cutomview>>>>>>>
  77  $oCustomView = new CustomView("Invoice");
  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(isPermitted('Invoice','Delete','') == 'yes')
  85  {
  86      $other_text['del'] = $app_strings[LBL_MASS_DELETE];
  87  }
  88  if(isPermitted('Invoice','EditView','') == 'yes')
  89  {
  90          $other_text['c_owner'] = $app_strings[LBL_CHANGE_OWNER];
  91  }
  92  
  93  if($viewnamedesc['viewname'] == 'All')
  94  {
  95      $smarty->assign("ALL", 'All');
  96  }
  97  
  98  $theme_path="themes/".$theme."/";
  99  $image_path=$theme_path."images/";
 100  $smarty->assign("MOD", $mod_strings);
 101  $smarty->assign("APP", $app_strings);
 102  $smarty->assign("IMAGE_PATH",$image_path);
 103  $smarty->assign("MODULE",$currentModule);
 104  $smarty->assign("SINGLE_MOD",'Invoice');
 105  $smarty->assign("CUSTOMVIEW_OPTION",$customviewcombo_html);
 106  $smarty->assign("VIEWID", $viewid);
 107  $smarty->assign("BUTTONS",$other_text);
 108  $category = getParentTab();
 109  $smarty->assign("CATEGORY",$category);
 110  
 111  //Retreive the list from Database
 112  //<<<<<<<<<customview>>>>>>>>>
 113  if($viewid != "0")
 114  {
 115      $listquery = getListQuery("Invoice");
 116      $query = $oCustomView->getModifiedCvListQuery($viewid,$listquery,"Invoice");
 117  }else
 118  {
 119      $query = getListQuery("Invoice");
 120  }
 121  //<<<<<<<<customview>>>>>>>>>
 122  
 123  if(isset($where) && $where != '')
 124  {
 125          $query .= ' and '.$where;
 126  }
 127  
 128  //$url_qry = getURLstring($focus);
 129  
 130  if(isset($order_by) && $order_by != '')
 131  {
 132      if($order_by == 'smownerid')
 133          {
 134          if( $adb->dbType == "pgsql")
 135               $query .= ' GROUP BY user_name';
 136                  $query .= ' ORDER BY user_name '.$sorder;
 137          }
 138          else
 139          {
 140          $tablename = getTableNameForField('Invoice',$order_by);
 141          $tablename = (($tablename != '')?($tablename."."):'');
 142          if( $adb->dbType == "pgsql")
 143               $query .= ' GROUP BY '.$tablename.$order_by;
 144  
 145                  $query .= ' ORDER BY '.$tablename.$order_by.' '.$sorder;
 146          }
 147  }
 148  
 149  
 150  //Retreiving the no of rows
 151  $count_result = $adb->query( mkCountQuery( $query));
 152  $noofrows = $adb->query_result($count_result,0,"count");
 153  
 154  //Storing Listview session object
 155  if($_SESSION['lvs'][$currentModule])
 156  {
 157      setSessionVar($_SESSION['lvs'][$currentModule],$noofrows,$list_max_entries_per_page);
 158  }
 159  
 160  $start = $_SESSION['lvs'][$currentModule]['start'];
 161         
 162  //Retreive the Navigation array
 163  $navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page);
 164  
 165   //Postgres 8 fixes
 166   if( $adb->dbType == "pgsql")
 167       $query = fixPostgresQuery( $query, $log, 0);
 168   
 169  
 170  // Setting the record count string
 171  //modified by rdhital
 172  $start_rec = $navigation_array['start'];
 173  $end_rec = $navigation_array['end_val']; 
 174  //By Raju Ends
 175  
 176  //limiting the query
 177  if ($start_rec ==0) 
 178      $limit_start_rec = 0;
 179  else
 180      $limit_start_rec = $start_rec -1;
 181      
 182  if( $adb->dbType == "pgsql")
 183       $list_result = $adb->query($query. " OFFSET ".$limit_start_rec." LIMIT ".$list_max_entries_per_page);
 184  else
 185       $list_result = $adb->query($query. " LIMIT ".$limit_start_rec.",".$list_max_entries_per_page);
 186  
 187  $record_string= $app_strings[LBL_SHOWING]." " .$start_rec." - ".$end_rec." " .$app_strings[LBL_LIST_OF] ." ".$noofrows;
 188  
 189  //Retreive the List View Table Header
 190  if($viewid !='')
 191  $url_string .="&viewname=".$viewid;
 192  
 193  $listview_header = getListViewHeader($focus,"Invoice",$url_string,$sorder,$order_by,"",$oCustomView);
 194  $smarty->assign("LISTHEADER", $listview_header);
 195  
 196  $listview_header_search = getSearchListHeaderValues($focus,"Invoice",$url_string,$sorder,$order_by,"",$oCustomView);
 197  $smarty->assign("SEARCHLISTHEADER",$listview_header_search);
 198  
 199  $listview_entries = getListViewEntries($focus,"Invoice",$list_result,$navigation_array,"","","EditView","Delete",$oCustomView);
 200  $smarty->assign("LISTENTITY", $listview_entries);
 201  $smarty->assign("SELECT_SCRIPT", $view_script);
 202  
 203  $navigationOutput = getTableHeaderNavigation($navigation_array, $url_string,"Invoice","index",$viewid);
 204  $alphabetical = AlphabeticalSearch($currentModule,'index','subject','true','basic',"","","","",$viewid);
 205  $fieldnames = getAdvSearchfields($module);
 206  $criteria = getcriteria_options();
 207  $smarty->assign("CRITERIA", $criteria);
 208  $smarty->assign("FIELDNAMES", $fieldnames);
 209  $smarty->assign("CUSTOMVIEW_OPTION",$customviewcombo_html);
 210  $smarty->assign("VIEWID", $viewid);
 211  $smarty->assign("BUTTONS", $other_text);
 212  $smarty->assign("ALPHABETICAL", $alphabetical);
 213  $smarty->assign("NAVIGATION", $navigationOutput);
 214  $smarty->assign("RECORD_COUNTS", $record_string);
 215  $smarty->assign("CUSTOMVIEW_OPTION",$customviewcombo_html);
 216  $smarty->assign("VIEWID", $viewid);
 217  $smarty->assign("BUTTONS", $other_text);
 218  
 219  $check_button = Button_Check($module);
 220  $smarty->assign("CHECK", $check_button);
 221  
 222  if(isset($_REQUEST['ajax']) && $_REQUEST['ajax'] != '')
 223      $smarty->display("ListViewEntries.tpl");
 224  else    
 225      $smarty->display("ListView.tpl");
 226  
 227  ?>


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