Bug 12502: Add vendor note, internal note, ordernumber and isbn to late orders page
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / lateorders.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE KohaDates %]
4 [% USE Branches %]
5 [% USE ColumnsSettings %]
6 [% SET footerjs = 1 %]
7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>Koha &rsaquo; Acquisitions &rsaquo; Late orders</title>
9 [% INCLUDE 'doc-head-close.inc' %]
10 </head>
11
12 <body id="acq_lateorders" class="acq">
13 [% INCLUDE 'header.inc' %]
14 [% INCLUDE 'acquisitions-search.inc' %]
15
16 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo; <a href="lateorders.pl">Late orders</a></div>
17
18 <div class="main container-fluid">
19     <div class="row">
20         <div class="col-sm-10 col-sm-push-2">
21             <main>
22
23 <h1>[% IF ( Supplier ) %][% Supplier | html %] : [% END %]Late orders</h1>
24 <div id="acqui_lateorders">
25
26 [% IF error_claim %]
27     [% IF ( error_claim == "no_email" ) %]
28         <div class="dialog alert">This vendor has no email</div>
29     [% ELSIF ( error_claim == "no_order_selected" ) %]
30         <div class="dialog alert">No order selected</div>
31     [% ELSE %]
32         <div class="dialog alert">[% error_claim | html %]</div>
33     [% END %]
34 [% END %]
35 [% IF info_claim %]
36     <div class="dialog message">Email has been sent.</div>
37 [% END %]
38 [% IF ( lateorders ) %]
39 <form action="lateorders.pl" name="claim" method="post">
40   <input type="hidden" name="op" value="send_alert" />
41   <input type="hidden" name="delay" value="[% delay | html %]" />
42   <input type="hidden" name="booksellerid" value="[% booksellerid | html %]" />
43         [% IF ( letters ) %]
44         <p><label for="letter_code">Claim using notice: </label><select name="letter_code" id="letter_code">
45           [% FOREACH letter IN letters %]
46                 <option value="[% letter.code | html %]">[% letter.name | html %]</option>
47           [% END %]
48           </select>
49         </p>
50         [% END %]
51     <table id="late_orders">
52       <thead>
53         <tr>
54             [% IF Supplier %]
55                 <th><a id="CheckAll" href="#">Check all</a><br /><a id="CheckNone" href="#">Uncheck all</a></th>
56             [% ELSE %]
57                 <th></th>
58             [% END %]
59             <th>Order line</th>
60             <th class="title-string">Order date</th>
61             <th class="title-string">Estimated delivery date</th>
62             <th>Vendor</th>
63             <th class="anti-the">Information</th>
64             <th>Total cost</th>
65             <th>Basket</th>
66             <th>Basket group</th>
67             <th>Library</th>
68             <th>Fund</th>
69             <th>Claims count</th>
70             <th class="title-string">Claimed date</th>
71             <th>Internal note</th>
72             <th>Vendor note</th>
73             <th>ISBN</th>
74         </tr>
75       </thead>
76       <tbody>
77       [% FOREACH lateorder IN lateorders %]
78         <tr>
79             <td>
80                 <input type="checkbox" value="[% lateorder.ordernumber | html %]" data-booksellerid="[% lateorder.supplierid | html %]" name="ordernumber">
81             </td>
82             <td>
83                 [% lateorder.ordernumber | $raw %]
84             </td>
85             <td>
86                 <span title="[% lateorder.orderdate | html %]">[% lateorder.orderdate | $KohaDates %] ([% lateorder.latesince | html %] days)</span>
87             </td>
88             <td>
89                 [% IF ( lateorder.estimateddeliverydate ) %]
90                     <span title="[% lateorder.estimateddeliverydate | html %]">[% lateorder.estimateddeliverydate | $KohaDates  %]</span>
91                 [% ELSE %]
92                     <span title="0000-00-00"></span>
93                 [% END %]
94             </td>
95             <td>
96                 [% lateorder.supplier | html %]
97                 ([% lateorder.supplierid | html %])
98             </td>
99             <td>
100                 <b>[% lateorder.title | html %]</b>
101                    [% IF ( lateorder.author ) %]<br/><i>Author:</i> [% lateorder.author | html %][% END %]
102                    [% IF ( lateorder.publisher ) %]
103                         <br/><i>Published by:</i> [% lateorder.publisher | html %]
104                         [% IF ( lateorder.publicationyear ) %]
105                             <i> in </i>[% lateorder.publicationyear | html %]
106                         [% END %]
107                    [% END %]
108             </td>
109             <td>
110                    [% lateorder.unitpricesupplier | html %]x[% lateorder.quantity | html %] = 
111                    [% lateorder.subtotal | html %]
112             </td>
113             <td>
114                 [% IF ( CAN_user_acquisition_order_manage ) %]
115                     <a href="basket.pl?basketno=[% lateorder.basketno | uri %]" title="basket">[% lateorder.basketname | html %] ([% lateorder.basketno | html %])</a>
116                 [% ELSE %]
117                     [% lateorder.basketname | html %] ([% lateorder.basketno | html %])
118                 [% END %]
119             </td>
120             <td>
121                 [% IF ( lateorder.basketgroupid ) %]
122                     [% IF ( CAN_user_acquisition_group_manage ) %]
123                         <a href="basketgroup.pl?op=add&booksellerid=[% lateorder.supplierid | uri %]&basketgroupid=[% lateorder.basketgroupid | uri %]" title="basketgroup">[% lateorder.basketgroupname | html %] ([% lateorder.basketgroupid | html %])</a>
124                     [% ELSE %]
125                         [% lateorder.basketgroupname | html %] ([% lateorder.basketgroupid | html %])</a>
126                     [% END %]
127                 [% END %]
128             </td>
129             <td>[% Branches.GetName( lateorder.branch ) | html %]
130             </td>
131             <td>[% lateorder.budget | html %]
132             </td>
133             <td>[% lateorder.claims_count | html %]</td>
134             <td>
135                 [% IF ( lateorder.claimed_date ) %]
136                     <span title="[% lateorder.claimed_date | html %]">[% lateorder.claimed_date | $KohaDates %]</span>
137                 [% ELSE %]
138                     <span title="0000-00-00"></span>
139                 [% END %]
140             </td>
141             <td><input name="internalnote" id="internalnote" type="text" value="[% lateorder.internalnote | html %]"></td>
142             <td><input name="vendornote" id="vendornote" type="text" value="[% lateorder.vendornote | html %]"></td>
143             <td>[% lateorder.isbn | $raw %]</td>
144         </tr>
145       [% END %]
146       </tbody>
147       <tfoot>
148         <tr>
149             <th colspan="6">Total</th>
150             <th>[% total | html %]</th>
151             <th colspan="9">&nbsp;</th>
152         </tr>
153       </tfoot>
154     </table>
155     <div class="spacer"></div>
156
157     <p style="display:block;">
158         <input type="button" value="Export as CSV" id="ExportSelected" />
159         [% UNLESS lateorder.budget_lock %]
160             <input type="submit"  value="Claim order" />
161         [% END %]
162         <input type="button" value="Save notes" id="savenotes"/>
163     </p>
164 </form>
165 [% ELSE %]<p>There are no late orders.</p>
166 [% END %]
167 </div> <!-- /#acqui_lateorders -->
168 </main>
169 </div> <!-- /.col-sm-10.col-sm-push-2 -->
170
171 <div class="col-sm-2 col-sm-pull-10">
172     <aside>
173 <form action="lateorders.pl" method="get">
174 <fieldset class="brief">
175 <h4>Filter results:</h4>
176 [% FOREACH ERROR_LOO IN ERROR_LOOP %]
177 [% IF ( ERROR_LOO.delay_digits ) %]<p class="error">The number of days ([% ERROR_LOO.bad_delay | html %]) must be a number between 0 and 999.</p>[% END %]
178 [% END %]
179 <ol>
180     <li><label for="delay">Order date:</label><input size="3" maxlength="3" id="delay" type="text" name="delay" value="[% delay | html %]" /> days ago</li>
181     <li><label for="from">Estimated delivery date from: </label>
182         <input type="text" size="10" id="from" name="estimateddeliverydatefrom" value="[% estimateddeliverydatefrom | html %]" class="datepickerfrom" />
183         <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
184     </li>
185     <li><label for="to">To: </label>
186         <input type="text" size="10" id="to" name="estimateddeliverydateto" value="[% estimateddeliverydateto | html %]" class="datepickerto" />
187         <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
188     </li>
189
190         <li><label for="booksellerid">Vendor:</label>
191                 <select id="booksellerid" size="1" tabindex="" name="booksellerid">
192             <option value=""></option>
193                         [% FOREACH SUPPLIER_LOO IN SUPPLIER_LOOP %]
194                 [% IF ( SUPPLIER_LOO.selected ) %]<option value="[% SUPPLIER_LOO.id | html %]" selected="selected">[% SUPPLIER_LOO.name | html %]</option>
195                 [% ELSE %]<option value="[% SUPPLIER_LOO.id | html %]">[% SUPPLIER_LOO.name | html %]</option>[% END %]
196                 [% END %]
197                 </select>
198 </ol>
199     <fieldset class="action"><input type="submit" value="Filter" /></fieldset>
200 </fieldset>
201     </form>
202 [% INCLUDE 'acquisitions-menu.inc' %]
203 </aside>
204 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
205 </div>
206
207 [% MACRO jsinclude BLOCK %]
208     [% Asset.js("js/acquisitions-menu.js") | $raw %]
209     [% INCLUDE 'datatables.inc' %]
210     [% INCLUDE 'columns_settings.inc' %]
211     [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
212     [% INCLUDE 'calendar.inc' %]
213     <script>
214         var late_orderst;
215         function check_uncheck() {
216             var all_nodes = $(late_orderst.fnGetNodes());
217             if ( $(all_nodes).find("input:checkbox[name=ordernumber]:checked").length > 0) {
218                 var booksellerid = $(all_nodes).find("input:checkbox[name=ordernumber]:checked:first").attr("data-booksellerid");
219                 $(all_nodes).find("input:checkbox[name=ordernumber][data-booksellerid!="+booksellerid+"]").prop('disabled', true);
220             } else {
221                 $("input:checkbox[name=ordernumber]").prop('disabled', false);
222             }
223         }
224
225         $(document).ready(function() {
226
227             var columns_settings = [% ColumnsSettings.GetColumns( 'acqui', 'lateorders', 'late_orders', 'json' ) | $raw %];
228             late_orderst = KohaTable("late_orders", {
229                 "aoColumnDefs": [
230                     { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
231                     { "sType": "anti-the", "aTargets" : [ "anti-the" ] },
232                     { "sType": "title-string", "aTargets" : [ "title-string" ] }
233                 ],
234                 "sPaginationType": "full",
235                 "bAutoWidth": false,
236                 "fnDrawCallback": function() {
237                     if ( typeof late_orderst != 'undefined' ) {
238                         check_uncheck();
239                         $('input:checkbox[name=ordernumber]').bind('click', check_uncheck);
240                     };
241                 }
242             }, columns_settings );
243             $('input:checkbox[name=ordernumber]').bind('click', check_uncheck);
244             $('#CheckAll').click(function(){ $(late_orderst.fnGetNodes()).find("td").checkCheckboxes();});
245             $('#CheckNone').click(function(){ $(late_orderst.fnGetNodes()).find("td").unCheckCheckboxes();});
246
247             // Generates a dynamic link for exporting the selection's data as CSV
248             $("#ExportSelected").click(function() {
249                 var all_nodes = $(late_orderst.fnGetNodes());
250                 var selected = $(all_nodes).find("input[name='ordernumber']:checked");
251
252                 if (selected.length == 0) {
253                     alert(_("Please select at least one item to export."));
254                     return false;
255                 }
256
257                 // Building the url from currently checked boxes
258                 var url = '/cgi-bin/koha/acqui/lateorders-export.pl?op=export';
259                 for (var i = 0; i < selected.length; i++) {
260                     url += '&amp;ordernumber=' + selected[i].value;
261                 }
262                 // And redirecting to the CSV page
263                 location.href = url;
264                 return false;
265             });
266             // Update all notes
267             $("#savenotes").click(function(){
268                 $("#savenotes").after("<span id=\"loading\" style=\"margin:4px;\"><img src=\"[% interface | html %]/[% theme | html %]/img/loading-small.gif\" alt=\"\" /> "+_("Loading")+"</span>");
269                 var all_nodes = $(late_orderst.fnGetNodes());
270                 var req = new XMLHttpRequest();
271                 var url = '/cgi-bin/koha/acqui/lateorders.pl';
272                 var data = new FormData();
273                 data.append("op","save");
274                 for (var i = 0; i < all_nodes.length; i++) {
275                     var order = $(all_nodes[i]).find("input[name='ordernumber']");
276                     var internalnote = $(all_nodes[i]).find("input[name='internalnote']")[0].value;
277                     var vendornote = $(all_nodes[i]).find("input[name='vendornote']")[0].value;
278                     var internalnote_key = order[0].value + "_i";
279                     var vendornote_key = order[0].value + "_v";
280                     data.append(internalnote_key, internalnote);
281                     data.append(vendornote_key, vendornote);
282                 }
283
284                 req.open("POST",url);
285                 req.send(data);
286                 req.onreadystatechange = function () {
287                     $("#loading").remove();
288                     if (req.readyState == '4' ){
289                         if ( req.status == 200 ){
290                             alert(_("Notes successfully saved"));
291                         }
292                         else {
293                             alert(_("Error while saving the notes. Please try again"));
294                         }
295                     }
296                 }
297             });
298         });
299     </script>
300 [% END %]
301
302 [% INCLUDE 'intranet-bottom.inc' %]