<link href="<?php echo base_url();?>adminassets/plugins/dataTables/css/jquery.dataTables.html" rel="stylesheet" type="text/css">
<link href="<?php echo base_url();?>adminassets/plugins/dataTables/css/dataTables.bootstrap.css" rel="stylesheet" type="text/css"> 
<div class="vd_content-wrapper">
      <div class="vd_container">
        <div class="vd_content clearfix">
          <div class="vd_head-section clearfix">
            <div class="vd_panel-header">
              <ul class="breadcrumb">
                <li><a href="<?php echo base_url();?>admin">Home</a> </li>
                <li class="active">Coupons</li>
              </ul>
              
 
            </div>
          </div>
          <!-- vd_head-section -->
          
          <div class="vd_title-section clearfix">
            <div class="vd_panel-header">
              <h1>Manage Coupons</h1>
              <button class="btn btn-info btn-xs pull-right" id="show">Add New Coupon</button>
<!-- vd_panel-menu --> 
            </div>
            <!-- vd_panel-header --> 
          </div>
          <!-- vd_title-section -->
          
          <div class="vd_content-section clearfix">
            
         <div class="row">
              <div class="vd_pricing-table">
               	<div class="col-md-4" id="tform" <?php  if(!$this->uri->segment(3)){?> style="display:none;" <?php }?>>
                <div class="panel widget">
                  <div class="panel-heading vd_bg-grey">
                    <h3 class="panel-title"> <span class="menu-icon"> <i class="fa fa-dot-circle-o"></i> </span> Add/Edit Coupon</h3>
                    
                  </div>
                  <div class="panel-body table-responsive">
                     <?php 
				  if($this->uri->segment(3))
					{
						$cedit=$this->db->get_where("coupons",array("id"=>$this->uri->segment(3)))->row();
						echo form_open_multipart("admin/add_coupon/".$this->uri->segment(3),array("class"=>"form-horizontal"));?>
                       <div class="form-group">
                        <label class="col-sm-3 control-label">Code</label>
                        <div class="col-sm-9 controls">
                          <input class="" name="code"  value="<?php echo $cedit->code;?>" type="text" required placeholder="Coupon Code">
                        </div>
                      </div>
                       <div class="form-group">
                        <label class="col-sm-3 control-label">Title</label>
                        <div class="col-sm-9 controls">
                          <input class="" name="title"  value="<?php echo $cedit->title;?>" type="text" required placeholder="Title">
                        </div>
                      </div>
                      <div class="form-group">
                        <label class="col-sm-3 control-label">Type</label>
                        <div class="col-sm-9 controls">
                        <select class="tailor" name="type">
                 			<option value="">Select Type</option>
                   			<option value="Percent" <?php if($cedit->distype=="Percent"){echo "selected";}?>>Percent</option>
                            <option value="Amount" <?php if($cedit->distype=="Amount"){echo "selected";}?>>Amount</option>
                      </select>
                        </div>
                      </div>
                      
                       <div class="form-group">
                        <label class="col-sm-3 control-label">Value</label>
                        <div class="col-sm-9 controls">
                          <input class="" name="value" value="<?php echo $cedit->disvalue;?>" type="text" required placeholder="Coupon Value">
                        </div>
                      </div>
                      <div class="form-group">
                        <label class="col-sm-3 control-label">Description</label>
                        <div class="col-sm-9 controls">
                        <textarea class="" name="desc" rows="2" placeholder="Description"><?php echo $cedit->desc;?></textarea>
                        </div>
                      </div>
                       
                      
                      
                      <div class="form-group">
                     
                      <label class="col-sm-3 control-label">Image</label>
                      
                      <div class="col-sm-9 controls">
                       <span class="btn vd_btn vd_bg-green fileinput-button"> <i class="glyphicon glyphicon-plus"></i> <span>Add Image</span> 
                    <!-- The file input field used as target for the file upload widget -->
                    <input id="fileupload" type="file" name="cfile">
                     <input type="hidden" name="oldt" value="<?php echo $cedit->image;?>" />
                <img class="img img-responsive" src="<?php echo base_url();?>assets/images/<?php echo $cedit->image;?>" />
                    </span></div>
                    	
                    </div>
                      <div class="col-sm-12 controls">
                       <button type="submit" name="submit" class="btn btn-primary">Update Coupon</button>
                       <a href="<?php echo base_url();?>admin/manage_coupons" class="btn btn-default">Cancel</a>
                    </span></div>
                      
                    <?php echo form_close();
					}
					else
					{
				  echo form_open_multipart("admin/add_coupon",array("class"=>"form-horizontal"));?>
                     
                      <div class="form-group">
                        <label class="col-sm-3 control-label">Code</label>
                        <div class="col-sm-9 controls">
                          <input class="" name="code" type="text" required placeholder="Coupon Code">
                        </div>
                      </div>
                      <div class="form-group">
                        <label class="col-sm-3 control-label">Title</label>
                        <div class="col-sm-9 controls">
                          <input class="" name="title" type="text" required placeholder="Title">
                        </div>
                      </div>
                      <div class="form-group">
                        <label class="col-sm-3 control-label">Type</label>
                        <div class="col-sm-9 controls">
                        <select class="tailor" name="type">
                 			<option value="">Select Type</option>
                   			<option value="Percent">Percent</option>
                            <option value="Amount">Amount</option>
                      </select>
                        </div>
                      </div>
                      
                       <div class="form-group">
                        <label class="col-sm-3 control-label">Value</label>
                        <div class="col-sm-9 controls">
                          <input class="" name="value" type="text" required placeholder="Coupon Value">
                        </div>
                      </div>
                      <div class="form-group">
                        <label class="col-sm-3 control-label">Description</label>
                        <div class="col-sm-9 controls">
                        <textarea class="" name="desc" rows="2" placeholder="Description"></textarea>
                        </div>
                      </div>
                       
                      
                      
                      <div class="form-group">
                     
                      <label class="col-sm-3 control-label">Image</label>
                      
                      <div class="col-md-9">
                      <input id="fileupload" type="file" name="cfile">
                      </div>
                    	
                    </div>
                      <div class="col-sm-12 controls">
                       <button type="submit" name="submit" class="btn btn-primary btn-block">Add Coupon</button>
                    </span></div>
                    <?php echo form_close();}?>
                  </div>
                </div>
                <!-- Panel Widget --> 
              </div>
               <?php foreach($coupons as $coupon){?>
                <div class="col-md-3">
                  <div class="plan">
                    <div class="plan-header vd_bg-green vd_white text-center vd_info-parent">
                      <h3 class="pd-10 mgbt-xs-0"><?php echo $coupon->code;?></h3>
                      <div class="price vd_bg-black-30"> <span class="main"><span class="font-light"><?php if($coupon->distype!="Percent"){echo "<i class='fa fa-inr'></i> ";}?></span><span class="font-bold"><?php echo $coupon->disvalue;if($coupon->distype=="Percent"){echo "%";}?></span> </span> <span class="suffix">Off</span> <span class="text"></span> </div>
                      <i class="caret-pos fa fa-caret-up vd_white"></i> </div>
                    <div class="features vd_bg-white font-sm content-list">
                      <ul class="list-wrapper">
                        <li><i class="glyphicon glyphicon-hdd mgr-10"></i> <b><?php echo $coupon->title;?></b></li>
                        <li><p style="font-size:14px;"><?php echo $coupon->desc;?></p></li>
                        <li><i class="fa fa-calendar-o mgr-10"></i> <b><?php echo date("d M Y",strtotime($coupon->valid));?></b></li>
                        <li><img class="img img-responsive" src="<?php echo base_url();?>assets/images/<?php echo $coupon->image;?>" /></li>
                      </ul>
                      <br/>
                      <div class="pd-10 text-center"> 
                     
                      <a class="btn btn-xs btn-warning" href="<?php echo base_url();?>admin/manage_coupons/<?php echo $coupon->id;?>"><i class="fa fa-edit"></i> Edit</a>
                       <a class="btn btn-xs btn-danger" href="<?php echo base_url();?>admin/coupon_del/<?php echo $coupon->id;?>"><i class="fa fa-trash-o"></i> Delete</a>
                      </div>	
                    </div>
                  </div>
                </div>
               <?php }?>
                
                
              </div>
              <!-- vd_pricing-table --> 
              
            </div>
          </div>
        </div>
        <!-- .vd_content --> 
      </div>
      <!-- .vd_container --> 
    </div>
  </div>
  <!-- .container --> 
