예제 #1
0
 public function dadosmethodAction()
 {
     $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");
     $methodsupplyModel = new MethodsupplyModel();
     $methodModel = new MethodModel();
     $methodData = $methodModel->fetchAll($methodModel->getAllMethod());
     //        var_dump($methodData);
     //        die;
     $count = count($methodData);
     if ($count > 0) {
         $total_pages = ceil($count / $limit);
     } else {
         $total_pages = 0;
     }
     if ($page > $total_pages) {
         $page = $total_pages;
     }
     $methodData = $methodModel->fetchAll($methodModel->getAllMethod($sidx, $sord, $limit, $page));
     $responce = new stdClass();
     $responce->page = $page;
     $responce->total = $total_pages;
     $responce->records = $count;
     $i = 0;
     $nmsupply = '';
     foreach ($methodData as $row) {
         $supply = $methodsupplyModel->fetchAll($methodsupplyModel->getSupplyByMethod($row->cdmethod));
         foreach ($supply as $rows) {
             $nmsupply .= $rows->nmsupply . ',';
         }
         $nmsupply = explode(",", $nmsupply);
         $nmsupply2 = array_slice($nmsupply, 0, count($nmsupply) - 1);
         $nmsupply3 = implode(",", $nmsupply2);
         if ($row->fgactive == '1') {
             $status = 'Ativo';
         } else {
             $status = 'Inativo';
         }
         $responce->rows[$i]['cell'] = array($row->cdmethod, $row->nmmethod, $row->cdequipment, $row->nmequipment, $nmsupply3, $row->cddocument, $row->nmdocument, $row->fgactive, $status);
         $i++;
         $nmsupply = '';
     }
     $this->view->dadosmethod = $responce;
 }
 public function dadosmethodAction()
 {
     $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");
     $methodModel = new MethodModel();
     $methodData = $methodModel->fetchAll($methodModel->getMethodByEachSupply());
     $count = count($methodData);
     if ($count > 0) {
         $total_pages = ceil($count / $limit);
     } else {
         $total_pages = 0;
     }
     if ($page > $total_pages) {
         $page = $total_pages;
     }
     $methodData = $methodModel->fetchAll(null, "{$sidx} {$sord}", $limit, $page * $limit - $limit);
     $responce = new stdClass();
     $responce->page = $page;
     $responce->total = $total_pages;
     $responce->records = $count;
     $i = 0;
     var_dump($methodData);
     foreach ($methodData as $row) {
         $responce->rows[$i]['cdmethod'] = $row->cdmethod;
         $responce->rows[$i]['cell'] = array($row->cdmethod, $row->nmmethod, $row->cdequipment, '', $row->cddocument);
         $i++;
     }
     $this->view->dadosmethod = $responce;
 }