shop.balmet.com

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

ebay_edit.twig (21546B)


      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"><i class="fa fa-reply"></i></a>
      7       </div>
      8       <h1>{{ heading_title }}</h1>
      9       <ul class="breadcrumb">
     10         {% for breadcrumb in breadcrumbs %}
     11         <li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
     12         {% endfor %}
     13       </ul>
     14     </div>
     15   </div>
     16   <div class="container-fluid">
     17     <div class="panel panel-default">
     18       <div class="panel-heading">
     19         <h3 class="panel-title"><i class="fa fa-pencil"></i> {{ text_listing_info }}</h3>
     20       </div>
     21       <div class="panel-body">
     22         <div class="alert alert-info" id="form-loading"> <i class="fa fa-cog fa-lg fa-spin"></i> {{ text_loading }} </div>
     23         <div class="alert alert-danger" id="form-error" style="display:none;">
     24           <div class="row">
     25             <div class="col-sm-8">{{ text_error_loading }}</div>
     26             <div class="col-sm-4 text-right"><a id="button-load" class="btn btn-primary"><i class="fa fa-refresh"></i> {{ button_retry }}</a></div>
     27           </div>
     28         </div>
     29         <div class="content displayNone" id="form-main">
     30           <div class="alert alert-success" id="form-success" style="display:none;">{{ text_saved }}</div>
     31           <div class="alert alert-danger" id="error_box" style="display:none;"></div>
     32           <form method="post" enctype="multipart/form-data" id="form" class="form-horizontal">
     33             <input type="hidden" name="itemId" value="" id="item-id" />
     34             <ul class="nav nav-tabs">
     35               <li class="active"><a data-toggle="tab" href="#tab-general">{{ tab_general }}</a></li>
     36               <li><a data-toggle="tab" href="#tab-recommendation">{{ tab_recommendations }}</a></li>
     37             </ul>
     38             <div class="tab-content">
     39               <div id="tab-general" class="tab-pane active">
     40                 <div class="form-group">
     41                   <label class="col-sm-2 control-label" for="title">{{ entry_title }}</label>
     42                   <div class="col-sm-10">
     43                     <input type="text" name="title" value="" id="title" class="form-control" />
     44                   </div>
     45                 </div>
     46                 <div class="form-group stdMatrix">
     47                   <input type="hidden" name="qty_local" value="0" id="qty_local" />
     48                   <input type="hidden" name="qty_ebay" value="0" id="qty_ebay" />
     49                   <input type="hidden" name="variant" value="0" />
     50                   <label class="col-sm-2 control-label" for="price">{{ entry_price }}</label>
     51                   <div class="col-sm-2">
     52                     <input type="text" name="price" value="" id="price" class="form-control" />
     53                   </div>
     54                 </div>
     55                 <div class="form-group stdMatrix">
     56                   <label class="col-sm-2 control-label" for="qty-instock">{{ entry_stock_store }}</label>
     57                   <div class="col-sm-2">
     58                   <input type="text" name="qty_instock" id="qty-instock" class="form-control" disabled="disabled" />
     59                   <span class="help-block">{{ help_stock_store }}</span> </div>
     60                 </div>
     61                 <div class="form-group stdMatrix">
     62                   <label class="col-sm-2 control-label" for="qty-listed">{{ entry_stock_listed }}</label>
     63                   <div class="col-sm-2">
     64                   <input type="text" name="qty_listed" id="qty-listed" class="form-control" disabled="disabled" />
     65                   <span class="help-block">{{ help_stock_listed }}</span> </div>
     66                 </div>
     67                 <div class="form-group stdMatrix">
     68                   <label class="col-sm-2 control-label">{{ entry_stock_reserve }}</label>
     69                   <div class="col-sm-2">
     70                   <input type="text" name="qty_reserve" value="0" id="qty-reserve" class="form-control" onkeyup="updateReserveMessage();" />
     71                   <span class="help-block">{{ help_stock_reserve }}</span> </div>
     72                 </div>
     73                 <div class="form-group" id="variantMatrix">
     74                   <label class="col-sm-2 control-label">{{ entry_stock_matrix_active }}</label>
     75                   <div class="col-sm-10">
     76                     <table class="table table-striped table-bordered table-hover">
     77                       <thead>
     78                         <tr>
     79                           <td class="text-center">{{ column_sku }}</td>
     80                           <td class="text-center">{{ column_stock_total }}</td>
     81                           <td class="text-center">{{ column_stock_listed }}</td>
     82                           <td class="text-center">{{ column_stock_reserve }}</td>
     83                           <td class="text-left">{{ column_combination }}</td>
     84                           <td class="text-center">{{ column_price }}</td>
     85                           <td class="text-center">{{ column_status }}</td>
     86                         </tr>
     87                       </thead>
     88                       <tbody id="matrix-active">
     89                         <input type="hidden" name="variant" value="1" />
     90                         <input type="hidden" name="optGroupArray" value="" id="option-groups" />
     91                         <input type="hidden" name="optGroupRelArray" value="" id="option-group-relationship" />
     92                       </tbody>
     93                     </table>
     94                   </div>
     95                 </div>
     96                 <div class="form-group" id="variantMatrixInactive" style="display:none;">
     97                   <label class="col-sm-2 control-label">{{ entry_stock_matrix_inactive }}</label>
     98                   <div class="col-sm-10">
     99                     <table class="table table-striped table-bordered table-hover">
    100                       <thead>
    101                         <tr>
    102                           <th class="text-center">{{ column_sku }}</th>
    103                           <th class="text-center">{{ column_stock_total }}</th>
    104                           <th class="text-center">{{ column_stock_reserve }}</th>
    105                           <th class="text-left">{{ column_combination }}</th>
    106                           <th class="text-center">{{ column_price }}</th>
    107                           <th class="text-center">{{ column_add }}</th>
    108                         </tr>
    109                       </thead>
    110                       <tbody id="matrix-inactive">
    111                       </tbody>
    112                     </table>
    113                   </div>
    114                 </div>
    115               </div>
    116               <div id="tab-recommendation" class="tab-pane">
    117                 <div class="alert alert-info" id="recommendations-loading"> <i class="fa fa-cog fa-lg fa-spin"></i> {{ text_check_recommendations }} </div>
    118                 <div class="alert alert-danger" id="recommendations-danger" style="display:none;"> <i class="fa fa-minus-circle"></i> </div>
    119                 <div class="alert alert-success" id="recommendations-success" style="display:none;"> <i class="fa fa-check-circle"></i> {{ text_success_recommendations }}</div>
    120               </div>
    121             </div>
    122           </form>
    123           <div class="well">
    124             <div class="row">
    125               <div class="col-sm-12 text-right">
    126                 <a class="btn btn-danger" id="button-end-item"><i class="fa fa-minus-circle"></i> {{ button_end }}</a>
    127                 <a class="btn btn-danger" id="button-remove-link"><i class="fa fa-minus-circle"></i> {{ button_remove }}</a>
    128                 <a class="btn btn-primary" href="{{ view_link }}" target="_BLANK" data-toggle="tooltip" title="{{ button_view }}"><i class="fa fa-external-link"></i></a>
    129                 <a class="btn btn-primary" id="button-edit-item" data-toggle="tooltip" title="{{ button_edit }}" style="display:none;"><i class="fa fa-pencil"></i></a>
    130                 <a class="btn btn-primary" id="button-save" data-toggle="tooltip" title="{{ button_save }}"><i class="fa fa-save"></i></a>
    131               </div>
    132             </div>
    133           </div>
    134         </div>
    135       </div>
    136     </div>
    137   </div>
    138 </div>
    139 <script type="text/javascript"><!--
    140   function updateReserveMessage(){
    141     var reserve = parseInt($('#qty-reserve').val());
    142     var local = parseInt($('#qty_local').val());
    143 
    144     if (reserve > local){
    145       alert('{{ error_reserve }}');
    146       $('#qty-reserve').val(local);
    147     }
    148   }
    149 
    150   function load(){
    151         $.ajax({
    152             url: 'index.php?route=extension/openbay/ebay/editLoad&user_token={{ user_token }}&product_id={{ product_id }}',
    153             type: 'GET',
    154             dataType: 'json',
    155             beforeSend: function(){
    156                 $('#form-loading').fadeIn('slow');
    157                 $('#form-main').hide();
    158                 $('#form-error').hide();
    159             },
    160             success: function(data) {
    161                 if (data.error == false){
    162                     if (data.data.listing.status == 0){
    163                         $('#form').hide();
    164                         $('#btn-end-item').hide();
    165                         $('#error_box').html('<p>{{ error_ended }}</p>').fadeIn('slow');
    166                     }else{
    167                         $('#title').val(data.data.listing.title);
    168                         $('#item-id').val(data.data.listing.itemId);
    169 
    170                         if (data.data.variant.variant == 1){
    171                             $('.stdMatrix').remove();
    172                             $('#option-groups').val(data.data.variant.data.group_information.option_groups);
    173                             $('#option-group-relationship').val(data.data.variant.data.group_information.option_group_relationship);
    174 
    175                             var i = 0;
    176                             var html = '';
    177 
    178                             $.each(data.data.variant.data.options, function( k, v ) {
    179                                 html = '';
    180 
    181                                 $('#matrix-active').append('<input type="hidden" name="opt[' + i + '][sku]" value="' + v.ebay.SKU + '" />');
    182 
    183                                 html += '<tr class="success">';
    184                                 html += '<input type="hidden" name="varPriceExCount" class="varPriceExCount" value="' + i + '" />';
    185                                 html += '<input type="hidden" name="opt[' + i + '][product_option_variant_id]" value="' + v.product_option_variant_id + '" />';
    186                                 html += '<td class="text-center">';
    187                                   if (v.local.sku == '') {
    188                                     html += '<span class="label label-danger">{{ error_no_sku }}</span>';
    189                                   } else {
    190                                     html += v.local.sku;
    191                                   }
    192                                 html += '</td>';
    193                                 html += '<td class="text-center">';
    194                                   if (v.local.stock < 1) {
    195                                     html += '<span class="label label-danger">' + v.local.stock + '</span>';
    196                                   } else {
    197                                     html += v.local.stock;
    198                                   }
    199                                 html += '</td>';
    200                                 html += '<td class="text-center">' + v.ebay.Quantity + '</td>';
    201                                 html += '<td class="text-center"><input type="text" name="opt[' + i + '][reserve]" value="' + v.local.reserve + '" class="text-center form-control" /></td>';
    202                                 html += '<td class="text-left">' + v.local.combination + '</td>';
    203                                 html += '<td class="text-left"><input type="text" name="opt[' + i + '][price]" value="' + v.ebay.StartPrice + '" value="0" class="text-center form-control" /></td>';
    204                                 html += '<td class="text-center"><input type="hidden" name="opt[' + i + '][active]" value="0" /><input type="checkbox" name="opt[' + i + '][active]" value="1" checked="checked" /></td>';
    205                                 html += '</tr>';
    206 
    207                                 $('#matrix-active').append(html);
    208 
    209                                 i++;
    210                             });
    211 
    212                             if (data.data.variant.data.options_inactive != false){
    213                                 $('#variantMatrixInactive').show();
    214                                 $.each(data.data.variant.data.options_inactive, function( k, v ) {
    215                                     $('#matrix-active').append('<input type="hidden" name="opt[' + i + '][sku]" value="' + v.local.sku + '" />');
    216                                     html = '';
    217                                     html += '<tr class="warning">';
    218                                     html += '<input type="hidden" name="varPriceExCount" class="varPriceExCount" value="' + i + '" />';
    219                                     html += '<input type="hidden" name="opt[' + i + '][product_option_variant_id]" value="' + v.product_option_variant_id + '" />';
    220                                     html += '<td class="text-center">';
    221                                       if (v.local.sku == '') {
    222                                         html += '<span class="label label-danger">{{ error_no_sku }}</span>';
    223                                       } else {
    224                                         html += v.local.sku;
    225                                       }
    226                                     html += '</td>';
    227                                     html += '<td class="text-center">';
    228                                     if (v.local.stock < 1) {
    229                                       html += '<span class="label label-danger">' + v.local.stock + '</span>';
    230                                     } else {
    231                                       html += v.local.stock;
    232                                     }
    233                                     html += '</td>';
    234                                     html += '<td class="text-center"><input type="text" name="opt[' + i + '][reserve]" value="' + v.local.reserve + '" class="text-center form-control"/></td>';
    235                                     html += '<td class="text-left">' + v.local.combination + '</td>';
    236                                     if (v.local.price == 0) {
    237                                       html += '<td class="text-left"><input type="text" name="opt[' + i + '][price]" value="' + parseFloat(data.data.product.price).toFixed(2) + '" value="0" class="text-center form-control" /></td>';
    238                                     } else {
    239                                       html += '<td class="text-left"><input type="text" name="opt[' + i + '][price]" value="' + v.local.price + '" value="0" class="text-center form-control" /></td>';
    240                                     }
    241                                     html += '<td class="text-center"><input type="hidden" name="opt[' + i + '][active]" value="0" /><input type="checkbox" name="opt[' + i + '][active]" value="1" /></td>';
    242                                     html += '</tr>';
    243 
    244                                     $('#matrix-inactive').append(html);
    245 
    246                                     i++;
    247                                 });
    248                             }
    249                         }else{
    250                             $('#variantMatrix').remove();
    251                             $('#price').val(data.data.listing.price);
    252                             $('#qty-instock').val(data.data.stock.quantity);
    253                             $('#qty_local').val(data.data.stock.quantity);
    254                             $('#qty-listed').val(data.data.listing.qty);
    255                             $('#qty_ebay').val(data.data.listing.qty);
    256                             $('#qty-reserve').val(data.data.reserve);
    257                         }
    258 
    259                         loadRecommendations();
    260                     }
    261                 }
    262 
    263                 $('#form-main').fadeIn('slow');
    264             },
    265             complete: function() {
    266               $('#form-loading').hide();
    267             },
    268             failure: function(){
    269                 $('#form-error').fadeIn('slow');
    270             },
    271             error: function(){
    272                 $('#form-error').fadeIn('slow');
    273             }
    274         });
    275     }
    276 
    277   function loadRecommendations() {
    278     var item_id = $('#item-id').val();
    279 
    280     $.ajax({
    281       url: 'index.php?route=extension/openbay/ebay/getItemRecommendations&user_token={{ user_token }}&item_id=' + item_id,
    282       type: 'GET',
    283       dataType: 'json',
    284       success: function(data) {
    285         if (data.error == false) {
    286           if (data.data == false) {
    287             $('#recommendations-success').fadeIn('slow');
    288           } else {
    289             $.each(data.data, function( key, value ) {
    290               $('#tab-recommendation').append('<div class="alert alert-info">' + value.message + '</div>');
    291             });
    292           }
    293         } else {
    294           $('#recommendations-error').append('{{ error_recommendations_load }}').fadeIn('slow');
    295         }
    296       },
    297       complete: function() {
    298         $('#recommendations-loading').hide();
    299       },
    300       failure: function(){
    301         $('#recommendations-error').append('{{ error_recommendations_load }}').fadeIn('slow');
    302       },
    303       error: function(){
    304         $('#recommendations-error').append('{{ error_recommendations_load }}').fadeIn('slow');
    305       }
    306     });
    307   }
    308 
    309   $('#button-save').bind('click', function() {
    310     $.ajax({
    311       type: 'POST',
    312       url: 'index.php?route=extension/openbay/ebay/editSave&user_token={{ user_token }}',
    313       dataType: 'json',
    314       data: $("#form").serialize(),
    315       beforeSend: function(){
    316         $('#button-save').empty().html('<i class="fa fa-cog fa-lg fa-spin"></i>').attr('disabled','disabled');
    317           $('#error_box').empty().hide();
    318           $('#form-success').hide();
    319       },
    320       success: function(data) {
    321           $('#reviewButtonLoading').hide();
    322           $('#reviewButton').show();
    323 
    324           if (data.Errors){
    325               if (data.Errors.ShortMessage){
    326                   $('#error_box').append('<p class="m3">' + data.Errors.LongMessage + '</p>');
    327               }else{
    328                   $.each(data.Errors, function(key,val){
    329                       $('#error_box').append('<p class="m3">' + val.LongMessage + '</p>');
    330                   });
    331               }
    332               $('#error_box').fadeIn('slow');
    333           }
    334 
    335           if (data.Ack !== 'Failure'){
    336             $('#form-success').fadeIn('slow');
    337             $('#button-save').hide();
    338             $('#button-edit-item').show();
    339           }
    340 
    341           $('#form').hide();
    342       },
    343       complete: function() {
    344         $('#button-save').empty().html('<i class="fa fa-save"></i> {{ button_save }}').removeAttr('disabled');
    345       },
    346       error: function (xhr, ajaxOptions, thrownError) {
    347           if (xhr.status != 0) { alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); }
    348         }
    349     });
    350     });
    351 
    352   $('#button-load').bind('click', function() {
    353     load();
    354   });
    355 
    356   $('#button-remove-link').on('click', function () {
    357     var pass = confirm("{{ text_confirm }}");
    358 
    359     if (pass == true) {
    360       $.ajax({
    361         type: 'GET',
    362         url: 'index.php?route=extension/openbay/ebay/removeItemLink&user_token={{ user_token }}&product_id={{ product_id }}',
    363         dataType: 'json',
    364         beforeSend: function(){
    365           $('#button-remove-link').empty().html('<i class="fa fa-cog fa-lg fa-spin"></i>').attr('disabled','disabled');
    366         },
    367         success: function () {
    368           alert('{{ text_alert_removed }}');
    369           window.location = 'index.php?route=marketplace/openbay/items&user_token={{ user_token }}';
    370         },
    371         error: function (xhr, ajaxOptions, thrownError) {
    372           if (xhr.status != 0) {
    373             alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
    374           }
    375         }
    376       });
    377     }
    378   });
    379 
    380   $('#button-end-item').on('click', function () {
    381     var pass = confirm("{{ text_confirm }}");
    382 
    383     if (pass == true) {
    384       var item_id = $('#item-id').val();
    385 
    386       if (item_id !== '') {
    387         $.ajax({
    388           type: 'GET',
    389           url: 'index.php?route=extension/openbay/ebay/endItem&user_token={{ user_token }}&item_id=' + item_id,
    390           dataType: 'json',
    391           beforeSend: function(){
    392             $('#button-end-item').empty().html('<i class="fa fa-cog fa-lg fa-spin"></i>').attr('disabled','disabled');
    393           },
    394           success: function (data) {
    395             if (data.error == true) {
    396               alert(data.msg);
    397             } else {
    398               alert('{{ text_alert_ended }}');
    399               window.location = 'index.php?route=marketplace/openbay/items&user_token={{ user_token }}';
    400             }
    401           },
    402           error: function (xhr, ajaxOptions, thrownError) {
    403             if (xhr.status != 0) {
    404               alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
    405             }
    406           }
    407         });
    408       }
    409     }
    410   });
    411 
    412   $('#button-edit-item').on('click', function () {
    413     window.location.href = window.location.href;
    414   });
    415 
    416   $(document).ready(function() {
    417     load();
    418   });
    419 //--></script>
    420 {{ footer }}