<script type="text/javascript" src="<?php echo $this->config->item('ckeditor_basepath'); ?>ckeditor.js"></script>
<ul class="breadcrumb">
    <li><a href="<?= site_url('admin/dashboard') ?>">Home</a></li> 
    <li class="active"><?php echo isset($coupon_id) ? $breadcum_edit : $breadcum ?></li> 
</ul>
<div class="page-content-wrap">
    <div class="row">
        <div class="col-md-12">
            <form action="" class="form-horizontal" method="post" enctype="multipart/form-data">
                <div class="panel panel-default">
                    <div class="panel-heading">                       
                        <h3 class="panel-title"><?php if($coupon_id){ ?>Edit<?php } else { ?> Add<?php } ?> Coupon</h3>
                        <ul class="panel-controls">
                            <li><a href="<?php echo site_url()?>admin/coupon-list"><span class="fa fa-backward" title="Back"></span></a></li>
                        </ul>
                    </div>
                  
                    <div class="panel-body form-group-separated">
                      
                        <div class="form-group">
                            <label class="col-md-3 col-xs-12 control-label">Coupon Code *</label>
                            <div class="col-md-6 col-xs-12">                                            
                                <div class="input-group">
                                    <span class="input-group-addon"><span class="fa fa-pencil"></span></span>
                                    <input type="text" name="coupon_code" class="form-control" value="<?= $coupon_code ?>"/>
                                </div>                                            
                                 <span class="help-block" style="color: red;"><?= strip_tags(form_error('coupon_code'))?></span>
                            </div>
                        </div>
                        
                        <div class="form-group">
                            <label class="col-md-3 col-xs-12 control-label">Coupon Price</label>
                            <div class="col-md-6 col-xs-12">                                            
                                <div class="input-group">
                                    <span class="input-group-addon"><span class="fa fa-pencil"></span></span>
                                    <input type="text" name="coupon_price" class="form-control" value="<?= $coupon_price ?>"/>
                                </div>   
                                  <span class="help-block" style="color: red;"><?= strip_tags(form_error('coupon_price'))?></span>
                            </div>
                        </div>   
                        
                        <div class="form-group">
                            <label class="col-md-3 col-xs-12 control-label">Minimum Order Amount</label>
                            <div class="col-md-6 col-xs-12">                                            
                                <div class="input-group">
                                    <span class="input-group-addon"><span class="fa fa-pencil"></span></span>
                                    <input type="text" name="minimum_order_amount" class="form-control" value="<?= $minimum_order_amount ?>"/>
                                </div>   
                                  <span class="help-block" style="color: red;"><?= strip_tags(form_error('minimum_order_amount'))?></span>
                            </div>
                        </div>                        
                        
                        
                        <div class="form-group">
                            <label class="col-md-3 control-label">Coupon Type</label>
                            <div class="col-md-9">
                                <label>
                                    <input type="radio" name="coupon_type" value="percentage" <?php echo isset($coupon_type) ? $coupon_type != 'money' ? 'checked' : "" : 'checked' ?> /> Percentage
                                </label>
                                <label>
                                    <input type="radio" name="coupon_type" value="money" <?php echo isset($coupon_type) ? $coupon_type == 'money' ? 'checked' : "" : '' ?>/> Money
                                </label>                              
                            </div>
                        </div>
                        
                        <div class="form-group">
                            <label class="col-md-3 col-xs-12 control-label">Country *</label>
                            <div class="col-md-6 col-xs-12">                                                                                            
                                <select class="form-control select" data-live-search="true" name="country_id" id="country_id">
                                       <option value="">Select Country</option>
                                     <?php foreach ($country_list as $country) { ?>
                                    <option value="<?= $country['ct_id']?>"<?php if($country['ct_id']== $country_id) { ?> selected="selected" <?php }?>><?= $country['country_name']?></option>  
                                     <?php }?>
                                </select>
                                 <span class="help-block" style="color: red;"><?= strip_tags(form_error('country_id'))?></span>
                            </div>
                        </div>
                        
                        <div class="form-group">
                            <label class="col-md-3 col-xs-12 control-label">Province*</label>
                            <div class="col-md-6 col-xs-12">                                                                                            
                                <select class="form-control select" data-live-search="true" name="province_id" id="province"> 
                                    <option value="">Select Country First</option>
                                     <?php if(isset($coupon_id)) {?>
                                     <?php foreach ($province_list as $province) { ?>
                                    <option value="<?= $province['province_id']?>"<?php if($province['province_id']== $province_id) { ?> selected="selected" <?php }?>><?= $province['province_name']?></option>  
                                     <?php }}?>
                                </select>
                                <span class="help-block" style="color: red;"><?= strip_tags(form_error('province_id'))?></span>
                            </div>
                        </div>
                        
                        <div class="form-group">
                            <label class="col-md-3 col-xs-12 control-label">Expiration Date</label>
                            <div class="col-md-6 col-xs-12">                                            
                                <div class="input-group">
                                    <span class="input-group-addon"><span class="fa fa-pencil"></span></span>
                                    <input type="text" name="expiration_date" class="form-control datepicker" value="<?= isset($expiration_date)?date('m/d/Y',$expiration_date):'' ?>"/>
                                </div>   
                                  <span class="help-block" style="color: red;"><?= strip_tags(form_error('expiration_date'))?></span>
                            </div>
                        </div>
                        
                    </div>
                    <div class="panel-footer">
                        <button class="btn btn-default" type="reset">Clear Form</button>                                    
                        <button class="btn btn-primary pull-right">Submit</button>
                    </div>
                </div>
            </form>

        </div>
    </div> 
</div>
  <script src="<?= $this->config->item('adminassets'); ?>js/plugins/bootstrap/bootstrap-datepicker.js"></script>
<script>
       function readURL(input) {
                                        if (input.files && input.files[0]) {
                                            var reader = new FileReader();
                                            //alert(input.id);
                                            reader.onload = function(e) {
                                                $('#' + input.id + '_preview').attr('src', e.target.result);
                                            }
                                            reader.readAsDataURL(input.files[0]);
                                        }
                                    }
                                    
                                    
                                    
        $(function() {
            $(".datepicker").datepicker();     
        });
                                    
</script>
<script type='text/javascript' src='<?= $this->config->item('adminassets'); ?>js/location.js'></script>

