2 $timestamp => localtime()
3 $ordering_type => undef
6 <div class="modal fade" id="add_catalog_item_dialog" name="add_catalog_item_dialog" tabindex="-1" role="dialog" aria-labelledby="addCatalogItemDialog">
7 <div class="modal-dialog modal-lg" role="document">
8 <div class="modal-content">
9 <div class="modal-header">
10 <h4 class="modal-title" id="addCatalogItemDialog">Add New Catalog Item</h4>
12 <div class="modal-body" id = "catalog_dialog">
13 <div class="container-fluid">
14 <form class="form-horizontal" role="form" method="post" id="add_new_catalog_item_form" name="add_new_catalog_form">
15 <div class="form-group" id = "get_item_name">
16 <label class="col-sm-3 control-label">Item Name: </label>
17 <div class="col-sm-9" >
18 <input class="form-control" type="text" id="item_name" name="item_name" placeholder="Item name must be in the database">
21 <div class="form-group">
22 <label class="col-sm-3 control-label">Category: </label>
23 <div class="col-sm-9">
24 <select class="form-control" id="item_category">
25 <option value="">Please select a category</option>
26 <option value="released variety">released variety</option>
27 <option value="pathogen assay ">pathogen assay</option>
28 <option value="control">control</option>
29 <option value="transgenic line">transgenic line</option>
33 <div class="form-group">
34 <label class="col-sm-3 control-label">Additional Info: </label>
35 <div class="col-sm-9" >
36 <input class="form-control" id="item_additional_info" placeholder="optional">
39 <div class="form-group">
40 <label class="col-sm-3 control-label">Material Source: </label>
41 <div class="col-sm-9" >
42 <input class="form-control" id="item_material_source" placeholder="optional">
45 <div class="form-group">
46 <label class="col-sm-3 control-label">Breeding Program: </label>
47 <div class="col-sm-9" >
48 <div id="item_breeding_program_div"></div>
51 <div class="form-group">
52 <label class="col-sm-3 control-label">Contact Person Username: </label>
53 <div class="col-sm-9" >
54 <input class="form-control" id="contact_person_name" placeholder="Please provide contact person username">
59 <div class="modal-footer">
60 <button type="reset" id="close_add_item_dialog" name="close_add_item_dialog" class="btn btn-default" >Close</button>
61 <button id="submit_catalog_item" type="button" class="btn btn-primary" >Add</button>
68 <div class="modal fade" id="add_item_saved_dialog_message" name="add_item_saved_dialog_message" tabindex="-1" role="dialog" aria-labelledby="addItemSavedDialog">
69 <div class="modal-dialog" role="document">
70 <div class="modal-content">
71 <div class="modal-header">
72 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
73 <h4 class="modal-title" id="addItemSavedDialog">Success</h4>
75 <div class="modal-body">
76 <div class="container-fluid">
78 <span class="ui-icon ui-icon-circle-check" style="float: left; margin: 0 7px 50px 0;"></span>
79 The catalog item was saved successfully.
83 <div class="modal-footer">
84 <button id="dismiss_item_saved_dialog" type="button" class="btn btn-default" data-dismiss="modal">Close & Reload</button>
92 jQuery(document).ready(function(){
94 jQuery("#add_catalog_item_button").click( function() {
96 jQuery("#item_name").autocomplete({
97 source: '/ajax/stock/accession_or_seedlot_or_population_or_vector_construct_autocomplete',
98 appendTo : catalog_dialog
101 jQuery('#add_catalog_item_dialog').modal('show');
102 get_select_box('breeding_programs', 'item_breeding_program_div', { 'name' : 'item_breeding_program_id', 'id' : 'item_breeding_program_id', 'empty': 1 });
106 jQuery('#submit_catalog_item').click( function() {
107 var name = jQuery('#item_name').val();
108 var category = jQuery('#item_category').val();
109 var additional_info = jQuery('#item_additional_info').val();
110 var material_source = jQuery('#item_material_source').val();
111 var breeding_program = jQuery('#item_breeding_program_id').val();
112 var contact_person = jQuery('#contact_person_name').val();
115 alert("Please provide a name");
118 if (category == '') {
119 alert("Please select a category");
122 if (breeding_program == '') {
123 alert("Please select a program");
126 if (contact_person == '') {
127 alert("Please provide contact username");
132 url: '/ajax/catalog/add_item',
137 'category': category,
138 'additional_info': additional_info,
139 'material_source': material_source,
140 'breeding_program_id': breeding_program,
141 'contact_person': contact_person,
143 beforeSend: function(response){
144 jQuery('#working_modal').modal('show');
146 success: function(response) {
147 jQuery('#working_modal').modal('hide');
148 if (response.success == 1) {
149 jQuery('#add_catalog_item_dialog').modal('hide');
150 jQuery('#add_item_saved_dialog_message').modal("show");
152 if (response.error_string) {
153 alert(response.error_string);
156 error: function(response){
157 jQuery('#working_modal').modal('hide');
158 alert('An error occurred adding item');
163 jQuery("#close_add_item_dialog").click(function() {
164 jQuery("#add_catalog_item_dialog").modal('hide');
168 jQuery("#dismiss_item_saved_dialog").click(function(){