예제 #1
0
	public function addEvents() {
		$user = $this->em->find('models\User','1');
		
		$event = new models\Event;
		$event->setUser($user);
		$event->setName('Hanami');
		$event->setDescription('Hanami makan2');
		$event->setPlace('Osaka Castle');
		$event->setDeadline(new DateTime('2011/08/21'));
		$event->setCost(3000);
		$event->setTimestart(new DateTime('2011/09/01'));
		$event->setTimeend(new DateTime('2011/09/01'));
		$event->setLimitation('');
		
		$this->em->persist($event);
		
		$event = new models\Event;
		$event->setUser($user);
		$event->setName('New year');
		$event->setDescription('New year makan2');
		$event->setPlace('Onohara');
		$event->setDeadline(new DateTime('2011/12/21'));
		$event->setCost(3000);
		$event->setTimestart(new DateTime('2011/12/31'));
		$event->setTimeend(new DateTime('2012/01/01'));
		$event->setLimitation('Single only');
		
		$this->em->persist($event);
		
		$this->em->flush();
		
		$data['message'] = 'done';
		$this->load->view('home', $data);
	}
예제 #2
0
	public function submit() {
		/*$this->load->library('unit_test');
		echo $this->unit->run($this->input->post('number_of_contacts'), 4);
		return;*/
		
		if ($this->_submit_validate() === FALSE) {
			$this->add();
			return;
		}
		
		$tags = explode(',', $this->input->post('tags'));
		$tagsArray = array();
		foreach ($tags as $tag) {
			$tag1 = $this->em->getRepository('models\\EventTag')->findOneBy(array('name' => trim($tag)));
			if (!($tag1)){
				$tag1 = new models\EventTag;
				$tag1->setName(trim($tag));
				$this->em->persist($tag1);
				$this->em->flush();
			}
			$tagsArray[] = $tag1;
		}
		
		// dummy!! should get the currently logged in user
		$user1 = $this->em->find('models\User','1');
		
		$event= new models\Event;
		$event->setUser($user1);
		$event->setName($this->input->post('name'));
		$event->setDescription($this->input->post('description'));
		$event->setPlace($this->input->post('place'));
		$event->setDeadline(new DateTime(str_replace('/', '-', $this->input->post('deadline'))));
		$event->setTimestart($this->processDateTimeInput($this->input->post('time-start')));
		$event->setTimeend($this->processDateTimeInput($this->input->post('time-end')));
		$event->setCost($this->input->post('cost'));
		$event->setLimitation($this->input->post('limitation'));
		$event->setTags($tagsArray);
		$this->em->persist($event);
		$this->em->flush();

		$this->index();

	}