Bug 26833: Logged in library doesn't show with suggestions count
[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_suggestions_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>
58             Manage suggestions:
59             <a href="/cgi-bin/koha/suggestion/suggestion.pl?branchcode=[% Branches.GetLoggedInBranchcode | url %]#ASKED">
60                 <span id="pendingsuggestions" class="pending-number-link">[% Branches.GetLoggedInBranchname | html %]: [% suggestions_count | html %]</span>
61             </a>
62             [% IF (all_pendingsuggestions > 0) %]
63                 /
64                 <a href="/cgi-bin/koha/suggestion/suggestion.pl?branchcode=__ANY__#ASKED">
65                     <span id="all_pendingsuggestions" class="pending-number-link">All libraries: [% all_pendingsuggestions | html %]</span>
66                 </a>
67             [% END %]
68         </p>
69         </fieldset>
70     </div>
71 </div>
72 [% END %]
73
74 </div>
75
76 [% IF ( loop_budget ) %]
77
78     <h3>All available funds</h3>
79
80     <div id="BudgetsAndFunds">
81     <table id="accounts">
82         <caption>
83           <span class="actions"><a href="#" id="expand_all">Expand all</a>
84           | <a href="#" id="collapse_all">Collapse all</a>
85           | <a href="#" id="hide_inactive">Hide inactive budgets</a>
86           | <a href="#" id="show_inactive">Show inactive budgets</a>
87           | <select id="library-filter">
88               <option value="">Filter by library</option>
89               [% FOREACH b IN Branches.all %]
90                 <option value="[% b.branchname | html %]">[% b.branchname | html %]</option>
91               [% END %]
92             </select>
93         </span>
94
95         </caption>
96
97         <thead>
98         <tr>
99             <th>Active</th>
100             <th>Budget period description</th>
101             <th>Fund code</th>
102             <th>Fund name</th>
103             <th>Owner</th>
104             <th>Library</th>
105             <th>Amount</th>
106             <th>Ordered</th>
107             <th>Spent</th>
108             <th>Total available</th>
109         </tr>
110         </thead>
111         <tfoot id="funds_total">
112         <tr>
113             <th></th>
114             <th></th>
115             <th colspan="4">Total</th>
116             <th class="data"></th>
117             <th class="data"></th>
118             <th class="data"></th>
119             <th class="data"></th>
120         </tr>
121         </tfoot>
122         <tbody>
123         [% FOREACH loop_budge IN loop_budget %]
124             [% IF loop_budge.budget_parent_id %]
125                 <tr data-tt-id="[% loop_budge.budget_id | html %]" data-tt-parent-id="[% loop_budge.budget_parent_id | html %]">
126             [% ELSE %]
127                 <tr data-tt-id="[% loop_budge.budget_id | html %]">
128             [% END %]
129
130                 <td>[% loop_budge.budget_period_active | html %]</td>
131                 <td>Budget [% loop_budge.budget_period_description | html %] [id=[% loop_budge.budget_period_id | html %]][% UNLESS loop_budge.budget_period_active %] (inactive)[% END %]</td>
132                 <td>
133                     [% IF ( CAN_user_acquisition_budget_manage ) %]
134                         <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% loop_budge.budget_period_id | uri %]">[% loop_budge.budget_code | html %]</a>
135                     [% ELSE %]
136                         [% loop_budge.budget_code | html %]
137                     [% END %]
138                 </td>
139                 <td>[% loop_budge.budget_name | html %]</td>
140                 <td>[% IF ( loop_budge.budget_owner ) %]
141                         <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>
142                     [% ELSE %]
143                         &nbsp;
144                     [% END %]
145                 </td>
146                 <td>[% Branches.GetName( loop_budge.budget_branchcode ) | html %]</td>
147                 <td class="data">
148                     [% IF loop_budge.budget_parent_id %]
149                         [% loop_budge.budget_amount | $Price %]
150                     [% ELSE %]
151                         <span class="total_amount">[% loop_budge.budget_amount | $Price %]</span>
152                     [% END %]
153                 </td>
154                 <td class="data">
155                     <a href="ordered.pl?fund=[% loop_budge.budget_id | uri %]&amp;fund_code=[% loop_budge.budget_code | uri %]">
156                     [% IF loop_budge.budget_parent_id %]
157                         [% loop_budge.budget_ordered | $Price %]
158                     [% ELSE %]
159                         <span class="total_amount">[% loop_budge.budget_ordered | $Price %]</span>
160                     [% END %]
161                     </a>
162                 </td>
163                 <td class="data">
164                     <a href="spent.pl?fund=[% loop_budge.budget_id | uri %]&amp;fund_code=[% loop_budge.budget_code | uri %]">
165                     [% IF loop_budge.budget_parent_id %]
166                         [% loop_budge.budget_spent | $Price %]
167                     [% ELSE %]
168                         <span class="total_amount">[% loop_budge.budget_spent | $Price %]</span>
169                     [% END %]
170                     </a>
171                 </td>
172                 <td class="data">
173                     [% IF loop_budge.budget_parent_id %]
174                         [% loop_budge.budget_avail | $Price %]
175                     [% ELSE %]
176                         <span class="total_amount">[% loop_budge.budget_avail | $Price %]</span>
177                     [% END %]
178                 </td>
179             </tr>
180         [% END %]
181         </tbody>
182     </table>
183     </div>
184     [% END %]
185
186 </main>
187 </div> <!-- /.col-sm-10.col-sm-push-2 -->
188
189 <div class="col-sm-2 col-sm-pull-10">
190     <aside>
191         [% INCLUDE 'acquisitions-menu.inc' %]
192     </aside>
193 </div>
194 </div> <!-- /.row -->
195
196 [% MACRO jsinclude BLOCK %]
197     [% INCLUDE 'datatables.inc' %]
198     [% Asset.js("lib/jquery/plugins/treetable/jquery.treetable.js") | $raw %]
199     [% Asset.js("js/acquisitions-menu.js") | $raw %]
200     <script>
201         dt_overwrite_html_sorting_localeCompare();
202
203         $(document).ready(function() {
204
205             var oTable = $("#accounts").dataTable($.extend(true, {}, dataTablesDefaults, {
206                 "fnDrawCallback": function ( oSettings ) {
207                     if ( oSettings.aiDisplay.length == 0 )
208                     {
209                         return;
210                     }
211
212                     var nTrs = $('#accounts tbody tr');
213                     var iColspan = nTrs[0].getElementsByTagName('td').length;
214                     var sLastGroup = "";
215                     for ( var i=0 ; i<nTrs.length ; i++ )
216                     {
217                         var iDisplayIndex = oSettings._iDisplayStart + i;
218                         var sGroup = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex] ]._aData[1];
219                         if ( sGroup != sLastGroup )
220                         {
221                             var nGroup = document.createElement( 'tr' );
222                             var nCell = document.createElement( 'td' );
223                             nCell.colSpan = iColspan;
224                             nCell.className = "group";
225                             nCell.innerHTML = sGroup;
226                             nGroup.appendChild( nCell );
227                             nTrs[i].parentNode.insertBefore( nGroup, nTrs[i] );
228                             sLastGroup = sGroup;
229                         }
230                     }
231                 },
232                 "footerCallback": function ( row, data, start, end, display ) {
233                     var api = this.api(), data;
234                     footer_column_sum( api, [ 6, 7, 8, 9 ] );
235                 },
236                 "aoColumnDefs": [
237                     { "bVisible": false, "aTargets": [ 0, 1 ] },
238                     { "bSortable": false, "aTargets": ["_all"] }
239                 ],
240                 'dom': '<"top pager"ilpf>tr<"bottom pager"ip>',
241                 'bSort': true,
242                 'aaSortingFixed': [[ 1, 'asc' ]],
243                 'bPaginate': false,
244                 "bAutoWidth": false
245             }));
246
247             $(oTable).treetable({
248                 expandable: true
249             });
250             $(oTable).treetable('expandAll');
251             $("#expand_all").click(function(e){
252                 e.preventDefault();
253                 $(oTable).treetable('expandAll');
254             });
255             $("#collapse_all").click(function(e){
256                 e.preventDefault();
257                 $(oTable).treetable('collapseAll');
258             });
259
260             $("#hide_inactive").click(function(e){
261                 e.preventDefault();
262                 oTable.fnFilter( 1, 0 ); // Show only active=1
263             });
264             $("#show_inactive").click(function(e){
265                 e.preventDefault();
266                 oTable.fnFilter( '', 0 );
267             });
268             $("#hide_inactive").click();
269
270             $("#library-filter").change(function(){
271                 $("#accounts").DataTable().search(this.value);
272                 $("#accounts").DataTable().draw();
273             });
274
275         });
276     </script>
277 [% END %]
278
279 [% INCLUDE 'intranet-bottom.inc' %]