Bug 24388: Remove uneeded test in lateorders.tt
[srvgit] / 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>
142                 [% IF ( lateorder.internalnote ) %]
143                     <p class="ordernote">
144                         <span id="internal-note-[% lateorder.ordernumber | html %]">[% lateorder.internalnote | html %]</span>
145                         <a class="edit_note noExport" data-ordernumber="[% lateorder.ordernumber | html %]" data-note_type="internal" href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% lateorder.ordernumber | html %]&type=internal" title="Edit internal note">
146                             <i class="fa fa-pencil"></i> Edit internal note
147                         </a>
148                     </p>
149                 [% ELSE %]
150                     <a class="edit_note noExport" data-ordernumber="[% lateorder.ordernumber | html %]" data-note_type="internal" href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% lateorder.ordernumber | html %]&type=internal" title="Add internal note">
151                         <i class="fa fa-plus"></i> Add internal note
152                     </a>
153                 [% END %]
154             </td>
155             <td>
156                 [% IF ( lateorder.vendornote ) %]
157                     <p class="ordernote">
158                         <span id="vendor-note-[% lateorder.ordernumber | html %]">[% lateorder.vendornote | html %]</span>
159                         <a class="edit_note noExport" data-ordernumber="[% lateorder.ordernumber | html %]" data-note_type="vendor" href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% lateorder.ordernumber | html %]&type=vendor" title="Edit vendor note">
160                             <i class="fa fa-pencil"></i> Edit vendor note
161                         </a>
162                     </p>
163                 [% ELSE %]
164                     <a class="edit_note noExport" data-ordernumber="[% lateorder.ordernumber | html %]" data-note_type="vendor" href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% lateorder.ordernumber | html %]&type=vendor" title="Add vendor note">
165                         <i class="fa fa-plus"></i> Add vendor note
166                     </a>
167                 [% END %]
168             </td>
169             <td>[% lateorder.isbn | $raw %]</td>
170         </tr>
171       [% END %]
172       </tbody>
173       <tfoot>
174         <tr>
175             <th colspan="6">Total</th>
176             <th>[% total | html %]</th>
177             <th colspan="9">&nbsp;</th>
178         </tr>
179       </tfoot>
180     </table>
181     <div class="spacer"></div>
182
183     <p style="display:block;">
184         <input type="button" value="Export as CSV" id="ExportSelected" />
185         <input type="submit"  value="Claim order" />
186     </p>
187 </form>
188 [% ELSE %]<p>There are no late orders.</p>
189 [% END %]
190 </div> <!-- /#acqui_lateorders -->
191 </main>
192 </div> <!-- /.col-sm-10.col-sm-push-2 -->
193
194 <div class="col-sm-2 col-sm-pull-10">
195     <aside>
196 <form action="lateorders.pl" method="get">
197 <fieldset class="brief">
198 <h4>Filter results:</h4>
199 [% FOREACH ERROR_LOO IN ERROR_LOOP %]
200 [% 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 %]
201 [% END %]
202 <ol>
203     <li><label for="delay">Order date:</label><input size="3" maxlength="3" id="delay" type="text" name="delay" value="[% delay | html %]" /> days ago</li>
204     <li><label for="from">Estimated delivery date from: </label>
205         <input type="text" size="10" id="from" name="estimateddeliverydatefrom" value="[% estimateddeliverydatefrom | html %]" class="datepickerfrom" />
206         <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
207     </li>
208     <li><label for="to">To: </label>
209         <input type="text" size="10" id="to" name="estimateddeliverydateto" value="[% estimateddeliverydateto | html %]" class="datepickerto" />
210         <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
211     </li>
212
213         <li><label for="booksellerid">Vendor:</label>
214                 <select id="booksellerid" size="1" tabindex="" name="booksellerid">
215             <option value=""></option>
216                         [% FOREACH SUPPLIER_LOO IN SUPPLIER_LOOP %]
217                 [% IF ( SUPPLIER_LOO.selected ) %]<option value="[% SUPPLIER_LOO.id | html %]" selected="selected">[% SUPPLIER_LOO.name | html %]</option>
218                 [% ELSE %]<option value="[% SUPPLIER_LOO.id | html %]">[% SUPPLIER_LOO.name | html %]</option>[% END %]
219                 [% END %]
220                 </select>
221 </ol>
222     <fieldset class="action"><input type="submit" value="Filter" /></fieldset>
223 </fieldset>
224     </form>
225 [% INCLUDE 'acquisitions-menu.inc' %]
226 </aside>
227 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
228 </div>
229
230 <!-- Modal for editing vendor and internal notes -->
231 <div class="modal" id="noteEditor" tabindex="-1" role="dialog" aria-labelledby="noteEditorLabel">
232     <div class="modal-dialog" role="document">
233         <form id="modify_order_notes" action="/cgi-bin/koha/acqui/modordernotes.pl" method="post">
234             <div class="modal-content">
235                 <div class="modal-header">
236                     <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
237                     <h4 class="modal-title" id="noteEditorLabel">Order note</h4>
238                 </div>
239                 <div class="modal-body">
240                 <textarea id="ordernotes" name="ordernotes" rows="3" cols="30" class="focus">[% ordernotes | html %]</textarea>
241                 <input type="hidden" id="ordernumber" name="ordernumber" value="" />
242                 <input type="hidden" name="op" value="save" />
243                 <input type="hidden" id="type" name="type" value="" />
244             </div>
245             <div class="modal-footer">
246                 <button type="submit" class="btn btn-default">Save</button>
247                 <button type="button" class="btn btn-link cancel" data-dismiss="modal">Cancel</button>
248             </div>
249             </div>
250         </form>
251     </div>
252 </div>
253
254 [% MACRO jsinclude BLOCK %]
255     [% Asset.js("js/acquisitions-menu.js") | $raw %]
256     [% INCLUDE 'datatables.inc' %]
257     [% INCLUDE 'columns_settings.inc' %]
258     [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
259     [% INCLUDE 'calendar.inc' %]
260     <script>
261         var late_orderst;
262         function check_uncheck() {
263             var all_nodes = $(late_orderst.fnGetNodes());
264             if ( $(all_nodes).find("input:checkbox[name=ordernumber]:checked").length > 0) {
265                 var booksellerid = $(all_nodes).find("input:checkbox[name=ordernumber]:checked:first").attr("data-booksellerid");
266                 $(all_nodes).find("input:checkbox[name=ordernumber][data-booksellerid!="+booksellerid+"]").prop('disabled', true);
267             } else {
268                 $("input:checkbox[name=ordernumber]").prop('disabled', false);
269             }
270         }
271
272         $(document).ready(function() {
273
274             var columns_settings = [% ColumnsSettings.GetColumns( 'acqui', 'lateorders', 'late_orders', 'json' ) | $raw %];
275             late_orderst = KohaTable("late_orders", {
276                 "aoColumnDefs": [
277                     { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
278                     { "sType": "anti-the", "aTargets" : [ "anti-the" ] },
279                     { "sType": "title-string", "aTargets" : [ "title-string" ] }
280                 ],
281                 "sPaginationType": "full",
282                 "bAutoWidth": false,
283                 "fnDrawCallback": function() {
284                     if ( typeof late_orderst != 'undefined' ) {
285                         check_uncheck();
286                         $('input:checkbox[name=ordernumber]').bind('click', check_uncheck);
287                     };
288                 }
289             }, columns_settings );
290             $('input:checkbox[name=ordernumber]').bind('click', check_uncheck);
291             $('#CheckAll').click(function(){ $(late_orderst.fnGetNodes()).find("td").checkCheckboxes();});
292             $('#CheckNone').click(function(){ $(late_orderst.fnGetNodes()).find("td").unCheckCheckboxes();});
293
294             // Generates a dynamic link for exporting the selection's data as CSV
295             $("#ExportSelected").click(function() {
296                 var all_nodes = $(late_orderst.fnGetNodes());
297                 var selected = $(all_nodes).find("input[name='ordernumber']:checked");
298
299                 if (selected.length == 0) {
300                     alert(_("Please select at least one item to export."));
301                     return false;
302                 }
303
304                 // Building the url from currently checked boxes
305                 var url = '/cgi-bin/koha/acqui/lateorders-export.pl?op=export';
306                 for (var i = 0; i < selected.length; i++) {
307                     url += '&amp;ordernumber=' + selected[i].value;
308                 }
309                 // And redirecting to the CSV page
310                 location.href = url;
311                 return false;
312             });
313
314             $(".edit_note").on("click", function(e) {
315                 e.preventDefault();
316                 var ordernumber = $(this).data("ordernumber");
317                 var note_type = $(this).data("note_type");
318                 var modalTitle = $(this).attr("title") + " (order number " + ordernumber + ")";
319                 var note_text = $( "#" + note_type + "-note-" + ordernumber ).html();
320                 $("#noteEditor .modal-title").text(modalTitle);
321                 $("#ordernumber").val( ordernumber );
322                 $("#ordernotes").html( note_text );
323                 $("#type").val( note_type );
324                 $("#noteEditor").modal("show");
325                 $("#ordernotes").focus();
326             });
327
328              $("#noteEditor").on('hidden.bs.modal', function (e) {
329                 $("#noteEditorLabel").html("");
330                 $("#noteEditor .modal-title").text("");
331                 $("#ordernotes").html( "" );
332                 $("#ordernumber").val("");
333                 $("#type").val("");
334             });
335         });
336     </script>
337 [% END %]
338
339 [% INCLUDE 'intranet-bottom.inc' %]