private function getCurrentLeavePeriod($startDate,$endDate){ $leavePeriod = new LeavePeriod(); $leavePeriod->Load("date_start <= ? and date_end >= ?",array($startDate,$endDate)); if(empty($leavePeriod->id)){ return new IceResponse(IceResponse::ERROR,"Error in leave period" ); }else{ return new IceResponse(IceResponse::SUCCESS,$leavePeriod); } }
public function getCurrentLeavePeriod($startDate, $endDate) { $leavePeriod = new LeavePeriod(); $leavePeriod->Load("date_start <= ? and date_end >= ?", array($startDate, $endDate)); if (empty($leavePeriod->id)) { $leavePeriod1 = new LeavePeriod(); $leavePeriod1->Load("date_start <= ? and date_end >= ?", array($startDate, $startDate)); $leavePeriod2 = new LeavePeriod(); $leavePeriod2->Load("date_start <= ? and date_end >= ?", array($endDate, $endDate)); if (!empty($leavePeriod1->id) && !empty($leavePeriod2->id)) { return new IceResponse(IceResponse::ERROR, "You are trying to apply leaves in two leave periods. You may apply leaves til {$leavePeriod1->date_end}. Rest you have to apply seperately"); } else { return new IceResponse(IceResponse::ERROR, "The leave period for your leave application is not defined. Please inform administrator"); } } else { return new IceResponse(IceResponse::SUCCESS, $leavePeriod); } }
private function getCurrentLeavePeriod() { $leavePeriod = new LeavePeriod(); $leavePeriod->Load("status = ?", array('Active')); if ($leavePeriod->status == 'Active') { return $leavePeriod; } return null; }