当前位置: 首页>>代码示例>>PHP>>正文


PHP Vtiger_Paging_Model::getPageLimit方法代码示例

本文整理汇总了PHP中Vtiger_Paging_Model::getPageLimit方法的典型用法代码示例。如果您正苦于以下问题:PHP Vtiger_Paging_Model::getPageLimit方法的具体用法?PHP Vtiger_Paging_Model::getPageLimit怎么用?PHP Vtiger_Paging_Model::getPageLimit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Vtiger_Paging_Model的用法示例。


在下文中一共展示了Vtiger_Paging_Model::getPageLimit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getListViewEntries

	/**
	 * Function to get the list view entries
	 * @param Vtiger_Paging_Model $pagingModel
	 * @return <Array> - Associative array of record id mapped to Vtiger_Record_Model instance.
	 */
	public function getListViewEntries($pagingModel)
	{
		$db = PearDatabase::getInstance();

		$module = $this->getModule();
		$moduleName = $module->getName();
		$parentModuleName = $module->getParentName();
		$qualifiedModuleName = $moduleName;
		if (!empty($parentModuleName)) {
			$qualifiedModuleName = $parentModuleName . ':' . $qualifiedModuleName;
		}
		$recordModelClass = Vtiger_Loader::getComponentClassName('Model', 'Record', $qualifiedModuleName);
		$listQuery = $this->getBasicListQuery();

		$startIndex = $pagingModel->getStartIndex();
		$pageLimit = $pagingModel->getPageLimit();

		$orderBy = $this->getForSql('orderby');
		if (!empty($orderBy) && $orderBy === 'smownerid') {
			$fieldModel = Vtiger_Field_Model::getInstance('assigned_user_id', $moduleModel);
			if ($fieldModel->getFieldDataType() == 'owner') {
				$orderBy = 'COALESCE(' . getSqlForNameInDisplayFormat(['first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'], 'Users') . ',vtiger_groups.groupname)';
			}
		}
		if (!empty($orderBy)) {
			$listQuery .= ' ORDER BY ' . $orderBy . ' ' . $this->getForSql('sortorder');
		}
		if ($module->isPagingSupported()) {
			$nextListQuery = $listQuery . ' LIMIT ' . ($startIndex + $pageLimit) . ',1';
			$listQuery .= " LIMIT $startIndex, $pageLimit";
		}

		$listResult = $db->pquery($listQuery, array());
		$noOfRecords = $db->num_rows($listResult);

		$listViewRecordModels = array();
		for ($i = 0; $i < $noOfRecords; ++$i) {
			$row = $db->query_result_rowdata($listResult, $i);
			$record = new $recordModelClass();
			$record->setData($row);

			if (method_exists($record, 'getModule') && method_exists($record, 'setModule')) {
				$moduleModel = Settings_Vtiger_Module_Model::getInstance($qualifiedModuleName);
				$record->setModule($moduleModel);
			}

			$listViewRecordModels[$record->getId()] = $record;
		}
		if ($module->isPagingSupported()) {
			$pagingModel->calculatePageRange($listViewRecordModels);

			$nextPageResult = $db->pquery($nextListQuery, array());
			$nextPageNumRows = $db->num_rows($nextPageResult);

			if ($nextPageNumRows <= 0) {
				$pagingModel->set('nextPageExists', false);
			}
		}
		return $listViewRecordModels;
	}
开发者ID:rubichcube,项目名称:YetiForceCRM,代码行数:65,代码来源:ListView.php

示例2: getListViewEntries

 /**
  * Function to get the list view entries
  * @param Vtiger_Paging_Model $pagingModel
  * @return <Array> - Associative array of record id mapped to Vtiger_Record_Model instance.
  */
 public function getListViewEntries($pagingModel)
 {
     $db = PearDatabase::getInstance();
     $moduleName = $this->getModule()->get('name');
     $moduleFocus = CRMEntity::getInstance($moduleName);
     $moduleModel = Vtiger_Module_Model::getInstance($moduleName);
     $queryGenerator = $this->get('query_generator');
     $listViewContoller = $this->get('listview_controller');
     $listQuery = $queryGenerator->getQuery();
     $startIndex = $pagingModel->getStartIndex();
     $pageLimit = $pagingModel->getPageLimit();
     $importedRecordIds = $this->getLastImportedRecord();
     $listViewRecordModels = array();
     if (count($importedRecordIds) != 0) {
         $moduleModel = $this->get('module');
         $listQuery .= ' AND ' . $moduleModel->basetable . '.' . $moduleModel->basetableid . ' IN (' . implode(',', $importedRecordIds) . ')';
         $listQuery .= " LIMIT {$startIndex}, {$pageLimit}";
         $listResult = $db->pquery($listQuery, array());
         $listViewEntries = $listViewContoller->getListViewRecords($moduleFocus, $moduleName, $listResult);
         $pagingModel->calculatePageRange($listViewEntries);
         foreach ($listViewEntries as $recordId => $record) {
             $record['id'] = $recordId;
             $listViewRecordModels[$recordId] = $moduleModel->getRecordFromArray($record);
         }
     }
     return $listViewRecordModels;
 }
