You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.1KB

  1. <?php
  2. use domain\Order\Order\OrderModule;
  3. use domain\User\User\User;
  4. use domain\User\User\UserModule;
  5. use common\helpers\Price;
  6. $userModule = UserModule::getInstance();
  7. $orderModule = OrderModule::getInstance();
  8. $credit = $userModule->getRepository()->getCredit($user);
  9. $countOrders = $orderModule->getRepository()->countOrdersByUser($user);
  10. ?>
  11. <ul class="nav nav-tabs">
  12. <?= menu_navigation_item('view', 'Récapitulatif', $action, $user) ?>
  13. <?= menu_navigation_item('update', 'Profil', $action, $user) ?>
  14. <?= menu_navigation_item('credit', 'Crédit <span class="label label-default badge">'.Price::format($credit).'</span>', $action, $user) ?>
  15. <?= menu_navigation_item('orders', 'Commandes <span class="label label-default badge">'.$countOrders.'</span>', $action, $user) ?>
  16. </ul>
  17. <?php
  18. function menu_navigation_item(string $action, string $label, string $currentAction, User $user) {
  19. $classActive = ($action == $currentAction) ? ' class="active"' : '';
  20. $url = Yii::$app->urlManager->createUrl(['user/'.$action, 'id' => $user->id]);
  21. return '<li'.$classActive.'><a href="'.$url.'">'.$label.'</a></li>';
  22. }
  23. ?>