Merge pull request #2236 from eileenmcnaughton/CRM-14008
[civicrm-core.git] / templates / CRM / Contact / Page / View / Note.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.4 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2013 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
8 | |
9 | CiviCRM is free software; you can copy, modify, and distribute it |
10 | under the terms of the GNU Affero General Public License |
11 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
12 | |
13 | CiviCRM is distributed in the hope that it will be useful, but |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
16 | See the GNU Affero General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU Affero General Public |
19 | License and the CiviCRM Licensing Exception along |
20 | with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
25 *}
26 <div class="view-content">
27 {if $action eq 4}{* when action is view *}
28 {if $notes}
29 <h3>{ts}View Note{/ts}</h3>
30 <div class="crm-block crm-content-block crm-note-view-block">
31 <table class="crm-info-panel">
32 <tr><td class="label">{ts}Subject{/ts}</td><td>{$note.subject}</td></tr>
33 <tr><td class="label">{ts}Date:{/ts}</td><td>{$note.modified_date|crmDate}</td></tr>
34 <tr><td class="label">{ts}Privacy:{/ts}</td><td>{$note.privacy}</td></tr>
35 <tr><td class="label"></td><td>{$note.note|nl2br}</td></tr>
36
37 {if $currentAttachmentInfo}
38 {include file="CRM/Form/attachment.tpl"}
39 {/if}
40 </table>
41 <div class="crm-submit-buttons"><input type="button" name='cancel' value="{ts}Done{/ts}" onclick="location.href='{crmURL p='civicrm/contact/view' q='action=browse&selectedChild=note'}';"/></div>
42
43 {if $comments}
44 <fieldset>
45 <legend>{ts}Comments{/ts}</legend>
46 <table class="display">
47 <thead>
48 <tr><th>{ts}Comment{/ts}</th><th>{ts}Created By{/ts}</th><th>{ts}Date{/ts}</th></tr>
49 </thead>
50 {foreach from=$comments item=comment}
51 <tr class="{cycle values='odd-row,even-row'}"><td>{$comment.note}</td><td>{$comment.createdBy}</td><td>{$comment.modified_date}</td></tr>
52 {/foreach}
53 </table>
54 </fieldset>
55 {/if}
56
57 </div>
58 {/if}
59 {elseif $action eq 1 or $action eq 2} {* action is add or update *}
60 <h3>
61 {if $parentId}
62 {if $action eq 1}{ts}New Comment{/ts}{else}{ts}Edit Comment{/ts}{/if}
63 {else}
64 {if $action eq 1}{ts}New Note{/ts}{else}{ts}Edit Note{/ts}{/if}
65 {/if}
66 </h3>
67 <div class="crm-block crm-form-block crm-note-form-block">
68 <div class="content crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
69 <table class="form-layout">
70 <tr>
71 <td class="label">{$form.subject.label}</td>
72 <td>
73 {$form.subject.html}
74 </td>
75 </tr>
76 <tr>
77 <td class="label">{$form.privacy.label}</td>
78 <td>
79 {$form.privacy.html}
80 </td>
81 </tr>
82 <tr>
83 <td class="label">{$form.note.label}</td>
84 <td>
85 {$form.note.html}
86 </td>
87 </tr>
88 <tr class="crm-activity-form-block-attachment">
89 <td colspan="2">
90 {include file="CRM/Form/attachment.tpl"}
91 </td>
92 </tr>
93 </table>
94
95 <div class="crm-section note-buttons-section no-label">
96 <div class="content crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
97 <div class="clear"></div>
98 </div>
99 </div>
100 {* include jscript to warn if unsaved form field changes *}
101 {include file="CRM/common/formNavigate.tpl"}
102 {/if}
103 {if ($action eq 8)}
104 <fieldset><legend>{ts}Delete Note{/ts}</legend>
105 <div class=status>{ts 1=$notes.$id.note}Are you sure you want to delete the note '%1'?{/ts}</div>
106 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl"}</div>
107 </fieldset>
108
109 {/if}
110
111 {if $permission EQ 'edit' AND ($action eq 16 or $action eq 4 or $action eq 8)}
112 <div class="action-link">
113 <a accesskey="N" href="{crmURL p='civicrm/contact/view/note' q="cid=`$contactId`&action=add"}" class="button"><span><div class="icon add-icon"></div>{ts}Add Note{/ts}</span></a>
114 </div>
115 <div class="clear"></div>
116 {/if}
117 <div class="crm-content-block">
118
119 {if $notes}
120
121 <script type="text/javascript">
122 var commentAction = '{$commentAction|escape:quotes}'
123
124 {literal}
125 var commentRows = {};
126
127 function showHideComments( noteId ) {
128
129 elRow = cj('tr#cnote_'+ noteId)
130
131 if (elRow.hasClass('view-comments')) {
132 cj('tr.note-comment_'+ noteId).remove()
133 commentRows['cnote_'+ noteId] = {};
134 cj('tr#cnote_'+ noteId +' span.icon_comments_show').show();
135 cj('tr#cnote_'+ noteId +' span.icon_comments_hide').hide();
136 elRow.removeClass('view-comments');
137 } else {
138 var getUrl = {/literal}"{crmURL p='civicrm/ajax/rest' h=0}"{literal};
139 cj.post(getUrl, { fnName: 'civicrm/note/tree_get', json: 1, id: noteId, sequential: 1 }, showComments, 'json' );
140 }
141
142 }
143
144 function showComments (response) {
145 var urlTemplate = '{/literal}{crmURL p='civicrm/contact/view' q="reset=1&cid=" h=0 }{literal}'
146 if (response['values'][0] && response['values'][0].entity_id) {
147 var noteId = response['values'][0].entity_id
148 var row = cj('tr#cnote_'+ noteId);
149
150 row.addClass('view-comments');
151
152 if (row.hasClass('odd') ) {
153 var rowClassOddEven = 'odd'
154 } else {
155 var rowClassOddEven = 'even'
156 }
157
158 if ( commentRows['cnote_'+ noteId] ) {
159 for ( var i in commentRows['cnote_'+ noteId] ) {
160 return false;
161 }
162 } else {
163 commentRows['cnote_'+ noteId] = {};
164 }
165 for (i in response['values']) {
166 if ( response['values'][i].id ) {
167 if ( commentRows['cnote_'+ noteId] &&
168 commentRows['cnote_'+ noteId][response['values'][i].id] ) {
169 continue;
170 }
171 str = '<tr id="cnote_'+ response['values'][i].id +'" class="'+ rowClassOddEven +' note-comment_'+ noteId +'">'
172 + '<td></td>'
173 + '<td style="padding-left: 2em">'
174 + response['values'][i].note
175 + '</td><td>'
176 + response['values'][i].subject
177 + '</td><td>'
178 + response['values'][i].modified_date
179 + '</td><td>'
180 + '<a href="'+ urlTemplate + response['values'][i].createdById +'">'+ response['values'][i].createdBy +'</a>'
181 + '</td><td>'+ commentAction.replace(/{cid}/g, response['values'][i].createdById).replace(/{id}/g, response['values'][i].id) +'</td></tr>'
182
183 commentRows['cnote_'+ noteId][response['values'][i].id] = str;
184 }
185 }
186 drawCommentRows('cnote_'+ noteId);
187
188 cj('tr#cnote_'+ noteId +' span.icon_comments_show').hide();
189 cj('tr#cnote_'+ noteId +' span.icon_comments_hide').show();
190 } else {
191 CRM.alert('{/literal}{ts escape="js"}There are no comments for this note{/ts}{literal}', '{/literal}{ts escape="js"}None Found{/ts}{literal}', 'alert');
192 }
193
194 }
195
196 function drawCommentRows(rowId) {
197 row = cj('tr#'+ rowId)
198 for (i in commentRows[rowId]) {
199 row.after(commentRows[rowId][i]);
200 row = cj('tr#cnote_'+ i);
201 }
202 }
203
204 {/literal}
205 </script>
206
207 <div class="crm-results-block">
208 {* show browse table for any action *}
209 <div id="notes">
210 {strip}
211 {include file="CRM/common/jsortable.tpl"}
212
213 <script type="text/javascript">
214 {literal}
215 cj(document).ready( function() {
216 var tabId = cj.fn.dataTableSettings[0].sInstance;
217
218 cj('table#'+ tabId).dataTable().fnSettings().aoDrawCallback.push( {
219 "fn": function () {
220 cj('#'+ tabId +' tr').each( function() {
221 drawCommentRows(this.id)
222 });
223 },
224 "sName": "user"
225 } );
226 });
227
228 {/literal}
229 </script>
230
231 <table id="options" class="display">
232 <thead>
233 <tr>
234 <th></th>
235 <th>{ts}Note{/ts}</th>
236 <th>{ts}Subject{/ts}</th>
237 <th>{ts}Date{/ts}</th>
238 <th>{ts}Created By{/ts}</th>
239 <th></th>
240 </tr>
241 </thead>
242
243 {foreach from=$notes item=note}
244 <tr id="cnote_{$note.id}" class="{cycle values="odd-row,even-row"} crm-note">
245 <td class="crm-note-comment">
246 {if $note.comment_count}
247 <span id="{$note.id}_show" style="display:block" class="icon_comments_show">
248 <a href="#" onclick="showHideComments({$note.id}); return false;" title="{ts}Show comments for this note.{/ts}"><span class="ui-icon dark-icon ui-icon-triangle-1-e"></span></a>
249 </span>
250 <span id="{$note.id}_hide" style="display:none" class="icon_comments_hide">
251 <a href="#" onclick="showHideComments({$note.id}); return false;" title="{ts}Hide comments for this note.{/ts}"><span class="ui-icon dark-icon ui-icon-triangle-1-s"></span></a>
252 </span>
253 {else}
254 <span class="ui-icon ui-icon-triangle-1-e" id="{$note.id}_hide" style="display:none"></span>
255 {/if}
256 </td>
257 <td class="crm-note-note">
258 {$note.note|mb_truncate:80:"...":false|nl2br}
259 {* Include '(more)' link to view entire note if it has been truncated *}
260 {assign var="noteSize" value=$note.note|count_characters:true}
261 {if $noteSize GT 80}
262 <a href="{crmURL p='civicrm/contact/view/note' q="action=view&selectedChild=note&reset=1&cid=`$contactId`&id=`$note.id`"}">{ts}(more){/ts}</a>
263 {/if}
264 </td>
265 <td class="crm-note-subject">{$note.subject}</td>
266 <td class="crm-note-modified_date">{$note.modified_date|crmDate}</td>
267 <td class="crm-note-createdBy">
268 <a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$note.contact_id`"}">{$note.createdBy}</a>
269 </td>
270 <td class="nowrap">{$note.action|replace:'xx':$note.id}</td>
271 </tr>
272 {/foreach}
273 </table>
274 {/strip}
275 </div>
276 </div>
277 {elseif ! ($action eq 1)}
278 <div class="messages status no-popup">
279 <div class="icon inform-icon"></div>
280 {capture assign=crmURL}{crmURL p='civicrm/contact/view/note' q="cid=`$contactId`&action=add"}{/capture}
281 {ts 1=$crmURL}There are no Notes for this contact. You can <a accesskey="N" href='%1'>add one</a>.{/ts}
282 </div>
283 {/if}
284 </div>
285 </div>