开发者ID:cannking,项目名称:vtigercrm-debug,代码行数:32,代码来源:ListView.php

示例3: getListViewEntries

 /**
  * Function to get the list view entries
  * @param Vtiger_Paging_Model $pagingModel
  * @return <Array> - Associative array of record id mapped to Vtiger_Record_Model instance.
  */
 public function getListViewEntries($pagingModel)
 {
     $db = PearDatabase::getInstance();
     $startIndex = $pagingModel->getStartIndex();
     $pageLimit = $pagingModel->getPageLimit();
     $orderBy = $this->getForSql('orderby');
     $sortOrder = $this->getForSql('sortorder');
     $listQuery = $this->getQuery();
     $searchKey = $this->get('search_key');
     $searchValue = $this->get('search_value');
     if (!empty($searchKey) && !empty($searchValue)) {
         $listQuery .= " WHERE {$searchKey} LIKE '{$searchValue}%'";
     }
     if ($orderBy) {
         $listQuery .= " ORDER BY {$orderBy} {$sortOrder}";
     }
     $listQuery .= " LIMIT {$startIndex}," . ($pageLimit + 1);
     $result = $db->pquery($listQuery, array());
     $num_rows = $db->num_rows($result);
     $listViewRecordModels = array();
     for ($i = 0; $i < $num_rows; $i++) {
         $recordModel = new EmailTemplates_Record_Model();
         $recordModel->setModule('EmailTemplates');
         $row = $db->query_result_rowdata($result, $i);
         $listViewRecordModels[$row['templateid']] = $recordModel->setData($row);
     }
     $pagingModel->calculatePageRange($listViewRecordModels);
     if ($num_rows > $pageLimit) {
         array_pop($listViewRecordModels);
         $pagingModel->set('nextPageExists', true);
     } else {
         $pagingModel->set('nextPageExists', false);
     }
     return $listViewRecordModels;
 }
开发者ID:nouphet,项目名称:vtigercrm-6.0.0-ja,代码行数:40,代码来源:ListView.php

示例4: initializeListViewContents

 public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer)
 {
     global $log;
     $log->debug("Entering ./views/FindDuplicates.php::initializeListViewContents");
     $currentUser = vglobal('current_user');
     $viewer = $this->getViewer($request);
     $module = $request->getModule();
     $moduleModel = Vtiger_Module_Model::getInstance($module);
     $massActionLink = array('linktype' => 'LISTVIEWBASIC', 'linklabel' => 'LBL_DELETE', 'linkurl' => 'Javascript:Vtiger_FindDuplicates_Js.massDeleteRecords("index.php?module=' . $module . '&action=MassDelete");', 'linkicon' => '');
     $massActionLinks[] = Vtiger_Link_Model::getInstanceFromValues($massActionLink);
     $viewer->assign('LISTVIEW_LINKS', $massActionLinks);
     $viewer->assign('MODULE_MODEL', $moduleModel);
     $pageNumber = $request->get('page');
     if (empty($pageNumber)) {
         $pageNumber = '1';
     }
     $pagingModel = new Vtiger_Paging_Model();
     $pagingModel->set('page', $pageNumber);
     $pageLimit = $pagingModel->getPageLimit();
     $duplicateSearchFields = $request->get('fields');
     $dataModelInstance = Vtiger_FindDuplicate_Model::getInstance($module);
     $dataModelInstance->set('fields', $duplicateSearchFields);
     $ignoreEmpty = $request->get('ignoreEmpty');
     $ignoreEmptyValue = false;
     if ($ignoreEmpty == 'on' || $ignoreEmpty == 'true' || $ignoreEmpty == '1') {
         $ignoreEmptyValue = true;
     }
     $dataModelInstance->set('ignoreEmpty', $ignoreEmptyValue);
     if (!$this->listViewEntries) {
         $this->listViewEntries = $dataModelInstance->getListViewEntries($pagingModel);
     }
     if (!$this->listViewHeaders) {
         $this->listViewHeaders = $dataModelInstance->getListViewHeaders();
     }
     if (!$this->rows) {
         $this->rows = $dataModelInstance->getRecordCount();
         $viewer->assign('TOTAL_COUNT', $this->rows);
     }
     $rowCount = 0;
     foreach ($this->listViewEntries as $group) {
         foreach ($group as $row) {
             $rowCount++;
         }
     }
     //for calculating the page range
     for ($i = 0; $i < $rowCount; $i++) {
         $dummyListEntries[] = $i;
     }
     $pagingModel->calculatePageRange($dummyListEntries);
     $viewer->assign('IGNORE_EMPTY', $ignoreEmpty);
     $viewer->assign('LISTVIEW_ENTRIES_COUNT', $rowCount);
     $viewer->assign('LISTVIEW_HEADERS', $this->listViewHeaders);
     $viewer->assign('LISTVIEW_ENTRIES', $this->listViewEntries);
     $viewer->assign('PAGING_MODEL', $pagingModel);
     $viewer->assign('PAGE_NUMBER', $pageNumber);
     $viewer->assign('MODULE', $module);
     $viewer->assign('DUPLICATE_SEARCH_FIELDS', $duplicateSearchFields);
     $customViewModel = CustomView_Record_Model::getAllFilterByModule($module);
     $viewer->assign('VIEW_NAME', $customViewModel->getId());
 }
