Bug 22498: Rename variable for budgets loop for invoice adjustments
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / invoice.tt
index aa5770f..6498f42 100644 (file)
@@ -8,7 +8,6 @@
 
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Acquisitions &rsaquo; Invoice</title>
-[% Asset.css("css/datatables.css") | $raw %]
 [% INCLUDE 'doc-head-close.inc' %]
 </head>
 
@@ -30,7 +29,7 @@
       [% END %]
       <h1>Invoice: [% invoicenumber | html %]</h1>
 
-      <p>Vendor: <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid | html %]">[% suppliername | html %]</a></p>
+      <p>Vendor: <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid | uri %]">[% suppliername | html %]</a></p>
         <form action="/cgi-bin/koha/acqui/invoice.pl" method="post" class="validated">
         <fieldset class="rows">
             <ol>
                     <input type="text" size="10" id="billingdate" name="billingdate" value="[% billingdate | $KohaDates %]" class="datepicker" /></li>
 
             <li><label for="shipmentcost">Shipping cost:</label>
-                    <input type="text" size="10" id="shipmentcost" name="shipmentcost" value="[% shipmentcost | html %]" /></li>
-            <li><label for="shipment_budget_id">Shipping fund:</label>
-                    <select id="shipment_budget_id" name="shipment_budget_id">
-                        <option value="">No fund</option>
-                      [% FOREACH budget IN budgets_loop %]
-                        [% IF ( budget.selected ) %]
-                          <option selected="selected" value="[% budget.budget_id | html %]">
-                        [% ELSE %]
-                          <option value="[% budget.budget_id | html %]">
-                        [% END %]
-                          [% budget.budget_name | html %]
-                        </option>
-                      [% END %]
-                    </select></li>
+                    <input type="text" size="10" id="shipmentcost" name="shipmentcost" value="[% shipmentcost | $Price on_editing => 1 %]" /></li>
+
+        <li>
+            <label for="shipment_budget_id">Shipping fund: </label>
+            <select id="shipment_budget_id" name="shipment_budget_id">
+                <option value="">No fund</option>
+                [% FOREACH budget IN budgets %]
+                    [% IF ( budget.selected ) %]
+                        <option value="[% budget.b_id | html %]" selected="selected">[% budget.b_txt | html %] [% IF ( !budget.b_active ) %](inactive)[% END %]</option>
+                    [% ELSIF ( budget.b_active ) %]
+                        <option value="[% budget.b_id | html %]">[% budget.b_txt | html %]</option>
+                    [% ELSE %]
+                        <option value="[% budget.b_id | html %]" class="b_inactive">[% budget.b_txt | html %] (inactive)</option>
+                    [% END %]
+                [% END %]
+            </select>
+            <label for="showallfunds" style="float:none;width:auto;">&nbsp;Show inactive:</label>
+            <input type="checkbox" id="showallfunds" />
+
+        </li>
 
             [% IF ( invoiceclosedate ) %]
             <li><span class="label">Status:</span>
@@ -80,7 +85,7 @@
             <fieldset class="action">
                 <input type="submit" value="Save" />
                 [% UNLESS orders_loop.size %]
-                <a href="invoice.pl?op=delete&invoiceid=[% invoiceid | html %]" id="delete">Delete</a>
+                <a href="invoice.pl?op=delete&invoiceid=[% invoiceid | uri %]" id="delete">Delete</a>
                 [% END %]
             </fieldset>
         </fieldset>
                              <th>Encumber while invoice open</th>
                              <th>&nbsp</th>
                           </tr>
-                          [% total_adj = 0 | html %]
+                          [% total_adj = 0 %]
                           [% FOREACH adjustment IN adjustments %]
-                              [% total_adj = total_adj + adjustment.adjustment | html %]
+                              [% total_adj = total_adj + adjustment.adjustment %]
                               <tr>
                                   <td><input type="hidden" name="adjustment_id" value="[% adjustment.adjustment_id | html %]" />[% adjustment.adjustment_id | html %]</td>
-                                  <td><input type="text" name="adjustment" id="adjustment_[% adjustment.adjustment_id | html %]" value="[% adjustment.adjustment | $Price | html %]" /></td>
+                                  <td><input type="text" name="adjustment" id="adjustment_[% adjustment.adjustment_id | html %]" value="[% adjustment.adjustment | $Price on_editing => 1 %]" /></td>
                                   <td>
