Bug 22556: Add ability to quickly filter funds/budgets by library on the Acquisitions...
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / acqui-home.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Price %]
4 [% USE Branches %]
5 [% SET footerjs = 1 %]
6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>Koha &rsaquo; Acquisitions</title>
8 [% INCLUDE 'doc-head-close.inc' %]
9 [% Asset.css("lib/jquery/plugins/treetable/stylesheets/jquery.treetable.css") | $raw %]
10 </head>
11
12 <body id="acq_acqui-home" class="acq">
13 [% INCLUDE 'header.inc' %]
14 [% INCLUDE 'acquisitions-search.inc' %]
15
16 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; Acquisitions</div>
17
18 <div class="main container-fluid">
19     <div class="row">
20         <div class="col-sm-10 col-sm-push-2">
21             <main>
22
23 [% INCLUDE 'acquisitions-toolbar.inc' %]
24
25 <h1>Acquisitions</h1>
26     [% INCLUDE 'budgets-active-currency.inc' hide = 'yes' %]
27     [% UNLESS ( loop_budget ) %]
28         [% IF ( CAN_user_acquisition_period_manage ) %]
29         <div class="dialog alert"><a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">You must define a budget in Administration</a></div>
30         [% ELSE %]
31         <div class="dialog alert">Your administrator must define a budget in Administration</div>
32         [% END %]
33     [% END %]
34 <div class="row">
35     [% IF ( suggestion && suggestions_count ) %]
36         <div class="col-sm-6">
37     [% ELSE %]
38         <div class="col-sm-12">
39     [% END %]
40 <div id="acqui_acqui_home_order">
41     <fieldset>
42         <legend>Manage orders</legend>
43         <form name="findsupplier" action="/cgi-bin/koha/acqui/booksellers.pl" method="post">
44             <p><label for="supplierpage">Vendor: </label><input type="text" size="25" name="supplier" id="supplierpage" class="focus" />
45             <input type="submit" value="Search" />
46             </p>
47         </form>
48     </fieldset>
49 </div>
50 </div>
51
52 [% IF ( CAN_user_acquisition_suggestions_manage && suggestion && suggestions_count ) %]
53 <div class="col-sm-6">
54     <div id="acqui_acqui_home_suggestions">
55         <fieldset>
56         <legend>Pending suggestions</legend>
57             <p>[% suggestions_count | html %] suggestions waiting. <a href="/cgi-bin/koha/suggestion/suggestion.pl#ASKED">Manage suggestions</a>.</p>
58         </fieldset>
59     </div>
60 </div>
61 [% END %]
62
63 </div>
64
65 [% IF ( loop_budget ) %]
66
67     <h3>All available funds[% IF LoginBranchname %] for [% LoginBranchname | html %][% END %]</h3>
68
69     <div id="BudgetsAndFunds">
70     <table id="accounts">
71         <caption>
72           <span class="actions"><a href="#" id="expand_all">Expand all</a>
73           | <a href="#" id="collapse_all">Collapse all</a>
74           | <a href="#" id="hide_inactive">Hide inactive budgets</a>
75           | <a href="#" id="show_inactive">Show inactive budgets</a>
76           | <select id="library-filter">
77               <option value="">Filter by library</option>
78               [% FOREACH b IN Branches.all %]
79                 <option value="[% b.branchname | html %]">[% b.branchname | html %]</option>
80               [% END %]
81             </select>
82         </span>
83
84         </caption>
85
86         <thead>
87         <tr>
88             <th>Active</th>
89             <th>Budget period description</th>
90             <th>Fund code</th>
91             <th>Fund name</th>
92             <th>Owner</th>
93             <th>Library</th>
94             <th>Amount</th>
95             <th>Ordered</th>
96             <th>Spent</th>
97             <th>Total available</th>
98         </tr>
99         </thead>
100         <tfoot id="funds_total">
101         <tr>
102             <th></th>
103             <th></th>
104             <th colspan="4">Total</th>
105             <th class="data"></th>
106             <th class="data"></th>
107             <th class="data"></th>
108             <th class="data"></th>
109         </tr>
110         </tfoot>
111         <tbody>
112         [% FOREACH loop_budge IN loop_budget %]
113             [% IF loop_budge.budget_parent_id %]
114                 <tr data-tt-id="[% loop_budge.budget_id | html %]" data-tt-parent-id="[% loop_budge.budget_parent_id | html %]">
115             [% ELSE %]
116                 <tr data-tt-id="[% loop_budge.budget_id | html %]">
117             [% END %]
118
119                 <td>[% loop_budge.budget_period_active | html %]</td>
120                 <td>Budget [% loop_budge.budget_period_description | html %] [id=[% loop_budge.budget_period_id | html %]][% UNLESS loop_budge.budget_period_active %] (inactive)[% END %]</td>
121                 <td>
122                     [% IF ( CAN_user_acquisition_budget_manage ) %]
123                         <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% loop_budge.budget_period_id | uri %]">[% loop_budge.budget_code | html %]</a>
124                     [% ELSE %]
125                         [% loop_budge.budget_code | html %]
126                     [% END %]
127                 </td>
128                 <td>[% loop_budge.budget_name | html %]</td>
129                 <td>[% IF ( loop_budge.budget_owner ) %]
130                         <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>
131                     [% ELSE %]
132                         &nbsp;
133                     [% END %]
134                 </td>
135                 <td>[% Branches.GetName( loop_budge.budget_branchcode ) | html %]</td>
136                 <td class="data">
137                     [% IF loop_budge.budget_parent_id %]
138                         [% loop_budge.budget_amount | $Price %]
139                     [% ELSE %]
140                         <span class="total_amount">[% loop_budge.budget_amount | $Price %]</span>
141                     [% END %]
142                 </td>
143                 <td class="data">
144                     <a href="ordered.pl?fund=[% loop_budge.budget_id | uri %]&amp;fund_code=[% loop_budge.budget_code | uri %]">
145                     [% IF loop_budge.budget_parent_id %]
146                         [% loop_budge.budget_ordered | $Price %]
147                     [% ELSE %]
148                         <span class="total_amount">[% loop_budge.budget_ordered | $Price %]</span>
149                     [% END %]
150                     </a>
151                 </td>
152                 <td class="data">
153                     <a href="spent.pl?fund=[% loop_budge.budget_id | uri %]&amp;fund_code=[% loop_budge.budget_code | uri %]">
154                     [% IF loop_budge.budget_parent_id %]
155                         [% loop_budge.budget_spent | $Price %]
156                     [% ELSE %]
157                         <span class="total_amount">[% loop_budge.budget_spent | $Price %]</span>
158                     [% END %]
159                     </a>
160                 </td>
161                 <td class="data">
162                     [% IF loop_budge.budget_parent_id %]
163                         [% loop_budge.budget_avail | $Price %]
164                     [% ELSE %]
165                         <span class="total_amount">[% loop_budge.budget_avail | $Price %]</span>
166                     [% END %]
167                 </td>
168             </tr>
169         [% END %]
170         </tbody>
171     </table>
172     </div>
173     [% END %]
174
175 </main>
176 </div> <!-- /.col-sm-10.col-sm-push-2 -->
177
178 <div class="col-sm-2 col-sm-pull-10">
179     <aside>
180         [% INCLUDE 'acquisitions-menu.inc' %]
181     </aside>
182 </div>
183 </div> <!-- /.row -->
184
185 [% MACRO jsinclude BLOCK %]
186     [% INCLUDE 'datatables.inc' %]
187     [% Asset.js("lib/jquery/plugins/treetable/jquery.treetable.js") | $raw %]
188     [% Asset.js("js/acquisitions-menu.js") | $raw %]
189     <script>
190         dt_overwrite_html_sorting_localeCompare();
191
192         $(document).ready(function() {
193
194             var oTable = $("#accounts").dataTable($.extend(true, {}, dataTablesDefaults, {
195                 "fnDrawCallback": function ( oSettings ) {
196                     if ( oSettings.aiDisplay.length == 0 )
197                     {
198                         return;
199                     }
200
201                     var nTrs = $('#accounts tbody tr');
202                     var iColspan = nTrs[0].getElementsByTagName('td').length;
203                     var sLastGroup = "";
204                     for ( var i=0 ; i<nTrs.length ; i++ )
205                     {
206                         var iDisplayIndex = oSettings._iDisplayStart + i;
207                         var sGroup = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex] ]._aData[1];
208                         if ( sGroup != sLastGroup )
209                         {
210                             var nGroup = document.createElement( 'tr' );
211                             var nCell = document.createElement( 'td' );
212                             nCell.colSpan = iColspan;
213                             nCell.className = "group";
214                             nCell.innerHTML = sGroup;
215                             nGroup.appendChild( nCell );
216                             nTrs[i].parentNode.insertBefore( nGroup, nTrs[i] );
217                             sLastGroup = sGroup;
218                         }
219                     }
220                 },
221                 "footerCallback": function ( row, data, start, end, display ) {
222                     var api = this.api(), data;
223                     footer_column_sum( api, [ 6, 7, 8, 9 ] );
224                 },
225                 "aoColumnDefs": [
226                     { "bVisible": false, "aTargets": [ 0, 1 ] },
227                     { "bSortable": false, "aTargets": ["_all"] }
228                 ],
229                 'dom': '<"top pager"ilpf>tr<"bottom pager"ip>',
230                 'bSort': true,
231                 'aaSortingFixed': [[ 1, 'asc' ]],
232                 'bPaginate': false,
233                 "bAutoWidth": false
234             }));
235
236             $(oTable).treetable({
237                 expandable: true
238             });
239             $(oTable).treetable('expandAll');
240             $("#expand_all").click(function(e){
241                 e.preventDefault();
242                 $(oTable).treetable('expandAll');
243             });
244             $("#collapse_all").click(function(e){
245                 e.preventDefault();
246                 $(oTable).treetable('collapseAll');
247             });
248
249             $("#hide_inactive").click(function(e){
250                 e.preventDefault();
251                 oTable.fnFilter( 1, 0 ); // Show only active=1
252             });
253             $("#show_inactive").click(function(e){
254                 e.preventDefault();
255                 oTable.fnFilter( '', 0 );
256             });
257             $("#hide_inactive").click();
258
259             $("#library-filter").change(function(){
260                 $("#accounts").DataTable().search(this.value);
261                 $("#accounts").DataTable().draw();
262             });
263
264         });
265     </script>
266 [% END %]
267
268 [% INCLUDE 'intranet-bottom.inc' %]