function getByPolicyGroupUserIdAndTypeId($user_id, $type_id, $where = NULL, $order = NULL) { if ($user_id == '') { return FALSE; } if ($type_id == '') { return FALSE; } if ($order == NULL) { $order = array('d.punch_type_id' => 'desc'); $strict = FALSE; } else { $strict = TRUE; } $pgf = new PolicyGroupFactory(); $pguf = new PolicyGroupUserFactory(); $cgmf = new CompanyGenericMapFactory(); $ripf = new RoundIntervalPolicyFactory(); $punch_type_relation_options = $ripf->getOptions('punch_type_relation'); if (isset($punch_type_relation_options[$type_id])) { $punch_type_ids = $punch_type_relation_options[$type_id]; $punch_type_ids[] = $type_id; } else { return FALSE; } $ph = array('user_id' => $user_id); $query = ' select d.* from ' . $pguf->getTable() . ' as a, ' . $pgf->getTable() . ' as b, ' . $cgmf->getTable() . ' as c, ' . $this->getTable() . ' as d where a.policy_group_id = b.id AND ( b.id = c.object_id AND b.company_id = c.company_id AND c.object_type_id = 130 ) AND c.map_id = d.id AND a.user_id = ? AND d.punch_type_id in ( ' . $this->getListSQL($punch_type_ids, $ph) . ') AND ( b.deleted = 0 AND d.deleted = 0 ) '; $query .= $this->getWhereSQL($where); $query .= $this->getSortSQL($order, $strict); $query .= ' LIMIT 1'; $this->rs = $this->db->Execute($query, $ph); return $this; }
$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); } //Select box options; $data['punch_type_options'] = $ripf->getOptions('punch_type'); $data['round_type_options'] = $ripf->getOptions('round_type'); $smarty->assign_by_ref('data', $data); break; } $smarty->assign_by_ref('ripf', $ripf); $smarty->display('policy/EditRoundIntervalPolicy.tpl');