Advertisement
Guest User

bootstrap tab

a guest
Jul 11th, 2016
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.20 KB | None | 0 0
  1. <div>
  2.     <!-- Nav tabs -->
  3.     <ul id="deshboardTabs" class="nav nav-tabs" role="tablist">
  4.         <?php foreach ($takenCourse as $course) : ?>
  5.         <li role="presentation" class="course-nav" data-code="<?php echo $course->courseCode;?>">
  6.             <a href="<?php echo urlencode($course->courseCode);?>" aria-controls="<?php echo $course->courseCode?>" role="tab" data-toggle="tab"
  7.             > <?php echo $course->vendorName.' : '.$course->courseCode;?> </a>
  8.         </li>
  9.         <?php endforeach;?>
  10.     </ul>
  11.  
  12.     <!-- Tab panes -->
  13.     <div class="tab-content">
  14.         <?php foreach ($takenCourse as $item):?>
  15.         <div role="tabpanel" class="tab-pane" id="<?php echo $item->courseCode;?>">
  16.             <div class="panel panel-default">
  17.                 <div class="panel-heading">Exam Score</div>
  18.                 <div class="panel-body">
  19.                     <div class="table-responsive">
  20.                         <table class="table table-striped table-hover table-sm table-bordered">
  21.                             <thead>
  22.                             <tr>
  23.                                 <th>Exam</th>
  24.                                 <th>Taken</th>
  25.                                 <th class="text-right">Latest Score</th>
  26.                                 <th class="text-right">Avg. Score</th>
  27.                                 <th class="text-right">Max Score</th>
  28.                                 <th>Avg. Time</th>
  29.                                 <th>Last Taken</th>
  30.                             </tr>
  31.                             </thead>
  32.                             <tbody>
  33.                             <?php
  34.                             $helpers = new Helpers();
  35.                             foreach($score as $row):
  36.                                 if ($row->course_name == $item->courseName) {
  37.                                     echo '<tr>'
  38.                                             . '<td>' . $row->exam_name . '</td>'
  39.                                             . '<td>' . $row->number_of_time_taken . ' Times</td>'
  40.                                             . '<td class="text-right">' . $row->last_score . '</td>'
  41.                                             . '<td class="text-right">' . $row->avg_score . '</td>'
  42.                                             . '<td class="text-right">' . $row->max_score . '</td>'
  43.                                             . '<td>' . $helpers->seconds2time($row->avg_time_taken) . '</td>'
  44.                                             . '<td>' . date('Y-d-m H:i', strtotime($row->taken_at)) . '</td>'
  45.                                             . '</tr>';
  46.                                 }
  47.                             endforeach;
  48.                             ?>
  49.                             </tbody>
  50.                         </table>
  51.                     </div>
  52.                 </div>
  53.             </div>
  54.  
  55.             <div class="panel panel-default">
  56.                 <div class="panel-heading">Score of Recent Exam</div>
  57.                 <div class="panel-body">
  58.                     <div class="table-responsive">
  59.                         <table class="table table-striped table-hover table-sm table-bordered">
  60.                             <thead>
  61.                             <tr>
  62.                                 <th>Serial</th>
  63.                                 <th>Vendor Name</th>
  64.                                 <th>Exam Name</th>
  65.                                 <th>Course Name</th>
  66.                                 <th>Score</th>
  67.                                 <th>Time Taken</th>
  68.                                 <th>Taken At</th>
  69.                             </tr>
  70.                             </thead>
  71.                             <tbody>
  72.                             <?php foreach ($recentScore as $score) :
  73.                                 if ($score->courseName == $item->courseName) {
  74.                                 ?>
  75.                                 <tr class="recent-score-table">
  76.                                     <td class="text-right"></td>
  77.                                     <td> <?php echo $score->vendorName; ?> </td>
  78.                                     <td> <?php echo $score->examName; ?> </td>
  79.                                     <td> <?php echo $score->courseName; ?> </td>
  80.                                     <td class="text-right"> <?php echo $score->score; ?> </td>
  81.                                     <td> <?php echo $helpers->seconds2time($score->time_taken); ?> </td>
  82.                                     <td> <?php echo date('Y-d-m H:i', strtotime($score->taken_at)); ?> </td>
  83.                                 </tr>
  84.                             <?php }
  85.                             endforeach; ?>
  86.                             </tbody>
  87.                         </table>
  88.                     </div>
  89.                 </div>
  90.             </div>
  91.         </div>
  92.         <?php endforeach;?>
  93.     </div>
  94. </div>
  95.  
  96. <script>
  97. $('.tab-pane').first().addClass('active');
  98. $('.course-nav').first().addClass('active');
  99. $('.nav-tabs li').on('click', function (event) {
  100.     event.preventDefault();
  101.     $('.nav-tabs li').removeClass('active');
  102.     $(this).addClass('active');
  103.     $('.tab-content div').hide();
  104.     $('#' + $(this).data('code')).tab('show');        
  105. });
  106. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement