[ Index ]
 

Code source de vtiger CRM 5.0.2

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

title

Body

[fermer]

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


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