function Validate() { //Make sure status/type combinations are correct. if (!in_array($this->getType(), $this->getOptions('status_type', $this->getStatus()))) { Debug::text('Type doesnt match status: Type: ' . $this->getType() . ' Status: ' . $this->getStatus(), __FILE__, __LINE__, __METHOD__, 10); $this->Validator->isTRUE('type', FALSE, TTi18n::gettext('Incorrect Type')); } //Check to make sure if this is an absence row, the absence policy is actually set. if ($this->getStatus() == 30 and $this->getAbsencePolicyID() == FALSE) { $this->Validator->isTRUE('absence_policy', FALSE, TTi18n::gettext('Invalid Absence Policy')); } //Check to make sure if this is an overtime row, the overtime policy is actually set. if ($this->getStatus() == 10 and $this->getType() == 30 and $this->getOverTimePolicyID() == FALSE) { $this->Validator->isTRUE('over_time_policy', FALSE, TTi18n::gettext('Invalid Overtime Policy')); } //Check to make sure if this is an premium row, the premium policy is actually set. if ($this->getStatus() == 10 and $this->getType() == 40 and $this->getPremiumPolicyID() == FALSE) { $this->Validator->isTRUE('premium_policy', FALSE, TTi18n::gettext('Invalid Premium Policy')); } //Check to make sure if this is an meal row, the meal policy is actually set. if ($this->getStatus() == 10 and $this->getType() == 100 and $this->getMealPolicyID() == FALSE) { $this->Validator->isTRUE('meal_policy', FALSE, TTi18n::gettext('Invalid Meal Policy')); } //Make sure that we aren't trying to overwrite an already overridden entry made by the user for some special purpose. if ($this->getDeleted() == FALSE and $this->isNew() == TRUE and in_array($this->getStatus(), array(10, 20, 30))) { Debug::text('Checking over already existing overridden entries ... User Date ID: ' . $this->getUserDateID() . ' Status ID: ' . $this->getStatus() . ' Type ID: ' . $this->getType(), __FILE__, __LINE__, __METHOD__, 10); $udtlf = new UserDateTotalListFactory(); if ($this->getStatus() == 20 and $this->getPunchControlID() > 0) { $udtlf->getByUserDateIdAndStatusAndTypeAndPunchControlIdAndOverride($this->getUserDateID(), $this->getStatus(), $this->getType(), $this->getPunchControlID(), TRUE); } elseif ($this->getStatus() == 30) { $udtlf->getByUserDateIdAndStatusAndTypeAndAbsencePolicyIDAndOverride($this->getUserDateID(), $this->getStatus(), $this->getType(), $this->getAbsencePolicyID(), TRUE); } elseif ($this->getStatus() == 10 and $this->getType() == 30) { $udtlf->getByUserDateIdAndStatusAndTypeAndOvertimePolicyIDAndOverride($this->getUserDateID(), $this->getStatus(), $this->getType(), $this->getOverTimePolicyID(), TRUE); } elseif ($this->getStatus() == 10 and $this->getType() == 40) { $udtlf->getByUserDateIdAndStatusAndTypeAndPremiumPolicyIDAndOverride($this->getUserDateID(), $this->getStatus(), $this->getType(), $this->getPremiumPolicyID(), TRUE); } elseif ($this->getStatus() == 10 and $this->getType() == 100) { $udtlf->getByUserDateIdAndStatusAndTypeAndMealPolicyIDAndOverride($this->getUserDateID(), $this->getStatus(), $this->getType(), $this->getMealPolicyID(), TRUE); } elseif ($this->getStatus() == 10 and ($this->getType() == 10 or $this->getType() == 20 and $this->getPunchControlID() > 0)) { $udtlf->getByUserDateIdAndStatusAndTypeAndPunchControlIdAndOverride($this->getUserDateID(), $this->getStatus(), $this->getType(), $this->getPunchControlID(), TRUE); } Debug::text('Record Count: ' . $udtlf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10); if ($udtlf->getRecordCount() > 0) { Debug::text('Found an overridden row... NOT SAVING: ' . $udtlf->getCurrent()->getId(), __FILE__, __LINE__, __METHOD__, 10); $this->Validator->isTRUE('override', FALSE, TTi18n::gettext('Similar entry already exists, not overriding')); } } return TRUE; }