public function indexAction() { $projectId =$this->_getProjectId(); $errorMsg = null; $cpps = new Pment_Models_CppMapper(); $condition[0] = $projectId; $condition[1] = null; if($this->getRequest()->isPost()) { $formData = $this->getRequest()->getPost(); $arrayCpps = array(); $key = trim($formData['key']); if($key != null) { $condition[1] = $formData['condition']; $arrayCpps = $cpps->fetchAllJoin($key,$condition); if(count($arrayCpps) == 0) { $errorMsg = General_Models_Text::$text_searchErrorNr; } } else { $errorMsg = General_Models_Text::$text_searchErrorNi; } } else { $arrayCpps = $cpps->fetchAllJoin(null,$condition); } if(count($arrayCpps) != 0) { $pageNumber = $this->_getParam('page'); $arrayCpps->setCurrentPageNumber($pageNumber); $arrayCpps->setItemCountPerPage('20'); } $this->view->messages = $this->_helper->flashMessenger->getMessages(); $this->view->arrayCpps = $arrayCpps; $this->view->errorMsg = $errorMsg; $this->view->projectId = $projectId; }
protected function pagePmentCpp($pdf,$page,$font) { $condition[0] = $this->_getParam('projectId',0); $condition[1] = null; //put the personal information to the pdf $cpps = new Pment_Models_CppMapper(); $arrayCpps = $cpps->fetchAllJoin(null,$condition); $count = 1;//every page show approximately 20 pieces; //$arrayCount = count($arrayContacts); $totalItems = $arrayCpps->getTotalItemCount(); $arrayCpps->setItemCountPerPage($totalItems); $pageNumber = ceil($totalItems / 25); $x = 0; $y = 750; $currentpage = 1; foreach($arrayCpps as $cpp) { if($count == 1) { $page->setLineWidth(0.5); $page->drawLine(50, 770, 560, 770); $page->drawLine(50, 125, 560, 125); $page->setFont($font,13) ->drawText("编号", 50, $y, 'UTF-8') ->drawText("姓名", 100, $y, 'UTF-8') ->drawText("岗位名称", 200, $y, 'UTF-8') ->drawText("职业资格", 300, $y, 'UTF-8') ->drawText("证书编号", 400, $y, 'UTF-8') ->drawText("开始承担责任时间", 470, $y, 'UTF-8'); $time = Date("Y-m-d,H:i"); $users = new System_Models_UserMapper(); $contactId = $users->getContactId($this->getUserId()); $contacts = new Employee_Models_ContactMapper(); $contactName = $contacts->findContactName($contactId); $page->setFont($font,11) ->drawText("工程岗位信息总览", 250, 790, 'UTF-8') ->drawText("导出人:".$contactName, 50, 100, 'UTF-8') ->drawText("导出日期:".$time, 250, 100, 'UTF-8') ->drawText("页数:".$currentpage."(".$pageNumber.")", 500, 100, 'UTF-8'); } $y -= 25;$count++; $page->setFont($font, 11) ->drawText($cpp->cppId, $x+=50, $y, 'UTF-8') ->drawText($cpp->contactName, $x+=50, $y, 'UTF-8') ->drawText($cpp->postName, $x+=100, $y, 'UTF-8') ->drawText($cpp->qualif, $x+=100, $y, 'UTF-8') ->drawText($cpp->certId, $x+=100, $y, 'UTF-8') ->drawText($cpp->startDate, $x+=70, $y, 'UTF-8'); if($count >= 25) { $pdf->pages[] = $page; $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4); $count = 1; $y = 750; $currentpage++; } $x = 0; } $pdf->pages[] = $page; $name_string = "工程岗位信息总览".time().".pdf"; $name_stringEn = urlencode("工程岗位信息总览".time()).".pdf"; $url = 'tmp/'.$name_string; $urlEn='tmp/'.$name_stringEn; $pdf->save($url); return $urlEn; }