fixed div id
[sgn.git] / mason / order / generate_identifier_barcode_dialog.mas
blob5c465b921d368a68d2de008423a260c4eae2f395
1 <%args>
3 $order_id => undef
4 $identifier => undef
5 $user_id => undef
6 $trial_id => undef
8 </%args>
11  <& /util/import_javascript.mas, classes => [ 'jqueryui.js', 'jquery.js'] &>
13 <div class="modal fade" id="generate_identifier_barcode_dialog" name="generate_identifier_barcode_dialog" tabindex="-1" role="dialog" aria-labelledby="generateIdentifierBarcodeDialog">
14     <div class="modal-dialog modal-lg" role="document">
15         <div class="modal-content">
16             <div class="modal-header" style="text-align: center">
17                 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
18                 <h4 class="modal-title" id="generateIdentifierBarcodeDialog">Generate Identifier Barcode</h4>
19             </div>
20             <div class="modal-body">
21                 <div class="container-fluid">
22                     <p>
23                         <button type="button" class="btn btn-primary" name="design_custom_barcode" id="design_custom_barcode">Design Custom Barcodes Using a List</button>
24                     </p>
25                     <p id = "barcode_dialog_subtitle2">
26                         <span class="ui-icon ui-icon-circle-check" style="float: left; margin: 0 7px 50px 0;"></span>
27                     </p>
28                     <div class="well well-sm">
29                         <div class="row">
30                             <div class="col-md-1 col-lg-1">
31                         </div>
32                         <div class="col-md-10 col-lg-10">
33 % if ($order_id) {
34                         <form class="form-horizontal" role="form" enctype="multipart/form-data" method="post" action="/barcode/identifier/download/pdf?order_id=<%$order_id%>" >
35 % } elsif ($trial_id) {
36                         <form class="form-horizontal" role="form" enctype="multipart/form-data" method="post" action="/barcode/identifier/download/pdf?trial_id=<%$trial_id%>" >
37 % } else {
38                         <form class="form-horizontal" role="form" enctype="multipart/form-data" method="post" action="/barcode/identifier/download/pdf?user_id=<%$user_id%>" >
39 % }
40                                 <div class="form-group" form-group-sm id="order_id_section" style="display: none">
41                                     <label class="col-sm-4 control-label" for="tracking_order_id">Order ID: </label>
42                                     <div class="col-sm-8 ">
43                                         <div class="input-group">
44                                             <input class="form-control col-sm-8" id="tracking_order_id" type="text" value="<%$order_id%>" disabled/>
45                                         </div>
46                                     </div>
47                                 </div>
48                                 <div class="form-group form-group-sm" >
49                                     <label class="col-sm-4 control-label">List of Identifiers: </label>
50                                     <div class="col-sm-8" id="item_list">
51                                     </div>
52                                 </div>
53                                 <div class="form-group form-group-sm">
54                                     <label class="col-sm-4 control-label">Barcode Type: </label>
55                                     <div class="col-sm-8">
56                                         <select class="form-control" id="select_barcode_type" name="select_barcode_type">
57                                             <option value="2D">2D Barcode</option>
58                                             <option value="1D">1D Barcode</option>
59                                         </select>
60                                     </div>
61                                 </div>
62                                 <div id="2D_fieldbook_option" >
63                                     <div class="form-group form-group-sm" >
64                                         <label class="col-sm-4 control-label">Enable 2D Barcode For FieldBook: </label>
65                                         <div class="col-sm-8">
66                                             <input type="checkbox" id="enable_fieldbook_2d_barcode" name="enable_fieldbook_2d_barcode" value="enable_fieldbook_2d_barcode" checked/>
67                                         </div>
68                                     </div>
69                                 </div>
71                                 <script defer="defer">
72                                 jQuery(document).ready(function() {
74                                     jQuery(document).on('change', '#select_barcode_type', function () {
75                                         var barcode_type = jQuery("#select_barcode_type").val();
76                                         if (barcode_type == "2D") {
77                                             jQuery("#2D_fieldbook_option").show();
78                                         } else if (barcode_type == "1D") {
79                                             jQuery("#2D_fieldbook_option").hide();
80                                         }
81                                     });
83                                     jQuery('#custom_barcode_trial_link').click(function () {
84                                         location.href = '/tools/label_designer';
85                                     });
87                                     jQuery(document).on('change', '#select_print_format', function () {
88                                         var format = jQuery("#select_print_format").val();
89                                         if (format == "32A4") {
90                                             var labels_row = 10;
91                                             var labels_cols = 4;
92                                             var tops_margin = 12;
93                                             var lefts_margin = 17;
94                                             var bottoms_margin = 12;
95                                             var rights_margin = 10;
96                                         }
97                                         if (format == "32_unique") {
98                                             var labels_row = 10;
99                                             var labels_cols = 4;
100                                             var tops_margin = 12;
101                                             var lefts_margin = 17;
102                                             var bottoms_margin = 12;
103                                             var rights_margin = 10;
104                                         }
105                                         else if (format == "CASS") {
106                                             var labels_row = 10;
107                                             var labels_cols = 2;
108                                             var tops_margin = 10;
109                                             var lefts_margin = 112;
110                                             var bottoms_margin = 13;
111                                             var rights_margin = 20;
112                                         }
113                                         else if (format == "MUSA") {
114                                             var labels_row = 10;
115                                             var labels_cols = 2;
116                                             var tops_margin = 10;
117                                             var lefts_margin = 112;
118                                             var bottoms_margin = 13;
119                                             var rights_margin = 20;
120                                         }
121                                         else if (format == "NCSU") {
122                                             var labels_row = 10;
123                                             var labels_cols = 3;
124                                             var tops_margin = 12;
125                                             var lefts_margin = 10;
126                                             var bottoms_margin = 12;
127                                             var rights_margin = 10;
128                                             var text = 'year,location';
129                                         }
130                                         else if (format == "20A4") {
131                                             var labels_row = 10;
132                                             var labels_cols = 2;
133                                             var tops_margin = 12;
134                                             var lefts_margin = 10;
135                                             var bottoms_margin = 12;
136                                             var rights_margin = 10;
137                                         }
138                                         else if (format == "IITA-3") {
139                                             var labels_row = 20;
140                                             var labels_cols = 3;
141                                             var tops_margin = 13;
142                                             var lefts_margin = 130;
143                                             var bottoms_margin = 11;
144                                             var rights_margin = 10;
145                                         }
146                                         else if (format == "IITA-2") {
147                                             var labels_row = 20;
148                                             var labels_cols = 2;
149                                             var tops_margin = 13;
150                                             var lefts_margin = 130;
151                                             var bottoms_margin = 11;
152                                             var rights_margin = 10;
153                                         }
154                                         else if (format == "crossing") {
155                                             var labels_row = 1;
156                                             var labels_cols = 1;
157                                             var tops_margin = 5;
158                                             var lefts_margin = 2;
159                                             var bottoms_margin = 0;
160                                             var rights_margin = 0;
161                                         }
162                                         jQuery("#text_margin").empty();
163                                         jQuery("#text_margin").val(text);
164                                         jQuery("#label_rows").empty();
165                                         jQuery("#label_rows").val(labels_row);
166                                         jQuery("#label_cols").empty();
167                                         jQuery("#label_cols").val(labels_cols);
168                                         jQuery("#select_barcode_type").prop('selectedIndex',1);
169                                         jQuery("#page_format").prop('selectedIndex',0);
170                                         jQuery("#tops_margin").empty();
171                                         jQuery("#tops_margin").val(tops_margin);
172                                         jQuery("#left_margin").empty();
173                                         jQuery("#left_margin").val(lefts_margin);
174                                         jQuery("#bottom_margin").empty();
175                                         jQuery("#bottom_margin").val(bottoms_margin);
176                                         jQuery("#right_margin").empty();
177                                         jQuery("#right_margin").val(rights_margin);
178                                     });
179                                 });
180                                 </script>
182                                 <div class="form-group form-group-sm">
183                                     <label class="col-sm-4 control-label">Printing Format (Optional): </label>
184                                     <div class="col-sm-8">
185                                         <select class="form-control" id="select_print_format" name="select_print_format">
186                                             <!--<option selected disabled>select printing format</option>-->
187                                             <option value="">select printing format</option>
188                                             <option value="CASS">CASS printing format</option>
189                                             <option value="MUSA">MUSA printing format</option>
190                                             <option value="32A4">32 label Size Sticker Paper</option>
191                                             <option value="32_unique">32 Unique label Size Sticker Paper</option>
192                                             <option value="20A4">20 label Size Sticker Paper</option>
193                                             <option value="IITA-3">IITA-3-barcode</option>
194                                             <option value="IITA-2">IITA-2-barcode</option>
195                                         </select>
196                                     </div>
197                                 </div>
198                                 <div class="form-group form-group-sm" style="display: none">
199                                     <label class="col-sm-4 control-label">Print Duplicate Labels Per Row: </label>
200                                     <div class="col-sm-8">
201                                         <input type="checkbox" name="duplicate_labels_per_row" checked="1" disabled="1" />
202                                     </div>
203                                 </div>
204                             </div>
205                         </div>
206                         <div class="col-md-1 col-lg-1">
207                         </div>
208                     </div>
209                 </p>
210                     <& /barcode/printer_settings.mas &>
211                     </center>
212                 </div>
213             </div>
214             <div class="modal-footer">
215                 <button class="btn btn-primary type="submit" type="submit" value="Download Barcodes">Download Barcodes</button>
216                 <button id="trial_barcode_dialog_ok_button" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
217             </div>
218         </form>
219         </div>
220     </div>
221 </div>
224 <script>
226 jQuery(document).ready(function () {
227     var project_id = "<%$trial_id%>";
228     var dialog_subtitle = '';
229     var dialog_subtitle2 = '';
230     var barcode_button_label = '';
232     jQuery('#barcode_dialog_subtitle').text(dialog_subtitle);
234     jQuery('#generate_item_barcode_button').click(function() {
235         jQuery('#generate_identifier_barcode_dialog').modal("show");
236         jQuery('#barcode_dialog_subtitle2').text('Generate barcodes for requested items');
238         jQuery.ajax({
239             url:'/ajax/order/order_tracking_ids',
240             data:{'order_id': "<% $order_id %>" },
241             success: function(response){
242                 var order_item_html = '<textarea class="form-control" id="identifier_names" name="identifier_names" >';
244                 for (i=0; i<response.tracking_info.length; i++) {
245                     order_item_html = order_item_html + response.tracking_info[i][0] + "\n";
246                 }
247                 order_item_html = order_item_html + "</textarea>";
248                 jQuery('#item_list').empty();
249                 jQuery('#item_list').html(order_item_html);
251             },
252             error: function(response){
253                 alert("Error retrieving requested item info.");
254             }
255         });
256     });
258     jQuery('#generate_active_item_barcode_button').click(function() {
259         jQuery('#generate_identifier_barcode_dialog').modal("show");
260         jQuery('#barcode_dialog_subtitle2').text('Generate barcodes for requested items');
262         jQuery.ajax({
263             url:'/ajax/order/active_order_tracking_ids',
264             success: function(response){
265                 console.log(response);
266                 var order_item_html = '<textarea class="form-control" id="identifier_names" name="identifier_names" >';
268                 for (i=0; i<response.tracking_info.length; i++) {
269                     order_item_html = order_item_html + response.tracking_info[i][0] + "\n";
270                 }
271                 order_item_html = order_item_html + "</textarea>";
272                 jQuery('#item_list').empty();
273                 jQuery('#item_list').html(order_item_html);
275             },
276             error: function(response){
277                 alert("Error retrieving requested item info.");
278             }
279         });
280     });
282     jQuery('#generate_barcodes_project_page').click(function() {
283         jQuery('#generate_identifier_barcode_dialog').modal("show");
284         jQuery('#barcode_dialog_subtitle2').text('Generate barcodes for active tracking identifiers');
286         jQuery.ajax({
287             url:'/ajax/tracking_activity/project_active_identifier_names/'+project_id,
289             success: function(response){
290                 console.log(response);
291                 var order_item_html = '<textarea class="form-control" id="identifier_names" name="identifier_names" >';
293                 for (i=0; i<response.data.length; i++) {
294                     order_item_html = order_item_html + response.data[i] + "\n";
295                 }
296                 order_item_html = order_item_html + "</textarea>";
297                 jQuery('#item_list').empty();
298                 jQuery('#item_list').html(order_item_html);
300             },
301             error: function(response){
302                 alert("Error retrieving requested item info.");
303             }
304         });
305     });
307     jQuery('#design_custom_barcode').click(function () {
308         location.href = '/tools/label_designer';
309     });
313 </script>