示例#1
0
 function createPayPeriodSchedule($company_id, $user_ids)
 {
     $ppsf = new PayPeriodScheduleFactory();
     $ppsf->setCompany($company_id);
     $ppsf->setName('Bi-Weekly');
     $ppsf->setDescription('Pay every two weeks');
     $ppsf->setType(20);
     $ppsf->setStartWeekDay(0);
     //$anchor_date = TTDate::getBeginWeekEpoch( (time()-(86400*42)) ); //Start 6 weeks ago
     $anchor_date = TTDate::getBeginWeekEpoch(time() - 86400 * 14);
     //Start 6 weeks ago
     $ppsf->setAnchorDate($anchor_date);
     $ppsf->setStartDayOfWeek(TTDate::getDayOfWeek($anchor_date));
     $ppsf->setTransactionDate(7);
     $ppsf->setTransactionDateBusinessDay(TRUE);
     /*
     $ppsf->setPrimaryDate( ($anchor_date+(86400*14)) );
     $ppsf->setPrimaryDateLastDayOfMonth( FALSE );
     $ppsf->setPrimaryTransactionDate( ($anchor_date+(86400*21)) );
     $ppsf->setPrimaryTransactionDateLastDayOfMonth( FALSE );
     $ppsf->setPrimaryTransactionDateBusinessDay( TRUE );
     
     $ppsf->setSecondaryDate( ($anchor_date+(86400*28)) );
     $ppsf->setSecondaryDateLastDayOfMonth( FALSE );
     $ppsf->setSecondaryTransactionDate( ($anchor_date+(86400*35))  );
     $ppsf->setSecondaryTransactionDateLastDayOfMonth( FALSE );
     $ppsf->setSecondaryTransactionDateBusinessDay( TRUE );
     */
     $ppsf->setDayStartTime(0);
     $ppsf->setShiftAssignedDay(10);
     //Day the shift starts on.
     $ppsf->setNewDayTriggerTime(4 * 3600);
     $ppsf->setMaximumShiftTime(16 * 3600);
     if ($ppsf->isValid()) {
         $insert_id = $ppsf->Save(FALSE);
         Debug::Text('Pay Period Schedule ID: ' . $insert_id, __FILE__, __LINE__, __METHOD__, 10);
         //Dont create pay periods twice.
         $ppsf->setEnableInitialPayPeriods(FALSE);
         $ppsf->setUser($user_ids);
         $ppsf->Save();
         return $insert_id;
     }
     Debug::Text('Failed Creating Pay Period Schedule!', __FILE__, __LINE__, __METHOD__, 10);
     return FALSE;
 }
 function createPayPeriodSchedule()
 {
     $ppsf = new PayPeriodScheduleFactory();
     $ppsf->setCompany($this->company_id);
     //$ppsf->setName( 'Bi-Weekly'.rand(1000,9999) );
     $ppsf->setName('Bi-Weekly');
     $ppsf->setDescription('Pay every two weeks');
     $ppsf->setType(20);
     $ppsf->setStartWeekDay(0);
     $anchor_date = TTDate::getBeginWeekEpoch(TTDate::getBeginYearEpoch());
     //Start 6 weeks ago
     $ppsf->setAnchorDate($anchor_date);
     $ppsf->setStartDayOfWeek(TTDate::getDayOfWeek($anchor_date));
     $ppsf->setTransactionDate(7);
     $ppsf->setTransactionDateBusinessDay(TRUE);
     $ppsf->setDayStartTime(0);
     $ppsf->setNewDayTriggerTime(4 * 3600);
     $ppsf->setMaximumShiftTime(16 * 3600);
     $ppsf->setShiftAssignedDay(10);
     //$ppsf->setContinuousTime( (4*3600) );
     $ppsf->setEnableInitialPayPeriods(FALSE);
     if ($ppsf->isValid()) {
         $insert_id = $ppsf->Save(FALSE);
         Debug::Text('Pay Period Schedule ID: ' . $insert_id, __FILE__, __LINE__, __METHOD__, 10);
         $ppsf->setUser(array($this->user_id));
         $ppsf->Save();
         $this->pay_period_schedule_id = $insert_id;
         return $insert_id;
     }
     Debug::Text('Failed Creating Pay Period Schedule!', __FILE__, __LINE__, __METHOD__, 10);
     return FALSE;
 }
 function createPayPeriodSchedule($type, $start_dow, $transaction_dow, $primary_dom, $secondary_dom, $primary_transaction_dom, $secondary_transaction_dom, $transaction_bd, $day_start_time = '00:00')
 {
     $ppsf = new PayPeriodScheduleFactory();
     $ppsf->setCompany($this->company_id);
     Debug::text('zzzCompany ID: ' . $this->company_id, __FILE__, __LINE__, __METHOD__, 10);
     $ppsf->setName('test_' . rand(1000, 99999));
     $ppsf->setDescription('test');
     /*
     									20 	=> 'Bi-Weekly',
     									30  => 'Semi-Monthly',
     									40	=> 'Monthly + Advance'
     */
     $ppsf->setType($type);
     $day_start_time = TTDate::parseTimeUnit($day_start_time);
     Debug::text('parsed Day Start Time: ' . $day_start_time, __FILE__, __LINE__, __METHOD__, 10);
     $ppsf->setDayStartTime($day_start_time);
     if ($type == 10 or $type == 20) {
         $ppsf->setStartDayOfWeek($start_dow);
         $ppsf->setTransactionDate($transaction_dow);
     } elseif ($type == 30) {
         $ppsf->setPrimaryDayOfMonth($primary_dom);
         $ppsf->setSecondaryDayOfMonth($secondary_dom);
         $ppsf->setPrimaryTransactionDayOfMonth($primary_transaction_dom);
         $ppsf->setSecondaryTransactionDayOfMonth($secondary_transaction_dom);
     } elseif ($type == 50) {
         $ppsf->setPrimaryDayOfMonth($primary_dom);
         $ppsf->setPrimaryTransactionDayOfMonth($primary_transaction_dom);
     }
     $ppsf->setTransactionDateBusinessDay((bool) $transaction_bd);
     $ppsf->setTimeZone('PST8PDT');
     $ppsf->setEnableInitialPayPeriods(FALSE);
     if ($ppsf->isValid()) {
         $pp_schedule_id = $ppsf->Save();
         $ppslf = new PayPeriodScheduleListFactory();
         $ret_obj = $ppslf->getById($pp_schedule_id)->getCurrent();
         return $ret_obj;
     }
     return FALSE;
 }
