public function dadosexaminationmaterialAction() { $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"); $cdexamination = $this->_request->getParam("cdexamination"); $materialModel = new MaterialModel(); $examinationmaterialData = $materialModel->fetchAll($materialModel->getMaterialByExamination($cdexamination)); $count = count($examinationmaterialData); if ($count > 0 && $limit != 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 0; } if ($page > $total_pages) { $page = $total_pages; } // $examinationData = $examinationModel->fetchAll(null, "$sidx $sord", $limit, ($page*$limit-$limit)); $responce = new stdClass(); $responce->page = $page; $responce->total = $total_pages; $responce->records = $count; $i = 0; foreach ($examinationmaterialData as $row) { $responce->rows[$i]['cdmaterial'] = $row->cdmaterial; $responce->rows[$i]['cell'] = array($row->cdexaminationmaterial, $row->cdmaterial, $row->nmmaterial, $row->nmdepartment); $i++; } $this->view->examinationmaterial = $responce; }