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">Breeding Program: </label>
26 <div class="col-sm-9" >
27 <div id="seedlot_breeding_program_div"></div>
30 <div class="form-group">
31 <label class="col-sm-3 control-label">Location: </label>
32 <div class="col-sm-9" >
33 <input class="form-control" id="seedlot_location" placeholder="Required">
36 <div class="form-group">
37 <label class="col-sm-3 control-label">Box Name: </label>
38 <div class="col-sm-9" >
39 <input class="form-control" id="seedlot_box_name" placeholder="Required">
43 <div class="well well-sm">
45 <div class="col-sm-3">
46 <div class="form-group">
47 <label class="col-sm-12 control-label">Contents: </label>
50 <div class="col-sm-9">
51 % if ($accession_uniquename || $cross_uniquename){
52 <div class="panel panel-default">
53 <div class="panel-body">
54 <div class="form-group">
55 <label class="col-sm-3 control-label">Accession name: </label>
56 <div class="col-sm-9" >
57 <input class="form-control" id="seedlot_accession_uniquename" placeholder="One Content Required" disabled value="<% $accession_uniquename %>">
62 <center><h4>OR</h4></center>
63 <div class="panel panel-default">
64 <div class="panel-body">
65 <div class="form-group">
66 <label class="col-sm-3 control-label">Cross Unique ID: </label>
67 <div class="col-sm-9" >
68 <input class="form-control" id="seedlot_cross_uniquename" placeholder="One Content Required" disabled value="<% $cross_uniquename %>">
74 <div class="panel panel-default">
75 <div class="panel-body">
76 <div class="form-group">
77 <label class="col-sm-3 control-label">Accession name: </label>
78 <div class="col-sm-9" >
79 <input class="form-control" id="seedlot_accession_uniquename" placeholder="One Content Required">
84 <center><h4>OR</h4></center>
85 <div class="panel panel-default">
86 <div class="panel-body">
87 <div class="form-group">
88 <label class="col-sm-3 control-label">Cross Unique ID: </label>
89 <div class="col-sm-9" >
90 <input class="form-control" id="seedlot_cross_uniquename" placeholder="One Content Required">
100 <div class="form-group">
101 <label class="col-sm-3 control-label">Amount (number of seeds): </label>
102 <div class="col-sm-9" >
103 <input class="form-control" id="seedlot_amount" placeholder="Amount OR Weight(g) Required">
106 <div class="form-group">
107 <label class="col-sm-3 control-label">Weight (g): </label>
108 <div class="col-sm-9" >
109 <input class="form-control" id="seedlot_weight" placeholder="Amount OR Weight(g) Required">
113 <div class="form-group">
114 <label class="col-sm-3 control-label">Population: </label>
115 <div class="col-sm-9" >
116 <input class="form-control" id="seedlot_population_name" placeholder="Optional">
120 <div class="form-group">
121 <label class="col-sm-3 control-label">Organization: </label>
122 <div class="col-sm-9" >
123 <input class="form-control" id="seedlot_organization" placeholder="Optional">
126 <div class="form-group">
127 <label class="col-sm-3 control-label">Timestamp: </label>
128 <div class="col-sm-9" >
129 <input class="form-control" id="seedlot_timestamp" value="<% $timestamp %>" placeholder="<% $timestamp %>">
132 <div class="form-group">
133 <label class="col-sm-3 control-label">Description: </label>
134 <div class="col-sm-9" >
135 <input class="form-control" id="seedlot_description" placeholder="Optional">
141 <div class="modal-footer">
142 <button id="create_new_seedlot_button" type="button" class="btn btn-primary" >OK</button>
149 jQuery(document).ready(function(){
151 jQuery("#seedlot_location").autocomplete({
152 source: '/ajax/stock/geolocation_autocomplete',
154 jQuery("#seedlot_accession_uniquename").autocomplete({
155 source: '/ajax/stock/accession_autocomplete',
157 jQuery("#seedlot_cross_uniquename").autocomplete({
158 source: '/ajax/stock/cross_autocomplete',
161 jQuery('[name="add_seedlot_button"]').click( function() {
162 jQuery('#add_seedlot_dialog').modal('show');
163 get_select_box('breeding_programs', 'seedlot_breeding_program_div', { 'name' : 'seedlot_breeding_program_id', 'id' : 'seedlot_breeding_program_id' });
166 jQuery('#create_new_seedlot_button').click( function() {
167 var name = jQuery('#seedlot_name').val();
168 var location = jQuery('#seedlot_location').val();
169 var box_name = jQuery('#seedlot_box_name').val();
170 var accession_uniquename = jQuery('#seedlot_accession_uniquename').val();
171 var cross_uniquename = jQuery('#seedlot_cross_uniquename').val();
172 var population_name = jQuery('#seedlot_population_name').val();
173 var organization = jQuery('#seedlot_organization').val();
174 var amount = jQuery('#seedlot_amount').val();
175 var weight = jQuery('#seedlot_weight').val();
176 var timestamp = jQuery('#seedlot_timestamp').val();
177 var description = jQuery('#seedlot_description').val();
178 var breeding_program_id = jQuery('#seedlot_breeding_program_id').val();
180 if (name == '') { alert("Please provide a name"); return; }
181 else if (location == '') { alert("Please provide a location"); return; }
182 else if (box_name == '') { alert("Please provide a box name"); return; }
183 else if (amount == '' && weight == '') { alert("Please provide an seed count amount or a weight in grams!"); return; }
184 else if (breeding_program_id == '') { alert("Please select a breeding program"); return; }
185 else if (accession_uniquename == '' && cross_uniquename == '') {
186 alert("Please provide an accession name or a cross unique id as the content of the seedlot."); return;
188 else if (accession_uniquename != '' && cross_uniquename != '') {
189 alert("Please provide an accession name OR a cross unique id as the content of the seedlot. Not both."); return;
194 url: '/ajax/breeders/seedlot-create',
196 'seedlot_name' : name,
197 'seedlot_location': location,
198 'seedlot_box_name':box_name,
199 'seedlot_accession_uniquename': accession_uniquename,
200 'seedlot_cross_uniquename': cross_uniquename,
201 'seedlot_organization': organization,
202 'seedlot_population_name': population_name,
203 'seedlot_amount':amount,
204 'seedlot_weight':weight,
205 'seedlot_timestamp':timestamp,
206 'seedlot_description':description,
207 'seedlot_breeding_program_id':breeding_program_id
209 beforeSend: function(response){
210 jQuery('#working_modal').modal('show');
212 success: function(response) {
213 jQuery('#working_modal').modal('hide');
214 if (response.success == 1) {
215 alert("The seedlot has been created.");
216 jQuery('#add_seedlot_dialog').modal('hide');
217 //seedlots_table.ajax.reload();
218 //document.location.reload();
220 if (response.error) {
221 alert(response.error);
224 error: function(response){
225 jQuery('#working_modal').modal('hide');
226 alert('An error occurred creating seed lot');