function editPunch($id, $data = NULL) { if ($id == '') { return FALSE; } //Edit out punch so its on the next day. $plf = new PunchListFactory(); $plf->getById($id); if ($plf->getRecordCount() == 1) { //var_dump($data); $p_obj = $plf->getCurrent(); //$p_obj->setUser( $this->user_id ); if (isset($data['type_id'])) { $p_obj->setType($data['type_id']); } if (isset($data['status_id'])) { $p_obj->setStatus($data['status_id']); } if (isset($data['time_stamp'])) { $p_obj->setTimeStamp($data['time_stamp']); } if ($p_obj->isValid() == TRUE) { $p_obj->Save(FALSE); $p_obj->getPunchControlObject()->setPunchObject($p_obj); $p_obj->getPunchControlObject()->setEnableCalcUserDateID(TRUE); $p_obj->getPunchControlObject()->setEnableCalcSystemTotalTime(TRUE); $p_obj->getPunchControlObject()->setEnableCalcWeeklySystemTotalTime(TRUE); $p_obj->getPunchControlObject()->setEnableCalcException(TRUE); $p_obj->getPunchControlObject()->setEnablePreMatureException(TRUE); $p_obj->getPunchControlObject()->setEnableCalcUserDateTotal(TRUE); $p_obj->getPunchControlObject()->setEnableCalcTotalTime(TRUE); if ($p_obj->getPunchControlObject()->isValid() == TRUE) { $p_obj->getPunchControlObject()->Save(); return TRUE; } } } return FALSE; }
Redirect::Page(URLBuilder::getURL(array('refresh' => TRUE), '../CloseWindow.php')); break; } else { $pf->FailTransaction(); } default: if ($id != '' and $action != 'submit') { Debug::Text(' ID was passed: ' . $id, __FILE__, __LINE__, __METHOD__, 10); $pclf = new PunchControlListFactory(); $pclf->getByPunchId($id); foreach ($pclf as $pc_obj) { //Debug::Arr($station,'Department', __FILE__, __LINE__, __METHOD__,10); //Get punches $plf = new PunchListFactory(); //$plf->getByPunchControlId( $pc_obj->getId() ); $plf->getById($id); if ($plf->getRecordCount() > 0) { $p_obj = $plf->getCurrent(); } else { $punch_data = NULL; } //Get Station data. $station_data = FALSE; $slf = new StationListFactory(); if ($p_obj->getStation() != FALSE) { $slf->getById($p_obj->getStation()); if ($slf->getRecordCount() > 0) { $s_obj = $slf->getCurrent(); $station_data = array('id' => $s_obj->getId(), 'type_id' => $s_obj->getType(), 'type' => Option::getByKey($s_obj->getType(), $s_obj->getOptions('type')), 'station_id' => $s_obj->getStation(), 'source' => $s_obj->getSource(), 'description' => Misc::TruncateString($s_obj->getDescription(), 20)); } }
function changePreviousPunchType() { Debug::text(' Previous Punch to Lunch/Break...', __FILE__, __LINE__, __METHOD__, 10); if (is_object($this->getPunchObject())) { if ($this->getPunchObject()->getType() == 20 and $this->getPunchObject()->getStatus() == 10) { Debug::text(' bbPrevious Punch to Lunch...', __FILE__, __LINE__, __METHOD__, 10); $shift_data = $this->getShiftData(); if (isset($shift_data['previous_punch_key']) and isset($shift_data['punches'][$shift_data['previous_punch_key']]) and $shift_data['punches'][$shift_data['previous_punch_key']]['type_id'] != 20) { $previous_punch_arr = $shift_data['punches'][$shift_data['previous_punch_key']]; Debug::text(' Previous Punch ID: ' . $previous_punch_arr['id'], __FILE__, __LINE__, __METHOD__, 10); if ($this->getPunchObject()->inMealPolicyWindow($this->getPunchObject()->getTimeStamp(), $previous_punch_arr['time_stamp']) == TRUE) { Debug::text(' Previous Punch needs to change to Lunch...', __FILE__, __LINE__, __METHOD__, 10); $plf = new PunchListFactory(); $plf->getById($previous_punch_arr['id']); if ($plf->getRecordCount() == 1) { Debug::text(' Modifying previous punch...', __FILE__, __LINE__, __METHOD__, 10); $pf = $plf->getCurrent(); $pf->setType(20); //Lunch //If we start re-rounding this punch we have to recalculate the total for the previous punch_control too. //$p_obj->setTimeStamp( $p_obj->getTimeStamp() ); //Re-round timestamp now that its a lunch punch. if ($pf->Save(FALSE) == TRUE) { Debug::text(' Returning TRUE!', __FILE__, __LINE__, __METHOD__, 10); return TRUE; } } } } } elseif ($this->getPunchObject()->getType() == 30 and $this->getPunchObject()->getStatus() == 10) { Debug::text(' bbPrevious Punch to Break...', __FILE__, __LINE__, __METHOD__, 10); $shift_data = $this->getShiftData(); if (isset($shift_data['previous_punch_key']) and isset($shift_data['punches'][$shift_data['previous_punch_key']]) and $shift_data['punches'][$shift_data['previous_punch_key']]['type_id'] != 30) { $previous_punch_arr = $shift_data['punches'][$shift_data['previous_punch_key']]; Debug::text(' Previous Punch ID: ' . $previous_punch_arr['id'], __FILE__, __LINE__, __METHOD__, 10); if ($this->getPunchObject()->inBreakPolicyWindow($this->getPunchObject()->getTimeStamp(), $previous_punch_arr['time_stamp']) == TRUE) { Debug::text(' Previous Punch needs to change to Break...', __FILE__, __LINE__, __METHOD__, 10); $plf = new PunchListFactory(); $plf->getById($previous_punch_arr['id']); if ($plf->getRecordCount() == 1) { Debug::text(' Modifying previous punch...', __FILE__, __LINE__, __METHOD__, 10); $pf = $plf->getCurrent(); $pf->setType(30); //Break //If we start re-rounding this punch we have to recalculate the total for the previous punch_control too. //$p_obj->setTimeStamp( $p_obj->getTimeStamp() ); //Re-round timestamp now that its a lunch punch. if ($pf->Save(FALSE) == TRUE) { Debug::text(' Returning TRUE!', __FILE__, __LINE__, __METHOD__, 10); return TRUE; } } } } } } Debug::text(' Returning false!', __FILE__, __LINE__, __METHOD__, 10); return FALSE; }