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
 case 'submit':
     //Debug::setVerbosity(11);
     Debug::Text('Submit!', __FILE__, __LINE__, __METHOD__, 10);
     $ppf->StartTransaction();
     if ($data['id'] == '') {
         $ppf->setCompany($current_company->getId());
         $ppf->setStatus(10);
         //Open
     } else {
         $ppf->setId($data['id']);
     }
     $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;