Merge branch 'b-3.6.1' of ../kivitendo-erp_20220811
[kivitendo-erp.git] / templates / webpages / ap / form_header.html
index fdcbefa..e3bc2e9 100644 (file)
@@ -1,38 +1,15 @@
 [%- USE L %]
+[%- USE P %]
 [%- USE HTML %]
 [%- USE T8 %]
-[%- USE LxERP %]
-
-<script type="text/javascript">
-<!--
-  function setTaxkey(accno, row) {
-    var taxkey = accno.options[accno.selectedIndex].value;
-    var reg = /--([0-9]*)/;
-    var found = reg.exec(taxkey);
-    var index = found[1];
-    index = parseInt(index);
-    var tax = 'taxchart_' + row;
-    for (var i = 0; i < document.getElementById(tax).options.length; ++i) {
-      var reg2 = new RegExp("^"+ index, "");
-      if (reg2.exec(document.getElementById(tax).options[i].value)) {
-        document.getElementById(tax).options[i].selected = true;
-        break;
-      }
-    }
-  };
-//-->
-</script>
+[%- USE LxERP %][%- USE P -%]
 
-<script type="text/javascript" src="js/show_history.js"></script>
+<h1>[% title | html %]</h1>
 
-<form method="post" action="[% script | html %]">
+[%- INCLUDE 'common/flash.html' %]
 
-<input type="hidden" name="selectvendor" value="[% selectvendor | html %]">
-<input type="hidden" name="selectdepartment" value="[% selectdepartment | html %]">
-<input type="hidden" name="selectcurrency" value="[% selectcurrency | html %]">
+<form method="post" action="[% script | html %]" id="form">
 
-<input type="hidden" name="oldvendor" value="[% oldvendor | html %]">
-<input type="hidden" name="vendor_id" value="[% vendor_id | html %]">
 <input type="hidden" name="terms" value="[% terms | html %]">
 
 <input type="hidden" name="creditlimit" value="[% creditlimit | html %]">
@@ -41,7 +18,7 @@
 <input type="hidden" name="forex" value="[% forex | html %]">
 <input type="hidden" name="lastmtime" value="[% HTML.escape(lastmtime) %]">
 
-<input type="hidden" name="id" value="[% id | html %]">
+<input id="id" type="hidden" name="id" value="[% id | html %]">
 <input type="hidden" name="sort" value="[% sort | html %]">
 <input type="hidden" name="closedto" value="[% closedto | html %]">
 <input type="hidden" name="locked" value="[% locked | html %]">
@@ -65,6 +42,8 @@
 
 <input type="hidden" name="paidaccounts" value="[% paidaccounts | html %]">
 
+[%- P.hidden_tag('convert_from_oe_id', convert_from_oe_id) -%]
+
 [% FOREACH i IN [1..paidaccounts] %]
   [% temp = "acc_trans_id_"_ i %]
   <input type="hidden" name="[% temp %]" value="[% $temp | html %]">
   <input type="hidden" name="[% temp %]" value="[% $temp | html %]">
 [% END %]
 
-<h1>[% title | html %]</h1>
-
 [% IF ( saved_message ) %]
   <p>[% saved_message | html %]</p>
 [% END %]
 
-<div class="tabwidget">
+<div id="ap_tabs" class="tabwidget">
  <ul>
   <li><a href="#ui-tabs-basic-data">[% 'Basic Data' | $T8 %]</a></li>
+[%- IF INSTANCE_CONF.get_webdav %]
+  <li><a href="#ui-tabs-webdav">[% 'WebDAV' | $T8 %]</a></li>
+[%- END %]
+[%- IF id AND INSTANCE_CONF.get_doc_storage %]
+      <li><a href="#ui-tabs-docs">[% 'Documents' | $T8 %]</a></li>
+      <li><a href="controller.pl?action=File/list&file_type=attachment&object_type=purchase_invoice&object_id=[% HTML.url(id) %]">[% 'Attachments' | $T8 %]</a></li>
+[%- END %]
 [%- IF id %]
