public function dadosAction() { $modelMedicineModel = new MedicineModel(); $getAllMedicineData = $modelMedicineModel->fetchAll($modelMedicineModel->getAllMedicineGrid()); $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"); $medicineModel = new MedicineModel(); $medicine = $medicineModel->fetchAll(); $count = count($medicine); if ($count > 0 && $limit > 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 0; } if ($page > $total_pages) { $page = $total_pages; } $getAllMedicineData = $medicineModel->fetchAll($modelMedicineModel->getAllMedicineGrid($sidx, $sord, $limit, $page)); $response = new stdClass(); $response->page = $page; $response->total = $total_pages; $response->records = $count; $i = 0; foreach ($getAllMedicineData as $row) { $responce->rows[$i]['cdmedicine'] = $row->cdmedicine; $response->rows[$i]['cell'] = array($row->idmedicine, $row->nmmedicine, $row->nmactive, $row->idnotation); $i++; } $data = ''; $this->view->dados = $response; }