<table class="table">
    <thead>
        <tr>
            <th><span>#</span></th>
            <th><span>Topic <a class="help" data-toggle="popover" title="Project Topic" data-content="And here's some amazing content. It's very engaging. Right?"><i class="feather icon-help-circle f-16"></i></a></span></th>
            <th><span>Deadline <a class="help" data-toggle="popover" title="Last date of Project Submission" data-content="And here's some amazing content. It's very engaging. Right?"><i class="feather icon-help-circle f-16"></i></a></span></th>
            <th><span>Remaining Days <a class="help" data-toggle="popover" title="Remaining Days for Project Submission" data-content="And here's some amazing content. It's very engaging. Right?"><i class="feather icon-help-circle f-16"></i></a></span></th>
            <th><span>Above deadline <a class="help" data-toggle="popover" title="Days after project Submission date" data-content="And here's some amazing content. It's very engaging. Right?"><i class="feather icon-help-circle f-16"></i></a></span></th>
            <th><span>Created <a class="help" data-toggle="popover" title="Project Added Date" data-content="And here's some amazing content. It's very engaging. Right?"><i class="feather icon-help-circle f-16"></i></a></span></th>
            <th><span>Actions</span></th>
        </tr>
    </thead>
    <tbody>
        <?php if(count($projects) < 1){
            echo '<tr><td class="text-center text-danger" colspan="7">No Data Found!</td></tr>';
        }else{ $i =1; foreach ($projects as $project): ?>
        <tr>
            <td><?= $i++ ?></td>
            <td><?= $project->topic ?></td>
            <td><?=  date('d M,Y',strtotime($project->deadline_date)) ?></td>
            <?php                                          
                    $date1 = date_create($project->deadline_date);
                    $date2 = date_create(date('Y-m-d'));
                    $diff = date_diff($date2,$date1);
                    $days = $diff->format('%R%a');
                    ?>
            <?php if($days>0){ ?>   
                <td><?php if($days>0) echo abs($days); ?></td>
                <td>0</td>
            <?php }else{ ?>
                <td>0</td>
                <td><?php echo abs($days); ?></td>
            <?php } ?>
            
            <td><?= date('d M,Y',strtotime($project->created)) ?></td>


            <td class="actions">
            <?php //if(@$userright_arr[0]['add_r']):?>
                <?= $this->Html->link($this->Html->tag('i', '', array('class'=>"fas fa-eye btn btn-success")), array('controller'=>'projects', 'action' => 'view', $project->id),array('escape'=>false)) ?>
                <?php //endif; ?>
            <?php if(@$userright_arr[0]['edit']):?>

                <?= $this->Html->link($this->Html->tag('i', '', array('class'=>"feather icon-edit btn btn-primary")), array('controller'=>'projects', 'action' => 'edit', $project->id),array('escape'=>false)) ?>
                <?php endif; ?>

            </td>  
        </tr>
        <?php endforeach; } ?>
    </tbody>
</table>