开发者ID:cin-system,项目名称:cinrepo,代码行数:60,代码来源:FindDuplicates.php

示例5: getListViewEntries

 /**
  * Function to get the list view entries
  * @param Vtiger_Paging_Model $pagingModel
  * @return <Array> - Associative array of record id mapped to Vtiger_Record_Model instance.
  */
 public function getListViewEntries($pagingModel)
 {
     $db = PearDatabase::getInstance();
     $module = $this->getModule();
     $moduleName = $module->getName();
     $parentModuleName = $module->getParentName();
     $qualifiedModuleName = $moduleName;
     if (!empty($parentModuleName)) {
         $qualifiedModuleName = $parentModuleName . ':' . $qualifiedModuleName;
     }
     $recordModelClass = Vtiger_Loader::getComponentClassName('Model', 'Record', $qualifiedModuleName);
     $listFields = $module->listFields;
     $listQuery = "SELECT ";
     foreach ($listFields as $fieldName => $fieldLabel) {
         $listQuery .= "{$fieldName}, ";
     }
     $listQuery .= $module->baseIndex . " FROM " . $module->baseTable;
     $params = array();
     $sourceModule = $this->get('sourceModule');
     if (!empty($sourceModule)) {
         $listQuery .= ' WHERE module_name = ?';
         $params[] = $sourceModule;
     }
     $startIndex = $pagingModel->getStartIndex();
     $pageLimit = $pagingModel->getPageLimit();
     $orderBy = $this->getForSql('orderby');
     if (!empty($orderBy)) {
         $listQuery .= ' ORDER BY ' . $orderBy . ' ' . $this->getForSql('sortorder');
     }
     $nextListQuery = $listQuery . ' LIMIT ' . ($startIndex + $pageLimit) . ',1';
     $listQuery .= " LIMIT {$startIndex}," . ($pageLimit + 1);
     $listResult = $db->pquery($listQuery, $params);
     $noOfRecords = $db->num_rows($listResult);
     $listViewRecordModels = array();
     for ($i = 0; $i < $noOfRecords; ++$i) {
         $row = $db->query_result_rowdata($listResult, $i);
         $record = new $recordModelClass();
         $row['module_name'] = vtranslate($row['module_name'], $row['module_name']);
         $row['execution_condition'] = vtranslate($record->executionConditionAsLabel($row['execution_condition']), 'Settings:Workflows');
         $record->setData($row);
         $listViewRecordModels[$record->getId()] = $record;
     }
     $pagingModel->calculatePageRange($listViewRecordModels);
     if ($db->num_rows($listResult) > $pageLimit) {
         array_pop($listViewRecordModels);
         $pagingModel->set('nextPageExists', true);
     } else {
         $pagingModel->set('nextPageExists', false);
     }
     $nextPageResult = $db->pquery($nextListQuery, $params);
     $nextPageNumRows = $db->num_rows($nextPageResult);
     if ($nextPageNumRows <= 0) {
         $pagingModel->set('nextPageExists', false);
     }
     return $listViewRecordModels;
 }
开发者ID:nouphet,项目名称:vtigercrm-6.0.0-ja,代码行数:61,代码来源:ListView.php

示例6: getListViewEntries

 /**
  * Function to get the list view entries
  * @param Vtiger_Paging_Model $pagingModel
  * @return <Array> - Associative array of record id mapped to Vtiger_Record_Model instance.
  */
 public function getListViewEntries($pagingModel)
 {
     $db = PearDatabase::getInstance();
     $module = $this->getModule();
     $parentModuleName = $module->getParentName();
     if (!empty($parentModuleName)) {
         $qualifiedModuleName = $parentModuleName . ':' . $module->getName();
     }
     $recordModelClass = Vtiger_Loader::getComponentClassName('Model', 'Record', $qualifiedModuleName);
     $listFields = $module->listFields;
     $listQuery = 'SELECT ';
     foreach ($listFields as $fieldName => $fieldLabel) {
         $listQuery .= '`' . $fieldName . '`, ';
     }
     $listQuery .= '`' . $module->baseIndex . '` FROM `' . $module->baseTable . '`';
     $params = [];
     $sourceModule = $this->get('sourceModule');
     if (!empty($sourceModule)) {
         $sourceModule = Vtiger_Functions::getModuleName($sourceModule);
         $listQuery .= ' WHERE `tabid` = ?';
         $params[] = $sourceModule;
     }
     $startIndex = $pagingModel->getStartIndex();
     $pageLimit = $pagingModel->getPageLimit();
     $orderBy = $this->getForSql('orderby');
     if (!empty($orderBy)) {
         $listQuery .= ' ORDER BY ' . $orderBy . ' ' . $this->getForSql('sortorder');
     }
     $nextListQuery = $listQuery . ' LIMIT ' . ($startIndex + $pageLimit) . ',1';
     $listQuery .= " LIMIT {$startIndex}," . ($pageLimit + 1);
     $listResult = $db->pquery($listQuery, $params);
     $listViewRecordModels = [];
     while ($row = $db->getRow($listResult)) {
         $recordModel = new $recordModelClass();
         $moduleName = Vtiger_Functions::getModuleName($row['tabid']);
         $relModuleName = Vtiger_Functions::getModuleName($row['reltabid']);
         $row['tabid'] = vtranslate($moduleName, $moduleName);
         $row['reltabid'] = vtranslate($relModuleName, $relModuleName);
         $recordModel->setData($row);
         $listViewRecordModels[$recordModel->getId()] = $recordModel;
     }
     $pagingModel->calculatePageRange($listViewRecordModels);
     if ($listResult->rowCount() > $pageLimit) {
         array_pop($listViewRecordModels);
         $pagingModel->set('nextPageExists', true);
     } else {
         $pagingModel->set('nextPageExists', false);
     }
     $nextPageResult = $db->pquery($nextListQuery, $params);
     if ($nextPageResult->rowCount() <= 0) {
         $pagingModel->set('nextPageExists', false);
     }
     return $listViewRecordModels;
 }
