Change form-submit css class to crm-form-submit
[civicrm-core.git] / templates / CRM / Contact / Page / View / Note.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.5 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2014 |
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="submit" class='cancel crm-form-submit' value="{ts}Done{/ts}"/></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 {/if}
101 {if ($action eq 8)}
102 <fieldset><legend>{ts}Delete Note{/ts}</legend>
103 <div class=status>{ts 1=$notes.$id.note}Are you sure you want to delete the note '%1'?{/ts}</div>
104 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl"}</div>
105 </fieldset>
106
107 {/if}
108
109 {if $permission EQ 'edit' AND ($action eq 16)}
110 <div class="action-link">
111 <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>
112 </div>
113 <div class="clear"></div>
114 {/if}
115 <div class="crm-content-block">
116
117 {if $notes and $action eq 16}
118
119 <script type="text/javascript">
120 var commentAction = '{$commentAction|escape:quotes}'
121
122 {literal}
123 var commentRows = {};
124
125 function showHideComments( noteId ) {
126
127 elRow = cj('tr#cnote_'+ noteId)
128
129 if (elRow.hasClass('view-comments')) {
130 cj('tr.note-comment_'+ noteId).remove()
131 commentRows['cnote_'+ noteId] = {};
132 cj('tr#cnote_'+ noteId +' span.icon_comments_show').show();
133 cj('tr#cnote_'+ noteId +' span.icon_comments_hide').hide();
134 elRow.removeClass('view-comments');
135 } else {
136 var getUrl = {/literal}"{crmURL p='civicrm/ajax/rest' h=0}"{literal};
137 cj.post(getUrl, { fnName: 'civicrm/note/tree_get', json: 1, id: noteId, sequential: 1 }, showComments, 'json' );
138 }
139
140 }
141
142 function showComments (response) {
143 var urlTemplate = '{/literal}{crmURL p='civicrm/contact/view' q="reset=1&cid=" h=0 }{literal}'
144 if (response['values'][0] && response['values'][0].entity_id) {
145 var noteId = response['values'][0].entity_id
146 var row = cj('tr#cnote_'+ noteId);
147
148 row.addClass('view-comments');
149
150 if (row.hasClass('odd') ) {
151 var rowClassOddEven = 'odd'
152 } else {
153 var rowClassOddEven = 'even'
154 }
155
156 if ( commentRows['cnote_'+ noteId] ) {
157 for ( var i in commentRows['cnote_'+ noteId] ) {
158 return false;
159 }
160 } else {
161 commentRows['cnote_'+ noteId] = {};
162 }
163 for (i in response['values']) {
164 if ( response['values'][i].id ) {
165 if ( commentRows['cnote_'+ noteId] &&
166 commentRows['cnote_'+ noteId][response['values'][i].id] ) {
167 continue;
168 }
169 str = '<tr id="cnote_'+ response['values'][i].id +'" class="'+ rowClassOddEven +' note-comment_'+ noteId +'">'
170 + '<td></td>'
171 + '<td style="padding-left: 2em">'
172 + response['values'][i].note
173 + '</td><td>'
174 + response['values'][i].subject
175 + '</td><td>'
176 + response['values'][i].modified_date
177 + '</td><td>'
178 + '<a href="'+ urlTemplate + response['values'][i].createdById +'">'+ response['values'][i].createdBy +'</a>'
179 + '</td><td>'
180 + response['values'][i].attachment
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 if (rowId) {
198 row = cj('tr#'+ rowId)
199 for (i in commentRows[rowId]) {
200 row.after(commentRows[rowId][i]);
201 row = cj('tr#cnote_'+ i);
202 }
203 }
204 }
205
206 {/literal}
207 </script>
208
209 <div class="crm-results-block">
210 {* show browse table for any action *}
211 <div id="notes">
212 {strip}
213 {include file="CRM/common/jsortable.tpl"}
214
215 <script type="text/javascript">
216 {literal}
217 cj(document).ready( function() {
218 var tabId = cj.fn.dataTableSettings[0].sInstance;
219
220 cj('table#'+ tabId).dataTable().fnSettings().aoDrawCallback.push( {
221 "fn": function () {
222 cj('#'+ tabId +' tr').each( function() {
223 drawCommentRows(this.id)
224 });
225 },
226 "sName": "user"
227 } );
228 });
229
230 {/literal}
231 </script>
232
233 <table id="options" class="display">
234 <thead>
235 <tr>
236 <th></th>
237 <th>{ts}Note{/ts}</th>
238 <th>{ts}Subject{/ts}</th>
239 <th>{ts}Date{/ts}</th>
240 <th>{ts}Created By{/ts}</th>
241 <th>{ts}Attachment(s){/ts}</th>
242 <th></th>
243 </tr>
244 </thead>
245
246 {foreach from=$notes item=note}
247 <tr id="cnote_{$note.id}" class="{cycle values="odd-row,even-row"} crm-note">
248 <td class="crm-note-comment">
249 {if $note.comment_count}
250 <span id="{$note.id}_show" style="display:block" class="icon_comments_show">
251 <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>
252 </span>
253 <span id="{$note.id}_hide" style="display:none" class="icon_comments_hide">
254 <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>
255 </span>
256 {else}
257 <span class="ui-icon ui-icon-triangle-1-e" id="{$note.id}_hide" style="display:none"></span>
258 {/if}
259 </td>
260 <td class="crm-note-note">
261 {$note.note|mb_truncate:80:"...":false|nl2br}
262 {* Include '(more)' link to view entire note if it has been truncated *}
263 {assign var="noteSize" value=$note.note|count_characters:true}
264 {if $noteSize GT 80}
265 <a href="{crmURL p='civicrm/contact/view/note' q="action=view&selectedChild=note&reset=1&cid=`$contactId`&id=`$note.id`"}">{ts}(more){/ts}</a>
266 {/if}
267 </td>
268 <td class="crm-note-subject">{$note.subject}</td>
269 <td class="crm-note-modified_date">{$note.modified_date|crmDate}</td>
270 <td class="crm-note-createdBy">
271 <a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$note.contact_id`"}">{$note.createdBy}</a>
272 </td>
273 <td class="crm-note-attachment">
274 {foreach from=$note.attachment item=fileinfo}
275 {$fileinfo}
276 {/foreach}
277 </td>
278 <td class="nowrap">{$note.action|replace:'xx':$note.id}</td>
279 </tr>
280 {/foreach}
281 </table>
282 {/strip}
283 </div>
284 </div>
285 {elseif ($action eq 16)}
286 <div class="messages status no-popup">
287 <div class="icon inform-icon"></div>
288 {capture assign=link}class="action-item medium-popup" accesskey="N" href="{crmURL p='civicrm/contact/view/note' q="cid=`$contactId`&action=add"}"{/capture}
289 {ts 1=$link}There are no Notes for this contact. You can <a %1>add one</a>.{/ts}
290 </div>
291 {/if}
292 </div>
293 </div>