shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

amazonus_listing.twig (16227B)


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