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

<!-- Title of the page -->
<?= $this->section('title') ?>Compensation and Benefits<?= $this->endSection() ?>
<!-- .Title -->

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

<!-- Select2 -->
<link rel="stylesheet" href="/adminlte/plugins/select2/css/select2.min.css">
<link rel="stylesheet" href="/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 Compensation and Benefits<?= $this->endSection() ?>
<!-- .Container title -->

<!-- Active breadcrumb -->
<?= $this->section('breadcrumbs') ?>
<li class="breadcrumb-item active">Compensation and Benefits</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/savecompben') ?>" method="post">
        <div class="modal-header">
          <h4 class="modal-title" >New Employee Income</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">Employee Income Information</p>
              <div class="row">
                <?php if($empLoaded) : ?>
                  <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="payschedule_id" value="<?= $_GET['payschedid'] ?>">
                        <input type="hidden" name="emppay_id" value="<?= $selectedEmployee->emppay_id ?>" >
                        <input type="hidden" name="emp_id" value="<?= $selectedEmployee->employee_id ?>" >
                    </div>
                    <div class="form-group">
                        <div class="form-check">
                            <input class="form-check-input" type="radio" id="rdoInFixedAmount" name="amount_type" value="fixed" checked>
                            <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 class="form-check">
                            <input class="form-check-input" type="radio" id="rdoInDaysBasedAmount" name="amount_type" value="daysbased">
                            <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>
                    <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>
                <?php else : ?>
                  <div class="col-12">
                    <p class="text-danger">No Employee Loaded. Please select employee first</p>
                  </div>
                <?php endif ?>
              </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/savecompben') ?>" method="post">
        <div class="modal-header">
          <h4 class="modal-title" >New Employee 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">Employee Deduction Information</p>
              <div class="row">
                <?php if($empLoaded) : ?>
                  <div class="col-12">
                    <div class="form-group">
                        <label>Select Deduction 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="payschedule_id" value="<?= $_GET['payschedid'] ?>">
                        <input type="hidden" name="emppay_id" value="<?= $selectedEmployee->emppay_id ?>" >
                        <input type="hidden" name="emp_id" value="<?= $selectedEmployee->employee_id ?>" >
                    </div>
                    <div class="form-group">
                        <div class="form-check">
                            <input class="form-check-input" type="radio" id="rdoDedFixedAmount" name="amount_type" value="fixed" checked>
                            <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 class="form-check">
                            <input class="form-check-input" type="radio" id="rdoDedDaysBasedAmount" name="amount_type" value="daysbased">
                            <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>
                    <div class="form-group">
                        <label for="txtDedAmount">Amount</label>
                        <input class="form-control" type="number" 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>
                <?php else : ?>
                  <div class="col-12">
                    <p class="text-danger">No Employee Loaded. Please select employee first</p>
                  </div>
                <?php endif ?>
              </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 -->
<div class="modal fade" id="mdlEditIncome">
  <div class="modal-dialog">
    <div class="modal-content">
      <form action="<?= url_to('payroll/savecompben') ?>" method="post">
        <div class="modal-header bg-warning">
          <h4 class="modal-title" >Edit Employee Income</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">Employee Income Information</p>
              <div class="row">
                <?php if($empLoaded) : ?>
                  <div class="col-12">
                    <div class="form-group">
                        <div class="form-group">
                            <label for="txtEditInDedName">Income Name</label>
                            <input class="form-control" type="text" readonly id="txtEditInDedName" name="inded_name">
                        </div>
                        <input type="hidden" id="txtEditInEmpPayIndedId" name="emppayinded_id" > <!-- Primary Key -->
                        <input type="hidden" name="emppay_id" value="<?= $selectedEmployee->emppay_id ?>" >
                        <input type="hidden" name="payschedule_id" value="<?= $_GET['payschedid'] ?>">
                        <input type="hidden" id="txtEditInInDedId" name="inded_id">
                        <input type="hidden" name="emp_id" value="<?= $selectedEmployee->employee_id ?>" >
                    </div>
                    <div class="form-group">
                        <div class="form-check">
                            <input class="form-check-input" type="radio" id="rdoEditInFixedAmount" name="amount_type" value="fixed">
                            <label for="rdoEditInFixedAmount" class="form-check-label">Fixed amount.</label>
                        </div>
                        <div class="form-check">
                            <input class="form-check-input" type="radio" id="rdoEditInPercentageAmount" name="amount_type" value="perc">
                            <label for="rdoEditInPercentageAmount" class="form-check-label">Amount is in percentage.</label>
                        </div>
                        <div class="form-check">
                            <input class="form-check-input" type="radio" id="rdoEditInDaysBasedAmount" name="amount_type" value="daysbased">
                            <label for="rdoEditInDaysBasedAmount" 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>
                    <div class="form-group">
                        <label for="txtEditInAmount">Amount</label>
                        <input class="form-control" type="number" id="txtEditInAmount" 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="chkEditInIsOverride" name="is_override">
                            <label for="chkEditInIsOverride" 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>
                <?php else : ?>
                  <div class="col-12">
                    <p class="text-danger">No Employee Loaded. Please select employee first</p>
                  </div>
                <?php endif ?>
              </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 -->
