Пример #1
0
	public function editAction()
	{
		$errorMsg = null;
		$editForm = new Employee_Forms_ContactSave();
		$editForm->submit->setLabel('保存修改');
		$editForm->submit2->setAttrib('class','hide');
	
		$contacts = new Employee_Models_ContactMapper();
		$contacts->populateContactDd($editForm);
		$contactId = $this->_getParam('id',0);
		$editForm = $contacts->formValidator($editForm,1);

		if($this->getRequest()->isPost())
		{
			$formData = $this->getRequest()->getPost();
			if($editForm->isValid($formData))
			{
				$array = $contacts->dataValidator($formData,1);
				$trigger = $array['trigger'];
				$errorMsg = $array['errorMsg'];
				if($trigger == 0)
				{
					$contact = new Employee_Models_Contact();
					$contact->setContactId($contactId);
					$contact->setName($editForm->getValue('name'));
					$contact->setGender($editForm->getValue('gender'));
					$contact->setBirth($editForm->getValue('birth'));
					$contact->setTitleName($editForm->getValue('titleName'));
					$contact->setTitleSpec($editForm->getValue('titleSpec'));
					$contact->setDeptName($editForm->getValue('deptName'));
					$contact->setDutyName($editForm->getValue('dutyName'));
					$contact->setEdu($editForm->getValue('edu'));
					$contact->setEnroll($editForm->getValue('enroll'));
					$contact->setPolitical($editForm->getValue('political'));
					$contact->setIdCard($editForm->getValue('idCard'));
					$contact->setEthnic($editForm->getValue('ethnic'));
					$contact->setAddress($editForm->getValue('address'));
					$contact->setZip($editForm->getValue('zip'));
					$contact->setPhoneHome($editForm->getValue('phoneHome'));
					$contact->setPhoneMob($editForm->getValue('phoneMob'));
					$contact->setResidence($editForm->getValue('residence'));
					$contact->setProbStart($editForm->getValue('probStart'));
					$contact->setProbEnd($editForm->getValue('probEnd'));
					$contact->setProfile($editForm->getValue('profile'));
					$contact->setSecurity($editForm->getValue('security'));
					$contact->setSecIn($editForm->getValue('secIn'));
					$contact->setSecDate($editForm->getValue('secDate'));
					$contact->setMedical($editForm->getValue('medical'));
					$contact->setRelation1($editForm->getValue('relation1'));
					$contact->setName1($editForm->getValue('name1'));
					$contact->setCompany1($editForm->getValue('company1'));
					$contact->setAddress1($editForm->getValue('address1'));
					$contact->setPhone1($editForm->getValue('phone1'));
					$contact->setRelation2($editForm->getValue('relation2'));
					$contact->setName2($editForm->getValue('name2'));
					$contact->setCompany2($editForm->getValue('company2'));
					$contact->setAddress2($editForm->getValue('address2'));
					$contact->setPhone2($editForm->getValue('phone2'));
					$contact->setRelation3($editForm->getValue('relation3'));
					$contact->setName3($editForm->getValue('name3'));
					$contact->setCompany3($editForm->getValue('company3'));
					$contact->setAddress3($editForm->getValue('address3'));
					$contact->setPhone3($editForm->getValue('phone3'));
					$contact->setRelation4($editForm->getValue('relation4'));
					$contact->setName4($editForm->getValue('name4'));
					$contact->setCompany4($editForm->getValue('company4'));
					$contact->setAddress4($editForm->getValue('address4'));
					$contact->setPhone4($editForm->getValue('phone4'));
					$contact->setRemark($editForm->getValue('remark'));
					$contacts->save($contact);
					$this->_helper->flashMessenger->addMessage('对员工: '.$contact->getName().'的修改成功。');
					$this->_redirect('/employee');
					}
					else
					{
						$editForm->populate($formData);
						}
				}
				else
				{
					$editForm->populate($formData);
					}
			}
			else
			{
				if($contactId >0)
				{
					$arrayContact = $contacts->findArrayContact($contactId);
					$editForm->populate($arrayContact);
					}
					else
					{
						$this->_redirect('/employee');
						}
				}
		$this->view->editForm = $editForm;
		$this->view->id = $contactId;
		}