本文整理汇总了PHP中WebserviceField类的典型用法代码示例。如果您正苦于以下问题:PHP WebserviceField类的具体用法?PHP WebserviceField怎么用?PHP WebserviceField使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WebserviceField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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]) != '') {
示例5: getConditionValue
/**
*
* @param mixed $value
* @param String $operator
* @param WebserviceField $field
*/
private function getConditionValue($value, $operator, $field)
{
$operator = strtolower($operator);
$db = PearDatabase::getInstance();
$inEqualityFieldTypes = ['currency', 'percentage', 'double', 'integer', 'number'];
if (is_string($value) && $this->ignoreComma == false) {
$commaSeparatedFieldTypes = array('picklist', 'multipicklist', 'owner', 'date', 'datetime', 'time', 'tree');
if (in_array($field->getFieldDataType(), $commaSeparatedFieldTypes)) {
$valueArray = explode(',', $value);
if ($field->getFieldDataType() == 'multipicklist' && in_array($operator, array('e', 'n'))) {
$valueArray = getCombinations($valueArray);
foreach ($valueArray as $key => $value) {
$valueArray[$key] = ltrim($value, ' |##| ');
}
}
} else {
$valueArray = array($value);
}
} elseif (is_array($value)) {
$valueArray = $value;
} else {
$valueArray = array($value);
}
$sql = array();
if ($operator == 'between' || $operator == 'bw' || $operator == 'notequal') {
if ($field->getFieldName() == 'birthday') {
$valueArray[0] = getValidDBInsertDateTimeValue($valueArray[0]);
$valueArray[1] = getValidDBInsertDateTimeValue($valueArray[1]);
$sql[] = "BETWEEN DATE_FORMAT(" . $db->quote($valueArray[0]) . ", '%m%d') AND " . "DATE_FORMAT(" . $db->quote($valueArray[1]) . ", '%m%d')";
} else {
if ($this->isDateType($field->getFieldDataType())) {
$start = explode(' ', $valueArray[0]);
$end = explode(' ', $valueArray[1]);
if ($operator == 'between' && count($start) == 2 && count($end) == 2) {
$valueArray[0] = getValidDBInsertDateTimeValue($start[0] . ' ' . $start[1]);
if ($start[0] == $end[0]) {
$dateTime = new DateTime($valueArray[0]);
$nextDay = $dateTime->modify('+1 days');
$nextDay = strtotime($nextDay->format('Y-m-d H:i:s')) - 1;
$nextDay = date('Y-m-d H:i:s', $nextDay);
$values = explode(' ', $nextDay);
$valueArray[1] = getValidDBInsertDateTimeValue($values[0]) . ' ' . $values[1];
} else {
$end = $valueArray[1];
$dateObject = new DateTimeField($end);
$valueArray[1] = $dateObject->getDBInsertDateTimeValue();
}
} else {
$valueArray[0] = getValidDBInsertDateTimeValue($valueArray[0]);
$dateTimeStart = explode(' ', $valueArray[0]);
if ($dateTimeStart[1] == '00:00:00' && $operator != 'between') {
$valueArray[0] = $dateTimeStart[0];
}
$valueArray[1] = getValidDBInsertDateTimeValue($valueArray[1]);
$dateTimeEnd = explode(' ', $valueArray[1]);
if ($dateTimeEnd[1] == '00:00:00' || $dateTimeEnd[1] == '23:59:59') {
$valueArray[1] = $dateTimeEnd[0];
}
}
}
if ($operator == 'notequal') {
$sql[] = "NOT BETWEEN " . $db->quote($valueArray[0]) . " AND " . $db->quote($valueArray[1]);
} else {
$sql[] = "BETWEEN " . $db->quote($valueArray[0]) . " AND " . $db->quote($valueArray[1]);
}
}
return $sql;
}
foreach ($valueArray as $value) {
if (!$this->isStringType($field->getFieldDataType())) {
$value = trim($value);
}
if ($operator == 'empty' || $operator == 'y') {
$sql[] = sprintf("IS NULL OR %s = ''", $this->getSQLColumn($field->getFieldName()));
continue;
}
if ($operator == 'ny') {
$sql[] = sprintf("IS NOT NULL AND %s != ''", $this->getSQLColumn($field->getFieldName()));
continue;
}
if (strtolower(trim($value)) == 'null' || trim($value) == '' && !$this->isStringType($field->getFieldDataType()) && ($operator == 'e' || $operator == 'n')) {
if ($operator == 'e') {
$sql[] = "IS NULL";
continue;
}
$sql[] = "IS NOT NULL";
continue;
} elseif ($field->getFieldDataType() == 'boolean') {
$value = strtolower($value);
if ($value == 'yes') {
$value = 1;
} elseif ($value == 'no') {
$value = 0;
}
//.........这里部分代码省略.........
示例6: 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';
//.........这里部分代码省略.........
示例7: 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);
//.........这里部分代码省略.........
示例8: 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);
//.........这里部分代码省略.........
示例9: 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;
//.........这里部分代码省略.........
示例10: 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));
}
}
}
示例11: initialize
function initialize()
{
global $adb, $current_user;
if ($this->moduleMeta === null) {
$moduleHandler = vtws_getModuleHandlerFromName($this->parent->getModuleName(), $current_user);
$this->moduleMeta = $moduleHandler->getMeta();
}
if ($this->parent->getModuleName() == 'Products' and $this->parent->getFieldName() == 'imagename') {
$sql = "select *, '0' as readonly from vtiger_field where vtiger_field.tabid=14 and fieldname='imagename'";
$result = $adb->pquery($sql, array());
$webserviceField = WebserviceField::fromQueryResult($adb, $result, 0);
$this->fieldInfo = $webserviceField;
} else {
$moduleFields = $this->moduleMeta->getModuleFields();
$this->fieldInfo = $moduleFields[$this->parent->getFieldName()];
}
}
示例12: 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;
}
示例13: getConditionValue
/**
*
* @param mixed $value
* @param String $operator
* @param WebserviceField $field
*/
private function getConditionValue($value, $operator, $field)
{
$operator = strtolower($operator);
$db = PearDatabase::getInstance();
if (is_string($value) && $this->ignoreComma == false) {
$valueArray = explode(',', $value);
if ($field->getFieldDataType() == 'multipicklist' && in_array($operator, array('e', 'n'))) {
$valueArray = getCombinations($valueArray);
foreach ($valueArray as $key => $value) {
$valueArray[$key] = ltrim($value, ' |##| ');
}
}
} elseif (is_array($value)) {
$valueArray = $value;
} else {
$valueArray = array($value);
}
$sql = array();
if ($operator == 'between' || $operator == 'bw' || $operator == 'notequal') {
if ($field->getFieldName() == 'birthday') {
$valueArray[0] = getValidDBInsertDateTimeValue($valueArray[0]);
$valueArray[1] = getValidDBInsertDateTimeValue($valueArray[1]);
$sql[] = "BETWEEN DATE_FORMAT(" . $db->quote($valueArray[0]) . ", '%m%d') AND " . "DATE_FORMAT(" . $db->quote($valueArray[1]) . ", '%m%d')";
} else {
if ($this->isDateType($field->getFieldDataType())) {
$valueArray[0] = getValidDBInsertDateTimeValue($valueArray[0]);
$dateTimeStart = explode(' ', $valueArray[0]);
if ($dateTimeStart[1] == '00:00:00' && $operator != 'between') {
$valueArray[0] = $dateTimeStart[0];
}
$valueArray[1] = getValidDBInsertDateTimeValue($valueArray[1]);
$dateTimeEnd = explode(' ', $valueArray[1]);
if ($dateTimeEnd[1] == '00:00:00') {
$valueArray[1] = $dateTimeEnd[0];
}
}
if ($operator == 'notequal') {
$sql[] = "NOT BETWEEN " . $db->quote($valueArray[0]) . " AND " . $db->quote($valueArray[1]);
} else {
$sql[] = "BETWEEN " . $db->quote($valueArray[0]) . " AND " . $db->quote($valueArray[1]);
}
}
return $sql;
}
foreach ($valueArray as $value) {
if (!$this->isStringType($field->getFieldDataType())) {
$value = trim($value);
}
if ($operator == 'empty' || $operator == 'y') {
$sql[] = sprintf("IS NULL OR %s = ''", $this->getSQLColumn($field->getFieldName()));
continue;
}
if (strtolower(trim($value)) == 'null' || trim($value) == '' && !$this->isStringType($field->getFieldDataType()) && ($operator == 'e' || $operator == 'n')) {
if ($operator == 'e') {
$sql[] = "IS NULL";
continue;
}
$sql[] = "IS NOT NULL";
continue;
} elseif ($field->getFieldDataType() == 'boolean') {
$value = strtolower($value);
if ($value == 'yes') {
$value = 1;
} elseif ($value == 'no') {
$value = 0;
}
} elseif ($this->isDateType($field->getFieldDataType())) {
$value = getValidDBInsertDateTimeValue($value);
$dateTime = explode(' ', $value);
if ($dateTime[1] == '00:00:00') {
$value = $dateTime[0];
}
}
if ($field->getFieldName() == 'birthday' && !$this->isRelativeSearchOperators($operator)) {
$value = "DATE_FORMAT(" . $db->quote($value) . ", '%m%d')";
} else {
$value = $db->sql_escape_string($value);
}
if (trim($value) == '' && ($operator == 's' || $operator == 'ew' || $operator == 'c') && ($this->isStringType($field->getFieldDataType()) || $field->getFieldDataType() == 'picklist' || $field->getFieldDataType() == 'multipicklist')) {
$sql[] = "LIKE ''";
continue;
}
if (trim($value) == '' && $operator == 'k' && $this->isStringType($field->getFieldDataType())) {
$sql[] = "NOT LIKE ''";
continue;
}
switch ($operator) {
case 'e':
$sqlOperator = "=";
break;
case 'n':
$sqlOperator = "<>";
break;
case 's':
//.........这里部分代码省略.........
示例14: 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));
}
}
}
示例15: 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);
//.........这里部分代码省略.........