Bug 33000: Use template wrapper for breadcrumbs: Acquisitions part 1
[srvgit] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / acqui-home.tt
index 3c1df10..a3b0806 100644 (file)
@@ -1,95 +1,79 @@
+[% USE raw %]
+[% USE Asset %]
 [% USE Price %]
+[% USE Branches %]
+[% USE TablesSettings %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
-<title>Koha &rsaquo; Acquisitions</title>
-<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
+<title>Acquisitions &rsaquo; Koha</title>
 [% INCLUDE 'doc-head-close.inc' %]
-[% INCLUDE 'datatables.inc' %]
-<script type="text/javascript">
-//<![CDATA[
-
-dt_overwrite_html_sorting_localeCompare();
-
-$(document).ready(function() {
-
-    var inactive = $(".b_inactive,.bu_active");
-    var active = $(".bu_inactive");
-    inactive.hide();
-    active.show();
-
-    $('#showallbudgets').click(function() {
-        if ( $('#showallbudgets:checked').val() !== undefined) {
-            inactive.show();
-            active.hide();
-        }
-        else {
-            inactive.hide();
-            active.show();
-        }
-    });
-    var srlt = $("#accounts").dataTable($.extend(true, {}, dataTablesDefaults, {
-        "aoColumns": [
-            null,
-            null,
-            null,
-            null,
-            null,
-            { "sType": "title-numeric" },
-            { "sType": "title-numeric" },
-            { "sType": "title-numeric" },
-            { "sType": "title-numeric" }
-        ],
-        'sDom': 't',
-        'bPaginate': false,
-        'bFilter': false,
-        'bInfo': false
-    } ) );
-});
-//]]>
-</script>
-
+[% Asset.css("lib/jquery/plugins/treetable/stylesheets/jquery.treetable.css") | $raw %]
 </head>
-<body id="acq_acqui-home" class="acq">
-[% INCLUDE 'header.inc' %]
-[% INCLUDE 'acquisitions-search.inc' %]
 
-<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo; </div>
+<body id="acq_acqui-home" class="acq">
+[% WRAPPER 'header.inc' %]
+    [% INCLUDE 'acquisitions-search.inc' %]
+[% END %]
 
-<div id="doc3" class="yui-t2">
+[% WRAPPER 'sub-header.inc' %]
+    [% WRAPPER breadcrumbs %]
+        [% WRAPPER breadcrumb_item bc_active= 1 %]
+            Acquisitions
+        [% END %]
+    [% END #/ WRAPPER breadcrumbs %]
+[% END %]
 
-<div id="bd">
-    <div id="yui-main">
-    <div class="yui-b">
+<div class="main container-fluid">
+    <div class="row">
+        <div class="col-sm-10 col-sm-push-2">
+            <main>
 
 [% INCLUDE 'acquisitions-toolbar.inc' %]
 
 <h1>Acquisitions</h1>
+    [% INCLUDE 'budgets-active-currency.inc' hide = 'yes' %]
     [% UNLESS ( loop_budget ) %]
         [% IF ( CAN_user_acquisition_period_manage ) %]
-        <div class="dialog alert">You must <a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">define a budget</a> in Administration</div>
+        <div class="dialog alert"><a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">You must define a budget in Administration</a></div>
         [% ELSE %]
         <div class="dialog alert">Your administrator must define a budget in Administration</div>
         [% END %]
     [% END %]
-<div class="yui-g">
-<div class="yui-u first">
+<div class="row">
+    [% IF ( suggestions_count || all_pendingsuggestions ) %]
+        <div class="col-sm-6">
+    [% ELSE %]
+        <div class="col-sm-12">
+    [% END %]
 <div id="acqui_acqui_home_order">
     <fieldset>
         <legend>Manage orders</legend>
         <form name="findsupplier" action="/cgi-bin/koha/acqui/booksellers.pl" method="post">
             <p><label for="supplierpage">Vendor: </label><input type="text" size="25" name="supplier" id="supplierpage" class="focus" />
-            <input type="submit" value="Search" />
+            <input type="submit" class="btn btn-primary" value="Search" />
             </p>
         </form>
     </fieldset>
 </div>
 </div>
 
-[% IF ( suggestion && suggestions_count ) %]
-<div class="yui-u">
+[% IF ( CAN_user_suggestions_suggestions_manage && ( suggestions_count || all_pendingsuggestions ) ) %]
+<div class="col-sm-6">
     <div id="acqui_acqui_home_suggestions">
         <fieldset>
         <legend>Pending suggestions</legend>
-            <p>[% suggestions_count %] suggestions waiting. <a href="/cgi-bin/koha/suggestion/suggestion.pl">Manage suggestions</a>.</p>
+        <p>
+            Manage suggestions:
+            <a href="/cgi-bin/koha/suggestion/suggestion.pl?branchcode=[% Branches.GetLoggedInBranchcode | url %]#ASKED">
+                <span id="pendingsuggestions" class="pending-number-link">[% Branches.GetLoggedInBranchname | html %]: [% suggestions_count | html %]</span>
+            </a>
+            [% IF (all_pendingsuggestions > 0) %]
+                /
+                <a href="/cgi-bin/koha/suggestion/suggestion.pl?branchcode=__ANY__#ASKED">
+                    <span id="all_pendingsuggestions" class="pending-number-link">All libraries: [% all_pendingsuggestions | html %]</span>
+                </a>
+            [% END %]
+        </p>
         </fieldset>
     </div>
 </div>
@@ -99,96 +83,211 @@ $(document).ready(function() {
 
 [% IF ( loop_budget ) %]
 
-            <h3>All available funds[% IF ( branchname ) %] for [% branchname %][% END %]</h3>
+<div class="page-section">
+    <h3>All available funds</h3>
 
     <div id="BudgetsAndFunds">
-    <p><label for="showallbudgets">Show active and inactive:</label> <input type="checkbox" id="showallbudgets" /></p>
-    <table id="accounts">
-        <thead>
-        <tr>
-            <th>Fund</th>
-            <th>Fund name</th>
-            <th class="b_inactive">Active</th>
-            <th>Owner</th>
-            <th>Library</th>
-            <th>Amount</th>
-            <th>Ordered</th>
-            <th>Spent</th>
-            <th>Avail</th>
-        </tr>
-        </thead>
-        <tfoot id="funds_total">
-        <tr>
-            <th>Total</th>
-            <th>&nbsp;</th>
-            <th class="b_inactive">&nbsp;</th>
-            <th>&nbsp;</th>
-            <th>&nbsp;</th>
-            <th class="data"><span class="bu_active">[% total %]</span><span class="bu_inactive" >[% total_active | $Price %]</span></th>
-            <th class="data"><span class="bu_active">[% totordered %]</span><span class="bu_inactive" >[% totordered_active | $Price %]</span></th>
-            <th class="data"><span class="bu_active">[% totspent %]</span><span class="bu_inactive" >[% totspent_active | $Price %]</span></th>
-            <th class="data"><span class="bu_active">[% totavail %]</span><span class="bu_inactive" >[% totavail_active | $Price %]</span></th>
-        </tr>
-        </tfoot>
-        <tbody>
-        [% FOREACH loop_budge IN loop_budget %]
-        [% IF ( loop_budge.budget_period_active ) %]
-            <tr>
-                <td>
-                    [% IF ( CAN_user_acquisition_budget_manage ) %]
-                        <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% loop_budge.budget_period_id %]">[% loop_budge.budget_code %]</a>
-                    [% ELSE %]
-                        [% loop_budge.budget_code %]
+        <div class="toolbar btn-toolbar">
+            <span class="actions">
+                <a href="#" id="expand_all">Expand all</a> |
+                <a href="#" id="collapse_all">Collapse all</a> |
+                <a href="#" id="hide_inactive">Hide inactive budgets</a> |
+                <a href="#" id="show_inactive">Show inactive budgets</a> |
+                <select id="library-filter">
+                    <option value="">Filter by library</option>
+                    [% FOREACH b IN Branches.all %]
+                        <option value="[% b.branchname | html %]">[% b.branchname | html %]</option>
                     [% END %]
-                </td>
-                <td>[% loop_budge.budget_name %]</td>
-                <td class="b_inactive">Active</td>
-                <td>[% IF ( loop_budge.budget_owner_borrowernumber ) %]
-                        <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% loop_budge.budget_owner_borrowernumber %]">[% loop_budge.budget_owner_surname %], [% loop_budge.budget_owner_firstname %]</a>
-                    [% ELSE %]
-                        &nbsp;
-                    [% END %]
-                </td>
-                <td>[% loop_budge.budget_branchname %]</td>
-                <td class="data"><span title="[% loop_budge.budget_amount %]">[% loop_budge.budget_amount | $Price %]</span></td>
-                <td class="data"><span title="[% loop_budge.budget_ordered %]"><a href="ordered.pl?fund=[% loop_budge.budget_id %]&amp;fund_code=[% loop_budge.budget_code %]">[% loop_budge.budget_ordered | $Price %]</a></span></td>
-                <td class="data"><span title="[% loop_budge.budget_spent %]"><a href="spent.pl?fund=[% loop_budge.budget_id %]&amp;fund_code=[% loop_budge.budget_code %]">[% loop_budge.budget_spent | $Price %]</span></a></td>
-                <td class="data"><span title="[% loop_budge.budget_avail %]">[% loop_budge.budget_avail | $Price %]</td>
-            </tr>
-        [% ELSE %]
-            <tr class="b_inactive">
-                <td>
-                    [% IF ( CAN_user_acquisition_budget_manage ) %]
-                        <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% loop_budge.budget_period_id %]">[% loop_budge.budget_code %]</a>
-                    [% ELSE %]
-                        [% loop_budge.budget_code %]
-                    [% END %]
-                </td>
-                <td>[% loop_budge.budget_name %]</td>
-                <td class="b_inactive">Inactive</td>
-                <td>[% IF ( loop_budge.budget_owner_borrowernumber ) %]
-                        <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% loop_budge.budget_owner_borrowernumber %]">[% loop_budge.budget_owner_surname %], [% loop_budge.budget_owner_firstname %]</a>
+                </select>
+            </span>
+        </div>
+            <table id="accounts">
+
+                <thead>
+                    <tr>
+                        <th>Active</th>
+                        <th>Budget period description</th>
+                        <th>Fund code</th>
+                        <th>Fund name</th>
+                        <th>Owner</th>
+                        <th>Library</th>
+                        <th>Amount</th>
+                        <th>Ordered</th>
+                        <th>Spent</th>
+                        <th>Total available</th>
+                    </tr>
+                </thead>
+                <tfoot id="funds_total">
+                    <tr>
+                        <th></th>
+                        <th></th>
+                        <th colspan="4">Total</th>
+                        <th class="data"></th>
+                        <th class="data"></th>
+                        <th class="data"></th>
+                        <th class="data"></th>
+                    </tr>
+                </tfoot>
+                <tbody>
+                [% FOREACH loop_budge IN loop_budget %]
+                    [% IF loop_budge.budget_parent_id %]
+                        <tr data-tt-id="[% loop_budge.budget_id | html %]" data-tt-parent-id="[% loop_budge.budget_parent_id | html %]">
                     [% ELSE %]
