ebay_new_bulk.twig (56898B)
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 {% for warning in error_warning %} 18 <div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> {{ warning }}</div> 19 {% endif %} 20 <div class="panel panel-default"> 21 <div class="panel-heading"> 22 <h3 class="panel-title"><i class="fa fa-list"></i> {{ text_bulk }}</h3> 23 </div> 24 <div class="panel-body" id="page-listing"> 25 {% set i = 0 %} 26 {% if error_fail is empty %} 27 <form action="{{ action }}" method="post" enctype="multipart/form-data" id="form" class="form-horizontal"> 28 <div class="well"> 29 <div class="row"> 30 <div class="col-sm-12 text-right"> 31 <a class="btn btn-primary" id="button-verify"><i class="fa fa-check"></i> {{ text_preview_all }}</a> 32 <a class="btn btn-primary" id="button-edit" style="display:none;"><i class="fa fa-pencil"></i> {{ button_edit }}</a> 33 <a class="btn btn-primary" id="button-submit" style="display:none;"><i class="fa fa-plus-circle"></i> {{ button_submit }}</a> 34 </div> 35 </div> 36 </div> 37 {% if products %} 38 {% for product in products %} 39 {% set price_original = product.price * ((default.defaults.tax / 100) + 1) %} 40 41 <div class="well listingBox" id="p_row_{{ i }}"> 42 <input type="hidden" class="product_id openbay_data_{{ i }}" name="product_id" value="{{ i }}" /> 43 <input type="hidden" class="openbay_data_{{ i }}" name="product_id" value="{{ product.product_id }}" id="product-id-{{ i }}" /> 44 <input type="hidden" name="price_original" id="price_original_{{ i }}" value="{{ price_original|number_format(2, '.', '') }}" /> 45 <input type="hidden" class="openbay_data_{{ i }}" name="catalog_epid" id="catalog_epid_{{ i }}" value="0" /> 46 <div class="row"> 47 <div class="col-sm-7"> 48 <h4 id="product_title_{{ i }}" style="display:none;"></h4> 49 </div> 50 <div class="col-sm-5 form-group text-right" id="p_row_buttons_{{ i }}"> 51 <a class="btn btn-primary" onclick="showCategory('{{ i }}');" id="editCategory_{{ i }}" ><i class="fa fa-pencil"></i> {{ text_category }}</a> 52 <a class="btn btn-primary" onclick="showProfiles('{{ i }}');" id="editProfiles_{{ i }}" ><i class="fa fa-pencil"></i> {{ text_profile }}</a> 53 <a class="btn btn-primary" style="display:none;" onclick="showCatalog('{{ i }}');" id="editCatalog_{{ i }}" ><i class="fa fa-pencil"></i> {{ text_catalog }}</a> 54 <a class="btn btn-primary" style="display:none;" onclick="showFeatures('{{ i }}');" id="editFeature_{{ i }}"><i class="fa fa-pencil"></i> {{ text_features }}</a> 55 <a class="btn btn-danger" onclick="removeBox('{{ i }}')"> <i class="fa fa-minus-circle"></i> {{ button_remove }}</a> 56 </div> 57 </div> 58 <div class="row"> 59 <div class="col-sm-12"> 60 <div class="row" id="product_messages_{{ i }}" style="display:none;"></div> 61 <div class="row product_content_{{ i }}"> 62 <div class="col-sm-2"> 63 <div class="row"> 64 <div class="col-sm-12 form-group text-center"> 65 <img class="img-thumbnail" src="{{ product.image }}" alt="{{ product.name }}" /> 66 </div> 67 </div> 68 <div class="row"> 69 <div class="col-sm-12 form-group"> 70 <h4 class="text-center"><span class="label label-success">{{ text_stock }}: {{ product.quantity }}</span></h4> 71 <input type="hidden" name="qty" value="{{ product.quantity }}" class="openbay_data_{{ i }}" /> 72 </div> 73 </div> 74 <div class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true" id="overlay-feature-{{ i }}" data-backdrop="static" data-keyboard="false"> 75 <div class="modal-dialog modal-lg"> 76 <div class="modal-content"> 77 <div class="modal-body"> 78 <div class="page-header"> 79 <div class="container-fluid"> 80 <div class="pull-right"> 81 <a onclick="overlayHide();" class="btn btn-default" data-toggle="tooltip" title="{{ text_close }}"><i class="fa fa-reply"></i></a> 82 </div> 83 <h1 class="panel-title">{{ text_features }}</h1> 84 </div> 85 </div> 86 <div class="container-fluid" style="display: none;" id="product_identifier_container_{{ i }}"> 87 <div class="panel panel-default"> 88 <div class="panel-body"> 89 <div class="well"> 90 <div class="row"> 91 <div class="form-group" id="product_identifier_ean_container_{{ i }}" style="display:none;"> 92 <label class="col-sm-2 control-label">{{ text_ean }}</label> 93 <div class="col-sm-10"> 94 <input type="hidden" id="identifier_ean_required_{{ i }}" class="product_identifier_required_{{ i }}" value="0" /> 95 <input type="hidden" id="identifier_ean_original_{{ i }}" value="{{ product.ean }}" /> 96 <input type="text" name="identifier_ean" value="{{ product.ean }}" id="identifier_ean_{{ i }}" class="form-control openbay_data_{{ i }}" /> 97 </div> 98 </div> 99 <div class="form-group" id="product_identifier_isbn_container_{{ i }}" style="display:none;"> 100 <label class="col-sm-2 control-label">{{ text_isbn }}</label> 101 <div class="col-sm-10"> 102 <input type="hidden" id="identifier_isbn_required_{{ i }}" class="product_identifier_required_{{ i }}" value="0" /> 103 <input type="hidden" id="identifier_isbn_original_{{ i }}" value="{{ product.isbn }}" /> 104 <input type="text" name="identifier_isbn" value="{{ product.isbn }}" id="identifier_isbn_{{ i }}" class="form-control openbay_data_{{ i }}" /> 105 </div> 106 </div> 107 <div class="form-group" id="product_identifier_upc_container_{{ i }}" style="display:none;"> 108 <label class="col-sm-2 control-label">{{ text_upc }}</label> 109 <div class="col-sm-10"> 110 <input type="hidden" id="identifier_upc_required_{{ i }}" class="product_identifier_required" value="0" /> 111 <input type="hidden" id="identifier_upc_original_{{ i }}" value="{{ product.upc }}" /> 112 <input type="text" name="identifier_upc" value="{{ product.upc }}" id="identifier_upc_{{ i }}" class="form-control openbay_data_{{ i }}" /> 113 </div> 114 </div> 115 <div class="form-group"> 116 <label class="col-sm-2 control-label">{{ text_identifier_not_required }}</label> 117 <div class="col-sm-10"> 118 <input type="checkbox" name="identifier_not_required" value="1" id="identifier_not_required_{{ i }}" class="form-control" onclick="identifierNotRequired({{ i }});"/> 119 </div> 120 </div> 121 </div> 122 </div> 123 </div> 124 </div> 125 </div> 126 <div id="feature-data-{{ i }}"></div> 127 </div> 128 </div> 129 </div> 130 </div> 131 <div class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true" id="overlay-category-{{ i }}" data-backdrop="static" data-keyboard="false"> 132 <div class="modal-dialog modal-lg"> 133 <div class="modal-content"> 134 <div class="modal-body"> 135 <div class="page-header"> 136 <div class="container-fluid"> 137 <div class="pull-right"> 138 <a onclick="overlayHide();" class="btn btn-default" data-toggle="tooltip" title="{{ text_close }}"><i class="fa fa-reply"></i></a> 139 </div> 140 <h1 class="panel-title">{{ text_category }}</h1> 141 </div> 142 </div> 143 <div class="container-fluid"> 144 <div class="panel panel-default"> 145 <div class="panel-body"> 146 <div class="well"> 147 <div class="row"> 148 <div class="form-group"> 149 <label class="col-sm-2 control-label">{{ text_suggested }}</label> 150 <div class="col-sm-10"> 151 <div class="alert alert-info" id="loadingSuggestedCat_{{ i }}"><i class="fa fa-cog fa-lg fa-spin"></i> {{ text_category }}</div> 152 <div id="suggestedCat_{{ i }}"></div> 153 <input type="hidden" name="finalCat" id="finalCat_{{ i }}" class="openbay_data_{{ i }}" /> 154 </div> 155 </div> 156 </div> 157 <div class="row"> 158 <div class="form-group" id="cSelections_{{ i }}" style="display:none;"> 159 <label class="col-sm-2 control-label">{{ text_category_choose }}</label> 160 <div class="col-sm-10"> 161 <div class="alert alert-info" id="imageLoading_{{ i }}"><i class="fa fa-cog fa-lg fa-spin"></i> {{ text_loading_categories }}</div> 162 <div class="row form-group"> 163 <div class="col-sm-12"> 164 <select id="catsSelect1_{{ i }}" class="form-control" onchange="loadCategories(2, false, {{ i }});"></select> 165 </div> 166 </div> 167 <div class="row form-group"> 168 <div class="col-sm-12"> 169 <select id="catsSelect2_{{ i }}" class="form-control" onchange="loadCategories(3, false, {{ i }});" style="display:none;"></select> 170 </div> 171 </div> 172 <div class="row form-group"> 173 <div class="col-sm-12"> 174 <select id="catsSelect3_{{ i }}" class="form-control" onchange="loadCategories(4, false, {{ i }});" style="display:none;"></select> 175 </div> 176 </div> 177 <div class="row form-group"> 178 <div class="col-sm-12"> 179 <select id="catsSelect4_{{ i }}" class="form-control" onchange="loadCategories(5, false, {{ i }}, false, {{ i }});" style="display:none;"></select> 180 </div> 181 </div> 182 <div class="row form-group"> 183 <div class="col-sm-12"> 184 <select id="catsSelect5_{{ i }}" class="form-control" onchange="loadCategories(6, false, {{ i }});" style="display:none;"></select> 185 </div> 186 </div> 187 <div class="row form-group"> 188 <div class="col-sm-12"> 189 <select id="catsSelect6_{{ i }}" class="form-control" onchange="loadCategories(7, false, {{ i }});" style="display:none;"></select> 190 </div> 191 </div> 192 </div> 193 </div> 194 </div> 195 </div> 196 </div> 197 </div> 198 </div> 199 </div> 200 </div> 201 </div> 202 </div> 203 <div class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true" id="overlay-catalog-{{ i }}" data-backdrop="static" data-keyboard="false"> 204 <div class="modal-dialog modal-lg"> 205 <div class="modal-content"> 206 <div class="modal-body"> 207 <div class="page-header"> 208 <div class="container-fluid"> 209 <div class="pull-right"> 210 <a onclick="overlayHide();" class="btn btn-default" data-toggle="tooltip" title="{{ text_close }}"><i class="fa fa-reply"></i></a> 211 </div> 212 <h1 class="panel-title">{{ text_catalog_search }}</h1> 213 </div> 214 </div> 215 <div class="container-fluid"> 216 <div class="panel panel-default"> 217 <div class="panel-body"> 218 <div class="well"> 219 <div class="row"> 220 <div class="form-group"> 221 <label class="col-sm-2 control-label">{{ text_search_term }}</label> 222 <div class="col-sm-10"> 223 <input type="text" name="catalog_search" id="catalog_search_{{ i }}" value="" class="form-control"/> 224 </div> 225 </div> 226 </div> 227 <div class="row"> 228 <div class="col-sm-12 text-right"> 229 <a onclick="searchEbayCatalog('{{ i }}');" class="btn btn-primary" id="button-catalog-search-{{ i }}">{{ text_search }}</a> 230 </div> 231 </div> 232 </div> 233 <div id="catalog-results-{{ i }}" style="display:none;"></div> 234 </div> 235 </div> 236 </div> 237 </div> 238 </div> 239 </div> 240 </div> 241 <div class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true" id="overlay-profile-{{ i }}" data-backdrop="static" data-keyboard="false"> 242 <div class="modal-dialog modal-lg"> 243 <div class="modal-content"> 244 <div class="modal-body"> 245 <div class="page-header"> 246 <div class="container-fluid"> 247 <div class="pull-right"> 248 <a onclick="overlayHide();" class="btn btn-default" data-toggle="tooltip" title="{{ text_close }}"><i class="fa fa-reply"></i></a> 249 </div> 250 <h1 class="panel-title">{{ text_profile }}</h1> 251 </div> 252 </div> 253 <div class="container-fluid"> 254 <div class="panel panel-default"> 255 <div class="panel-body"> 256 <div class="well"> 257 <div class="form-group"> 258 <label class="col-sm-2 control-label">{{ text_profile_theme }}</label> 259 <div class="col-sm-10"> 260 <select name="theme_profile" class="openbay_data_{{ i }} form-control"> 261 {% for profile in default.profiles_theme %} 262 <option value="{{ profile.ebay_profile_id }}"{% if default.profiles_theme_def == profile.ebay_profile_id %} selected{% endif %}>{{ profile.name }}</option> 263 {% endfor %} 264 </select> 265 </div> 266 </div> 267 <div class="form-group"> 268 <label class="col-sm-2 control-label">{{ text_profile_shipping }}</label> 269 <div class="col-sm-10"> 270 <select name="shipping_profile" class="openbay_data_{{ i }} form-control"> 271 {% for profile in default.profiles_shipping %} 272 <option value="{{ profile.ebay_profile_id }}"{% if default.profiles_shipping_def == profile.ebay_profile_id %} selected{% endif %}>{{ profile.name }}</option> 273 {% endfor %} 274 </select> 275 </div> 276 </div> 277 <div class="form-group"> 278 <label class="col-sm-2 control-label">{{ text_profile_generic }}</label> 279 <div class="col-sm-10"> 280 <select name="generic_profile" id="generic_profile_{{ i }}" class="openbay_data_{{ i }} form-control" onchange="genericProfileChange({{ i }});"> 281 {% for profile in default.profiles_generic %} 282 <option value="{{ profile.ebay_profile_id }}"{% if default.profiles_generic_def == profile.ebay_profile_id %} selected{% endif %}>{{ profile.name }}</option> 283 {% endfor %} 284 </select> 285 </div> 286 </div> 287 <div class="form-group"> 288 <label class="col-sm-2 control-label">{{ text_profile_returns }}</label> 289 <div class="col-sm-10"> 290 <select name="return_profile" class="openbay_data_{{ i }} form-control"> 291 {% for profile in default.profiles_returns %} 292 <option value="{{ profile.ebay_profile_id }}"{% if default.profiles_returns_def == profile.ebay_profile_id %} selected{% endif %}>{{ profile.name }}</option> 293 {% endfor %} 294 </select> 295 </div> 296 </div> 297 </div> 298 </div> 299 </div> 300 </div> 301 </div> 302 </div> 303 </div> 304 </div> 305 </div> 306 <div class="col-sm-10"> 307 <div class="form-group"> 308 <label class="col-sm-2 control-label">{{ text_title }}</label> 309 <div class="col-sm-10"> 310 <input type="text" name="title" class="openbay_data_{{ i }} form-control" value="{{ product.name }}" id="title_{{ i }}" /> 311 </div> 312 </div> 313 <div class="form-group"> 314 <label class="col-sm-2 control-label">{{ text_price }}</label> 315 <div class="col-sm-10"> 316 {% set price_new = product.price * ((default.defaults.tax / 100) + 1) %} 317 <input id="price_{{ i }}" type="text" name="price" class="openbay_data_{{ i }} form-control" value="{{ price_new|number_format(2, '.', '') }}" /> 318 </div> 319 </div> 320 <div class="alert alert-info" id="conditionLoading_{{ i }}"><i class="fa fa-cog fa-lg fa-spin"></i> {{ text_loading_condition }}</div> 321 <div class="form-group" id="conditionContainer_{{ i }}" style="display:none;"> 322 <label class="col-sm-2 control-label">{{ entry_condition }}</label> 323 <div class="col-sm-10"> 324 <select name="condition" class="openbay_data_{{ i }} form-control" id="conditionRow_{{ i }}"></select> 325 </div> 326 </div> 327 <div class="alert alert-info" id="durationLoading_{{ i }}"><i class="fa fa-cog fa-lg fa-spin"></i> {{ text_loading_duration }}</div> 328 <div class="form-group" id="durationContainer_{{ i }}" style="display:none;"> 329 <label class="col-sm-2 control-label">{{ text_duration }}</label> 330 <div class="col-sm-10"> 331 <select name="duration" class="openbay_data_{{ i }} form-control" id="durationRow_{{ i }}"></select> 332 </div> 333 </div> 334 </div> 335 </div> 336 </div> 337 </div> 338 </div> 339 {% set i = i + 1 %} 340 {% endfor %} 341 {% else %} 342 <div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> {{ text_no_results }}</div> 343 {% endif %} 344 </form> 345 <div class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true" id="overlay-loading" data-backdrop="static" data-keyboard="false"> 346 <div class="modal-dialog modal-lg"> 347 <div class="modal-content"> 348 <div class="modal-body"> 349 <div class="progress"> 350 <div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="1" aria-valuemin="0" aria-valuemax="100" style="width: 0%" id="loading-bar"></div> 351 </div> 352 <p class="text-center">{{ text_preparing0 }} <span id="ajax-count-complete-display">0</span> {{ text_preparing1 }} <span id="ajax-count-total-display">0</span> {{ text_preparing2 }} </p> 353 </div> 354 </div> 355 </div> 356 </div> 357 {% else %} 358 {% for fail in error_fail %} 359 <div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> {{ fail }}</div> 360 {% endfor %} 361 {% endif %} 362 </div> 363 </div> 364 </div> 365 366 <input type="hidden" id="total-items" value="{{ count }}" name="total-items" /> 367 <input type="hidden" id="ajax-count" value="0" /> 368 <input type="hidden" id="ajax-count-total" value="0" /> 369 <input type="hidden" id="ajax-count-complete" value="0" /> 370 <script type="text/javascript"> 371 $(document).ready(function() { 372 overlay('overlay-loading'); 373 374 {# This will run productCount times #} 375 {% for j in 0..i %} 376 getSuggestedCategories('{{ j }}'); 377 modifyPrices('{{ j }}'); 378 {% endfor %} 379 380 $('#activeItems').text($('#total-items').val()); 381 }); 382 383 function overlay(screen) { 384 $('#ajax-count-complete').val(0); 385 $('#ajax-count-complete-display').text(0); 386 $('#ajax-count-total').val(0); 387 $('#ajax-count-total-display').text(0); 388 $('#loading-bar').css('width', '0%'); 389 $('#'+screen).modal('toggle'); 390 } 391 392 function overlayHide() { 393 $('.modal').modal('hide'); 394 } 395 396 function modifyPrices(id) { 397 var price_original = parseFloat($('#price_original_'+id).val()); 398 var price_modified = ''; 399 var modify_percent = ''; 400 401 $.ajax({ 402 url: 'index.php?route=extension/openbay/ebay_profile/profileGet&user_token={{ user_token }}&ebay_profile_id='+$('#generic_profile_'+id).val(), 403 type: 'GET', 404 async: true, 405 dataType: 'json', 406 beforeSend: function() { addCount(); }, 407 success: function(data) { 408 409 if (data.data.price_modify !== false && typeof data.data.price_modify !== 'undefined') { 410 modify_percent = 100 + parseFloat(data.data.price_modify); 411 modify_percent = parseFloat(modify_percent / 100); 412 price_modified = price_original * modify_percent; 413 414 $('#price_'+id).val(parseFloat(price_modified).toFixed(2)); 415 } 416 417 removeCount(); 418 }, 419 failure: function() { 420 removeCount(); 421 }, 422 error: function() { 423 removeCount(); 424 } 425 }); 426 } 427 428 function addCount() { 429 var count = parseInt($('#ajax-count').val()) + 1; 430 $('#ajax-count').val(count); 431 var count1 = parseInt($('#ajax-count-total').val())+1; 432 $('#ajax-count-total').val(count1); 433 $('#ajax-count-total-display').text(count1); 434 } 435 436 function removeCount() { 437 var count = parseInt($('#ajax-count').val())-1; 438 $('#ajax-count').val(count); 439 var count1 = parseInt($('#ajax-count-complete').val())+1; 440 $('#ajax-count-complete').val(count1); 441 $('#ajax-count-complete-display').text(count1); 442 443 var modifier = 0; 444 var current = 0; 445 var total = $('#ajax-count-total').val(); 446 447 modifier = 100 / total; 448 current = parseFloat(modifier * count1); 449 450 $('#loading-bar').css('width', current+"%"); 451 452 if (count == 0) { 453 overlayHide(); 454 } 455 } 456 457 function removeBox(id) { 458 $('#p_row_'+id).fadeOut('medium'); 459 460 setTimeout(function() { 461 $('#p_row_'+id).remove(); 462 }, 1000); 463 464 $('#total-items').val($('#total-items').val()-1); 465 466 if ($('.listingBox').length == 1) { 467 window.location = "index.php?route=marketplace/openbay/items&user_token={{ user_token }}"; 468 } else { 469 $('#activeItems').text($('#total-items').val()); 470 } 471 } 472 473 function useManualCategory(id) { 474 loadCategories(1, true, id); 475 $('#cSelections_'+id).show(); 476 } 477 478 function getSuggestedCategories(id) { 479 var qry = $('#title_'+id).val(); 480 481 $.ajax({ 482 url: 'index.php?route=extension/openbay/ebay/getSuggestedCategories&user_token={{ user_token }}&qry='+qry, 483 type: 'GET', 484 async: true, 485 dataType: 'json', 486 beforeSend: function() { $('#loadingSuggestedCat_'+id).show(); addCount(); }, 487 success: function(data) { 488 var html_inj = ''; 489 490 if (data.error == false && data.data) { 491 var i = 1; 492 493 $.each(data.data, function(key,val) { 494 if (val.percent != 0) { 495 html_inj += '<div class="row form-group">'; 496 html_inj += '<div class="col-sm-1 text-right">'; 497 html_inj += '<input type="radio" id="suggested_category_'+id+'" name="suggested_'+id+'" value="'+val.id+'" onchange="categorySuggestedChange('+val.id+','+id+')"'; 498 if (i == 1) { 499 html_inj += ' checked="checked"'; 500 categorySuggestedChange(val.id, id); 501 } 502 html_inj += '/>'; 503 html_inj += '</div>'; 504 html_inj += '<div class="col-sm-11">'; 505 html_inj += '('+val.percent+'% match) '+val.name; 506 html_inj += '</div>'; 507 html_inj += '</div>'; 508 } 509 i++; 510 }); 511 512 html_inj += '<div class="row form-group">'; 513 html_inj += '<div class="col-sm-1 text-right"><input type="radio" id="manual_use_category_'+id+'" name="suggested_'+id+'" value="" onchange="useManualCategory('+id+')" /></div>'; 514 html_inj += '<div class="col-sm-11">{{ text_category_choose }}</div>'; 515 html_inj += '</div>'; 516 } else { 517 html_inj += '<div class="row form-group">'; 518 html_inj += '<div class="col-sm-1 text-right"><input type="radio" id="manual_use_category_'+id+'" name="suggested_'+id+'" value="" onchange="useManualCategory('+id+')" /></div>'; 519 html_inj += '<div class="col-sm-11">{{ text_category_choose }}</div>'; 520 html_inj += '</div>'; 521 useManualCategory(id); 522 } 523 $('#suggestedCat_'+id).empty().html(html_inj); 524 $('#loadingSuggestedCat_'+id).hide(); 525 removeCount(); 526 }, 527 failure: function() { 528 $('#loadingSuggestedCat_'+id).hide(); 529 removeCount(); 530 }, 531 error: function() { 532 $('#loadingSuggestedCat_'+id).hide(); 533 removeCount(); 534 } 535 }); 536 } 537 538 function loadCategories(level, skip, id) { 539 var parent = ''; 540 541 if (level == 1) { 542 parent = '' 543 } else { 544 var prevLevel = level - 1; 545 parent = $('#catsSelect'+prevLevel+'_'+id).val(); 546 } 547 548 var countI = level; 549 550 while(countI <= 6) { 551 $('#catsSelect'+countI+'_'+id).hide().empty(); 552 countI++; 553 } 554 555 $.ajax({ 556 url: 'index.php?route=extension/openbay/ebay/getCategories&user_token={{ user_token }}&parent='+parent, 557 type: 'GET', 558 dataType: 'json', 559 beforeSend: function() { 560 $('#imageLoading_'+id).show(); 561 }, 562 success: function(data) { 563 if (data.items != null) { 564 $('#catsSelect'+level+'_'+id).empty(); 565 $('#catsSelect'+level+'_'+id).append('<option value="">-- SELECT --</option>'); 566 $.each(data.cats, function(key, val) { 567 if (val.CategoryID != parent) { 568 $('#catsSelect'+level+'_'+id).append('<option value="'+val.CategoryID+'">'+val.CategoryName+'</option>'); 569 } 570 }); 571 572 if (skip != true) { 573 $('#finalCat_'+id).val(''); 574 } 575 576 $('#catsSelect'+level+'_'+id).show(); 577 } else { 578 if (data.error) { 579 580 } else { 581 $('#finalCat_'+id).val($('#catsSelect'+prevLevel+'_'+id).val()); 582 getCategoryFeatures($('#catsSelect'+prevLevel+'_'+id).val(), id); 583 } 584 } 585 $('#imageLoading_'+id).hide(); 586 } 587 }); 588 } 589 590 function getCategoryFeatures(cat, id) { 591 itemFeatures(cat, id); 592 $('#editCatalog_'+id).show(); 593 594 $('#durationLoading_'+id).show(); 595 $('#durationContainer_'+id).hide(); 596 597 $('#conditionLoading_'+id).show(); 598 $('#conditionContainer_'+id).hide(); 599 600 $('#product_identifier_container_'+id).hide(); 601 $('.product_identifier_required_'+id).val('0'); 602 603 $.ajax({ 604 url: 'index.php?route=extension/openbay/ebay/getCategoryFeatures&user_token={{ user_token }}&category='+cat, 605 type: 'GET', 606 dataType: 'json', 607 beforeSend: function() { addCount(); }, 608 success: function(data) { 609 if (data.error == false) { 610 var html_inj = ''; 611 612 listingDuration(data.data.durations, id); 613 614 if (data.data.conditions) { 615 $.each(data.data.conditions, function(key, val) { 616 html_inj += '<option value='+val.id+'>'+val.name+'</option>'; 617 }); 618 619 if (html_inj == '') { 620 $('#conditionRow_'+id).empty(); 621 $('#conditionContainer_'+id).hide(); 622 $('#conditionLoading_'+id).hide(); 623 } else { 624 $('#conditionRow_'+id).empty().html(html_inj); 625 $('#conditionContainer_'+id).show(); 626 $('#conditionLoading_'+id).hide(); 627 } 628 } 629 630 if (data.data.ean_identifier_requirement != '') { 631 $('#product_identifier_container_'+id).show(); 632 $('#product_identifier_ean_container_'+id).show(); 633 634 if (data.data.ean_identifier_requirement == 'Required') { 635 $('#identifier_ean_required_'+id).val(1); 636 } 637 } 638 639 if (data.data.isbn_identifier_requirement != '') { 640 $('#product_identifier_container_'+id).show(); 641 $('#product_identifier_isbn_container_'+id).show(); 642 643 if (data.data.isbn_identifier_requirement == 'Required') { 644 $('#identifier_isbn_required_'+id).val(1); 645 } 646 } 647 648 if (data.data.upc_identifier_requirement != '') { 649 $('#product_identifier_container_'+id).show(); 650 $('#product_identifier_upc_container_'+id).show(); 651 652 if (data.data.upc_identifier_requirement == 'Required') { 653 $('#identifier_upc_required_'+id).val(1); 654 } 655 } 656 } else { 657 alert(data.msg); 658 } 659 removeCount(); 660 }, 661 failure: function() { 662 removeCount(); 663 }, 664 error: function() { 665 removeCount(); 666 } 667 }); 668 } 669 670 function itemFeatures(category_id, id) { 671 $('#editFeature_'+id).hide(); 672 673 var product_id = $('#product-id-' + id).val(); 674 675 $.ajax({ 676 url: 'index.php?route=extension/openbay/ebay/getEbayCategorySpecifics&user_token={{ user_token }}&category_id=' + category_id + '&product_id=' + product_id, 677 type: 'GET', 678 dataType: 'json', 679 beforeSend: function() { addCount(); }, 680 success: function(data) { 681 if (data.error == false) { 682 $('#feature-data-' + id).empty(); 683 684 var html_inj = ''; 685 var html_inj2 = ''; 686 var show_other = 0; 687 var show_other_value = ''; 688 689 if (data.data) { 690 html_inj = ''; 691 html_inj += '<div class="container-fluid">'; 692 html_inj += '<div class="panel panel-default">'; 693 html_inj += '<div class="panel-body">'; 694 html_inj += '<div class="well">'; 695 html_inj += '<div class="row">'; 696 $.each(data.data, function(option_specific_key, option_specific_value) { 697 html_inj2 = ''; 698 html_inj += '<div class="row form-group">'; 699 html_inj += '<label class="col-sm-2 control-label">'+option_specific_value.name+'</label>'; 700 html_inj += '<div class="col-sm-10">'; 701 702 if (("options" in option_specific_value) && (option_specific_value.validation.max_values == 1)) { 703 // matched_value_key in option_specific_value 704 if ("matched_value_key" in option_specific_value) { 705 $.each(option_specific_value.options, function(option_key, option) { 706 if (option_specific_value.matched_value_key == option_key) { 707 html_inj2 += '<option value="' + option + '" selected>' + option + '</option>'; 708 } else { 709 html_inj2 += '<option value="' + option + '">' + option + '</option>'; 710 } 711 }); 712 } else { 713 html_inj2 += '<option disabled selected>{{ text_select }}</option>'; 714 715 $.each(option_specific_value.options, function(option_key, option) { 716 html_inj2 += '<option value="' + option + '">' + option + '</option>'; 717 }); 718 } 719 720 show_other = false; 721 show_other_value = ''; 722 723 if (option_specific_value.validation.selection_mode == 'FreeText') { 724 if (option_specific_value.unmatched_value != '') { 725 html_inj2 += '<option value="Other" selected>{{ text_other }}</option>'; 726 show_other = true; 727 show_other_value = option_specific_value.unmatched_value; 728 } else { 729 html_inj2 += '<option value="Other">{{ text_other }}</option>'; 730 } 731 } 732 733 html_inj += '<div class="row">'; 734 html_inj += '<div class="col-sm-7">'; 735 html_inj += '<select name="feat[' + option_specific_value.name + ']" class="openbay_data_' + id + ' form-control" id="spec_sel_' + id + '" onchange="toggleSpecOther(' + id + ');">' + html_inj2 + '</select>'; 736 html_inj += '</div>'; 737 738 if (show_other == true) { 739 html_inj += '<div class="col-sm-5" id="spec_' + id + '_other">'; 740 } else { 741 html_inj += '<div class="col-sm-5" id="spec_' + id + '_other" style="display:none;">'; 742 } 743 html_inj += '<input placeholder="{{ text_other }}" type="text" name="featother[' + option_specific_value.name + ']" class="form-control openbay_data_' + id + '" value="' + show_other_value + '"/>'; 744 html_inj += '</div>'; 745 html_inj += '</div>'; 746 } else if (("options" in option_specific_value) && (option_specific_value.validation.max_values > 1)) { 747 html_inj += '<div class="row">'; 748 $.each(option_specific_value.options, function(option_key, option) { 749 html_inj += '<div class="col-sm-2">'; 750 html_inj += '<label class="checkbox-inline">'; 751 html_inj += '<input type="checkbox" name="feat[' + option_specific_value.name + '][]" value="' + option + '" class="openbay_data_' + id + '" /> ' + option; 752 html_inj += '</label>'; 753 html_inj += '</div>'; 754 }); 755 html_inj += '</div>'; 756 } else { 757 html_inj += '<div class="row">'; 758 html_inj += '<div class="col-sm-7">'; 759 html_inj += '<input type="text" name="feat[' + option_specific_value.name + ']" class="openbay_data_' + id + ' form-control col-sm-6" value="' + option_specific_value.unmatched_value + '" />'; 760 html_inj += '</div>'; 761 html_inj += '</div>'; 762 } 763 764 html_inj += '</div>'; 765 html_inj += '</div>'; 766 }); 767 html_inj += '</div>'; 768 html_inj += '</div>'; 769 html_inj += '</div>'; 770 html_inj += '</div>'; 771 html_inj += '</div>'; 772 $('#feature-data-'+id).append(html_inj); 773 } else { 774 $('#feature-data-'+id).text('None'); 775 } 776 } else { 777 alert(data.msg); 778 } 779 780 $('#editFeature_'+id).show(); 781 782 removeCount(); 783 }, 784 failure: function() { 785 removeCount(); 786 }, 787 error: function() { 788 removeCount(); 789 } 790 }); 791 } 792 793 function toggleSpecOther(id) { 794 var selectVal = $('#spec_sel_'+id).val(); 795 if (selectVal == 'Other') { 796 $('#spec_'+id+'_other').show(); 797 } else { 798 $('#spec_'+id+'_other').hide(); 799 } 800 } 801 802 function searchEbayCatalog(id) { 803 var qry = $('#catalog_search_'+id).val(); 804 var cat = $('#finalCat_'+id).val(); 805 var html = ''; 806 $('#catalog-results-'+id).empty().hide(); 807 808 if (qry == '') { 809 $('#catalog_search_'+id).before('<div class="alert alert-danger" id="catalog_search_'+id+'_error"><i class="fa fa-exclamation-circle"></i> {{ text_search_text }}</div>'); 810 } else { 811 $.ajax({ 812 url: 'index.php?route=extension/openbay/ebay/searchEbayCatalog&user_token={{ user_token }}', 813 type: 'POST', 814 dataType: 'json', 815 data: { category_id: cat, page: 1, search: qry }, 816 beforeSend: function() { 817 $('#catalog_search_'+id+'_error').remove(); 818 $('#button-catalog-search-'+id).empty().html('<i class="fa fa-cog fa-lg fa-spin"></i>').attr('disabled','disabled'); 819 }, 820 success: function(data) { 821 if (data.error == false) { 822 if (data.results > 0) { 823 data.products = $.makeArray(data.products); 824 825 $.each(data.products, function(key, val) { 826 html = ''; 827 html += '<div class="well">'; 828 html += '<div class="row">'; 829 html += '<div class="col-sm-1">'; 830 html += '<input type="radio" class="openbay_data_'+id+'" name="catalog_epid_'+id+'" value="'+val.productIdentifier.ePID+'" />'; 831 html += '</div>'; 832 html += '<div class="col-sm-2 text-center">'; 833 if (typeof(val.stockPhotoURL) != "undefined" && val.stockPhotoURL !== null) { 834 html += '<img class="img-thumbnail" src="'+val.stockPhotoURL.thumbnail.value+'"/>'; 835 } else { 836 html += '<span class="img-thumbnail"><i class="fa fa-camera fa-5x"></i></span>'; 837 } 838 html += '</div>'; 839 html += '<div class="col-sm-9">'; 840 html += '<p>'+val.productDetails.value.text.value+'</p>'; 841 html += '</div>'; 842 html += '</div>'; 843 html += '</div>'; 844 845 $('#catalog-results-'+id).append(html).show(); 846 }); 847 } else { 848 $('#catalog-results-'+id).append('<div class="alert alert-warning"><i class="fa fa-warning"></i> {{ text_catalog_no_products }}</div>').show(); 849 } 850 } else { 851 $('#catalog-results-'+id).append('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> '+data.error_message+'</div>').show(); 852 } 853 }, 854 complete: function() { 855 $('#button-catalog-search-'+id).empty().html('<i class="fa fa-lg fa-search"></i> {{ text_search }}').removeAttr('disabled'); 856 }, 857 failure: function() { 858 $('#catalog-results-'+id).append('{{ text_search_failed }}'); 859 }, 860 error: function() { 861 $('#catalog-results-'+id).append('{{ text_search_failed }}'); 862 } 863 }); 864 } 865 } 866 867 function listingDuration(data, id) { 868 var lang = new Array(); 869 var listingDefault = '{{ default.defaults.listing_duration }}'; 870 871 lang["Days_1"] = '1 Day'; 872 lang["Days_3"] = '3 Days'; 873 lang["Days_5"] = '5 Days'; 874 lang["Days_7"] = '7 Days'; 875 lang["Days_10"] = '10 Days'; 876 lang["Days_30"] = '30 Days'; 877 lang["GTC"] = 'GTC'; 878 879 html_inj = ''; 880 $.each(data, function(key, val) { 881 html_inj += '<option value="'+val+'"'; 882 if (val == listingDefault) { html_inj += ' selected="selected"';} 883 html_inj += '>'+lang[val]+'</option>'; 884 }); 885 886 $('#durationRow_'+id).empty().html(html_inj); 887 $('#durationLoading_'+id).hide(); 888 $('#durationContainer_'+id).show(); 889 } 890 891 function categorySuggestedChange(val, id) { 892 $('#cSelections_'+id).hide(); 893 loadCategories(1, true, id); 894 $('#finalCat_'+id).val(val); 895 getCategoryFeatures(val, id); 896 } 897 898 $('#button-verify').bind('click', function() { 899 var id = ''; 900 var name = ''; 901 var processedData = ''; 902 903 overlay('overlay-loading'); 904 905 $('#button-verify').hide(); 906 $('#button-edit').show(); 907 $('#button-submit').show(); 908 909 $.each($('.product_id'), function(i) { 910 id = $(this).val(); 911 name = $('#title_'+$(this).val()).val(); 912 913 $('#product_messages_'+id).html('<div class="alert alert-info"><i class="fa fa-cog fa-lg fa-spin"></i> {{ text_loading }}</div>').show(); 914 $('.product_content_'+id).hide(); 915 $('#product_title_'+id).text(name).show(); 916 917 $('#catalog_epid_'+id).val($("input[type='radio'][name='catalog_epid_"+id+"']:checked").val()); 918 919 processedData = $(".openbay_data_"+id).serialize(); 920 921 $.ajax({ 922 url: 'index.php?route=extension/openbay/ebay/verifyBulk&user_token={{ user_token }}&i='+id, 923 type: 'POST', 924 dataType: 'json', 925 data: processedData, 926 beforeSend: function() { addCount(); }, 927 success: function(data) { 928 var html = ''; 929 if (data.ack != 'Failure') { 930 var fee_total = ''; 931 var currency = ''; 932 933 $('#p_row_buttons_'+data.i).prepend('<a class="btn btn-primary button-preview" target="_BLANK" href="'+data.preview+'">{{ text_preview }}</a>'); 934 935 if (data.errors) { 936 $.each(data.errors, function(k,v) { 937 html += '<div class="alert alert-warning"><i class="fa fa-warning"></i> '+v+'</div>'; 938 }); 939 } 940 941 $.each(data.fees, function(key, val) { 942 if (val.Fee != 0.0 && val.Name != 'ListingFee') { 943 fee_total = fee_total + parseFloat(val.Fee); 944 } 945 currency = val.Cur; 946 }); 947 948 html += '<div class="alert alert-info"><i class="fa fa-info-circle"></i> {{ text_total_fee }} '+currency+' '+parseFloat(fee_total).toFixed(2)+'</div>'; 949 } else { 950 $.each(data.errors, function(k,v) { 951 html += '<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> '+v+'</div>'; 952 }); 953 } 954 $('#product_messages_'+data.i).html(html); 955 removeCount(); 956 }, 957 failure: function() { 958 removeCount(); 959 alert('{{ text_error_reverify }}'); 960 }, 961 error: function() { 962 removeCount(); 963 alert('{{ text_error_reverify }}'); 964 } 965 }); 966 }); 967 }); 968 969 $('#button-edit').bind('click', function() { 970 var id = ''; 971 var name = ''; 972 973 $('#button-verify').show(); 974 $('#button-edit').hide(); 975 $('#button-submit').hide(); 976 $('.button-preview').remove(); 977 $('.button-listing-view').remove(); 978 979 $.each($('.product_id'), function(i) { 980 id = $(this).val(); 981 name = $('#title_'+$(this).val()).val(); 982 $('#product_messages_'+$(this).val()).empty().hide(); 983 $('.product_content_'+$(this).val()).show(); 984 $('#product_title_'+$(this).val()).text(name).hide(); 985 }); 986 }); 987 988 $('#button-submit').bind('click', function() { 989 var confirm_box = confirm('{{ text_ajax_confirm_listing }}'); 990 if (confirm_box) { 991 var id = ''; 992 var name = ''; 993 var processedData = ''; 994 995 overlay('overlay-loading'); 996 997 $('#button-verify').hide(); 998 $('#button-edit').hide(); 999 $('#button-submit').hide(); 1000 $('.button-preview').remove(); 1001 1002 $.each($('.product_id'), function(i) { 1003 id = $(this).val(); 1004 name = $('#title_'+$(this).val()).val(); 1005 1006 $('.product_content_'+$(this).val()).hide(); 1007 $('#product_title_'+$(this).val()).text(name).show(); 1008 1009 $.ajax({ 1010 url: 'index.php?route=extension/openbay/ebay/listItemBulk&user_token={{ user_token }}&i='+id, 1011 type: 'POST', 1012 dataType: 'json', 1013 data: $(".openbay_data_"+id).serialize(), 1014 beforeSend: function() { addCount(); }, 1015 success: function(data) { 1016 var html = ''; 1017 if (data.ack != 'Failure') { 1018 if (data.errors) { 1019 $.each(data.errors, function(k,v) { 1020 html += '<div class="alert alert-warning"><i class="fa fa-warning"></i> '+v+'</div>'; 1021 }); 1022 } 1023 1024 $('#p_row_buttons_'+data.i).prepend('<a class="btn btn-primary button-listing-view" href="{{ listing_link }}'+data.itemid+'" target="_BLANK">{{ button_view }}</a>'); 1025 1026 html += '<div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> {{ text_listed }}'+data.itemid+'</div>'; 1027 } else { 1028 $.each(data.errors, function(k,v) { 1029 html += '<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> '+v+'</div>'; 1030 }); 1031 } 1032 $('#product_messages_'+data.i).html(html).show(); 1033 removeCount(); 1034 }, 1035 failure: function() { 1036 removeCount(); 1037 }, 1038 error: function() { 1039 removeCount(); 1040 } 1041 }); 1042 }); 1043 } 1044 }); 1045 1046 function identifierNotRequired(id) { 1047 var not_required_text = "{{ setting.product_details.product_identifier_unavailable_text }}"; 1048 1049 if ($('#identifier_not_required_' + id + ':checked').length == 1) { 1050 if ($('#identifier_ean_required_' + id).val() == 1) { 1051 $('#identifier_ean_' + id).val(not_required_text); 1052 } 1053 if ($('#identifier_isbn_required_' + id).val() == 1) { 1054 $('#identifier_isbn_' + id).val(not_required_text); 1055 } 1056 if ($('#identifier_upc_required_' + id).val() == 1) { 1057 $('#identifier_upc_' + id).val(not_required_text); 1058 } 1059 } else { 1060 if ($('#identifier_ean_required_' + id).val() == 1) { 1061 $('#identifier_ean_' + id).val($('#identifier_ean_original_' + id).val()); 1062 } 1063 if ($('#identifier_isbn_required_' + id).val() == 1) { 1064 $('#identifier_isbn_' + id).val($('#identifier_isbn_original_' + id).val()); 1065 } 1066 if ($('#identifier_upc_required_' + id).val() == 1) { 1067 $('#identifier_upc_' + id).val($('#identifier_upc_original_' + id).val()); 1068 } 1069 } 1070 } 1071 1072 function showFeatures(id) { 1073 overlay('overlay-feature-'+id); 1074 } 1075 1076 function showCatalog(id) { 1077 overlay('overlay-catalog-'+id); 1078 } 1079 1080 function showProfiles(id) { 1081 overlay('overlay-profile-'+id); 1082 } 1083 1084 function showCategory(id) { 1085 overlay('overlay-category-'+id); 1086 } 1087 1088 function genericProfileChange(id) { 1089 modifyPrices(id); 1090 } 1091 </script> 1092 {{ footer }}