示例#4
0
 function createPayPeriodSchedule()
 {
     $ppsf = new PayPeriodScheduleFactory();
     $ppsf->setCompany($this->company_id);
     $ppsf->setName('Semi-Monthly');
     $ppsf->setDescription('');
     $ppsf->setType(30);
     $ppsf->setStartWeekDay(0);
     $anchor_date = TTDate::getBeginWeekEpoch(TTDate::getBeginYearEpoch(time()) - 86400 * (7 * 6));
     //Start 6 weeks ago
     $ppsf->setAnchorDate($anchor_date);
     $ppsf->setPrimaryDayOfMonth(1);
     $ppsf->setSecondaryDayOfMonth(16);
     $ppsf->setPrimaryTransactionDayOfMonth(20);
     $ppsf->setSecondaryTransactionDayOfMonth(5);
     $ppsf->setTransactionDateBusinessDay(TRUE);
     $ppsf->setTimeZone('PST8PDT');
     $ppsf->setDayStartTime(0);
     $ppsf->setNewDayTriggerTime(4 * 3600);
     $ppsf->setMaximumShiftTime(16 * 3600);
     $ppsf->setShiftAssignedDay(10);
     $ppsf->setEnableInitialPayPeriods(FALSE);
     if ($ppsf->isValid()) {
         $insert_id = $ppsf->Save(FALSE);
         Debug::Text('Pay Period Schedule ID: ' . $insert_id, __FILE__, __LINE__, __METHOD__, 10);
         $ppsf->setUser(array($this->user_id));
         $ppsf->Save();
         $this->pay_period_schedule_id = $insert_id;
         return $insert_id;
     }
     Debug::Text('Failed Creating Pay Period Schedule!', __FILE__, __LINE__, __METHOD__, 10);
     return FALSE;
 }
    }
}
//var_dump($pay_period_schedule_data);
$ppsf = new PayPeriodScheduleFactory();
$action = Misc::findSubmitButton();
$action = strtolower($action);
switch ($action) {
    case 'submit':
        //Debug::setVerbosity(11);
        Debug::Text('Submit!', __FILE__, __LINE__, __METHOD__, 10);
        $ppsf->StartTransaction();
        $ppsf->setId($pay_period_schedule_data['id']);
        $ppsf->setCompany($current_company->getId());
        $ppsf->setName($pay_period_schedule_data['name']);
        $ppsf->setDescription($pay_period_schedule_data['description']);
        $ppsf->setType($pay_period_schedule_data['type']);
        $ppsf->setStartWeekDay($pay_period_schedule_data['start_week_day_id']);
        if ($pay_period_schedule_data['type'] == 5) {
            $ppsf->setAnnualPayPeriods($pay_period_schedule_data['annual_pay_periods']);
        }
        if ($pay_period_schedule_data['type'] == 10 or $pay_period_schedule_data['type'] == 20) {
            $ppsf->setStartDayOfWeek($pay_period_schedule_data['start_day_of_week']);
            $ppsf->setTransactionDate($pay_period_schedule_data['transaction_date']);
        } elseif ($pay_period_schedule_data['type'] == 30) {
            $ppsf->setPrimaryDayOfMonth($pay_period_schedule_data['primary_day_of_month']);
            $ppsf->setSecondaryDayOfMonth($pay_period_schedule_data['secondary_day_of_month']);
            $ppsf->setPrimaryTransactionDayOfMonth($pay_period_schedule_data['primary_transaction_day_of_month']);
            $ppsf->setSecondaryTransactionDayOfMonth($pay_period_schedule_data['secondary_transaction_day_of_month']);
        } elseif ($pay_period_schedule_data['type'] == 50) {
            $ppsf->setPrimaryDayOfMonth($pay_period_schedule_data['primary_day_of_month']);
            $ppsf->setPrimaryTransactionDayOfMonth($pay_period_schedule_data['primary_transaction_day_of_month']);