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

<!-- Title of the page -->
<?= $this->section('title') ?>Employee Payroll Transaction<?= $this->endSection() ?>
<!-- .Title -->

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

<!-- Select2 -->
<link rel="stylesheet" href="<?= base_url() ?>adminlte/plugins/select2/css/select2.min.css">
<link rel="stylesheet" href="<?= base_url() ?>adminlte/plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css">

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

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

<!-- Container title -->
<?= $this->section('containertitle') ?>Employee Payroll Transaction <span class="text-md text-muted">for period of <strong><?= $payTrans->payroll_from ?> to <?= $payTrans->payroll_to ?></strong> </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">Employee Payroll Transaction</li>
<?= $this->endSection() ?>
<!-- .Active breadcrumb -->

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

<!-- Modal Add Income -->
<div class="modal fade" id="mdlAddIncome">
  <div class="modal-dialog">
    <div class="modal-content">
      <form action="<?= url_to('payroll/saveemppaytransaddinded') ?>" 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 Income to Assign</label>
                    <select class="form-control" style="width: 100%;" name="inded_id">
                        <?php foreach($incomeList as $income): ?>
                          <option value="<?= $income->inded_id ?>"><?= $income->inded_name ?></option>
                        <?php endforeach; ?>
                    </select>
                    <input type="hidden" name="emppaytrans_id" id="txtInEmpPayTransId" >
                    
                  </div>
                  <div class="form-group">
                    <div class="form-check">
                        <input class="form-check-input" type="radio" id="rdoInDaysBasedAmount" name="amount_type" value="daysbased" checked>
                        <label for="rdoInDaysBasedAmount" class="form-check-label">Daily based amount.</label>
                        <p class="text-muted"><small><i>Your amount entered multiplied by number of days</i></small></p>
                    </div>
                    <div class="form-check">
                        <input class="form-check-input" type="radio" id="rdoInFixedAmount" name="amount_type" value="fixed">
                        <label for="rdoInFixedAmount" class="form-check-label">Fixed amount.</label>
                    </div>
                    <div class="form-check">
                        <input class="form-check-input" type="radio" id="rdoInPercentageAmount" name="amount_type" value="perc">
                        <label for="rdoInPercentageAmount" class="form-check-label">Amount is in percentage.</label>
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="txtInAmount">Amount</label>
                    <input class="form-control" type="text" id="txtInAmount" name="amount" step="0.01" values="<?= old('amount') ?>">
                  </div>
                  <div class="form-group">
                    <div class="custom-control custom-checkbox">
                        <input class="custom-control-input" type="checkbox" id="chkInIsOverride" name="is_override">
                        <label for="chkInIsOverride" class="custom-control-label">Override computations if there are any.</label>
                        <p><small><i>Override will implement this amount and not the computational amount made like in SSS, Philhealth, Pag-IBIG and taxastion</i></small></p>
                    </div>  
                  </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>

<!-- Modal Add Deduction -->
<div class="modal fade" id="mdlAddDeduction">
  <div class="modal-dialog">
    <div class="modal-content">
      <form action="<?= url_to('payroll/saveemppaytransaddinded') ?>" 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 Deduciton to Assign</label>
                    <select class="form-control" style="width: 100%;" name="inded_id">
                        <?php foreach($deductionList as $deduction): ?>
                          <option value="<?= $deduction->inded_id ?>"><?= $deduction->inded_name ?></option>
                        <?php endforeach; ?>
                    </select>
                    <input type="hidden" name="emppaytrans_id" id="txtDedEmpPayTransId" >
                    
                  </div>
                  <div class="form-group">
                    <div class="form-check">
                        <input class="form-check-input" type="radio" id="rdoDedDaysBasedAmount" name="amount_type" value="daysbased" checked>
                        <label for="rdoDedDaysBasedAmount" class="form-check-label">Daily based amount.</label>
                        <p class="text-muted"><small><i>Your amount entered multiplied by number of days</i></small></p>
                    </div>
                    <div class="form-check">
                        <input class="form-check-input" type="radio" id="rdoDedFixedAmount" name="amount_type" value="fixed">
                        <label for="rdoDedFixedAmount" class="form-check-label">Fixed amount.</label>
                    </div>
                    <div class="form-check">
                        <input class="form-check-input" type="radio" id="rdoDedPercentageAmount" name="amount_type" value="perc">
                        <label for="rdoDedPercentageAmount" class="form-check-label">Amount is in percentage.</label>
                    </div>
                    
                  </div>
                  <div class="form-group">
                    <label for="txtDedAmount">Amount</label>
                    <input class="form-control" type="text" id="txtDedAmount" name="amount" step="0.01" values="<?= old('amount') ?>">
                  </div>
                  <div class="form-group">
                    <div class="custom-control custom-checkbox">
                        <input class="custom-control-input" type="checkbox" id="chkDedIsOverride" name="is_override">
                        <label for="chkDedIsOverride" class="custom-control-label">Override computations if there are any.</label>
                        <p><small><i>Override will implement this amount and not the computational amount made like in SSS, Philhealth, Pag-IBIG and taxastion</i></small></p>
                    </div>  
                  </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>

