1 [% USE HTML %][% USE LxERP %][% USE L %]
 
   4  <div class="listtop">[% FORM.title %]</div>
 
   6  [%- INCLUDE 'common/flash.html' %]
 
   8  <form method="post" action="controller.pl" enctype="multipart/form-data">
 
   9   [% L.hidden_tag('action', 'CsvImport/dispatch') %]
 
  10   [% L.hidden_tag('profile.type', SELF.profile.type) %]
 
  12   <h2>[%- LxERP.t8('Import profiles') %]</h2>
 
  15    [%- IF SELF.profile.id %]
 
  17      <th align="right">[%- LxERP.t8('Current profile') %]:</th>
 
  18      <td>[%- HTML.escape(SELF.profile.name) %]</td>
 
  22    [%- IF SELF.all_profiles.size %]
 
  24      <th align="right">[%- LxERP.t8('Existing profiles') %]:</th>
 
  26       [% L.select_tag('profile.id', L.options_for_select(SELF.all_profiles, title => 'name', default => SELF.profile.id), style => 'width: 300px') %]
 
  29       [% L.submit_tag('action_new', LxERP.t8('Load profile')) %]
 
  30       [% L.submit_tag('action_destroy', LxERP.t8('Delete profile'), confirm => LxERP.t8('Do you really want to delete this object?')) %]
 
  36     <th align="right" valign="top">[%- LxERP.t8('Save settings as') %]:</th>
 
  38      [% L.input_tag('profile.name', '', style => 'width: 300px') %]
 
  40      [% L.checkbox_tag('profile.is_default', label => LxERP.t8('Make default profile')) %]
 
  42     <td valign="top">[% L.submit_tag('action_save', LxERP.t8('Save profile')) %]</td>
 
  48   <h2>[%- LxERP.t8('Help on column names') %]</h2>
 
  50   <div class="help_toggle">
 
  51    <a href="#" onClick="javascript:$('.help_toggle').toggle()">[% LxERP.t8("Show help text") %]</a>
 
  54   <div class="help_toggle" style="display:none">
 
  55    <p><a href="#" onClick="javascript:$('.help_toggle').toggle()">[% LxERP.t8("Hide help text") %]</a></p>
 
  58     <tr class="listheading">
 
  59      <th>[%- LxERP.t8('Column name') %]</th>
 
  60      <th>[%- LxERP.t8('Meaning') %]</th>
 
  63     [%- FOREACH row = SELF.displayable_columns %]
 
  64      <tr class="listrow[% loop.count % 2 %]">
 
  65       <td>[%- HTML.escape(row.name) %]</td>
 
  66       <td>[%- HTML.escape(row.description) %]</td>
 
  71 [%- IF SELF.type == 'contacts' %]
 
  73     [%- LxERP.t8('At least one of the columns #1, customer, customernumber, vendor, vendornumber (depending on the target table) is required for matching the entry to an existing customer or vendor.', 'cp_cv_id') %]
 
  76 [%- ELSIF SELF.type == 'addresses' %]
 
  78     [%- LxERP.t8('At least one of the columns #1, customer, customernumber, vendor, vendornumber (depending on the target table) is required for matching the entry to an existing customer or vendor.', 'trans_id') %]
 
  81 [%- ELSIF SELF.type == 'parts' %]
 
  83     [%- LxERP.t8("If the article type is set to 'mixed' then a column called 'type' must be present.") %]
 
  84     [% LxERP.t8("Type can be either 'part' or 'service'.") %]
 
  89     [%- L.submit_tag('action_download_sample', LxERP.t8('Download sample file')) %]
 
  96   <h2>[%- LxERP.t8('Settings') %]</h2>
 
 100     <th align="right">[%- LxERP.t8('Number Format') %]:</th>
 
 102      [% SET options = L.options_for_select([ '1.000,00', '1000,00', '1,000.00', '1000.00' ], default => SELF.profile.get('numberformat')) %]
 
 103      [% L.select_tag('settings.numberformat', options, style => 'width: 300px') %]
 
 108     <th align="right">[%- LxERP.t8('Charset') %]:</th>
 
 109     <td colspan="10">[% L.select_tag('settings.charset', L.options_for_select(SELF.all_charsets, default => SELF.profile.get('charset')), style => 'width: 300px') %]</td>
 
 113     <th align="right">[%- LxERP.t8('Separator') %]:</th>
 
 114     [% SET custom_sep_char = SELF.sep_char %]
 
 115     [% FOREACH entry = SELF.all_sep_chars %]
 
 117       [% IF SELF.sep_char == entry.first %] [% SET custom_sep_char = '' %] [%- END %]
 
 118       [% L.radio_button_tag('sep_char', value => entry.first, label => entry.last, checked => SELF.sep_char == entry.first) %]
 
 123      [% L.radio_button_tag('sep_char', value => 'custom', checked => custom_sep_char != '') %]
 
 124      [% L.input_tag('custom_sep_char', custom_sep_char, size => 3, maxlength => 1) %]
 
 129     <th align="right">[%- LxERP.t8('Quote character') %]:</th>
 
 130     [% SET custom_quote_char = SELF.quote_char %]
 
 131     [% FOREACH entry = SELF.all_quote_chars %]
 
 133       [% IF SELF.quote_char == entry.first %] [% SET custom_quote_char = '' %] [%- END %]
 
 134       [% L.radio_button_tag('quote_char', value => entry.first, label => entry.last, checked => SELF.quote_char == entry.first) %]
 
 139      [% L.radio_button_tag('quote_char', value => 'custom', checked => custom_quote_char != '') %]
 
 140      [% L.input_tag('custom_quote_char', custom_quote_char, size => 3, maxlength => 1) %]
 
 145     <th align="right">[%- LxERP.t8('Escape character') %]:</th>
 
 146     [% SET custom_escape_char = SELF.escape_char %]
 
 147     [% FOREACH entry = SELF.all_escape_chars %]
 
 149       [% IF SELF.escape_char == entry.first %] [% SET custom_escape_char = '' %] [%- END %]
 
 150       [% L.radio_button_tag('escape_char', value => entry.first, label => entry.last, checked => SELF.escape_char == entry.first) %]
 
 155      [% L.radio_button_tag('escape_char', value => 'custom', checked => custom_escape_char != '') %]
 
 156      [% L.input_tag('custom_escape_char', custom_escape_char, size => 3, maxlength => 1) %]
 
 161     <th align="right">[%- LxERP.t8('Check for duplicates') %]:</th>
 
 163      [% opts = [ [ 'no_check',  LxERP.t8('Do not check for duplicates') ],
 
 164                  [ 'check_csv', LxERP.t8('Discard duplicate entries in CSV file') ],
 
 165                  [ 'check_db',  LxERP.t8('Discard entries with duplicates in database or CSV file') ] ] %]
 
 166      [% L.select_tag('settings.duplicates', L.options_for_select(opts, default => SELF.profile.get('duplicates')), style => 'width: 300px') %]
 
 170 [%- IF SELF.type == 'parts' %]
 
 171  [%- INCLUDE 'csv_import/_form_parts.html' %]
 
 172 [%- ELSIF SELF.type == 'customers_vendors' %]
 
 173  [%- INCLUDE 'csv_import/_form_customers_vendors.html' %]
 
 177     <th align="right">[%- LxERP.t8('Import file') %]:</th>
 
 178     <td colspan="10">[% L.input_tag('file', '', type => 'file', accept => '*') %]</td>
 
 181    [%- IF SELF.file.exists %]
 
 183      <th align="right">[%- LxERP.t8('Existing file on server') %]:</th>
 
 184      <td colspan="10">[%- LxERP.t8('Uploaded on #1, size #2 kB', SELF.file.displayable_mtime, LxERP.format_amount(SELF.file.size / 1024, 2)) %]</td>
 
 190   [% L.submit_tag('action_test', LxERP.t8('Test and preview')) %]
 
 191   [% IF (SELF.import_status == 'tested') && SELF.num_importable %]
 
 192    [% L.submit_tag('action_import', LxERP.t8('Import')) %]
 
 197  [%- IF SELF.import_status %]
 
 198   [%- IF SELF.errors %]
 
 199    [%- PROCESS 'csv_import/_errors.html' %]
 
 202   [%- PROCESS 'csv_import/_result.html' %]
 
 203   [%- PROCESS 'csv_import/_preview.html' %]
 
 206  <script type="text/javascript">
 
 208     $(document).ready(function() {
 
 209       $('#action_save').click(function() {
 
 210         if ($('#profile_name').attr('value') != '')
 
 212         alert('[% LxERP.t8('Please enter a profile name.') %]');