pquery("SELECT filename, filesize FROM vtiger_notes WHERE notesid = ?", array($entityId)); $fileName = $adb->query_result($res, 0, 'filename'); $size = $adb->query_result($res, 0, 'filesize'); echo Zend_Json::encode(array('success'=>true, 'error'=>$errorMessage, 'name'=>$fileName, 'size'=>$size)); exit; } $document = CRMEntity::getInstance('Documents'); $document->retrieve_entity_info($entityId, 'Documents'); $parentId = vtlib_purify($_REQUEST['parentid']); $draft->saveEmailDocumentRel($parentId, $entityId); //link the attachment to emails $attachRes = $adb->pquery("SELECT attachmentsid FROM vtiger_seattachmentsrel WHERE crmid = ?", array($entityId)); $attachId = $adb->query_result($attachRes, 0, 'attachmentsid'); $draft->saveAttachmentRel($parentId, $attachId); $res['name'] = $document->column_fields['filename']; $res['size'] = $document->column_fields['filesize']; $res['docid'] = $entityId; $res['emailid'] = $parentId; $response = Zend_Json::encode($res); echo $response; } ?>