public function indexAction()
	{
		$projectId =$this->_getProjectId();
		$errorMsg = null;
		$cps = new Pment_Models_CpMapper();
		$addForm = new Pment_Forms_CpSave();
		$contractors = new Contract_Models_ContractorMapper();
		$addForm->submit->setLabel("添加");
		$contractors->populateContractors($addForm);

		if($this->getRequest()->isPost())
		{
			$formData = $this->getRequest()->getPost();
			$array = $cps->dataValidator($formData,$projectId);
			$trigger = $array['trigger'];
			$errorMsg = $array['errorMsg'];
			if($trigger == 0)
			{
				$cp = new Pment_Models_Cp();
				$cp->setProjectId($projectId);
				$cp->setContractorId($formData['contractorId']);
				$cps->save($cp);
				$errorMsg = "添加成功";
				}
			}
		$condition = 'projectId';
		$key = $projectId;
		$arrayCps = $cps->fetchAllJoin($key,$condition);
		if(count($arrayCps) != 0)
		{
			$pageNumber = $this->_getParam('page');
			$arrayCps->setCurrentPageNumber($pageNumber);
			$arrayCps->setItemCountPerPage('20');
			}
		$this->view->addForm = $addForm;
		$this->view->messages = $this->_helper->flashMessenger->getMessages();
		$this->view->arrayCps = $arrayCps;
		$this->view->errorMsg = $errorMsg;
	}
Exemple #2
0
	public function fetchAllContractorIds($projectId)
	{
		$resultSet = $this->getDbTable()->fetchAllContractorIds($projectId);
		$entries = array();
		foreach ($resultSet as $row) {
			$entry = new Pment_Models_Cp();

			 $entry ->setContractorId($row->contractorId)
					->setProjectId($row->projectId)
					->setContractorName($row->name);
					$entries[] = $entry;
		}
		return $entries;
		}