<!DOCTYPE html>
<html >
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Coupons Report</title>

    <!-- Fonts -->
    <link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
     <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">

    <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.15/css/jquery.dataTables.css">

    <script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.15/js/jquery.dataTables.js"></script>

    <script>

        $(document).ready(function() 
        {
          $('#all').change(function() {
            if($(this).is(":checked")) 
            {  
              $("#alldiv").show(); 
              $("#customdiv").hide();
              $('#Custom').attr('checked', false);
              $('#couponid').attr('checked', false);
                $("#selectdiv").hide();
                $('#cissue').attr('checked', false);
                $("#couponissue").hide();
                $('#cuse').attr('checked', false);
                $("#usegiven").hide();
                $('#credeem1').attr('checked', false);
                $("#credeem").hide();
            }
           
         });
        $('#Custom').change(function() {
        if($(this).is(":checked")) 
        {
            $("#customdiv").show();
            $("#alldiv").hide();
            $('#all').attr('checked', false);
        }
        else
        {
          $("#customdiv").hide();
            $("#alldiv").show();
         
            $('.chbox-new').prop('checked', true);
            $('#couponid').attr('checked', false);
            $("#selectdiv").hide();
            $('#cissue').attr('checked', false);
            $("#couponissue").hide();
            $('#cuse').attr('checked', false);
            $("#usegiven").hide();
            $('#credeem1').attr('checked', false);
            $("#credeem").hide();
               
        }
        
        });
        $('#couponid').change(function() {
            if($(this).is(":checked")) 
            { $("#selectdiv").show(); }
            else
            {$("#selectdiv").hide(); }
         });
        $('#cissue').change(function() {
            if($(this).is(":checked")) 
            { $("#couponissue").show(); }
            else
            {$("#couponissue").hide(); }
         });
        $('#cuse').change(function() {
            if($(this).is(":checked")) 
            { $("#usegiven").show();  }
            else
            { $("#usegiven").hide();}
         });
         $('#credeem1').change(function() {
            if($(this).is(":checked")) 
            { $("#credeem").show();}
            else
            { $("#credeem").hide(); }
         });
      
        $('#issuefrom').datepicker({ autoclose: true  });
        $('#issueto').datepicker({ autoclose: true });
        $('#table_id').DataTable({
                "order": [[ 6, "desc" ]]
            });
      });
 
    </script>
    <style>
        .odd{
            background-color: #fififi !important;
        }
        .even{
            background-color: #e1e1e1 !important;
        }
        .rtext{
            width: 146px;
            text-align: center;
            margin-left: 26px;

        }
        .calendertext
        {
          height: 33px ;
          border-radius: 6px;
          border: solid 1px black;
            width: 67px;
            text-align: center;
                font-size: 12px;
        }
        .body-design
        {
             padding-left: 20px;
             padding-right: 20px;

        }
        hr{
               
    border-width: 1px;
        }
      .selectbox
        {
          height: 33px ;
          border-radius: 6px;
            border: solid 1px black;
            margin:-6px 0px -6px 19px;
        }
        input[type="checkbox"]
        {
            margin: 4px 5px 0;
        }
       
    </style>
