Merge pull request #5248 from solgenomics/topic/batch_update_trials
[sgn.git] / mason / breeders_toolbox / discard_seedlots.mas
blob572a0bf5f310560a04d91a9198a65130a8960427
1 <%args>
2 $user_role
3 $timestamp => localtime()
4 </%args>
6 <div class="modal fade" id="discard_seedlots_using_list_dialog" name="discard_seedlots_using_list_dialog" tabindex="-1" role="dialog" aria-labelledby="discardSeedlotsDialog">
7     <div class="modal-dialog modal-lg" role="document">
8         <div class="modal-content">
9             <div class="modal-header">
10                 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
11                 <h4 class="modal-title" id="discardSeedlotsDialog">Mark Seedlots as Discarded </h4>
12             </div>
13             <div class="modal-body">
14                 <div class="container-fluid">
15                     <form class="form-horizontal" role="form" method="post" id="discard_seedlots_form" name="discard_seedlots_form">
16                         <div class="form-group" id="seedlot_list_section" >
17                             <label class="col-sm-4 control-label">List of Seedlots:</label>
18                             <div class="col-sm-8" id="select_seedlot_list" name="select_seedlot_list"></div>
19                         </div>
20                         <div class="form-group">
21                             <label class="col-sm-4 control-label">Reason for Discarding: </label>
22                             <div class="col-sm-8" >
23                                 <textarea class="form-control" id="reason_for_discarding" name="reason_for_discarding" placeholder="Required"></textarea>
25                             </div>
26                         </div>
27                     </form>
28                 </div>
29             </div>
30             <div class="modal-footer">
31                 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
32                 <button type="button" class="btn btn-primary" name="discard_seedlots_submit" id="discard_seedlots_submit">Submit</button>
33             </div>
34         </div>
35     </div>
36 </div>
38 <div class="modal fade" id="discard_seedlot_saved_dialog_message" name="discard_seedlot_saved_dialog_message" tabindex="-1" role="dialog" aria-labelledby="discardSeedlotSavedDialog">
39     <div class="modal-dialog" role="document">
40         <div class="modal-content">
41             <div class="modal-header">
42                 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
43                 <h4 class="modal-title" id="discardSeedlotSavedDialog">Success</h4>
44             </div>
45             <div class="modal-body">
46                 <div class="container-fluid">
47                     <p>
48                         <span class="ui-icon ui-icon-circle-check" style="float: left; margin: 0 7px 50px 0;"></span>
49                         The seedlots were marked as DISCARDED.
50                     </p>
51                 </div>
52             </div>
53             <div class="modal-footer">
54                 <button id="dismiss_discard_seedlot_saved_dialog" type="button" class="btn btn-default" data-dismiss="modal">Close & Reload</button>
55             </div>
56         </div>
57     </div>
58 </div>
61 <script>
62 jQuery(document).ready(function(){
64     jQuery("#discard_seedlot_link").click( function() {
65         jQuery('#discard_seedlots_using_list_dialog').modal('show');
66     });
68     var list = new CXGN.List();
69     document.getElementById("select_seedlot_list").innerHTML = list.listSelect("select_seedlot_list", [ 'seedlots' ], 'Please select a list of seedlots to discard','', undefined);
71     jQuery('#discard_seedlots_submit').click(function(){
73         var seedlot_list_id = jQuery('#select_seedlot_list_list_select').val();
74         var discard_reason = jQuery('#reason_for_discarding').val();
76         if (seedlot_list_id === '') {
77             alert("Please select a list");
78             return;
79         }
81         if (discard_reason === '') {
82             alert("Please provide reason for discarding these seedlots");
83             return;
84         }
86         jQuery.ajax({
87             url: '/ajax/breeders/seedlot/discard',
88             dataType: "json",
89             data : {
90                 'seedlot_list_id' : seedlot_list_id,
91                 'discard_reason': discard_reason,
92             },
93             beforeSend: function(response){
94                 jQuery('#working_modal').modal('show');
95             },
96             success: function(response) {
97                 jQuery('#working_modal').modal('hide');
98                 if (response.success == 1) {
99                     jQuery('#discard_seedlots_using_list_dialog').modal('hide');
100                     jQuery('#discard_seedlot_saved_dialog_message').modal("show");
101                 }
102                 if (response.error_string) {
103                     alert(response.error_string);
104                 }
105             },
106             error: function(response){
107                 jQuery('#working_modal').modal('hide');
108                 alert('An error occurred discarding seedlots');
109             }
110         });
111     });
113     jQuery("#dismiss_discard_seedlot_saved_dialog").click( function() {
114         jQuery('#discard_seedlot_saved_dialog_message').modal('hide');
115         location.reload();
116     });
120 </script>