| 1 | {* |
| 2 | +--------------------------------------------------------------------+ |
| 3 | | CiviCRM version 4.4 | |
| 4 | +--------------------------------------------------------------------+ |
| 5 | | Copyright CiviCRM LLC (c) 2004-2013 | |
| 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} |
| 29 | cj(function($) { |
| 30 | {/literal} |
| 31 | var cid=parseFloat("{$contactId}");//parseInt is octal by default |
| 32 | var contactIndividual = "{crmURL p='civicrm/ajax/rest' q='entity=contact&action=get&json=1&contact_type=Individual&return=display_name,sort_name,email&rowCount=50' h=0}"; |
| 33 | var viewIndividual = "{crmURL p='civicrm/contact/view' q='reset=1&cid=' h=0}"; |
| 34 | var editIndividual = "{crmURL p='civicrm/contact/add' q='reset=1&action=update&cid=' h=0}"; |
| 35 | var checkSimilar = {$checkSimilar}; |
| 36 | var lastnameMsg; |
| 37 | {literal} |
| 38 | $(document).ready(function() { |
| 39 | if (cj('#contact_sub_type *').length == 0) {//if they aren't any subtype we don't offer the option |
| 40 | cj('#contact_sub_type').parent().hide(); |
| 41 | } |
| 42 | if (!isNaN(cid) || ! checkSimilar) { |
| 43 | return;//no dupe check if this is a modif or if checkSimilar is disabled (contact_ajax_check_similar in civicrm_setting table) |
| 44 | } |
| 45 | cj('#last_name').blur(function () { |
| 46 | // Close msg if it exists |
| 47 | lastnameMsg && lastnameMsg.close && lastnameMsg.close(); |
| 48 | if (this.value == '') return; |
| 49 | cj.getJSON(contactIndividual,{sort_name:cj('#last_name').val()}, |
| 50 | function(data){ |
| 51 | if (data.is_error == 1 || data.count == 0) { |
| 52 | return; |
| 53 | } |
| 54 | var 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>"; |
| 55 | if ( data.count == 1 ) { |
| 56 | var title = "{/literal}{ts escape='js'}Similar Contact Found{/ts}{literal}"; |
| 57 | } else { |
| 58 | var title = "{/literal}{ts escape='js'}Similar Contacts Found{/ts}{literal}"; |
| 59 | } |
| 60 | msg += '<ul class="matching-contacts-actions">'; |
| 61 | cj.each(data.values, function(i,contact){ |
| 62 | if ( !(contact.email) ) { |
| 63 | contact.email = ''; |
| 64 | } |
| 65 | msg += '<li><a href="'+viewIndividual+contact.id+'">'+ contact.display_name +'</a> '+contact.email+'</li>'; |
| 66 | }); |
| 67 | msg += '</ul>'; |
| 68 | lastnameMsg = CRM.alert(msg, title); |
| 69 | cj('.matching-contacts-actions a').click(function(){ |
| 70 | // No confirmation dialog on click |
| 71 | global_formNavigate = true; |
| 72 | return true; |
| 73 | }); |
| 74 | }); |
| 75 | }); |
| 76 | }); |
| 77 | }); |
| 78 | </script> |
| 79 | {/literal} |
| 80 | |
| 81 | <table class="form-layout-compressed"> |
| 82 | <tr> |
| 83 | {if $form.prefix_id} |
| 84 | <td> |
| 85 | {$form.prefix_id.label}<br/> |
| 86 | {$form.prefix_id.html} |
| 87 | </td> |
| 88 | {/if} |
| 89 | {if $form.formal_title} |
| 90 | <td> |
| 91 | {$form.formal_title.label}<br/> |
| 92 | {$form.formal_title.html} |
| 93 | </td> |
| 94 | {/if} |
| 95 | {if $form.first_name} |
| 96 | <td> |
| 97 | {$form.first_name.label}<br /> |
| 98 | {$form.first_name.html} |
| 99 | </td> |
| 100 | {/if} |
| 101 | {if $form.middle_name} |
| 102 | <td> |
| 103 | {$form.middle_name.label}<br /> |
| 104 | {$form.middle_name.html} |
| 105 | </td> |
| 106 | {/if} |
| 107 | {if $form.last_name} |
| 108 | <td> |
| 109 | {$form.last_name.label}<br /> |
| 110 | {$form.last_name.html} |
| 111 | </td> |
| 112 | {/if} |
| 113 | {if $form.suffix_id} |
| 114 | <td> |
| 115 | {$form.suffix_id.label}<br/> |
| 116 | {$form.suffix_id.html} |
| 117 | </td> |
| 118 | {/if} |
| 119 | </tr> |
| 120 | |
| 121 | <tr> |
| 122 | <td colspan="2"> |
| 123 | {$form.current_employer.label} {help id="id-current-employer" file="CRM/Contact/Form/Contact.hlp"}<br /> |
| 124 | {$form.current_employer.html|crmAddClass:twenty} |
| 125 | <div id="employer_address" style="display:none;"></div> |
| 126 | </td> |
| 127 | <td> |
| 128 | {$form.job_title.label}<br /> |
| 129 | {$form.job_title.html} |
| 130 | </td> |
| 131 | <td> |
| 132 | {$form.nick_name.label}<br /> |
| 133 | {$form.nick_name.html} |
| 134 | </td> |
| 135 | <td> |
| 136 | {if $buildContactSubType} |
| 137 | {$form.contact_sub_type.label}<br /> |
| 138 | {$form.contact_sub_type.html} |
| 139 | {/if} |
| 140 | </td> |
| 141 | </tr> |
| 142 | </table> |
| 143 | |
| 144 | {include file="CRM/Contact/Form/CurrentEmployer.tpl"} |