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