Beispiel #1
0
 private function _sendPayment($marker, $marks, $assessmentAssoc, $assessmentFix = 0)
 {
     if (count($marks) === 0 && empty($assessmentAssoc)) {
         return false;
     }
     foreach ($marks as $markAssoc) {
         $mark = new Mark();
         $mark->setKey($markAssoc[$mark->getKeyField()]);
         $mark->paid();
         $mark->update();
         $markKeys[] = $markAssoc[$mark->getKeyField()];
     }
     $assessmentAmount = 0;
     if (!empty($assessmentAssoc)) {
         $assessment = new Assessment();
         $assessment->setKey($assessmentAssoc[$assessment->getKeyField()]);
         $assessment->paid();
         $assessment->update();
         $markKeys[] = 'Assessment script';
         $assessmentAmount = 1;
     }
     if ($assessmentFix) {
         $assessmentFix = new AssessmentFix();
         $assessmentFix->setKey($this->_getUser());
         $assessmentFix->paid();
         $assessmentFix->update();
         $markKeys[] = 'Assessment bounty';
     }
     $this->load->model('wage');
     $amount = ($assessmentFix + count($marks) + $assessmentAmount) * 1.5;
     $wage = new Wage();
     $wage->paid($marker, $amount, $markKeys);
     $wage->create();
     return $amount;
 }
             }
             $tmp_rows = Misc::ArrayGroupBy($tmp_rows, array(Misc::trimSortPrefix($filter_data['primary_group_by']), Misc::trimSortPrefix($filter_data['secondary_group_by'])), Misc::trimSortPrefix($ignore_elements));
         }
         if (isset($tmp_rows)) {
             foreach ($tmp_rows as $row) {
                 $rows[] = $row;
             }
             if ($filter_data['primary_sort'] == 'hire_date') {
                 $filter_data['primary_sort'] = 'hire_date_order';
             }
             //$rows = Sort::Multisort($rows, $filter_data['primary_sort'], NULL, 'ASC');
             $rows = Sort::Multisort($rows, Misc::trimSortPrefix($filter_data['primary_sort']), Misc::trimSortPrefix($filter_data['secondary_sort']), $filter_data['primary_sort_dir'], $filter_data['secondary_sort_dir']);
             $total_row = Misc::ArrayAssocSum($rows, NULL, 2);
             //Get values to go directly on the PD7AE (05) form.
             if (isset($total_row)) {
                 $form_data = array('cpp' => Misc::MoneyFormat($total_row['cpp_total']), 'ei' => Misc::MoneyFormat($total_row['ei_total']), 'tax' => Misc::MoneyFormat($total_row['tax_total']), 'amount_due' => Misc::MoneyFormat($total_row['total']), 'gross_payroll' => Misc::MoneyFormat($total_row[$pseal_obj->getTotalGross()]), 'employees' => $total_employees, 'due_date' => Wage::getRemittanceDueDate($transaction_date, $total_row['total']), 'end_remitting_period' => date('Y-m', $transaction_date));
             }
             //var_dump($form_data);
             $last_row = count($rows);
             $rows[$last_row] = $total_row;
             foreach ($static_columns as $static_column_key => $static_column_val) {
                 $rows[$last_row][Misc::trimSortPrefix($static_column_key)] = NULL;
             }
             unset($static_column_key, $static_column_val);
         }
     }
 }
 foreach ($filter_data['column_ids'] as $column_key) {
     //$filter_columns[$column_key] = $report_columns[$column_key];
     $filter_columns[Misc::trimSortPrefix($column_key)] = $columns[$column_key];
 }
 function _pdf_Header()
 {
     if ($this->pdf->getPage() == 1) {
         //Draw separate table at the top showing the summarized data specifically for the form.
         $column_options = array('cpp_total' => TTi18n::getText('CPP Contributions'), 'ei_total' => TTi18n::getText('EI Premiums'), 'tax_total' => TTi18n::getText('Tax Deductions'), 'total' => TTi18n::getText('This Payment'), 'gross_payroll' => TTi18n::getText('Gross Payroll'), 'employees' => TTi18n::getText('Total Employees'), 'end_remitting_period' => TTi18n::getText('End of Period'), 'due_date' => TTi18n::getText('Due Date'));
         $columns = array('cpp_total' => TRUE, 'ei_total' => TRUE, 'tax_total' => TRUE, 'total' => TRUE, 'gross_payroll' => TRUE, 'employees' => TRUE, 'end_remitting_period' => TRUE, 'due_date' => TRUE);
         $header_layout = $this->config['other']['layout']['header'];
         $margins = $this->pdf->getMargins();
         //Draw report information
         if ($this->pdf->getPage() > 1) {
             $this->_pdf_drawLine(0.75);
             //Slightly smaller than first/last lines.
         }
         if (is_array($columns) and count($columns) > 0) {
             $this->pdf->SetFont($this->config['other']['default_font'], 'B', $this->_pdf_fontSize($this->config['other']['table_header_font_size']));
             $this->pdf->setTextColor(0);
             $this->pdf->setDrawColor(0);
             $this->pdf->setFillColor(240);
             //Grayscale only.
             $column_widths = $this->_pdf_getTableColumnWidths($this->getLargestColumnData(array_intersect_key($column_options, (array) $columns)), $this->config['other']['layout']['header']);
             //Table largest column data;
             $cell_height = $this->_pdf_getMaximumHeightFromArray($columns, $column_options, $column_widths, $this->config['other']['table_header_word_wrap'], $this->_pdf_fontSize($header_layout['height']));
             foreach ($columns as $column => $tmp) {
                 if (isset($column_options[$column]) and isset($column_widths[$column])) {
                     $cell_width = $column_widths[$column];
                     if ($this->pdf->getX() + $cell_width > $this->pdf->getPageWidth()) {
                         Debug::Text(' Page not wide enough, it should be at least: ' . ($this->pdf->getX() + $cell_width) . ' Page Width: ' . $this->pdf->getPageWidth(), __FILE__, __LINE__, __METHOD__, 10);
                         $this->pdf->Ln();
                     }
                     $this->pdf->Cell($cell_width, $this->_pdf_fontSize($header_layout['height']), $column_options[$column], $header_layout['border'], 0, $header_layout['align'], $header_layout['fill'], '', $header_layout['stretch']);
                     //Wrapping shouldn't be needed as the cell widths should expand to at least fit the header. Wrapping may be needed on regular rows though.
                     //$this->pdf->MultiCell( $cell_width, $cell_height, $column_options[$column], 0, $header_layout['align'], $header_layout['fill'], 0 );
                 } else {
                     Debug::Text(' Invalid Column: ' . $column, __FILE__, __LINE__, __METHOD__, 10);
                 }
             }
             $this->pdf->Ln();
             $this->_pdf_drawLine(0.75);
             //Slightly smaller than first/last lines.
             //Reset all styles/fills after page break.
             $this->pdf->SetFont($this->config['other']['default_font'], '', $this->_pdf_fontSize($this->config['other']['table_row_font_size']));
             $this->pdf->SetTextColor(0);
             $this->pdf->SetDrawColor(0);
             $this->pdf->setFillColor(255);
             //Draw data
             $border = 0;
             $row_layout = array('max_width' => 30, 'cell_padding' => 2, 'height' => 5, 'align' => 'R', 'border' => 0, 'fill' => 1, 'stretch' => 1);
             //Get the earliest transaction date of all pay periods.
             $this->form_data['pay_period'] = array_unique((array) $this->form_data['pay_period']);
             ksort($this->form_data['pay_period']);
             $transaction_date = current((array) $this->form_data['pay_period']);
             Debug::Text('Transaction Date: ' . TTDate::getDate('DATE', $transaction_date) . '(' . $transaction_date . ')', __FILE__, __LINE__, __METHOD__, 10);
             $summary_table_data = $this->total_row;
             $summary_table_data['cpp_total'] = TTi18n::formatCurrency(isset($summary_table_data['cpp_total']) ? $summary_table_data['cpp_total'] : 0);
             $summary_table_data['ei_total'] = TTi18n::formatCurrency(isset($summary_table_data['ei_total']) ? $summary_table_data['ei_total'] : 0);
             $summary_table_data['tax_total'] = TTi18n::formatCurrency(isset($summary_table_data['tax_total']) ? $summary_table_data['tax_total'] : 0);
             $summary_table_data['total'] = TTi18n::formatCurrency(isset($summary_table_data['total']) ? $summary_table_data['total'] : 0);
             $summary_table_data['gross_payroll'] = TTi18n::formatCurrency(isset($summary_table_data['gross_payroll']) ? $summary_table_data['gross_payroll'] : 0);
             $summary_table_data['employees'] = count($this->user_ids);
             $remittance_due_date = Wage::getRemittanceDueDate($transaction_date, isset($summary_table_data['total']) ? $summary_table_data['total'] : 0);
             $summary_table_data['due_date'] = $remittance_due_date > 0 ? TTDate::getDate('DATE', $remittance_due_date) : TTi18n::getText("N/A");
             $summary_table_data['end_remitting_period'] = $transaction_date > 0 ? date('Y-m', $transaction_date) : TTi18n::getText("N/A");
             foreach ($columns as $column => $tmp) {
                 $value = $summary_table_data[$column];
                 $cell_width = isset($column_widths[$column]) ? $column_widths[$column] : 30;
                 $this->pdf->Cell($cell_width, $this->_pdf_fontSize($row_layout['height']), $value, $border, 0, $row_layout['align'], $row_layout['fill'], '', $row_layout['stretch']);
             }
             $this->pdf->Ln();
             $this->_pdf_drawLine(0.75);
             //Slightly smaller than first/last lines.
             $this->pdf->Ln();
             $this->_pdf_drawLine(0.75);
             //Slightly smaller than first/last lines.
         }
     }
     parent::_pdf_Header();
     return TRUE;
 }