本文整理汇总了PHP中Vtiger_RelationListView_Model类的典型用法代码示例。如果您正苦于以下问题:PHP Vtiger_RelationListView_Model类的具体用法?PHP Vtiger_RelationListView_Model怎么用?PHP Vtiger_RelationListView_Model使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Vtiger_RelationListView_Model类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRelatedModuleRecordIds
public function getRelatedModuleRecordIds(Vtiger_Request $request, $recordIds = [])
{
$db = PearDatabase::getInstance();
$basicModule = $request->getModule();
$relatedModules = $request->get('related_modules');
$parentModuleModel = Vtiger_Module_Model::getInstance($basicModule);
$relatedIds = [];
if (!empty($relatedModules)) {
foreach ($relatedModules as $relModData) {
$relModData = explode('::', $relModData);
$relatedModule = $relModData[0];
$type = $relModData[1];
switch ($type) {
case 0:
$field = $relModData[2];
foreach ($recordIds as $recordId) {
$recordModel = Vtiger_Record_Model::getInstanceById($recordId, $basicModule);
if ($recordModel->get($field) != 0 && Vtiger_Functions::getCRMRecordType($recordModel->get($field)) == $relatedModule) {
$relatedIds[] = $recordModel->get($field);
}
}
break;
case 1:
$relatedModuleModel = Vtiger_Module_Model::getInstance($relatedModule);
$instance = CRMEntity::getInstance($relatedModule);
$relationModel = Vtiger_Relation_Model::getInstance($parentModuleModel, $relatedModuleModel);
$fieldModel = $relationModel->getRelationField();
$tablename = $fieldModel->get('table');
$tabIndex = $instance->table_index;
$relIndex = $this->getRelatedFieldName($relatedModule, $basicModule);
if (!$relIndex) {
break;
}
$sql = "SELECT vtiger_crmentity.crmid FROM vtiger_crmentity INNER JOIN {$tablename} ON {$tablename}.{$tabIndex} = vtiger_crmentity.crmid\n\t\t\t\t\t\tWHERE {$tablename}.{$relIndex} IN (" . $db->generateQuestionMarks($recordIds) . ")";
$result = $db->pquery($sql, $recordIds);
while ($crmid = $db->getSingleValue($result)) {
$relatedIds[] = $crmid;
}
break;
case 2:
foreach ($recordIds as $recordId) {
$recordModel = Vtiger_Record_Model::getInstanceById($recordId, $basicModule);
$relationListView = Vtiger_RelationListView_Model::getInstance($recordModel, $relatedModule);
$query = $relationListView->getRelationQuery();
$queryEx = explode('FROM', $query, 2);
$query = 'SELECT DISTINCT vtiger_crmentity.crmid FROM' . $queryEx[1];
$result = $db->query($query);
while ($crmid = $db->getSingleValue($result)) {
$relatedIds[] = $crmid;
}
}
break;
}
$relatedIds = array_unique($relatedIds);
}
}
return $relatedIds;
}
示例2: getSelectedRecords
private function getSelectedRecords()
{
$parentRecordModel = Vtiger_Record_Model::getInstanceById($this->src_record, $this->src_module);
$relationListView = Vtiger_RelationListView_Model::getInstance($parentRecordModel, $this->moduleName);
$pagingModel = new Vtiger_Paging_Model();
$pagingModel->set('limit', 'no_limit');
$entries = $relationListView->getEntries($pagingModel);
return array_keys($entries);
}
示例3: getInstance
public static function getInstance($record, $moduleName, $relatedRecord, $relatedModuleName)
{
$modelClassName = Vtiger_Loader::getComponentClassName('Model', 'RelatedCommentModal', $moduleName);
$instance = new $modelClassName();
$recordModel = Vtiger_Record_Model::getInstanceById($record, $moduleName);
$relationListView = Vtiger_RelationListView_Model::getInstance($recordModel, $relatedModuleName);
$instance->set('relationListView', $relationListView)->set('record', $record)->set('moduleName', $moduleName)->set('relatedRecord', $relatedRecord)->set('relatedModuleName', $relatedModuleName);
return $instance;
}
示例4: showRelatedRecords
/**
* Function returns related records based on related moduleName
* @param Vtiger_Request $request
* @return <type>
*/
function showRelatedRecords(Vtiger_Request $request)
{
$parentId = $request->get('record');
$pageNumber = $request->get('page');
$limit = $request->get('limit');
$relatedModuleName = $request->get('relatedModule');
$orderBy = $request->get('orderby');
$sortOrder = $request->get('sortorder');
$whereCondition = $request->get('whereCondition');
$moduleName = $request->getModule();
if ($sortOrder == "ASC") {
$nextSortOrder = "DESC";
$sortImage = "icon-chevron-down";
} else {
$nextSortOrder = "ASC";
$sortImage = "icon-chevron-up";
}
$parentRecordModel = Vtiger_Record_Model::getInstanceById($parentId, $moduleName);
$relationListView = Vtiger_RelationListView_Model::getInstance($parentRecordModel, $relatedModuleName);
if (!empty($orderBy)) {
$relationListView->set('orderby', $orderBy);
$relationListView->set('sortorder', $sortOrder);
}
if (empty($pageNumber)) {
$pageNumber = 1;
}
$pagingModel = new Vtiger_Paging_Model();
$pagingModel->set('page', $pageNumber);
if (!empty($limit)) {
$pagingModel->set('limit', $limit);
}
if ($whereCondition) {
$relationListView->set('whereCondition', $whereCondition);
}
$models = $relationListView->getEntries($pagingModel);
$header = $relationListView->getHeaders();
$viewer = $this->getViewer($request);
$viewer->assign('MODULE', $moduleName);
$viewer->assign('RELATED_RECORDS', $models);
$viewer->assign('RELATED_HEADERS', $header);
$viewer->assign('RELATED_MODULE', $relatedModuleName);
$viewer->assign('RELATED_MODULE_MODEL', Vtiger_Module_Model::getInstance($relatedModuleName));
$viewer->assign('PAGING_MODEL', $pagingModel);
return $viewer->view('SummaryWidgets.tpl', $moduleName, 'true');
}
示例5: process
function process(Vtiger_Request $request)
{
$moduleName = $request->getModule();
$relatedModuleName = $request->get('relatedModule');
$parentId = $request->get('record');
$label = $request->get('tab_label');
$parentRecordModel = Vtiger_Record_Model::getInstanceById($parentId, $moduleName);
$relationListView = Vtiger_RelationListView_Model::getInstance($parentRecordModel, $relatedModuleName, $label);
$relationModel = $relationListView->getRelationModel();
$viewer = $this->getViewer($request);
if (array_key_exists($relatedModuleName, $relationModel->getEmailEnabledModulesInfoForDetailView())) {
$viewer->assign('CUSTOM_VIEWS', CustomView_Record_Model::getAllByGroup($relatedModuleName));
$viewer->assign('STATUS_VALUES', $relationModel->getCampaignRelationStatusValues());
$viewer->assign('SELECTED_IDS', $request->get('selectedIds'));
$viewer->assign('EXCLUDED_IDS', $request->get('excludedIds'));
}
return parent::process($request);
}
示例6: getRecordsCount
/**
* Function to get related Records count from this relation
* @param <Vtiger_Request> $request
* @return <Number> Number of record from this relation
*/
public function getRecordsCount(Vtiger_Request $request)
{
$moduleName = $request->getModule();
$relatedModuleName = $request->get('relatedModule');
$parentId = $request->get('record');
$label = $request->get('tab_label');
$parentRecordModel = Vtiger_Record_Model::getInstanceById($parentId, $moduleName);
$relationListView = Vtiger_RelationListView_Model::getInstance($parentRecordModel, $relatedModuleName, $label);
$count = $relationListView->getRelatedEntriesCount();
$result = array();
$result['module'] = $moduleName;
$result['viewname'] = $cvId;
$result['count'] = $count;
$response = new Vtiger_Response();
$response->setEmitType(Vtiger_Response::$EMIT_JSON);
$response->setResult($result);
$response->emit();
}
示例7: handleTask
/**
* @param $context \Workflow\VTEntity
* @return string
*/
public function handleTask(&$context)
{
global $list_max_entries_per_page, $adb, $currentModule;
$old_list_max_entries_per_page = $list_max_entries_per_page;
if ($this->get("related_module") == -1) {
return "no";
}
$currentModule = $this->getModuleName();
$found_rows = $this->get("found_rows");
if (empty($found_rows) || $found_rows == -1) {
$found_rows = 1;
}
$parts = explode("#~#", $this->get("related_module"));
$functionName = $parts[0];
$relatedModuleName = \Workflow\VtUtils::getModuleName($parts[1]);
//$relationListView = Vtiger_RelationListView_Model::getInstance($parentRecordModel, $relatedModuleName, $label);
$parentRecordModel = Vtiger_Record_Model::getInstanceById($context->getId(), $context->getModuleName());
/**
* @var Vtiger_RelationListView_Model $relatedListView
*/
$relationListView = Vtiger_RelationListView_Model::getInstance($parentRecordModel, $relatedModuleName);
$query = $relationListView->getRelationQuery();
$query = preg_replace('/SELECT(.+)FROM/imU', 'SELECT vtiger_crmentity.crmid FROM', $query);
$logger = new \Workflow\ConditionLogger();
$relModule = \Workflow\VtUtils::getModuleName($parts[1]);
$objMySQL = new \Workflow\ConditionMysql($relModule, $context);
$objMySQL->setLogger($logger);
$main_module = \CRMEntity::getInstance($relModule);
$sqlCondition = $objMySQL->parse($this->get("condition"));
$sqlTables = $objMySQL->generateTables();
$logs = $logger->getLogs();
$this->setStat($logs);
$idColumn = $main_module->table_name . "." . $main_module->table_index;
$sqlQuery = "SELECT {$idColumn} " . $sqlTables . " WHERE {$idColumn} IN (" . $query . ")" . (strlen($sqlCondition) > 3 ? " AND " . $sqlCondition : "");
$this->addStat("MySQL Query: " . $sqlQuery);
$result = $adb->query($sqlQuery, true);
$this->addStat("num Rows: " . $adb->num_rows($result));
$this->addStat("have to at least x rows: " . $found_rows);
if ($adb->num_rows($result) >= $found_rows) {
return 'yes';
}
return "no";
}
示例8: relatedIds
public function relatedIds($id, $relatedModule, $relatedLabel, $relatedHandler = null)
{
$ids = vtws_getIdComponents($id);
$sourceModule = $this->webserviceObject->getEntityName();
global $currentModule;
$currentModule = $sourceModule;
$sourceRecordModel = Vtiger_Record_Model::getInstanceById($ids[1], $sourceModule);
$targetModel = Vtiger_RelationListView_Model::getInstance($sourceRecordModel, $relatedModule, $relatedLabel);
$sql = $targetModel->getRelationQuery();
$relatedWebserviceObject = VtigerWebserviceObject::fromName($adb, $relatedModule);
$relatedModuleWSId = $relatedWebserviceObject->getEntityId();
// Rewrite query to pull only crmid transformed as webservice id.
$sqlFromPart = substr($sql, stripos($sql, ' FROM ') + 6);
$sql = sprintf("SELECT DISTINCT concat('%sx',vtiger_crmentity.crmid) as wsid FROM %s", $relatedModuleWSId, $sqlFromPart);
$rs = $this->pearDB->pquery($sql, array());
$relatedIds = array();
while ($row = $this->pearDB->fetch_array($rs)) {
$relatedIds[] = $row['wsid'];
}
return $relatedIds;
}
示例9: getListViewCount
/**
* Function to get listView count
* @param Vtiger_Request $request
*/
function getListViewCount(Vtiger_Request $request)
{
$moduleName = $this->getModule($request);
$sourceModule = $request->get('src_module');
$sourceField = $request->get('src_field');
$sourceRecord = $request->get('src_record');
$orderBy = $request->get('orderby');
$sortOrder = $request->get('sortorder');
$currencyId = $request->get('currency_id');
$searchKey = $request->get('search_key');
$searchValue = $request->get('search_value');
$relatedParentModule = $request->get('related_parent_module');
$relatedParentId = $request->get('related_parent_id');
if (!empty($relatedParentModule) && !empty($relatedParentId)) {
$parentRecordModel = Vtiger_Record_Model::getInstanceById($relatedParentId, $relatedParentModule);
$listViewModel = Vtiger_RelationListView_Model::getInstance($parentRecordModel, $moduleName, $label);
} else {
$listViewModel = Vtiger_ListView_Model::getInstanceForPopup($moduleName, $sourceModule);
}
if (!empty($sourceModule)) {
$listViewModel->set('src_module', $sourceModule);
$listViewModel->set('src_field', $sourceField);
$listViewModel->set('src_record', $sourceRecord);
$listViewModel->set('currency_id', $currencyId);
}
if (!empty($orderBy)) {
$listViewModel->set('orderby', $orderBy);
$listViewModel->set('sortorder', $sortOrder);
}
if (!empty($searchKey) && !empty($searchValue)) {
$listViewModel->set('search_key', $searchKey);
$listViewModel->set('search_value', $searchValue);
}
if (!empty($relatedParentModule) && !empty($relatedParentId)) {
$count = $listViewModel->getRelatedEntriesCount();
} else {
$count = $listViewModel->getListViewCount();
}
return $count;
}
示例10: showRelatedList
/**
* Function returns related records
* @param Vtiger_Request $request
* @return <type>
*/
function showRelatedList(Vtiger_Request $request)
{
$moduleName = $request->getModule();
$relatedModuleName = $request->get('relatedModule');
$parentId = $request->get('record');
$label = $request->get('tab_label');
$requestedPage = $request->get('page');
if (empty($requestedPage)) {
$requestedPage = 1;
}
$pagingModel = new Vtiger_Paging_Model();
$pagingModel->set('page', $requestedPage);
$parentRecordModel = Vtiger_Record_Model::getInstanceById($parentId, $moduleName);
$relationListView = Vtiger_RelationListView_Model::getInstance($parentRecordModel, $relatedModuleName, $label);
$orderBy = $request->get('orderby');
$sortOrder = $request->get('sortorder');
if (empty($orderBy) && empty($sortOrder)) {
$moduleInstance = CRMEntity::getInstance($relatedModuleName);
$orderBy = $moduleInstance->default_order_by;
$sortOrder = $moduleInstance->default_sort_order;
}
if ($sortOrder == "ASC") {
$nextSortOrder = "DESC";
$sortImage = "glyphicon glyphicon-chevron-down";
} else {
$nextSortOrder = "ASC";
$sortImage = "glyphicon glyphicon-chevron-up";
}
if (!empty($orderBy)) {
$relationListView->set('orderby', $orderBy);
$relationListView->set('sortorder', $sortOrder);
}
$models = $relationListView->getEntries($pagingModel);
$links = $relationListView->getLinks();
$header = $relationListView->getHeaders();
$noOfEntries = count($models);
$parentRecordCurrencyId = $parentRecordModel->get('currency_id');
if ($parentRecordCurrencyId) {
$relatedModuleModel = Vtiger_Module_Model::getInstance($relatedModuleName);
foreach ($models as $recordId => $recorModel) {
$productIdsList[$recordId] = $recordId;
}
$unitPricesList = $relatedModuleModel->getPricesForProducts($parentRecordCurrencyId, $productIdsList);
foreach ($models as $recordId => $recorModel) {
$recorModel->set('unit_price', $unitPricesList[$recordId]);
}
}
$relationModel = $relationListView->getRelationModel();
$relationField = $relationModel->getRelationField();
$viewer = $this->getViewer($request);
$viewer->assign('RELATED_RECORDS', $models);
$viewer->assign('PARENT_RECORD', $parentRecordModel);
$viewer->assign('RELATED_LIST_LINKS', $links);
$viewer->assign('RELATED_HEADERS', $header);
$viewer->assign('RELATED_MODULE', $relationModel->getRelationModuleModel());
$viewer->assign('RELATED_ENTIRES_COUNT', $noOfEntries);
$viewer->assign('RELATION_FIELD', $relationField);
if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false)) {
$totalCount = $relationListView->getRelatedEntriesCount();
$pageLimit = $pagingModel->getPageLimit();
$pageCount = ceil((int) $totalCount / (int) $pageLimit);
if ($pageCount == 0) {
$pageCount = 1;
}
$viewer->assign('PAGE_COUNT', $pageCount);
$viewer->assign('TOTAL_ENTRIES', $totalCount);
$viewer->assign('PERFORMANCE', true);
}
$viewer->assign('MODULE', $moduleName);
$viewer->assign('PAGING', $pagingModel);
$viewer->assign('ORDER_BY', $orderBy);
$viewer->assign('SORT_ORDER', $sortOrder);
$viewer->assign('NEXT_SORT_ORDER', $nextSortOrder);
$viewer->assign('SORT_IMAGE', $sortImage);
$viewer->assign('COLUMN_NAME', $orderBy);
$viewer->assign('USER_MODEL', Users_Record_Model::getCurrentUserModel());
return $viewer->view('RelatedList.tpl', $moduleName, 'true');
}
示例11: getNoOfEntries
function getNoOfEntries($request, $relatedModuleName)
{
$pagingModel = new Vtiger_Paging_Model();
$pagingModel->set('page', 1);
$recordId = $request->get('relatedRecord');
$moduleName = $request->get('relatedModule');
$allowCountModules = array('Contacts', 'Accounts', 'Quotes', 'SalesOrder', 'Invoice', 'HelpDesk', 'Coupons', 'Calendar');
if (in_array($relatedModuleName, $allowCountModules)) {
$parentRecordModel = Vtiger_Record_Model::getInstanceById($recordId, $moduleName);
$relationListView = Vtiger_RelationListView_Model::getInstance($parentRecordModel, $relatedModuleName);
$models = $relationListView->getEntries($pagingModel);
$noOfEntries = count($models);
return $noOfEntries;
}
return -1;
}
示例12: showRelatedTree
function showRelatedTree(Vtiger_Request $request)
{
$moduleName = $request->getModule();
$parentId = $request->get('record');
$relatedModuleName = $request->get('relatedModule');
$parentRecordModel = Vtiger_Record_Model::getInstanceById($parentId, $moduleName);
$relationListView = Vtiger_RelationListView_Model::getInstance($parentRecordModel, $relatedModuleName);
$relationModel = $relationListView->getRelationModel();
$header = $relationListView->getTreeHeaders();
$entries = $relationListView->getTreeEntries();
$viewer = $this->getViewer($request);
$viewer->assign('MODULE', $moduleName);
$viewer->assign('RECORDID', $parentId);
$viewer->assign('RELATED_MODULE_NAME', $relatedModuleName);
$viewer->assign('RELATED_RECORDS', $entries);
$viewer->assign('RELATED_HEADERS', $header);
$viewer->assign('SHOW_CREATOR_DETAIL', $relationModel->showCreatorDetail());
$viewer->assign('SHOW_COMMENT', $relationModel->showComment());
$viewer->assign('USER_MODEL', Users_Record_Model::getCurrentUserModel());
return $viewer->view('RelatedTreeContent.tpl', $moduleName, 'true');
}
示例13: getRelatedListPageCount
/**
* Function to get the page count for reltedlist
* @return total number of pages
*/
function getRelatedListPageCount(Vtiger_Request $request)
{
$moduleName = $request->getModule();
$relatedModuleName = $request->get('relatedModule');
$parentId = $request->get('record');
$label = $request->get('tab_label');
$totalCount = 0;
$relModules = [$relatedModuleName];
if (in_array('ProductsAndServices', $relModules)) {
$label = '';
$relModules = ['Products', 'OutsourcedProducts', 'Assets', 'Services', 'OSSOutsourcedServices', 'OSSSoldServices'];
}
if (in_array('Comments', $relModules)) {
$totalCount = ModComments_Record_Model::getCommentsCount($parentId);
} else {
$pagingModel = new Vtiger_Paging_Model();
$parentRecordModel = Vtiger_Record_Model::getInstanceById($parentId, $moduleName);
foreach ($relModules as $relatedModuleName) {
$relationListView = Vtiger_RelationListView_Model::getInstance($parentRecordModel, $relatedModuleName, $label);
if (!vtlib_isModuleActive($relatedModuleName) || !$relationListView->getRelationModel()) {
continue;
}
$totalCount += (int) $relationListView->getRelatedEntriesCount();
$pageLimit = $pagingModel->getPageLimit();
$pageCount = ceil((int) $totalCount / (int) $pageLimit);
}
}
if ($pageCount == 0) {
$pageCount = 1;
}
$result = array();
$result['numberOfRecords'] = $totalCount;
$result['page'] = $pageCount;
$response = new Vtiger_Response();
$response->setResult($result);
$response->emit();
}
示例14: getCreateViewUrl
public function getCreateViewUrl()
{
$createViewUrl = parent::getCreateViewUrl();
$currentUserModel = Users_Record_Model::getCurrentUserModel();
$parentRecordModel = $this->getParentRecordModel();
$currencyValue = $parentRecordModel->get('hdnGrandTotal');
$parentRecordModelCurrencyId = $parentRecordModel->get('currency_id');
if ($parentRecordModelCurrencyId == $currentUserModel->get('currency_id')) {
$amount = CurrencyField::convertToUserFormat($currencyValue, null, true);
} else {
$baseCurrencyId = CurrencyField::getDBCurrencyId();
$allCurrencies = getAllCurrencies();
foreach ($allCurrencies as $currencyInfo) {
if ($parentRecordModelCurrencyId == $currencyInfo['currency_id']) {
$currencyValue = CurrencyField::convertToDollar($currencyValue, $currencyInfo['conversionrate']);
}
}
foreach ($allCurrencies as $currencyInfo) {
if ($baseCurrencyId == $currencyInfo['currency_id']) {
$currencyValue = CurrencyField::convertFromMasterCurrency($currencyValue, $currencyInfo['conversionrate']);
}
}
$amount = CurrencyField::convertToUserFormat($currencyValue);
}
return $createViewUrl . '&relatedcontact=' . $parentRecordModel->get('contact_id') . '&relatedorganization=' . $parentRecordModel->get('account_id') . '&amount=' . $amount;
}
示例15: getEntries
/**
* Function to get list of record models in this relation
* @param <Vtiger_Paging_Model> $pagingModel
* @return <array> List of record models <Vtiger_Record_Model>
*/
public function getEntries($pagingModel)
{
$relationModel = $this->getRelationModel();
$parentRecordModel = $this->getParentRecordModel();
$relatedModuleName = $relationModel->getRelationModuleModel()->getName();
$relatedRecordModelsList = parent::getEntries($pagingModel);
$emailEnabledModulesInfo = $relationModel->getEmailEnabledModulesInfoForDetailView();
if (array_key_exists($relatedModuleName, $emailEnabledModulesInfo) && $relatedRecordModelsList) {
$fieldName = $emailEnabledModulesInfo[$relatedModuleName]['fieldName'];
$tableName = $emailEnabledModulesInfo[$relatedModuleName]['tableName'];
$db = PearDatabase::getInstance();
$relatedRecordIdsList = array_keys($relatedRecordModelsList);
$query = "SELECT campaignrelstatus, {$fieldName} FROM {$tableName}\n\t\t\t\t\t\tINNER JOIN vtiger_campaignrelstatus ON vtiger_campaignrelstatus.campaignrelstatusid = {$tableName}.campaignrelstatusid\n\t\t\t\t\t\tWHERE {$fieldName} IN (" . generateQuestionMarks($relatedRecordIdsList) . ") AND campaignid = ?";
array_push($relatedRecordIdsList, $parentRecordModel->getId());
$result = $db->pquery($query, $relatedRecordIdsList);
$numOfrows = $db->num_rows($result);
for ($i = 0; $i < $numOfrows; $i++) {
$recordId = $db->query_result($result, $i, $fieldName);
$relatedRecordModel = $relatedRecordModelsList[$recordId];
$relatedRecordModel->set('status', $db->query_result($result, $i, 'campaignrelstatus'));
$relatedRecordModelsList[$recordId] = $relatedRecordModel;
}
}
return $relatedRecordModelsList;
}