开发者ID:Bergdahls,项目名称:YetiForceCRM,代码行数:59,代码来源:ListView.php

示例7: getPageCount

 public function getPageCount(Vtiger_Request $request)
 {
     $numOfRecords = $this->getListViewCount($request);
     $pagingModel = new Vtiger_Paging_Model();
     $pageCount = ceil((int) $numOfRecords / (int) $pagingModel->getPageLimit());
     if ($pageCount == 0) {
         $pageCount = 1;
     }
     $result = array();
     $result['page'] = $pageCount;
     $result['numberOfRecords'] = $numOfRecords;
     $response = new Vtiger_Response();
     $response->setResult($result);
     $response->emit();
 }
开发者ID:cannking,项目名称:vtigercrm-debug,代码行数:15,代码来源:ListAjax.php

示例8: getListViewEntries

 /**
  * Function to get the list view entries
  * @param Vtiger_Paging_Model $pagingModel
  * @return <Array> - Associative array of record id mapped to Vtiger_Record_Model instance.
  */
 public function getListViewEntries($pagingModel)
 {
     $db = PearDatabase::getInstance();
     $module = $this->getModule();
     $moduleName = $module->getName();
     $parentModuleName = $module->getParentName();
     $qualifiedModuleName = $moduleName;
     if (!empty($parentModuleName)) {
         $qualifiedModuleName = $parentModuleName . ':' . $qualifiedModuleName;
     }
     $recordModelClass = Vtiger_Loader::getComponentClassName('Model', 'Record', $qualifiedModuleName);
     $listQuery = $this->getBasicListQuery();
     $startIndex = $pagingModel->getStartIndex();
     $pageLimit = $pagingModel->getPageLimit();
     $orderBy = $this->getForSql('orderby');
     if (!empty($orderBy)) {
         $listQuery .= ' ORDER BY ' . $orderBy . ' ' . $this->getForSql('sortorder');
     }
     if ($module->isPagingSupported()) {
         $nextListQuery = $listQuery . ' LIMIT ' . ($startIndex + $pageLimit) . ',1';
         $listQuery .= " LIMIT {$startIndex}, {$pageLimit}";
     }
     $listResult = $db->pquery($listQuery, array());
     $noOfRecords = $db->num_rows($listResult);
     $listViewRecordModels = array();
     for ($i = 0; $i < $noOfRecords; ++$i) {
         $row = $db->query_result_rowdata($listResult, $i);
         $record = new $recordModelClass();
         $record->setData($row);
         if (method_exists($record, 'getModule') && method_exists($record, 'setModule')) {
             $moduleModel = Settings_Vtiger_Module_Model::getInstance($qualifiedModuleName);
             $record->setModule($moduleModel);
         }
         $listViewRecordModels[$record->getId()] = $record;
     }
     if ($module->isPagingSupported()) {
         $pagingModel->calculatePageRange($listViewRecordModels);
         $nextPageResult = $db->pquery($nextListQuery, array());
         $nextPageNumRows = $db->num_rows($nextPageResult);
         if ($nextPageNumRows <= 0) {
             $pagingModel->set('nextPageExists', false);
         }
     }
     return $listViewRecordModels;
 }
开发者ID:nouphet,项目名称:vtigercrm-6.0.0-ja,代码行数:50,代码来源:ListView.php

