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"); $centerModel = new CenterModel(); $supplycentre = $centerModel->fetchAll(); $count = count($supplycentre); if ($count > 0 && $limit != 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 0; } if ($page > $total_pages) { $page = $total_pages; } $supplycentre = $centerModel->fetchAll(null, "{$sidx} {$sord}", $limit, $page * $limit - $limit); $responce = new stdClass(); $responce->page = $page; $responce->total = $total_pages; $responce->records = $count; $i = 0; $companyModel = new CompanyModel(); $physicallocationModel = new PhysicallocationModel(); foreach ($supplycentre as $row) { $fgtype = ''; switch ($row->fgsupplycentretype) { case 1: $fgtype = 'Estocagem'; break; case 2: $fgtype = 'Consumo'; break; } $fgactive = ''; switch ($row->fgactive) { case 1: $fgactive = 'Ativo'; break; case 2: $fgactive = 'Inativo'; break; } $company = ''; $physicallocation = ''; $responce->rows[$i]['cdsupplycentre'] = $row->cdsupplycentre; if ($row->cdcompany != '' && $row->cdcompany != null) { $nmcompany = $companyModel->getNmCopanyByCdCompany($row->cdcompany); $company = $nmcompany->nmcompany; } if ($row->cdphysicallocation != null && $row->cdphysicallocation != '') { $nmphysicallocation = $physicallocationModel->getColorParentPhysicallocation($row->cdphysicallocation); $physicallocation = $nmphysicallocation->nmphysicallocation; } $responce->rows[$i]['cell'] = array($row->cdsupplycentre, $row->idsupplycentre, $fgtype, $company, $physicallocation, $fgactive, $row->cdcompany, $row->cdphysicallocation, $row->fgsupplycentretype); $i++; } $this->view->dados = $responce; }