예제 #1
0
	public function editAction()
	{
		$errorMsg = null;
		$editForm = new Pment_Forms_PlogSave();
		$plogs = new Pment_Models_PlogMapper();
		$editForm->submit->setLabel('保存修改');
		$editForm->submit2->setAttrib('class','hide');
		$plogId = $this->_getParam('id',0);
		$projectId =$this->_getProjectId();
		$editForm = $plogs->formValidator($editForm,1);

		if($this->getRequest()->isPost())
		{
			$formData = $this->getRequest()->getPost();
			$formData['projectId'] = $projectId;
			if($editForm->isValid($formData))
			{
				$array = $plogs->dataValidator($formData,1);
				$trigger = $array['trigger'];
				$errorMsg = $array['errorMsg'];
				if($trigger == 0)
				{
					$userId = $this->_getUserId();
					$users = new System_Models_UserMapper();
					$contactId = $users->getContactId($userId); 
					$plog = new Pment_Models_Plog();
					$plog->setPlogId($plogId);
					$plog->setProjectId($projectId);
					$plog->setLogDate($editForm->getValue('logDate'));
					$plog->setWeatherAm($editForm->getValue('weatherAm'));
					$plog->setWeatherPm($editForm->getValue('weatherPm'));
					$plog->setTempHi($editForm->getValue('tempHi'));
					$plog->setTempLo($editForm->getValue('tempLo'));
					$plog->setPart($editForm->getValue('part'));
					$plog->setNumber($editForm->getValue('number'));
					$plog->setOperator($editForm->getValue('operator'));
					$plog->setForeman($editForm->getValue('foreman'));
					$plog->setSafety($editForm->getValue('safety'));
					$plog->setProblem($editForm->getValue('problem'));
					$plog->setResolve($editForm->getValue('resolve'));
					$plog->setRelatedFile($editForm->getValue('relatedFile'));
					$plog->setChangeSig($editForm->getValue('changeSig'));
					$plog->setMaterial($editForm->getValue('material'));
					$plog->setContactId($contactId);
					$plog->setRemark($editForm->getValue('remark'));
					$plogs->save($plog); 
					$this->_helper->flashMessenger->addMessage('对日志: '.$plog->getLogDate().'的修改成功。');
					$this->_redirect('/pment/plog/display/id/'.$plog->getPlogId());
					}
					else
					{
						$editForm->populate($formData);
						}
				}
				else
				{
					$editForm->populate($formData);
					}
			}
			else
			{
				if($plogId >0)
				{
					$arrayPlog = $plogs->findarrayPlog($plogId);
					$editForm->populate($arrayPlog);
					}
					else
					{
						$this->_redirect('/pment/plog');
						}
				}
		$this->view->errorMsg = $errorMsg;
		$this->view->editForm = $editForm;
		$this->view->id = $plogId; 
	}