예제 #1
0
	public function editAction()
	{
		$editForm = new Project_Forms_ProjectSave();
		$projects = new Project_Models_ProjectMapper();
		$structypes = new General_Models_StructypeMapper();
		$editForm->submit->setLabel('保存修改');
		$editForm->submit2->setAttrib('class','hide');
		$structypes->populateStructypeDd($editForm);
		$projectId = $this->_getParam('id',0);
		$editForm = $projects->formValidator($editForm,1);

		if($this->getRequest()->isPost())
		{
			$formData = $this->getRequest()->getPost();
			if($editForm->isValid($formData))
			{
				$array = $projects->dataValidator($formData,1);
				$trigger = $array['trigger'];
				$errorMsg = $array['errorMsg'];
				if($trigger == 0)
				{
					$project = new Project_Models_Project();
					$project->setProjectId($projectId);
					$project->setName($editForm->getValue('name'));
					$project->setaddress($editForm->getValue('address'));
					$project->setStatus($editForm->getValue('status'));
					$project->setStructype($editForm->getValue('structype'));
					$project->setLevel($editForm->getValue('level'));
					$project->setPeriod($editForm->getValue('period'));
					$project->setStartDate($editForm->getValue('startDate'));
					$project->setContactId($editForm->getValue('contactId'));
					$project->setConstructor($editForm->getValue('constructor'));
					$project->setContractor($editForm->getValue('contractor'));
					$project->setSupervisor($editForm->getValue('supervisor'));
					$project->setDesigner($editForm->getValue('designer'));
					$project->setLicense($editForm->getValue('license'));
					$project->setAmount($editForm->getValue('amount'));
					$project->setConstrArea($editForm->getValue('constrArea'));
 					$project->setRemark($editForm->getValue('remark'));
					$projects->save($project); 
					$this->_helper->flashMessenger->addMessage('对工程: '.$project->getName().'的修改成功。');
					$this->_redirect('/project');
					}
					else
					{
						$editForm->populate($formData);
						}
				}
				else
				{
					$editForm->populate($formData);
					}
			}
			else
			{
				if($projectId >0)
				{
					$arrayProject = $projects->findArrayProject($projectId);
					$editForm->populate($arrayProject);
					}
					else
					{
						$this->_redirect('/project');
						}
				}
		$this->view->editForm = $editForm;
		$this->view->id = $projectId; 	
	}