public function editAction() { $editForm = new Vendor_Forms_VendorSave(); $editForm->submit->setLabel("保存修改"); $editForm->submit2->setAttrib('class','hide'); $vendors = new Vendor_Models_VendorMapper(); $vId = $this->_getParam('id',0); $vtypes = new General_Models_VtypeMapper(); $vtypes->populateDd($editForm); $editForm = $vendors->formValidator($editForm,1); if($this->getRequest()->isPost()) { $formData = $this->getRequest()->getPost(); if($editForm->isValid($formData)) { $vendor = new Vendor_Models_Vendor(); $userId = $this->getUserId(); $users = new System_Models_UserMapper(); $contactId = $users->getContactId($userId); $vendor->setVId($vId); $vendor->setContact($editForm->getValue('contact')); $vendor->setName($editForm->getValue('name')); $vendor->setTypeId($editForm->getValue('typeId')); $vendor->setBusiField($editForm->getValue('busiField')); $vendor->setPhoneNo($editForm->getValue('phoneNo')); $vendor->setOtherContact($editForm->getValue('otherContact')); $vendor->setAddress($editForm->getValue('address')); $vendor->setRemark($editForm->getValue('remark')); $vendor->setContactId($contactId); $vendors->save($vendor); $this->_helper->flashMessenger->addMessage('对供应商:'.$vendor->getName().'的修改成功。'); $this->_redirect('/vendor'); } else { $editForm->populate($formData); } } else { if($vId>0) { $arrayVendor = $vendors->findArrayVendor($vId); $editForm->populate($arrayVendor); } else { $this->_redirect('/vendor/'); } } $this->view->editForm = $editForm; $this->view->id = $vId; }
public function fetchAllJoin($key=null,$condition=null) { if($condition == null) { $resultSet = $this->getDbTable()->fetchAll(); } else { $resultSet = $this->getDbTable()->search($key,$condition); } $entries = array(); foreach ($resultSet as $row) { $entry = new Vendor_Models_Vendor(); $entry ->setVId($row->vId) ->setName($row->name) ->setContact($row->contact) ->setTypeId($row->typeId) ->setPhoneNo($row->phoneNo) ->setOtherContact($row->otherContact) ->setAddress($row->address) ->setContactId($row->contactId); $contacts = new Employee_Models_ContactMapper(); $contactName = $contacts->findContactName($entry->getContactId()); $vtypes = new General_Models_VtypeMapper(); $typeName = $vtypes->findTypeName($entry->getTypeId()); $entry->setTypeName($typeName); $entry->setContactName($contactName); $entries[] = $entry; } return $entries; }