| 1 | {* |
| 2 | +--------------------------------------------------------------------+ |
| 3 | | CiviCRM version 4.7 | |
| 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 | <div class="crm-block crm-form-block crm-import-datasource-form-block"> |
| 28 | {if $showOnlyDataSourceFormPane} |
| 29 | {include file=$dataSourceFormTemplateFile} |
| 30 | {else} |
| 31 | {* Import Wizard - Step 1 (choose data source) *} |
| 32 | {* @var $form Contains the array for the form elements and other form associated information assigned to the template by the controller *} |
| 33 | |
| 34 | {* WizardHeader.tpl provides visual display of steps thru the wizard as well as title for current step *} |
| 35 | {include file="CRM/common/WizardHeader.tpl"} |
| 36 | <div id="help"> |
| 37 | {ts}The Import Wizard allows you to easily import contact records from other applications into CiviCRM. For example, if your organization has contacts in MS Access® or Excel®, and you want to start using CiviCRM to store these contacts, you can 'import' them here.{/ts} {help id='choose-data-source-intro'} |
| 38 | </div> |
| 39 | <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div> |
| 40 | <div id="choose-data-source" class="form-item"> |
| 41 | <h3>{ts}Choose Data Source{/ts}</h3> |
| 42 | <table class="form-layout"> |
| 43 | <tr class="crm-import-datasource-form-block-dataSource"> |
| 44 | <td class="label">{$form.dataSource.label}</td> |
| 45 | <td>{$form.dataSource.html} {help id='data-source-selection'}</td> |
| 46 | </tr> |
| 47 | </table> |
| 48 | </div> |
| 49 | |
| 50 | {* Data source form pane is injected here when the data source is selected. *} |
| 51 | <div id="data-source-form-block"> |
| 52 | {if $dataSourceFormTemplateFile} |
| 53 | {include file=$dataSourceFormTemplateFile} |
| 54 | {/if} |
| 55 | </div> |
| 56 | |
| 57 | <div id="common-form-controls" class="form-item"> |
| 58 | <h3>{ts}Import Options{/ts}</h3> |
| 59 | <table class="form-layout-compressed"> |
| 60 | <tr class="crm-import-datasource-form-block-contactType"> |
| 61 | <td class="label">{$form.contactType.label}</td> |
| 62 | <td>{$form.contactType.html} {help id='contact-type'} |
| 63 | <span id="contact-subtype">{$form.subType.label} {$form.subType.html} {help id='contact-sub-type'}</span></td> |
| 64 | </tr> |
| 65 | <tr class="crm-import-datasource-form-block-onDuplicate"> |
| 66 | <td class="label">{$form.onDuplicate.label}</td> |
| 67 | <td>{$form.onDuplicate.html} {help id='dupes'}</td> |
| 68 | </tr> |
| 69 | <tr class="crm-import-datasource-form-block-dedupe"> |
| 70 | <td class="label">{$form.dedupe.label}</td> |
| 71 | <td><span id="contact-dedupe">{$form.dedupe.html}</span> {help id='id-dedupe_rule'}</td> |
| 72 | </tr> |
| 73 | <tr class="crm-import-datasource-form-block-fieldSeparator"> |
| 74 | <td class="label">{$form.fieldSeparator.label}</td> |
| 75 | <td>{$form.fieldSeparator.html} {help id='id-fieldSeparator'}</td> |
| 76 | </tr> |
| 77 | <tr>{include file="CRM/Core/Date.tpl"}</tr> |
| 78 | <tr> |
| 79 | <td></td><td class="description">{ts}Select the format that is used for date fields in your import data.{/ts}</td> |
| 80 | </tr> |
| 81 | |
| 82 | {if $geoCode} |
| 83 | <tr class="crm-import-datasource-form-block-doGeocodeAddress"> |
| 84 | <td class="label"></td> |
| 85 | <td>{$form.doGeocodeAddress.html} {$form.doGeocodeAddress.label}<br /> |
| 86 | <span class="description"> |
| 87 | {ts}This option is not recommended for large imports. Use the command-line geocoding script instead.{/ts} |
| 88 | </span> |
| 89 | {docURL page="Managing Scheduled Jobs" resource="wiki"} |
| 90 | </td> |
| 91 | </tr> |
| 92 | {/if} |
| 93 | |
| 94 | {if $savedMapping} |
| 95 | <tr class="crm-import-datasource-form-block-savedMapping"> |
| 96 | <td class="label"><label for="savedMapping">{if $loadedMapping}{ts}Select a Different Field Mapping{/ts}{else}{ts}Load Saved Field Mapping{/ts}{/if}</label></td> |
| 97 | <td>{$form.savedMapping.html}<br /> |
| 98 | <span class="description">{ts}Select Saved Mapping or Leave blank to create a new One.{/ts}</span></td> |
| 99 | </tr> |
| 100 | { /if} |
| 101 | </table> |
| 102 | </div> |
| 103 | |
| 104 | <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"} </div> |
| 105 | |
| 106 | {literal} |
| 107 | <script type="text/javascript"> |
| 108 | CRM.$(function($) { |
| 109 | //build data source form block |
| 110 | buildDataSourceFormBlock(); |
| 111 | buildSubTypes(); |
| 112 | buildDedupeRules(); |
| 113 | }); |
| 114 | |
| 115 | function buildDataSourceFormBlock(dataSource) |
| 116 | { |
| 117 | var dataUrl = {/literal}"{crmURL p=$urlPath h=0 q=$urlPathVar}"{literal}; |
| 118 | |
| 119 | if (!dataSource ) { |
| 120 | var dataSource = cj("#dataSource").val(); |
| 121 | } |
| 122 | |
| 123 | if ( dataSource ) { |
| 124 | dataUrl = dataUrl + '&dataSource=' + dataSource; |
| 125 | } else { |
| 126 | cj("#data-source-form-block").html( '' ); |
| 127 | return; |
| 128 | } |
| 129 | |
| 130 | cj("#data-source-form-block").load( dataUrl ); |
| 131 | } |
| 132 | |
| 133 | function buildSubTypes( ) |
| 134 | { |
| 135 | element = cj('input[name="contactType"]:checked').val( ); |
| 136 | var postUrl = {/literal}"{crmURL p='civicrm/ajax/subtype' h=0 }"{literal}; |
| 137 | var param = 'parentId='+ element; |
| 138 | cj.ajax({ type: "POST", url: postUrl, data: param, async: false, dataType: 'json', |
| 139 | |
| 140 | success: function(subtype){ |
| 141 | if ( subtype.length == 0 ) { |
| 142 | cj("#subType").empty(); |
| 143 | cj("#contact-subtype").hide(); |
| 144 | } else { |
| 145 | cj("#contact-subtype").show(); |
| 146 | cj("#subType").empty(); |
| 147 | |
| 148 | cj("#subType").append("<option value=''>- {/literal}{ts escape='js'}select{/ts}{literal} -</option>"); |
| 149 | for ( var key in subtype ) { |
| 150 | // stick these new options in the subtype select |
| 151 | cj("#subType").append("<option value="+key+">"+subtype[key]+" </option>"); |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | |
| 156 | } |
| 157 | }); |
| 158 | |
| 159 | } |
| 160 | |
| 161 | function buildDedupeRules( ) |
| 162 | { |
| 163 | element = cj("input[name=contactType]:checked").val(); |
| 164 | var postUrl = {/literal}"{crmURL p='civicrm/ajax/dedupeRules' h=0 }"{literal}; |
| 165 | var param = 'parentId='+ element; |
| 166 | cj.ajax({ type: "POST", url: postUrl, data: param, async: false, dataType: 'json', |
| 167 | |
| 168 | success: function(dedupe){ |
| 169 | if ( dedupe.length == 0 ) { |
| 170 | cj("#dedupe").empty(); |
| 171 | cj("#contact-dedupe").hide(); |
| 172 | } else { |
| 173 | cj("#contact-dedupe").show(); |
| 174 | cj("#dedupe").empty(); |
| 175 | |
| 176 | cj("#dedupe").append("<option value=''>- {/literal}{ts escape='js'}select{/ts}{literal} -</option>"); |
| 177 | for ( var key in dedupe ) { |
| 178 | // stick these new options in the dedupe select |
| 179 | cj("#dedupe").append("<option value="+key+">"+dedupe[key]+" </option>"); |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | |
| 184 | } |
| 185 | }); |
| 186 | |
| 187 | } |
| 188 | |
| 189 | </script> |
| 190 | {/literal} |
| 191 | {/if} |
| 192 | </div> |