Auftrags-Controller: taxincluded vom Kunden oder aus Benutzereinstellung holen.
[kivitendo-erp.git] / templates / webpages / order / tabs / basic_data.html
1 [%- USE T8 %]
2 [%- USE HTML %]
3 [%- USE LxERP %]
4 [%- USE L %]
5
6 <div id="ui-tabs-basic-data">
7   <table width="100%">
8     <tr valign="top">
9       <td>
10         <table width="100%">
11           <tr>
12             <th align="right">[% SELF.cv | $T8 %]</th>
13             [% SET cv_id = SELF.cv _ '_id' %]
14             <td>[% L.customer_vendor_picker("order.${SELF.cv}" _ '_id', SELF.order.$cv_id, type=SELF.cv, style='width: 300px') %]</td>
15           </tr>
16
17           <tr id='cp_row' [%- IF !SELF.order.${SELF.cv}.contacts.size %]style='display:none'[%- END %]>
18             <th align="right">[% 'Contact Person' | $T8 %]</th>
19             <td>[% L.select_tag('order.cp_id',
20                                 SELF.order.${SELF.cv}.contacts,
21                                 default=SELF.order.cp_id,
22                                 title_key='full_name_dep',
23                                 value_key='cp_id',
24                                 with_empty=1,
25                                 style='width: 300px') %]</td>
26           </tr>
27
28           <tr id='shipto_row' [%- IF !SELF.order.${SELF.cv}.shipto.size %]style='display:none'[%- END %]>
29             <th align="right">[% 'Shipping Address' | $T8 %]</th>
30             <td>[% L.select_tag('order.shipto_id',
31                                 SELF.order.${SELF.cv}.shipto,
32                                 default=SELF.order.shipto_id,
33                                 title_key='displayable_id',
34                                 value_key='shipto_id',
35                                 with_empty=1,
36                                 style='width: 300px') %]</td>
37           </tr>
38
39           <tr>
40             <th align="right">[% 'Steuersatz' | $T8 %]</th>
41             <td>[% L.select_tag('order.taxzone_id', SELF.all_taxzones, default=SELF.order.taxzone_id, title_key='description', style='width: 300px') %]</td>
42           </tr>
43
44           <tr>
45             <th align="right">[% 'Shipping Point' | $T8 %]</th>
46             <td>[% L.input_tag('order.shippingpoint', SELF.order.shippingpoint, style='width: 300px') %]</td>
47           </tr>
48
49           <tr>
50             <th align="right">[% 'Ship via' | $T8 %]</th>
51             <td>[% L.input_tag('order.shipvia', SELF.order.shipvia, style='width: 300px') %]</td>
52           </tr>
53
54           <tr>
55             <th align="right">[% 'Transaction description' | $T8 %]</th>
56             <td>[% L.input_tag('order.transaction_description', SELF.order.transaction_description, style='width: 300px') %]</td>
57           </tr>
58
59         </table>
60       </td>
61
62       <td align="right">
63         <table>
64
65           <tr>
66             <td colspan="2" align="center">
67               [%- IF SELF.order.closed %] [% 'Closed' | $T8 %] [%- ELSE %] [% 'Open' | $T8 %] [%- END %]
68             </td>
69           </tr>
70
71           <tr>
72             <th align="right">[% 'Employee' | $T8 %]</th>
73             <td>[% L.select_tag('order.employee_id',
74               SELF.all_employees,
75               default=(SELF.order.employee_id ? SELF.order.employee_id : SELF.current_employee_id),
76               title_key='safe_name') %]</td>
77           </tr>
78
79           [% IF SELF.cv == 'customer' %]
80           <tr>
81             <th align="right">[% 'Salesman' | $T8 %]</th>
82             <td>[% L.select_tag('order.salesman_id',
83               SELF.all_salesmen,
84               default=(SELF.order.salesman_id ? SELF.order.salesman_id : SELF.current_employee_id),
85               title_key='safe_name') %]</td>
86           </tr>
87           [% END %]
88
89           <tr>
90             <th width="70%" align="right" nowrap>[% 'Order Number' | $T8 %]</th>
91             <td>[% L.input_tag('order.ordnumber', SELF.order.ordnumber, size = 11) %]</td>
92           </tr>
93
94           <tr>
95             <th width="70%" align="right" nowrap>[% 'Quotation Number' | $T8 %]</th>
96             <td>[% L.input_tag('order.quonumber', SELF.order.quonumber, size = 11) %]</td>
97           </tr>
98
99           <tr>
100             <th width="70%" align="right" nowrap>[% 'Customer Order Number' | $T8 %]</th>
101             <td>[% L.input_tag('order.cusordnumber', SELF.order.cusordnumber, size = 11) %]</td>
102           </tr>
103
104           <tr>
105             <th width="70%" align="right" nowrap>[% 'Order Date' | $T8 %]</th>
106             <td>[% L.date_tag('order.transdate', SELF.order.transdate) %]</td>
107           </tr>
108
109           <tr>
110             <th width="70%" align="right" nowrap>[% 'Insert Date' | $T8 %]</th>
111             <td>[% SELF.order.itime_as_date %]</td>
112           </tr>
113
114           <tr>
115             <th width="70%" align="right" nowrap>[% 'Project Number' | $T8 %]</th>
116             <td>[%- L.select_tag('order.globalproject_id', SELF.all_projects, default=SELF.order.globalproject_id, title_key='projectnumber', with_empty = 1) %]</td>
117           </tr>
118
119         </table>
120
121       </td>
122     </tr>
123   </table>
124
125   [%- PROCESS order/tabs/_item_input.html %]
126
127   <table width="100%">
128     <tr>
129       <td>
130
131         <div id="row_table_scroll_id" style="overflow-y: auto; height: 25vh">
132           <table id="row_table_id" width="100%">
133             <thead>
134               <tr class="listheading">
135                 <th class="listheading" style='display:none'></th>
136                 <th class="listheading" style='text-align:center' nowrap width="1"><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]"></th>
137                 <th class="listheading" style='text-align:center' nowrap width="1"><img src="image/close.png" alt="[%- LxERP.t8('delete item') %]"></th>
138                 <th class="listheading" nowrap width="15">[%- 'Partnumber'  | $T8 %] </th>
139                 <th class="listheading" nowrap           >[%- 'Description'  | $T8 %] </th>
140                 <th class="listheading" nowrap width="5" >[%- 'Qty'          | $T8 %] </th>
141                 <th class="listheading" nowrap width="5" >[%- 'Price Factor' | $T8 %] </th>
142                 <th class="listheading" nowrap width="5" >[%- 'Unit'         | $T8 %] </th>
143                 <th class="listheading" nowrap width="15">[%- 'Price'        | $T8 %] </th>
144                 <th class="listheading" nowrap width="5" >[%- 'Discount'     | $T8 %] </th>
145                 <th class="listheading" nowrap width="10">[%- 'Extended'     | $T8 %] </th>
146               </tr>
147             </thead>
148
149             [%- FOREACH item = SELF.order.items_sorted %]
150               [%- PROCESS order/tabs/_row.html ITEM=item %]
151             [%- END %]
152
153           </table>
154         </div>
155
156       </td>
157     </tr>
158
159     <tr>
160     </tr>
161
162     <tr>
163       <td colspan="100%" width="100%">
164         <table width="100%">
165           <tr>
166             <td>
167               <table>
168                 <tr>
169                   <th align="left">[% 'Notes' | $T8 %]</th>
170                   <th align="left">[% 'Internal Notes' | $T8 %]</th>
171                 </tr>
172                 <tr valign="top">
173                   <td>
174                     [% L.textarea_tag('order.notes', SELF.order.notes, wrap="soft", style="width: 350px; height: 150px", class="texteditor") %]
175                   </td>
176                   <td>
177                     [% L.textarea_tag('order.intnotes', SELF.order.intnotes, wrap="soft", style="width: 350px; height: 150px") %]
178                   </td>
179                 </tr>
180               </table>
181             </td>
182
183             <td>
184               <table>
185                 <tr>
186                   <th align="right">[% 'Payment Terms' | $T8 %]</th>
187                   <td>[% L.select_tag('order.payment_id',
188                                       SELF.all_payment_terms,
189                                       default = SELF.order.payment_id,
190                                       with_empty = 1,
191                                       title_key = 'description',
192                                       style = 'width: 250px') %]</td>
193                 </tr>
194                 <tr>
195                   <th align="right">[% 'Delivery Terms' | $T8 %]</th>
196                   <td>[% L.select_tag('order.delivery_term_id',
197                                       SELF.all_delivery_terms,
198                                       default = SELF.order.delivery_term_id,
199                                       with_empty = 1,
200                                       title_key = 'description',
201                                       style = 'width: 250px') %]</td>
202                 </tr>
203               </table>
204             </td>
205
206             <td align="right">
207               <table>
208                 <tr id="taxincluded_row_id" [%- IF !SELF.taxes.size %]style="display:none"[%- END %]>
209                   <td align=right colspan="2">
210                     <label for="order.taxincluded"><b>[% 'Tax Included' | $T8 %]</b></label>
211                     [% L.yes_no_tag('order.taxincluded', SELF.order.taxincluded, class='recalc') %]
212                   </td>
213                 </tr>
214
215                 <tr id="subtotal_row_id" [%- IF SELF.order.taxincluded %]style="display:none"[%- END %]>
216                   <th align="right">[%- 'Subtotal' | $T8 %]</th>
217                   <td align="right">
218                     [%- L.div_tag(SELF.order.netamount_as_number, id='netamount_id') %]
219                   </td>
220                 </tr>
221                 [%- FOREACH tax = SELF.taxes %]
222                   [%- PROCESS order/tabs/_tax_row.html TAX=tax TAXINCLUDED=SELF.order.taxincluded %]
223                 [%- END %]
224                 <tr id="amount_row_id">
225                   <th align="right">[%- 'Total' | $T8 %]</th>
226                   <td align="right">
227                     [%- L.div_tag(SELF.order.amount_as_number, id='amount_id') %]
228                   </td>
229                 </tr>
230               </table>
231             </td>
232
233           </tr>
234         </table>
235       </td>
236     </tr>
237
238   </table>
239
240 </div>
241
242
243 [% L.sortable_element('#row_table_id') %]
244
245 <script type='text/javascript'>
246 function reload_cv_dependend_selections() {
247   var data = $('#order_form').serialize();
248   data += '&action=Order/customer_vendor_changed';
249
250   $.post("controller.pl", data, kivi.eval_json_result);
251 }
252
253 function add_item() {
254   if ($('#add_item_parts_id').val() == '') return;
255
256   var data = $('#order_form').serialize();
257   data += '&action=Order/add_item';
258   data += '&type=' + $('#type').val();
259
260   $.post("controller.pl", data, kivi.eval_json_result);
261 }
262
263 function delete_order_item_row(clicked) {
264   var row = $(clicked).parents("tbody").first();
265   $(row).remove();
266
267   recalc_amounts_and_taxes();
268 }
269
270 function recalc_amounts_and_taxes() {
271   var data = $('#order_form').serialize();
272   data += '&action=Order/recalc_amounts_and_taxes';
273   data += '&type=' + $('#type').val();
274
275   $.post("controller.pl", data, kivi.eval_json_result);
276 }
277
278 function redisplay_linetotals(data) {
279   $('.row_entry [name="linetotal"]').each(function(idx, elt) {
280     $(elt).html(data[idx]);
281   });
282 }
283
284 function row_table_scroll_down() {
285   $('#row_table_scroll_id').scrollTop($('#row_table_scroll_id')[0].scrollHeight);
286 }
287
288 function row_set_keyboard_events_by_id(item_id) {
289   var row = $('#item_' + item_id).parents("tbody").first();
290
291   row_set_keyboard_events(row);
292 }
293
294 function row_set_keyboard_events(rows) {
295   $(rows).keydown(function(event) {
296     if(event.keyCode == 40 && event.shiftKey == true) {
297       // shift arrow down
298       event.preventDefault();
299       var row = $(event.target).parents(".row_entry").first();
300       $(row).children().not(':first').show();
301       return false;
302     }
303     if(event.keyCode == 38 && event.shiftKey == true) {
304       // shift arrow up
305       event.preventDefault();
306       var row = $(event.target).parents(".row_entry").first();
307       $(row).children().not(':first').hide();
308       return false;
309     }
310   });
311
312   $(rows).dblclick(function(event) {
313       event.preventDefault();
314       var row = $(event.target).parents(".row_entry").first();
315       $(row).children().not(':first').toggle();
316       return false;
317   });
318 }
319
320 var email_dialog;
321
322 function show_email_dialog(html) {
323   var id            = 'jqueryui_popup_dialog';
324   var dialog_params = {
325     id:     id,
326     width:  800,
327     height: 500,
328     modal:  true,
329     close: function(event, ui) {
330       email_dialog.remove();
331     },
332   };
333
334   $('#' + id).remove();
335
336   email_dialog = $('<div style="display:none" id="' + id + '"></div>').appendTo('body');
337   email_dialog.html(html);
338   email_dialog.dialog(dialog_params);
339
340   $('.cancel').click(close_email_dialog);
341
342   return true;
343 }
344
345 close_email_dialog = function() {
346   email_dialog.dialog("close");
347 }
348
349
350 $(function(){
351   $('#order_[%- cv_id %]').change(reload_cv_dependend_selections);
352   $('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_sellprice_as_number').val(kivi.format_amount(o.sellprice, -2)) });
353   $('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_description').val(o.description) });
354   $('.add_item_input').keydown(function(event) {
355     if(event.keyCode == 13) {
356       event.preventDefault();
357       add_item();
358       return false;
359     }
360   });
361   row_set_keyboard_events($('.row_entry'));
362   $('.recalc').change(recalc_amounts_and_taxes);
363 });
364
365 </script>