Bug 32661: Use template wrapper for invoices page tabs
[srvgit] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / invoices.tt
index 0edb542..8df2db4 100644 (file)
@@ -1,5 +1,6 @@
 [% USE raw %]
 [% USE Asset %]
+[% USE AuthorisedValues %]
 [% USE KohaDates %]
 [% USE Branches %]
 [% SET footerjs = 1 %]
 </head>
 
 <body id="acq_invoices" class="acq">
-[% INCLUDE 'header.inc' %]
-[% INCLUDE 'acquisitions-search.inc' %]
+[% WRAPPER 'header.inc' %]
+    [% INCLUDE 'acquisitions-search.inc' %]
+[% END %]
 
 
+[% WRAPPER 'sub-header.inc' %]
 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
     <ol>
         <li>
@@ -27,6 +30,7 @@
         </li>
     </ol>
 </nav>
+[% END %]
 
 <div class="main container-fluid">
     <div class="row">
@@ -48,6 +52,7 @@
                             <label for="show_only_subscription_[% tab | html %]">
                                 Show only subscriptions
                             </label>
+                            <p><a id="CheckAll[% tab | html %]table" data-cb="[% tab | html %]" class="checkall" href="#"><i class="fa fa-check"></i> Select all</a> | <a id="UncheckAll[% tab | html %]table" data-cb="[% tab | html %]" class="uncheckall" href="#"><i class="fa fa-remove"></i> Clear all</a></p>
                             <table id="[% tab | html %]resultst" class="result">
                                 <thead>
                                     <tr>
@@ -84,9 +89,9 @@
                                             <td>[% invoice.receiveditems | html %]</td>
                                             <td>
                                                 [% IF invoice.closedate %]
-                                                    Closed on [% invoice.closedate | $KohaDates %]
+                                                    <span>Closed on [% invoice.closedate | $KohaDates %]</span>
                                                 [% ELSE %]
-                                                    Open
+                                                    <span>Open</span>
                                                 [% END %]
                                             </td>
                                             <td>
                                                             [% IF CAN_user_acquisition_edit_invoices %]
                                                                 <li><a href="invoice.pl?op=close&amp;invoiceid=[% invoice.invoiceid | uri %]&amp;referer=/cgi-bin/koha/acqui/invoices.pl%3Fop=do_search%26invoicenumber=[% invoicenumber | uri %]%26supplier=[% booksellerid | uri %]%26shipmentdatefrom=[% shipmentdatefrom | $KohaDates %]%26shipmentdateto=[% shipmentdateto | $KohaDates %]%26billingdatefrom=[% billingdatefrom | $KohaDates %]%26billingdateto=[% billingdateto | $KohaDates %]%26isbneanissn=[% isbneanissn | uri %]%26title=[% title | uri %]%26author=[% author | uri %]%26publisher=[% publisher | uri %]%26publicationyear=[% publicationyear | uri %]%26branch=[% branch | uri %]"><i class="fa fa-times-circle"></i> Close</a></li>
                                                             [% END %]
