<?php 
global $path_to_root, $print_as_quote, $print_invoice_no, $packing_slip, $dflt_lang,$hrm_empl_salutation;

$doctype = $this->formData['doctype'];
$header2type = true;

$this->SetLang(@$this->formData['rep_lang'] ? $this->formData['rep_lang'] : ($_SESSION["wa_current_user"]->prefs->language ? $_SESSION["wa_current_user"]->prefs->language : $dflt_lang));

  // leave layout files names without path to enable including
  // modified versions from company/x/reporting directory
 
     
$this->title = _("Employee Details");
$addr_title = _("Employee Personal Information");
//	$this->formData['document_name'] =_("Employee ID.");

$empl_details = GetRow('kv_empl_info', array('empl_id' => $this->formData['order_no']));
$job_details = GetRow('kv_empl_job', array('empl_id' => $this->formData['order_no']));

$Addr1 = array(
    'title' => $addr_title,
    'id' => $this->formData['order_no'],
    'name' => @$this->formData['name'] ? $this->formData['name'] : @$this->formData['name'],
    'dept' => $this->formData['location_name'], 
    'desig' => $this->formData['payment_terms'], 						 
    'joining' => $this->formData['ord_date']
);

$this->formData['domicile'] = $this->company['domicile'];

$Footer[0] = ''; //_("All amounts stated in Company  Currency") ;

// default values
if (!isset($this->formData['document_date']))
$this->formData['document_date'] = Today();

if (!isset($this->formData['document_number']))
$this->formData['document_number'] = $print_invoice_no == 0 && isset($this->formData['reference']) ? $this->formData['reference'] : @$this->formData['trans_no'];

// footer generic content
if (@$this->formData['bank_name'])
$Footer[] = _("Bank"). ": ".$this->formData['bank_name']. ", " . _("Bank Account") . ": " . $this->formData['acc_no'];


//if ($this->formData['doctype'] == 'payslip')
 //$Footer[] = _("* Subject to Realisation of the Cheque.");
if (isset($this->params['comments']) && $this->params['comments'] != '')
$Footer[] = $this->params['comments'];

if(isset($Addr1['name']))
$this->formData['recipient_name'] = $Addr1['name'];

$this->row = $this->pageHeight - $this->topMargin;
$this->rightMargin = $this->rightMargin-10;
$upper = $this->row - 2 * $this->lineHeight;
$lower = $this->bottomMargin + 8 * $this->lineHeight;
$iline1 = $upper - 7.5 * $this->lineHeight;
$iline2 = $iline1 - 8 * $this->lineHeight;
$iline3 = $iline2 - 1.5 * $this->lineHeight;
$iline4 = $iline3 - 1.5 * $this->lineHeight;
$iline5 = $iline4 - 3 * $this->lineHeight;
$iline6 = $iline5 - 1.5 * $this->lineHeight;
$iline7 = $lower;
$right = $this->pageWidth - $this->rightMargin;

$width = ($right - $this->leftMargin) / 5;
$icol = $this->pageWidth / 2;
$ccol = 40;
//display_error($this->cols[0]);
$c2col = $ccol + 60;
$ccol2 = $icol / 2;
$mcol = $icol + 8;
$mcol2 = $this->pageWidth - $ccol2;
$cols = count_array($this->cols);
/*	$this->SetDrawColor(205, 205, 205);
$this->rectangle($this->leftMargin, $iline2, $right - $this->leftMargin, $iline2 - $iline3, "F", null, array(222, 231, 236));   
$this->Line($iline2);
$this->Line($iline3);

if ($this->formData['doctype'] == 'payslip'){
    $this->rectangle($this->leftMargin, $iline5-314, $right - $this->leftMargin, $iline5 - $iline6+12, "F", null, array(255, 211, 179));   
    //$this->Line($iline6-136);
}
//$this->Line($iline6-166);
$col = $this->leftMargin;
if ($this->formData['doctype'] == 'payslip'){
    $this->LineTo($col += $width+80, $iline2,$col, $iline7+40);
    $this->LineTo($col += $width-20, $iline2,$col, $iline7+40);
    $this->LineTo($col += $width+80, $iline2,$col, $iline7+40);
}
$this->LineTo($right, $iline2 ,$right, $iline7+10);
$this->LineTo($this->leftMargin, $iline2 ,$this->leftMargin, $iline7+10); */
// Company Logo
$this->NewLine();
$logo = company_path() . "/images/" . $this->company['coy_logo'];
//$empl_image = company_path() . "/images/empl/" .empl_img_name($this->formData['order_no'].".jpg");

if ($this->company['coy_logo'] != '' && file_exists($logo))	{
    $this->AddImage($logo, $ccol, $this->row, 0, 40);
}else{
    $this->fontSize += 4;
    $this->Font('bold');
    $this->Text($ccol, $this->company['coy_name'], $icol);
    $this->Font();
    $this->fontSize -= 4;
}
//display_error($ccol+580);
//if ($this->company['coy_logo'] != '' && file_exists($logo))	{
//if ($this->pageNumber = 1)
//	$this->AddImage($empl_image, $ccol+580, $this->row-200, 0, 40);
//	}
/*}else{
    $this->fontSize += 4;
    $this->Font('bold');
    $this->Text($ccol, $this->company['coy_name'], $icol);
    $this->Font();
    $this->fontSize -= 4;
}*/
// Document title
$this->SetTextColor(190, 190, 190);
$this->fontSize += 10;
$this->Font('bold');
$this->TextWrap($mcol, $this->row, $this->pageWidth - $this->rightMargin - $mcol - 20, $this->title, 'right');
$this->Font();
$this->fontSize -= 10;
$this->NewLine();
$this->SetTextColor(0, 0, 0);
$adrline = $this->row;

