<div class="col-sm-10">
    <div class="col-sm-12 gray">
        <div class="col-sm-4 col-sm-offset-8 ">
            <div class="input-group">
                <input type="text" 
                       class="form-control"  
                       placeholder="Search coupon..."
                       oninput="searchCoupon(this.value,'<?php echo base_url() . 'search-coupon' ?>')"
                       aria-describedby="basic-addon1">
                <span class="input-group-addon" id="basic-addon1"><i class="fa fa-search"></i></span>
            </div>
        </div>
    </div>
    <div class="col-sm-12" ><br></div>
    <div class="row ">
        <div class="col-sm-12 ">
            <div class="col-sm-12 gray_ttc" >
                <div class="col-sm-12 " style="border-bottom: 2px solid #8CC73F;padding-top: 10px;padding-bottom: 10px;padding-left: 0px;font-weight: bold">
                    <div class="col-sm-1">Serial</div>
                    <div class="col-sm-2">Name</div>
                    <div class="col-sm-2">Code</div>
                    <div class="col-sm-1">Type</div>
                    <div class="col-sm-2">Price Type</div>
                    <div class="col-sm-3">Expire</div>
                    <div class="col-sm-1">Action</div>
                </div>
                <div class="col-sm-12"><br></div> 


                <div id="coupon_view">
                    <?php
                    foreach ($all_coupon as $coupon_value) {
                        $serial++;
                        ?>
                        <div class="col-sm-12 white" style="padding-top: 10px;padding-bottom: 10px;">
                            <div class="col-sm-1"><?php echo $serial; ?></div>
                            <div class="col-sm-2"><?php echo $coupon_value->coupon_name; ?></div>
                            <div class="col-sm-2"><?php echo $coupon_value->coupon_code; ?></div>
                            <div class="col-sm-1"><?php 
                            if($coupon_value->coupon_type==1){
                                echo 'Feature';
                            }else if($coupon_value->coupon_type==2){
                                echo 'Course';
                            }else if($coupon_value->coupon_type==3){
                                echo 'Video Course';
                            }
                            ?></div>
                            <div class="col-sm-2"><?php 
                            if($coupon_value->coupon_price_type==1){
                                echo 'Percentage (<strong>'.  round($coupon_value->coupon_discount_amount).'%</strong>)';
                            }else if($coupon_value->coupon_price_type==2){
                                echo 'Fixed (<strong>'.  $coupon_value->coupon_discount_amount.'</strong>)';
                            }
                            ?></div>
                            <div class="col-sm-3"><?php 
                            if($coupon_value->coupon_expire_type==1){
                                echo '<strong>'.  round($coupon_value->coupon_can_use_number).' Days</strong>';
                            }else if($coupon_value->coupon_expire_type==2){
                                echo '<strong>'.  date("j F Y", strtotime($coupon_value->coupon_start_date)).' - '.date("j F Y", strtotime($coupon_value->coupon_finish_date)).'</strong>';
                            }
                            ?></div>
                            <div class="col-sm-1" id="coupon_status_view<?php echo $coupon_value->coupon_id; ?>">
                                <?php
                                if ($coupon_value->coupon_status == 1) {
                                    ?>
                                    <a href="javascript:void(0)"
                                       onclick="checkStatus('<?php echo base_url() . 'check-coupon-status' ?>', 'Inactive', '<?php echo $coupon_value->coupon_id; ?>')"
                                       ><i class="fa fa-user-times" title="Inacitve"></i></a>
                                       <?php
                                   } else if ($coupon_value->coupon_status == 2) {
                                       ?>
                                    <a href="javascript:void(0)"
                                       onclick="checkStatus('<?php echo base_url() . 'check-coupon-status' ?>', 'Active', '<?php echo $coupon_value->coupon_id; ?>')"
                                       ><i class="fa fa-user-plus" title="Acitve"></i></a>
                                       <?php
                                   }
                                   ?>
                                <a href="javascript:void(0)"
                                   onclick="checkStatus('<?php echo base_url() . 'check-coupon-status' ?>', 'Delete', '<?php echo $coupon_value->coupon_id; ?>')"
                                   ><i class="fa fa-trash-o" title="Delete"></i></a>
                                <a href="<?php echo base_url().'edit-coupon/'.$coupon_value->coupon_code ?>"><i class="fa fa-edit" title="Edit"></i></a>
                            </div>
                        </div>
                        <div class="col-sm-12"><br></div> 
                        <?php
                    }
                    ?>


                    <?php
                    $total_page = ceil($total_coupon->total / 10);
                    if ($total_page > 1) {
                        ?>
                        <nav class="course-pagination">
                            <ul class="pagination">
                                <?php
                                if ($page > 2) {
                                    ?>
                                    <li>
                                        <a href="<?php echo base_url() . 'manage-coupon/'; ?>" aria-label="Previous">
                                            <span aria-hidden="true" title="First Page">&laquo;&laquo;</span>
                                        </a>
                                    </li>
                                    <li>
                                        <a href="<?php echo base_url() . 'manage-coupon/' . ($page - 1); ?>" aria-label="Previous">
                                            <span aria-hidden="true" title="Previous Page">&laquo;</span>
                                        </a>
                                    </li>
                                <?php } elseif ($page > 1) { ?>
                                    <li>
                                        <a href="<?php echo base_url() . 'manage-coupon/' . ($page - 1); ?>" aria-label="Previous">
                                            <span aria-hidden="true" title="Previous Page">&laquo;</span>
                                        </a>
                                    </li>
                                    <?php
                                }
                                for ($i = 0; $total_page > $i; $i++) {
                                    echo '<li><a href="' . base_url() . 'manage-coupon/' . ($i + 1) . '">' . ($i + 1) . '</a></li>';
                                }
                                if ($total_page != $page) {
                                    ?>
                                    <li>
                                        <a href="<?php echo base_url() . 'manage-coupon/' . ($page + 1); ?>" aria-label="Next">
                                            <span aria-hidden="true" title="Next Page">&raquo;</span>
                                        </a>
                                    </li>
                                    <li>
                                        <a href="<?php echo base_url() . 'manage-coupon/' . $total_page; ?>" aria-label="Next">
                                            <span aria-hidden="true" title="Last Page">&raquo;&raquo;</span>
                                        </a>
                                    </li>
                                <?php } ?>
                            </ul>
                        </nav>
                    <?php } ?>
                </div>
            </div>
        </div>
    </div>

    <br>
    <br>
    <div class="col-sm-12 gray text-left" style="padding-left: 20px">
        <label><a href="<?php echo base_url() ?>super_admin">Dashboard </a>->>Manage Coupon</label>
    </div>   
</div>
<script type="text/javascript" src="<?php echo base_url()?>back_end_resource/coupon/coupon.js">
</script>