commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / civicrm / templates / CRM / Admin / Page / Tag.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.6 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2015 |
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
27 {capture assign=docLink}{docURL page="user/organising-your-data/groups-and-tags"}{/capture}
28
29 {if $action eq 1 or $action eq 2 or $action eq 8}
30 {include file="CRM/Admin/Form/Tag.tpl"}
31 {else}
32 <div class="crm-content-block">
33 <div id="help">
34 {ts 1=$docLink}Tags can be assigned to any contact record, and are a convenient way to find contacts. You can create as many tags as needed to organize and segment your records.{/ts} {$docLink}
35 </div>
36
37 {if $rows}
38 {if !($action eq 1 and $action eq 2)}
39 <div class="crm-submit-buttons">
40 <div class="action-link">
41 {crmButton q="action=add&reset=1" id="newTag" icon="circle-plus"}{ts}Add Tag{/ts}{/crmButton}
42 {if $adminTagSet}
43 {crmButton q="action=add&reset=1&tagset=1" id="newTagSet" icon="circle-plus"}{ts}Add Tag Set{/ts}{/crmButton}
44 {/if}
45 </div>
46 </div>
47 {/if}
48
49 {include file="CRM/common/jsortable.tpl"}
50 <div id="merge_tag_status"></div>
51 <div id="cat">
52 {strip}
53 <table id="options" class="display">
54 <thead>
55 <tr>
56 <th>{ts}Tag{/ts}</th>
57 <th>{ts}ID{/ts}</th>
58 <th id="nosort">{ts}Description{/ts}</th>
59 <th>{ts}Parent (ID){/ts}</th>
60 <th>{ts}Used For{/ts}</th>
61 <th>{ts}Tag set?{/ts}</th>
62 <th>{ts}Reserved?{/ts}</th>
63 <th></th>
64 </tr>
65 </thead>
66 {foreach from=$rows item=row key=id }
67 <tr class="{cycle values="odd-row,even-row"} {$row.class} crm-tag crm-entity" id="tag-{$row.id}">
68 <td class="crm-tag-name crm-editable crmf-name">{$row.name}</td>
69 <td class="crm-tag-id">{$row.id}</td>
70 <td class="crm-tag-description crm-editable crmf-description">{$row.description} </td>
71 <td class="crm-tag-parent">{$row.parent}{if $row.parent_id} ({$row.parent_id}){/if}</td>
72 <td class="crm-tag-used_for">{$row.used_for}</td>
73 <td class="crm-tag-is_tagset">{if $row.is_tagset}<img src="{$config->resourceBase}i/check.gif" alt="{ts}Tag Set{/ts}" />{/if}</td>
74 <td class="crm-tag-is_reserved">{if $row.is_reserved}<img src="{$config->resourceBase}i/check.gif" alt="{ts}Reserved{/ts}" />{/if}</td>
75 <td>{$row.action|replace:'xx':$row.id}</td>
76 </tr>
77 {/foreach}
78 </table>
79 {/strip}
80 </div>
81 {if !($action eq 1 and $action eq 2)}
82 <div class="crm-submit-buttons">
83 <div class="action-link">
84 {crmButton q="action=add&reset=1" id="newTag" icon="circle-plus"}{ts}Add Tag{/ts}{/crmButton}
85 {if $adminTagSet}
86 {crmButton q="action=add&reset=1&tagset=1" id="newTagSet" icon="circle-plus"}{ts}Add Tag Set{/ts}{/crmButton}
87 {/if}
88 </div>
89 </div>
90 {/if}
91 {else}
92 <div class="messages status no-popup">
93 <div class="icon inform-icon"></div>&nbsp;
94 {capture assign=crmURL}{crmURL p='civicrm/admin/tag' q="action=add&reset=1"}{/capture}
95 {ts 1=$crmURL}There are no Tags present. You can <a href='%1'>add one</a>.{/ts}
96 </div>
97 {/if}
98
99 </div>
100
101 {literal}
102 <script type="text/javascript">
103 CRM.$(function($) {
104 var tag;
105 $('.merge_tag').click(function(e) {
106 tag = $(this).crmEditableEntity();
107 mergeTagDialog();
108 e.preventDefault();
109 });
110
111 function mergeTagDialog() {
112 var tagUrl = {/literal}"{crmURL p='civicrm/ajax/mergeTagList' h=0}"{literal};
113 var title = {/literal}'{ts escape="js" 1="%1"}Merge tag %1 into:{/ts}'{literal};
114 CRM.confirm({
115 title: ts(title, {1: tag.name}),
116 message: '<input name="select_merge_tag" class="big" />',
117 open: function() {
118 var dialog = this;
119 $('input[name=select_merge_tag]', dialog)
120 .crmSelect2({
121 placeholder: {/literal}'{ts escape="js"}- select tag -{/ts}'{literal},
122 minimumInputLength: 1,
123 ajax: {
124 url: tagUrl,
125 data: function(term) {
126 return {term: term, fromId: tag.id};
127 },
128 results: function(response) {
129 return {results: response};
130 }
131 }
132 })
133 .change(function() {
134 $('.messages', dialog).remove();
135 if ($(this).val() && $(this).select2('data').warning) {
136 $(dialog).append('<div class="messages status">{/literal}{ts escape='js'}Note: the selected tag is used by additional entities.{/ts}{literal}</div>');
137 }
138 });
139 }
140 })
141 .on('dialogclose', function() {
142 $('input[name=select_merge_tag]', this).select2('destroy');
143 })
144 .on('crmConfirm:yes', function() {
145 var toId = $("input[name=select_merge_tag]", this).val();
146 if (!toId) {
147 $("input[name=select_merge_tag]", this).crmError('{/literal}{ts escape='js'}Select a tag{/ts}{literal}');
148 return false;
149 }
150 var postUrl = {/literal}"{crmURL p='civicrm/ajax/mergeTags' h=0 }"{literal};
151 var data = {fromId: tag.id, toId: toId, key:{/literal}"{crmKey name='civicrm/ajax/mergeTags'}"{literal}};
152 $.ajax({
153 type: "POST",
154 url: postUrl,
155 data: data,
156 dataType: "json",
157 success: function(values) {
158 if ( values.status == true ) {
159 $('#tag-' + toId).children('td.crm-tag-used_for').text(values.tagB_used_for);
160 $('#tag-' + tag.id).html('<td colspan="8"><div class="status message"><div class="icon inform-icon"></div>' + values.message + '</div></td>');
161 }
162 }
163 });
164 });
165 }
166 });
167 </script>
168 {/literal}
169
170 {/if}