public function ajaxaddAction()
	{
		$this->_helper->layout()->disableLayout();
		$this->_helper->viewRenderer->setNoRender(true);
		$mtrId = $this->_getParam('mtrId',0);
		$cmt = $this->_getParam('comment',0);
		if($mtrId != null)
		{
			$userId = $this->getUserId();
			$users = new System_Models_UserMapper();
			$contactId = $users->getContactId($userId);
			$comments = new Pment_Models_CommentMapper();
			$comment = new Pment_Models_Comment();
			$comment->setMtrId($mtrId);
			$comment->setComment($cmt);
			$comment->setContactId($contactId);
			$comment->setAddDate(date('Y-m-d,H:i'));
			$id = $comments->save($comment);
			$contacts = new Employee_Models_ContactMapper();
			$contactName = $contacts->findContactName($contactId);
			$json['addDate'] = $comment->getAddDate();
			$json['contactId'] = $comment->getContactId();
			$json['contactName'] = $contactName;
			$json['cId'] = $id;
			$json = Zend_Json::encode($json);
			echo $json;
			}
			else
			{
				$this->_redirect('/pment/mplan');
				}
	}
Example #2
0
	public function save(Pment_Models_Comment $comment)
	{
		$data = array(
			'cId' => $comment->getCId(),
			'mtrId' => $comment->getMtrId(),
			'addDate' => $comment->getAddDate(),
			'comment' => $comment->getComment(),
			'contactId' => $comment->getContactId()
			);
		if (null === ($id = $comment->getCId())) {
			unset($data['cId']);
			$id = $this->getDbTable()->insert($data);
			return $id;
		} else {
			$this->getDbTable()->update($data, array('cId = ?' => $comment->getCId()));
		}
	}