コード例 #1
0
	public function editAction()
	{
		$projectId =$this->_getProjectId();
		$editForm = new Pment_Forms_SubcontractSave();
		$editForm->submit->setLabel("保存修改");
		$editForm->submit2->setAttrib('class','hide');
		$errorMsg = null;
		$subcontracts = new Pment_Models_SubcontractMapper();
		$scontrId = $this->_getParam('id',0);
		
		$subcontracts->populateSubcontractDd($editForm,$projectId);
		$editForm = $subcontracts->formValidator($editForm,1);
		if($this->getRequest()->isPost())
		{
			$formData = $this->getRequest()->getPost();
			if($editForm->isValid($formData))
			{
				$array = $subcontracts->dataValidator($formData,1);
				$trigger = $array['trigger'];
				$errorMsg = $array['errorMsg'];
				if($trigger == 0)
				{
					$subcontract = new Pment_Models_Subcontract();
					$subcontract->setScontrId($scontrId);
					$subcontract->setProjectId($projectId);
					$subcontract->setScontrType($editForm->getValue('scontrType'));
					$subcontract->setContractorId($editForm->getValue('contractorId'));
					$subcontract->setDetail($editForm->getValue('detail'));
					$subcontract->setContent($editForm->getValue('content'));
					$subcontract->setQuality($editForm->getValue('quality'));
					$subcontract->setStartDateExp($editForm->getValue('startDateExp'));
					$subcontract->setEndDateExp($editForm->getValue('endDateExp'));
					$subcontract->setStartDateAct($editForm->getValue('startDateAct'));
					$subcontract->setEndDateAct($editForm->getValue('endDateAct'));
					$subcontract->setBrConContr($editForm->getValue('brConContr'));
					$subcontract->setBrResContr($editForm->getValue('brResContr'));
					$subcontract->setBrConSContr($editForm->getValue('brConSContr'));
					$subcontract->setBrResSContr($editForm->getValue('brResSContr'));
					$subcontract->setContrAmt($editForm->getValue('contrAmt'));
					$subcontract->setGuarantee($editForm->getValue('guarantee'));
					$subcontract->setPrjMargin($editForm->getValue('prjMargin'));
					$subcontract->setPrjWarr($editForm->getValue('prjWarr'));
					$subcontract->setRemark($editForm->getValue('remark'));
					$subcontracts->save($subcontract);
					$this->_helper->flashMessenger->addMessage('对工程分包单信息的修改成功。');
					$this->_redirect('/pment/subcontract');
					}
					else
					{
						$editForm->populate($formData);
						}
				}
				else
				{
					$editForm->populate($formData);
					}
		 	}
			else
		 	{
				if($scontrId>0)
				{
					$arraySubcontract = $subcontracts->findArraySubcontract($scontrId);
					$editForm->populate($arraySubcontract);
					}
					else
					{
						$this->_redirect('/pment/subcontract');
						}
				}
		$this->view->errorMsg = $errorMsg;
		$this->view->id = $scontrId;
		$this->view->editForm = $editForm;
	}