-                        &nbsp;
+                        <tr data-tt-id="[% loop_budge.budget_id | html %]">
                     [% END %]
-                </td>
-                <td>[% loop_budge.budget_branchname %]</td>
-                <td class="data"><span title="[% loop_budge.budget_amount %]">[% loop_budge.budget_amount | $Price %]</span></td>
-                <td class="data"><span title="[% loop_budge.budget_ordered %]"><a href="ordered.pl?fund=[% loop_budge.budget_id %]&amp;fund_code=[% loop_budge.budget_code %]">[% loop_budge.budget_ordered | $Price %]</a></span></td>
-                <td class="data"><span title="[% loop_budge.budget_spent %]"><a href="spent.pl?fund=[% loop_budge.budget_id %]&amp;fund_code=[% loop_budge.budget_code %]">[% loop_budge.budget_spent | $Price %]</span></a></td>
-                <td class="data"><span title="[% loop_budge.budget_avail %]">[% loop_budge.budget_avail | $Price %]</td>
-            </tr>
-        [% END %]
-        [% END %]
-        </tbody>
-    </table>
-    </div>
-    [% END %]
 
+                        <td>[% loop_budge.budget_period_active | html %]</td>
+                        <td>Budget [% loop_budge.budget_period_description | html %] [id=[% loop_budge.budget_period_id | html %]][% UNLESS loop_budge.budget_period_active %] (inactive)[% END %]</td>
+                        <td>
+                            [% IF ( CAN_user_acquisition_budget_manage ) %]
+                                <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% loop_budge.budget_period_id | uri %]">[% loop_budge.budget_code | html %]</a>
+                            [% ELSE %]
+                                [% loop_budge.budget_code | html %]
+                            [% END %]
+                        </td>
+                        <td>[% loop_budge.budget_name | html %]</td>
+                        <td>[% IF ( loop_budge.budget_owner ) %]
+                                <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% loop_budge.budget_owner.borrowernumber | uri %]">[% loop_budge.budget_owner.surname | html %], [% loop_budge.budget_owner.firstname | html %]</a>
+                            [% ELSE %]
+                                &nbsp;
+                            [% END %]
+                        </td>
+                        <td>[% Branches.GetName( loop_budge.budget_branchcode ) | html %]</td>
+                        <td class="data">
+                            <span class="total_amount" data-parent_id="[% loop_budge.budget_parent_id | html %]" data-self_id="[% loop_budge.budget_id | html %]">[% loop_budge.budget_amount | $Price %]</span>
+                        </td>
+                        <td class="data">
+                            <a href="ordered.pl?fund=[% loop_budge.budget_id | uri %]&amp;fund_code=[% loop_budge.budget_code | uri %]">
+                            [% IF loop_budge.children.size %]
+                                <a title="Ordered from this fund" href="ordered.pl?fund=[% loop_budge.budget_id | uri %]&amp;fund_code=[% loop_budge.budget_code | uri %]">
+                                    (<span class="total_amount">[% loop_budge.budget_ordered | $Price %]</span>)
+                                </a>
+                                <span title="Ordered from this fund and children" class="inclusive_amount">[% loop_budge.total_ordered | $Price %]</span>
+                            [% ELSE %]
+                                <a href="ordered.pl?fund=[% loop_budge.budget_id | uri %]&amp;fund_code=[% loop_budge.budget_code | uri %]">
+                                    <span class="total_amount">[% loop_budge.budget_ordered | $Price %]</span>
+                                </a>
+                            [% END %]
+                        </td>
+                        <td class="data">
+                            [% IF loop_budge.children.size %]
+                                <a title="Spent from this fund" href="spent.pl?fund=[% loop_budge.budget_id | uri %]&amp;fund_code=[% loop_budge.budget_code | uri %]">
+                                    (<span class="total_amount">[% loop_budge.budget_spent | $Price %]</span>)
+                                </a>
+                                <span title="Spent from this fund and children" class="inclusive_amount">[% loop_budge.total_spent | $Price %]</span>
+                            [% ELSE %]
+                                <a href="spent.pl?fund=[% loop_budge.budget_id | uri %]&amp;fund_code=[% loop_budge.budget_code | uri %]">
+                                    <span class="total_amount">[% loop_budge.budget_spent | $Price %]</span>
+                                </a>
+                            [% END %]
+                        </td>
+                        <td class="data">
+                            [% IF loop_budge.children.size %]
+                                (<span title="Remaining in this fund" class="parent_amount" data-parent_id="[% loop_budge.budget_parent_id | html %]" data-self_id="[% loop_budge.budget_id | html %]">[% loop_budge.budget_avail | $Price %]</span>)
+                                <span title="Remaining with child funds included" class="total_amount" data-parent_id="[% loop_budge.budget_parent_id | html %]" data-self_id="[% loop_budge.budget_id | html %]">[% loop_budge.total_avail | $Price %]</span>
+                            [% ELSE %]
+                                <span class="total_amount" data-parent_id="[% loop_budge.budget_parent_id | html %]" data-self_id="[% loop_budge.budget_id | html %]">[% loop_budge.budget_avail | $Price %]</span>
+                            [% END %]
+                        </td>
+                    </tr>
+                [% END %]
+                </tbody>
+            </table>
+    </div><!-- /#BudgetsAndFunds -->
+</div><!-- /.page-section -->
+[% END %]
+
+</main>
+</div> <!-- /.col-sm-10.col-sm-push-2 -->
+
+<div class="col-sm-2 col-sm-pull-10">
+    <aside>
+        [% INCLUDE 'acquisitions-menu.inc' %]
+    </aside>
 </div>
