<!-- Extend area where template is defined -->
<?= $this->extend('templates/adminlte/generalcontent') ?>
<!-- .Extend -->

<!-- Title of the page -->
<?= $this->section('title') ?>Pay Trans Review &amp; Approval<?= $this->endSection() ?>
<!-- .Title -->

<!-- CSS of the page -->
<?= $this->section('css') ?>

<?= $this->endSection() ?>
<!-- .CSS -->

<!-- body attribute - class definition -->
<?= $this->section('bodyclass') ?>sidebar-mini<?= $this->endSection() ?>
<!-- .body attribute -->

<!-- Container title -->
<?= $this->section('containertitle') ?>Payroll Transaction<span class="text-sm text-muted"> Review &amp; Approval</span><?= $this->endSection() ?>
<!-- .Container title -->

<!-- Active breadcrumb -->
<?= $this->section('breadcrumbs') ?>
<li class="breadcrumb-item"><a href="/payroll/paytrans">Payroll Transaction</a></li>
<li class="breadcrumb-item active">Payroll Transaction Review &amp; Approval</li>
<?= $this->endSection() ?>
<!-- .Active breadcrumb -->

<!-- Main content -->
<?= $this->section('main') ?>

<!-- Modal Add Branch -->
<div class="modal fade" id="mdlAddPayTrans">
  <div class="modal-dialog">
    <div class="modal-content">
      <form action="<?= url_to('payroll/addpaytrans') ?>" method="post">
        <div class="modal-header">
          <h4 class="modal-title" >New Payroll Transaction</h4>
          <button type="button" class="close" data-dismiss="modal" aria-label="Close">
            <span aria-hidden="true">&times;</span>
          </button>
        </div>
        <div class="modal-body">
          <div class="row">
            <div class="col-12">
              <p class="lead">Payroll Group Information</p>
              <div class="row">
                <div class="col-12">
                    <div class="form-group">
                        <label>Select Payroll Type</label>
                        <select class="form-control" name="paytype_id">
                            <option value="-1">-- Select Payroll Type --</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label for="txtNoOfDays">Number of Days</label>
                        <input class="form-control" type="text" id="txtNoOfDays" name="no_of_days" value="<?= old('no_of_days') ?>" readonly>
                    </div>
                    <div class="form-group">
                        <label for="txtRemarks">Remarks</label>
                        <textarea class="form-control" rows="3" placeholder="Enter remarks here..." name="remarks" id="txtRemarks"><?= old('remarks') ?></textarea>
                    </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="modal-footer">
            <button type="submit" class="btn btn-primary">Save changes</button>
            <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        </div>
      </form>
    </div>
  </div>
</div>

<?php if($payTrans->is_open): ?>
<div class="row">
    <div class="col-12">
        <div class="card">
            <div class="card-header">
                <h3 class="card-title">Information of Payroll Transaction</h3>
            </div>
            <div class="card-body">
              <p>Payroll Period: <?= $payTrans->payroll_from ?> to <?= $payTrans->payroll_to ?> [Total Days: <?= $payTrans->no_of_days ?>]</p>
              <p>Payroll Type: <?= $payTrans->paytype_name ?></p>
              <p>Schedule: <?= $payTrans->sched_name ?></p>
              <p>Total Employee: <?= $payTrans->total_emp ?></p>
              <p>Total Gross: <?= $payTrans->total_gross ?></p>
              <p>Status: <?= ($payTrans->is_open) ? 'Open' : 'Closed' ?></p>
              <table class="table table-bordered">
                  <tr>
                      <th>Total Employee</th>
                      <th>Total Gross</th>
                      <th>Total Deduction</th>
                      <th>Total Net</th>
                      <th>Total SSS Contribution</th>
                      <th>Total Philhealth Contribution</th>
                      <th>Total Pagibig Contribution</th>
                      <th>Total Tax</th>
                  </tr>
                  <tr>
                      <td><?= $totalEmp ?></td>
                      <td><?= number_format($totalGross, 2, '.', ',') ?></td>
                      <td><?= number_format($totalDeduction, 2, '.', ',') ?></td>
                      <td><?= number_format($totalNet, 2, '.', ',') ?></td>
                      <td><?= number_format($totalSSSContri, 2, '.', ',') ?></td>
                      <td><?= number_format($totalPhilhealthContri, 2, '.', ',') ?></td>
                      <td><?= number_format($totalPagibigContri, 2, '.', ',') ?></td>
                      <td><?= number_format($totalTax, 2, '.', ',') ?></td>
                  </tr>
              </table>
                
            </div>
            <div class="card-footer">
                <?php if($payTrans->is_open): ?>
                    <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#mdlClosePayTrans">Close Payroll Transaction</button>
                <?php else: ?>
                    <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#mdlOpenPayTrans">Open Payroll Transaction</button>
                <?php endif; ?>
            </div>
        </div>
    </div>
</div>
<?php else: ?>
<div class="row">
    <div class="col-12">
        <div class="card">
            <div class="card-header">
                <h3 class="card-title">Information of Payroll Transaction</h3>
            </div>
            <div class="card-body">
              <p>Payroll Period: <?= $payTrans->payroll_from ?> to <?= $payTrans->payroll_to ?> [Total Days: <?= $payTrans->no_of_days ?>]</p>
              <p>Payroll Type: <?= $payTrans->paytype_name ?></p>
              <p>Schedule: <?= $payTrans->sched_name ?></p>
              <p>Total Employee: <?= $payTrans->total_emp ?></p>
              <p>Total Gross: <?= $payTrans->total_gross ?></p>
              <p>Status: <?= ($payTrans->is_open) ? 'Open' : 'Closed' ?></p>
              <table class="table table-bordered">
                  <tr>
                      <th>Total Employee</th>
                      <th>Total Gross</th>
                      <th>Total Deduction</th>
                      <th>Total Net</th>
                      <th>Total SSS Contribution</th>
                      <th>Total Philhealth Contribution</th>
                      <th>Total Pagibig Contribution</th>
                      <th>Total Tax</th>
                  </tr>
                  <tr>
                      <td><?= $totalEmp ?></td>
                      <td><?= number_format($totalGross, 2, '.', ',') ?></td>
                      <td><?= number_format($totalDeduction, 2, '.', ',') ?></td>
                      <td><?= number_format($totalNet, 2, '.', ',') ?></td>
                      <td><?= number_format($totalSSSContri, 2, '.', ',') ?></td>
                      <td><?= number_format($totalPhilhealthContri, 2, '.', ',') ?></td>
                      <td><?= number_format($totalPagibigContri, 2, '.', ',') ?></td>
                      <td><?= number_format($totalTax, 2, '.', ',') ?></td>
                  </tr>
              </table>
                
            </div>
            <div class="card-footer">
                <?php if($payTrans->is_open): ?>
                    <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#mdlClosePayTrans">Close Payroll Transaction</button>
                <?php else: ?>
                    <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#mdlOpenPayTrans">Open Payroll Transaction</button>
                <?php endif; ?>
            </div>
        </div>
    </div>
</div>
<?php endif; ?>

<?= $this->endSection() ?>
<!-- .Main content -->

<!-- Javascript -->

<?= $this->section('js') ?>

<script>
$(document).ready(function() {
    
});

</script>

<?= $this->endSection() ?>

<!-- .Javascript -->