Location: PHPKode > projects > CenterFlow > app/controllers/test_sessions_controller.php
<?

class TestSessionsController extends AppController
{
	var $name = 'TestSessions';
	var $scaffold;
	var $helpers = array('Html','Text','Javascript');
	var $uses = array('TestSession','TestPlan','TestSessionItem');

	function beforeFilter()
	{
		$this->checkSession();
	}

	function begin($test_plan_id)
	{
		if(isset($this->data))
		{
			if($this->TestSession->save($this->data['TestSession']))
			{
				$session_id = $this->TestSession->getLastInsertId();
				$this->data['TestSessionItem']['test_session_id'] = $session_id;
				$items = $this->data['TestSessionItem']['test_item_id'];
				foreach($items as $test_item_id)
				{
					$this->data['TestSessionItem']['id'] = '';
					$this->data['TestSessionItem']['test_item_id'] = $test_item_id;
					$this->data['TestSessionItem']['test_session_id'] = $session_id;
					$this->TestSession->TestSessionItem->save($this->data);
				}
				$this->set('data',$this->TestSession->read());
				$msg = ($this->data['TestSession']['id'] == '') ? 'Session created' : 'Session saved';
				$this->set('msg_type','notice');
				$this->set('msg',$msg);
				$this->redirect("/TestSessions/view/$session_id");
			}
			else
			{
				$this->set('msg_type','error');
				$this->set('msg','Save Failed');
			}
		}
		else
		{
			$data = $this->TestPlan->findById($test_plan_id);
			$this->set('person',$this->Session->read('Person'));
			$this->set('data',$data);
		}
	}

	function load($id)
	{
		if(isset($this->data))
		{
			pr($this->data);
			$saved_data = $this->data;
		}
		$data = $this->TestSession->fetchSession($id);
		$this->set('data',$data);
	}

}
?>
Return current item: CenterFlow