<!DOCTYPE html>
<html>

    <head>
        <title>Employee Details</title>
    </head>

    <body>
        <div class="heading">
            <div class="logo col-3" style="background-color: cadetblue">
                <img src="images/pdf/logo.png">
            </div>
            <div class="companay_name col-6 text-right">
            </div>
        </div>
        <div class="clearfix"></div>
        <div class="title">
            <div class="col-6">
                <div style="height: 10px;"></div>
            </div>
            <div class="col-6 text-right">
                <h1>EMPLOYEE DETAILS</h1>
                <div class="details-box">
                </div>
            </div>
        </div>
        <div class="clearfix"></div>
        <div class="table-body">
            <table class="table table-fixed table-primary dataTable">
                <thead>
                    <?php
                    $j = 1;
                    $modelemployee = Employee::model()->findAll(array('condition' => 'id="' . $id . '"'));
                    $total = 0;

                    foreach ($modelemployee as $j => $model) {
                        ?>

                        <tr>
                            <td width="300">Employee Code</td>
                            <td><?php echo $this->ciphertext($model->employee_code, "d"); ?></td>

                        </tr><tr>
                            <td width="300">Employee name</td>
                            <td><?php echo $this->ciphertext($model->first_name, "d") . ' ' . $this->ciphertext($model->last_name, "d"); ?></td>

                        </tr><tr>
                            <td width="300">Gender</td>
                            <td> <?php
                                if ($model->gender == 1) {
                                    echo 'Male';
                                } else if ($model->gender == 2) {
                                    echo 'Female';
                                }
                                ?></td>

                        </tr><tr>
                            <td width="300">Department</td>
                            <td><?php echo $model->departmentdetail->department_name; ?></td>

                        </tr><tr>
                            <td width="300">Designation</td>
                            <td><?php echo $model->designationdetail->designation_name; ?></td>

                        </tr>

                        <tr>
                            <td width="300">Nationality</td>
                            <td><?php echo $model->employeenationality->country_name; ?></td>

                        </tr>

                        <tr>
                            <td width="300">Date of Birth</td>
                            <td><?php
                                $date_of_birth = '-';
                                if ($model->date_of_birth != '' && $model->date_of_birth != '0000-00-00') {
                                    $date_of_birth = date("d/m/Y", strtotime($model->date_of_birth));
                                }
                                echo $date_of_birth;
                                ?></td>

                        </tr> 
                        <tr><td>Accommodation</td><td><?php 
                        if($model->housing_facility=='Y'){
                            echo 'Yes';
                        }else{
                            echo 'No';
                        }
                        ?></td></tr>
                        <tr>
                            <td width="300">UAE Address</td>
                            <td><?php echo $model->present_address; ?></td>

                        </tr> <tr>
                            <td width="300">Native Address</td>
                            <td><?php echo $model->permanent_address; ?></td>

                        </tr> 
                        <tr>
                            <td width="300">Official Mobile</td>
                            <td><?php echo $model->phone; ?></td>

                        </tr> <tr>
                            <td width="300">Personal Mobile</td>
                            <td><?php echo $model->mobile; ?></td>

                        </tr> <tr>
                            <td width="300">Official Email</td>
                            <td><?php echo $model->email; ?></td>
                        </tr> <tr>
                            <td width="300">Date of Joining</td>
                            <td> <?php
                                $date_join = '-';
                                if ($model->date_join != '' && $model->date_join != '0000-00-00') {
                                    $date_join = date("d/m/Y", strtotime($model->date_join));
                                }
                                echo $date_join;
                                ?></td>

                        </tr> <tr>
                            <td width="300">Branch</td>
                            <td><?php echo $model->branch_sponsor->branch_or_sponsor_name; ?></td>

                        </tr>

                        <tr>
                            <td width="300">Employee Type</td>
                            <td> <?php
                                $employee_type = '-';
                                if ($model->employee_type == 1) {
                                    $employee_type = 'Limited';
                                } else if ($model->employee_type ==2) {
                                    $employee_type = 'Unlimited';
                                }
                                echo $employee_type;
                                ?></td>

                        </tr>
                        <tr>
                            <td width="300">IBAN No</td>
                            <td><?php echo $model->employee_iban_no; ?></td>

                        </tr>

                        </tr>

                        <?php
                    }
                    ?>
                </thead>

            </table>
        <div class="clearfix"></div><br/>
        <div class="title text-center"> SALARY DETAILS</div>
        <table class="table table-fixed table-primary">
            <tr>
                <th>No</th> 
                <th>Salary Type</th>
                <th>Date From</th>
                <th>Amount</th>
            </tr>
            <tbody>
                <?php  
            $model_salary= EmployeeSalary::model()->findAll(array('condition' => 'employee_id="'. $model->id.'" and isActive="Y"'));
            $total_salary_amount=0.00;
            if(!empty($model_salary)){
            foreach ($model_salary as $i => $salary_detail):
                if($salary_detail->amount>0){
                    $total_salary_amount+=$salary_detail->amount;
                ?>
            <tr>
                <td><?php echo ($i+1); ?></td>
                <td><?php echo $salary_detail->salary->salary_name; ?></td>
                <td><?php echo date("d/m/Y", strtotime($salary_detail->valid_from));?></td>
                <td class="text-right"><?php echo Yii::app()->numberFormatter->formatCurrency($salary_detail->amount,""); ?></td>
            </tr>
            <?php 
                }
                endforeach; 
            }?>
            </tbody>
            <tfoot>          
                <tr><th colspan="3" class="text-right">Total</th><th class="text-right"><?php echo Yii::app()->numberFormatter->formatCurrency($total_salary_amount,""); ?></th></tr>
            </tfoot>
        </table>
    </div>
        </div>
        <!--    mpdf
                <htmlpagefooter name="myfooter">
                    <div style="border-top: 1px dotted #000000; font-size: 12px; text-align: center; padding-top: 10px; ">
                        <div style="text-align:center;width:100%">This report is auto generated by Bluesky project on 
<?php
date_default_timezone_set("Asia/Dubai");
echo date('d/m/Y') . " " . date("h:i:sa");
?> </div>
                        <div style="text-align:center;width:100%">Page {PAGENO} of {nb} </div>
                    </div>
                </htmlpagefooter>
                <sethtmlpagefooter name="myfooter" page="all" value="on" />-->

    </body>

</html>
