 <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1 class="m-0 text-dark">Wallet</h1>
          </div><!-- /.col -->
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="<?php echo base_url() ?>admin/admin/dashboard">Dashboard</a></li>
              <li class="breadcrumb-item"><a href="#">My Store</a></li>
              <li class="breadcrumb-item active">Wallet</li>

            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->
    <!-- Main content -->
    <?php
    $atp_id = user_id();
    $this->db->select('user_wallet_balance, user_id, user_atp_current_package');
    $this->db->where('user_id', $atp_id);
    $atp_details = $this->db->get('users')->row();

    $this->db->where('user_id', $atp_details->user_id);
    $this->db->order_by('id', 'desc');
    $get_recharge_details_by_user_id = $this->db->get('wallet_recharge_details')->result();

    ?>
    <section class="content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-sm-4">
            <div class="info-box mb-3"  style="background-color: #267c39;">
              <span class="info-box-icon"><i style="color:#fff" class="fas fa-wallet"></i></span>

              <div class="info-box-content">
                <span class="info-box-text" style="color:#fff">Wallet Balance</span>
                <span class="info-box-number" style="color:#fff">&#x20B9; <?php echo $atp_details->user_wallet_balance ?></span>
               
              </div>
              <!-- /.info-box-content -->
            </div>
          </div>
          <?php if($atp_details->user_atp_current_package > 0): ?>
           <!--  <div class="col-sm-4">
              <a href="#" data-toggle="modal" data-target="#recharge-model">
                <div class="info-box mb-3 bg-info" style="background-color:orange!important">
                  <div class="info-box-content" style="text-align: center;">
                    <span class="info-box-text"><i class="fa fa-plus" aria-hidden="true"></i></span>
                    <span   class="info-box-number">Recharge Your Wallet</span>
                  </div>
                 /.info-box-content
                </div>
              </a>
            </div> -->
          <?php endif; ?>
        </div>
      </div>
    </section>
    <section class="content">
      <div class="demo">
        <div class="container">
            <div class="row">
              <?php 
              $i=1; 
              foreach ($all_package as $key => $package):
                // Generate random RGB values for each color component
                // Use the RGB values to create a dynamic color
                $color = $package->package_color;
                ?>
                <div class="col-md-3 col-sm-6">
                    <div class="pricingTable green_<?php echo $i; ?>">
                        <div class="pricingTable-header">
                            <i class=""><img src="<?php echo base_url(); ?><?php echo $package->package_image; ?>" alt="" width="70px"></i>
                            <div class="price-value"> ₹<?php echo $package->package_price; ?>.00 <i style="font-size: 15px;">+ <?php echo $app_setting->gst_percantage?>% GST</i><span class="month"></span> </div>
                        </div>
                        <h3 class="heading"><?php echo $package->package_name; ?></h3>
                        <div class="pricing-content">
                            <ul>
                              <li style="font-size: 17px"><b>Balance Recived ₹<?php echo $package->package_balance_amount; ?></b></li>
                              <?php if($package->package_program_type == 1): ?>
                                <li>Studnet Reg. Charge <b>₹<?php echo $package->package_student_reg_fee; ?></b></li>
                              <?php else: ?>
                                <li>Studnet Reg. Royalty <b><?php echo $package->package_student_reg_fee; ?>%</b></li>
                              <?php endif; ?>
                              <li>Student Lead Charge <b>₹<?php echo $package->package_lead_price; ?></b></li>
                              <li>Digital Certificate Change <b>₹<?php echo $package->package_digital_certificate_price; ?></b></li>
                              <li>Live Class Charge <b>₹<?php echo $package->package_live_class_price; ?></b></li>
                              <li>Video Course Charge <b><?php echo $package->package_video_course_percantage; ?>%</b></li>

                            </ul>
                        </div>
                        <?php if(atp_details()->user_atp_current_package == $package->package_id):?>
                          <div class="pricingTable-signup text-center">
                              <a>ACTIVE PACKAGE</a>
                          </div>
                          <div class="pricingTable-signup text-center mt-3">
                              <a class="bg-primary" onclick="return confirm('Are you sure? Yow Want to Active <?php echo $package->package_name; ?>.')" href="<?php echo base_url(); ?>admin/store/active_package/<?php echo $package->package_rand_code; ?>">
                                <span class="d-flex text-center">Reactive Package</span>
                                <small>Pay Only ₹<?php $tax_amt = ($package->package_price * $app_setting->gst_percantage) / 100;
                                echo $package->package_price + $tax_amt; ?></small></a>
                          </div>
                        <?php else: ?>
                          <div class="pricingTable-signup text-center">
                              <a onclick="return confirm('Are you sure? Yow Want to Active <?php echo $package->package_name; ?>.')" href="<?php echo base_url(); ?>admin/store/active_package/<?php echo $package->package_rand_code; ?>">
                                <span class="d-flex text-center">Active Now</span>
                                <small>Pay Only ₹<?php $tax_amt = ($package->package_price * $app_setting->gst_percantage) / 100;
                                echo $package->package_price + $tax_amt; ?></small></a>
                          </div>
                        <?php endif;?>
                    </div>
                </div>
                <style type="text/css">
                  .pricingTable.green_<?php echo $i; ?> .heading,
                  .pricingTable.green_<?php echo $i; ?> .price-value {
                      color: <?php echo $color; ?>
                  }

                  .pricingTable.green_<?php echo $i; ?> .pricingTable-signup a,
                  .pricingTable.green_<?php echo $i; ?>:hover .pricingTable-header {
                      background: <?php echo $color; ?>
                  }

                  .pricingTable.green_<?php echo $i; ?> .pricingTable-signup a:hover {
                      box-shadow: 0 0 10px <?php echo $color; ?>
                  }
                </style>
              <?php $i++; endforeach;?>
            </div>
        </div>
    </div>
    </section>
    <section class="content">
      <div class="container-fluid">
        <!-- Info boxes -->
        <div class="card card-default">
          <div class="card-header">
            <h3 class="card-title">Wallet Recharge History</h3>
            <div class="card-tools">
              <form>
                <label for="start-date">Start date:</label>
                <input type="date" id="start-date" required name="start_date_r">
                <label for="end-date">End date:</label>
                <input type="date" id="end-date" required name="end_date_r">
                <button type="submit" class="btn btn-success btn-sm">Search</button>
              </form>
            </div>
          </div>
         
           
            <!-- /.card-header -->
            <div class="card-body">
              <table id="example101" class="table table-bordered table-striped">
                <thead>
                <tr>
                  <th>id</th>
                  <th>Date</th>
                  <th>Package Amount</th>
                  <th>GST</th>
                  <th>Total Recharge Amount</th>
                  <th>Credit Amount</th>
                  <th>Status</th>
                  <th>Payment ID</th>
                  <th>Comment</th>
                  <!-- <th>Invoice</th> -->
                </tr>
                </thead>
                <tbody>
                  <?php 
                  $a=1;
                  $recharge_package_amount = 0; 
                  $rechage_amount = 0;
                  $credit_amount = 0;
                  foreach ($get_recharge_details_by_user_id as $key => $recharge):
                  if($recharge->comment == 'Wallet Recharge'): 
                    if(isset($_GET['start_date_r']))
                    {
                      if(date('Y-m-d', strtotime($recharge->date)) > $_GET['start_date_r']  && date('Y-m-d', strtotime($recharge->date)) < $_GET['end_date_r'])
                      {
                        $recharge_package_amount += $recharge->recharge_package_amount;
                        $rechage_amount += $recharge->rechage_amount;
                        $credit_amount += $recharge->credit_amount;
                      ?>
                        <tr>
                          <td><?php echo $a ?></td>
                          <td><?php echo date('d-m-Y h:i a', strtotime($recharge->date)) ?></td>
                          <td><?php echo $recharge->recharge_package_amount ?></td>
                          <td><?php echo $app_setting->gst_percantage ?>%</td>
                          <td><?php echo $recharge->rechage_amount ?></td>
                          <td><?php echo $recharge->credit_amount ?></td>
                          <td>
                          <?php if($recharge->payment_status == 'Credit'){?>
                              <span class="badge badge-success"><?php echo $recharge->payment_status ?></span>
                          <?php }else{?>
                              <span class="badge badge-danger"><?php echo $recharge->payment_status ?></span>
                          <?php }; ?>
                          </td>
                          <td><?php echo $recharge->rechage_id ?></td>
                          <td><?php echo $recharge->comment ?></td>
                        </tr>
                    <?php };
                  } else {

                        $recharge_package_amount += $recharge->recharge_package_amount;
                        $rechage_amount += $recharge->rechage_amount;
                        $credit_amount += $recharge->credit_amount;
                        ?>
                      <tr>
                        <td><?php echo $a ?></td>
                        <td><?php echo date('d-m-Y h:i a', strtotime($recharge->date)) ?></td>
                        <td><?php echo $recharge->recharge_package_amount ?></td>
                        <td><?php echo $app_setting->gst_percantage ?>%</td>
                        <td><?php echo $recharge->rechage_amount ?></td>
                        <td><?php echo $recharge->credit_amount ?></td>
                        <td>
                        <?php if($recharge->payment_status == 'Credit'){?>
                            <span class="badge badge-success"><?php echo $recharge->payment_status ?></span>
                        <?php }else{?>
                            <span class="badge badge-danger"><?php echo $recharge->payment_status ?></span>
                        <?php }; ?>
                        </td>
                        <td><?php echo $recharge->rechage_id ?></td>
                        <td><?php echo $recharge->comment ?></td>
                      </tr>
                    <?php }; ?>
                  <?php endif;
                  $a++; ?>
                  <?php endforeach; ?>
                  <tr>
                    <td></td>
                    <td><b>Total</b></td>
                    <td><?php echo $recharge_package_amount?></td>
                    <td></td>
                    <td><?php echo $rechage_amount; ?></td>
                    <td><?php echo $credit_amount; ?></td>
                    <td></td>
                    <td></td>
                    <td></td>
                  </tr>
                </tbody>
               
              </table>
            </div>
          </div>
        </div>
      </section>
    

    <section class="content">
      <div class="container-fluid">
        <!-- Info boxes -->
        <div class="card card-default">
          <div class="card-header">
            <h3 class="card-title">Wallet Utilization History</h3>
            <div class="card-tools">
              <form>
                <label for="start-date">Start date:</label>
                <input type="date" id="start-date" required name="start_date_h">
                <label for="end-date">End date:</label>
                <input type="date" id="end-date" required name="end_date_h">
                <button type="submit" class="btn btn-success btn-sm">Search</button>
              </form>
            </div>
          </div>
            <div class="card-body">
             
              <table id="example100" class="table table-bordered table-striped">
                <thead>
                <tr>
                  <th>id</th>
                  <th>Date</th>
                  <th>Amount</th>
                  <th>Status</th>
                  <th>Payment ID</th>
                  <th>Comment</th>
                </tr>
                </thead>
                <tbody>
                
                <?php $i=1; foreach ($get_recharge_details_by_user_id as $key => $recharge):?>
                  <?php if($recharge->payment_status == 'Debit'):
                  if(isset($_GET['start_date_h']))
                  {
  
                    if(date('Y-m-d', strtotime($recharge->date)) > $_GET['start_date_h']  && date('Y-m-d', strtotime($recharge->date)) < $_GET['end_date_h'])
                    {
                      $rechage_amount_2 += $recharge->rechage_amount;
                    ?>
                    <tr>
                      <td><?php echo $i ?></td>
                      <td><?php echo date('d-m-Y', strtotime($recharge->date)) ?></td>
                      <?php if($recharge->payment_status == 'Credit'){?>
                        <td><?php echo $recharge->rechage_amount ?></td>
                      <?php }else{?>
                          <td><?php echo $recharge->rechage_amount ?></td>
                      <?php }; ?>
                      <td>
                      <?php if($recharge->payment_status == 'Credit'){?>
                          <span class="badge badge-success"><?php echo $recharge->payment_status ?></span>
                      <?php }else{?>
                          <span class="badge badge-danger"><?php echo $recharge->payment_status ?></span>
                      <?php }; ?>
                      </td>
                      <td><?php echo $recharge->rechage_id ?></td>
                      <td><?php echo $recharge->comment ?></td>
                    </tr>
                    <?php 
                    }
                  }
                  else
                    {
                    $rechage_amount_2 += $recharge->rechage_amount;
                    ?>
                      <tr>
                      <td><?php echo $i ?></td>
                      <td><?php echo date('d-m-Y', strtotime($recharge->date)) ?></td>
                      <?php if($recharge->payment_status == 'Credit'){?>
                        <td><?php echo $recharge->rechage_amount ?></td>
                      <?php }else{?>
                          <td><?php echo $recharge->rechage_amount ?></td>
                      <?php }; ?>
                      <td>
                      <?php if($recharge->payment_status == 'Credit'){?>
                          <span class="badge badge-success"><?php echo $recharge->payment_status ?></span>
                      <?php }else{?>
                          <span class="badge badge-danger"><?php echo $recharge->payment_status ?></span>
                      <?php }; ?>
                      </td>
                      <td><?php echo $recharge->rechage_id ?></td>
                      <td><?php echo $recharge->comment ?></td>
                    </tr>
                  <?php }?>
                <?php endif; $i++;  endforeach; ?>
                <tr>
                  <td></td>
                  <td><b>Total</b></td>
                  <td><?php echo $rechage_amount_2; ?></td>
                  <td></td>
                  <td></td>
                  <td></td>
                </tr>
                </tbody>
               
              </table>
            </div>
        </div>
      </div><!--/. container-fluid -->
    </section>
    <!-- /.content -->
  </div>
