public function fetchAllPalteNo() { $resultSet = $this->getDbTable()->fetchAllPalteNo(); $vehicles = array(); foreach ($resultSet as $row) { $vehicle = new Vehicle_Models_Vehicle(); $vehicle->setVeId($row->veId) ->setPlateNo($row->plateNo) ->setName($row->name); $vehicles[] = $vehicle; } return $vehicles; }
public function editAction() { $veId = $this->_getParam('id',0); $editForm = new Vehicle_Forms_VehicleSave(); $vehicles = new Vehicle_Models_VehicleMapper(); $editForm->submit->setLabel('保存修改'); $editForm->submit2->setAttrib('class','hide'); $plateNoEl = $editForm->getElement('plateNo'); $plateNoEl->setAttrib('disabled','disabled'); $plateNo = $vehicles->findPlateNo($veId); $plateNoEl->setValue($plateNo); $editForm = $vehicles->formValidator($editForm,1); $errorMsg = null; if($this->getRequest()->isPost()) { $formData = $this->getRequest()->getPost(); if($editForm->isValid($formData)) { $array = $vehicles->dataValidator($formData,1); $trigger = $array['trigger']; $errorMsg = $array['errorMsg']; if($trigger == 0) { $vehicle = new Vehicle_Models_Vehicle(); $vehicle->setVeId($veId); $vehicle->setPlateNo($plateNo); $vehicle->setName($editForm->getValue('name')); $vehicle->setColor($editForm->getValue('color')); $vehicle->setLicense($editForm->getValue('license')); $vehicle->setContactId($editForm->getValue('contactId')); $vehicle->setPilot($editForm->getValue('pilot')); $vehicle->setUser($editForm->getValue('user')); $vehicle->setFuelCons($editForm->getValue('fuelCons')); $vehicle->setPrice($editForm->getValue('price')); $vehicle->setBrand($editForm->getValue('brand')); $vehicle->setPDate($editForm->getValue('pDate')); $vehicle->setRemark($editForm->getValue('remark')); $vehicles->save($vehicle); $this->_helper->flashMessenger->addMessage('对'.$plateNo.'的修改成功。'); $this->_redirect('/vehicle'); } else { $editForm->populate($formData); $plateNoEl->setValue($plateNo); } } else { $editForm->populate($formData); $plateNoEl->setValue($plateNo); } } else { if($veId > 0) { $arrayVehicle = $vehicles->findArrayVehicle($veId); $editForm->populate($arrayVehicle); } else { $this->_redirect('/vehicle'); } } $this->view->errorMsg = $errorMsg; $this->view->editForm = $editForm; $this->view->id = $veId; }