-                                      [% reasons = AuthorisedValues.Get("ADJ_REASON") | html %]
+                                      [% reasons = AuthorisedValues.Get("ADJ_REASON") %]
                                       [% IF reasons.0 %]
                                           <select id="reason_[% adjustment.adjustment_id | html %]" name="reason">
                                               <option value="">No reason</option>
                                   <td>
                                       <select id="budget_id_[% adjustment.adjustment_id | html %]" name="budget_id">
                                               <option value="">No fund</option>
-                                          [% FOREACH budget IN budgets_loop %]
-                                              [% IF ( budget.budget_id == adjustment.budget_id ) %]
-                                                  <option selected="selected" value="[% budget.budget_id | html %]">
+                                          [% FOREACH budget IN budgets %]
+                                              [% IF ( budget.b_id == adjustment.budget_id ) %]
+                                                  <option selected="selected" value="[% budget.b_id | html %]">
                                               [% ELSE %]
-                                                  <option value="[% budget.budget_id | html %]">
+                                                  <option value="[% budget.b_id | html %]">
                                               [% END %]
-                                              [% budget.budget_name | html %]
+                                              [% budget.b_txt | html %]
                                               </option>
                                           [% END %]
                                       </select>
                                   <label for="adjustment_new">Amount: </label>
                                   <input type="text" name="adjustment" id="adjustment_new" />
                               </li>
-                              [% reasons = AuthorisedValues.Get("ADJ_REASON") | html %]
+                              [% reasons = AuthorisedValues.Get("ADJ_REASON") %]
                               [% IF reasons.0 %]
                                   <li>
                                       <label for="reason_[% adjustment.adjustment_id | html %]">Reason: </label>
                                   <label for="budget_id_new">Fund: </label>
                                   <select id="budget_id_new" name="budget_id">
                                       <option selected="selected" value="">No fund</option>
-                                      [% FOREACH budget IN budgets_loop %]
-                                          <option value="[% budget.budget_id | html %]">
-                                          [% budget.budget_name | html %]
+                                      [% FOREACH budget IN budgets %]
+                                          <option value="[% budget.b_id | html %]">
+                                          [% budget.b_txt | html %]
                                           </option>
                                       [% END %]
                                   </select>
                   </fieldset>
               </form>
       <p>
-          <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | html %]">Go to receipt page</a>
-          [% IF Koha.Preference('AcqEnableFiles') %]| <a href="/cgi-bin/koha/acqui/invoice-files.pl?invoiceid=[% invoiceid | html %]">Manage invoice files</a>[% END %]
+          <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | uri %]">Go to receipt page</a>
+          [% IF Koha.Preference('AcqEnableFiles') %]| <a href="/cgi-bin/koha/acqui/invoice-files.pl?invoiceid=[% invoiceid | uri %]">Manage invoice files</a>[% END %]
       </p>
       <h2>Invoice details</h2>
       <fieldset>
                 <th>Library</th>
                 <th class="tax_excluded">Actual cost tax exc.</th>
                 <th class="tax_included">Actual cost tax inc.</th>
+                <th class="replacementprice">Replacement price</th>
                 <th>Qty.</th>
                 <th class="tax_excluded">Total tax exc. ([% currency.symbol | html %])</th>
                 <th class="tax_included">Total tax inc. ([% currency.symbol | html %])</th>
                 <tr>
                   <td>
                     [% IF order.biblionumber %]
-                      <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% order.biblionumber | html %]">[% order.title | html %]</a>
+                      <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% order.biblionumber | uri %]">[% order.title | html %]</a>
                       [% IF ( order.author ) %]
                         <br /><em>by</em> [% order.author | html %]
                       [% END %]
                     [% END %]
                   </td>
                   <td><p>[% order.branchcode | html %]</p></td>
-                  <td class="number tax_excluded">[% order.unitprice_tax_excluded | $Price | html %]</td>
-                  <td class="number tax_included">[% order.unitprice_tax_included | $Price | html %]</td>
+                  <td class="number tax_excluded">[% order.unitprice_tax_excluded | $Price %]</td>
+                  <td class="number tax_included">[% order.unitprice_tax_included | $Price %]</td>
+                  <td class="number replacementprice">[% order.replacementprice | $Price %]</td>
                   <td class="number">[% order.quantity | html %]</td>
-                  <td class="number tax_excluded">[% order.total_tax_excluded | $Price | html %]</td>
-                  <td class="number tax_included">[% order.total_tax_included | $Price | html %]</td>
+                  <td class="number tax_excluded">[% order.total_tax_excluded | $Price %]</td>
+                  <td class="number tax_included">[% order.total_tax_included | $Price %]</td>
                   <td class="number">[% order.tax_rate * 100 | html %]</td>
