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.

_menu_navigation.php 1.5KB

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