@@ -16,7 +16,7 @@ |
||
16 | 16 | return $this->createQueryBuilder('o') |
17 | 17 | ->select('o.id, o.number') |
18 | 18 | ->andWhere('o.number LIKE :number') |
19 | - ->setParameter('number', '%' . $number . '%') |
|
19 | + ->setParameter('number', '%'.$number.'%') |
|
20 | 20 | ->getQuery() |
21 | 21 | ->getArrayResult() |
22 | 22 | ; |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $labels = []; |
64 | 64 | foreach ($labelsAux as $label) |
65 | 65 | { |
66 | - if(!in_array($label, ['MonthDate', 'YearDate', 'DateDate'])) |
|
66 | + if (!in_array($label, ['MonthDate', 'YearDate', 'DateDate'])) |
|
67 | 67 | { |
68 | 68 | $labels[] = $label; |
69 | 69 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | $labels = []; |
86 | 86 | foreach ($labelsAux as $label) |
87 | 87 | { |
88 | - if(!in_array($label, ['MonthDate', 'YearDate', 'DateDate'])) |
|
88 | + if (!in_array($label, ['MonthDate', 'YearDate', 'DateDate'])) |
|
89 | 89 | { |
90 | 90 | $labels[] = preg_replace('/(?!^)[A-Z]{2,}(?=[A-Z][a-z])|[A-Z][a-z]/', ' $0', $label); |
91 | 91 | } |
@@ -158,21 +158,21 @@ discard block |
||
158 | 158 | } |
159 | 159 | $labels = array_keys($datas[0]); |
160 | 160 | $datesMedia = []; |
161 | - foreach($datas as $data) |
|
161 | + foreach ($datas as $data) |
|
162 | 162 | { |
163 | 163 | $date = new \DateTime($data[$labels[0]]); |
164 | 164 | $dateFormated = $date->format($configuration['timePeriod']['presentationFormat']); |
165 | - $currentDateMedia = isset($datesMedia[$dateFormated])?$datesMedia[$dateFormated]:array('quantity' => 0, 'media' => 0); |
|
166 | - $currentDateMedia['quantity'] = $currentDateMedia['quantity']+1; |
|
167 | - $currentDateMedia['media'] = $currentDateMedia['media']+$data[$labels[1]]; |
|
165 | + $currentDateMedia = isset($datesMedia[$dateFormated]) ? $datesMedia[$dateFormated] : array('quantity' => 0, 'media' => 0); |
|
166 | + $currentDateMedia['quantity'] = $currentDateMedia['quantity'] + 1; |
|
167 | + $currentDateMedia['media'] = $currentDateMedia['media'] + $data[$labels[1]]; |
|
168 | 168 | $datesMedia[$dateFormated] = $currentDateMedia; |
169 | 169 | } |
170 | 170 | $fetched = []; |
171 | - foreach($datesMedia as $date => $dateMedia) |
|
171 | + foreach ($datesMedia as $date => $dateMedia) |
|
172 | 172 | { |
173 | 173 | $fetched[] = [ |
174 | 174 | $labels[0] => $date, |
175 | - $labels[1] => round($dateMedia['media']/$dateMedia['quantity'], 1) |
|
175 | + $labels[1] => round($dateMedia['media'] / $dateMedia['quantity'], 1) |
|
176 | 176 | ]; |
177 | 177 | } |
178 | 178 | return $fetched; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | if ($configuration->isHtmlRequest()) { |
60 | 60 | $view |
61 | - ->setTemplate($configuration->getTemplate(ResourceActions::SHOW . '.html')) |
|
61 | + ->setTemplate($configuration->getTemplate(ResourceActions::SHOW.'.html')) |
|
62 | 62 | ->setTemplateVar($this->metadata->getName()) |
63 | 63 | ->setData([ |
64 | 64 | 'configuration' => $configuration, |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | $configuration = $request->get('configuration'); |
93 | 93 | $currencyProvider = $this->get('sylius.currency_provider'); |
94 | 94 | |
95 | - if(isset($configuration['timePeriod'])) |
|
95 | + if (isset($configuration['timePeriod'])) |
|
96 | 96 | { |
97 | 97 | $configuration['timePeriod']['start'] = new \DateTime($configuration['timePeriod']['start']['date'], new \DateTimeZone($configuration['timePeriod']['start']['timezone'])); |
98 | 98 | $configuration['timePeriod']['end'] = new \DateTime($configuration['timePeriod']['end']['date'], new \DateTimeZone($configuration['timePeriod']['end']['timezone'])); |
@@ -191,13 +191,13 @@ discard block |
||
191 | 191 | $responseData = []; |
192 | 192 | foreach ($data->getData() as $key => $value) |
193 | 193 | { |
194 | - if(is_array($value)) |
|
194 | + if (is_array($value)) |
|
195 | 195 | { |
196 | 196 | foreach ($value as $k => $v) |
197 | 197 | { |
198 | 198 | $responseData[] = [$k, $v]; |
199 | 199 | } |
200 | - }else { |
|
200 | + } else { |
|
201 | 201 | $responseData[] = [$key, $value]; |
202 | 202 | } |
203 | 203 | } |
@@ -197,7 +197,7 @@ |
||
197 | 197 | { |
198 | 198 | $responseData[] = [$k, $v]; |
199 | 199 | } |
200 | - }else { |
|
200 | + } else { |
|
201 | 201 | $responseData[] = [$key, $value]; |
202 | 202 | } |
203 | 203 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $selectPeriod = ''; |
70 | 70 | $selectGroupBy = ''; |
71 | 71 | foreach ($configuration['groupBy'] as $groupByElement) { |
72 | - if(strlen($selectPeriod) > 0) { |
|
72 | + if (strlen($selectPeriod) > 0) { |
|
73 | 73 | $selectPeriod .= ', '; |
74 | 74 | $selectGroupBy .= ','; |
75 | 75 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function addLeftJoin($join, $alias): string |
92 | 92 | { |
93 | - if(!isset($this->joins[$join])) { |
|
93 | + if (!isset($this->joins[$join])) { |
|
94 | 94 | $this->joins[$join] = $alias; |
95 | 95 | |
96 | 96 | $this->qb->leftJoin($join, $alias); |
@@ -136,19 +136,19 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public function addChannel(array $configuration = [], $field = null): void |
138 | 138 | { |
139 | - if(isset($configuration['channel']) && $configuration['channel'] != null) { |
|
139 | + if (isset($configuration['channel']) && $configuration['channel'] != null) { |
|
140 | 140 | $storeIds = []; |
141 | 141 | |
142 | - if($configuration['channel'] instanceof ChannelInterface) { |
|
142 | + if ($configuration['channel'] instanceof ChannelInterface) { |
|
143 | 143 | $storeIds[] = $configuration['channel']->getId(); |
144 | - }else if(is_array($configuration['channel']) && !in_array(0, $configuration['channel'])) { |
|
144 | + } else if (is_array($configuration['channel']) && !in_array(0, $configuration['channel'])) { |
|
145 | 145 | $storeIds = $configuration['channel']; |
146 | 146 | } |
147 | 147 | |
148 | - if(!(count($storeIds) > 0)) |
|
148 | + if (!(count($storeIds) > 0)) |
|
149 | 149 | return; |
150 | 150 | |
151 | - if(!$field) { |
|
151 | + if (!$field) { |
|
152 | 152 | $alias = $this->qb->getRootAliases()[0]; |
153 | 153 | $field = $alias.'.channel'; |
154 | 154 | } |
@@ -164,10 +164,10 @@ discard block |
||
164 | 164 | */ |
165 | 165 | public function addUserGender(array $configuration = []): void |
166 | 166 | { |
167 | - if(isset($configuration['userGender']) && $configuration['userGender'] != null) { |
|
167 | + if (isset($configuration['userGender']) && $configuration['userGender'] != null) { |
|
168 | 168 | $rootAlias = $cAlias = $this->qb->getRootAliases()[0]; |
169 | 169 | |
170 | - if(!$this->hasRootEntity(Customer::class)) |
|
170 | + if (!$this->hasRootEntity(Customer::class)) |
|
171 | 171 | $cAlias = $this->addLeftJoin($rootAlias.'.customer', 'c'); |
172 | 172 | |
173 | 173 | $this->qb |
@@ -181,20 +181,20 @@ discard block |
||
181 | 181 | */ |
182 | 182 | public function addUserBuyer(array $configuration = []): void |
183 | 183 | { |
184 | - if(isset($configuration['userBuyer']) && $configuration['userBuyer'] != null && $configuration['userBuyer'] != 'both') { |
|
184 | + if (isset($configuration['userBuyer']) && $configuration['userBuyer'] != null && $configuration['userBuyer'] != 'both') { |
|
185 | 185 | $rootAlias = $this->qb->getRootAliases()[0]; |
186 | 186 | |
187 | - if(!$this->hasRootEntity(Customer::class)) |
|
187 | + if (!$this->hasRootEntity(Customer::class)) |
|
188 | 188 | $this->addLeftJoin($rootAlias.'.customer', 'c'); |
189 | 189 | |
190 | 190 | $oAlias = $this->addLeftJoin('c.orders', 'o'); |
191 | 191 | |
192 | - if($configuration['userBuyer'] == 'yes') { |
|
192 | + if ($configuration['userBuyer'] == 'yes') { |
|
193 | 193 | $this->qb |
194 | 194 | ->andWhere($this->qb->expr()->isNotNull($oAlias.'.checkoutCompletedAt')) |
195 | 195 | ->andWhere($oAlias.'.itemsTotal > 0') |
196 | 196 | ; |
197 | - }else { |
|
197 | + } else { |
|
198 | 198 | $this->qb |
199 | 199 | ->andWhere($this->qb->expr()->isNull($oAlias.'.checkoutCompletedAt')) |
200 | 200 | ; |
@@ -209,10 +209,10 @@ discard block |
||
209 | 209 | public function addUserCountry(array $configuration = [], string $addressType = 'shipping'): void |
210 | 210 | { |
211 | 211 | $type = 'user'.ucfirst($addressType).'Country'; |
212 | - if(isset($configuration[$type]) && $configuration[$type] != null) { |
|
212 | + if (isset($configuration[$type]) && $configuration[$type] != null) { |
|
213 | 213 | $rootAlias = $cAlias = $this->qb->getRootAliases()[0]; |
214 | 214 | |
215 | - if(!$this->hasRootEntity(Customer::class)) |
|
215 | + if (!$this->hasRootEntity(Customer::class)) |
|
216 | 216 | $cAlias = $this->addLeftJoin($rootAlias.'.customer', 'c'); |
217 | 217 | |
218 | 218 | $caAlias = $this->addLeftJoin($cAlias.'.addresses', 'c'.substr($addressType, 0, 1).'a'); |
@@ -230,10 +230,10 @@ discard block |
||
230 | 230 | public function addUserProvince(array $configuration = [], string $addressType = 'shipping'): void |
231 | 231 | { |
232 | 232 | $type = 'user'.ucfirst($addressType).'Province'; |
233 | - if(isset($configuration[$type]) && $configuration[$type] != null) { |
|
233 | + if (isset($configuration[$type]) && $configuration[$type] != null) { |
|
234 | 234 | $rootAlias = $cAlias = $this->qb->getRootAliases()[0]; |
235 | 235 | |
236 | - if(!$this->hasRootEntity(Customer::class)) |
|
236 | + if (!$this->hasRootEntity(Customer::class)) |
|
237 | 237 | $cAlias = $this->addLeftJoin($rootAlias.'.customer', 'c'); |
238 | 238 | |
239 | 239 | $caAlias = $this->addLeftJoin($cAlias.'.addresses', 'c'.substr($addressType, 0, 1).'a'); |
@@ -251,10 +251,10 @@ discard block |
||
251 | 251 | public function addUserCity(array $configuration = [], string $addressType = 'shipping'): void |
252 | 252 | { |
253 | 253 | $type = 'user'.ucfirst($addressType).'City'; |
254 | - if(isset($configuration[$type]) && $configuration[$type] != null) { |
|
254 | + if (isset($configuration[$type]) && $configuration[$type] != null) { |
|
255 | 255 | $rootAlias = $cAlias = $this->qb->getRootAliases()[0]; |
256 | 256 | |
257 | - if(!$this->hasRootEntity(Customer::class)) |
|
257 | + if (!$this->hasRootEntity(Customer::class)) |
|
258 | 258 | $cAlias = $this->addLeftJoin($rootAlias.'.customer', 'c'); |
259 | 259 | |
260 | 260 | $caAlias = $this->addLeftJoin($cAlias.'.addresses', 'c'.substr($addressType, 0, 1).'a'); |
@@ -272,10 +272,10 @@ discard block |
||
272 | 272 | public function addUserPostcode(array $configuration = [], string $addressType = 'shipping'): void |
273 | 273 | { |
274 | 274 | $type = 'user'.ucfirst($addressType).'Postcode'; |
275 | - if(isset($configuration[$type]) && $configuration[$type] != null) { |
|
275 | + if (isset($configuration[$type]) && $configuration[$type] != null) { |
|
276 | 276 | $rootAlias = $cAlias = $this->qb->getRootAliases()[0]; |
277 | 277 | |
278 | - if(!$this->hasRootEntity(Customer::class)) |
|
278 | + if (!$this->hasRootEntity(Customer::class)) |
|
279 | 279 | $cAlias = $this->addLeftJoin($rootAlias.'.customer', 'c'); |
280 | 280 | |
281 | 281 | $caAlias = $this->addLeftJoin($cAlias.'.addresses', 'c'.substr($addressType, 0, 1).'2a'); |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | */ |
293 | 293 | public function addProduct(array $configuration = [], string $field = 'p.id'): void |
294 | 294 | { |
295 | - if(isset($configuration['product']) && $configuration['product'] != null) { |
|
295 | + if (isset($configuration['product']) && $configuration['product'] != null) { |
|
296 | 296 | $this->qb |
297 | 297 | ->andWhere($this->qb->expr()->in($field, $configuration['product'])) |
298 | 298 | ; |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | */ |
306 | 306 | public function addProductBrand(array $configuration = [], string $field = 'p.vendor'): void |
307 | 307 | { |
308 | - if(isset($configuration['productBrand']) && $configuration['productBrand'] != null) { |
|
308 | + if (isset($configuration['productBrand']) && $configuration['productBrand'] != null) { |
|
309 | 309 | $this->qb |
310 | 310 | ->andWhere($this->qb->expr()->in($field, $configuration['productBrand'])) |
311 | 311 | ; |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | */ |
319 | 319 | public function addProductCategory(array $configuration = [], string $field = 'pt.id'): void |
320 | 320 | { |
321 | - if(isset($configuration['productCategory']) && $configuration['productCategory'] != null) { |
|
321 | + if (isset($configuration['productCategory']) && $configuration['productCategory'] != null) { |
|
322 | 322 | $this->qb |
323 | 323 | ->andWhere($this->qb->expr()->in($field, $configuration['productCategory'])) |
324 | 324 | ; |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | */ |
332 | 332 | public function addOrderNumbers(array $configuration = [], string $field = 'o.id'): void |
333 | 333 | { |
334 | - if(isset($configuration['orderNumbers']) && $configuration['orderNumbers'] != null) { |
|
334 | + if (isset($configuration['orderNumbers']) && $configuration['orderNumbers'] != null) { |
|
335 | 335 | $this->qb |
336 | 336 | ->andWhere($this->qb->expr()->in($field, $configuration['orderNumbers'])) |
337 | 337 | ; |
@@ -141,12 +141,13 @@ discard block |
||
141 | 141 | |
142 | 142 | if($configuration['channel'] instanceof ChannelInterface) { |
143 | 143 | $storeIds[] = $configuration['channel']->getId(); |
144 | - }else if(is_array($configuration['channel']) && !in_array(0, $configuration['channel'])) { |
|
144 | + } else if(is_array($configuration['channel']) && !in_array(0, $configuration['channel'])) { |
|
145 | 145 | $storeIds = $configuration['channel']; |
146 | 146 | } |
147 | 147 | |
148 | - if(!(count($storeIds) > 0)) |
|
149 | - return; |
|
148 | + if(!(count($storeIds) > 0)) { |
|
149 | + return; |
|
150 | + } |
|
150 | 151 | |
151 | 152 | if(!$field) { |
152 | 153 | $alias = $this->qb->getRootAliases()[0]; |
@@ -167,8 +168,9 @@ discard block |
||
167 | 168 | if(isset($configuration['userGender']) && $configuration['userGender'] != null) { |
168 | 169 | $rootAlias = $cAlias = $this->qb->getRootAliases()[0]; |
169 | 170 | |
170 | - if(!$this->hasRootEntity(Customer::class)) |
|
171 | - $cAlias = $this->addLeftJoin($rootAlias.'.customer', 'c'); |
|
171 | + if(!$this->hasRootEntity(Customer::class)) { |
|
172 | + $cAlias = $this->addLeftJoin($rootAlias.'.customer', 'c'); |
|
173 | + } |
|
172 | 174 | |
173 | 175 | $this->qb |
174 | 176 | ->andWhere($this->qb->expr()->in($cAlias.'.gender', $configuration['userGender'])) |
@@ -184,8 +186,9 @@ discard block |
||
184 | 186 | if(isset($configuration['userBuyer']) && $configuration['userBuyer'] != null && $configuration['userBuyer'] != 'both') { |
185 | 187 | $rootAlias = $this->qb->getRootAliases()[0]; |
186 | 188 | |
187 | - if(!$this->hasRootEntity(Customer::class)) |
|
188 | - $this->addLeftJoin($rootAlias.'.customer', 'c'); |
|
189 | + if(!$this->hasRootEntity(Customer::class)) { |
|
190 | + $this->addLeftJoin($rootAlias.'.customer', 'c'); |
|
191 | + } |
|
189 | 192 | |
190 | 193 | $oAlias = $this->addLeftJoin('c.orders', 'o'); |
191 | 194 | |
@@ -194,7 +197,7 @@ discard block |
||
194 | 197 | ->andWhere($this->qb->expr()->isNotNull($oAlias.'.checkoutCompletedAt')) |
195 | 198 | ->andWhere($oAlias.'.itemsTotal > 0') |
196 | 199 | ; |
197 | - }else { |
|
200 | + } else { |
|
198 | 201 | $this->qb |
199 | 202 | ->andWhere($this->qb->expr()->isNull($oAlias.'.checkoutCompletedAt')) |
200 | 203 | ; |
@@ -212,8 +215,9 @@ discard block |
||
212 | 215 | if(isset($configuration[$type]) && $configuration[$type] != null) { |
213 | 216 | $rootAlias = $cAlias = $this->qb->getRootAliases()[0]; |
214 | 217 | |
215 | - if(!$this->hasRootEntity(Customer::class)) |
|
216 | - $cAlias = $this->addLeftJoin($rootAlias.'.customer', 'c'); |
|
218 | + if(!$this->hasRootEntity(Customer::class)) { |
|
219 | + $cAlias = $this->addLeftJoin($rootAlias.'.customer', 'c'); |
|
220 | + } |
|
217 | 221 | |
218 | 222 | $caAlias = $this->addLeftJoin($cAlias.'.addresses', 'c'.substr($addressType, 0, 1).'a'); |
219 | 223 | |
@@ -233,8 +237,9 @@ discard block |
||
233 | 237 | if(isset($configuration[$type]) && $configuration[$type] != null) { |
234 | 238 | $rootAlias = $cAlias = $this->qb->getRootAliases()[0]; |
235 | 239 | |
236 | - if(!$this->hasRootEntity(Customer::class)) |
|
237 | - $cAlias = $this->addLeftJoin($rootAlias.'.customer', 'c'); |
|
240 | + if(!$this->hasRootEntity(Customer::class)) { |
|
241 | + $cAlias = $this->addLeftJoin($rootAlias.'.customer', 'c'); |
|
242 | + } |
|
238 | 243 | |
239 | 244 | $caAlias = $this->addLeftJoin($cAlias.'.addresses', 'c'.substr($addressType, 0, 1).'a'); |
240 | 245 | |
@@ -254,8 +259,9 @@ discard block |
||
254 | 259 | if(isset($configuration[$type]) && $configuration[$type] != null) { |
255 | 260 | $rootAlias = $cAlias = $this->qb->getRootAliases()[0]; |
256 | 261 | |
257 | - if(!$this->hasRootEntity(Customer::class)) |
|
258 | - $cAlias = $this->addLeftJoin($rootAlias.'.customer', 'c'); |
|
262 | + if(!$this->hasRootEntity(Customer::class)) { |
|
263 | + $cAlias = $this->addLeftJoin($rootAlias.'.customer', 'c'); |
|
264 | + } |
|
259 | 265 | |
260 | 266 | $caAlias = $this->addLeftJoin($cAlias.'.addresses', 'c'.substr($addressType, 0, 1).'a'); |
261 | 267 | |
@@ -275,8 +281,9 @@ discard block |
||
275 | 281 | if(isset($configuration[$type]) && $configuration[$type] != null) { |
276 | 282 | $rootAlias = $cAlias = $this->qb->getRootAliases()[0]; |
277 | 283 | |
278 | - if(!$this->hasRootEntity(Customer::class)) |
|
279 | - $cAlias = $this->addLeftJoin($rootAlias.'.customer', 'c'); |
|
284 | + if(!$this->hasRootEntity(Customer::class)) { |
|
285 | + $cAlias = $this->addLeftJoin($rootAlias.'.customer', 'c'); |
|
286 | + } |
|
280 | 287 | |
281 | 288 | $caAlias = $this->addLeftJoin($cAlias.'.addresses', 'c'.substr($addressType, 0, 1).'2a'); |
282 | 289 |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | { |
307 | 307 | $cityLabel = ucfirst(strtolower($address->getCity())).', '.$address->getCountryCode(); |
308 | 308 | |
309 | - if(!in_array($cityLabel, $choices)) |
|
309 | + if (!in_array($cityLabel, $choices)) |
|
310 | 310 | { |
311 | 311 | $choices[$cityLabel] = $address->getCity(); |
312 | 312 | } |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | |
325 | 325 | /** @var ProvinceInterface $province */ |
326 | 326 | foreach ($provinces as $province) { |
327 | - if(!isset($provincesLabel[$province->getCode()])) { |
|
327 | + if (!isset($provincesLabel[$province->getCode()])) { |
|
328 | 328 | $provincesLabel[$province->getCode()] = $province->getName(); |
329 | 329 | } |
330 | 330 | } |
@@ -332,9 +332,9 @@ discard block |
||
332 | 332 | /** @var AddressInterface $address */ |
333 | 333 | foreach ($addresses as $address) |
334 | 334 | { |
335 | - $provinceLabel = isset($provincesLabel[$address->getProvinceCode()])?ucfirst(strtolower($provincesLabel[$address->getProvinceCode()])).', '.$address->getCountryCode():null; |
|
335 | + $provinceLabel = isset($provincesLabel[$address->getProvinceCode()]) ?ucfirst(strtolower($provincesLabel[$address->getProvinceCode()])).', '.$address->getCountryCode() : null; |
|
336 | 336 | |
337 | - if($provinceLabel && !in_array($provinceLabel, $choices)) |
|
337 | + if ($provinceLabel && !in_array($provinceLabel, $choices)) |
|
338 | 338 | { |
339 | 339 | $choices[$provinceLabel] = $address->getProvinceCode(); |
340 | 340 | } |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | { |
354 | 354 | $postcode = $address->getPostcode(); |
355 | 355 | |
356 | - if(!in_array($postcode, $choices)) |
|
356 | + if (!in_array($postcode, $choices)) |
|
357 | 357 | { |
358 | 358 | $choices[$postcode] = $postcode; |
359 | 359 | } |