</head>
<body>
<div class="content">
   <div class="body-design">
            <div class="row">
                    <div class="col-lg-12 col-md-12">
                           <div class="box-header with-border">
                                <h3 class="box-title"><center>Coupons Report</center></h3>
                           </div>
                    </div>
            </div>
   
            <div class="row" style="background-color:#f5f5f5;" >
               <div class="col-lg-2 col-md-2" style="margin-top:20px;">
               <?php echo Form::open(array('url'=>'merchant/customtokenreport/download','method'=>'POST','role'=>"form",
                            'files'=>true,'id'=>'adds-add-form')); ?>

                  <div class="right-box">
                    <input type="checkbox" class="chbox-new" name="all" id="all" value="all" checked>All<br>
                    <input type="checkbox" class="chbox" name="Custom" id="Custom" value="Custom">Custom<br>
                       <div class="customdiv" id="customdiv" style="display:none;">
                        
                          <input type="checkbox" class="chbox" name="couponid" id="couponid" value="couponid">Coupon ID<br><br>
                            <div class="selectdiv" id="selectdiv" style="display:none;">
                            <select id="cid" name="cid" class="selectbox" >
                               <option value='all' >All Coupons </option>
                               <?php foreach($allcoupon as $tokenss): ?>
                               <option value='<?php echo $tokenss->id; ?>'><?php echo $tokenss->id; ?></option>
                               <?php endforeach; ?>           
                            </select><br><br>
                            </div>

                          <input type="checkbox" class="chbox" name="cissue" id="cissue" value="cissue">Coupons Issued Between<br><br>
                              <div class="couponissue" id="couponissue" style="margin:-6px 0px -6px 19px; display:none;">
                                 <input type="text" name="issuefrom" id="issuefrom" class="calendertext" Placeholder="From"/>&emsp;
                                 <input type="text" name="issueto" id="issueto" class="calendertext" Placeholder="To"/>
                              </div><br>
                        
                          <input type="checkbox" class="chbox" name="cuse" id="cuse" value="cuse">No of Uses Given<br><br>
                            <div class="usegiven" id="usegiven" style="margin:-6px 0px -6px 19px; display:none;">
                                <input type="text" name="usefrom" id="usefrom" class="calendertext" Placeholder="From"/>&emsp;
                                 <input type="text" name="useto" id="useto" class="calendertext" Placeholder="To"/>
                            </div><br>
                            <input type="checkbox" class="chbox" name="credeem1" id="credeem1" value="credeem1">No of Times Redeemed<br><br>
                            <div class="credeem" id="credeem" style="margin:-6px 0px -6px 19px; display:none;">
                                  <input type="text" name="redeemfrom" id="redeemfrom" class="calendertext" Placeholder="From"/>&emsp;
                                    <input type="text" name="redeemto" id="redeemto" class="calendertext" Placeholder="To"/>
                            </div><br>
                             <div class="customdownload" >
                        <center >
                        <input type="submit" class="btn btn-primary"name="view report" value="Download Excel">
                        </center>
                        </div>
                        <?php echo Form::close(); ?>


                        </div> <br>
                         <div class="alldiv" id="alldiv" >
                        <center ><a href="<?php echo url('merchant/tokenreport/download'); ?>" >
                        <input type="button" class="btn btn-primary"name="view report" value="Download Excel"></a>
                        </center>
                        </div>
                    </div>
                    
                    </div>
                    
                    <div class="col-lg-10 col-md-10" style="background-color:#fff;">
                    <hr style="margin-left: -14px; margin-top: 0px;">

                    <div class="box">
                             
                                   <div class="box-body">
                                   <!--table code start-->
                                    <table id="table_id" class="table table-bordered table-striped" >
                                     <thead>
                                       <tr style="background-color:#6a91c6; color:#fff;">
                                            <th>Coupon ID</th>
                                             <th>Booklet ID</th>
                                            <th>Coupon Name</th>
                                            <th>Coupons Issued Date</th>
                                             <th>Coupons Issued Time</th>
                                            <th>Unique Code</th>
                                            <th>Mobile Number</th>
                                            <th>Member's Name</th>
                                            <th>No. of Uses given</th>
                                            <th>No. of Times Redeemed</th>
                                            <th>Expiry Date of the Coupon</th>
					    <th>Campaign ID</th>
                                            <th>Comments</th>
                                        </tr>
                                     </thead>
                                <tbody>
                                    <?php foreach($data as $token): ?>
                                      
                                        <tr>
                                        <td><?php echo $token->tokenid; ?></td>
                                        <td><?php echo $token->booklet_id; ?></td></td>
                                        <td style="word-wrap: break-word; width:60px;"><?php echo $token->tname; ?></td>
                                        <td><?php echo date('Y-m-d', strtotime($token->created_at)); ?></td>
                                                 
                                        <td><?php echo date('H:i:s', strtotime($token->created_at)); ?></td>
                                        <td><?php echo $token->token_code; ?> </td>
                                        <td><?php echo $token->mobile; ?></td>
                                        <td><?php echo $token->name; ?></td>
                                        <td><?php echo $token->use_limit; ?></td>
                                        <?php if($token->actul_used>0): ?>
                             <td><a href="<?php echo url('merchant/specifictokenreport/'.$token->token_code); ?>"><?php echo $token->actul_used; ?></a></td>
                                        <?php else: ?>
                                        <td><?php echo $token->actul_used; ?></td>
                                        <?php endif; ?>
                                        <td><?php echo date('Y-m-d',strtotime($token->token_valide)); ?></td>
                                        
					<td><?php echo $token->usefor; ?></td>
                                        <td><?php echo $token->comment; ?></td>
                                       </tr>
				       
                                    <?php endforeach; ?>
                                 </tbody>
                              </table>
                                   <!--table code ends-->
                                 
                                   </div><!--box-body-->
                             </div><!--box -->
                    </div>
            </div>
            </div><!--body design ends-->

</div><!--conten end-->
</body>
</html>
