function getByPayPeriodScheduleIdArray($id)
 {
     $ppsulf = new PayPeriodScheduleUserListFactory();
     $ppsulf->getByPayPeriodScheduleId($id);
     foreach ($ppsulf as $user) {
         $user_list[$user->getUser()] = NULL;
     }
     if (isset($user_list)) {
         return $user_list;
     }
     return array();
 }
 function setUser($ids)
 {
     if (is_array($ids)) {
         if (!$this->isNew()) {
             //If needed, delete mappings first.
             $ppsulf = new PayPeriodScheduleUserListFactory();
             $ppsulf->getByPayPeriodScheduleId($this->getId());
             $user_ids = array();
             foreach ($ppsulf as $pay_period_schedule) {
                 $user_id = $pay_period_schedule->getUser();
                 Debug::text('Schedule ID: ' . $pay_period_schedule->getPayPeriodSchedule() . ' User ID: ' . $user_id, __FILE__, __LINE__, __METHOD__, 10);
                 //Delete users that are not selected.
                 if (!in_array($user_id, $ids)) {
                     Debug::text('Deleting User: '******'s that need to be updated.
                     Debug::text('NOT Deleting User: '******'' and isset($user_ids) and !in_array($id, $user_ids)) {
                 $ppsuf = new PayPeriodScheduleUserFactory();
                 $ppsuf->setPayPeriodSchedule($this->getId());
                 $ppsuf->setUser($id);
                 $user_obj = $ulf->getById($id)->getCurrent();
                 if ($this->Validator->isTrue('user', $ppsuf->Validator->isValid(), TTi18n::gettext('Selected Employee is already assigned to another Pay Period') . ' (' . $user_obj->getFullName() . ')')) {
                     $ppsuf->save();
                 }
             }
         }
         return TRUE;
     }
     return FALSE;
 }
 }
 if (!is_array($pay_period_ids)) {
     $pay_period_ids = array($pay_period_ids);
 }
 TTLog::addEntry($current_company->getId(), TTi18n::gettext('Notice'), TTi18n::gettext('Recalculating Company Pay Stubs for Pay Periods:') . ' ' . implode(',', $pay_period_ids), $current_user->getId(), 'pay_stub');
 $init_progress_bar = TRUE;
 foreach ($pay_period_ids as $pay_period_id) {
     Debug::text('Pay Period ID: ' . $pay_period_id, __FILE__, __LINE__, __METHOD__, 10);
     $pplf = new PayPeriodListFactory();
     $pplf->getByIdAndCompanyId($pay_period_id, $current_company->getId());
     $epoch = TTDate::getTime();
     foreach ($pplf as $pay_period_obj) {
         Debug::text('Pay Period Schedule ID: ' . $pay_period_obj->getPayPeriodSchedule(), __FILE__, __LINE__, __METHOD__, 10);
         //Grab all users for pay period
         $ppsulf = new PayPeriodScheduleUserListFactory();
         $ppsulf->getByPayPeriodScheduleId($pay_period_obj->getPayPeriodSchedule());
         $total_pay_stubs = $ppsulf->getRecordCount();
         //echo "Total Pay Stubs: $total_pay_stubs - ". ceil(100 / $total_pay_stubs) ."<Br>\n";
         if ($init_progress_bar == TRUE) {
             //InitProgressBar( ceil(100 / $total_pay_stubs) );
             InitProgressBar();
             $init_progress_bar = FALSE;
         }
         $progress_bar->setValue(0);
         $progress_bar->display();
         //Delete existing pay stub. Make sure we only
         //delete pay stubs that are the same as what we're creating.
         $pslf = new PayStubListFactory();
         $pslf->getByPayPeriodId($pay_period_obj->getId());
         foreach ($pslf as $pay_stub_obj) {
             Debug::text('Existing Pay Stub: ' . $pay_stub_obj->getId(), __FILE__, __LINE__, __METHOD__, 10);