<section class="panel panel-default">
<header class="header bg-white b-b clearfix">
                  <div class="row m-t-sm">
                  <div class="col-sm-12 m-b-xs">
                  <?php  if($role == 1){ ?>
                  <a href="<?=base_url()?>projects/milestones/add/<?=$project_id?>" data-toggle="ajaxModal" class="btn btn-sm btn-success"><?=lang('add_milestone')?></a> 
                  <?php } ?>

                     

                    </div>
                  </div>
                </header>
    <div class="table-responsive">
                  <table class="table table-striped b-t b-light AppendDataTables">
                    <thead>
                      <tr>
                        <th><?=lang('milestone_name')?></th>
                        <th><?=lang('start_date')?></th>
                        <th><?=lang('due_date')?></th>
                        <th><?=lang('progress')?></th>
                        <?php if($role == '1'){ ?>
                        <th><?=lang('options')?></th>
                        <?php } ?>
                      </tr>
                    </thead>
                    <tbody>
                    <?php
                    $milestones = $this -> db -> where('project',$project_id) -> get('milestones') -> result();
                    if (!empty($milestones)) {
                    foreach ($milestones as $key => $m) { 
                      $progress = $this -> applib -> cal_milestone_progress($m->id);
                      ?>
            
                      <tr>
                        <td><a class="text-primary" href="<?=base_url()?>projects/view/<?=$m->project?>?group=milestones&view=milestone&id=<?=$m->id?>" data-original-title="<?=$m->description?>" data-toggle="tooltip" data-placement="right" title = ""><?=$m->milestone_name?></a></td>
                        <td><?=$m->start_date?></td>
                        <td><?php
                              $due_date = $m->due_date;
                              $due_time = strtotime($due_date);
                              $current_time = time();
                              ?>
                        <?=$due_date?>
                        <?php if ($current_time > $due_time){ ?>
                           <span class="badge bg-danger"><?=lang('overdue')?></span>
                        <?php } ?>
                        </td>
                        <td>
                        <div class="inline ">
                        <div class="easypiechart text-success" data-percent="<?=$progress?>" data-line-width="5" data-track-Color="#f0f0f0" data-bar-color="#<?php if($progress >= 100){ echo '8ec165';}else{ echo 'fb6b5b'; } ?>" data-rotate="270" data-scale-Color="false" data-size="50" data-animate="2000">
                          <span class="small text-muted"><?=$progress?>%</span>
                        </div>
                      </div>

                    </td>
                     <?php  if($role == 1){ ?>
                        <td>
                       
                        <a class="btn btn-xs btn-info" href="<?=base_url()?>projects/milestones/edit/<?=$m->id?>" data-toggle="ajaxModal"><i class="fa fa-edit"></i></a>

                        <a href="<?=base_url()?>projects/milestones/delete/<?=$m->project?>/<?=$m->id?>" data-toggle="ajaxModal" title="<?=lang('delete_milestone')?>" class="btn btn-xs btn-danger"><i class="fa fa-trash-o text-white"></i></a>
                        </td>
                        <?php } ?>
                        
                      </tr>
                      <?php } } ?>
                    </tbody>
                  </table>
                </div>

<!-- End details -->
 </section>