/**
  * This method controls what happens when you move to /note/editSave in your app.
  * Edits a note (performs the editing after form submit).
  * POST request.
  */
 public function editSave()
 {
     // All methods inside this controller are only accessible for admins (= users that have role type 7)
     Auth::checkAdminAuthentication();
     materialModel::updateMaterial();
     Redirect::to('material/index/0');
 }
Ejemplo n.º 2
0
 public function dadosAction()
 {
     $this->_helper->layout->disableLayout();
     $page = $this->_request->getParam("page", 1);
     $limit = $this->_request->getParam("rows");
     $sidx = $this->_request->getParam("sidx", 1);
     $sord = $this->_request->getParam("sord");
     $materialModel = new materialModel();
     $material = $materialModel->fetchAll();
     $count = count($material);
     if ($count > 0 && $limit > 0) {
         $total_pages = ceil($count / $limit);
     } else {
         $total_pages = 0;
     }
     if ($page > $total_pages) {
         $page = $total_pages;
     }
     $material = $materialModel->fetchAll(null, "{$sidx} {$sord}", $limit, $page * $limit - $limit);
     $response = new stdClass();
     $response->page = $page;
     $response->total = $total_pages;
     $response->records = $count;
     $i = 0;
     foreach ($material as $rows) {
         switch ($rows->fgactive) {
             case '0':
                 $fgactive = 'Ativo';
                 break;
             case '1':
                 $fgactive = 'Inativo';
                 break;
         }
         $response->rows[$i]['cell'] = array($rows->idmaterial, $rows->nmmaterial, $fgactive, $rows->cdmaterial);
         $i++;
     }
     $this->view->dados = $response;
 }