<!-- Modal Edit Income Deduction -->
<div class="modal fade" id="mdlEditIncomeDeduction">
  <div class="modal-dialog">
    <div class="modal-content">
      <form action="<?= url_to('payroll/saveemppaytransaddinded') ?>" method="post">
        <div class="modal-header bg-warning">
          <h4 class="modal-title" >Edit Income or Deduction</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">Income or Deduction Information</p>
              <div class="row">
                <div class="col-12">
                  <div class="form-group">
                    <label for="txtEditInDedName">Income Name</label>
                    <input class="form-control" type="text" readonly id="txtEditInDedName" name="inded_name">
                    <input type="hidden" name="emppaytransinded_id" id="hdnEditInDedEmpPayTransInDedId" >
                    <input type="hidden" name="emppaytrans_id" id="hdnEditInDedEmpPayTransId" >
                    <input type="hidden" name="inded_id" id="hdnEditInDedInDedId" >
                    
                  </div>
                  <div class="form-group">
                    <div class="form-check">
                        <input class="form-check-input" type="radio" id="rdoEditInDedDaysBasedAmount" name="amount_type" value="daysbased" checked>
                        <label for="rdoEditInDedDaysBasedAmount" class="form-check-label">Daily based amount.</label>
                        <p class="text-muted"><small><i>Your amount entered multiplied by number of days</i></small></p>
                    </div>
                    <div class="form-check">
                        <input class="form-check-input" type="radio" id="rdoEditInDedFixedAmount" name="amount_type" value="fixed">
                        <label for="rdoEditInDedFixedAmount" class="form-check-label">Fixed amount.</label>
                    </div>
                    <div class="form-check">
                        <input class="form-check-input" type="radio" id="rdoEditInDedPercentageAmount" name="amount_type" value="perc">
                        <label for="rdoEditInDedPercentageAmount" class="form-check-label">Amount is in percentage.</label>
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="txtEditInDedAmount">Amount</label>
                    <input class="form-control" type="text" id="txtEditInDedAmount" name="amount" step="0.01" values="<?= old('amount') ?>">
                    <p id="lblEditInDed_daysbased"></p>
                  </div>
                  <div class="form-group">
                    <div class="custom-control custom-checkbox">
                        <input class="custom-control-input" type="checkbox" id="chkEditInDedIsOverride" name="is_override">
                        <label for="chkEditInDedIsOverride" class="custom-control-label">Override computations if there are any.</label>
                        <p><small><i>Override will implement this amount and not the computational amount made like in SSS, Philhealth, Pag-IBIG and taxastion</i></small></p>
                    </div>  
                  </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>


<!-- Payroll Group selection -->
<div class="row">
    <div class="col-12">
        <div class="card">
            <div class="card-header">
                <h3 class="card-title">Select Payroll Group to Process</h3>
            </div>
            <div class="card-body">
                <div class="row">
                  <div class="col-12">
                    <form action="/payroll/emppaytrans/<?= $payTrans->paytrans_id ?>" method="get">
                      <div class="form-group">
                        <label>Payroll Group</label>
                        <div class="input-group mb-3">  
                          <select class="form-control select2 rounded-0" name="grpid">
                            <option value="-1">-- Select --</option>
                            <?php foreach($paygroups as $paygroup): ?>
                              <?php $selected = ($paygroupid != null && $paygroupid == $paygroup->pay_group_id) ? 'selected' : ''; ?>
                              <option value="<?= $paygroup->pay_group_id ?>" <?= $selected ?>><?= '['.$paygroup->pay_group_code.'] '.$paygroup->pay_group_name ?></option>
                            <?php endforeach; ?>
                          </select>
                          <span class="input-group-append">
                            <button type="submit" class="btn btn-info btn-flat">View from this Group</button>
                          </span>
                        </div>
                      </div>
                    </form>
                  </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- Employee Income And Transaction Adjustment -->
