2 $sampling_facilities => ();
5 <& /util/import_javascript.mas, classes => [ 'CXGN.BreedersToolbox.GenotypingTrial' ] &>
8 <div class="modal fade" id="sampling_trial_dialog" name="sampling_trial_dialog" tabindex="-1" role="dialog" aria-labelledby="addSamplingTrialDialog">
9 <div class="modal-dialog modal-xl" role="document">
10 <div class="modal-content">
11 <div class="modal-header">
12 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
13 <h4 class="modal-title" id="addSamplingTrialDialog">Add Sampling Trial</h4>
15 <div class="modal-body">
16 <form class="form-horizontal" role="form" method="post" enctype="multipart/form-data" encoding="multipart/form-data" id="upload_sampling_trials_form" name="upload_sampling_trials_form" >
18 <div class="container-fluid">
20 <&| /util/workflow.mas, id=> "sampling_trial_create_workflow" &>
21 <&| /util/workflow.mas:step, title=> "Intro" &>
22 <& /page/page_title.mas, title=>"This workflow will guide you through adding a sampling trial in the database" &>
23 <p>Sampling trials can represent 96 or 384 well plates, or more generically any sampling scheme.</p>
24 <p>Each sample has a globally unique tissue sample ID.</p>
25 <p>The "contents" of each sample can be either a tissue sample, plant name, plot name, or accession name. This "source" name must be in the database already. This is useful if you provide a field trial entity (such as a plot or plant or tissue sample name), so that phenotypes and genotypes can be directly compared.</p>
29 <button class="btn btn-primary" onclick="Workflow.complete(this); return false;">Go to Next Step</button>
33 <&| /util/workflow.mas:step, title=> "Basic Info" &>
34 <& /page/page_title.mas, title=>"Provide info about your sampling trial" &>
36 <div class="form-group">
37 <label class="col-sm-5 control-label">Sampling Facility: </label>
38 <div class="col-sm-7">
39 <select class="form-control" id="sampling_trial_facility_select">
40 % foreach my $facility(@$sampling_facilities){
41 <option value="<%$facility%>"><%$facility%></option>
46 <div class="form-group">
47 <label class="col-sm-5 control-label">Sampling Trial Name: </label>
48 <div class="col-sm-7">
49 <input class="form-control" id="sampling_trial_name" name="sampling_trial_name" type="text" placeholder=" e.g. 18DNA00001"/>
52 <div class="form-group">
53 <label class="col-sm-5 control-label">Sample Type: </label>
54 <div class="col-sm-7">
55 <select class="form-control" id="sampling_trial_plate_sample_type">
56 <option value="Tissue">Tissue</option>
57 <option value="DNA">DNA</option>
58 <option value="RNA">RNA</option>
62 <div class="form-group">
63 <label class="col-sm-5 control-label">Sampling Trial's Breeding Program: </label>
64 <div class="col-sm-7">
65 <span id="sampling_trial_breeding_program_select_div"></span>
68 <div class="form-group">
69 <label class="col-sm-5 control-label">Sampling Trial's Location: </label>
70 <div class="col-sm-7">
71 <span id="sampling_trial_location_select_div"></span>
74 <div class="form-group">
75 <label class="col-sm-5 control-label">Sampling Trial's Year: </label>
76 <div class="col-sm-7">
77 <span id="sampling_trial_year_select_div"></span>
80 <div class="form-group">
81 <label class="col-sm-5 control-label">Sampling Trials's Description: </label>
82 <div class="col-sm-7">
83 <textarea class="form-control" id="sampling_trial_description" name="sampling_trial_description" maxlength="250"></textarea>
89 <button class="btn btn-primary" onclick="Workflow.complete(this); return false;">Go to Next Step</button>
92 <&| /util/workflow.mas:step, title=> "Samples Info" &>
93 <& /page/page_title.mas, title=>"Provide information about the samples" &>
96 <div class="form-group">
97 <label class="col-sm-3 control-label">Select One: </label>
98 <div class="col-sm-9">
99 <select class="form-control" id="sampling_trial_well_input_option">
100 <option value="xls">I am uploading a sampling design I made in Excel</option>
101 <option value="design">I need to design a completely new sampling trial</option>
106 <div id="sampling_trial_well_upload_section">
107 <h3>You want to upload an existing samples layout</h3>
109 <div class="well well-sm">
111 <div class="col-sm-4">
112 <&| /page/explanation.mas, title=>'Template information' &>
114 <b>File format information</b>
116 <a id="sampling_trial_layout_upload_spreadsheet_info_format">Spreadsheet format</a>
120 <div class="col-sm-8">
122 <div class="panel panel-default">
123 <div class="panel-body">
124 <div class="form-group">
125 <label class="col-sm-6 control-label">Select Samples Layout XLSX (or XLS) File: </label>
126 <div class="col-sm-6">
127 <input type="file" name="sampling_trial_layout_upload" id="sampling_trial_layout_upload" encoding="multipart/form-data" />
138 <div id="sampling_trial_well_design_section" style="display:none">
139 <h3>You want to design a completely new sampling trial.</h3>
141 <div class="well well-sm">
143 <li>Select a list for the source material of each tissue sample. Then indicate how many replicates are required.</li>
144 <li>Note: From the most desirable to least desirable source observation unit you can choose: tissue samples, plants, plots, or accessions</li>
147 <div class="form-group">
148 <label class="col-sm-7 control-label">Source Observation Unit List: </label>
149 <div class="col-sm-5">
150 <span id="sampling_trial_accession_select_box_span">[loading...]</span>
153 <div class="form-group">
154 <label class="col-sm-7 control-label">Replicates: </label>
155 <div class="col-sm-5">
156 <input class="form-control" id="sampling_trial_replicates" name="sampling_trial_replicates" type="number" placeholder="1"/>
159 <div class="form-group form-group-sm">
160 <label class="col-sm-7 control-label"><i>Optional</i> Sample Concentration (ng/ul): <small>(If you used the same conc for all samples)</small></label>
161 <div class="col-sm-5">
162 <input class="form-control" id="sampling_trial_concentration" name="sampling_trial_concentration" type="text" />
165 <div class="form-group form-group-sm">
166 <label class="col-sm-7 control-label"><i>Optional</i> Sampling Volume (ul): <small>(If you used the same vol for all samples)</small></label>
167 <div class="col-sm-5">
168 <input class="form-control" id="sampling_trial_volume" name="sampling_well_volume" type="text" />
171 <div class="form-group form-group-sm">
172 <label class="col-sm-7 control-label"><i>Optional</i> Tissue: <small>(If used the same tissue for all samples)</small> </label>
173 <div class="col-sm-5">
174 <select class="form-control" id="sampling_trial_tissue">
175 <option value="leaf">Leaf</option>
176 <option value="root">Root</option>
177 <option value="stem">Stem</option>
178 <option value="seed">Seed</option>
179 <option value="fruit">Fruit</option>
180 <option value="tuber">Tuber</option>
184 <div class="form-group form-group-sm">
185 <label class="col-sm-7 control-label"><i>Optional</i> NCBI Taxonomy ID: <small>(Official NCBI ID.)</small> </label>
186 <div class="col-sm-5">
187 <input class="form-control" id="sampling_trial_ncbi_taxonomy_id" name="sampling_trial_ncbi_taxonomy_id" type="text" />
190 <div class="form-group form-group-sm">
191 <label class="col-sm-7 control-label"><i>Optional</i> Extraction: <small>(If used the same extraction for all samples)</small> </label>
192 <div class="col-sm-5">
193 <input class="form-control" id="sampling_trial_extraction" name="sampling_trial_extraction" type="text" />
196 <div class="form-group form-group-sm">
197 <label class="col-sm-7 control-label"><i>Optional</i> Person: <small>(If same person prepared all samples.)</small> </label>
198 <div class="col-sm-5">
199 <input class="form-control" id="sampling_trial_person" name="sampling_trial_person" type="text" />
202 <div class="form-group form-group-sm">
203 <label class="col-sm-7 control-label"><i>Optional</i> Date: <small>(If sampled on same date. YYYY/MM/DD)</small> </label>
204 <div class="col-sm-5">
205 <input class="form-control" id="sampling_trial_date" name="sampling_trial_date" type="text" placeholder="YYYY/MM/DD"/>
208 <div class="form-group form-group-sm">
209 <label class="col-sm-7 control-label"><i>Optional</i> Notes: <small>(Additional notes for these samples.)</small> </label>
210 <div class="col-sm-5">
211 <input class="form-control" id="sampling_trial_notes" name="sampling_trial_notes" type="text" />
218 <button class="btn btn-primary" onclick="Workflow.complete(this); return false;">Go to Next Step</button>
221 <&| /util/workflow.mas:step, title=> "Linkage" &>
222 <& /page/page_title.mas, title=>"Is your sampling trial linked with field trials in the database? This information can also be added from the sampling trial detail page once the trial is saved in the database." &>
224 <p>If you provided us with information about where the sample originated (e.g. it came from a plot name or plant name or tissue sample name in a field trial), we will automatically create linkage between the field trial(s) and this sampling trial.</p>
228 <button class="btn btn-lg btn-primary" onclick="Workflow.complete(this); return false;" >Continue to Next Step</button>
231 <&| /util/workflow.mas:step, title=> "Confirm" &>
232 <& /page/page_title.mas, title=>"Finalize and submit your sampling trial" &>
236 <button type="button" class="btn btn-primary" name="add_sampling_trial_submit" id="add_sampling_trial_submit">Submit</button>
239 <&| /util/workflow.mas:complete, title=> "Complete" &>
240 <& /page/page_title.mas, title=>"Complete! Your sampling trial was saved in the database." &>
243 <span class="ui-icon ui-icon-circle-check" style="float: left; margin: 0 7px 50px 0;"></span>
244 The sampling trial was saved successfully
253 <div class="modal-footer">
254 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
260 <div class="modal fade" id="sampling_trial_layout_upload_spreadsheet_info_format_dialog" name="sampling_trial_layout_upload_spreadsheet_info_format_dialog" tabindex="-1" role="dialog" aria-labelledby="uploadSamplingTrialInfoDialog">
261 <div class="modal-dialog modal-xl" role="document">
262 <div class="modal-content">
263 <div class="modal-header" style="text-align: center">
264 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
265 <h4 class="modal-title" id="uploadSamplingTrialInfoDialog">Upload Template Information</h4>
267 <div class="modal-body">
268 <div class="container-fluid">
269 <b>This is for uploading a pre-existing sampling trial layout.</b>
271 <b>File must be Excel file (.xls or .xlsx)</b>
275 The first row (header) must contain the following:
277 <table class="table table-hover table-bordered table-condensed" >
283 <td>source_observation_unit_name</td>
284 <td>sample_number</td>
287 <td>ncbi_taxonomy_id</td>
291 <td>concentration</td>
297 <b>Required fields:</b>
299 <li>date (should be YYYY-MM-DD)</li>
300 <li>sample_name (the globally unique identifier for the sample)</li>
301 <li>source_observation_unit_name (must exist in the database. the identifier of the origin material. in order of most desirable identifier to least desirable identifier that can be used here: tissue sample name, plant name, plot name, accession name. For blank wells, you can write BLANK here and place a 1 in the is_blank column also.)</li>
302 <li>sample_number (the sample number for the sample. Must be unique within this sampling trial)</li>
303 <li>replicate (the replicate number for the sample)</li>
304 <li>tissue_type (must be either leaf, root, stem, seed, fruit or tuber)</li>
307 <b>Optional fields:</b>
309 <li>ncbi_taxonomy_id (NCBI taxonomy identifier)</li>
310 <li>person (the name of the person who prepared the sample)</li>
311 <li>notes (any additional notes on the sample)</li>
312 <li>extraction (free-text for the extraction method e.g. CTAB)</li>
313 <li>concentration (concentration in ng/ul)</li>
314 <li>volume (volume in ul)</li>
319 <div class="modal-footer">
320 <button id="close_upload_sampling_spreadsheet_info_dialog" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
327 jQuery(document).ready(function(){
329 jQuery('button[name="create_sampling_trial_button"]').click(function(){
330 jQuery('#sampling_trial_dialog').modal('show');
333 jQuery('#sampling_trial_dialog').on('show.bs.modal', function (e) {
334 get_select_box("locations", "sampling_trial_location_select_div", {'id':'sampling_trial_location_select', 'name':'sampling_trial_location_select'});
335 get_select_box("breeding_programs", "sampling_trial_breeding_program_select_div", {'id':'sampling_trial_breeding_program_select', 'name':'sampling_trial_breeding_program_select'});
336 get_select_box("years", "sampling_trial_year_select_div", {'auto_generate': 1, 'id':'sampling_trial_year_select', 'name':'sampling_trial_year_select'});
338 var l = new CXGN.List();
339 var html = l.listSelect('sampling_trial_accession_select_box', [ 'accessions', 'plots', 'plants', 'tissue_samples' ], undefined, undefined, undefined);
340 jQuery('#sampling_trial_accession_select_box_span').html(html);
343 jQuery('#sampling_trial_layout_upload_spreadsheet_info_format').click(function(){
344 jQuery('#sampling_trial_layout_upload_spreadsheet_info_format_dialog').modal('show');
347 jQuery('#sampling_trial_well_input_option').change(function(){
348 if (jQuery(this).val() == 'xls'){
349 jQuery("#sampling_trial_well_upload_section").show();
350 jQuery("#sampling_trial_well_design_section").hide();
352 if (jQuery(this).val() == 'design' ){
353 jQuery("#sampling_trial_well_design_section").show();
354 jQuery("#sampling_trial_well_upload_section").hide();
355 jQuery('#sampling_trial_layout_upload').val('');
359 var sampling_data = new Object();
360 jQuery('#add_sampling_trial_submit').click(function () {
361 sampling_data = new Object();
362 sampling_data.breeding_program = jQuery('#sampling_trial_breeding_program_select').val();
363 sampling_data.year = jQuery('#sampling_trial_year_select').val();
364 sampling_data.sampling_facility = jQuery('#sampling_trial_facility_select').val();
365 sampling_data.location = jQuery('#sampling_trial_location_select').val();
366 sampling_data.description = jQuery('#sampling_trial_description').val();
367 sampling_data.replicates = jQuery('#sampling_trial_replicates').val();
368 sampling_data.name = jQuery('#sampling_trial_name').val();
369 sampling_data.sample_type = jQuery('#sampling_trial_plate_sample_type').val();
370 sampling_data.sample_concentration = jQuery('#sampling_trial_concentration').val();
371 sampling_data.ncbi_taxonomy_id = jQuery('#sampling_trial_ncbi_taxonomy_id').val();
372 sampling_data.sample_extraction = jQuery('#sampling_trial_extraction').val();
373 sampling_data.sample_date = jQuery('#sampling_trial_date').val();
374 sampling_data.sample_person = jQuery('#sampling_trial_person').val();
375 sampling_data.sample_volume = jQuery('#sampling_trial_volume').val();
376 sampling_data.sample_tissue = jQuery('#sampling_trial_tissue').val();
377 sampling_data.sample_notes = jQuery('#sampling_trial_notes').val();
379 if (sampling_data.breeding_program == '') {
380 alert("A breeding program is required. Please try again.");
383 if (sampling_data.year == '') {
384 alert("A year is required. Please try again.");
387 if (sampling_data.location == '') {
388 alert("A location is required. Please try again.");
391 if (sampling_data.name == '') {
392 alert("A sampling trial name is required and it should be unique in the database. Please try again.");
395 if (sampling_data.description == '') {
396 alert("A sampling trial description is required. Please try again.");
399 if (sampling_data.sample_type == '') {
400 alert("A sampling trial type is required. Please try again.");
403 if (sampling_data.replicates == '') {
404 sampling_data.replicates = 1;
407 var uploadFileXLS = jQuery("#sampling_trial_layout_upload").val();
408 if (uploadFileXLS === ''){
409 sampling_data.list_id = jQuery('#sampling_trial_accession_select_box_list_select').val();
410 var l = new CXGN.List();
411 if (! l.validate(sampling_data.list_id, 'accessions', true) && ! l.validate(sampling_data.list_id, 'plots', true) && ! l.validate(sampling_data.list_id, 'plants', true) && ! l.validate(sampling_data.list_id, 'tissue_samples', true)) {
412 alert('The list contains elements that are not accessions or plots or plants or tissue_samples.');
415 var elements = l.getList(sampling_data.list_id);
416 if (typeof elements == 'undefined' ) {
417 alert("There are no elements in the list provided.");
420 sampling_data.elements = elements;
423 url: '/ajax/breeders/generatesamplingtrial',
425 beforeSend: function(){
426 jQuery("working_modal").modal('show');
429 'sampling_data': JSON.stringify(sampling_data)
431 success : function(response) {
432 console.log(response);
433 jQuery("working_modal").modal('hide');
434 if (response.error) {
435 alert(response.error);
438 sampling_data.design = response.design;
439 store_sampling_trial(sampling_data);
442 error: function(response) {
443 alert('An error occurred trying the create the sampling trial layout.');
444 jQuery("working_modal").modal('hide');
449 jQuery('#upload_sampling_trials_form').attr("action", "/ajax/breeders/parsesamplingtrial");
450 jQuery("#upload_sampling_trials_form").submit();
454 jQuery('#upload_sampling_trials_form').iframePostForm({
458 complete: function (response) {
459 console.log(response);
460 if (response.error) {
461 alert(response.error);
464 if (response.error_string) {
465 alert(response.error_string);
468 if (response.success) {
469 sampling_data.design = response.design;
470 store_sampling_trial(sampling_data);
475 function store_sampling_trial(sampling_data) {
477 url: '/ajax/breeders/storesamplingtrial',
479 beforeSend: function(){
480 jQuery("#working_modal").modal('show');
483 'sampling_data': JSON.stringify(sampling_data)
485 success : function(response) {
486 jQuery("#working_modal").modal('hide');
487 if (response.error) {
488 alert(response.error);
491 alert(response.message);
492 Workflow.complete('#add_sampling_trial_submit');
493 Workflow.focus("#sampling_trial_create_workflow", -1); //Go to success page
494 Workflow.check_complete("#sampling_trial_create_workflow");
497 error: function(response) {
498 alert('An error occurred trying the create the layout.');
499 jQuery("#working_modal").modal('hide');