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 ($curator_flag) { print "<th>Name</th><th>Info</th><th>Edit</th><th>Delete</th>"; }
25 else { print "<th>Name</th><th>Info</th>"; }
33 foreach my $bp (@$breeding_programs) {
35 print "<tr><td><b><a href=\"/breeders/program/$bp->[0]\" >$bp->[1]</a></b></td><td>$bp->[2]</td>";
38 print "<td><a title=\"edit this breeding program\" id=\"edit_breeding_program_link\_".$bp->[1]."\" href=\"javascript:edit_breeding_program($bp->[0],'$bp->[1]','$bp->[2]')\" ><span class=\"glyphicon glyphicon-pencil\"></span></a></td>";
39 print "<td><a title=\"delete this breeding program\" id=\"delete_breeding_program_link\_".$bp->[1]."\" href=\"javascript:delete_breeding_program($bp->[0],'$bp->[1]')\" ><font color=\"red\">X</font></a></td></tr>";
50 <button type="button" class="btn btn-primary" name="new_breeding_program_link" id="new_breeding_program_link">Add New Program</button>
54 <!-- Modal Dialogs Below Here -->
56 <div class="modal fade" id="store_breeding_program_dialog" name="store_breeding_program_dialog" tabindex="-1" role="dialog" aria-labelledby="storeBreedingProgramDialog">
57 <div class="modal-dialog" role="document">
58 <div class="modal-content">
59 <div class="modal-header">
60 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
61 <h4 class="modal-title" id="addBreedingProgramDialog">Store Breeding Program Details</h4>
63 <div class="modal-body">
64 <div class="container-fluid">
65 <form class="form-horizontal" role="form" name="store_breeding_program_form" id="store_breeding_program_form">
66 <div class="form-group" id="store_breeding_program_id" style="display: none"></div>
67 <div class="form-group">
68 <label class="col-sm-2 control-label">Name: </label>
69 <div class="col-sm-10">
70 <input class="form-control" name="store_breeding_program_name" id="store_breeding_program_name" type="text" />
73 <div class="form-group">
74 <label class="col-sm-2 control-label">Description: </label>
75 <div class="col-sm-10">
76 <input class="form-control" name="store_breeding_program_desc" id="store_breeding_program_desc" type="text" />
82 <div class="modal-footer">
83 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
84 <button type="button" class="btn btn-primary" name="store_breeding_program_submit" id="store_breeding_program_submit">Store Breeding Program Details</button>
93 jQuery(document).ready(function() {
95 $("button#new_breeding_program_link").click( function(event) {
96 event.preventDefault();
97 $("#store_breeding_program_dialog").modal("show");
100 $('#store_breeding_program_submit').click( function(event) {
101 event.preventDefault();
102 var id= jQuery('#store_breeding_program_id').val();
103 var name = jQuery('#store_breeding_program_name').val();
104 var desc = jQuery('#store_breeding_program_desc').val();
106 if ( (name === '') || (desc === '')) {
107 alert("Please enter a name and a description.");
110 // console.log("Name is "+name+" and desc is: "+desc);
113 url: '/breeders/program/store',
114 data: { 'id': id, 'name': name, 'desc': desc },
115 beforeSend: function() { jQuery('#working').dialog("open") },
116 success: function(response) {
117 if (response.error) { alert(response.error); }
119 alert(response.success);
121 jQuery('#working').dialog("close");
124 error: function(response) {
125 alert("An error occurred."+ response.responseText);
126 jQuery('#working').dialog("close");
129 $("#store_breeding_program_dialog").modal("hide");
135 function edit_breeding_program(program_id, program_name, program_description) {
136 jQuery('#store_breeding_program_id').val(program_id);
137 jQuery('#store_breeding_program_name').val(program_name);
138 jQuery('#store_breeding_program_desc').val(program_description);
139 $("#store_breeding_program_dialog").modal("show");
143 function delete_breeding_program(program_id, program_name) {
144 if (confirm("Delete breeding program "+program_name+"? The associated trials will not be deleted, but be listed under 'Other'")) {
146 url: '/breeders/program/delete/'+program_id,
147 error: function(response) {
148 alert("An error occurred.");
150 success: function(response) {
151 if (response.error) {
152 alert(response.error);