Exemple #1
0
switch ($action) {
    case 'print_form':
    case 'display_form':
    case 'display_report':
        //Debug::setVerbosity(11);
        if ($action == 'print_form') {
            $show_background = FALSE;
        } else {
            $show_background = TRUE;
        }
        Debug::Text('Submit!: ' . $action, __FILE__, __LINE__, __METHOD__, 10);
        Debug::Arr($filter_data, 'aFilter Data', __FILE__, __LINE__, __METHOD__, 10);
        //Save report setup data
        $ugdlf->getByCompanyIdAndScriptAndDefault($current_company->getId(), $_SERVER['SCRIPT_NAME']);
        if ($ugdlf->getRecordCount() > 0) {
            $ugdf->setID($ugdlf->getCurrent()->getID());
        }
        $ugdf->setCompany($current_company->getId());
        $ugdf->setScript($_SERVER['SCRIPT_NAME']);
        $ugdf->setName($title);
        $ugdf->setData($setup_data);
        $ugdf->setDefault(TRUE);
        if ($ugdf->isValid()) {
            $ugdf->Save();
        }
        $ulf = new UserListFactory();
        $ulf->getSearchByCompanyIdAndArrayCriteria($current_company->getId(), $filter_data);
        if ($ulf->getRecordCount() > 0) {
            foreach ($ulf as $u_obj) {
                $filter_data['user_ids'][] = $u_obj->getId();
            }
 case 'delete':
 case 'save':
     Debug::Text('Action: ' . $action, __FILE__, __LINE__, __METHOD__, 10);
     $generic_data['id'] = UserGenericDataFactory::reportFormDataHandler($action, $filter_data, $generic_data, URLBuilder::getURL(NULL, $_SERVER['SCRIPT_NAME']));
     unset($generic_data['name']);
 default:
     BreadCrumb::setCrumb($title);
     if ($action == 'load') {
         Debug::Text('Loading Report!', __FILE__, __LINE__, __METHOD__, 10);
         extract(UserGenericDataFactory::getReportFormData($generic_data['id']));
     } elseif ($action == '') {
         //Check for default saved report first.
         $ugdlf->getByUserIdAndScriptAndDefault($current_user->getId(), $_SERVER['SCRIPT_NAME']);
         if ($ugdlf->getRecordCount() > 0) {
             Debug::Text('Found Default Report!', __FILE__, __LINE__, __METHOD__, 10);
             $ugd_obj = $ugdlf->getCurrent();
             $filter_data = $ugd_obj->getData();
             $generic_data['id'] = $ugd_obj->getId();
         } else {
             Debug::Text('Default Settings!', __FILE__, __LINE__, __METHOD__, 10);
             //Default selections
             $filter_data['user_status_ids'] = array(-1);
             $filter_data['branch_ids'] = array(-1);
             $filter_data['department_ids'] = array(-1);
             $filter_data['user_title_ids'] = array(-1);
             $filter_data['pay_period_ids'] = array('-0000-' . array_shift(array_keys($pay_period_options)));
             $filter_data['group_ids'] = array(-1);
             $filter_data['currency_ids'] = array(-1);
             $default_columns = array(5 => '-1000-full_name');
             $pseallf = new PayStubEntryAccountLinkListFactory();
             $pseallf->getByCompanyId($current_company->getId());
 function reCalculate()
 {
     //Re-generate final pay stub
     //get current pay period based off their last day of work
     $pplf = new PayPeriodListFactory();
     $pay_period_id = $pplf->getByUserIdAndEndDate($this->getUser(), $this->getLastDate())->getCurrent()->getId();
     Debug::Text('Pay Period ID: ' . $pay_period_id, __FILE__, __LINE__, __METHOD__, 10);
     if (is_numeric($pay_period_id) == FALSE) {
         UserGenericStatusFactory::queueGenericStatus($this->getUserObject()->getFullName(TRUE) . ' - ' . TTi18n::gettext('Pay Stub'), 10, TTi18n::gettext('Pay Period is invalid!'), NULL);
         return FALSE;
     }
     if ($this->getEnableGeneratePayStub() == TRUE) {
         //Find out if a pay stub is already generated for the pay period we are currently in.
         //If it is, delete it so we can start from fresh
         $pslf = new PayStubListFactory();
         $pslf->getByUserIdAndPayPeriodId($this->getUser(), $pay_period_id);
         foreach ($pslf as $pay_stub) {
             Debug::Text('Found Pay Stub ID: ' . $pay_stub->getId(), __FILE__, __LINE__, __METHOD__, 10);
             //Do not delete PAID pay stubs!
             if ($pay_stub->getStatus() == 10) {
                 Debug::Text('Last Pay Stub Exists: ' . $pay_stub->getId(), __FILE__, __LINE__, __METHOD__, 10);
                 $pay_stub->setDeleted(TRUE);
                 $pay_stub->Save();
             }
         }
         //FIXME: Make sure user isn't already in-active! Otherwise pay stub won't generate.
         //Check if pay stub is already generated as well, if it is, and marked paid, then
         //we can't re-generate it, we need to skip this step.
         Debug::Text('Calculating Pay Stub...', __FILE__, __LINE__, __METHOD__, 10);
         $cps = new CalculatePayStub();
         $cps->setUser($this->getUser());
         $cps->setPayPeriod($pay_period_id);
         $cps->calculate();
         Debug::Text('Done Calculating Pay Stub', __FILE__, __LINE__, __METHOD__, 10);
     } else {
         UserGenericStatusFactory::queueGenericStatus($this->getUserObject()->getFullName(TRUE), 20, TTi18n::gettext('Not generating final pay stub!'), NULL);
     }
     //FIXME: Alert the user if they don't have enough information in TimeTrex to get accurate values.
     //Get insurable hours, earnings, and vacation pay now that the final pay stub is generated
     $ugdlf = new UserGenericDataListFactory();
     $ugdlf->getByCompanyIdAndScriptAndDefault($this->getUserObject()->getCompany(), $this->getTable());
     if ($ugdlf->getRecordCount() > 0) {
         Debug::Text('Found Company Form Setup!', __FILE__, __LINE__, __METHOD__, 10);
         $ugd_obj = $ugdlf->getCurrent();
         $setup_data = $ugd_obj->getData();
     }
     unset($ugd_obj);
     if (isset($setup_data)) {
         //var_dump($setup_data);
         if (isset($setup_data['insurable_earnings_psea_ids'])) {
             $insurable_earnings_psea_ids = $setup_data['insurable_earnings_psea_ids'];
         } else {
             //Fall back to Total Gross.
             $insurable_earnings_psea_ids = $this->getPayStubEntryAccountLinkObject()->getTotalGross();
         }
     }
     //Find out the date of how far back we have to go to get insurable values.
     //Insurable Hours
     $insurable_hours_start_date = $this->getInsurablePayPeriodStartDate($this->getInsurableHoursReportPayPeriods());
     //Insurable hours dont include stats!Just get total signed in hours.
     //If someone has just a negative bank time balance, those are NOT insurable.
     $udtlf = new UserDateTotalListFactory();
     $worked_total_time = $udtlf->getWorkedTimeSumByUserIDAndStartDateAndEndDate($this->getUser(), $insurable_hours_start_date, $this->getLastDate());
     Debug::text('Worked Total Time: ' . $worked_total_time, __FILE__, __LINE__, __METHOD__, 10);
     $total_hours = Misc::MoneyFormat(TTDate::getHours($worked_total_time), FALSE);
     Debug::Text('Total Insurable Hours: ' . $total_hours, __FILE__, __LINE__, __METHOD__, 10);
     $insurable_earnings_start_date = $this->getInsurablePayPeriodStartDate($this->getInsurableEarningsReportPayPeriods());
     $pself = new PayStubEntryListFactory();
     $total_earnings = $this->getTotalInsurableEarnings();
     //$total_earnings = $pself->getAmountSumByUserIdAndEntryNameIdAndStartDateAndEndDate( $this->getUser(), $insurable_earnings_psea_ids, $insurable_earnings_start_date, $this->getLastDate(), 0 );
     //$total_earnings = $total_earnings['amount'];
     //Note, this includes the current pay stub we just generated
     Debug::Text('Total Insurable Earnings: ' . $total_earnings, __FILE__, __LINE__, __METHOD__, 10);
     UserGenericStatusFactory::queueGenericStatus($this->getUserObject()->getFullName(TRUE) . ' - ' . TTi18n::gettext('Record of Employment'), 30, TTi18n::gettext('Insurable Hours:') . ' ' . $total_hours . ' ' . TTi18n::gettext('Insurable Earnings:') . ' ' . $total_earnings, NULL);
     //ReSave these
     if ($this->getId() != '') {
         $rlf = new ROEListFactory();
         $rlf->getById($this->getId());
         if ($rlf->getRecordCount() > 0) {
             $roe_obj = $rlf->getCurrent();
             $roe_obj->setInsurableHours($total_hours);
             $roe_obj->setInsurableEarnings($total_earnings);
             if ($roe_obj->isValid()) {
                 $roe_obj->Save();
             }
         }
     }
     return TRUE;
 }
 function exportPayStub($pslf = NULL, $export_type = NULL)
 {
     global $current_company;
     if (!is_object($pslf) and $this->getId() != '') {
         $pslf = new PayStubListFactory();
         $pslf->getById($this->getId());
     }
     if (get_class($pslf) !== 'PayStubListFactory') {
         return FALSE;
     }
     if ($export_type == '') {
         return FALSE;
     }
     if ($pslf->getRecordCount() > 0) {
         Debug::Text('aExporting...', __FILE__, __LINE__, __METHOD__, 10);
         switch (strtolower($export_type)) {
             case 'hsbc':
             case '1464':
             case '105':
             case 'ach':
                 //Get file creation number
                 $ugdlf = new UserGenericDataListFactory();
                 $ugdlf->getByCompanyIdAndScriptAndDefault($current_company->getId(), 'PayStubFactory', TRUE);
                 if ($ugdlf->getRecordCount() > 0) {
                     Debug::Text('Found Script Setup Data!', __FILE__, __LINE__, __METHOD__, 10);
                     $ugd_obj = $ugdlf->getCurrent();
                     $setup_data = $ugd_obj->getData();
                 } else {
                     $ugd_obj = new UserGenericDataFactory();
                 }
                 Debug::Text('bExporting...', __FILE__, __LINE__, __METHOD__, 10);
                 //get User Bank account info
                 $balf = new BankAccountListFactory();
                 $balf->getCompanyAccountByCompanyId($current_company->getID());
                 if ($balf->getRecordCount() > 0) {
                     $company_bank_obj = $balf->getCurrent();
                     //Debug::Arr($company_bank_obj,'Company Bank Object', __FILE__, __LINE__, __METHOD__,10);
                 }
                 if (isset($setup_data['file_creation_number'])) {
                     $setup_data['file_creation_number']++;
                 } else {
                     //Start at a high number, in attempt to eliminate conflicts.
                     $setup_data['file_creation_number'] = 500;
                 }
                 Debug::Text('bFile Creation Number: ' . $setup_data['file_creation_number'], __FILE__, __LINE__, __METHOD__, 10);
                 //Increment file creation number in DB
                 if ($ugd_obj->getId() == '') {
                     $ugd_obj->setID($ugd_obj->getId());
                 }
                 $ugd_obj->setCompany($current_company->getId());
                 $ugd_obj->setName('PayStubFactory');
                 $ugd_obj->setScript('PayStubFactory');
                 $ugd_obj->setData($setup_data);
                 $ugd_obj->setDefault(TRUE);
                 if ($ugd_obj->isValid()) {
                     $ugd_obj->Save();
                 }
                 $eft = new EFT();
                 $eft->setFileFormat($export_type);
                 $eft->setOriginatorID($current_company->getOriginatorID());
                 $eft->setFileCreationNumber($setup_data['file_creation_number']);
                 $eft->setDataCenter($current_company->getDataCenterID());
                 $eft->setOriginatorShortName($current_company->getShortName());
                 $psealf = new PayStubEntryAccountListFactory();
                 foreach ($pslf as $pay_stub_obj) {
                     Debug::Text('Looping over Pay Stub... ID: ' . $pay_stub_obj->getId(), __FILE__, __LINE__, __METHOD__, 10);
                     //Get pay stub entries.
                     $pself = new PayStubEntryListFactory();
                     $pself->getByPayStubId($pay_stub_obj->getId());
                     $prev_type = NULL;
                     $description_subscript_counter = 1;
                     foreach ($pself as $pay_stub_entry) {
                         $description_subscript = NULL;
                         //$pay_stub_entry_name_obj = $psenlf->getById( $pay_stub_entry->getPayStubEntryNameId() ) ->getCurrent();
                         $pay_stub_entry_name_obj = $psealf->getById($pay_stub_entry->getPayStubEntryNameId())->getCurrent();
                         if ($prev_type == 40 or $pay_stub_entry_name_obj->getType() != 40) {
                             $type = $pay_stub_entry_name_obj->getType();
                         }
                         //var_dump( $pay_stub_entry->getDescription() );
                         if ($pay_stub_entry->getDescription() !== NULL and $pay_stub_entry->getDescription() !== FALSE and strlen($pay_stub_entry->getDescription()) > 0) {
                             $pay_stub_entry_descriptions[] = array('subscript' => $description_subscript_counter, 'description' => $pay_stub_entry->getDescription());
                             $description_subscript = $description_subscript_counter;
                             $description_subscript_counter++;
                         }
                         if ($type != 40 or $type == 40 and $pay_stub_entry->getAmount() != 0) {
                             $pay_stub_entries[$type][] = array('id' => $pay_stub_entry->getId(), 'pay_stub_entry_name_id' => $pay_stub_entry->getPayStubEntryNameId(), 'type' => $pay_stub_entry_name_obj->getType(), 'name' => $pay_stub_entry_name_obj->getName(), 'display_name' => $pay_stub_entry_name_obj->getName(), 'rate' => $pay_stub_entry->getRate(), 'units' => $pay_stub_entry->getUnits(), 'ytd_units' => $pay_stub_entry->getYTDUnits(), 'amount' => $pay_stub_entry->getAmount(), 'ytd_amount' => $pay_stub_entry->getYTDAmount(), 'description' => $pay_stub_entry->getDescription(), 'description_subscript' => $description_subscript, 'created_date' => $pay_stub_entry->getCreatedDate(), 'created_by' => $pay_stub_entry->getCreatedBy(), 'updated_date' => $pay_stub_entry->getUpdatedDate(), 'updated_by' => $pay_stub_entry->getUpdatedBy(), 'deleted_date' => $pay_stub_entry->getDeletedDate(), 'deleted_by' => $pay_stub_entry->getDeletedBy());
                         }
                         $prev_type = $pay_stub_entry_name_obj->getType();
                     }
                     if (isset($pay_stub_entries)) {
                         $pay_stub = array('id' => $pay_stub_obj->getId(), 'display_id' => str_pad($pay_stub_obj->getId(), 12, 0, STR_PAD_LEFT), 'user_id' => $pay_stub_obj->getUser(), 'pay_period_id' => $pay_stub_obj->getPayPeriod(), 'start_date' => $pay_stub_obj->getStartDate(), 'end_date' => $pay_stub_obj->getEndDate(), 'transaction_date' => $pay_stub_obj->getTransactionDate(), 'status' => $pay_stub_obj->getStatus(), 'entries' => $pay_stub_entries, 'created_date' => $pay_stub_obj->getCreatedDate(), 'created_by' => $pay_stub_obj->getCreatedBy(), 'updated_date' => $pay_stub_obj->getUpdatedDate(), 'updated_by' => $pay_stub_obj->getUpdatedBy(), 'deleted_date' => $pay_stub_obj->getDeletedDate(), 'deleted_by' => $pay_stub_obj->getDeletedBy());
                         unset($pay_stub_entries);
                         //Get User information
                         $ulf = new UserListFactory();
                         $user_obj = $ulf->getById($pay_stub_obj->getUser())->getCurrent();
                         //Get company information
                         $clf = new CompanyListFactory();
                         $company_obj = $clf->getById($user_obj->getCompany())->getCurrent();
                         //get User Bank account info
                         $balf = new BankAccountListFactory();
                         $user_bank_obj = $balf->getUserAccountByCompanyIdAndUserId($user_obj->getCompany(), $user_obj->getId());
                         if ($user_bank_obj->getRecordCount() > 0) {
                             $user_bank_obj = $user_bank_obj->getCurrent();
                         } else {
                             continue;
                         }
                         $record = new EFT_Record();
                         $record->setType('C');
                         $amount = $pay_stub['entries'][40][0]['amount'];
                         $record->setCPACode(200);
                         $record->setAmount($amount);
                         unset($amount);
                         $record->setDueDate(TTDate::getBeginDayEpoch($pay_stub_obj->getTransactionDate()));
                         //$record->setDueDate( strtotime("24-Sep-99") );
                         $record->setInstitution($user_bank_obj->getInstitution());
                         $record->setTransit($user_bank_obj->getTransit());
                         $record->setAccount($user_bank_obj->getAccount());
                         $record->setName($user_obj->getFullName());
                         $record->setOriginatorShortName($company_obj->getShortName());
                         $record->setOriginatorLongName(substr($company_obj->getName(), 0, 30));
                         $record->setOriginatorReferenceNumber('TT' . $pay_stub_obj->getId());
                         if (isset($company_bank_obj) and is_object($company_bank_obj)) {
                             $record->setReturnInstitution($company_bank_obj->getInstitution());
                             $record->setReturnTransit($company_bank_obj->getTransit());
                             $record->setReturnAccount($company_bank_obj->getAccount());
                         }
                         $eft->setRecord($record);
                     }
                 }
                 $eft->compile();
                 $output = $eft->getCompiledData();
                 break;
             case 'cheque_9085':
             case 'cheque_9209p':
             case 'cheque_dlt103':
             case 'cheque_dlt104':
             case 'cheque_cr_standard_form_1':
             case 'cheque_cr_standard_form_2':
                 $border = 0;
                 $show_background = 0;
                 $pdf = new TTPDF();
                 $pdf->setMargins(0, 0, 0, 0);
                 $pdf->SetAutoPageBreak(FALSE);
                 $pdf->SetFont('freeserif', '', 10);
                 $psealf = new PayStubEntryAccountListFactory();
                 $i = 0;
                 foreach ($pslf as $pay_stub_obj) {
                     //Get pay stub entries.
                     $pself = new PayStubEntryListFactory();
                     $pself->getByPayStubId($pay_stub_obj->getId());
                     $pay_stub_entries = NULL;
                     $prev_type = NULL;
                     $description_subscript_counter = 1;
                     foreach ($pself as $pay_stub_entry) {
                         $description_subscript = NULL;
                         //$pay_stub_entry_name_obj = $psenlf->getById( $pay_stub_entry->getPayStubEntryNameId() ) ->getCurrent();
                         $pay_stub_entry_name_obj = $psealf->getById($pay_stub_entry->getPayStubEntryNameId())->getCurrent();
                         //Use this to put the total for each type at the end of the array.
                         if ($prev_type == 40 or $pay_stub_entry_name_obj->getType() != 40) {
                             $type = $pay_stub_entry_name_obj->getType();
                         }
                         //Debug::text('Pay Stub Entry Name ID: '. $pay_stub_entry_name_obj->getId() .' Type ID: '. $pay_stub_entry_name_obj->getType() .' Type: '. $type, __FILE__, __LINE__, __METHOD__,10);
                         //var_dump( $pay_stub_entry->getDescription() );
                         if ($pay_stub_entry->getDescription() !== NULL and $pay_stub_entry->getDescription() !== FALSE and strlen($pay_stub_entry->getDescription()) > 0) {
                             $pay_stub_entry_descriptions[] = array('subscript' => $description_subscript_counter, 'description' => $pay_stub_entry->getDescription());
                             $description_subscript = $description_subscript_counter;
                             $description_subscript_counter++;
                         }
                         $amount_words = str_pad(ucwords(Numbers_Words::toWords(floor($pay_stub_entry->getAmount()), "en_US")) . ' ', 65, "-", STR_PAD_RIGHT);
                         //echo "Amount: ". floor($pay_stub_entry->getAmount()) ." - Words: ". $amount_words ."<br>\n";
                         //var_dump($amount_words);
                         if ($type != 40 or $type == 40 and $pay_stub_entry->getAmount() != 0) {
                             $pay_stub_entries[$type][] = array('id' => $pay_stub_entry->getId(), 'pay_stub_entry_name_id' => $pay_stub_entry->getPayStubEntryNameId(), 'type' => $pay_stub_entry_name_obj->getType(), 'name' => $pay_stub_entry_name_obj->getName(), 'display_name' => $pay_stub_entry_name_obj->getName(), 'rate' => $pay_stub_entry->getRate(), 'units' => $pay_stub_entry->getUnits(), 'ytd_units' => $pay_stub_entry->getYTDUnits(), 'amount' => $pay_stub_entry->getAmount(), 'amount_padded' => str_pad($pay_stub_entry->getAmount(), 12, '*', STR_PAD_LEFT), 'amount_words' => $amount_words, 'amount_cents' => Misc::getAfterDecimal($pay_stub_entry->getAmount()), 'ytd_amount' => $pay_stub_entry->getYTDAmount(), 'description' => $pay_stub_entry->getDescription(), 'description_subscript' => $description_subscript, 'created_date' => $pay_stub_entry->getCreatedDate(), 'created_by' => $pay_stub_entry->getCreatedBy(), 'updated_date' => $pay_stub_entry->getUpdatedDate(), 'updated_by' => $pay_stub_entry->getUpdatedBy(), 'deleted_date' => $pay_stub_entry->getDeletedDate(), 'deleted_by' => $pay_stub_entry->getDeletedBy());
                         }
                         unset($amount_words);
                         //Only for net pay, make a total YTD of Advance plus Net.
                         /*
                         if ( $type == 40 ) {
                         	$pay_stub_entries[$type][0]['ytd_net_plus_advance'] =
                         }
                         */
                         $prev_type = $pay_stub_entry_name_obj->getType();
                     }
                     //Get User information
                     $ulf = new UserListFactory();
                     $user_obj = $ulf->getById($pay_stub_obj->getUser())->getCurrent();
                     //Get company information
                     $clf = new CompanyListFactory();
                     $company_obj = $clf->getById($user_obj->getCompany())->getCurrent();
                     if ($user_obj->getCountry() == 'CA') {
                         $date_format = 'd/m/Y';
                     } else {
                         $date_format = 'm/d/Y';
                     }
                     $pay_stub = array('id' => $pay_stub_obj->getId(), 'display_id' => str_pad($pay_stub_obj->getId(), 15, 0, STR_PAD_LEFT), 'user_id' => $pay_stub_obj->getUser(), 'pay_period_id' => $pay_stub_obj->getPayPeriod(), 'start_date' => $pay_stub_obj->getStartDate(), 'end_date' => $pay_stub_obj->getEndDate(), 'transaction_date' => $pay_stub_obj->getTransactionDate(), 'transaction_date_display' => date($date_format, $pay_stub_obj->getTransactionDate()), 'status' => $pay_stub_obj->getStatus(), 'entries' => $pay_stub_entries, 'tainted' => $pay_stub_obj->getTainted(), 'created_date' => $pay_stub_obj->getCreatedDate(), 'created_by' => $pay_stub_obj->getCreatedBy(), 'updated_date' => $pay_stub_obj->getUpdatedDate(), 'updated_by' => $pay_stub_obj->getUpdatedBy(), 'deleted_date' => $pay_stub_obj->getDeletedDate(), 'deleted_by' => $pay_stub_obj->getDeletedBy());
                     unset($pay_stub_entries);
                     Debug::text($i . '. Pay Stub Transaction Date: ' . $pay_stub_obj->getTransactionDate(), __FILE__, __LINE__, __METHOD__, 10);
                     //Get Pay Period information
                     $pplf = new PayPeriodListFactory();
                     $pay_period_obj = $pplf->getById($pay_stub_obj->getPayPeriod())->getCurrent();
                     $pp_start_date = $pay_period_obj->getStartDate();
                     $pp_end_date = $pay_period_obj->getEndDate();
                     $pp_transaction_date = $pay_period_obj->getTransactionDate();
                     //Get pay period numbers
                     $ppslf = new PayPeriodScheduleListFactory();
                     $pay_period_schedule_obj = $ppslf->getById($pay_period_obj->getPayPeriodSchedule())->getCurrent();
                     $pay_period_data = array('start_date' => TTDate::getDate('DATE', $pp_start_date), 'end_date' => TTDate::getDate('DATE', $pp_end_date), 'transaction_date' => TTDate::getDate('DATE', $pp_transaction_date), 'annual_pay_periods' => $pay_period_schedule_obj->getAnnualPayPeriods());
                     $pdf->AddPage();
                     switch ($export_type) {
                         case 'cheque_9085':
                             $adjust_x = 0;
                             $adjust_y = -5;
                             if ($show_background == 1) {
                                 $pdf->Image(Environment::getBasePath() . 'interface/images/nebs_cheque_9085.jpg', 0, 0, 210, 300);
                             }
                             $pdf->setXY(Misc::AdjustXY(17, $adjust_x), Misc::AdjustXY(42, $adjust_y));
                             $pdf->Cell(100, 5, $pay_stub['entries'][40][0]['amount_words'], $border, 0, 'L');
                             $pdf->Cell(15, 5, $pay_stub['entries'][40][0]['amount_cents'] . '/100', $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(130, $adjust_x), Misc::AdjustXY(50, $adjust_y));
                             $pdf->Cell(38, 5, $pay_stub['transaction_date_display'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(175, $adjust_x), Misc::AdjustXY(50, $adjust_y));
                             $pdf->Cell(23, 5, ' ' . $pay_stub_obj->getCurrencyObject()->getSymbol() . $pay_stub['entries'][40][0]['amount_padded'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(17, $adjust_x), Misc::AdjustXY(55, $adjust_y));
                             $pdf->Cell(100, 5, $user_obj->getFullName(), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(17, $adjust_x), Misc::AdjustXY(60, $adjust_y));
                             $pdf->Cell(100, 5, $user_obj->getAddress1() . ' ' . $user_obj->getAddress2(), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(17, $adjust_x), Misc::AdjustXY(65, $adjust_y));
                             $pdf->Cell(100, 5, $user_obj->getCity() . ', ' . $user_obj->getProvince() . ' ' . $user_obj->getPostalCode(), $border, 0, 'L');
                             //Cheque Stub
                             $stub_2_offset = 95;
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(110, $adjust_y));
                             $pdf->Cell(75, 5, $user_obj->getFullName(), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(110 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(75, 5, $user_obj->getFullName(), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(115, $adjust_y));
                             $pdf->Cell(75, 5, TTi18n::gettext('Identification #:') . ' ' . $pay_stub['display_id'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(115 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(75, 5, TTi18n::gettext('Identification #:') . ' ' . $pay_stub['display_id'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(110, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay Start Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['start_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(110 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay Start Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['start_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(115, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay End Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['end_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(115 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay End Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['end_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(120, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Payment Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['transaction_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(120 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Payment Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['transaction_date']), $border, 0, 'L');
                             //Earnings
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(120, $adjust_y));
                             $pdf->Cell(40, 5, TTi18n::gettext('Net Pay: ') . $pay_stub_obj->getCurrencyObject()->getSymbol() . $pay_stub['entries'][40][0]['amount'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(120 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(40, 5, TTi18n::gettext('Net Pay: ') . $pay_stub_obj->getCurrencyObject()->getSymbol() . $pay_stub['entries'][40][0]['amount'], $border, 0, 'L');
                             break;
                         case 'cheque_9209p':
                             $adjust_x = 0;
                             $adjust_y = -5;
                             if ($show_background == 1) {
                                 $pdf->Image(Environment::getBasePath() . 'interface/images/nebs_cheque_9209P.jpg', 0, 0, 210, 300);
                             }
                             $pdf->setXY(Misc::AdjustXY(25, $adjust_x), Misc::AdjustXY(42, $adjust_y));
                             $pdf->Cell(100, 10, $pay_stub['entries'][40][0]['amount_words'], $border, 0, 'L');
                             $pdf->Cell(15, 10, $pay_stub['entries'][40][0]['amount_cents'] . '/100', $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(172, $adjust_x), Misc::AdjustXY(25, $adjust_y));
                             $pdf->Cell(10, 10, TTi18n::gettext('Date:') . ' ', $border, 0, 'C');
                             $pdf->setXY(Misc::AdjustXY(182, $adjust_x), Misc::AdjustXY(25, $adjust_y));
                             $pdf->Cell(25, 10, $pay_stub['transaction_date_display'], $border, 0, 'C');
                             $pdf->setXY(Misc::AdjustXY(172, $adjust_x), Misc::AdjustXY(42, $adjust_y));
                             $pdf->Cell(35, 10, $pay_stub['entries'][40][0]['amount_padded'], $border, 0, 'C');
                             $pdf->setXY(Misc::AdjustXY(25, $adjust_x), Misc::AdjustXY(57, $adjust_y));
                             $pdf->Cell(100, 5, $user_obj->getFullName(), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(25, $adjust_x), Misc::AdjustXY(62, $adjust_y));
                             $pdf->Cell(100, 5, $user_obj->getAddress1() . ' ' . $user_obj->getAddress2(), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(25, $adjust_x), Misc::AdjustXY(67, $adjust_y));
                             $pdf->Cell(100, 5, $user_obj->getCity() . ', ' . $user_obj->getProvince() . ' ' . $user_obj->getPostalCode(), $border, 0, 'L');
                             //Cheque Stub
                             $stub_2_offset = 100;
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(110, $adjust_y));
                             $pdf->Cell(75, 5, $user_obj->getFullName(), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(110 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(75, 5, $user_obj->getFullName(), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(115, $adjust_y));
                             $pdf->Cell(75, 5, TTi18n::gettext('Identification #:') . ' ' . $pay_stub['display_id'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(115 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(75, 5, TTi18n::gettext('Identification #:') . ' ' . $pay_stub['display_id'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(110, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay Start Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['start_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(110 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay Start Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['start_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(115, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay End Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['end_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(115 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay End Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['end_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(120, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Payment Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['transaction_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(120 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Payment Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['transaction_date']), $border, 0, 'L');
                             //Earnings
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(120, $adjust_y));
                             $pdf->Cell(40, 5, TTi18n::gettext('Net Pay: ') . $pay_stub_obj->getCurrencyObject()->getSymbol() . $pay_stub['entries'][40][0]['amount'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(120 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(40, 5, TTi18n::gettext('Net Pay: ') . $pay_stub_obj->getCurrencyObject()->getSymbol() . $pay_stub['entries'][40][0]['amount'], $border, 0, 'L');
                             break;
                         case 'cheque_dlt103':
                             $adjust_x = 0;
                             $adjust_y = -5;
                             if ($show_background == 1) {
                                 $pdf->Image(Environment::getBasePath() . 'interface/images/nebs_cheque_dlt103.jpg', 0, 0, 210, 300);
                             }
                             $pdf->setXY(Misc::AdjustXY(25, $adjust_x), Misc::AdjustXY(54, $adjust_y));
                             $pdf->Cell(100, 10, $pay_stub['entries'][40][0]['amount_words'], $border, 0, 'L');
                             $pdf->Cell(15, 10, $pay_stub['entries'][40][0]['amount_cents'] . '/100', $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(172, $adjust_x), Misc::AdjustXY(33, $adjust_y));
                             $pdf->Cell(10, 10, TTi18n::gettext('Date:') . ' ', $border, 0, 'C');
                             $pdf->setXY(Misc::AdjustXY(182, $adjust_x), Misc::AdjustXY(33, $adjust_y));
                             $pdf->Cell(25, 10, $pay_stub['transaction_date_display'], $border, 0, 'C');
                             $pdf->setXY(Misc::AdjustXY(172, $adjust_x), Misc::AdjustXY(46, $adjust_y));
                             $pdf->Cell(35, 10, $pay_stub['entries'][40][0]['amount_padded'], $border, 0, 'C');
                             $pdf->setXY(Misc::AdjustXY(25, $adjust_x), Misc::AdjustXY(46, $adjust_y));
                             $pdf->Cell(100, 5, $user_obj->getFullName(), $border, 0, 'L');
                             //Cheque Stub
                             $stub_2_offset = 100;
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(110, $adjust_y));
                             $pdf->Cell(75, 5, $user_obj->getFullName(), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(110 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(75, 5, $user_obj->getFullName(), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(115, $adjust_y));
                             $pdf->Cell(75, 5, TTi18n::gettext('Identification #:') . ' ' . $pay_stub['display_id'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(115 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(75, 5, TTi18n::gettext('Identification #:') . ' ' . $pay_stub['display_id'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(110, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay Start Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['start_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(110 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay Start Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['start_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(115, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay End Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['end_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(115 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay End Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['end_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(120, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Payment Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['transaction_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(120 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Payment Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['transaction_date']), $border, 0, 'L');
                             //Earnings
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(120, $adjust_y));
                             $pdf->Cell(40, 5, TTi18n::gettext('Net Pay: ') . $pay_stub_obj->getCurrencyObject()->getSymbol() . $pay_stub['entries'][40][0]['amount'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(120 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(40, 5, TTi18n::gettext('Net Pay: ') . $pay_stub_obj->getCurrencyObject()->getSymbol() . $pay_stub['entries'][40][0]['amount'], $border, 0, 'L');
                             break;
                         case 'cheque_dlt104':
                             $adjust_x = 0;
                             $adjust_y = -5;
                             if ($show_background == 1) {
                                 $pdf->Image(Environment::getBasePath() . 'interface/images/nebs_cheque_dlt104.jpg', 0, 0, 210, 300);
                             }
                             $pdf->setXY(Misc::AdjustXY(25, $adjust_x), Misc::AdjustXY(52, $adjust_y));
                             $pdf->Cell(100, 10, $pay_stub['entries'][40][0]['amount_words'], $border, 0, 'L');
                             $pdf->Cell(15, 10, $pay_stub['entries'][40][0]['amount_cents'] . '/100', $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(172, $adjust_x), Misc::AdjustXY(33, $adjust_y));
                             $pdf->Cell(10, 10, TTi18n::gettext('Date:') . ' ', $border, 0, 'C');
                             $pdf->setXY(Misc::AdjustXY(182, $adjust_x), Misc::AdjustXY(33, $adjust_y));
                             $pdf->Cell(25, 10, $pay_stub['transaction_date_display'], $border, 0, 'C');
                             $pdf->setXY(Misc::AdjustXY(172, $adjust_x), Misc::AdjustXY(43, $adjust_y));
                             $pdf->Cell(35, 10, $pay_stub['entries'][40][0]['amount_padded'], $border, 0, 'C');
                             $pdf->setXY(Misc::AdjustXY(25, $adjust_x), Misc::AdjustXY(48, $adjust_y));
                             $pdf->Cell(100, 5, $user_obj->getFullName(), $border, 0, 'L');
                             //Cheque Stub
                             $stub_2_offset = 100;
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(110, $adjust_y));
                             $pdf->Cell(75, 5, $user_obj->getFullName(), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(110 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(75, 5, $user_obj->getFullName(), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(115, $adjust_y));
                             $pdf->Cell(75, 5, TTi18n::gettext('Identification #:') . ' ' . $pay_stub['display_id'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(115 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(75, 5, TTi18n::gettext('Identification #:') . ' ' . $pay_stub['display_id'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(110, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay Start Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['start_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(110 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay Start Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['start_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(115, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay End Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['end_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(115 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay End Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['end_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(120, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Payment Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['transaction_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(120 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Payment Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['transaction_date']), $border, 0, 'L');
                             //Earnings
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(120, $adjust_y));
                             $pdf->Cell(40, 5, TTi18n::gettext('Net Pay: ') . $pay_stub_obj->getCurrencyObject()->getSymbol() . $pay_stub['entries'][40][0]['amount'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(120 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(40, 5, TTi18n::gettext('Net Pay: ') . $pay_stub_obj->getCurrencyObject()->getSymbol() . $pay_stub['entries'][40][0]['amount'], $border, 0, 'L');
                             break;
                         case 'cheque_cr_standard_form_1':
                             $adjust_x = 0;
                             $adjust_y = -5;
                             if ($show_background == 1) {
                                 $pdf->Image(Environment::getBasePath() . 'interface/images/nebs_cheque_9085.jpg', 0, 0, 210, 300);
                             }
                             $pdf->setXY(Misc::AdjustXY(20, $adjust_x), Misc::AdjustXY(41, $adjust_y));
                             $pdf->Cell(100, 5, $pay_stub['entries'][40][0]['amount_words'] . TTi18n::gettext(' and ') . $pay_stub['entries'][40][0]['amount_cents'] . '/100 *****', $border, 0, 'J');
                             $pdf->setXY(Misc::AdjustXY(100, $adjust_x), Misc::AdjustXY(23, $adjust_y));
                             $pdf->Cell(38, 5, $pay_stub['transaction_date_display'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(136, $adjust_x), Misc::AdjustXY(32, $adjust_y));
                             $pdf->Cell(24, 5, '  $' . $pay_stub['entries'][40][0]['amount_padded'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(20, $adjust_x), Misc::AdjustXY(33, $adjust_y));
                             $pdf->Cell(100, 5, $user_obj->getFullName(), $border, 0, 'L');
                             //Cheque Stub
                             $stub_2_offset = 95;
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(110, $adjust_y));
                             $pdf->Cell(75, 5, $user_obj->getFullName(), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(110 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(75, 5, $user_obj->getFullName(), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(115, $adjust_y));
                             $pdf->Cell(75, 5, TTi18n::gettext('Identification #:') . ' ' . $pay_stub['display_id'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(115 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(75, 5, TTi18n::gettext('Identification #:') . ' ' . $pay_stub['display_id'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(110, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay Start Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['start_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(110 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay Start Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['start_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(115, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay End Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['end_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(115 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Pay End Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['end_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(120, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Payment Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['transaction_date']), $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(160, $adjust_x), Misc::AdjustXY(120 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(50, 5, TTi18n::gettext('Payment Date:') . ' ' . TTDate::getDate('DATE', $pay_stub['transaction_date']), $border, 0, 'L');
                             //Earnings
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(120, $adjust_y));
                             $pdf->Cell(40, 5, TTi18n::gettext('Net Pay: $') . $pay_stub['entries'][40][0]['amount'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(15, $adjust_x), Misc::AdjustXY(120 + $stub_2_offset, $adjust_y));
                             $pdf->Cell(40, 5, TTi18n::gettext('Net Pay: $') . $pay_stub['entries'][40][0]['amount'], $border, 0, 'L');
                             //Signature lines
                             $pdf->setXY(Misc::AdjustXY(7, $adjust_x), Misc::AdjustXY(250, $adjust_y));
                             $border = 0;
                             $pdf->Cell(40, 5, TTi18n::gettext('Employee Signature:'), $border, 0, 'L');
                             $pdf->Cell(60, 5, '_____________________________', $border, 0, 'L');
                             $pdf->Cell(40, 5, TTi18n::gettext('Supervisor Signature:'), $border, 0, 'R');
                             $pdf->Cell(60, 5, '_____________________________', $border, 0, 'L');
                             $pdf->Ln();
                             $pdf->Cell(40, 5, '', $border, 0, 'R');
                             $pdf->Cell(60, 5, $user_obj->getFullName(), $border, 0, 'C');
                             $pdf->Ln();
                             $pdf->Cell(147, 5, '', $border, 0, 'R');
                             $pdf->Cell(60, 5, '_____________________________', $border, 0, 'C');
                             $pdf->Ln();
                             $pdf->Cell(140, 5, '', $border, 0, 'R');
                             $pdf->Cell(60, 5, TTi18n::gettext('(print name)'), $border, 0, 'C');
                             break;
                         case 'cheque_cr_standard_form_2':
                             $pdf_created_date = time();
                             $adjust_x = 0;
                             $adjust_y = -5;
                             if ($show_background == 1) {
                                 $pdf->Image(Environment::getBasePath() . 'interface/images/nebs_cheque_9085.jpg', 0, 0, 210, 300);
                             }
                             $pdf->setXY(Misc::AdjustXY(20, $adjust_x), Misc::AdjustXY(41, $adjust_y));
                             $pdf->Cell(100, 5, $pay_stub['entries'][40][0]['amount_words'] . TTi18n::gettext(' and ') . $pay_stub['entries'][40][0]['amount_cents'] . '/100 *****', $border, 0, 'J');
                             $pdf->setXY(Misc::AdjustXY(100, $adjust_x), Misc::AdjustXY(23, $adjust_y));
                             $pdf->Cell(38, 5, $pay_stub['transaction_date_display'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(136, $adjust_x), Misc::AdjustXY(32, $adjust_y));
                             $pdf->Cell(24, 5, '$  ' . $pay_stub['entries'][40][0]['amount_padded'], $border, 0, 'L');
                             $pdf->setXY(Misc::AdjustXY(20, $adjust_x), Misc::AdjustXY(33, $adjust_y));
                             $pdf->Cell(100, 5, $user_obj->getFullName(), $border, 0, 'L');
                             //Cheque Stub
                             $stub_2_offset = 110;
                             $pdf->SetFont('', 'U', 14);
                             $pdf->setXY(Misc::AdjustXY(65, $adjust_x), Misc::AdjustXY(100, $adjust_y));
                             $pdf->Cell(75, 5, TTi18n::gettext('Recipient Copy:'), $border, 0, 'C');
                             $pdf->SetFont('', '', 10);
                             $pdf->setXY(Misc::AdjustXY(75, $adjust_x), Misc::AdjustXY(110, $adjust_y));
                             $pdf->SetFont('', 'B', 10);
                             $pdf->Cell(30, 5, TTi18n::gettext('Date of Issue:'), $border, 0, 'J');
                             $pdf->SetFont('', '', 10);
                             $pdf->Cell(130, 5, TTDate::getDate('DATE+TIME', $pdf_created_date), $border, 0, 'J');
                             $pdf->setXY(Misc::AdjustXY(75, $adjust_x), Misc::AdjustXY(110 + $stub_2_offset, $adjust_y));
                             $pdf->SetFont('', 'B', 10);
                             $pdf->Cell(30, 5, TTi18n::gettext('Date of Issue:'), $border, 0, 'J');
                             $pdf->SetFont('', '', 10);
                             $pdf->Cell(130, 5, TTDate::getDate('DATE+TIME', $pdf_created_date), $border, 0, 'J');
                             $pdf->setXY(Misc::AdjustXY(75, $adjust_x), Misc::AdjustXY(120, $adjust_y));
                             $pdf->SetFont('', 'B', 10);
                             $pdf->Cell(30, 5, TTi18n::gettext('Recipient:'), $border, 0, 'J');
                             $pdf->SetFont('', '', 10);
                             $pdf->Cell(110, 5, $user_obj->getFullName(), $border, 0, 'J');
                             $pdf->setXY(Misc::AdjustXY(75, $adjust_x), Misc::AdjustXY(120 + $stub_2_offset, $adjust_y));
                             $pdf->SetFont('', 'B', 10);
                             $pdf->Cell(30, 5, TTi18n::gettext('Recipient:'), $border, 0, 'J');
                             $pdf->SetFont('', '', 10);
                             $pdf->Cell(130, 5, $user_obj->getFullName(), $border, 0, 'J');
                             //Earnings
                             $pdf->setXY(Misc::AdjustXY(75, $adjust_x), Misc::AdjustXY(130, $adjust_y));
                             $pdf->SetFont('', 'B', 10);
                             $pdf->Cell(30, 5, TTi18n::gettext('Amount:'), $border, 0, 'J');
                             $pdf->SetFont('', '', 10);
                             $pdf->Cell(100, 5, ' $' . $pay_stub['entries'][40][0]['amount'], $border, 0, 'J');
                             $pdf->setXY(Misc::AdjustXY(75, $adjust_x), Misc::AdjustXY(130 + $stub_2_offset, $adjust_y));
                             $pdf->SetFont('', 'B', 10);
                             $pdf->Cell(30, 5, TTi18n::gettext('Amount:'), $border, 0, 'J');
                             $pdf->SetFont('', '', 10);
                             $pdf->Cell(100, 5, ' $' . $pay_stub['entries'][40][0]['amount'], $border, 0, 'J');
                             $pdf->setXY(Misc::AdjustXY(75, $adjust_x), Misc::AdjustXY(140, $adjust_y));
                             $pdf->SetFont('', 'B', 10);
                             $pdf->Cell(30, 5, TTi18n::gettext('Regarding:'), $border, 0, 'J');
                             $pdf->SetFont('', '', 10);
                             $pdf->Cell(100, 5, TTi18n::gettext('Payment from') . ' ' . TTDate::getDate('DATE', $pay_stub['start_date']) . ' ' . TTi18n::gettext('to') . ' ' . TTDate::getDate('DATE', $pay_stub['end_date']), $border, 0, 'J');
                             $pdf->setXY(Misc::AdjustXY(75, $adjust_x), Misc::AdjustXY(140 + $stub_2_offset, $adjust_y));
                             $pdf->SetFont('', 'B', 10);
                             $pdf->Cell(30, 5, TTi18n::gettext('Regarding:'), $border, 0, 'J');
                             $pdf->SetFont('', '', 10);
                             $pdf->Cell(100, 5, TTi18n::gettext('Payment from') . ' ' . TTDate::getDate('DATE', $pay_stub['start_date']) . ' ' . TTi18n::gettext('to') . ' ' . TTDate::getDate('DATE', $pay_stub['end_date']), $border, 0, 'J');
                             $pdf->SetFont('', 'U', 14);
                             $pdf->setXY(Misc::AdjustXY(65, $adjust_x), Misc::AdjustXY(210, $adjust_y));
                             $pdf->Cell(75, 5, $company_obj->getName() . ' ' . TTi18n::gettext('Copy:'), $border, 0, 'C');
                             $pdf->setXY(Misc::AdjustXY(30, $adjust_x), Misc::AdjustXY(260, $adjust_y));
                             $column_widths = array('generated_by' => 25, 'signed_by' => 25, 'received_by' => 35, 'date' => 35, 'sin_ssn' => 35);
                             $line_h = 4;
                             $cell_h_min = $cell_h_max = $line_h * 4;
                             $pdf->SetFont('', '', 8);
                             $pdf->setFillColor(255, 255, 255);
                             $pdf->MultiCell($column_widths['generated_by'], $line_h, TTi18n::gettext('Generated By') . "\n\n\n ", 1, 'C', 1, 0);
                             $pdf->MultiCell($column_widths['signed_by'], $line_h, TTi18n::gettext('Signed By') . "\n\n\n ", 1, 'C', 1, 0);
                             $pdf->MultiCell($column_widths['received_by'], $line_h, TTi18n::gettext('Received By') . "\n\n\n ", 'T,L,B', 'C', 1, 0);
                             $pdf->MultiCell($column_widths['date'], $line_h, TTi18n::gettext('Date') . "\n\n\n ", 'T,B', 'C', 1, 0);
                             $pdf->MultiCell($column_widths['sin_ssn'], $line_h, TTi18n::gettext('SIN / SSN') . "\n\n\n ", 'T,R,B', 'C', 1, 0);
                             $pdf->Ln();
                             $pdf->SetFont('', '', 10);
                             break;
                     }
                     $i++;
                 }
                 $output = $pdf->Output('', 'S');
                 break;
         }
     }
     if (isset($output)) {
         return $output;
     }
     return FALSE;
 }
 static function reportFormDataHandler($action, $filter_data, $generic_data, $redirect_url)
 {
     global $current_company, $current_user;
     if ($action == '') {
         return FALSE;
     }
     if (!is_array($generic_data)) {
         return FALSE;
     }
     $saved_report_id = FALSE;
     $ugdlf = new UserGenericDataListFactory();
     $ugdf = new UserGenericDataFactory();
     if ($action == 'save' or $action == 'update') {
         Debug::Text('Save Report!', __FILE__, __LINE__, __METHOD__, 10);
         if (isset($generic_data['id']) and $generic_data['id'] != '' and $generic_data['id'] != 0) {
             $ugdlf->getByUserIdAndId($current_user->getId(), $generic_data['id']);
             if ($ugdlf->getRecordCount() > 0) {
                 $ugdf = $ugdlf->getCurrent();
             }
             $ugdf->setID($generic_data['id']);
         }
         $ugdf->setCompany($current_company->getId());
         $ugdf->setUser($current_user->getId());
         $ugdf->setScript(self::handleScriptName($_SERVER['SCRIPT_NAME']));
         if (isset($generic_data['name']) and $generic_data['name'] != '') {
             $ugdf->setName($generic_data['name']);
         }
         $ugdf->setData($filter_data);
         if (isset($generic_data['is_default'])) {
             $ugdf->setDefault(TRUE);
         }
     } elseif ($action == 'delete' and isset($generic_data['id']) and $generic_data['id'] != '') {
         $ugdlf->getByUserIdAndId($current_user->getId(), $generic_data['id']);
         if ($ugdlf->getRecordCount() > 0) {
             $ugd_obj = $ugdlf->getCurrent();
             $ugd_obj->setDeleted(TRUE);
             $ugd_obj->Save();
         }
         Redirect::Page($redirect_url);
         return TRUE;
     }
     if (is_object($ugdf) and $ugdf->isValid()) {
         $ugf_id = $ugdf->Save();
         if (is_numeric($ugf_id)) {
             $saved_report_id = $ugf_id;
         } elseif ($ugf_id === TRUE) {
             $saved_report_id = $generic_data['id'];
         }
         unset($ugf_id);
     }
     return $saved_report_id;
 }