+  [%- IF AUTH.assert('record_links', 1) %]
   <li><a href="controller.pl?action=RecordLinks/ajax_list&object_model=PurchaseInvoice&object_id=[% HTML.url(id) %]">[% 'Linked Records' | $T8 %]</a></li>
+  [%- END %]
   <li><a href="[% 'controller.pl?action=AccTrans/list_transactions&trans_id=' _ HTML.url(id) | html %]">[% LxERP.t8('Transactions') %]</a></li>
 [%- END %]
  </ul>
 
+[%- IF id AND INSTANCE_CONF.get_doc_storage %]
+   <div id="ui-tabs-docs"></div>
+[%- END %]
+
 <div id="ui-tabs-basic-data">
 <table width="100%">
   <tr valign="top">
               <tr>
                 <th align="right" nowrap>[% 'Vendor' | $T8 %]</th>
                 <td colspan="3">
-                  [% IF ( selectvendor ) %]
-                    <select name="vendor" onchange="document.getElementById('update_button').click();">[% selectvendor %]</select>
-                  [% ELSE %]
-                    <input name=vendor value="[% vendor | html %]" size="35">
-                  [% END %]
-                  <input type="button" value="D" onclick="show_vc_details('vendor')">
+                 [% P.customer_vendor.picker("vendor_id", vendor_id, type="vendor", style="width: 330px", onchange="\$('#update_button').click()") %]
+                 [% L.button_tag("show_vc_details('vendor')", LxERP.t8('Details (one letter abbreviation)')) %]
+                 [% L.hidden_tag("previous_vendor_id", vendor_id) %]
                 </td>
               </tr>
 
 
               <tr>
                 <th align="right" nowrap>[% 'Currency' | $T8 %]</th>
-                <td><select name="currency">[% selectcurrency %]</select></td>
+                <td>[% L.select_tag("currency", currencies, default=currency, value_key="name", title_key="name") %]</td>
 
                 [% IF ( defaultcurrency && (currency != defaultcurrency) ) %]
                   <th align=right>[% 'Exchangerate' | $T8 %]</th>
 
               </tr>
 
-              [% IF ( selectdepartment ) %]
+              [% IF ALL_DEPARTMENTS %]
                 <tr>
                   <th align="right" nowrap>[% 'Department' | $T8 %]</th>
-                  <td colspan="3">
-                    <select name="department">[% selectdepartment %]</select>
-                  </td>
+                  <td colspan=3>[% L.select_tag('department_id', ALL_DEPARTMENTS, default = department_id, title_key = 'description', with_empty = 1, style = "width:334px") %]</td>
                 </tr>
               [% END %]
 
+              <tr>
+                <th align="right">[% 'Transaction description' | $T8 %]</th>
+                <td colspan="3">[% L.input_tag("transaction_description", transaction_description, style="width:330px", "data-validate"=INSTANCE_CONF.get_require_transaction_description_ps ? 'required' : '') %]</td>
+              </tr>
               <tr>
                 <td align="right"><input name="taxincluded" class="checkbox" type="checkbox" value="1" [% IF ( taxincluded ) %]checked[% END %]></td>
                 <th align=left nowrap>[% 'Tax Included' | $T8 %]</th>
             <table>
               <tr>
                 <th align="right" nowrap>[% 'Invoice Number' | $T8 %]</th>
-                <td><input name="invnumber" size="11" value="[% invnumber | html %]" [% readonly %]></td>
+                <td>[% L.input_tag("invnumber", invnumber, size="11", readonly=readonly) %]</td>
               </tr>
               <tr>
                 <th align="right" nowrap>[% 'Order Number' | $T8 %]</th>
-                <td><input name="ordnumber" size="11" value="[% ordnumber | html %]" [% readonly %]></td>
+                <td>[% L.input_tag("ordnumber", ordnumber, size="11", readonly=readonly) %]</td>
               </tr>
               <tr>
                 <th align="right" nowrap>[% 'Invoice Date' | $T8 %]</th>
