function createRoundingPolicy($company_id, $type) { $ripf = new RoundIntervalPolicyFactory(); $ripf->setCompany($company_id); switch ($type) { case 10: //In $ripf->setName('5min'); $ripf->setPunchType(40); //In $ripf->setRoundType(30); //Up $ripf->setInterval(60 * 5); //5mins $ripf->setGrace(60 * 3); //3min $ripf->setStrict(FALSE); break; case 20: //Out $ripf->setName('5min'); $ripf->setPunchType(50); //In $ripf->setRoundType(10); //Down $ripf->setInterval(60 * 5); //5mins $ripf->setGrace(60 * 3); //3min $ripf->setStrict(FALSE); break; case 30: //Day total $ripf->setName('15min'); $ripf->setPunchType(120); //In $ripf->setRoundType(10); //Down $ripf->setInterval(60 * 15); //15mins $ripf->setGrace(60 * 3); //3min $ripf->setStrict(FALSE); break; case 40: //Lunch total $ripf->setName('15min'); $ripf->setPunchType(100); //In $ripf->setRoundType(10); //Down $ripf->setInterval(60 * 15); //15mins $ripf->setGrace(60 * 3); //3min $ripf->setStrict(FALSE); break; case 50: //Break total $ripf->setName('15min'); $ripf->setPunchType(110); //In $ripf->setRoundType(10); //Down $ripf->setInterval(60 * 15); //15mins $ripf->setGrace(60 * 3); //3min $ripf->setStrict(FALSE); break; } if ($ripf->isValid()) { $insert_id = $ripf->Save(); Debug::Text('Rounding Policy ID: ' . $insert_id, __FILE__, __LINE__, __METHOD__, 10); return $insert_id; } Debug::Text('Failed Creating Rounding Policy!', __FILE__, __LINE__, __METHOD__, 10); return FALSE; }
case 'submit': Debug::Text('Submit!', __FILE__, __LINE__, __METHOD__, 10); $ripf->setId($data['id']); $ripf->setCompany($current_company->getId()); $ripf->setName($data['name']); $ripf->setPunchType($data['punch_type_id']); $ripf->setRoundType($data['round_type_id']); $ripf->setInterval($data['interval']); $ripf->setGrace($data['grace']); if (isset($data['strict'])) { $ripf->setStrict(TRUE); } else { $ripf->setStrict(FALSE); } if ($ripf->isValid()) { $ripf->Save(); Redirect::Page(URLBuilder::getURL(NULL, 'RoundIntervalPolicyList.php')); break; } default: if (isset($id)) { BreadCrumb::setCrumb($title); $riplf = new RoundIntervalPolicyListFactory(); $riplf->getByIdAndCompanyID($id, $current_company->getID()); foreach ($riplf as $rip_obj) { //Debug::Arr($station,'Department', __FILE__, __LINE__, __METHOD__,10); $data = array('id' => $rip_obj->getId(), 'name' => $rip_obj->getName(), 'punch_type_id' => $rip_obj->getPunchType(), 'round_type_id' => $rip_obj->getRoundType(), 'interval' => $rip_obj->getInterval(), 'grace' => $rip_obj->getGrace(), 'strict' => $rip_obj->getStrict(), 'created_date' => $rip_obj->getCreatedDate(), 'created_by' => $rip_obj->getCreatedBy(), 'updated_date' => $rip_obj->getUpdatedDate(), 'updated_by' => $rip_obj->getUpdatedBy(), 'deleted_date' => $rip_obj->getDeletedDate(), 'deleted_by' => $rip_obj->getDeletedBy()); } } elseif ($action != 'submit') { $data = array('interval' => 900, 'grace' => 0); }