Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
39de6fd5 | 3 | | CiviCRM version 4.6 | |
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 | {* tpl for building Individual related fields *} | |
27 | <script type="text/javascript"> | |
28 | {literal} | |
3cc60a06 | 29 | CRM.$(function($) { |
6267d9d6 CW |
30 | {/literal} |
31 | var cid = "{$contactId}", | |
32 | viewIndividual = "{crmURL p='civicrm/contact/view' q='reset=1&cid=' h=0}", | |
33 | checkSimilar = {$checkSimilar}, | |
34 | lastnameMsg; | |
35 | {literal} | |
36 | if ($('#contact_sub_type *').length == 0) {//if they aren't any subtype we don't offer the option | |
37 | $('#contact_sub_type').parent().hide(); | |
38 | } | |
39 | if (cid.length || !checkSimilar) { | |
40 | return;//no dupe check if this is a modif or if checkSimilar is disabled (contact_ajax_check_similar in civicrm_setting table) | |
41 | } | |
42 | $('#last_name').change(function() { | |
43 | // Close msg if it exists | |
44 | lastnameMsg && lastnameMsg.close && lastnameMsg.close(); | |
45 | if (this.value == '') return; | |
46 | CRM.api3('contact', 'get', { | |
47 | sort_name: $('#last_name').val(), | |
48 | contact_type: 'Individual', | |
49 | 'return': 'display_name,sort_name,email' | |
32f43226 CW |
50 | }).done(function(data) { |
51 | var title = data.count == 1 ? {/literal}"{ts escape='js'}Similar Contact Found{/ts}" : "{ts escape='js'}Similar Contacts Found{/ts}"{literal}, | |
52 | msg = "<em>{/literal}{ts escape='js'}If the person you were trying to add is listed below, click their name to view or edit their record{/ts}{literal}:</em>"; | |
53 | if (data.is_error == 1 || data.count == 0) { | |
54 | return; | |
55 | } | |
56 | msg += '<ul class="matching-contacts-actions">'; | |
57 | $.each(data.values, function(i, contact) { | |
58 | contact.email = contact.email || ''; | |
6267d9d6 CW |
59 | msg += '<li><a href="'+viewIndividual+contact.id+'">'+ contact.display_name +'</a> '+contact.email+'</li>'; |
60 | }); | |
61 | msg += '</ul>'; | |
62 | lastnameMsg = CRM.alert(msg, title); | |
32f43226 | 63 | $('.matching-contacts-actions a').click(function() { |
6267d9d6 | 64 | // No confirmation dialog on click |
abb6e044 | 65 | $('[data-warn-changes=true]').attr('data-warn-changes', 'false'); |
6a488035 TO |
66 | }); |
67 | }); | |
68 | }); | |
69 | }); | |
70 | </script> | |
71 | {/literal} | |
72 | ||
73 | <table class="form-layout-compressed"> | |
74 | <tr> | |
75 | {if $form.prefix_id} | |
76 | <td> | |
77 | {$form.prefix_id.label}<br/> | |
78 | {$form.prefix_id.html} | |
32f43226 | 79 | </td> |
6a488035 | 80 | {/if} |
e171748b OB |
81 | {if $form.formal_title} |
82 | <td> | |
83 | {$form.formal_title.label}<br/> | |
84 | {$form.formal_title.html} | |
85 | </td> | |
86 | {/if} | |
8b49cb50 | 87 | {if $form.first_name} |
6a488035 | 88 | <td> |
31037a42 | 89 | {$form.first_name.label}<br /> |
6a488035 TO |
90 | {$form.first_name.html} |
91 | </td> | |
8b49cb50 OB |
92 | {/if} |
93 | {if $form.middle_name} | |
6a488035 TO |
94 | <td> |
95 | {$form.middle_name.label}<br /> | |
96 | {$form.middle_name.html} | |
97 | </td> | |
8b49cb50 OB |
98 | {/if} |
99 | {if $form.last_name} | |
6a488035 TO |
100 | <td> |
101 | {$form.last_name.label}<br /> | |
102 | {$form.last_name.html} | |
103 | </td> | |
8b49cb50 | 104 | {/if} |
6a488035 TO |
105 | {if $form.suffix_id} |
106 | <td> | |
107 | {$form.suffix_id.label}<br/> | |
108 | {$form.suffix_id.html} | |
109 | </td> | |
110 | {/if} | |
111 | </tr> | |
112 | ||
113 | <tr> | |
114 | <td colspan="2"> | |
66aa3a9f CW |
115 | {$form.employer_id.label} {help id="id-current-employer" file="CRM/Contact/Form/Contact.hlp"}<br /> |
116 | {$form.employer_id.html} | |
6a488035 TO |
117 | </td> |
118 | <td> | |
119 | {$form.job_title.label}<br /> | |
120 | {$form.job_title.html} | |
121 | </td> | |
122 | <td> | |
123 | {$form.nick_name.label}<br /> | |
124 | {$form.nick_name.html} | |
125 | </td> | |
126 | <td> | |
127 | {if $buildContactSubType} | |
128 | {$form.contact_sub_type.label}<br /> | |
129 | {$form.contact_sub_type.html} | |
130 | {/if} | |
131 | </td> | |
132 | </tr> | |
133 | </table> |