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();
         $pending_requests[$r_obj->getColumn('pay_period_id')] = $r_obj->getColumn('total');
 $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();
         } elseif ($ud_obj->getCompanyDeductionObject()->getUserValue1()) {