Ejemplo n.º 1
0
	public function find($fileId,File_Models_File $file) 
	{
		$resultSet = $this->getDbTable()->find($fileId);

		if (0 == count($resultSet)) {

			return;
		}

		$row = $resultSet->current();
		$file->setFileId($row->file_id)
				->setName($row->file_name)
				->setDisplay($row->file_display)
				->setSize($row->file_size)
				->setSpecId($row->specId)
				->setEdition($row->file_edition)
				->setContactId($row->contactId)
				->setInFlag($row->file_inFlag)
				->setProjFlag($row->file_projFlag)
				->setProjectId($row->projectId)
				->setStatus($row->file_status)
				->setRemark($row->file_remark)
				->setType($row->file_type)
				->setParent($row->file_parent)
				->setCTime($row->file_cTime);

		$contacts = new Employee_Models_ContactMapper();
		$contactName = $contacts->findContactName($file->getContactId());
		$file->setContactName($contactName);
	}
Ejemplo n.º 2
0
	public function addAction()
	{
		$specId = $this->_getParam('id',0);
		$files = new File_Models_FileMapper();
		$errorMsg = null;
		$fileForm = new File_Forms_FileSave();
		$fileForm->setAttrib('enctype', 'multipart/form-data');
		
		$specs = new General_Models_SpecMapper();
		$arraySpecs = $specs->fetchAll();
		$spec = new General_Models_Spec();
		$specs->findSpec($specId,$spec);
		
		if($this->getRequest()->isPost())
		{
			$formData = $this->getRequest()->getPost();
			if($fileForm->isValid($formData))
			{
				if($fileForm->fileUpload->receive())
				{
					$file = new File_Models_File();
					$files = new File_Models_FileMapper();
					
					$size = $fileForm->fileUpload->getFileSize(); //size
					$fullName = $fileForm->fileUpload->getFileName();//name
					$arr = explode('/',$fullName);
					$fileName = end($arr);
					$arr2 = explode('.',$fileName);
					$fName = $arr2[0]; //displayName
					$type = $arr2[1];
					$userId = $this->getUserId();
					$users = new System_Models_UserMapper();
					$contactId = $users->getContactId($userId); //contactId
					
					$file->setName($fullName);
					$file->setDisplay($fName);
					$file->setSize($size);
					$file->setSpecId($specId);
					$file->setEdition($fileForm->getValue('edition'));
					$file->setContactId($contactId);
					$file->setInFlag($fileForm->getValue('inFlag'));
					$file->setProjFlag(0);
					$file->setProjectId(0);
					$file->setStatus($fileForm->getValue('status'));
					$file->setParent($fileForm->getValue('parent'));
					$file->setRemark($fileForm->getValue('remark'));
					$file->setType($type);
					$files->save($file);
					$this->_helper->flashMessenger->addMessage('文件上传成功。');
					$this->_redirect('/file/index/index/id/'.$specId);
					}
				}
			}
		$this->view->spec = $spec;
		$this->view->specId = $specId;
		$this->view->arraySpecs = $arraySpecs;
		$this->view->errorMsg = $errorMsg;
		$this->view->fileForm = $fileForm;
	}