예제 #1
0
 function getROE($rlf = NULL, $show_background = TRUE)
 {
     if (!is_object($rlf) and $this->getId() != '') {
         $rlf = TTnew('ROEListFactory');
         $rlf->getById($this->getId());
     }
     if (get_class($rlf) !== 'ROEListFactory') {
         return FALSE;
     }
     $border = 0;
     if ($rlf->getRecordCount() > 0) {
         $ppsf = TTnew('PayPeriodScheduleListFactory');
         $pay_period_type_options = $ppsf->getOptions('type');
         $pdf = new TTPDF();
         $pdf->setMargins(0, 0, 0, 0);
         $pdf->SetAutoPageBreak(FALSE);
         foreach ($rlf as $r_obj) {
             $pdf->SetFont('freesans', '', 12);
             //Get User information
             $ulf = TTnew('UserListFactory');
             $user_obj = $ulf->getById($r_obj->getUser())->getCurrent();
             $ulf = TTnew('UserListFactory');
             $created_user_obj = $ulf->getById($r_obj->getCreatedBy())->getCurrent();
             //Get company information
             $clf = TTnew('CompanyListFactory');
             $company_obj = $clf->getById($user_obj->getCompany())->getCurrent();
             $pdf->AddPage();
             if ($show_background == TRUE) {
                 //Use this command to convert PDF to images: convert -density 600x600 -quality 00 $file
                 $pdf->Image(Environment::getImagesPath() . 'roe-template.jpg', 0, 0, 210, 300);
             }
             //Serial
             $pdf->setXY(10, 17);
             $pdf->Cell(55, 10, $r_obj->getSerial(), $border, 0, 'L');
             //Employer Info
             $pdf->setXY(10, 30);
             $pdf->Cell(120, 10, $company_obj->getName(), $border, 0, 'L');
             $pdf->setXY(10, 40);
             $pdf->Cell(120, 10, $company_obj->getAddress1() . ' ' . $company_obj->getAddress2(), $border, 0, 'L');
             $pdf->setXY(10, 50);
             $pdf->Cell(90, 10, $company_obj->getCity() . ', ' . $company_obj->getProvince(), $border, 0, 'L');
             $postal_code_a = substr($company_obj->getPostalCode(), 0, 3);
             $postal_code_b = substr($company_obj->getPostalCode(), 3, 6);
             $pdf->setXY(110, 50);
             $pdf->Cell(10, 10, $postal_code_a, $border, 0, 'L');
             $pdf->setXY(122, 50);
             $pdf->Cell(10, 10, $postal_code_b, $border, 0, 'L');
             //Business Number
             $pdf->setXY(138, 28);
             $pdf->Cell(120, 10, $company_obj->getBusinessNumber(), $border, 0, 'L');
             //Pay Period Type
             $pdf->setXY(138, 40);
             $pdf->Cell(50, 10, $pay_period_type_options[$r_obj->getPayPeriodType()], $border, 0, 'L');
             //SIN
             $pdf->setXY(138, 50);
             $pdf->Cell(50, 10, $user_obj->getSIN(), $border, 0, 'L');
             //Employee info
             $pdf->SetFontSize(10);
             $pdf->setXY(10, 75);
             $pdf->Cell(90, 5, $user_obj->getFullName(), $border, 0, 'L');
             $pdf->setXY(10, 80);
             $pdf->Cell(90, 5, $user_obj->getAddress1() . ' ' . $user_obj->getAddress2(), $border, 0, 'L');
             $pdf->setXY(10, 85);
             $pdf->Cell(90, 5, $user_obj->getCity() . ', ' . $user_obj->getProvince() . ' ' . $user_obj->getPostalCode(), $border, 0, 'L');
             $pdf->SetFontSize(12);
             //Employee Title
             if (is_object($user_obj->getTitleObject())) {
                 $title = $user_obj->getTitleObject()->getName();
             } else {
                 $title = NULL;
             }
             $pdf->setXY(10, 100);
             $pdf->Cell(90, 10, $title, $border, 0, 'L');
             //First Day Worked
             $pdf->SetFontSize(10);
             $first_date = getdate($r_obj->getFirstDate());
             $pdf->setXY(175, 64);
             $pdf->Cell(8, 10, $first_date['mday'], $border, 0, 'C');
             $pdf->setXY(185, 64);
             $pdf->Cell(8, 10, $first_date['mon'], $border, 0, 'C');
             $pdf->setXY(196, 64);
             $pdf->Cell(10, 10, $first_date['year'], $border, 0, 'C');
             //Last day paid
             $last_date = getdate($r_obj->getLastDate());
             $pdf->setXY(175, 75);
             $pdf->Cell(8, 10, $last_date['mday'], $border, 0, 'C');
             $pdf->setXY(185, 75);
             $pdf->Cell(8, 10, $last_date['mon'], $border, 0, 'C');
             $pdf->setXY(196, 75);
             $pdf->Cell(10, 10, $last_date['year'], $border, 0, 'C');
             //Pay Period End Date
             $pay_period_end_date = getdate($r_obj->getPayPeriodEndDate());
             $pdf->setXY(175, 86);
             $pdf->Cell(8, 10, $pay_period_end_date['mday'], $border, 0, 'C');
             $pdf->setXY(185, 86);
             $pdf->Cell(8, 10, $pay_period_end_date['mon'], $border, 0, 'C');
             $pdf->setXY(196, 86);
             $pdf->Cell(10, 10, $pay_period_end_date['year'], $border, 0, 'C');
             //Insurable Hours
             $pdf->SetFontSize(10);
             $pdf->setXY(75, 113);
             $pdf->Cell(25, 10, Misc::getBeforeDecimal($r_obj->getInsurableHours()), $border, 0, 'R');
             $pdf->setXY(101, 113);
             $pdf->Cell(10, 10, Misc::getAfterDecimal(Misc::MoneyFormat($r_obj->getInsurableHours(), FALSE)), $border, 0, 'L');
             //Enter Code
             $pdf->setXY(185, 113);
             $pdf->Cell(10, 10, $r_obj->getCode(), $border, 0, 'C');
             //Further Information Contact Name
             $pdf->setXY(130, 126);
             $pdf->Cell(75, 5, $created_user_obj->getFullName(), $border, 0, 'R');
             $pdf->setXY(130, 132);
             $pdf->Cell(75, 10, $created_user_obj->getWorkPhone(), $border, 0, 'R');
             //Insurable Earnings
             $pdf->setXY(75, 131);
             $pdf->Cell(25, 10, Misc::getBeforeDecimal($r_obj->getInsurableEarnings()), $border, 0, 'R');
             $pdf->setXY(101, 131);
             $pdf->Cell(10, 10, Misc::getAfterDecimal(Misc::MoneyFormat($r_obj->getInsurableEarnings(), FALSE)), $border, 0, 'L');
             //Check to see if a pay period didn't have earnings.
             if ($r_obj->isPayPeriodWithNoEarnings() == TRUE) {
                 $pay_period_earnings = $r_obj->getInsurableEarningsByPayPeriod();
                 if (is_array($pay_period_earnings)) {
                     //Add additional entries for testing alignment purposes.
                     /*
                     for( $y=0; $y < 14; $y++ ) {
                     	$pay_period_earnings[] = array('amount' => rand(1,10) );
                     }
                     */
                     $top_left_x = $x = Misc::AdjustXY(30, 0);
                     $top_left_y = $y = Misc::AdjustXY(157, 0);
                     $col = 1;
                     $i = 1;
                     foreach ($pay_period_earnings as $pay_period_earning) {
                         Debug::Text('I: ' . $i . ' X: ' . $x . ' Y: ' . $y . ' Col: ' . $col . ' Amount: ' . (double) $pay_period_earning['amount'], __FILE__, __LINE__, __METHOD__, 10);
                         $pdf->setXY($x, $y);
                         $pdf->Cell(6, 6, Misc::MoneyFormat((double) $pay_period_earning['amount'], FALSE), $border, 0, 'R');
                         if ($i > 0 and $i % 3 == 0) {
                             $x = $top_left_x;
                             $y += 7;
                         } else {
                             $x += 35;
                         }
                         $i++;
                     }
                 }
             }
             //Box 17A, Vacation pay in last pay period.
             $vacation_pay = $r_obj->getLastPayPeriodVacationEarnings();
             if ($vacation_pay > 0) {
                 $pdf->setXY(132, 155);
                 $pdf->Cell(10, 10, Misc::getBeforeDecimal(Misc::MoneyFormat($vacation_pay, FALSE)), $border, 0, 'R');
                 $pdf->Cell(10, 10, Misc::getAfterDecimal(Misc::MoneyFormat($vacation_pay, FALSE)), $border, 0, 'L');
             }
             //Comments
             $pdf->setXY(115, 212);
             $pdf->MultiCell(85, 5, $r_obj->getComments(), $border, 'L');
             //English
             $pdf->setXY(8.5, 256.5);
             $pdf->Cell(10, 10, 'X', $border, 0, 'L');
             //ROE creator phone number
             $pdf->setXY(75, 258);
             $pdf->Cell(25, 10, $created_user_obj->getWorkPhone(), $border, 0, 'L');
             //ROE create name.
             $pdf->SetFontSize(12);
             $pdf->setXY(87, 273);
             $pdf->Cell(75, 10, $created_user_obj->getFullName(), $border, 0, 'C');
             //Create Date
             $created_date = getdate($r_obj->getCreatedDate());
             $pdf->SetFontSize(10);
             $pdf->setXY(175, 273);
             $pdf->Cell(8, 10, $created_date['mday'], $border, 0, 'C');
             $pdf->setXY(185, 273);
             $pdf->Cell(8, 10, $created_date['mon'], $border, 0, 'C');
             $pdf->setXY(195, 273);
             $pdf->Cell(10, 10, $created_date['year'], $border, 0, 'C');
         }
         $output = $pdf->Output('', 'S');
     }
     if (isset($output)) {
         return $output;
     }
     return FALSE;
 }