<div class="col-md-12">
    <table class="table table-bordered datatable">
        <thead>
        <tr>
            <th width="40%">Discount Period</th>
            <th width="30%">Date Applied</th>
            <th width="30%">Applied By</th>
        </tr>
        </thead>
        <tbody>
        <?php if(count($AccountDiscountPlan)): ?>
            <?php foreach($AccountDiscountPlan as $AccountDiscountPlanRow): ?>
        <tr>
            <td><?php echo $AccountDiscountPlanRow->StartDate.' to '.Date('Y-m-d',strtotime('-1 day',strtotime($AccountDiscountPlanRow->EndDate))); ?></td>
            <td><?php echo Date('Y-m-d',strtotime($AccountDiscountPlanRow->created_at)); ?></td>
            <td><?php echo $AccountDiscountPlanRow->CreatedBy; ?></td>
        </tr>
                <?php break; ?>
            <?php endforeach; ?>
        <?php endif; ?>
        </tbody>
    </table>
    <table class="table table-bordered datatable">
        <thead>
        <tr>
            <th width="20%">Discount</th>
            <th width="20%">Threshold</th>
            <th width="20%">Unlimited</th>
            <th width="40%">Used Minutes(%)</th>
        </tr>
        </thead>
        <tbody>
        <?php if(count($AccountDiscountPlan)): ?>
            <?php foreach($AccountDiscountPlan as $AccountDiscountPlanRow): ?>
                <?php
                $UsedPercent = 100;
                    if($AccountDiscountPlanRow->Threshold > 0){
                        $UsedPercent = number_format(($AccountDiscountPlanRow->MinutesUsed/$AccountDiscountPlanRow->Threshold)*100,2);
                    }
                ?>
                <tr>
                    <td><?php echo $AccountDiscountPlanRow->Name; ?></td>
                    <td><?php echo $AccountDiscountPlanRow->Threshold; ?></td>
                    <td><?php echo $AccountDiscountPlanRow->Unlimited; ?></td>
                    <td>
                        <div class="progress discount_progress">
                            <div style="width: <?php echo $UsedPercent; ?>%" aria-valuemax="100" aria-valuemin="0" aria-valuenow="<?php echo $UsedPercent; ?>" role="progressbar" class="progress-bar progress-bar-success">
                                <span>
                                    <?php if($AccountDiscountPlanRow->Threshold > 0): ?>
                                        <?php echo $UsedPercent; ?>% Used ( <?php echo $AccountDiscountPlanRow->MinutesUsed; ?> Minutes Used )
                                    <?php else: ?>
                                        <?php echo $AccountDiscountPlanRow->MinutesUsed; ?> Minutes Used
                                    <?php endif; ?>

                                </span>
                            </div>
                        </div>
                    </td>
                </tr>
            <?php endforeach; ?>
        <?php else: ?>
            <tr>
                <td colspan="3">No Data</td>
            </tr>
        <?php endif; ?>
        </tbody>
        <tfoot>
        <tr>
        </tr>
        </tfoot>
    </table>
</div>
