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