-                                                        [% END %]
+                                                        [% END # /IF invoice.closedate %]
                                                         [% UNLESS invoice.receivedbiblios || invoice.receiveditems %]
                                                             [% IF CAN_user_acquisition_delete_invoices %]
                                                                 <li><a href="invoice.pl?op=delete&amp;invoiceid=[% invoice.invoiceid | uri %]&amp;referer=/cgi-bin/koha/acqui/invoices.pl%3Fop=do_search%26invoicenumber=[% invoicenumber | uri %]%26supplier=[% booksellerid | uri %]%26shipmentdatefrom=[% shipmentdatefrom | $KohaDates %]%26shipmentdateto=[% shipmentdateto | $KohaDates %]%26billingdatefrom=[% billingdatefrom | $KohaDates %]%26billingdateto=[% billingdateto | $KohaDates %]%26isbneanissn=[% isbneanissn | uri %]%26title=[% title | uri %]%26author=[% author | uri %]%26publisher=[% publisher | uri %]%26publicationyear=[% publicationyear | uri %]%26branch=[% branch | uri %]" class="delete_invoice"><i class="fa fa-trash"></i> Delete</a></li>
                                                             [% END %]
                                                         [% END %]
                                                     </ul>
-                                                </div>
+                                                </div> <!-- /.btn-group dropup -->
                                             </td>
                                         </tr>
-                                    [% END %]
+                                    [% END # /FOREACH invoice %]
                                 </tbody>
-                            </table>
+                            </table> <!-- /#[% tab | html %]resultst -->
 
                             [% IF CAN_user_acquisition_merge_invoices %]
                                 [% IF tab == 'closed' %]
                                 [% ELSE  %]
                                     <a class="btn btn-default merge" id="merge_open" href="#merge_invoices" data-table="openedresultst"><i class="fa fa-compress"></i> Merge selected invoices</a>
                                     <a class="btn btn-default" id="close_sel" href="#close_selected" data-table="openedresultst" data-op="close" data-referer="referer=/cgi-bin/koha/acqui/invoices.pl%3Fop=do_search%26invoicenumber=[% invoicenumber | uri %]%26supplier=[% booksellerid | uri %]%26shipmentdatefrom=[% shipmentdatefrom | $KohaDates %]%26shipmentdateto=[% shipmentdateto | $KohaDates %]%26billingdatefrom=[% billingdatefrom | $KohaDates %]%26billingdateto=[% billingdateto | $KohaDates %]%26isbneanissn=[% isbneanissn | uri %]%26title=[% title | uri %]%26author=[% author | uri %]%26publisher=[% publisher | uri %]%26publicationyear=[% publicationyear | uri %]%26branch=[% branch | uri %]"><i class="fa fa-times-circle"></i> Close selected invoices</a>
-                                [% END %]
-                            [% END %] <!-- invoices_table -->
-                        [% END %]
+                                [% END # /IF tab == 'closed' %]
+                            [% END # /IF CAN_user_acquisition_merge_invoices %]
+                        [% END # /BLOCK invoices_table %]
 
-                        <div id="invoicestabs" class="toptabs" style="clear:both;">
-                            <ul class="ui-tabs-nav">
-                                <li><a href="#opened">Open invoices ([% openedinvoices.size || 0 | html %])</a></li>
-                                <li><a href="#closed">Closed invoices ([% closedinvoices.size || 0 | html %]) </a></li>
-                            </ul>
-                            <div id="opened">
-                                [% IF openedinvoices %]
-                                    [% INCLUDE invoices_table invoices = openedinvoices %]
-                                [% ELSE %]
-                                    <div class="dialog message">
-                                        <p>Your search returned no open invoices.</p>
-                                    </div>
-                                [% END %]
-                            </div> <!-- opened -->
-                            <div id="closed">
-                                [% IF closedinvoices %]
-                                    [% INCLUDE invoices_table invoices = closedinvoices closed = 1 %]
-                                [% ELSE %]
-                                    <div class="dialog message">
-                                        <p>Your search returned no closed invoices.</p>
-                                    </div>
-                                [% END %]
-                            </div> <!-- closed -->
-                        </div> <!-- invoicestabs -->
+                        [% WRAPPER tabs id= "invoicestabs" %]
+                            [% WRAPPER tabs_nav %]
+                                [% WRAPPER tab_item tabname= "opened" active= 1 %] Open invoices ([% openedinvoices.size || 0 | html %]) [% END %]
+                                [% WRAPPER tab_item tabname= "closed" %] Closed invoices ([% closedinvoices.size || 0 | html %]) [% END %]
+                            [% END %]
+                            [% WRAPPER tab_panels %]
+                                [% WRAPPER tab_panel tabname="opened" active= 1 %]
+                                    [% IF openedinvoices %]
+                                        [% INCLUDE invoices_table invoices = openedinvoices %]
+                                    [% ELSE %]
+                                        <div class="dialog message">
+                                            <p>Your search returned no open invoices.</p>
+                                        </div>
+                                    [% END %]
+                                [% END # /#opened %]
 
+                                [% WRAPPER tab_panel tabname="closed" %]
+                                    [% IF closedinvoices %]
+                                        [% INCLUDE invoices_table invoices = closedinvoices closed = 1 %]
+                                    [% ELSE %]
+                                        <div class="dialog message">
+                                            <p>Your search returned no closed invoices.</p>
+                                        </div>
+                                    [% END %]
+                                [% END # /#closed %]
+                            [% END # /tab_panels %]
+                        [% END # /#invoicestabs %]
 
                         <div id="merge_invoices">
                             <form id="merge_invoice_form" action="/cgi-bin/koha/acqui/invoice.pl" method="post">
                                             <span class="label">Status:</span> <span id="merge_status"></span>
                                         </li>
                                         <li>
-                                            <input type="submit" value="Merge" />
+                                            <input type="submit" class="btn btn-primary" value="Merge" />
                                         </li>
                                     </ol>
                                     <input type="hidden" name="op" value="mod" />
                                     <input type="hidden" id="merge_invoiceid" name="invoiceid" value="" />
-                                </fieldset>
-                            </form>
-                        </div>
-                    [% ELSE %]
+                                </fieldset> <!-- /.rows -->
+                            </form> <!-- /#merge_invoice_form -->
+                        </div> <!-- /#merge_invoices -->
+                    [% ELSE # IF invoices %]
                         <p>Sorry, but there are no results for your search.</p>
                         <p>Search was:
                             <ul>
                                 [% END %]
                                 [% IF shipmentdatefrom %]
                                     <li>
-                                        Shipment date:
+                                        <span>Shipment date:</span>
                                         [% IF shipmentdateto %]
-                                            From [% shipmentdatefrom | $KohaDates %]
-                                            To [% shipmentdateto | $KohaDates %]
+                                            <span>From [% shipmentdatefrom | $KohaDates %]</span>
+                                            <span>To [% shipmentdateto | $KohaDates %]</span>
                                         [% ELSE %]
-                                            All since [% shipmentdatefrom | $KohaDates %]
+                                            <span>All since [% shipmentdatefrom | $KohaDates %]</span>
                                         [% END %]
                                     </li>
                                 [% ELSE %]
                                 [% END %]
                                 [% IF billingdatefrom %]
                                     <li>
-                                        Billing date:
+                                        <span>Billing date:</span>
                                         [% IF billingdateto %]
-                                            From [% billingdatefrom | $KohaDates %]
-                                            To [% billingdateto | $KohaDates %]
+                                            <span>From [% billingdatefrom | $KohaDates %]</span>
+                                            <span>To [% billingdateto | $KohaDates %]</span>
                                         [% ELSE %]
-                                            All since [% billingdatefrom | $KohaDates %]
+                                            <span>All since [% billingdatefrom | $KohaDates %]</span>
                                         [% END %]
                                     </li>
                                 [% ELSE %]
                                 [% END %]
                             </ul>
                         </p>
-                    [% END %]<!-- invoices -->
+                    [% END # /IF invoices %]
                 [% ELSE %]
                     <p>Use the search form on the left to find invoices.</p>
                 [% END %]<!-- do_search -->
                                     <ol>
                                         <li>
                                             <label for="shipmentdatefrom">From:</label>
-                                            <input type="text" id="shipmentdatefrom" name="shipmentdatefrom" size="10" value="[% shipmentdatefrom | $KohaDates %]" class="flatpickr" data-date_to="shipmentdateto" />
+                                            <input type="text" id="shipmentdatefrom" name="shipmentdatefrom" size="10" value="[% shipmentdatefrom | html %]" class="flatpickr" data-date_to="shipmentdateto" />
                                             <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
                                         </li>
                                         <li>
                                             <label for="shipmentdateto">To:</label>
-                                            <input type="text" id="shipmentdateto" name="shipmentdateto" size="10" value="[% shipmentdateto | $KohaDates %]" class="flatpickr" />
+                                            <input type="text" id="shipmentdateto" name="shipmentdateto" size="10" value="[% shipmentdateto | html %]" class="flatpickr" />
                                             <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
                                         </li>
                                     </ol>
                                     <ol>
                                         <li>
                                             <label for="billingdatefrom">From:</label>
-                                            <input type="text" id="billingdatefrom" name="billingdatefrom" size="10" value="[% billingdatefrom | $KohaDates %]" class="flatpickr" data-date_to="billingdateto" />
+                                            <input type="text" id="billingdatefrom" name="billingdatefrom" size="10" value="[% billingdatefrom | html %]" class="flatpickr" data-date_to="billingdateto" />
                                             <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
                                         </li>
                                         <li>
                                             <label for="billingdateto">To:</label>
-                                            <input type="text" id="billingdateto" name="billingdateto" size="10" value="[% billingdateto | $KohaDates %]" class="flatpickr" />
+                                            <input type="text" id="billingdateto" name="billingdateto" size="10" value="[% billingdateto | html %]" class="flatpickr" />
                                             <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
                                         </li>
                                     </ol>
                                     [% PROCESS options_for_libraries libraries => Branches.all( selected => branch, unfiltered => 1 ) %]
                                 </select>
                             </li>
+                        [% FOR field IN additional_fields_for_invoice %]
+                            <li>
+                                <label for="additional_field_[% field.id | html %]ID"> [% field.name | html %]: </label>
+                                [% IF field.authorised_value_category %]
+                                    <select id="additional_field_[% field.id | html %]" name="additional_field_[% field.id | html %]">
+                                        <option value="">All</option>
+                                        [% FOREACH av IN AuthorisedValues.GetAuthValueDropbox(field.authorised_value_category) %]
+                                            [% IF av.authorised_value == additional_field_filters.${field.id} %]
+                                                <option value="[% av.authorised_value | html %]" selected="selected">[% av.lib | html %]</option>
+                                            [% ELSE %]
+                                                <option value="[% av.authorised_value | html %]">[% av.lib | html %]</option>
+                                            [% END %]
+                                        [% END %]
+                                    </select>
+                                [% ELSE %]
+                                    <input id="additional_field_[% field.id | html %]" type="text" value="[% additional_field_filters.${field.id} | html %]" name="additional_field_[% field.id | html %]" />
+                                [% END %]
+                            </li>
+                        [% END %]
                         </ol>
                         <fieldset class="action">
-                            <input type="submit" value="Search" />
+                            <input type="submit" class="btn btn-primary" value="Search" />
                         </fieldset>
-                    </fieldset>
+                    </fieldset> <!-- /.sidebar.brief -->
                     <input type="hidden" name="op" id="op" value="do_search" />
                 </form>
                 [% INCLUDE 'acquisitions-menu.inc' %]
     [% INCLUDE 'calendar.inc' %]
     <script>
         $(document).ready(function() {
-            $('#invoicestabs').tabs();
+            $('[id^="CheckAll"]').click( function() {
+                var table_id = "#" + $(this).attr('data-cb') + "resultst";
+                $(table_id).find('.select-invoice[type="checkbox"]').each( function() {
+                    $(this).prop("checked" , true );
+                });
+            });
+            $('[id^="UncheckAll"]').click( function() {
+                var table_id = "#" + $(this).attr('data-cb') + "resultst";
+                $(table_id).find('.select-invoice[type="checkbox"]').each( function() {
+                    $(this).prop("checked" , false );
+                });
+            });
+
             $(".delete_invoice").click(function(){
                 return confirmDelete(_("Are you sure you want to delete this invoice?"));
             });