(MT #1855) Make an Ajax+JSON search receiving orders
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / parcel.tmpl
1 <!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
2 <title>Koha &rsaquo; Acquisitions &rsaquo; <!-- TMPL_IF name="date" -->
3             Receipt Summary for <!-- TMPL_VAR NAME="name" --> <!--TMPL_IF Name="invoice"-->Invoice <!-- TMPL_VAR NAME="invoice" --><!--/TMPL_IF --> on <!-- TMPL_VAR NAME="formatteddatereceived" --><!-- TMPL_ELSE -->Receive Orders from <!-- TMPL_VAR NAME="name" --><!-- /TMPL_IF --></title>
4 <!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
5 <!-- TMPL_INCLUDE NAME="greybox.inc" -->
6 <script type="text/javascript" src="<!-- TMPL_VAR NAME="yuipath" -->/json/json-min.js"></script> 
7 <script type="text/JavaScript" language="JavaScript">
8 //<![CDATA[
9
10     var rowsToCollapse = 5;
11
12     $(document).ready(function(){
13
14         rowCountPending  = $("table#pendingt tbody.filterclass tr").length;
15         rowCountReceived = $("table#receivedt tbody.filterclass tr").length;
16         if (rowCountPending  > rowsToCollapse) { pendingCollapse(); }
17         if (rowCountReceived > rowsToCollapse) { receivedCollapse(); }
18     });
19
20      // Case-insensitive version of jquery's contains function
21      jQuery.extend(jQuery.expr[':'], { 
22             icontains : "jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0" 
23      });
24
25      // Contains exactly function
26      jQuery.extend(jQuery.expr[':'], {
27           containsExactly: "$(a).text() == m[3]"
28      });
29
30
31     // Collapse pending items table
32     function pendingCollapse() {
33         $("#pendingcollapserow").remove();
34         $("table#pendingt tbody.filterclass tr:gt(" + rowsToCollapse + ")").hide();
35         $("#basketfilter").focus();
36         $("<tr><td id=\"pendingcollapserow\" colspan=\"7\">Only the first " + rowsToCollapse + " items are displayed. <a href=\"javascript:pendingExpand();\">Click here to show all " + rowCountPending + " items<\/a>.<\/td><\/tr>").appendTo("table#pendingt");
37
38     }
39
40     // Expend pending items table
41     function pendingExpand() {
42         $("#pendingcollapserow").remove();
43         $("table#pendingt tr").show();
44         $("<tr><td id=\"pendingcollapserow\" colspan=\"7\">All " + rowCountPending + " items are displayed. <a href=\"javascript:pendingCollapse();\">Click here to show only the first " + rowsToCollapse + " items<\/a>.<\/td><\/tr>").appendTo("table#pendingt");
45     }
46
47     // Collapse already received items table
48     function receivedCollapse() {
49         $("#receivedcollapserow").remove();
50         $("table#receivedt tbody.filterclass tr:gt(" + rowsToCollapse + ")").hide();
51         $("<tr><td id=\"receivedcollapserow\" colspan=\"7\">Only the first " + rowsToCollapse + " items are displayed. <a href=\"javascript:receivedExpand();\">Click here to show all " + rowCountReceived + " items<\/a>.<\/td><\/tr>").appendTo("table#receivedt");
52
53     }
54
55     // Expand already received items table
56     function receivedExpand() {
57         $("#receivedcollapserow").remove();
58         $("table#receivedt tr").show();
59         $("<tr><td id=\"receivedcollapserow\" colspan=\"7\">All " + rowCountReceived + " items are displayed. <a href=\"javascript:receivedCollapse();\">Click here to show only the first " + rowsToCollapse + " items<\/a>.<\/td><\/tr>").appendTo("table#receivedt");
60     }
61
62     // Launch filtering
63     function filter() {
64
65     var summaryStatus = jQuery.trim($("#summaryfilter").val());
66         var basketStatus  = $("#basketfilter").val();
67         var orderStatus   = $("#orderfilter").val();
68
69         if (summaryStatus == '' && basketStatus == '' && orderStatus == '') { clearFilters(); return false; }
70
71         var filtered = "table#pendingt tbody.filterclass tr";
72
73         // We hide everything
74         $("#nothingfoundrow").remove();
75         $(filtered).hide();
76
77         // Do the search
78         var callback =  {
79                 success: function(o) {
80                         var jsonString = o.responseText;
81                         var gst = "<!-- TMPL_VAR NAME="gst" -->";
82                         try { 
83                                 var orders = YAHOO.lang.JSON.parse(jsonString);
84                                 var foundCount = orders.length;
85
86                                 for( i = 0 ; i < orders.length ; i++){
87                                         order = orders[i];
88                                         $('<tr>'
89                        + '<td class="basketfilterclass"><a href="/cgi-bin/koha/acqui/basket.pl?basketno=' + order.basketno + '">' + order.basketno + '</a></td>'
90                        + '<td class="orderfilterclass"> ' + order.ordernumber + ' </td>'
91                        + '<td class="summaryfilterclass">'
92                        + '<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=' + order.biblionumber + '">' + order.title + '</a> / ' + order.author + '&ndash;' + order.isbn + '</td>'
93                        + '<td><a href="/cgi-bin/koha/catalogue/showmarc.pl?id=' + order.biblionumber + '" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=' + order.biblionumber + '" title="MARC" rel="gb_page_center[600,500]">Card</a></td>'
94                        + '<td>' + order.quantrem + ' / ' + order.quantity + '</td>'
95                        + '<td>' + order.ecost + '</td>'
96                        + '<td>' + order.ordertotal + '</td>'
97                        + '<td>'
98                        + '<a href="orderreceive.pl?ordernumber=' + order.ordernumber + '&amp;datereceived=<!-- TMPL_VAR NAME="invoicedatereceived" -->&amp;invoice=<!-- TMPL_VAR NAME="invoice" -->&amp;gst=' + gst + '&amp;freight=' + order.freight + '&amp;supplierid=<!-- TMPL_VAR NAME="supplierid" -->">Receive</a> /' 
99                        + '<a href="parcel.pl?type=intra&amp;ordernumber=' + order.ordernumber + '&amp;biblionumber=' + order.biblionumber + '&amp;action=cancelorder&amp;supplierid=<!-- TMPL_VAR NAME="supplierid" -->&amp;datereceived=<!-- TMPL_VAR NAME="invoicedatereceived" -->&amp;invoice=<!-- TMPL_VAR NAME="invoice" -->" onclick="return confirm(' + _('Are you sure you want to cancel this order?') + ');">Cancel</a>'
100                        + '</td></tr>').appendTo("table#pendingt");
101                                 }
102
103                                 // If nothing has been found, we tell the user so
104                                 if (orders.length == 0) {
105                                     $("<tr><td id=\"nothingfoundrow\" colspan=\"8\">No items match your criteria.<\/tr>").appendTo("table#pendingt");
106                                 }
107                         }catch(e){alert(e);}
108                 }
109         }
110         var transaction = YAHOO.util.Connect.asyncRequest('GET', '/cgi-bin/koha/acqui/parcel.pl?supplierid=<!-- TMPL_VAR NAME="supplierid" -->&search='+summaryStatus+'&basketno='+basketStatus+'&orderno='+orderStatus+'&format=json', callback, null);
111
112         return false;
113     }
114     
115     // Clear already applied filters
116     function clearFilters() {
117         $("#nothingfoundrow").remove();
118         $("table#pendingt tbody.filterclass tr").show();
119         pendingExpand();
120     }
121
122 //]]>
123 </script>
124
125 </head>
126 <body>
127 <!-- TMPL_INCLUDE NAME="header.inc" -->
128 <!-- TMPL_INCLUDE NAME="acquisitions-search.inc" -->
129
130 <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;  <!-- TMPL_IF name="datereceived" -->
131             Receipt Summary for <i><!-- TMPL_VAR NAME="name" --></i> <!--TMPL_IF Name="invoice"--><i>[ <!-- TMPL_VAR NAME="invoice" --> ]</i><!--/TMPL_IF --> on <i><!-- TMPL_VAR NAME="formatteddatereceived" --></i>
132         <!-- TMPL_ELSE -->
133             Receive orders from <!-- TMPL_VAR NAME="name" -->
134         <!-- /TMPL_IF --></div>
135
136 <div id="doc3" class="yui-t2">
137    
138    <div id="bd">
139         <div id="yui-main">
140         <div class="yui-b">
141         <!-- TMPL_IF NAME="receive_error" -->
142         <div class="dialog alert">
143         <h3>Error adding items:</h3>
144         <ul>
145         <!-- TMPL_LOOP NAME="error_loop" -->
146                 <li><!-- TMPL_VAR NAME="error_param" --><!-- TMPL_IF NAME="error_duplicate_barcode" -->Duplicate Barcode<!-- /TMPL_IF --> <!-- todo: other error conditions come here. --></li>
147         <!-- /TMPL_LOOP -->
148         </ul>
149         </div>
150         <!-- /TMPL_IF -->
151     <h1>
152         <!-- TMPL_IF name="datereceived" -->
153             Receipt Summary for <i><!-- TMPL_VAR NAME="name" --></i> <!--TMPL_IF Name="invoice"--> <i> [ <!-- TMPL_VAR NAME="invoice" --> ] </i><!--/TMPL_IF --> on <i><!-- TMPL_VAR NAME="formatteddatereceived" --></i>
154         <!-- TMPL_ELSE -->
155             Receive orders from <!-- TMPL_VAR NAME="name" -->
156         <!-- /TMPL_IF -->
157     </h1>
158
159     <!-- TMPL_IF NAME="success_delorder" -->
160     <div class="dialog message">The order has been successfully canceled.</div>
161     <!-- TMPL_ELSE -->
162         <!-- TMPL_IF NAME="error_delitem" -->
163             <div class="dialog alert">The order has been canceled, although one or more items could not have been deleted.</div>
164         <!-- /TMPL_IF -->
165         <!-- TMPL_IF NAME="error_delbiblio" -->
166             <div class="dialog alert">The order has been canceled, although the record has not been deleted.</div>
167         <!-- /TMPL_IF -->
168     <!-- /TMPL_IF -->
169
170 <div id="acqui_receive_summary">
171     <p>Invoice number: <!-- TMPL_VAR NAME="invoice" --></p>
172     <p>Received by: <!-- TMPL_VAR NAME="loggedinusername" --></p>
173     <p>On: <!-- TMPL_VAR NAME="formatteddatereceived" --></p>
174         <!-- TODO: Add date picker, change rcv date. -->
175 </div>
176 <div id="acqui_receive_search">
177     <h2>Items in shipment</h2>
178         <form action="/cgi-bin/koha/acqui/parcel.pl" id="filterform" onsubmit="return filter();">
179         <fieldset class="rows">
180
181             <legend>Filters :</legend>
182          
183             <ol>
184
185                 <li>    
186                     <label for="summaryfilter">ISBN, author or title :</label>
187                     <input type="text" name="summaryfilter" id="summaryfilter" />
188                 </li>
189
190                 <li>    
191                     <label for="basketfilter">Basket :</label>
192                     <input type="text" name="basketfilter" id="basketfilter" /><br />
193                 </li>
194
195                 <li>    
196                     <label for="orderfilter">Order :</label>
197                     <input type="text" name="orderfilter" id="orderfilter" /><br />
198                 </li>
199
200                 <li>    
201                     <input type="submit" value="OK" />
202                     <input type="reset" value="Clear Filters" onclick="clearFilters();" />
203                 </li>
204                 
205             </ol>
206
207         </fieldset>
208     </form>
209
210  <table id="pendingt"> <caption>Pending Orders</caption>
211     <thead>
212         <tr>
213             <th>Basket</th>
214             <th>Order</th>
215             <th>Summary</th>
216             <th>View Record</th>
217             <th>Still on order</th>
218             <th>Unit cost</th>
219             <th>Order cost</th>
220             <th>Order</th>
221         </tr>
222     </thead>
223     <tbody class="filterclass">
224         <!-- TMPL_LOOP NAME="loop_orders" -->
225         <!-- TMPL_UNLESS NAME="__odd__" -->
226             <tr class="highlight">
227         <!-- TMPL_ELSE -->
228             <tr>
229         <!-- /TMPL_UNLESS -->
230                 <td class="basketfilterclass"><a href="/cgi-bin/koha/acqui/basket.pl?basketno=<!-- TMPL_VAR NAME="basketno" -->"><!-- TMPL_VAR NAME="basketno" --></a></td>
231                 <td class="orderfilterclass"><a href="neworderempty.pl?ordnum=<!-- TMPL_VAR NAME="ordernumber" -->&booksellerid=<!-- TMPL_VAR NAME="supplierid" -->"><!-- TMPL_VAR NAME="ordernumber" --></a></td>
232                 <td class="summaryfilterclass">
233                   <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR name="biblionumber" -->"><!-- TMPL_VAR NAME="title" escape="html"--></a>
234                 <!-- TMPL_IF NAME="author" --> / <!-- TMPL_VAR NAME="author" --><!--/TMPL_IF-->
235                 <!-- TMPL_IF NAME="isbn" --> &ndash; <!-- TMPL_VAR NAME="isbn" --><!--/TMPL_IF-->
236                 <!-- TMPL_IF NAME="publishercode" --><br />Publisher :<!-- TMPL_VAR NAME="publishercode" --><!--/TMPL_IF-->
237                 </td>
238                 <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?id=<!-- TMPL_VAR NAME="biblionumber" -->" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=<!-- TMPL_VAR NAME="biblionumber" -->" title="MARC" rel="gb_page_center[600,500]">Card</a></td>
239                 <td><!-- TMPL_VAR NAME="quantrem" --> / <!-- TMPL_VAR NAME="quantity" --></td>
240                 <td><!-- TMPL_VAR NAME="ecost" --></td>
241                 <td><!-- TMPL_VAR NAME="ordertotal" --></td>
242                                 <td>
243                                     <a href="orderreceive.pl?ordernumber=<!-- TMPL_VAR NAME="ordernumber" -->&amp;datereceived=<!-- TMPL_VAR NAME="invoicedatereceived" -->&amp;invoice=<!-- TMPL_VAR NAME="invoice" -->&amp;gst=<!-- TMPL_VAR NAME="gst" -->&amp;freight=<!-- TMPL_VAR NAME="freight" -->&amp;supplierid=<!-- TMPL_VAR NAME="supplierid" -->">Receive</a> / 
244                                     <a href="parcel.pl?type=intra&amp;ordernumber=<!-- TMPL_VAR NAME="ordernumber" -->&amp;biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;action=cancelorder&amp;supplierid=<!-- TMPL_VAR NAME="supplierid" -->&amp;datereceived=<!-- TMPL_VAR NAME="invoicedatereceived" -->&amp;invoice=<!-- TMPL_VAR NAME="invoice" -->" onclick="return confirm(_('Are you sure you want to cancel this order?'));">Cancel</a>
245                                 </td>
246             </tr>
247         <!-- /TMPL_LOOP -->
248     </tbody>
249     <tbody>
250             <tr><td colspan="3">&nbsp;</td>
251                 <th>TOTAL</th>
252                 <th> <!-- TMPL_VAR NAME="totalPquantity" --> </th>
253                                 <td>&nbsp;</td>
254                 <th><!-- TMPL_VAR NAME="ordergrandtotal" --></th>
255                                 <td>&nbsp;</td>
256             </tr>
257     </tbody>
258      </table>
259    <div id="resultnumber">
260         <!-- Row of numbers corresponding to search result pages -->
261         <!-- TMPL_IF NAME="displayprev" -->
262                 <a href="parcel.pl?type=intra&amp;supplierid=<!-- TMPL_VAR NAME="supplierid" -->&amp;startfrom=<!-- TMPL_VAR NAME="prevstartfrom" --><!--TMPL_IF Name="datereceived"-->&amp;datereceived=<!--TMPL_VAR Name="datereceived"--><!--/TMPL_IF--><!--TMPL_IF Name="invoice"-->&amp;invoice=<!--TMPL_VAR Name="invoice"--><!--/TMPL_IF--><!--TMPL_IF Name="resultsperpage"-->&amp;resultsperpage=<!--TMPL_VAR Name="resultsperpage"--><!--/TMPL_IF-->#resultnumber">&lt;&lt; Previous</a>
263         <!-- /TMPL_IF -->
264         <!-- TMPL_LOOP NAME="numbers" -->
265                 <!-- TMPL_IF NAME="highlight" -->
266                 <span class="current"><!-- TMPL_VAR NAME="number" --></span>
267                 <!-- TMPL_ELSE -->
268                 <a href="parcel.pl?type=intra&amp;supplierid=<!-- TMPL_VAR NAME="supplierid" -->&amp;startfrom=<!-- TMPL_VAR NAME="startfrom" --><!--TMPL_IF Name="datereceived"-->&amp;datereceived=<!--TMPL_VAR Name="datereceived"--><!--/TMPL_IF--><!--TMPL_IF Name="invoice"-->&amp;invoice=<!--TMPL_VAR Name="invoice"--><!--/TMPL_IF--><!--TMPL_IF Name="resultsperpage"-->&amp;resultsperpage=<!--TMPL_VAR Name="resultsperpage"--><!--/TMPL_IF-->#resultnumber"><!-- TMPL_VAR NAME="number" --></a>
269                 <!-- /TMPL_IF -->
270         <!-- /TMPL_LOOP -->
271         <!-- TMPL_IF NAME="displaynext" -->
272                 <a href="parcel.pl?type=intra&amp;supplierid=<!-- TMPL_VAR NAME="supplierid" -->&amp;startfrom=<!-- TMPL_VAR NAME="nextstartfrom" --><!--TMPL_IF Name="datereceived"-->&amp;datereceived=<!--TMPL_VAR Name="datereceived"--><!--/TMPL_IF--><!--TMPL_IF Name="invoice"-->&amp;invoice=<!--TMPL_VAR Name="invoice"--><!--/TMPL_IF--><!--TMPL_IF Name="resultsperpage"-->&amp;resultsperpage=<!--TMPL_VAR Name="resultsperpage"--><!--/TMPL_IF-->#resultnumber">Next &gt;&gt;</a>
273         <!-- /TMPL_IF -->
274         </div>
275 </div>
276 <div id="acqui_receive_receivelist">
277     <h2>Already Received</h2>
278
279    <form action="/cgi-bin/koha/acqui/parcel.pl" method="get" name="orderform">
280     <table id="receivedt">
281         <thead>
282             <tr>
283                 <th>Basket</th>
284                 <th>Order</th>
285                 <th>Summary</th>
286                 <th>View Record</th>
287                 <th>Est cost</th>
288                 <th>Actual cost</th>
289                 <th>TOTAL</th>
290             </tr>
291         </thead>
292         <tbody class="filterclass">
293             <!-- TMPL_LOOP NAME="loop_received" -->
294         <!-- TMPL_UNLESS NAME="__odd__" -->
295             <tr class="highlight">
296         <!-- TMPL_ELSE -->
297             <tr>
298         <!-- /TMPL_UNLESS -->
299                 <td><a href="/cgi-bin/koha/acqui/basket.pl?basketno=<!-- TMPL_VAR NAME="basketno" -->"><!-- TMPL_VAR NAME="basketno" --></a></td>
300                 <td><a href="neworderempty.pl?ordnum=<!-- TMPL_VAR NAME="ordernumber" -->&booksellerid=<!-- TMPL_VAR NAME="supplierid" -->"><!-- TMPL_VAR NAME="ordernumber" --></a></td>
301                 <td><a href="/cgi-bin/koha/catalogue/detail.pl?amp;biblionumber=<!-- TMPL_VAR name="biblionumber" -->"><!-- TMPL_VAR NAME="title" --></a>
302                 <!-- TMPL_IF NAME="author" --> / <!-- TMPL_VAR NAME="author" --><!--/TMPL_IF-->
303                 <!-- TMPL_IF NAME="isbn" --> - <!-- TMPL_VAR NAME="isbn" --><!--/TMPL_IF-->
304                 <!-- TMPL_IF NAME="publishercode" --><br />Publisher :<!-- TMPL_VAR NAME="publishercode" --><!--/TMPL_IF-->
305                 </td>
306                 <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?id=<!-- TMPL_VAR NAME="biblionumber" -->" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=<!-- TMPL_VAR NAME="biblionumber" -->" title="MARC" rel="gb_page_center[600,500]">Card</a></td>
307                 <td><!-- TMPL_VAR NAME="ecost" --></td>
308                 <td><!-- TMPL_VAR NAME="unitprice" --></td>
309                 <td><!-- TMPL_VAR NAME="total" --></td>
310             </tr>
311             <!-- /TMPL_LOOP -->
312         </tbody>
313         <tbody>
314             <tr>
315                 <td colspan="3">&nbsp;</td>
316                 <th>SUBTOTAL</th>
317                 <td>&nbsp;</td>
318                 <th><!-- TMPL_VAR NAME="totalprice" --></th>
319                 <th><!-- TMPL_VAR NAME="tototal" --></th>
320             </tr>
321               <!-- TMPL_IF NAME="totalfreight" -->
322                     <tr>
323                 <td colspan="5">
324                 </td>
325                 </p>
326                             <th colspan="1">Shipping</th>
327                 <td><!-- TMPL_VAR NAME="totalfreight" --></td>
328             </tr> <!-- /TMPL_IF -->
329               <!-- TMPL_IF NAME="gst" -->
330                     <tr>
331                 <td colspan="5">
332                 <p class="message">
333                             <b>HELP</b><br />
334                     The total at the bottom of the page should be within a few cents of the total for the invoice.
335                 </p>
336                 </td>
337                             <td><b>GST</b></td>
338                 <td><!-- TMPL_VAR NAME="gst" --></td>
339             </tr> <!-- /TMPL_IF -->
340             <tr>
341             <td colspan="3">&nbsp;</td>
342                 <th>TOTAL</th>
343                 <td colspan="2">&nbsp;</td>
344                 <th><!-- TMPL_VAR NAME="grandtot" --></th>
345             </tr>
346     </tbody>
347     </table>
348     </form>
349 </div>
350
351 </div>
352 </div>
353 <div class="yui-b">
354 <!-- TMPL_INCLUDE NAME="acquisitions-menu.inc" -->
355 </div>
356 </div>
357 <!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->