-                <td>[% L.date_tag('transdate', transdate) %]</td>
+                <td>[% L.date_tag('transdate', transdate, onchange='kivi.SalesPurchase.set_duedate_on_reference_date_change("transdate")') %]</td>
               </tr>
               <tr>
                 <th align="right" nowrap>[% 'Due Date' | $T8 %]</th>
                 <td>[% L.date_tag('duedate', duedate) %]</td>
               </tr>
+              <tr>
+                <th align="right" nowrap>[% LxERP.t8('Tax point') %]</th>
+                <td>[% L.date_tag('tax_point', tax_point, id='tax_point') %]</td>
+              </tr>
+              <tr>
+                <th align=right nowrap>[% 'Delivery Date' | $T8 %]</th>
+                <td>[% L.date_tag('deliverydate', deliverydate) %]</td>
+              </tr>
               <tr>
                 <th align="right" nowrap>[% 'Project Number' | $T8 %]</th>
                 <td>
-                  [% L.select_tag('globalproject_id', ALL_PROJECTS, with_empty = 1, default = globalproject_id, value_key = 'id', title_key = 'projectnumber') %]
+                  [% P.project.picker('globalproject_id', globalproject_id, onchange="document.getElementById('update_button').click();") %]
                 </td>
               </tr>
             </table>
         [% FOREACH i IN [1..rowcount] %]
           <tr>
             <td>
-              [% selected_accno_full = "selected_accno_full_"_ i %]
-              [% L.select_tag('AP_amount_'_ i, ALL_CHARTS_AP_amount, value_title_sub = \AP_amount_value_title_sub, onchange = 'setTaxkey(this, '_ i _')', default = $selected_accno_full) %]
-
-              <input type="hidden" name="previous_AP_amount_[% i %]" value="[% $selected_accno_full %]">
+              [% SET selected_chart_id = "AP_amount_chart_id_"_ i %]
+              [% P.chart.picker("AP_amount_chart_id_" _ i, $selected_chart_id, style="width: 400px", type="AP_amount", class=(initial_focus == 'row_' _ i ? "initial_focus" : "")) %]
+              [% L.hidden_tag("previous_AP_amount_chart_id_" _ i, $selected_chart_id) %]
               <input type="hidden" name="tax_[% i %]" value="[% temp = "tax"_ i %][% $temp | html %]">
             </td>
             <td>
               <input name="amount_[% i %]" size="10" value="[% temp = "amount_"_ i %][% $temp | html %]">
             </td>
             <td>
-              [% temp = "tax_"_ i %][% $temp | html %]
+              [% temp_r = "tax_reverse_"_ i %]
+              [% IF ($temp_r) %]
+                [% $temp_r | html %]
+                &nbsp;&nbsp;&nbsp;
+                [% temp_c = "tax_charge_"_ i %][% $temp_c | html %]
+              [% ELSE %]
+                [% temp = "tax_"_ i %][% $temp | html %]
+              [% END %]
             </td>
             <td>
               [% temp = 'selected_taxchart_'_ i %]
-              [% L.select_tag('taxchart_'_ i, ALL_TAXCHARTS, value_title_sub = \taxchart_value_title_sub, default = $temp) %]
+              [% taxcharts = 'taxcharts_' _ i %]
+              [% L.select_tag('taxchart_'_ i, $taxcharts, value_title_sub = \taxchart_value_title_sub, default = $temp, style="width: 250px") %]
             </td>
             <td>
               [% temp = "project_id_"_ i %]
-              [% L.select_tag(temp, ALL_PROJECTS, with_empty = 1, default = loop.last ? globalproject_id : $temp, value_key = 'id', title_key = 'projectnumber') %]
+              [% P.project.picker(temp, loop.last ? globalproject_id : $temp) %]
             </td>
           </tr>
         [% END %]
         </tr>
         <tr>
           <td>
-            [% L.select_tag('APselected', ALL_CHARTS_AP, value_title_sub = \APselected_value_title_sub, default = APselected) %]
+            [% P.chart.picker('AP_chart_id', AP_chart_id, style="width: 400px", type="AP") %]
           </td>
           <th align="left">[% invtotal | html %]</th>
           <td colspan="4"></td>
     </tr>
     <tr>
       <td>
