PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/include/ListView/ListViewPagging.php

https://bitbucket.org/yousef_fadila/vtiger
PHP | 86 lines | 67 code | 5 blank | 14 comment | 22 complexity | 564abfaef833bf28067b2c6e5393b324 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0
  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. global $app_strings, $mod_strings, $current_language, $currentModule, $theme;
  11. global $list_max_entries_per_page;
  12. require_once('Smarty_setup.php');
  13. require_once('include/ListView/ListView.php');
  14. require_once('modules/CustomView/CustomView.php');
  15. require_once('include/DatabaseUtil.php');
  16. checkFileAccessForInclusion("modules/$currentModule/$currentModule.php");
  17. require_once("modules/$currentModule/$currentModule.php");
  18. if(!is_string($_SESSION[$currentModule.'_listquery']) || !empty($_REQUEST['globalSearch'])){
  19. // Custom View
  20. $customView = new CustomView($currentModule);
  21. $viewid = $customView->getViewId($currentModule);
  22. $customview_html = $customView->getCustomViewCombo($viewid);
  23. $viewinfo = $customView->getCustomViewByCvid($viewid);
  24. if($viewid != "0"&& $viewid != 0){
  25. $listquery = getListQuery($currentModule);
  26. $list_query= $customView->getModifiedCvListQuery($viewid, $listquery, $currentModule);
  27. }else{
  28. $list_query = getListQuery($currentModule);
  29. }
  30. // Enabling Module Search
  31. $url_string = '';
  32. if($_REQUEST['query'] == 'true') {
  33. if(!empty($_REQUEST['tagSearchText'])){
  34. $searchValue = vtlib_purify($_REQUEST['globalSearchText']);
  35. $where = '(' . getTagWhere($searchValue, $current_user->id) . ')';
  36. } else if(!empty($_REQUEST['globalSearch'])){
  37. $searchValue = vtlib_purify($_REQUEST['globalSearchText']);
  38. $where = '(' . getUnifiedWhere($list_query,$currentModule,$searchValue) . ')';
  39. $url_string .= '&query=true&globalSearch=true&globalSearchText='.$searchValue;
  40. }else{
  41. list($where, $ustring) = split('#@@#', getWhereCondition($currentModule));
  42. $url_string .= "&query=true$ustring";
  43. }
  44. }
  45. //print_r($where);
  46. if($where != '') {
  47. $list_query = "$list_query AND $where";
  48. $_SESSION['export_where'] = $where;
  49. }else{
  50. unset($_SESSION['export_where']);
  51. }
  52. // Sorting
  53. if($order_by) {
  54. if($order_by == 'smownerid'){
  55. if( $adb->dbType == "pgsql"){
  56. $list_query .= ' GROUP BY user_name';
  57. }
  58. $list_query .= ' ORDER BY user_name '.$sorder;
  59. }else {
  60. $tablename = getTableNameForField($currentModule, $order_by);
  61. $tablename = ($tablename != '')? ($tablename . '.') : '';
  62. if( $adb->dbType == "pgsql"){
  63. $list_query .= ' GROUP BY '. $tablename . $order_by;
  64. }
  65. $list_query .= ' ORDER BY ' . $tablename . $order_by . ' ' . $sorder;
  66. }
  67. }
  68. }else{
  69. //TODO: remove after calendar module listview cleanup.
  70. //its failing for calendar module.
  71. $dummyQuery = getListQuery($currentModule);
  72. $list_query = $_SESSION[$currentModule.'_listquery'];
  73. }
  74. $count_result = $adb->query(mkCountQuery($list_query));
  75. $noofrows = $adb->query_result($count_result,0,"count");
  76. $pageNumber = ceil($noofrows/$list_max_entries_per_page);
  77. if($pageNumber == 0){
  78. $pageNumber = 1;
  79. }
  80. echo $app_strings['LBL_LIST_OF'].' '.$pageNumber;
  81. ?>