|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Widget that displays the actual value of the team's sales. |
|
4
|
|
|
* |
|
5
|
|
|
* @copyright YetiForce S.A. |
|
6
|
|
|
* @license YetiForce Public License 5.0 (licenses/LicenseEN.txt or yetiforce.com) |
|
7
|
|
|
* @author Radosław Skrzypczak <[email protected]> |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Class to Team's actual sales widget. |
|
12
|
|
|
*/ |
|
13
|
|
|
class SSalesProcesses_ActualSalesOfTeam_Dashboard extends SSalesProcesses_TeamsEstimatedSales_Dashboard |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* Function to get search params in address listview. |
|
17
|
|
|
* |
|
18
|
|
|
* @param int $owner number id of user |
|
19
|
|
|
* @param array $time |
|
20
|
|
|
* |
|
21
|
|
|
* @return string |
|
22
|
|
|
*/ |
|
23
|
|
|
public function getSearchParams($owner, $time) |
|
24
|
|
|
{ |
|
25
|
|
|
$conditions = []; |
|
26
|
|
|
$listSearchParams = []; |
|
27
|
|
|
if (!empty($owner)) { |
|
28
|
|
|
array_push($conditions, ['assigned_user_id', 'e', $owner]); |
|
29
|
|
|
} |
|
30
|
|
|
if (!empty($time)) { |
|
31
|
|
|
array_push($conditions, ['actual_date', 'bw', implode(',', $time)]); |
|
32
|
|
|
} |
|
33
|
|
|
$listSearchParams[] = $conditions; |
|
34
|
|
|
|
|
35
|
|
|
return '&viewname=All&search_params=' . urlencode(json_encode($listSearchParams)); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** {@inheritdoc} */ |
|
39
|
|
|
public function getQuery(array $time, $owner = false): App\QueryGenerator |
|
40
|
|
|
{ |
|
41
|
|
|
$sum = new \yii\db\Expression('SUM(actual_sale)'); |
|
42
|
|
|
$queryGenerator = new \App\QueryGenerator('SSalesProcesses'); |
|
43
|
|
|
$queryGenerator->setFields(['assigned_user_id']) |
|
44
|
|
|
->setCustomColumn(['estimated' => $sum]) |
|
45
|
|
|
->setGroup('assigned_user_id') |
|
46
|
|
|
->addCondition('actual_date', implode(',', $time), 'bw'); |
|
47
|
|
|
if ('all' !== $owner) { |
|
48
|
|
|
$queryGenerator->addNativeCondition(['smownerid' => $owner]); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
return $queryGenerator; |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|