-- CRM-13624 Display paper clip icon for file attachments for Note and CiviHR profiles
authorNileema <nileema@nileema.(none)>
Wed, 6 Nov 2013 07:55:21 +0000 (13:25 +0530)
committerNileema <nileema@nileema.(none)>
Wed, 6 Nov 2013 07:55:21 +0000 (13:25 +0530)
----------------------------------------
* CRM-13624: All Tabs - Paperclip Icon
  http://issues.civicrm.org/jira/browse/CRM-13624

CRM/Contact/Page/View/Note.php
CRM/Core/BAO/CustomValueTable.php
CRM/Core/BAO/File.php
css/civicrm.css
i/icons/jquery-ui-3E3E3E.gif [new file with mode: 0644]
templates/CRM/Contact/Page/View/Note.tpl

index e6d54f7df0fd480df5e3c5c635114749a234cf07..9a570257ae39c81bf1cd571a6fa5cd5fbf4eb429 100644 (file)
@@ -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;
       }
     }
 
index 74beeed525e579ad96beb6b8d7990d2ac487f997..011116f98eb4f3aaaba8d09150caaecf08f297ed 100644 (file)
@@ -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;          
+            }
           }
         }
       }
index f09e64a11d19a4b036df80279b950588a8464dca..c74d6488d89ee5206216de686b5b778ad8cee543 100644 (file)
     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
index e20282fb89185b40a6eff5162c744373c1a72ed1..78f36da8e48eb37dfeb3062179295590bbf54ee5 100644 (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
diff --git a/i/icons/jquery-ui-3E3E3E.gif b/i/icons/jquery-ui-3E3E3E.gif
new file mode 100644 (file)
index 0000000..f74568b
Binary files /dev/null and b/i/icons/jquery-ui-3E3E3E.gif differ
index 6dc07d0e38832e8a3d3891c7e995ae4b2e2dbfe9..2a9dbf73d24658243027b0071a29b6651e5e9e01 100644 (file)
           <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>
             <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}