@@ -20,9 +20,10 @@ class CreateReportJob extends BaseObject implements RetryableJobInterface
20
20
const TTR = 600 ; // in seconds
21
21
22
22
/**
23
- * @var int $customer
23
+ * @var int[] $customer_ids array of customer IDs.
24
+ * Limits the orders to one or more customers.
24
25
*/
25
- public int $ customer ;
26
+ public array $ customer_ids ;
26
27
27
28
/**
28
29
* @var int $userId
@@ -50,9 +51,10 @@ class CreateReportJob extends BaseObject implements RetryableJobInterface
50
51
public bool $ items ;
51
52
52
53
/**
53
- * @var array if set, the report will be generated on order numbers instead of date range.
54
+ * @var array|null if set, the report will be generated on order numbers instead of date range.
54
55
*/
55
- public array $ order_nrs ;
56
+ public ?array $ order_nrs = null ;
57
+
56
58
57
59
/**
58
60
* @inheritDoc
@@ -97,9 +99,10 @@ protected function processReport(): string
97
99
if (is_array ($ this ->order_nrs )) {
98
100
$ ordersQuery ->where (['customer_reference ' => $ this ->order_nrs ]);
99
101
} else {
100
- $ ordersQuery ->where (['customer_id ' => $ this ->customer ]);
101
- $ ordersQuery ->andWhere (['between ' , 'created_date ' , $ this ->start_date , $ this ->end_date ])
102
+ $ ordersQuery ->andWhere (['between ' , 'created_date ' , $ this ->start_date , $ this ->end_date ]);
102
103
}
104
+ // limit access by customer
105
+ $ ordersQuery ->andWhere (['IN ' , 'customer_id ' , $ this ->customer_ids ]);
103
106
104
107
105
108
$ dir = Yii::getAlias ('@console ' ) . '/runtime/reports/ ' ;
0 commit comments