本文整理汇总了PHP中WebserviceField::fromArray方法的典型用法代码示例。如果您正苦于以下问题:PHP WebserviceField::fromArray方法的具体用法?PHP WebserviceField::fromArray怎么用?PHP WebserviceField::fromArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebserviceField
的用法示例。
在下文中一共展示了WebserviceField::fromArray方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTableFieldList
protected function getTableFieldList($tableName)
{
$tableFieldList = array();
$factory = WebserviceField::fromArray($this->pearDB, array('tablename' => $tableName));
$dbTableFields = $factory->getTableFields();
foreach ($dbTableFields as $dbField) {
if ($dbField->primaryKey) {
if ($this->idColumn === null) {
$this->idColumn = $dbField->name;
} else {
throw new WebServiceException(WebServiceErrorCode::$UNKOWNENTITY, "Entity table with multi column primary key is not supported");
}
}
$field = $this->getFieldArrayFromDBField($dbField, $tableName);
$webserviceField = WebserviceField::fromArray($this->pearDB, $field);
$fieldDataType = $this->getFieldType($dbField, $tableName);
if ($fieldDataType === null) {
$fieldDataType = $this->getFieldDataTypeFromDBType($dbField->type);
}
$webserviceField->setFieldDataType($fieldDataType);
if (strcasecmp($fieldDataType, 'reference') === 0) {
$webserviceField->setReferenceList($this->getReferenceList($dbField, $tableName));
}
array_push($tableFieldList, $webserviceField);
}
return $tableFieldList;
}
示例2: retrieveMetaForTables
function retrieveMetaForTables()
{
$db = PearDatabase::getInstance();
foreach ($this->metaTableList as $tableName) {
$sql = "SELECT * FROM {$tableName} WHERE deleted=0";
$params = array();
$result = $db->pquery($sql, $params);
if (!empty($result)) {
$it = new SqlResultIterator($db, $result);
foreach ($it as $row) {
$fieldArray = $this->getFieldArrayFromTaxRow($row, $tableName, $this->metaTablePrefix[$tableName]);
$webserviceField = WebserviceField::fromArray($db, $fieldArray);
$webserviceField->setDefault($row->percentage);
$this->moduleFields[$webserviceField->getFieldName()] = $webserviceField;
}
}
}
}
示例3: getTableFieldList
protected function getTableFieldList($tableName)
{
$tableFieldList = array();
$factory = WebserviceField::fromArray($this->pearDB, array('tablename' => $tableName));
$dbTableFields = $factory->getTableFields();
foreach ($dbTableFields as $dbField) {
if ($dbField->primaryKey) {
if ($this->idColumn === null) {
$this->idColumn = $dbField->name;
} else {
throw new WebServiceException(WebServiceErrorCode::$UNKOWNENTITY, "Entity table with multi column primary key is not supported");
}
}
$field = $this->getFieldArrayFromDBField($dbField, $tableName);
if (preg_match('/tax\\d+/', $dbField->name) != 0) {
$taxLabel = $this->getTaxLabelFromName($dbField->name);
if (!empty($taxLabel)) {
$field['fieldlabel'] = $taxLabel;
}
}
$webserviceField = WebserviceField::fromArray($this->pearDB, $field);
$fieldDataType = $this->getFieldType($dbField, $tableName);
if ($fieldDataType === null) {
$fieldDataType = $this->getFieldDataTypeFromDBType($dbField->type);
}
$webserviceField->setFieldDataType($fieldDataType);
if (strcasecmp($fieldDataType, 'reference') === 0) {
if ($webserviceField->getFieldName() == 'parent_id') {
$webserviceField->setReferenceList(getInventoryModules());
} else {
$webserviceField->setReferenceList(array('Products', 'Services'));
}
}
array_push($tableFieldList, $webserviceField);
}
return $tableFieldList;
}
示例4: getWebserviceFieldObject
/**
* Function to get the Webservice Field Object for the current Field Object
* @return WebserviceField instance
*/
public function getWebserviceFieldObject()
{
if ($this->webserviceField == false) {
$db = PearDatabase::getInstance();
$row = array();
$row['uitype'] = $this->get('uitype');
$row['block'] = $this->get('block');
$row['tablename'] = $this->get('table');
$row['columnname'] = $this->get('column');
$row['fieldname'] = $this->get('name');
$row['fieldlabel'] = $this->get('label');
$row['displaytype'] = $this->get('displaytype');
$row['masseditable'] = $this->get('masseditable');
$row['typeofdata'] = $this->get('typeofdata');
$row['presence'] = $this->get('presence');
$row['tabid'] = $this->getModuleId();
$row['fieldid'] = $this->get('id');
$row['readonly'] = !$this->getProfileReadWritePermission();
$row['defaultvalue'] = $this->get('defaultvalue');
$this->webserviceField = WebserviceField::fromArray($db, $row);
}
return $this->webserviceField;
}
示例5: getAdvancedFilterList
function getAdvancedFilterList($reportid)
{
global $adb;
global $modules;
global $log;
global $current_user;
$advft_criteria = array();
$sql = 'SELECT * FROM vtiger_relcriteria_grouping WHERE queryid = ? ORDER BY groupid';
$groupsresult = $adb->pquery($sql, array($reportid));
$i = 1;
$j = 0;
while ($relcriteriagroup = $adb->fetch_array($groupsresult)) {
$groupId = $relcriteriagroup["groupid"];
$groupCondition = $relcriteriagroup["group_condition"];
$ssql = 'select vtiger_relcriteria.* from vtiger_report
inner join vtiger_relcriteria on vtiger_relcriteria.queryid = vtiger_report.queryid
left join vtiger_relcriteria_grouping on vtiger_relcriteria.queryid = vtiger_relcriteria_grouping.queryid
and vtiger_relcriteria.groupid = vtiger_relcriteria_grouping.groupid';
$ssql .= " where vtiger_report.reportid = ? AND vtiger_relcriteria.groupid = ? order by vtiger_relcriteria.columnindex";
$result = $adb->pquery($ssql, array($reportid, $groupId));
$noOfColumns = $adb->num_rows($result);
if ($noOfColumns <= 0) {
continue;
}
while ($relcriteriarow = $adb->fetch_array($result)) {
$columnIndex = $relcriteriarow["columnindex"];
$criteria = array();
$criteria['columnname'] = $relcriteriarow["columnname"];
$criteria['comparator'] = $relcriteriarow["comparator"];
$advfilterval = $relcriteriarow["value"];
$col = explode(":", $relcriteriarow["columnname"]);
$moduleFieldLabel = $col[2];
$fieldName = $col[3];
list($module, $fieldLabel) = explode('__', $moduleFieldLabel, 2);
$fieldInfo = getFieldByReportLabel($module, $fieldLabel);
$fieldType = null;
if (!empty($fieldInfo)) {
$field = WebserviceField::fromArray($adb, $fieldInfo);
$fieldType = $field->getFieldDataType();
}
if ($fieldType == 'currency') {
if ($field->getUIType() == '71') {
$advfilterval = CurrencyField::convertToUserFormat($advfilterval, $current_user);
} else {
if ($field->getUIType() == '72') {
$advfilterval = CurrencyField::convertToUserFormat($advfilterval, $current_user, true);
}
}
}
$temp_val = explode(",", $relcriteriarow["value"]);
if ($col[4] == 'D' || $col[4] == 'T' && $col[1] != 'time_start' && $col[1] != 'time_end' || $col[4] == 'DT') {
$val = array();
for ($x = 0; $x < count($temp_val); $x++) {
if ($col[4] == 'D') {
$date = new DateTimeField(trim($temp_val[$x]));
$val[$x] = $date->getDisplayDate();
} elseif ($col[4] == 'DT') {
$date = new DateTimeField(trim($temp_val[$x]));
$val[$x] = $date->getDisplayDateTimeValue();
} else {
$date = new DateTimeField(trim($temp_val[$x]));
$val[$x] = $date->getDisplayTime();
}
}
$advfilterval = implode(",", $val);
}
//In vtiger6 report filter conditions, if the value has "(double quotes) then it is failed.
$criteria['value'] = Vtiger_Util_Helper::toSafeHTML(decode_html($advfilterval));
$criteria['column_condition'] = $relcriteriarow["column_condition"];
$advft_criteria[$relcriteriarow['groupid']]['columns'][$j] = $criteria;
$advft_criteria[$relcriteriarow['groupid']]['condition'] = $groupCondition;
$j++;
}
$i++;
}
// Clear the condition (and/or) for last group, if any.
if (!empty($advft_criteria[$i - 1]['condition'])) {
$advft_criteria[$i - 1]['condition'] = '';
}
$this->advft_criteria = $advft_criteria;
$log->info("Reports :: Successfully returned getAdvancedFilterList");
return true;
}
示例6: getPDFMakerFieldValue
public function getPDFMakerFieldValue($report, $picklistArray, $dbField, $valueArray, $fieldName)
{
global $current_user, $default_charset;
$db = PearDatabase::getInstance();
$value = $valueArray[$fieldName];
$fld_type = $dbField->type;
list($module, $fieldLabel) = explode('_', $dbField->name, 2);
$fieldInfo = $this->getFieldByPDFMakerLabel($module, $fieldLabel);
$fieldType = null;
$fieldvalue = $value;
if (!empty($fieldInfo)) {
$field = WebserviceField::fromArray($db, $fieldInfo);
$fieldType = $field->getFieldDataType();
}
if ($fieldType == 'currency' && $value != '') {
// Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion
if ($field->getUIType() == '72') {
$curid_value = explode("::", $value);
$currency_id = $curid_value[0];
$currency_value = $curid_value[1];
$cur_sym_rate = getCurrencySymbolandCRate($currency_id);
if ($value != '') {
if ($dbField->name == 'Products_Unit_Price') {
// need to do this only for Products Unit Price
if ($currency_id != 1) {
$currency_value = (double) $cur_sym_rate['rate'] * (double) $currency_value;
}
}
$formattedCurrencyValue = CurrencyField::convertToUserFormat($currency_value, null, true);
$fieldvalue = CurrencyField::appendCurrencySymbol($formattedCurrencyValue, $cur_sym_rate['symbol']);
}
} else {
$currencyField = new CurrencyField($value);
$fieldvalue = $currencyField->getDisplayValue();
}
} elseif ($dbField->name == "PurchaseOrder_Currency" || $dbField->name == "SalesOrder_Currency" || $dbField->name == "Invoice_Currency" || $dbField->name == "Quotes_Currency" || $dbField->name == "PriceBooks_Currency") {
if ($value != '') {
$fieldvalue = getTranslatedCurrencyString($value);
}
} elseif (in_array($dbField->name, $this->ui101_fields) && !empty($value)) {
$entityNames = getEntityName('Users', $value);
$fieldvalue = $entityNames[$value];
} elseif ($fieldType == 'date' && !empty($value)) {
if ($module == 'Calendar' && $field->getFieldName() == 'due_date') {
$endTime = $valueArray['calendar_end_time'];
if (empty($endTime)) {
$recordId = $valueArray['calendar_id'];
$endTime = getSingleFieldValue('vtiger_activity', 'time_end', 'activityid', $recordId);
}
$date = new DateTimeField($value . ' ' . $endTime);
$fieldvalue = $date->getDisplayDate();
} else {
$fieldvalue = DateTimeField::convertToUserFormat($value);
}
} elseif ($fieldType == "datetime" && !empty($value)) {
$date = new DateTimeField($value);
$fieldvalue = $date->getDisplayDateTimeValue();
} elseif ($fieldType == 'time' && !empty($value) && $field->getFieldName() != 'duration_hours') {
if ($field->getFieldName() == "time_start" || $field->getFieldName() == "time_end") {
$date = new DateTimeField($value);
$fieldvalue = $date->getDisplayTime();
} else {
$fieldvalue = $value;
}
} elseif ($fieldType == "picklist" && !empty($value)) {
if (is_array($picklistArray)) {
if (is_array($picklistArray[$dbField->name]) && $field->getFieldName() != 'activitytype' && !in_array($value, $picklistArray[$dbField->name])) {
$fieldvalue = $app_strings['LBL_NOT_ACCESSIBLE'];
} else {
$fieldvalue = $this->getTranslatedString($value, $module);
}
} else {
$fieldvalue = $this->getTranslatedString($value, $module);
}
} elseif ($fieldType == "multipicklist" && !empty($value)) {
if (is_array($picklistArray[1])) {
$valueList = explode(' |##| ', $value);
$translatedValueList = array();
foreach ($valueList as $value) {
if (is_array($picklistArray[1][$dbField->name]) && !in_array($value, $picklistArray[1][$dbField->name])) {
$translatedValueList[] = $app_strings['LBL_NOT_ACCESSIBLE'];
} else {
$translatedValueList[] = $this->getTranslatedString($value, $module);
}
}
}
if (!is_array($picklistArray[1]) || !is_array($picklistArray[1][$dbField->name])) {
$fieldvalue = str_replace(' |##| ', ', ', $value);
} else {
implode(', ', $translatedValueList);
}
} elseif ($fieldType == 'double') {
if ($current_user->truncate_trailing_zeros == true) {
$fieldvalue = decimalFormat($fieldvalue);
}
}
if ($fieldvalue == "") {
return "-";
}
$fieldvalue = str_replace("<", "<", $fieldvalue);
//.........这里部分代码省略.........
示例7: getReferenceFieldColumnList
function getReferenceFieldColumnList($moduleName, $fieldInfo)
{
$adb = PearDatabase::getInstance();
$columnsSqlList = array();
$fieldInstance = WebserviceField::fromArray($adb, $fieldInfo);
$referenceModuleList = $fieldInstance->getReferenceList();
$reportSecondaryModules = explode(':', $this->secondarymodule);
if ($moduleName != $this->primarymodule && in_array($this->primarymodule, $referenceModuleList)) {
$entityTableFieldNames = getEntityFieldNames($this->primarymodule);
$entityTableName = $entityTableFieldNames['tablename'];
$entityFieldNames = $entityTableFieldNames['fieldname'];
$columnList = array();
if (is_array($entityFieldNames)) {
foreach ($entityFieldNames as $entityColumnName) {
$columnList["{$entityColumnName}"] = "{$entityTableName}.{$entityColumnName}";
}
} else {
$columnList[] = "{$entityTableName}.{$entityFieldNames}";
}
if (count($columnList) > 1) {
$columnSql = getSqlForNameInDisplayFormat($columnList, $this->primarymodule);
} else {
$columnSql = implode('', $columnList);
}
$columnsSqlList[] = $columnSql;
} else {
foreach ($referenceModuleList as $referenceModule) {
$entityTableFieldNames = getEntityFieldNames($referenceModule);
$entityTableName = $entityTableFieldNames['tablename'];
$entityFieldNames = $entityTableFieldNames['fieldname'];
$referenceTableName = '';
$dependentTableName = '';
if ($moduleName == 'HelpDesk' && $referenceModule == 'Accounts') {
$referenceTableName = 'vtiger_accountRelHelpDesk';
} elseif ($moduleName == 'HelpDesk' && $referenceModule == 'Contacts') {
$referenceTableName = 'vtiger_contactdetailsRelHelpDesk';
} elseif ($moduleName == 'HelpDesk' && $referenceModule == 'Products') {
$referenceTableName = 'vtiger_productsRel';
} elseif ($moduleName == 'HelpDesk' && $referenceModule == 'Project') {
$referenceTableName = 'vtiger_projectRelHelpDesk';
} elseif ($moduleName == 'Calendar' && $referenceModule == 'Accounts') {
$referenceTableName = 'vtiger_accountRelCalendar';
} elseif ($moduleName == 'Calendar' && $referenceModule == 'Contacts') {
$referenceTableName = 'vtiger_contactdetailsCalendar';
} elseif ($moduleName == 'Calendar' && $referenceModule == 'Leads') {
$referenceTableName = 'vtiger_leaddetailsRelCalendar';
} elseif ($moduleName == 'Calendar' && $referenceModule == 'Potentials') {
$referenceTableName = 'vtiger_potentialRelCalendar';
} elseif ($moduleName == 'Calendar' && $referenceModule == 'Invoice') {
$referenceTableName = 'vtiger_invoiceRelCalendar';
} elseif ($moduleName == 'Calendar' && $referenceModule == 'Quotes') {
$referenceTableName = 'vtiger_quotesRelCalendar';
} elseif ($moduleName == 'Calendar' && $referenceModule == 'PurchaseOrder') {
$referenceTableName = 'vtiger_purchaseorderRelCalendar';
} elseif ($moduleName == 'Calendar' && $referenceModule == 'SalesOrder') {
$referenceTableName = 'vtiger_salesorderRelCalendar';
} elseif ($moduleName == 'Calendar' && $referenceModule == 'HelpDesk') {
$referenceTableName = 'vtiger_troubleticketsRelCalendar';
} elseif ($moduleName == 'Calendar' && $referenceModule == 'Campaigns') {
$referenceTableName = 'vtiger_campaignRelCalendar';
} elseif ($moduleName == 'Contacts' && $referenceModule == 'Accounts') {
$referenceTableName = 'vtiger_accountContacts';
} elseif ($moduleName == 'Contacts' && $referenceModule == 'Contacts') {
$referenceTableName = 'vtiger_contactdetailsContacts';
} elseif ($moduleName == 'Accounts' && $referenceModule == 'Accounts') {
$referenceTableName = 'vtiger_accountAccounts';
} elseif ($moduleName == 'Campaigns' && $referenceModule == 'Products') {
$referenceTableName = 'vtiger_productsCampaigns';
} elseif ($moduleName == 'Faq' && $referenceModule == 'Products') {
$referenceTableName = 'vtiger_productsFaq';
} elseif ($moduleName == 'Invoice' && $referenceModule == 'SalesOrder') {
$referenceTableName = 'vtiger_salesorderInvoice';
} elseif ($moduleName == 'Invoice' && $referenceModule == 'Contacts') {
$referenceTableName = 'vtiger_contactdetailsInvoice';
} elseif ($moduleName == 'Invoice' && $referenceModule == 'Accounts') {
$referenceTableName = 'vtiger_accountInvoice';
} elseif ($moduleName == 'Potentials' && $referenceModule == 'Campaigns') {
$referenceTableName = 'vtiger_campaignPotentials';
} elseif ($moduleName == 'Products' && $referenceModule == 'Vendors') {
$referenceTableName = 'vtiger_vendorRelProducts';
} elseif ($moduleName == 'PurchaseOrder' && $referenceModule == 'Contacts') {
$referenceTableName = 'vtiger_contactdetailsPurchaseOrder';
} elseif ($moduleName == 'PurchaseOrder' && $referenceModule == 'Vendors') {
$referenceTableName = 'vtiger_vendorRelPurchaseOrder';
} elseif ($moduleName == 'Quotes' && $referenceModule == 'Potentials') {
$referenceTableName = 'vtiger_potentialRelQuotes';
} elseif ($moduleName == 'Quotes' && $referenceModule == 'Accounts') {
$referenceTableName = 'vtiger_accountQuotes';
} elseif ($moduleName == 'SalesOrder' && $referenceModule == 'Potentials') {
$referenceTableName = 'vtiger_potentialRelSalesOrder';
} elseif ($moduleName == 'SalesOrder' && $referenceModule == 'Accounts') {
$referenceTableName = 'vtiger_accountSalesOrder';
} elseif ($moduleName == 'SalesOrder' && $referenceModule == 'Contacts') {
$referenceTableName = 'vtiger_contactdetailsSalesOrder';
} elseif ($moduleName == 'SalesOrder' && $referenceModule == 'Quotes') {
$referenceTableName = 'vtiger_quotesSalesOrder';
} elseif ($moduleName == 'Potentials' && $referenceModule == 'Contacts') {
$referenceTableName = 'vtiger_contactdetailsPotentials';
} elseif ($moduleName == 'Potentials' && $referenceModule == 'Accounts') {
$referenceTableName = 'vtiger_accountPotentials';
//.........这里部分代码省略.........
示例8: saveAdvancedFilters
/**
* Function saves Reports Filter information
*/
function saveAdvancedFilters()
{
$db = PearDatabase::getInstance();
$reportId = $this->getId();
$advancedFilter = $this->get('advancedFilter');
if (!empty($advancedFilter)) {
$db->pquery('DELETE FROM vtiger_relcriteria WHERE queryid = ?', array($reportId));
$db->pquery('DELETE FROM vtiger_relcriteria_grouping WHERE queryid = ?', array($reportId));
foreach ($advancedFilter as $groupIndex => $groupInfo) {
if (empty($groupInfo)) {
continue;
}
$groupColumns = $groupInfo['columns'];
$groupCondition = $groupInfo['condition'];
foreach ($groupColumns as $columnIndex => $columnCondition) {
if (empty($columnCondition)) {
continue;
}
$advFilterColumn = $columnCondition["columnname"];
$advFilterComparator = $columnCondition["comparator"];
$advFilterValue = $columnCondition["value"];
$advFilterColumnCondition = $columnCondition["column_condition"];
$columnInfo = explode(":", $advFilterColumn);
$moduleFieldLabel = $columnInfo[2];
list($module, $fieldLabel) = explode('__', $moduleFieldLabel, 2);
$fieldInfo = getFieldByReportLabel($module, $fieldLabel);
$fieldType = null;
if (!empty($fieldInfo)) {
$field = WebserviceField::fromArray($db, $fieldInfo);
$fieldType = $field->getFieldDataType();
}
if ($fieldType == 'currency') {
if ($field->getUIType() == '72') {
// Some of the currency fields like Unit Price, Totoal , Sub-total - doesn't need currency conversion during save
$advFilterValue = Vtiger_Currency_UIType::convertToDBFormat($advFilterValue, null, true);
} else {
$advFilterValue = Vtiger_Currency_UIType::convertToDBFormat($advFilterValue);
}
}
$tempVal = explode(",", $advFilterValue);
if (($columnInfo[4] == 'D' || $columnInfo[4] == 'T' && $columnInfo[1] != 'time_start' && $columnInfo[1] != 'time_end' || $columnInfo[4] == 'DT') && ($columnInfo[4] != '' && $advFilterValue != '')) {
$val = array();
for ($i = 0; $i < count($tempVal); $i++) {
if (trim($tempVal[$i]) != '') {
$date = new DateTimeField(trim($tempVal[$i]));
if ($columnInfo[4] == 'D') {
$val[$i] = DateTimeField::convertToDBFormat(trim($tempVal[$i]));
} elseif ($columnInfo[4] == 'DT') {
/**
* While generating query to retrieve report, for date time fields we are only taking
* date field and appending '00:00:00' for correct results depending on time zone.
* If you save the time also here by converting to db format, while showing in edit
* view it was changing the date selected.
*/
$values = explode(' ', $tempVal[$i]);
$date = new DateTimeField($values[0]);
$val[$i] = $date->getDBInsertDateValue();
} else {
$val[$i] = $date->getDBInsertTimeValue();
}
}
}
$advFilterValue = implode(",", $val);
}
$db->pquery('INSERT INTO vtiger_relcriteria (queryid, columnindex, columnname, comparator, value,
groupid, column_condition) VALUES (?,?,?,?,?,?,?)', array($reportId, $columnIndex, $advFilterColumn, $advFilterComparator, $advFilterValue, $groupIndex, $advFilterColumnCondition));
// Update the condition expression for the group to which the condition column belongs
$groupConditionExpression = '';
if (!empty($advancedFilter[$groupIndex]["conditionexpression"])) {
$groupConditionExpression = $advancedFilter[$groupIndex]["conditionexpression"];
}
$groupConditionExpression = $groupConditionExpression . ' ' . $columnIndex . ' ' . $advFilterColumnCondition;
$advancedFilter[$groupIndex]["conditionexpression"] = $groupConditionExpression;
}
$groupConditionExpression = $advancedFilter[$groupIndex]["conditionexpression"];
if (empty($groupConditionExpression)) {
continue;
}
// Case when the group doesn't have any column criteria
$db->pquery("INSERT INTO vtiger_relcriteria_grouping(groupid, queryid, group_condition, condition_expression) VALUES (?,?,?,?)", array($groupIndex, $reportId, $groupCondition, $groupConditionExpression));
}
}
}
示例9: getReportFieldValue
/**
*
* @global Users $current_user
* @param ReportRun $report
* @param Array $picklistArray
* @param ADOFieldObject $dbField
* @param Array $valueArray
* @param String $fieldName
* @return String
*/
function getReportFieldValue($report, $picklistArray, $dbField, $valueArray, $fieldName)
{
global $current_user, $default_charset;
$db = PearDatabase::getInstance();
$value = $valueArray[$fieldName];
$fld_type = $dbField->type;
list($module, $fieldLabel) = explode('__', $dbField->name, 2);
$fieldInfo = getFieldByReportLabel($module, $fieldLabel);
$fieldType = null;
$fieldvalue = $value;
if (!empty($fieldInfo)) {
$field = WebserviceField::fromArray($db, $fieldInfo);
$fieldType = $field->getFieldDataType();
}
if ($fieldType == 'currency' && $value != '') {
// Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion
if ($field->getUIType() == '72') {
$curid_value = explode("::", $value);
$currency_id = $curid_value[0];
$currency_value = $curid_value[1];
$cur_sym_rate = getCurrencySymbolandCRate($currency_id);
if ($value != '') {
if ($dbField->name == 'Products_Unit_Price') {
// need to do this only for Products Unit Price
if ($currency_id != 1) {
$currency_value = (double) $cur_sym_rate['rate'] * (double) $currency_value;
}
}
$formattedCurrencyValue = CurrencyField::convertToUserFormat($currency_value, null, true);
$fieldvalue = CurrencyField::appendCurrencySymbol($formattedCurrencyValue, $cur_sym_rate['symbol']);
}
} else {
$currencyField = new CurrencyField($value);
$fieldvalue = $currencyField->getDisplayValue();
}
} elseif ($dbField->name == "PriceBooks_Currency") {
if ($value != '') {
$fieldvalue = getTranslatedCurrencyString($value);
}
} elseif (in_array($dbField->name, $report->ui101_fields) && !empty($value)) {
$entityNames = getEntityName('Users', $value);
$fieldvalue = $entityNames[$value];
} elseif ($fieldType == 'date' && !empty($value)) {
if ($module == 'Calendar' && $field->getFieldName() == 'due_date') {
$endTime = $valueArray['calendar_end_time'];
if (empty($endTime)) {
$recordId = $valueArray['calendar_id'];
$endTime = getSingleFieldValue('vtiger_activity', 'time_end', 'activityid', $recordId);
}
$date = new DateTimeField($value . ' ' . $endTime);
$fieldvalue = $date->getDisplayDate();
} else {
if (!($field->getUIType() == '5')) {
$date = new DateTimeField($fieldvalue);
$fieldvalue = $date->getDisplayDateTimeValue();
}
}
} elseif ($fieldType == "datetime" && !empty($value)) {
$date = new DateTimeField($value);
$fieldvalue = $date->getDisplayDateTimeValue();
} elseif ($fieldType == 'time' && !empty($value) && $field->getFieldName() != 'duration_hours') {
if ($field->getFieldName() == "time_start" || $field->getFieldName() == "time_end") {
$date = new DateTimeField($value);
$fieldvalue = $date->getDisplayTime();
} else {
$userModel = Users_Privileges_Model::getCurrentUserModel();
if ($userModel->get('hour_format') == '12') {
$value = Vtiger_Time_UIType::getTimeValueInAMorPM($value);
}
$fieldvalue = $value;
}
} elseif ($fieldType == "picklist" && !empty($value)) {
if (is_array($picklistArray)) {
if (is_array($picklistArray[$dbField->name]) && $field->getFieldName() != 'activitytype' && !in_array($value, $picklistArray[$dbField->name])) {
$fieldvalue = $app_strings['LBL_NOT_ACCESSIBLE'];
} else {
$fieldvalue = getTranslatedString($value, $module);
}
} else {
$fieldvalue = getTranslatedString($value, $module);
}
} elseif ($fieldType == "multipicklist" && !empty($value)) {
if (is_array($picklistArray[1])) {
$valueList = explode(' |##| ', $value);
$translatedValueList = array();
foreach ($valueList as $value) {
if (is_array($picklistArray[1][$dbField->name]) && !in_array($value, $picklistArray[1][$dbField->name])) {
$translatedValueList[] = $app_strings['LBL_NOT_ACCESSIBLE'];
} else {
$translatedValueList[] = getTranslatedString($value, $module);
//.........这里部分代码省略.........
示例10: explode
if (empty($column_condition)) {
continue;
}
$adv_filter_column = $column_condition["columnname"];
$adv_filter_comparator = $column_condition["comparator"];
$adv_filter_value = $column_condition["value"];
$adv_filter_column_condition = $column_condition["columncondition"];
$adv_filter_groupid = $column_condition["groupid"];
$column_info = explode(":", $adv_filter_column);
$moduleFieldLabel = $column_info[2];
$fieldName = $column_info[3];
list($module, $fieldLabel) = explode('_', $moduleFieldLabel, 2);
$fieldInfo = getFieldByReportLabel($module, $fieldLabel);
$fieldType = null;
if (!empty($fieldInfo)) {
$field = WebserviceField::fromArray($adb, $fieldInfo);
$fieldType = $field->getFieldDataType();
}
if ($fieldType == 'currency' or $fieldType == 'double') {
$flduitype = $fieldInfo['uitype'];
if ($flduitype == '72' or $flduitype == 9 or $flduitype == 7) {
$adv_filter_value = CurrencyField::convertToDBFormat($adv_filter_value, null, true);
} else {
$adv_filter_value = CurrencyField::convertToDBFormat($adv_filter_value);
}
}
$temp_val = explode(",", $adv_filter_value);
if (($column_info[4] == 'D' || $column_info[4] == 'T' && $column_info[1] != 'time_start' && $column_info[1] != 'time_end' || $column_info[4] == 'DT') && ($column_info[4] != '' && $adv_filter_value != '')) {
$val = array();
for ($x = 0; $x < count($temp_val); $x++) {
if (trim($temp_val[$x]) != '') {
示例11: saveAdvancedFilters
/**
* Function saves Reports Filter information
*/
function saveAdvancedFilters()
{
$db = PearDatabase::getInstance();
$reportId = $this->getId();
$advancedFilter = $this->get('advancedFilter');
if (!empty($advancedFilter)) {
$db->pquery('DELETE FROM vtiger_relcriteria WHERE queryid = ?', array($reportId));
$db->pquery('DELETE FROM vtiger_relcriteria_grouping WHERE queryid = ?', array($reportId));
foreach ($advancedFilter as $groupIndex => $groupInfo) {
if (empty($groupInfo)) {
continue;
}
$groupColumns = $groupInfo['columns'];
$groupCondition = $groupInfo['condition'];
foreach ($groupColumns as $columnIndex => $columnCondition) {
if (empty($columnCondition)) {
continue;
}
$advFilterColumn = $columnCondition["columnname"];
$advFilterComparator = $columnCondition["comparator"];
$advFilterValue = $columnCondition["value"];
$advFilterColumnCondition = $columnCondition["column_condition"];
$columnInfo = explode(":", $advFilterColumn);
$moduleFieldLabel = $columnInfo[2];
list($module, $fieldLabel) = explode('_', $moduleFieldLabel, 2);
$fieldInfo = getFieldByReportLabel($module, $fieldLabel);
$fieldType = null;
if (!empty($fieldInfo)) {
$field = WebserviceField::fromArray($db, $fieldInfo);
$fieldType = $field->getFieldDataType();
}
if ($fieldType == 'currency') {
if ($field->getUIType() == '71') {
$advFilterValue = Vtiger_Currency_UIType::convertToDBFormat($advFilterValue, null, true);
} else {
$advFilterValue = Vtiger_Currency_UIType::convertToDBFormat($advFilterValue);
}
}
$tempVal = explode(",", $advFilterValue);
if (($columnInfo[4] == 'D' || $columnInfo[4] == 'T' && $columnInfo[1] != 'time_start' && $columnInfo[1] != 'time_end' || $columnInfo[4] == 'DT') && ($columnInfo[4] != '' && $advFilterValue != '')) {
$val = array();
for ($i = 0; $i < count($tempVal); $i++) {
if (trim($tempVal[$i]) != '') {
$date = new DateTimeField(trim($tempVal[$i]));
if ($columnInfo[4] == 'D') {
$val[$i] = DateTimeField::convertToDBFormat(trim($tempVal[$i]));
} elseif ($columnInfo[4] == 'DT') {
$val[$i] = $date->getDBInsertDateTimeValue();
} else {
$val[$i] = $date->getDBInsertTimeValue();
}
}
}
$advFilterValue = implode(",", $val);
}
$db->pquery('INSERT INTO vtiger_relcriteria (queryid, columnindex, columnname, comparator, value,
groupid, column_condition) VALUES (?,?,?,?,?,?,?)', array($reportId, $columnIndex, $advFilterColumn, $advFilterComparator, $advFilterValue, $groupIndex, $advFilterColumnCondition));
// Update the condition expression for the group to which the condition column belongs
$groupConditionExpression = '';
if (!empty($advancedFilter[$groupIndex]["conditionexpression"])) {
$groupConditionExpression = $advancedFilter[$groupIndex]["conditionexpression"];
}
$groupConditionExpression = $groupConditionExpression . ' ' . $columnIndex . ' ' . $advFilterColumnCondition;
$advancedFilter[$groupIndex]["conditionexpression"] = $groupConditionExpression;
}
$groupConditionExpression = $advancedFilter[$groupIndex]["conditionexpression"];
if (empty($groupConditionExpression)) {
continue;
}
// Case when the group doesn't have any column criteria
$db->pquery("INSERT INTO vtiger_relcriteria_grouping(groupid, queryid, group_condition, condition_expression) VALUES (?,?,?,?)", array($groupIndex, $reportId, $groupCondition, $groupConditionExpression));
}
}
}
示例12: getReportFieldValue
/**
*
* @global Users $current_user
* @param ReportRun $report
* @param Array $picklistArray
* @param ADOFieldObject $dbField
* @param Array $valueArray
* @param String $fieldName
* @return String
*/
function getReportFieldValue($report, $picklistArray, $dbField, $valueArray, $fieldName)
{
global $current_user;
$db = PearDatabase::getInstance();
$value = $valueArray[$fieldName];
$fld_type = $dbField->type;
list($module, $fieldLabel) = explode('_', $dbField->name, 2);
$fieldInfo = getFieldByReportLabel($module, $fieldLabel);
$fieldType = null;
$fieldvalue = $value;
if (!empty($fieldInfo)) {
$field = WebserviceField::fromArray($db, $fieldInfo);
$fieldType = $field->getFieldDataType();
}
if ($fieldType == 'currency' && $value != '') {
// Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion
if ($field->getUIType() == '72') {
$curid_value = explode("::", $value);
$currency_id = $curid_value[0];
$currency_value = $curid_value[1];
$cur_sym_rate = getCurrencySymbolandCRate($currency_id);
if ($value != '') {
$formattedCurrencyValue = CurrencyField::convertToUserFormat($currency_value, null, true);
$fieldvalue = CurrencyField::appendCurrencySymbol($formattedCurrencyValue, $cur_sym_rate['symbol']);
}
} else {
$currencyField = new CurrencyField($value);
$fieldvalue = $currencyField->getDisplayValue();
}
} elseif ($dbField->name == "PurchaseOrder_Currency" || $dbField->name == "SalesOrder_Currency" || $dbField->name == "Invoice_Currency" || $dbField->name == "Quotes_Currency" || $dbField->name == "PriceBooks_Currency") {
if ($value != '') {
$fieldvalue = getTranslatedCurrencyString($value);
}
} elseif (in_array($dbField->name, $report->ui101_fields) && !empty($value)) {
if (is_numeric($value)) {
$entityNames = getEntityName('Users', $value);
$fieldvalue = $entityNames[$value];
} else {
$fieldvalue = $value;
}
} elseif ($fieldType == 'date' && !empty($value)) {
if ($module == 'Calendar' && $field->getFieldName() == 'due_date') {
$endTime = $valueArray['calendar_end_time'];
if (empty($endTime)) {
$recordId = $valueArray['calendar_id'];
$endTime = getSingleFieldValue('vtiger_activity', 'time_end', 'activityid', $recordId);
}
$date = new DateTimeField($value . ' ' . $endTime);
$fieldvalue = $date->getDisplayDate();
} else {
$fieldvalue = DateTimeField::convertToUserFormat($value);
}
} elseif ($fieldType == "datetime" && !empty($value)) {
$date = new DateTimeField($value);
$fieldvalue = $date->getDisplayDateTimeValue();
} elseif ($fieldType == 'time' && !empty($value) && $field->getFieldName() != 'duration_hours' && $field->getFieldName() != 'totaltime') {
$date = new DateTimeField($value);
$fieldvalue = $date->getDisplayTime();
} elseif ($fieldType == "picklist" && !empty($value)) {
if (is_array($picklistArray)) {
if (is_array($picklistArray[$dbField->name]) && $field->getFieldName() != 'activitytype' && !in_array($value, $picklistArray[$dbField->name])) {
$fieldvalue = $app_strings['LBL_NOT_ACCESSIBLE'];
} else {
$fieldvalue = getTranslatedString($value, $module);
}
} else {
$fieldvalue = getTranslatedString($value, $module);
}
} elseif ($fieldType == "multipicklist" && !empty($value)) {
if (is_array($picklistArray[1])) {
$valueList = explode(' |##| ', $value);
$translatedValueList = array();
foreach ($valueList as $value) {
if (is_array($picklistArray[1][$dbField->name]) && !in_array($value, $picklistArray[1][$dbField->name])) {
$translatedValueList[] = $app_strings['LBL_NOT_ACCESSIBLE'];
} else {
$translatedValueList[] = getTranslatedString($value, $module);
}
}
}
if (!is_array($picklistArray[1]) || !is_array($picklistArray[1][$dbField->name])) {
$fieldvalue = str_replace(' |##| ', ', ', $value);
} else {
implode(', ', $translatedValueList);
}
}
if ($fieldvalue == "") {
return "-";
}
$fieldvalue = str_replace("<", "<", $fieldvalue);
//.........这里部分代码省略.........
示例13: getReport
function getReport(Vtiger_Request $request)
{
$viewer = $this->getViewer($request);
$moduleName = $request->getModule();
$record = $request->get('record');
$page = $request->get('page');
//$data = $this->reportData; //TODO
$calculation = $this->calculationFields;
//if(empty($data)){
$reportModel = Reports_Record_Model::getInstanceById($record);
$reportModel->setModule('Reports');
$reportType = $reportModel->get('reporttype');
$pagingModel = new Vtiger_Paging_Model();
$pagingModel->set('page', $page);
$pagingModel->set('limit', self::REPORT_LIMIT + 1);
$reportData = $reportModel->getReportData($pagingModel);
$data = $reportData['data'];
$dataRaw = $reportData['data_raw'];
$calculation = $reportModel->getReportCalulationData();
$advFilterSql = $reportModel->getAdvancedFilterSQL();
$query = $reportModel->getReportSQL($advFilterSql, 'PDF');
$countQuery = $reportModel->generateCountQuery($query);
$this->count = $reportModel->getReportsCount($countQuery);
//}
/*готовим данные в нужный нам формат для новой таблицы*/
/*получим поле для группировки*/
global $adb;
$reportRun = ReportRun::getInstance($record);
$fieldRawArr = $reportRun->getGroupingList();
foreach ($fieldRawArr as $value) {
$fieldRaw = explode('_', $value, 2);
break;
}
$groupModule = str_replace('`', '', $fieldRaw[0]);
$groupLabel = explode(' ', $fieldRaw[1], 2);
$groupLabel = str_replace('`', '', $groupLabel[0]);
//это системное имя, нужен перевод
$fieldInfo = getFieldByReportLabel($groupModule, $groupLabel);
$fieldType = null;
if (!empty($fieldInfo)) {
$field = WebserviceField::fromArray($adb, $fieldInfo);
$fieldType = $field->getFieldDataType();
}
if (!empty($fieldInfo)) {
$translatedLabel = getTranslatedString($field->getFieldLabelKey(), $groupModule);
} else {
$translatedLabel = getTranslatedString($groupLabel, $groupModule);
$translatedLabel = str_replace("_", " ", $translatedLabel);
}
$groupLabel = $translatedLabel;
/*STRING TRANSLATION starts TODO*/
/*$moduleLabel ='';
if(in_array($module,$modules_selected))
$moduleLabel = getTranslatedString($module,$module);
if(empty($translatedLabel)) {
$translatedLabel = getTranslatedString(str_replace('_', " ",
$fld->name), $module);
}*/
/*if(!empty($this->secondarymodule)) {
if($moduleLabel != '') {
$headerLabel = $moduleLabel." ". $translatedLabel;
}
}*/
/*формируем нужный массив*/
$dataGrouped = array();
foreach ($data as $index => $row) {
$groupIndex = $row[$groupLabel];
if (!isset($dataGrouped[$groupIndex])) {
$dataGrouped[$groupIndex] = array('rows' => array(), 'summary' => array());
}
$dataGrouped[$groupIndex]['rows'][] = $row;
foreach ($row as $reportField => $value) {
$dataRawVal = explode('::', $dataRaw[$index][$reportField]);
$dataRawType = empty($dataRawVal[1]) ? 'undefined' : $dataRawVal[1];
$dataRawVal = $dataRawVal[0];
if (!isset($dataGrouped[$groupIndex]['summary'][$reportField])) {
if ($dataRawType == 'currency') {
$dataRawVal = $dataRawVal + 0;
}
if (empty($dataRawType)) {
$dataRawVal = (string) $dataRawVal;
}
$dataGrouped[$groupIndex]['summary'][$reportField] = $dataRawVal;
} elseif ($dataRawType == 'currency') {
/*можно позже добавить другие типы данных*/
$summed = $dataGrouped[$groupIndex]['summary'][$reportField] + $dataRawVal;
$dataGrouped[$groupIndex]['summary'][$reportField] = $summed;
/*todo переделать в пользовательский формат*/
}
}
}
/*end*/
/*убираем ненужные столбцы*/
$columns = array('SUM' => false, 'AVG' => false, 'MIN' => false, 'MAX' => false);
foreach ($calculation as $metriks) {
foreach ($metriks as $index => $metrik) {
$postfix = substr($index, -3, 3);
if ($columns[$postfix]) {
continue;
//.........这里部分代码省略.........
示例14: GenerateReport
//.........这里部分代码省略.........
echo "<script type='text/javascript' id='__reportrun_directoutput_recordcount_script'>\r\n\t\t\t\t\t\tif(\$('_reportrun_total')) \$('_reportrun_total').innerHTML={$noofrows};</script>";
} else {
$sHTML = '<table cellpadding="5" cellspacing="0" align="center" class="rptTable">
<tr>' . $header . '<!-- BEGIN values -->
<tr>' . $valtemplate . '</tr>
</table>';
}
//<<<<<<<<construct HTML>>>>>>>>>>>>
$return_data[] = $sHTML;
$return_data[] = $noofrows;
$return_data[] = $sSQL;
return $return_data;
}
} elseif ($outputformat == "PDF") {
$sSQL = $this->sGetSQLforReport($this->reportid, $filtersql);
$result = $adb->query($sSQL);
if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1) {
$picklistarray = $this->getAccessPickListValues();
}
if ($result) {
$y = $adb->num_fields($result);
$noofrows = $adb->num_rows($result);
$custom_field_values = $adb->fetch_array($result);
$column_definitions = $adb->getFieldsDefinition($result);
do {
$arraylists = array();
for ($i = 0; $i < $y; $i++) {
$fld = $adb->field_name($result, $i);
$fld_type = $column_definitions[$i]->type;
list($module, $fieldLabel) = explode('_', $fld->name, 2);
$fieldInfo = getFieldByReportLabel($module, $fieldLabel);
$fieldType = null;
if (!empty($fieldInfo)) {
$field = WebserviceField::fromArray($adb, $fieldInfo);
$fieldType = $field->getFieldDataType();
}
if (!empty($fieldInfo)) {
$translatedLabel = getTranslatedString($field->getFieldLabelKey(), $module);
} else {
$translatedLabel = getTranslatedString(str_replace('_', " ", $fieldLabel), $module);
}
/*STRING TRANSLATION starts */
$moduleLabel = '';
if (in_array($module, $modules_selected)) {
$moduleLabel = getTranslatedString($module, $module);
}
if (empty($translatedLabel)) {
$translatedLabel = getTranslatedString(str_replace('_', " ", $fld->name));
}
$headerLabel = $translatedLabel;
if (!empty($this->secondarymodule)) {
if ($moduleLabel != '') {
$headerLabel = $moduleLabel . " " . $translatedLabel;
}
}
// Check for role based pick list
$temp_val = $fld->name;
$fieldvalue = getReportFieldValue($this, $picklistarray, $fld, $custom_field_values, $i);
$arraylists[$headerLabel] = $fieldvalue;
}
$arr_val[] = $arraylists;
set_time_limit($php_max_execution_time);
} while ($custom_field_values = $adb->fetch_array($result));
return $arr_val;
}
} elseif ($outputformat == "TOTALXLS") {