<?php $__env->startSection('content'); ?>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<style>

.user-info {
            margin: 0 auto;
            max-width: 100%;
            background-color: #f9f9f9;
            border: 1px solid #ddd;
            border-radius: 5px;
            padding: 10px;
            margin: 0 0 10px 0;
        }
  </style>

 <div class="container-xxl flex-grow-1 container-p-y">
              <div class="row">
                <div class="col-lg-12 mb-4 order-0">
                  <div class="card">
                        <div class="card-body">
                            <div>
                                <h3><?php echo e(__('Accounting')); ?></h3>
                                <?php if(session('status')): ?>
    <div class="alert alert-success">
        <?php echo e(session('status')); ?>

    </div>
<?php endif; ?>
                            </div>
                        </div>
                  </div>
                </div>
              </div>
              <div class="card">
                <div class="card-body">

                  <div class="table-responsive text-nowrap">
                    <table id="myDataTable" class="table" width="100%" cellspacing="0">
                      <thead>
                          <tr>
                              <th><?php echo e(__('shopname')); ?></th>
                              <th><?php echo e(__('contactdetails')); ?></th>
                              <th><?php echo e(__('plantype')); ?></th>
                              <th><?php echo e(__('dues')); ?></th>
                              <th><?php echo e(__('action')); ?></th>


                          </tr>
                      </thead>
                      <tbody  class="table-border-bottom-0">
                          <!-- Table rows -->
                          <?php $__currentLoopData = $adminList; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $admin): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                          <tr>
                              <td>
                                <img src="<?php echo e(asset($admin->shopimage)); ?>" width="40px" height="40px" alt="Img">
                                <br>
                              <b>  <?php echo e($admin->shopname); ?></b>

                              </td>
                              <td>
                                <p><strong><?php echo e(__('name')); ?>:</strong> <?php echo e($admin->name); ?></p>
                                <p><?php echo e(substr($admin->adress, 0, 50) . (strlen($admin->adress) > 50 ? '...' : '')); ?></p>
                                <p><strong><?php echo e(__('Phone')); ?>:</strong> <?php echo e($admin->shopnumber); ?></p>
                                <p><strong><?php echo e(__('Email')); ?>:</strong> <?php echo e($admin->email); ?></p>
                            </td>
                              <td>
                                <?php if($admin->plan_type == 0 ): ?>
                                <span class="badge rounded-pill bg-primary"><?php echo e(__('free')); ?></span>
                            <?php elseif($admin->plan_type == 1): ?>
                            <span class="badge rounded-pill bg-primary"><?php echo e(__('standard')); ?></span>
                            <?php else: ?>
                            <span class="badge rounded-pill bg-primary"><?php echo e(__('premium')); ?></span>

                            <?php endif; ?>
                              </td>
                              <td><?php echo e($admin->dues."¥"); ?></td>
                              <td>
                                <?php if( $admin->dues !=0 ): ?>

                                

                                <a href="<?php echo e(url('super-admin/email-admin/'.$admin->id)); ?>"  class="btn btn-primary"> <?php echo e(__('emailInvoice')); ?></a><br>
                                <button style="margin-top: 5px" data-bs-toggle="modal"
                                data-bs-target="#exampleModal" onclick="adminInfo(<?php echo e($admin); ?>)"
                                type="button"class="btn btn-success"><?php echo e(__('transactions')); ?></button>
                                <?php else: ?>
                                <button data-bs-toggle="modal"
                                data-bs-target="#exampleModal" onclick="adminInfo(<?php echo e($admin); ?>)"
                                type="button"class="btn btn-success"><?php echo e(__('transactions')); ?></button>


                                <?php endif; ?>

                              </td>

                          </tr>
                          <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                      </tbody>

                  </table>
              </div>
                </div>
              </div>
        </div>


        <div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">

          <div class="modal-dialog modal-xl modal-dialog-centered">
              <div class="modal-content">
                    <div class="modal-header text-center">
                      <div class="d-flex justify-content-center align-items-center">
                      </div>
                      <div class="buttons-container">
                          <button type="button" class="btn btn-primary" id="printButton"><?php echo e(__('print')); ?></button>
                          <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                      </div>
                  </div>


                  <div class="modal-body">

                      <div class="user-info">
                        <p id="shop_name">Shop Name: ----</p>
                          <p id="repersent_name">Name: ----</p>
                          <p id="adress_name">Name: ----</p>
                          <p class="usernumber" id="usernumber">Mobile Number: ----</p>
                          <p class="ad_email" id="ad_email"> Email: ----</p>
                          <p class="regdate" id="regdate"> REG DAte: ----</p>

                      </div>


                      <div id="cart-section">
                      <div class="card"  style="padding: 0 10px">



                        <h3 class="text-center"><?php echo e(__('transactions')); ?></h3>

                              <div class="card">

                                  <div class="table-wrapper">
                                      <table class="table" id="cart-table">
                                          <thead>
                                            <tr>
                                              <th><?php echo e(__('id')); ?></th>
                                              <th><?php echo e(__('invoice no')); ?></th>
                                              <th><?php echo e(__('month')); ?></th>
                                              <th><?php echo e(__('payment Date')); ?></th>
                                              <th><?php echo e(__('ammount')); ?></th>
                                              <th><?php echo e(__('pay method')); ?></th>
                                              <th><?php echo e(__('Trans ID')); ?></th>


                                          </tr>
                                          </thead>

                                          <tbody id="cart-table-body" class="table-border-bottom-0">
                                          </tbody>
                                      </table>

                                  </div>

                              </div>







                  </div>
                      </div>
                  </div>
              </div>
              <script>
                $('#myDataTable').hide(); // Hide the table initially
                  $(document).ready(function() {
                      $('#myDataTable').DataTable({
                          order: [
                              [0, 'desc']
                          ], // Sort by the first column (index 0) in descending order
                          orderMulti: false, // Disable multi-column ordering
                          initComplete: function(settings, json) {
                              $('#myDataTable')
                                  .show(); // Show the table after DataTable initialization
                          }
                      });
                  });
          </script>
          </div>
    <script>
        function adminInfo(admin) {
          document.getElementById('repersent_name').textContent = " <?php echo e(__('name')); ?> : " + admin.name;
          document.getElementById('shop_name').textContent = " <?php echo e(__('Shop Name')); ?> : " + admin.shopname;
          document.getElementById('adress_name').textContent = " <?php echo e(__('adress')); ?> : " + admin.adress;
          document.getElementById('usernumber').textContent = " <?php echo e(__('Phone')); ?> : " + admin.shopnumber;
          document.getElementById('ad_email').textContent = " <?php echo e(__('Email')); ?> : " + admin.email;
          document.getElementById('regdate').textContent = " <?php echo e(__('RegDate')); ?> : " + admin.created_at.split('T')[0];
           var admin_id = admin.id;
          $.ajax({
            url: "<?php echo e(route('billingdetails')); ?>",
            type: 'GET',
            data: {admin_id: admin_id},
            success: function(response) {
            console.log(response);

                const tbody = document.getElementById('cart-table-body');

// Clear any existing rows from the table
tbody.innerHTML = '';
response.forEach(rowData => {
                const row = `<tr>
                                <td>${rowData.id}</td>
                                <td>${rowData.inv_no}</td>
                                <td>${rowData.month}</td>
                                <td>${rowData.pay_date}</td>
                                <td>${rowData.amount}¥</td>
                                <td>${rowData.pay_method}</td>
                                <td>${rowData.transaction_code}</td>
                            </tr>`;
                tbody.innerHTML += row;
            });

            },
            error: function(xhr) {
                // Handle any errors
                console.log(xhr.responseText);
            }
        });


        }
        function sendemail(admin){

        }
    </script>

<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/xorgeekc/public_html/medishop/resources/views/admin/admin_profile/ad_accounting.blade.php ENDPATH**/ ?>