Merge pull request #5123 from solgenomics/topic/wishlist
[sgn.git] / mason / order / stocks.mas
bloba2927f01710f5442a2304d3ef7ee2c37fc7225e5
1 <%args>
3 $role => "stock_orderer"
4 $check_vendor_role => undef
5 $tracking_order_activity => undef
6 $user_id
8 </%args>
11 <& /util/import_javascript.mas, classes => [ 'jquery', 'jquery/dataTables', 'CXGN.BreedersToolbox.HTMLSelect.js', 'CXGN.List' ] &>
13 % if ($check_vendor_role == 1) {
14     <&| /page/page_title.mas, title => "Manage Orders for Vendor" &>
15     </&>
16 % } else {
17     <&| /page/page_title.mas, title => "Your Orders" &>
18     </&>
21 <td>
22     <a href="/catalog/view"><p>Go to Catalog Page</p></a>
23 </td>
25 <br/>
26 % if ($check_vendor_role == 1) {
27     <&| /page/info_section.mas, title => 'Manage Current Orders', collapsible=>1, collapsed=>0 &>
28         <div class = "well well-sm">
29             <div class = "panel panel-default">
30                 <div class = "panel-body">
31                     <div style="overflow:scroll">
32                         <table id = "vendor_current_orders" class="table table-hover table-striped">
33                         </table>
34                     </div>
35                 </div>
36             </div>
37         </div>
38     </&>
40     <&| /page/info_section.mas, title => 'Completed Orders', collapsible=>1, collapsed=>1 &>
41         <div class = "well well-sm">
42             <div class = "panel panel-default">
43                 <div class = "panel-body">
44                     <div style="overflow:scroll">
45                         <table id = "vendor_completed_orders" class="table table-hover table-striped">
46                         </table>
47                     </div>
48                 </div>
49             </div>
50         </div>
51     </&>
52 % }
54 % if ($check_vendor_role != 1) {
55     <&| /page/info_section.mas, title => 'Your Current Orders', collapsible=>1, collapsed=>0 &>
56         <div class = "well well-sm">
57             <div class = "panel panel-default">
58                 <div class = "panel-body">
59                     <div style="overflow:scroll">
60                         <table id = "user_current_orders" class="table table-hover table-striped">
61                             <thead>
62                                 <tr>
63                                     <th>Order Number</th>
64                                     <th>Submitted Date</th>
65                                     <th>Order Details</th>
66                                     <th>Status</th>
67                                     <th>Send Order to</th>
68                                     <th>Comments</th>
69                                 </tr>
70                             </thead>
71                         </table>
72                     </div>
73                 </div>
74             </div>
75         </div>
76     </&>
78     <&| /page/info_section.mas, title => 'Your Completed Orders', collapsible=>1, collapsed=>0 &>
79         <div class = "well well-sm">
80             <div class = "panel panel-default">
81                 <div class = "panel-body">
82                     <div style="overflow:scroll">
83                         <table id = "user_completed_orders" class="table table-hover table-striped">
84                             <thead>
85                                 <tr>
86                                     <th>Order Number</th>
87                                     <th>Submitted Date</th>
88                                     <th>Order Details</th>
89                                     <th>Status</th>
90                                     <th>Completed Date</th>
91                                     <th>Processed by</th>
92                                     <th>Comments</th>
93                                 </tr>
94                             </thead>
95                         </table>
96                     </div>
97                 </div>
98             </div>
99         </div>
100     </&>
101 % }
103 <div class="modal fade" id="update_order_dialog" name="update_order_dialog" tabindex="-1" role="dialog" aria-labelledby="updateOrderDialog">
104     <div class="modal-dialog modal-lg" role="document">
105         <div class="modal-content">
106             <div class="modal-header">
107                 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
108                 <h4 class="modal-title" id="updateOrderDialog">Update Order</h4>
109             </div>
110             <div class="modal-body">
111                 <div class="container-fluid">
112                     <div id="update_order_div">
113                     </div>
114                 </div>
115             </div>
116             <div class="modal-footer">
117                 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
118                 <button id="update_order_button" type="button" class="btn btn-primary" >Update</button>
119             </div>
120         </div>
121     </div>
122 </div>
124 <div class="modal fade" id="update_saved_dialog" name="update_saved_dialog" tabindex="-1" role="dialog" aria-labelledby="updateSavedDialog">
125     <div class="modal-dialog" role="document">
126         <div class="modal-content">
127             <div class="modal-header">
128                 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
129                 <h4 class="modal-title" id="updateSavedDialog">Success</h4>
130             </div>
131             <div class="modal-body">
132                 <div class="container-fluid">
133                     <p>
134                         <span class="ui-icon ui-icon-circle-check" style="float: left; margin: 0 7px 50px 0;"></span>
135                         The order has been updated.
136                     </p>
137                 </div>
138             </div>
139             <div class="modal-footer">
140                 <button id="dismiss_update_saved_dialog" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
141             </div>
142         </div>
143     </div>
144 </div>
146 <div class="modal fade" id="re_open_order_dialog" name="re_open_order_dialog" tabindex="-1" role="dialog" aria-labelledby="reOpenOrderDialog">
147     <div class="modal-dialog modal-lg" role="document">
148         <div class="modal-content">
149             <div class="modal-header">
150                 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
151                 <h4 class="modal-title" id="reOpenOrderDialog">Re-Open Order</h4>
152             </div>
153             <div class="modal-body">
154                 <div class="container-fluid">
155                     <div id="re_open_order_div">
156                     </div>
157                 </div>
158             </div>
159             <div class="modal-footer">
160                 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
161                 <button id="re_open_order_button" type="button" class="btn btn-primary" >Re-Open</button>
162             </div>
163         </div>
164     </div>
165 </div>
167 % if (($check_vendor_role == 1) && $tracking_order_activity) {
168     <&| /page/info_section.mas, title => 'Tracking Order Progress', collapsible=>1, collapsed=>0 &>
169         <div class = "well well-sm">
170             <div class = "panel panel-default">
171                 <div class = "panel-body">
172                     <!--
173                     <button id="download_active_item_file_button" class="btn btn-primary">Download Item File</button>
174                     <button id="download_ontology_file_button" class="btn btn-primary">Download Data Collection Ontologies</button>
175                     -->
176                     <button id="generate_active_item_barcode_button" class="btn btn-primary">Generate Item Barcodes</button>
177                     <a href="/activity/record" class="btn btn-default">Go to Record Page</a>
178                 </div>
179                 <div class = "panel-body">
181                 <div style="overflow:scroll">
182                     <table class="table table-hover table-bordered" id="order_progress_table">
183                         <thead>
184                             <tr>
185                                 <th>Order Number</th>
186                                 <th>Order Details</th>
187                                 <th>Tracking ID</th>
188                                 <th>Material</th>
189 % my $activity_types = $c->config->{tracking_activities_header};
190 % my @column_header = split ',',$activity_types;
191 % foreach my $column_header(@column_header){
192                                 <th><%$column_header%></th>
194                             </tr>
195                         </thead>
196                     </table>
197                 </div>
198                 </div>
199             </div>
200         </div>
201     </&>
202 % }
204 <& /order/create_item_file_dialog.mas&>
205 <& /order/create_ontology_file_dialog.mas &>
206 <& /order/generate_identifier_barcode_dialog.mas, identifier => "", user_id => $user_id &>
208 <script>
210 $(window).ready( function() {
212     jQuery('#user_current_orders').DataTable( {
213         'autoWidth': false,
214         'ajax': '/ajax/order/current',
215     });
217     jQuery('#user_completed_orders').DataTable( {
218         'autoWidth': false,
219         'ajax': '/ajax/order/completed',
220     });
222     jQuery('#vendor_current_orders').DataTable( {
223         'autoWidth': false,
224         'ajax': '/ajax/order/vendor_current_orders',
225         columns: [
226             { title: "Order Number", "data": null, "render": function ( data, type, row ) { return "<a href='/order/details/view/"+row.order_id+"'>"+row.order_id+"</a>"; } },
227             { title: "Ordered by", "data": "order_from_name" },
228             { title: "Submitted Date", "data": "create_date" },
229             { title: "Order Details", "data": "order_details" },
230             { title: "Status", "data": "order_status" },
231             { title: "Comments", "data": "contact_person_comments" },
232             { title: "Update", "data": "null", "render": function ( data, type, row ) { return "<a onclick='updateOrder(\""+row.order_id+"\", \""+row.order_from_name+"\")' >Update</a>"; } },
233         ]
234     });
236     jQuery('#vendor_completed_orders').DataTable( {
237         'autoWidth': false,
238         'ajax': '/ajax/order/vendor_completed_orders',
239         columns: [
240             { title: "Order Number", "data": null, "render": function ( data, type, row ) { return "<a href='/order/details/view/"+row.order_id+"'>"+row.order_id+"</a>"; } },
241             { title: "Ordered by", "data": "order_from_name" },
242             { title: "Submitted Date", "data": "create_date" },
243             { title: "Order Details", "data": "order_details" },
244             { title: "Status", "data": "order_status" },
245             { title: "Completion Date", "data": "completion_date" },
246             { title: "Comments", "data": "contact_person_comments" },
247             { title: "Update", "data": "null", "render": function ( data, type, row ) { return "<a onclick='reOpenOrder(\""+row.order_id+"\", \""+row.order_from_name+"\")' >Re-Open</a>"; } },
248         ]
249     });
251     jQuery('#update_order_button').click( function() {
252         var order_id = jQuery('#update_order_id').val();
253         var new_order_status = jQuery('#update_order_status').val();
254         if (!new_order_status) {
255             alert ("Please select a status");
256             return;
257         }
258         var contact_person_comments = jQuery('#contact_person_comments').val();
260         jQuery.ajax({
261             url: '/ajax/order/update',
262             dataType: "json",
263             type: 'POST',
264             data : {
265                 'order_id' : order_id,
266                 'new_status': new_order_status,
267                 'contact_person_comments': contact_person_comments
268             },
269             beforeSend: function(response){
270                 jQuery('#working_modal').modal('show');
271             },
272             success: function(response) {
273                 jQuery('#working_modal').modal('hide');
274                 if (response.success == 1) {
275                     jQuery('#update_saved_dialog').modal('show');
276                     jQuery('#update_order_dialog').modal('hide');
277                 }
278                 if (response.error_string) {
279                     alert(response.error);
280                 }
281             },
282             error: function(response){
283                 jQuery('#working_modal').modal('hide');
284                 alert('An error occurred updating the order');
285             }
286         });
287     });
289     jQuery("#dismiss_update_saved_dialog").click(function(){
290         location.reload();
291     });
293     jQuery('#re_open_order_button').click( function() {
294         var order_id = jQuery('#re_open_order_id').val();
295         var re_open_status = jQuery('#re_open_status').val();
296         var re_open_comments = jQuery('#re_open_comments').val();
297         if (!re_open_comments) {
298             alert ("Please add comments for re-opening the order");
299             return;
300         }
302         jQuery.ajax({
303             url: '/ajax/order/update',
304             dataType: "json",
305             type: 'POST',
306             data : {
307                 'order_id' : order_id,
308                 'new_status': re_open_status,
309                 'contact_person_comments': re_open_comments
310             },
311             beforeSend: function(response){
312                 jQuery('#working_modal').modal('show');
313             },
314             success: function(response) {
315                 jQuery('#working_modal').modal('hide');
316                 if (response.success == 1) {
317                     jQuery('#update_saved_dialog').modal('show');
318                     jQuery('#re_open_order_dialog').modal('hide');
319                 }
320                 if (response.error_string) {
321                     alert(response.error);
322                 }
323             },
324             error: function(response){
325                 jQuery('#working_modal').modal('hide');
326                 alert('An error occurred updating the order');
327             }
328         });
329     });
331     jQuery('#order_progress_table').DataTable({
332         'autoWidth': false,
333         'ajax': '/ajax/order/progress',
334     });
338 function updateOrder(order_id, order_from_name){
339     var html = '';
340     html += '<form class="form-horizontal"><div class="form-group"><label class="col-sm-3 control-label">Order Number: </label><div class="col-sm-9" ><input class="form-control" id="update_order_id" name="update_order_id" value="'+order_id+'" disabled></div></div>';
341     html += '<div class="form-group"><label class="col-sm-3 control-label">Ordered by: </label><div class="col-sm-9" ><input class="form-control" id="ordered_by_name" name="ordered_by_name" value="'+order_from_name+'" disabled></div></div>';
342     html += '<div class="form-group"><label class="col-sm-3 control-label">Status: </label><div class="col-sm-9" ><select class="form-control" id="update_order_status" name="update_order_status"><option disabled value="" selected hidden>Select a status</option>';
343     html += '<option value='+"being_processed"+'>'+"being_processed"+'</option>';
344     html += '<option value='+"shipped"+'>'+"shipped"+'</option>';
345     html += '<option value='+"completed"+'>'+"completed"+'</option>';
346     html += '<option value='+"cancelled"+'>'+"cancelled"+'</option>';
347     html += '</select></div></div>';
348     html += '<div class="form-group"><label class="col-sm-3 control-label">Comments: </label><div class="col-sm-9" ><input class="form-control" id="contact_person_comments" placeholder="Optional"></div></div></form>'
350     jQuery('#update_order_div').html(html);
351     jQuery('#update_order_dialog').modal('show');
355 function reOpenOrder(order_id, order_from_name){
356     var re_open = "re-opened"
357     var html = '';
358     html += '<form class="form-horizontal"><div class="form-group"><label class="col-sm-3 control-label">Order Number: </label><div class="col-sm-9" ><input class="form-control" id="re_open_order_id" name="re_open_order_id" value="'+order_id+'" disabled></div></div>';
359     html += '<div class="form-group"><label class="col-sm-3 control-label">Ordered by: </label><div class="col-sm-9" ><input class="form-control" id="re_open_ordered_by" name="re_open_ordered_by" value="'+order_from_name+'" disabled></div></div>';
360     html += '<div class="form-group"><label class="col-sm-3 control-label">Status: </label><div class="col-sm-9" ><input class="form-control" id="re_open_status" name="re_open_status" value="'+re_open+'" disabled></div></div>';
361     html += '<div class="form-group"><label class="col-sm-3 control-label">Comments: </label><div class="col-sm-9" ><input class="form-control" id="re_open_comments" placeholder="Required"></div></div></form>'
363     jQuery('#re_open_order_div').html(html);
364     jQuery('#re_open_order_dialog').modal('show');
369 </script>