Esempio n. 1
0
	public function find($cppId, Pment_Models_Cpp $cpp)
	{
		$result = $this->getDbTable()->find($cppId);

		if (0 == count($result)) {
			return;
		}

		$row = $result->current();

		$cpp->setCppId($row->cppId)
				->setContactId($row->contactId)
				->setPostId($row->postId)
				->setProjectId($row->projectId)
				->setQualif($row->qualif)
				->setStartDate($row->startDate)
				->setResponsi($row->responsi)
				->setRemark($row->remark)
				->setCertId($row->certId)
				->setCTime($row->cTime);
		$contactId = $cpp->getContactId();
		$projectId = $cpp->getProjectId();
		$postId = $cpp->getPostId();
	
		$contacts = new Employee_Models_ContactMapper();
		$cpp->setContactName($contacts->findContactName($contactId));
		
		$projects = new Project_Models_ProjectMapper();
		$cpp->setProjectName($projects->findProjectName($projectId));
				
		$posts = new General_Models_PostMapper();
		$post = $posts->findPostName($postId);
		$cpp->setPostName($post['name']);
		$cpp->setPostDetail($post['detail']);
	}
Esempio n. 2
0
	public function editAction() 
	{
		$errorMsg = null;
		$editForm = new Pment_Forms_CppSave();
		$cpps = new Pment_Models_CppMapper();
		$editForm->submit->setLabel("保存修改");
		$editForm->submit2->setAttrib('class','hide');
		$projectId =$this->_getProjectId();
		$cppId = $this->_getParam('id',0);
		$cpps->populateCppDd($editForm);
		$editForm = $cpps->formValidator($editForm,1);

		if($this->getRequest()->isPost())
		{
			$formData = $this->getRequest()->getPost();
			if($editForm->isValid($formData))
			{
				$array = $cpps->dataValidator($formData,1);
				$trigger = $array['trigger'];
				$errorMsg = $array['errorMsg'];
				if($trigger == 0)
				{
					$cpp = new Pment_Models_Cpp();
					$cpp->setCppId($cppId);
					$cpp->setPostId($editForm->getValue('postId'));
					$cpp->setContactId($editForm->getValue('contactId'));
					$cpp->setProjectId($projectId);
					$cpp->setCertId($editForm->getValue('certId'));
					$cpp->setQualif($editForm->getValue('qualif'));
					$cpp->setStartDate($editForm->getValue('startDate'));
					$cpp->setResponsi($editForm->getValue('responsi'));
					$cpp->setRemark($editForm->getValue('remark'));
					$cpps->save($cpp);
					$this->_redirect('/pment/cpp');
					}
					else
					{
						$editForm->populate($formData);
						}
				}
				else
				{
					$editForm->populate($formData);
					}
		}
		else
		{
			if($cppId > 0)
			{
				$arrayCpp = $cpps->findArrayCpp($cppId);
				$editForm->populate($arrayCpp);
				}
			else
			{
				$this->_redirect('/pment/cpp');
				}
			}
	$this->view->errorMsg = $errorMsg;
	$this->view->editForm = $editForm;
	$this->view->id = $cppId;
	}