예제 #1
0
	public function indexAction()
	{
		$projects = new Project_Models_ProjectMapper();
		$vehicles = new Vehicle_Models_VehicleMapper();
		
		$arrayProjects = $projects->fetchAllJoin();
		$arrayVehicles = $vehicles->fetchAllJoin();
		
		$this->view->arrayProjects = $arrayProjects;
		$this->view->arrayVehicles = $arrayVehicles;
		
		$messages = new Admin_Models_MessageMapper();
		$validations = new Pment_Models_MplanMapper();
		
		$userId = $this->getUserId();
		$arrayMessages = $messages->fetchAllNews($userId);
		$arrayValidations = $validations->fetchAllValidations($userId);
		
		$this->view->arrayMessages = $arrayMessages;
		$this->view->arrayValidations = $arrayValidations;
	}
예제 #2
0
	public function populateVeDd($form) 
	{
		$vehicles = new Vehicle_Models_VehicleMapper();
		$arrayVehicles = $vehicles->fetchAllPalteNo();

		foreach($arrayVehicles as $vehicle)
		{
			$text = '车牌: '.$vehicle->getPlateNo()." 名称: ".$vehicle->getName();
			$form->getElement('veId')->addMultiOption($vehicle->getVeId(),$text);
		}
	}
예제 #3
0
	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;
	}
예제 #4
0
	public function editAction()
	{
		$projectId =$this->getProjectId();
		$editForm = new Vehicle_Forms_VerecordSave();
		$editForm->submit->setLabel('保存修改');
		$editForm->submit2->setAttrib('class','hide');
		$veId = $editForm->getElement('veId');
		$veId->setAttrib('disabled','disabled');

		$recordId = $this->_getParam('id',0);
		
		$verecords = new Vehicle_Models_VerecordMapper();
		$verecords->populateVeDd($editForm);
		$vId = $verecords->findVeId($recordId);
		
		$editForm = $verecords->formValidator($editForm,1);
		
		$errorMsg = null;
		if($this->getRequest()->isPost())
		{
			$formData = $this->getRequest()->getPost();
			if($editForm->isValid($formData))
			{
				$array = $verecords->dataValidator($formData,$recordId,$vId,1);
				$trigger = $array['trigger'];
				$errorMsg = $array['errorMsg'];
				if($trigger == 0)
				{
					$verecord = new Vehicle_Models_verecord();
					$verecord->setrecordId($recordId);
					$verecord->setVeId($vId);
					$verecord->setPrjFlag(1);
					$verecord->setProjectId($projectId);
					$verecord->setStartDate($editForm->getValue('startDate'));
					$verecord->setEndDate($editForm->getValue('endDate'));
					$verecord->setRoute($editForm->getValue('route'));
					$verecord->setMileBf($editForm->getValue('mileBf'));
					$verecord->setMileAf($editForm->getValue('mileAf'));
					$verecord->setPurpose($editForm->getValue('purpose'));
					$verecord->setUser($editForm->getValue('user'));
					$verecord->setMileRef($editForm->getValue('mileRef'));
					$verecord->setContactId($editForm->getValue('contactId'));
					$verecord->setAmount($editForm->getValue('amount'));
					$verecord->setRemark($editForm->getValue('remark'));
					$verecords->save($verecord);
					$veId = new Vehicle_Models_VehicleMapper();
					$plateNo = $veId->findPlateNo($verecord->getVeId());
					$this->_helper->flashMessenger->addMessage('对工程用车记录'.$plateNo.'修改成功。');
					$this->_redirect('/pment/verecord');
					}
					else
					{
						$editForm->populate($formData);
						$veId->setValue($vId);
						}
				}
				else
				{
					$editForm->populate($formData);
					$veId->setValue($vId);
					}
			}
			else
			{
				if($recordId > 0)
				{
					$arrayVerecord = $verecords->findArrayVerecord($recordId);
					$editForm->populate($arrayVerecord);
					}
					else
					{
						$this->_redirect('/pment/verecord');
						}
				}
		$this->view->errorMsg = $errorMsg;
		$this->view->editForm = $editForm;
		$this->view->id = $recordId;
	}