// Company data
$this->TextWrapLines($ccol, $icol, $this->company['postal_address']);
$this->Font('italic');
if (@$this->company['phone']){
    $this->Text($ccol, _("Phone"), $c2col);
    $this->Text($c2col, $this->company['phone'], $mcol);
    $this->NewLine();
}
if (@$this->company['fax']){
    $this->Text($ccol, _("Fax"), $c2col);
    $this->Text($c2col, $this->company['fax'], $mcol);
    $this->NewLine();
}
if (@$this->company['email']){
    $this->Text($ccol, _("Email"), $c2col);

    $url = "mailto:" . $this->company['email'];
    $this->SetTextColor(0, 0, 255);
    $this->Text($c2col, $this->company['email'], $mcol);
    $this->SetTextColor(0, 0, 0);
    $this->addLink($url, $c2col, $this->row, $mcol, $this->row + $this->lineHeight);

    $this->NewLine();
}

$this->Font();
$this->row = $adrline;
$this->NewLine(3);
$this->Text($mcol + 200, _("Date"),$mcol2);
$this->Text($mcol + 280, $this->formData['document_date']);
$this->NewLine(2);
$this->fontSize += 4;
if(isset($_POST['page_titl']))
    $this->Text($mcol + 200, $_POST['page_titl'],$mcol2);
//display_error($_POST['page_titl']);
$this->fontSize -= 4;

$this->NewLine();
//$this->Text($mcol + 100, $this->formData['document_name']);
//	$this->Text($mcol + 180, $this->formData['document_number']);
$this->NewLine(2);

if ($this->pageNumber > 1)
    $this->Text($mcol + 180, _("Page") . ' ' . $this->pageNumber);
$this->row = $iline1 - $this->lineHeight;		

$this->fontSize -= 4;
$this->fontSize += 6;
$this->Text($ccol, _("Employee Personal Information"), $icol,0,-21);
//$this->Text($mcol, $Addr1['title']);
$this->fontSize -= 2;

// address1
$temp = $this->row = $this->row - $this->lineHeight - 5;
/*if($this->formData['doctype'] == 'paysummary' ){
if($Addr1['id'] != ''){
    $this->Text($ccol, 'Month', $icol,0,-4);
    $this->Text($ccol+100, kv_month_name_by_id($Addr1['id']), $icol,0,-4);
    $this->NewLine();
}

$this->NewLine();
$this->Text($ccol, 'Year', $icol,0,1);
$fYear = get_fiscalyear($Addr1['year']);
$this->Text($ccol+100, $fYear['begin'] .' - '. $fYear['end'], $icol,0,1);
}
else{*/
$this->Text($ccol, _('Employee ID'), $icol,0,-14);
$this->Text($ccol+120, $empl_details['empl_id'], $icol,0,-14);		
$this->Text($ccol+285, _('Department'), $icol,0,-14);
$dept = GetSingleValue('kv_empl_departments', 'description', array('id'=> $job_details['department']));
$this->Text($ccol+380, $dept, $icol,0,-14);	

$this->NewLine();
$this->Text($ccol, _('Name of Employee'), $icol,0,-10);

if($empl_details['empl_salutation'] == null || $empl_details['empl_salutation']  == '' || $empl_details['empl_salutation']  == 0 )
    $empl_salutation = 1; 
else
    $empl_salutation = $empl_details['empl_salutation'];
$this->Text($ccol+120, $hrm_empl_salutation[$empl_salutation] . ' ' . $empl_details['empl_firstname'] .' '. $empl_details['empl_lastname'], $icol,0,-10);		
$this->Text($ccol+285, _('Mobile Phone'), $icol,0,-10);		 
$this->Text($ccol+380, $empl_details['mobile_phone'], $icol,0,-10);	

$this->NewLine();
$this->Text($ccol, _('Email'), $icol,0,-6);		 
$this->Text($ccol+120, $empl_details['email'], $icol,0,-6);

// Line headers
$this->row = $iline2 - $this->lineHeight - 1;
$this->Font('bold');
$count = count_array($this->headers);
$this->cols[$count] = $right ;
for ($i = 0; $i < $count; $i++)
    $this->TextCol($i, $i + 1, $this->headers[$i], -2);
$this->Font();

// Footer
$this->Font('italic');
$this->row = $iline7 - $this->lineHeight - 50;

foreach ($Footer as $line => $txt){
    if (!is_numeric($line))	{// title => link			
        $this->fontSize -= 2;
        $this->TextWrap($ccol, $this->row, $right - $ccol, $line, 'C');
        $this->row -= $this->lineHeight;
        $this->SetTextColor(0, 0, 255);
        $this->TextWrap($ccol, $this->row, $right - $ccol, $txt, 'C');
        $this->SetTextColor(0, 0, 0);
        $this->addLink($txt, $ccol, $this->row, $this->pageWidth - $this->rightMargin, $this->row + $this->lineHeight);
        $this->fontSize += 2;
    }
    else
        $this->TextWrap($ccol, $this->row, $right - $ccol, $txt, 'C');
    $this->row -= $this->lineHeight;

}

$this->Font();
$temp = $iline6 - $this->lineHeight - 2;
$this->row = $temp;