CSV-Import: Auswahl der Felder für die Duplikat-Prüfung
[kivitendo-erp.git] / templates / webpages / csv_import / form.html
1 [%- USE HTML %]
2 [%- USE LxERP %]
3 [%- USE L %]
4 [%- USE T8 %]
5 <body>
6
7  <div class="listtop">[% FORM.title %]</div>
8
9  [%- INCLUDE 'common/flash.html' %]
10
11  <form method="post" action="controller.pl" enctype="multipart/form-data">
12   [% L.hidden_tag('form_sent', '1') %]
13   [% L.hidden_tag('action', 'CsvImport/dispatch') %]
14   [% L.hidden_tag('profile.type', SELF.profile.type) %]
15
16   <h2>[%- LxERP.t8('Import profiles') %]</h2>
17
18   <table>
19    [%- IF SELF.profile.id %]
20     <tr>
21      <th align="right">[%- LxERP.t8('Current profile') %]:</th>
22      <td>[%- HTML.escape(SELF.profile.name) %]</td>
23     </tr>
24    [%- END %]
25
26    [%- IF SELF.all_profiles.size %]
27     <tr>
28      <th align="right">[%- LxERP.t8('Existing profiles') %]:</th>
29      <td>
30       [% L.select_tag('profile.id', L.options_for_select(SELF.all_profiles, title => 'name', default => SELF.profile.id), style => 'width: 300px') %]
31      </td>
32      <td>
33       [% L.submit_tag('action_new', LxERP.t8('Load profile')) %]
34       [% L.submit_tag('action_destroy', LxERP.t8('Delete profile'), confirm => LxERP.t8('Do you really want to delete this object?')) %]
35      </td>
36     </tr>
37    [%- END %]
38
39    <tr>
40     <th align="right" valign="top">[%- LxERP.t8('Save settings as') %]:</th>
41     <td valign="top">
42      [% L.input_tag('profile.name', '', style => 'width: 300px') %]
43      <br>
44      [% L.checkbox_tag('profile.is_default', label => LxERP.t8('Make default profile')) %]
45     </td>
46     <td valign="top">[% L.submit_tag('action_save', LxERP.t8('Save profile')) %]</td>
47    </tr>
48   </table>
49
50   <hr>
51
52   <h2>[%- LxERP.t8('Help on column names') %]</h2>
53
54   <div class="help_toggle">
55    <a href="#" onClick="javascript:$('.help_toggle').toggle()">[% LxERP.t8("Show help text") %]</a>
56   </div>
57
58   <div class="help_toggle" style="display:none">
59    <p><a href="#" onClick="javascript:$('.help_toggle').toggle()">[% LxERP.t8("Hide help text") %]</a></p>
60
61    <table>
62     <tr class="listheading">
63      <th>[%- LxERP.t8('Column name') %]</th>
64      <th>[%- LxERP.t8('Meaning') %]</th>
65     </tr>
66
67     [%- FOREACH row = SELF.displayable_columns %]
68      <tr class="listrow[% loop.count % 2 %]">
69       <td>[%- HTML.escape(row.name) %]</td>
70       <td>[%- HTML.escape(row.description) %]</td>
71      </tr>
72     [%- END %]
73    </table>
74
75 [%- IF SELF.type == 'contacts' %]
76    <p>
77     [%- 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') %]
78    </p>
79
80 [%- ELSIF SELF.type == 'addresses' %]
81    <p>
82     [%- 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') %]
83    </p>
84
85 [%- ELSIF SELF.type == 'parts' %]
86    <p>
87     [%- LxERP.t8("If the article type is set to 'mixed' then a column called 'type' must be present.") %]
88     [% LxERP.t8("Type can be either 'part' or 'service'.") %]
89    </p>
90 [%- END %]
91
92    <p>
93     [%- L.submit_tag('action_download_sample', LxERP.t8('Download sample file')) %]
94    </p>
95
96   </div>
97
98   <hr>
99
100   <h2>[%- LxERP.t8('Settings') %]</h2>
101
102   <table>
103    <tr>
104     <th align="right">[%- LxERP.t8('Number Format') %]:</th>
105     <td colspan="10">
106      [% SET options = L.options_for_select([ '1.000,00', '1000,00', '1,000.00', '1000.00' ], default => SELF.profile.get('numberformat')) %]
107      [% L.select_tag('settings.numberformat', options, style => 'width: 300px') %]
108     </td>
109    </tr>
110
111    <tr>
112     <th align="right">[%- LxERP.t8('Charset') %]:</th>
113     <td colspan="10">[% L.select_tag('settings.charset', L.options_for_select(SELF.all_charsets, default => SELF.profile.get('charset')), style => 'width: 300px') %]</td>
114    </tr>
115
116    <tr>
117     <th align="right">[%- LxERP.t8('Separator') %]:</th>
118     [% SET custom_sep_char = SELF.sep_char %]
119     [% FOREACH entry = SELF.all_sep_chars %]
120      <td>
121       [% IF SELF.sep_char == entry.first %] [% SET custom_sep_char = '' %] [%- END %]
122       [% L.radio_button_tag('sep_char', value => entry.first, label => entry.last, checked => SELF.sep_char == entry.first) %]
123      </td>
124     [%- END %]
125
126     <td>
127      [% L.radio_button_tag('sep_char', value => 'custom', checked => custom_sep_char != '') %]
128      [% L.input_tag('custom_sep_char', custom_sep_char, size => 3, maxlength => 1) %]
129     </td>
130    </tr>
131
132    <tr>
133     <th align="right">[%- LxERP.t8('Quote character') %]:</th>
134     [% SET custom_quote_char = SELF.quote_char %]
135     [% FOREACH entry = SELF.all_quote_chars %]
136      <td>
137       [% IF SELF.quote_char == entry.first %] [% SET custom_quote_char = '' %] [%- END %]
138       [% L.radio_button_tag('quote_char', value => entry.first, label => entry.last, checked => SELF.quote_char == entry.first) %]
139      </td>
140     [%- END %]
141
142     <td>
143      [% L.radio_button_tag('quote_char', value => 'custom', checked => custom_quote_char != '') %]
144      [% L.input_tag('custom_quote_char', custom_quote_char, size => 3, maxlength => 1) %]
145     </td>
146    </tr>
147
148    <tr>
149     <th align="right">[%- LxERP.t8('Escape character') %]:</th>
150     [% SET custom_escape_char = SELF.escape_char %]
151     [% FOREACH entry = SELF.all_escape_chars %]
152      <td>
153       [% IF SELF.escape_char == entry.first %] [% SET custom_escape_char = '' %] [%- END %]
154       [% L.radio_button_tag('escape_char', value => entry.first, label => entry.last, checked => SELF.escape_char == entry.first) %]
155      </td>
156     [%- END %]
157
158     <td>
159      [% L.radio_button_tag('escape_char', value => 'custom', checked => custom_escape_char != '') %]
160      [% L.input_tag('custom_escape_char', custom_escape_char, size => 3, maxlength => 1) %]
161     </td>
162    </tr>
163
164    [% duplicate_fields = SELF.worker.get_duplicate_check_fields() %]
165    [% IF ( duplicate_fields.size ) %]
166      <tr>
167        <th align="right">[%- LxERP.t8('Check for duplicates') %]:</th>
168
169        <td colspan=10>
170          [% FOREACH key = duplicate_fields.keys %]
171            <input type="checkbox" name="settings.duplicates_[% key | html %]" id="settings.duplicates_[% key | html %]" value="1"[% IF ( SELF.profile.get('duplicates_'_ key) || (duplicate_fields.$key.default && !FORM.form_sent ) ) %] checked="checked"[% END %]\>
172            <label for="settings.duplicates_[% key | html %]">[% duplicate_fields.$key.label | html %]</label>
173          [% END %]
174        </td>
175      </tr>
176
177      <tr>
178        <th align="right"></th>
179
180        <td colspan=10>
181          [% opts = [ [ 'no_check',  LxERP.t8('Do not check for duplicates') ],
182                      [ 'check_csv', LxERP.t8('Discard duplicate entries in CSV file') ],
183                      [ 'check_db',  LxERP.t8('Discard entries with duplicates in database or CSV file') ] ] %]
184          [% L.select_tag('settings.duplicates', L.options_for_select(opts, default => SELF.profile.get('duplicates')), style => 'width: 300px') %]
185        </td>
186      </tr>
187    [% END %]
188
189 [%- IF SELF.type == 'parts' %]
190  [%- INCLUDE 'csv_import/_form_parts.html' %]
191 [%- ELSIF SELF.type == 'customers_vendors' %]
192  [%- INCLUDE 'csv_import/_form_customers_vendors.html' %]
193 [%- END %]
194
195    <tr>
196     <th align="right">[%- LxERP.t8('Preview Mode') %]:</th>
197     <td colspan="10">
198       [% L.radio_button_tag('settings.full_preview', value=2, checked=SELF.profile.get('full_preview')==2, label=LxERP.t8('Full Preview')) %]
199       [% L.radio_button_tag('settings.full_preview', value=1, checked=SELF.profile.get('full_preview')==1, label=LxERP.t8('Only Warnings and Errors')) %]
200       [% L.radio_button_tag('settings.full_preview', value=0, checked=!SELF.profile.get('full_preview'),   label=LxERP.t8('First 20 Lines')) %]
201     </td>
202    </tr>
203
204    <tr>
205     <th align="right">[%- LxERP.t8('Import file') %]:</th>
206     <td colspan="10">[% L.input_tag('file', '', type => 'file', accept => '*') %]</td>
207    </tr>
208
209    [%- IF SELF.file.exists %]
210     <tr>
211      <th align="right">[%- LxERP.t8('Existing file on server') %]:</th>
212      <td colspan="10">[%- LxERP.t8('Uploaded on #1, size #2 kB', SELF.file.displayable_mtime, LxERP.format_amount(SELF.file.size / 1024, 2)) %]</td>
213     </tr>
214    [%- END %]
215
216   </table>
217
218   [% L.submit_tag('action_test', LxERP.t8('Test and preview')) %]
219   [% IF (SELF.import_status == 'tested') && SELF.num_importable %]
220    [% L.submit_tag('action_import', LxERP.t8('Import')) %]
221   [%- END %]
222
223  </form>
224
225  [%- IF SELF.import_status %]
226   [%- IF SELF.errors %]
227    [%- PROCESS 'csv_import/_errors.html' %]
228   [%- END %]
229
230   [%- PROCESS 'csv_import/_result.html' %]
231   [%- PROCESS 'csv_import/_preview.html' %]
232  [%- END %]
233
234  <script type="text/javascript">
235   <!--
236     $(document).ready(function() {
237       $('#action_save').click(function() {
238         if ($('#profile_name').attr('value') != '')
239           return true;
240         alert('[% LxERP.t8('Please enter a profile name.') %]');
241         return false;
242       })
243     });
244     -->
245  </script>
246 </body>
247 </html>