예제 #1
0
 public function getWidget()
 {
     $widget = array();
     $model = Vtiger_Module_Model::getInstance($this->Data['relatedmodule']);
     if ($model->isPermitted('DetailView')) {
         $this->Config['url'] = $this->getUrl();
         $this->Config['tpl'] = 'Basic.tpl';
         if ($this->Data['action'] == 1) {
             $createPermission = $model->isPermitted('EditView');
             $this->Config['action'] = $createPermission == true ? 1 : 0;
             $this->Config['actionURL'] = $model->getQuickCreateUrl();
         }
         if (isset($this->Data['filter'])) {
             $filterArray = explode('::', $this->Data['filter']);
             $this->Config['field_name'] = $filterArray[2];
         }
         if (isset($this->Data['checkbox']) && $this->Data['checkbox'] != '-') {
             $this->Config['url'] .= '&whereCondition[' . getTableNameForField(getTabModuleName($this->Data['relatedmodule']), $this->Data['checkbox']) . '.' . $this->Data['checkbox'] . ']=1';
             $on = 'LBL_SWITCH_ON_' . strtoupper($this->Data['checkbox']);
             $translateOn = vtranslate($on, $model->getName());
             if ($on == $translateOn) {
                 $translateOn = vtranslate('LBL_YES', $model->getName());
             }
             $off = 'LBL_SWITCH_OFF_' . strtoupper($this->Data['checkbox']);
             $translateOff = vtranslate($off, $model->getName());
             if ($off == $translateOff) {
                 $translateOff = vtranslate('LBL_NO', $model->getName());
             }
             $this->Config['checkboxLables'] = ['on' => $translateOn, 'off' => $translateOff];
         }
         $widget = $this->Config;
     }
     return $widget;
 }
