[ Index ]
 

Code source de vtiger CRM 5.0.2

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

title

Body

[fermer]

/modules/PurchaseOrder/ -> 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/PurchaseOrder/PurchaseOrder.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  
  30  global $app_strings,$list_max_entries_per_page,$currentModule,$theme;
  31  
  32  $log = LoggerManager::getLogger('order_list');
  33  
  34  if (!isset($where)) $where = "";
  35  
  36  $url_string = '&smodule=PO';
  37  
  38  $focus = new PurchaseOrder();
  39  $smarty = new vtigerCRM_Smarty;
  40  $other_text = Array();
  41  
  42  if(!$_SESSION['lvs'][$currentModule])
  43  {
  44      unset($_SESSION['lvs']);
  45      $modObj = new ListViewSession();
  46      $modObj->sorder = $sorder;
  47      $modObj->sortby = $order_by;
  48      $_SESSION['lvs'][$currentModule] = get_object_vars($modObj);
  49  }
  50  
  51  if($_REQUEST['errormsg'] != '')
  52  {
  53          $errormsg = $_REQUEST['errormsg'];
  54          $smarty->assign("ERROR","The User does not have permission to Change/Delete ".$errormsg." ".$currentModule);
  55  }else
  56  {
  57          $smarty->assign("ERROR","");
  58  }
  59  //<<<<<<<<<<<<<<<<<<< sorting - stored in session >>>>>>>>>>>>>>>>>>>>
  60  $sorder = $focus->getSortOrder();
  61  $order_by = $focus->getOrderBy();
  62  
  63  $_SESSION['PURCHASEORDER_ORDER_BY'] = $order_by;
  64  $_SESSION['PURCHASEORDER_SORT_ORDER'] = $sorder;
  65  //<<<<<<<<<<<<<<<<<<< sorting - stored in session >>>>>>>>>>>>>>>>>>>>
  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  //<<<<cutomview>>>>>>>
  78  $oCustomView = new CustomView("PurchaseOrder");
  79  $viewid = $oCustomView->getViewId($currentModule);
  80  $customviewcombo_html = $oCustomView->getCustomViewCombo($viewid);
  81  $viewnamedesc = $oCustomView->getCustomViewByCvid($viewid);
  82  //<<<<<customview>>>>>
  83  $smarty->assign("CHANGE_OWNER",getUserslist());
  84  $smarty->assign("CHANGE_GROUP_OWNER",getGroupslist());
  85  
  86  if(isPermitted('PurchaseOrder','Delete','') == 'yes')
  87  {
  88      $other_text['del'] = $app_strings[LBL_MASS_DELETE];
  89  }
  90  if(isPermitted('PurchaseOrder','EditView','') == 'yes')
  91  {
  92          $other_text['c_owner'] = $app_strings[LBL_CHANGE_OWNER];
  93  }
  94  if($viewnamedesc['viewname'] == 'All')
  95  {
  96      $smarty->assign("ALL", 'All');
  97  }
  98  
  99  $theme_path="themes/".$theme."/";
 100  $image_path=$theme_path."images/";
 101  $smarty->assign("MOD", $mod_strings);
 102  $smarty->assign("APP", $app_strings);
 103  $smarty->assign("IMAGE_PATH",$image_path);
 104  $smarty->assign("MODULE",$currentModule);
 105  $smarty->assign("SINGLE_MOD",'PurchaseOrder');
 106  $smarty->assign("CUSTOMVIEW_OPTION",$customviewcombo_html);
 107  $smarty->assign("VIEWID", $viewid);
 108  $category = getParentTab();
 109  $smarty->assign("CATEGORY",$category);
 110  $smarty->assign("BUTTONS", $other_text);
 111  $smarty->assign("CUSTOMVIEW", $custom_view_strings);
 112  //Retreive the list from Database
 113  //<<<<<<<<<customview>>>>>>>>>
 114  if($viewid != "0")
 115  {
 116      $listquery = getListQuery("PurchaseOrder");
 117      $query = $oCustomView->getModifiedCvListQuery($viewid,$listquery,"PurchaseOrder");
 118  }else
 119  {
 120      $query = getListQuery("PurchaseOrder");
 121  }
 122  //<<<<<<<<customview>>>>>>>>>
 123  
 124  if(isset($where) && $where != '')
 125  {
 126          $query .= ' and '.$where;
 127  }
 128  
 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('PurchaseOrder',$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  //Retreiving the no of rows
 150  $count_result = $adb->query( mkCountQuery( $query));
 151  $noofrows = $adb->query_result($count_result,0,"count");
 152          
 153  //Storing Listview session object
 154  if($_SESSION['lvs'][$currentModule])
 155  {
 156      setSessionVar($_SESSION['lvs'][$currentModule],$noofrows,$list_max_entries_per_page);
 157  }
 158  
 159  $start = $_SESSION['lvs'][$currentModule]['start'];
 160  
 161  //Retreive the Navigation array
 162  $navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page);
 163   //Postgres 8 fixes
 164   if( $adb->dbType == "pgsql")
 165       $query = fixPostgresQuery( $query, $log, 0);
 166  
 167  
 168  
 169  // Setting the record count string
 170  //modified by rdhital
 171  $start_rec = $navigation_array['start'];
 172  $end_rec = $navigation_array['end_val']; 
 173  //By Raju Ends
 174  
 175  //limiting the query
 176  if ($start_rec ==0) 
 177      $limit_start_rec = 0;
 178  else
 179      $limit_start_rec = $start_rec -1;
 180      
 181  if( $adb->dbType == "pgsql")
 182       $list_result = $adb->query($query. " OFFSET ".$limit_start_rec." LIMIT ".$list_max_entries_per_page);
 183  else
 184       $list_result = $adb->query($query. " LIMIT ".$limit_start_rec.",".$list_max_entries_per_page);
 185  
 186  $record_string= $app_strings[LBL_SHOWING]." " .$start_rec." - ".$end_rec." " .$app_strings[LBL_LIST_OF] ." ".$noofrows;
 187  
 188  //Retreive the List View Table Header
 189  if($viewid !='')
 190  $url_string .="&viewname=".$viewid;
 191  
 192  $listview_header = getListViewHeader($focus,"PurchaseOrder",$url_string,$sorder,$order_by,"",$oCustomView);
 193  $smarty->assign("LISTHEADER", $listview_header);
 194  
 195  $listview_header_search = getSearchListHeaderValues($focus,"PurchaseOrder",$url_string,$sorder,$order_by,"",$oCustomView);
 196  $smarty->assign("SEARCHLISTHEADER",$listview_header_search);
 197  
 198  $listview_entries = getListViewEntries($focus,"PurchaseOrder",$list_result,$navigation_array,"","","EditView","Delete",$oCustomView);
 199  $smarty->assign("LISTENTITY", $listview_entries);
 200  $smarty->assign("SELECT_SCRIPT", $view_script);
 201  
 202  $navigationOutput = getTableHeaderNavigation($navigation_array, $url_string,"PurchaseOrder","index",$viewid);
 203  $alphabetical = AlphabeticalSearch($currentModule,'index','subject','true','basic',"","","","",$viewid);
 204  $fieldnames = getAdvSearchfields($module);
 205  $criteria = getcriteria_options();
 206  $smarty->assign("CRITERIA", $criteria);
 207  $smarty->assign("FIELDNAMES", $fieldnames);
 208  $smarty->assign("ALPHABETICAL", $alphabetical);
 209  $smarty->assign("NAVIGATION", $navigationOutput);
 210  $smarty->assign("RECORD_COUNTS", $record_string);
 211  
 212  $check_button = Button_Check($module);
 213  $smarty->assign("CHECK", $check_button);
 214  
 215  if(isset($_REQUEST['ajax']) && $_REQUEST['ajax'] != '')
 216      $smarty->display("ListViewEntries.tpl");
 217  else    
 218      $smarty->display("ListView.tpl");
 219  ?>


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