<script type="text/javascript">
$(function () {
  $('#example100').DataTable( {
    "responsive": true,
    "lengthChange": true, 
    "autoWidth": false,  
    "searching": true,
    "ordering": false,
    dom: 'Bfrtip',
    buttons: [
         {
            extend: 'print',
            footer: false,
            title: '<table class="table table-condensed"><tbody><tr style="border:1px ridge gray"><td class="no-line"><br/><br/><img src="<?php echo base_url().atp_details()->user_atp_logo ?>" style="padding:10px;width:200px"></td><td class="no-line text-right" align="right"><center><h1><b style="font-family:"Merriweather",serif"><?php echo preg_replace('/[^a-zA-Z0-9]/', ' ',atp_details()->user_business_name); ?></b></h1><b></b><br/><b>Helpline No : <?php echo atp_details()->user_mobile; ?></b> | <b><?php echo atp_details()->user_email; ?></b><br/><b>GSTIN : <?php echo atp_details()->user_gst; ?></b></center></td></tr></tbody></table><table class="table table-condensed"><tbody><tr style="border:1px ridge gray; text-align:center"><td><h3>Wallet Utilization History</h3></td></tr></tbody></table>',
            
         } 
         ,
          {
              extend: 'excel',
              title: '<?php echo preg_replace('/[^a-zA-Z0-9]/', ' ',atp_details()->user_business_name); ?> | Wallet Utilization History',
          }        
      ],
  });
  $('#example101').DataTable( {
    "responsive": true,"lengthChange": true, "autoWidth": false,  "searching": true,"ordering": false,
      dom: 'Bfrtip',
      buttons: [
         {
            extend: 'print',
            footer: false,
            title: '<table class="table table-condensed"><tbody><tr style="border:1px ridge gray"><td class="no-line"><br/><br/><img src="<?php echo base_url().atp_details()->user_atp_logo ?>" style="padding:10px;width:200px"></td><td class="no-line text-right" align="right"><center><h1><b style="font-family:"Merriweather",serif"><?php echo preg_replace('/[^a-zA-Z0-9]/', ' ',atp_details()->user_business_name); ?></b></h1><b></b><br/><b>Helpline No : <?php echo atp_details()->user_mobile; ?></b> | <b><?php echo atp_details()->user_email; ?></b><br/><b>GSTIN : <?php echo atp_details()->user_gst; ?></b></center></td></tr></tbody></table><table class="table table-condensed"><tbody><tr style="border:1px ridge gray; text-align:center"><td><h3>Wallet Recharge History</h3></td></tr></tbody></table>',
            
         } 
         ,
          {
              extend: 'excel',
              title: '<?php echo preg_replace('/[^a-zA-Z0-9]/', ' ',atp_details()->user_business_name); ?> | Wallet Recharge History',
          }        
      ],
  });
});
  </script>


