本文整理汇总了PHP中QueryGenerator::setFields方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryGenerator::setFields方法的具体用法?PHP QueryGenerator::setFields怎么用?PHP QueryGenerator::setFields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryGenerator
的用法示例。
在下文中一共展示了QueryGenerator::setFields方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: populateTo
public function populateTo($request)
{
$viewer = $this->getViewer($request);
$inventoryRecordId = $request->get('record');
$recordModel = Vtiger_Record_Model::getInstanceById($inventoryRecordId, $request->getModule());
$inventoryModule = $recordModel->getModule();
$inventotyfields = $inventoryModule->getFields();
$toEmailConsiderableFields = array('contact_id', 'account_id', 'vendor_id');
$db = PearDatabase::getInstance();
$to = array();
$to_info = array();
$toMailNamesList = array();
foreach ($toEmailConsiderableFields as $fieldName) {
if (!array_key_exists($fieldName, $inventotyfields)) {
continue;
}
$fieldModel = $inventotyfields[$fieldName];
if (!$fieldModel->isViewable()) {
continue;
}
$fieldValue = $recordModel->get($fieldName);
if (empty($fieldValue)) {
continue;
}
$referenceList = $fieldModel->getReferenceList();
$referenceModule = $referenceList[0];
$fieldLabel = Vtiger_Util_Helper::getLabel($fieldValue);
$referenceModuleModel = Vtiger_Module_Model::getInstance($referenceModule);
$emailFields = $referenceModuleModel->getFieldsByType('email');
if (count($emailFields) <= 0) {
continue;
}
$current_user = Users_Record_Model::getCurrentUserModel();
$queryGenerator = new QueryGenerator($referenceModule, $current_user);
$queryGenerator->setFields(array_keys($emailFields));
$query = $queryGenerator->getQuery();
$query .= ' AND crmid = ' . $fieldValue;
$result = $db->pquery($query, array());
$num_rows = $db->num_rows($result);
if ($num_rows <= 0) {
continue;
}
foreach ($emailFields as $fieldName => $emailFieldModel) {
$emailValue = $db->query_result($result, 0, $fieldName);
if (!empty($emailValue)) {
$to[] = $emailValue;
$to_info[$fieldValue][] = $emailValue;
$toMailNamesList[$fieldValue][] = array('label' => $fieldLabel, 'value' => $emailValue);
break;
}
}
if (!empty($to)) {
break;
}
}
$viewer->assign('TO', $to);
$viewer->assign('TOMAIL_NAMES_LIST', $toMailNamesList);
$viewer->assign('TOMAIL_INFO', $to_info);
}
示例2: getWorkflowQuery
public function getWorkflowQuery($workflow)
{
$conditions = Zend_Json::decode(decode_html($workflow->test));
$moduleName = $workflow->moduleName;
$queryGenerator = new QueryGenerator($moduleName, $this->user);
$queryGenerator->setFields(array('id'));
$this->addWorkflowConditionsToQueryGenerator($queryGenerator, $conditions);
if ($moduleName == 'Calendar' || $moduleName == 'Events') {
if ($conditions) {
$queryGenerator->addConditionGlue('AND');
}
// We should only get the records related to proper activity type
if ($moduleName == 'Calendar') {
$queryGenerator->addCondition('activitytype', 'Emails', 'n');
$queryGenerator->addCondition('activitytype', 'Task', 'e', 'AND');
} else {
if ($moduleName == "Events") {
$queryGenerator->addCondition('activitytype', 'Emails', 'n');
$queryGenerator->addCondition('activitytype', 'Task', 'n', 'AND');
}
}
}
$query = $queryGenerator->getQuery();
return $query;
}
示例3: getQuery
/**
* Function returns the Query for the relationhips
* @param <Vtiger_Record_Model> $recordModel
* @param type $actions
* @return <String>
*/
public function getQuery($recordModel, $actions = false)
{
$parentModuleModel = $this->getParentModuleModel();
$relatedModuleModel = $this->getRelationModuleModel();
$relatedModuleName = $relatedModuleModel->get('name');
$parentModuleName = $parentModuleModel->get('name');
$functionName = $this->get('name');
$focus = CRMEntity::getInstance($parentModuleName);
$focus->id = $recordModel->getId();
if (method_exists($parentModuleModel, $functionName)) {
$query = $parentModuleModel->{$functionName}($recordModel, $relatedModuleModel);
} else {
$result = $focus->{$functionName}($recordModel->getId(), $parentModuleModel->getId(), $relatedModuleModel->getId(), $actions);
$query = $result['query'];
}
//modify query if any module has summary fields, those fields we are displayed in related list of that module
$relatedListFields = $relatedModuleModel->getConfigureRelatedListFields();
if (count($relatedListFields) > 0) {
$currentUser = Users_Record_Model::getCurrentUserModel();
$queryGenerator = new QueryGenerator($relatedModuleName, $currentUser);
$queryGenerator->setFields($relatedListFields);
$selectColumnSql = $queryGenerator->getSelectClauseColumnSQL();
$newQuery = spliti('FROM', $query);
$selectColumnSql = 'SELECT DISTINCT vtiger_crmentity.crmid,' . $selectColumnSql;
}
if ($functionName == ('get_pricebook_products' || 'get_pricebook_services')) {
$selectColumnSql = $selectColumnSql . ', vtiger_pricebookproductrel.listprice';
}
$query = $selectColumnSql . ' FROM ' . $newQuery[1];
return $query;
}
示例4: getCalculations
function getCalculations(Vtiger_Request $request)
{
$fromModule = $request->get('fromModule');
$record = $request->get('record');
$showtype = $request->get('showtype');
$rqLimit = $request->get('limit');
$db = PearDatabase::getInstance();
$fields = ['id', 'name', 'calculationsstatus'];
$limit = 10;
$params = [];
if (!empty($rqLimit)) {
$limit = $rqLimit;
}
if ($fromModule == 'Accounts') {
$fields[] = 'potentialid';
} elseif ($fromModule == 'Potentials') {
$fields[] = 'assigned_user_id';
}
$calculationConfig = Settings_SalesProcesses_Module_Model::getConfig('calculation');
$calculationsStatus = $calculationConfig['calculationsstatus'];
$currentUser = Users_Record_Model::getCurrentUserModel();
$module = 'Calculations';
$instance = CRMEntity::getInstance($module);
$securityParameter = $instance->getUserAccessConditionsQuerySR($module, $currentUser);
$queryGenerator = new QueryGenerator($module, $currentUser);
$queryGenerator->setFields($fields);
$sql = $queryGenerator->getQuery();
if ($securityParameter != '') {
$sql .= $securityParameter;
}
$calculationsStatusSearch = implode("','", $calculationsStatus);
$showtype = $request->get('showtype');
if ($showtype == 'archive') {
$sql .= " AND vtiger_calculations.calculationsstatus IN ('{$calculationsStatusSearch}')";
} else {
$sql .= " AND vtiger_calculations.calculationsstatus NOT IN ('{$calculationsStatusSearch}')";
}
if ($fromModule == 'Accounts') {
$sql .= ' AND vtiger_calculations.relatedid = ?';
$params[] = $record;
} elseif ($fromModule == 'Potentials') {
$sql .= ' AND vtiger_calculations.potentialid = ?';
$params[] = $record;
}
$sql .= ' LIMIT ' . $limit;
$result = $db->pquery($sql, $params);
$returnData = array();
for ($i = 0; $i < $db->num_rows($result); $i++) {
$returnData[] = $db->query_result_rowdata($result, $i);
}
return $returnData;
}
示例5: 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();
$cvId = $request->get('viewname');
$moduleName = $request->get('source_module');
$queryGenerator = new QueryGenerator($moduleName, $currentUser);
if (!empty($cvId)) {
$queryGenerator->initForCustomViewById($cvId);
}
$acceptedFields = array('user_name', 'title', 'first_name', 'last_name', 'email1', 'email2', 'secondaryemail', 'phone_work', 'phone_mobile', 'phone_fax', 'address_street', 'address_city', 'address_state', 'address_country', 'address_postalcode');
$queryGenerator->setFields($acceptedFields);
$query = $queryGenerator->getQuery();
return $query;
}
示例6: convertMap2Array
private function convertMap2Array()
{
global $adb, $current_user;
$xml = $this->getXMLContent();
if (isset($xml->records)) {
foreach ($xml->records->record as $k => $v) {
if (isset($v->action)) {
$action = strtolower((string) $v->action);
if (!in_array($action, $this->actions)) {
$action = $this->default_action;
}
} else {
$action = $this->default_action;
}
if (isset($v->id)) {
$rs = $adb->pquery('select setype from vtiger_crmentity where crmid=? and deleted=0', array((int) $v->id));
if ($adb->num_rows($rs) == 1) {
$recinfo = $adb->fetch_array($rs);
$this->mapping[$action]['ids'][] = (int) $v->id;
$this->mapping[$action][$recinfo['setype']][] = (int) $v->id;
if (!in_array($recinfo['setype'], $this->mapping['modules'])) {
$this->mapping['modules'][] = $recinfo['setype'];
}
}
} else {
$tabid = getTabid((string) $v->module);
$ui4rs = $adb->pquery('select fieldname from vtiger_field where uitype=4 and tabid=?', array($tabid));
$ui4 = $adb->query_result($ui4rs, 0, 0);
$queryGenerator = new QueryGenerator((string) $v->module, $current_user);
$queryGenerator->setFields(array('id'));
$queryGenerator->addCondition($ui4, (string) $v->value, 'e');
$query = $queryGenerator->getQuery();
$idrs = $adb->pquery($query, array());
if ($idrs and $adb->num_rows($idrs) > 0) {
$id = $adb->query_result($idrs, 0, 0);
$this->mapping[$action]['ids'][] = (int) $id;
$this->mapping[$action][(string) $v->module][] = (int) $id;
if (!in_array($recinfo['setype'], $this->mapping['modules'])) {
$this->mapping['modules'][] = $recinfo['setype'];
}
}
}
}
}
}
示例7: getQuery
/**
* Function returns the Query for the relationhips
* @param <Vtiger_Record_Model> $recordModel
* @param type $actions
* @return <String>
*/
public function getQuery($recordModel, $actions = false, $relationListView_Model = false)
{
$parentModuleModel = $this->getParentModuleModel();
$relatedModuleModel = $this->getRelationModuleModel();
$relatedModuleName = $relatedModuleModel->get('name');
$parentModuleName = $parentModuleModel->get('name');
$functionName = $this->get('name');
$focus = CRMEntity::getInstance($parentModuleName);
$focus->id = $recordModel->getId();
if (method_exists($parentModuleModel, $functionName)) {
$query = $parentModuleModel->{$functionName}($recordModel, $relatedModuleModel);
} else {
$result = $focus->{$functionName}($recordModel->getId(), $parentModuleModel->getId(), $relatedModuleModel->getId(), $actions);
$query = $result['query'];
}
//modify query if any module has summary fields, those fields we are displayed in related list of that module
$relatedListFields = $this->getRelationFields(true, true);
if (count($relatedListFields) == 0) {
$relatedListFields = $relatedModuleModel->getConfigureRelatedListFields();
}
if (count($relatedListFields) > 0) {
$currentUser = Users_Record_Model::getCurrentUserModel();
$queryGenerator = new QueryGenerator($relatedModuleName, $currentUser);
$queryGenerator->setFields($relatedListFields);
$selectColumnSql = $queryGenerator->getSelectClauseColumnSQL();
$newQuery = explode('FROM', $query);
$selectColumnSql = 'SELECT DISTINCT vtiger_crmentity.crmid, ' . $selectColumnSql;
}
if ($functionName == 'get_product_pricebooks') {
$selectColumnSql = $selectColumnSql . ' ,vtiger_pricebookproductrel.listprice, vtiger_pricebook.currency_id, vtiger_products.unit_price';
}
if ($functionName == 'get_service_pricebooks') {
$selectColumnSql = $selectColumnSql . ' ,vtiger_pricebookproductrel.listprice, vtiger_pricebook.currency_id, vtiger_service.unit_price';
}
if ($selectColumnSql && $newQuery[1]) {
$query = $selectColumnSql . ' FROM ' . $newQuery[1];
}
if ($relationListView_Model) {
$searchParams = $relationListView_Model->get('search_params');
$this->addSearchConditions($query, $searchParams, $relatedModuleName);
}
return $query;
}
示例8: getData
public function getData(Vtiger_Request $request, $widget)
{
$db = PearDatabase::getInstance();
$fields = ['id', 'name', 'calculationsstatus', 'relatedid', 'hdnGrandTotal', 'assigned_user_id'];
$limit = 10;
$params = [];
if (!empty($widget->get('limit'))) {
$limit = $widget->get('limit');
}
$calculationConfig = Settings_SalesProcesses_Module_Model::getConfig('calculation');
$calculationsStatus = $calculationConfig['calculationsstatus'];
$currentUser = Users_Record_Model::getCurrentUserModel();
$module = 'Calculations';
$instance = CRMEntity::getInstance($module);
$securityParameter = $instance->getUserAccessConditionsQuerySR($module, $currentUser);
$queryGenerator = new QueryGenerator($module, $currentUser);
$queryGenerator->setFields($fields);
$sql = $queryGenerator->getQuery();
if ($securityParameter != '') {
$sql .= $securityParameter;
}
if (!empty($calculationsStatus)) {
$calculationsStatusSearch = implode("','", $calculationsStatus);
$sql .= " AND vtiger_calculations.calculationsstatus NOT IN ('{$calculationsStatusSearch}')";
}
$showtype = $request->get('showtype');
if ($showtype == 'common') {
$shownersTable = Vtiger_SharedOwner_UIType::getShownerTable($module);
$sql .= ' AND vtiger_crmentity.crmid IN (SELECT DISTINCT crmid FROM ' . $shownersTable . ' WHERE userid = ?';
} else {
$sql .= ' AND vtiger_crmentity.smownerid = ?';
}
$params[] = $currentUser->getId();
$sql .= ' LIMIT ' . $limit;
$result = $db->pquery($sql, $params);
$returnData = array();
for ($i = 0; $i < $db->num_rows($result); $i++) {
$returnData[] = $db->query_result_rowdata($result, $i);
}
return $returnData;
}
示例9: getData
public function getData(Vtiger_Request $request, $widget)
{
$db = PearDatabase::getInstance();
$fields = ['id', 'potentialname', 'sales_stage', 'related_to', 'assigned_user_id'];
$limit = 10;
$params = [];
if (!empty($widget->get('limit'))) {
$limit = $widget->get('limit');
}
$potentialConfig = Settings_SalesProcesses_Module_Model::getConfig('potential');
$potentialSalesStage = $potentialConfig['salesstage'];
$currentUser = Users_Record_Model::getCurrentUserModel();
$module = 'Potentials';
$instance = CRMEntity::getInstance($module);
$securityParameter = $instance->getUserAccessConditionsQuerySR($module, $currentUser);
$queryGenerator = new QueryGenerator($module, $currentUser);
$queryGenerator->setFields($fields);
$sql = $queryGenerator->getQuery();
if ($securityParameter != '') {
$sql .= $securityParameter;
}
if (!empty($potentialSalesStage)) {
$potentialSalesStageSearch = implode("','", $potentialSalesStage);
$sql .= " AND vtiger_potential.sales_stage NOT IN ('{$potentialSalesStageSearch}')";
}
$showtype = $request->get('showtype');
if ($showtype == 'common') {
$sql .= ' AND FIND_IN_SET( ?, vtiger_crmentity.shownerid )';
} else {
$sql .= ' AND vtiger_crmentity.smownerid = ?';
}
$params[] = $currentUser->getId();
$sql .= ' LIMIT ' . $limit;
$result = $db->pquery($sql, $params);
$returnData = array();
for ($i = 0; $i < $db->num_rows($result); $i++) {
$returnData[] = $db->query_result_rowdata($result, $i);
}
return $returnData;
}
示例10: getData
public function getData(Vtiger_Request $request, $widget)
{
$db = PearDatabase::getInstance();
$fields = ['id', 'assetname', 'dateinservice', 'parent_id'];
$limit = 10;
$params = [];
if (!empty($widget->get('limit'))) {
$limit = $widget->get('limit');
}
$assetConfig = Settings_SalesProcesses_Module_Model::getConfig('asset');
$currentUser = Users_Record_Model::getCurrentUserModel();
$module = 'Assets';
$instance = CRMEntity::getInstance($module);
$securityParameter = $instance->getUserAccessConditionsQuerySR($module, $currentUser);
$queryGenerator = new QueryGenerator($module, $currentUser);
$queryGenerator->setFields($fields);
$sql = $queryGenerator->getQuery();
if ($securityParameter != '') {
$sql .= $securityParameter;
}
if (!empty($assetStatus)) {
$assetStatus = implode("','", $assetConfig['assetstatus']);
$sql .= " AND vtiger_assets.assetstatus NOT IN ('{$assetStatus}')";
}
$showtype = $request->get('showtype');
if ($showtype == 'common') {
$sql .= ' AND FIND_IN_SET( ?, vtiger_crmentity.shownerid )';
} else {
$sql .= ' AND vtiger_crmentity.smownerid = ?';
}
$sql .= ' AND vtiger_assets.pot_renewal = 0';
$params[] = $currentUser->getId();
$sql .= ' ORDER BY vtiger_assets.dateinservice ASC LIMIT ' . $limit;
$result = $db->pquery($sql, $params);
$returnData = array();
for ($i = 0; $i < $db->num_rows($result); $i++) {
$returnData[] = $db->query_result_rowdata($result, $i);
}
return $returnData;
}
示例11: getPicklistValues
/**
* Function to get all the available picklist values for the current field
* @return <Array> List of picklist values if the field is of type MultiReferenceValue.
*/
public function getPicklistValues()
{
if (!empty($this->get('picklistValues'))) {
return $this->get('picklistValues');
}
$params = $this->get('field')->getFieldParams();
$db = PearDatabase::getInstance();
$currentUser = Users_Record_Model::getCurrentUserModel();
$fieldInfo = Vtiger_Functions::getModuleFieldInfoWithId($params['field']);
$queryGenerator = new QueryGenerator($params['module'], $currentUser);
$queryGenerator->setFields([$fieldInfo['columnname']]);
if ($params['filterField'] != '-') {
$queryGenerator->addCondition($params['filterField'], $params['filterValue'], 'e');
}
$query = $queryGenerator->getQuery();
$result = $db->query($query);
$values = [];
while ($value = $db->getSingleValue($result)) {
$values[$value] = vtranslate($value, $params['module']);
}
$this->set('picklistValues', $values);
return $values;
}
示例12: getModuleFilters
/**
* this function returns the widget information for an module type widget
*/
private function getModuleFilters($sid)
{
global $adb, $current_user;
$querycvid = "select vtiger_homemoduleflds.fieldname,vtiger_homemodule.* from vtiger_homemoduleflds\n\t\t\t\t\tleft join vtiger_homemodule on vtiger_homemodule.stuffid=vtiger_homemoduleflds.stuffid\n\t\t\t\t\twhere vtiger_homemoduleflds.stuffid=?";
$resultcvid = $adb->pquery($querycvid, array($sid));
$modname = $adb->query_result($resultcvid, 0, "modulename");
$cvid = $adb->query_result($resultcvid, 0, "customviewid");
$maxval = $adb->query_result($resultcvid, 0, "maxentries");
$column_count = $adb->num_rows($resultcvid);
$cvid_check_query = $adb->pquery("SELECT * FROM vtiger_customview WHERE cvid = ?", array($cvid));
if (isPermitted($modname, 'index') == "yes") {
if ($adb->num_rows($cvid_check_query) > 0) {
$focus = CRMEntity::getInstance($modname);
$oCustomView = new CustomView($modname);
if ($modname == "Calendar") {
$listquery = getListQuery($modname);
if (trim($listquery) == '') {
$listquery = $focus->getListQuery($modname);
}
$query = $oCustomView->getModifiedCvListQuery($cvid, $listquery, $modname);
} else {
$queryGenerator = new QueryGenerator($modname, $current_user);
$queryGenerator->initForCustomViewById($cvid);
$customViewFields = $queryGenerator->getCustomViewFields();
$fields = $queryGenerator->getFields();
$newFields = array_diff($fields, $customViewFields);
for ($l = 0; $l < $column_count; $l++) {
$customViewColumnInfo = $adb->query_result($resultcvid, $l, "fieldname");
$details = explode(':', $customViewColumnInfo);
$newFields[] = $details[2];
}
$queryGenerator->setFields($newFields);
$query = $queryGenerator->getQuery();
}
$count_result = $adb->query(mkCountQuery($query));
$noofrows = $adb->query_result($count_result, 0, "count");
$navigation_array = getNavigationValues(1, $noofrows, $maxval);
//To get the current language file
global $current_language, $app_strings;
$fieldmod_strings = return_module_language($current_language, $modname);
if ($modname == "Calendar") {
$query .= "AND vtiger_activity.activitytype NOT IN ('Emails')";
}
$list_result = $adb->query($query . " LIMIT 0," . $maxval);
if ($modname == "Calendar") {
for ($l = 0; $l < $column_count; $l++) {
$fieldinfo = $adb->query_result($resultcvid, $l, "fieldname");
list($tabname, $colname, $fldname, $fieldmodlabel) = explode(":", $fieldinfo);
$fieldheader = explode("_", $fieldmodlabel, 2);
$fldlabel = $fieldheader[1];
$pos = strpos($fldlabel, "_");
if ($pos == true) {
$fldlabel = str_replace("_", " ", $fldlabel);
}
$field_label = isset($app_strings[$fldlabel]) ? $app_strings[$fldlabel] : (isset($fieldmod_strings[$fldlabel]) ? $fieldmod_strings[$fldlabel] : $fldlabel);
$cv_presence = $adb->pquery("SELECT * from vtiger_cvcolumnlist WHERE cvid = ? and columnname LIKE '%" . $fldname . "%'", array($cvid));
if ($is_admin == false) {
$fld_permission = getFieldVisibilityPermission($modname, $current_user->id, $fldname);
}
if ($fld_permission == 0 && $adb->num_rows($cv_presence)) {
$field_query = $adb->pquery("SELECT fieldlabel FROM vtiger_field WHERE fieldname = ? AND tablename = ? and vtiger_field.presence in (0,2)", array($fldname, $tabname));
$field_label = $adb->query_result($field_query, 0, 'fieldlabel');
$header[] = $field_label;
}
$fieldcolumns[$fldlabel] = array($tabname => $colname);
}
$listview_entries = getListViewEntries($focus, $modname, $list_result, $navigation_array, "", "", "EditView", "Delete", $oCustomView, 'HomePage', $fieldcolumns);
} else {
$controller = new ListViewController($adb, $current_user, $queryGenerator);
$controller->setHeaderSorting(false);
$header = $controller->getListViewHeader($focus, $modname, '', '', '', true);
$listview_entries = $controller->getListViewEntries($focus, $modname, $list_result, $navigation_array, true);
}
$return_value = array('ModuleName' => $modname, 'cvid' => $cvid, 'Maxentries' => $maxval, 'Header' => $header, 'Entries' => $listview_entries);
if (sizeof($header) != 0) {
return $return_value;
} else {
return array('Entries' => "Fields not found in Selected Filter");
}
} else {
return array('Entries' => "<font color='red'>Filter You have Selected is Not Found</font>");
}
} else {
return array('Entries' => "<font color='red'>Permission Denied</font>");
}
}
示例13: getRelationQuery
/**
* Function to get relation query for particular module with function name
* @param <record> $recordId
* @param <String> $functionName
* @param Vtiger_Module_Model $relatedModule
* @return <String>
*/
public function getRelationQuery($recordId, $functionName, $relatedModule)
{
$relatedModuleName = $relatedModule->getName();
$focus = CRMEntity::getInstance($this->getName());
$focus->id = $recordId;
$result = $focus->{$functionName}($recordId, $this->getId(), $relatedModule->getId());
$query = $result['query'] . ' ' . $this->getSpecificRelationQuery($relatedModuleName);
$nonAdminQuery = $this->getNonAdminAccessControlQueryForRelation($relatedModuleName);
//modify query if any module has summary fields, those fields we are displayed in related list of that module
$relatedListFields = $relatedModule->getConfigureRelatedListFields();
if ($relatedModuleName == 'Documents') {
$relatedListFields['filelocationtype'] = 'filelocationtype';
$relatedListFields['filestatus'] = 'filestatus';
}
if (count($relatedListFields) > 0) {
$currentUser = Users_Record_Model::getCurrentUserModel();
$queryGenerator = new QueryGenerator($relatedModuleName, $currentUser);
$queryGenerator->setFields($relatedListFields);
$selectColumnSql = $queryGenerator->getSelectClauseColumnSQL();
$newQuery = spliti('FROM', $query);
$selectColumnSql = 'SELECT DISTINCT vtiger_crmentity.crmid,' . $selectColumnSql;
$query = $selectColumnSql . ' FROM ' . $newQuery[1];
}
if ($nonAdminQuery) {
$query = appendFromClauseToQuery($query, $nonAdminQuery);
}
return $query;
}
示例14: getExportRecordIds
function getExportRecordIds($moduleName, $viewid, $input)
{
global $adb, $current_user, $list_max_entries_per_page;
$idstring = vtlib_purify($input['idstring']);
$export_data = vtlib_purify($input['export_data']);
if (in_array($moduleName, getInventoryModules()) && $export_data == 'currentpage') {
$queryGenerator = new QueryGenerator($moduleName, $current_user);
$queryGenerator->initForCustomViewById($viewid);
if ($input['query'] == 'true') {
$queryGenerator->addUserSearchConditions($input);
}
$queryGenerator->setFields(array('id'));
$query = $queryGenerator->getQuery();
$current_page = ListViewSession::getCurrentPage($moduleName, $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, array());
$idstring = array();
$focus = CRMEntity::getInstance($moduleName);
for ($i = 0; $i < $adb->num_rows($result); $i++) {
$idstring[] = $adb->query_result($result, $i, $focus->table_index);
}
$idstring = implode(';', $idstring);
$export_data = 'selecteddata';
}
return $idstring . '#@@#' . $export_data;
}
示例15: getTopQuotes
/** function used to get the top 5 quotes from the ListView query
* @return array $values - array with the title, header and entries like Array('Title'=>$title,'Header'=>$listview_header,'Entries'=>$listview_entries) where as listview_header and listview_entries are arrays of header and entity values which are returned from function getListViewHeader and getListViewEntries
*/
function getTopQuotes($maxval, $calCnt)
{
require_once "data/Tracker.php";
require_once 'modules/Quotes/Quotes.php';
require_once 'include/logging.php';
require_once 'include/ListView/ListView.php';
require_once 'include/utils/utils.php';
require_once 'modules/CustomView/CustomView.php';
global $app_strings, $current_language, $current_user;
$current_module_strings = return_module_language($current_language, 'Quotes');
global $list_max_entries_per_page, $adb, $theme, $mod_strings;
$log = LoggerManager::getLogger('quote_list');
$url_string = '';
$sorder = '';
$oCustomView = new CustomView("Quotes");
$customviewcombo_html = $oCustomView->getCustomViewCombo();
if (isset($_REQUEST['viewname']) == false || $_REQUEST['viewname'] == '') {
if ($oCustomView->setdefaultviewid != "") {
$viewid = $oCustomView->setdefaultviewid;
} else {
$viewid = "0";
}
}
$theme_path = "themes/" . $theme . "/";
$image_path = $theme_path . "images/";
//Retreive the list from Database
//<<<<<<<<<customview>>>>>>>>>
$date_var = date('Y-m-d');
$currentModule = 'Quotes';
$viewId = getCvIdOfAll($currentModule);
$queryGenerator = new QueryGenerator($currentModule, $current_user);
$queryGenerator->initForCustomViewById($viewId);
$meta = $queryGenerator->getMeta($currentModule);
$accessibleFieldNameList = array_keys($meta->getModuleFields());
$customViewFields = $queryGenerator->getCustomViewFields();
$fields = $queryGenerator->getFields();
$newFields = array_diff($fields, $customViewFields);
$widgetFieldsList = array('subject', 'potential_id', 'account_id', 'total');
$widgetFieldsList = array_intersect($accessibleFieldNameList, $widgetFieldsList);
$widgetSelectedFields = array_chunk(array_intersect($customViewFields, $widgetFieldsList), 2);
//select the first chunk of two fields
$widgetSelectedFields = $widgetSelectedFields[0];
if (count($widgetSelectedFields) < 2) {
$widgetSelectedFields = array_chunk(array_merge($widgetSelectedFields, $accessibleFieldNameList), 2);
//select the first chunk of two fields
$widgetSelectedFields = $widgetSelectedFields[0];
}
$newFields = array_merge($newFields, $widgetSelectedFields);
$queryGenerator->setFields($newFields);
$_REQUEST = getTopQuotesSearch($_REQUEST, array('assigned_user_id' => $current_user->column_fields['user_name'], 'validtill' => $date_var, 'quotestage.Rejected' => $current_module_strings['Rejected'], 'quotestage.Accepted' => $current_module_strings['Accepted']));
$queryGenerator->addUserSearchConditions($_REQUEST);
$search_qry = '&query=true' . getSearchURL($_REQUEST);
$query = $queryGenerator->getQuery();
//<<<<<<<<customview>>>>>>>>>
$query .= " LIMIT " . $adb->sql_escape_string($maxval);
if ($calCnt == 'calculateCnt') {
$list_result_rows = $adb->query(mkCountQuery($query));
return $adb->query_result($list_result_rows, 0, 'count');
}
$list_result = $adb->query($query);
//Retreiving the no of rows
$noofrows = $adb->num_rows($list_result);
//Retreiving the start value from request
if (isset($_REQUEST['start']) && $_REQUEST['start'] != '') {
$start = vtlib_purify($_REQUEST['start']);
} else {
$start = 1;
}
//Retreive the Navigation array
$navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page);
if ($navigation_array['start'] == 1) {
if ($noofrows != 0) {
$start_rec = $navigation_array['start'];
} else {
$start_rec = 0;
}
if ($noofrows > $list_max_entries_per_page) {
$end_rec = $navigation_array['start'] + $list_max_entries_per_page - 1;
} else {
$end_rec = $noofrows;
}
} else {
if ($navigation_array['next'] > $list_max_entries_per_page) {
$start_rec = $navigation_array['next'] - $list_max_entries_per_page;
$end_rec = $navigation_array['next'] - 1;
} else {
$start_rec = $navigation_array['prev'] + $list_max_entries_per_page;
$end_rec = $noofrows;
}
}
$focus = new Quotes();
$title = array('TopOpenQuotes.gif', $current_module_strings['LBL_MY_TOP_QUOTE'], 'home_mytopquote');
//Retreive the List View Table Header
$controller = new ListViewController($adb, $current_user, $queryGenerator);
$controller->setHeaderSorting(false);
$header = $controller->getListViewHeader($focus, $currentModule, $url_string, $sorder, $order_by, true);
$entries = $controller->getListViewEntries($focus, $currentModule, $list_result, $navigation_array, true);
//.........这里部分代码省略.........