Example #1
0
 public static function create($name, $location, $message, $tinyUrl = null)
 {
     $visitor = new Visitor(null);
     $visitor->setName($name);
     $visitor->setLocation($location);
     $visitor->setMessage($message);
     $visitor->setTinyUrl($tinyUrl);
     $visitor->setGeneratedId($visitor->generateId());
     $visitor->setId($visitor->save());
     return $visitor;
 }
Example #2
0
 public function executeUpdate()
 {
     $member_code = $this->getRequestParameter('code');
     $member = MemberPeer::retrieveByCode($member_code);
     $dept = $this->getContext()->getUser()->getAttribute('department', null, 'bo');
     $now = date('dmY');
     $time = date('Y/m/d h:i');
     $i18n = new sfI18N();
     $i18n->initialize($this->getContext());
     $i18n->setCulture($this->getUser()->getCulture());
     $action_i18n = $i18n->globalMessageFormat->format('save as new');
     $action_type = $this->getRequestParameter('action_type');
     if ($member->hasVisit()) {
         //$pk = $member()->getVisitorId()->getId();
         //$visitor = VisitorPeer::retrieveByPk($this->getRequestParameter('id'));
         $member_id = $member->getId();
         $visitor = VisitorPeer::retrieveByMember($member_id);
         $this->forward404Unless($visitor);
         //$c = new Criteria();
         //$c->add(VisitorPeer::ID, $pk);
         //$visitor = VisitorPeer::doSelectOne($c);
         $visitor->setTimeOut($time);
         $visitor->save();
         return $this->redirect('default/index2');
     } else {
         $visitor = new Visitor();
         $visitor->setId($this->getRequestParameter('id'));
         $visitor->setMemberId($member->getId());
         $visitor->setTimeIn($time);
         $visitor->setDepartmentId($dept->getId());
         $visitor->setCode($now);
         $visitor->save();
         return $this->redirect('default/index2');
     }
 }