Bug 21364: Allow closing basket from vendor view/search
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / booksellers.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE KohaDates %]
4 [% SET footerjs = 1 %]
5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>Koha &rsaquo; Search for vendor [% supplier | html %]</title>
7 [% INCLUDE 'doc-head-close.inc' %]
8 <style>
9 #vendors td{
10         vertical-align: top;
11 }
12 </style>
13 </head>
14
15 <body id="acq_booksellers" class="acq">
16 [% INCLUDE 'header.inc' %]
17 [% INCLUDE 'acquisitions-search.inc' %]
18
19 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo; Search for vendor <em>[% supplier | html %]</em> </div>
20
21 <div class="main container-fluid">
22     <div class="row">
23         <div class="col-sm-10 col-sm-push-2">
24             <main>
25
26 [% INCLUDE 'acquisitions-toolbar.inc' %]
27 [% UNLESS ( count == 1 ) %]
28     [% UNLESS count %]
29         <h1>Your search returned no results.</h1>
30     [% ELSIF ( supplier.length < 1 ) %]
31         <h1>Vendor search: [% count | html %] results found</h1>
32     [% ELSE %]
33         <h1>Vendor search: [% count | html %] results found for '[% supplier | html %]'</h1>
34     [% END %]
35 [% END %]
36 [% IF ( loop_suppliers.size ) %]
37     [% UNLESS (count == 1) %]
38         <p>Choose a vendor in the list to jump directly to the right place.
39         <select id="supplierlist">
40             [% FOREACH supplier1 IN loop_suppliers %]
41                 <option value="[% supplier1.booksellerid | html %]">[% supplier1.name | html %]</option>
42             [% END %]
43         </select>
44         </p>
45     [% END %]
46     [% IF ( allbaskets ) %]
47         <a href="/cgi-bin/koha/acqui/booksellers.pl?supplier=[% supplier | uri %]&amp;booksellerid=[% booksellerid | uri %]">Show active baskets only</a>
48     [% ELSE %]
49         <a href="/cgi-bin/koha/acqui/booksellers.pl?supplier=[% supplier | uri %]&amp;booksellerid=[% booksellerid | uri %]&amp;allbaskets=1">Show all baskets</a>
50     [% END %]
51     [% UNLESS booksellerid %]
52         | <a href="#" id="show_active_vendors">Show active vendors only</a><a href="#" id="show_all_vendors">Show all vendors</a>
53     [% END %]
54     <div id="acqui_order_supplierlist">
55         [% FOREACH supplier IN loop_suppliers %]
56             [% IF ( supplier.active ) %]
57                 <div class="supplier">
58             [% ELSE %]
59                 <div class="supplier inactive">
60             [% END %]
61                 <span class="suppliername">
62                     [% IF (supplier.name) %]
63                         <a name="[% supplier.booksellerid | html %]" href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% supplier.booksellerid | html %]">[% supplier.name | html %]</a>
64                     [% ELSE %]
65                         <a name="[% supplier.booksellerid | html %]" href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% supplier.booksellerid | html %]">NO NAME</a>
66                     [% END %]
67                 </span>
68                 <span class="action">
69                     [% IF ( CAN_user_acquisition_order_manage ) %]
70                         [% IF ( supplier.active ) %]
71                             <a class="btn btn-default btn-sm" href="/cgi-bin/koha/acqui/basketheader.pl?booksellerid=[% supplier.booksellerid | html %]&amp;op=add_form"><i class="fa fa-plus"></i> New basket</a>
72                         [% ELSE %]
73                             (inactive)
74                         [% END %]
75                     [% END %]
76                         [% IF ( supplier.loop_basket.size ) %]
77                     <a class="btn btn-default btn-sm" href="/cgi-bin/koha/acqui/parcels.pl?booksellerid=[% supplier.booksellerid | html %]"><i class="fa fa-inbox"></i> Receive shipment</a>
78                         [% END %]
79                 </span>
80                 <div class="baskets">
81                     [% IF ( supplier.loop_basket.size ) %]
82                         <table class="baskets">
83                             <thead>
84                                 <tr>
85                                     <th>No.</th>
86                                     <th>Name</th>
87                                     <th class="title-numeric">Item count</th>
88                                     <th class="title-numeric">Bibliographic record count</th>
89                                     <th>Items expected</th>
90                                     <th>Created by</th>
91                                     <th class="title-string">Date</th>
92                                     <th>Basket group</th>
93                                     <th class="title-string">Closed</th>
94                                     <th>Actions</th>
95                                 </tr>
96                             </thead>
97                             <tbody>
98                                 [% FOREACH basket IN supplier.loop_basket %]
99                                     [% IF ( basket.uncertainprices ) %]
100                                         <tr class="problem">
101                                     [% ELSE %]
102                                         <tr>
103                                     [% END %]
104                                         <td>[% basket.basketno | html %]</td>
105                                         <td><a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basket.basketno | html %]">[% basket.basketname | html %]<a></td>
106                                         <td>
107                                             <span title="[% basket.total_items | html %]">[% basket.total_items | html %]
108                                                 [% IF basket.total_items_cancelled %]
109                                                     ([% basket.total_items_cancelled | html %] cancelled)
110                                                 [% END %]
111                                             </span>
112                                         </td>
113                                         <td>
114                                             <span title="[% basket.total_biblios | html %]">[% basket.total_biblios | html %]
115                                                 [% IF basket.total_biblios_cancelled %]
116                                                     ([% basket.total_biblios_cancelled | html %] cancelled)
117                                                 [% END %]
118                                             </span>
119                                         </td>
120                                         <td>[% basket.expected_items | html %]</td>
121                                         <td>
122                                             [% IF basket.authorisedby %]
123                                                 [% basket.authorisedby.firstname | html %]
124                                                 [% basket.authorisedby.surname | html %]
125                                             [% END %]
126                                         </td>
127                                         <td><span title="[% basket.creationdate | html %]">[% basket.creationdate | $KohaDates %]</span></td>
128                                         <td>
129                                           [% IF basket.basketgroup %]
130                                             [% basketgroup = basket.basketgroup %]
131                                             [% IF basketgroup.closed %]
132                                               [% basketgroup.name | html %] (closed)
133                                             [% ELSE %]
134                                               <a href="/cgi-bin/koha/acqui/basketgroup.pl?op=add&amp;booksellerid=[% basket.booksellerid | uri %]&amp;basketgroupid=[% basketgroup.id | uri %]">[% basketgroup.name | html %]</a>
135                                             [% END %]
136                                           [% END %]
137                                         </td>
138                                         <td>
139                                             [% IF ( basket.closedate ) %]
140                                                 <span title="[% basket.closedate | html %]">[% basket.closedate | $KohaDates %]</span>
141                                             [% ELSE %]
142                                                 <span title="9999-99-99"></span>
143                                             [% END %]
144                                         </td>
145                                         <td class="actions">
146                                         [% IF not basket.closedate and supplier.active %]
147                                             <div class="dropup">
148                                                 <div class="btn-group">
149                                                 [%# There should be no space between these two buttons, it would render badly %]
150                                                     <a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basket.basketno | html %]"><i class="fa fa-eye"></i> View</a><a class="btn btn-default btn-xs dropdown-toggle" id="basketactions[% basket.basknetno | html %]" role="button" data-toggle="dropdown" href="#"><b class="caret"></b></a>
151                                                     <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="basketactions[% basketn.basketno | html %]">
152                                                         <li><a id="addtoBasketLabel[% basket.basketno | html %]" href="#addtoBasket[% basket.basketno | html %]" role="button" data-toggle="modal"><i class="fa fa-plus"></i> Add to basket</a></li>
153                                                         [% IF basket.total_items %]
154                                                         <li><a href="/cgi-bin/koha/acqui/basket.pl?op=close&basketno=[% basket.basketno | html %]&booksellerid=[% supplier.id | html %]"><i class="fa fa-times-circle"></i> Close this basket</a></li>
155                                                         [% END %]
156                                                     </ul>
157                                                     <!-- Modal -->
158                                                     <div id="addtoBasket[% basket.basketno | html %]" class="modal" tabindex="-1" role="dialog" aria-labelledby="addtoBasketLabel[% basket.basketno | html %]" aria-hidden="true" data-basketno="[% basket.basketname | html %]">
159                                                         <div class="modal-dialog">
160                                                             <div class="modal-content">
161                                                                 <div class="modal-body">
162                                                                     [% INCLUDE 'acquisitions-add-to-basket.inc' booksellerid=supplier.booksellerid basketno=basket.basketno %]
163                                                                 </div>
164                                                                 <div class="modal-footer">
165                                                                     <a href="#" class="cancel" data-dismiss="modal" aria-hidden="true">Cancel</a>
166                                                                 </div>
167                                                             </div>
168                                                         </div>
169                                                     </div>
170                                         [% ELSE %]
171                                             <a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basket.basketno | html %]"><i class="fa fa-eye"></i> View</a>
172                                         [% END %]
173                                         </td>
174                                     </tr>
175                                 [% END %][%# FOREACH basket IN supplier.loop_basket %]
176                             </tbody>
177                         </table>
178
179                     [% ELSE %]
180                         <p>No pending baskets</p>
181                     [% END %][%# IF ( supplier.loop_basket.size ) %]
182                 </div>
183             </div>
184         [% END %][%# FOREACH supplier IN loop_suppliers %]
185     </div>
186 [% END %][%# IF ( loop_suppliers.size ) %]
187 </main>
188 </div> <!-- /.col-sm-10.col-sm-push-2 -->
189     <div class="col-sm-2 col-sm-pull-10">
190         <aside>
191             [% IF ( booksellerid ) %]
192                 [% INCLUDE 'vendor-menu.inc' %]
193             [% END %]
194             [% INCLUDE 'acquisitions-menu.inc' %]
195         </aside>
196     </div>
197 </div> <!-- /.row -->
198
199 [% MACRO jsinclude BLOCK %]
200     [% Asset.js("js/acquisitions-menu.js") | $raw %]
201     [% INCLUDE 'datatables.inc' %]
202     <script>
203         $(document).ready(function() {
204             $("table.baskets").dataTable($.extend(true, {}, dataTablesDefaults, {
205                 'sDom': 't',
206                 'bPaginate': false,
207                 'bFilter': false,
208                 'bInfo': false,
209                 "aaSorting": [[ 1, "asc" ]],
210                 "aoColumnDefs": [
211                     { "sType": "title-string", "aTargets" : [ "title-string" ] },
212                     { "sType": "title-numeric", "aTargets" : [ "title-numeric" ] },
213                     { 'aTargets': [-1], 'bSortable': false }
214                 ]
215             }));
216             $("#supplierlist").change(function() {
217                 var id = $(this).find("option:selected").val();
218                 window.location.href = "#" + id;
219             });
220             $(".modal").on("show", function(){
221                 var basket = $(this).data("basketno");
222                 var legend = _("Add order to basket %s").format(basket);
223                 $(this).find("legend").html(legend);
224             });
225             $("#show_all_vendors").hide();
226             $("#show_active_vendors").on('click', function(e){
227                 e.preventDefault();
228                 $(".inactive").hide();
229                 $("#show_active_vendors").hide();
230                 $("#show_all_vendors").show();
231             });
232             $("#show_all_vendors").on('click', function(e){
233                 e.preventDefault();
234                 $(".inactive").show();
235                 $("#show_all_vendors").hide();
236                 $("#show_active_vendors").show();
237             });
238         });
239     </script>
240 [% END %]
241
242 [% INCLUDE 'intranet-bottom.inc' %]