8 $content_accession_name
16 $owners_string => undef
17 $maintenance_enabled => undef
18 $discard_info => undef
23 <& /util/import_javascript.mas, classes => [ 'bootstrap_min.js', 'jquery.iframe-post-form','CXGN.List','CXGN.BreedersToolbox.Accessions', 'CXGN.BreedersToolbox.UploadPedigrees', 'jquery', 'jquery.dataTables' ] &>
31 % my $edit_seedlot_link;
32 % my $new_transaction_link;
33 % if (!$discard_info) {
34 % $edit_seedlot_link = "[<a id='edit_seedlot_details_link' >Edit Seedlot Details</a>]";
35 % $new_transaction_link = "[<a id='add_seedlot_transaction_button' >Add New Transaction</a>]";
38 <& /page/page_title.mas, title => 'Seedlot '.$uniquename &>
40 <&| /page/info_section.mas, title=>"Details", collapsible => 1, collapsed=>0, subtitle=> $edit_seedlot_link &>
42 <table class="table table-bordered table-hover">
43 % if ($discard_info) {
44 <tr><td><b>Discard Info</b></td><td><% $discard_info %></td></tr>
46 <tr><td><b>Breeding Program</b></td><td><div id="seedlot_breeding_program_div">[LOADING...]</div></td></tr>
47 <tr><td><b>Seedlot Name</b></td><td><a href="/stock/<% $seedlot_id %>/view"><% $uniquename %></a></td></tr>
48 <tr><td><b>Seedlot Description</b></td><td><% $description %></td></tr>
49 <tr><td><b>Organization</b></td><td><% $organization_name %></td></tr>
50 <tr><td><b>Location Code</b><td><div id="seedlot_location_code_div">[LOADING...]</div></td></tr>
51 <tr><td><b>Box Name</b></td><td><% $box_name %></td></tr>
52 <tr><td><b>Quality issues</b></td><td><% $quality %></td></tr>
53 <tr><td><b>Contents</b></td><td><% $content_html %></td></tr>
54 <!--<tr><td><b>Population</b></td><td><% $population_name %></td></tr>-->
55 <tr><td><b>Current count</b></td><td><% $current_count %></td></tr>
56 <tr><td><b>Current weight (g)</b></td><td><% $current_weight %></td></tr>
57 <tr><td><b>Submitters</b></td><td><% $owners_string %></td></tr>
66 <&| /page/info_section.mas, title=>"Transactions Table", collapsible => 1, collapsed=>0, subtitle=>$new_transaction_link &>
68 <div style="overflow:scroll">
69 <table id="available_seedlot_transactions_table" class="table table-hover table-bordered">
75 <&| /page/info_section.mas, title=>"Mark this seedlot as DISCARDED", collapsible => 1, collapsed=>1 &>
76 % if ($user_role eq "curator" ) {
77 <div class="well well-sm">
78 <div class="panel panel-default">
79 <div class="panel-body">
80 % if ($discard_info) {
81 <button class="btn btn-sm btn-default" style="margin:3px" id ="discard_seedlot_usage_info" name = "discard_seedlot_usage_info">Usage Help <span class="glyphicon glyphicon-question-sign"></span></button><button class="btn btn-sm btn-primary" style="margin:3px" id="undo_discarding_seedlot_link">Undo Discarding this Seedlot</button>
83 <button class="btn btn-sm btn-default" style="margin:3px" id ="discard_seedlot_usage_info" name = "discard_seedlot_usage_info">Usage Help <span class="glyphicon glyphicon-question-sign"></span></button><button class="btn btn-sm btn-primary" style="margin:3px" id="discard_seedlot_details_page_link">Mark this Seedlot as DISCARDED</button>
89 You need to be logged in or you do not have sufficient privileges to mark this seedlot as DISCARDED.
93 <& /breeders_toolbox/discard_single_seedlot.mas, seedlot_id => $seedlot_id, uniquename => $uniquename &>
94 <& /breeders_toolbox/discard_undo_seedlot_usage.mas &>
96 % if ( $maintenance_enabled ) {
97 <& /page/page_title.mas, title => 'Maintenance Events' &>
99 <&| /page/info_section.mas, title=>"Events Table", collapsible=>1, collapsed=>0, subtitle=>"[<a href='/breeders/seedlot/maintenance/record?seedlot_name=$uniquename' id='add_seedlot_maintenance_button' >Record Maintenance</a>]" &>
100 <& /breeders_toolbox/seedlot_maintenance/table.mas, seedlot_id => $seedlot_id, seedlot_name => $uniquename &>
104 <div class="modal fade" id="add_seedlot_transaction_dialog" name="add_seedlot_transaction_dialog" tabindex="-1" role="dialog" aria-labelledby="seedlot_transaction_dialog">
105 <div class="modal-dialog modal-xl" role="document">
106 <div class="modal-content">
107 <div class="modal-header">
108 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
109 <h4 class="modal-title" id="seedlot_transaction_dialog">Add New Seedlot Transaction</h4>
111 <div class="modal-body">
112 <div class="container-fluid">
113 <form class="form-horizontal" role="form" method="post" id="create_new_seedlot_transaction_form" name="create_new_seedlot_transaction_form">
115 <div class="form-group">
116 <label class="col-sm-3 control-label">Transaction Type: </label>
117 <div class="col-sm-9" >
118 <select class="form-control" id="seedlot_transaction_factor">
119 <option value="1">Added to this Seedlot (<% $uniquename %>)</option>
120 <option value="-1">Taken from this Seedlot (<% $uniquename %>)</option>
125 <div id="seedlot_transaction_from_seedlot">
126 <div class="form-group">
127 <label class="col-sm-3 control-label">Taken From Existing Seedlot:<br/><small>Only showing seedlots with matching content</small></label>
128 <div class="col-sm-9" >
129 <div id="seedlot_transaction_seedlot_div"></div>
134 <div id="seedlot_transaction_to_seedlot" style="display: none">
135 <div class="form-group">
136 <label class="col-sm-3 control-label">Transferring to a new seed lot?: </label>
137 <div class="col-sm-9" >
138 <select class="form-control" id="seedlot_transaction_to_seedlot_new">
139 <option value="no">No</option>
140 <option value="yes">Yes</option>
144 <div id="seedlot_transaction_to_seedlot_new_no">
145 <div class="form-group">
146 <label class="col-sm-3 control-label">To Existing Seedlot:<br/><small>Only showing seedlots with matching content</small> </label>
147 <div class="col-sm-9" >
148 <div id="seedlot_transaction_to_seedlot_existing"></div>
152 <div id="seedlot_transaction_to_seedlot_new_yes" style="display: none">
153 <div class="well well-sm">
154 <div class="panel panel-default">
155 <div class="panel-body">
156 <div class="form-group">
157 <label class="col-sm-3 control-label">To New Seedlot: </label>
158 <div class="col-sm-9" >
160 <div class="form-group">
161 <label class="col-sm-3 control-label">Name: </label>
162 <div class="col-sm-9" >
163 <input class="form-control" id="transaction_new_seedlot_name" placeholder="Required">
166 <div class="form-group">
167 <label class="col-sm-3 control-label">Seedlot Description: </label>
168 <div class="col-sm-9" >
169 <input class="form-control" id="transaction_new_seedlot_description" placeholder="Optional">
172 <div class="form-group">
173 <label class="col-sm-3 control-label">Breeding Program: </label>
174 <div class="col-sm-9" >
175 <div id="transaction_new_seedlot_breeding_program_div"></div>
178 <div class="form-group">
179 <label class="col-sm-3 control-label">Location: </label>
180 <div class="col-sm-9" >
181 <input class="form-control" id="transaction_new_seedlot_location" placeholder="Required">
184 <div class="form-group">
185 <label class="col-sm-3 control-label">Box Name: </label>
186 <div class="col-sm-9" >
187 <input class="form-control" id="transaction_new_seedlot_box_name" placeholder="Required">
191 <div class="form-group">
192 <label class="col-sm-3 control-label">Quality issues: </label>
193 <div class="col-sm-9" >
194 <input class="form-control" id="transaction_new_seedlot_quality" placeholder="Leave blank for no issues">
198 <div class="well well-sm">
200 <div class="col-sm-3">
201 <div class="form-group">
202 <label class="col-sm-12 control-label">Contents:<br/><small>Contents must match between seedlots</small> </label>
205 <div class="col-sm-9">
206 <div class="panel panel-default">
207 <div class="panel-body">
208 <div class="form-group">
209 % if ($content_accession_name){
210 <label class="col-sm-3 control-label">Accession name: </label>
211 <div class="col-sm-9" >
212 <input class="form-control" id="transaction_new_seedlot_accession_uniquename" disabled value="<% $content_accession_name %>">
215 % if ($content_cross_name){
216 <label class="col-sm-3 control-label">Cross Unique ID: </label>
217 <div class="col-sm-9" >
218 <input class="form-control" id="transaction_new_seedlot_cross_uniquename" disabled value="<% $content_cross_name %>">
228 <div class="form-group">
229 <label class="col-sm-3 control-label">Starting Amount (number of seeds): </label>
230 <div class="col-sm-9" >
231 <input class="form-control" id="transaction_new_seedlot_amount" placeholder="Amount OR Weight Required" disabled value="0">
234 <div class="form-group">
235 <label class="col-sm-3 control-label">Starting Weight (g): </label>
236 <div class="col-sm-9" >
237 <input class="form-control" id="transaction_new_seedlot_weight" placeholder="Amount OR Weight Required" disabled value="0">
241 <div class="form-group">
242 <label class="col-sm-3 control-label">Population: </label>
243 <div class="col-sm-9" >
244 <input class="form-control" id="transaction_new_seedlot_population_name" placeholder="Optional">
248 <div class="form-group">
249 <label class="col-sm-3 control-label">Organization: </label>
250 <div class="col-sm-9" >
251 <input class="form-control" id="transaction_new_seedlot_organization" placeholder="Optional">
254 <div class="form-group">
255 <label class="col-sm-3 control-label">Timestamp: </label>
256 <div class="col-sm-9" >
257 <input class="form-control" id="transaction_new_seedlot_timestamp" value="<% $timestamp %>" placeholder="<% $timestamp %>">
260 <div class="form-group">
261 <label class="col-sm-3 control-label">Transaction Description: </label>
262 <div class="col-sm-9" >
263 <input class="form-control" id="transaction_new_seedlot_transaction_description" placeholder="Optional">
274 <div class="form-group">
275 <label class="col-sm-3 control-label">Transaction Amount (number of seeds): </label>
276 <div class="col-sm-9" >
277 <input class="form-control" id="seedlot_transaction_amount" placeholder="Amount OR Weight Required">
280 <div class="form-group">
281 <label class="col-sm-3 control-label">Transaction Weight (g): </label>
282 <div class="col-sm-9" >
283 <input class="form-control" id="seedlot_transaction_weight" placeholder="Amount OR Weight Required">
286 <div class="form-group">
287 <label class="col-sm-3 control-label">Timestamp: </label>
288 <div class="col-sm-9" >
289 <input class="form-control" id="seedlot_transaction_timestamp" value="<% $timestamp %>" placeholder="<% $timestamp %>">
292 <div class="form-group">
293 <label class="col-sm-3 control-label">Transaction Description: </label>
294 <div class="col-sm-9" >
295 <input class="form-control" id="seedlot_transaction_description" placeholder="Optional">
301 <div class="modal-footer">
302 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
303 <button id="create_new_seedlot_transaction_button" type="button" class="btn btn-primary" >Submit</button>
309 <div class="modal fade" id="edit_seedlot_transaction_dialog" name="edit_seedlot_transaction_dialog" tabindex="-1" role="dialog" aria-labelledby="seedlot_edit_transaction_dialog">
310 <div class="modal-dialog modal-lg" role="document">
311 <div class="modal-content">
312 <div class="modal-header">
313 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
314 <h4 class="modal-title" id="seedlot_edit_transaction_dialog">Edit Seedlot Transaction</h4>
316 <div class="modal-body">
317 <div class="container-fluid">
318 <div id="edit_seedlot_transaction_div">
322 <div class="modal-footer">
323 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
324 <button id="edit_seedlot_transaction_button" type="button" class="btn btn-primary" >Save</button>
330 <div class="modal fade" id="edit_seedlot_details_dialog" name="edit_seedlot_details_dialog" tabindex="-1" role="dialog" aria-labelledby="seedlot_edit_details_dialog">
331 <div class="modal-dialog modal-lg" role="document">
332 <div class="modal-content">
333 <div class="modal-header">
334 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
335 <h4 class="modal-title" id="seedlot_edit_details_dialog">Edit Seedlot Details</h4>
337 <div class="modal-body">
338 <div class="container-fluid">
339 <form class="form-horizontal">
340 <div class="form-group">
341 <label class="col-sm-3 control-label">Seedlot Name: </label>
342 <div class="col-sm-9" >
343 <input class="form-control" type="text" id="edit_seedlot_details_uniquename" value="LOADING..."/>
346 <div class="form-group">
347 <label class="col-sm-3 control-label">Seedlot Description: </label>
348 <div class="col-sm-9" >
349 <input class="form-control" type="text" id="edit_seedlot_details_description" placeholder="Optional"/>
352 <div class="form-group">
353 <label class="col-sm-3 control-label">Breeding Program: </label>
354 <div class="col-sm-9" >
355 <input class="form-control" type="text" id="edit_seedlot_details_breeding_program" value="LOADING..."/>
358 <div class="form-group">
359 <label class="col-sm-3 control-label">Organization: </label>
360 <div class="col-sm-9" >
361 <input class="form-control" type="text" id="edit_seedlot_details_organization" value="LOADING..."/>
364 <div class="form-group">
365 <label class="col-sm-3 control-label">Location Code: </label>
366 <div class="col-sm-9" >
367 <input class="form-control" type="text" id="edit_seedlot_details_location" value="LOADING..."/>
370 <div class="form-group">
371 <label class="col-sm-3 control-label">Box Name: </label>
372 <div class="col-sm-9" >
373 <input class="form-control" type="text" id="edit_seedlot_details_box_name" value="LOADING..."/>
377 <div class="form-group">
378 <label class="col-sm-3 control-label">Quality issues: </label>
379 <div class="col-sm-9" >
380 <input class="form-control" id="edit_seedlot_details_quality" placeholder="Leave blank for no issues">
384 <div class="well well-sm">
386 <div class="col-sm-3">
387 <div class="form-group">
388 <label class="col-sm-12 control-label">Contents: </label>
391 <div class="col-sm-9">
392 <div class="panel panel-default">
393 <div class="panel-body">
394 <div class="form-group">
395 <label class="col-sm-3 control-label">Accession name: </label>
396 <div class="col-sm-9" >
397 <input class="form-control" id="edit_seedlot_details_accession" placeholder="One Content Required">
402 <center><h4>OR</h4></center>
403 <div class="panel panel-default">
404 <div class="panel-body">
405 <div class="form-group">
406 <label class="col-sm-3 control-label">Cross Unique ID: </label>
407 <div class="col-sm-9" >
408 <input class="form-control" id="edit_seedlot_details_cross" placeholder="One Content Required">
418 <div class="form-group">
419 <label class="col-sm-3 control-label">Population: </label>
420 <div class="col-sm-9" >
421 <input class="form-control" type="text" id="edit_seedlot_details_population" value="LOADING..."/>
428 <div class="modal-footer">
429 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
430 <button id="edit_seedlot_details_button" type="button" class="btn btn-primary" >Save</button>
436 <div class="modal fade" id="transaction_saved_dialog_message" name="transaction_saved_dialog_message" tabindex="-1" role="dialog" aria-labelledby="transactionSavedDialog">
437 <div class="modal-dialog" role="document">
438 <div class="modal-content">
439 <div class="modal-header">
440 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
441 <h4 class="modal-title" id="transactionSavedDialog">Success</h4>
443 <div class="modal-body">
444 <div class="container-fluid">
446 <span class="ui-icon ui-icon-circle-check" style="float: left; margin: 0 7px 50px 0;"></span>
447 The transaction was saved successfully.
451 <div class="modal-footer">
452 <button id="dismiss_transaction_saved_dialog" type="button" class="btn btn-default" data-dismiss="modal">Close & Reload</button>
459 jQuery(document).ready(function () {
461 jQuery('#add_seedlot_transaction_button').click( function() {
462 get_select_box('seedlots', 'seedlot_transaction_seedlot_div', { 'name' : 'seedlot_transaction_seedlot_id', 'id' : 'seedlot_transaction_seedlot_id', 'multiple':'0', 'seedlot_content_accession_name':'<% $content_accession_name %>', 'seedlot_content_cross_name':'<% $content_cross_name %>', 'exclude_discarded': '1', 'seedlot_id':'<% $seedlot_id %>', 'exclude_self': '1' });
463 get_select_box('seedlots', 'seedlot_transaction_to_seedlot_existing', { 'name' : 'seedlot_transaction_to_seedlot_existing_id', 'id' : 'seedlot_transaction_to_seedlot_existing_id', 'multiple':'0', 'seedlot_content_accession_name':'<% $content_accession_name %>', 'seedlot_content_cross_name':'<% $content_cross_name %>', 'exclude_discarded': '1', 'seedlot_id':'<% $seedlot_id %>' });
464 get_select_box('breeding_programs', 'transaction_new_seedlot_breeding_program_div', { 'name' : 'transaction_new_seedlot_breeding_program_id', 'id' : 'transaction_new_seedlot_breeding_program_id' });
465 jQuery('#add_seedlot_transaction_dialog').modal('show')
468 jQuery("#transaction_new_seedlot_location").autocomplete({
469 source: '/ajax/stock/geolocation_autocomplete',
471 jQuery("#edit_seedlot_details_accession").autocomplete({
472 source: '/ajax/stock/accession_autocomplete',
474 jQuery("#edit_seedlot_details_cross").autocomplete({
475 source: '/ajax/stock/cross_autocomplete',
478 var status = "<% $status %>";
479 var seedlot_transactions_table = jQuery('#available_seedlot_transactions_table').DataTable( {
480 'ajax': '/ajax/breeders/seedlot/<% $seedlot_id %>/transactions',
482 { title: "Transaction Id", "data": "transaction_id" },
483 { title: "Transaction Date", "data": "timestamp" },
484 { title: "From", "data": "from" },
485 { title: "To", "data": "to" },
486 { title: "Transaction Num Seeds", "data": "value" },
487 { title: "Transaction Weight (g)", "data": "weight" },
488 { title: "Operator", "data": "operator" },
489 { title: "Transaction Description", "data": "description" },
490 { title: "Options", "data": "null", "render" : function ( data, type, row ) {
491 if (status == 'discarded') {
493 } else {return "<a onclick='editSeedlotTransaction("+row.transaction_id+")' >[Edit]</a>";}
499 url: '/ajax/breeders/seedlot/<% $seedlot_id %>',
500 success: function(response) {
501 //console.log(response);
502 if (response.success == 1) {
503 jQuery('#seedlot_location_code_div').html(response.location_code);
504 jQuery('#seedlot_breeding_program_div').html(response.breeding_program);
505 jQuery('#edit_seedlot_details_uniquename').val(response.uniquename);
506 jQuery('#edit_seedlot_details_description').val(response.description);
507 jQuery('#edit_seedlot_details_breeding_program').val(response.breeding_program);
508 jQuery('#edit_seedlot_details_organization').val(response.organization_name);
509 jQuery('#edit_seedlot_details_population').val(response.population_name);
510 jQuery('#edit_seedlot_details_location').val(response.location_code);
511 jQuery('#edit_seedlot_details_box_name').val(response.box_name);
512 jQuery('#edit_seedlot_details_quality').val(response.quality);
513 var accession_name = '';
514 if (response.accession){
515 accession_name = response.accession[1];
519 cross_name = response.cross[1];
521 jQuery('#edit_seedlot_details_accession').val(accession_name);
522 jQuery('#edit_seedlot_details_cross').val(cross_name);
524 if (response.error) {
525 alert(response.error);
528 error: function(response) {
529 alert('An error occurred retrieving seedlot details');
533 jQuery('#create_new_seedlot_transaction_button').click( function() {
534 var factor = jQuery('#seedlot_transaction_factor').val();
535 var to_new = jQuery('#seedlot_transaction_to_seedlot_new').val();
536 var from_existing_seedlot_id_array;
537 var from_existing_seedlot_id;
538 var to_existing_seedlot_id_array;
539 var to_existing_seedlot_id;
540 var to_new_seedlot_name;
541 var to_new_seedlot_description;
542 var to_new_seedlot_breeding_program_id;
543 var to_new_seedlot_location_name;
544 var to_new_seedlot_box_name;
545 var to_new_seedlot_quality;
546 var to_new_seedlot_accession_name;
547 var to_new_seedlot_cross_name;
548 var to_new_seedlot_amount;
549 var to_new_seedlot_weight;
550 var to_new_seedlot_population_name;
551 var to_new_seedlot_organization;
552 var to_new_seedlot_timestamp;
555 from_existing_seedlot_id_array = jQuery('#seedlot_transaction_seedlot_id').val();
556 if (from_existing_seedlot_id_array.length > 1) {
557 alert("Please select only one seedlot.");
560 from_existing_seedlot_id = from_existing_seedlot_id_array[0];
565 to_existing_seedlot_id_array = jQuery('#seedlot_transaction_to_seedlot_existing_id').val();
566 if (to_existing_seedlot_id_array.length > 1) {
567 alert("Please select only one seedlot.");
570 to_existing_seedlot_id = to_existing_seedlot_id_array[0];
573 if (to_new == 'yes'){
574 to_new_seedlot_name = jQuery('#transaction_new_seedlot_name').val();
575 to_new_seedlot_breeding_program_id = jQuery('#transaction_new_seedlot_breeding_program_id').val();
576 to_new_seedlot_location_name = jQuery('#transaction_new_seedlot_location').val();
577 to_new_seedlot_box_name = jQuery('#transaction_new_seedlot_box_name').val();
578 to_new_seedlot_accession_name = "<% $content_accession_name %>";
579 to_new_seedlot_cross_name = "<% $content_cross_name %>";
580 to_new_seedlot_amount = jQuery('#transaction_new_seedlot_amount').val();
581 to_new_seedlot_weight = jQuery('#transaction_new_seedlot_weight').val();
582 to_new_seedlot_population_name = jQuery('#transaction_new_seedlot_population_name').val();
583 to_new_seedlot_organization = jQuery('#transaction_new_seedlot_organization').val();
584 to_new_seedlot_timestamp = jQuery('#transaction_new_seedlot_timestamp').val();
585 to_new_seedlot_description = jQuery('#transaction_new_seedlot_description').val();
586 to_new_seedlot_quality = jQuery('#transaction_new_seedlot_quality').val();
588 if (to_new_seedlot_accession_name == '' && to_new_seedlot_cross_name == '') {
589 alert("Please provide an accession name or a cross unique id as the content of the seedlot."); return;
591 if (to_new_seedlot_accession_name != '' && to_new_seedlot_cross_name != '') {
592 alert("Please provide an accession name OR a cross unique id as the content of the seedlot. Not both."); return;
594 if (to_new_seedlot_location_name == ''){
595 alert("Please provide a location for new seedlot."); return;
597 if (to_new_seedlot_box_name == ''){
598 alert("Please provide a box name for new seedlot."); return;
600 if (to_new_seedlot_amount == '' && to_new_seedlot_weight == ''){
601 alert("Please provide a starting amount OR weight in grams for new seedlot."); return;
603 if (to_new_seedlot_timestamp == ''){
604 alert("Please provide a timestamp for new seedlot created."); return;
608 var amount = jQuery('#seedlot_transaction_amount').val();
609 var weight = jQuery('#seedlot_transaction_weight').val();
610 var timestamp = jQuery('#seedlot_transaction_timestamp').val();
611 var transaction_description = jQuery('#seedlot_transaction_description').val();
613 if (factor == '') { alert("Please provide a factor"); }
614 else if (amount == '' && weight == '') { alert("Please provide an amount OR a weight in grams"); }
615 else if (timestamp == '') { alert("Please provide a timestamp"); }
616 else if (from_existing_seedlot_id == '' && to_existing_seedlot_id == '' && to_new_seedlot_name == '') { alert("Please provide seed lot"); }
620 url: '/ajax/breeders/seedlot/<% $seedlot_id %>/transaction/add',
623 'seedlot_id': <% $seedlot_id %>,
626 'timestamp': timestamp,
627 'transaction_description': transaction_description,
628 'from_existing_seedlot_id': from_existing_seedlot_id,
629 'to_existing_seedlot_id': to_existing_seedlot_id,
630 'to_new_seedlot_name' : to_new_seedlot_name,
631 'to_new_seedlot_breeding_program_id': to_new_seedlot_breeding_program_id,
632 'to_new_seedlot_location_name': to_new_seedlot_location_name,
633 'to_new_seedlot_box_name': to_new_seedlot_box_name,
634 'to_new_seedlot_accession_name': to_new_seedlot_accession_name,
635 'to_new_seedlot_cross_name': to_new_seedlot_cross_name,
636 'to_new_seedlot_amount': to_new_seedlot_amount,
637 'to_new_seedlot_weight': to_new_seedlot_weight,
638 'to_new_seedlot_population_name': to_new_seedlot_population_name,
639 'to_new_seedlot_organization': to_new_seedlot_organization,
640 'to_new_seedlot_timestamp': to_new_seedlot_timestamp,
641 'to_new_seedlot_description': to_new_seedlot_description,
642 'to_new_seedlot_quality': to_new_seedlot_quality
644 beforeSend: function(){
645 jQuery('#working_modal').modal('show');
647 success: function(response) {
648 jQuery('#working_modal').modal('hide');
649 if (response.success == 1) {
650 jQuery('#add_seedlot_transaction_dialog').modal('hide');
651 jQuery('#transaction_saved_dialog_message').modal('show');
652 seedlot_transactions_table.ajax.reload();
654 if (response.error) {
655 alert(response.error);
658 error: function(response) {
659 jQuery('#working_modal').modal('hide');
660 alert('An error occurred creating seedlot transaction');
666 jQuery('#seedlot_transaction_factor').change(function(){
667 var transaction_factor = jQuery('#seedlot_transaction_factor').val();
668 if (transaction_factor == 1){
669 jQuery('#seedlot_transaction_to_seedlot').hide();
670 jQuery('#seedlot_transaction_from_seedlot').show();
672 if (transaction_factor == -1){
673 jQuery('#seedlot_transaction_from_seedlot').hide();
674 jQuery('#seedlot_transaction_to_seedlot').show();
678 jQuery('#seedlot_transaction_to_seedlot_new').change(function(){
679 var option = jQuery('#seedlot_transaction_to_seedlot_new').val();
680 if (option == 'yes'){
681 jQuery('#seedlot_transaction_to_seedlot_new_no').hide();
682 jQuery('#seedlot_transaction_to_seedlot_new_yes').show();
685 jQuery('#seedlot_transaction_to_seedlot_new_no').show();
686 jQuery('#seedlot_transaction_to_seedlot_new_yes').hide();
690 jQuery('#edit_seedlot_transaction_button').click(function(){
691 var transaction_id = jQuery('#edit_seedlot_transaction_id').val();
692 var operator = jQuery('#edit_seedlot_transaction_operator').val();
693 var amount = jQuery('#edit_seedlot_transaction_amount').val();
694 var weight = jQuery('#edit_seedlot_transaction_weight').val();
695 var transaction_description = jQuery('#edit_seedlot_transaction_description').val();
696 var timestamp = jQuery('#edit_seedlot_transaction_timestamp').val();
697 if (transaction_id == ''){
698 alert('Transaction ID must not be blank');
699 } else if (operator == ''){
700 alert('Operator must not be blank');
701 } else if (amount == '' && weight == ''){
702 alert('Amount OR weight must not be blank');
703 } else if (timestamp == ''){
704 alert('Timestamp must not be blank');
707 url: '/ajax/breeders/seedlot/<% $seedlot_id %>/transaction/'+transaction_id+'/edit',
711 'weight_gram':weight,
712 'description':transaction_description,
713 'timestamp':timestamp
715 beforeSend: function(){
716 jQuery('#working_modal').modal('show');
718 success: function(response) {
719 jQuery('#working_modal').modal('hide');
720 if (response.success == 1) {
721 jQuery('#edit_seedlot_transaction_dialog').modal('hide');
722 jQuery('#transaction_saved_dialog_message').modal('show');
723 seedlot_transactions_table.ajax.reload();
725 if (response.error) {
726 alert(response.error);
729 error: function(response) {
730 jQuery('#working_modal').modal('hide');
731 alert('An error occurred editing seedlot transaction details');
737 jQuery('#edit_seedlot_details_link').click(function(){
738 jQuery('#edit_seedlot_details_dialog').modal('show');
741 jQuery('#edit_seedlot_details_button').click(function(){
742 var uniquename = jQuery('#edit_seedlot_details_uniquename').val();
743 var description = jQuery('#edit_seedlot_details_description').val();
744 var breeding_program = jQuery('#edit_seedlot_details_breeding_program').val();
745 var organization = jQuery('#edit_seedlot_details_organization').val();
746 var population = jQuery('#edit_seedlot_details_population').val();
747 var location = jQuery('#edit_seedlot_details_location').val();
748 var box_name = jQuery('#edit_seedlot_details_box_name').val();
749 var quality = jQuery('#edit_seedlot_details_quality').val();
750 var accession = jQuery('#edit_seedlot_details_accession').val();
751 var cross = jQuery('#edit_seedlot_details_cross').val();
752 if (uniquename == ''){
753 alert('Seedlot name must not be blank');
754 } else if (breeding_program == ''){
755 alert('Breeding program must not be blank');
756 } else if (location == ''){
757 alert('Location must not be blank');
758 } else if (accession == '' && cross == '') {
759 alert("Please provide an accession name or a cross unique id as the content of the seedlot."); return;
761 else if (accession != '' && cross != '') {
762 alert("Please provide an accession name OR a cross unique id as the content of the seedlot. Not both."); return;
766 url: '/ajax/breeders/seedlot/<% $seedlot_id %>/edit',
768 'uniquename':uniquename,
769 'description':description,
770 'breeding_program':breeding_program,
771 'organization':organization,
772 'population':population,
776 'accession':accession,
779 beforeSend: function(){
780 jQuery('#working_modal').modal('show');
782 success: function(response) {
783 jQuery('#working_modal').modal('hide');
784 if (response.success == 1) {
785 alert('Seedlot updated!');
786 document.location.reload();
788 if (response.error) {
789 alert(response.error);
792 error: function(response) {
793 jQuery('#working_modal').modal('hide');
794 alert('An error occurred editing seedlot details');
800 jQuery('#dismiss_transaction_saved_dialog').click(function(){
806 function editSeedlotTransaction(transaction_id){
808 url: '/ajax/breeders/seedlot/<% $seedlot_id %>/transaction/'+transaction_id,
809 beforeSend: function(){
810 jQuery('#working_modal').modal('show');
812 success: function(response) {
813 jQuery('#working_modal').modal('hide');
814 if (response.success == 1) {
815 html = '<form class="form-horizontal"><div class="form-group"><label class="col-sm-3 control-label">Transaction ID: </label><div class="col-sm-9" ><input type="text" class="form-control" id="edit_seedlot_transaction_id" value="'+response.transaction_id+'" disabled /></div></div><div class="form-group"><label class="col-sm-3 control-label">Operator: </label><div class="col-sm-9" ><input type="text" id="edit_seedlot_transaction_operator" class="form-control" value="'+response.operator+'" /></div></div><div class="form-group"><label class="col-sm-3 control-label">Transaction Type: </label><div class="col-sm-9" ><input type="text" class="form-control" id="edit_seedlot_transaction_type" value="'+response.transaction_type+'" disabled/></div></div><div class="form-group"><label class="col-sm-3 control-label">Amount (Number of seeds): </label><div class="col-sm-9" ><input type="number" class="form-control" id="edit_seedlot_transaction_amount" value="'+response.amount+'" /></div></div><div class="form-group"><label class="col-sm-3 control-label">Weight (g): </label><div class="col-sm-9" ><input type="text" class="form-control" id="edit_seedlot_transaction_weight" value="'+response.weight_gram+'" /></div></div><div class="form-group"><label class="col-sm-3 control-label">Timestamp: </label><div class="col-sm-9" ><input type="text" class="form-control" id="edit_seedlot_transaction_timestamp" value="'+response.timestamp+'" disabled /></div></div><div class="form-group"><label class="col-sm-3 control-label">Transaction Description: </label><div class="col-sm-9" ><input type="text" class="form-control" id="edit_seedlot_transaction_description" value="'+response.description+'" /></div></div></form>';
816 jQuery('#edit_seedlot_transaction_div').html(html);
817 jQuery('#edit_seedlot_transaction_dialog').modal('show');
819 if (response.error) {
820 alert(response.error);
823 error: function(response){
824 jQuery('#working_modal').modal('hide');
825 alert('An error occurred getting seedlot transaction');