예제 #2
0
    echo "<table border='0' cellpadding='5' cellspacing='0' width='100%' height='450px'><tr><td align='center'>";
    echo "<div style='border: 3px solid rgb(153, 153, 153); background-color: rgb(255, 255, 255); width: 55%; position: relative; z-index: 10000000;'>\n\n\t\t<table border='0' cellpadding='5' cellspacing='0' width='98%'>\n\t\t<tbody><tr>\n\t\t<td rowspan='2' width='11%'><img src='" . vtiger_imageurl('denied.gif', $theme) . "' ></td>\n\t\t<td style='border-bottom: 1px solid rgb(204, 204, 204);' nowrap='nowrap' width='70%'><span clas\n\t\ts='genHeaderSmall'>{$app_strings['LBL_PERMISSION']}</span></td>\n\t\t</tr>\n\t\t<tr>\n\t\t<td class='small' align='right' nowrap='nowrap'>\n\t\t<a href='javascript:window.history.back();'>{$app_strings['LBL_GO_BACK']}</a><br>\n\t\t</td>\n\t\t</tr>\n\t\t</tbody></table>\n\t\t</div>";
    echo "</td></tr></table>";
    exit;
}
$listquery = getListQuery($currentModule);
$list_query = $customView->getModifiedCvListQuery($viewid, $listquery, $currentModule);
if ($where != '') {
    $list_query = "{$list_query} AND {$where}";
}
// Sorting
if (!empty($order_by)) {
    if ($order_by == 'smownerid') {
        $list_query .= ' ORDER BY user_name ' . $sorder;
    } else {
        $tablename = getTableNameForField($currentModule, $order_by);
        $tablename = $tablename != '' ? $tablename . '.' : '';
        $list_query .= ' ORDER BY ' . $tablename . $order_by . ' ' . $sorder;
    }
}
//Postgres 8 fixes
if ($adb->dbType == "pgsql") {
    $list_query = fixPostgresQuery($list_query, $log, 0);
}
if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true) {
    $count_result = $adb->query(mkCountQuery($list_query));
    $noofrows = $adb->query_result($count_result, 0, "count");
} else {
    $noofrows = null;
}
$queryMode = isset($_REQUEST['query']) && $_REQUEST['query'] == 'true';
예제 #3
0
$folders = array();
$emptyfolders = array();
if ($foldercount > 0) {
    for ($i = 0; $i < $foldercount; $i++) {
        $query = '';
        $displayFolder = '';
        $query = $focus->query;
        $list_query = '';
        $list_query = $focus->query;
        $folder_id = $adb->query_result($result, $i, "folderid");
        $query .= " and vtiger_notes.folderid = {$folder_id}";
        if ($folder_id != $request_folderid) {
            $start[$folder_id] = 1;
        }
        if (isset($order_by) && $order_by != '') {
            $tablename = getTableNameForField('Documents', $order_by);
            $tablename = $tablename != '' ? $tablename . "." : '';
            if ($adb->dbType == "pgsql") {
                $query .= ' GROUP BY ' . $tablename . $order_by;
                $list_query .= ' GROUP BY ' . $tablename . $order_by;
                $focus->additional_query .= ' GROUP BY ' . $tablename . $order_by;
            }
            $query .= ' ORDER BY ' . $tablename . $order_by . ' ' . $sorder;
            $list_query .= ' ORDER BY ' . $tablename . $order_by . ' ' . $sorder;
            $focus->additional_query .= ' ORDER BY ' . $tablename . $order_by . ' ' . $sorder;
        }
        //Retreiving the no of rows
        $count_result = $adb->query(mkCountQuery($query));
        $num_records = $adb->query_result($count_result, 0, "count");
        if ($num_records > 0) {
            $displayFolder = true;
예제 #4
0
if ($viewid != "0") {
    $queryGenerator->initForCustomViewById($viewid);
} else {
    $queryGenerator->initForDefaultCustomView();
}
if (isset($_REQUEST['query']) && $_REQUEST['query'] == 'true') {
    $queryGenerator->addUserSearchConditions($_REQUEST);
    $ustring = getSearchURL($_REQUEST);
    // we have a query
    $url_string .= "&query=true" . $ustring;
    $smarty->assign("SEARCH_URL", $url_string);
}
$list_query = $queryGenerator->getQuery();
$view_script = "<script language='javascript'>\r\nfunction set_selected()\r\n{\r\n\tlen=document.massdelete.viewname.length;\r\n\tfor(i=0;i<len;i++)\r\n\t{\r\n\t\tif(document.massdelete.viewname[i].value == '{$viewid}')\r\n\t\tdocument.massdelete.viewname[i].selected = true;\r\n\t}\r\n}\r\n\tset_selected();\r\n\t</script>";
if (isset($order_by) && $order_by != '') {
    $tablename = getTableNameForField('Faq', $order_by);
    $tablename = $tablename != '' ? $tablename . "." : '';
    if ($adb->dbType == "pgsql") {
        $list_query .= ' GROUP BY ' . $tablename . $order_by;
    }
    $list_query .= ' ORDER BY ' . $tablename . $order_by . ' ' . $sorder;
}
//Constructing the list view
$smarty->assign("MOD", $mod_strings);
$smarty->assign("APP", $app_strings);
$smarty->assign("THEME", $theme);
$smarty->assign("IMAGE_PATH", $image_path);
$smarty->assign("MODULE", $currentModule);
$smarty->assign("BUTTONS", $other_text);
$smarty->assign("CATEGORY", $category);
$smarty->assign("SINGLE_MOD", 'Document');
예제 #5
0
    unset($_SESSION['export_where']);
}
$view_script = "<script language='javascript'>\n\tfunction set_selected()\n\t{\n\t\tlen=document.massdelete.viewname.length;\n\t\tfor(i=0;i<len;i++)\n\t\t{\n\t\t\tif(document.massdelete.viewname[i].value == '{$viewid}')\n\t\t\t\tdocument.massdelete.viewname[i].selected = true;\n\t\t}\n\t}\n\tset_selected();\n\t</script>";
// mailer_export
if (isset($other_text['mailer_exp'])) {
    $view_script .= "<script language='javascript'>\n\tfunction mailer_export()\n\t{\n    document.massdelete.action.value=\"MailerExport\";\n    document.massdelete.step.value=\"ask\";\n    window.locate=\"index.php?module=Accounts&action=MailerExport&from=Accounts&step=ask\";\n\t}\n\t</script>";
}
// end of mailer export
if (isset($order_by) && $order_by != '') {
    if ($order_by == 'smownerid') {
        if ($adb->dbType == "pgsql") {
            $query .= ' GROUP BY user_name';
        }
        $query .= ' ORDER BY user_name ' . $sorder;
    } else {
        $tablename = getTableNameForField('Accounts', $order_by);
        $tablename = $tablename != '' ? $tablename . "." : '';
        if ($adb->dbType == "pgsql") {
            $query .= ' GROUP BY ' . $tablename . $order_by;
        }
        $query .= ' ORDER BY ' . $tablename . $order_by . ' ' . $sorder;
    }
}
//Postgres 8 fixes
if ($adb->dbType == "pgsql") {
    $query = fixPostgresQuery($query, $log, 0);
}
if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true) {
    $count_result = $adb->query(mkCountQuery($query));
    $noofrows = $adb->query_result($count_result, 0, "count");
} else {
예제 #6
0
 public static function getListViewNavigation($currentRecordId)
 {
     global $currentModule, $current_user, $adb, $log, $list_max_entries_per_page;
     Zend_Json::$useBuiltinEncoderDecoder = true;
     $reUseData = false;
     $displayBufferRecordCount = 10;
     $bufferRecordCount = 15;
     if ($currentModule == 'Documents') {
         $sql = "select folderid from vtiger_notes where notesid=?";
         $params = array($currentRecordId);
         $result = $adb->pquery($sql, $params);
         $folderId = $adb->query_result($result, 0, 'folderid');
     }
     $cv = new CustomView();
     $viewId = $cv->getViewId($currentModule);
     if (!empty($_SESSION[$currentModule . '_DetailView_Navigation' . $viewId])) {
         $recordNavigationInfo = Zend_Json::decode($_SESSION[$currentModule . '_DetailView_Navigation' . $viewId]);
         $pageNumber = 0;
         if (count($recordNavigationInfo) == 1) {
             foreach ($recordNavigationInfo as $recordIdList) {
                 if (in_array($currentRecordId, $recordIdList)) {
                     $reUseData = true;
                 }
             }
         } else {
             $recordList = array();
             $recordPageMapping = array();
             foreach ($recordNavigationInfo as $start => $recordIdList) {
                 foreach ($recordIdList as $index => $recordId) {
                     $recordList[] = $recordId;
                     $recordPageMapping[$recordId] = $start;
                     if ($recordId == $currentRecordId) {
                         $searchKey = count($recordList) - 1;
                     }
                 }
             }
             if ($searchKey > $displayBufferRecordCount - 1 && $searchKey < count($recordList) - $displayBufferRecordCount) {
                 $reUseData = true;
             }
         }
     }
     if ($reUseData === false) {
         $recordNavigationInfo = array();
         if (!empty($_REQUEST['start'])) {
             $start = ListViewSession::getRequestStartPage();
         } else {
             $start = ListViewSession::getCurrentPage($currentModule, $viewId);
         }
         $startRecord = ($start - 1) * $list_max_entries_per_page - $bufferRecordCount;
         if ($startRecord < 0) {
             $startRecord = 0;
         }
         $list_query = $_SESSION[$currentModule . '_listquery'];
         $instance = CRMEntity::getInstance($currentModule);
         $instance->getNonAdminAccessControlQuery($currentModule, $current_user);
         vtlib_setup_modulevars($currentModule, $instance);
         if ($currentModule == 'Documents' && !empty($folderId)) {
             $list_query = preg_replace("/[\n\r\\s]+/", " ", $list_query);
             $hasOrderBy = stripos($list_query, 'order by');
             if ($hasOrderBy > 0) {
                 $list_query = substr($list_query, 0, $hasOrderBy - 1) . " AND vtiger_notes.folderid={$folderId} " . substr($list_query, $hasOrderBy);
             } else {
                 $list_query .= " AND vtiger_notes.folderid={$folderId}";
                 $order_by = $instance->getOrderByForFolder($folderId);
                 $sorder = $instance->getSortOrderForFolder($folderId);
                 $tablename = getTableNameForField($currentModule, $order_by);
                 $tablename = $tablename != '' ? $tablename . "." : '';
                 if (!empty($order_by)) {
                     $list_query .= ' ORDER BY ' . $tablename . $order_by . ' ' . $sorder;
                 }
             }
         }
         if ($start != 1) {
             $recordCount = $list_max_entries_per_page + 2 * $bufferRecordCount;
         } else {
             $recordCount = $list_max_entries_per_page + $bufferRecordCount;
         }
         $list_query .= " LIMIT {$startRecord}, {$recordCount}";
         $resultAllCRMIDlist_query = $adb->pquery($list_query, array());
         $navigationRecordList = array();
         while ($forAllCRMID = $adb->fetch_array($resultAllCRMIDlist_query)) {
             $navigationRecordList[] = $forAllCRMID[$instance->table_index];
         }
         $pageCount = 0;
         $current = $start;
         if ($start == 1) {
             $firstPageRecordCount = $list_max_entries_per_page;
         } else {
             $firstPageRecordCount = $bufferRecordCount;
             $current -= 1;
         }
         $searchKey = array_search($currentRecordId, $navigationRecordList);
         $recordNavigationInfo = array();
         if ($searchKey !== false) {
             foreach ($navigationRecordList as $index => $recordId) {
                 if (!is_array($recordNavigationInfo[$current])) {
                     $recordNavigationInfo[$current] = array();
                 }
                 if ($index == $firstPageRecordCount || $index == $firstPageRecordCount + $pageCount * $list_max_entries_per_page) {
                     $current++;
                     $pageCount++;
                 }
                 $recordNavigationInfo[$current][] = $recordId;
             }
         }
         $_SESSION[$currentModule . '_DetailView_Navigation' . $viewId] = Zend_Json::encode($recordNavigationInfo);
     }
     return $recordNavigationInfo;
 }
예제 #7
0
파일: export.php 프로젝트: nvh3010/quancrm
/**
 * This function exports all the data for a given module
 * Param $type - module name
 * Return type text
 */
function export($type)
{
    global $log, $list_max_entries_per_page;
    $log->debug("Entering export(" . $type . ") method ...");
    global $adb;
    $focus = 0;
    $content = '';
    if ($type != "") {
        // vtlib customization: Hook to dynamically include required module file.
        // Refer to the logic in setting $currentModule in index.php
        $focus = CRMEntity::getInstance($type);
    }
    $log = LoggerManager::getLogger('export_' . $type);
    $db = PearDatabase::getInstance();
    $oCustomView = new CustomView("{$type}");
    $viewid = $oCustomView->getViewId("{$type}");
    $sorder = $focus->getSortOrder();
    $order_by = $focus->getOrderBy();
    $search_type = $_REQUEST['search_type'];
    $export_data = $_REQUEST['export_data'];
    if (isset($_SESSION['export_where']) && $_SESSION['export_where'] != '' && $search_type == 'includesearch') {
        $where = $_SESSION['export_where'];
    }
    $query = $focus->create_export_query($where);
    if ($search_type != 'includesearch' && $type != 'Calendar') {
        $stdfiltersql = $oCustomView->getCVStdFilterSQL($viewid);
        $advfiltersql = $oCustomView->getCVAdvFilterSQL($viewid);
        if (isset($stdfiltersql) && $stdfiltersql != '') {
            $query .= ' and ' . $stdfiltersql;
        }
        if (isset($advfiltersql) && $advfiltersql != '') {
            $query .= ' and ' . $advfiltersql;
        }
    }
    $params = array();
    if (($search_type == 'withoutsearch' || $search_type == 'includesearch') && $export_data == 'selecteddata') {
        $idstring = explode(";", $_REQUEST['idstring']);
        if ($type == 'Accounts' && count($idstring) > 0) {
            $query .= ' and vtiger_account.accountid in (' . generateQuestionMarks($idstring) . ')';
            array_push($params, $idstring);
        } elseif ($type == 'Contacts' && count($idstring) > 0) {
            $query .= ' and vtiger_contactdetails.contactid in (' . generateQuestionMarks($idstring) . ')';
            array_push($params, $idstring);
        } elseif ($type == 'Potentials' && count($idstring) > 0) {
            $query .= ' and vtiger_potential.potentialid in (' . generateQuestionMarks($idstring) . ')';
            array_push($params, $idstring);
        } elseif ($type == 'Leads' && count($idstring) > 0) {
            $query .= ' and vtiger_leaddetails.leadid in (' . generateQuestionMarks($idstring) . ')';
            array_push($params, $idstring);
        } elseif ($type == 'Products' && count($idstring) > 0) {
            $query .= ' and vtiger_products.productid in (' . generateQuestionMarks($idstring) . ')';
            array_push($params, $idstring);
        } elseif ($type == 'Documents' && count($idstring) > 0) {
            $query .= ' and vtiger_notes.notesid in (' . generateQuestionMarks($idstring) . ')';
            array_push($params, $idstring);
        } elseif ($type == 'HelpDesk' && count($idstring) > 0) {
            $query .= ' and vtiger_troubletickets.ticketid in (' . generateQuestionMarks($idstring) . ')';
            array_push($params, $idstring);
        } elseif ($type == 'Vendors' && count($idstring) > 0) {
            $query .= ' and vtiger_vendor.vendorid in (' . generateQuestionMarks($idstring) . ')';
            array_push($params, $idstring);
        } else {
            if (count($idstring) > 0) {
                // vtlib customization: Hook to make the export feature available for custom modules.
                $query .= " and {$focus->table_name}.{$focus->table_index} in (" . generateQuestionMarks($idstring) . ')';
                array_push($params, $idstring);
                // END
            }
        }
    }
    if (isset($order_by) && $order_by != '') {
        if ($order_by == 'smownerid') {
            $query .= ' ORDER BY user_name ' . $sorder;
        } elseif ($order_by == 'lastname' && $type == 'Documents') {
            $query .= ' ORDER BY vtiger_contactdetails.lastname  ' . $sorder;
        } elseif ($order_by == 'crmid' && $type == 'HelpDesk') {
            $query .= ' ORDER BY vtiger_troubletickets.ticketid  ' . $sorder;
        } else {
            $tablename = getTableNameForField($type, $order_by);
            $tablename = $tablename != '' ? $tablename . "." : '';
            if ($adb->dbType == "pgsql") {
                $query .= ' GROUP BY ' . $tablename . $order_by;
            }
            $query .= ' ORDER BY ' . $tablename . $order_by . ' ' . $sorder;
        }
    }
    if ($export_data == 'currentpage') {
        $current_page = ListViewSession::getCurrentPage($type, $viewid);
        $limit_start_rec = ($current_page - 1) * $list_max_entries_per_page;
        if ($limit_start_rec < 0) {
            $limit_start_rec = 0;
        }
        $query .= ' LIMIT ' . $limit_start_rec . ',' . $list_max_entries_per_page;
    }
    $result = $adb->pquery($query, $params, true, "Error exporting {$type}: " . "<BR>{$query}");
    $fields_array = $adb->getFieldsArray($result);
    $fields_array = array_diff($fields_array, array("user_name"));
    $__processor = new ExportUtils($type, $fields_array);
    // Translated the field names based on the language used.
    $translated_fields_array = array();
    for ($i = 0; $i < count($fields_array); $i++) {
        $translated_fields_array[$i] = getTranslatedString($fields_array[$i], $type);
    }
    $header = implode("\",\"", array_values($translated_fields_array));
    $header = "\"" . $header;
    $header .= "\"\r\n";
    /** Output header information */
    echo $header;
    $column_list = implode(",", array_values($fields_array));
    while ($val = $adb->fetchByAssoc($result, -1, false)) {
        $new_arr = array();
        $val = $__processor->sanitizeValues($val);
        foreach ($val as $key => $value) {
            if ($type == 'Documents' && $key == 'description') {
                $value = strip_tags($value);
                $value = str_replace('&nbsp;', '', $value);
                array_push($new_arr, $value);
            } elseif ($key != "user_name") {
                // Let us provide the module to transform the value before we save it to CSV file
                $value = $focus->transform_export_value($key, $value);
                array_push($new_arr, preg_replace("/\"/", "\"\"", $value));
            }
        }
        $line = implode("\",\"", $new_arr);
        $line = "\"" . $line;
        $line .= "\"\r\n";
        /** Output each row information */
        echo $line;
    }
    $log->debug("Exiting export method ...");
    return true;
}
예제 #8
0
$url_string = '';
if ($_REQUEST['query'] == 'true') {
    $queryGenerator->addUserSearchConditions($_REQUEST);
    $ustring = getSearchURL($_REQUEST);
    $url_string .= "&query=true{$ustring}";
    $smarty->assign('SEARCH_URL', $url_string);
}
$list_query = $queryGenerator->getQuery();
$where = $queryGenerator->getConditionalWhere();
if (isset($where) && $where != '') {
    $_SESSION['export_where'] = $where;
} else {
    unset($_SESSION['export_where']);
}
if (isset($order_by) && $order_by != '') {
    $tablename = getTableNameForField('Vendors', $order_by);
    $tablename = $tablename != '' ? $tablename . "." : '';
    if ($adb->dbType == "pgsql") {
        $list_query .= ' GROUP BY ' . $tablename . $order_by;
    }
    $list_query .= ' ORDER BY ' . $tablename . $order_by . ' ' . $sorder;
}
//Postgres 8 fixes
if ($adb->dbType == "pgsql") {
    $list_query = fixPostgresQuery($list_query, $log, 0);
}
if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true) {
    $count_result = $adb->query(mkCountQuery($list_query));
    $noofrows = $adb->query_result($count_result, 0, "count");
} else {
    $noofrows = null;
예제 #9
0
파일: ListView.php 프로젝트: Pengzw/c3crm
$navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page);
//Postgres 8 fixes
if ($adb->dbType == "pgsql") {
    $query = fixPostgresQuery($query, $log, 0);
}
// Setting the record count string
//modified by rdhital
$start_rec = $navigation_array['start'];
$end_rec = $navigation_array['end_val'];
//By raju Ends
//limiting the query
if (isset($order_by) && $order_by != '') {
    if ($order_by == 'smownerid') {
        $query_order_by = 'user_name';
    } else {
        $tablename = getTableNameForField('Notes', $order_by);
        $tablename = $tablename != '' ? $tablename . "." : '';
        $query_order_by = $tablename . $order_by;
    }
}
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, $query_order_by, $sorder);
$record_string = $app_strings["LBL_SHOWING"] . " " . $start_rec . " - " . $end_rec . " " . $app_strings["LBL_LIST_OF"] . " " . $noofrows;
//Retreive the List View Table Header
if ($viewid != '') {
    $url_string .= "&viewname=" . $viewid;
}
예제 #10
0
파일: ListView.php 프로젝트: hardikk/HNH
        $list_query .= " AND vtiger_potential.sales_stage = '" . $mod_strings['Closed Won'] . "' AND " . $where;
    } elseif (isset($_REQUEST['from_homepagedb']) && $_REQUEST['from_homepagedb'] == 'true') {
        $list_query .= " AND vtiger_potential.sales_stage not in( '" . $mod_strings['Closed Won'] . "' , '" . $mod_strings['Closed Lost'] . "' )AND " . $where;
    }
    $_SESSION['export_where'] = $where;
} else {
    unset($_SESSION['export_where']);
}
if (isset($order_by) && $order_by != '') {
    if ($order_by == 'smownerid') {
        if ($adb->dbType == "pgsql") {
            $list_query .= ' GROUP BY user_name';
        }
        $list_query .= ' ORDER BY user_name ' . $sorder;
    } else {
        $tablename = getTableNameForField('Potentials', $order_by);
        $tablename = $tablename != '' ? $tablename . "." : '';
        if ($adb->dbType == "pgsql") {
            $list_query .= ' GROUP BY ' . $tablename . $order_by;
        }
        $list_query .= ' ORDER BY ' . $tablename . $order_by . ' ' . $sorder;
    }
}
if ($viewid == 0) {
    echo "<table border='0' cellpadding='5' cellspacing='0' width='100%' height='450px'><tr><td align='center'>";
    echo "<div style='border: 3px solid rgb(153, 153, 153); background-color: rgb(255, 255, 255); width: 55%; position: relative; z-index: 10000000;'>\n\n\t\t<table border='0' cellpadding='5' cellspacing='0' width='98%'>\n\t\t<tbody><tr>\n\t\t<td rowspan='2' width='11%'><img src='" . vtiger_imageurl('denied.gif', $theme) . "' ></td>\n\t\t<td style='border-bottom: 1px solid rgb(204, 204, 204);' nowrap='nowrap' width='70%'><span clas\n\t\ts='genHeaderSmall'>{$app_strings['LBL_PERMISSION']}</span></td>\n\t\t</tr>\n\t\t<tr>\n\t\t<td class='small' align='right' nowrap='nowrap'>\n\t\t<a href='javascript:window.history.back();'>{$app_strings['LBL_GO_BACK']}</a><br>\n\t\t</td>\n\t\t</tr>\n\t\t</tbody></table>\n\t\t</div>";
    echo "</td></tr></table>";
    exit;
}
//Constructing the list view
$smarty->assign("MOD", $mod_strings);
예제 #11
0
    $list_query .= " AND vtiger_seactivityrel.crmid in (select contactid from vtiger_contactdetails) AND vtiger_emaildetails.email_flag !='WEBMAIL'";
}
if ($_REQUEST['folderid'] == '3') {
    $list_query .= " AND vtiger_seactivityrel.crmid in (select accountid from vtiger_account)";
}
if ($_REQUEST['folderid'] == '4') {
    $list_query .= " AND vtiger_seactivityrel.crmid in (select leadid from vtiger_leaddetails)";
}
if ($_REQUEST['folderid'] == '5') {
    $list_query .= " AND vtiger_salesmanactivityrel.smid in (select id from vtiger_users)";
}
if ($_REQUEST['folderid'] == '6') {
    $list_query .= " AND vtiger_emaildetails.email_flag ='WEBMAIL'";
}
if (isset($order_by) && $order_by != '') {
    $tablename = getTableNameForField('Emails', $order_by);
    $tablename = $tablename != '' ? $tablename . "." : '';
    $list_query .= ' ORDER BY ' . $tablename . $order_by . ' ' . $sorder;
}
$list_result = $adb->query($list_query);
//Constructing the list view
$smarty->assign("CUSTOMVIEW_OPTION", $customviewcombo_html);
$smarty->assign("VIEWID", $viewid);
$smarty->assign("MOD", $mod_strings);
$smarty->assign("APP", $app_strings);
$smarty->assign("THEME", $theme);
$smarty->assign("IMAGE_PATH", $image_path);
$smarty->assign("MODULE", $currentModule);
$smarty->assign("SINGLE_MOD", 'Email');
$smarty->assign("BUTTONS", $other_text);
$category = getParentTab();
예제 #12
0
if ($_REQUEST['query'] == 'true') {
    $queryGenerator->addUserSearchConditions($_REQUEST);
    $ustring = getSearchURL($_REQUEST);
    $url_string .= "&query=true{$ustring}";
    $smarty->assign('SEARCH_URL', $url_string);
}
$list_query = $queryGenerator->getQuery();
//sort by "assignedto" and default sort by "ticketid"(DESC)
if (isset($order_by) && $order_by != '') {
    if ($order_by == 'smownerid') {
        if ($adb->dbType == "pgsql") {
            $list_query .= ' GROUP BY user_name';
        }
        $list_query .= ' ORDER BY user_name ' . $sorder;
    } else {
        $tablename = getTableNameForField('Campaigns', $order_by);
        $tablename = $tablename != '' ? $tablename . "." : '';
        if ($adb->dbType == "pgsql") {
            $list_query .= ' GROUP BY ' . $tablename . $order_by;
        }
        $list_query .= ' ORDER BY ' . $tablename . $order_by . ' ' . $sorder;
    }
} else {
    if ($adb->dbType == "pgsql") {
        $list_query .= ' GROUP BY vtiger_campaign.campaignid';
    }
    $list_query .= ' ORDER BY vtiger_campaign.campaignid DESC';
}
//Postgres 8 fixes
if ($adb->dbType == "pgsql") {
    $list_query = fixPostgresQuery($list_query, $log, 0);
예제 #13
0
$url_string = '';
if ($_REQUEST['query'] == 'true') {
    $queryGenerator->addUserSearchConditions($_REQUEST);
    $ustring = getSearchURL($_REQUEST);
    $url_string .= "&query=true{$ustring}";
    $smarty->assign('SEARCH_URL', $url_string);
}
$query = $queryGenerator->getQuery();
if (isset($order_by) && $order_by != '') {
    if ($order_by == 'smownerid') {
        if ($adb->dbType == "pgsql") {
            $query .= ' GROUP BY user_name';
        }
        $query .= ' ORDER BY user_name ' . $sorder;
    } else {
        $tablename = getTableNameForField('PurchaseOrder', $order_by);
        $tablename = $tablename != '' ? $tablename . "." : '';
        if ($adb->dbType == "pgsql") {
            $query .= ' GROUP BY ' . $tablename . $order_by;
        }
        $query .= ' ORDER BY ' . $tablename . $order_by . ' ' . $sorder;
    }
}
//Postgres 8 fixes
if ($adb->dbType == "pgsql") {
    $query = fixPostgresQuery($query, $log, 0);
}
if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true) {
    $count_result = $adb->query(mkCountQuery($query));
    $noofrows = $adb->query_result($count_result, 0, "count");
} else {
예제 #14
0
파일: ListView.php 프로젝트: hardikk/HNH
    if (isset($_REQUEST['from_homepagedb']) && $_REQUEST['from_homepagedb'] == 'true') {
        $list_query .= " and (vtiger_troubletickets.status!='Closed' or vtiger_troubletickets.status is null) and " . $where;
    }
    $_SESSION['export_where'] = $where;
} else {
    unset($_SESSION['export_where']);
}
//sort by "assignedto" and default sort by "ticketid"(DESC)
if (isset($order_by) && $order_by != '') {
    if ($order_by == 'smownerid') {
        if ($adb->dbType == "pgsql") {
            $list_query .= ' GROUP BY vtiger_users.user_name';
        }
        $list_query .= " ORDER BY case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end " . $sorder;
    } else {
        $tablename = getTableNameForField('HelpDesk', $order_by);
        $tablename = $tablename != '' ? $tablename . "." : '';
        if ($adb->dbType == "pgsql") {
            $list_query .= ' GROUP BY ' . $tablename . $order_by;
        }
        $list_query .= ' ORDER BY ' . $tablename . $order_by . ' ' . $sorder;
    }
} else {
    if ($adb->dbType == "pgsql") {
        $list_query .= ' GROUP BY vtiger_troubletickets.ticketid';
    }
    $list_query .= ' ORDER BY vtiger_troubletickets.ticketid DESC';
}
//Constructing the list view
//Postgres 8 fixes
if ($adb->dbType == "pgsql") {
예제 #15
0
    $smarty->assign("ALL", 'All');
}
//Retreive the list from Database
//<<<<<<<<<customview>>>>>>>>>
if ($viewid != "0") {
    $listquery = getListQuery("PriceBooks");
    $list_query = $oCustomView->getModifiedCvListQuery($viewid, $listquery, "PriceBooks");
} else {
    $list_query = getListQuery("PriceBooks");
}
//<<<<<<<<customview>>>>>>>>>
if (isset($where) && $where != '') {
    $list_query .= ' and ' . $where;
}
if (isset($order_by) && $order_by != '') {
    $tablename = getTableNameForField('PriceBooks', $order_by);
    $tablename = $tablename != '' ? $tablename . "." : '';
    if ($adb->dbType == "pgsql") {
        $list_query .= ' GROUP BY ' . $tablename . $order_by;
    }
    $list_query .= ' ORDER BY ' . $tablename . $order_by . ' ' . $sorder;
}
///Postgres 8 fixes
if ($adb->dbType == "pgsql") {
    $list_query = fixPostgresQuery($list_query, $log, 0);
}
if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true) {
    $count_result = $adb->query(mkCountQuery($list_query));
    $noofrows = $adb->query_result($count_result, 0, "count");
} else {
    $noofrows = null;
예제 #16
0
    $url_string .= "&query=true" . $ustring;
    $log->info("Here is the where clause for the list view: {$where}");
    $smarty->assign("SEARCH_URL", $url_string);
}
$query = $queryGenerator->getQuery();
$where = $queryGenerator->getConditionalWhere();
if (isset($where) && $where != '') {
    $_SESSION['export_where'] = $where;
} else {
    unset($_SESSION['export_where']);
}
if (isset($order_by) && $order_by != '') {
    if ($order_by == 'smownerid') {
        $query .= ' ORDER BY user_name ' . $sorder;
    } else {
        $tablename = getTableNameForField('Leads', $order_by);
        $tablename = $tablename != '' ? $tablename . "." : '';
        if ($adb->dbType == "pgsql") {
            $query .= ' GROUP BY ' . $tablename . $order_by;
        }
        $query .= ' ORDER BY ' . $tablename . $order_by . ' ' . $sorder;
    }
}
//Postgres 8 fixes
if ($adb->dbType == "pgsql") {
    $query = fixPostgresQuery($query, $log, 0);
}
if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true) {
    $count_result = $adb->query(mkCountQuery($query));
    $noofrows = $adb->query_result($count_result, 0, "count");
} else {
예제 #17
0
}
//<<<<<<<<customview>>>>>>>>>
if (isset($where) && $where != '') {
    $list_query .= " AND " . $where;
    $_SESSION['export_where'] = $where;
} else {
    unset($_SESSION['export_where']);
}
if (isset($order_by) && $order_by != '') {
    if ($order_by == 'smownerid') {
        if ($adb->dbType == "pgsql") {
            $list_query .= ' GROUP BY user_name';
        }
        $list_query .= ' ORDER BY user_name ' . $sorder;
    } else {
        $tablename = getTableNameForField('Contacts', $order_by);
        $tablename = $tablename != '' ? $tablename . "." : '';
        if ($adb->dbType == "pgsql") {
            $list_query .= ' GROUP BY ' . $tablename . $order_by;
        }
        $list_query .= ' ORDER BY ' . $tablename . $order_by . ' ' . $sorder;
    }
}
//Constructing the list view
$smarty->assign("MOD", $mod_strings);
$smarty->assign("APP", $app_strings);
$smarty->assign("THEME", $theme);
$smarty->assign("IMAGE_PATH", $image_path);
$smarty->assign("BUTTONS", $other_text);
$category = getParentTab();
$smarty->assign("CATEGORY", $category);
예제 #18
0
} else {
    $query = getListQuery("Invoice");
}
//<<<<<<<<customview>>>>>>>>>
if (isset($where) && $where != '') {
    $query .= ' and ' . $where;
}
//$url_qry = getURLstring($focus);
if (isset($order_by) && $order_by != '') {
    if ($order_by == 'smownerid') {
        if ($adb->dbType == "pgsql") {
            $query .= ' GROUP BY user_name';
        }
        $query .= ' ORDER BY user_name ' . $sorder;
    } else {
        $tablename = getTableNameForField('Invoice', $order_by);
        $tablename = $tablename != '' ? $tablename . "." : '';
        if ($adb->dbType == "pgsql") {
            $query .= ' GROUP BY ' . $tablename . $order_by;
        }
        $query .= ' ORDER BY ' . $tablename . $order_by . ' ' . $sorder;
    }
}
//Postgres 8 fixes
if ($adb->dbType == "pgsql") {
    $query = fixPostgresQuery($query, $log, 0);
}
if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true) {
    $count_result = $adb->query(mkCountQuery($query));
    $noofrows = $adb->query_result($count_result, 0, "count");
} else {
예제 #19
0
        $list_query .= " AND " . $where;
    }
}
if (isset($_REQUEST['from_homepage'])) {
    $today = date("Y-m-d", time());
    if ($_REQUEST['from_homepage'] == 'upcoming_activities') {
        $list_query .= " AND (vtiger_activity.status is NULL OR vtiger_activity.status not in ('Completed','Deferred')) and (vtiger_activity.eventstatus is NULL OR  vtiger_activity.eventstatus not in ('Held','Not Held')) AND (date_start >= '{$today}' OR vtiger_recurringevents.recurringdate >= '{$today}')";
    } elseif ($_REQUEST['from_homepage'] == 'pending_activities') {
        $list_query .= " AND (vtiger_activity.status is NULL OR vtiger_activity.status not in ('Completed','Deferred')) and (vtiger_activity.eventstatus is NULL OR  vtiger_activity.eventstatus not in ('Held','Not Held')) AND (due_date <= '{$today}' OR vtiger_recurringevents.recurringdate <= '{$today}')";
    }
}
if (isset($order_by) && $order_by != '') {
    if ($order_by == 'smownerid') {
        $list_query .= ' ORDER BY user_name ' . $sorder;
    } else {
        $tablename = getTableNameForField('Calendar', $order_by);
        $tablename = $tablename != '' ? $tablename . "." : '';
        if ($order_by == 'lastname') {
            $list_query .= ' ORDER BY vtiger_contactdetails.lastname ' . $sorder;
        } else {
            $list_query .= ' ORDER BY ' . $tablename . $order_by . ' ' . $sorder;
        }
    }
}
//Constructing the list view
$smarty->assign("CUSTOMVIEW_OPTION", $customviewcombo_html);
$smarty->assign("VIEWID", $viewid);
$smarty->assign("MOD", $mod_strings);
$smarty->assign("APP", $app_strings);
$smarty->assign("THEME", $theme);
$smarty->assign("IMAGE_PATH", $image_path);
예제 #20
0
/** 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;
}
예제 #21
0
    $list_query = $oCustomView->getModifiedCvListQuery($viewid, $listquery, "SalesOrder");
} else {
    $list_query = getListQuery("SalesOrder");
}
//<<<<<<<<customview>>>>>>>>>
if (isset($where) && $where != '') {
    $list_query .= ' and ' . $where;
}
if (isset($order_by) && $order_by != '') {
    if ($order_by == 'smownerid') {
        if ($adb->dbType == "pgsql") {
            $list_query .= ' GROUP BY user_name';
        }
        $list_query .= ' ORDER BY user_name ' . $sorder;
    } else {
        $tablename = getTableNameForField('SalesOrder', $order_by);
        $tablename = $tablename != '' ? $tablename . "." : '';
        if ($adb->dbType == "pgsql") {
            $list_query .= ' GROUP BY ' . $tablename . $order_by;
        }
        $list_query .= ' ORDER BY ' . $tablename . $order_by . ' ' . $sorder;
    }
}
///Postgres 8 fixes
if ($adb->dbType == "pgsql") {
    $list_query = fixPostgresQuery($list_query, $log, 0);
}
if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true) {
    $count_result = $adb->query(mkCountQuery($list_query));
    $noofrows = $adb->query_result($count_result, 0, "count");
} else {
/** 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;
    }
}