<?php
$package = $this->setting_model->get_package_by_id(atp_details()->user_atp_current_package); 
?>
  <!-- /.content-wrapper -->

<div class="modal fade" id="recharge-model" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Enter Amount</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <?php echo form_open('admin/store/add_recharge_amount', ['id' => 'payment_form']); ?>
          <div class="form-group">
            <label for="message-text" class="col-form-label">Enter Amount: <span style="color: red">*</span></p></label>
            <input type="number" class="form-control" id="message-text" name="amount" required placeholder="Enter Amount">
          </div>
             <div class="form-group">
              <div for="message-text" class="">GST: &#x20B9; <span id="amount_id"></span></p></div>
              <div for="message-text" class="">Recive Amount: &#x20B9; <span id="amount"></span></p></div>
            </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
          <button type="submit" class="btn btn-primary">Submit</button>
        </div>
      <?php echo form_close() ?>
    </div>
  </div>
</div>
<script type="text/javascript">
  $("#payment_form").submit(function(){
    var main_amt = $('#message-text').val();
    if(main_amt < 1000)
    {
      swal("Oops!", "Please Enter Max 1000 & Min <?php echo $package->package_price?>", 'error');
      return false;
    }
    else if(main_amt > <?php echo $package->package_price?>)
    {
      swal("Oops!", "Please Enter Max 1000 & Min <?php echo $package->package_price?>", 'error');
      return false;
    }
    else
    {
      $("#payment_form").submit();
    }
    
  });
  $("#message-text").keyup(function(){
    var amount = $('#message-text').val();
    var gst = "<?php echo $app_setting->gst_percantage; ?>"
    var data = Math.round((amount * parseInt(gst) / 100));
    var main =  amount - data;
    $('#amount_id').html(data);
    $('#amount').html(main);
  });
