687751331dbc34df5567909118efab6c6e3ad390
[civicrm-core.git] / templates / CRM / Form / attachment.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | Copyright CiviCRM LLC. All rights reserved. |
4 | |
5 | This work is published under the GNU AGPLv3 license with some |
6 | permitted exceptions and without any warranty. For full license |
7 | and copyright information, see https://civicrm.org/licensing |
8 +--------------------------------------------------------------------+
9 *}
10 {if $form.attachFile_1 OR $currentAttachmentInfo}
11 {if $action EQ 4 AND $currentAttachmentInfo} {* For View action we exclude the form fields and just show any current attachments. *}
12 <tr>
13 <td class="label"><label>{ts}Current Attachment(s){/ts}</label></td>
14 <td class="view-value">
15 {foreach from=$currentAttachmentInfo key=attKey item=attVal}
16 <div id="attachStatusMesg" class="status hiddenElement"></div>
17 <div id="attachFileRecord_{$attVal.fileID}">
18 <strong><a href="{$attVal.url}"><i class="crm-i {$attVal.icon}" aria-hidden="true"></i> {$attVal.cleanName}</a></strong>
19 {if $attVal.description}&nbsp;-&nbsp;{$attVal.description}{/if}
20 {if !empty($attVal.tag)}
21 <br />
22 {ts}Tags{/ts}: {$attVal.tag}
23 <br />
24 {/if}
25 </div>
26 {/foreach}
27 </td>
28 </tr>
29 {elseif $action NEQ 4}
30 {if $context EQ 'pcpCampaign'}
31 {capture assign=attachTitle}{ts}Include a Picture or an Image{/ts}{/capture}
32 {else}
33 {capture assign=attachTitle}{ts}Attachment(s){/ts}{/capture}
34 {/if}
35 {if !$noexpand}
36 <div class="crm-accordion-wrapper {if $context NEQ 'pcpCampaign' AND !$currentAttachmentInfo}collapsed{/if}">
37 <div class="crm-accordion-header">
38 {$attachTitle}
39 </div><!-- /.crm-accordion-header -->
40 <div class="crm-accordion-body">
41 {/if}
42 <div id="attachments">
43 <table class="form-layout-compressed">
44 {if $form.attachFile_1}
45 {if $context EQ 'pcpCampaign'}
46 <div class="description">{ts}You can upload a picture or image to include on your page. Your file should be in .jpg, .gif, or .png format. Recommended image size is 250 x 250 pixels. Images over 360 pixels wide will be automatically resized to fit.{/ts}</div>
47 {/if}
48 <tr>
49 <td class="label">{$form.attachFile_1.label}</td>
50 <td>{$form.attachFile_1.html}&nbsp;{$form.attachDesc_1.html}<a href="#" class="crm-hover-button crm-clear-attachment" style="visibility: hidden;" title="{ts}Clear{/ts}"><i class="crm-i fa-times" aria-hidden="true"></i></a>
51 <div class="description">{ts}Browse to the <strong>file</strong> you want to upload.{/ts}{if $maxAttachments GT 1} {ts 1=$maxAttachments}You can have a maximum of %1 attachment(s).{/ts}{/if} {ts 1=$config->maxFileSize}Each file must be less than %1M in size. You can also add a short description.{/ts}</div>
52 </td>
53 </tr>
54 {if $form.tag_1.html}
55 <tr>
56 <td class="label">{$form.tag_1.label}</td>
57 <td><div class="crm-select-container crm-attachment-tags">{$form.tag_1.html}</div></td>
58 </tr>
59 {/if}
60 {if $tagsetInfo.file}
61 <tr>{include file="CRM/common/Tagset.tpl" tagsetType='file' tableLayout=true tagsetElementName="file_taglist_1"}</tr>
62 {/if}
63 {section name=attachLoop start=2 loop=$numAttachments+1}
64 {assign var=index value=$smarty.section.attachLoop.index}
65 {assign var=attachName value="attachFile_"|cat:$index}
66 {assign var=attachDesc value="attachDesc_"|cat:$index}
67 {assign var=tagElement value="tag_"|cat:$index}
68 <tr class="attachment-fieldset solid-border-top"><td colspan="2"></td></tr>
69 <tr>
70 <td class="label">{$form.attachFile_1.label}</td>
71 <td>{$form.$attachName.html}&nbsp;{$form.$attachDesc.html}<a href="#" class="crm-hover-button crm-clear-attachment" style="visibility: hidden;" title="{ts}Clear{/ts}"><i class="crm-i fa-times" aria-hidden="true"></i></a></td>
72 </tr>
73 <tr>
74 <td class="label">{$form.$tagElement.label}</td>
75 <td><div class="crm-select-container crm-attachment-tags">{$form.$tagElement.html}</div></td>
76 </tr>
77 {if $tagsetInfo.file}
78 <tr>{include file="CRM/common/Tagset.tpl" tagsetType='file' tableLayout=true tagsetElementName="file_taglist_$index"}</tr>
79 {/if}
80 {/section}
81
82 {/if}
83 {if $currentAttachmentInfo}
84 <tr class="attachment-fieldset solid-border-top"><td colspan="2"></td></tr>
85 <tr>
86 <td class="label">{ts}Current Attachment(s){/ts}</td>
87 <td class="view-value">
88 {foreach from=$currentAttachmentInfo key=attKey item=attVal}
89 <div class="crm-attachment-wrapper crm-entity" id="file_{$attVal.fileID}">
90 <strong><a class="crm-attachment" href="{$attVal.url}">{$attVal.cleanName}</a></strong>
91 {if $attVal.description}&nbsp;-&nbsp;{$attVal.description}{/if}
92 {if $attVal.deleteURLArgs}
93 <a href="#" class="crm-hover-button delete-attachment" data-filename="{$attVal.cleanName}" data-args="{$attVal.deleteURLArgs}" title="{ts}Delete File{/ts}"><span class="icon delete-icon"></span></a>
94 {/if}
95 {if !empty($attVal.tag)}
96 <br/>
97 {ts}Tags{/ts}: {$attVal.tag}
98 <br/>
99 {/if}
100 </div>
101 {/foreach}
102 </td>
103 </tr>
104 <tr>
105 <td class="label">&nbsp;</td>
106 <td>{$form.is_delete_attachment.html}&nbsp;{$form.is_delete_attachment.label}
107 </td>
108 </tr>
109 {/if}
110 </table>
111 </div>
112 </div><!-- /.crm-accordion-body -->
113 </div><!-- /.crm-accordion-wrapper -->
114 {literal}
115 <script type="text/javascript">
116 CRM.$(function($) {
117 var $form = $("form.{/literal}{$form.formClass}{literal}");
118 $form
119 .on('click', '.crm-clear-attachment', function(e) {
120 e.preventDefault();
121 $(this).css('visibility', 'hidden').closest('td').find(':input').val('');
122 })
123 .on('change', '#attachments :input', function() {
124 $(this).closest('td').find('.crm-clear-attachment').css('visibility', 'visible');
125 });
126 });
127 </script>
128 {/literal}
129 {/if} {* edit/add if*}
130
131 {if $currentAttachmentInfo}
132 {include file="CRM/Form/attachmentjs.tpl"}
133 {/if}
134
135 {/if} {* top level if *}