function setMonthlyAdvanceDeduction($id)
 {
     $id = trim($id);
     Debug::Text('ID: ' . $id, __FILE__, __LINE__, __METHOD__, 10);
     $psealf = new PayStubEntryAccountListFactory();
     if ($id == '' or $id == 0 or $this->Validator->isResultSetWithRows('monthly_advance_deduction', $psealf->getByID($id), TTi18n::gettext('Pay Stub Account is invalid'))) {
         $this->data['monthly_advance_deduction'] = $id;
         return TRUE;
     }
     return FALSE;
 }
 function getByTypeArrayByCompanyIdAndStatusId($company_id, $status_id)
 {
     $psealf = new PayStubEntryAccountListFactory();
     $psealf->getByCompanyIdAndStatusId($company_id, $status_id);
     $pseallf = new PayStubEntryAccountLinkListFactory();
     $pseallf->getByCompanyId($company_id);
     if ($pseallf->getRecordCount() == 0) {
         return FALSE;
     }
     $psea_type_map = $pseallf->getCurrent()->getPayStubEntryAccountIDToTypeIDMap();
     if ($psealf->getRecordCount() > 0) {
         foreach ($psealf as $psea_obj) {
             $entry_name_list[$psea_obj->getType()][] = $psea_obj->getId();
         }
         foreach ($entry_name_list[40] as $key => $entry_name_id) {
             if (isset($psea_type_map[$entry_name_id])) {
                 $tmp_entry_name_list[$entry_name_id] = $entry_name_list[$psea_type_map[$entry_name_id]];
             }
         }
         return $tmp_entry_name_list;
     }
     return FALSE;
 }
        if ($current_company->getCountry() == 'CA') {
            $psealf->setEmployeeCPP($data['employee_cpp']);
            $psealf->setEmployeeEI($data['employee_ei']);
        }
        if ($psealf->isValid()) {
            $psealf->Save();
            Redirect::Page(URLBuilder::getURL(array('data_saved' => TRUE), 'EditPayStubEntryAccountLink.php'));
            break;
        }
    default:
        BreadCrumb::setCrumb($title);
        $pseallf = new PayStubEntryAccountLinkListFactory();
        $pseallf->getByCompanyId($current_company->getId());
        if ($pseallf->getRecordCount() > 0) {
            $pseal_obj = $pseallf->getCurrent();
            $data = array('id' => $pseal_obj->getId(), 'total_gross' => $pseal_obj->getTotalGross(), 'total_employee_deduction' => $pseal_obj->getTotalEmployeeDeduction(), 'total_employer_deduction' => $pseal_obj->getTotalEmployerDeduction(), 'total_net_pay' => $pseal_obj->getTotalNetPay(), 'regular_time' => $pseal_obj->getRegularTime(), 'monthly_advance' => $pseal_obj->getMonthlyAdvance(), 'monthly_advance_deduction' => $pseal_obj->getMonthlyAdvanceDeduction(), 'employee_cpp' => $pseal_obj->getEmployeeCPP(), 'employee_ei' => $pseal_obj->getEmployeeEI(), 'created_date' => $pseal_obj->getCreatedDate(), 'created_by' => $pseal_obj->getCreatedBy(), 'updated_date' => $pseal_obj->getUpdatedDate(), 'updated_by' => $pseal_obj->getUpdatedBy(), 'deleted_date' => $pseal_obj->getDeletedDate(), 'deleted_by' => $pseal_obj->getDeletedBy());
        }
        $psealf_tmp = new PayStubEntryAccountListFactory();
        $data['earning_account_options'] = $psealf_tmp->getByCompanyIdAndStatusIdAndTypeIdArray($current_company->getId(), 10, array(10));
        $data['employee_deduction_account_options'] = $psealf_tmp->getByCompanyIdAndStatusIdAndTypeIdArray($current_company->getId(), 10, array(20));
        $data['employer_deduction_account_options'] = $psealf_tmp->getByCompanyIdAndStatusIdAndTypeIdArray($current_company->getId(), 10, array(30));
        $data['total_account_options'] = $psealf_tmp->getByCompanyIdAndStatusIdAndTypeIdArray($current_company->getId(), 10, array(40));
        $data['accrual_account_options'] = $psealf_tmp->getByCompanyIdAndStatusIdAndTypeIdArray($current_company->getId(), 10, array(50));
        $data['other_account_options'] = $psealf_tmp->getByCompanyIdAndStatusIdAndTypeIdArray($current_company->getId(), 10, array(60, 65));
        //var_dump($data);
        $smarty->assign_by_ref('data', $data);
        $smarty->assign_by_ref('data_saved', $data_saved);
        break;
}
$smarty->assign_by_ref('psealf', $psealf);
$smarty->display('pay_stub/EditPayStubEntryAccountLink.tpl');
Ejemplo n.º 4
0
switch ($action) {
    default:
        if (isset($id) and !isset($ids)) {
            $ids = array($id);
        }
        if (count($ids) > 0) {
            $pslf = new PayStubListFactory();
            if ($permission->Check('pay_stub', 'view')) {
                $pslf->getByCompanyIdAndId($current_company->getId(), $ids);
            } else {
                $pslf->getByUserIdAndId($current_user->getId(), $ids);
            }
            //foreach ($ids as $id) {
            $i = 0;
            foreach ($pslf as $pay_stub_obj) {
                $psealf = new PayStubEntryAccountListFactory();
                //Get pay stub entries.
                $pself = new PayStubEntryListFactory();
                $pself->getByPayStubId($pay_stub_obj->getId());
                Debug::text('Pay Stub Entries: ' . $pself->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
                $prev_type = NULL;
                $description_subscript_counter = 1;
                foreach ($pself as $pay_stub_entry) {
                    Debug::text('Pay Stub Entry Account ID: ' . $pay_stub_entry->getPayStubEntryNameId(), __FILE__, __LINE__, __METHOD__, 10);
                    $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();
                    }
 $filter_data['pay_period_ids'] = array();
 foreach ($tmp_filter_pay_period_ids as $key => $filter_pay_period_id) {
     $filter_data['pay_period_ids'][] = Misc::trimSortPrefix($filter_pay_period_id);
 }
 unset($key, $tmp_filter_pay_period_ids, $filter_pay_period_id);
 //if ( isset($filter_data['pay_period_ids']) AND isset($filter_data['user_ids']) ) {
 if (isset($filter_data['pay_period_ids'])) {
     //Get column headers
     $psealf->getByCompanyId($current_company->getId());
     foreach ($psealf as $psea_obj) {
         //$report_columns[$psen_obj->getId()] = $psen_obj->getDescription();
         $report_columns[$psea_obj->getId()] = $psea_obj->getName();
     }
     //var_dump($report_columns);
     $report_columns = Misc::prependArray($static_columns, $report_columns);
     $psealf = new PayStubEntryAccountListFactory();
     $psealf->getByCompanyId($current_company->getId());
     if ($psealf->getRecordCount() > 0) {
         foreach ($psealf as $psea_obj) {
             $psea_arr[$psea_obj->getId()] = array('name' => $psea_obj->getName(), 'debit_account' => $psea_obj->getDebitAccount(), 'credit_account' => $psea_obj->getCreditAccount());
         }
     }
     //var_dump($psea_arr);
     //Get all pay stubs.
     $pslf = new PayStubListFactory();
     //$pslf->getByUserIdAndCompanyIdAndPayPeriodId( $filter_data['user_ids'], $current_company->getId(), $filter_data['pay_period_ids'] );
     $pslf->getSearchByCompanyIdAndArrayCriteria($current_company->getId(), $filter_data);
     if ($pslf->getRecordCount() > 0) {
         $ulf = new UserListFactory();
         $blf = new BranchListFactory();
         $branch_options = $blf->getByCompanyIdArray($current_company->getId());
Ejemplo n.º 6
0
         $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);
         if (!isset($filter_data['column_ids'])) {
             $filter_data['column_ids'] = array();
         }
         $filter_data['column_ids'] = array_merge($filter_data['column_ids'], array('-1000-full_name', '-1060-total', '-1070-ei_total', '-1080-cpp_total', '-1090-tax_total', '-1100-gross_payroll'));
         $filter_data['primary_sort'] = '-1000-full_name';
         $filter_data['secondary_sort'] = '-1060-total';
     }
 }
 $filter_data = Misc::preSetArrayValues($filter_data, array('include_user_ids', 'exclude_user_ids', 'user_status_ids', 'group_ids', 'branch_ids', 'department_ids', 'user_title_ids', 'pay_period_ids', 'column_ids'), NULL);
 //Deduction PSEA accounts
 $psealf = new PayStubEntryAccountListFactory();
 $filter_data['deduction_pay_stub_entry_account_options'] = $psealf->getByCompanyIdAndStatusIdAndTypeIdArray($current_company->getId(), 10, array(20, 30), FALSE);
 $ulf = new UserListFactory();
 $all_array_option = array('-1' => TTi18n::gettext('-- All --'));
 //Get include employee list.
 $ulf->getByCompanyId($current_company->getId());
 $user_options = $ulf->getArrayByListFactory($ulf, FALSE, TRUE);
 $filter_data['src_include_user_options'] = Misc::arrayDiffByKey((array) $filter_data['include_user_ids'], $user_options);
 $filter_data['selected_include_user_options'] = Misc::arrayIntersectByKey((array) $filter_data['include_user_ids'], $user_options);
 //Get exclude employee list
 $exclude_user_options = Misc::prependArray($all_array_option, $ulf->getArrayByListFactory($ulf, FALSE, TRUE));
 $filter_data['src_exclude_user_options'] = Misc::arrayDiffByKey((array) $filter_data['exclude_user_ids'], $user_options);
 $filter_data['selected_exclude_user_options'] = Misc::arrayIntersectByKey((array) $filter_data['exclude_user_ids'], $user_options);
 //Get employee status list.
 $user_status_options = Misc::prependArray($all_array_option, $ulf->getOptions('status'));
 $filter_data['src_user_status_options'] = Misc::arrayDiffByKey((array) $filter_data['user_status_ids'], $user_status_options);
 static function releaseAllAccruals($user_id, $effective_date = NULL)
 {
     Debug::Text('Release 100% of all accruals!', __FILE__, __LINE__, __METHOD__, 10);
     if ($user_id == '') {
         return FALSE;
     }
     if ($effective_date == '') {
         $effective_date = TTDate::getTime();
     }
     Debug::Text('Effective Date: ' . TTDate::getDate('DATE+TIME', $effective_date), __FILE__, __LINE__, __METHOD__, 10);
     $ulf = new UserListFactory();
     $ulf->getById($user_id);
     if ($ulf->getRecordCount() > 0) {
         $user_obj = $ulf->getCurrent();
     } else {
         return FALSE;
     }
     //Get all PSE acccount accruals
     $psealf = new PayStubEntryAccountListFactory();
     $psealf->getByCompanyIdAndStatusIdAndTypeId($user_obj->getCompany(), 10, 50);
     if ($psealf->getRecordCount() > 0) {
         $ulf->StartTransaction();
         foreach ($psealf as $psea_obj) {
             //Get PSE account that affects this accrual.
             $psealf_tmp = new PayStubEntryAccountListFactory();
             $psealf_tmp->getByCompanyIdAndAccrualId($user_obj->getCompany(), $psea_obj->getId());
             if ($psealf_tmp->getRecordCount() > 0) {
                 $release_account_id = $psealf_tmp->getCurrent()->getId();
                 $psaf = new PayStubAmendmentFactory();
                 $psaf->setStatus(50);
                 //Active
                 $psaf->setType(20);
                 //Percent
                 $psaf->setUser($user_obj->getId());
                 $psaf->setPayStubEntryNameId($release_account_id);
                 $psaf->setPercentAmount(100);
                 $psaf->setPercentAmountEntryNameId($psea_obj->getId());
                 $psaf->setEffectiveDate($effective_date);
                 $psaf->setDescription('Release Accrual Balance');
                 if ($psaf->isValid()) {
                     Debug::Text('Release Accrual Is Valid!!: ', __FILE__, __LINE__, __METHOD__, 10);
                     $psaf->Save();
                 }
             } else {
                 Debug::Text('No Release Account for this Accrual!!', __FILE__, __LINE__, __METHOD__, 10);
             }
         }
         //$ulf->FailTransaction();
         $ulf->CommitTransaction();
     } else {
         Debug::Text('No Accruals to release...', __FILE__, __LINE__, __METHOD__, 10);
     }
     return FALSE;
 }
 function setPayStubEntryNameId($id)
 {
     $id = trim($id);
     Debug::text('Entry Account ID: ' . $id, __FILE__, __LINE__, __METHOD__, 10);
     //$psenlf = new PayStubEntryNameListFactory();
     $psealf = new PayStubEntryAccountListFactory();
     $result = $psealf->getById($id);
     if ($this->Validator->isResultSetWithRows('pay_stub_entry_name_id', $result, TTi18n::gettext('Invalid Entry Account Id'))) {
         Debug::text('TRUE: ' . $id . ' matches result: ' . $result->getCurrent()->getId(), __FILE__, __LINE__, __METHOD__, 10);
         $this->data['pay_stub_entry_name_id'] = $result->getCurrent()->getId();
         return TRUE;
     }
     return FALSE;
 }
 function setPayStubEntryAccount($id)
 {
     $id = trim($id);
     Debug::Text('ID: ' . $id, __FILE__, __LINE__, __METHOD__, 10);
     $psealf = new PayStubEntryAccountListFactory();
     if ($this->Validator->isResultSetWithRows('pay_stub_entry_account', $psealf->getByID($id), TTi18n::gettext('Pay Stub Account is invalid'))) {
         $this->data['pay_stub_entry_account_id'] = $id;
         return TRUE;
     }
     return FALSE;
 }
 function getPayStubEntryAccountsTypeArray()
 {
     if (is_array($this->pay_stub_entry_accounts_type_obj)) {
         //Debug::text('Returning Cached data...' , __FILE__, __LINE__, __METHOD__,10);
         return $this->pay_stub_entry_accounts_type_obj;
     } else {
         $psealf = new PayStubEntryAccountListFactory();
         $this->pay_stub_entry_accounts_type_obj = $psealf->getByTypeArrayByCompanyIdAndStatusId($this->getUserObject()->getCompany(), 10);
         if (is_array($this->pay_stub_entry_accounts_type_obj)) {
             return $this->pay_stub_entry_accounts_type_obj;
         }
         Debug::text('Returning FALSE...', __FILE__, __LINE__, __METHOD__, 10);
         return FALSE;
     }
 }
 function Validate()
 {
     if ($this->getType() == 50) {
         //If the PSE account is an accrual, it can't link to one as well.
         $this->setAccrual(NULL);
     }
     //Make sure this account doesn't point to itself as an accrual.
     if ($this->isNew() == FALSE and $this->getAccrual() == $this->getId()) {
         $this->Validator->isTrue('accrual', FALSE, TTi18n::gettext('Accrual account is invalid'));
     }
     //Make sure PS order is correct, in that types can't be separated by total or accrual accounts.
     $pseallf = new PayStubEntryAccountLinkListFactory();
     $pseallf->getByCompanyId($this->getCompany());
     if ($pseallf->getRecordCount() > 0) {
         $pseal_obj = $pseallf->getCurrent();
         $psealf = new PayStubEntryAccountListFactory();
         $psealf->getByCompanyIdAndTypeId($this->getCompany(), 40);
         if ($psealf->getRecordCount() > 0) {
             foreach ($psealf as $psea_obj) {
                 $psea_map[$psea_obj->getId()] = $psea_obj->getOrder();
             }
             unset($psea_obj);
         }
         switch ($this->getType()) {
             case 10:
                 //Earning
                 //Greater the 0, less then Total Gross Account
                 if (isset($psea_map[$pseal_obj->getTotalGross()])) {
                     $min_ps_order = 0;
                     $max_ps_order = $psea_map[$pseal_obj->getTotalGross()];
                 }
                 break;
             case 20:
                 //EE Deduction
                 //Greater then Total Gross Account, less then Total Employee Deduction
                 if (isset($psea_map[$pseal_obj->getTotalGross()]) and isset($psea_map[$pseal_obj->getTotalEmployeeDeduction()])) {
                     $min_ps_order = $psea_map[$pseal_obj->getTotalGross()];
                     $max_ps_order = $psea_map[$pseal_obj->getTotalEmployeeDeduction()];
                 }
                 break;
             case 30:
                 //ER Deduction
                 //Greater then Net Pay Account, less then Total Employer Deduction
                 if (isset($psea_map[$pseal_obj->getTotalNetPay()]) and isset($psea_map[$pseal_obj->getTotalEmployerDeduction()])) {
                     $min_ps_order = $psea_map[$pseal_obj->getTotalNetPay()];
                     $max_ps_order = $psea_map[$pseal_obj->getTotalEmployerDeduction()];
                 }
                 break;
             case 50:
                 //Accrual
                 //Greater then Total Employer Deduction
                 if (isset($psea_map[$pseal_obj->getTotalEmployerDeduction()])) {
                     $min_ps_order = $psea_map[$pseal_obj->getTotalEmployerDeduction()];
                     $max_ps_order = 10001;
                 }
                 break;
         }
         if (isset($min_ps_order) and isset($max_ps_order) and ($this->getOrder() <= $min_ps_order or $this->getOrder() >= $max_ps_order)) {
             Debug::text('PS Order... Min: ' . $min_ps_order . ' Max: ' . $max_ps_order, __FILE__, __LINE__, __METHOD__, 10);
             $this->Validator->isTrue('ps_order', FALSE, TTi18n::gettext('Order is invalid for this type of account, it must be between') . ' ' . ($min_ps_order + 1) . ' ' . TTi18n::gettext('and') . ' ' . ($max_ps_order - 1));
         }
     }
     return TRUE;
 }
 }
 */
 $status_options = Option::getByArray($status_options_filter, $rpsaf->getOptions('status'));
 $pay_stub_amendment_data['status_options'] = $status_options;
 $frequency_options = $rpsaf->getOptions('frequency');
 $pay_stub_amendment_data['frequency_options'] = $frequency_options;
 $percent_amount_options = $rpsaf->getOptions('percent_amount');
 $pay_stub_amendment_data['percent_amount_options'] = $percent_amount_options;
 $pay_stub_amendment_data['type_options'] = $rpsaf->getOptions('type');
 $pseallf = new PayStubEntryAccountLinkListFactory();
 $pseallf->getByCompanyId($current_company->getId());
 if ($pseallf->getRecordCount() > 0) {
     $net_pay_psea_id = $pseal_obj = $pseallf->getCurrent()->getTotalNetPay();
 }
 //$psenlf = new PayStubEntryNameListFactory();
 $psealf = new PayStubEntryAccountListFactory();
 $pay_stub_amendment_data['pay_stub_entry_name_options'] = $psealf->getByCompanyIdAndStatusIdAndTypeIdArray($current_company->getId(), 10, array(10, 20, 30, 50, 60, 65));
 $pay_stub_amendment_data['percent_amount_entry_name_options'] = $psealf->getByCompanyIdAndStatusIdAndTypeIdArray($current_company->getId(), 10, array(10, 20, 30, 40, 50, 60, 65));
 if (isset($net_pay_psea_id)) {
     unset($pay_stub_amendment_data['percent_amount_entry_name_options'][$net_pay_psea_id]);
 }
 $smarty->assign_by_ref('pay_stub_amendment_data', $pay_stub_amendment_data);
 $user_options = UserListFactory::getByCompanyIdArray($current_company->getId(), FALSE);
 $user_options = Misc::prependArray(array(-1 => TTi18n::gettext('-- ALL --')), $user_options);
 $pay_stub_amendment_data['user_options'] = $user_options;
 if (isset($pay_stub_amendment_data['user_ids']) and is_array($pay_stub_amendment_data['user_ids'])) {
     $tmp_user_options = $user_options;
     foreach ($pay_stub_amendment_data['user_ids'] as $user_id) {
         if (isset($tmp_user_options[$user_id])) {
             $filter_user_options[$user_id] = $tmp_user_options[$user_id];
         }
Ejemplo n.º 13
0
 if (isset($mapped_row['user_id']) and $mapped_row['user_id'] != '') {
     $ulf->getById($mapped_row['user_id']);
 } elseif (isset($mapped_row['user_name']) and $mapped_row['user_name'] != '') {
     $ulf->getByUserName($mapped_row['user_name']);
 }
 if ($ulf->getRecordCount() == 1) {
     $u_obj = $ulf->getCurrent();
     $psaf->setUser($u_obj->getId());
     if (isset($mapped_row['status_id']) and $mapped_row['status_id'] != '') {
         $psaf->setStatus(Misc::importCallInputParseFunction('status_id', $mapped_row['status_id'], $filtered_import_map['status_id']['default_value'], $filtered_import_map['status_id']['parse_hint']));
     }
     if (isset($mapped_row['type_id']) and $mapped_row['type_id'] != '') {
         $psaf->setType(Misc::importCallInputParseFunction('type_id', $mapped_row['type_id'], $filtered_import_map['type_id']['default_value'], $filtered_import_map['type_id']['parse_hint']));
     }
     if (isset($mapped_row['pay_stub_account']) and $mapped_row['pay_stub_account'] != '') {
         $psealf = new PayStubEntryAccountListFactory();
         $psealf->getByCompanyIdAndTypeAndFuzzyName($ulf->getCurrent()->getCompany(), array(10, 20, 30, 50, 60, 65), $mapped_row['pay_stub_account']);
         if ($psealf->getRecordCount() > 0) {
             $psaf->setPayStubEntryNameId(Misc::importCallInputParseFunction('pay_stub_account', $psealf->getCurrent()->getId(), $filtered_import_map['pay_stub_account']['default_value'], $filtered_import_map['pay_stub_account']['parse_hint']));
         } else {
             $psaf->setPayStubEntryNameId(Misc::importCallInputParseFunction('pay_stub_account', "Invalid Pay Stub Account ", $filtered_import_map['pay_stub_account']['default_value'], $filtered_import_map['pay_stub_account']['parse_hint']));
         }
     }
     if (isset($mapped_row['units']) and $mapped_row['units'] != '') {
         $psaf->setUnits(Misc::importCallInputParseFunction('units', $mapped_row['units'], $filtered_import_map['units']['default_value'], $filtered_import_map['units']['parse_hint']));
     }
     if (isset($mapped_row['rate']) and $mapped_row['rate'] != '') {
         $psaf->setRate(Misc::importCallInputParseFunction('rate', $mapped_row['rate'], $filtered_import_map['rate']['default_value'], $filtered_import_map['rate']['parse_hint']));
     }
     if (isset($mapped_row['amount']) and $mapped_row['amount'] != '') {
         $psaf->setAmount(Misc::importCallInputParseFunction('amount', $mapped_row['amount'], $filtered_import_map['amount']['default_value'], $filtered_import_map['amount']['parse_hint']));
            $delete = FALSE;
        }
        $psealf = new PayStubEntryAccountListFactory();
        foreach ($ids as $id) {
            $psealf->getByIdAndCompanyId($id, $current_company->getId());
            foreach ($psealf as $psea_obj) {
                $psea_obj->setDeleted($delete);
                if ($psea_obj->isValid()) {
                    $psea_obj->Save();
                }
            }
        }
        Redirect::Page(URLBuilder::getURL(NULL, 'PayStubEntryAccountList.php'));
        break;
    default:
        BreadCrumb::setCrumb($title);
        $psealf = new PayStubEntryAccountListFactory();
        $psealf->getByCompanyId($current_company->getId());
        $pager = new Pager($psealf);
        $status_options = $psealf->getOptions('status');
        $type_options = $psealf->getOptions('type');
        foreach ($psealf as $psea_obj) {
            $rows[] = array('id' => $psea_obj->getId(), 'status_id' => $psea_obj->getStatus(), 'status' => $status_options[$psea_obj->getStatus()], 'type_id' => $psea_obj->getType(), 'type' => $type_options[$psea_obj->getType()], 'name' => $psea_obj->getName(), 'ps_order' => $psea_obj->getOrder(), 'debit_account' => $psea_obj->getDebitAccount(), 'credit_account' => $psea_obj->getCreditAccount(), 'deleted' => $psea_obj->getDeleted());
        }
        $smarty->assign_by_ref('rows', $rows);
        $smarty->assign_by_ref('sort_column', $sort_column);
        $smarty->assign_by_ref('sort_order', $sort_order);
        $smarty->assign_by_ref('paging_data', $pager->getPageVariables());
        break;
}
$smarty->display('pay_stub/PayStubEntryAccountList.tpl');
 function setPayStubEntryAccountId($id)
 {
     $id = trim($id);
     Debug::text('Entry Account ID: ' . $id, __FILE__, __LINE__, __METHOD__, 10);
     if ($id == '' or empty($id)) {
         $id = NULL;
     }
     $psealf = new PayStubEntryAccountListFactory();
     if ($id == NULL or $this->Validator->isResultSetWithRows('pay_stub_entry_account_id', $psealf->getById($id), TTi18n::gettext('Invalid Pay Stub Account'))) {
         $this->data['pay_stub_entry_account_id'] = $id;
         return TRUE;
     }
     return FALSE;
 }
Ejemplo n.º 16
0
 function getNextPayStubAccountOrderByTypeId($type_id)
 {
     global $current_company;
     Debug::Text('Type ID: ' . $type_id, __FILE__, __LINE__, __METHOD__, 10);
     if (!is_object($current_company)) {
         return FALSE;
     }
     if ($type_id == '') {
         return FALSE;
     }
     $psealf = new PayStubEntryAccountListFactory();
     $psealf->getHighestOrderByCompanyIdAndTypeId($current_company->getId(), $type_id);
     if ($psealf->getRecordCount() > 0) {
         foreach ($psealf as $psea_obj) {
             return $psea_obj->getOrder() + 1;
         }
     }
     return FALSE;
 }
Ejemplo n.º 17
0
 $data['us_eic_filing_status_options'] = $cdf->getOptions('us_eic_filing_status');
 $data['federal_filing_status_options'] = $cdf->getOptions('federal_filing_status');
 $data['state_filing_status_options'] = $cdf->getOptions('state_filing_status');
 $data['state_ga_filing_status_options'] = $cdf->getOptions('state_ga_filing_status');
 $data['state_nj_filing_status_options'] = $cdf->getOptions('state_nj_filing_status');
 $data['state_nc_filing_status_options'] = $cdf->getOptions('state_nc_filing_status');
 $data['state_ma_filing_status_options'] = $cdf->getOptions('state_ma_filing_status');
 $data['state_al_filing_status_options'] = $cdf->getOptions('state_al_filing_status');
 $data['state_ct_filing_status_options'] = $cdf->getOptions('state_ct_filing_status');
 $data['state_wv_filing_status_options'] = $cdf->getOptions('state_wv_filing_status');
 $data['state_me_filing_status_options'] = $cdf->getOptions('state_me_filing_status');
 $data['state_de_filing_status_options'] = $cdf->getOptions('state_de_filing_status');
 $data['state_dc_filing_status_options'] = $cdf->getOptions('state_dc_filing_status');
 $data['calculation_options'] = $cdf->getOptions('calculation');
 $data['js_arrays'] = $cdf->getJavaScriptArrays();
 $psealf = new PayStubEntryAccountListFactory();
 $data['pay_stub_entry_account_options'] = $psealf->getByCompanyIdAndStatusIdAndTypeIdArray($current_company->getId(), 10, array(10, 20, 30, 50), FALSE);
 //$data['pay_stub_entry_account_options'] = PayStubEntryAccountListFactory::getByCompanyIdAndStatusIdAndTypeIdArray( $current_company->getId(), 10, array(20,30), FALSE );
 $data['include_pay_stub_entry_account_options'] = $psealf->getByCompanyIdAndStatusIdAndTypeIdArray($current_company->getId(), 10, array(10, 20, 30, 40, 50), FALSE);
 if (isset($data['include_pay_stub_entry_account_ids']) and is_array($data['include_pay_stub_entry_account_ids'])) {
     $tmp_psea_options = $psealf->getByCompanyIdAndStatusIdAndTypeIdArray($current_company->getId(), 10, array(10, 20, 30, 40, 50), FALSE);
     foreach ($data['include_pay_stub_entry_account_ids'] as $include_psea_id) {
         if (isset($tmp_psea_options[$include_psea_id])) {
             $filter_include_options[$include_psea_id] = $tmp_psea_options[$include_psea_id];
         }
     }
     unset($include_psea_id, $tmp_psea_options);
 }
 $smarty->assign_by_ref('filter_include_options', $filter_include_options);
 $data['exclude_pay_stub_entry_account_options'] = $psealf->getByCompanyIdAndStatusIdAndTypeIdArray($current_company->getId(), 10, array(10, 20, 30, 40, 50), FALSE);
 if (isset($data['exclude_pay_stub_entry_account_ids']) and is_array($data['exclude_pay_stub_entry_account_ids'])) {
        } else {
            $delete = FALSE;
        }
        $rpsalf = new RecurringPayStubAmendmentListFactory();
        foreach ($ids as $id) {
            $rpsalf->getById($id);
            foreach ($rpsalf as $recurring_pay_stub_amendment) {
                $recurring_pay_stub_amendment->setDeleted($delete);
                $recurring_pay_stub_amendment->Save();
            }
        }
        unset($recurring_pay_stub_amendment);
        Redirect::Page(URLBuilder::getURL(NULL, 'RecurringPayStubAmendmentList.php', FALSE));
        break;
    default:
        URLBuilder::setURL(NULL, array('sort_column' => $sort_column, 'sort_order' => $sort_order));
        $rpsalf = new RecurringPayStubAmendmentListFactory();
        $rpsalf->getByCompanyId($current_company->getId(), $current_user_prefs->getItemsPerPage(), $page, NULL, $sort_array);
        $pager = new Pager($rpsalf);
        $psealf = new PayStubEntryAccountListFactory();
        foreach ($rpsalf as $recurring_pay_stub_amendment) {
            $recurring_pay_stub_amendments[] = array('id' => $recurring_pay_stub_amendment->GetId(), 'name' => $recurring_pay_stub_amendment->getName(), 'description' => $recurring_pay_stub_amendment->getDescription(), 'status' => Option::getByKey($recurring_pay_stub_amendment->getStatus(), $recurring_pay_stub_amendment->getOptions('status')), 'frequency' => Option::getByKey($recurring_pay_stub_amendment->getFrequency(), $recurring_pay_stub_amendment->getOptions('frequency')), 'pay_stub_entry_name' => $psealf->getById($recurring_pay_stub_amendment->getPayStubEntryNameId())->getCurrent()->getName(), 'deleted' => $recurring_pay_stub_amendment->getDeleted());
        }
        $smarty->assign_by_ref('recurring_pay_stub_amendments', $recurring_pay_stub_amendments);
        $smarty->assign_by_ref('sort_column', $sort_column);
        $smarty->assign_by_ref('sort_order', $sort_order);
        $smarty->assign_by_ref('paging_data', $pager->getPageVariables());
        $smarty->assign_by_ref('user_id', $user_id);
        break;
}
$smarty->display('pay_stub_amendment/RecurringPayStubAmendmentList.tpl');
Ejemplo n.º 19
0
 function getPayStub($pslf = NULL, $hide_employer_rows = TRUE)
 {
     if (!is_object($pslf) and $this->getId() != '') {
         $pslf = new PayStubListFactory();
         $pslf->getById($this->getId());
     }
     if (get_class($pslf) !== 'PayStubListFactory') {
         return FALSE;
     }
     $border = 0;
     if ($pslf->getRecordCount() > 0) {
         $pdf = new TTPDF('P', 'mm', 'Letter');
         $pdf->setMargins(0, 0);
         //$pdf->SetAutoPageBreak(TRUE, 30);
         $pdf->SetAutoPageBreak(FALSE);
         $pdf->SetFont('freeserif', '', 10);
         //$pdf->SetFont('FreeSans','',10);
         $i = 0;
         foreach ($pslf as $pay_stub_obj) {
             $psealf = new PayStubEntryAccountListFactory();
             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();
             //Use Pay Stub dates, not Pay Period dates.
             $pp_start_date = $pay_stub_obj->getStartDate();
             $pp_end_date = $pay_stub_obj->getEndDate();
             $pp_transaction_date = $pay_stub_obj->getTransactionDate();
             //Get pay period numbers
             $ppslf = new PayPeriodScheduleListFactory();
             $pay_period_schedule_obj = $ppslf->getById($pay_period_obj->getPayPeriodSchedule())->getCurrent();
             //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();
             //Change locale to users own locale.
             TTi18n::setCountry($user_obj->getCountry());
             TTi18n::setLanguage($user_obj->getUserPreferenceObject()->getLanguage());
             TTi18n::setLocale();
             //
             // Pay Stub Header
             //
             $pdf->AddPage();
             $adjust_x = 20;
             $adjust_y = 10;
             //Logo
             $pdf->Image($company_obj->getLogoFileName(), Misc::AdjustXY(0, $adjust_x + 0), Misc::AdjustXY(1, $adjust_y + 0), 50, 12, '', '', '', FALSE, 300, '', FALSE, FALSE, 0, TRUE);
             //Company name/address
             $pdf->SetFont('', 'B', 14);
             $pdf->setXY(Misc::AdjustXY(50, $adjust_x), Misc::AdjustXY(0, $adjust_y));
             $pdf->Cell(75, 5, $company_obj->getName(), $border, 0, 'C');
             $pdf->SetFont('', '', 10);
             $pdf->setXY(Misc::AdjustXY(50, $adjust_x), Misc::AdjustXY(5, $adjust_y));
             $pdf->Cell(75, 5, $company_obj->getAddress1() . ' ' . $company_obj->getAddress2(), $border, 0, 'C');
             $pdf->setXY(Misc::AdjustXY(50, $adjust_x), Misc::AdjustXY(10, $adjust_y));
             $pdf->Cell(75, 5, $company_obj->getCity() . ', ' . $company_obj->getProvince() . ' ' . strtoupper($company_obj->getPostalCode()), $border, 0, 'C');
             //Pay Period info
             $pdf->SetFont('', '', 10);
             $pdf->setXY(Misc::AdjustXY(125, $adjust_x), Misc::AdjustXY(0, $adjust_y));
             $pdf->Cell(30, 5, TTi18n::gettext('Pay Start Date:') . ' ', $border, 0, 'R');
             $pdf->setXY(Misc::AdjustXY(125, $adjust_x), Misc::AdjustXY(5, $adjust_y));
             $pdf->Cell(30, 5, TTi18n::gettext('Pay End Date:') . ' ', $border, 0, 'R');
             $pdf->setXY(Misc::AdjustXY(125, $adjust_x), Misc::AdjustXY(10, $adjust_y));
             $pdf->Cell(30, 5, TTi18n::gettext('Payment Date:') . ' ', $border, 0, 'R');
             $pdf->SetFont('', 'B', 10);
             $pdf->setXY(Misc::AdjustXY(155, $adjust_x), Misc::AdjustXY(0, $adjust_y));
             $pdf->Cell(20, 5, TTDate::getDate('DATE', $pp_start_date), $border, 0, 'R');
             $pdf->setXY(Misc::AdjustXY(155, $adjust_x), Misc::AdjustXY(5, $adjust_y));
             $pdf->Cell(20, 5, TTDate::getDate('DATE', $pp_end_date), $border, 0, 'R');
             $pdf->setXY(Misc::AdjustXY(155, $adjust_x), Misc::AdjustXY(10, $adjust_y));
             $pdf->Cell(20, 5, TTDate::getDate('DATE', $pp_transaction_date), $border, 0, 'R');
             //Line
             $pdf->setLineWidth(1);
             $pdf->Line(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY(17, $adjust_y), Misc::AdjustXY(185, $adjust_y), Misc::AdjustXY(17, $adjust_y));
             $pdf->SetFont('', 'B', 14);
             $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY(19, $adjust_y));
             $pdf->Cell(175, 5, TTi18n::gettext('STATEMENT OF EARNINGS AND DEDUCTIONS'), $border, 0, 'C', 0);
             //Line
             $pdf->setLineWidth(1);
             $pdf->Line(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY(27, $adjust_y), Misc::AdjustXY(185, $adjust_y), Misc::AdjustXY(27, $adjust_y));
             $pdf->setLineWidth(0.25);
             //Get pay stub entries.
             $pself = new PayStubEntryListFactory();
             $pself->getByPayStubId($pay_stub_obj->getId());
             Debug::text('Pay Stub Entries: ' . $pself->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10);
             $prev_type = NULL;
             $description_subscript_counter = 1;
             foreach ($pself as $pay_stub_entry) {
                 Debug::text('Pay Stub Entry Account ID: ' . $pay_stub_entry->getPayStubEntryNameId(), __FILE__, __LINE__, __METHOD__, 10);
                 $description_subscript = NULL;
                 $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);
                 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 if 40 (a total) and the amount is 0, skip it.
                 //This if the employee has no deductions at all, it won't be displayed
                 //on the pay stub.
                 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();
             }
             //There should always be pay stub entries for a pay stub.
             if (!isset($pay_stub_entries)) {
                 continue;
             }
             //Debug::Arr($pay_stub_entries, 'Pay Stub Entries...', __FILE__, __LINE__, __METHOD__,10);
             //$pay_period_number = $pay_period_schedule_obj->getCurrentPayPeriodNumber( $pay_period_obj->getTransactionDate(), $pay_period_obj->getEndDate() );
             $block_adjust_y = 30;
             //
             //Earnings
             //
             if (isset($pay_stub_entries[10])) {
                 //Earnings Header
                 $pdf->SetFont('', 'B', 10);
                 $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
                 $pdf->Cell(90, 5, TTi18n::gettext('Earnings'), $border, 0, 'L');
                 $pdf->Cell(17, 5, TTi18n::gettext('Rate'), $border, 0, 'R');
                 $pdf->Cell(23, 5, TTi18n::gettext('Hrs/Units'), $border, 0, 'R');
                 $pdf->Cell(20, 5, TTi18n::gettext('Amount'), $border, 0, 'R');
                 $pdf->Cell(25, 5, TTi18n::gettext('YTD Amount'), $border, 0, 'R');
                 $block_adjust_y = $block_adjust_y + 5;
                 $pdf->SetFont('', '', 10);
                 foreach ($pay_stub_entries[10] as $pay_stub_entry) {
                     if ($pay_stub_entry['type'] == 10) {
                         if ($pay_stub_entry['description_subscript'] != '') {
                             $subscript = '[' . $pay_stub_entry['description_subscript'] . ']';
                         } else {
                             $subscript = NULL;
                         }
                         $pdf->setXY(Misc::AdjustXY(2, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
                         $pdf->Cell(88, 5, $pay_stub_entry['name'] . $subscript, $border, 0, 'L');
                         $pdf->Cell(17, 5, TTi18n::formatNumber($pay_stub_entry['rate'], TRUE), $border, 0, 'R');
                         $pdf->Cell(23, 5, TTi18n::formatNumber($pay_stub_entry['units'], TRUE), $border, 0, 'R');
                         $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entry['amount']), $border, 0, 'R');
                         $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount']), $border, 0, 'R');
                     } else {
                         //Total
                         $pdf->SetFont('', 'B', 10);
                         $pdf->line(Misc::AdjustXY(110, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(130, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
                         $pdf->line(Misc::AdjustXY(131, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(150, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
                         $pdf->line(Misc::AdjustXY(151, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(175, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
                         $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
                         $pdf->Cell(90, 5, $pay_stub_entry['name'], $border, 0, 'L');
                         $pdf->Cell(17, 5, '', $border, 0, 'R');
                         $pdf->Cell(23, 5, TTi18n::formatNumber($pay_stub_entry['units'], TRUE), $border, 0, 'R');
                         $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entry['amount']), $border, 0, 'R');
                         $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount']), $border, 0, 'R');
                     }
                     $block_adjust_y = $block_adjust_y + 5;
                 }
             }
             //
             // Deductions
             //
             if (isset($pay_stub_entries[20])) {
                 $max_deductions = count($pay_stub_entries[20]);
                 //Deductions Header
                 $block_adjust_y = $block_adjust_y + 5;
                 $pdf->SetFont('', 'B', 10);
                 if ($max_deductions > 2) {
                     $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
                     $pdf->Cell(40, 5, TTi18n::gettext('Deductions'), $border, 0, 'L');
                     $pdf->Cell(20, 5, TTi18n::gettext('Amount'), $border, 0, 'R');
                     $pdf->Cell(25, 5, TTi18n::gettext('YTD Amount'), $border, 0, 'R');
                     $pdf->setXY(Misc::AdjustXY(90, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
                     $pdf->Cell(40, 5, TTi18n::gettext('Deductions'), $border, 0, 'L');
                 } else {
                     $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
                     $pdf->Cell(130, 5, TTi18n::gettext('Deductions'), $border, 0, 'L');
                 }
                 $pdf->Cell(20, 5, TTi18n::gettext('Amount'), $border, 0, 'R');
                 $pdf->Cell(25, 5, TTi18n::gettext('YTD Amount'), $border, 0, 'R');
                 $block_adjust_y = $tmp_block_adjust_y = $top_block_adjust_y = $block_adjust_y + 5;
                 $pdf->SetFont('', '', 10);
                 $x = 0;
                 $max_block_adjust_y = 0;
                 foreach ($pay_stub_entries[20] as $pay_stub_entry) {
                     //Start with the right side.
                     if ($x < floor($max_deductions / 2)) {
                         $tmp_adjust_x = 90;
                     } else {
                         if ($tmp_block_adjust_y != 0) {
                             $block_adjust_y = $tmp_block_adjust_y;
                             $tmp_block_adjust_y = 0;
                         }
                         $tmp_adjust_x = 0;
                     }
                     if ($pay_stub_entry['type'] == 20) {
                         if ($pay_stub_entry['description_subscript'] != '') {
                             $subscript = '[' . $pay_stub_entry['description_subscript'] . ']';
                         } else {
                             $subscript = NULL;
                         }
                         if ($max_deductions > 2) {
                             $pdf->setXY(Misc::AdjustXY(2, $tmp_adjust_x + $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
                             $pdf->Cell(38, 5, $pay_stub_entry['name'] . $subscript, $border, 0, 'L');
                         } else {
                             $pdf->setXY(Misc::AdjustXY(2, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
                             $pdf->Cell(128, 5, $pay_stub_entry['name'] . $subscript, $border, 0, 'L');
                         }
                         $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entry['amount']), $border, 0, 'R');
                         $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount']), $border, 0, 'R');
                     } else {
                         $block_adjust_y = $max_block_adjust_y + 0;
                         //Total
                         $pdf->SetFont('', 'B', 10);
                         $pdf->line(Misc::AdjustXY(130, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(150, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
                         $pdf->line(Misc::AdjustXY(151, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(175, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
                         $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
                         $pdf->Cell(130, 5, $pay_stub_entry['name'], $border, 0, 'L');
                         $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entry['amount']), $border, 0, 'R');
                         $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount']), $border, 0, 'R');
                     }
                     $block_adjust_y = $block_adjust_y + 5;
                     if ($block_adjust_y > $max_block_adjust_y) {
                         $max_block_adjust_y = $block_adjust_y;
                     }
                     $x++;
                 }
                 //Draw line to separate the two columns
                 if ($max_deductions > 2) {
                     $pdf->Line(Misc::AdjustXY(88, $adjust_x), Misc::AdjustXY($top_block_adjust_y - 5, $adjust_y), Misc::AdjustXY(88, $adjust_x), Misc::AdjustXY($max_block_adjust_y - 5, $adjust_y));
                 }
                 unset($x, $max_deductions, $tmp_adjust_x, $max_block_adjust_y, $tmp_block_adjust_y, $top_block_adjust_y);
             }
             if (isset($pay_stub_entries[40][0])) {
                 $block_adjust_y = $block_adjust_y + 5;
                 //Net Pay entry
                 $pdf->SetFont('', 'B', 10);
                 $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
                 $pdf->Cell(130, 5, $pay_stub_entries[40][0]['name'], $border, 0, 'L');
                 $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entries[40][0]['amount']), $border, 0, 'R');
                 $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entries[40][0]['ytd_amount']), $border, 0, 'R');
                 $block_adjust_y = $block_adjust_y + 5;
             }
             //
             //Employer Contributions
             //
             //echo "Employee Ded: <br>\n";
             if (isset($pay_stub_entries[30]) and $hide_employer_rows != TRUE) {
                 $max_deductions = count($pay_stub_entries[30]);
                 //echo "Max Employee Ded: ". $max_deductions ."<br>\n";
                 //Deductions Header
                 $block_adjust_y = $block_adjust_y + 5;
                 $pdf->SetFont('', 'B', 10);
                 if ($max_deductions > 2) {
                     $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
                     $pdf->Cell(40, 5, TTi18n::gettext('Employer Contributions'), $border, 0, 'L');
                     $pdf->Cell(20, 5, TTi18n::gettext('Amount'), $border, 0, 'R');
                     $pdf->Cell(25, 5, TTi18n::gettext('YTD Amount'), $border, 0, 'R');
                     $pdf->setXY(Misc::AdjustXY(90, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
                     $pdf->Cell(40, 5, TTi18n::gettext('Employer Contributions'), $border, 0, 'L');
                 } else {
                     $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
                     $pdf->Cell(130, 5, TTi18n::gettext('Employer Contributions'), $border, 0, 'L');
                 }
                 $pdf->Cell(20, 5, TTi18n::gettext('Amount'), $border, 0, 'R');
                 $pdf->Cell(25, 5, TTi18n::gettext('YTD Amount'), $border, 0, 'R');
                 $block_adjust_y = $tmp_block_adjust_y = $top_block_adjust_y = $block_adjust_y + 5;
                 $pdf->SetFont('', '', 10);
                 $x = 0;
                 $max_block_adjust_y = 0;
                 foreach ($pay_stub_entries[30] as $pay_stub_entry) {
                     //Start with the right side.
                     if ($x < floor($max_deductions / 2)) {
                         $tmp_adjust_x = 90;
                     } else {
                         if ($tmp_block_adjust_y != 0) {
                             $block_adjust_y = $tmp_block_adjust_y;
                             $tmp_block_adjust_y = 0;
                         }
                         $tmp_adjust_x = 0;
                     }
                     if ($pay_stub_entry['type'] == 30) {
                         if ($pay_stub_entry['description_subscript'] != '') {
                             $subscript = '[' . $pay_stub_entry['description_subscript'] . ']';
                         } else {
                             $subscript = NULL;
                         }
                         if ($max_deductions > 2) {
                             $pdf->setXY(Misc::AdjustXY(2, $tmp_adjust_x + $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
                             $pdf->Cell(38, 5, $pay_stub_entry['name'] . $subscript, $border, 0, 'L');
                         } else {
                             $pdf->setXY(Misc::AdjustXY(2, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
                             $pdf->Cell(128, 5, $pay_stub_entry['name'] . $subscript, $border, 0, 'L');
                         }
                         $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entry['amount']), $border, 0, 'R');
                         $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount']), $border, 0, 'R');
                     } else {
                         $block_adjust_y = $max_block_adjust_y + 0;
                         //Total
                         $pdf->SetFont('', 'B', 10);
                         $pdf->line(Misc::AdjustXY(130, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(150, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
                         $pdf->line(Misc::AdjustXY(151, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(175, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
                         $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
                         $pdf->Cell(130, 5, $pay_stub_entry['name'], $border, 0, 'L');
                         $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entry['amount']), $border, 0, 'R');
                         $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount']), $border, 0, 'R');
                     }
                     $block_adjust_y = $block_adjust_y + 5;
                     if ($block_adjust_y > $max_block_adjust_y) {
                         $max_block_adjust_y = $block_adjust_y;
                     }
                     $x++;
                 }
                 //Draw line to separate the two columns
                 if ($max_deductions > 2) {
                     $pdf->Line(Misc::AdjustXY(88, $adjust_x), Misc::AdjustXY($top_block_adjust_y - 5, $adjust_y), Misc::AdjustXY(88, $adjust_x), Misc::AdjustXY($max_block_adjust_y - 5, $adjust_y));
                 }
                 unset($x, $max_deductions, $tmp_adjust_x, $max_block_adjust_y, $tmp_block_adjust_y, $top_block_adjust_y);
             }
             //
             //Accruals PS accounts
             //
             if (isset($pay_stub_entries[50])) {
                 //Accrual Header
                 $block_adjust_y = $block_adjust_y + 5;
                 $pdf->SetFont('', 'B', 10);
                 $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
                 $pdf->Cell(130, 5, TTi18n::gettext('Accruals'), $border, 0, 'L');
                 $pdf->Cell(20, 5, TTi18n::gettext('Amount'), $border, 0, 'R');
                 $pdf->Cell(25, 5, TTi18n::gettext('Balance'), $border, 0, 'R');
                 $block_adjust_y = $block_adjust_y + 5;
                 $pdf->SetFont('', '', 10);
                 foreach ($pay_stub_entries[50] as $pay_stub_entry) {
                     if ($pay_stub_entry['type'] == 50) {
                         if ($pay_stub_entry['description_subscript'] != '') {
                             $subscript = '[' . $pay_stub_entry['description_subscript'] . ']';
                         } else {
                             $subscript = NULL;
                         }
                         $pdf->setXY(Misc::AdjustXY(2, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
                         $pdf->Cell(128, 5, $pay_stub_entry['name'] . $subscript, $border, 0, 'L');
                         $pdf->Cell(20, 5, TTi18n::formatNumber($pay_stub_entry['amount']), $border, 0, 'R');
                         $pdf->Cell(25, 5, TTi18n::formatNumber($pay_stub_entry['ytd_amount']), $border, 0, 'R');
                     }
                     $block_adjust_y = $block_adjust_y + 5;
                 }
             }
             //
             //Accrual Policy Balances
             //
             $ablf = new AccrualBalanceListFactory();
             $ablf->getByUserIdAndCompanyIdAndEnablePayStubBalanceDisplay($user_obj->getId(), $user_obj->getCompany(), TRUE);
             if ($ablf->getRecordCount() > 0) {
                 //Accrual Header
                 $block_adjust_y = $block_adjust_y + 5;
                 $pdf->SetFont('', 'B', 10);
                 $pdf->setXY(Misc::AdjustXY(40, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
                 $accrual_time_header_start_x = $pdf->getX();
                 $accrual_time_header_start_y = $pdf->getY();
                 $pdf->Cell(70, 5, TTi18n::gettext('Accrual Time Balances as of ') . TTDate::getDate('DATE', time()), $border, 0, 'L');
                 $pdf->Cell(25, 5, TTi18n::gettext('Balance (hrs)'), $border, 0, 'R');
                 $block_adjust_y = $block_adjust_y + 5;
                 $box_height = 5;
                 $pdf->SetFont('', '', 10);
                 foreach ($ablf as $ab_obj) {
                     $balance = $ab_obj->getBalance();
                     if (!is_numeric($balance)) {
                         $balance = 0;
                     }
                     $pdf->setXY(Misc::AdjustXY(40, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
                     $pdf->Cell(70, 5, $ab_obj->getColumn('name'), $border, 0, 'L');
                     $pdf->Cell(25, 5, TTi18n::formatNumber(TTDate::getHours($balance)), $border, 0, 'R');
                     $block_adjust_y = $block_adjust_y + 5;
                     $box_height = $box_height + 5;
                     unset($balance);
                 }
                 $pdf->Rect($accrual_time_header_start_x, $accrual_time_header_start_y, 95, $box_height);
                 unset($accrual_time_header_start_x, $accrual_time_header_start_y, $box_height);
             }
             //
             //Descriptions
             //
             if (isset($pay_stub_entry_descriptions) and count($pay_stub_entry_descriptions) > 0) {
                 //Description Header
                 $block_adjust_y = $block_adjust_y + 5;
                 $pdf->SetFont('', 'B', 10);
                 $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
                 $pdf->Cell(175, 5, TTi18n::gettext('Notes'), $border, 0, 'L');
                 $block_adjust_y = $block_adjust_y + 5;
                 $pdf->SetFont('', '', 8);
                 $x = 0;
                 foreach ($pay_stub_entry_descriptions as $pay_stub_entry_description) {
                     if ($x % 2 == 0) {
                         $pdf->setXY(Misc::AdjustXY(2, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
                     } else {
                         $pdf->setXY(Misc::AdjustXY(90, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y));
                     }
                     //$pdf->Cell(173,5, '['.$pay_stub_entry_description['subscript'].'] '.$pay_stub_entry_description['description'], $border, 0, 'L');
                     $pdf->Cell(85, 5, '[' . $pay_stub_entry_description['subscript'] . '] ' . $pay_stub_entry_description['description'], $border, 0, 'L');
                     if ($x % 2 != 0) {
                         $block_adjust_y = $block_adjust_y + 5;
                     }
                     $x++;
                 }
             }
             unset($x, $pay_stub_entry_descriptions, $pay_stub_entry_description);
             //
             // Pay Stub Footer
             //
             $block_adjust_y = 215;
             //Line
             $pdf->setLineWidth(1);
             $pdf->Line(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y, $adjust_y), Misc::AdjustXY(185, $adjust_y), Misc::AdjustXY($block_adjust_y, $adjust_y));
             //Non Negotiable
             $pdf->SetFont('', 'B', 14);
             $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 3, $adjust_y));
             $pdf->Cell(175, 5, TTi18n::gettext('NON NEGOTIABLE'), $border, 0, 'C', 0);
             //Employee Address
             $pdf->SetFont('', 'B', 12);
             $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 9, $adjust_y));
             $pdf->Cell(60, 5, TTi18n::gettext('CONFIDENTIAL'), $border, 0, 'C', 0);
             $pdf->SetFont('', '', 10);
             $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 14, $adjust_y));
             $pdf->Cell(60, 5, $user_obj->getFullName(), $border, 0, 'C', 0);
             $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 19, $adjust_y));
             $pdf->Cell(60, 5, $user_obj->getAddress1(), $border, 0, 'C', 0);
             $address2_adjust_y = 0;
             if ($user_obj->getAddress2() != '') {
                 $address2_adjust_y = 5;
                 $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 24, $adjust_y));
                 $pdf->Cell(60, 5, $user_obj->getAddress2(), $border, 0, 'C', 0);
             }
             $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 24 + $address2_adjust_y, $adjust_y));
             $pdf->Cell(60, 5, $user_obj->getCity() . ', ' . $user_obj->getProvince() . ' ' . $user_obj->getPostalCode(), $border, 1, 'C', 0);
             //Pay Period - Balance - ID
             $net_pay_amount = 0;
             if (isset($pay_stub_entries[40][0])) {
                 $net_pay_amount = $pay_stub_entries[40][0]['amount'];
             }
             if (isset($pay_stub_entries[65]) and count($pay_stub_entries[65]) > 0) {
                 $net_pay_label = TTi18n::gettext('Balance');
             } else {
                 $net_pay_label = TTi18n::gettext('Net Pay');
             }
             /*
             if ( $pay_period_schedule_obj->getType() != 5 AND $pay_period_number > 0 AND $pay_period_schedule_obj->getAnnualPayPeriods() > 0 ) {
             	$pdf->setXY( Misc::AdjustXY(125, $adjust_x), Misc::AdjustXY($block_adjust_y+10, $adjust_y) );
             	$pdf->Cell(50, 5, TTi18n::gettext('Pay Period').' '. $pay_period_number .' '. TTi18n::gettext('of') .' '. $pay_period_schedule_obj->getAnnualPayPeriods(), $border, 1, 'L', 0);
             }
             */
             $pdf->SetFont('', 'B', 12);
             $pdf->setXY(Misc::AdjustXY(125, $adjust_x), Misc::AdjustXY($block_adjust_y + 17, $adjust_y));
             $pdf->Cell(50, 5, $net_pay_label . ': ' . $pay_stub_obj->getCurrencyObject()->getSymbol() . $net_pay_amount . ' ' . $pay_stub_obj->getCurrencyObject()->getISOCode(), $border, 1, 'L', 0);
             if ($pay_stub_obj->getTainted() == TRUE) {
                 $tainted_flag = 'T';
             } else {
                 $tainted_flag = '';
             }
             $pdf->SetFont('', '', 8);
             $pdf->setXY(Misc::AdjustXY(125, $adjust_x), Misc::AdjustXY($block_adjust_y + 30, $adjust_y));
             $pdf->Cell(50, 5, TTi18n::gettext('Identification #:') . ' ' . str_pad($pay_stub_obj->getId(), 12, 0, STR_PAD_LEFT) . $tainted_flag, $border, 1, 'L', 0);
             unset($net_pay_amount, $tainted_flag);
             //Line
             $pdf->setLineWidth(1);
             $pdf->Line(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 35, $adjust_y), Misc::AdjustXY(185, $adjust_y), Misc::AdjustXY($block_adjust_y + 35, $adjust_y));
             $pdf->SetFont('', '', 6);
             $pdf->setXY(Misc::AdjustXY(0, $adjust_x), Misc::AdjustXY($block_adjust_y + 38, $adjust_y));
             $pdf->Cell(175, 1, TTi18n::gettext('Pay Stub Generated by') . ' ' . APPLICATION_NAME, $border, 0, 'C', 0);
             unset($pay_period_schedule_obj, $pay_stub_entries, $pay_period_number);
             $i++;
         }
         $output = $pdf->Output('', 'S');
     }
     TTi18n::setMasterLocale();
     if (isset($output)) {
         return $output;
     }
     return FALSE;
 }
 function setPercentAmountEntryNameId($id)
 {
     $id = trim($id);
     /*
     		$psenlf = new PayStubEntryNameListFactory();
     		$result = $psenlf->getById( $id )->getCurrent();
     */
     $psealf = new PayStubEntryAccountListFactory();
     $result = $psealf->getById($id)->getCurrent();
     if ($this->Validator->isResultSetWithRows('percent_amount_entry_name', $result, TTi18n::gettext('Invalid Percent Of'))) {
         $this->data['percent_amount_entry_name_id'] = $id;
         return FALSE;
     }
     return FALSE;
 }
    function getUnitSumByPayStubIdAndType($pay_stub_id, $type_id, $where = NULL, $order = NULL)
    {
        if ($pay_stub_id == '') {
            return FALSE;
        }
        if ($type_id == '') {
            return FALSE;
        }
        //$psenlf = new PayStubEntryNameListFactory();
        $psealf = new PayStubEntryAccountListFactory();
        $ph = array('pay_stub_id' => $pay_stub_id, 'type_id' => $type_id);
        $query = '
					select 	sum(units)
					from	' . $this->getTable() . ' as a,
							' . $psealf->getTable() . ' as b
					where	a.pay_stub_entry_name_id = b.id
						AND a.pay_stub_id = ?
						AND b.type_id = ?
						AND a.deleted = 0
				';
        $query .= $this->getWhereSQL($where);
        $query .= $this->getSortSQL($order);
        $sum = $this->db->GetOne($query, $ph);
        if ($sum !== FALSE or $sum !== NULL) {
            Debug::text('Unit Sum: ' . $sum, __FILE__, __LINE__, __METHOD__, 10);
            return $sum;
        }
        Debug::text('Unit Sum is NULL', __FILE__, __LINE__, __METHOD__, 10);
        return FALSE;
    }
    function getSearchByCompanyIdAndArrayCriteria($company_id, $filter_data, $limit = NULL, $page = NULL, $where = NULL, $order = NULL)
    {
        if ($company_id == '') {
            return FALSE;
        }
        if (!is_array($order)) {
            //Use Filter Data ordering if its set.
            if (isset($filter_data['sort_column']) and $filter_data['sort_order']) {
                $order = array(Misc::trimSortPrefix($filter_data['sort_column']) => $filter_data['sort_order']);
            }
        }
        $additional_order_fields = array('b.last_name', 'b.first_name');
        if ($order == NULL) {
            $order = array('a.effective_date' => 'desc', 'a.status_id' => 'asc', 'b.last_name' => 'asc');
            $strict = FALSE;
        } else {
            //Always try to order by status first so UNPAID employees go to the bottom.
            if (isset($order['last_name'])) {
                $order['b.last_name'] = $order['last_name'];
                unset($order['last_name']);
            }
            if (isset($order['first_name'])) {
                $order['b.first_name'] = $order['first_name'];
                unset($order['first_name']);
            }
            if (isset($order['type'])) {
                $order['type_id'] = $order['type'];
                unset($order['type']);
            }
            if (isset($order['status'])) {
                $order['status_id'] = $order['status'];
                unset($order['status']);
            }
            if (isset($order['effective_date'])) {
                $order['b.last_name'] = 'asc';
            } else {
                $order['a.effective_date'] = 'desc';
            }
            $strict = TRUE;
        }
        //Debug::Arr($order,'bOrder Data:', __FILE__, __LINE__, __METHOD__,10);
        //Debug::Arr($filter_data,'Filter Data:', __FILE__, __LINE__, __METHOD__,10);
        $uf = new UserFactory();
        $psealf = new PayStubEntryAccountListFactory();
        $ph = array('company_id' => $company_id);
        $query = '
					select 	a.*
					from 	' . $this->getTable() . ' as a
						LEFT JOIN ' . $uf->getTable() . ' as b ON a.user_id = b.id
						LEFT JOIN ' . $psealf->getTable() . ' as c ON a.pay_stub_entry_name_id  = c.id
					where	b.company_id = ?
					';
        if (isset($filter_data['permission_children_ids']) and isset($filter_data['permission_children_ids'][0]) and !in_array(-1, (array) $filter_data['permission_children_ids'])) {
            $query .= ' AND b.id in (' . $this->getListSQL($filter_data['permission_children_ids'], $ph) . ') ';
        }
        if (isset($filter_data['user_id']) and isset($filter_data['user_id'][0]) and !in_array(-1, (array) $filter_data['user_id'])) {
            $query .= ' AND b.id in (' . $this->getListSQL($filter_data['user_id'], $ph) . ') ';
        }
        if (isset($filter_data['status_id']) and isset($filter_data['status_id'][0]) and !in_array(-1, (array) $filter_data['status_id'])) {
            $query .= ' AND a.status_id in (' . $this->getListSQL($filter_data['status_id'], $ph) . ') ';
        }
        if (isset($filter_data['group_id']) and isset($filter_data['group_id'][0]) and !in_array(-1, (array) $filter_data['group_id'])) {
            if (isset($filter_data['include_subgroups']) and (bool) $filter_data['include_subgroups'] == TRUE) {
                $uglf = new UserGroupListFactory();
                $filter_data['group_id'] = $uglf->getByCompanyIdAndGroupIdAndSubGroupsArray($company_id, $filter_data['group_id'], TRUE);
            }
            $query .= ' AND b.group_id in (' . $this->getListSQL($filter_data['group_id'], $ph) . ') ';
        }
        if (isset($filter_data['default_branch_id']) and isset($filter_data['default_branch_id'][0]) and !in_array(-1, (array) $filter_data['default_branch_id'])) {
            $query .= ' AND b.default_branch_id in (' . $this->getListSQL($filter_data['default_branch_id'], $ph) . ') ';
        }
        if (isset($filter_data['default_department_id']) and isset($filter_data['default_department_id'][0]) and !in_array(-1, (array) $filter_data['default_department_id'])) {
            $query .= ' AND b.default_department_id in (' . $this->getListSQL($filter_data['default_department_id'], $ph) . ') ';
        }
        if (isset($filter_data['title_id']) and isset($filter_data['title_id'][0]) and !in_array(-1, (array) $filter_data['title_id'])) {
            $query .= ' AND b.title_id in (' . $this->getListSQL($filter_data['title_id'], $ph) . ') ';
        }
        if (isset($filter_data['recurring_ps_amendment_id']) and isset($filter_data['recurring_ps_amendment_id'][0]) and !in_array(-1, (array) $filter_data['recurring_ps_amendment_id'])) {
            $query .= ' AND a.recurring_ps_amendment_id in (' . $this->getListSQL($filter_data['recurring_ps_amendment_id'], $ph) . ') ';
        }
        if (isset($filter_data['start_date']) and trim($filter_data['start_date']) != '') {
            $ph[] = strtolower(trim($filter_data['start_date']));
            $query .= ' AND a.effective_date >= ?';
        }
        if (isset($filter_data['end_date']) and trim($filter_data['end_date']) != '') {
            $ph[] = strtolower(trim($filter_data['end_date']));
            $query .= ' AND a.effective_date <= ?';
        }
        if (isset($filter_data['effective_date']) and trim($filter_data['effective_date']) != '') {
            $ph[] = strtolower(trim($filter_data['effective_date']));
            $query .= ' AND a.effective_date = ?';
        }
        $query .= '
						AND ( a.deleted = 0 AND b.deleted = 0 AND c.deleted = 0 )
					';
        $query .= $this->getWhereSQL($where);
        $query .= $this->getSortSQL($order, $strict, $additional_order_fields);
        if ($limit == NULL) {
            $this->rs = $this->db->Execute($query, $ph);
        } else {
            $this->rs = $this->db->PageExecute($query, $limit, $page, $ph);
        }
        return $this;
    }
Ejemplo n.º 23
0
            $otpf->Save();
            Redirect::Page(URLBuilder::getURL(NULL, 'OverTimePolicyList.php'));
            break;
        }
    default:
        if (isset($id)) {
            BreadCrumb::setCrumb($title);
            $otplf = new OverTimePolicyListFactory();
            $otplf->getByIdAndCompanyID($id, $current_company->getID());
            foreach ($otplf as $otp_obj) {
                //Debug::Arr($station,'Department', __FILE__, __LINE__, __METHOD__,10);
                $data = array('id' => $otp_obj->getId(), 'name' => $otp_obj->getName(), 'type_id' => $otp_obj->getType(), 'trigger_time' => $otp_obj->getTriggerTime(), 'rate' => Misc::removeTrailingZeros($otp_obj->getRate()), 'wage_group_id' => $otp_obj->getWageGroup(), 'accrual_rate' => Misc::removeTrailingZeros($otp_obj->getAccrualRate()), 'accrual_policy_id' => $otp_obj->getAccrualPolicyID(), 'pay_stub_entry_account_id' => $otp_obj->getPayStubEntryAccountId(), 'created_date' => $otp_obj->getCreatedDate(), 'created_by' => $otp_obj->getCreatedBy(), 'updated_date' => $otp_obj->getUpdatedDate(), 'updated_by' => $otp_obj->getUpdatedBy(), 'deleted_date' => $otp_obj->getDeletedDate(), 'deleted_by' => $otp_obj->getDeletedBy());
            }
        } elseif ($action != 'submit') {
            $data = array('trigger_time' => 0, 'rate' => '1.00', 'accrual_rate' => '1.00');
        }
        $aplf = new AccrualPolicyListFactory();
        $accrual_options = $aplf->getByCompanyIDArray($current_company->getId(), TRUE);
        $psealf = new PayStubEntryAccountListFactory();
        $pay_stub_entry_options = $psealf->getByCompanyIdAndStatusIdAndTypeIdArray($current_company->getId(), 10, array(10, 20, 30, 50));
        $wglf = new WageGroupListFactory();
        $data['wage_group_options'] = $wglf->getArrayByListFactory($wglf->getByCompanyId($current_company->getId()), TRUE);
        //Select box options;
        $data['type_options'] = $otpf->getOptions('type');
        $data['accrual_options'] = $accrual_options;
        $data['pay_stub_entry_options'] = $pay_stub_entry_options;
        $smarty->assign_by_ref('data', $data);
        break;
}
$smarty->assign_by_ref('otpf', $otpf);
$smarty->display('policy/EditOverTimePolicy.tpl');
Ejemplo n.º 24
0
 */
require_once '../../includes/global.inc.php';
require_once Environment::getBasePath() . 'includes/Interface.inc.php';
if (!$permission->Check('report', 'enabled') or !$permission->Check('report', 'view_pay_stub_summary')) {
    $permission->Redirect(FALSE);
    //Redirect
}
$smarty->assign('title', TTi18n::gettext($title = 'Pay Stub Summary Report'));
// See index.php
/*
 * Get FORM variables
 */
extract(FormVariables::GetVariables(array('action', 'generic_data', 'filter_data')));
URLBuilder::setURL($_SERVER['SCRIPT_NAME'], array('filter_data' => $filter_data));
$static_columns = array('-0900-first_name' => TTi18n::gettext('First Name'), '-0901-middle_name' => TTi18n::gettext('Middle Name'), '-0902-middle_initial' => TTi18n::gettext('Middle Initial'), '-0903-last_name' => TTi18n::gettext('Last Name'), '-1000-full_name' => TTi18n::gettext('Full Name'), '-1002-employee_number' => TTi18n::gettext('Employee #'), '-1010-title' => TTi18n::gettext('Title'), '-1020-province' => TTi18n::gettext('Province/State'), '-1030-country' => TTi18n::gettext('Country'), '-1039-group' => TTi18n::gettext('Group'), '-1040-default_branch' => TTi18n::gettext('Default Branch'), '-1050-default_department' => TTi18n::gettext('Default Department'), '-1060-sin' => TTi18n::gettext('SIN/SSN'), '-1065-birth_date' => TTi18n::gettext('Birth Date'), '-1070-hire_date' => TTi18n::gettext('Hire Date'), '-1080-since_hire_date' => TTi18n::gettext('Since Hired'), '-1085-termination_date' => TTi18n::gettext('Termination Date'), '-1086-institution' => TTi18n::gettext('Bank Institution'), '-1087-transit' => TTi18n::gettext('Bank Transit/Routing'), '-1089-account' => TTi18n::gettext('Bank Account'), '-1090-pay_period' => TTi18n::gettext('Pay Period'), '-1100-pay_stub_start_date' => TTi18n::gettext('Start Date'), '-1110-pay_stub_end_date' => TTi18n::gettext('End Date'), '-1120-pay_stub_transaction_date' => TTi18n::gettext('Transaction Date'), '-1130-currency' => TTi18n::gettext('Currency'), '-1131-current_currency' => TTi18n::gettext('Current Currency'));
$psealf = new PayStubEntryAccountListFactory();
$psen_columns = $psealf->getByCompanyIdAndStatusIdAndTypeIdArray($current_company->getId(), 10, array(10, 20, 30, 40, 50, 60, 65), FALSE);
$columns = Misc::prependArray($static_columns, $psen_columns);
$default_transaction_start_date = TTDate::getBeginMonthEpoch(time());
$default_transaction_end_date = TTDate::getEndMonthEpoch(time());
//Get all pay periods
$pplf = new PayPeriodListFactory();
$pplf->getPayPeriodsWithPayStubsByCompanyId($current_company->getId());
$pay_period_options = array();
if ($pplf->getRecordCount() > 0) {
    $pp = 0;
    foreach ($pplf as $pay_period_obj) {
        $pay_period_ids[] = $pay_period_obj->getId();
        $pay_period_end_dates[$pay_period_obj->getId()] = $pay_period_obj->getEndDate();
        if ($pp == 0) {
            $default_transaction_start_date = $pay_period_obj->getEndDate();
Ejemplo n.º 25
0
 $filter_data['src_branch_options'] = Misc::arrayDiffByKey((array) $filter_data['branch_ids'], $branch_options);
 $filter_data['selected_branch_options'] = Misc::arrayIntersectByKey((array) $filter_data['branch_ids'], $branch_options);
 //Get departments
 $dlf = new DepartmentListFactory();
 $dlf->getByCompanyId($current_company->getId());
 $department_options = Misc::prependArray($all_array_option, $dlf->getArrayByListFactory($dlf, FALSE, TRUE));
 $filter_data['src_department_options'] = Misc::arrayDiffByKey((array) $filter_data['department_ids'], $department_options);
 $filter_data['selected_department_options'] = Misc::arrayIntersectByKey((array) $filter_data['department_ids'], $department_options);
 //Get employee titles
 $utlf = new UserTitleListFactory();
 $utlf->getByCompanyId($current_company->getId());
 $user_title_options = Misc::prependArray($all_array_option, $utlf->getArrayByListFactory($utlf, FALSE, TRUE));
 $filter_data['src_user_title_options'] = Misc::arrayDiffByKey((array) $filter_data['user_title_ids'], $user_title_options);
 $filter_data['selected_user_title_options'] = Misc::arrayIntersectByKey((array) $filter_data['user_title_ids'], $user_title_options);
 //Deduction PSEA accounts
 $psealf = new PayStubEntryAccountListFactory();
 $filter_data['deduction_pay_stub_entry_account_options'] = $psealf->getByCompanyIdAndStatusIdAndTypeIdArray($current_company->getId(), 10, array(20, 30, 40), TRUE);
 $filter_data['earning_pay_stub_entry_account_options'] = $psealf->getByCompanyIdAndStatusIdAndTypeIdArray($current_company->getId(), 10, array(10, 40), TRUE);
 $filter_data['income_pay_stub_entry_account_options'] = $psealf->getByCompanyIdAndStatusIdAndTypeIdArray($current_company->getId(), 10, array(10, 30, 40), TRUE);
 //Get employee list
 //$filter_data['user_options'] = UserListFactory::getByCompanyIdArray( $current_company->getId(), FALSE );
 //Quarters
 $filter_data['year_options'] = $year_options;
 $setup_data['state_options'] = $state_options;
 $saved_report_options = $ugdlf->getByUserIdAndScriptArray($current_user->getId(), $_SERVER['SCRIPT_NAME']);
 $generic_data['saved_report_options'] = $saved_report_options;
 $smarty->assign_by_ref('generic_data', $generic_data);
 $smarty->assign_by_ref('filter_data', $filter_data);
 $smarty->assign_by_ref('setup_data', $setup_data);
 $smarty->assign_by_ref('ugdf', $ugdf);
 $smarty->display('report/Form940ez.tpl');
        $pseaf->setType($data['type_id']);
        $pseaf->setName($data['name']);
        $pseaf->setOrder($data['order']);
        $pseaf->setAccrual($data['accrual_id']);
        $pseaf->setDebitAccount($data['debit_account']);
        $pseaf->setCreditAccount($data['credit_account']);
        if ($pseaf->isValid()) {
            $pseaf->Save();
            Redirect::Page(URLBuilder::getURL(NULL, 'PayStubEntryAccountList.php'));
            break;
        }
    default:
        if (isset($id)) {
            BreadCrumb::setCrumb($title);
            $psealf = new PayStubEntryAccountListFactory();
            $psealf->getById($id);
            foreach ($psealf as $psea_obj) {
                //Debug::Arr($station,'Department', __FILE__, __LINE__, __METHOD__,10);
                $data = array('id' => $psea_obj->getId(), 'status_id' => $psea_obj->getStatus(), 'type_id' => $psea_obj->getType(), 'name' => $psea_obj->getName(), 'order' => $psea_obj->getOrder(), 'accrual_id' => $psea_obj->getAccrual(), 'debit_account' => $psea_obj->getDebitAccount(), 'credit_account' => $psea_obj->getCreditAccount(), 'accrual_id' => $psea_obj->getAccrual(), 'created_date' => $psea_obj->getCreatedDate(), 'created_by' => $psea_obj->getCreatedBy(), 'updated_date' => $psea_obj->getUpdatedDate(), 'updated_by' => $psea_obj->getUpdatedBy(), 'deleted_date' => $psea_obj->getDeletedDate(), 'deleted_by' => $psea_obj->getDeletedBy());
            }
        }
        //Select box options;
        $data['status_options'] = $pseaf->getOptions('status');
        $data['type_options'] = $pseaf->getOptions('type');
        $psealf = new PayStubEntryAccountListFactory();
        $data['accrual_options'] = $psealf->getByCompanyIdAndStatusIdAndTypeIdArray($current_company->getId(), 10, array(50), TRUE);
        $smarty->assign_by_ref('data', $data);
        break;
}
$smarty->assign_by_ref('pseaf', $pseaf);
$smarty->display('pay_stub/EditPayStubEntryAccount.tpl');
 static function getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName($company_id, $type_id, $name)
 {
     $psealf = new PayStubEntryAccountListFactory();
     $psealf->getByCompanyIdAndTypeAndFuzzyName($company_id, $type_id, $name);
     if ($psealf->getRecordCount() > 0) {
         return $psealf->getCurrent()->getId();
     }
     return FALSE;
 }
Ejemplo n.º 28
0
                $last_date = $punch_obj->getPunchControlObject()->getUserDateObject()->getDateStamp();
            } else {
                $last_date = TTDate::getTime();
            }
            Debug::Text('Last Punch Date: ' . TTDate::getDate('DATE+TIME', $last_date), __FILE__, __LINE__, __METHOD__, 10);
            //Get pay period of last shift workd
            $plf = new PayPeriodListFactory();
            $pay_period_obj = $plf->getByUserIdAndEndDate($user_id, $last_date)->getCurrent();
            $pay_period_type_id = FALSE;
            if (is_object($pay_period_obj->getPayPeriodScheduleObject())) {
                $pay_period_type_id = $pay_period_obj->getPayPeriodScheduleObject()->getType();
            }
            $roe_data = array('user_id' => $user_id, 'pay_period_type_id' => $pay_period_type_id, 'first_date' => $first_date, 'last_date' => $last_date, 'pay_period_end_date' => $pay_period_obj->getEndDate());
        }
        //Select box options;
        $roe_data['code_options'] = $roef->getOptions('code');
        $ppsf = new PayPeriodScheduleFactory();
        $roe_data['pay_period_type_options'] = $ppsf->getOptions('type');
        unset($roe_data['pay_period_type_options'][5]);
        $user_options = UserListFactory::getByCompanyIdArray($current_company->getId(), FALSE);
        $smarty->assign_by_ref('user_options', $user_options);
        //PSEA accounts
        $psealf = new PayStubEntryAccountListFactory();
        $earning_pay_stub_entry_account_options = $psealf->getByCompanyIdAndStatusIdAndTypeIdArray($current_company->getId(), 10, array(10, 30, 40), TRUE);
        $smarty->assign_by_ref('earning_pay_stub_entry_account_options', $earning_pay_stub_entry_account_options);
        $smarty->assign_by_ref('roe_data', $roe_data);
        $smarty->assign_by_ref('setup_data', $setup_data);
        break;
}
$smarty->assign_by_ref('roef', $roef);
$smarty->display('roe/EditROE.tpl');