Browse Source

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

refactoring
Guillaume Bourgeois 2 years ago
parent
commit
0b16e3cdb1
2 changed files with 8 additions and 6 deletions
  1. +2
    -6
      backend/views/user/index.php
  2. +6
    -0
      common/components/ActiveRecordCommon.php

+ 2
- 6
backend/views/user/index.php View File

'attribute' => 'username', 'attribute' => 'username',
'label' => 'Nom', 'label' => 'Nom',
'value' => function ($model) { '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);
} }
], ],
[ [
'orders' => function ($url, $model) { 'orders' => function ($url, $model) {
$url = Yii::$app->urlManager->createUrl(['user/orders', 'id' => $model['id']]); $url = Yii::$app->urlManager->createUrl(['user/orders', 'id' => $model['id']]);
$countOrders = Order::searchCount([ $countOrders = Order::searchCount([
'id_user' => $model['id']
'id_user' => $model['id'],
], ['conditions' => 'date_delete IS NULL']); ], ['conditions' => 'date_delete IS NULL']);


$html = ''; $html = '';

+ 6
- 0
common/components/ActiveRecordCommon.php View File

} }
} }


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

if (isset($options['as_array'])) { if (isset($options['as_array'])) {
$records = $records->asArray(); $records = $records->asArray();
} }
return $record; return $record;
} }
} elseif ($options['type_search'] == self::SEARCH_COUNT) { } elseif ($options['type_search'] == self::SEARCH_COUNT) {
$primaryKey = static::primaryKey();
$records = $records->groupBy($class::tableName() . '.'.$primaryKey[0]);
return $records->count(); return $records->count();
} }



Loading…
Cancel
Save