<!-- Main Content -->

<div class="page-wrapper">

    <div class="container-fluid pt-25">

    	<div class="row">

    		<div class="col-md-12">

    			<div class="alert alert-success alert-dismissible" role="alert" <?php if($this->session->flashdata('message')==''){ ?> style="display:none" <?php } ?> >

          			<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>

          			<?php echo $this->session->flashdata('message'); ?>

        		</div>

    		</div>

    	</div>
    	<?php if($this->admin_type=='superadmin' || (in_array('7.1', $this->authority))){ ?>
        <div class="row">

            <div class="col-sm-12">

                <div class="panel panel-default card-view">

                    <div class="panel-heading">

                        <div class="pull-left">

                            <h6 class="panel-title txt-dark">Add Reward Point</h6>

                        </div>

                        <div class="clearfix"></div>

                    </div>

                    <div class="panel-wrapper collapse in">

                        <div class="panel-body">

                            <form id="couponForm" action="<?php echo base_url(A."/addRewardPoint"); ?>" method="POST">
                                <div class="row">
                                    <div class="form-group col-md-3">
                                        <label class="control-label">Point</label>
                                        <input type="number" class="form-control" name="point" placeholder="Enter Point" required />
                                    </div>
                                    <div class="form-group col-md-3">
                                        <label class="control-label">Offer Percent (%)</label>
                                        <input type="number" class="form-control" name="percent" placeholder="Enter Percent" required/>
                                    </div>
                                    <div class="form-group col-md-3">
                                        <label class="control-label">Validity (Days)</label>
                                        <input type="text" class="form-control" name="expire_days" placeholder="Enter No. of days" required />
                                    </div>
                                    <div class="form-group col-md-3"><br>
                                        <button type="submit" class="btn btn-success btn-anim mt-5">
                                            <i class="icon-rocket"></i><span class="btn-text">Add</span>
                                        </button>
                                    </div>
                                </div>
                                <div class="row">
                                </div>
                            </form>

                        </div>

                    </div>

                </div>  

            </div>

        </div>
        <?php } ?>
		<!-- Row -->

		<div class="row">

			<div class="col-sm-12">

				<div class="panel panel-default card-view">

					<div class="panel-heading">

						<div class="pull-left">

							<h6 class="panel-title txt-dark">Reward Points List</h6>

						</div>

						<div class="clearfix"></div>

					</div>

					<div class="panel-wrapper collapse in">

						<div class="panel-body">
							<?php if($this->admin_type=='superadmin' || (in_array('7.2', $this->authority))){ ?>
							<div class="table-wrap">

								<div class="table-responsive">

									<table id="datable_1" class="table table-hover display  pb-30" >

										<thead>

							                <tr>

							                  <th>SR.No.</th>

                                              <th>Point</th>

							                  <th>Offer Percent</th>
							                  <th>Validity (Days)</th>

                                              <th>Date</th>

							                  <th>Action</th>

							                </tr>

							            </thead>



							            <tbody>

							                <?php if(!empty($list)){ foreach ($list as $key => $value): ?>

							                <tr id="<?php echo "reward_point_".$value['id']; ?>">

							                  <td><?php echo $key+1; ?></td>

                                              <td><?php echo $value['point']; ?></td>

                                              <td><?php echo $value['percent']; ?></td>

							                  <td><?php echo $value['expire_days']; ?></td>

                                              <td><?php echo $value['date']; ?></td>
							                  <td>
							                  	<?php if($this->admin_type=='superadmin' || (in_array('7.3', $this->authority))){ ?>
							                    	<a href="<?php echo base_url(A.'/edit-rewards-point/'.$value['id']); ?>" class="text-inverse pr-10">
							                    		<button class="btn btn-info btn-icon-anim btn-square">
							                    			<i class="fa fa-pencil fa-lg"></i>
							                    		</button>
							                    	</a>

							                    <?php } ?>
							                    <?php if($this->admin_type=='superadmin' || (in_array('7.4', $this->authority))){ ?>
							                    	<a href="javascript:void(0)" class="text-inverse reward_point_delete" data-table="reward_point" data-id="<?php echo $value['id']; ?>">
							                    		<button class="btn btn-danger btn-icon-anim btn-square">
								                    		<i class="fa fa-trash fa-lg"></i>
								                    	</button>
							                    	</a>
							                    <?php } ?>
							                  </td>

							                </tr>

							                <?php endforeach; } ?>

							            </tbody>

									</table>

								</div>

							</div>
							<?php } ?>
						</div>

					</div>

				</div>	

			</div>

		</div>

		<!-- /Row -->

	</div>

<script type="text/javascript">

	var site_url = "<?php echo base_url(); ?>";

	var urlLink = "<?php echo A; ?>";


    $(".reward_point_delete").on("click",function(){

	    var id = $(this).attr('data-id');

	    var table = $(this).attr('data-table');

	    var ok = confirm("Are you sure you want to delete?");

	    if (ok) {

	        $.ajax({

	            url: site_url+urlLink+'/deleteCoupon',

	            type:'POST',

	            data:'id='+id+'&table='+table,

	            success: function(data){

	                if(data==1)

	                {

	                    location.reload();

	                }

	            },

	        });

	    }

	});



</script>