コード例 #1
0
 function createAccrualPolicy($company_id, $type)
 {
     $apf = new AccrualPolicyFactory();
     $apf->setCompany($company_id);
     switch ($type) {
         case 10:
             //Bank Time
             $apf->setName('Bank Time');
             $apf->setType(10);
             break;
         case 20:
             //Calendar Based: Vacation/PTO
             $apf->setName('Personal Time Off (PTO)/Vacation');
             $apf->setType(20);
             $apf->setApplyFrequency(10);
             $apf->setMilestoneRolloverHireDate(TRUE);
             $apf->setMinimumEmployedDays(30);
             break;
         case 30:
             //Calendar Based: Vacation/PTO
             $apf->setName('Sick Time');
             $apf->setType(20);
             $apf->setApplyFrequency(10);
             $apf->setMilestoneRolloverHireDate(TRUE);
             $apf->setMinimumEmployedDays(30);
             break;
     }
     if ($apf->isValid()) {
         $insert_id = $apf->Save();
         Debug::Text('Accrual Policy ID: ' . $insert_id, __FILE__, __LINE__, __METHOD__, 10);
         $apmf = new AccrualPolicyMilestoneFactory();
         if ($type == 20) {
             $apmf->setAccrualPolicy($insert_id);
             $apmf->setLengthOfService(1);
             $apmf->setLengthOfServiceUnit(40);
             $apmf->setAccrualRate(3600 * 8 * 5);
             $apmf->setMaximumTime(3600 * 8 * 5);
             if ($apmf->isValid()) {
                 Debug::Text('Saving Milestone...', __FILE__, __LINE__, __METHOD__, 10);
                 $apmf->Save();
             }
             $apmf->setAccrualPolicy($insert_id);
             $apmf->setLengthOfService(2);
             $apmf->setLengthOfServiceUnit(40);
             $apmf->setAccrualRate(3600 * 8 * 10);
             $apmf->setMaximumTime(3600 * 8 * 10);
             if ($apmf->isValid()) {
                 Debug::Text('Saving Milestone...', __FILE__, __LINE__, __METHOD__, 10);
                 $apmf->Save();
             }
             $apmf->setAccrualPolicy($insert_id);
             $apmf->setLengthOfService(3);
             $apmf->setLengthOfServiceUnit(40);
             $apmf->setAccrualRate(3600 * 8 * 15);
             $apmf->setMaximumTime(3600 * 8 * 15);
             if ($apmf->isValid()) {
                 Debug::Text('Saving Milestone...', __FILE__, __LINE__, __METHOD__, 10);
                 $apmf->Save();
             }
         } elseif ($type == 30) {
             $apmf->setAccrualPolicy($insert_id);
             $apmf->setLengthOfService(1);
             $apmf->setLengthOfServiceUnit(10);
             $apmf->setAccrualRate(3600 * 8 * 3);
             $apmf->setMaximumTime(3600 * 8 * 3);
             if ($apmf->isValid()) {
                 Debug::Text('Saving Milestone...', __FILE__, __LINE__, __METHOD__, 10);
                 $apmf->Save();
             }
             $apmf->setAccrualPolicy($insert_id);
             $apmf->setLengthOfService(1);
             $apmf->setLengthOfServiceUnit(40);
             $apmf->setAccrualRate(3600 * 8 * 6);
             $apmf->setMaximumTime(3600 * 8 * 6);
             if ($apmf->isValid()) {
                 Debug::Text('Saving Milestone...', __FILE__, __LINE__, __METHOD__, 10);
                 $apmf->Save();
             }
         }
         return $insert_id;
     }
     Debug::Text('Failed Creating Accrual Policy!', __FILE__, __LINE__, __METHOD__, 10);
     return FALSE;
 }
コード例 #2
0
 $apf->StartTransaction();
 $apf->setId($data['id']);
 $apf->setCompany($current_company->getId());
 $apf->setName($data['name']);
 $apf->setType($data['type_id']);
 if (isset($data['enable_pay_stub_balance_display'])) {
     $apf->setEnablePayStubBalanceDisplay(TRUE);
 } else {
     $apf->setEnablePayStubBalanceDisplay(FALSE);
 }
 $apf->setApplyFrequency($data['apply_frequency_id']);
 $apf->setApplyFrequencyMonth($data['apply_frequency_month']);
 $apf->setApplyFrequencyDayOfMonth($data['apply_frequency_day_of_month']);
 $apf->setApplyFrequencyDayOfWeek($data['apply_frequency_day_of_week']);
 if (isset($data['milestone_rollover_hire_date'])) {
     $apf->setMilestoneRolloverHireDate(TRUE);
 } else {
     $apf->setMilestoneRolloverHireDate(FALSE);
     $apf->setMilestoneRolloverMonth($data['milestone_rollover_month']);
     $apf->setMilestoneRolloverDayOfMonth($data['milestone_rollover_day_of_month']);
 }
 $apf->setMinimumEmployedDays($data['minimum_employed_days']);
 if ($apf->isValid()) {
     $ap_id = $apf->Save();
     if ($ap_id === TRUE) {
         $ap_id = $data['id'];
     }
     if (($data['type_id'] == 20 or $data['type_id'] == 30) and isset($data['milestone_rows']) and count($data['milestone_rows']) > 0) {
         foreach ($data['milestone_rows'] as $milestone_row_id => $milestone_row) {
             Debug::Text('Row ID: ' . $milestone_row_id, __FILE__, __LINE__, __METHOD__, 10);
             if ($milestone_row['accrual_rate'] > 0) {