本文整理汇总了PHP中QueryGenerator::initForCustomViewById方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryGenerator::initForCustomViewById方法的具体用法?PHP QueryGenerator::initForCustomViewById怎么用?PHP QueryGenerator::initForCustomViewById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryGenerator
的用法示例。
在下文中一共展示了QueryGenerator::initForCustomViewById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
}
示例2: process
function process(Vtiger_Request $request)
{
global $log;
$log->debug("Entering ./views/MiniListWizard.php::process");
$currentUser = Users_Record_Model::getCurrentUserModel();
$viewer = $this->getViewer($request);
$moduleName = $request->getModule();
$viewer->assign('MODULE_NAME', $moduleName);
$viewer->assign('WIZARD_STEP', $request->get('step'));
switch ($request->get('step')) {
case 'step1':
$modules = Vtiger_Module_Model::getSearchableModules();
//Since comments is not treated as seperate module
unset($modules['ModComments']);
$viewer->assign('MODULES', $modules);
break;
case 'step2':
$selectedModule = $request->get('selectedModule');
$filters = CustomView_Record_Model::getAllByGroup($selectedModule);
$viewer->assign('ALLFILTERS', $filters);
break;
case 'step3':
$selectedModule = $request->get('selectedModule');
$filterid = $request->get('filterid');
$db = PearDatabase::getInstance();
$generator = new QueryGenerator($selectedModule, $currentUser);
$generator->initForCustomViewById($filterid);
$listviewController = new ListViewController($db, $currentUser, $generator);
$listviewController->getListViewHeaderFields();
$viewer->assign('LIST_VIEW_CONTROLLER', $listviewController);
$viewer->assign('SELECTED_MODULE', $selectedModule);
break;
}
$viewer->view('dashboards/MiniListWizard.tpl', $moduleName);
}
示例3: getKeyMetricsWithCount
protected function getKeyMetricsWithCount()
{
global $current_user, $adb;
$current_user = Users_Record_Model::getCurrentUserModel();
require_once 'modules/CustomView/ListViewTop.php';
$metriclists = getMetricList();
foreach ($metriclists as $key => $metriclist) {
$metricresult = NULL;
if ($metriclist['module'] == "Calendar") {
$listquery = getListQuery($metriclist['module']);
$oCustomView = new CustomView($metriclist['module']);
$metricsql = $oCustomView->getModifiedCvListQuery($metriclist['id'], $listquery, $metriclist['module']);
$metricresult = $adb->query(Vtiger_Functions::mkCountQuery($metricsql));
} else {
$queryGenerator = new QueryGenerator($metriclist['module'], $current_user);
$queryGenerator->initForCustomViewById($metriclist['id']);
$metricsql = $queryGenerator->getQuery();
$metricresult = $adb->query(Vtiger_Functions::mkCountQuery($metricsql));
}
if ($metricresult) {
$rowcount = $adb->fetch_array($metricresult);
$metriclists[$key]['count'] = $rowcount['count'];
}
}
return $metriclists;
}
示例4: addRelationsFromRelatedModuleViewId
/**
* Function to add relations using related module viewid
* @param Vtiger_Request $request
*/
public function addRelationsFromRelatedModuleViewId(Vtiger_Request $request)
{
$sourceRecordId = $request->get('sourceRecord');
$relatedModuleName = $request->get('relatedModule');
$viewId = $request->get('viewId');
if ($viewId) {
$sourceModuleModel = Vtiger_Module_Model::getInstance($request->getModule());
$relatedModuleModel = Vtiger_Module_Model::getInstance($relatedModuleName);
$relationModel = Vtiger_Relation_Model::getInstance($sourceModuleModel, $relatedModuleModel);
$emailEnabledModulesInfo = $relationModel->getEmailEnabledModulesInfoForDetailView();
if (array_key_exists($relatedModuleName, $emailEnabledModulesInfo)) {
$fieldName = $emailEnabledModulesInfo[$relatedModuleName]['fieldName'];
$db = PearDatabase::getInstance();
$currentUserModel = Users_Record_Model::getCurrentUserModel();
$queryGenerator = new QueryGenerator($relatedModuleName, $currentUserModel);
$queryGenerator->initForCustomViewById($viewId);
$query = $queryGenerator->getQuery();
$result = $db->pquery($query, array());
$numOfRows = $db->num_rows($result);
for ($i = 0; $i < $numOfRows; $i++) {
$relatedRecordIdsList[] = $db->query_result($result, $i, $fieldName);
}
if (empty($relatedRecordIdsList)) {
$response = new Vtiger_Response();
$response->setResult(array(false));
$response->emit();
} else {
foreach ($relatedRecordIdsList as $relatedRecordId) {
$relationModel->addRelation($sourceRecordId, $relatedRecordId);
}
}
}
}
}
示例5: render
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');
}
}
示例6: getKeyMetricsWithCount
protected function getKeyMetricsWithCount()
{
global $log;
$log->debug("Entering ./dashboards/KeyMetrics.php::getKeyMetricsWithCount");
global $current_user, $adb;
$current_user = Users_Record_Model::getCurrentUserModel();
require_once 'modules/CustomView/ListViewTop.php';
$metriclists = getMetricList();
foreach ($metriclists as $key => $metriclist) {
$metricresult = NULL;
$queryGenerator = new QueryGenerator($metriclist['module'], $current_user);
$queryGenerator->initForCustomViewById($metriclist['id']);
if ($metriclist['module'] == "Calendar") {
// For calendar we need to eliminate emails or else it will break in status empty condition
$queryGenerator->addCondition('activitytype', "Emails", 'n', QueryGenerator::$AND);
}
$metricsql = $queryGenerator->getQuery();
$metricresult = $adb->query(Vtiger_Functions::mkCountQuery($metricsql));
if ($metricresult) {
$rowcount = $adb->fetch_array($metricresult);
$metriclists[$key]['count'] = $rowcount['count'];
}
}
return $metriclists;
}
示例7: getContent
function getContent(Mobile_API_Request $request)
{
global $current_user, $adb;
$current_user = $this->getActiveUser();
$module = $request->get('module');
$limit = $request->get('number');
$offset = $request->get('offset');
$search = isset($_REQUEST['src_str']) ? $request->get('src_str') : '';
$customView = new CustomView($module);
if (!empty($_REQUEST['view'])) {
$viewid = $_REQUEST['view'];
} else {
$viewid = $customView->getViewId($module);
}
$queryGenerator = new QueryGenerator($module, $current_user);
if ($viewid != "0") {
$queryGenerator->initForCustomViewById($viewid);
} else {
$queryGenerator->initForDefaultCustomView();
}
$list_query = $queryGenerator->getQuery();
//get entity fields for each module
$entity_sql = "select fieldname,tablename,entityidfield from vtiger_entityname where modulename =?";
$ws_entity = $adb->pquery($entity_sql, array($module));
$fieldname = $adb->query_result($ws_entity, 0, 'fieldname');
$tablename = $adb->query_result($ws_entity, 0, 'tablename');
//set the list and content order
if ($module == 'Contacts' || $module == 'Leads') {
$list_query .= " AND (lastname LIKE '%{$search}%' OR firstname LIKE '%{$search}%') ORDER BY lastname";
} elseif ($module != 'Calendar' and $module != 'Events') {
$list_query .= " AND " . $tablename . "." . $fieldname . " LIKE '%{$search}%' ORDER BY " . $tablename . "." . $fieldname;
} elseif ($module == 'Calendar' || $module == 'Events') {
$calendarview_selected = $request->get('viewName');
$list_query .= " AND vtiger_activity.activitytype!='Emails'";
if ($calendarview_selected == 'week') {
$list_query .= " AND week(date_start) = week(NOW()) AND year(date_start) = year(NOW())";
} elseif ($calendarview_selected == 'month') {
$list_query .= " AND month(date_start) = month(NOW()) AND year(date_start) = year(NOW())";
} elseif ($calendarview_selected == 'year') {
$list_query .= " AND year(date_start) = year(NOW())";
} elseif ($calendarview_selected == 'today') {
$list_query .= " AND DATE(date_start) = DATE(NOW())";
}
$list_query .= " AND subject LIKE '%{$search}%' ORDER BY date_start DESC";
} else {
$list_query .= " AND " . $tablename . "." . $fieldname . " LIKE '%{$search}%' ORDER BY " . $tablename . "." . $fieldname;
}
$list_query .= " LIMIT {$offset}, {$limit};";
$listview_entries = $adb->pquery($list_query, array());
$response = new Mobile_API_Response();
$response->setResult(array('records' => $listview_entries, 'module' => $module));
return $response;
}
示例8: 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;
}
示例9: getInstance
/**
* Static Function to get the Instance of Vtiger ListView model for a given module and custom view
* @param <String> $moduleName - Module Name
* @param <Number> $viewId - Custom View Id
* @return Vtiger_ListView_Model instance
*/
public static function getInstance($moduleName, $sourceModule)
{
$db = PearDatabase::getInstance();
$currentUser = vglobal('current_user');
$modelClassName = Vtiger_Loader::getComponentClassName('Model', 'ListView', $moduleName);
$instance = new $modelClassName();
$sourceModuleModel = Vtiger_Module_Model::getInstance($sourceModule);
$queryGenerator = new QueryGenerator($sourceModuleModel->get('name'), $currentUser);
$cvidObj = CustomView_Record_Model::getAllFilterByModule($sourceModuleModel->get('name'));
$cvid = $cvidObj->getId('cvid');
$queryGenerator->initForCustomViewById($cvid);
$controller = new ListViewController($db, $currentUser, $queryGenerator);
return $instance->set('module', $sourceModuleModel)->set('query_generator', $queryGenerator)->set('listview_controller', $controller);
}
示例10: 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);
//.........这里部分代码省略.........
示例11: QueryGenerator
/*+********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
* Contributor(s): mmbrich
********************************************************************************/
require_once 'modules/CustomView/CustomView.php';
require_once 'user_privileges/default_module_view.php';
global $currentModule, $current_user;
$queryGenerator = new QueryGenerator(vtlib_purify($_REQUEST["list_type"]), $current_user);
if ($_REQUEST["cvid"] != "0") {
$queryGenerator->initForCustomViewById(vtlib_purify($_REQUEST["cvid"]));
} else {
$queryGenerator->initForDefaultCustomView();
}
$rs = $adb->query($queryGenerator->getQuery());
if ($_REQUEST["list_type"] == "Leads") {
$reltable = "vtiger_campaignleadrel";
$relid = "leadid";
} elseif ($_REQUEST["list_type"] == "Contacts") {
$reltable = "vtiger_campaigncontrel";
$relid = "contactid";
} elseif ($_REQUEST["list_type"] == "Accounts") {
$reltable = "vtiger_campaignaccountrel";
$relid = "accountid";
}
$focus = CRMEntity::getInstance($currentModule);
示例12: process
public function process(Vtiger_Request $request)
{
require_once "libraries/PHPExcel/PHPExcel.php";
$currentUser = Users_Record_Model::getCurrentUserModel();
$module = $request->getModule(false);
//this is the type of things in the current view
$filter = $request->get('viewname');
//this is the cvid of the current custom filter
$recordIds = $this->getRecordsListFromRequest($request);
//this handles the 'all' situation.
//we now know what we want to render and can get a handle to the respective view, probably should use a listviewcontroller to get the data
$selectedModule = $request->get("targetmodule");
//set up our spreadsheet to write out to
$workbook = new PHPExcel();
$worksheet = $workbook->setActiveSheetIndex(0);
$header_styles = array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => 'E1E0F7')), 'font' => array('bold' => true));
$row = 1;
$col = 0;
$generator = new QueryGenerator($selectedModule, $currentUser);
$generator->initForCustomViewById($filter);
$customView = CustomView_Record_Model::getInstanceById($filter);
$listviewController = new ListViewController($db, $currentUser, $generator);
$headers = $listviewController->getListViewHeaderFields();
//get the column headers, they go in row 0 of the spreadsheet
foreach ($headers as $column => $webserviceField) {
$fieldObj = Vtiger_Field::getInstance($webserviceField->getFieldId());
//echo $fieldObj->label;
$fields[] = $fieldObj;
$worksheet->setCellValueExplicitByColumnAndRow($col, $row, decode_html(vtranslate($fieldObj->label, $selectedModule)), PHPExcel_Cell_DataType::TYPE_STRING);
$col++;
}
$row++;
$targetModuleFocus = CRMEntity::getInstance($selectedModule);
//ListViewController has lots of paging stuff and things we don't want
//so lets just itterate across the list of IDs we have and get the field values
foreach ($recordIds as $id) {
$col = 0;
$record = Vtiger_Record_Model::getInstanceById($id, $selectedModule);
foreach ($fields as $field) {
//depending on the uitype we might want the raw value, the display value or something else.
//we might also want the display value sans-links so we can use strip_tags for that
//phone numbers need to be explicit strings
$value = $record->getDisplayValue($field->name);
$uitype = $field->uitype;
switch ($uitype) {
case 4:
//numbers
//numbers
case 25:
case 7:
case 71:
$worksheet->setCellvalueExplicitByColumnAndRow($col, $row, strip_tags($value), PHPExcel_Cell_DataType::TYPE_NUMERIC);
break;
case 6:
//datetimes
//datetimes
case 23:
case 70:
$worksheet->setCellvalueExplicitByColumnAndRow($col, $row, PHPExcel_Shared_Date::PHPToExcel(strtotime($value)), PHPExcel_Cell_DataType::TYPE_NUMERIC);
$worksheet->getStyleByColumnAndRow($col, $row)->getNumberFormat()->setFormatCode('DD/MM/YYYY HH:MM:SS');
//format the date to the users preference
break;
default:
$worksheet->setCellValueExplicitByColumnAndRow($col, $row, decode_html(strip_tags($value)), PHPExcel_Cell_DataType::TYPE_STRING);
}
//echo strip_tags($value);
$col++;
}
//echo "<br>";
$row++;
}
//having written out all the data lets have a go at getting the columns to auto-size
$col = 0;
$row = 1;
foreach ($headers as $column => $webserviceField) {
$cell = $worksheet->getCellByColumnAndRow($col, $row);
$worksheet->getStyleByColumnAndRow($col, $row)->applyFromArray($header_styles);
$worksheet->getColumnDimension($cell->getColumn())->setAutoSize(true);
$col++;
}
$rootDirectory = vglobal('root_directory');
$tmpDir = vglobal('tmp_dir');
$tempFileName = tempnam($rootDirectory . $tmpDir, 'xls');
$workbookWriter = PHPExcel_IOFactory::createWriter($workbook, 'Excel5');
$workbookWriter->save($tempFileName);
if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
header('Pragma: public');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
}
header('Content-Type: application/x-msexcel');
header('Content-Length: ' . @filesize($tempFileName));
$filename = decode_html($customView->get('viewname')) . ".xls";
header('Content-disposition: attachment; filename="' . $filename . '"');
$fp = fopen($tempFileName, 'rb');
fpassthru($fp);
}
示例13: getSelectAllQuery
function getSelectAllQuery($input, $module)
{
global $adb, $current_user;
$viewid = vtlib_purify($input['viewname']);
if ($module == "Calendar") {
$listquery = getListQuery($module);
$oCustomView = new CustomView($module);
$query = $oCustomView->getModifiedCvListQuery($viewid, $listquery, $module);
$where = '';
if ($input['query'] == 'true') {
list($where, $ustring) = explode("#@@#", getWhereCondition($module, $input));
if (isset($where) && $where != '') {
$query .= " AND " . $where;
}
}
} else {
$queryGenerator = new QueryGenerator($module, $current_user);
$queryGenerator->initForCustomViewById($viewid);
if ($input['query'] == 'true') {
$queryGenerator->addUserSearchConditions($input);
}
$queryGenerator->setFields(array('id'));
$query = $queryGenerator->getQuery();
if ($module == 'Documents') {
$folderid = vtlib_purify($input['folderidstring']);
$folderid = str_replace(';', ',', $folderid);
$query .= " AND vtiger_notes.folderid in (" . $folderid . ")";
}
}
$result = $adb->pquery($query, array());
return $result;
}
示例14: getKeyMetrics
/** to get the details of a KeyMetrics on Home page
* @returns $customviewlist Array in the following format
* $values = Array('Title'=>Array(0=>'image name',
* 1=>'Key Metrics',
* 2=>'home_metrics'
* ),
* 'Header'=>Array(0=>'Metrics',
* 1=>'Count'
* ),
* 'Entries'=>Array($cvid=>Array(
* 0=>$customview name,
* 1=>$no of records for the view
* ),
* $cvid=>Array(
* 0=>$customview name,
* 1=>$no of records for the view
* ),
* |
* |
* $cvid=>Array(
* 0=>$customview name,
* 1=>$no of records for the view
* )
* )
*
*/
function getKeyMetrics($maxval, $calCnt)
{
require_once "data/Tracker.php";
require_once 'modules/CustomView/CustomView.php';
require_once 'include/logging.php';
require_once 'include/ListView/ListView.php';
global $app_strings;
global $adb;
global $log;
global $current_language;
$metricviewnames = "'Hot Leads'";
$current_module_strings = return_module_language($current_language, "CustomView");
$log = LoggerManager::getLogger('metrics');
$metriclists = getMetricList();
// Determine if the KeyMetrics widget should appear or not?
if ($calCnt == 'calculateCnt') {
return count($metriclists);
}
$log->info("Metrics :: Successfully got MetricList to be displayed");
if (isset($metriclists)) {
global $current_user;
foreach ($metriclists as $key => $metriclist) {
$queryGenerator = new QueryGenerator($metriclist['module'], $current_user);
$queryGenerator->initForCustomViewById($metriclist['id']);
$metricsql = $queryGenerator->getQuery();
$metricsql = mkCountQuery($metricsql);
$metricresult = $adb->query($metricsql);
if ($metricresult) {
if ($metriclist['module'] == "Calendar") {
$metriclists[$key]['count'] = $adb->num_rows($metricresult);
} else {
$rowcount = $adb->fetch_array($metricresult);
$metriclists[$key]['count'] = $rowcount['count'];
}
}
}
$log->info("Metrics :: Successfully build the Metrics");
}
$title = array();
$title[] = 'keyMetrics.gif';
$title[] = $app_strings['LBL_HOME_KEY_METRICS'];
$title[] = 'home_metrics';
$header = array();
$header[] = $app_strings['LBL_HOME_METRICS'];
$header[] = $app_strings['LBL_MODULE'];
$header[] = $app_strings['LBL_HOME_COUNT'];
$entries = array();
if (isset($metriclists)) {
$oddRow = true;
foreach ($metriclists as $metriclist) {
$value = array();
// JFV - fix wrongly truncationed utf8 string
if (function_exists("mb_strimwidth")) {
$CVname = mb_strimwidth($current_module_strings['JFV_cv_name'][$metriclist['name']] ? $current_module_strings['JFV_cv_name'][$metriclist['name']] : $metriclist['name'], 0, 20, '...', "UTF-8");
} else {
// JFV END
$CVname = strlen($metriclist['name']) > 20 ? substr($metriclist['name'], 0, 20) . '...' : $metriclist['name'];
// JFV
}
// JFV END
$value[] = '<a href="index.php?action=ListView&module=' . $metriclist['module'] . '&viewname=' . $metriclist['id'] . '">' . $CVname . '</a> <font style="color:#6E6E6E;">(' . $metriclist['user'] . ')</font>';
$value[] = '<a href="index.php?action=ListView&module=' . $metriclist['module'] . '&viewname=' . $metriclist['id'] . '">' . getTranslatedString($metriclist['module']) . '</a>';
$value[] = '<a href="index.php?action=ListView&module=' . $metriclist['module'] . '&viewname=' . $metriclist['id'] . '">' . $metriclist['count'] . '</a>';
$entries[$metriclist['id']] = $value;
}
}
$values = array('Title' => $title, 'Header' => $header, 'Entries' => $entries);
if ($display_empty_home_blocks || count($value) != 0) {
return $values;
}
}
示例15: createRecords
public function createRecords()
{
$adb = PearDatabase::getInstance();
$moduleName = $this->module;
$focus = CRMEntity::getInstance($moduleName);
$moduleHandler = vtws_getModuleHandlerFromName($moduleName, $this->user);
$moduleMeta = $moduleHandler->getMeta();
$moduleObjectId = $moduleMeta->getEntityId();
$moduleFields = $moduleMeta->getModuleFields();
$entityData = array();
$tableName = Import_Utils_Helper::getDbTableName($this->user);
$sql = 'SELECT * FROM ' . $tableName . ' WHERE status = ' . Import_Data_Action::$IMPORT_RECORD_NONE;
if ($this->batchImport) {
$configReader = new Import_Config_Model();
$importBatchLimit = $configReader->get('importBatchLimit');
$sql .= ' LIMIT ' . $importBatchLimit;
}
$result = $adb->query($sql);
$numberOfRecords = $adb->num_rows($result);
if ($numberOfRecords <= 0) {
return;
}
$fieldMapping = $this->fieldMapping;
$fieldColumnMapping = $moduleMeta->getFieldColumnMapping();
for ($i = 0; $i < $numberOfRecords; ++$i) {
$row = $adb->raw_query_result_rowdata($result, $i);
$rowId = $row['id'];
$entityInfo = null;
$fieldData = array();
foreach ($fieldMapping as $fieldName => $index) {
$fieldData[$fieldName] = $row[$fieldName];
}
$mergeType = $this->mergeType;
$createRecord = false;
if (method_exists($focus, 'importRecord')) {
$entityInfo = $focus->importRecord($this, $fieldData);
} else {
if (!empty($mergeType) && $mergeType != Import_Utils_Helper::$AUTO_MERGE_NONE) {
$queryGenerator = new QueryGenerator($moduleName, $this->user);
$customView = new CustomView($moduleName);
$viewId = $customView->getViewIdByName('All', $moduleName);
if (!empty($viewId)) {
$queryGenerator->initForCustomViewById($viewId);
} else {
$queryGenerator->initForDefaultCustomView();
}
$fieldsList = array('id');
$queryGenerator->setFields($fieldsList);
$mergeFields = $this->mergeFields;
if ($queryGenerator->getWhereFields() && $mergeFields) {
$queryGenerator->addConditionGlue(QueryGenerator::$AND);
}
foreach ($mergeFields as $index => $mergeField) {
if ($index != 0) {
$queryGenerator->addConditionGlue(QueryGenerator::$AND);
}
$comparisonValue = $fieldData[$mergeField];
$fieldInstance = $moduleFields[$mergeField];
if ($fieldInstance->getFieldDataType() == 'owner') {
$userId = getUserId_Ol($comparisonValue);
$comparisonValue = getUserFullName($userId);
}
if ($fieldInstance->getFieldDataType() == 'reference') {
if (strpos($comparisonValue, '::::') > 0) {
$referenceFileValueComponents = explode('::::', $comparisonValue);
} else {
$referenceFileValueComponents = explode(':::', $comparisonValue);
}
if (count($referenceFileValueComponents) > 1) {
$comparisonValue = trim($referenceFileValueComponents[1]);
}
}
$queryGenerator->addCondition($mergeField, $comparisonValue, 'e', '', '', '', true);
}
$query = $queryGenerator->getQuery();
$duplicatesResult = $adb->query($query);
$noOfDuplicates = $adb->num_rows($duplicatesResult);
if ($noOfDuplicates > 0) {
if ($mergeType == Import_Utils_Helper::$AUTO_MERGE_IGNORE) {
$entityInfo['status'] = self::$IMPORT_RECORD_SKIPPED;
} elseif ($mergeType == Import_Utils_Helper::$AUTO_MERGE_OVERWRITE || $mergeType == Import_Utils_Helper::$AUTO_MERGE_MERGEFIELDS) {
for ($index = 0; $index < $noOfDuplicates - 1; ++$index) {
$duplicateRecordId = $adb->query_result($duplicatesResult, $index, $fieldColumnMapping['id']);
$entityId = vtws_getId($moduleObjectId, $duplicateRecordId);
vtws_delete($entityId, $this->user);
}
$baseRecordId = $adb->query_result($duplicatesResult, $noOfDuplicates - 1, $fieldColumnMapping['id']);
$baseEntityId = vtws_getId($moduleObjectId, $baseRecordId);
if ($mergeType == Import_Utils_Helper::$AUTO_MERGE_OVERWRITE) {
$fieldData = $this->transformForImport($fieldData, $moduleMeta);
$fieldData['id'] = $baseEntityId;
$entityInfo = vtws_update($fieldData, $this->user);
$entityInfo['status'] = self::$IMPORT_RECORD_UPDATED;
}
if ($mergeType == Import_Utils_Helper::$AUTO_MERGE_MERGEFIELDS) {
$filteredFieldData = array();
foreach ($fieldData as $fieldName => $fieldValue) {
// empty will give false for value = 0
if (!empty($fieldValue) || $fieldValue != "") {
$filteredFieldData[$fieldName] = $fieldValue;
//.........这里部分代码省略.........