2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.4 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2013 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
26 <div class="view-content">
27 {if $action eq 4}{* when action is view *}
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>
37 {if $currentAttachmentInfo}
38 {include file="CRM/Form/attachment.tpl"}
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>
45 <legend>{ts}Comments{/ts}</legend>
46 <table class="display">
48 <tr><th>{ts}Comment{/ts}</th><th>{ts}Created By{/ts}</th><th>{ts}Date{/ts}</th></tr>
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>
59 {elseif $action eq 1 or $action eq 2} {* action is add or update *}
62 {if $action eq 1}{ts}New Comment{/ts}{else}{ts}Edit Comment{/ts}{/if}
64 {if $action eq 1}{ts}New Note{/ts}{else}{ts}Edit Note{/ts}{/if}
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">
71 <td class="label">{$form.subject.label}</td>
77 <td class="label">{$form.privacy.label}</td>
83 <td class="label">{$form.note.label}</td>
88 <tr class="crm-activity-form-block-attachment">
90 {include file="CRM/Form/attachment.tpl"}
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>
100 {* include jscript to warn if unsaved form field changes *}
101 {include file="CRM/common/formNavigate.tpl"}
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>
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>
115 <div class="clear"></div>
117 <div class="crm-content-block">
121 <script type="text/javascript">
122 var commentAction = '{$commentAction|escape:quotes}'
125 var commentRows = {};
127 function showHideComments( noteId ) {
129 elRow = cj('tr#cnote_'+ noteId)
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');
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' );
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);
150 row.addClass('view-comments');
152 if (row.hasClass('odd') ) {
153 var rowClassOddEven = 'odd'
155 var rowClassOddEven = 'even'
158 if ( commentRows['cnote_'+ noteId] ) {
159 for ( var i in commentRows['cnote_'+ noteId] ) {
163 commentRows['cnote_'+ noteId] = {};
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] ) {
171 str = '<tr id="cnote_'+ response['values'][i].id +'" class="'+ rowClassOddEven +' note-comment_'+ noteId +'">'
173 + '<td style="padding-left: 2em">'
174 + response['values'][i].note
176 + response['values'][i].subject
178 + response['values'][i].modified_date
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>'
183 commentRows['cnote_'+ noteId][response['values'][i].id] = str;
186 drawCommentRows('cnote_'+ noteId);
188 cj('tr#cnote_'+ noteId +' span.icon_comments_show').hide();
189 cj('tr#cnote_'+ noteId +' span.icon_comments_hide').show();
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');
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);
207 <div class="crm-results-block">
208 {* show browse table for any action *}
211 {include file="CRM/common/jsortable.tpl"}
213 <script type="text/javascript">
215 cj(document).ready( function() {
216 var tabId = cj.fn.dataTableSettings[0].sInstance;
218 cj('table#'+ tabId).dataTable().fnSettings().aoDrawCallback.push( {
220 cj('#'+ tabId +' tr').each( function() {
221 drawCommentRows(this.id)
231 <table id="options" class="display">
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>
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>
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>
254 <span class="ui-icon ui-icon-triangle-1-e" id="{$note.id}_hide" style="display:none"></span>
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}
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>
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>
270 <td class="nowrap">{$note.action|replace:'xx':$note.id}</td>
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}