amazon_listing.twig (17091B)
1 {{ header }}{{ column_left }} 2 <div id="content"> 3 <div class="page-header"> 4 <div class="container-fluid"> 5 <div class="pull-right"> <a href="{{ url_return }}" data-toggle="tooltip" title="{{ button_cancel }}" class="btn btn-default"><i class="fa fa-reply"></i></a> </div> 6 <h1>{{ heading_title }}</h1> 7 <ul class="breadcrumb"> 8 {% for breadcrumb in breadcrumbs %} 9 <li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li> 10 {% endfor %} 11 </ul> 12 </div> 13 </div> 14 <div class="container-fluid"> 15 {% if error_warning %} 16 <div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> {{ error_warning }}</div> 17 {% endif %} 18 {% if listing_errors %} 19 <div class="alert alert-danger alert-dismissible"> 20 <ul> 21 {% for listing_error in listing_errors %} 22 <li><i class="fa fa-exclamation-circle"></i> {{ listing_error }}</li> 23 {% endfor %} 24 </ul> 25 </div> 26 {% endif %} 27 <div class="panel-body" id="search-container"> 28 <div class="alert alert-danger" id="search-error" style="display:none;"></div> 29 <div class="well"> 30 <div class="row"> 31 <div class="col-md-4"> 32 <div class="form-group"> 33 <input type="text" name="search_string" placeholder="{{ text_placeholder_search }}" id="search-string" class="form-control" /> 34 </div> 35 </div> 36 <div class="col-md-1"> 37 <div class="form-group"> <a id="search-submit" class="btn btn-primary" data-toggle="tooltip" title="{{ button_search }}"><i class="fa fa-search"></i></a> </div> 38 </div> 39 </div> 40 <div class="row"> 41 <div class="col-md-12"> 42 <div class="form-group"> 43 {% for id, name in marketplaces %} 44 <label class="radio-inline"> 45 {% if default_marketplace == id %} 46 <input type="radio" name="marketplace" id="marketplace_{{ id }}" value="{{ id }}" checked="checked" /> 47 {% else %} 48 <input type="radio" name="marketplace" id="marketplace_{{ id }}" value="{{ id }}" /> 49 {% endif %} 50 {{ name }} </label> 51 {% endfor %} 52 </div> 53 </div> 54 </div> 55 </div> 56 <div class="well"> {{ text_not_in_catalog }}<a href="{{ url_advanced }}" id="create_new" class="btn btn-primary"><i class="fa fa-plus-circle"></i> {{ button_new }}</a> </div> 57 </div> 58 <div class="panel-body" id="search-result-container" style="display:none;"> 59 <table class="table table-bordered table-hover"> 60 <thead> 61 <tr> 62 <th class="text-center">{{ column_image }}</th> 63 <th class="text-center">{{ column_asin }}</th> 64 <th class="text-left">{{ column_name }}</th> 65 <th class="text-center">{{ column_price }}</th> 66 <th class="text-center">{{ column_action }}</th> 67 </tr> 68 </thead> 69 <tbody> 70 </tbody> 71 </table> 72 </div> 73 <div class="panel-body" id="chosen-product" style="display:none;"> 74 <div id="chosen-product-preview" class="well" style="display:none;"></div> 75 <div class="panel"> 76 <div class="panel-body"> 77 <form method="POST" action="{{ form_action }}" class="form-horizontal"> 78 <input type="hidden" name="asin" value="" /> 79 <input type="hidden" name="marketplace" value="{{ default_marketplace }}" /> 80 <input type="hidden" name="product_id" value="{{ product_id }}" /> 81 <input type="hidden" name="quantity" value="{{ quantity }}" id="quantity" /> 82 <ul class="nav nav-tabs"> 83 <li class="active"><a href="#required-info" data-toggle="tab">{{ tab_required }}</a></li> 84 <li><a href="#additional-info" data-toggle="tab">{{ tab_additional }}</a></li> 85 </ul> 86 <div class="tab-content"> 87 <div class="tab-pane active" id="required-info"> 88 <div class="form-group"> 89 <label class="col-sm-2 control-label" for="quantity-display">{{ entry_quantity }}</label> 90 <div class="col-sm-10"> 91 <input type="text" name="quantity_display" id="quantity-display" value="{{ quantity }}" class="form-control" disabled/> 92 </div> 93 </div> 94 <div class="form-group required"> 95 <label class="col-sm-2 control-label" for="sku">{{ entry_sku }}</label> 96 <div class="col-sm-10"> 97 <input type="text" name="sku" value="{{ sku }}" placeholder="{{ entry_sku }}" id="sku" class="form-control" /> 98 <span class="help-block">{{ help_sku }}</span> </div> 99 </div> 100 <div class="form-group required"> 101 <label class="col-sm-2 control-label" for="condition">{{ entry_condition }}</label> 102 <div class="col-sm-10"> 103 <select name="condition" id="condition" class="form-control"> 104 {% for value, title in conditions %} 105 {% if (value == default_condition %} 106 <option selected="selected" value="{{ value }}">{{ title }}</option> 107 {% else %} 108 <option value="{{ value }}">{{ title }}</option> 109 {% endif %} 110 {% endfor %} 111 </select> 112 </div> 113 </div> 114 <div class="form-group required"> 115 <div class="col-sm-2"> 116 <div class="row"> 117 <div class="col-sm-12 text-right form-group"> 118 <label class="control-label" for="price">{{ entry_price }}</label> 119 </div> 120 </div> 121 <div class="row"> 122 <div class="col-sm-12 text-right form-group"> <a id="button-amazon-price" class="btn btn-primary">{{ button_amazon_price }}</a> </div> 123 </div> 124 </div> 125 <div class="col-sm-10"> 126 <input type="text" name="price" value="{{ price }}" placeholder="{{ entry_price }}" id="price" class="form-control" /> 127 </div> 128 </div> 129 </div> 130 <div class="tab-pane" id="additional-info"> 131 <div class="form-group"> 132 <label class="col-sm-2 control-label" for="condition_note">{{ entry_condition_note }}</label> 133 <div class="col-sm-10"> 134 <textarea name="condition_note" class="form-control" rows="3" id="condition_note" placeholder="{{ text_placeholder_condition }}"></textarea> 135 </div> 136 </div> 137 <div class="form-group"> 138 <label class="col-sm-2 control-label" for="sale_price">{{ entry_sale_price }}</label> 139 <div class="col-sm-10"> 140 <input type="text" name="sale_price" placeholder="{{ entry_sale_price }}" id="sale_price" class="form-control" /> 141 <span class="help-block">{{ help_sale_price }}</span> </div> 142 </div> 143 <div class="form-group"> 144 <label class="col-sm-2 control-label" for="sale_price">{{ entry_sale_date }}</label> 145 <div class="col-sm-3"> 146 <div class="input-group date"> 147 <input type="text" class="form-control" id="sale_from" data-date-format="YYYY-MM-DD" placeholder="{{ entry_from }}" name="sale_from"> 148 <span class="input-group-btn"> 149 <button type="button" class="btn btn-primary"><i class="fa fa-calendar"></i></button> 150 </span> </div> 151 </div> 152 <div class="col-sm-3"> 153 <div class="input-group date"> 154 <input type="text" class="form-control" id="sale_to" data-date-format="YYYY-MM-DD" placeholder="{{ entry_to }}" name="sale_to"> 155 <span class="input-group-btn"> 156 <button type="button" class="btn btn-primary"><i class="fa fa-calendar"></i></button> 157 </span> </div> 158 </div> 159 </div> 160 <div class="form-group"> 161 <label class="col-sm-2 control-label" for="start_selling">{{ entry_start_selling }}</label> 162 <div class="col-sm-3"> 163 <div class="input-group date"> 164 <input type="text" class="form-control" id="start_selling" data-date-format="YYYY-MM-DD" placeholder="{{ entry_start_selling }}" name="start_selling"> 165 <span class="input-group-btn"> 166 <button type="button" class="btn btn-primary"><i class="fa fa-calendar"></i></button> 167 </span> </div> 168 </div> 169 </div> 170 <div class="form-group"> 171 <label class="col-sm-2 control-label" for="input-date-restock">{{ entry_restock_date }}</label> 172 <div class="col-sm-3"> 173 <div class="input-group date"> 174 <input type="text" class="form-control" id="input-date-restock" data-date-format="YYYY-MM-DD" placeholder="{{ entry_restock_date }}" name="restock_date"> 175 <span class="input-group-btn"> 176 <button type="button" class="btn btn-primary"><i class="fa fa-calendar"></i></button> 177 </span> </div> 178 </div> 179 </div> 180 </div> 181 </div> 182 </form> 183 </div> 184 </div> 185 <div class="well"> 186 <div class="row"> 187 <div class="col-md-12 text-right"> <a class="btn btn-primary" id="button-list" onclick="validateQuickListing();">{{ button_list }}</a> </div> 188 </div> 189 </div> 190 </div> 191 </div> 192 </div> 193 <script type="text/javascript"> 194 $('#search-submit').bind('click', function(e) { 195 e.preventDefault(); 196 197 $('#search-string').val($.trim($('#search-string').val())); 198 199 $.ajax({ 200 url: 'index.php?route=extension/openbay/amazon_listing/search&user_token={{ user_token }}', 201 type: 'POST', 202 dataType: 'json', 203 data: {search_string : encodeURIComponent($('#search-string').val()), marketplace: $('input[name="marketplace"]:checked').val()}, 204 beforeSend: function(){ 205 $('#search-submit').empty().html('<i class="fa fa-cog fa-lg fa-spin"></i>').attr('disabled','disabled'); 206 $('#search-error').hide(); 207 $('#search-result-container').hide(); 208 $('#chosen-product').hide(); 209 }, 210 complete: function() { 211 $('#search-submit').empty().html('<i class="fa fa-search"></i> {{ button_search }}').removeAttr('disabled').show(); 212 }, 213 success: function(data) { 214 if (data.error){ 215 $('#search-error').empty().html('<i class="fa fa-exclamation-circle"></i> ' + data.error).show(); 216 } else { 217 var html = ''; 218 var count = 0; 219 var funcString = ''; 220 221 $.each(data['data'], function(index, value) { 222 functString = "listProduct('" + value.asin + "')"; 223 224 html += '<tr>'; 225 html += ' <td class="text-center"><img src="' + value.image + '" /></td>'; 226 html += ' <td class="text-center">' + value.asin + '</td>'; 227 html += ' <td class="text-left">' + value.name + '</td>'; 228 html += ' <td class="text-center">' + value.price + '</td>'; 229 html += ' <td class="text-center">'; 230 html += ' <a target="_blank" href="' + value.link + '" class="btn btn-primary" data-toggle="tooltip" title="{{ button_view_on_amazon }}"><i class="fa fa-eye"></i></a>'; 231 html += ' <a onclick="' + functString + '" class="btn btn-primary" data-toggle="tooltip" title="{{ text_list }}"><i class="fa fa-check-square"></i></a>'; 232 html += ' </td>'; 233 html += '</tr>'; 234 235 count++; 236 }); 237 238 if (count != 0){ 239 $('#search-result-container tbody').html(html); 240 $('#search-result-container').css('opacity', 0).slideDown('slow').animate({ opacity: 1 },{ queue: false, duration: 'slow' }); 241 } else { 242 $('#search-error').empty().html('<i class="fa fa-exclamation-circle"></i> {{ text_no_results }}').show(); 243 } 244 } 245 246 $('#search-submit').show(); 247 }, 248 error: function(){ 249 alert('error'); 250 }, 251 failure: function(){ 252 alert('failure'); 253 } 254 }); 255 }); 256 257 $('#button-amazon-price').bind('click', function(e) { 258 e.preventDefault(); 259 260 $.ajax({ 261 url: 'index.php?route=extension/openbay/amazon_listing/bestPrice&user_token={{ user_token }}', 262 type: 'POST', 263 dataType: 'json', 264 data: $('form input[name="asin"], form select[name="condition"], form input[name="marketplace"]'), 265 beforeSend: function(){ 266 $('#button-amazon-price').empty().html('<i class="fa fa-cog fa-lg fa-spin"></i>').attr('disabled','disabled'); 267 $('#best-price-info').remove(); 268 }, 269 complete: function() { 270 $('#button-amazon-price').empty().html('{{ button_amazon_price }}').removeAttr('disabled').show(); 271 }, 272 success: function(data) { 273 if (data['error']) { 274 alert(data.error); 275 } else { 276 $('form input[name="price"]').val(data.data.amount); 277 278 $('#price').before('<div class="alert alert-info" id="best-price-info">'+data.data.amount+' '+data.data.currency+' plus shipping '+data.data.shipping+' '+data.data.currency+'</div>'); 279 } 280 }, 281 error: function(){ 282 alert('error'); 283 }, 284 failure: function(){ 285 alert('failure'); 286 } 287 }); 288 }); 289 290 $('#button-list').bind('click', function() { 291 var error = false; 292 293 if ($('#quantity').val() < 1){ 294 alert('{{ error_stock }}'); 295 error = true; 296 } 297 298 if ($('#price').val() == '' || $('#price').val() == 0){ 299 alert('{{ error_price }}'); 300 error = true; 301 } 302 303 if ($('#sku').val() == '' || $('#sku').val() == 0){ 304 alert('{{ error_sku }}'); 305 error = true; 306 } 307 308 if (error == false){ 309 $('#chosen-product form').submit(); 310 } 311 }); 312 313 function listProduct(asin) { 314 getProduct(asin); 315 $('form input[name="asin"]').val(asin); 316 $('#chosen-product').css('opacity', 0).slideDown('slow').animate({ opacity: 1 },{ queue: false, duration: 'slow' }); 317 $('#search-result-container').css('opacity', 1).slideUp('medium').animate({ opacity: 0 },{ queue: false, duration: 'medium' }); 318 $('html, body').animate({ scrollTop: 0 }, 'slow'); 319 } 320 321 function getProduct(asin){ 322 $.ajax({ 323 url: 'index.php?route=extension/openbay/amazon_listing/getProductByAsin&user_token={{ user_token }}', 324 type: 'POST', 325 dataType: 'json', 326 data: {asin : asin, market : $('form input[name="marketplace"]').val() }, 327 beforeSend: function(){ 328 $('#chosen-product-preview').empty(); 329 }, 330 success: function(data) { 331 var html = ''; 332 html += '<div class="row">'; 333 if (data.img != '') { 334 html += '<div class="col-md-1 text-center">'; 335 html += '<img src="'+data.img+'" />'; 336 html += '</div>'; 337 } 338 html += '<div class="col-md-11 text-left">'; 339 html += '<h2>'+data.title+'<br /><small>ASIN: '+asin+'</small></h2>'; 340 html += '</div>'; 341 html += '</div>'; 342 343 $('#chosen-product-preview').html(html).css('opacity', 0).slideDown('slow').animate({ opacity: 1 },{ queue: false, duration: 'slow' }); 344 }, 345 error: function (xhr, ajaxOptions, thrownError) { 346 if (xhr.status != 0) { alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); } 347 } 348 }); 349 } 350 351 $(document).ready(function() { 352 $('.search-container input[name="marketplace"]').bind('change', function(){ 353 $('form input[name="marketplace"]').val($(this).val()); 354 }); 355 }); 356 </script> 357 <script type="text/javascript"><!-- 358 $('.date').datetimepicker({ 359 language: '{{ datepicker }}', 360 pickTime: false 361 }); 362 363 $('.datetime').datetimepicker({ 364 language: '{{ datepicker }}', 365 pickDate: true, 366 pickTime: true 367 }); 368 369 $('.time').datetimepicker({ 370 language: '{{ datepicker }}', 371 pickDate: false 372 }); 373 //--></script> 374 {{ footer }}