'fid' => $fieldID,
)
);
+ $customValue['deleteURLArgs'] = CRM_Core_BAO_File::deleteURLArgs($table, $dao->$entityIDName, $fileDAO->id);
$customValue['fileName'] = CRM_Utils_File::cleanFileName(basename($fileDAO->uri));
if ($fileDAO->mime_type == "image/jpeg" ||
$fileDAO->mime_type == "image/pjpeg" ||
list($sql, $params) = self::sql($entityTable, $entityID, $fileTypeID);
}
else {
- list($sql, $params) = self::sql($entityTable, $entityID, NULL);
+ list($sql, $params) = self::sql($entityTable, $entityID, 0);
}
$dao = CRM_Core_DAO::executeQuery($sql, $params);
*
*/
class CRM_Core_Page_File extends CRM_Core_Page {
- function run() {
+ function run() {
$eid = CRM_Utils_Request::retrieve('eid', 'Positive', $this, TRUE);
$fid = CRM_Utils_Request::retrieve('fid', 'Positive', $this, FALSE);
$id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
{*include custom data js file*}
{include file="CRM/common/customData.tpl"}
+
{if $customValueCount }
{literal}
<script type="text/javascript">
{/literal}
{/if}
{/if}
+
+{include file="CRM/Form/attachmentjs.tpl"}
});
{/literal}
</script>
+
{/if}
<span class="crm-clear-link">(<a href="#" title="unselect" onclick="unselectRadio('{$element_name}', '{$form.formName}'); return false;" >{ts}clear{/ts}</a>)</span>
{elseif $element.data_type eq 'File'}
{if $element.element_value.data}
+ <div id="attachStatusMesg_{$element_name}" class="status hiddenElement"></div>
+ <div id="attachFile_{$element_name}">
<span class="html-adjust"><br />
{ts}Attached File{/ts}:
- {if $element.element_value.displayURL }
+ {if $element.element_value.displayURL}
<a href="#" onclick="popUp('{$element.element_value.imageURL}'); return false;" ><img src="{$element.element_value.displayURL}" height = "{$element.element_value.imageThumbHeight}" width="{$element.element_value.imageThumbWidth}"></a>
{else}
<a href="{$element.element_value.fileURL}">{$element.element_value.fileName}</a>
{/if}
- {if $element.element_value.deleteURL }
- <br />
- {$element.element_value.deleteURL}
+ {if $element.element_value.deleteURL}
+ <a href="#" onclick="showDelete('{$element.element_value.fileName}', '{$element.element_value.deleteURLArgs}', {$element.element_value.fid}, '#attachStatusMesg_{$element_name}', '#attachFile_{$element_name}'); return false;" title="{ts}Delete this file{/ts}"><span class="icon red-icon delete-icon" style="margin:0px 0px -5px 20px" title="{ts}Delete this file{/ts}"></span></a>
{/if}
</span>
+ </div>
{/if}
{elseif $element.html_type eq 'Autocomplete-Select'}
{if $element.data_type eq 'ContactReference'}
</tr>
{/if}
-
<strong><a href="{$attVal.url}">{$attVal.cleanName}</a></strong>
{if $attVal.description} - {$attVal.description}{/if}
{if $attVal.deleteURLArgs}
- <a href="#" onclick="showDelete('{$attVal.cleanName}', '{$attVal.deleteURLArgs}', {$attVal.fileID}); return false;" title="{ts}Delete this attachment{/ts}"><span class="icon red-icon delete-icon" style="margin:0px 0px -5px 20px" title="{ts}Delete this attachment{/ts}"></span></a>
+ <a href="#" onclick="showDelete('{$attVal.cleanName}', '{$attVal.deleteURLArgs}', {$attVal.fileID}, '#attachStatusMesg', '#attachFileRecord_{$attVal.fileID}'); return false;" title="{ts}Delete this attachment{/ts}"><span class="icon red-icon delete-icon" style="margin:0px 0px -5px 20px" title="{ts}Delete this attachment{/ts}"></span></a>
{/if}
{if !empty($attVal.tag)}
<br/>
</script>
{/literal}
{/if} {* edit/add if*}
-{if $currentAttachmentInfo}
-<script type="text/javascript">
-{literal}
- function hideStatus( ) {
- cj( '#attachStatusMesg' ).hide( );
- }
-
- function showDelete( fileName, postURLData, fileID ) {
- var confirmMsg = '{/literal}{ts escape="js"}Are you sure you want to delete attachment: {/ts}{literal}' + fileName + ' <a href="#" onclick="deleteAttachment( \'' + postURLData + '\',' + fileID + ' ); return false;" style="text-decoration: underline;">{/literal}{ts escape='js'}Yes{/ts}{literal}</a> <a href="#" onclick="hideStatus( ); return false;" style="text-decoration: underline;">{/literal}{ts escape='js'}No{/ts}{literal}</a>';
- cj( '#attachStatusMesg' ).show( ).html( confirmMsg );
- }
- function deleteAttachment( postURLData, fileID ) {
- var postUrl = {/literal}"{crmURL p='civicrm/file/delete' h=0 }"{literal};
- cj.ajax({
- type: "GET",
- data: postURLData,
- url: postUrl,
- success: function(html){
- var resourceBase = {/literal}"{$config->resourceBase}"{literal};
- var successMsg = '{/literal}{ts escape="js"}The selected attachment has been deleted.{/ts}{literal} <a href="#" onclick="hideStatus( ); return false;"><img title="{/literal}{ts escape='js'}close{/ts}{literal}" src="' +resourceBase+'i/close.png"/></a>';
- cj( '#attachFileRecord_' + fileID ).hide( );
- cj( '#attachStatusMesg' ).show( ).html( successMsg );
- }
- });
- }
-{/literal}
-</script>
+{if $currentAttachmentInfo}
+{include file="CRM/Form/attachmentjs.tpl"}
{/if}
+
{/if} {* top level if *}
--- /dev/null
+<script type="text/javascript">
+{literal}
+ function hideStatus( divName ) {
+ cj( divName ).hide( );
+ }
+
+ function showDelete( fileName, postURLData, fileID, divName, divFile ) {
+ var confirmMsg = '{/literal}{ts escape="js"}Are you sure you want to delete attachment: {/ts}{literal}' + fileName + ' <a href="#" onclick="deleteAttachment( \'' + postURLData + '\',' + fileID + ',\'' + divName + '\', \'' + divFile + '\' ); return false;" style="text-decoration: underline;">{/literal}{ts escape='js'}Yes{/ts}{literal}</a> <a href="#" onclick="hideStatus( divName ); return false;" style="text-decoration: underline;">{/literal}{ts escape='js'}No{/ts}{literal}</a>';
+ cj( divName ).show( ).html( confirmMsg );
+p }
+
+ function deleteAttachment( postURLData, fileID, divName, divFile ) {
+ var postUrl = {/literal}"{crmURL p='civicrm/file/delete' h=0 }"{literal};
+ cj.ajax({
+ type: "GET",
+ data: postURLData,
+ url: postUrl,
+ success: function(html){
+ var resourceBase = {/literal}"{$config->resourceBase}"{literal};
+ var successMsg = '{/literal}{ts escape="js"}The selected attachment has been deleted.{/ts}{literal} <a href="#" onclick="hideStatus( \'' + divName + '\'); return false;"><img title="{/literal}{ts escape='js'}close{/ts}{literal}" src="' +resourceBase+'i/close.png"/></a>';
+ cj( divFile ).hide( );
+ cj( divName ).show( ).html( successMsg );
+ }
+ });
+ }
+{/literal}
+</script>