<?php 
$this->load->view('site/templates/commonheader');
$this->load->view('site/templates/shop_header'); 
?>
<div style="background:none repeat scroll 0 0 #FFFFFF;border-bottom:1px solid #DDDDDD;border-top:1px solid #DDDDDD;padding: 20px 0;" class="add_shop">
    <div class="main">    			
                <?php if ($couponCardsList->num_rows() > 0){ ?>
                <div>
    				<a href="shops/<?php echo $this->uri->segment(2); ?>/add-coupon-code">Create New Coupon.</a><br /><br />
                </div>
                <form class="tab_form_list">
                     <table class="tab_form_list_table" align="center" width="100">
                        <thead>     
                            <tr class="table-header">
                                <th><span>Code</span></th>
                                <th><span>Value</span></th>        
                                <th><span>Remain</span></th>        
                                <th><span>Purchased</span></th>        
                                <th><span>Date From</span></th> 
                                <th><span>Date To</span></th> 
                                <th><span>Card Status</span></th>   
                                <th><span>Action</span></th>
                            </tr>
                        </thead>
                        <tbody align="center">                    
                        <?php foreach ($couponCardsList->result() as $row){ ?>
                            <tr id="couponcard-<?php echo $row->id;?>" >                            
                                <td><?php echo $row->code;?></td>        
                                <td><?php echo $row->price_value;?> %</td>        
                                <td><?php echo ($row->quantity - $row->purchase_count);?></td>
                                <td><?php echo $row->purchase_count;?></td>
                                <td><?php echo $row->datefrom;?></td>
                                <td><?php echo $row->dateto;?></td>
                                <td><?php if(strtotime($row->dateto) < strtotime(date('Y-m-d'))){ echo 'Expired'; }else{ 
												if($row->purchase_count > 0){ echo 'Redeemed'; }else{ echo 'Not Used'; }}?></td>
                                <td><a href="shops/<?php echo $this->uri->segment(2); ?>/edit-coupon-code/<?php echo $row->id;?>">Edit</a></td>
                            </tr>
                        <?php } ?>
                        </tbody>
                     </table>     
                 </form>
        		<?php }else{ ?>
                <div class=" warning-error">
                    <h3>
                        <span style="margin:0 0 0 3px; color:#000; font-weight:bold">No Coupon Code in your Shop yet.</span>
                        <a href="shops/<?php echo $this->uri->segment(2); ?>/add-coupon-code">
                        	<span>Create New Coupon.</span>                  
                        </a>
                    </h3>
                </div>
                <?php } ?>
    </div>
</div>
<?php $this->load->view('site/templates/footer'); ?>