<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
<?php init_head(); ?>
<div id="wrapper">
    <div class="content">
        <div class="panel_s">
            <div class="panel-body">
                <div class="clearfix">
                    <h4 class="pull-left no-margin"><?php echo html_escape($title); ?></h4>

                    <?php if ($title === 'My Submissions') { ?>
                        <a href="<?php echo admin_url('project_costing/project_costing/create'); ?>" class="btn btn-primary pull-right">
                            <i class="fa fa-plus"></i> New Project
                        </a>
                    <?php } ?>
                </div>
                <hr class="hr-panel-heading" />

                <div class="table-responsive">
                    <table class="table table-bordered table-striped">
                        <thead>
                            <tr>
                                <th>#</th>
                                <th>Proposal Name</th>
                                <th>Client</th>
                                <th>Client Category</th>
                                <th>Engagement Type</th>
                                <th>Mode</th>
                                <th>Status</th>
                                <th>Total</th>
                                <th>Date Created</th>
                                <th width="140">Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php if (!empty($projects)) { ?>
                                <?php foreach ($projects as $project) { ?>
                                    <tr>
                                        <td><?php echo $project['id']; ?></td>
                                        <td><?php echo html_escape($project['proposal_name']); ?></td>
                                        <td><?php echo html_escape($project['client_name']); ?></td>
                                        <td><?php echo html_escape($project['client_category_name']); ?></td>
                                        <td><?php echo html_escape($project['engagement_type_name']); ?></td>
                                        <td><?php echo ucfirst(str_replace('_', ' ', $project['engagement_mode'])); ?></td>
                                        <td>
                                            <span class="label label-<?php echo $project['overall_status'] == 'approved' ? 'success' : ($project['overall_status'] == 'rejected' ? 'danger' : 'warning'); ?>">
                                                <?php echo ucfirst($project['overall_status']); ?>
                                            </span>
                                        </td>
                                        <td>RM <?php echo number_format((float)$project['overall_total'], 2); ?></td>
                                        <td><?php echo _dt($project['datecreated']); ?></td>
                                        <td>
                                            <a href="<?php echo admin_url('project_costing/project_costing/view/' . $project['id']); ?>" class="btn btn-default btn-icon">
                                                <i class="fa fa-eye"></i>
                                            </a>

                                            <?php if ($title === 'My Submissions' || is_admin()) { ?>
                                                <a href="<?php echo admin_url('project_costing/project_costing/edit/' . $project['id']); ?>" class="btn btn-primary btn-icon">
                                                    <i class="fa fa-pencil"></i>
                                                </a>
                                            <?php } ?>
                                        </td>
                                    </tr>
                                <?php } ?>
                            <?php } else { ?>
                                <tr>
                                    <td colspan="10" class="text-center">No submissions found.</td>
                                </tr>
                            <?php } ?>
                        </tbody>
                    </table>
                </div>

            </div>
        </div>
    </div>
</div>
<?php init_tail(); ?>