</script>


<style type="text/css">
.pricingTable {
    text-align: center;
    background: #fff;
/*     margin: 0 -15px; */
    box-shadow: 0 0 10px #ababab;
    padding-bottom: 20px;
    border-radius: 10px;
    color: #cad0de;
    transform: scale(1);
    transition: all .5s ease 0s;
    margin-bottom: 20px;
}

.pricingTable:hover {
    transform: scale(1.05);
    z-index: 1
}

.pricingTable .pricingTable-header {
    padding: 20px 0;
    background: #f5f6f9;
    border-radius: 10px 10px 50% 50%;
    transition: all .5s ease 0s
}

.pricingTable:hover .pricingTable-header {
    background: #ff9624
}

.pricingTable .pricingTable-header i {
    font-size: 50px;
    color: #858c9a;
    margin-bottom: 10px;
    transition: all .5s ease 0s
}

.pricingTable .price-value {
    font-size: 25px;
    color: #ff9624;
    transition: all .5s ease 0s
}

.pricingTable .month {
    display: block;
    font-size: 14px;
    color: #cad0de
}

.pricingTable:hover .month,
.pricingTable:hover .price-value,
.pricingTable:hover .pricingTable-header i {
    color: #fff
}

.pricingTable .heading {
    font-size: 18px;
    color: #ff9624;
    margin-bottom: 10px;
    text-transform: uppercase;
    margin-top: 20px;
}