<div class="row">
    <div class="col-12">
        <?php if(isset($emppaytrans)): foreach($emppaytrans as $empPayTransaction): ?>
          <div id="payrollTabInfo<?= $empPayTransaction['empPayTrans']->emppaytrans_id ?>" class="card card-primary card-outline card-tabs" style="display:none;">
            <div class="card-header p-0 pt-1 border-bottom-0">
              <ul class="nav nav-tabs" id="payroll-tab" role="tablist">
                <li class="nav-item">
                  <a class="nav-link active" id="payroll-tab-PayInfo-tab<?= $empPayTransaction['empPayTrans']->emppaytrans_id ?>" data-toggle="pill" 
                  href="#payroll-tab-PayInfo<?= $empPayTransaction['empPayTrans']->emppaytrans_id ?>" role="tab" aria-controls="custom-tabs-three-home" aria-selected="true">Payroll Information of <strong><?= $empPayTransaction['empPayTrans']->last_name.', '.$empPayTransaction['empPayTrans']->first_name ?></strong></a>
                </li>
                <li class="nav-item">
                  <a class="nav-link" id="payroll-tab-PayInDed-tab<?= $empPayTransaction['empPayTrans']->emppaytrans_id ?>" data-toggle="pill" 
                  href="#payroll-tab-PayInDed<?= $empPayTransaction['empPayTrans']->emppaytrans_id ?>" role="tab" aria-controls="custom-tabs-three-profile" aria-selected="false">Income and Deduction</a>
                </li>
              </ul>
            </div>
            <div class="card-body">
              <div class="tab-content" id="payroll-tabContent">
                <div class="tab-pane fade show active" id="payroll-tab-PayInfo<?= $empPayTransaction['empPayTrans']->emppaytrans_id ?>" role="tabpanel" 
                aria-labelledby="payroll-tab-PayInfo-tab<?= $empPayTransaction['empPayTrans']->emppaytrans_id ?>">
                  
                  <form action="/payroll/emppaytransupdateworkdays" method="post">
                    <div class="card">
                      <div class="card-body">
                        <div class="row">
                          <div class="col-12 col-sm-4">
                            <div class="form-group">
                              <label>Daily Rate</label>
                              <input type="text" class="form-control" value="<?= number_format($empPayTransaction['empPayTrans']->basic_daily_pay, 2) ?>" readonly>
                            </div>
                          </div>
                          <div class="col-12 col-sm-4">
                            <div class="form-group">
                              <label>Work Days</label>
                              <input type="number" step="0.05" class="form-control" name="actual_work_days" value="<?= number_format($empPayTransaction['empPayTrans']->actual_work_days, 2) ?>">
                              <input type="hidden" name="emppaytrans_id" value="<?= $empPayTransaction['empPayTrans']->emppaytrans_id ?>">
                            </div>
                          </div>
                          <div class="col-12 col-sm-4">
                            <div class="form-group">
                              <label>Salary</label>
                              <input type="text" class="form-control" value="<?= number_format($empPayTransaction['empPayTrans']->basic_pay, 2) ?>" readonly>
                            </div>
                          </div>
                        </div>
                        <div class="row">
                          <div class="col-12 col-sm-4">
                            <div class="form-group">
                              <label>Taxable Income</label>
                              <input type="text" class="form-control" value="<?= number_format($empPayTransaction['empPayTrans']->taxable_income, 2) ?>" readonly>
                            </div>
                          </div>
                          <div class="col-12 col-sm-4">
                            <div class="form-group">
                              <label>Nontaxable Income</label>
                              <input type="text" class="form-control" value="<?= number_format($empPayTransaction['empPayTrans']->nontaxable_income, 2) ?>" readonly>
                            </div>
                          </div>
                          <div class="col-12 col-sm-4">
                            <div class="form-group">
                              <label>Gross Salary</label>
                              <input type="text" class="form-control" value="<?= number_format($empPayTransaction['empPayTrans']->gross_income, 2) ?>" readonly>
                            </div>
                          </div>
                        </div>
                        <div class="row">
                          <div class="col-12 col-sm-4">
                            <div class="form-group">
                              <label>Taxable Deductions</label>
                              <input type="text" class="form-control" value="<?= number_format($empPayTransaction['empPayTrans']->taxable_deduction, 2) ?>" readonly>
                            </div>
                          </div>
                          <div class="col-12 col-sm-4">
                            <div class="form-group">
                              <label>Nontaxable Deductions</label>
                              <input type="text" class="form-control" value="<?= number_format($empPayTransaction['empPayTrans']->nontaxable_deduction, 2) ?>" readonly>
                              <p><i class="small">(this will be deducted to taxable income)</i></p>
                            </div>
                          </div>
                          <div class="col-12 col-sm-4">
                            <div class="form-group">
                              <label>Total Deduction</label>
                              <input type="text" class="form-control" value="<?= number_format($empPayTransaction['empPayTrans']->total_deduction, 2) ?>" readonly>
                            </div>
                          </div>
                        </div>
                        <div class="row">
                          <div class="col-12 col-sm-6">
                            <div class="form-group">
                              <label>Income Tax</label>
                              <input type="text" class="form-control" value="<?= number_format($empPayTransaction['empPayTrans']->income_tax, 2) ?>" readonly>
                            </div>
                          </div>
                          <div class="col-12 col-sm-6">
                            <div class="form-group">
                              <label>Net Income</label>
                              <input type="text" class="form-control" value="<?= number_format($empPayTransaction['empPayTrans']->net_pay, 2) ?>" readonly>
                            </div>
                          </div>
                        </div>
                      </div>
                      <div class="card-footer">
                        <button type="submit" class="btn btn-primary">Save Changes</button>
                        <a href="/payroll/emppaytransrecom/<?= $empPayTransaction['empPayTrans']->emppaytrans_id ?>" class="btn btn-primary">Recompute Payroll</a>
                        <button type="button" class="btn btn-secondary" onclick="$('#payrollTabInfo<?= $empPayTransaction['empPayTrans']->emppaytrans_id ?>').toggle()">Close</button>
                      </div>
                    </div>
                  </form>

                </div>
                <div class="tab-pane fade" id="payroll-tab-PayInDed<?= $empPayTransaction['empPayTrans']->emppaytrans_id ?>" role="tabpanel" 
                aria-labelledby="payroll-tab-PayInDed-tab<?= $empPayTransaction['empPayTrans']->emppaytrans_id ?>">
                  
                  <form action="" method="post">
                    <div class="car">
                      <div class="card-body">
                        <table class="table table-bordered">
                          <thead>
                            <th>
                              Description
                            </th>
                            <th>
                              Deduction
                            </th>
                            <th>
                              Income
                            </th>
                            <th>
                              Action
                            </th>
                          </thead>
                          <tr>
                            <td>
                              Basic Pay
                            </td>
                            <td>
                              &nbsp;
                            </td>
                            <td>
                              <?= number_format($empPayTransaction['empPayTrans']->basic_pay, 2, ".", ",") ?>
                            </td>
                            <td>
                              &nbsp;
                            </td>
                          </tr>
                          <?php 
                            $grossIncome = $empPayTransaction['empPayTrans']->basic_pay;
                            $totalDeduction = 0;
                            foreach($empPayTransaction['empPayTransInDedIncome'] as $empPayTransInDedIncome): 
                          ?>
                            <tr>
                              <td>
                                <?= $empPayTransInDedIncome->inded_name ?>
                              </td>
                              <td>
                                &nbsp;
                              </td>
                              <td>
                                <?= number_format($empPayTransInDedIncome->amount, 2, ".", ",") ?>
                              </td>
                              <td>
                                <a href="#" class="ml-3" data-toggle="tooltip" title="Edit Income or Deduction" 
                                data-emppaytransinded_id="<?= $empPayTransInDedIncome->emppaytransinded_id ?>"
                                data-emppaytrans_id="<?= $empPayTransInDedIncome->emppaytrans_id ?>"
                                data-inded_id="<?= $empPayTransInDedIncome->inded_id ?>"
                                data-inded_name="<?= $empPayTransInDedIncome->inded_name ?>"
                                data-is_fixed_amt="<?= $empPayTransInDedIncome->is_fixed_amt ?>"
                                data-is_percent_amt="<?= $empPayTransInDedIncome->is_percent_amt ?>"
                                data-worked_days_based="<?= $empPayTransInDedIncome->worked_days_based ?>"
                                data-amount="<?= $empPayTransInDedIncome->amount ?>"
                                data-base_amount="<?= $empPayTransInDedIncome->base_amount ?>"
                                data-is_override="<?= $empPayTransInDedIncome->is_override ?>"
                                onclick="editIncomeDeduction(this)"><i class="fas fa-edit "></i></a>
                                <a href="/payroll/emppaytransdelinded/<?= $empPayTransInDedIncome->emppaytransinded_id.'/'.$empPayTransInDedIncome->emppaytrans_id ?>" onclick="return confirm('Are you sure you want to delete this item?')" class="ml-3" data-toggle="tooltip" title="Delete Employee Information"><i class="fas fa-trash "></i></a>
                              </td>
                            </tr>
                          <?php 
                            $grossIncome += $empPayTransInDedIncome->amount;
                            endforeach; 
                          ?>

                          <tr>
                            <td><strong>Gross Income</strong></td><td>&nbsp;</td><td class="text-right"><strong><?= number_format($grossIncome, 2, ".", ",") ?></strong></td><td>&nbsp;</td>
                          </tr>

                          <?php foreach($empPayTransaction['empPayTransInDedDeduction'] as $empPayTransInDedDeduction): ?>
                            <tr>
                              <td>
                                <?= $empPayTransInDedDeduction->inded_name ?>
                              </td>
                              <td>
                                <?= "-".number_format($empPayTransInDedDeduction->amount, 2, ".", ",") ?>
                              </td>
                              <td>
                                &nbsp;
                              </td>
                              <td>
                                <a href="#" class="ml-3" data-toggle="tooltip" title="Edit Income or Deduction" 
                                data-emppaytransinded_id="<?= $empPayTransInDedDeduction->emppaytransinded_id ?>"
                                data-emppaytrans_id="<?= $empPayTransInDedDeduction->emppaytrans_id ?>"
                                data-inded_id="<?= $empPayTransInDedDeduction->inded_id ?>"
                                data-inded_name="<?= $empPayTransInDedDeduction->inded_name ?>"
                                data-is_fixed_amt="<?= $empPayTransInDedDeduction->is_fixed_amt ?>"
                                data-is_percent_amt="<?= $empPayTransInDedDeduction->is_percent_amt ?>"
                                data-worked_days_based="<?= $empPayTransInDedDeduction->worked_days_based ?>"
                                data-amount="<?= $empPayTransInDedDeduction->amount ?>"
                                data-base_amount="<?= $empPayTransInDedDeduction->base_amount ?>"
                                data-is_override="<?= $empPayTransInDedDeduction->is_override ?>"
                                onclick="editIncomeDeduction(this)"><i class="fas fa-edit "></i></a>
                                <a href="/payroll/emppaytransdelinded/<?= $empPayTransInDedDeduction->emppaytransinded_id.'/'.$empPayTransInDedDeduction->emppaytrans_id ?>" onclick="return confirm('Are you sure you want to delete this item?')" class="ml-3" data-toggle="tooltip" title="Delete Employee Information"><i class="fas fa-trash "></i></a>
                              </td>
                            </tr>
                          <?php 
                            $totalDeduction += $empPayTransInDedDeduction->amount;
                            endforeach; 
                          ?>
                          <tr>
                            <td><strong>Total Deduction</strong></td><td class="text-right"><strong>-<?= number_format($totalDeduction, 2, ".", ",") ?></strong></td><td>&nbsp;</td><td>&nbsp;</td>
                          </tr>
                          <tr>
                            <td><strong>Net Income</strong></td><td>&nbsp;</td><td class="text-right"><strong><?= number_format(($grossIncome - $totalDeduction), 2, ".", ",") ?></strong></td><td>&nbsp;</td>
                          </tr>
                        </table>
                      </div>
                      <div class="card-footer">
                        <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#mdlAddIncome">Add Income</button>
                        <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#mdlAddDeduction">Add Deduction</button>
                        <button type="button" class="btn btn-secondary" onclick="$('#payrollTabInfo<?= $empPayTransaction['empPayTrans']->emppaytrans_id ?>').toggle()">Close</button>
                      </div>
                    </div>
                  </form>

                </div>
              </div>
            </div>
            <!-- /.card -->
          </div>
        <?php endforeach; endif; ?>
    </div>
