コード例 #1
0
 function createNextPayPeriod($end_date = NULL, $offset = NULL)
 {
     if ($end_date == NULL or $end_date == '') {
         $end_date = NULL;
     }
     if ($offset == NULL or $offset == '') {
         $offset = 86400;
         //24hrs
     }
     if ($this->getType() == 5) {
         return FALSE;
     }
     Debug::text('Current TimeZone: ' . TTDate::getTimeZone(), __FILE__, __LINE__, __METHOD__, 10);
     //Handle timezones in this function rather then getNextPayPeriod()
     //Because if we set the timezone back to the original in that function, it
     //gets written to the database in the "original" timezone, not the proper timezone.
     $this->setPayPeriodTimeZone();
     Debug::text('Pay Period TimeZone: ' . TTDate::getTimeZone(), __FILE__, __LINE__, __METHOD__, 10);
     Debug::text('End Date (' . $end_date . '): ' . TTDate::getDate('DATE+TIME', $end_date), __FILE__, __LINE__, __METHOD__, 10);
     $this->getNextPayPeriod($end_date);
     Debug::text('Next pay period starts: ' . TTDate::getDate('DATE+TIME', $this->getNextStartDate()), __FILE__, __LINE__, __METHOD__, 10);
     //If the start date is within 24hrs of now, insert the next pay period.
     if ($this->getNextStartDate() <= TTDate::getTime() + $offset) {
         Debug::text('Insert new pay period. Start Date: ' . $this->getNextStartDate() . ' End Date: ' . $this->getNextEndDate(), __FILE__, __LINE__, __METHOD__, 10);
         $ppf = new PayPeriodFactory();
         $ppf->setCompany($this->getCompany());
         $ppf->setPayPeriodSchedule($this->getId());
         $ppf->setStatus(10);
         $ppf->setStartDate($this->getNextStartDate());
         $ppf->setEndDate($this->getNextEndDate());
         $ppf->setTransactionDate($this->getNextTransactionDate());
         $ppf->setPrimary($this->getNextPrimary());
         $ppf->setEnableImportData(TRUE);
         //Import punches when creating new pay periods.
         if ($ppf->isValid()) {
             $new_pay_period_id = $ppf->Save();
             Debug::text('New Pay Period ID: ' . $new_pay_period_id, __FILE__, __LINE__, __METHOD__, 10);
             if ($new_pay_period_id != '') {
                 $this->setOriginalTimeZone();
                 return TRUE;
             } else {
                 Debug::text('aSaving Pay Period Failed!', __FILE__, __LINE__, __METHOD__, 10);
             }
         } else {
             Debug::text('bSaving Pay Period Failed!', __FILE__, __LINE__, __METHOD__, 10);
         }
     } else {
         Debug::text('***NOT inserting or changing status of new pay period yet, not within offset.', __FILE__, __LINE__, __METHOD__, 10);
     }
     $this->setOriginalTimeZone();
     return FALSE;
 }
コード例 #2
0
     $ppf->setPayPeriodSchedule($data['pay_period_schedule_id']);
     if (is_object($ppf->getPayPeriodScheduleObject())) {
         $ppf->getPayPeriodScheduleObject()->setPayPeriodTimeZone();
     }
     $ppf->setStartDate($data['start_date']);
     $ppf->setEndDate($data['end_date'] + 59);
     $ppf->setTransactionDate($data['transaction_date'] + 59);
     if (isset($data['advance_end_date'])) {
         $ppf->setAdvanceEndDate($data['advance_end_date']);
     }
     if (isset($data['advance_transaction_date'])) {
         $ppf->setAdvanceTransactionDate($data['advance_transaction_date']);
     }
     $ppf->setEnableImportData(TRUE);
     //Import punches when creating new pay periods.
     if ($ppf->isValid()) {
         $ppf->Save();
         $ppf->CommitTransaction();
         Redirect::Page(URLBuilder::getURL(array('id' => $data['pay_period_schedule_id']), 'PayPeriodList.php'));
         break;
     }
     $ppf->FailTransaction();
 default:
     if (isset($id)) {
         BreadCrumb::setCrumb($title);
         $pplf = new PayPeriodListFactory();
         $pplf->getByIdAndCompanyId($id, $current_company->getId());
         foreach ($pplf as $pp_obj) {
             //Debug::Arr($station,'Department', __FILE__, __LINE__, __METHOD__,10);
             $data = array('id' => $pp_obj->getId(), 'company_id' => $pp_obj->getCompany(), 'pay_period_schedule_id' => $pp_obj->getPayPeriodSchedule(), 'pay_period_schedule_type_id' => $pp_obj->getPayPeriodScheduleObject()->getType(), 'start_date' => $pp_obj->getStartDate(), 'end_date' => $pp_obj->getEndDate(), 'transaction_date' => $pp_obj->getTransactionDate(), 'advance_end_date' => $pp_obj->getAdvanceEndDate(), 'advance_transaction_date' => $pp_obj->getAdvanceTransactionDate(), 'deleted' => $pp_obj->getDeleted(), 'created_date' => $pp_obj->getCreatedDate(), 'created_by' => $pp_obj->getCreatedBy(), 'updated_date' => $pp_obj->getUpdatedDate(), 'updated_by' => $pp_obj->getUpdatedBy(), 'deleted_date' => $pp_obj->getDeletedDate(), 'deleted_by' => $pp_obj->getDeletedBy());
         }