-        <table width="100%">
-        <tr>
-          <th align="left" width="1%">[% 'Notes' | $T8 %]</th>
-          <td align="left">
-            <textarea name="notes" rows="[% textarea_rows %]" cols="50" wrap="soft" [% readonly %]>[% notes | html %]</textarea>
-          </td>
-
-          <th align="left" width=1%>[% 'Notes for vendor' | $T8 %]</th>
-          <td align="left">
-            <textarea name="intnotes" rows="[% textarea_rows %]" cols="50" wrap="soft" readonly>[% intnotes | html %]</textarea>
-          </td>
-        </tr>
-      </table>
+        <table>
+          <tr>
+           <th align="left">[% 'Notes' | $T8 %]</th>
+           <th align="left">[% 'Internal Notes' | $T8 %]</th>
+           <th align="left">[% 'Payment Terms' | $T8 %]</th>
+          </tr>
+          <tr valign="top">
+           <td>
+            [% L.textarea_tag("notes", notes, wrap="soft", rows=textarea_rows, cols=50, readonly=readonly) %]
+           </td>
+           <td>
+            [% L.textarea_tag("intnotes", intnotes, wrap="soft", rows=textarea_rows, cols=50, readonly=readonly) %]
+           </td>
+           <td>
+             [% L.select_tag('payment_id', payment_terms, default=payment_id, title_key='description', with_empty=1, style="width: 250px", onchange="kivi.SalesPurchase.set_duedate_on_reference_date_change('transdate')") %]
+           </td>
+          <tr>
+        </table>
     </td>
   </tr>
   <tr>
     <td>
+      [% UNLESS no_payment_bookings %]
       <table width="100%">
         <tr class="listheading">
           <th class="listheading" colspan="7">[% 'Payments' | $T8 %]</th>
             [% temp = "paid_"_ i %]
             <td align="center">
               [% IF( changeable ) %]
-                <input name="[% temp %]" size="11" value="[% $temp | html %]" onBlur="check_right_number_format(this);">
+                <input name="[% temp %]" size="11" data-validate="number" class="numeric" value="[% $temp | html %]" id="[%- 'payment_' _ temp -%]">
               [% ELSE %]
                 [% $temp | html %]
                 <input type="hidden" name="[% temp %]" value="[% $temp | html %]">
               </td>
             [% END %]
 
-            [% temp = "AP_paid_"_ i %]
+            [% temp     = "AP_paid_"_ i %]
+            [% readonly = "AP_paid_readonly_desc_"_ i %]
             <td align="center">
               [% IF( changeable ) %]
                 [% L.select_tag(temp, ALL_CHARTS_AP_paid, value_title_sub = \AP_paid_value_title_sub, default = ($temp || accno_arap))  %]
               [% ELSE %]
-                [% $temp | html %]
+                [% $readonly | html %]
                 <input type="hidden" name="[% temp %]" value="[% $temp | html %]">
               [% END %]
             </td>
             <td align="center">
               [% temp = "paid_project_id_"_ i %]
               [% IF( changeable ) %]
-                [% L.select_tag(temp, ALL_PROJECTS, with_empty = 1, default = $temp, value_key = 'id', title_key = 'projectnumber') %]
+                [% P.project.picker(temp, $temp) %]
               [% ELSE %]
                 <input type="hidden" name="[% temp %]" value="[% $temp | html %]">
                 [% temp = "label"_ temp %]
           <td align="center">[% LxERP.format_amount(paid_missing, 2) | html %]</td>
         </tr>
       </table>
+      [% END %]
     </td>
   </tr>
 </table>
 </div>
+[% PROCESS 'webdav/_list.html' %]
+<div id="ui-tabs-1">
+ [% LxERP.t8('Loading...') %]
 </div>
+</div>
+
+<hr size="3" noshade>
 
 <script type='text/javascript'>
- $('#ap_set_to_paid_missing').click(function(){ $('input[name^="paid_"]:last').val('[% LxERP.format_amount(paid_missing, 2) %]') });
+ $('#ap_set_to_paid_missing').click(function(){ $('input[id^="payment_paid_"]:last').val("[% LxERP.format_amount(paid_missing, 2) %]") });
 </script>