shop.balmet.com

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

etsy_links.twig (7461B)


      1 {{ header }}{{ column_left }}
      2 <div id="content">
      3   <div class="page-header">
      4     <div class="container-fluid">
      5       <div class="pull-right">
      6         <a href="{{ cancel }}" data-toggle="tooltip" title="{{ button_cancel }}" class="btn btn-default" id="btn-cancel"><i class="fa fa-reply"></i></a>
      7       </div>
      8       <h1>{{ heading_title }}</h1>      <ul class="breadcrumb">
      9         {% for breadcrumb in breadcrumbs %}
     10         <li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
     11         {% endfor %}
     12       </ul>
     13     </div>
     14   </div>
     15   <div class="container-fluid">
     16     <div class="panel panel-default">
     17       <div class="panel-heading">
     18         <h3 class="panel-title"><i class="fa fa-plus fa-lg"></i> {{ text_new_link }}</h3>
     19       </div>
     20       <div class="panel-body">
     21         <div class="alert alert-success" id="alert-link-save" style="display:none;"><i class="fa fa-check fa-lg" style="color:green"></i> {{ text_link_saved }}</div>
     22         <div class="alert alert-danger" id="alert-link-error" style="display:none;"></div>
     23         <div class="well">
     24       <div class="row">
     25         <div class="col-sm-6">
     26           <div class="form-group">
     27             <label class="control-label" for="input-name">{{ entry_name }}</label>
     28             <input type="hidden" name="add_link_product_id" value="" id="input-product-id"/>
     29             <input type="text" name="add_link_product" value="" placeholder="{{ entry_name }}" id="input-name" class="form-control" />
     30           </div>
     31         </div>
     32         <div class="col-sm-6">
     33           <div class="form-group">
     34             <label class="control-label" for="input-etsy-id">{{ entry_etsy_id }}</label>
     35             <input type="text" name="add_link_etsy_id" value="" placeholder="{{ entry_etsy_id }}" id="input-etsy-id" class="form-control" />
     36           </div>
     37           <a onclick="addLink();" class="btn btn-primary pull-right" id="button-submit-link"><i class="fa fa-check"></i> {{ button_save }}</a> </div>
     38       </div>
     39     </div>
     40       </div>
     41     </div>
     42     <div class="panel panel-default">
     43       <div class="panel-heading">
     44         <h3 class="panel-title"><i class="fa fa-link fa-lg"></i> {{ text_current_links }}</h3>
     45       </div>
     46       <div class="panel-body">
     47         <div class="table-responsive">
     48           <table class="table table-bordered table-hover">
     49           <thead>
     50             <tr>
     51               <th class="text-left">{{ column_product }}</th>
     52               <th class="text-center">{{ column_item_id }}</th>
     53               <th class="text-center">{{ column_store_stock }}</th>
     54               <th class="text-center">{{ column_status }}</th>
     55               <th class="text-center">{{ column_action }}</th>
     56             </tr>
     57           </thead>
     58           <tbody id="show-linked-items">
     59             {% if items %}
     60               {% for id => $item in items %}
     61                 <tr id="row-{{ item.etsy_listing_id }}">
     62                   <td class="text-left"><a href="{{ item.link_edit }}" target="_BLANK">{{ item.name }}</a></td>
     63                   <td class="text-center"><a href="{{ item.link_etsy }}" target="_BLANK">{{ item.etsy_item_id }}</a></td>
     64                   <td class="text-center">{{ item.quantity }}</td>
     65                   <td class="text-center">{% if item.status == 1 %}
     66                     <i class="fa fa-check" style="color: green;"></i>
     67                     {% else %}
     68                     <i class="fa fa-times" style="color: red;"></i>
     69                     {% endif %}</td>
     70                   <td class="text-center"><button class="btn btn-danger" id="row-delete-btn-{{ item.etsy_listing_id }}" onclick="deleteLink('{{ item.etsy_listing_id }}')"><i class="fa fa-times"></i></button></td>
     71                 </tr>
     72               {% endfor %}
     73             {% else %}
     74             <tr>
     75               <td colspan="5" class="text-center">{{ text_no_links }}</td>
     76             </tr>
     77             {% endif %}
     78           </tbody>
     79         </table>
     80         </div>
     81         <div class="row">
     82           <div class="col-sm-6 text-left">{{ pagination }}</div>
     83           <div class="col-sm-6 text-right">{{ results }}</div>
     84         </div>
     85       </div>
     86     </div>
     87   </div>
     88 </div>
     89 <script type="text/javascript"><!--
     90   function addLink() {
     91     var product_id = $('#input-product-id').val();
     92     var etsy_id = $('#input-etsy-id').val();
     93 
     94     if (product_id == '') {
     95       alert('{{ error_product_id }}');
     96       return false;
     97     }
     98 
     99     if (etsy_id == '') {
    100       alert('{{ error_etsy_id }}');
    101       return false;
    102     }
    103 
    104     $.ajax({
    105       url: 'index.php?route=extension/openbay/etsy_product/addLink&user_token={{ user_token }}',
    106       dataType: 'json',
    107       method: 'POST',
    108       data: { 'product_id' : product_id, 'etsy_id' : etsy_id },
    109       beforeSend: function() {
    110         $('#alert-link-save').hide();
    111         $('#alert-link-error').hide().empty();
    112         $('#button-submit-link').empty().html('<i class="fa fa-cog fa-lg fa-spin"></i>').attr('disabled','disabled');
    113       },
    114       success: function(json) {
    115         if (json.error == false) {
    116           $('#input-product-id').val('');
    117           $('#input-name').val('');
    118           $('#input-etsy-id').val('');
    119           $('#alert-link-save').show();
    120         } else {
    121           $('#alert-link-error').html('<i class="fa fa-times fa-lg" style="color:red;"></i> '+json.error).show();
    122         }
    123 
    124         $('#button-submit-link').empty().html('<i class="fa fa-check"></i> {{ button_save }}').removeAttr('disabled');
    125       },
    126       failure: function() {
    127         $('#button-submit').empty().html('<i class="fa fa-check"></i> {{ button_save }}').removeAttr('disabled');
    128       }
    129     });
    130   }
    131 
    132   function deleteLink(etsy_link_id) {
    133     $.ajax({
    134       url: 'index.php?route=extension/openbay/etsy_product/deleteLink&user_token={{ user_token }}',
    135       dataType: 'json',
    136       method: 'POST',
    137       data: { 'etsy_link_id' : etsy_link_id },
    138       beforeSend: function() {
    139         $('#row-delete-btn-'+etsy_link_id).empty().html('<i class="fa fa-cog fa-lg fa-spin"></i>').attr('disabled','disabled');
    140       },
    141       success: function(json) {
    142         if (json.error == false) {
    143           $('#row-'+etsy_link_id).remove();
    144         } else {
    145           $('#row-delete-btn-'+etsy_link_id).empty().html('<i class="fa fa-times fa-lg" style="color:red;"></i>').removeAttr('disabled');
    146           $('#alert-link-error').html('<i class="fa fa-times fa-lg"></i> '+json.error).show();
    147         }
    148       },
    149       failure: function() {
    150         $('#row-delete-btn-'+etsy_link_id).empty().html('<i class="fa fa-times fa-lg"></i>').removeAttr('disabled');
    151       }
    152     });
    153   }
    154 
    155   $('input[name=\'add_link_product\']').autocomplete({
    156     'source': function(request, response) {
    157       $.ajax({
    158         url: 'index.php?route=catalog/product/autocomplete&user_token={{ user_token }}&filter_name=' +  encodeURIComponent(request),
    159         dataType: 'json',
    160         success: function(json) {
    161           response($.map(json, function(item) {
    162             return {
    163               label: item['name'],
    164               value: item['product_id']
    165             }
    166           }));
    167         }
    168       });
    169     },
    170     'select': function(item) {
    171       $('input[name=\'add_link_product\']').val(item['label']);
    172       $('#input-product-id').val(item['value']);
    173     }
    174   });
    175 
    176   $(document).ready(function() {
    177 
    178   });
    179 //--></script>
    180 {{ footer }}