<div class="modal fade" id="mdlEditDeduction">
  <div class="modal-dialog">
    <div class="modal-content">
      <form action="<?= url_to('payroll/savecompben') ?>" method="post">
        <div class="modal-header bg-warning">
          <h4 class="modal-title" >Edit Employee 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">Employee Deduction Information</p>
              <div class="row">
                <?php if($empLoaded) : ?>
                  <div class="col-12">
                    <div class="form-group">
                        <div class="form-group">
                            <label for="txtEditDedInDedName">Deduction Name</label>
                            <input class="form-control" type="text" readonly id="txtEditDedInDedName" name="inded_name">
                        </div>
                        <input type="hidden" id="txtEditDedEmpPayIndedId" name="emppayinded_id" > <!-- Primary Key -->
                        <input type="hidden" name="emppay_id" value="<?= $selectedEmployee->emppay_id ?>" >
                        <input type="hidden" name="payschedule_id" value="<?= $_GET['payschedid'] ?>">
                        <input type="hidden" id="txtEditDedInDedId" name="inded_id">
                        <input type="hidden" name="emp_id" value="<?= $selectedEmployee->employee_id ?>" >
                    </div>
                    <div class="form-group">
                        <div class="form-check">
                            <input class="form-check-input" type="radio" id="rdoEditDedFixedAmount" name="amount_type" value="fixed">
                            <label for="rdoEditDedFixedAmount" class="form-check-label">Fixed amount.</label>
                        </div>
                        <div class="form-check">
                            <input class="form-check-input" type="radio" id="rdoEditDedPercentageAmount" name="amount_type" value="perc">
                            <label for="rdoEditDedPercentageAmount" class="form-check-label">Amount is in percentage.</label>
                        </div>
                        <div class="form-check">
                            <input class="form-check-input" type="radio" id="rdoEditDedDaysBasedAmount" name="amount_type" value="daysbased">
                            <label for="rdoEditDedDaysBasedAmount" 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>
                    <div class="form-group">
                        <label for="txtEditDedAmount">Amount</label>
                        <input class="form-control" type="number" id="txtEditDedAmount" 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="chkEditDedIsOverride" name="is_override">
                            <label for="chkEditDedIsOverride" 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>
                <?php else : ?>
                  <div class="col-12">
                    <p class="text-danger">No Employee Loaded. Please select employee first</p>
                  </div>
                <?php endif ?>
              </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>


<div class="row">
    <div class="col-12">
        <div class="card">
            <div class="card-header">
                <h3 class="card-title">Select Schedule and Employee</h3>
            </div>
            <div class="card-body">
              <div class="row">
                <div class="col-12">
                  <form action="/payroll/compben" method="get">
                    <div class="row">
                      <div class="col-12 col-sm-4">
                        <div class="form-group">
                          <label>Select Schedule</label>
                          <select class="form-control" name="payschedid">
                              <?php foreach($paySchedules as $paySchedule): ?>
                                  <?php $selected = ($empLoaded && $_GET['payschedid'] == $paySchedule->payschedule_id) ? 'selected' : ''; ?>
                                  <?= '<option value="'.$paySchedule->payschedule_id.'" '.$selected.'>['.$paySchedule->sched_code.'] '.$paySchedule->sched_name.'</option>' ?>
                              <?php endforeach; ?>
                          </select>
                        </div>
                      </div>
                      <div class="col-12 col-sm-8">
                        <label>Select Employee</label>
                        <div class="form-group">
                          <div class="input-group mb-3">
                            <select class="form-control select2 rounded-0" name="empid">
                                <?php foreach($empPayInfos as $empPayInfo): ?>
                                    <?php $selected = ($empLoaded && $selectedEmployee->employee_id == $empPayInfo->employee_id) ? 'selected' : ''; ?>
                                    <?= '<option value="'.$empPayInfo->employee_id.'" '.$selected.'>'.$empPayInfo->last_name.', '.$empPayInfo->first_name.'</option>' ?>
                                <?php endforeach; ?>
                            </select>
                            <span class="input-group-append">
                              <button type="submit" class="btn btn-info btn-flat">Load Income &amp; Deduction</button>
                            </span>
                          </div>
                        </div>
                      </div>
                    </div>
                  </form>
                </div>
              </div>
              
            </div>
            
        </div>
    </div>
