function calcUserDateTotal() { if ($this->getEnableCalcUserDateTotal() == TRUE) { Debug::Text(' Calculating User Date Total...', __FILE__, __LINE__, __METHOD__, 10); //Add a row to the user date total table, as "worked" hours. //Edit if it already exists and is not set as override. $udtlf = new UserDateTotalListFactory(); $udtlf->getByUserDateIdAndPunchControlId($this->getUserDateID(), $this->getId()); Debug::text(' Checking for Conflicting User Date Total Records, count: ' . $udtlf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10); if ($udtlf->getRecordCount() > 0) { Debug::text(' Found Conflicting User Date Total Records, removing them before re-calc', __FILE__, __LINE__, __METHOD__, 10); foreach ($udtlf as $udt_obj) { if ($udt_obj->getOverride() == FALSE) { Debug::text(' bFound Conflicting User Date Total Records, removing them before re-calc', __FILE__, __LINE__, __METHOD__, 10); $udt_obj->Delete(); } } } Debug::text(' cFound Conflicting User Date Total Records, removing them before re-calc: PreMature: ' . (int) $this->getEnablePreMatureException(), __FILE__, __LINE__, __METHOD__, 10); if ($this->getDeleted() == FALSE) { Debug::text(' Calculating Total Time for day. Punch Control ID: ' . $this->getId(), __FILE__, __LINE__, __METHOD__, 10); $udtf = new UserDateTotalFactory(); $udtf->setUserDateID($this->getUserDateID()); $udtf->setPunchControlID($this->getId()); $udtf->setStatus(20); //Worked $udtf->setType(10); //Total $udtf->setBranch($this->getBranch()); $udtf->setDepartment($this->getDepartment()); $udtf->setJob($this->getJob()); $udtf->setJobItem($this->getJobItem()); $udtf->setQuantity($this->getQuantity()); $udtf->setBadQuantity($this->getBadQuantity()); $udtf->setTotalTime($this->getTotalTime()); $udtf->setActualTotalTime($this->getActualTotalTime()); //Let smartReCalculate handle calculating totals/exceptions. if ($udtf->isValid()) { $udtf->Save(); } } } return FALSE; }