Bug 28079: Set focus to search box field when adding an order to basket
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / basket.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% PROCESS 'i18n.inc' %]
4 [% BLOCK csv_export %]
5     <div class="btn-group">
6         <a id="exportbutton" class="btn btn-default" href="[% script_name | url %]?op=export&amp;basketno=[% basketno | uri %]&amp;booksellerid=[% booksellerid | uri %]"><i class="fa fa-download"></i> Export as CSV</a>
7       <a class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></a>
8       <ul class="dropdown-menu" id="export-csv-menu">
9           <li><a href="#">Default</a></li>
10           [% IF csv_profiles %]
11               [% FOR csv IN csv_profiles %]
12                 <li><a href="#" data-value="[% csv.export_format_id | html %]">[% csv.profile | html %]</a></li>
13               [% END %]
14           [% END %]
15        </ul>
16     </div>
17 [% END %]
18 [% USE KohaDates %]
19 [% USE Branches %]
20 [% USE Price %]
21 [% USE AuthorisedValues %]
22 [% USE TablesSettings %]
23 [% SET footerjs = 1 %]
24 [% INCLUDE 'doc-head-open.inc' %]
25 <title>[% UNLESS ( basketno ) %]New [% END %]Basket [% basketname | html %] ([% basketno | html %]) for [% booksellername | html %] &rsaquo; Acquisitions &rsaquo; Koha</title>
26 [% INCLUDE 'doc-head-close.inc' %]
27 <style>
28     .sortmsg {font-size: 80%;}
29 </style>
30 </head>
31
32 <body id="acq_basket" class="acq">
33 [% INCLUDE 'header.inc' %]
34 [% INCLUDE 'acquisitions-search.inc' %]
35
36 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
37     <ol>
38         <li>
39             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
40         </li>
41         <li>
42             <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a>
43         </li>
44         <li>
45             <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid | uri %]">[% booksellername | html %]</a>
46         </li>
47         <li>
48             <a href="#" aria-current="page">
49                 [% UNLESS ( basketno ) %]
50                     [% IF ( delete_confirmed ) %]
51                         Deleted
52                     [% ELSE %]
53                         New
54                     [% END %]
55                 [% END %]
56                 Basket [% basketname | html %]
57                 [% IF ( basketno ) %]
58                     ([% basketno | html %])
59                 [% END %]
60                 for [% booksellername | html %]
61             </a>
62         </li>
63     </ol>
64 </nav>
65
66 <div class="main container-fluid">
67     <div class="row">
68         <div class="col-sm-10 col-sm-push-2">
69             <main>
70
71     [% IF (cannot_manage_basket) %]
72         <div class="dialog alert">You are not authorised to manage this basket.</div>
73     [% ELSE %]
74
75         [% IF !confirm_close && !edi_confirm %]
76         [% UNLESS ( selectbasketg ) %]
77             [% UNLESS ( closedate ) %]
78             [% UNLESS ( delete_confirmed ) %]
79                 <div id="toolbar" class="btn-toolbar fh-fixedHeader">
80                     [% IF active %]
81                         <div class="btn-group"><a href="#addtoBasket" role="button" class="btn btn-default" data-toggle="modal"><i class="fa fa-plus"></i> Add to basket</a></div>
82                     [% END %]
83                     <div class="btn-group"><a href="basketheader.pl?booksellerid=[% booksellerid | uri %]&amp;basketno=[% basketno | uri %]&amp;op=add_form" class="btn btn-default" id="basketheadbutton"><i class="fa fa-pencil"></i> Edit basket</a></div>
84                     [% IF CAN_user_acquisition_delete_baskets %]
85                         <div class="btn-group"><a href="#deleteBasketModal" role="button" class="btn btn-default" data-toggle="modal" id="delbasketbutton"><i class="fa fa-trash"></i> Delete basket</a></div>
86                     [% END %]
87                    [% IF ( unclosable ) %]
88                     [% ELSIF ( uncertainprices ) %]
89                         <div class="btn-group"><a href="/cgi-bin/koha/acqui/uncertainprice.pl?booksellerid=[% booksellerid | uri %]&amp;owner=1" class="btn btn-default" id="uncertpricesbutton"><i class="fa fa-usd"></i> Uncertain prices</a></div>
90                         <div title="Can not close baskets that have items with uncertain prices in them." class="btn-group">
91                             <a href="" class="btn btn-default disabled" id="closebutton"><i class="fa fa-times-circle"></i> Close basket</a>
92                         </div>
93                     [% ELSE %]
94                         <div class="btn-group">
95                             <a href="/cgi-bin/koha/acqui/basket.pl?op=close&amp;basketno=[% basketno | uri %]&amp;booksellerid=[% booksellerid | uri %]" class="btn btn-default" id="closebutton"><i class="fa fa-times-circle"></i> Close basket</a>
96                         </div>
97                     [% END %]
98
99                     [% PROCESS csv_export %]
100
101                         [% IF ediaccount %]
102                         <div class="btn-group"><a href="/cgi-bin/koha/acqui/edi_ean.pl?op=ediorder&amp;basketno=[% basketno | uri %]&amp;booksellerid=[% booksellerid | uri %]" class="btn btn-default" id="ediorderbutton"><i class="fa fa-download"></i> Create EDIFACT order</a></div>
103                         [% END %]
104
105                         [% IF ( active && books_loop ) %]
106                             <div class="btn-group">
107                                 <form action="/cgi-bin/koha/acqui/basket.pl" method="post">
108                                     <input type="hidden" name="op" value="email" />
109                                     <input type="hidden" name="basketno" value="[% basketno | html %]" />
110                                     <button type="submit" class="btn btn-default" id="emailvendorbutton"><i class="fa fa-envelope"></i> E-mail order</button>
111                                 </form>
112                             </div>
113                         [% END %]
114                 </div>
115             [% END %]
116
117             <!-- Modal for confirm deletion box-->
118                 <div class="modal" id="deleteBasketModal" tabindex="-1" role="dialog" aria-labelledby="delbasketModalLabel" aria-hidden="true">
119                     <div class="modal-dialog">
120                     <div class="modal-content">
121                     <div class="modal-header">
122                         <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
123                         <h3>Confirm deletion</h3>
124                     </div>
125                     [% UNLESS book_foot_loop %]
126                         <div class="modal-body">
127                            <p>Are you sure you want to delete this basket?</p>
128                         </div>
129                         <div class="modal-footer">
130                             <button type="button" class="btn btn-primary" data-dismiss="modal">Cancel</button>
131                             <form action="/cgi-bin/koha/acqui/basket.pl" method="get">
132                                 <input type="hidden" name="op" value="delete_confirm" />
133                                 <input type="hidden" name="basketno" value="[% basketno | html %]" />
134                                 <input type="hidden" name="booksellerid" value="[% booksellerid | html %]" />
135                                 <input type="hidden" name="delbiblio" value="0" />
136                                 <button type="submit" class="btn btn-default btn-default">Delete basket</button>
137                             </form>
138                         </div>
139                     [% ELSE %]
140                         <div class="modal-body">
141                            <p>Are you sure you want to delete this basket?</p>
142                            <p>Warning:</p>
143                            <p>All orders of this basket will be cancelled and used funds will be refunded.</p>
144                            <p>If items have been created when ordering or receiving, they will be deleted.</p>
145                            <p>You can choose to delete bibliographic records if possible (bibliographic records that have other items or that are used in a subscription or another order will not be deleted).</p>
146                         </div>
147                         <div class="modal-footer">
148                             <button type="button" class="btn btn-primary" data-dismiss="modal">Cancel</button>
149                             <form action="/cgi-bin/koha/acqui/basket.pl" method="get">
150                                 <input type="hidden" name="op" value="delete_confirm" />
151                                 <input type="hidden" name="basketno" value="[% basketno | html %]" />
152                                 <input type="hidden" name="booksellerid" value="[% booksellerid | html %]" />
153                                 <input type="hidden" name="delbiblio" value="0" />
154                                 <button type="submit" class="btn btn-default btn-default">Delete basket and orders</button>
155                             </form>
156
157                             <form action="/cgi-bin/koha/acqui/basket.pl" method="get">
158                                 <input type="hidden" name="op" value="delete_confirm" />
159                                 <input type="hidden" name="basketno" value="[% basketno | html %]" />
160                                 <input type="hidden" name="booksellerid" value="[% booksellerid | html %]" />
161                                 <input type="hidden" name="delbiblio" value="1" />
162                                 <button type="submit" class="btn btn-default btn-default">Delete basket, orders, and records</button>
163                             </form>
164
165                         </div>
166                     [% END %]
167                     </div>
168                     </div>
169                 </div>
170 <!-- End of Modal-->
171             [% ELSE %]
172                 <div id="toolbar" class="btn-toolbar">
173                     [% IF grouped %]
174                         <div title="Can not reopen baskets that are part of a basket group." class="btn-group">
175                             <div class="btn-group"><a href="#" class="btn btn-default disabled" id="reopenbutton"><i class="fa fa-refresh"></i> Reopen basket</a></div>
176                         </div>
177                     [% ELSE %]
178                         <div class="btn-group"><a href="#" class="btn btn-default" id="reopenbutton"><i class="fa fa-refresh"></i> Reopen basket</a></div>
179
180                         [% PROCESS csv_export %]
181                     [% END %]
182                 </div>
183             [% END %]
184             [% END %]
185
186     [% IF ( NO_BOOKSELLER ) %]
187     <h2>Vendor not found</h2>
188     [% ELSE %]
189         [% IF ( delete_confirmed ) %]
190             <div class="dialog message">
191                 <h3>Basket deleted</h3>
192             </div>
193             [% IF (cannotdelbiblios) %]
194                 <div class="dialog alert">
195                     <p><strong>Warning:</strong></p>
196                     <p><strong>The following records could not be deleted:</strong></p>
197                     <ul>
198                     [% FOREACH cannotdelbiblio IN cannotdelbiblios %]
199                         <li><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% cannotdelbiblio.biblionumber | uri %]">[% cannotdelbiblio.title | html %]</a> by [% cannotdelbiblio.author | html %]:
200                             <ul>
201                             [% IF (cannotdelbiblio.itemcount) %]<li>[% cannotdelbiblio.itemcount | html %] item(s) attached.</li>[% END %]
202                             [% IF (cannotdelbiblio.subscriptions) %]<li>[% cannotdelbiblio.subscriptions | html %] subscription(s) attached.</li>[% END %]
203                             [% IF (cannotdelbiblio.countbiblio) %]<li>[% cannotdelbiblio.countbiblio | html %] order(s) attached.</li>[% END %]
204                             [% IF (cannotdelbiblio.othererror) %]<li>Unknown error.</li>[% END %]
205                             </ul>
206                         </li>
207                     [% END %]
208                     </ul>
209                 </div>
210                 <a href="booksellers.pl">Go back to vendor page</a>
211             [% ELSE %]
212                 <a href="/cgi-bin/koha/acqui/booksellers.pl?booksellerid=[% booksellerid | uri %]" class="btn btn-default btn-sm">Show baskets for vendor [% booksellername | html %]</a> <a href="/cgi-bin/koha/acqui/booksellers.pl" class="btn btn-default btn-sm">Show all active baskets</a>
213             [% END %]
214         [% ELSE %]
215
216         [% FOR m IN messages %]
217             <div class="dialog [% m.type | html %]">
218                 [% SWITCH m.code %]
219                 [% CASE 'no_email' %]
220                     This vendor has no contact selected for sending orders to or is missing an e-mail address.
221                 [% CASE 'no_basketno' %]
222                     No basket given.
223                 [% CASE 'no_letter' %]
224                     There is no notice template with code ACQORDER defined.
225                 [% CASE 'email_sent' %]
226                     Order e-mail was sent to the vendor.
227                 [% CASE %]
228                     ERROR! - [% m.code | html %]
229                 [% END %]
230             </div>
231         [% END %]
232         <h1>[% UNLESS ( basketno ) %]New [% END %]Basket [% basketname | html %] ([% basketno | html %]) for <a href="supplier.pl?booksellerid=[% booksellerid | uri %]">[% booksellername | html %]</a></h1>
233         [% IF ( basketno ) %]
234             <div id="acqui_basket_summary" class="row">
235                 <div class="rows">
236                 <div class="col-sm-6">
237                 <ol>
238                 [% IF ( basketnote ) %]<li><span class="label">Internal note:</span> [% basketnote | html %]</li>[% END %]
239                 [% IF ( basketbooksellernote ) %]<li><span class="label">Vendor note:</span> [% basketbooksellernote | html %]</li>[% END %]
240                 [% IF ( basketcontractno ) %]
241                     <li><span class="label">Contract name:</span> <a href="../admin/aqcontract.pl?op=add_form&amp;contractnumber=[% basketcontractno | uri %]&amp;booksellerid=[% booksellerid | uri %]">[% basketcontractname | html %]</a></li>
242                 [% END %]
243                 [% IF deliveryplace %]<li><span class="label">Delivery place:</span> [% Branches.GetName( deliveryplace ) | html %]</li>[% END %]
244                 [% IF billingplace %]<li><span class="label">Billing place:</span> [% Branches.GetName( billingplace ) | html %]</li>[% END %]
245                 [% IF ( authorisedbyname ) %]<li><span class="label">[% tp('basket created by', 'Created by:') | html %]</span>  [% authorisedbyname | html %]</li>[% END %]
246                 <li id="managedby">
247                     <form action="/cgi-bin/koha/acqui/basket.pl" method="post">
248                         <span class="label">Managed by:</span>
249                         <div style="float:left">
250                             <ul id="users_names" style="padding-left:0">
251                                 [% FOREACH user IN users %]
252                                     <li id="user_[% user.borrowernumber | html %]">
253                                         [% user.firstname | html %] [% user.surname | html %]
254                                         <a href="#" data-borrowernumber="[% user.borrowernumber | html %]" class="del_user"><i class="fa fa-trash"></i> Delete user</a>
255                                     </li>
256                                 [% END %]
257                                 <li>
258                                     <a href="#" id="add_user"><i class="fa fa-plus"></i> Add user</a>
259                                 </li>
260                                 <li id="add_user_submit" style="display:none;">
261                                     <button type="submit" class="btn btn-default btn-xs">Save changes</button>
262                                 </li>
263                             </ul>
264                         </div>
265                         <input type="hidden" id="basketno" name="basketno" value="[% basketno | html %]" />
266                         <input type="hidden" id="users_ids" name="users_ids" value="[% users_ids | html %]" />
267                         <input type="hidden" id="op" name="op" value="mod_users" />
268                     </form>
269
270                 </li>
271                 <li id="branch">
272                     <span class="label">Managing library:</span>
273                     [% IF basketbranchcode %]
274                         [% Branches.GetName( basketbranchcode ) | html %]
275                         <a href="#" id="set_managing_library"><i class="fa fa-pencil"></i> Change library</a>
276                     [% ELSE %]
277                         No library
278                         <a href="#" id="set_managing_library"><i class="fa fa-pencil"></i> Set library</a>
279                     [% END %]
280                 </li>
281                 [% IF branches_loop.size %]
282                     <li id="managing_library_entry" style="display:none;">
283                         <span class="label">&nbsp;</span>
284                         <div style="float:left">
285                             <form action="/cgi-bin/koha/acqui/basket.pl" method="post">
286                                 <select id="select_managing_library" name="branch">
287                                     <option value="">(no library)</option>
288                                     [% FOREACH branch IN branches_loop %]
289                                         [% IF ( basketbranchcode == branch.branchcode ) %]
290                                             <option selected="selected" value="[% branch.branchcode | html %]"> [% branch.branchname | html %]</option>
291                                         [% ELSE %]
292                                             <option value="[% branch.branchcode | html %]"> [% branch.branchname | html %]</option>
293                                         [% END %]
294                                     [% END %]
295                                 </select>
296                                 <a id="library_entry_cancel" href="#" class="cancel">Cancel</a>
297                                 <input type="hidden" id="basketno" name="basketno" value="[% basketno | html %]" />
298                                 <input type="hidden" id="op" name="op" value="mod_branch" />
299                             </form>
300                         </div>
301                     </li>
302                 [% END %]
303
304                 [% INCLUDE 'additional-fields-display.inc' available=available_additional_fields values=additional_field_values %]
305
306                 </ol>
307                 </div> <!-- /.col-sm-6 -->
308
309                 <div class="col-sm-6">
310                     <ol>
311                         [% IF ( creationdate ) %]
312                             <li><span class="label">Opened on:</span>  [% creationdate | $KohaDates %]</li>
313                         [% END %]
314                         [% IF ( closedate ) %]
315                             <li><span class="label">Closed on:</span> [% closedate | $KohaDates %]</li>
316                         [% END %]
317                         [% IF ( ediaccount ) %]
318                             [%- BLOCK edi_status -%]
319                                 [%- SWITCH edi_order.status -%]
320                                     [%- CASE 'Pending'   -%]Pending
321                                     [%- CASE 'Sent'      -%]Sent
322                                     [%- CASE 'Processed' -%]Processed
323                                 [%- END -%]
324                             [%- END -%]
325                             [% IF ( edi_order ) %]
326                             <li><span class="label">EDI status:</span> [%- PROCESS edi_status edi_order=edi_order -%] ([% edi_order.transfer_date | $KohaDates %])</li>
327                             [% ELSE %]
328                             <li><span class="label">EDI status:</span> Not ordered</li>
329                             [% END %]
330                         [% END %]
331                         [% IF ( estimateddeliverydate ) %]
332                             <li><span class="label">Estimated delivery date:</span> [% estimateddeliverydate | $KohaDates %]</li>
333                         [% END %]
334                         <li><span class="label">Orders are standing:</span> [% IF is_standing %]Yes[% ELSE %]No[% END %]</li>
335
336                         [% IF basket.create_items %]
337                             <li>
338                                 <span class="label">Create items when:</span>
339                                 [% SWITCH basket.create_items %]
340                                     [% CASE 'receiving' %]Receiving items
341                                     [% CASE 'cataloguing' %]Cataloguing items
342                                     [% CASE %]Placing orders
343                                 [% END %]
344                             </li>
345                         [% END %]
346                     </ol>
347
348                     [% IF ( closedate ) %]
349                         <ol>
350                             <li>
351                                 <span class="label">Basket group:</span>
352                                 [% IF basketgroup.id and not basketgroup.name %]
353                                     [% SET basketgroup.name = "Basket group no. " _ basketgroup.id %]
354                                 [% END %]
355
356                                 [% IF basketgroup.closed %]
357                                     [% IF ( CAN_user_acquisition_group_manage ) %]
358                                         <a href="basketgroup.pl?op=add&booksellerid=[% booksellerid | uri %]&basketgroupid=[% basketgroup.id | uri %]" title="basketgroup">[% basketgroup.name | html %] (closed)</a>
359                                     [% ELSE %]
360                                         [% basketgroup.name | html %] (closed)
361                                     [% END %]
362                                 [% ELSIF ( ! CAN_user_acquisition_group_manage ) %]
363                                     [%- IF basketgroup.id -%]
364                                 [% basketgroup.name | html %]
365                                     [%- ELSE -%]
366                                         No group
367                                     [%- END -%]
368                                 [% ELSE %]
369                                     [% IF ( CAN_user_acquisition_group_manage ) %]
370                                         [% IF ( basketgroup.id ) %]
371                                             [% basketgroup.name | html %]
372                                             <a href="#" id="set_basket_group"><i class="fa fa-pencil"></i> Change basket group</a>
373                                         [% ELSE %]
374                                             No group
375                                             <a href="#" id="set_basket_group"><i class="fa fa-pencil"></i> Set basket group</a>
376                                         [% END %]
377                                     [% END %]
378                                 [% END %]
379                             </li>
380                             [% IF ( CAN_user_acquisition_group_manage ) %]
381                                 <li id="basket_grouping" style="display:none;">
382                                     <span class="label">&nbsp;</span>
383                                     <div style="float:left">
384                                         <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="post">
385                                             <select id="basketgroupid" name="basketgroupid">
386                                                 <option value="">No group</option>
387                                                 [% FOREACH bg IN basketgroups %]
388                                                     [% IF ( bg.default ) %]
389                                                         <option value="[% bg.id | html %]" selected="selected">[% bg.name | html %]</option>
390                                                     [% ELSE %]
391                                                         [% UNLESS bg.closed %]
392                                                             <option value="[% bg.id | html %]">[% bg.name | html %]</option>
393                                                         [% ELSE %]
394                                                             <option value="[% bg.id | html %]" disabled="disabled">[% bg.name | html %] (closed)</option>
395                                                         [% END %]
396                                                     [% END %]
397                                                 [% END %]
398                                                 <option value="new">Add new group</option>
399                                             </select>
400                                             <a href="#" id="basket_group_cancel" class="cancel">Cancel</a>
401                                             <input type="hidden" id="basketno" value="[% basketno | html %]" name="basketno" />
402                                             <input type="hidden" value="mod_basket" name="op" />
403                                             <input type="hidden" name="booksellerid" value="[% booksellerid | html %]" />
404                                         </form>
405                                     </div>
406                                 </li>
407                             [% END # /IF ( CAN_user_acquisition_group_manage ) %]
408                             [% IF basketgroup.deliveryplace %]
409                                 <li>
410                                     <span class="label">Basket group delivery placename:</span> [% Branches.GetName( basketgroup.deliveryplace ) | html %]
411                                 </li>
412                             [% END %]
413                             [% IF basketgroup.billingplace %]
414                                 <li>
415                                     <span class="label">Basket group billing place:</span> [% Branches.GetName( basketgroup.billingplace ) | html %]
416                                 </li>
417                             [% END %]
418                         </ol>
419                     [% END # /IF closeddate %]
420                     </div> <!-- /.rows -->
421                 </div> <!-- /.col-sm-6 -->
422             </div> <!-- /#acqui_basket_summary.row -->
423         [% END %]
424         [% IF ( duplinbatch ) %]<div class="dialog alert">
425         <h4>Duplicate warning</h4>
426         <p>Some records have not been automatically added because they match an existing record in your catalog:<a href="/cgi-bin/koha/acqui/addorderiso2709.pl?import_batch_id=[% duplinbatch | uri %]&amp;basketno=[% basketno | uri %]&amp;booksellerid=[% booksellerid | uri %]" title="Open in new window" target="_blank" style="margin-left:10px"><i class="fa fa-window-restore"></i> Display them</a></p>
427         </div>[% END %]
428
429         <div id="acqui_basket_content">
430         [% IF ( books_loop ) %]
431             <h2>Orders</h2>
432             <table id="orders">
433                 <thead>
434                     <tr>
435                         <th>No.</th>
436                         <th>[% tp('noun', 'Order') | html %]</th>
437                         <th>RRP tax exc.</th>
438                         <th>Actual cost tax exc.</th>
439                         <th>Budgeted cost tax exc.</th>
440                         <th>RRP tax inc.</th>
441                         <th>Actual cost tax inc.</th>
442                         <th>Budgeted cost tax inc.</th>
443                         <th>Replacement price</th>
444                         <th>Qty.</th>
445                         <th>Total tax exc. ([% currency | html %])</th>
446                         <th>Total tax inc. ([% currency | html %])</th>
447                         <th>GST %</th>
448                         <th>GST</th>
449                         <th>Fund</th>
450                         <th>Supplier report</th>
451                         [% IF ( active ) %]
452                             [% UNLESS ( closedate ) %]
453                                 <th class="NoSort">Modify</th>
454                                 <th class="NoSort">Cancel order</th>
455                             [% END %]
456                         [% END %]
457                     </tr>
458                 </thead>
459                 <tfoot>
460                 [% FOREACH foot_loo IN book_foot_loop %]
461                     <tr>
462                         <th></th>
463                         <th>Total (GST [% foot_loo.tax_rate * 100 | html %])</th>
464                         <th>&nbsp;</th>
465                         <th>&nbsp;</th>
466                         <th>&nbsp;</th>
467                         <th>&nbsp;</th>
468                         <th>&nbsp;</th>
469                         <th>&nbsp;</th>
470                         <th>&nbsp;</th>
471                         <th>[% foot_loo.quantity | html %]</th>
472                         <th>[% foot_loo.total_tax_excluded | $Price %]</th>
473                         <th>[% foot_loo.total_tax_included | $Price %]</th>
474                         <th>&nbsp;</th>
475                         <th>[% foot_loo.tax_value | $Price %]</th>
476                         <th>&nbsp;</th>
477                         <th>&nbsp;</th>
478                         [% IF ( active ) %]
479                             [% UNLESS ( closedate ) %]
480                                 <th>&nbsp;</th>
481                                 <th>&nbsp;</th>
482                             [% END %]
483                         [% END %]
484                     </tr>
485                 [% END %]
486                 <tr>
487                     <th></th>
488                     <th>Total ([% currency | html %])</th>
489                     <th>&nbsp;</th>
490                     <th>&nbsp;</th>
491                     <th>&nbsp;</th>
492                     <th>&nbsp;</th>
493                     <th>&nbsp;</th>
494                     <th>&nbsp;</th>
495                     <th>&nbsp;</th>
496                     <th>[% total_quantity | html %]</th>
497                     <th>[% total_tax_excluded | $Price %]</th>
498                     <th>[% total_tax_included | $Price %]</th>
499                     <th>&nbsp;</th>
500                     <th>[% total_tax_value | $Price %]</th>
501                     <th>&nbsp;</th>
502                     <th>&nbsp;</th>
503                     [% IF ( active ) %]
504                         [% UNLESS ( closedate ) %]
505                             <th>&nbsp;</th>
506                             <th>&nbsp;</th>
507                         [% END %]
508                     [% END %]
509                 </tr>
510                 </tfoot>
511                 <tbody>
512                 [% FOREACH books_loo IN books_loop %]
513                     [% IF ( books_loo.order_received ) %]
514                         <tr class="disabled">
515                     [% ELSE %]
516                         <tr>
517                     [% END %]
518                         <td>
519                             [% books_loo.ordernumber | html %]
520                         </td>
521                         <td>
522                             <p>
523                                 [% IF ( books_loo.order_received ) %] <span class="order-received">(received)</span>[% END %]
524                                 [%- IF books_loo.title %]
525                                     <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% books_loo.biblionumber | uri %]">[% books_loo.title | html %]</a>[% IF books_loo.author %] by [% books_loo.author | html %][% END -%]
526                                 [%- ELSE -%]
527                                     <em>Deleted bibliographic record, can't find title</em><br />
528                                 [%- END %]
529                                 <br />
530                                 [%- IF ( books_loo.isbn ) %] - [% books_loo.isbn | html %][% END -%]
531                                 [%- IF ( books_loo.issn ) %] - [% books_loo.issn | html %][% END -%]
532                                 [%- IF ( books_loo.publishercode ) %], [% books_loo.publishercode | html %][% END -%]
533                                 [%- IF ( books_loo.publicationyear ) %], [% books_loo.publicationyear | html -%]
534                                 [%- ELSIF ( books_loo.copyrightdate ) %] [% books_loo.copyrightdate | html %][% END -%]
535                                 [%- IF ( books_loo.editionstatement ) %], [% books_loo.editionstatement | html %][% END -%]
536                                 [%- IF ( books_loo.suggestionid ) %]
537                                     <br/>
538                                     Suggested by: [% books_loo.surnamesuggestedby | html %][% IF ( books_loo.firstnamesuggestedby ) %], [% books_loo.firstnamesuggestedby | html %] [% END %]
539                                     (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% books_loo.suggestionid | uri %]&amp;op=show">suggestion #[% books_loo.suggestionid | html %]</a>)
540                                 [% END %]
541                             </p>
542                                 [% IF ( books_loo.order_internalnote ) %]
543                                     <p class="ordernote"><strong>Internal note: </strong><span id="internal-note-[% books_loo.ordernumber | html %]">[% books_loo.order_internalnote | html %]</span> <a class="edit_note noExport" data-ordernumber="[% books_loo.ordernumber | html %]" data-note_type="internal" href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% books_loo.ordernumber | html %]&type=internal" title="Edit internal note"><i class="fa fa-pencil"></i> Edit internal note</a></p>
544                                 [% ELSE %]
545                                     <a class="edit_note noExport" data-ordernumber="[% books_loo.ordernumber | html %]" data-note_type="internal" href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% books_loo.ordernumber | html %]&type=internal" title="Add internal note"><i class="fa fa-plus"></i> Add internal note</a>
546                                 [% END %]
547                                 [% IF ( books_loo.order_vendornote ) %]
548                                     <p class="ordernote"><strong>Vendor note: </strong> <span id="vendor-note-[% books_loo.ordernumber | html %]">[% books_loo.order_vendornote | html %]</span> <a class="edit_note noExport" data-ordernumber="[% books_loo.ordernumber | html %]" data-note_type="vendor" href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% books_loo.ordernumber | html %]&type=vendor" title="Edit vendor note"><i class="fa fa-pencil"></i> Edit vendor note</a></p>
549                                 [% ELSE %]
550                                     <a class="edit_note noExport" data-ordernumber="[% books_loo.ordernumber | html %]" data-note_type="vendor" href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% books_loo.ordernumber | html %]&type=vendor" title="Add vendor note"><i class="fa fa-plus"></i> Add vendor note</a>
551                                 [% END %]
552                             [% IF (books_loo.transferred_from) %]
553                               [% basket = books_loo.transferred_from.basket %]
554                               [% bookseller = books_loo.transferred_from.bookseller %]
555                               [% timestamp = books_loo.transferred_from.timestamp %]
556                               <p>Transferred from basket:
557                                 <a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basket.basketno | uri %]"> [% basket.basketname | html %]</a>
558                                 (<a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% bookseller.id | uri %]">[% bookseller.name | html %]</a>)
559                                 on <span title="[% timestamp | $KohaDates with_hours = 1 %]">
560                                   [% timestamp | $KohaDates %]
561                                 </span>
562                               </p>
563                             [% END %]
564                             [% SET claims = books_loo.order_object.claims %]
565                             [% IF claims.count %]
566                                 <p>
567                                     This order has been claimed [% claims.count | html %] times. On [% FOR c IN claims %][% c.claimed_on | $KohaDates %][% UNLESS loop.last %], [% END %][% END %]
568                                 </p>
569                             [% END %]
570                         </td>
571                         [% SET zero_regex = "^0{1,}\.?0{1,}[^1-9]" %] [%# 0 or 0.0 or 0.00 or 00 or 00.0 or 00.00 or 0.000 ... %]
572                         [%# FIXME: use of a regexp is not ideal; bugs 9410 and 10929 suggest better way of handling this %]
573                         <td class="number [% IF books_loo.rrp_tax_excluded.search(zero_regex) %]error[% END %]">[% books_loo.rrp_tax_excluded | $Price %] [% IF ( books_loo.uncertainprice ) %] (Uncertain) [% END %] </td>
574                         <td class="number [% IF books_loo.unitprice_tax_excluded.search(zero_regex) %]error[% END %]">[% books_loo.unitprice_tax_excluded | $Price %]</td>
575                         <td class="number [% IF books_loo.ecost_tax_excluded.search(zero_regex) %]error[% END %]">[% books_loo.ecost_tax_excluded | $Price %]</td>
576                         <td class="number [% IF books_loo.rrp_tax_included.search(zero_regex) %]error[% END %]">[% books_loo.rrp_tax_included | $Price %]</td>
577                         <td class="number [% IF books_loo.unitprice_tax_included.search(zero_regex) %]error[% END %]">[% books_loo.unitprice_tax_included | $Price %]</td>
578                         <td class="number [% IF books_loo.ecost_tax_included.search(zero_regex) %]error[% END %]">[% books_loo.ecost_tax_included | $Price %]</td>
579                         <td class="number [% IF books_loo.replacementprice.search(zero_regex) %]error[% END %]">[% books_loo.replacementprice | $Price %]</td>
580                         <td class="number [% IF books_loo.quantity.search(zero_regex) %]error[% END %]">[% books_loo.quantity | html %]</td>
581                         <td class="number [% IF books_loo.total_tax_excluded.search(zero_regex) %]error[% END %]">[% books_loo.total_tax_excluded | $Price %]</td>
582                         <td class="number [% IF books_loo.total_tax_included.search(zero_regex) %]error[% END %]">[% books_loo.total_tax_included | $Price %]</td>
583                         <td class="number">[% books_loo.tax_rate * 100 | html %]</td>
584                         <td class="number [% IF books_loo.tax_value.search(zero_regex) %]error[% END %]">[% books_loo.tax_value | $Price %]</td>
585                         <td>[% books_loo.budget_name | html %]</td>
586                         <td>[% books_loo.suppliers_report | html %]</td>
587                         [% IF ( active ) %]
588                             [% UNLESS ( closedate ) %]
589                             <td>
590                                 <a href="neworderempty.pl?ordernumber=[% books_loo.ordernumber | uri %]&amp;booksellerid=[% booksellerid | uri %]&amp;basketno=[% basketno | uri %]">Modify</a>
591                                 [% UNLESS (books_loo.order_received) %]
592                                     <br />
593                                     <a href="#" class="transfer_order" data-ordernumber="[% books_loo.ordernumber | html %]">Transfer</a>
594                                 [% END %]
595                             </td>
596                             <td>
597                             [% IF ( books_loo.orderstatus != "complete") %]
598                                 [% IF ( books_loo.left_holds_on_order ) %]
599                                     <span class="button" title="Can't cancel order, ([% books_loo.holds_on_order | html %]) holds are linked with this order. Cancel holds first">Can't cancel order</span><br>
600                                 [% ELSE %]
601                                     <a href="/cgi-bin/koha/acqui/cancelorder.pl?ordernumber=[% books_loo.ordernumber | uri %]&biblionumber=[% books_loo.biblionumber | uri %]&basketno=[% basketno | uri %]&referrer=/cgi-bin/koha/acqui/basket.pl%3Fbasketno=[% basketno | uri %]" class="button">Cancel order</a><br>
602                                 [% END %]
603                                 [% IF ( books_loo.can_del_bib ) %]
604                                     <a href="/cgi-bin/koha/acqui/cancelorder.pl?ordernumber=[% books_loo.ordernumber | uri %]&biblionumber=[% books_loo.biblionumber | uri %]&basketno=[% basketno | uri %]&del_biblio=1&referrer=/cgi-bin/koha/acqui/basket.pl%3Fbasketno=[% basketno | uri %]" class="button">Cancel order and delete catalog record</a><br>
605                                 [% ELSE %]
606                                     <span class="button" title="Can't delete catalog record, see constraints below">Can't cancel order and delete catalog record</span><br>
607                                 [% END %]
608                                 [% IF ( books_loo.left_item ) %]
609                                     <strong title="Can't delete catalog record, because of [% books_loo.items | html %] existing hold(s)" >[% books_loo.items | html %] item(s) left</strong><br>
610                                 [% END %]
611                                 [% IF ( books_loo.left_biblio ) %]
612                                     <strong title="Can't delete catalog record, delete other orders linked to it first">[% books_loo.biblios | html %] order(s) left</strong><br>
613                                 [% END %]
614                                 [% IF ( books_loo.left_subscription ) %]
615                                     <strong title="Can't delete catalog record, delete subscriptions first">[% books_loo.subscriptions | html %] subscription(s) left</strong><br>
616                                 [% END %]
617                                 [% IF ( books_loo.left_holds ) %]
618                                     <strong title="Can't delete catalog record or order, cancel holds first">[% books_loo.holds | html %] hold(s) left</strong>
619                                 [% END %]
620                             [% END %]
621                             </td>
622                             [% END %]
623                         [% END %]
624                     </tr>
625                 [% END %]
626                 </tbody>
627             </table>
628         [% END %]
629         [% IF ( listincgst ) %]<small class="highlight">** Vendor's listings already include tax.</small>
630         [% END %]
631         </div> <!-- /#acqui_basket_content -->
632         [% IF (cancelledorders_loop) %]
633           <div id="cancelledorders">
634             <h2>Cancelled orders</h2>
635             <table id="cancelledorderst">
636               <thead>
637                 <tr>
638                   <th>No.</th>
639                   <th>[% tp('noun', 'Order') | html %]</th>
640                   <th class="tax_excluded">RRP tax exc.</th>
641                   <th class="tax_excluded">ecost tax exc.</th>
642                   <th class="tax_included">RRP tax inc.</th>
643                   <th class="tax_included">ecost tax inc.</th>
644                   <th class="replacementprice">Replacement price</th>
645                   <th>Qty.</th>
646                   <th class="tax_excluded">Total tax exc. ([% currency | html %])</th>
647                   <th class="tax_included">Total tax inc. ([% currency | html %])</th>
648                   <th>GST %</th>
649                   <th>GST</th>
650                   <th>Fund</th>
651                 </tr>
652               </thead>
653               <tbody>
654                 [% FOREACH order IN cancelledorders_loop %]
655                   <tr style="color:grey">
656                     <td>
657                         [% order.ordernumber | html %]
658                     </td>
659                     <td>
660                       <p>
661                         [% IF ( order.order_received ) %] <span class="order-received">(received)</span>[% END %]
662                         [% IF (order.title) %]
663                           [% order.title | html %][% IF order.author %] by [% order.author | html %][% END %]
664                         [% ELSE %]
665                           <em>Deleted bibliographic record, can't find title</em>
666                         [% END %]
667                         <br />
668                         [% IF ( order.order_internalnote ) %] [% order.order_internalnote | html %][% END %]
669                         [% IF ( order.isbn ) %] - [% order.isbn | html %][% END %]
670                         [% IF ( order.issn ) %] - [% order.issn | html %][% END %]
671                         [% IF ( order.publishercode ) %], [% order.publishercode | html %][% END %]
672                         [% IF ( order.publicationyear ) %], [% order.publicationyear | html %]
673                         [% ELSIF ( order.copyrightdate ) %] [% order.copyrightdate | html %][% END %]
674                         [% IF ( books_loo.editionstatement ) %], [% books_loo.editionstatement | html %][% END %]
675                         [% IF ( order.cancellationreason ) %]
676                           <br />
677                           Cancellation reason: [% AuthorisedValues.GetByCode( 'ORDER_CANCELLATION_REASON', order.cancellationreason ) | html %]
678                         [% END %]
679                       </p>
680                       [% IF order.transferred_to %]
681                         [% basket = order.transferred_to.basket %]
682                         [% bookseller = order.transferred_to.bookseller %]
683                         [% timestamp = order.transferred_to.timestamp %]
684                         <p>Transferred to basket:
685                           <a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basket.basketno | uri %]"> [% basket.basketname | html %]</a>
686                           (<a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% bookseller.id | uri %]">[% bookseller.name | html %]</a>)
687                           on <span title="[% timestamp | $KohaDates with_hours = 1 %]">
688                             [% timestamp | $KohaDates %]
689                           </span>
690                         </p>
691                       [% END %]
692                     </td>
693                     <td class="number">
694                         [% order.rrp_tax_excluded | $Price %]
695                         [% IF ( order.uncertain ) %]
696                             (Uncertain)
697                         [% END %]
698                     </td>
699                     <td class="number">[% order.ecost_tax_excluded | $Price %]</td>
700                     <td class="number">[% order.rrp_tax_included | $Price %]</td>
701                     <td class="number">[% order.ecost_tax_included | $Price %]</td>
702                     <td class="number">[% order.replacementprice | $Price %]</td>
703                     <td class="number">[% order.quantity | html %]</td>
704                     <td class="number">[% order.total_tax_excluded | $Price %]</td>
705                     <td class="number">[% order.total_tax_included | $Price %]</td>
706                     <td class="number">[% order.tax_rate * 100 | html %]</td>
707                     <td class="number">[% order.tax_value | $Price %]</td>
708                     <td>[% order.budget_name | html %]
709                   </tr>
710                 [% END %]
711               </tbody>
712             </table>
713           </div> <!-- /#cancelledorders -->
714         [% END %]
715         <br />
716
717         [% UNLESS ( closedate ) %]
718             <!-- Modal -->
719             <div id="addtoBasket" class="modal" tabindex="-1" role="dialog" aria-labelledby="addtoBasketLabel" aria-hidden="true" data-basketno="[% basket.basketname | html %]">
720                 <div class="modal-dialog" role="document">
721                     <div class="modal-content">
722                         <div class="modal-header">
723                             <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
724                             <h4 class="modal-title" id="addtoBasketLabel">Add order to basket</h4>
725                         </div>
726                         <div class="modal-body">
727                             [% IF active %]
728                                 [% INCLUDE 'acquisitions-add-to-basket.inc' %]
729                             [% END %]
730                         </div>
731                         <div class="modal-footer">
732                             <a href="#" class="cancel" data-dismiss="modal" aria-hidden="true">Cancel</a>
733                         </div>
734                     </div><!-- /.modal-content -->
735                 </div><!-- /.modal-dialog -->
736             </div><!-- /.modal -->
737         [% END %]
738
739 [% END %]
740 [% END %]    [% ELSE %] <!-- if we want just to select a basketgroup for a closed basket -->
741     [% END %]
742 [% IF ( confirm_close ) %]
743         <div id="closebasket_needsconfirmation" class="dialog alert">
744
745         <form action="/cgi-bin/koha/acqui/basket.pl">
746             <h1>Are you sure you want to close basket [% basketname | html %]?</h1>
747             [% IF ( CAN_user_acquisition_group_manage ) %]
748             <p>
749             <label for="createbasketgroup">Attach this basket to a new basket group with the same name</label>
750             <input type="checkbox" id="createbasketgroup" name="createbasketgroup"/>
751             </p>
752             [% END %]
753             <input type="hidden" id="basketno" value="[% basketno | html %]" name="basketno" />
754             <input type="hidden" value="close" name="op" />
755             <input type="hidden" name="booksellerid" value="[% booksellerid | html %]" />
756             <input type="hidden" name="confirm" value="1" />
757             <input type="hidden" name="basketgroupname" value="[% basketgroupname | html %]" />
758             <button type="submit" class="approve" accesskey="y"><i class="fa fa-fw fa-check"></i> Yes, close (Y)</button>
759         </form>
760         <form action="/cgi-bin/koha/acqui/basket.pl" method="get">
761             <input type="hidden" name="basketno" value="[% basketno | html %]" />
762             <button type="submit" class="deny" accesskey="n"><i class="fa fa-fw fa-remove"></i> No, don't close (N)</button>
763         </form>
764         </div>
765     [% END %]
766 [% IF edi_confirm %]
767         <div id="closebasket_needsconfirmation" class="dialog alert">
768
769         <form action="/cgi-bin/koha/acqui/basket.pl">
770             <h1>Are you sure you want to generate an EDIFACT order and close basket [% basketname | html %]?</h1>
771             [% IF CAN_user_acquisition_group_manage %]
772             <p>
773             <label for="createbasketgroup">Attach this basket to a new basket group with the same name</label>
774             <input type="checkbox" id="createbasketgroup" name="createbasketgroup"/>
775             </p>
776             [% END %]
777             <input type="hidden" id="basketno" value="[% basketno | html %]" name="basketno" />
778             <input type="hidden" value="ediorder" name="op" />
779             <input type="hidden" name="ean" value="[% ean | html %]" />
780             <input type="hidden" name="booksellerid" value="[% booksellerid | html %]" />
781             <input type="hidden" name="confirm" value="1" />
782             <input type="hidden" name="basketgroupname" value="[% basketgroupname | html %]" />
783             <button type="submit" class="approve" accesskey="Y"><i class="fa fa-fw fa-check"></i> Yes, close (Y)</button>
784         </form>
785         <form action="/cgi-bin/koha/acqui/basket.pl" method="get">
786             <input type="hidden" name="basketno" value="[% basketno | html %]" />
787             <button type="submit" class="deny" accesskey="N"><i class="fa fa-fw fa-remove"></i> No, don't close (N)</button>
788         </form>
789         </div>
790     [% END %]
791 [% END %][%# IF (cannot_manage_basket) %]
792
793             </main>
794         </div> <!-- /.col-sm-10.col-sm-push-2 -->
795
796         <div class="col-sm-2 col-sm-pull-10">
797             <aside>
798                 [% INCLUDE 'vendor-menu.inc' %]
799                 [% INCLUDE 'acquisitions-menu.inc' %]
800             </aside>
801         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
802     </div> <!-- /.row -->
803
804
805 <!-- Modal for editing vendor and internal notes -->
806 <div class="modal" id="noteEditor" tabindex="-1" role="dialog" aria-labelledby="noteEditorLabel">
807     <div class="modal-dialog" role="document">
808         <form id="modify_order_notes" action="/cgi-bin/koha/acqui/modordernotes.pl" method="post">
809             <div class="modal-content">
810                 <div class="modal-header">
811                     <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
812                     <h4 class="modal-title" id="noteEditorLabel">Order note</h4>
813                 </div>
814                 <div class="modal-body">
815                 <textarea id="ordernotes" name="ordernotes" rows="3" cols="30" class="focus">[% ordernotes | html %]</textarea>
816                 <input type="hidden" id="ordernumber" name="ordernumber" value="" />
817                 <input type="hidden" name="op" value="save" />
818                 <input type="hidden" id="type" name="type" value="" />
819             </div>
820             <div class="modal-footer">
821                 <button type="submit" class="btn btn-default">Save</button>
822                 <button type="button" class="btn btn-link cancel" data-dismiss="modal">Cancel</button>
823             </div>
824             </div>
825         </form>
826     </div>
827 </div>
828
829 [% MACRO jsinclude BLOCK %]
830     [% Asset.js("js/acquisitions-menu.js") | $raw %]
831     [% INCLUDE 'datatables.inc' %]
832     [% INCLUDE 'columns_settings.inc' %]
833     [% Asset.js("lib/hc-sticky.js") | $raw %]
834     [% Asset.js("js/acq.js") | $raw %]
835     <script>
836         function updateColumnsVisibility(visible) {
837             if ( visible ) {
838                 $("table .tax_excluded, .tax_included").show();
839             } else {
840                 [% IF ( listincgst ) %]
841                     $("table .tax_excluded").hide();
842                 [% ELSE %]
843                     $("table .tax_included").hide();
844                 [% END %]
845             }
846         }
847
848         var Sticky;
849
850         $(document).ready(function() {
851             if ( $('#toolbar').length ) {
852                 Sticky = $("#toolbar");
853                 Sticky.hcSticky({
854                     stickTo: "main",
855                     stickyClass: "floating"
856                 });
857             }
858
859             [% UNLESS ( closedate ) %]
860                 $('#addtoBasket').on('show', function () {
861                    $(this).find(".modal-body").html($(".acqui_basket_add")[0].outerHTML);
862                 });
863             [% END %]
864
865             $("body").on("click", ".del_user", function(e){
866                 e.preventDefault();
867                 del_user( $(this).data("borrowernumber") );
868             });
869
870             $("#add_user").on("click",function(e){
871                 e.preventDefault();
872                 UserSearchPopup();
873             });
874
875             $(".transfer_order").on("click",function(e){
876                 e.preventDefault();
877                 transfer_order_popup( $(this).data("ordernumber"));
878             });
879
880             $(".edit_note").on("click", function(e) {
881                 e.preventDefault();
882                 var ordernumber = $(this).data("ordernumber");
883                 var note_type = $(this).data("note_type");
884                 var modalTitle = $(this).attr("title") + " (order number " + ordernumber + ")";
885                 var note_text = $( "#" + note_type + "-note-" + ordernumber ).html();
886                 $("#noteEditor .modal-title").text(modalTitle);
887                 $("#ordernumber").val( ordernumber );
888                 $("#ordernotes").html( note_text );
889                 $("#type").val( note_type );
890                 $("#noteEditor").modal("show");
891                 $("#ordernotes").focus();
892             });
893
894              $("#noteEditor").on('hidden.bs.modal', function (e) {
895                 $("#noteEditorLabel").html("");
896                 $("#noteEditor .modal-title").text("");
897                 $("#ordernotes").html( "" );
898                 $("#ordernumber").val("");
899                 $("#type").val("");
900             });
901
902             $("#set_managing_library").on("click", function(e){
903                 e.preventDefault();
904                 $(this).hide();
905                 $("#managing_library_entry").show();
906             });
907
908             $("#library_entry_cancel").on("click", function(e){
909                 e.preventDefault();
910                 $("#managing_library_entry").hide();
911                 $("#set_managing_library").show();
912             });
913
914             $("#set_basket_group").on("click", function(e){
915                 e.preventDefault();
916                 $(this).hide();
917                 $("#basket_grouping").show();
918             });
919
920             $("#basket_group_cancel").on("click", function(e){
921                 e.preventDefault();
922                 $("#basket_grouping").hide();
923                 $("#set_basket_group").show();
924             });
925
926             $(".modal").on("shown.bs.modal", function(){
927                 var basket = $(this).data("basketno");
928                 var legend = _("Add order to basket %s").format(basket);
929                 $(this).find("h4").text( legend );
930                 $(this).find("legend").html(legend);
931                 $(this).find("input:text").focus();
932             });
933         });
934     </script>
935
936     [% UNLESS ( closedate ) %]
937         <script>
938             function transfer_order_popup(ordernumber) {
939                 var url = "/cgi-bin/koha/acqui/transferorder.pl?"
940                     + "ordernumber=" + ordernumber
941                 window.open(url, 'TransferOrder','width=600,height=400,toolbar=false,scrollbars=yes');
942             }
943
944             function confirm_ediorder() {
945                 var is_confirmed = confirm(_("Are you sure you want to close this basket and generate an EDIFACT order?"));
946                 if (is_confirmed) {
947                     window.location = "/cgi-bin/koha/acqui/basket.pl?op=edi_confirm&basketno=[% basketno | html %]";
948                 }
949             }
950         </script>
951     [% ELSE %]
952         <script>
953             $(document).ready(function(){
954                 $("#basketgroupid").change(function(){
955                     if($(this).val() == "new"){
956                         location.href="/cgi-bin/koha/acqui/basketgroup.pl?op=add&booksellerid=[% booksellerid | html %]";
957                     } else {
958                         $(this).parent().submit();
959                     }
960                 });
961             });
962         </script>
963         [% UNLESS ( grouped ) %]
964             <script>
965                 function confirm_reopen() {
966                     var skip = [% IF ( skip_confirm_reopen ) %] 1 [% ELSE %] 0 [% END %];
967                     var is_confirmed = skip || confirm(_("Are you sure you want to reopen this basket?"));
968                     if (is_confirmed) {
969                         window.location = "/cgi-bin/koha/acqui/basket.pl?op=reopen&basketno=[% basketno | html %]";
970                     }
971                 }
972             </script>
973         [% END %]
974     [% END %]
975     <script>
976         var columns_settings = [% TablesSettings.GetColumns( 'acqui', 'basket', 'orders', 'json' ) | $raw %];
977         [% SET table_settings = TablesSettings.GetTableSettings( 'acqui', 'basket', 'orders' ) %];
978         $(document).ready(function() {
979             KohaTable("orders", {
980                 "sPaginationType": "full",
981                 "autoWidth": false,
982                 "exportColumns": [0,1,2,3,4,5,6,7,8,9,10,11,12,13],
983                 "iDisplayLength": [% table_settings.default_display_length | html %],
984                 "order": [[ [% table_settings.default_sort_order | html %], 'asc']],
985             }, columns_settings);
986
987             var cancelledorderst = $("#cancelledorderst").dataTable($.extend(true, {}, dataTablesDefaults, {
988                 "sPaginationType": "full"
989             } ) );
990             $("#reopenbutton").on("click",function(e){
991                 e.preventDefault();
992                 confirm_reopen();
993             });
994             // Generates a dynamic link for exporting the selections data as CSV
995             $("#exportbutton, #export-csv-menu a").click(function() {
996                 // Building the url from currently checked boxes
997                 var url = '/cgi-bin/koha/acqui/basket.pl';
998                 url += $('#exportbutton').attr('href');
999                 if($(this).attr("data-value")) {
1000                     url += '&amp;csv_profile=' + $(this).attr("data-value");
1001                 }
1002                 // And redirecting to the CSV page
1003                 location.href = url;
1004                 return false;
1005             });
1006             $("#select_managing_library").on("change", function(){
1007                 $(this).parent().submit();
1008             });
1009         });
1010
1011         function UserSearchPopup(f) {
1012             window.open(
1013                 "/cgi-bin/koha/acqui/add_user_search.pl",
1014                 'UserSearchPopup',
1015                 'width=840, height=500, scrollbars=yes, toolbar=no,'
1016              );
1017         }
1018
1019         function add_user(borrowernumber, borrowername) {
1020             var ids = $("#users_ids").val();
1021             if(ids.length > 0) {
1022                 ids = ids.split(':');
1023             } else {
1024                 ids = new Array;
1025             }
1026             if (ids.indexOf(borrowernumber.toString()) < 0) {
1027                 ids.push(borrowernumber);
1028                 $("#users_ids").val(ids.join(':'));
1029                 var li = '<li id="user_'+borrowernumber+'">'+borrowername
1030                 + ' <a href="#" data-borrowernumber="'+borrowernumber+'" class="del_user"><i class="fa fa-trash"></i> '
1031                     + _("Delete user") + '</a></li>';
1032                 $("#users_names").prepend(li);
1033                 $("#add_user_submit").show();
1034                 return 0;
1035             }
1036             return -1;
1037         }
1038
1039         function del_user(borrowernumber) {
1040             $("#user_"+borrowernumber).remove();
1041             var ids = $("#users_ids").val().split(':');
1042             ids.splice(ids.indexOf(borrowernumber.toString()), 1);
1043             $("#users_ids").val(ids.join(':'));
1044             $("#add_user_submit").show();
1045         }
1046     </script>
1047 [% END %]
1048
1049 [% INCLUDE 'intranet-bottom.inc' %]