</div>
<div class="row">
  <div class="col-12">
    <div class="card">
      <div class="card-header">
        <h3 class="card-title">Payroll Income and Deduction Details</h3>
      </div>
      <div class="card-body">
        <div class="row">
          <div class="col-12">
            <?php if($empLoaded): ?>
              <div class="row">
                    <div class="col-6 col-xs-6">
                      <p><strong>Employee Name:</strong> <?= $selectedEmployee->last_name . ', ' . $selectedEmployee->first_name ?></p>
                      <p><strong>Employee ID:</strong> <?= $selectedEmployee->company_issued_id ?></p>
                  </div>
                  <div class="col-6 col-xs-6 text-right">
                    <p><strong>Basic Salary</strong> <?= $selectedEmployee->basic_monthly_pay ?></p>
                    <p><strong>Date:</strong> 20/09/2024</p>
                  </div>
              </div>
              <table class="table table-bordered">
                  <thead>
                      <tr>
                          <th>Description</th>
                          <th colspan="2" class="text-center">Amount</th>
                          <th>Action</th>
                      </tr>
                  </thead>
                  <tbody>
                    <?php 
                      $grossTotal = $selectedEmployee->basic_daily_pay * 13; 
                      $taxableGross = $selectedEmployee->basic_daily_pay * 13;
                      $deductionTotal = 0; 
                    ?>
                    <tr>
                      <td>
                        <span class="pl-3">Basic Salary</span><br>
                        <span class="pl-4 text-sm"><i>Php<?= number_format($selectedEmployee->basic_daily_pay, 2, ".", ",") ?> daily rate (assumes 13 days of work per cutoff)</i></span>
                      </td>
                      <td>&nbsp;</td>
                      <td class="text-right"><?= number_format($selectedEmployee->basic_daily_pay * 13, 2, ".", ",") ?></td>
                      <td>&nbsp;</td>
                    </tr>
                    <?php foreach($empPayIncomeList as $empPayIncome):?>
                      <tr>
                        <td><span class="pl-3"><?= $empPayIncome->inded_name ?></span></td>
                        <td>&nbsp;</td>
                        <td class="text-right"><?= number_format($empPayIncome->amount, 2, ".", ",") ?></td>
                        <td>
                          <a href="#" class="ml-3" data-toggle="tooltip" title="Edit Income Information" 
                            data-emppayinded_id = "<?= $empPayIncome->emppayinded_id ?>" 
                            data-inded_name = "<?= $empPayIncome->inded_name ?>"
                            data-emppay_id = "<?= $empPayIncome->emppay_id ?>" 
                            data-payschedule_id = "<?= $empPayIncome->payschedule_id ?>" 
                            data-inded_id = "<?= $empPayIncome->inded_id ?>" 
                            data-is_fixed_amt = "<?= $empPayIncome->is_fixed_amt ?>" 
                            data-is_percent_amt = "<?= $empPayIncome->is_percent_amt ?>" 
                            data-amount = "<?= $empPayIncome->amount ?>" 
                            data-is_override = "<?= $empPayIncome->is_override ?>"
                            onclick="editIncome(this)"><i class="fas fa-edit"></i></a>
                          <form action="/payroll/delcomben" method="post" class="ml-3 d-inline-block">
                            <input type="hidden" name="emppayinded_id" value="<?= $empPayIncome->emppayinded_id ?>">
                            <input type="hidden" name="payschedule_id" value="<?= $empPayIncome->payschedule_id ?>">
                            <input type="hidden" name="emp_id" value="<?= $selectedEmployee->employee_id ?>">
                            <button type="submit" class="btn btn-link p-0 m-0"><i class="fas fa-trash "></i></a>
                          </form>
                        </td>
                      </tr>
                    <?php 

                    $grossTotal += $empPayIncome->amount;
                    if($empPayIncome->is_taxable) $taxableGross += $empPayIncome->amount;
                  
                    endforeach; ?>
                      <tr>
                        <td><strong>Gross Total</strong></td>
                        <td>&nbsp;</td>
                        <td class="text-right"><strong>Php <?= number_format($grossTotal, 2, ".", ","); ?></strong></td>
                        <td>&nbsp;</td>
                      </tr>
                    
                    <?php foreach($empPayDeductionList as $empPayDeduction):?>
                      <tr>
                        <td><span class="pl-3"><?= $empPayDeduction->inded_name ?></span></td>
                        <td class="text-right">-<?= number_format($empPayDeduction->amount, 2, ".", ",") ?></td>
                        <td>&nbsp;</td>
                        <td>
                          <a href="#" class="ml-3" data-toggle="tooltip" title="Edit Deduction Information" 
                            data-emppayinded_id = "<?= $empPayDeduction->emppayinded_id ?>" 
                            data-inded_name = "<?= $empPayDeduction->inded_name ?>"
                            data-emppay_id = "<?= $empPayDeduction->emppay_id ?>" 
                            data-payschedule_id = "<?= $empPayDeduction->payschedule_id ?>" 
                            data-inded_id = "<?= $empPayDeduction->inded_id ?>" 
                            data-is_fixed_amt = "<?= $empPayDeduction->is_fixed_amt ?>" 
                            data-is_percent_amt = "<?= $empPayDeduction->is_percent_amt ?>" 
                            data-amount = "<?= $empPayDeduction->amount ?>" 
                            data-is_override = "<?= $empPayDeduction->is_override ?>"
                            onclick="editDeduction(this)"><i class="fas fa-edit "></i></a>
                            <form action="/payroll/delcomben" method="post" class="ml-3 d-inline-block">
                              <input type="hidden" name="emppayinded_id" value="<?= $empPayDeduction->emppayinded_id ?>">
                              <input type="hidden" name="payschedule_id" value="<?= $empPayDeduction->payschedule_id ?>">
                              <input type="hidden" name="emp_id" value="<?= $selectedEmployee->employee_id ?>">
                              <button type="submit" class="btn btn-link p-0 m-0"><i class="fas fa-trash "></i></a>
                          </form>
                        </td>
                      </tr>
                    <?php 

                    $deductionTotal += $empPayDeduction->amount;
                  
                    endforeach; 
                    ?>
                      <tr>
                        <td><strong>Total Deductions</strong></td>
                        <td class="text-right"><strong>Php <?= number_format($deductionTotal, 2, ".", ","); ?></strong></td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                      </tr>
                  </tbody>
                  <tfoot>
                      <tr>
                        <th><span class="text-uppercase">Net Income</span></th>
                        <td>&nbsp;</td>
                        <th class="text-right">Php <?= number_format($grossTotal - $deductionTotal, 2, ".", ",") ?></th>
                        <td>&nbsp;</td>
                      </tr>
                  </tfoot>
              </table>
            <?php else: ?>
              <p>Select an employee first then click on "Load Income &amp; Deduction" button</p>
            <?php endif; ?>
          </div>
        </div>
      </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>
      </div>
    </div>
  </div>
