public static function retrieveByTime($time, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $criteria = new Criteria(VVisitDeptDailyPeer::DATABASE_NAME); $criteria->add(VVisitDeptDailyPeer::CODE, $time); $v = VVisitDeptDailyPeer::doSelect($criteria, $con); return !empty($v) > 0 ? $v[0] : null; }
public static function retrieveByPK($time_in, $department_id, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $criteria = new Criteria(); $criteria->add(VVisitDeptDailyPeer::TIME_IN, $time_in); $criteria->add(VVisitDeptDailyPeer::DEPARTMENT_ID, $department_id); $v = VVisitDeptDailyPeer::doSelect($criteria, $con); return !empty($v) ? $v[0] : null; }
public function filterSummary($c, $filters) { $filters_key = array_keys($filters); foreach ($filters_key as $key) { $value = $filters[$key]; if ($value == '' || $value == null) { continue; } $column = VVisitDeptDailyPeer::getTableMap()->getColumn($key); $name = $column->getFullyQualifiedName(); $creoleType = $column->getCreoleType(); if ($creoleType == CreoleTypes::TIMESTAMP || $creoleType == CreoleTypes::DATE) { $from = $value['from']; $to = $value['to']; if ($from != '' && $from != null) { $c->add($name, $from, Criteria::GREATER_EQUAL); } if ($to != '' && $to != null) { $c->addAnd($name, $to, Criteria::LESS_EQUAL); } } else { if ($creoleType == CreoleTypes::INTEGER || $creoleType == CreoleTypes::BIGINT) { $c->add($name, $value, Criteria::EQUAL); } else { if ($creoleType == CreoleTypes::VARCHAR || $creoleType == CreoleTypes::CHAR) { $c->add($name, "%{$value}%", Criteria::LIKE); } } } } }
public function executeListDetail() { $group_id = $this->getContext()->getUser()->getAttribute('group_id', null, 'bo'); $c = new Criteria(); $c->add(JobPeer::CODE, $this->getModuleName()); $job = JobPeer::doSelectOne($c); $acl = AclPeer::retrieveByPK($group_id, $job->getId()); #if (!$acl) $this->forward('default', 'error404'); #$this->can_edit = $acl->getEditPriv() == 1; #$this->can_remove = $acl->getRemovePriv() == 1; $c = new Criteria(); $time = $this->getRequestParameter('time_in'); $this->daily_visit = VVisitDeptDailyPeer::retrieveByTime($time); $c->add(VisitorPeer::CODE, $time, Criteria::IN); #$dept = $this->getContext()->getUser()->getAttribute('department', null, 'bo'); #$c->add(VisitorPeer::DEPARTMENT_ID, $dept->getChildRecurs(), Criteria::IN); $this->sortDetail($c); if ($this->getRequest()->hasParameter('filters')) { $filters = $this->getRequestParameter('filters'); if ($this->hasRequestParameter('member_name') && $this->getRequestParameter('member_name') == '') { $filters['MEMBER_ID'] = null; } if ($filters == 'clear') { $this->filters = null; } else { $defined_filter = false; foreach ($filters as $f) { if (is_array($f)) { if (strlen($f['from']) > 0 || strlen($f['to']) > 0) { $defined_filter = true; break; } } else { if ($f != null && $f != '') { $defined_filter = true; break; } } } if ($defined_filter) { $this->filters = $filters; $this->filterDetail($c, $this->getRequestParameter('filters')); } } } $rpp = $this->getRequestParameter('max_per_page', $this->getUser()->getAttribute('max_per_page', ParamsPeer::retrieveByCode('row_per_page')->getValue(), 'visitor')); $this->getUser()->setAttribute('max_per_page', $rpp, 'visitor'); $pager = new sfPropelPager('Visitor', $rpp); $pager->setCriteria($c); $page = $this->getRequestParameter('page', $this->getUser()->getAttribute('page', 1, 'visitor')); $this->getUser()->setAttribute('page', $page, 'visitor'); $pager->setPage($page); $pager->init(); $this->pager = $pager; $actions = array(array('name' => 'filter', 'color' => 'white')); array_unshift($actions, array('name' => 'back', 'url' => 'rpt_borang/summary', 'color' => 'green')); $this->actions = $actions; $this->subtitle = ''; }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = VVisitDeptDailyPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setTotal($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setRataRata($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setTimeIn($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setDepartmentId($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setCode($arr[$keys[4]]); } }