public function findMtncJoin($mtnId,Vehicle_Models_Mtnc $mtnc) { $row = $this->getDbTable()->fetchRow('mtnId = '.$mtnId); if (0 == count($row)){ return; } $mtnc->setMtnId($row->mtnId) ->setVeId($row->veId) ->setRDate($row->rDate) ->setDetail($row->detail) ->setContactId($row->contactId) ->setMile($row->mile) ->setAmount($row->amount) ->setRemark($row->remark) ->setCTime($row->cTime); $veId = $mtnc->getVeId(); $vehicles = new Vehicle_Models_VehicleMapper(); $plateNo = $vehicles->findPlateNo($veId); $mtnc->setPlateNo($plateNo); $contacts = new Employee_Models_ContactMapper(); $contactName = $contacts->findContactName($mtnc->getContactId()); $mtnc->setContactName($contactName); }
public function editAction() { $editForm = new Vehicle_Forms_MtncSave(); $editForm->submit->setLabel('保存修改'); $editForm->submit2->setAttrib('class','hide'); $veId = $editForm->getElement('veId'); $veId->setAttrib('disabled','disabled'); $mtnId = $this->_getParam('id',0); $from = $this->_getParam('from',0); $mtncs = new Vehicle_Models_MtncMapper(); $mtncs->populateVeDd($editForm); $vId = $mtncs->findVeId($mtnId); $editForm = $mtncs->formValidator($editForm,1); $errorMsg = null; $link = null; if($from == 0) { $link = "/vehicle/mtnc"; } elseif($from == 1) { $link = '"/vehicle/index/display/id/'.$vId.'"'; } if($this->getRequest()->isPost()) { $formData = $this->getRequest()->getPost(); if($editForm->isValid($formData)) { $array = $mtncs->dataValidator($formData,$mtnId,$vId,1); $trigger = $array['trigger']; $errorMsg = $array['errorMsg']; if($trigger == 0) { $mtnc = new Vehicle_Models_Mtnc(); $mtnc->setMtnId($mtnId); $mtnc->setVeId($vId); $mtnc->setRDate($editForm->getValue('rDate')); $mtnc->setDetail($editForm->getValue('detail')); $mtnc->setContactId($editForm->getValue('contactId')); $mtnc->setMile($editForm->getValue('mile')); $mtnc->setAmount($editForm->getValue('amount')); $mtnc->setRemark($editForm->getValue('remark')); $mtncs->save($mtnc); $veId = new Vehicle_Models_VehicleMapper(); $plateNo = $veId->findPlateNo($mtnc->getVeId()); $this->_helper->flashMessenger->addMessage($plateNo.'修改成功。'); $this->_redirect($link); } else { $editForm->populate($formData); $veId->setValue($vId); } } else { $editForm->populate($formData); $veId->setValue($vId); } } else { if($mtnId > 0) { $arrayMtnc = $mtncs->findArrayMtnc($mtnId); $editForm->populate($arrayMtnc); } else { $this->_redirect($link); } } $this->view->errorMsg = $errorMsg; $this->view->editForm = $editForm; $this->view->id = $mtnId; $this->view->blink = $link; }