示例9: getListViewEntries

 /**
  * Function to get the list view entries
  * @param Vtiger_Paging_Model $pagingModel
  * @return <Array> - Associative array of record id mapped to Vtiger_Record_Model instance.
  */
 public function getListViewEntries($pagingModel)
 {
     $db = PearDatabase::getInstance();
     $startIndex = $pagingModel->getStartIndex();
     $pageLimit = $pagingModel->getPageLimit();
     $orderBy = $this->getForSql('orderby');
     $sortOrder = $this->getForSql('sortorder');
     $listQuery = $this->getQuery();
     $searchKey = $this->get('search_key');
     $searchValue = $this->get('search_value');
     if (!empty($searchKey) && !empty($searchValue)) {
         $listQuery .= " WHERE {$searchKey} LIKE '{$searchValue}%'";
     }
     if (!empty($orderBy) && $orderBy === 'smownerid') {
         $fieldModel = Vtiger_Field_Model::getInstance('assigned_user_id', $moduleModel);
         if ($fieldModel->getFieldDataType() == 'owner') {
             $orderBy = 'COALESCE(CONCAT(vtiger_users.first_name,vtiger_users.last_name),vtiger_groups.groupname)';
         }
     }
     if ($orderBy) {
         $listQuery .= " ORDER BY {$orderBy} {$sortOrder}";
     }
     $listQuery .= " LIMIT {$startIndex}," . ($pageLimit + 1);
     $result = $db->pquery($listQuery, array());
     $num_rows = $db->num_rows($result);
     $listViewRecordModels = array();
     for ($i = 0; $i < $num_rows; $i++) {
         $recordModel = new EmailTemplates_Record_Model();
         $recordModel->setModule('EmailTemplates');
         $row = $db->query_result_rowdata($result, $i);
         $listViewRecordModels[$row['templateid']] = $recordModel->setData($row);
     }
     $pagingModel->calculatePageRange($listViewRecordModels);
     if ($num_rows > $pageLimit) {
         array_pop($listViewRecordModels);
         $pagingModel->set('nextPageExists', true);
     } else {
         $pagingModel->set('nextPageExists', false);
     }
     return $listViewRecordModels;
 }
开发者ID:Bergdahls,项目名称:YetiForceCRM,代码行数:46,代码来源:ListView.php

示例10: getListViewEntries

 /**
  * Function to get the list view entries
  * @param Vtiger_Paging_Model $pagingModel
  * @return <Array> - Associative array of record id mapped to Vtiger_Record_Model instance.
  */
 public function getListViewEntries($pagingModel)
 {
     $db = PearDatabase::getInstance();
     $moduleName = $this->getModule()->get('name');
     $moduleFocus = CRMEntity::getInstance($moduleName);
     $moduleModel = Vtiger_Module_Model::getInstance($moduleName);
     $queryGenerator = $this->get('query_generator');
     $listViewContoller = $this->get('listview_controller');
     $listQuery = $this->getQuery();
     $listQuery = preg_replace("/vtiger_crmentity.deleted\\s*=\\s*0/i", 'vtiger_crmentity.deleted = 1', $listQuery);
     $startIndex = $pagingModel->getStartIndex();
     $pageLimit = $pagingModel->getPageLimit();
     $orderBy = $this->getForSql('orderby');
     $sortOrder = $this->getForSql('sortorder');
     if (!empty($orderBy)) {
         $listQuery .= ' ORDER BY ' . $orderBy . ' ' . $sortOrder;
     }
     $listQuery .= " LIMIT {$startIndex}," . ($pageLimit + 1);
     $listResult = $db->pquery($listQuery, array());
     $listViewRecordModels = array();
     $listViewEntries = $listViewContoller->getListViewRecords($moduleFocus, $moduleName, $listResult);
     $pagingModel->calculatePageRange($listViewEntries);
     if ($db->num_rows($listResult) > $pageLimit) {
         array_pop($listViewEntries);
         $pagingModel->set('nextPageExists', true);
     } else {
         $pagingModel->set('nextPageExists', false);
     }
     $index = 0;
     foreach ($listViewEntries as $recordId => $record) {
         $rawData = $db->query_result_rowdata($listResult, $index++);
         $record['id'] = $recordId;
         $listViewRecordModels[$recordId] = $moduleModel->getRecordFromArray($record, $rawData);
     }
     return $listViewRecordModels;
 }
开发者ID:nouphet,项目名称:vtigercrm-6.0.0-ja,代码行数:41,代码来源:ListView.php

