Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

_menu_navigation.php 1.1KB

1234567891011121314151617181920212223242526272829303132
  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. ?>