예제 #5
0
	public function editAction()
	{
		$editForm = new Vehicle_Forms_RepairSave();
		$editForm->submit->setLabel('保存修改');
		$editForm->submit2->setAttrib('class','hide');
		$veId = $editForm->getElement('veId');
		$veId->setAttrib('disabled','disabled');

		$repId = $this->_getParam('id',0);
		$from = $this->_getParam('from',0);
		
		$repairs = new Vehicle_Models_RepairMapper();
		$repairs->populateVeDd($editForm);
		$vId = $repairs->findVeId($repId);
		
		$editForm = $repairs->formValidator($editForm,1);
		
		$errorMsg = null;
		$link = null;
		if($from == 0)
		{
			$link = "/vehicle/repair";
			}
			elseif($from == 1)
			{
				$link = '"/vehicle/index/display/id/'.$vId.'"';
				}
		if($this->getRequest()->isPost())
		{
			$formData = $this->getRequest()->getPost();
			if($editForm->isValid($formData))
			{
				$array = $repairs->dataValidator($formData,1);
				$trigger = $array['trigger'];
				$errorMsg = $array['errorMsg'];
				if($trigger == 0)
				{
					$repair = new Vehicle_Models_Repair();
					$repair->setRepId($repId);
					$repair->setVeId($vId);
					$repair->setRDate($editForm->getValue('rDate'));
					$repair->setReason($editForm->getValue('reason'));
					$repair->setDetail($editForm->getValue('detail'));
					$repair->setContactId($editForm->getValue('contactId'));
					$repair->setSpot($editForm->getValue('spot'));
					$repair->setDescr($editForm->getValue('descr'));
					$repair->setAmount($editForm->getValue('amount'));
					$repair->setInsFlag($editForm->getValue('insFlag'));
					if($editForm->getValue('insFlag') == '1')
					{
						$repair->setIndem($editForm->getValue('indem'));
						}
						else
						{
							$repair->setIndem('');
							}
					$repair->setIndem($editForm->getValue('indem'));
					$repair->setRemark($editForm->getValue('remark'));
					$repairs->save($repair);
					$veId = new Vehicle_Models_VehicleMapper();
					$plateNo = $veId->findPlateNo($repair->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($repId > 0)
				{
					$arrayRepair = $repairs->findArrayRepair($repId);
					$editForm->populate($arrayRepair);
					}
					else
					{
						$this->_redirect($link);
						}
				}
		$this->view->errorMsg = $errorMsg;
		$this->view->editForm = $editForm;
		$this->view->id = $repId;
		$this->view->blink = $link;
	}
	public function addAction()
	{
		$drirecords = new Vehicle_Models_DrirecordMapper();
		$addForm = new Vehicle_Forms_DrirecordSave();
		$addForm->submit->setLabel('保存继续新建');
		$addForm->submit2->setLabel('保存返回上页');
		$errorMsg = null;
		$drirecords->populateVeDd($addForm);
		$drirecords->populateDate($addForm);
		
		$addForm = $drirecords->formValidator($addForm,0);
		
		if($this->getRequest()->isPost())
		{
			$btClicked = $this->getRequest()->getPost('submit');
			$formData = $this->getRequest()->getPost();
			
			if($addForm->isValid($formData))
			{
				$array = $drirecords->dataValidator($formData,null,$addForm->getValue('veId'),0);
				$trigger = $array['trigger'];
				$errorMsg = $array['errorMsg'];
				if($trigger == 0)
				{
					$drirecord = new Vehicle_Models_Drirecord();
					$drirecord->setVeId($addForm->getValue('veId'));
					$drirecord->setRYear($addForm->getValue('rYear'));
					$drirecord->setRMonth($addForm->getValue('rMonth'));
					$drirecord->setMileEarly($addForm->getValue('mileEarly'));
					$drirecord->setMileEnd($addForm->getValue('mileEnd'));
					$drirecord->setRemark($addForm->getValue('remark'));
					$drirecords->save($drirecord);
					$errorMsg = General_Models_Text::$text_save_success;
					if($btClicked == '保存继续新建')
					{
						$addForm->reset();
						}
						else
						{
							$veId = new Vehicle_Models_VehicleMapper();
							$plateNo = $veId->findPlateNo($drirecord->getVeId());
							$this->_helper->flashMessenger->addMessage($plateNo.'创建成功。');
							$this->_redirect('/vehicle/drirecord');
							}
					}
					else
					{
						$addForm->populate($formData);
						}
				}
				else
				{
					$addForm->populate($formData);
					}
			}
			$this->view->errorMsg = $errorMsg;
			$this->view->addForm = $addForm;
		}
예제 #7
0
	public function ajaxdeleteAction()
	{
		$this->_helper->layout()->disableLayout();
		$this->_helper->viewRenderer->setNoRender(true);
		$veId = $this->_getParam('id',0);
		if($veId > 0)
		{
			$vehicles = new Vehicle_Models_VehicleMapper();
			try{
				$vehicles->delete($veId);
				echo "s";
				}
				catch(Exception $e)
				{
					echo "f";
					}
			}
			else
			{
				$this->_redirect('/vehicle');
				}
		}