示例11: getListViewEntries

	/**
	 * Function to get the list view entries
	 * @param Vtiger_Paging_Model $pagingModel
	 * @return <Array> - Associative array of record id mapped to Vtiger_Record_Model instance.
	 */
	public function getListViewEntries($pagingModel) {
		$db = PearDatabase::getInstance();
		$moduleName = $this->getModule()->get('name');
		$moduleFocus = CRMEntity::getInstance($moduleName);
		$moduleModel = Vtiger_Module_Model::getInstance($moduleName);

		$queryGenerator = $this->get('query_generator');
		$listViewContoller = $this->get('listview_controller');

        $orderBy = $this->getForSql('orderby');
		$sortOrder = $this->getForSql('sortorder');

		if(!empty($orderBy)){
            $columnFieldMapping = $moduleModel->getColumnFieldMapping();
            $orderByFieldName = $columnFieldMapping[$orderBy];
            $orderByFieldModel = $moduleModel->getField($orderByFieldName);
            if($orderByFieldModel && $orderByFieldModel->getFieldDataType() == Vtiger_Field_Model::REFERENCE_TYPE){
                //IF it is reference add it in the where fields so that from clause will be having join of the table
                $queryGenerator = $this->get('query_generator');
                $queryGenerator->addWhereField($orderByFieldName);
            }
        }
		if (!empty($orderBy) && $orderBy === 'smownerid') {
			$fieldModel = Vtiger_Field_Model::getInstance('assigned_user_id', $moduleModel);
			if ($fieldModel->getFieldDataType() == 'owner') {
				$orderBy = 'COALESCE(' . getSqlForNameInDisplayFormat(['first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'], 'Users') . ',vtiger_groups.groupname)';
			}
		}

		$listQuery = $this->getQuery();
		$listQuery = preg_replace("/vtiger_crmentity.deleted\s*=\s*0/i", 'vtiger_crmentity.deleted = 1', $listQuery);

		$startIndex = $pagingModel->getStartIndex();
		$pageLimit = $pagingModel->getPageLimit();

		if(!empty($orderBy)) {
            if($orderByFieldModel && $orderByFieldModel->isReferenceField()){
                $referenceModules = $orderByFieldModel->getReferenceList();
                $referenceNameFieldOrderBy = array();
                foreach($referenceModules as $referenceModuleName) {
                    $referenceModuleModel = Vtiger_Module_Model::getInstance($referenceModuleName);
                    $referenceNameFields = $referenceModuleModel->getNameFields();

                    $columnList = array();
                    foreach($referenceNameFields as $nameField) {
                        $fieldModel = $referenceModuleModel->getField($nameField);
                        $columnList[] = $fieldModel->get('table').'.'.$fieldModel->get('column');
                    }
                    if(count($columnList) > 1) {
                        $referenceNameFieldOrderBy[] = getSqlForNameInDisplayFormat(array('first_name'=>$columnList[0],'last_name'=>$columnList[1]),'Users').' '.$sortOrder;
                    } else {
                        $referenceNameFieldOrderBy[] = implode('', $columnList).' '.$sortOrder ;
                    }
                }
                $listQuery .= ' ORDER BY '. implode(',',$referenceNameFieldOrderBy);
            }else{
                $listQuery .= ' ORDER BY '. $orderBy . ' ' .$sortOrder;
            }
		}
		$listQuery .= " LIMIT $startIndex,".($pageLimit+1);

		$listResult = $db->pquery($listQuery, array());
		$listViewRecordModels = array();
		$listViewEntries =  $listViewContoller->getListViewRecords($moduleFocus,$moduleName, $listResult);
		$pagingModel->calculatePageRange($listViewEntries);

		if($db->num_rows($listResult) > $pageLimit){
			array_pop($listViewEntries);
			$pagingModel->set('nextPageExists', true);
		}else{
			$pagingModel->set('nextPageExists', false);
		}

		$index = 0;
		foreach($listViewEntries as $recordId => $record) {
			$rawData = $db->query_result_rowdata($listResult, $index++);
			$record['id'] = $recordId;
			$listViewRecordModels[$recordId] = $moduleModel->getRecordFromArray($record, $rawData);
			$listViewRecordModels[$recordId]->lockEditView = Users_Privileges_Model::checkLockEdit($moduleName, $recordId);
			$listViewRecordModels[$recordId]->isPermittedToEditView = Users_Privileges_Model::isPermitted($moduleName, 'EditView', $recordId);
			$listViewRecordModels[$recordId]->colorList = Settings_DataAccess_Module_Model::executeColorListHandlers( $moduleName, $recordId, $listViewRecordModels[$recordId] );
		}
		return $listViewRecordModels;
	}
开发者ID:rubichcube,项目名称:YetiForceCRM,代码行数:89,代码来源:ListView.php