</div>


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

<!-- Javascript -->

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

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

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

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

});

function editIncome(element) {
  
  $('#txtEditInDedName').val($(element).data('inded_name'));
  $('#txtEditInEmpPayIndedId').val($(element).data('emppayinded_id'));
  //$('#emppay_id').val($(element).data('emppay_id'));
  //$('#payschedule_id').val($(element).data('payschedule_id'));
  $('#txtEditInInDedId').val($(element).data('inded_id'));
  
  $("[name='amount_type'][value='" + ($(element).data('is_fixed_amt') ? 'fixed' : ($(element).data('is_percent_amt') ? 'perc' : 'daysbased'))  + "']").prop('checked', true);

  //$("[name='amount_type'][value='" + ($(element).data('is_fixed_amt') ? 'fixed' : 'perc')  + "']").prop('checked', true);
  $('#txtEditInAmount').val($(element).data('amount'));
  $('#chkEditInIsOverride').prop('checked', $(element).data('is_override'));

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

function editDeduction(element) {
  
  $('#txtEditDedInDedName').val($(element).data('inded_name'));
  $('#txtEditDedEmpPayIndedId').val($(element).data('emppayinded_id'));
  $('#txtEditDedInDedId').val($(element).data('inded_id'));

  $('[name="amount_type"][value="' + ($(element).data('is_fixed_amt') ? 'fixed' : ($(element).data('is_percent_amt') ? 'perc' : 'daysbased'))  + '"]').prop('checked', true);
  
  //$("[name='amount_type'][value='" + ($(element).data('is_fixed_amt') ? 'fixed' : 'perc')  + "']").prop('checked', true);
  $('#txtEditDedAmount').val($(element).data('amount'));
  $('#chkEditDedIsOverride').prop('checked', $(element).data('is_override'));
  $('#mdlEditDeduction').modal('show');
}

</script>

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

<!-- .Javascript -->