Browse Source

[backend] Distributions : optimisation chargement ajax des distributions (commandes, produits)

refactoring
Guillaume Bourgeois 4 years ago
parent
commit
265106496c
2 changed files with 14 additions and 7 deletions
  1. +2
    -2
      backend/controllers/DistributionController.php
  2. +12
    -5
      common/models/Order.php

+ 2
- 2
backend/controllers/DistributionController.php View File

}]) }])
->orderBy('product_distribution.active DESC, order ASC') ->orderBy('product_distribution.active DESC, order ASC')
->asArray() ->asArray()
->all();
->all();
$potentialRevenues = 0; $potentialRevenues = 0;
$potentialWeight = 0; $potentialWeight = 0;

+ 12
- 5
common/models/Order.php View File

*/ */
public function initPaidAmount() public function initPaidAmount()
{ {
$history = CreditHistory::find()
->where(['id_order' => $this->id])
->all();

if(isset($this->creditHistory)) {
$history = $this->creditHistory ;
}
else {
$history = CreditHistory::find()
->where(['id_order' => $this->id])
->all();
}
$this->paid_amount = 0 ; $this->paid_amount = 0 ;


if(count($history)) { if(count($history)) {
if(is_array($orders)) { if(is_array($orders)) {
if(count($orders)) { if(count($orders)) {
foreach($orders as $order) { foreach($orders as $order) {
$order->init() ;
if(is_a($order, 'common\models\Order')) {
$order->init() ;
}
} }
return $orders ; return $orders ;
} }

Loading…
Cancel
Save