9 if ($user && $user->check_roles("curator")) {
14 <& /page/page_title.mas, title=>"Manage Breeding Programs" &>
16 <div class="container-fluid">
19 <table class="table table-condensed table-striped table-hover">
24 if ($delete_flag) { print "<th>Name</th><th>Info</th><th>Delete</th>"; }
25 else { print "<th>Name</th><th>Info</th>"; }
33 foreach my $bp (@$breeding_programs) {
35 print "<tr><td><b>$bp->[1]</b></td><td>$bp->[2]</td>";
38 print "<td><a title=\"delete this breeding program\" id=\"delete_breeding_program_link\_".$bp->[1]."\" href=\"javascript:delete_breeding_program($bp->[0])\" ><font color=\"red\">X</font></a></td></tr>";
49 <button type="button" class="btn btn-primary" name="new_breeding_program_link" id="new_breeding_program_link">Add New Program</button>
53 <!-- Modal Dialogs Below Here -->
55 <div class="modal fade" id="new_breeding_program_dialog" name="new_breeding_program_dialog" tabindex="-1" role="dialog" aria-labelledby="addBreedingProgramDialog">
56 <div class="modal-dialog" role="document">
57 <div class="modal-content">
58 <div class="modal-header">
59 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
60 <h4 class="modal-title" id="addBreedingProgramDialog">Add New Breeding Program</h4>
62 <div class="modal-body">
63 <div class="container-fluid">
64 <form class="form-horizontal" role="form" name="new_breeding_program_form" id="new_breeding_program_form">
65 <div class="form-group">
66 <label class="col-sm-2 control-label">Name: </label>
67 <div class="col-sm-10">
68 <input class="form-control" name="new_breeding_program_name" id="new_breeding_program_name" type="text" />
71 <div class="form-group">
72 <label class="col-sm-2 control-label">Description: </label>
73 <div class="col-sm-10">
74 <input class="form-control" name="new_breeding_program_desc" id="new_breeding_program_desc" type="text" />
80 <div class="modal-footer">
81 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
82 <button type="button" class="btn btn-primary" name="new_breeding_program_submit" id="new_breeding_program_submit">Add Breeding Program</button>
89 <div id="new_breeding_program_dialog">
91 <tr><td>Name</td><td><input type="text" id="new_breeding_program_name" size="15" /></td></tr>
92 <tr><td>Description</td><td><input type="text" id="new_breeding_program_desc" size="30" /></td></tr>
100 jQuery(document).ready(function() {
102 $("button#new_breeding_program_link").click( function(event) {
103 event.preventDefault();
104 $("#new_breeding_program_dialog").modal("show");
107 $('button#new_breeding_program_submit').click( function(event) {
108 event.preventDefault();
109 var name = jQuery('#new_breeding_program_name').val();
110 var desc = jQuery('#new_breeding_program_desc').val();
111 if ( (name === '') || (desc === '')) {
112 alert("Please enter a name and a description.");
116 url: '/breeders/program/new',
117 data: { 'name': name, 'desc': desc },
118 beforeSend: function() { jQuery('#working').dialog("open") },
119 error: function(response) {
120 alert("An error occurred."+ response.responseText);
121 jQuery('#working').dialog("close");
123 success: function(response) {
124 if (response.error) {
125 alert(response.error);
129 alert("The new breeding program "+name+" was created");
131 jQuery('#working').dialog("close");
135 $("#new_breeding_program_dialog").modal("hide");
139 //jQuery('#new_breeding_program_dialog').dialog( {
140 // title: "Add new breeding program",
144 // 'OK': { id: 'new_breeding_program_dialog_ok_button',
146 // click: function() { store_new_breeding_program(); }
148 // 'Cancel': { id: 'new_breeding_program_dialog_cancel_button',
150 // click: function() {
151 // jQuery('#new_breeding_program_dialog').dialog("close"); }
157 //function store_new_breeding_program() {
158 // var name = jQuery('#new_breeding_program_name').val();
159 // var desc = jQuery('#new_breeding_program_desc').val();
160 // if ( (name === '') || (desc === '')) {
161 // alert("Please enter a name and a description.");
165 // url: '/breeders/program/new',
166 // data: { 'name': name, 'desc': desc },
168 // beforeSend: function() { jQuery('#working').dialog("open") },
169 // error: function(response) {
170 // alert("An error occurred."+ response.responseText);
171 // jQuery('#working').dialog("close");
174 // success: function(response) {
175 // if (response.error) {
176 // alert(response.error);
180 // alert("The new breeding program "+name+" was created");
182 // jQuery('#working').dialog("close");
183 // location.reload();
187 // jQuery('#new_breeding_program_dialog').dialog("close");
191 function delete_breeding_program(program_id) {
192 if (confirm("Delete breeding program? The associated trials will not be deleted, but be listed under 'Other'")) {
194 url: '/breeders/program/delete/'+program_id,
195 error: function(response) {
196 alert("An error occurred.");
198 success: function(response) {
199 if (response.error) {
200 alert(response.error);