Exemplo n.º 1
0
 public function indexAction()
 {
     $this->view->Title = "Racehorse Trainers";
     $this->view->headTitle($this->view->Title);
     $condition = array();
     $page = $this->getRequest()->getParam('page');
     list($this->view->Pager, $this->view->trainers) = Trainer::getAll($condition, $page, 50, $order = 'lastName,firstName');
 }
Exemplo n.º 2
0
 public function indexAction()
 {
     $this->view->Title = 'Trainers Listing';
     $this->view->headTitle($this->view->Title);
     $page = $this->getRequest()->getParam('page');
     $condition = array();
     $ordder = "trainersListId";
     list($this->view->Pager, $this->view->Trainers) = Trainer::getAll($condition, $page, 20, $ordder);
 }
Exemplo n.º 3
0
 public function indexAction()
 {
     $stateId = $this->getRequest()->getParam('id');
     $condition = array('stateNo =?' => $stateId);
     $page = $this->getRequest()->getParam('page');
     $request = $this->getRequest()->getParams();
     $this->view->nameplain = $request['name_plain'];
     list($this->view->Pager, $this->view->trainers) = Trainer::getAll($condition, $page, 50, $order = 'lastName,firstName');
     /** Get state name **/
     $state = State::getById($stateId);
     switch ($state->name) {
         case "NSW":
             $this->view->Title = "Racehorse Trainers in New South Wales";
             break;
         case "VIC":
             $this->view->Title = "Racehorse Trainers in Victoria";
             break;
         case "QLD":
             $this->view->Title = "Racehorse Trainers in Queensland";
             break;
         case "TAS":
             $this->view->Title = "Racehorse Trainers in Tasmania";
             break;
         case "SA":
             $this->view->Title = "Racehorse Trainers in South Australia";
             break;
         case "WA":
             $this->view->Title = "Racehorse Trainers in Western Australia";
             break;
         case "NT":
             $this->view->Title = "Racehorse Trainers in Northern Territory";
             break;
         case "ACT":
             $this->view->Title = "Racehorse Trainers in Australian Capital Territory";
             break;
     }
     $this->view->headTitle($this->view->Title);
     $this->view->active = "state";
 }
Exemplo n.º 4
0
    sendResponse($pokemon->getTrainers());
});
$app->post('/trainers/create', function () use($app) {
    $body = $app->request->getBody();
    $json = json_decode($body);
    $trainer = Trainer::create($json->name, $json->rivalId, $json->pokemon, $json->badgeIds);
    sendResponse($trainer);
});
$app->post('/trainers/delete', function () use($app) {
    $body = $app->request->getBody();
    $json = json_decode($body);
    $trainer = Trainer::delete($json->id);
    sendResponse($trainer);
});
$app->get('/trainers', function () use($app) {
    sendResponse(Trainer::getAll());
});
$app->post('/trainers/:id/pokemon/add', function ($id) use($app) {
    $body = $app->request->getBody();
    $json = json_decode($body);
    $trainer = Trainer::getById($id);
    $result = $trainer->addPokemon($json->pokemonId, $json->pokemonLevel);
    sendResponse($result);
});
$app->post('/trainers/:id/pokemon/remove', function ($id) use($app) {
    $body = $app->request->getBody();
    $json = json_decode($body);
    $trainer = Trainer::getById($id);
    $result = $trainer->removePokemon($json->pokemonId);
    sendResponse($result);
});
Exemplo n.º 5
0
 public function indexAction()
 {
     $page = $this->getRequest()->getParam('page');
     if (!$page) {
         $_SESSION['Condition'] = "";
     }
     if ($this->getRequest()->isPost()) {
         $request = $this->getRequest()->getParams();
         $error = $this->_checkFormSearch($request);
         if (count($error) == 0) {
             if ($request['textSearch']) {
                 $condition = array();
                 if ($request['option'] == "firstname") {
                     $condition['firstName LIKE ?'] = "%{$request['textSearch']}%";
                 }
                 if ($request['option'] == "lastname") {
                     $condition['lastName LIKE ?'] = "%{$request['textSearch']}%";
                 }
                 if ($request['option'] == "city") {
                     $condition['city LIKE ?'] = "%{$request['textSearch']}%";
                 }
                 $session_condition = array();
                 $session_condition['option'] = $request['option'];
                 $session_condition['textSearch'] = $request['textSearch'];
                 $_SESSION['Condition'] = $session_condition;
                 $this->view->Title = 'Trainers Listing';
                 $this->view->headTitle($this->view->Title);
                 list($this->view->Pager, $this->view->Trainers) = Trainer::getAllBySearch($condition, 1, 20, $order = 'firstName, lastName');
             }
         } else {
             $this->view->Title = 'Trainers Listing';
             $this->view->headTitle($this->view->Title);
             $condition = array();
             $ordder = "trainersListId";
             list($this->view->Pager, $this->view->Trainers) = Trainer::getAll($condition, $page, 20, $order = 'firstName, lastName');
             $this->view->error = $error;
         }
     } else {
         if (!$_SESSION['Condition']['textSearch'] || !$_SESSION['Condition']['option']) {
             $this->view->Title = 'Trainers Listing';
             $this->view->headTitle($this->view->Title);
             $condition = array();
             $ordder = "trainersListId";
             list($this->view->Pager, $this->view->Trainers) = Trainer::getAll($condition, $page, 20, $order = 'firstName, lastName');
         } else {
             $condition = array();
             if ($_SESSION['Condition']['option'] == "firstname") {
                 $condition['firstName LIKE ?'] = "%{$_SESSION['Condition']['textSearch']}%";
             }
             if ($_SESSION['Condition']['option'] == "lastname") {
                 $condition['lastName LIKE ?'] = "%{$_SESSION['Condition']['textSearch']}%";
             }
             if ($_SESSION['Condition']['option'] == "city") {
                 $condition['city LIKE ?'] = "%{$_SESSION['Condition']['textSearch']}%";
             }
             $this->view->Title = 'Trainers Listing';
             $this->view->headTitle($this->view->Title);
             list($this->view->Pager, $this->view->Trainers) = Trainer::getAll($condition, $page, 20, $order = 'firstName, lastName');
         }
     }
 }