diff --git a/include/controllers/default/crunchbutton/admin/restaurants/index.php b/include/controllers/default/crunchbutton/admin/restaurants/index.php index 951f42e58..d40980543 100644 --- a/include/controllers/default/crunchbutton/admin/restaurants/index.php +++ b/include/controllers/default/crunchbutton/admin/restaurants/index.php @@ -18,7 +18,12 @@ class Controller_admin_restaurants extends Crunchbutton_Controller_Account /* @var $view Cana_View */ $communities = Community::q('select * from community'); - $community = $this->restaurant->community()->items()[0]; + if (count($this->restaurant->community()->items())) { + $community = $this->restaurant->community()->items()[0]; + } else { + $community = new Crunchbutton_Community(); + $community = $community->getTest(); + } $view->communities = $communities; $view->community = $community; @@ -35,8 +40,7 @@ class Controller_admin_restaurants extends Crunchbutton_Controller_Account $this->restaurant = $restaurant; if (c::getPagePiece(2) == 'new') { - c::view()->display('admin/restaurants/restaurant'); - + $this->_restaurantForm(); } elseif ($restaurant->id_restaurant) { c::view()->restaurant = $restaurant; switch (c::getPagePiece(3)) { diff --git a/include/library/Crunchbutton/Community.php b/include/library/Crunchbutton/Community.php index 944a2c6c3..a15043aa0 100644 --- a/include/library/Crunchbutton/Community.php +++ b/include/library/Crunchbutton/Community.php @@ -75,4 +75,16 @@ class Crunchbutton_Community extends Cana_Table { ->idVar('id_community') ->load($id); } + + /** + * Returns the Testing community + * + * @return Crunchbutton_Community + */ + public function getTest() + { + $row = $this->q('SELECT * FROM community WHERE name="Testing" ')->current(); + return $row; + } + } \ No newline at end of file diff --git a/include/views/default/crunchbutton/admin/restaurants/restaurant.phtml b/include/views/default/crunchbutton/admin/restaurants/restaurant.phtml index f3e4cb835..b9528eec0 100644 --- a/include/views/default/crunchbutton/admin/restaurants/restaurant.phtml +++ b/include/views/default/crunchbutton/admin/restaurants/restaurant.phtml @@ -230,7 +230,7 @@ input.notification {width: 400px;}