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

<!-- Title of the page -->
<?= $this->section('title') ?>Payslip Printing<?= $this->endSection() ?>
<!-- .Title -->

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

<?php foreach($empPayTransactions as $empPayTrans): ?>

<!-- title row -->
<div class="row">
    <div class="col-12">
        <h2 class="page-header">
            KARAT WORLD
            <small class="float-right"><span class="text-muted">Employee:</span> [<?= $empPayTrans->company_issued_id ?>] <?= $empPayTrans->last_name.", ".$empPayTrans->first_name ?></small>
        </h2>
    </div>
      <!-- /.col -->
</div>
    <!-- info row -->
<div class="row invoice-info">
    <div class="col-sm-4 invoice-col">
    Payslip of <strong><?= $empPayTrans->last_name.", ".$empPayTrans->first_name ?></strong>
    </div>
    <!-- /.col -->
    <div class="col-sm-4 invoice-col">
    Payroll Period <br>
    <strong><?= date("F d, Y", strtotime($payTrans->payroll_from))." to ".date("F d, Y", strtotime($payTrans->payroll_to)) ?></strong><br>
    </div>
    <!-- /.col -->
    <div class="col-sm-4 invoice-col">
    Payroll Date <br>
    <strong><?= ($payTrans->payschedule_id == 1) ? date("F 7, Y", strtotime($payTrans->payroll_to)) : date("F t, Y", strtotime($payTrans->payroll_to)) ?></strong>
    </div>
    <!-- /.col -->
</div>
<!-- /.row -->

<!-- Table row -->
<div class="row">
    <div class="col-12 table-responsive">
    <table class="table table-striped">
        <thead>
        <tr>
            <th>Description</th>
            <th>Deduction</th>
            <th>Income</th>
            <th>Total</th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Basic Pay @<?= number_format($empPayTrans->basic_daily_pay, 2, '.', ',') ?> x <?= number_format($empPayTrans->actual_work_days, 2, '.', ',') ?> days</td>
            <td>&nbsp;</td>
            <td><?= number_format($empPayTrans->basic_pay, 2, '.', ',') ?></td>
            <td>&nbsp;</td>
        </tr>
        <?php 
            $grossIncome = $empPayTrans->basic_pay;
            $totalDeduction = 0;
            foreach($empPayTransInDeds as $empPayTransIncome): 
                if($empPayTransIncome->emppaytrans_id == $empPayTrans->emppaytrans_id && $empPayTransIncome->is_income == 1):
        ?>
        <tr>
            <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?= $empPayTransIncome->payslip_display ?></td>
            <td>&nbsp;</td>
            <td><?= number_format($empPayTransIncome->amount, 2, '.', ',') ?></td>
            <td>&nbsp;</td>
        </tr>
        <?php 
            $grossIncome += $empPayTransIncome->amount;
                endif;
            endforeach; 
        ?>

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

        <?php 
            foreach($empPayTransInDeds as $empPayTransDeduction): 
                if($empPayTransDeduction->emppaytrans_id == $empPayTrans->emppaytrans_id && $empPayTransDeduction->is_income == 0):
        ?>
        <tr>
            <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?= $empPayTransDeduction->payslip_display ?></td>
            <td>-<?= number_format($empPayTransDeduction->amount, 2, '.', ','); ?></td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <?php 
            $totalDeduction += $empPayTransDeduction->amount;
                endif;
            endforeach; 
        ?>

        <tr>
            <td><strong>Total Deduction</strong></td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td class="text-right">-<strong><?= number_format($totalDeduction, 2, ".", ",") ?></strong></td>
        </tr>
        </tbody>
    </table>
    </div>
    <!-- /.col -->
</div>
<!-- /.row -->

<div class="row">
    <!-- accepted payments column -->
    <div class="col-6">
    <p class="text-muted well well-sm shadow-none" style="margin-top: 10px;">
    I have fully read and understood all details concerning my wage for the above stated period.  Wherein, I am fully satisfied with the computations made, without prejudice to my behalf.  That all data stated above, I hereby acknowledge, to be true and correct.
    </p>
    <p class="lead"><?= $empPayTrans->last_name.", ".$empPayTrans->first_name ?></p>
    <p>____________________________________</p>
    <p class="text-muted well well-sm shadow-none" style="margin-top: 10px;">
    <i>Signature of Employee</i>
    </p>
    </div>
    <!-- /.col -->
    <div class="col-6">
    <p class="lead">Summary of Payslip</p>

    <div class="table-responsive">
        <table class="table">
        <tr>
            <th style="width:50%">Gross Income:</th>
            <td><?= number_format($grossIncome, 2, ".", ",") ?></td>
        </tr>
        <tr>
            <th>Total Deduction</th>
            <td>(<?= number_format($totalDeduction, 2, ".", ",") ?>)</td>
        </tr>
        <tr>
            <th>Tax:</th>
            <td>(<?= number_format($empPayTrans->income_tax, 2, ".", ",") ?>)</td>
        </tr>
        <tr>
            <th>Net Income:</th>
            <td><?= number_format($empPayTrans->net_pay, 2, ".", ",") ?></td>
        </tr>
        </table>
    </div>
    </div>
    <!-- /.col -->
</div>
<!-- /.row -->

<div style="page-break-after: always;"></div>

<?php endforeach; ?>

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