</div>
<!-- .content -->

<!-- Footer Start -->
  <footer class="footer-1"  id="footer">      
    <div class="vd_bottom ">
        <div class="container">
            <div class="row">
              <div class=" col-xs-12">
                <div class="copyright">
                  	Copyright &copy;2017 YaaraIndia. All Rights Reserved 
                </div>
              </div>
            </div><!-- row -->
        </div><!-- container -->
    </div>
  </footer>
<!-- Footer END -->
  

</div>

<!-- .vd_body END  -->
<a id="back-top" href="#" data-action="backtop" class="vd_back-top visible"> <i class="fa  fa-angle-up"> </i> </a>

<!--
<a class="back-top" href="#" id="back-top"> <i class="icon-chevron-up icon-white"> </i> </a> -->

<!-- Javascript =============================================== --> 
<!-- Placed at the end of the document so the pages load faster --> 
<script>	
					$(document).ready(function(){ 
					$("#show").click(function(){
						$("#table").toggleClass("col-md-8","col-md-12");
						$("#tform").toggle();
					});
//						$(".tailor_del").click(function(){
//							var tid=$(this).attr('id');
//							$(this).closest("tr").remove();
//							$.ajax({
//							 type: "POST",
//							 url: '<?php //echo base_url();?>index.php/product/tailor_del',
//							 data: {tid:tid},
//							 success: function(response){
//								 //alert(response);
//							 }
//							 });
//						});
//					
					});
				</script>
