Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
819d0d41 | 3 | | CiviCRM version 4.5 | |
6a488035 | 4 | +--------------------------------------------------------------------+ |
819d0d41 | 5 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
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} | |
6a488035 TO |
29 | <div class="crm-block crm-content-block crm-note-view-block"> |
30 | <table class="crm-info-panel"> | |
31 | <tr><td class="label">{ts}Subject{/ts}</td><td>{$note.subject}</td></tr> | |
32 | <tr><td class="label">{ts}Date:{/ts}</td><td>{$note.modified_date|crmDate}</td></tr> | |
33 | <tr><td class="label">{ts}Privacy:{/ts}</td><td>{$note.privacy}</td></tr> | |
34 | <tr><td class="label"></td><td>{$note.note|nl2br}</td></tr> | |
35 | ||
36 | {if $currentAttachmentInfo} | |
37 | {include file="CRM/Form/attachment.tpl"} | |
38 | {/if} | |
39 | </table> | |
71b47fcd CW |
40 | <div class="crm-submit-buttons"> |
41 | <a class="button cancel" href="{crmURL p='civicrm/contact/view' q="selectedChild=note&reset=1&cid=`$contactId`"}">{ts}Done{/ts}</a> | |
42 | </div> | |
6a488035 TO |
43 | |
44 | {if $comments} | |
45 | <fieldset> | |
46 | <legend>{ts}Comments{/ts}</legend> | |
47 | <table class="display"> | |
48 | <thead> | |
49 | <tr><th>{ts}Comment{/ts}</th><th>{ts}Created By{/ts}</th><th>{ts}Date{/ts}</th></tr> | |
50 | </thead> | |
51 | {foreach from=$comments item=comment} | |
52 | <tr class="{cycle values='odd-row,even-row'}"><td>{$comment.note}</td><td>{$comment.createdBy}</td><td>{$comment.modified_date}</td></tr> | |
53 | {/foreach} | |
54 | </table> | |
55 | </fieldset> | |
56 | {/if} | |
57 | ||
58 | </div> | |
59 | {/if} | |
60 | {elseif $action eq 1 or $action eq 2} {* action is add or update *} | |
6a488035 TO |
61 | <div class="crm-block crm-form-block crm-note-form-block"> |
62 | <div class="content crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div> | |
63 | <table class="form-layout"> | |
64 | <tr> | |
65 | <td class="label">{$form.subject.label}</td> | |
66 | <td> | |
67 | {$form.subject.html} | |
68 | </td> | |
69 | </tr> | |
70 | <tr> | |
71 | <td class="label">{$form.privacy.label}</td> | |
72 | <td> | |
73 | {$form.privacy.html} | |
74 | </td> | |
75 | </tr> | |
76 | <tr> | |
77 | <td class="label">{$form.note.label}</td> | |
78 | <td> | |
79 | {$form.note.html} | |
80 | </td> | |
81 | </tr> | |
82 | <tr class="crm-activity-form-block-attachment"> | |
83 | <td colspan="2"> | |
84 | {include file="CRM/Form/attachment.tpl"} | |
85 | </td> | |
86 | </tr> | |
87 | </table> | |
88 | ||
89 | <div class="crm-section note-buttons-section no-label"> | |
90 | <div class="content crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div> | |
91 | <div class="clear"></div> | |
92 | </div> | |
93 | </div> | |
6a488035 TO |
94 | {/if} |
95 | {if ($action eq 8)} | |
6a488035 TO |
96 | <div class=status>{ts 1=$notes.$id.note}Are you sure you want to delete the note '%1'?{/ts}</div> |
97 | <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl"}</div> | |
6a488035 TO |
98 | |
99 | {/if} | |
100 | ||
4e8065a9 | 101 | {if $permission EQ 'edit' AND ($action eq 16)} |
6a488035 | 102 | <div class="action-link"> |
77042884 | 103 | <a accesskey="N" href="{crmURL p='civicrm/contact/view/note' q="cid=`$contactId`&action=add"}" class="button medium-popup"><span><div class="icon add-icon"></div>{ts}Add Note{/ts}</span></a> |
6a488035 TO |
104 | </div> |
105 | <div class="clear"></div> | |
106 | {/if} | |
107 | <div class="crm-content-block"> | |
108 | ||
4e8065a9 | 109 | {if $notes and $action eq 16} |
6a488035 TO |
110 | |
111 | <script type="text/javascript"> | |
112 | var commentAction = '{$commentAction|escape:quotes}' | |
113 | ||
114 | {literal} | |
115 | var commentRows = {}; | |
116 | ||
117 | function showHideComments( noteId ) { | |
118 | ||
119 | elRow = cj('tr#cnote_'+ noteId) | |
120 | ||
121 | if (elRow.hasClass('view-comments')) { | |
122 | cj('tr.note-comment_'+ noteId).remove() | |
123 | commentRows['cnote_'+ noteId] = {}; | |
124 | cj('tr#cnote_'+ noteId +' span.icon_comments_show').show(); | |
125 | cj('tr#cnote_'+ noteId +' span.icon_comments_hide').hide(); | |
126 | elRow.removeClass('view-comments'); | |
127 | } else { | |
128 | var getUrl = {/literal}"{crmURL p='civicrm/ajax/rest' h=0}"{literal}; | |
129 | cj.post(getUrl, { fnName: 'civicrm/note/tree_get', json: 1, id: noteId, sequential: 1 }, showComments, 'json' ); | |
130 | } | |
131 | ||
132 | } | |
133 | ||
134 | function showComments (response) { | |
135 | var urlTemplate = '{/literal}{crmURL p='civicrm/contact/view' q="reset=1&cid=" h=0 }{literal}' | |
136 | if (response['values'][0] && response['values'][0].entity_id) { | |
137 | var noteId = response['values'][0].entity_id | |
138 | var row = cj('tr#cnote_'+ noteId); | |
139 | ||
140 | row.addClass('view-comments'); | |
141 | ||
142 | if (row.hasClass('odd') ) { | |
143 | var rowClassOddEven = 'odd' | |
144 | } else { | |
145 | var rowClassOddEven = 'even' | |
146 | } | |
147 | ||
148 | if ( commentRows['cnote_'+ noteId] ) { | |
149 | for ( var i in commentRows['cnote_'+ noteId] ) { | |
150 | return false; | |
151 | } | |
152 | } else { | |
153 | commentRows['cnote_'+ noteId] = {}; | |
154 | } | |
155 | for (i in response['values']) { | |
156 | if ( response['values'][i].id ) { | |
157 | if ( commentRows['cnote_'+ noteId] && | |
158 | commentRows['cnote_'+ noteId][response['values'][i].id] ) { | |
159 | continue; | |
160 | } | |
161 | str = '<tr id="cnote_'+ response['values'][i].id +'" class="'+ rowClassOddEven +' note-comment_'+ noteId +'">' | |
162 | + '<td></td>' | |
163 | + '<td style="padding-left: 2em">' | |
164 | + response['values'][i].note | |
165 | + '</td><td>' | |
166 | + response['values'][i].subject | |
167 | + '</td><td>' | |
168 | + response['values'][i].modified_date | |
169 | + '</td><td>' | |
170 | + '<a href="'+ urlTemplate + response['values'][i].createdById +'">'+ response['values'][i].createdBy +'</a>' | |
9a042a42 | 171 | + '</td><td>' |
46f9b197 | 172 | + response['values'][i].attachment |
6a488035 TO |
173 | + '</td><td>'+ commentAction.replace(/{cid}/g, response['values'][i].createdById).replace(/{id}/g, response['values'][i].id) +'</td></tr>' |
174 | ||
175 | commentRows['cnote_'+ noteId][response['values'][i].id] = str; | |
176 | } | |
177 | } | |
178 | drawCommentRows('cnote_'+ noteId); | |
179 | ||
180 | cj('tr#cnote_'+ noteId +' span.icon_comments_show').hide(); | |
181 | cj('tr#cnote_'+ noteId +' span.icon_comments_hide').show(); | |
182 | } else { | |
183 | CRM.alert('{/literal}{ts escape="js"}There are no comments for this note{/ts}{literal}', '{/literal}{ts escape="js"}None Found{/ts}{literal}', 'alert'); | |
184 | } | |
185 | ||
186 | } | |
187 | ||
188 | function drawCommentRows(rowId) { | |
73bc3675 | 189 | if (rowId) { |
6a488035 TO |
190 | row = cj('tr#'+ rowId) |
191 | for (i in commentRows[rowId]) { | |
192 | row.after(commentRows[rowId][i]); | |
193 | row = cj('tr#cnote_'+ i); | |
194 | } | |
73bc3675 | 195 | } |
6a488035 TO |
196 | } |
197 | ||
198 | {/literal} | |
199 | </script> | |
200 | ||
201 | <div class="crm-results-block"> | |
202 | {* show browse table for any action *} | |
203 | <div id="notes"> | |
204 | {strip} | |
205 | {include file="CRM/common/jsortable.tpl"} | |
206 | ||
207 | <script type="text/javascript"> | |
208 | {literal} | |
32678ccb CW |
209 | CRM.$(function($) { |
210 | var tabId = $.fn.dataTableSettings[0].sInstance; | |
211 | ||
212 | $('table#'+ tabId).dataTable().fnSettings().aoDrawCallback.push( { | |
213 | "fn": function () { | |
214 | $('#'+ tabId +' tr').each( function() { | |
215 | drawCommentRows(this.id) | |
216 | }); | |
217 | }, | |
218 | "sName": "user" | |
219 | } ); | |
220 | }); | |
6a488035 TO |
221 | |
222 | {/literal} | |
223 | </script> | |
224 | ||
225 | <table id="options" class="display"> | |
226 | <thead> | |
227 | <tr> | |
228 | <th></th> | |
229 | <th>{ts}Note{/ts}</th> | |
230 | <th>{ts}Subject{/ts}</th> | |
231 | <th>{ts}Date{/ts}</th> | |
232 | <th>{ts}Created By{/ts}</th> | |
34f51a07 | 233 | <th>{ts}Attachment(s){/ts}</th> |
6a488035 TO |
234 | <th></th> |
235 | </tr> | |
236 | </thead> | |
237 | ||
238 | {foreach from=$notes item=note} | |
239 | <tr id="cnote_{$note.id}" class="{cycle values="odd-row,even-row"} crm-note"> | |
240 | <td class="crm-note-comment"> | |
241 | {if $note.comment_count} | |
242 | <span id="{$note.id}_show" style="display:block" class="icon_comments_show"> | |
243 | <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> | |
244 | </span> | |
245 | <span id="{$note.id}_hide" style="display:none" class="icon_comments_hide"> | |
246 | <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> | |
247 | </span> | |
248 | {else} | |
249 | <span class="ui-icon ui-icon-triangle-1-e" id="{$note.id}_hide" style="display:none"></span> | |
250 | {/if} | |
251 | </td> | |
252 | <td class="crm-note-note"> | |
253 | {$note.note|mb_truncate:80:"...":false|nl2br} | |
254 | {* Include '(more)' link to view entire note if it has been truncated *} | |
255 | {assign var="noteSize" value=$note.note|count_characters:true} | |
256 | {if $noteSize GT 80} | |
71b47fcd | 257 | <a class="crm-popup" href="{crmURL p='civicrm/contact/view/note' q="action=view&selectedChild=note&reset=1&cid=`$contactId`&id=`$note.id`"}">{ts}(more){/ts}</a> |
6a488035 TO |
258 | {/if} |
259 | </td> | |
260 | <td class="crm-note-subject">{$note.subject}</td> | |
261 | <td class="crm-note-modified_date">{$note.modified_date|crmDate}</td> | |
262 | <td class="crm-note-createdBy"> | |
263 | <a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$note.contact_id`"}">{$note.createdBy}</a> | |
264 | </td> | |
34f51a07 N |
265 | <td class="crm-note-attachment"> |
266 | {foreach from=$note.attachment item=fileinfo} | |
267 | {$fileinfo} | |
268 | {/foreach} | |
269 | </td> | |
6a488035 TO |
270 | <td class="nowrap">{$note.action|replace:'xx':$note.id}</td> |
271 | </tr> | |
272 | {/foreach} | |
273 | </table> | |
274 | {/strip} | |
275 | </div> | |
276 | </div> | |
4e8065a9 | 277 | {elseif ($action eq 16)} |
6a488035 TO |
278 | <div class="messages status no-popup"> |
279 | <div class="icon inform-icon"></div> | |
77042884 | 280 | {capture assign=link}class="action-item medium-popup" accesskey="N" href="{crmURL p='civicrm/contact/view/note' q="cid=`$contactId`&action=add"}"{/capture} |
4e8065a9 | 281 | {ts 1=$link}There are no Notes for this contact. You can <a %1>add one</a>.{/ts} |
6a488035 TO |
282 | </div> |
283 | {/if} | |
284 | </div> | |
285 | </div> |