-                  <td class="number">[% order.tax_value | $Price | html %]</td>
+                  <td class="number">[% order.tax_value | $Price %]</td>
                   <td>[% order.budget_name | html %]</td>
                 </tr>
               [% END %]
                     <th colspan="2">Total (GST [% tf.tax_rate * 100 | html %] %)</th>
                     <th class="tax_excluded"></th>
                     <th class="tax_included"></th>
+                    <th class="replacementprice"/>
                     <th>[% tf.quantity | html %]</th>
-                    <th class="tax_excluded">[% tf.total_tax_excluded | $Price | html %]</th>
-                    <th class="tax_included">[% tf.total_tax_included | $Price | html %]</th>
+                    <th class="tax_excluded">[% tf.total_tax_excluded | $Price %]</th>
+                    <th class="tax_included">[% tf.total_tax_included | $Price %]</th>
                     <th>&nbsp;</th>
-                    <th>[% tf.tax_value | $Price | html %]</th>
+                    <th>[% tf.tax_value | $Price %]</th>
                     <th>&nbsp;</th>
                 </tr>
               [% END %]
                 <th colspan="2">Total ([% currency.symbol | html %])</th>
                 <th class="tax_excluded"></th>
                 <th class="tax_included"></th>
+                <th class="replacementprice"/>
                 <th>[% total_quantity | html %]</th>
-                <th class="tax_excluded">[% total_tax_excluded | $Price | html %]</th>
-                <th class="tax_included">[% total_tax_included | $Price | html %]</th>
+                <th class="tax_excluded">[% total_tax_excluded | $Price %]</th>
+                <th class="tax_included">[% total_tax_included | $Price %]</th>
                 <th>&nbsp;</th>
-                <th>[% total_tax_value | $Price | html %]</th>
+                <th>[% total_tax_value | $Price %]</th>
                 <th>&nbsp;</th>
               </tr>
               <tr>
                 <th colspan="2">Total + Adjustments + Shipment cost ([% currency.symbol | html %])</th>
                 <th class="tax_excluded"></th>
                 <th class="tax_included"></th>
+                <th class="replacementprice"/>
                 <th>[% total_quantity | html %]</th>
-                <th class="tax_excluded">[% total_tax_excluded_shipment + total_adj | $Price | html %]</th>
-                <th class="tax_included">[% total_tax_included_shipment | $Price | html %]</th>
+                <th class="tax_excluded">[% total_tax_excluded_shipment + total_adj | $Price %]</th>
+                <th class="tax_included">[% total_tax_included_shipment | $Price %]</th>
                 <th>&nbsp;</th>
-                <th>[% total_tax_value | $Price | html %]</th>
+                <th>[% total_tax_value | $Price %]</th>
                 <th>&nbsp;</th>
               </tr>
             </tfoot>
         [% ELSE %]
             <div class="dialog message"><p>No orders yet</p>
             [% IF adjustments && adjustments.count > 0 || shipmentcost && shipmentcost > 0 %]
-            <p>Adjustments plus shipping:[% total_adj + shipmentcost | $Price | html %]</p>
+            <p>Adjustments plus shipping:[% total_adj + shipmentcost | $Price %]</p>
             [% END %]
             </div>
         [% END %]
                 <tbody>
                 [% FOREACH f IN files %]
                     <tr>
-                         <td><a href="/cgi-bin/koha/acqui/invoice-files.pl?invoiceid=[% invoiceid | html %]&amp;op=download&amp;view=1&amp;file_id=[% f.file_id | html %]">[% f.file_name | html %]</a></td>
+                         <td><a href="/cgi-bin/koha/acqui/invoice-files.pl?invoiceid=[% invoiceid | uri %]&amp;op=download&amp;view=1&amp;file_id=[% f.file_id | uri %]">[% f.file_name | html %]</a></td>
                          <td>[% f.file_type | html %]</td>
                          <td>[% f.file_description | html %]</td>
                          <td class="title-string">
             $("a.delete_adjustment").click(function(){
                 return ( confirm( _("Are you sure you want to delete this file ?") ) );
             });
+
+            //keep a copy of all budgets before removing the inactives
+            var budgetId = $("#shipment_budget_id");
+            var disabledBudgetsCopy = budgetId.html();
+            $('.b_inactive').remove();
+
+            $('#showallfunds').click(function() {
+                if ($(this).is(":checked")) {
+                    budgetId.html(disabledBudgetsCopy); //Puts back all the funds
+                }
+                else {
+                    $('.b_inactive').remove();
+                }
+            });
         });
     </script>
 [% END %]