[ Index ]
 

Code source de vtiger CRM 5.0.2

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

title

Body

[fermer]

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


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