-</div>
-<div class="yui-b">
-[% INCLUDE 'acquisitions-menu.inc' %]
-</div>
-</div>
+</div> <!-- /.row -->
+
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'datatables.inc' %]
+    [% Asset.js("lib/jquery/plugins/treetable/jquery.treetable.js") | $raw %]
+    [% Asset.js("js/acquisitions-menu.js") | $raw %]
+    [% INCLUDE 'columns_settings.inc' %]
+    <script>
+        dt_overwrite_html_sorting_localeCompare();
+
+        $(document).ready(function() {
+            var table_settings = [% TablesSettings.GetTableSettings( 'acqui', 'acq_acqui-home', 'accounts', 'json' ) | $raw %];
+            var oTable = KohaTable("accounts", {
+                "fnDrawCallback": function ( oSettings ) {
+                    if ( oSettings.aiDisplay.length == 0 )
+                    {
+                        return;
+                    }
+
+                    var nTrs = $('#accounts tbody tr');
+                    var iColspan = nTrs[0].getElementsByTagName('td').length;
+                    var sLastGroup = "";
+                    for ( var i=0 ; i<nTrs.length ; i++ )
+                    {
+                        var iDisplayIndex = oSettings._iDisplayStart + i;
+                        var sGroup = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex] ]._aData[1];
+                        if ( sGroup != sLastGroup )
+                        {
+                            var nGroup = document.createElement( 'tr' );
+                            var nCell = document.createElement( 'td' );
+                            nCell.colSpan = iColspan;
+                            nCell.className = "group";
+                            nCell.innerHTML = sGroup;
+                            nGroup.appendChild( nCell );
+                            nTrs[i].parentNode.insertBefore( nGroup, nTrs[i] );
+                            sLastGroup = sGroup;
+                        }
+                    }
+                },
+                "footerCallback": function ( row, data, start, end, display ) {
+                    var api = this.api(), data;
+                    footer_column_sum( api, [ 6, 7, 8, 9 ] );
+                },
+                "aoColumnDefs": [
+                    { "bVisible": false, "aTargets": [ 0, 1 ] },
+                    { "bSortable": false, "aTargets": ["_all"] }
+                ],
+                'bSort': true,
+                'aaSortingFixed': [[ 1, 'asc' ]],
+                'bPaginate': false,
+                "bAutoWidth": false
+            }, table_settings );
+
+            $(oTable).treetable({
+                expandable: true
+            });
+            $(oTable).treetable('expandAll');
+            $("#expand_all").click(function(e){
+                e.preventDefault();
+                $(oTable).treetable('expandAll');
+            });
+            $("#collapse_all").click(function(e){
+                e.preventDefault();
+                $(oTable).treetable('collapseAll');
+            });
+
+            $("#hide_inactive").click(function(e){
+                e.preventDefault();
+                oTable.fnFilter( 1, 0 ); // Show only active=1
+            });
+            $("#show_inactive").click(function(e){
+                e.preventDefault();
+                oTable.fnFilter( '', 0 );
+            });
+            $("#hide_inactive").click();
+
+            $("#library-filter").change(function(){
+                $("#accounts").DataTable().search(this.value);
+                $("#accounts").DataTable().draw();
+            });
+
+        });
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]