55e27db29d64966a1e4c5060db59dcc8b2bb4b28
[kivitendo-erp.git] / templates / webpages / order / form.html
1 [%- USE T8 %]
2 [%- USE LxERP %]
3 [%- USE L %]
4
5 <div id="print_options" style="display:none">
6   <form method="post" action="controller.pl" id="print_options_form">
7     [% SELF.print_options %]
8     <br>
9     [% L.button_tag('print()', LxERP.t8('Print')) %]
10     <a href="#" onclick="$('#print_options').dialog('close');">[% LxERP.t8("Cancel") %]</a>
11   </form>
12 </div>
13
14 <form method="post" action="controller.pl" id="order_form">
15   <div class="listtop">[% FORM.title %]</div>
16
17   [% L.hidden_tag('callback', FORM.callback) %]
18   [% L.hidden_tag('type',     FORM.type) %]
19   [% L.hidden_tag('id',       SELF.order.id) %]
20
21   [%- INCLUDE 'common/flash.html' %]
22
23   <div class="tabwidget" id="order_tabs">
24     <ul>
25       <li><a href="#ui-tabs-basic-data">[% 'Basic Data' | $T8 %]</a></li>
26 [%- IF INSTANCE_CONF.get_webdav %]
27       <li><a href="#ui-tabs-webdav">[% 'WebDAV' | $T8 %]</a></li>
28 [%- END %]
29     </ul>
30
31     [% PROCESS "order/tabs/basic_data.html" %]
32     [% PROCESS 'webdav/_list.html' %]
33     <div id="ui-tabs-1">
34       [%- LxERP.t8("Loading...") %]
35     </div>
36   </div>
37
38   <br>
39
40   [% L.hidden_tag('action', 'Order/dispatch') %]
41
42   [% L.button_tag('save()', LxERP.t8('Save')) %]
43   [% L.button_tag('show_print_options()', LxERP.t8('Print')) %]
44   [% L.button_tag('email()', LxERP.t8('E-mail')) %]
45   [% L.button_tag('save_and_delivery_order()', LxERP.t8('Save and Delivery Order')) %]
46 [%- IF SELF.order.id && ( (SELF.cv == 'customer' && INSTANCE_CONF.get_sales_order_show_delete) || (SELF.cv == 'vendor' && INSTANCE_CONF.get_purchase_order_show_delete) ) %]
47   [% L.button_tag('delete_order()', LxERP.t8('Delete'), confirm=LxERP.t8("Are you sure?")) %]
48 [%- END %]
49
50 </form>
51
52
53 <script type='text/javascript'>
54
55 function delete_order() {
56   var data = $('#order_form').serializeArray();
57   data.push({ name: 'action', value: 'Order/delete' });
58
59   $.post("controller.pl", data, kivi.eval_json_result);
60 }
61
62 function save() {
63   if (!check_cv()) return;
64   var data = $('#order_form').serializeArray();
65   data.push({ name: 'action', value: 'Order/save' });
66
67   $.post("controller.pl", data, kivi.eval_json_result);
68 }
69
70 function show_print_options() {
71   if (!check_cv()) return;
72
73   kivi.popup_dialog({
74     id: 'print_options',
75     dialog: {
76       title: kivi.t8('Print options'),
77       width:  800,
78       height: 300
79     }
80   });
81 }
82
83 function print() {
84   $('#print_options').dialog('close');
85
86   var data = $('#order_form').serializeArray();
87   data = data.concat($('#print_options_form').serializeArray());
88   data.push({ name: 'action', value: 'Order/print' });
89
90   $.post("controller.pl", data, kivi.eval_json_result);
91 }
92
93 function download_pdf(pdf_filename, key) {
94   var data = [];
95   data.push({ name: 'action', value: 'Order/download_pdf' });
96   data.push({ name: 'type', value: $('#type').val() });
97   data.push({ name: 'pdf_filename', value: pdf_filename });
98   data.push({ name: 'key', value: key });
99   $.download("controller.pl", data);
100 }
101
102 function email() {
103   if (!check_cv()) return;
104   var data = $('#order_form').serializeArray();
105   data.push({ name: 'action', value: 'Order/show_email_dialog' });
106
107   $.post("controller.pl", data, kivi.eval_json_result);
108 }
109
110 function save_and_delivery_order() {
111   if (!check_cv()) return;
112   var data = $('#order_form').serializeArray();
113   data.push({ name: 'action', value: 'Order/save_and_delivery_order' });
114
115   $.post("controller.pl", data, kivi.eval_json_result);
116 }
117
118 function check_cv() {
119   if ($('#order_[%- cv_id %]').val() == '') {
120     [%- IF SELF.cv == 'customer' %]
121       alert(kivi.t8('Please select a customer.'));
122     [%- ELSE %]
123       alert(kivi.t8('Please select a vendor.'));
124     [%- END %]
125     return false;
126   }
127   return true;
128 }
129 </script>