public function find($trainingId,Pment_Models_Training $training) { $resultSet = $this->getDbTable()->find($trainingId); if (0 == count($resultSet)) { return; } $row = $resultSet->current(); $training->setTraId($row->traId) ->setProjectId($row->projectId) ->setTraDate($row->traDate) ->setContent($row->content) ->setName($row->name) ->setContactId($row->contactId) ->setRemark($row->remark) ->setCTime($row->cTime); $contacts = new Employee_Models_ContactMapper(); $contactName = $contacts->findContactName($training->getContactId()); $training->setContactName($contactName); }
public function editAction() { $errorMsg = null; $editForm = new Pment_Forms_TrainingSave(); $trainings = new Pment_Models_TrainingMapper(); $editForm->submit->setLabel('保存修改'); $editForm->submit2->setAttrib('class','hide'); $traId = $this->_getParam('id',0); $projectId =$this->_getProjectId(); $editForm = $trainings->formValidator($editForm,1); if($this->getRequest()->isPost()) { $formData = $this->getRequest()->getPost(); if($editForm->isValid($formData)) { $array = $trainings->dataValidator($formData,1); $trigger = $array['trigger']; $errorMsg = $array['errorMsg']; if($trigger == 0) { $userId = $this->_getUserId(); $users = new System_Models_UserMapper(); $contactId = $users->getContactId($userId); $training = new Pment_Models_Training(); $training->setTraId($traId); $training->setProjectId($projectId); $training->setTraDate($editForm->getValue('traDate')); $training->setContent($editForm->getValue('content')); $training->setName($editForm->getValue('name')); $training->setContactId($contactId); $training->setRemark($editForm->getValue('remark')); $trainings->save($training); $this->_helper->flashMessenger->addMessage('对安全培训信息的修改成功。'); $this->_redirect('/pment/training'); } else { $editForm->populate($formData); } } else { $editForm->populate($formData); } } else { if($traId >0) { $arrayTraining = $trainings->findarrayTraining($traId); $editForm->populate($arrayTraining); } else { $this->_redirect('/pment/training'); } } $this->view->errorMsg = $errorMsg; $this->view->editForm = $editForm; $this->view->id = $traId; }