amazon_bulk_listing.twig (10800B)
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="{{ link_overview }}" 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 bulk_listing_status %} 16 <div class="well"> 17 <div class="row"> 18 <div class="col-sm-12"> 19 <div class="form-group"> 20 <label class="control-label" for="filter-marketplace">{{ text_marketplace }}</label> 21 <select id="filter-marketplace" name="filter_marketplace" class="form-control"> 22 {% for marketplace in marketplaces %} 23 {% if filter_marketplace == marketplace.code %} 24 <option selected="selected" value="{{ marketplace.code }}">{{ marketplace.name }}</option> 25 {% else %} 26 <option value="{{ marketplace.code }}">{{ marketplace.name }}</option> 27 {% endif %} 28 {% endfor %} 29 </select> 30 </div> 31 </div> 32 </div> 33 <div class="row"> 34 <div class="col-sm-12 text-right"> <a class="btn btn-primary" id="button-filter"><i class="fa fa-filter"></i> {{ button_filter }}</a> <a class="btn btn-primary" id="button-search"><i class="fa fa-search"></i> {{ button_search }}</a> </div> 35 </div> 36 </div> 37 <form id="bulk-list-form" class="form-horizontal"> 38 <table class="table table-bordered table-hover"> 39 <thead> 40 <tr> 41 <th class="text-center"><input type="checkbox" onclick="$('input[name*=\'product_ids[]\']').prop('checked', this.checked);"/></th> 42 <th class="text-center">{{ column_image }}</th> 43 <th class="text-left">{{ column_name }}</th> 44 <th class="text-right">{{ column_model }}</th> 45 <th class="text-right">{{ column_status }}</th> 46 <th class="text-right">{{ column_matches }}</th> 47 <th class="text-left">{{ column_result }}</th> 48 </tr> 49 </thead> 50 <tbody> 51 {% if products %} 52 {% for product in products %} 53 <tr> 54 <td class="text-center"><input class="amazon-listing" type="checkbox" name="product_ids[]" value="{{ product.product_id }}"/></td> 55 <td class="text-center"><img src="{{ product.image }}"/></td> 56 <td class="text-left"><a href="{{ product.href }}" target="_blank">{{ product.name }}</a></td> 57 <td class="text-right">{{ product.model }}</td> 58 <td class="text-right">{{ product.search_status }}</td> 59 <td class="text-right">{% if product.matches is not null %}{{ product.matches }}{% else %}-{% endif %}</td> 60 <td class="text-left" id="result-{{ product.product_id }}"> 61 {% if product.matches !== null %} 62 {% set checked = false %} 63 {% if product.matches > 0 %} 64 <input class="amazon-listing" type="radio" name="products[{{ product.product_id }}]" value=""/> {{ text_dont_list }}<br/> 65 {% for search_results in product.search_results %} 66 {% if not checked %} 67 <input class="amazon-listing" checked="checked" type="radio" name="products[{{ product.product_id }}]" value="{{ search_result.asin }}"/> 68 {% set checked = true %} 69 {% else %} 70 <input class="amazon-listing" type="radio" name="products[{{ product.product_id }}]" value="{{ search_result.asin }}"/> 71 {% endif %} 72 <a target="_blank" href="{{ search_result.href }}">{{ search_result.title }}</a><br/> 73 {% endfor %} 74 {% else %} 75 <input class="amazon-listing" checked="checked" type="radio" name="products[{{ product.product_id }}]" value=""/> {{ text_dont_list }}<br/> 76 {% endif %} 77 {% endif %} 78 </td> 79 </tr> 80 {% endfor %} 81 {% else %} 82 <tr> 83 <td colspan="7" class="text-center">{{ text_no_results }}</td> 84 </tr> 85 {% endif %} 86 </tbody> 87 </table> 88 </form> 89 <div class="row"> 90 <div class="col-sm-6 text-left">{{ pagination }}</div> 91 <div class="col-sm-6 text-right">{{ results }}</div> 92 </div> 93 <div class="well" style="margin-top:10px;"> 94 <div class="row"> 95 <div class="col-sm-4"> 96 <div class="form-group"> 97 <label for="input-condition" class="control-label">{{ entry_condition }}</label> 98 <select name="condition" class="form-control" id="input-condition"> 99 <option value=""></option> 100 {% for value, name in conditions %} 101 {% if value == default_condition %} 102 <option selected="selected" value="{{ value }}">{{ name }}</option> 103 {% else %} 104 <option value="{{ value }}">{{ name }}</option> 105 {% endif %} 106 {% endfor %} 107 </select> 108 </div> 109 </div> 110 <div class="col-sm-4"> 111 <div class="form-group"> 112 <label for="input-condition-note" class="control-label">{{ entry_condition_note }}</label> 113 <input type="text" name="condition_note" class="form-control" id="input-condition-note" /> 114 </div> 115 </div> 116 <div class="col-sm-4"> 117 <div class="form-group"> 118 <label for="input-start" class="control-label">{{ entry_start_selling }}</label> 119 <div class="input-group date"> 120 <input type="text" class="form-control" id="input-start" data-date-format="YYYY-MM-DD" placeholder="{{ entry_start_selling }}" name="start_selling"> 121 <span class="input-group-btn"> 122 <button type="button" class="btn btn-primary"><i class="fa fa-calendar"></i></button> 123 </span> </div> 124 </div> 125 </div> 126 </div> 127 <div class="row"> 128 <div class="col-sm-12"> 129 <div class="pull-right"> <a class="btn btn-primary" id="button-list"><i class="fa fa-plus-circle"></i> {{ button_list }}</a> </div> 130 </div> 131 </div> 132 </div> 133 {% else %} 134 <div class="warning">{{ error_bulk_listing_permission }}</div> 135 {% endif %} 136 </div> 137 <script type="text/javascript"><!-- 138 $(document).ready(function () { 139 $('#product-form table thead input[type="checkbox"]').change(function () { 140 var checkboxes = $('input[name="product_ids[]"]'); 141 if ($(this).is(':checked')) { 142 checkboxes.attr('checked', 'checked'); 143 } else { 144 checkboxes.removeAttr('checked'); 145 } 146 }); 147 148 $('input[name="product_ids[]"]').change(function () { 149 if (!$(this).is(':checked')) { 150 $('#product-form table thead input[type="checkbox"]').removeAttr('checked'); 151 } 152 }); 153 }); 154 155 $('#button-filter').bind('click', function() { 156 url = 'index.php?route=extension/openbay/amazon/bulkListProducts&user_token={{ user_token }}'; 157 url += '&filter_marketplace=' + $("select[name='filter_marketplace']").val(); 158 location = url; 159 }); 160 161 $('#button-list').bind('click', function(e) { 162 e.preventDefault(); 163 164 var request_data = $('input.amazon-listing:checked').serialize(); 165 166 if (request_data) { 167 request_data += '&marketplace={{ filter_marketplace }}'; 168 } 169 170 var condition = $('select[name="condition"]').val(); 171 var condition_note = $('input[name="condition_note"]').val(); 172 173 if (condition && condition_note) { 174 request_data += '&condition=' + encodeURIComponent(condition) + '&condition_note=' + encodeURIComponent(condition_note); 175 } 176 177 var start_selling = $('input[name="start_selling"]').val(); 178 179 if (start_selling) { 180 request_data += '&start_selling=' + encodeURIComponent(start_selling); 181 } 182 183 $.ajax({ 184 url: 'index.php?route=extension/openbay/amazon/doBulkList&user_token={{ user_token }}', 185 data: request_data, 186 dataType: 'json', 187 type: 'POST', 188 success: function (json) { 189 $('.warning, .success').remove(); 190 191 var html = ''; 192 193 if (json.status) { 194 html = '<div class="success">' + json.message + '</div>'; 195 $('input.amazon-listing:checked[value!=""]').parent().parent().fadeOut(450); 196 } else { 197 html = '<div class="warning">' + json.message + '</div>'; 198 } 199 200 $('.box').prepend(html); 201 }, 202 error: function(xhr, ajaxOptions, thrownError) { 203 if (xhr.status != 0) { alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); } 204 } 205 }); 206 }); 207 208 $('#button-search').bind('click', function(e) { 209 e.preventDefault(); 210 211 var request_data = $('input[name="product_ids[]"]:checked').serialize(); 212 213 if (request_data != '') { 214 request_data += '&marketplace={{ filter_marketplace }}'; 215 216 $.ajax({ 217 url: 'index.php?route=extension/openbay/amazon/doBulkSearch&user_token={{ user_token }}', 218 data: request_data, 219 dataType: 'json', 220 type: 'POST', 221 beforeSend: function() { 222 $('.alert-dismissible').remove(); 223 }, 224 success: function (json) { 225 $.each(json, function (key, value) { 226 var element = $('#result-' + key); 227 if (value.error) { 228 element.html('<div class="alert alert-danger alert-dismissible">' + value.error + '</span>'); 229 } else if (value.success) { 230 element.html('<div class="alert alert-success alert-dismissible">' + value.success + '</span>'); 231 } 232 233 $('input[name="product_ids[]"]').removeAttr('checked'); 234 }); 235 }, 236 error: function(xhr, ajaxOptions, thrownError) { 237 if (xhr.status != 0) { alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); } 238 } 239 }); 240 } else { 241 $('#bulk-list-form').prepend('<div class="alert alert-danger alert-dismissible">{{ error_select_items }}</div>'); 242 } 243 }); 244 //--></script></div> 245 {{ footer }}