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