function getUserWageObject($user_wage_id)
{
    global $user_wage_obj;
    if (isset($user_wage_obj[$user_wage_id]) and is_object($user_wage_obj[$user_wage_id])) {
        return $user_wage_obj[$user_wage_id];
    } else {
        $uwlf = new UserWageListFactory();
        //This handles future wage changes properly.
        $uwlf->getByID($user_wage_id);
        if ($uwlf->getRecordCount() > 0) {
            $user_wage_obj[$user_wage_id] = $uwlf->getCurrent();
            return $user_wage_obj[$user_wage_id];
        }
        return FALSE;
    }
}
 function postInstall()
 {
     Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9);
     //Go through all employee wages and update HourlyRate to the accurate annual hourly rate.
     //Take into account wage entries that don't have the proper effective date based on the employees hire date, force a correct effective_date.
     $uwlf = new UserWageListFactory();
     $uwlf->getAll();
     if ($uwlf->getRecordCount() > 0) {
         foreach ($uwlf as $uw_obj) {
             $uw_obj->setHourlyRate($uw_obj->calcHourlyRate(time(), TRUE));
             if ($uw_obj->getWageGroup() == 0 and $uw_obj->isValidEffectiveDate($uw_obj->getEffectiveDate()) == FALSE) {
                 //Set wage effective date to employees hire date.
                 $u_obj = $uw_obj->getUserObject();
                 if (is_object($u_obj)) {
                     $uw_obj->setEffectiveDate($u_obj->getHireDate());
                 }
             }
             if ($uw_obj->isValid()) {
                 $uw_obj->Save();
             }
         }
     }
     return TRUE;
 }
 function getArrayByUserIdAndStartDateAndEndDate($user_id, $start_date = FALSE, $end_date = FALSE)
 {
     $uwlf = new UserWageListFactory();
     $uwlf->getByUserIdAndStartDateAndEndDate($user_id, $start_date, $end_date);
     foreach ($uwlf as $uw_obj) {
         $list[$uw_obj->getEffectiveDate()] = array('wage' => $uw_obj->getWage(), 'type_id' => $uw_obj->getType(), 'hourly_rate' => $uw_obj->getHourlyRate(), 'effective_date' => $uw_obj->getEffectiveDate());
     }
     if (isset($list)) {
         return $list;
     }
     return FALSE;
 }
             $tmp_pay_period_id = Misc::trimSortPrefix($tmp_pay_period_id);
             if ($i == 0) {
                 $end_date = $pay_period_end_dates[$tmp_pay_period_id];
             } else {
                 if ($pay_period_end_dates[$tmp_pay_period_id] > $end_date) {
                     $end_date = $pay_period_end_dates[$tmp_pay_period_id];
                 }
             }
             $i++;
         }
         unset($tmp_pay_period_id, $i);
     }
 } else {
     $end_date = $filter_data['end_date'];
 }
 $uwlf = new UserWageListFactory();
 $uwlf->getLastWageByUserIdAndDate($filter_data['user_id'], $end_date);
 if ($uwlf->getRecordCount() > 0) {
     foreach ($uwlf as $uw_obj) {
         $user_wage[$uw_obj->getUser()] = $uw_obj->getBaseCurrencyHourlyRate($uw_obj->getHourlyRate());
     }
 }
 unset($end_date);
 //var_dump($user_wage);
 $pending_requests = array();
 if (isset($filter_data['pay_period_ids']) and count($filter_data['pay_period_ids']) > 0) {
     //Get all pending requests
     $rlf = new RequestListFactory();
     $rlf->getSumByPayPeriodIdAndStatus($filter_data['pay_period_ids'], 30);
     if ($rlf->getRecordCount() > 0) {
         $r_obj = $rlf->getCurrent();
 $pay_period_schedule_user_map = $ppslf->getUserToPayPeriodScheduleMapArrayByListFactory($ppslf);
 $pglf = new PolicyGroupListFactory();
 $pglf->getByCompanyIdAndUserId($current_company->getId(), $filter_data['user_ids']);
 $policy_group_user_map = $pglf->getUserToPolicyGroupMapArrayByListFactory($pglf);
 $crlf = new CurrencyListFactory();
 $crlf->getByCompanyId($current_company->getId());
 $currency_options = $crlf->getArrayByListFactory($crlf, FALSE, TRUE);
 $upf = new UserPreferenceFactory();
 $language_options = TTi18n::getLanguageArray();
 $date_format_options = $upf->getOptions('date_format');
 $time_format_options = $upf->getOptions('time_format');
 $time_unit_format_options = $upf->getOptions('time_unit_format');
 $timesheet_view_options = $upf->getOptions('timesheet_view');
 $start_week_day_options = $upf->getOptions('start_week_day');
 $time_zone_options = $upf->getOptions('time_zone');
 $uwlf = new UserWageListFactory();
 $uwlf->getLastWageByUserIdAndDate($filter_data['user_ids'], TTDate::getTime());
 if ($uwlf->getRecordCount() > 0) {
     foreach ($uwlf as $uw_obj) {
         $user_wage[$uw_obj->getUser()] = array('type_id' => $uw_obj->getType(), 'type' => Option::getByKey($uw_obj->getType(), $uw_obj->getOptions('type')), 'wage' => $uw_obj->getWage(), 'effective_date' => $uw_obj->getEffectiveDate());
     }
     //var_dump($user_wage);
 }
 $udlf = new UserDeductionListFactory();
 $udlf->getByCompanyIdAndUserId($current_company->getId(), $filter_data['user_ids']);
 if ($udlf->getRecordCount() > 0) {
     foreach ($udlf as $ud_obj) {
         //Get UserValue options
         $user_value_1_options = $ud_obj->getCompanyDeductionObject()->getUserValue1Options();
         if ($ud_obj->getUserValue1() !== FALSE) {
             $tmp_user_value = $ud_obj->getUserValue1();
Beispiel #6
0
 }
 if ($user_id === FALSE) {
     echo " \t\t\tFailed!\n";
     $commit_trans = FALSE;
     $e++;
 } else {
     echo " \t\t\tSuccess!\n";
     if (isset($mapped_row['wage_type_id']) and $mapped_row['wage_type_id'] != '' and isset($mapped_row['wage']) and $mapped_row['wage'] != '') {
         echo "    Importing User Wage Information...";
         //Import Salary information
         if (isset($mapped_row['wage_effective_date'])) {
             $wage_effective_date = Misc::importCallInputParseFunction('wage_effective_date', $mapped_row['wage_effective_date'], $filtered_import_map['wage_effective_date']['default_value'], $filtered_import_map['wage_effective_date']['parse_hint']);
         } else {
             $wage_effective_date = $uf->getHireDate();
         }
         $uwlf = new UserWageListFactory();
         $uwlf->getByUserIdAndStartDateAndEndDate($user_id, $wage_effective_date, $wage_effective_date);
         if ($uwlf->getRecordCount() == 1) {
             $uwf = $uwlf->getCurrent();
             echo "(U) ";
         } else {
             $uwf = new UserWageFactory();
         }
         $uwf->setUser($user_id);
         if (isset($mapped_row['wage_type_id']) and $mapped_row['wage_type_id'] != '') {
             $uwf->setType(Misc::importCallInputParseFunction('wage_type_id', $mapped_row['wage_type_id'], $filtered_import_map['wage_type_id']['default_value'], $filtered_import_map['wage_type_id']['parse_hint']));
         }
         if (isset($mapped_row['wage']) and $mapped_row['wage'] != '') {
             $uwf->setWage(Misc::importCallInputParseFunction('wage', $mapped_row['wage'], $filtered_import_map['wage']['default_value'], $mapped_row['wage_type_id']));
         }
         if ($uwf->getType() == 20) {
             $uwlf->getByIdAndCompanyId($id, $current_company->getId());
             foreach ($uwlf as $wage) {
                 $wage->setDeleted($delete);
                 $wage->Save();
             }
         }
     }
     Redirect::Page(URLBuilder::getURL(array('user_id' => $user_id), 'UserWageList.php'));
     break;
 default:
     //Get Permission Hierarchy Children first, as this can be used for viewing, or editing.
     $user_has_default_wage = FALSE;
     $hlf = new HierarchyListFactory();
     $permission_children_ids = $hlf->getHierarchyChildrenByCompanyIdAndUserIdAndObjectTypeID($current_company->getId(), $current_user->getId());
     Debug::Arr($permission_children_ids, 'Permission Children Ids:', __FILE__, __LINE__, __METHOD__, 10);
     $uwlf = new UserWageListFactory();
     $uwlf->GetByUserIdAndCompanyId($user_id, $current_company->getId(), $current_user_prefs->getItemsPerPage(), $page, NULL, $sort_array);
     $pager = new Pager($uwlf);
     $wglf = new WageGroupListFactory();
     $wage_group_options = $wglf->getArrayByListFactory($wglf->getByCompanyId($current_company->getId()), TRUE);
     $user_obj = $ulf->getByIdAndCompanyId($user_id, $current_company->getId())->getCurrent();
     if (is_object($user_obj)) {
         $is_owner = $permission->isOwner($user_obj->getCreatedBy(), $user_obj->getID());
         $is_child = $permission->isChild($user_obj->getId(), $permission_children_ids);
         $currency_symbol = NULL;
         if (is_object($user_obj->getCurrencyObject())) {
             $currency_symbol = $user_obj->getCurrencyObject()->getSymbol();
         }
         if ($permission->Check('wage', 'view') or $permission->Check('wage', 'view_own') and $is_owner === TRUE or $permission->Check('wage', 'view_child') and $is_child === TRUE) {
             foreach ($uwlf as $wage) {
                 $wages[] = array('id' => $wage->getId(), 'user_id' => $wage->getUser(), 'wage_group_id' => $wage->getWageGroup(), 'wage_group' => Option::getByKey($wage->getWageGroup(), $wage_group_options), 'type' => Option::getByKey($wage->getType(), $wage->getOptions('type')), 'wage' => Misc::removeTrailingZeros($wage->getWage()), 'currency_symbol' => $currency_symbol, 'effective_date' => TTDate::getDate('DATE', $wage->getEffectiveDate()), 'is_owner' => $is_owner, 'is_child' => $is_child, 'deleted' => $wage->getDeleted());
Beispiel #8
0
 function getUserWageObject($user_wage_id)
 {
     if (isset($this->user_wage_obj[$user_wage_id]) and is_object($this->user_wage_obj[$user_wage_id])) {
         return $this->user_wage_obj[$user_wage_id];
     } else {
         $uwlf = new UserWageListFactory();
         $uwlf->getByID($user_wage_id);
         if ($uwlf->getRecordCount() > 0) {
             $this->user_wage_obj[$user_wage_id] = $uwlf->getCurrent();
             return $this->user_wage_obj[$user_wage_id];
         }
         return FALSE;
     }
 }
 function getUserHourlyRate($user_id, $date)
 {
     Debug::text('User ID: ' . $user_id . ' Date: ' . $date, __FILE__, __LINE__, __METHOD__, 10);
     if ($user_id == '') {
         return '0.00';
     }
     if ($date == '') {
         $date = TTDate::getTime();
     }
     $epoch = TTDate::parseDateTime($date);
     $uwlf = new UserWageListFactory();
     $uwlf->getByUserIdAndDate($user_id, $epoch);
     if ($uwlf->getRecordCount() > 0) {
         $hourly_rate = $uwlf->getCurrent()->getHourlyRate();
         return $hourly_rate;
     }
     return '0.00';
 }
Beispiel #10
0
 foreach ($ulf as $u_obj) {
     $filter_data['user_ids'][] = $u_obj->getId();
 }
 //Get title list,
 $utlf = new UserTitleListFactory();
 $user_titles = $utlf->getByCompanyIdArray($current_company->getId());
 //Get default branch list
 $blf = new BranchListFactory();
 $branch_options = $blf->getByCompanyIdArray($current_company->getId());
 $dlf = new DepartmentListFactory();
 $department_options = $dlf->getByCompanyIdArray($current_company->getId());
 /*
 	Get Wage History
 */
 if (isset($columns['wage'])) {
     $uwlf = new UserWageListFactory();
     $uwlf->getByUserIdAndCompanyIdAndStartDateAndEndDate($filter_data['user_ids'], $current_company->getId(), $filter_data['start_date'], $filter_data['end_date']);
     if ($uwlf->getRecordCount() > 0) {
         foreach ($uwlf as $uw_obj) {
             $user_wage_rows[$uw_obj->getUser()][] = array('type_id' => $uw_obj->getType(), 'type' => Option::getByKey($uw_obj->getType(), $uw_obj->getOptions('type')), 'wage' => $uw_obj->getWage(), 'currency_symbol' => $uw_obj->getUserObject()->getCurrencyObject()->getSymbol(), 'effective_date' => $uw_obj->getEffectiveDate(), 'effective_date_since' => TTDate::getHumanTimeSince($uw_obj->getEffectiveDate()));
         }
     }
 }
 /*
 	Get Attendance History
 */
 if (isset($columns['attendance'])) {
     //Get policy names.
     $oplf = new OverTimePolicyListFactory();
     $over_time_policy_arr = $oplf->getByCompanyIdArray($current_company->getId(), FALSE);
     $aplf = new AbsencePolicyListFactory();
 function isValidEffectiveDate($epoch)
 {
     //Check to see if this is the first default wage entry, or if we are editing the first record.
     if ($this->getWageGroup() != 0) {
         //If we aren't the default wage group, return valid always.
         return TRUE;
     }
     $must_validate = FALSE;
     $uwlf = new UserWageListFactory();
     $uwlf->getByUserIdAndGroupIDAndBeforeDate($this->getUser(), 0, $epoch);
     //Debug::text(' Total Rows: '. $uwlf->getRecordCount() .' User: '******' Epoch: '. $epoch , __FILE__, __LINE__, __METHOD__,10);
     if ($uwlf->getRecordCount() <= 1) {
         //If it returns one row, we need to check to see if the returned row is the current record.
         if ($uwlf->getRecordCount() == 0) {
             $must_validate = TRUE;
         } elseif ($uwlf->getRecordCount() == 1 and $this->isNew() == FALSE) {
             //Check to see if we are editing the current record.
             if (is_object($uwlf->getCurrent()) and $this->getId() == $uwlf->getCurrent()->getId()) {
                 $must_validate = TRUE;
             } else {
                 $must_validate = FALSE;
             }
         }
     }
     if ($must_validate == TRUE) {
         if (is_object($this->getUserObject()) and $this->getUserObject()->getHireDate() != '') {
             //User has hire date, make sure its before or equal to the first wage effective date.
             if ($epoch <= $this->getUserObject()->getHireDate()) {
                 return TRUE;
             } else {
                 return FALSE;
             }
         }
     }
     return TRUE;
 }
Beispiel #12
0
             $uwf->setNote($wage_data['note']);
             if ($uwf->isValid()) {
                 $uwf->Save();
                 Redirect::Page(URLBuilder::getURL(array('user_id' => $user_id, 'saved_search_id' => $saved_search_id), 'UserWageList.php'));
                 break;
             }
         } else {
             $permission->Redirect(FALSE);
             //Redirect
             exit;
         }
     }
 default:
     if (isset($id)) {
         BreadCrumb::setCrumb($title);
         $uwlf = new UserWageListFactory();
         $uwlf->getByIdAndCompanyId($id, $current_company->getId());
         foreach ($uwlf as $wage) {
             $user_obj = $ulf->getByIdAndCompanyId($wage->getUser(), $current_company->getId())->getCurrent();
             if (is_object($user_obj)) {
                 $is_owner = $permission->isOwner($user_obj->getCreatedBy(), $user_obj->getID());
                 $is_child = $permission->isChild($user_obj->getId(), $permission_children_ids);
                 if ($permission->Check('wage', 'edit') or $permission->Check('wage', 'edit_own') and $is_owner === TRUE or $permission->Check('wage', 'edit_child') and $is_child === TRUE) {
                     $user_id = $wage->getUser();
                     Debug::Text('Labor Burden Hourly Rate: ' . $wage->getLaborBurdenHourlyRate($wage->getHourlyRate()), __FILE__, __LINE__, __METHOD__, 10);
                     $wage_data = array('id' => $wage->getId(), 'user_id' => $wage->getUser(), 'wage_group_id' => $wage->getWageGroup(), 'type' => $wage->getType(), 'wage' => Misc::removeTrailingZeros($wage->getWage()), 'hourly_rate' => Misc::removeTrailingZeros($wage->getHourlyRate()), 'weekly_time' => $wage->getWeeklyTime(), 'effective_date' => $wage->getEffectiveDate(), 'labor_burden_percent' => (double) $wage->getLaborBurdenPercent(), 'note' => $wage->getNote(), 'created_date' => $wage->getCreatedDate(), 'created_by' => $wage->getCreatedBy(), 'updated_date' => $wage->getUpdatedDate(), 'updated_by' => $wage->getUpdatedBy(), 'deleted_date' => $wage->getDeletedDate(), 'deleted_by' => $wage->getDeletedBy());
                     $tmp_effective_date = TTDate::getDate('DATE', $wage->getEffectiveDate());
                 } else {
                     $permission->Redirect(FALSE);
                     //Redirect
                     exit;