<?php
$current_date = date('Y-m-d');
$condition = 'salary.salary_occurence="2" AND employee_id="' . $model->employee_id . '" and t.isActive="Y" AND valid_from <="' . $current_date . '" AND valid_to ="0000-00-00"';
$model_salary = EmployeeSalary::model()->with('salary')->find(array('select' => 'sum(amount) as amount,valid_from', 'condition' => $condition));
$total_salary = 0.00;
$salary_date = "";
$salary_month = "";
if ($model_salary->amount > 0) {
    $total_salary = $model_salary->amount;
    $salary_date = date("d/m/Y", strtotime($model_salary->valid_from));
    $salary_month = date("m/Y", strtotime($model_salary->valid_from));
}

?>
<!DOCTYPE html>
<html>
    <head>
        <title>Salary Certificate</title>
        <style>

            @page {

                //margin-top: 1.9cm;
                margin-bottom: 0cm !important;
                margin-left: 0cm;
                margin-right: 0cm;
                header: html_myHeader;
                footer: html_myfooter;
                font-family: 'Oswald', sans-serif;


            }
            @import url('https://fonts.googleapis.com/css?family=Open+Sans:400,600,700,800');

            table, tr, td{
                border:solid 1px #333333;
                border-collapse: collapse;
                padding: 10px;

            }
        </style>
    </head>
    <body style="width: 960px; margin: 0 auto; font-family: open sans; font-size: 15px !important;">
        <div class="">
            <div class="col-6">
                <br>
                <div class="h3" style="margin-top: 0;margin-bottom: 0;">
                    <?php echo " "; ?>
                </div>
            </div>
            <div style="text-align: right;margin-right: 50px;">
                <div>
                    <img src="uploads/logo/<?php echo $model->employeedetail->branch_sponsor->branch_or_sponsor_logo; ?>" style="height: 70px">
                </div>

            </div>
        </div>
        <br>
        <div class="page" style="width: 80%; margin: 0 auto; font-family: open sans;">
            <div class="">
                <div style="text-align: left">
                    <p><?php echo $model->employeedetail->branch_sponsor->branch_or_sponsor_code.'/'.$model->mascertificate->code;?>/<?php echo $ref_no; ?>/<?php echo date('y');?></p>
                    <p>Date: <?php echo date("d/m/Y"); ?></p>
                    <p>To,<br><?php echo $model->addresses_to; ?></p>

                </div>

                <br>
                <div style="text-align: left;">
                    <h4>Subject: Salary Certificate</h4>
                </div>
                <br>
                <div style="text-align: left; font-size: 13px;">
                    Dear Sir/Madam,
                </div>
                <br>
                <div style="text-align: justify; font-size: 12px;">
                    <p>This is to confirm that below employee holding <?php echo $model->employeedetail->employeenationality->nationality; ?> Passport <?php echo $model_document->document_number ?> and Emirates ID <span><?php echo $model_document_emirate->document_number; ?></span> is working with us. Please find the details below.</p>
                    <table border="1" style="font-size: 13px;">
                        <thead><tr>
                            <th>S.N.</th>
                            <th>Name</th>
                            <th>Designation</th>
                            <th>Date of Joining</th>
                            <th>Salary in AED</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td>1</td>
                            <td><?php echo $sign . '' . $model->employeedetail->employeefullname; ?></td>
                            <td><?php echo $model->employeedetail->designationdetail->designation_name; ?></td>
                            <td><?php echo date_format(date_create($model->employeedetail->date_join), "d/m/Y") ?></td>
                            <td><?php echo $model->employeedetail->currencydetails->currency_code . ' ' . $total_salary; ?>/-</td>
                        </tr>
                        </tbody>
                    </table>
                    <p style="font-size: 13px;">This letter is issued upon the request of the employee and bears no financial liability towards the company.</p>
                </div>
                <br>
                <div>
                    <p>Kind Regards,</p><br><br>
                    <?php
                    foreach ($signature as $value) {
                        echo '<h4>' . $value . '</h4>';
                    }
                    ?> 

                </div>
            </div>
        </div>
        <?php
if($model->employeedetail->branch_sponsor->footer_logo!=''){
?>
    <htmlpagefooter name="myfooter">
        <div style="width:100%; border-top: 1px solid black;">
              <img src="<?php echo Yii::app()->baseUrl; ?>/uploads/logo/<?php echo $model->employeedetail->branch_sponsor->footer_logo;    ?>" style="width:100%;margin-bottom:-5px !important;">
        </div>
    </htmlpagefooter> 
    <?php } ?>
</body>
</html>