Pārlūkot izejas kodu

[Backend] Utilisateurs : correctif nombre de commandes dans liste utilisateurs #546

refactoring
Guillaume Bourgeois pirms 2 gadiem
vecāks
revīzija
0b16e3cdb1
2 mainītis faili ar 8 papildinājumiem un 6 dzēšanām
  1. +2
    -6
      backend/views/user/index.php
  2. +6
    -0
      common/components/ActiveRecordCommon.php

+ 2
- 6
backend/views/user/index.php Parādīt failu

@@ -67,11 +67,7 @@ $this->render('_menu', [
'attribute' => 'username',
'label' => 'Nom',
'value' => function ($model) {
if (isset($model['name_legal_person']) && strlen($model['name_legal_person'])) {
return $model['name_legal_person'];
} else {
return $model['lastname'] . ' ' . $model['name'];
}
return User::getUsernameFromArray($model);
}
],
[
@@ -112,7 +108,7 @@ $this->render('_menu', [
'orders' => function ($url, $model) {
$url = Yii::$app->urlManager->createUrl(['user/orders', 'id' => $model['id']]);
$countOrders = Order::searchCount([
'id_user' => $model['id']
'id_user' => $model['id'],
], ['conditions' => 'date_delete IS NULL']);

$html = '';

+ 6
- 0
common/components/ActiveRecordCommon.php Parādīt failu

@@ -136,6 +136,10 @@ class ActiveRecordCommon extends \yii\db\ActiveRecord
}
}

if (isset($options['groupby'])) {
$records = $records->groupBy($options['groupby']);
}

if (isset($options['as_array'])) {
$records = $records->asArray();
}
@@ -148,6 +152,8 @@ class ActiveRecordCommon extends \yii\db\ActiveRecord
return $record;
}
} elseif ($options['type_search'] == self::SEARCH_COUNT) {
$primaryKey = static::primaryKey();
$records = $records->groupBy($class::tableName() . '.'.$primaryKey[0]);
return $records->count();
}


Notiek ielāde…
Atcelt
Saglabāt