public function indexAction() 
	{
		$projectId =$this->_getProjectId();
		$mstprgs = new Pment_Models_MstprgMapper();
		$errorMsg = null;
		$condition[0] = $projectId;
		$condition[1] = null;
		if($this->getRequest()->isPost())
		{
			$arrayMstprgs = array();
			$formData = $this->getRequest()->getPost();
			$key = trim($formData['key']);
			if($key!=null)
			{
				$condition[1] = $formData['condition'];
				$arrayMstprgs = $mstprgs->fetchAllJoin($key,$condition);
				if(count($arrayMstprgs) == 0)
				{
					$errorMsg = General_Models_Text::$text_searchErrorNr;
				}
			}
			else
			{
				$errorMsg = General_Models_Text::$text_searchErrorNi;
			}
		}
		else
		{
			$arrayMstprgs = $mstprgs->fetchAllJoin(null,$condition);
		}
		if(count($arrayMstprgs) != 0)
		{
			$pageNumber = $this->_getParam('page');
			$arrayMstprgs->setCurrentPageNumber($pageNumber);
			$arrayMstprgs->setItemCountPerPage('20');
			}
		$this->view->messages = $this->_helper->flashMessenger->getMessages();
		$this->view->arrayMstprgs = $arrayMstprgs;
		$this->view->errorMsg = $errorMsg;
		$this->view->projectId = $projectId;
		}
Esempio n. 2
0
	protected function pagePmentMsprg($pdf,$page,$font)
	{
		$condition[0] = $this->_getParam('projectId',0);
		$condition[1] = null;
		//put the personal information to the pdf
		$mstprgs = new Pment_Models_MstprgMapper();
		$arrayMstprgs = $mstprgs->fetchAllJoin(null, $condition);
		$count = 1;//every page show approximately 20 pieces;
		//$arrayCount = count($arrayContacts);
		$totalItems = $arrayMstprgs->getTotalItemCount();
		$arrayMstprgs->setItemCountPerPage($totalItems);
		$pageNumber = ceil($totalItems / 25);
		$x = 0; $y = 750;
		$currentpage = 1;
		foreach($arrayMstprgs as $mstprg)
		{
			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("开始日期", 220, $y, 'UTF-8')
						->drawText("结束日期", 320, $y, 'UTF-8')
						->drawText("工期(天)", 390, $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($mstprg->mstprgId, $x+=50, $y, 'UTF-8')
						->drawText($mstprg->task, $x+=100, $y, 'UTF-8')
						->drawText($mstprg->startDate, $x+=70, $y, 'UTF-8')
						->drawText($mstprg->endDate, $x+=100, $y, 'UTF-8')
						->drawText($mstprg->period, $x+=80, $y, 'UTF-8')
						->drawText($mstprg->contactName, $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;
	}