public static function render($userInputObject, $user) { global $list_max_entries_per_page; $adb = PearDatabase::getInstance(); $viewer = new Import_UI_Viewer(); $ownerId = $userInputObject->get('foruser'); $owner = new Users(); $owner->id = $ownerId; $owner->retrieve_entity_info($ownerId, 'Users'); if (!is_admin($user) && $user->id != $owner->id) { $viewer->display('OperationNotPermitted.tpl', 'Vtiger'); exit; } $userDBTableName = Import_Utils::getDbTableName($owner); $moduleName = $userInputObject->get('module'); $moduleMeta = self::getModuleMeta($moduleName, $user); $result = $adb->query('SELECT recordid FROM ' . $userDBTableName . ' WHERE status is NOT NULL AND recordid IS NOT NULL'); $noOfRecords = $adb->num_rows($result); $importedRecordIds = array(); for ($i = 0; $i < $noOfRecords; ++$i) { $importedRecordIds[] = $adb->query_result($result, $i, 'recordid'); } if (count($importedRecordIds) == 0) { $importedRecordIds[] = 0; } $focus = CRMEntity::getInstance($moduleName); $queryGenerator = new QueryGenerator($moduleName, $user); $customView = new CustomView($moduleName); $viewId = $customView->getViewIdByName('All', $moduleName); $queryGenerator->initForCustomViewById($viewId); $list_query = $queryGenerator->getQuery(); // Fetch only last imported records $list_query .= ' AND ' . $focus->table_name . '.' . $focus->table_index . ' IN (' . implode(',', $importedRecordIds) . ')'; 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; } $start = ListViewSession::getRequestCurrentPage($moduleName, $list_query, $viewId, false); $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($list_query . " LIMIT {$limit_start_rec}, {$list_max_entries_per_page}", array()); $recordListRangeMsg = getRecordRangeMessage($list_result, $limit_start_rec, $noofrows); $viewer->assign('recordListRange', $recordListRangeMsg); $controller = new ListViewController($adb, $user, $queryGenerator); $listview_header = $controller->getListViewHeader($focus, $moduleName, $url_string, $sorder, $order_by, true); $listview_entries = $controller->getListViewEntries($focus, $moduleName, $list_result, $navigation_array, true); $viewer->assign('CURRENT_PAGE', $start); $viewer->assign('LISTHEADER', $listview_header); $viewer->assign('LISTENTITY', $listview_entries); $viewer->assign('FOR_MODULE', $moduleName); $viewer->assign('FOR_USER', $ownerId); $isAjax = $userInputObject->get('ajax'); if (!empty($isAjax)) { echo $viewer->fetch('ListViewEntries.tpl'); } else { $viewer->display('ImportListView.tpl'); } }
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'; $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 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']));
/** Function to display the Services which are related to the PriceBook * @param string $query - query to get the list of products which are related to the current PriceBook * @param object $focus - PriceBook object which contains all the information of the current PriceBook * @param string $returnset - return_module, return_action and return_id which are sequenced with & to pass to the URL which is optional * return array $return_data which will be formed like array('header'=>$header,'entries'=>$entries_list) where as $header contains all the header columns and $entries_list will contain all the Service entries */ function getPriceBookRelatedServices($query, $focus, $returnset = '') { global $log; $log->debug("Entering getPriceBookRelatedServices(" . $query . "," . get_class($focus) . "," . $returnset . ") method ..."); global $adb; global $app_strings; global $current_language, $current_user; $current_module_strings = return_module_language($current_language, 'Services'); global $list_max_entries_per_page; global $urlPrefix; global $theme; $pricebook_id = $_REQUEST['record']; $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; $computeCount = $_REQUEST['withCount']; if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true || (bool) $computeCount == true) { $noofrows = $adb->query_result($adb->query(mkCountQuery($query)), 0, 'count'); } else { $noofrows = null; } $module = 'PriceBooks'; $relatedmodule = 'Services'; 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'] != '' && $_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; 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()); } $header = array(); $header[] = $current_module_strings['LBL_LIST_SERVICE_NAME']; if (getFieldVisibilityPermission('Services', $current_user->id, 'unit_price') == '0') { $header[] = $current_module_strings['LBL_SERVICE_UNIT_PRICE']; } $header[] = $current_module_strings['LBL_PB_LIST_PRICE']; if (isPermitted("PriceBooks", "EditView", "") == 'yes' || isPermitted("PriceBooks", "Delete", "") == 'yes') { $header[] = $app_strings['LBL_ACTION']; } $currency_id = $focus->column_fields['currency_id']; $numRows = $adb->num_rows($list_result); for ($i = 0; $i < $numRows; $i++) { $entity_id = $adb->query_result($list_result, $i, "crmid"); $unit_price = $adb->query_result($list_result, $i, "unit_price"); if ($currency_id != null) { $prod_prices = getPricesForProducts($currency_id, array($entity_id), 'Services'); $unit_price = $prod_prices[$entity_id]; } $listprice = $adb->query_result($list_result, $i, "listprice"); $field_name = $entity_id . "_listprice"; $entries = array(); $entries[] = textlength_check($adb->query_result($list_result, $i, "servicename")); if (getFieldVisibilityPermission('Services', $current_user->id, 'unit_price') == '0') { $entries[] = CurrencyField::convertToUserFormat($unit_price, null, true); } $entries[] = CurrencyField::convertToUserFormat($listprice, null, true); $action = ""; if (isPermitted("PriceBooks", "EditView", "") == 'yes' && isPermitted('Services', 'EditView', $entity_id) == 'yes') { $action .= '<img style="cursor:pointer;" src="themes/images/editfield.gif" border="0" onClick="fnvshobj(this,\'editlistprice\'),editProductListPrice(\'' . $entity_id . '\',\'' . $pricebook_id . '\',\'' . $listprice . '\')" alt="' . $app_strings["LBL_EDIT_BUTTON"] . '" title="' . $app_strings["LBL_EDIT_BUTTON"] . '"/>'; } else { $action .= '<img src="' . vtiger_imageurl('blank.gif', $theme) . '" border="0" />'; } if (isPermitted("PriceBooks", "Delete", "") == 'yes' && isPermitted('Services', 'Delete', $entity_id) == 'yes') { if ($action != "") { $action .= ' | '; } $action .= '<img src="themes/images/delete.gif" onclick="if(confirm(\'' . $app_strings['ARE_YOU_SURE'] . '\')) deletePriceBookProductRel(' . $entity_id . ',' . $pricebook_id . ');" alt="' . $app_strings["LBL_DELETE"] . '" title="' . $app_strings["LBL_DELETE"] . '" style="cursor:pointer;" border="0">'; } if ($action != "") { $entries[] = $action; } $entries_list[] = $entries; } $navigationOutput[] = getRecordRangeMessage($list_result, $limit_start_rec, $noofrows); $navigationOutput[] = getRelatedTableHeaderNavigation($navigation_array, '', $module, $relatedmodule, $focus->id); $return_data = array('header' => $header, 'entries' => $entries_list, 'navigation' => $navigationOutput); $log->debug("Exiting getPriceBookRelatedServices method ..."); return $return_data; }
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 = $controller->getListViewEntries($focus, $currentModule, $list_result, $navigation_array); $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, $num_records); 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; } } else { $smarty->assign("NO_FOLDERS", "yes"); }
} elseif ($start < 0) { $start = 1; } $start = ceil($start); } else { $start = 1; } $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 {
$mail_arr = getMailFields($tabid); if (!empty($mail_arr)) { $tablename = str_replace("vtiger_", "", $mail_arr['tablename']); $fieldname = $mail_arr['fieldname']; $fieldlabel = $mail_arr['fieldlabel']; $focus->search_fields[$fieldlabel] = array($tablename => $fieldname); $focus->search_fields_name[$fieldlabel] = $fieldname; } } $listview_header = getSearchListViewHeader($focus, "{$currentModule}", $url_string, $sorder, $order_by); $smarty->assign("LISTHEADER", $listview_header); $smarty->assign("HEADERCOUNT", count($listview_header) + 1); $listview_entries = getSearchListViewEntries($focus, "{$currentModule}", $list_result, $navigation_array, $form); $smarty->assign("LISTENTITY", $listview_entries); if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true) { $record_string = getRecordRangeMessage($list_result, $start_rec, $noofrows); } else { $record_string = ''; } $navigationOutput = getTableHeaderSimpleNavigation($navigation_array, $url_string, $currentModule, "Popup"); $smarty->assign("NAVIGATION", $navigationOutput); $smarty->assign("RECORD_STRING", $record_string); $smarty->assign("RECORD_COUNTS", $noofrows); $smarty->assign("POPUPTYPE", $popuptype); $smarty->assign("PARENT_MODULE", isset($_REQUEST['parent_module']) ? vtlib_purify($_REQUEST['parent_module']) : ''); // Field Validation Information $tabid = getTabid($currentModule); $validationData = getDBValidationData($focus->tab_name, $tabid); $validationArray = split_validationdataArray($validationData); $smarty->assign("VALIDATION_DATA_FIELDNAME", $validationArray['fieldname']); $smarty->assign("VALIDATION_DATA_FIELDDATATYPE", $validationArray['datatype']);