2 $timestamp => localtime()
3 $accession_uniquename => ''
4 $cross_uniquename => ''
7 <div class="modal fade" id="add_seedlot_dialog" name="add_seedlot_dialog" tabindex="-1" role="dialog" aria-labelledby="seedlot_dialog">
8 <div class="modal-dialog modal-lg" role="document">
9 <div class="modal-content">
10 <div class="modal-header">
11 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
12 <h4 class="modal-title" id="seedlot_dialog">Create New Seedlot</h4>
14 <div class="modal-body">
15 <div class="container-fluid">
16 <form class="form-horizontal" role="form" method="post" id="create_new_seedlot_form" name="create_new_seedlot_form">
18 <div class="form-group">
19 <label class="col-sm-3 control-label">Name: </label>
20 <div class="col-sm-9" >
21 <input class="form-control" id="seedlot_name" placeholder="Required">
24 <div class="form-group">
25 <label class="col-sm-3 control-label">Seedlot Description: </label>
26 <div class="col-sm-9" >
27 <input class="form-control" id="seedlot_description" placeholder="Optional">
30 <div class="form-group">
31 <label class="col-sm-3 control-label">Breeding Program: </label>
32 <div class="col-sm-9" >
33 <div id="seedlot_breeding_program_div"></div>
36 <div class="form-group">
37 <label class="col-sm-3 control-label">Location: </label>
38 <div class="col-sm-9" >
39 <input class="form-control" id="seedlot_location" placeholder="Required">
42 <div class="form-group">
43 <label class="col-sm-3 control-label">Box Name: </label>
44 <div class="col-sm-9" >
45 <input class="form-control" id="seedlot_box_name" placeholder="Required">
49 <div class="form-group">
50 <label class="col-sm-3 control-label">Quality issues:</label>
51 <div class="col-sm-9" >
52 <input class="form-control" id="seedlot_quality" placeholder="list quality issues here, or 'ok' for good quality seed" >
56 <div class="well well-sm">
58 <div class="col-sm-3">
59 <div class="form-group">
60 <label class="col-sm-12 control-label">Contents: </label>
63 <div class="col-sm-9">
64 % if ($accession_uniquename || $cross_uniquename){
65 <div class="panel panel-default">
66 <div class="panel-body">
67 <div class="form-group">
68 <label class="col-sm-3 control-label">Accession name: </label>
69 <div class="col-sm-9" >
70 <input class="form-control" id="seedlot_accession_uniquename" placeholder="One Content Required" disabled value="<% $accession_uniquename %>">
75 <center><h4>OR</h4></center>
76 <div class="panel panel-default">
77 <div class="panel-body">
78 <div class="form-group">
79 <label class="col-sm-3 control-label">Cross Unique ID: </label>
80 <div class="col-sm-9" >
81 <input class="form-control" id="seedlot_cross_uniquename" placeholder="One Content Required" disabled value="<% $cross_uniquename %>">
87 <div class="panel panel-default">
88 <div class="panel-body">
89 <div class="form-group">
90 <label class="col-sm-3 control-label">Accession name: </label>
91 <div class="col-sm-9" >
92 <input class="form-control" id="seedlot_accession_uniquename" placeholder="One Content Required">
97 <center><h4>OR</h4></center>
98 <div class="panel panel-default">
99 <div class="panel-body">
100 <div class="form-group">
101 <label class="col-sm-3 control-label">Cross Unique ID: </label>
102 <div class="col-sm-9" >
103 <input class="form-control" id="seedlot_cross_uniquename" placeholder="One Content Required">
113 <div class="form-group">
114 <label class="col-sm-3 control-label">Source: </label>
115 <div class="col-sm-9">
116 <input class="form-control" id="seedlot_source" placeholder="Optional">
117 <span style="font-size: 80; color: #666">Seedlot/Plot/Subplot/Plant name to be used as the source for the first transaction</span>
121 <div class="form-group">
122 <label class="col-sm-3 control-label">Amount (number of seeds): </label>
123 <div class="col-sm-9" >
124 <input class="form-control" id="seedlot_amount" placeholder="Amount OR Weight(g) Required">
127 <div class="form-group">
128 <label class="col-sm-3 control-label">Weight (g): </label>
129 <div class="col-sm-9" >
130 <input class="form-control" id="seedlot_weight" placeholder="Amount OR Weight(g) Required">
134 <div class="form-group">
135 <label class="col-sm-3 control-label">Population: </label>
136 <div class="col-sm-9" >
137 <input class="form-control" id="seedlot_population_name" placeholder="Optional">
141 <div class="form-group">
142 <label class="col-sm-3 control-label">Organization: </label>
143 <div class="col-sm-9" >
144 <input class="form-control" id="seedlot_organization" placeholder="Optional">
147 <div class="form-group">
148 <label class="col-sm-3 control-label">Timestamp: </label>
149 <div class="col-sm-9" >
150 <input class="form-control" id="seedlot_timestamp" value="<% $timestamp %>" placeholder="<% $timestamp %>">
153 <div class="form-group">
154 <label class="col-sm-3 control-label">Transaction Description: </label>
155 <div class="col-sm-9" >
156 <input class="form-control" id="seedlot_transaction_description" placeholder="Optional">
162 <div class="modal-footer">
163 <button id="create_new_seedlot_button" type="button" class="btn btn-primary" >OK</button>
170 jQuery(document).ready(function(){
172 jQuery("#seedlot_location").autocomplete({
173 source: '/ajax/stock/geolocation_autocomplete',
175 jQuery("#seedlot_accession_uniquename").autocomplete({
176 source: '/ajax/stock/accession_autocomplete',
178 jQuery("#seedlot_cross_uniquename").autocomplete({
179 source: '/ajax/stock/cross_autocomplete',
181 jQuery("#seedlot_source").autocomplete({
182 source: '/ajax/stock/seedlot_source_autocomplete'
185 jQuery('[name="add_seedlot_button"]').click( function() {
186 jQuery('#add_seedlot_dialog').modal('show');
187 get_select_box('breeding_programs', 'seedlot_breeding_program_div', { 'name' : 'seedlot_breeding_program_id', 'id' : 'seedlot_breeding_program_id' });
190 jQuery('#create_new_seedlot_button').click( function() {
191 var name = jQuery('#seedlot_name').val();
192 var seedlot_description = jQuery('#seedlot_description').val();
193 var location = jQuery('#seedlot_location').val();
194 var box_name = jQuery('#seedlot_box_name').val();
195 var accession_uniquename = jQuery('#seedlot_accession_uniquename').val();
196 var cross_uniquename = jQuery('#seedlot_cross_uniquename').val();
197 var population_name = jQuery('#seedlot_population_name').val();
198 var organization = jQuery('#seedlot_organization').val();
199 var source = jQuery("#seedlot_source").val();
200 var amount = jQuery('#seedlot_amount').val();
201 var weight = jQuery('#seedlot_weight').val();
202 var timestamp = jQuery('#seedlot_timestamp').val();
203 var transaction_description = jQuery('#seedlot_transaction_description').val();
204 var breeding_program_id = jQuery('#seedlot_breeding_program_id').val();
205 var seedlot_quality = jQuery('#seedlot_quality').val();
207 if (name == '') { alert("Please provide a name"); return; }
208 else if (location == '') { alert("Please provide a location"); return; }
209 else if (box_name == '') { alert("Please provide a box name"); return; }
210 else if (amount == '' && weight == '') { alert("Please provide a seed count amount or a weight in grams!"); return; }
211 else if (isNaN(amount)) { alert("If inputting a seed count amount, it must be a numeric value."); return; }
212 else if (isNaN(weight)) { alert("If inputting a weight, it must be a numeric value."); return; }
213 else if (breeding_program_id == '') { alert("Please select a breeding program"); return; }
214 else if (accession_uniquename == '' && cross_uniquename == '') {
215 alert("Please provide an accession name or a cross unique id as the content of the seedlot."); return;
217 else if (accession_uniquename != '' && cross_uniquename != '') {
218 alert("Please provide an accession name OR a cross unique id as the content of the seedlot. Not both."); return;
223 url: '/ajax/breeders/seedlot-create',
225 'seedlot_name' : name,
226 'seedlot_description': seedlot_description,
227 'seedlot_location': location,
228 'seedlot_box_name':box_name,
229 'seedlot_accession_uniquename': accession_uniquename,
230 'seedlot_cross_uniquename': cross_uniquename,
231 'seedlot_organization': organization,
232 'seedlot_population_name': population_name,
233 'seedlot_source': source,
234 'seedlot_amount':amount,
235 'seedlot_weight':weight,
236 'seedlot_timestamp':timestamp,
237 'seedlot_transaction_description':transaction_description,
238 'seedlot_breeding_program_id':breeding_program_id,
239 'seedlot_quality' : seedlot_quality
242 beforeSend: function(response){
243 jQuery('#working_modal').modal('show');
245 success: function(response) {
246 jQuery('#working_modal').modal('hide');
247 if (response.success == 1) {
248 alert("The seedlot has been created.");
249 jQuery('#add_seedlot_dialog').modal('hide');
250 //seedlots_table.ajax.reload();
251 //document.location.reload();
253 if (response.error) {
254 alert(response.error);
257 error: function(response){
258 jQuery('#working_modal').modal('hide');
259 alert('An error occurred creating seed lot');