Merge pull request #5123 from solgenomics/topic/wishlist
[sgn.git] / mason / order / upload_catalog_items_dialog.mas
blob5069e889329599f740ff8b5282b93bdad96ed96c
1 <%args>
3 </%args>
6 <div class="modal fade" id="upload_catalog_items_dialog" name="upload_catalog_items_dialog" tabindex="-1" role="dialog" aria-labelledby="uploadCatalogItemsDialog">
7     <div class="modal-dialog modal-lg" role="document">
8         <div class="modal-content">
9             <div class="modal-header">
10                 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
11                 <h4 class="modal-title" id="uploadCatalogItemsDialog">Upload Catalog Items </h4>
12             </div>
13             <div class="modal-body">
14                 <div class="container-fluid">
15                     <&| /page/explanation.mas, title=>'Template Information' &>
16                         <p>
17                             <b>File Format Information</b>
18                             <br>
19                             <a id="upload_catalog_items_format">Spreadsheet Format</a>
20                             <br>
21                         </p>
22                     </&>
23                     <form class="form-horizontal" role="form" method="post" enctype="multipart/form-data" encoding="multipart/form-data" id="upload_catalog_items_form" name="upload_catalog_items_form">
24                         <div class="form-group">
25                             <label class="col-sm-4 control-label">Upload File (.xls or .xlsx): </label>
26                                 <div class="col-sm-8">
27                                     <input type="file" name="catalog_items_upload_file" id="catalog_items_upload_file" encoding="multipart/form-data" />
28                                 </div>
29                         </div>
30                     </form>
31                 </div>
32             </div>
33             <div class="modal-footer">
34                 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
35                 <button type="button" class="btn btn-primary" name="upload_catalog_items_submit" id="upload_catalog_items_submit">Upload File</button>
36             </div>
37         </div>
38     </div>
39 </div>
41 <div class="modal fade" id="upload_catalog_items_error_display" name="upload_catalog_items_error_display" tabindex="-1" role="dialog" aria-labelledby="uploadCatalogItemsErrorDialog">
42     <div class="modal-dialog modal-lg" role="document">
43         <div class="modal-content">
44             <div class="modal-header">
45                 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
46                 <h4 class="modal-title" id="uploadCatalogItemsErrorDialog">Upload Catalog Items File Error</h4>
47             </div>
48             <div class="modal-body">
49                 <div class="container-fluid">
50                     <table>
51                         <tbody></tbody>
52                     </table>
53                 </div>
54             </div>
55             <div class="modal-footer">
56                 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
57             </div>
58         </div>
59     </div>
60 </div>
62 <div class="modal fade" id="catalog_items_saved_dialog_message" name="catalog_items_saved_dialog_message" tabindex="-1" role="dialog" aria-labelledby="catalogItemsSavedDialog">
63     <div class="modal-dialog" role="document">
64         <div class="modal-content">
65             <div class="modal-header">
66                 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
67                 <h4 class="modal-title" id="catalogItemsSavedDialog">Success</h4>
68             </div>
69             <div class="modal-body">
70                 <div class="container-fluid">
71                     <p>
72                         <span class="ui-icon ui-icon-circle-check" style="float: left; margin: 0 7px 50px 0;"></span>
73                         The catalog items were saved successfully.
74                     </p>
75                 </div>
76             </div>
77             <div class="modal-footer">
78                 <button id="dismiss_catalog_items_saved_dialog" type="button" class="btn btn-default" data-dismiss="modal">Close & Reload</button>
79             </div>
80         </div>
81     </div>
82 </div>
84 <div class="modal fade" id="upload_catalog_items_format_dialog" name="upload_catalog_items_format_dialog" tabindex="-1" role="dialog" aria-labelledby="uploadCatalogItemsFormatDialog">
85     <div class="modal-dialog modal-lg" role="document">
86         <div class="modal-content">
87             <div class="modal-header">
88                 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
89                 <h4 class="modal-title" id="uploadCatalogItemsFormatDialog">Template Information</h4>
90             </div>
91             <div class="modal-body">
92                 <div class="container-fluid">
93                     <b>Catalog Items may be uploaded in an Excel file (.xls or .xlsx)</b>
94                     <br>
95                     <b>Header:</b>
96                     <br>
97                     The first row (header) must contain the following:
98                     <br>
99                     <table class="table table-bordered table-hover">
100                         <tbody>
101                             <tr>
102                                 <td>item_name</td>
103                                 <td>category</td>
104                                 <td>additional_info</td>
105                                 <td>material_source</td>
106                                 <td>breeding_program</td>
107                                 <td>contact_person_username</td>
108                             </tr>
109                         </tbody>
110                     </table>
111                     <b>Required columns:</b>
112                     <ul>
113                         <li><b>item_name:</b>Item name must be in the database, can be accession, seedlot, population or vector_construct stock type</li>
114                         <li><b>category:</b>Must be one of the following (released variety, pathogen assay, control, transgenic line). This field can be customized, please contact us. </li>
115                         <li><b>additional_info:</b> Required in the header, but value may be left blank.</li>
116                         <li><b>material_source:</b> Required in the header, but value may be left blank.</li>
117                         <li><b>breeding_program:</b>Breeding program must be in the database.</li>
118                         <li><b>contact_person_username:</b>Please indicate contact person of each item. Contact person username must be in the database</li>
119                     </ul>
120                 </div>
121             </div>
122             <div class="modal-footer">
123                 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
124             </div>
125         </div>
126     </div>
127 </div>
130 <script>
132 jQuery(document).ready( function() {
134     jQuery("#upload_catalog_items_button").click(function(){
136         jQuery("#upload_catalog_items_format").click(function(){
137             jQuery("#upload_catalog_items_format_dialog").modal("show");
138         });
140         jQuery("#upload_catalog_items_dialog").modal("show");
141     });
144     jQuery("#upload_catalog_items_submit").click(function(){
145         var uploadFile = jQuery("#catalog_items_upload_file").val();
146         jQuery('#upload_catalog_items_form').attr("action", "/ajax/catalog/upload_items");
147         if (uploadFile === ''){
148             alert("Please select a file");
149             return;
150         }
151         jQuery("#upload_catalog_items_form").submit();
152         jQuery("#upload_catalog_items_dialog").modal("hide");
153     });
155     jQuery("#upload_catalog_items_form").iframePostForm({
156         json: true,
157         post: function(){
158             jQuery("#working_modal").modal("show");
159         },
160         complete: function(response){
161             jQuery("#working_modal").modal("hide");
162             if (response.error_string){
163                 jQuery("#upload_catalog_items_error_display tbody").html('');
164                 jQuery("#upload_catalog_items_error_display tbody").append(response.error_string);
165                 jQuery("#upload_catalog_items_error_display").modal("show");
166                 return;
167             }
168             if (response.error) {
169                 alert(response.error);
170                 return;
171             }
172             if (response.success) {
173                 jQuery('#catalog_items_saved_dialog_message').modal("show");
174             }
175         }
176     });
178     jQuery("#dismiss_catalog_items_saved_dialog").click(function(){
179         location.reload();
180     });
185 </script>