[ Index ]
 

Code source de vtiger CRM 5.0.2

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

title

Body

[fermer]

/modules/Vendors/ -> 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  require_once ('include/database/PearDatabase.php');
  12  require_once ('include/database/Postgres8.php');
  13  require_once ('Smarty_setup.php');
  14  require_once ('modules/Vendors/Vendors.php');
  15  require_once ('include/ListView/ListView.php');
  16  require_once ('include/utils/utils.php');
  17  require_once ('modules/CustomView/CustomView.php');
  18  require_once ('include/DatabaseUtil.php');
  19  
  20  global $app_strings,$mod_strings,$list_max_entries_per_page,$currentModule,$theme;
  21  
  22  $theme_path="themes/".$theme."/";
  23  $image_path=$theme_path."images/";
  24  require_once ($theme_path.'layout_utils.php');
  25  
  26  $smarty = new vtigerCRM_Smarty;
  27  $smarty->assign("MOD", $mod_strings);
  28  $smarty->assign("APP", $app_strings);
  29  $smarty->assign("IMAGE_PATH",$image_path);
  30  $smarty->assign("MODULE",$currentModule);
  31  $smarty->assign("SINGLE_MOD",'Vendor');
  32  $category = getParentTab();
  33  $smarty->assign("CATEGORY",$category);
  34  
  35  $focus = new Vendors();
  36  $other_text = Array();
  37  
  38  if(!$_SESSION['lvs'][$currentModule])
  39  {
  40      unset($_SESSION['lvs']);
  41      $modObj = new ListViewSession();
  42      $modObj->sorder = $sorder;
  43      $modObj->sortby = $order_by;
  44      $_SESSION['lvs'][$currentModule] = get_object_vars($modObj);
  45  }
  46  
  47  if($_REQUEST['errormsg'] != '')
  48  {
  49          $errormsg = $_REQUEST['errormsg'];
  50          $smarty->assign("ERROR","The User does not have permission to delete ".$errormsg." ".$currentModule);
  51  }else
  52  {
  53          $smarty->assign("ERROR","");
  54  }
  55  if (!isset($where)) $where = "";
  56  
  57  //<<<<<<<<<<<<<<<<<<< sorting - stored in session >>>>>>>>>>>>>>>>>>>>
  58  if($_REQUEST['order_by'] != '')
  59      $order_by = $_REQUEST['order_by'];
  60  else
  61      $order_by = (($_SESSION['VENDORS_ORDER_BY'] != '')?($_SESSION['VENDORS_ORDER_BY']):($focus->default_order_by));
  62  
  63  if($_REQUEST['sorder'] != '')
  64      $sorder = $_REQUEST['sorder'];
  65  else
  66      $sorder = (($_SESSION['VENDORS_SORT_ORDER'] != '')?($_SESSION['VENDORS_SORT_ORDER']):($focus->default_sort_order));
  67  
  68  $_SESSION['VENDORS_ORDER_BY'] = $order_by;
  69  $_SESSION['VENDORS_SORT_ORDER'] = $sorder;
  70  //<<<<<<<<<<<<<<<<<<< sorting - stored in session >>>>>>>>>>>>>>>>>>>>
  71  
  72  if(isset($_REQUEST['query']) && $_REQUEST['query'] != '' && $_REQUEST['query'] == 'true')
  73  {
  74      list($where, $ustring) = split("#@@#",getWhereCondition($currentModule));
  75      // we have a query
  76      $url_string .="&query=true".$ustring;
  77      $log->info("Here is the where clause for the list view: $where");
  78      $smarty->assign("SEARCH_URL",$url_string);
  79  
  80  }
  81  
  82  //<<<<cutomview>>>>>>>
  83  $oCustomView = new CustomView("Vendors");
  84  $viewid = $oCustomView->getViewId($currentModule);
  85  $customviewcombo_html = $oCustomView->getCustomViewCombo($viewid);
  86  $viewnamedesc = $oCustomView->getCustomViewByCvid($viewid);
  87  //<<<<<customview>>>>>
  88  
  89  // Buttons and View options
  90  if(isPermitted('Vendors','DeleteVendor','') == 'yes')
  91  {
  92      $other_text['del'] = $app_strings[LBL_MASS_DELETE];
  93  }
  94  
  95  if($viewnamedesc['viewname'] == 'All')
  96  {
  97      $smarty->assign("ALL", 'All');
  98  }
  99  
 100  //Retreive the list from Database
 101  //<<<<<<<<<customview>>>>>>>>>
 102  if($viewid != "0")
 103  {
 104      $listquery = getListQuery("Vendors");
 105      $list_query = $oCustomView->getModifiedCvListQuery($viewid,$listquery,"Vendors");
 106  }else
 107  {
 108      $list_query = getListQuery("Vendors");
 109  }
 110  //<<<<<<<<customview>>>>>>>>>
 111  
 112  if(isset($where) && $where != '')
 113  {
 114          $list_query .= ' and '.$where;
 115  }
 116  
 117  if(isset($order_by) && $order_by != '')
 118  {
 119      $tablename = getTableNameForField('Vendors',$order_by);
 120      $tablename = (($tablename != '')?($tablename."."):'');
 121  
 122      if( $adb->dbType == "pgsql")
 123           $list_query .= ' GROUP BY '.$tablename.$order_by;
 124      
 125          $list_query .= ' ORDER BY '.$tablename.$order_by.' '.$sorder;
 126  }
 127  
 128  //Retreiving the no of rows
 129  $count_result = $adb->query( mkCountQuery( $list_query));
 130  $noofrows = $adb->query_result($count_result,0,"count");
 131  
 132  //Storing Listview session object
 133  if($_SESSION['lvs'][$currentModule])
 134  {
 135      setSessionVar($_SESSION['lvs'][$currentModule],$noofrows,$list_max_entries_per_page);
 136  }
 137  
 138  $start = $_SESSION['lvs'][$currentModule]['start'];
 139  
 140  //Retreive the Navigation array
 141  $navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page);
 142  //Postgres 8 fixes
 143   if( $adb->dbType == "pgsql")
 144       $list_query = fixPostgresQuery( $list_query, $log, 0);
 145  
 146  // Setting the record count string
 147  //modified by rdhital
 148  $start_rec = $navigation_array['start'];
 149  $end_rec = $navigation_array['end_val']; 
 150  //By raju Ends
 151  
 152  //limiting the query
 153  if ($start_rec ==0) 
 154      $limit_start_rec = 0;
 155  else
 156      $limit_start_rec = $start_rec -1;
 157      
 158  if( $adb->dbType == "pgsql")
 159       $list_result = $adb->query($list_query. " OFFSET ".$limit_start_rec." LIMIT ".$list_max_entries_per_page);
 160  else
 161       $list_result = $adb->query($list_query. " LIMIT ".$limit_start_rec.",".$list_max_entries_per_page);
 162  
 163  $record_string= $app_strings[LBL_SHOWING]." " .$start_rec." - ".$end_rec." " .$app_strings[LBL_LIST_OF] ." ".$noofrows;
 164  
 165  //Retreive the List View Table Header
 166  if($viewid !='')
 167  $url_string .="&viewname=".$viewid;
 168  
 169  $listview_header = getListViewHeader($focus,"Vendors",$url_string,$sorder,$order_by,"",$oCustomView);
 170  $smarty->assign("LISTHEADER", $listview_header);
 171  
 172  $listview_header_search = getSearchListHeaderValues($focus,"Vendors",$url_string,$sorder,$order_by,"",$oCustomView);
 173  $smarty->assign("SEARCHLISTHEADER",$listview_header_search);
 174  
 175  $listview_entries = getListViewEntries($focus,"Vendors",$list_result,$navigation_array,'','&return_module=Vendors&return_action=index','EditView','Delete',$oCustomView);
 176  $smarty->assign("LISTENTITY", $listview_entries);
 177  $smarty->assign("CUSTOMVIEW_OPTION",$customviewcombo_html);
 178  $smarty->assign("VIEWID", $viewid);
 179  $navigationOutput = getTableHeaderNavigation($navigation_array, $url_string,"Vendors","index",$viewid);
 180  $alphabetical = AlphabeticalSearch($currentModule,'index','vendorname','true','basic',"","","","",$viewid);
 181  $fieldnames = getAdvSearchfields($module);
 182  $criteria = getcriteria_options();
 183  $smarty->assign("CRITERIA", $criteria);
 184  $smarty->assign("FIELDNAMES", $fieldnames);
 185  $smarty->assign("ALPHABETICAL", $alphabetical);
 186  $smarty->assign("NAVIGATION", $navigationOutput);
 187  $smarty->assign("RECORD_COUNTS", $record_string);
 188  $smarty->assign("BUTTONS", $other_text);
 189  
 190  $check_button = Button_Check($module);
 191  $smarty->assign("CHECK", $check_button);
 192  
 193  if(isset($_REQUEST['ajax']) && $_REQUEST['ajax'] != '')
 194      $smarty->display("ListViewEntries.tpl");
 195  else    
 196      $smarty->display("ListView.tpl");
 197  ?>


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