epic-ts
[kivitendo-erp.git] / templates / webpages / csv_import / form.html
1 [%- USE HTML %]
2 [%- USE LxERP %]
3 [%- USE L %]
4 [%- USE T8 %]
5  <h1>[% FORM.title %]</h1>
6
7  [%- INCLUDE 'common/flash.html' %]
8
9  <form method="post" action="controller.pl" enctype="multipart/form-data">
10   [% L.hidden_tag('form_sent', '1') %]
11   [% L.hidden_tag('action', 'CsvImport/dispatch') %]
12   [% L.hidden_tag('profile.type', SELF.profile.type) %]
13
14   <h2>[%- LxERP.t8('Import profiles') %]</h2>
15
16   <table>
17    [%- IF SELF.profile.id %]
18     <tr>
19      <th align="right">[%- LxERP.t8('Current profile') %]:</th>
20      <td>[%- HTML.escape(SELF.profile.name) %]</td>
21     </tr>
22    [%- END %]
23
24    [%- IF SELF.all_profiles.size %]
25     <tr>
26      <th align="right">[%- LxERP.t8('Existing profiles') %]:</th>
27      <td>
28       [% L.select_tag('profile.id', SELF.all_profiles, title_key = 'name', default = SELF.profile.id, style = 'width: 300px') %]
29      </td>
30      <td>
31       [% L.submit_tag('action_new', LxERP.t8('Load profile')) %]
32       [% L.submit_tag('action_destroy', LxERP.t8('Delete profile'), confirm => LxERP.t8('Do you really want to delete this object?')) %]
33      </td>
34     </tr>
35    [%- END %]
36
37    <tr>
38     <th align="right" valign="top">[%- LxERP.t8('Save settings as') %]:</th>
39     <td valign="top">
40      [% L.input_tag('profile.name', '', style => 'width: 300px') %]
41      <br>
42      [% L.checkbox_tag('profile.is_default', label => LxERP.t8('Make default profile')) %]
43     </td>
44     <td valign="top">[% L.submit_tag('action_save', LxERP.t8('Save profile')) %]</td>
45    </tr>
46   </table>
47
48   <hr>
49
50   <h2>[%- LxERP.t8('Help on column names') %]</h2>
51
52   <div class="help_toggle">
53    <a href="#" onClick="javascript:$('.help_toggle').toggle()">[% LxERP.t8("Show help text") %]</a>
54   </div>
55
56   <div class="help_toggle" style="display:none">
57    <p><a href="#" onClick="javascript:$('.help_toggle').toggle()">[% LxERP.t8("Hide help text") %]</a></p>
58
59    [%- IF SELF.worker.is_multiplexed %]
60      <table>
61        <tr class="listheading">
62          [%- FOREACH p = SELF.worker.profile %]
63            <th>[%- p.row_ident %]</th>
64          [%- END %]
65        </tr>
66        <tr class="listrow[% loop.count % 2 %]">
67          [%- FOREACH p = SELF.worker.profile %]
68            [% SET ri = p.row_ident %]
69          <td>
70            <table>
71              <tr class="listheading">
72                <th>[%- LxERP.t8('Column name') %]</th>
73                <th>[%- LxERP.t8('Meaning') %]</th>
74              </tr>
75
76              [%- FOREACH row = SELF.displayable_columns.$ri %]
77              <tr class="listrow[% loop.count % 2 %]">
78                <td>[%- HTML.escape(row.name) %]</td>
79                <td>[%- HTML.escape(row.description) %]</td>
80              </tr>
81              [%- END %]
82            </table>
83          </td>
84          [%- END %]
85        </tr>
86      </table>
87    [%- ELSE %]
88      <table>
89        <tr class="listheading">
90          <th>[%- LxERP.t8('Column name') %]</th>
91          <th>[%- LxERP.t8('Meaning') %]</th>
92        </tr>
93
94        [%- FOREACH row = SELF.displayable_columns %]
95        <tr class="listrow[% loop.count % 2 %]">
96          <td>[%- HTML.escape(row.name) %]</td>
97          <td>[%- HTML.escape(row.description) %]</td>
98        </tr>
99        [%- END %]
100      </table>
101    [%- END %]
102
103 [%- IF SELF.type == 'contacts' %]
104    <p>
105     [%- LxERP.t8("You can update existing contacts by providing the 'cp_id' column with their database IDs. Otherwise: ") %]
106     [%- 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') %]
107    </p>
108
109 [%- ELSIF SELF.type == 'addresses' %]
110    <p>
111     [%- 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') %]
112    </p>
113
114 [%- ELSIF SELF.type == 'parts' %]
115    <p>
116     [1]:
117     [% LxERP.t8('The three columns "make_X", "model_X" and "lastcost_X" with the same number "X" are used to import vendor part numbers and vendor prices.') %]
118     [% LxERP.t8('The column triplets can occur multiple times with different numbers "X" each time (e.g. "make_1", "model_1", "lastcost_1", "make_2", "model_2", "lastcost_2", "make_3", "model_3", "lastcost_3" etc).') %]
119     [% LxERP.t8('The items are imported accoring do their number "X" regardless of the column order inside the file.') %]
120     [% LxERP.t8('The column "make_X" can contain either a vendor\'s database ID, a vendor number or a vendor\'s name.') %]
121    </p>
122     <p>
123     [2]:
124     [% LxERP.t8('Onhand only sets the quantity in master data, not in inventory. This is only a legacy info field and will be overwritten as soon as a inventory transfer happens.') %]
125    </p>
126    <p>
127     [3]:
128     [% LxERP.t8("If the article type is set to 'mixed' then a column called 'type' must be present.") %]
129     [% LxERP.t8("Type can be either 'part', 'service' or 'assembly'.") %]
130     [% LxERP.t8("Assemblies can not be imported (yet). But the type column is used for sanity checks on price updates in order to prevent that articles with the wrong type will be updated.") %]
131    </p>
132
133 [%- ELSIF SELF.type == 'inventories' %]
134    <p>
135     [%- LxERP.t8('One of the columns "qty" or "target_qty" must be given. If "target_qty" is given, the quantity to transfer for each transfer will be calculate, so that the quantity for this part, warehouse and bin will result in the given "target_qty" after each transfer.') %]
136    </p>
137
138 [%- ELSIF SELF.type == 'orders' %]
139    <p>
140     [1]:
141     [% LxERP.t8('The column "datatype" must be present and must be at the same position / column in each data set. The values must be the row names (see settings) for order and item data respectively.') %]
142    </p>
143    <p>
144     [2]:
145     [%- LxERP.t8('Amount and net amount are calculated by kivitendo. "verify_amount" and "verify_netamount" can be used for sanity checks.') %]<br>
146     [%- LxERP.t8('If amounts differ more than "Maximal amount difference" (see settings), this item is marked as invalid.') %]<br>
147    </p>
148 [%- END %]
149
150    <p>
151     [%- L.submit_tag('action_download_sample', LxERP.t8('Download sample file')) %]
152    </p>
153
154   </div>
155
156   <hr>
157
158   <h2>[%- LxERP.t8('Settings') %]</h2>
159
160   <div class="settings_toggle"[% UNLESS SELF.deferred || SELF.import_status %] style="display:none"[% END %]>
161    <a href="#" onClick="javascript:$('.settings_toggle').toggle()">[% LxERP.t8("Show settings") %]</a>
162   </div>
163
164   <div class="settings_toggle"[% IF SELF.deferred || SELF.import_status %] style="display:none"[% END %]>
165    <p><a href="#" onClick="javascript:$('.settings_toggle').toggle()">[% LxERP.t8("Hide settings") %]</a></p>
166
167   <table>
168    <tr>
169     <th align="right">[%- LxERP.t8('Number Format') %]:</th>
170     <td colspan="10">
171      [% L.select_tag('settings.numberformat', ['1.000,00', '1000,00', '1,000.00', '1000.00'], default = SELF.profile.get('numberformat'), style = 'width: 300px') %]
172     </td>
173    </tr>
174
175    <tr>
176     <th align="right">[%- LxERP.t8('Charset') %]:</th>
177     <td colspan="10">[% L.select_tag('settings.charset', SELF.all_charsets, default = SELF.profile.get('charset'), style = 'width: 300px') %]</td>
178    </tr>
179
180    <tr>
181     <th align="right">[%- LxERP.t8('Separator') %]:</th>
182     [% SET custom_sep_char = SELF.sep_char %]
183     [% FOREACH entry = SELF.all_sep_chars %]
184      <td>
185       [% IF SELF.sep_char == entry.first %] [% SET custom_sep_char = '' %] [%- END %]
186       [% L.radio_button_tag('sep_char', value => entry.first, label => entry.last, checked => SELF.sep_char == entry.first) %]
187      </td>
188     [%- END %]
189
190     <td>
191      [% L.radio_button_tag('sep_char', value => 'custom', checked => custom_sep_char != '') %]
192      [% L.input_tag('custom_sep_char', custom_sep_char, size => 3, maxlength => 1) %]
193     </td>
194    </tr>
195
196    <tr>
197     <th align="right">[%- LxERP.t8('Quote character') %]:</th>
198     [% SET custom_quote_char = SELF.quote_char %]
199     [% FOREACH entry = SELF.all_quote_chars %]
200      <td>
201       [% IF SELF.quote_char == entry.first %] [% SET custom_quote_char = '' %] [%- END %]
202       [% L.radio_button_tag('quote_char', value => entry.first, label => entry.last, checked => SELF.quote_char == entry.first) %]
203      </td>
204     [%- END %]
205
206     <td>
207      [% L.radio_button_tag('quote_char', value => 'custom', checked => custom_quote_char != '') %]
208      [% L.input_tag('custom_quote_char', custom_quote_char, size => 3, maxlength => 1) %]
209     </td>
210    </tr>
211
212    <tr>
213     <th align="right">[%- LxERP.t8('Escape character') %]:</th>
214     [% SET custom_escape_char = SELF.escape_char %]
215     [% FOREACH entry = SELF.all_escape_chars %]
216      <td>
217       [% IF SELF.escape_char == entry.first %] [% SET custom_escape_char = '' %] [%- END %]
218       [% L.radio_button_tag('escape_char', value => entry.first, label => entry.last, checked => SELF.escape_char == entry.first) %]
219      </td>
220     [%- END %]
221
222     <td>
223      [% L.radio_button_tag('escape_char', value => 'custom', checked => custom_escape_char != '') %]
224      [% L.input_tag('custom_escape_char', custom_escape_char, size => 3, maxlength => 1) %]
225     </td>
226    </tr>
227
228    [% duplicate_fields = SELF.worker.get_duplicate_check_fields() %]
229    [% IF ( duplicate_fields.size ) %]
230      <tr>
231        <th align="right">[%- LxERP.t8('Check for duplicates') %]:</th>
232
233        <td colspan=10>
234          [% FOREACH key = duplicate_fields.keys %]
235            <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 %]>
236            <label for="settings.duplicates_[% key | html %]">[% duplicate_fields.$key.label | html %]</label>
237          [% END %]
238        </td>
239      </tr>
240
241      <tr>
242        <th align="right"></th>
243
244        <td colspan=10>
245          [% opts = [ [ 'no_check',  LxERP.t8('Do not check for duplicates') ],
246                      [ 'check_csv', LxERP.t8('Discard duplicate entries in CSV file') ],
247                      [ 'check_db',  LxERP.t8('Discard entries with duplicates in database or CSV file') ] ] %]
248          [% L.select_tag('settings.duplicates', opts, default = SELF.profile.get('duplicates'), style = 'width: 300px') %]
249        </td>
250      </tr>
251    [% END %]
252
253 [%- IF SELF.type == 'parts' %]
254  [%- INCLUDE 'csv_import/_form_parts.html' %]
255 [%- ELSIF SELF.type == 'customers_vendors' %]
256  [%- INCLUDE 'csv_import/_form_customers_vendors.html' %]
257 [%- ELSIF SELF.type == 'contacts' %]
258  [%- INCLUDE 'csv_import/_form_contacts.html' %]
259 [%- ELSIF SELF.type == 'inventories' %]
260  [%- INCLUDE 'csv_import/_form_inventories.html' %]
261 [%- ELSIF SELF.type == 'orders' %]
262  [%- INCLUDE 'csv_import/_form_orders.html' %]
263 [%- ELSIF SELF.type == 'bank_transactions' %]
264  [%- INCLUDE 'csv_import/_form_banktransactions.html' %]
265 [%- END %]
266
267    <tr>
268     <th align="right">[%- LxERP.t8('Preview Mode') %]:</th>
269     <td colspan="10">
270       [% L.radio_button_tag('settings.full_preview', value=2, checked=SELF.profile.get('full_preview')==2, label=LxERP.t8('Full Preview')) %]
271       [% L.radio_button_tag('settings.full_preview', value=1, checked=SELF.profile.get('full_preview')==1, label=LxERP.t8('Only Warnings and Errors')) %]
272       [% L.radio_button_tag('settings.full_preview', value=0, checked=!SELF.profile.get('full_preview'),   label=LxERP.t8('First 20 Lines')) %]
273     </td>
274    </tr>
275
276    <tr>
277     <th align="right">[%- LxERP.t8('Import file') %]:</th>
278     <td colspan="10">[% L.input_tag('file', '', type => 'file', accept => '*') %]</td>
279    </tr>
280
281    [%- IF SELF.file.exists %]
282     <tr>
283      <th align="right">[%- LxERP.t8('Existing file on server') %]:</th>
284      <td colspan="10">[%- LxERP.t8('Uploaded on #1, size #2 kB', SELF.file.displayable_mtime, LxERP.format_amount(SELF.file.size / 1024, 2)) %]</td>
285     </tr>
286    [%- END %]
287
288   </table>
289
290   </div>
291   <hr>
292
293   [% L.submit_tag('action_test', LxERP.t8('Test and preview')) %]
294   [% L.submit_tag('action_import', LxERP.t8('Import'), style='display:none') %]
295
296  </form>
297
298  <div id='results'>
299  [%- IF SELF.deferred %]
300    [%- PROCESS 'csv_import/_deferred_results.html' %]
301  [%- ELSIF SELF.import_status %]
302    [%- PROCESS 'csv_import/_results.html' %]
303  [%- END %]
304  </div>
305
306
307  <script type="text/javascript">
308   <!--
309     $(document).ready(function() {
310       $('#action_save').click(function() {
311         if ($('#profile_name').val() != '')
312           return true;
313         alert('[% LxERP.t8('Please enter a profile name.') %]');
314         return false;
315       })
316     });
317     -->
318  </script>