480a0c5ab5c14ec7d6b6503be848845943bb5f65
[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.employee_id',
83               SELF.all_employees,
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>[% 'Customer Order Number' | $T8 %]</th>
96             <td>[% L.input_tag('order.cusordnumber', SELF.order.cusordnumber, size = 11) %]</td>
97           </tr>
98
99           <tr>
100             <th width="70%" align="right" nowrap>[% 'Order Date' | $T8 %]</th>
101             <td>[% L.date_tag('order.transdate', SELF.order.transdate) %]</td>
102           </tr>
103
104           <tr>
105             <th width="70%" align="right" nowrap>[% 'Project Number' | $T8 %]</th>
106             <td>[%- L.select_tag('order.globalproject_id', SELF.all_projects, default=SELF.order.globalproject_id, title_key='projectnumber', with_empty = 1) %]</td>
107           </tr>
108
109         </table>
110
111       </td>
112     </tr>
113   </table>
114
115   [%- PROCESS order/tabs/_item_input.html %]
116
117   <table width="100%">
118     <tr>
119       <td>
120
121         <div id="row_table_scroll_id" style="overflow-y: auto; height: 45vh;">
122           <table id="row_table_id" width="100%">
123             <thead>
124               <tr class="listheading">
125                 <th class="listheading" style='display:none'></th>
126                 <th class="listheading" style='text-align:center' nowrap width="1"><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]"></th>
127                 <th class="listheading" style='text-align:center' nowrap width="1"><img src="image/close.png" alt="[%- LxERP.t8('delete item') %]"></th>
128                 <th class="listheading" nowrap width="15">[%- 'Partnumber'  | $T8 %] </th>
129                 <th class="listheading" nowrap           >[%- 'Description'  | $T8 %] </th>
130                 <th class="listheading" nowrap width="5" >[%- 'Qty'          | $T8 %] </th>
131                 <th class="listheading" nowrap width="5" >[%- 'Price Factor' | $T8 %] </th>
132                 <th class="listheading" nowrap width="5" >[%- 'Unit'         | $T8 %] </th>
133                 <th class="listheading" nowrap width="15">[%- 'Price'        | $T8 %] </th>
134                 <th class="listheading" nowrap width="5" >[%- 'Discount'     | $T8 %] </th>
135                 <th class="listheading" nowrap width="10">[%- 'Extended'     | $T8 %] </th>
136               </tr>
137             </thead>
138
139             [%- FOREACH item = SELF.order.items_sorted %]
140               [%- PROCESS order/tabs/_row.html ITEM=item %]
141             [%- END %]
142
143           </table>
144         </div>
145
146       </td>
147     </tr>
148
149     <tr>
150     </tr>
151
152     <tr>
153       <td align="right">
154         <table>
155           [%- IF NOT taxincluded %]
156           <tr>
157             <th align="right">[%- 'Subtotal' | $T8 %]</th>
158             <td align="right">
159               [%- L.div_tag(SELF.order.netamount_as_number, id='netamount_id') %]
160             </td>
161           </tr>
162           [%- END %]
163           [%- FOREACH tax = SELF.taxes %]
164             [%- PROCESS order/tabs/_tax_row.html TAX=tax %]
165           [%- END %]
166           <tr id="amount_row_id">
167             <th align="right">[%- 'Total' | $T8 %]</th>
168             <td align="right">
169               [%- L.div_tag(SELF.order.amount_as_number, id='amount_id') %]
170           </tr>
171         </table>
172       </td>
173     </tr>
174
175     <tr>
176       <td><hl></td>
177     </tr>
178
179   </table>
180
181 </div>
182
183
184 [% L.sortable_element('#row_table_id') %]
185
186 <script type='text/javascript'>
187 function reload_cv_dependend_selections() {
188   $.post("controller.pl", { 'action': 'Order/customer_vendor_changed',
189                             'cv_id':  function(){ return $('#order_[%- cv_id%]').val() },
190                             'type':   function(){ return $('#type').val() },
191                           }, kivi.eval_json_result);
192 }
193
194 function add_item() {
195   if ($('#add_item_parts_id').val() == '') return;
196
197   var data = $('#order_form').serialize();
198   data += '&action=Order/add_item';
199   data += '&type=' + $('#type').val();
200
201   $.post("controller.pl", data, kivi.eval_json_result);
202 }
203
204 function delete_order_item_row(clicked) {
205   var row = $(clicked).parents("tbody").first();
206   $(row).remove();
207
208   recalc_amounts_and_taxes();
209 }
210
211 function recalc_amounts_and_taxes() {
212   var data = $('#order_form').serialize();
213   data += '&action=Order/recalc_amounts_and_taxes';
214   data += '&type=' + $('#type').val();
215
216   $.post("controller.pl", data, kivi.eval_json_result);
217 }
218
219 function row_table_scroll_down() {
220   $('#row_table_scroll_id').scrollTop($('#row_table_scroll_id')[0].scrollHeight);
221 }
222
223 function row_set_keyboard_events_by_id(item_id) {
224   var row = $('#item_' + item_id).parents("tbody").first();
225
226   row_set_keyboard_events(row);
227 }
228
229 function row_set_keyboard_events(rows) {
230   console.log(rows);
231
232   $(rows).keydown(function(event) {
233     if(event.keyCode == 40 && event.shiftKey == true) {
234       // shift arrow down
235       event.preventDefault();
236       var row = $(event.target).parents(".row_entry").first();
237       $(row).children().not(':first').show();
238       return false;
239     }
240     if(event.keyCode == 38 && event.shiftKey == true) {
241       // shift arrow up
242       event.preventDefault();
243       var row = $(event.target).parents(".row_entry").first();
244       $(row).children().not(':first').hide();
245       return false;
246     }
247   });
248
249   $(rows).dblclick(function(event) {
250       event.preventDefault();
251       var row = $(event.target).parents(".row_entry").first();
252       $(row).children().not(':first').toggle();
253       return false;
254   });
255 }
256
257 $(function(){
258   $('#order_[%- cv_id %]').change(reload_cv_dependend_selections);
259   $('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_sellprice_as_number').val(kivi.format_amount(o.sellprice, -2)) });
260   $('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_description').val(o.description) });
261   $('.add_item_input').keydown(function(event) {
262     if(event.keyCode == 13) {
263       event.preventDefault();
264       add_item();
265       return false;
266     }
267   });
268   row_set_keyboard_events($('.row_entry'));
269 });
270
271 </script>