Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
2c4c49ca | 3 | | CiviCRM version 4.7 | |
6a488035 | 4 | +--------------------------------------------------------------------+ |
e7112fa7 | 5 | | Copyright CiviCRM LLC (c) 2004-2015 | |
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 | {* this template is used for adding/editing/viewing relationships *} | |
39082712 | 27 | |
6a488035 | 28 | {if $action eq 4 } {* action = view *} |
239dac31 CW |
29 | <div class="crm-block crm-content-block crm-relationship-view-block"> |
30 | <table class="crm-info-panel"> | |
31 | {foreach from=$viewRelationship item="row"} | |
32 | <tr> | |
33 | <td class="label">{$row.relation}</td> | |
34 | <td><a class="no-popup" href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.cid`"}">{$row.name}</a></td> | |
35 | </tr> | |
36 | {if $isCurrentEmployer} | |
37 | <tr><td class="label">{ts}Current Employee?{/ts}</td><td>{ts}Yes{/ts}</td></tr> | |
38 | {/if} | |
39 | {if $row.start_date} | |
40 | <tr><td class="label">{ts}Start Date{/ts}</td><td>{$row.start_date|crmDate}</td></tr> | |
41 | {/if} | |
42 | {if $row.end_date} | |
43 | <tr><td class="label">{ts}End Date{/ts}</td><td>{$row.end_date|crmDate}</td></tr> | |
44 | {/if} | |
45 | {if $row.description} | |
46 | <tr><td class="label">{ts}Description{/ts}</td><td>{$row.description}</td></tr> | |
47 | {/if} | |
6a488035 | 48 | {foreach from=$viewNote item="rec"} |
239dac31 CW |
49 | {if $rec } |
50 | <tr><td class="label">{ts}Note{/ts}</td><td>{$rec}</td></tr> | |
6a488035 | 51 | {/if} |
239dac31 CW |
52 | {/foreach} |
53 | <tr> | |
54 | <td class="label"><label>{ts}Permissions{/ts}</label></td> | |
55 | <td> | |
56 | {if $row.is_permission_a_b or $row.is_permission_b_a} | |
57 | {if $row.is_permission_a_b} | |
58 | <div> | |
59 | {if $row.rtype EQ 'a_b' AND $is_contact_id_a} | |
60 | {ts 1=$displayName 2=$row.display_name}<strong>%1</strong> can view and update information about %2.{/ts} | |
61 | {else} | |
62 | {ts 1=$row.display_name 2=$displayName}<strong>%1</strong> can view and update information about %2.{/ts} | |
63 | {/if} | |
64 | </div> | |
65 | {/if} | |
66 | {if $row.is_permission_b_a} | |
67 | <div> | |
68 | {if $row.rtype EQ 'a_b' AND $is_contact_id_a} | |
69 | {ts 1=$row.display_name 2=$displayName}<strong>%1</strong> can view and update information about %2.{/ts} | |
70 | {else} | |
71 | {ts 1=$displayName 2=$row.display_name}<strong>%1</strong> can view and update information about %2.{/ts} | |
72 | {/if} | |
73 | </div> | |
74 | {/if} | |
75 | {else} | |
76 | {ts}None{/ts} | |
77 | {/if} | |
78 | </td> | |
79 | </tr> | |
80 | <tr><td class="label">{ts}Status{/ts}</td><td>{if $row.is_active}{ts}Enabled{/ts}{else}{ts}Disabled{/ts}{/if}</td></tr> | |
6a488035 | 81 | {/foreach} |
239dac31 CW |
82 | </table> |
83 | {include file="CRM/Custom/Page/CustomDataView.tpl"} | |
84 | </div> | |
6a488035 TO |
85 | {/if} |
86 | ||
239dac31 | 87 | {if $action eq 2 or $action eq 1} {* add and update actions *} |
6a488035 | 88 | <div class="crm-block crm-form-block crm-relationship-form-block"> |
239dac31 CW |
89 | <table class="form-layout-compressed"> |
90 | <tr class="crm-relationship-form-block-relationship_type_id"> | |
91 | <td class="label">{$form.relationship_type_id.label}</td> | |
92 | <td>{$form.relationship_type_id.html}</td> | |
93 | </tr> | |
94 | <tr class="crm-relationship-form-block-related_contact_id"> | |
95 | <td class="label">{$form.related_contact_id.label}</td> | |
379d96db | 96 | <td>{$form.related_contact_id.html}</td> |
239dac31 CW |
97 | </tr> |
98 | <tr class="crm-relationship-form-block-is_current_employer" style="display:none;"> | |
99 | <td class="label">{$form.is_current_employer.label}</td> | |
100 | <td>{$form.is_current_employer.html}</td> | |
101 | </tr> | |
102 | <tr class="crm-relationship-form-block-start_date"> | |
103 | <td class="label">{$form.start_date.label}</td> | |
104 | <td>{include file="CRM/common/jcalendar.tpl" elementName=start_date}<span>{$form.end_date.label} {include file="CRM/common/jcalendar.tpl" elementName=end_date}</span><br /> | |
105 | <span class="description">{ts}If this relationship has start and/or end dates, specify them here.{/ts}</span></td> | |
106 | </tr> | |
107 | <tr class="crm-relationship-form-block-description"> | |
108 | <td class="label">{$form.description.label}</td> | |
109 | <td>{$form.description.html}</td> | |
110 | </tr> | |
111 | <tr class="crm-relationship-form-block-note"> | |
112 | <td class="label">{$form.note.label}</td> | |
113 | <td>{$form.note.html}</td> | |
114 | </tr> | |
115 | <tr class="crm-relationship-form-block-is_permission_a_b"> | |
116 | {capture assign="contact_b"}{if $action eq 1}{ts}selected contact(s){/ts}{else}{$display_name_b}{/if}{/capture} | |
117 | <td class="label"><label>{ts}Permissions{/ts}</label></td> | |
118 | <td> | |
119 | {$form.is_permission_a_b.html} | |
120 | {ts 1=$display_name_a 2=$contact_b}<strong>%1</strong> can view and update information about %2.{/ts} | |
121 | </td> | |
122 | </tr> | |
123 | <tr class="crm-relationship-form-block-is_permission_b_a"> | |
124 | <td class="label"></td> | |
125 | <td> | |
126 | {$form.is_permission_b_a.html} | |
127 | {ts 1=$contact_b|ucfirst 2=$display_name_a}<strong>%1</strong> can view and update information about %2.{/ts} | |
128 | </td> | |
129 | </tr> | |
130 | <tr class="crm-relationship-form-block-is_active"> | |
131 | <td class="label">{$form.is_active.label}</td> | |
132 | <td>{$form.is_active.html}</td> | |
133 | </tr> | |
134 | </table> | |
135 | <div id="customData"></div> | |
136 | <div class="spacer"></div> | |
137 | </div> | |
138 | {/if} | |
139 | {if ($action EQ 1) OR ($action EQ 2) } | |
13d9bc82 CW |
140 | {*include custom data js file *} |
141 | {include file="CRM/common/customData.tpl"} | |
239dac31 CW |
142 | <script type="text/javascript"> |
143 | {literal} | |
3cc60a06 | 144 | CRM.$(function($) { |
239dac31 | 145 | var |
b50fdacc | 146 | $form = $("form.{/literal}{$form.formClass}{literal}"), |
239dac31 CW |
147 | relationshipData = {/literal}{$relationshipData|@json_encode}{literal}; |
148 | $('[name=relationship_type_id]', $form).change(function() { | |
149 | var | |
150 | val = $(this).val(), | |
379d96db | 151 | $contactField = $('#related_contact_id[type=text]', $form); |
239dac31 CW |
152 | if (!val && $contactField.length) { |
153 | $contactField | |
154 | .prop('disabled', true) | |
379d96db CW |
155 | .attr('placeholder', {/literal}'{ts escape='js'}- first select relationship type -{/ts}'{literal}) |
156 | .change(); | |
239dac31 CW |
157 | } |
158 | else if (val) { | |
159 | var | |
160 | pieces = val.split('_'), | |
161 | rType = pieces[0], | |
162 | source = pieces[1], // a or b | |
163 | target = pieces[2], // b or a | |
164 | contact_type = relationshipData[rType]['contact_type_' + target], | |
165 | contact_sub_type = relationshipData[rType]['contact_sub_type_' + target]; | |
166 | // ContactField only exists for ADD action, not update | |
167 | if ($contactField.length) { | |
379d96db | 168 | var api = {params: {}}; |
239dac31 | 169 | if (contact_type) { |
379d96db | 170 | api.params.contact_type = contact_type; |
239dac31 CW |
171 | } |
172 | if (contact_sub_type) { | |
379d96db | 173 | api.params.contact_sub_type = contact_sub_type; |
239dac31 CW |
174 | } |
175 | $contactField | |
176 | .val('') | |
177 | .prop('disabled', false) | |
379d96db | 178 | .data('api-params', api) |
b7ceb253 | 179 | .data('user-filter', {}) |
379d96db CW |
180 | .attr('placeholder', relationshipData[rType]['placeholder_' + target]) |
181 | .change(); | |
239dac31 | 182 | } |
6a488035 | 183 | |
239dac31 CW |
184 | // Show/hide employer field |
185 | $('.crm-relationship-form-block-is_current_employer', $form).toggle(rType === {/literal}'{$employmentRelationship}'{literal}); | |
6a488035 | 186 | |
239dac31 CW |
187 | // Swap the permission checkboxes to match selected relationship direction |
188 | $('#is_permission_a_b', $form).attr('name', 'is_permission_' + source + '_' + target); | |
189 | $('#is_permission_b_a', $form).attr('name', 'is_permission_' + target + '_' + source); | |
6a488035 | 190 | |
239dac31 CW |
191 | CRM.buildCustomData('Relationship', rType); |
192 | } | |
193 | }).change(); | |
194 | }); | |
195 | {/literal} | |
196 | </script> | |
6a488035 TO |
197 | {/if} |
198 | ||
199 | {if $action eq 8} | |
239dac31 CW |
200 | <div class="status"> |
201 | {ts}Are you sure you want to delete this Relationship?{/ts} | |
202 | </div> | |
6a488035 | 203 | {/if} |
239dac31 | 204 | <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div> |