</div>


<!-- List of Employee for Payroll -->
<div class="row">
    <div class="col-12">
        <div class="card">
            <div class="card-header">
                <h3 class="card-title">List of Employee for Payroll</h3>
            </div>
            <div class="card-body">
              <?php if($paygroupid == null || $paygroupid == -1): ?>
                <p>Please select payroll group.</p>
              <?php else: ?>
                <div class="card-body table-responsive p-0">
                  <?php if($transactionStatus == 'INIT'): ?>
                    <p>You may change the working days for this payroll cutoff. Deduct days off or absences on <strong>working days</strong> field.</p>
                  <?php elseif($transactionStatus == 'OPEN'): ?>
                    <p>Adjust entry of each employee by clicking on <strong>Edit</strong> icon</p>
                  <?php else: ?>
                    <p>Transactions for this payroll group has been <strong>POSTED</strong>.</p>
                  <?php endif; ?>
                  
                  <?= $tblEmpPayTrans ?>

                </div>
              <?php endif; ?>
            </div>
            <div class="card-footer">
              <?php if($paygroupid != null && $paygroupid != -1): ?>
                
                <?php if($transactionStatus == 'INIT'): ?>
                  <?php if(strpos($tblEmpPayTrans, 'No Employee Found') === false): ?>
                    <a class="btn btn-warning" href="/payroll/emppaytransinit/<?= $payTrans->paytrans_id.'/'.$paygroupid.'/'.$payTrans->paytype_id ?>">Initialize Payroll</a>
                  <?php endif; ?>
                <?php elseif($transactionStatus == 'OPEN'): ?>
                  <a class="btn btn-primary" href="/payroll/emppaytransreport/<?= $payTrans->paytrans_id.'/'.$paygroupid ?>">View Report Summary</a>
                  <a class="btn btn-warning" href="/payroll/emppaytransviewempinit/<?= $payTrans->paytrans_id.'/'.$paygroupid ?>">Initialize Employee</a>
                <?php else: ?>
                  <a class="btn btn-danger" href="/payroll/emppaytransinit/">Re-open Payroll</a>
                <?php endif; ?>

              <?php endif; ?>
            </div>
        </div>
    </div>
