public function addAction()
	{
		$addForm = new Vendor_Forms_VendorSave();
		$addForm->submit->setLabel("保存继续新建");
		$addForm->submit2->setLabel("保存返回上页");
		$errorMsg = null;
		$vendors = new Vendor_Models_VendorMapper();
		$vtypes = new General_Models_VtypeMapper();
		$vtypes->populateDd($addForm);
		$addForm = $vendors->formValidator($addForm,0);

		if($this->getRequest()->isPost())
		{
			$btClicked = $this->getRequest()->getPost('submit');
			$formData = $this->getRequest()->getPost();
			if($addForm->isValid($formData))
			{
				$array = $vendors->dataValidator($formData,0);
				$trigger = $array['trigger'];
				$errorMsg = $array['errorMsg'];
				if($trigger == 0)
				{
					$userId = $this->getUserId();
					$users = new System_Models_UserMapper();
					$contactId = $users->getContactId($userId); 
					$vendor = new Vendor_Models_Vendor();
					$vendor->setName($addForm->getValue('name'));
					$vendor->setContact($addForm->getValue('contact'));
					$vendor->setTypeId($addForm->getValue('typeId'));
					$vendor->setBusiField($addForm->getValue('busiField'));
					$vendor->setPhoneNo($addForm->getValue('phoneNo'));
					$vendor->setOtherContact($addForm->getValue('otherContact'));
					$vendor->setAddress($addForm->getValue('address'));
					$vendor->setRemark($addForm->getValue('remark'));
					$vendor->setContactId($contactId);
					$vendors->save($vendor);
					$errorMsg = General_Models_Text::$text_save_success;
					$addForm->reset();
					if($btClicked=="保存返回上页")
					{
						$this->_helper->flashMessenger->addMessage('对供应商:'.$vendor->getName().'的新建成功。');
						$this->_redirect('/vendor');
						}
					}
					else
					{
						$addForm->populate($formData);
						}
				}
				else
				{
					$addForm->populate($formData);
					}
		}
		$this->view->errorMsg = $errorMsg;
		$this->view->addForm = $addForm;
	}
Example #2
0
	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;
	}