Merge branch 'master' of ssh://172.20.0.1/var/git/espo/backend
This commit is contained in:
@@ -53,7 +53,8 @@ class Currency extends \Espo\Core\Utils\Database\Orm\Base
|
||||
"<=" => Util::toUnderScore($entityName) . "." . $currencyColumnName . " * {$alias}.rate <= {value}",
|
||||
"<>" => Util::toUnderScore($entityName) . "." . $currencyColumnName . " * {$alias}.rate <> {value}"
|
||||
),
|
||||
'notStorable' => true
|
||||
'notStorable' => true,
|
||||
'orderBy' => $converedFieldName . " {direction}"
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -41,7 +41,7 @@ return array (
|
||||
'weekStart' => 0,
|
||||
'thousandSeparator' => ',',
|
||||
'decimalMark' => '.',
|
||||
'exportDelimiter' => ',',
|
||||
'exportDelimiter' => ';',
|
||||
'currencyList' =>
|
||||
array (
|
||||
),
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
"closeDate": "Close Date",
|
||||
"contacts": "Contacts",
|
||||
"description": "Description",
|
||||
"amountConverted": "Amount (converted)"
|
||||
"amountConverted": "Amount (converted)",
|
||||
"amountWeightedConverted": "Amount Weighted"
|
||||
},
|
||||
"links": {
|
||||
"contacts": "Contacts",
|
||||
|
||||
@@ -11,7 +11,23 @@
|
||||
},
|
||||
"amountConverted": {
|
||||
"type": "currencyConverted",
|
||||
"readOnly": true
|
||||
"readOnly": true
|
||||
},
|
||||
"amountWeightedConverted": {
|
||||
"type": "float",
|
||||
"readOnly": true,
|
||||
"notStorable": true,
|
||||
"select": "opportunity.amount * amount_currency_alias.rate * opportunity.probability / 100",
|
||||
"where": {
|
||||
"=": "(opportunity.amount * amount_currency_alias.rate * opportunity.probability / 100) = {value}",
|
||||
"<": "(opportunity.amount * amount_currency_alias.rate * opportunity.probability / 100) < {value}",
|
||||
">": "(opportunity.amount * amount_currency_alias.rate * opportunity.probability / 100) > {value}",
|
||||
"<=": "(opportunity.amount * amount_currency_alias.rate * opportunity.probability / 100) <= {value}",
|
||||
">=": "(opportunity.amount * amount_currency_alias.rate * opportunity.probability / 100) >= {value}",
|
||||
"<>": "(opportunity.amount * amount_currency_alias.rate * opportunity.probability / 100) <> {value}"
|
||||
},
|
||||
"orderBy": "amountWeightedConverted {direction}",
|
||||
"view": "Fields.CurrencyConverted"
|
||||
},
|
||||
"account": {
|
||||
"type": "link",
|
||||
|
||||
@@ -104,7 +104,7 @@ class Query
|
||||
}
|
||||
|
||||
if (empty($params['aggregation'])) {
|
||||
$selectPart = $this->getSelect($entity, $params['select']);
|
||||
$selectPart = $this->getSelect($entity, $params['select'], $params['distinct']);
|
||||
$orderPart = $this->getOrder($entity, $params['orderBy'], $params['order']);
|
||||
|
||||
if (!empty($params['additionalColumns']) && is_array($params['additionalColumns']) && !empty($params['relationName'])) {
|
||||
@@ -179,7 +179,7 @@ class Query
|
||||
}
|
||||
}
|
||||
|
||||
protected function getFunctionPart($function, $part)
|
||||
protected function getFunctionPart($function, $part, $entityName, $distinct = false)
|
||||
{
|
||||
switch ($function) {
|
||||
case 'MONTH':
|
||||
@@ -187,11 +187,19 @@ class Query
|
||||
case 'DAY':
|
||||
return "DATE_FORMAT({$part}, '%Y-%m-%d')";
|
||||
}
|
||||
if ($distinct) {
|
||||
$idPart = $this->toDb($entityName) . ".id";
|
||||
switch ($function) {
|
||||
case 'SUM':
|
||||
case 'COUNT':
|
||||
return $function . "({$part}) * COUNT(DISTINCT {$idPart}) / COUNT({$idPart})";
|
||||
}
|
||||
}
|
||||
return $function . '(' . $part . ')';
|
||||
}
|
||||
|
||||
|
||||
protected function convertComplexExpression($entity, $field, $entityName = null)
|
||||
protected function convertComplexExpression($entity, $field, $entityName = null, $distinct = false)
|
||||
{
|
||||
$function = null;
|
||||
$relName = null;
|
||||
@@ -216,12 +224,12 @@ class Query
|
||||
}
|
||||
}
|
||||
if ($function) {
|
||||
$part = $this->getFunctionPart(strtoupper($function), $part);
|
||||
$part = $this->getFunctionPart(strtoupper($function), $part, $entityName, $distinct);
|
||||
}
|
||||
return $part;
|
||||
}
|
||||
|
||||
protected function getSelect(IEntity $entity, $fields = null)
|
||||
protected function getSelect(IEntity $entity, $fields = null, $distinct = false)
|
||||
{
|
||||
$select = "";
|
||||
$arr = array();
|
||||
@@ -237,7 +245,7 @@ class Query
|
||||
if (array_key_exists($field, $entity->fields)) {
|
||||
$fieldDefs = $entity->fields[$field];
|
||||
} else {
|
||||
$part = $this->convertComplexExpression($entity, $field, $entity->getEntityName());
|
||||
$part = $this->convertComplexExpression($entity, $field, $entity->getEntityName(), $distinct);
|
||||
$arr[] = $part . ' AS `' . $field . '`';
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,16 @@
|
||||
Espo.define('Views.Fields.CurrencyConverted', 'Views.Fields.Float', function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
detailTemplate: 'fields.currency.detail',
|
||||
|
||||
listTemplate: 'fields.currency.detail',
|
||||
|
||||
data: function () {
|
||||
return _.extend({
|
||||
currencyValue: this.getConfig().get('baseCurrency'),
|
||||
}, Dep.prototype.data.call(this));
|
||||
},
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
|
||||
<meta content="utf-8" http-equiv="encoding">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<meta name="description" content="EspoCRM is Open Source CRM application. Increase profitability through customer loyalty!">
|
||||
|
||||
<link rel="icon" href="client/img/favicon.ico" type="image/x-icon">
|
||||
<link rel="shortcut icon" href="client/img/favicon.ico" type="image/x-icon">
|
||||
<script type="text/javascript">
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
|
||||
<meta content="utf-8" http-equiv="encoding">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<meta name="description" content="EspoCRM is Open Source CRM application. Increase profitability through customer loyalty!">
|
||||
|
||||
<script type="text/javascript" src="client/lib/jquery-2.0.2.min.js"></script>
|
||||
<script type="text/javascript" src="client/lib/underscore-min.js"></script>
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "espocrm",
|
||||
"version": "2.5.2",
|
||||
"version": "2.6.0",
|
||||
"description": "",
|
||||
"main": "index.php",
|
||||
"repository": "",
|
||||
|
||||
Reference in New Issue
Block a user