示例12: getListViewEntries

 /**
  * Function to get the list view entries
  * @param Vtiger_Paging_Model $pagingModel
  * @return <Array> - Associative array of record id mapped to Vtiger_Record_Model instance.
  */
 public function getListViewEntries($pagingModel)
 {
     $db = PearDatabase::getInstance();
     $moduleName = $this->getModule()->get('name');
     $moduleFocus = CRMEntity::getInstance($moduleName);
     $moduleModel = Vtiger_Module_Model::getInstance($moduleName);
     $queryGenerator = $this->get('query_generator');
     $listViewContoller = $this->get('listview_controller');
     $folderKey = $this->get('folder_id');
     $folderValue = $this->get('folder_value');
     if (!empty($folderValue)) {
         $queryGenerator->addCondition($folderKey, $folderValue, 'e');
     }
     $searchParams = $this->get('search_params');
     if (empty($searchParams)) {
         $searchParams = array();
     }
     $glue = "";
     if (count($queryGenerator->getWhereFields()) > 0 && count($searchParams) > 0) {
         $glue = QueryGenerator::$AND;
     }
     $queryGenerator->parseAdvFilterList($searchParams, $glue);
     $searchKey = $this->get('search_key');
     $searchValue = $this->get('search_value');
     $operator = $this->get('operator');
     if (!empty($searchKey)) {
         $queryGenerator->addUserSearchConditions(array('search_field' => $searchKey, 'search_text' => $searchValue, 'operator' => $operator));
     }
     $orderBy = $this->getForSql('orderby');
     $sortOrder = $this->getForSql('sortorder');
     //List view will be displayed on recently created/modified records
     if (empty($orderBy) && empty($sortOrder) && $moduleName != "Users") {
         $orderBy = 'modifiedtime';
         $sortOrder = 'DESC';
     }
     if (!empty($orderBy)) {
         $columnFieldMapping = $moduleModel->getColumnFieldMapping();
         $orderByFieldName = $columnFieldMapping[$orderBy];
         $orderByFieldModel = $moduleModel->getField($orderByFieldName);
         if ($orderByFieldModel && $orderByFieldModel->getFieldDataType() == Vtiger_Field_Model::REFERENCE_TYPE) {
             //IF it is reference add it in the where fields so that from clause will be having join of the table
             $queryGenerator = $this->get('query_generator');
             $queryGenerator->addWhereField($orderByFieldName);
             //$queryGenerator->whereFields[] = $orderByFieldName;
         }
     }
     if (!empty($orderBy) && $orderBy === 'smownerid') {
         $fieldModel = Vtiger_Field_Model::getInstance('assigned_user_id', $moduleModel);
         if ($fieldModel->getFieldDataType() == 'owner') {
             $orderBy = 'COALESCE(CONCAT(vtiger_users.first_name,vtiger_users.last_name),vtiger_groups.groupname)';
         }
     }
     $listQuery = $this->getQuery();
     $sourceModule = $this->get('src_module');
     if (!empty($sourceModule)) {
         if (method_exists($moduleModel, 'getQueryByModuleField')) {
             $overrideQuery = $moduleModel->getQueryByModuleField($sourceModule, $this->get('src_field'), $this->get('src_record'), $listQuery);
             if (!empty($overrideQuery)) {
                 $listQuery = $overrideQuery;
             }
         }
     }
     $startIndex = $pagingModel->getStartIndex();
     $pageLimit = $pagingModel->getPageLimit();
     if (!empty($orderBy)) {
         if ($orderByFieldModel && $orderByFieldModel->isReferenceField()) {
             $referenceModules = $orderByFieldModel->getReferenceList();
             $referenceNameFieldOrderBy = array();
             foreach ($referenceModules as $referenceModuleName) {
                 $referenceModuleModel = Vtiger_Module_Model::getInstance($referenceModuleName);
                 $referenceNameFields = $referenceModuleModel->getNameFields();
                 $columnList = array();
                 foreach ($referenceNameFields as $nameField) {
                     $fieldModel = $referenceModuleModel->getField($nameField);
                     $columnList[] = $fieldModel->get('table') . $orderByFieldModel->getName() . '.' . $fieldModel->get('column');
                 }
                 if (count($columnList) > 1) {
                     $referenceNameFieldOrderBy[] = getSqlForNameInDisplayFormat(array('first_name' => $columnList[0], 'last_name' => $columnList[1]), 'Users') . ' ' . $sortOrder;
                 } else {
                     $referenceNameFieldOrderBy[] = implode('', $columnList) . ' ' . $sortOrder;
                 }
             }
             $listQuery .= ' ORDER BY ' . implode(',', $referenceNameFieldOrderBy);
         } else {
             $listQuery .= ' ORDER BY ' . $orderBy . ' ' . $sortOrder;
         }
     }
     $viewid = ListViewSession::getCurrentView($moduleName);
     if (empty($viewid)) {
         $viewid = $pagingModel->get('viewid');
     }
     $_SESSION['lvs'][$moduleName][$viewid]['start'] = $pagingModel->get('page');
     ListViewSession::setSessionQuery($moduleName, $listQuery, $viewid);
     $listQuery .= " LIMIT {$startIndex}," . ($pageLimit + 1);
     $listResult = $db->pquery($listQuery, array());
//.........这里部分代码省略.........
开发者ID:cannking,项目名称:vtigercrm-debug,代码行数:101,代码来源:ListView.php

示例13: getListViewEntries

 /**
  * Function to get the list view entries
  * @param Vtiger_Paging_Model $pagingModel
  * @return <Array> - Associative array of record id mapped to Vtiger_Record_Model instance.
  */
 public function getListViewEntries($pagingModel)
 {
     $db = PearDatabase::getInstance();
     $module = $this->getModule();
     $parentModuleName = $module->getParentName();
     $qualifiedModuleName = 'PDF';
     //$moduleName;
     if (!empty($parentModuleName)) {
         $qualifiedModuleName = $parentModuleName . ':' . $qualifiedModuleName;
     }
     $recordModelClass = Vtiger_Loader::getComponentClassName('Model', 'Record', $qualifiedModuleName);
     $listFields = $module->listFields;
     $listQuery = 'SELECT ';
     foreach ($listFields as $fieldName => $fieldLabel) {
         $listQuery .= '`' . $fieldName . '`, ';
     }
     $listQuery .= '`' . $module->baseIndex . '` FROM `' . $module->baseTable . '`';
     $params = [];
     $sourceModule = $this->get('sourceModule');
     if (!empty($sourceModule)) {
         $listQuery .= ' WHERE `module_name` = ?';
         $params[] = $sourceModule;
     }
     $startIndex = $pagingModel->getStartIndex();
     $pageLimit = $pagingModel->getPageLimit();
     $orderBy = $this->getForSql('orderby');
     if (!empty($orderBy) && $orderBy === 'smownerid') {
         $fieldModel = Vtiger_Field_Model::getInstance('assigned_user_id', $moduleModel);
         if ($fieldModel->getFieldDataType() == 'owner') {
             $orderBy = 'COALESCE(CONCAT(`vtiger_users`.`first_name`, `vtiger_users`.`last_name`), `vtiger_groups`.`groupname`)';
         }
     }
     if (!empty($orderBy)) {
         $listQuery .= ' ORDER BY ' . $orderBy . ' ' . $this->getForSql('sortorder');
     }
     $nextListQuery = $listQuery . ' LIMIT ' . ($startIndex + $pageLimit) . ',1';
     $listQuery .= " LIMIT {$startIndex}," . ($pageLimit + 1);
     $listResult = $db->pquery($listQuery, $params);
     $listViewRecordModels = [];
     while ($row = $db->fetchByAssoc($listResult)) {
         $record = new $recordModelClass();
         $module_name = $row['module_name'];
         //To handle translation of calendar to To Do
         if ($module_name == 'Calendar') {
             $module_name = vtranslate('LBL_TASK', $module_name);
         } else {
             $module_name = vtranslate($module_name, $module_name);
         }
         $row['module_name'] = $module_name;
         $row['summary'] = vtranslate($row['summary'], $qualifiedModuleName);
         $record->setData($row);
         $listViewRecordModels[$record->getId()] = $record;
     }
     $pagingModel->calculatePageRange($listViewRecordModels);
     if ($db->num_rows($listResult) > $pageLimit) {
         array_pop($listViewRecordModels);
         $pagingModel->set('nextPageExists', true);
     } else {
         $pagingModel->set('nextPageExists', false);
     }
     $nextPageResult = $db->pquery($nextListQuery, $params);
     $nextPageNumRows = $db->num_rows($nextPageResult);
     if ($nextPageNumRows <= 0) {
         $pagingModel->set('nextPageExists', false);
     }
     return $listViewRecordModels;
 }
开发者ID:Bergdahls,项目名称:YetiForceCRM,代码行数:72,代码来源:ListView.php

示例14: getExportQuery

 /**
  * Function that generates Export Query based on the mode
  * @param Vtiger_Request $request
  * @return <String> export query
  */
 function getExportQuery(Vtiger_Request $request)
 {
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $mode = $request->getMode();
     $cvId = $request->get('viewname');
     $moduleName = $request->get('source_module');
     $queryGenerator = new QueryGenerator($moduleName, $currentUser);
     $queryGenerator->initForCustomViewById($cvId);
     $fieldInstances = $this->moduleFieldInstances;
     $accessiblePresenceValue = array(0, 2);
     foreach ($fieldInstances as $field) {
         // Check added as querygenerator is not checking this for admin users
         $presence = $field->get('presence');
         if (in_array($presence, $accessiblePresenceValue)) {
             $fields[] = $field->getName();
         }
     }
     $queryGenerator->setFields($fields);
     $query = $queryGenerator->getQuery();
     if (in_array($moduleName, getInventoryModules())) {
         $query = $this->moduleInstance->getExportQuery($this->focus, $query);
     }
     $this->accessibleFields = $queryGenerator->getFields();
     switch ($mode) {
         case 'ExportAllData':
             return $query;
             break;
         case 'ExportCurrentPage':
             $pagingModel = new Vtiger_Paging_Model();
             $limit = $pagingModel->getPageLimit();
             $currentPage = $request->get('page');
             if (empty($currentPage)) {
                 $currentPage = 1;
             }
             $currentPageStart = ($currentPage - 1) * $limit;
             if ($currentPageStart < 0) {
                 $currentPageStart = 0;
             }
             $query .= ' LIMIT ' . $currentPageStart . ',' . $limit;
             return $query;
             break;
         case 'ExportSelectedRecords':
             $idList = $this->getRecordsListFromRequest($request);
             $baseTable = $this->moduleInstance->get('basetable');
             $baseTableColumnId = $this->moduleInstance->get('basetableid');
             if (!empty($idList)) {
                 if (!empty($baseTable) && !empty($baseTableColumnId)) {
                     $idList = implode(',', $idList);
                     $query .= ' AND ' . $baseTable . '.' . $baseTableColumnId . ' IN (' . $idList . ')';
                 }
             } else {
                 $query .= ' AND ' . $baseTable . '.' . $baseTableColumnId . ' NOT IN (' . implode(',', $request->get('excluded_ids')) . ')';
             }
             return $query;
             break;
         default:
             return $query;
             break;
     }
 }
开发者ID:cannking,项目名称:vtigercrm-debug,代码行数:65,代码来源:ExportData.php

示例15: getPageCount

	/**
	 * Function to get the page count for list
	 * @return total number of pages
	 */
	function getPageCount(Vtiger_Request $request){
		$listViewCount = $this->getListViewCount($request);
		$pagingModel = new Vtiger_Paging_Model();
		$pageLimit = $pagingModel->getPageLimit();
		$pageCount = ceil((int) $listViewCount / (int) $pageLimit);

		$result = array();
		$result['page'] = $pageCount;
		$result['numberOfRecords'] = $listViewCount;
		$response = new Vtiger_Response();
		$response->setResult($result);
		$response->emit();
	}
开发者ID:nvh3010,项目名称:quancrm,代码行数:17,代码来源:List.php


注:本文中的Vtiger_Paging_Model::getPageLimit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。