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

class TestItemsController extends AppController
{
	var $name = 'TestItems';
	var $scaffold;
	var $helpers = array('Html','Text','Javascript');

	function listing($test_plan_id)
	{
		$allData = $this->TestItem->findAllByTestPlanId($test_plan_id);
		$this->set('test_plan_id',$test_plan_id);
		$this->set('data',$allData);
	}

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

	function add($test_plan_id)
	{
		$this->TestItem->id = 0;
		$this->set('data', array());
		$this->set('test_plan_id',$test_plan_id);
		$this->render('view', 'ajax');
	}

	function view($id)
	{
		$this->TestItem->id = $id;
		$data = $this->TestItem->findById($id);
		$this->set('data', $data);
		$this->render('view', 'ajax');
	}

	function save($id)
	{
		if(!is_numeric($id)){ $id = 0; }
		if($id != 0){$this->TestItem->id = $id;};
		//If the save goes through, re-render the Todolist

		if ($this->TestItem->save($this->params['data']['TestItem']))
		{
			if($id == 0) //adding new TestItem
			{
				$TestItem = $this->params['data']['TestItem'];
				$this->listing($TestItem['test_plan_id']);
				$this->render('listing','ajax');
			}
			else
			{
				$this->list_one($id);
				$this->render('list_one','ajax');
			}
		}
		else
		{
			print 'Error saving';
		}
	}


	function list_one($id)
	{
		$this->TestItem->id = $id;
		$data = $this->TestItem->findById($id);
		$this->set('data',$data);
		$this->layout = 'ajax';
	}
}
?>
Return current item: CenterFlow