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