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;
 }
                 $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();
         $pending_requests[$r_obj->getColumn('pay_period_id')] = $r_obj->getColumn('total');
     }
示例#4
0
     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) {
             if (isset($mapped_row['wage_weekly_time']) and $mapped_row['wage_weekly_time'] != '') {
                 $uwf->setWeeklyTime(Misc::importCallInputParseFunction('wage_weekly_time', $mapped_row['wage_weekly_time'], $filtered_import_map['wage_weekly_time']['default_value'], $filtered_import_map['wage_weekly_time']['parse_hint']));
示例#5
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';
 }
 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;
 }