public function findComplete($contactId,Employee_Models_Contact $contact) { $result = $this->getDbTable()->find($contactId); if (0 == count($result)) { return; } $row = $result->current(); $contact->setContactId($row->contactId) ->setName($row->contactName) ->setGender($row->gender) ->setTitleName($row->titleName) ->setBirth($row->birth) ->setIdCard($row->idCard) ->setPhoneHome($row->phoneHome) ->setPhoneMob($row->phoneMob) ->setAddress($row->address) ->setZip($row->zip) ->setEthnic($row->ethnic) ->setPolitical($row->political) ->setEnroll($row->enroll) ->setEdu($row->edu) ->setDutyName($row->dutyName) ->setDeptName($row->deptName) ->setTitleSpec($row->titleSpec) ->setRemark($row->remark) ->setCTime($row->cTime) ->setResidence($row->residence) ->setProbStart($row->probStart) ->setProbEnd($row->probEnd) ->setProfile($row->profile) ->setSecurity($row->security) ->setSecIn($row->secIn) ->setSecDate($row->secDate) ->setMedical($row->medical) ->setRelation1($row->relation1) ->setName1($row->name1) ->setCompany1($row->company1) ->setAddress1($row->address1) ->setPhone1($row->phone1) ->setRelation2($row->relation2) ->setName2($row->name2) ->setCompany2($row->company2) ->setAddress2($row->address2) ->setPhone2($row->phone2) ->setRelation3($row->relation3) ->setName3($row->name3) ->setCompany3($row->company3) ->setAddress3($row->address3) ->setPhone3($row->phone3) ->setRelation4($row->relation4) ->setName4($row->name4) ->setCompany4($row->company4) ->setAddress4($row->address4) ->setPhone4($row->phone4); $age = $this->caculateAge($contact->getBirth()); $contact->setAge($age); }
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; }