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