if ($_REQUEST['order_by'] != '') { $order_by = $adb->sql_escape_string($_REQUEST['order_by']); } elseif ($_SESSION['user_orderby'] != '') { $order_by = $adb->sql_escape_string($_SESSION['user_orderby']); } else { $order_by = 'last_name'; } $_SESSION['user_orderby'] = $orderby; $list_query .= ' ORDER BY ' . $order_by . ' ' . $sorder; $list_result = $adb->query($list_query); //Retreive the Navigation array $navigation_array = getNavigationValues($start, $adb->num_rows($list_result), $no_of_users['user']); $navigationOutput = getTableHeaderNavigation($navigation_array, $url_string, "Administration", "index", ''); $smarty->assign("MOD", return_module_language($current_language, 'Settings')); $smarty->assign("CMOD", $mod_strings); $smarty->assign("APP", $app_strings); $smarty->assign("CURRENT_USERID", $current_user->id); $smarty->assign("THEME", $theme); $smarty->assign("IMAGE_PATH", $image_path); $smarty->assign("CATEGORY", $category); $smarty->assign("LIST_HEADER", getListViewHeader($focus, "Users", $url_string, $sorder, $order_by, "", "")); $smarty->assign("LIST_ENTRIES", getListViewEntries($focus, "Users", $list_result, $navigation_array, "", "", "EditView", "Delete", "")); $smarty->assign("USER_COUNT", $no_of_users); $smarty->assign("RECORD_COUNTS", $record_string); $smarty->assign("NAVIGATION", $navigationOutput); $smarty->assign("USER_IMAGES", getUserImageNames()); if ($_REQUEST['ajax'] != '') { $smarty->display("UserListViewContents.tpl"); } else { $smarty->display("UserListView.tpl"); }
/** * this function returns the widget information for an module type widget */ private function getModuleFilters($sid) { global $adb, $current_user; $querycvid = "select vtiger_homemoduleflds.fieldname,vtiger_homemodule.* from vtiger_homemoduleflds\n\t\t\t\t\tleft join vtiger_homemodule on vtiger_homemodule.stuffid=vtiger_homemoduleflds.stuffid\n\t\t\t\t\twhere vtiger_homemoduleflds.stuffid=?"; $resultcvid = $adb->pquery($querycvid, array($sid)); $modname = $adb->query_result($resultcvid, 0, "modulename"); $cvid = $adb->query_result($resultcvid, 0, "customviewid"); $maxval = $adb->query_result($resultcvid, 0, "maxentries"); $column_count = $adb->num_rows($resultcvid); $cvid_check_query = $adb->pquery("SELECT * FROM vtiger_customview WHERE cvid = ?", array($cvid)); if (isPermitted($modname, 'index') == "yes") { if ($adb->num_rows($cvid_check_query) > 0) { $focus = CRMEntity::getInstance($modname); $oCustomView = new CustomView($modname); if ($modname == "Calendar") { $listquery = getListQuery($modname); if (trim($listquery) == '') { $listquery = $focus->getListQuery($modname); } $query = $oCustomView->getModifiedCvListQuery($cvid, $listquery, $modname); } else { $queryGenerator = new QueryGenerator($modname, $current_user); $queryGenerator->initForCustomViewById($cvid); $customViewFields = $queryGenerator->getCustomViewFields(); $fields = $queryGenerator->getFields(); $newFields = array_diff($fields, $customViewFields); for ($l = 0; $l < $column_count; $l++) { $customViewColumnInfo = $adb->query_result($resultcvid, $l, "fieldname"); $details = explode(':', $customViewColumnInfo); $newFields[] = $details[2]; } $queryGenerator->setFields($newFields); $query = $queryGenerator->getQuery(); } $count_result = $adb->query(mkCountQuery($query)); $noofrows = $adb->query_result($count_result, 0, "count"); $navigation_array = getNavigationValues(1, $noofrows, $maxval); //To get the current language file global $current_language, $app_strings; $fieldmod_strings = return_module_language($current_language, $modname); if ($modname == "Calendar") { $query .= "AND vtiger_activity.activitytype NOT IN ('Emails')"; } $list_result = $adb->query($query . " LIMIT 0," . $maxval); if ($modname == "Calendar") { for ($l = 0; $l < $column_count; $l++) { $fieldinfo = $adb->query_result($resultcvid, $l, "fieldname"); list($tabname, $colname, $fldname, $fieldmodlabel) = explode(":", $fieldinfo); $fieldheader = explode("_", $fieldmodlabel, 2); $fldlabel = $fieldheader[1]; $pos = strpos($fldlabel, "_"); if ($pos == true) { $fldlabel = str_replace("_", " ", $fldlabel); } $field_label = isset($app_strings[$fldlabel]) ? $app_strings[$fldlabel] : (isset($fieldmod_strings[$fldlabel]) ? $fieldmod_strings[$fldlabel] : $fldlabel); $cv_presence = $adb->pquery("SELECT * from vtiger_cvcolumnlist WHERE cvid = ? and columnname LIKE '%" . $fldname . "%'", array($cvid)); if ($is_admin == false) { $fld_permission = getFieldVisibilityPermission($modname, $current_user->id, $fldname); } if ($fld_permission == 0 && $adb->num_rows($cv_presence)) { $field_query = $adb->pquery("SELECT fieldlabel FROM vtiger_field WHERE fieldname = ? AND tablename = ? and vtiger_field.presence in (0,2)", array($fldname, $tabname)); $field_label = $adb->query_result($field_query, 0, 'fieldlabel'); $header[] = $field_label; } $fieldcolumns[$fldlabel] = array($tabname => $colname); } $listview_entries = getListViewEntries($focus, $modname, $list_result, $navigation_array, "", "", "EditView", "Delete", $oCustomView, 'HomePage', $fieldcolumns); } else { $controller = new ListViewController($adb, $current_user, $queryGenerator); $controller->setHeaderSorting(false); $header = $controller->getListViewHeader($focus, $modname, '', '', '', true); $listview_entries = $controller->getListViewEntries($focus, $modname, $list_result, $navigation_array, true); } $return_value = array('ModuleName' => $modname, 'cvid' => $cvid, 'Maxentries' => $maxval, 'Header' => $header, 'Entries' => $listview_entries); if (sizeof($header) != 0) { return $return_value; } else { return array('Entries' => "Fields not found in Selected Filter"); } } else { return array('Entries' => "<font color='red'>Filter You have Selected is Not Found</font>"); } } else { return array('Entries' => "<font color='red'>Permission Denied</font>"); } }
if ($adb->dbType == "pgsql") { $list_result = $adb->pquery($list_query . " OFFSET {$limit_start_rec} LIMIT {$list_max_entries_per_page}", array()); } else { $list_result = $adb->pquery($list_query . " LIMIT {$limit_start_rec}, {$list_max_entries_per_page}", array()); } $recordListRangeMsg = getRecordRangeMessage($list_result, $limit_start_rec); $smarty->assign('recordListRange', $recordListRangeMsg); //Retreive the List View Table Header if ($viewid != '') { $url_string .= "&viewname=" . $viewid; } $listview_header = getListViewHeader($focus, "SalesOrder", $url_string, $sorder, $order_by, "", $oCustomView); $smarty->assign("LISTHEADER", $listview_header); $listview_header_search = getSearchListHeaderValues($focus, "SalesOrder", $url_string, $sorder, $order_by, "", $oCustomView); $smarty->assign("SEARCHLISTHEADER", $listview_header_search); $listview_entries = getListViewEntries($focus, "SalesOrder", $list_result, $navigation_array, '', '&return_module=SalesOrder&return_action=index', 'EditView', 'Delete', $oCustomView); $smarty->assign("LISTENTITY", $listview_entries); $smarty->assign("SELECT_SCRIPT", $view_script); //Added to select Multiple records in multiple pages $smarty->assign("SELECTEDIDS", vtlib_purify($_REQUEST['selobjs'])); $smarty->assign("ALLSELECTEDIDS", vtlib_purify($_REQUEST['allselobjs'])); $smarty->assign("CURRENT_PAGE_BOXES", implode(array_keys($listview_entries), ";")); $navigationOutput = getTableHeaderSimpleNavigation($navigation_array, $url_string, "SalesOrder", 'index', $viewid); $alphabetical = AlphabeticalSearch($currentModule, 'index', 'subject', 'true', 'basic', "", "", "", "", $viewid); $fieldnames = getAdvSearchfields($module); $criteria = getcriteria_options(); $smarty->assign("CRITERIA", $criteria); $smarty->assign("FIELDNAMES", $fieldnames); $smarty->assign("ALPHABETICAL", $alphabetical); $smarty->assign("NAVIGATION", $navigationOutput); $smarty->assign("CUSTOMVIEW_OPTION", $customviewcombo_html);
$start = ListViewSession::getRequestCurrentPage($currentModule, $list_query, $viewid, $queryMode); $navigation_array = VT_getSimpleNavigationValues($start, $list_max_entries_per_page, $noofrows); $limit_start_rec = ($start - 1) * $list_max_entries_per_page; if ($adb->dbType == "pgsql") { $list_result = $adb->pquery($list_query . " OFFSET {$limit_start_rec} LIMIT {$list_max_entries_per_page}", array()); } else { $list_result = $adb->pquery($list_query . " LIMIT {$limit_start_rec}, {$list_max_entries_per_page}", array()); } $recordListRangeMsg = getRecordRangeMessage($list_result, $limit_start_rec); $smarty->assign('recordListRange', $recordListRangeMsg); //Retreive the List View Table Header $listview_header = getListViewHeader($focus, "PriceBooks", $url_string, $sorder, $order_by, "", $oCustomView); $smarty->assign("LISTHEADER", $listview_header); $listview_header_search = getSearchListHeaderValues($focus, "PriceBooks", $url_string, $sorder, $order_by, "", $oCustomView); $smarty->assign("SEARCHLISTHEADER", $listview_header_search); $listview_entries = getListViewEntries($focus, "PriceBooks", $list_result, $navigation_array, '', '&return_module=PriceBooks&return_action=index', 'EditView', 'Delete', $oCustomView); $smarty->assign("LISTENTITY", $listview_entries); //Added to select Multiple records in multiple pages $smarty->assign("SELECTEDIDS", vtlib_purify($_REQUEST['selobjs'])); $smarty->assign("ALLSELECTEDIDS", vtlib_purify($_REQUEST['allselobjs'])); $smarty->assign("CURRENT_PAGE_BOXES", implode(array_keys($listview_entries), ";")); $navigationOutput = getTableHeaderSimpleNavigation($navigation_array, $url_string, "PriceBooks", "index", $viewid); $alphabetical = AlphabeticalSearch($currentModule, 'index', 'bookname', 'true', 'basic', "", "", "", "", $viewid); $fieldnames = getAdvSearchfields($module); $criteria = getcriteria_options(); $smarty->assign("CRITERIA", $criteria); $smarty->assign("FIELDNAMES", $fieldnames); $smarty->assign("ALPHABETICAL", $alphabetical); $smarty->assign("NAVIGATION", $navigationOutput); $smarty->assign("CUSTOMVIEW_OPTION", $customviewcombo_html); $smarty->assign("VIEWID", $viewid);
$url_string .= "&viewname=" . $viewid; } //Cambiado code to add close button in custom vtiger_field if ($viewid != 0 && $viewid != "") { if (!isset($oCustomView->list_fields['Close'])) { $oCustomView->list_fields['Close'] = array('vtiger_activity' => 'eventstatus'); } if (!isset($oCustomView->list_fields_name['Close'])) { $oCustomView->list_fields_name['Close'] = 'eventstatus'; } } $listview_header = getListViewHeader($focus, "Calendar", $url_string, $sorder, $order_by, "", $oCustomView); $smarty->assign("LISTHEADER", $listview_header); $listview_header_search = getSearchListHeaderValues($focus, "Calendar", $url_string, $sorder, $order_by, "", $oCustomView); $smarty->assign("SEARCHLISTHEADER", $listview_header_search); $listview_entries = getListViewEntries($focus, "Calendar", $list_result, $navigation_array, "", "", "EditView", "Delete", $oCustomView); $smarty->assign("LISTENTITY", $listview_entries); $smarty->assign("SELECT_SCRIPT", $view_script); //Added to select Multiple records in multiple pages $smarty->assign("SELECTEDIDS", vtlib_purify($_REQUEST['selobjs'])); $smarty->assign("ALLSELECTEDIDS", vtlib_purify($_REQUEST['allselobjs'])); $smarty->assign("CURRENT_PAGE_BOXES", implode(array_keys($listview_entries), ";")); $navigationOutput = getTableHeaderSimpleNavigation($navigation_array, $url_string, "Calendar", "ListView", $viewid); $alphabetical = AlphabeticalSearch($currentModule, 'ListView', 'subject', 'true', 'basic', "", "", "", "", $viewid); $fieldnames = getAdvSearchfields($module); $criteria = getcriteria_options(); $smarty->assign("CRITERIA", $criteria); $smarty->assign("FIELDNAMES", $fieldnames); $smarty->assign("ALPHABETICAL", $alphabetical); $smarty->assign("NAVIGATION", $navigationOutput); $category = getParentTab();
function getTopInvoice($maxval, $calCnt) { require_once "data/Tracker.php"; require_once 'modules/Invoice/Invoice.php'; require_once 'include/logging.php'; require_once 'include/ListView/ListView.php'; require_once 'include/utils/utils.php'; require_once 'modules/CustomView/CustomView.php'; global $app_strings, $current_language, $current_user, $adb, $list_max_entries_per_page, $theme; $current_module_strings = return_module_language($current_language, 'Invoice'); $log = LoggerManager::getLogger('invoice_list'); $url_string = ''; $sorder = ''; $oCustomView = new CustomView("Invoice"); $customviewcombo_html = $oCustomView->getCustomViewCombo(); if (isset($_REQUEST['viewname']) == false || $_REQUEST['viewname'] == '') { if ($oCustomView->setdefaultviewid != "") { $viewid = $oCustomView->setdefaultviewid; } else { $viewid = "0"; } } $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; //Retreive the list from Database //<<<<<<<<<customview>>>>>>>>> $date_var = date('Y-m-d'); //Changed for Patch 2 by Don $where = ' and vtiger_crmentity.smownerid=' . $current_user->id . ' and vtiger_invoice.invoicestatus != \'Paid\''; $query = getListQuery("Invoice", $where); $query .= " ORDER BY total DESC"; //<<<<<<<<customview>>>>>>>>> $query .= " LIMIT " . $adb->sql_escape_string($maxval); if ($calCnt == 'calculateCnt') { $list_result_rows = $adb->query(mkCountQuery($query)); return $adb->query_result($list_result_rows, 0, 'count'); } $list_result = $adb->query($query); //Retreiving the no of rows $noofrows = $adb->num_rows($list_result); //Retreiving the start value from request if (isset($_REQUEST['start']) && $_REQUEST['start'] != '') { $start = vtlib_purify($_REQUEST['start']); } else { $start = 1; } //Retreive the Navigation array $navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page); if ($navigation_array['start'] == 1) { if ($noofrows != 0) { $start_rec = $navigation_array['start']; } else { $start_rec = 0; } if ($noofrows > $list_max_entries_per_page) { $end_rec = $navigation_array['start'] + $list_max_entries_per_page - 1; } else { $end_rec = $noofrows; } } else { if ($navigation_array['next'] > $list_max_entries_per_page) { $start_rec = $navigation_array['next'] - $list_max_entries_per_page; $end_rec = $navigation_array['next'] - 1; } else { $start_rec = $navigation_array['prev'] + $list_max_entries_per_page; $end_rec = $noofrows; } } $focus = new Invoice(); $title = array('myTopInvoices.gif', $current_module_strings['LBL_MY_TOP_INVOICE'], 'home_mytopinv'); //Retreive the List View Table Header $listview_header = getListViewHeader($focus, "Invoice", $url_string, $sorder, $order_by, "HomePage", $oCustomView); $header = array($listview_header[1], $listview_header[2]); $listview_entries = getListViewEntries($focus, "Invoice", $list_result, $navigation_array, "HomePage", "", "EditView", "Delete", $oCustomView); foreach ($listview_entries as $crmid => $valuearray) { $entries[$crmid] = array($valuearray[1], $valuearray[2]); } $search_qry = "&query=true&Fields0=vtiger_invoice.invoicestatus&Condition0=isn&Srch_value0=Paid&Fields1=vtiger_crmentity.smownerid&Condition1=is&Srch_value1=" . $current_user->column_fields['user_name'] . "&searchtype=advance&search_cnt=2&matchtype=all"; $values = array('ModuleName' => 'Invoice', 'Title' => $title, 'Header' => $header, 'Entries' => $entries, 'search_qry' => $search_qry); if ($display_empty_home_blocks && $noofrows == 0 || $noofrows > 0) { return $values; } }
$start = ListViewSession::getRequestCurrentPage($currentModule, $list_query, $viewid, $queryMode); $navigation_array = VT_getSimpleNavigationValues($start, $list_max_entries_per_page, $noofrows); $limit_start_rec = ($start - 1) * $list_max_entries_per_page; if ($adb->dbType == "pgsql") { $list_result = $adb->pquery($list_query . " OFFSET {$limit_start_rec} LIMIT {$list_max_entries_per_page}", array()); } else { $list_result = $adb->pquery($list_query . " LIMIT {$limit_start_rec}, {$list_max_entries_per_page}", array()); } $recordListRangeMsg = getRecordRangeMessage($list_result, $limit_start_rec); $smarty->assign('recordListRange', $recordListRangeMsg); $smarty->assign("CUSTOMVIEW_OPTION", $customview_html); // Navigation $navigationOutput = getTableHeaderSimpleNavigation($navigation_array, $url_string, $currentModule, 'index', $viewid); $smarty->assign("NAVIGATION", $navigationOutput); $listview_header = getListViewHeader($focus, $currentModule, $url_string, $sorder, $order_by, '', $customView); $listview_entries = getListViewEntries($focus, $currentModule, $list_result, $navigation_array, '', '', 'EditView', 'Delete', $customView); $listview_header_search = getSearchListHeaderValues($focus, $currentModule, $url_string, $sorder, $order_by, '', $customView); $smarty->assign('LISTHEADER', $listview_header); $smarty->assign('LISTENTITY', $listview_entries); $smarty->assign('SEARCHLISTHEADER', $listview_header_search); // Module Search $alphabetical = AlphabeticalSearch($currentModule, 'index', $focus->def_basicsearch_col, 'true', 'basic', '', '', '', '', $viewid); $fieldnames = getAdvSearchfields($currentModule); $criteria = getcriteria_options(); $smarty->assign("ALPHABETICAL", $alphabetical); $smarty->assign("FIELDNAMES", $fieldnames); $smarty->assign("CRITERIA", $criteria); $smarty->assign("AVALABLE_FIELDS", getMergeFields($currentModule, "available_fields")); $smarty->assign("FIELDS_TO_MERGE", getMergeFields($currentModule, "fileds_to_merge")); $_SESSION[$currentModule . '_listquery'] = $list_query; if (isset($_REQUEST['ajax']) && $_REQUEST['ajax'] != '') {
/** Function to get related list entries in detailed array format * @param $module -- modulename:: Type string * @param $relatedmodule -- relatedmodule:: Type string * @param $focus -- focus:: Type object * @param $query -- query:: Type string * @param $button -- buttons:: Type string * @param $returnset -- returnset:: Type string * @param $id -- id:: Type string * @param $edit_val -- edit value:: Type string * @param $del_val -- delete value:: Type string * @returns $related_entries -- related entires:: Type string array */ function GetRelatedListBase($module, $relatedmodule, $focus, $query, $button, $returnset, $id = '', $edit_val = '', $del_val = '', $skipActions = false) { $log = LoggerManager::getLogger('account_list'); $log->debug("Entering GetRelatedList(" . $module . "," . $relatedmodule . "," . get_class($focus) . "," . $query . "," . $button . "," . $returnset . "," . $edit_val . "," . $del_val . ") method ..."); require_once 'Smarty_setup.php'; require_once "data/Tracker.php"; require_once 'include/database/PearDatabase.php'; global $adb, $app_strings, $current_language; $current_module_strings = return_module_language($current_language, $module); global $list_max_entries_per_page, $urlPrefix, $currentModule, $theme, $theme_path, $theme_path, $mod_strings; $smarty = new vtigerCRM_Smarty(); if (!isset($where)) { $where = ""; } $button = '<table cellspacing=0 cellpadding=2><tr><td>' . $button . '</td></tr></table>'; // Added to have Purchase Order as form Title $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; $smarty->assign("MOD", $mod_strings); $smarty->assign("APP", $app_strings); $smarty->assign("THEME", $theme); $smarty->assign("IMAGE_PATH", $image_path); $smarty->assign("MODULE", $relatedmodule); // We do not have RelatedListView in Detail View mode of Calendar module. So need to skip it. if ($module != 'Calendar') { $focus->initSortByField($relatedmodule); } //Retreive the list from Database //Appending the security parameter Security fix by Don if ($relatedmodule != 'Faq' && $relatedmodule != 'PriceBook' && $relatedmodule != 'Vendors' && $relatedmodule != 'Users') { global $current_user; $secQuery = getNonAdminAccessControlQuery($relatedmodule, $current_user); if (strlen($secQuery) > 1) { $query = appendFromClauseToQuery($query, $secQuery); } } if ($relatedmodule == 'Leads') { $query .= " AND vtiger_leaddetails.converted = 0"; } if (isset($where) && $where != '') { $query .= ' and ' . $where; } if (!$_SESSION['rlvs'][$module][$relatedmodule]) { $modObj = new ListViewSession(); $modObj->sortby = $focus->default_order_by; $modObj->sorder = $focus->default_sort_order; $_SESSION['rlvs'][$module][$relatedmodule] = get_object_vars($modObj); } if (!empty($_REQUEST['order_by'])) { if (method_exists($focus, getSortOrder)) { $sorder = $focus->getSortOrder(); } if (method_exists($focus, getOrderBy)) { $order_by = $focus->getOrderBy(); } if (isset($order_by) && $order_by != '') { $_SESSION['rlvs'][$module][$relatedmodule]['sorder'] = $sorder; $_SESSION['rlvs'][$module][$relatedmodule]['sortby'] = $order_by; } } elseif ($_SESSION['rlvs'][$module][$relatedmodule]) { $sorder = $_SESSION['rlvs'][$module][$relatedmodule]['sorder']; $order_by = $_SESSION['rlvs'][$module][$relatedmodule]['sortby']; } else { $order_by = $focus->default_order_by; $sorder = $focus->default_sort_order; } //Added by Don for AssignedTo ordering issue in Related Lists $query_order_by = $order_by; if ($order_by == 'smownerid') { $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users'); $query_order_by = "case when (vtiger_users.user_name not like '') then {$userNameSql} else vtiger_groups.groupname end "; } elseif ($order_by != 'crmid' && !empty($order_by)) { $tabname = getTableNameForField($relatedmodule, $order_by); if ($tabname !== '' and $tabname != NULL) { $query_order_by = $tabname . "." . $query_order_by; } } if (!empty($query_order_by)) { $query .= ' ORDER BY ' . $query_order_by . ' ' . $sorder; } if ($relatedmodule == 'Calendar') { $mod_listquery = "activity_listquery"; } else { $mod_listquery = strtolower($relatedmodule) . "_listquery"; } $_SESSION[$mod_listquery] = $query; $url_qry = "&order_by=" . $order_by . "&sorder=" . $sorder; $computeCount = isset($_REQUEST['withCount']) ? $_REQUEST['withCount'] : ''; if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true || (bool) $computeCount == true) { //Retreiving the no of rows if ($relatedmodule == "Calendar") { //for calendar related list, count will increase when we have multiple contacts //relationship for single activity $count_query = mkCountQuery($query); $count_result = $adb->query($count_query); $noofrows = $adb->query_result($count_result, 0, "count"); } else { $count_query = mkCountQuery($query); $count_result = $adb->query($count_query); if ($adb->num_rows($count_result) > 0) { $noofrows = $adb->query_result($count_result, 0, "count"); } else { $noofrows = $adb->num_rows($count_result); } } } else { $noofrows = null; } //Setting Listview session object while sorting/pagination if (isset($_REQUEST['relmodule']) && $_REQUEST['relmodule'] != '' && $_REQUEST['relmodule'] == $relatedmodule) { $relmodule = vtlib_purify($_REQUEST['relmodule']); if ($_SESSION['rlvs'][$module][$relmodule]) { setSessionVar($_SESSION['rlvs'][$module][$relmodule], $noofrows, $list_max_entries_per_page, $module, $relmodule); } } global $relationId; $start = RelatedListViewSession::getRequestCurrentPage($relationId, $query); $navigation_array = VT_getSimpleNavigationValues($start, $list_max_entries_per_page, $noofrows); $limit_start_rec = ($start - 1) * $list_max_entries_per_page; $list_result = $adb->pquery($query . " LIMIT {$limit_start_rec}, {$list_max_entries_per_page}", array()); /* Save the related list in session for when we click in a register * from this list we will can navigate with the arrows left and right, to move only in this related list */ $relcv = new CustomView(); $relviewId = $relcv->getViewId($relatedmodule); ListViewSession::setSessionQuery($relatedmodule, $query, $relviewId); $_SESSION['lvs'][$relatedmodule][$relviewId]['start'] = $start; //Retreive the List View Table Header $id = vtlib_purify($_REQUEST['record']); $listview_header = getListViewHeader($focus, $relatedmodule, '', $sorder, $order_by, $id, '', $module, $skipActions); //"Accounts"); if ($noofrows > 15) { $smarty->assign('SCROLLSTART', '<div style="overflow:auto;height:315px;width:100%;">'); $smarty->assign('SCROLLSTOP', '</div>'); } $smarty->assign("LISTHEADER", $listview_header); if ($module == 'PriceBook' && $relatedmodule == 'Products') { $listview_entries = getListViewEntries($focus, $relatedmodule, $list_result, $navigation_array, 'relatedlist', $returnset, $edit_val, $del_val, '', '', '', '', $skipActions); } if ($module == 'Products' && $relatedmodule == 'PriceBooks') { $listview_entries = getListViewEntries($focus, $relatedmodule, $list_result, $navigation_array, 'relatedlist', $returnset, 'EditListPrice', 'DeletePriceBookProductRel', '', '', '', '', $skipActions); } elseif ($relatedmodule == 'SalesOrder') { $listview_entries = getListViewEntries($focus, $relatedmodule, $list_result, $navigation_array, 'relatedlist', $returnset, 'SalesOrderEditView', 'DeleteSalesOrder', '', '', '', '', $skipActions); } else { $listview_entries = getListViewEntries($focus, $relatedmodule, $list_result, $navigation_array, 'relatedlist', $returnset, $edit_val, $del_val, '', '', '', '', $skipActions); } $navigationOutput = array(); $navigationOutput[] = getRecordRangeMessage($list_result, $limit_start_rec, $noofrows); if (empty($id) && !empty($_REQUEST['record'])) { $id = vtlib_purify($_REQUEST['record']); } $navigationOutput[] = getRelatedTableHeaderNavigation($navigation_array, $url_qry, $module, $relatedmodule, $id); $related_entries = array('header' => $listview_header, 'entries' => $listview_entries, 'navigation' => $navigationOutput); $log->debug("Exiting GetRelatedList method ..."); return $related_entries; }
$_SESSION['lvs'][$currentModule]['start'][$folder_id] = $start[$folder_id]; } $limit_start_rec = ($start[$folder_id] - 1) * $max_entries_per_page; if ($adb->dbType == "pgsql") { $list_result = $adb->pquery($query . " OFFSET {$limit_start_rec} LIMIT {$max_entries_per_page}", array()); } else { $list_result = $adb->pquery($query . " LIMIT {$limit_start_rec}, {$max_entries_per_page}", array()); } //navigation end $folder_details = array(); $folderid = $adb->query_result($result, $i, "folderid"); $folder_details['folderid'] = $folderid; $folder_details['foldername'] = $adb->query_result($result, $i, "foldername"); $foldername = $folder_details['foldername']; $folder_details['description'] = $adb->query_result($result, $i, "description"); $folder_files = getListViewEntries($focus, "Documents", $list_result, $navigation_array, "", "", "EditView", "Delete", $oCustomView); $folder_details['entries'] = $folder_files; $folder_details['navigation'] = getTableHeaderSimpleNavigation($navigation_array, $url_string, "Documents", $folder_id, $viewid); $folder_details['recordListRange'] = getRecordRangeMessage($list_result, $limit_start_rec); if ($displayFolder == true) { $folders[$foldername] = $folder_details; } else { $emptyfolders[$foldername] = $folder_details; } if ($folderid == 1) { $default_folder_details = $folder_details; } } if (count($folders) == 0) { $folders[$default_folder_details['foldername']] = $default_folder_details; }
$smarty->assign("SHOW_MASS_SELECT", 'false'); //Retreiving the start value from request if ($module_name == $_REQUEST['nav_module'] && isset($_REQUEST['start']) && $_REQUEST['start'] != '') { $start = vtlib_purify($_REQUEST['start']); } else { $start = 1; } $info_message = '&recordcount=' . vtlib_purify($_REQUEST['recordcount']) . '&noofrows=' . vtlib_purify($_REQUEST['noofrows']) . '&message=' . vtlib_purify($_REQUEST['message']) . '&skipped_record_count=' . vtlib_purify($_REQUEST['skipped_record_count']); $url_string = '&modulename=' . vtlib_purify($_REQUEST['modulename']) . '&nav_module=' . $module_name . $info_message; $viewid = ''; //Retreive the Navigation array $navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page); $navigationOutput = getTableHeaderNavigation($navigation_array, $url_string, "Import", "ImportSteplast", $viewid); //Retreive the List View Header and Entries $listview_header = getListViewHeader($object, $module_name); $listview_entries = getListViewEntries($object, $module_name, $list_result, $navigation_array, "", "", "EditView", "Delete", ""); //commented to remove navigation buttons from import list view //$smarty->assign("NAVIGATION", $navigationOutput); $smarty->assign("HIDE_CUSTOM_LINKS", 1); //Added to hide the CustomView links in imported records ListView // Remove all the links for the list view header as they do not work in this page. for ($i = 0; $i < count($listview_header); $i++) { $listview_header[$i] = strip_tags($listview_header[$i]); } $smarty->assign("LISTHEADER", $listview_header); $smarty->assign("LISTENTITY", $listview_entries); $smarty->display("ListViewEntries.tpl"); } } } unset($_SESSION['import_table_picklist']);
/** function used to get the top 5 notes from the ListView query * @return array $values - array with the title, header and entries like Array('Title'=>$title,'Header'=>$listview_header,'Entries'=>$listview_entries) where as listview_header and listview_entries are arrays of header and entity values which are returned from function getListViewHeader and getListViewEntries */ function getMyNotes() { require_once "data/Tracker.php"; require_once 'modules/Notes/Notes.php'; require_once 'include/logging.php'; require_once 'include/ListView/ListView.php'; require_once 'include/database/PearDatabase.php'; require_once 'include/ComboUtil.php'; require_once 'include/utils/utils.php'; require_once 'modules/CustomView/CustomView.php'; global $app_strings, $current_language, $current_user; $current_module_strings = return_module_language($current_language, 'Notes'); global $list_max_entries_per_page, $adb, $theme, $mod_strings; $log = LoggerManager::getLogger('note_list'); $url_string = ''; $sorder = ''; $oCustomView = ""; $focus = new Notes(); $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; //Retreive the list from Database //<<<<<<<<<customview>>>>>>>>> $date_var = date('Y-m-d'); $where = ' and smownerid=' . $current_user->id; $query = getListQuery("Notes", $where); $query .= " ORDER BY modifiedtime DESC"; //<<<<<<<<customview>>>>>>>>> $list_result = $adb->limitQuery($query, 0, 5); //Retreiving the no of rows $noofrows = $adb->num_rows($list_result); //Retreiving the start value from request if (isset($_REQUEST['start']) && $_REQUEST['start'] != '') { $start = $_REQUEST['start']; } else { $start = 1; } //Retreive the Navigation array $navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page); if ($navigation_array['start'] == 1) { if ($noofrows != 0) { $start_rec = $navigation_array['start']; } else { $start_rec = 0; } if ($noofrows > $list_max_entries_per_page) { $end_rec = $navigation_array['start'] + $list_max_entries_per_page - 1; } else { $end_rec = $noofrows; } } else { if ($navigation_array['next'] > $list_max_entries_per_page) { $start_rec = $navigation_array['next'] - $list_max_entries_per_page; $end_rec = $navigation_array['next'] - 1; } else { $start_rec = $navigation_array['prev'] + $list_max_entries_per_page; $end_rec = $noofrows; } } $title = array('TopOpenNotes.gif', $current_module_strings['LBL_MY_TOP_NOTE'], 'home_mytopnote'); //Retreive the List View Table Header $listview_header = getListViewHeader($focus, "Notes", $url_string, $sorder, $order_by, "HomePage", $oCustomView); $listview_entries = getListViewEntries($focus, "Notes", $list_result, $navigation_array, "HomePage", "", "EditView", "Delete", $oCustomView); $values = array('Title' => $title, 'Header' => $listview_header, 'Entries' => $listview_entries); //if ( ($display_empty_home_blocks && $noofrows == 0 ) || ($noofrows>0) ) return $values; }
} $navigation_array = VT_getSimpleNavigationValues($start, $list_max_entries_per_page, $noofrows); $limitStartRecord = ($navigation_array['start'] - 1) * $list_max_entries_per_page; if ($adb->dbType == "pgsql") { $listquery = $listquery . " OFFSET {$limitStartRecord} LIMIT {$list_max_entries_per_page}"; } else { $listquery = $listquery . " LIMIT {$limitStartRecord}, {$list_max_entries_per_page}"; } $list_result = $adb->query($listquery); $moduleRecordCount[$module]['recordListRangeMessage'] = getRecordRangeMessage($list_result, $limitStartRecord, $noofrows); $info_message = '&recordcount=' . $_REQUEST['recordcount'] . '&noofrows=' . $_REQUEST['noofrows'] . '&message=' . $_REQUEST['message'] . '&skipped_record_count=' . $_REQUEST['skipped_record_count']; $url_string = '&modulename=' . $_REQUEST['modulename'] . '&nav_module=' . $module_name . $info_message; $viewid = ''; $navigationOutput = getTableHeaderSimpleNavigation($navigation_array, $url_string, $module, "UnifiedSearch", $viewid); $listview_header = getListViewHeader($focus, $module, "", "", "", "global", $oCustomView); $listview_entries = getListViewEntries($focus, $module, $list_result, $navigation_array, "", "", "", "", $oCustomView); //Do not display the Header if there are no entires in listview_entries if (count($listview_entries) > 0) { $display_header = 1; if (vtlib_isModuleActive('ListViewColors') && count($listview_entries) == 2) { $listview_entries_for1 = $listview_entries; } elseif (!vtlib_isModuleActive('ListViewColors') && count($listview_entries) == 1) { $listview_entries_for1 = $listview_entries; } } else { $display_header = 0; } $smarty->assign("NAVIGATION", $navigationOutput); $smarty->assign("LISTHEADER", $listview_header); $smarty->assign("LISTENTITY", $listview_entries); $smarty->assign("DISPLAYHEADER", $display_header);
/** Function to get related list entries in detailed array format * @param $module -- modulename:: Type string * @param $relatedmodule -- relatedmodule:: Type string * @param $focus -- focus:: Type object * @param $query -- query:: Type string * @param $button -- buttons:: Type string * @param $returnset -- returnset:: Type string * @param $id -- id:: Type string * @param $edit_val -- edit value:: Type string * @param $del_val -- delete value:: Type string * @returns $related_entries -- related entires:: Type string array * */ function GetRelatedList($module, $relatedmodule, $focus, $query, $button, $returnset, $id = '', $edit_val = '', $del_val = '') { global $log; //changed by dingjianting on 2007-11-05 for php5.2.x $log->debug("Entering GetRelatedList() method ..."); require_once 'include/CRMSmarty.php'; require_once 'include/DatabaseUtil.php'; global $adb; global $app_strings; global $current_language; $current_module_strings = return_module_language($current_language, $module); global $list_max_entries_per_page; global $urlPrefix; global $currentModule; global $theme; global $theme_path; global $mod_strings; $list_max_entries_per_page = 10000; // focus_list is the means of passing data to a ListView. global $focus_list; $smarty = new CRMSmarty(); if (!isset($where)) { $where = ""; } $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; $smarty->assign("MOD", $mod_strings); $smarty->assign("APP", $app_strings); $smarty->assign("IMAGE_PATH", $image_path); $smarty->assign("MODULE", $relatedmodule); if (isset($where) && $where != '') { $query .= ' and ' . $where; } /* if(!isset($_SESSION['rlvs'][$module][$relatedmodule]) || !$_SESSION['rlvs'][$module][$relatedmodule]) { $modObj = new ListViewSession(); $modObj->sortby = $focus->default_order_by; $modObj->sorder = $focus->default_sort_order; $_SESSION['rlvs'][$module][$relatedmodule] = get_object_vars($modObj); } */ if (empty($order_by)) { $order_by = $focus->entity_table . "." . $focus->default_order_by; } if (empty($sorder)) { $sorder = $focus->default_sort_order; } $url_qry = "&order_by=" . $order_by; $count_query = mkCountQuery($query); $count_result = $adb->query($count_query); $noofrows = $adb->query_result($count_result, 0, "count"); //Setting Listview session object while sorting/pagination if (isset($_REQUEST['relmodule']) && $_REQUEST['relmodule'] != '' && $_REQUEST['relmodule'] == $relatedmodule) { if (isset($_REQUEST['start']) && $_REQUEST['start'] != '') { $start = $_REQUEST['start']; } else { $start = 1; } } else { $start = 1; } $navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page); $start_rec = $navigation_array['start']; $end_rec = $navigation_array['end_val']; //limiting the query if ($start_rec <= 0) { $limit_start_rec = 0; } else { $limit_start_rec = $start_rec - 1; } //$list_result = $adb->limitQuery2($query,$limit_start_rec,$list_max_entries_per_page,$order_by,$sorder); $list_result = $adb->limitQuery($query, $limit_start_rec, $list_max_entries_per_page, $order_by, $sorder); //Retreive the List View Table Header if ($noofrows == 0) { $smarty->assign('NOENTRIES', $app_strings['LBL_NONE_SCHEDULED']); } else { setRelmodFieldList($relatedmodule, $focus); //set more module field $id = $_REQUEST['record']; $listview_header = getListViewHeader($focus, $relatedmodule, '', $sorder, $order_by, $id, '', $module); //"Accounts"); if ($noofrows > 15) { $smarty->assign('SCROLLSTART', '<div style="overflow:auto;height:315px;width:100%;">'); $smarty->assign('SCROLLSTOP', '</div>'); } $smarty->assign("LISTHEADER", $listview_header); if ($relatedmodule != 'SalesOrder') { $listview_entries = getListViewEntries($focus, $relatedmodule, $list_result, $navigation_array, 'relatedlist', $returnset); } else { $listview_entries = getListViewEntries($focus, $relatedmodule, $list_result, $navigation_array, 'relatedlist', $returnset, 'SalesOrderEditView', 'DeleteSalesOrder'); } $navigationOutput = array(); //$navigationOutput[] = $app_strings['LBL_SHOWING']." " .$start_rec." - ".$end_rec." " .$app_strings['LBL_LIST_OF'] ." ".$noofrows; $navigationOutput[] = $app_strings['LBL_SHOWING'] . " " . $start_rec . " - " . $noofrows; $module_rel = $module . '&relmodule=' . $relatedmodule . '&record=' . $id; //$navigationOutput[] = getRelatedTableHeaderNavigation($navigation_array, $url_qry,$module_rel); //changed by dfar2008 on 2012-04-15 for relatedlist $related_entries = array('header' => $listview_header, 'entries' => $listview_entries, 'navigation' => $navigationOutput); $log->debug("Exiting GetRelatedList method ..."); return $related_entries; } }
private function getModuleFilters($sid) { global $adb, $current_user; $querycvid = "select ec_homemoduleflds.fieldname,ec_homemodule.* from ec_homemoduleflds left join ec_homemodule on ec_homemodule.stuffid=ec_homemoduleflds.stuffid where ec_homemoduleflds.stuffid=" . $sid; $resultcvid = $adb->query($querycvid); $modname = $adb->query_result($resultcvid, 0, "modulename"); $cvid = $adb->query_result($resultcvid, 0, "customviewid"); $maxval = $adb->query_result($resultcvid, 0, "maxentries"); $column_count = $adb->num_rows($resultcvid); $cvid_check_query = $adb->pquery("SELECT * FROM ec_customview WHERE cvid = '{$cvid}'"); if (isPermitted($modname, 'index') == "yes") { if ($adb->num_rows($cvid_check_query) > 0) { if ($modname == 'Calendar') { require_once "modules/Calendar/Activity.php"; $focus = new Activity(); } else { require_once "modules/{$modname}/{$modname}.php"; $focus = new $modname(); } $oCustomView = new CustomView($modname); $listquery = getListQuery($modname); if (trim($listquery) == '') { $listquery = $focus->getListQuery($modname); } $query = $oCustomView->getModifiedCvListQuery($cvid, $listquery, $modname); $count_result = $adb->query(mkCountQuery($query)); $noofrows = $adb->query_result($count_result, 0, "count"); $navigation_array = getNavigationValues(1, $noofrows, $maxval); //To get the current language file global $current_language, $app_strings; $fieldmod_strings = return_module_language($current_language, $modname); if ($modname == 'Calendar') { $query .= "AND ec_activity.activitytype NOT IN ('Emails')"; } if ($adb->dbType == "pgsql") { $list_result = $adb->query($query . " OFFSET 0 LIMIT " . $maxval); } else { $list_result = $adb->query($query . " LIMIT 0," . $maxval); } for ($l = 0; $l < $column_count; $l++) { $fieldinfo = $adb->query_result($resultcvid, $l, "fieldname"); list($tabname, $colname, $fldname, $fieldmodlabel) = explode(":", $fieldinfo); //For Header starts $fieldheader = explode("_", $fieldmodlabel, 2); $fldlabel = $fieldheader[1]; $pos = strpos($fldlabel, "_"); if ($pos == true) { $fldlabel = str_replace("_", " ", $fldlabel); } $field_label = isset($app_strings[$fldlabel]) ? $app_strings[$fldlabel] : (isset($fieldmod_strings[$fldlabel]) ? $fieldmod_strings[$fldlabel] : $fldlabel); $cv_presence = $adb->query("SELECT * from ec_cvcolumnlist WHERE cvid = {$cvid} and columnname LIKE '%" . $fldname . "%'"); if ($is_admin == false) { $fld_permission = getFieldVisibilityPermission($modname, $current_user->id, $fldname); } if ($fld_permission == 0 && $adb->num_rows($cv_presence)) { $field_query = $adb->query("SELECT fieldlabel FROM ec_field WHERE fieldname = '{$fldname}' AND tablename = '{$tabname}'"); $field_label = $adb->query_result($field_query, 0, 'fieldlabel'); $header[] = $field_label; } $fieldcolumns[$fldlabel] = array($tabname => $colname); //For Header ends } $listview_entries = getListViewEntries($focus, $modname, $list_result, $navigation_array, "", "", "EditView", "Delete", $oCustomView, 'HomePage', $fieldcolumns); $return_value = array('ModuleName' => $modname, 'cvid' => $cvid, 'Maxentries' => $maxval, 'Header' => $header, 'Entries' => $listview_entries); if (sizeof($header) != 0) { return $return_value; } else { echo "Fields not found in Selected Filter"; } } else { echo "<font color='red'>Filter You have Selected is Not Found</font>"; } } else { echo "<font color='red'>Permission Denied</font>"; } }
$end_rec = $navigation_array['end_val']; //By Raju Ends //limiting the query if ($start_rec == 0) { $limit_start_rec = 0; } else { $limit_start_rec = $start_rec - 1; } if ($adb->dbType == "pgsql") { $list_result = $adb->query($list_query . " OFFSET " . $limit_start_rec . " LIMIT " . $list_max_entries_per_page); } else { $list_result = $adb->query($list_query . " LIMIT " . $limit_start_rec . "," . $list_max_entries_per_page); } $record_string = $app_strings[LBL_SHOWING] . " " . $start_rec . " - " . $end_rec . " " . $app_strings[LBL_LIST_OF] . " " . $noofrows; $navigationOutput = getTableHeaderNavigation($navigation_array, $url_string, "Recyclebin", "index", ""); $lvEntries = getListViewEntries($focus, $select_module, $list_result, $navigation_array, "", "", "", "", $cur_mod_view, '', '', '', true); } $smarty->assign("NAVIGATION", $navigationOutput); $smarty->assign("RECORD_COUNTS", $record_string); //to get the field name that mentions the module $query = "select fieldname from vtiger_entityname where modulename =?"; $module_fielaname = $adb->query_result($adb->pquery($query, array($select_module)), 0, 'fieldname'); if (strpos($module_fielaname, ',')) { $field_array = explode(',', $module_fielaname); $index_field = $field_array[0]; } else { $index_field = $module_fielaname; } $alphabetical = AlphabeticalSearch($currentModule, 'index', $index_field, 'true', 'basic', "", "", "", "", $viewid); $category = getParentTab(); $check_button = Button_Check($_REQUEST['module']);
/** Function to get related list entries in detailed array format * @param $module -- modulename:: Type string * @param $relatedmodule -- relatedmodule:: Type string * @param $focus -- focus:: Type object * @param $query -- query:: Type string * @param $button -- buttons:: Type string * @param $returnset -- returnset:: Type string * @param $id -- id:: Type string * @param $edit_val -- edit value:: Type string * @param $del_val -- delete value:: Type string * @returns $related_entries -- related entires:: Type string array * */ function GetRelatedList($module, $relatedmodule, $focus, $query, $button, $returnset, $id = '', $edit_val = '', $del_val = '') { $log = LoggerManager::getLogger('account_list'); $log->debug("Entering GetRelatedList(" . $module . "," . $relatedmodule . "," . get_class($focus) . "," . $query . "," . $button . "," . $returnset . "," . $edit_val . "," . $del_val . ") method ..."); require_once 'Smarty_setup.php'; require_once "data/Tracker.php"; require_once 'include/database/PearDatabase.php'; global $adb; global $app_strings; global $current_language; $current_module_strings = return_module_language($current_language, $module); global $list_max_entries_per_page; global $urlPrefix; global $currentModule; global $theme; global $theme_path; global $theme_path; global $mod_strings; // focus_list is the means of passing data to a ListView. global $focus_list; $smarty = new vtigerCRM_Smarty(); if (!isset($where)) { $where = ""; } $button = '<table cellspacing=0 cellpadding=2><tr><td>' . $button . '</td></tr></table>'; // Added to have Purchase Order as form Title $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; $smarty->assign("MOD", $mod_strings); $smarty->assign("APP", $app_strings); $smarty->assign("THEME", $theme); $smarty->assign("IMAGE_PATH", $image_path); $smarty->assign("MODULE", $relatedmodule); // We do not have RelatedListView in Detail View mode of Calendar module. So need to skip it. if ($module != 'Calendar') { $focus->initSortByField($relatedmodule); } //Retreive the list from Database //Appending the security parameter if ($relatedmodule != 'Products' && $relatedmodule != 'Faq' && $relatedmodule != 'PriceBook' && $relatedmodule != 'Vendors') { global $current_user; require 'user_privileges/user_privileges_' . $current_user->id . '.php'; require 'user_privileges/sharing_privileges_' . $current_user->id . '.php'; $tab_id = getTabid($relatedmodule); if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3) { $sec_parameter = getListViewSecurityParameter($relatedmodule); $query .= ' ' . $sec_parameter; } } if ($relatedmodule == 'Leads') { $query .= " AND vtiger_leaddetails.converted = 0"; } if (isset($where) && $where != '') { $query .= ' and ' . $where; } if (!$_SESSION['rlvs'][$module][$relatedmodule]) { $modObj = new ListViewSession(); $modObj->sortby = $focus->default_order_by; $modObj->sorder = $focus->default_sort_order; $_SESSION['rlvs'][$module][$relatedmodule] = get_object_vars($modObj); } if (isset($_REQUEST['relmodule']) && $_REQUEST['relmodule'] == $relatedmodule) { if (method_exists($focus, getSortOrder)) { $sorder = $focus->getSortOrder(); } if (method_exists($focus, getOrderBy)) { $order_by = $focus->getOrderBy(); } if (isset($order_by) && $order_by != '') { $_SESSION['rlvs'][$module][$relatedmodule]['sorder'] = $sorder; $_SESSION['rlvs'][$module][$relatedmodule]['sortby'] = $order_by; } } elseif ($_SESSION['rlvs'][$module][$relatedmodule]) { $sorder = $_SESSION['rlvs'][$module][$relatedmodule]['sorder']; $order_by = $_SESSION['rlvs'][$module][$relatedmodule]['sortby']; } else { $order_by = $focus->default_order_by; $sorder = $focus->default_sort_order; } //Added by Don for AssignedTo ordering issue in Related Lists $query_order_by = $order_by; if ($order_by == 'smownerid') { $query_order_by = "case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end "; } elseif ($order_by != 'crmid' && !empty($order_by)) { $tabname = getTableNameForField($relatedmodule, $order_by); if ($tabname !== '' and $tabname != NULL) { $query_order_by = $tabname . "." . $query_order_by; } } if (!empty($query_order_by)) { $query .= ' ORDER BY ' . $query_order_by . ' ' . $sorder; } if ($relatedmodule == 'Calendar') { $mod_listquery = "activity_listquery"; } else { $mod_listquery = strtolower($relatedmodule) . "_listquery"; } $_SESSION[$mod_listquery] = $query; $url_qry .= "&order_by=" . $order_by . "&sorder=" . $sorder; //Retreiving the no of rows if ($relatedmodule == "Calendar") { //$count_query = "select count(*) as count, vtiger_activity.activitytype ".substr($query, stripos($query,'from'),strlen($query)); $count_query = mkCountQuery($query); $count_result = $adb->query($count_query); $noofrows = $adb->query_result($count_result, 0, "count"); } else { $count_query = mkCountQuery($query); $count_result = $adb->query($count_query); if ($adb->num_rows($count_result) > 0) { $noofrows = $adb->query_result($count_result, 0, "count"); } else { $noofrows = $adb->num_rows($count_result); } } //Setting Listview session object while sorting/pagination if (isset($_REQUEST['relmodule']) && $_REQUEST['relmodule'] != '' && $_REQUEST['relmodule'] == $relatedmodule) { $relmodule = vtlib_purify($_REQUEST['relmodule']); if ($_SESSION['rlvs'][$module][$relmodule]) { setSessionVar($_SESSION['rlvs'][$module][$relmodule], $noofrows, $list_max_entries_per_page, $module, $relmodule); } } $start = $_SESSION['rlvs'][$module][$relatedmodule]['start']; $navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page); $start_rec = $navigation_array['start']; $end_rec = $navigation_array['end_val']; //limiting the query if ($start_rec == 0) { $limit_start_rec = 0; } else { $limit_start_rec = $start_rec - 1; } if ($adb->dbType == "pgsql") { $list_result = $adb->pquery($query . " OFFSET {$limit_start_rec} LIMIT {$list_max_entries_per_page}", array()); } else { $list_result = $adb->pquery($query . " LIMIT {$limit_start_rec}, {$list_max_entries_per_page}", array()); } //Retreive the List View Table Header if ($noofrows == 0) { $smarty->assign('NOENTRIES', $app_strings['LBL_NONE_SCHEDULED']); } else { $id = vtlib_purify($_REQUEST['record']); $listview_header = getListViewHeader($focus, $relatedmodule, '', $sorder, $order_by, $id, '', $module); //"Accounts"); if ($noofrows > 15) { $smarty->assign('SCROLLSTART', '<div style="overflow:auto;height:315px;width:100%;">'); $smarty->assign('SCROLLSTOP', '</div>'); } $smarty->assign("LISTHEADER", $listview_header); if ($module == 'PriceBook' && $relatedmodule == 'Products') { $listview_entries = getListViewEntries($focus, $relatedmodule, $list_result, $navigation_array, 'relatedlist', $returnset, $edit_val, $del_val); } if ($module == 'Products' && $relatedmodule == 'PriceBook') { $listview_entries = getListViewEntries($focus, $relatedmodule, $list_result, $navigation_array, 'relatedlist', $returnset, 'EditListPrice', 'DeletePriceBookProductRel'); } elseif ($relatedmodule == 'SalesOrder') { $listview_entries = getListViewEntries($focus, $relatedmodule, $list_result, $navigation_array, 'relatedlist', $returnset, 'SalesOrderEditView', 'DeleteSalesOrder'); } else { $listview_entries = getListViewEntries($focus, $relatedmodule, $list_result, $navigation_array, 'relatedlist', $returnset); } $navigationOutput = array(); $navigationOutput[] = $app_strings[LBL_SHOWING] . " " . $start_rec . " - " . $end_rec . " " . $app_strings[LBL_LIST_OF] . " " . $noofrows; $module_rel = $module . '&relmodule=' . $relatedmodule . '&record=' . $id; $navigationOutput[] = getRelatedTableHeaderNavigation($navigation_array, $url_qry, $module_rel); $related_entries = array('header' => $listview_header, 'entries' => $listview_entries, 'navigation' => $navigationOutput); $log->debug("Exiting GetRelatedList method ..."); return $related_entries; } }