</div>

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

<!-- Javascript -->

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

<!-- Select2 -->
<script src="<?= base_url() ?>adminlte/plugins/select2/js/select2.full.min.js"></script>

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

  //Initialize Select2 Elements
  $('.select2').select2();
    
});

function showEmpPayTransDetails(emppaytransid)
{
  $("div[id^='payrollTabInfo']" ).hide();
  $("#payrollTabInfo"+emppaytransid).toggle();

  $("#txtInEmpPayTransId").val(emppaytransid);
  $("#txtDedEmpPayTransId").val(emppaytransid);
}

function editIncomeDeduction(element)
{
  $('#hdnEditInDedEmpPayTransInDedId').val($(element).data("emppaytransinded_id"));
  $('#hdnEditInDedEmpPayTransId').val($(element).data("emppaytrans_id"));
  $('#hdnEditInDedInDedId').val($(element).data("inded_id"));
  $('#txtEditInDedName').val($(element).data('inded_name'));
 
  $('[name="amount_type"][value="' + ($(element).data('is_fixed_amt') ? 'fixed' : ($(element).data('is_percent_amt') ? 'perc' : 'daysbased'))  + '"]').prop('checked', true);

  
  if($(element).data('worked_days_based'))
  {
    $('#txtEditInDedAmount').val($(element).data('base_amount'));
    $('#lblEditInDed_daysbased').html('Computed amount is ' + $(element).data('amount'))
  }
  else
  {
    $('#txtEditInDedAmount').val($(element).data('amount'));
    $('#lblEditInDed_daysbased').html('');
  }
    
  $('#chkEditInDedIsOverride').prop('checked', $(element).data('is_override'));

  $('#mdlEditIncomeDeduction').modal('show');
}

</script>

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

<!-- .Javascript -->