Commit 34f51a07 authored by Nileema's avatar Nileema

-- CRM-13624 Display paper clip icon for file attachments for Note and CiviHR profiles

----------------------------------------
* CRM-13624: All Tabs - Paperclip Icon
  http://issues.civicrm.org/jira/browse/CRM-13624
parent 19caf821
......@@ -131,6 +131,10 @@ class CRM_Contact_Page_View_Note extends CRM_Core_Page {
$contact->fetch();
$values[$note->id]['createdBy'] = $contact->display_name;
$values[$note->id]['comment_count'] = CRM_Core_BAO_Note::getChildCount($note->id);
// paper icon view for attachments part
$paperIconAttachmentInfo = CRM_Core_BAO_File::paperIconAttachment('civicrm_note', $note->id);
$values[$note->id]['attachment'] = $paperIconAttachmentInfo;
}
}
......
......@@ -399,7 +399,8 @@ SELECT cg.table_name,
cg.id as groupID,
cg.is_multiple,
cf.column_name,
cf.id as fieldID
cf.id as fieldID,
cf.data_type as fieldDataType
FROM civicrm_custom_group cg,
civicrm_custom_field cf
WHERE cf.custom_group_id = cg.id
......@@ -419,6 +420,7 @@ AND $cond
$fields[$dao->table_name][] = $dao->fieldID;
$select[$dao->table_name][] = "{$dao->column_name} AS custom_{$dao->fieldID}";
$isMultiple[$dao->table_name] = $dao->is_multiple ? TRUE : FALSE;
$file[$dao->table_name][$dao->fieldID] = $dao->fieldDataType;
}
$result = array();
......@@ -430,13 +432,29 @@ AND $cond
$fieldName = "custom_{$fieldID}";
if ($isMultiple[$tableName]) {
if ($formatMultiRecordField) {
$result["{$dao->id}"]["{$fieldID}"] = $dao->$fieldName;
if($file[$tableName][$fieldID] == 'File') {
if($fileid = $dao->$fieldName) {
$fileurl = CRM_Core_BAO_File::paperIconAttachment($tableName,$entityID);
$result["{$dao->id}"]["{$fieldID}"] = $fileurl[$dao->$fieldName];
}
}
else {
$result["{$dao->id}"]["{$fieldID}"] = $dao->$fieldName;
}
} else {
$result["{$fieldID}_{$dao->id}"] = $dao->$fieldName;
}
}
else {
$result[$fieldID] = $dao->$fieldName;
if($file[$tableName][$fieldID] == 'File') {
if($fileid = $dao->$fieldName) {
$fileurl = CRM_Core_BAO_File::paperIconAttachment($tableName,$entityID);
$result[$fieldID] = $fileurl[$dao->$fieldName];
}
}
else {
$result[$fieldID] = $dao->$fieldName;
}
}
}
}
......
......@@ -556,5 +556,52 @@
CRM_Core_BAO_File::deleteEntityFile($params['entityTable'], $params['entityID'], NULL, $params['fileID']);
}
}
/**
* function to display paper icon for a file attachment -- CRM-13624
*
* @static
* @access public
*/
static function paperIconAttachment( $entityTable, $entityID ) {
if (empty($entityTable) || !$entityID) {
$results = NULL;
return $results;
}
$currentAttachmentInfo = self::getEntityFile( $entityTable, $entityID );
foreach($currentAttachmentInfo as $fileKey => $fileValue) {
$fileID = $fileValue['fileID'];
$fileType = $fileValue['mime_type'];
$eid = $entityID;
if($fileID) {
if ($fileType == 'image/jpeg' ||
$fileType == 'image/pjpeg' ||
$fileType == 'image/gif' ||
$fileType == 'image/x-png' ||
$fileType == 'image/png'
) {
$url = $fileValue['url'];
$alt = $fileValue['cleanName'];
$file_url[$fileID] = "
<a href=\"$url\" class='crm-image-popup'>
<div class='icon paper-icon' title=\"$alt\" alt=\"$alt\"></div>
</a>";
// for non image files
}
else {
$url = $fileValue['url'];
$alt = $fileValue['cleanName'];
$file_url[$fileID] = "<a href=\"$url\"><div class='icon paper-icon' title=\"$alt\" alt=\"$alt\"></div></a>";
}
}
}
if(empty($file_url)) {
$results = NULL;
}
else {
$results = $file_url;
}
return $results;
}
}
\ No newline at end of file
......@@ -4032,3 +4032,6 @@ span.crm-status-icon {
color: #fff;
}
.crm-container .paper-icon {
background-position: -101px -222px;background-image: url("../i/icons/jquery-ui-3E3E3E.gif");
}
\ No newline at end of file
......@@ -236,6 +236,7 @@
<th>{ts}Subject{/ts}</th>
<th>{ts}Date{/ts}</th>
<th>{ts}Created By{/ts}</th>
<th>{ts}Attachment(s){/ts}</th>
<th></th>
</tr>
</thead>
......@@ -267,6 +268,11 @@
<td class="crm-note-createdBy">
<a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$note.contact_id`"}">{$note.createdBy}</a>
</td>
<td class="crm-note-attachment">
{foreach from=$note.attachment item=fileinfo}
{$fileinfo}
{/foreach}
</td>
<td class="nowrap">{$note.action|replace:'xx':$note.id}</td>
</tr>
{/foreach}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment