moved crossing trial addition to modal
[sgn.git] / mason / breeders_toolbox / seedlots.mas
bloba85db988e26cf5728956ac754de34e52854b6b1b
2 <%args>
3 $timestamp
4 $preferred_species
5 $editable_stock_props
6 $programs
7 $locations
8 $crossing_trials
9 </%args>
11 <& /page/page_title.mas, title=>"Available Seedlots" &>
13 <style>
14 .ui-autocomplete {
15     z-index: 5000;
17 </style>
18   
19   <& /util/import_javascript.mas, classes => [ 'bootstrap_min.js', 'jquery.iframe-post-form','CXGN.List','CXGN.BreedersToolbox.Accessions', 'CXGN.BreedersToolbox.UploadPedigrees', 'jquery', 'jquery.dataTables', 'CXGN.BreedersToolbox.Crosses' ] &>
22 <&| /page/info_section.mas, title=>"About Seedlots",  collapsible => 1, collapsed=>1 &>
23     <div class="well well-sm">
24         <div class="panel panel-default">
25             <div class="panel-body">
26                 <b><p>What are seedlots?</p></b>
27                 <ul>
28                 <li>Seedlots represent physical seed in packets.</li>
29                 <li>This seed can be from crosses or for named accessions.</li>
30                 <li>Seedlots can have a specific location, box, weight(g), and count.</li>
31                 <li>Seed can be transferred into and out of a seedlot. Such as from a seedlot into a plot.</li>
32                 <li>Seedlots can belong to breeding programs and organizations.</li>
33                 </ul>
35                 <b><p>How do I inventory my seed?</p></b>
36                 <ul>
37                 <li>1) Make sure your seedlots are in the database. Use "Add New Seedlot" to add a single seedlot or "Upload New Seedlots" to add many.</li>
38                 <li>2) Make sure your seedlots are barcoded. You can print these barcodes from the database.</li>
39                 <li>3) Use the "Seed Inventory" Android Application to scan seedlot barcodes and record weight. Then click "Upload Inventory" on the Manage Seedlots page to upload this info into the database. If you do not want to use the Seed Inventory Android Application you can create your own CSV file and upload that.</li>
40                 <li><b>For more info about the "Seed Inventory" Android Application go to <a href="http://www.wheatgenetics.org/research/software/35-inventory">Seed Inventory</a>.</b></li>
41                 <li>It is also possible to manually enter a transaction by going to the seedlot detail page and clicking "Add New Transaction".</li>
42                 </ul>
43             </div>
44         </div>
45     </div>
46 </&>
49 <&| /page/info_section.mas, title=>"Seedlots",  collapsible => 1, subtitle => '[<a name="add_seedlot_button">Add New Seedlot</a>]&nbsp;&nbsp;&nbsp;[<a name="seedlot_bulk_upload">Upload Seedlots</a>]&nbsp;&nbsp;&nbsp;[<a id="seedlot_upload_inventory">Upload Inventory</a>]'&>
51 <br/>
53 <div class="well well-sm">
54     <div class="panel panel-default">
55         <div class="panel-body">
57 <&| /page/info_section.mas, title=>"Search Seedlots",  collapsible => 1, collapsed=>0 &>
59 <div class="well well-sm">
60     <form class="form-horizontal" id="search_seedlot_form" name="search_seedlot_form">
61         <div class="form-group form-group-sm">
62             <label class="col-sm-3 control-label">Seedlot Name: </label>
63             <div class="col-sm-9" >
64                 <input class="form-control" id="search_seedlot_form_seedlot_name" type="text" />
65             </div>
66         </div>
67         <div class="form-group form-group-sm">
68             <label class="col-sm-3 control-label">Breeding Program: </label>
69             <div class="col-sm-9" >
70                 <input class="form-control" id="search_seedlot_form_breeding_program" type="text" />
71             </div>
72         </div>
73         <div class="form-group form-group-sm">
74             <label class="col-sm-3 control-label">Contents (Accession Uniquename): </label>
75             <div class="col-sm-9" >
76                 <input class="form-control" id="search_seedlot_form_contents_accession" type="text" />
77             </div>
78         </div>
79         <div class="form-group form-group-sm">
80             <label class="col-sm-3 control-label">Contents (Cross Uniquename): </label>
81             <div class="col-sm-9" >
82                 <input class="form-control" id="search_seedlot_form_contents_cross" type="text" />
83             </div>
84         </div>
85         <div class="form-group form-group-sm">
86             <label class="col-sm-3 control-label">Location: </label>
87             <div class="col-sm-9" >
88                 <input class="form-control" id="search_seedlot_form_location" type="text" />
89             </div>
90         </div>
91         <div class="form-group form-group-sm">
92             <label class="col-sm-3 control-label">Minimum Count: </label>
93             <div class="col-sm-9" >
94                 <input class="form-control" id="search_seedlot_form_minimum_count" type="number" />
95             </div>
96         </div>
97     </form>
98     <center>
99     <button class="btn btn-primary" id="submit_seedlot_search" />Search</button>
100     </center>
101 </div>
102 </&>
104 <br/>
106 <table id="available_seedlots_table" class="table table-hover table-striped table-bordered">
107 </table>
109 <hr>
111 <div id="available_seedlots_to_list" style="display:none">
112 </div>
113 <div id="available_seedlots_add_to_list">
114 </div>
116         </div>
117     </div>
118 </div>
119 </&>
121 <& /breeders_toolbox/upload_seedlots_dialogs.mas &>
122 <& /breeders_toolbox/upload_seedlots_inventory_dialogs.mas &>
123 <& /breeders_toolbox/add_seedlot_dialogs.mas, timestamp=>$timestamp &>
124 <& /breeders_toolbox/add_accessions_dialogs.mas, preferred_species=>$preferred_species, editable_stock_props=>$editable_stock_props &>
125 <& /breeders_toolbox/upload_crosses_dialogs.mas, programs=>$programs, locations=>$locations, crossing_trials=>$crossing_trials &>
126 <& /breeders_toolbox/add_cross_dialogs.mas, programs=>$programs, locations=>$locations, crossing_trials=>$crossing_trials &>
128 <script>
129 jQuery(document).ready(function(){
131     var seedlots_table = jQuery('#available_seedlots_table').DataTable({
132         'searching' : false,
133         'ordering'  : false,
134         'processing': true,
135         'serverSide': true,
136         'lengthMenu': [10,20,50,100,1000],
137         'ajax': { 'url': '/ajax/breeders/seedlots',
138                   'data': function(d) {
139                      d.seedlot_name  = jQuery('#search_seedlot_form_seedlot_name').val();
140                      d.breeding_program = jQuery('#search_seedlot_form_breeding_program').val();
141                      d.minimum_count   = jQuery('#search_seedlot_form_minimum_count').val();
142                      d.location     = jQuery('#search_seedlot_form_location').val();
143                      d.contents_accession = jQuery('#search_seedlot_form_contents_accession').val();
144                      d.contents_cross = jQuery('#search_seedlot_form_contents_cross').val();
145                 }
146         },
147         columns: [
148             { title: "Seedlot Name", "data": null, "render": function ( data, type, row ) { return "<a href='/breeders/seedlot/"+row.seedlot_stock_id+"'>"+row.seedlot_stock_uniquename+"</a>"; } },
149             { title: "Breeding Program", "data": "breeding_program_name" },
150             { title: "Contents", "data": "contents_html" },
151             { title: "Location", "data": "location" },
152             { title: "Count", "data": "count" },
153             { title: "Weight (g)", "data": "weight_gram" },
154             { title: "Owners", "data": "owners_string" },
155             { title: "Organization", "data": "organization" },
156             { title: "Box", "data": "box" },
157             { title: "Delete", "data": "null", "render": function ( data, type, row ) { return "<a onclick='removeSeedlot("+row.seedlot_stock_id+")' >X</a>"; } },
158         ],
159         "fnInitComplete": function(oSettings, json) {
160             //console.log(json);
161             if (!isLoggedIn()) {
162                 jQuery('#available_seedlots_add_to_list').html("<div class='well well-sm'><h3>Please login to use lists!</h3></div>");
163             } else {
164                 var html = "";
165                 for(var i=0; i<json.data.length; i++){
166                     html += json.data[i].seedlot_stock_uniquename+"\n";
167                 }
168                 jQuery("#available_seedlots_to_list").html(html);
169                 addToListMenu("available_seedlots_add_to_list", "available_seedlots_to_list", {
170                     selectText: true,
171                     listType: 'seedlots',
172                     listName: 'seedlots'
173                 });
174             }
175         }
176     });
178     jQuery('#submit_seedlot_search').click( function() {
179         seedlots_table.search("available_seedlots_table").draw();
180     });
182     jQuery('#search_seedlot_form').keypress( function( e ) {
183         var code = e.keyCode || e.which;
184         if( code == 13 ) {
185             jQuery('#submit_seedlot_search').click();
186         }
187     });
191 function removeSeedlot(seedlot_stock_id){
192     if (confirm("Are you sure you want to delete this seedlot?")){
193         jQuery.ajax({
194             url: '/ajax/breeders/seedlot/'+seedlot_stock_id+'/delete',
195             beforeSend: function(){
196                 jQuery('#working_modal').modal('show');
197             },
198             success: function(response) {
199                 jQuery('#working_modal').modal('hide');
200                 if (response.success == 1) {
201                     alert("The seedlot has been deleted.");
202                     location.reload();
203                 }
204                 if (response.error) {
205                     alert(response.error);
206                 }
207             },
208             error: function(response){
209                 jQuery('#working_modal').modal('hide');
210                 alert('An error occurred deleting seed lot');
211             }
212         });
213     }
216 </script>