Exemplo n.º 1
0
	public function find($id,Pment_Models_Subcontract $subcontract)
	{
		$resultSet = $this->getDbTable()->find($id);

		if (0 == count($resultSet)) {

			return;
		}

		$row = $resultSet->current();
		$subcontract->setScontrId($row->scontrId)
				->setProjectId($row->projectId)
				->setScontrType($row->scontrType)
				->setContractorId($row->contractorId)
				->setContent($row->content)
				->setDetail($row->detail)
				->setQuality($row->quality)
				->setStartDateExp($row->startDateExp)
				->setEndDateExp($row->endDateExp)
				->setPeriodExp($row->periodExp)
				->setStartDateAct($row->startDateAct)
				->setEndDateAct($row->endDateAct)
				->setPeriodAct($row->periodAct)
				->setBrConContr($row->brConContr)
				->setBrResContr($row->brResContr)
				->setBrConSContr($row->brConSContr)
				->setBrResSContr($row->brResSContr)
				->setContrAmt($row->contrAmt)
				->setGuarantee($row->guarantee)
				->setPrjMargin($row->prjMargin)
				->setPrjWarr($row->prjWarr)
				->setRemark($row->remark)
				->setCTime($row->cTime);

		$contractors = new Contract_Models_ContractorMapper();
		$contractorName = $contractors->findContractorName($subcontract->getContractorId());
		$subcontract->setContractorName($contractorName);
	}
	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;
	}