<script type="text/javascript" src='<?php echo base_url();?>adminassets/plugins/jquery-ui/jquery-ui.custom.min.js'></script>
<script type="text/javascript" src="<?php echo base_url();?>adminassets/plugins/jquery-ui-touch-punch/jquery.ui.touch-punch.min.js"></script>

<script type="text/javascript" src="<?php echo base_url();?>adminassets/js/caroufredsel.js"></script> 
<script type="text/javascript" src="<?php echo base_url();?>adminassets/js/plugins.js"></script>

<script type="text/javascript" src="<?php echo base_url();?>adminassets/plugins/breakpoints/breakpoints.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>adminassets/plugins/dataTables/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>adminassets/plugins/prettyPhoto-plugin/js/jquery.prettyPhoto.js"></script> 

<script type="text/javascript" src="<?php echo base_url();?>adminassets/plugins/mCustomScrollbar/jquery.mCustomScrollbar.concat.min.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>adminassets/plugins/tagsInput/jquery.tagsinput.min.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>adminassets/plugins/bootstrap-switch/bootstrap-switch.min.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>adminassets/plugins/blockUI/jquery.blockUI.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>adminassets/plugins/pnotify/js/jquery.pnotify.min.js"></script>

<script type="text/javascript" src="<?php echo base_url();?>adminassets/js/theme.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>adminassets/custom/custom.js"></script>

<script type="text/javascript" src="<?php echo base_url();?>adminassets/plugins/dataTables/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>adminassets/plugins/dataTables/dataTables.bootstrap.js"></script>


</body>
</html>