.pricingTable .pricing-content ul {
    list-style: none;
    padding: 0;
    margin-bottom: 30px
}

.pricingTable .pricing-content ul li {
    line-height: 30px;
    color: #a7a8aa
}

.pricingTable .pricingTable-signup a {
    display: inline-block;
    font-size: 15px;
    color: #fff;
    padding: 10px 35px;
    border-radius: 20px;
    background: #ffa442;
    text-transform: uppercase;
    transition: all .3s ease 0s
}

.pricingTable .pricingTable-signup a:hover {
    box-shadow: 0 0 10px #ffa442
}

.pricingTable.blue .heading,
.pricingTable.blue .price-value {
    color: #4b64ff
}

.pricingTable.blue .pricingTable-signup a,
.pricingTable.blue:hover .pricingTable-header {
    background: #4b64ff
}

.pricingTable.blue .pricingTable-signup a:hover {
    box-shadow: 0 0 10px #4b64ff
}

.pricingTable.red .heading,
.pricingTable.red .price-value {
    color: #ff4b4b
}

.pricingTable.red .pricingTable-signup a,
.pricingTable.red:hover .pricingTable-header {
    background: #ff4b4b
}

.pricingTable.red .pricingTable-signup a:hover {
    box-shadow: 0 0 10px #ff4b4b
}



.pricingTable.blue:hover .price-value,
.pricingTable.green:hover .price-value,
.pricingTable.red:hover .price-value {
    color: #fff
}

@media screen and (max-width:990px) {
    .pricingTable {
        margin: 0 0 20px
    }
}</style>