1function get_datatable_language(langid, langcode){ 2 var language = {}; 3 4 switch(langcode) { 5 case 'lat': 6 language = { 7 "emptyTable": "Nema podataka za prikaz", 8 "info": "Prikaz _START_ do _END_ od _TOTAL_ podataka", 9 "infoEmpty": "Prikaz 0 do 0 od 0 podataka", 10 "infoFiltered": "(filtrirano od _MAX_ podataka)", 11 "infoPostFix": "", 12 "thousands": ",", 13 "lengthMenu": "Prikaži _MENU_ podataka", 14 "loadingRecords": "UÄitavanje...", 15 "processing": "Obrada...", 16 "search": "Pretraga:", 17 "zeroRecords": "Nema rezultata za zadati kriterijum", 18 "paginate": { 19 "first": "Prva", 20 "last": "Poslednja", 21 "next": "SledeÄa", 22 "previous": "Predhodna" 23 } 24 }; 25 break; 26 case 'cir': 27 language = { 28 "emptyTable": "Ðема подаÑака за пÑиказ", 29 "info": "ÐÑиказ _START_ до _END_ од _TOTAL_ подаÑака", 30 "infoEmpty": "ÐÑиказ 0 до 0 од 0 подаÑака", 31 "infoFiltered": "(ÑилÑÑиÑано од _MAX_ подаÑака)", 32 "infoPostFix": "", 33 "thousands": ",", 34 "lengthMenu": "ÐÑикажи _MENU_ подаÑака", 35 "loadingRecords": "УÑиÑаванÑе...", 36 "processing": "ÐбÑада...", 37 "search": "ÐÑеÑÑага:", 38 "zeroRecords": "Ðема ÑезÑлÑаÑа за задаÑи кÑиÑеÑиÑÑм", 39 "paginate": { 40 "first": "ÐÑва", 41 "last": "ÐоÑледÑа", 42 "next": "СледеÑа", 43 "previous": "ÐÑеÑÑ Ð¾Ð´Ð½Ð°" 44 } 45 }; 46 break; 47 case 'eng': 48 language = { 49 "emptyTable": "No data to display", 50 "info": "Display _START_ to _END_ from _TOTAL_ rows", 51 "infoEmpty": "Display 0 to 0 from 0 rows", 52 "infoFiltered": "(filtered from _MAX_ rows)", 53 "infoPostFix": "", 54 "thousands": ",", 55 "lengthMenu": "Show _MENU_ rows", 56 "loadingRecords": "Loading...", 57 "processing": "Processing...", 58 "search": "Search:", 59 "zeroRecords": "Nema rezultata za zadati kriterijum", 60 "paginate": { 61 "first": "First", 62 "last": "Last", 63 "next": "Next", 64 "previous": "Previous" 65 } 66 }; 67 break; 68 default: 69 language = { 70 "emptyTable": "Nema podataka za prikaz", 71 "info": "Prikaz _START_ do _END_ od _TOTAL_ podataka", 72 "infoEmpty": "Prikaz 0 do 0 od 0 podataka", 73 "infoFiltered": "(filtrirano od _MAX_ podataka)", 74 "infoPostFix": "", 75 "thousands": ",", 76 "lengthMenu": "Prikaži _MENU_ podataka", 77 "loadingRecords": "UÄitavanje...", 78 "processing": "Obrada...", 79 "search": "Pretraga:", 80 "zeroRecords": "Nema rezultata za zadati kriterijum", 81 "paginate": { 82 "first": "Prva", 83 "last": "Poslednja", 84 "next": "SledeÄa", 85 "previous": "Predhodna" 86 } 87 }; 88 } 89 return language; 90} 91 92function orderSetInfoData(customerName, customerLastName, customerEmail, customerPhone, customerAddress, customerCity, customerZipCode, customerPaymentType, recipientName, recipientLastName, recipientPhone, recipientAddress, recipientCity, recipientZipCode, deliveryType, deliveryPersonalId, deliveryServiceId){ 93 var data = { 94 action: 'setorderinfodata', 95 customername:customerName, 96 customerlastname:customerLastName, 97 customeremail:customerEmail, 98 customerphone:customerPhone, 99 customeraddress:customerAddress, 100 customercity:customerCity, 101 customerzipcode:customerZipCode, 102 customerpaymenttype:customerPaymentType, 103 recipientname:recipientName, 104 recipientlastname:recipientLastName, 105 recipientphone:recipientPhone, 106 recipientaddress:recipientAddress, 107 recipientcity:recipientCity, 108 recipientzipcode:recipientZipCode, 109 deliverytype:deliveryType, 110 deliverypersonalid:deliveryPersonalId, 111 deliveryserviceid:deliveryServiceId 112 }; 113 $.ajax({ 114 type: "POST", 115 data: data, 116 url: "index.php", 117 error: function (XMLHttpRequest, textStatus, errorThrown) { 118 alert("ERROR:" + errorThrown); 119 }, 120 success: function (response) { 121 if(response=='orderinfodataset'){ 122 window.location.href = "checkout_confirmation"; 123 } 124 } 125 }); 126 127} 128 129function updateProductRating(productId,newRating){ 130 var data = { 131 action: 'updateproductrating', 132 productid:productId, 133 newrating:newRating 134 }; 135 $.ajax({ 136 type: "POST", 137 data: data, 138 url: "index.php", 139 error: function (XMLHttpRequest, textStatus, errorThrown) { 140 alert("ERROR:" + errorThrown); 141 }, 142 success: function (response) { 143 window.location.reload(); 144 } 145 }); 146 147} 148 149function get_commercialist_partners(){
150 var partnerid = $('.container_commercilalist_partner').attr('partnerid'); 151 var partneraddressid = $('.container_commercilalist_partner').attr('partneraddressid'); 152 var langid=$('.container_commercilalist_partner').attr('langid'); 153 var langcode=$('.container_commercilalist_partner').attr('langcode'); 154 155 //IMPORTANT 156 var language = {}; 157 language = get_datatable_language(langid,langcode); 158 //IMPORTANT END 159 160 161 162 $("#commercilalist_partner").DataTable({ 163 stateSave: true, 164 "processing": true, 165 "serverSide": true, 166 "ajax":{ 167 url :"index.php", // json datasource 168 type: "post", // method , by default get 169 data: ({action : 'getcommercialistpartner', 170 partnerid : function() { return $('.container_commercilalist_partner').attr('partnerid') }, 171 partneraddressid : function() { return $('.container_commercilalist_partner').attr('partneraddressid') } 172 }), 173 error: function(){ // error handling 174 $(".commercilalist_partner-grid-error").html(""); 175 $("#commercilalist_partner").append('<tbody class="employee-grid-error"><tr><th colspan="3">Nema pronaÄenih podataka</th></tr></tbody>'); 176 $("#commercilalist_partner-grid_processing").css("display","none"); 177 }, 178 dataSrc: function(a){ 179 console.log(a); 180 for(var i = 0; i < a.aaData.length;i++) 181 { 182 var partnerAddress = ''; 183 if(a.aaData[i][3].length>0){ 184 var partnerAddress = '<div class="row"> <div class="col-lg-12"><label>'+a.aaData[i][2]+'</label>'; 185 186 for(var j = 0; j < a.aaData[i][3].length;j++) 187 { 188 189 partnerAddressRow='<div class="row">'; 190 partnerAddressRow=partnerAddressRow+'<div class="col-lg-9">'+a.aaData[i][3][j].objectname+' - '+a.aaData[i][3][j].address+', '+a.aaData[i][3][j].city+' '+a.aaData[i][3][j].zip+'</div>'; 191 partnerAddressRow=partnerAddressRow+'<div class="col-lg-3 partnerAddressSelectCont">';//<button class="btn btn-primary -child partnerAddressSelectBTN" style="padding:2px 4px!important;" partnerid="'+a.aaData[i][99]+'" partneraddressid="'+a.aaData[i][3][j].partneraddressid+'">Izaberi adresu partnera</button></div>'; 192 var clone = $('.partnerAddressSelectBTNTemplate').clone(true).removeClass('partnerAddressSelectBTNTemplate').addClass('partnerAddressSelectBTN').removeClass('hide'); 193 $(clone).attr('partnerid', a.aaData[i][99]); 194 $(clone).attr('partneraddressid', a.aaData[i][3][j].partneraddressid); 195 196 // partnerAddressRow.append(clone); 197 partnerAddressRow=partnerAddressRow+clone.get(0).outerHTML+'</div>'; 198 partnerAddress=partnerAddress+partnerAddressRow; 199 200 } 201 partnerAddress=partnerAddress+'</div></div>'; 202 } else { 203 partnerAddress = a.aaData[i][2]; 204 } 205 206 207 a.aaData[i][2] = partnerAddress; 208 209 210 var infoBTN = ''; 211 var clone = $('.partnerInfoBTNTemplate').clone(true).removeClass('partnerInfoBTNTemplate').addClass('partnerInfoBTN').removeClass('hide'); 212 $(clone).attr('partnerid', a.aaData[i][99]); 213 $(clone).attr('partneraddressid', 0); 214 infoBTN = clone.get(0).outerHTML; 215 216 var selectBTN = ''; 217 var clone = $('.partnerSelectBTNTemplate').clone(true).removeClass('partnerSelectBTNTemplate').addClass('partnerSelectBTN').removeClass('hide'); 218 $(clone).attr('partnerid', a.aaData[i][99]); 219 $(clone).attr('partneraddressid', 0); 220 selectBTN = clone.get(0).outerHTML; 221 222 223 a.aaData[i][3] = infoBTN +" "+ selectBTN; 224 225 226 //a.aaData[i][5] = selectBTN; 227 } 228 229 $(".loadingIcon").addClass("hide"); 230 $(".runReportCont").removeClass('hide'); 231 232 return a.aaData; 233 } 234 }, 235 "language": language 236 }).on('click','.partnerInfoBTN', function(){ 237 alert('partnerid='+$(this).attr('partnerid')+' partneraddressid='+$(this).attr('partneraddressid')); 238 // var documentid=$(this).attr('documentid'); 239 // if(documentid !='' && documentid>0 ){ 240 // var getUrl = window.location; 241 // var baseUrl = getUrl .protocol + "//" + getUrl.host + "/" + getUrl.pathname.split('/')[1]+"/invoice/change/"+documentid; 242 // var win = window.open(baseUrl, '_blank'); 243 // win.focus(); 244 // } else { 245 // alert('DoÅ¡lo je do greÅ¡ke. LOCATE_DOC_0001'); 246 // } 247 248 }).on('click','.partnerSelectBTN', function(){ 249 //alert('partnerid='+$(this).attr('partnerid')+' partneraddressid='+$(this).attr('partneraddressid')); 250 commercialistSelectPartner($(this).attr('partnerid'),$(this).attr('partneraddressid')); 251 }).on('click','.partnerAddressSelectBTN', function(){ 252 //alert('partnerid='+$(this).attr('partnerid')+' partneraddressid='+$(this).attr('partneraddressid')); 253 commercialistSelectPartner($(this).attr('partnerid'),$(this).attr('partneraddressid')); 254 }); 255} 256 257function commercialistSelectPartner(partnerid,partneraddressid){ 258 var data = { 259 action: 'setcommercialistpartner', 260 partnerid:partnerid, 261 partneraddressid:partneraddressid 262 }; 263 $.ajax({ 264 type: "POST", 265 data: data, 266 url: "index.php", 267 error: function (XMLHttpRequest, textStatus, errorThrown) { 268 alert("ERROR:" + errorThrown); 269 }, 270 success: function (response) { 271 window.location.href = "commercialist_select_partner"; 272 } 273 }); 274} 275function commercialistPartnerInfo(partnerid,partneraddressid){ 276 var data = { 277 action: 'commercialistpartnerinfo', 278 partnerid:partnerid, 279 partneraddressid:partneraddressid 280 }; 281 $.ajax({ 282 type: "POST", 283 data: data, 284 url: "index.php", 285 error: function (XMLHttpRequest, textStatus, errorThrown) { 286 alert("ERROR:" + errorThrown); 287 }, 288 success: function (response) { 289 //if(response == 0){ 290 // alertify.error('Error: 2001. User data not updated!!!'); 291 //} 292 } 293 }); 294} 295function commercialistSelectPartnerWithAddress(partnerid,partneraddressid){ 296 var data = { 297 action: 'setcommercialistpartner', 298 partnerid:partnerid, 299 partneraddressid:partneraddressid 300 }; 301 $.ajax({ 302 type: "POST", 303 data: data, 304 url: "index.php", 305 error: function (XMLHttpRequest, textStatus, errorThrown) { 306 alert("ERROR:" + errorThrown); 307 }, 308 success: function (response) { 309 window.location.href = "commercialist_select_partner"; 310 } 311 }); 312} 313 314function commercialist_remove_select_partner(){ 315 var data = { 316 action: 'removecommercialistselectedpartner' 317 }; 318 $.ajax({ 319 type: "POST", 320 data: data, 321 url: "index.php", 322 error: function (XMLHttpRequest, textStatus, errorThrown) { 323 alert("ERROR:" + errorThrown); 324 }, 325 success: function (response) { 326 window.location.reload(); 327 328 } 329 }); 330} 331 332 333function userLogDataInsertUpdate(){ 334 var data = { 335 action: 'userlogdatauinsertpdate' 336 }; 337 $.ajax({ 338 type: "POST", 339 data: data, 340 url: "index.php", 341 error: function (XMLHttpRequest, textStatus, errorThrown) { 342 alert("ERROR:" + errorThrown); 343 }, 344 success: function (response) { 345 //if(response == 0){ 346 // alertify.error('Error: 2001. User data not updated!!!'); 347 //} 348 349 } 350 }); 351} 352 353 354function addToShopcart(id, ime, cena, rebate, tax, slika, kolicina, attr, lang, langcode, unitname, unitstep) { 355 var d = { 356 action : 'prodhaveattrs', 357 id: id 358 } 359 $.ajax({ 360 type: 'POST', 361 data: d, 362 url: 'index.php', 363 error: function (XMLHttpRequest, textStatus, errorThrown) { 364 alert("ERROR:" + errorThrown); 365 }, 366 success: function (response) { 367 console.log(response); 368 if (response == 1) { 369 alert('ima attr');
370 location.href = '?page=proizvod&id=' + id; 371 return; 372 } 373 else { 374 var data = { 375 action : 'addtocart', 376 id: id, 377 name: ime, 378 price: cena, 379 rebate: rebate, 380 tax: tax, 381 pic: slika, 382 qty: kolicina, 383 attr: attr, 384 unitname: unitname, 385 unitstep: unitstep 386 }; 387 $.ajax({ 388 type: "POST", 389 data: data, 390 url: "index.php", 391 error: function (XMLHttpRequest, textStatus, errorThrown) { 392 alert("ERROR:" + errorThrown); 393 }, 394 success: function (response) { 395 //alert(response); 396 var a = JSON.parse(response); 397 var shopcartitemcount = a[0].shopcartitemcount; 398 var lastaddedproductqty = a[0].lastaddedproductqty; 399 var newshopcartcount = parseInt(shopcartitemcount); 400 $(".cms_shopcartCount").text(newshopcartcount); 401 //var shopcartcount = $(".cms_shopcartCount").text(); 402 // 403 404 //$("#cart_item_counter").html(coun); 405 $( ".cms_productInputDecIncCont" ).each(function() { 406 //alert($( this ).attr('prodid')+' = '+id); 407 //alert(JSON.parse($( this ).attr('attr'))); 408 //alert($( this ).attr('attr')+' = '+attr); 409 if( ($( this ).attr('prodid')==id) && ($( this ).attr('attr')==attr)){ 410 var max = parseFloat($( this ).find('.cms_productQtyInput').attr('maxquantity')); 411 var cartQuantity = parseFloat(lastaddedproductqty); 412 var newMaxQuantity = Math.round((max-cartQuantity)*100)/100 ; 413 $( this ).find('.cms_productQtyInput').attr('max',newMaxQuantity); 414 415 } 416 417 }); 418 if($(".product_add_to_shopcart").hasClass('add2cart')){ 419 $( ".cms_productInputDecIncCont" ).each(function() { 420 //alert($( this ).attr('prodid')+' = '+id); 421 //alert(JSON.parse($( this ).attr('attr'))); 422 //alert(JSON.parse($( this ).attr('attr'))+' = '+attr); 423 if( ($( this ).attr('prodid')==id) && (JSON.parse($( this ).attr('attr'))==attr)){ 424 var max = parseFloat($( this ).find('.cms_productQtyInput').attr('maxquantity')); 425 var cartQuantity = parseFloat(lastaddedproductqty); 426 var newMaxQuantity = Math.round((max-cartQuantity)*100)/100 ; 427 $( this ).find('.cms_productQtyInput').attr('max',newMaxQuantity); 428 429 } 430 431 }); 432 } 433 if($(".product_add_to_shopcart").hasClass('product')){ 434 var max = parseFloat($(".product_add_to_shopcart").parent().find('.cms_productQtyInput').attr('maxquantity')); 435 var cartQuantity = parseFloat(lastaddedproductqty); 436 var newMaxQuantity = Math.round((max-cartQuantity)*100)/100 ; 437 $(".product_add_to_shopcart").parent().find('.cms_productQtyInput').attr('max',newMaxQuantity); 438 } 439 440 441 442 443 444 445 var msg = ""; 446 switch (langcode) { 447 case 'lat': 448 msg = 'Proizvod '+ime+' je dodat u korpu.'; 449 break; 450 case 'eng': 451 msg = 'Product '+ime+' has been added to the cart.'; 452 break; 453 case 'cir': 454 msg = 'ÐÑоизвод '+ime+' Ñе Ð´Ð¾Ð´Ð°Ñ Ñ ÐºÐ¾ÑпÑ.'; 455 break; 456 default: 457 msg = 'Proizvod '+ime+' je dodat u korpu.'; 458 } 459 alertify.success(msg); 460 } 461 }); 462 } 463 } 464 }); 465 466 467}
468function addToShopcartRequest(id, ime, cena, rebate, tax, slika, kolicina, attr, lang, langcode, unitname, unitstep) { 469 var d = { 470 action : 'prodhaveattrs', 471 id: id 472 } 473 $.ajax({ 474 type: 'POST', 475 data: d, 476 url: 'index.php', 477 error: function (XMLHttpRequest, textStatus, errorThrown) { 478 alert("ERROR:" + errorThrown); 479 }, 480 success: function (response) { 481 console.log(response); 482 if (response == 1) { 483 alert('ima attr'); 484 location.href = '?page=proizvod&id=' + id; 485 return; 486 } 487 else { 488 var data = { 489 action : 'addtocartrequest', 490 id: id, 491 name: ime, 492 price: cena, 493 rebate: rebate, 494 tax: tax, 495 pic: slika, 496 qty: kolicina, 497 attr: attr, 498 unitname: unitname, 499 unitstep: unitstep 500 }; 501 $.ajax({ 502 type: "POST", 503 data: data, 504 url: "index.php", 505 error: function (XMLHttpRequest, textStatus, errorThrown) { 506 alert("ERROR:" + errorThrown); 507 }, 508 success: function (response) { 509 var a = JSON.parse(response); 510 var shopcartitemcount = a[0].shopcartitemcount; 511 var lastaddedproductqty = a[0].lastaddedproductqty; 512 var newshopcartcount = parseInt(shopcartitemcount); 513 $(".cms_shopcartCount").text(newshopcartcount); 514 515 $( ".cms_productInputDecIncCont" ).each(function() { 516 if( ($( this ).attr('prodid')==id) && ($( this ).attr('attr')==attr)){ 517 var max = parseFloat($( this ).find('.cms_productQtyInput').attr('maxquantity')); 518 var cartQuantity = parseFloat(lastaddedproductqty); 519 var newMaxQuantity = Math.round((max-cartQuantity)*100)/100 ; 520 $( this ).find('.cms_productQtyInput').attr('max',newMaxQuantity); 521 522 } 523 524 }); 525 526 var msg = ""; 527 switch (langcode) { 528 case 'lat': 529 msg = 'Proizvod '+ime+' je dodat u korpu.'; 530 break; 531 case 'eng': 532 msg = 'Product '+ime+' has been added to the cart.'; 533 break; 534 case 'cir': 535 msg = 'ÐÑоизвод '+ime+' Ñе Ð´Ð¾Ð´Ð°Ñ Ñ ÐºÐ¾ÑпÑ.'; 536 break; 537 default: 538 msg = 'Proizvod '+ime+' je dodat u korpu.'; 539 } 540 alertify.success(msg); 541 } 542 }); 543 } 544 } 545 }); 546 547 548} 549 550 551function addToShopcartB2B(id, ime, cena, rebate, tax, slika, kolicina, attr, lang, langcode, unitname, unitstep) { 552 553// var base = jQuery('base')[0].baseURI; 554 var d = { 555 action : 'prodhaveattrs', 556 id: id 557 } 558 $.ajax({ 559 type: 'POST', 560 data: d, 561 url: 'index.php', 562 error: function (XMLHttpRequest, textStatus, errorThrown) { 563 alert("ERROR:" + errorThrown); 564 }, 565 success: function (response) { 566 console.log(response); 567 if (response == 1) { 568 //alert('ima attr'); 569 location.href = '?page=proizvod&id=' + id; 570 return; 571 } 572 else { 573 var data = { 574 action : 'addtocartB2B', 575 id: id, 576 name: ime, 577 price: cena, 578 rebate: rebate, 579 tax: tax, 580 pic: slika, 581 qty: kolicina, 582 attr: attr, 583 unitname: unitname, 584 unitstep: unitstep 585 }; 586 $.ajax({ 587 type: "POST", 588 data: data, 589 url: "index.php", 590 error: function (XMLHttpRequest, textStatus, errorThrown) { 591 alert("ERROR:" + errorThrown); 592 }, 593 success: function (response) { 594 //alert(response); 595 var coun = JSON.parse(response); 596 var a = JSON.parse(response); 597 var shopcartitemcount = a[0].shopcartitemcount; 598 var lastaddedproductqty = a[0].lastaddedproductqty; 599 var newshopcartcount = parseInt(shopcartitemcount); 600 $(".cms_shopcartCount").text(newshopcartcount); 601 602 603 604 605 if($(".product_add_to_shopcartB2B").hasClass('b2baddtocart')){ 606 $( ".cms_productInputDecIncCont" ).each(function() { 607 //alert($( this ).attr('prodid')+' = '+id); 608 //alert(JSON.parse($( this ).attr('attr'))); 609 //alert($( this ).attr('attr')+' = '+attr); 610 if( ($( this ).attr('prodid')==id)){ 611 var max = parseFloat($( this ).find('.cms_productQtyInput').attr('maxquantity')); 612 var cartQuantity = parseFloat(lastaddedproductqty); 613 var newMaxQuantity = Math.round((max-cartQuantity)*100)/100 ; 614 $( this ).find('.cms_productQtyInput').attr('max',newMaxQuantity); 615 616 } 617 618 }); 619 620 621 } else { 622 //set rest quantity and new max quantity 623 $( ".cms_productInputDecIncCont" ).each(function() { 624 //alert($( this ).attr('prodid')+' = '+id); 625 //alert(JSON.parse($( this ).attr('attr'))); 626 //alert($( this ).attr('attr')+' = '+attr); 627 if( ($( this ).attr('prodid')==id) && ($( this ).attr('attr')==attr)){ 628 var max = parseFloat($( this ).find('.cms_productQtyInput').attr('maxquantity')); 629 var cartQuantity = parseFloat(lastaddedproductqty); 630 var newMaxQuantity = Math.round((max-cartQuantity)*100)/100 ; 631 $( this ).find('.cms_productQtyInput').attr('max',newMaxQuantity); 632 633 } 634 635 }); 636 637 } 638 639 640 if($(".product_add_to_shopcartB2B").hasClass('product')){ 641 var max = parseFloat($(".product_add_to_shopcartB2B").parent().find('.cms_productQtyInput').attr('maxquantity')); 642 var cartQuantity = parseFloat(lastaddedproductqty); 643 var newMaxQuantity = Math.round((max-cartQuantity)*100)/100 ; 644 $(".product_add_to_shopcartB2B").parent().find('.cms_productQtyInput').attr('max',newMaxQuantity); 645 } 646 647 648 var viewtype = ''; 649 //check if function called from B2BLineProductBox for Regular Type 650 $( ".product_add_to_shopcartB2B" ).each(function() { 651 if( ($( this ).attr('prodid')==id) && ($( this ).attr('attr')==attr)){ 652 if($( this ).hasClass('dualcode')){ 653 viewtype='B2BLine'; 654 } 655 } 656 657 }); 658 659 //if function called from B2BLineProductBox set check icon 660 if(viewtype='B2BLine'){ 661 //show quantity from shopcart 662 $( ".cms_product_with_attribut_quantity_in_chart" ).each(function() { 663 if( ($( this ).attr('prodid')==id) && ($( this ).attr('attr')==attr)){ 664 $( this ).text(lastaddedproductqty); 665 } 666 667 }); 668 $( ".jq_productLineOK" ).each(function() { 669 if( ($( this ).attr('prodid')==id) && ($( this ).attr('attr')==attr)){ 670 $( this ).html('<i class="fa fa-2x fa-check-square" aria-hidden="true" style="color:#00970C"></i>'); 671 } 672 673 }); 674 } 675 676 //product_add_to_shopcart_requestB2B 677 678 var msg = ""; 679 switch (langcode) { 680 case 'lat': 681 msg = 'Proizvod '+ime+' je dodat u korpu.'; 682 break; 683 case 'eng': 684 msg = 'Product '+ime+' has been added to the cart.'; 685 break; 686 case 'cir': 687 msg = 'ÐÑоизвод '+ime+' Ñе Ð´Ð¾Ð´Ð°Ñ Ñ ÐºÐ¾ÑпÑ.'; 688 break; 689 default: 690 msg = 'Proizvod '+ime+' je dodat u korpu.'; 691 } 692 alertify.success(msg); 693 } 694 }); 695 } 696 } 697 }); 698} 699 700 701function addToShopcartRequestB2B(id, ime, cena, rebate, tax, slika, kolicina, attr, lang, langcode, unitname, unitstep) { 702 var d = { 703 action : 'prodhaveattrs', 704 id: id 705 } 706 $.ajax({ 707 type: 'POST', 708 data: d, 709 url: 'index.php', 710 error: function (XMLHttpRequest, textStatus, errorThrown) { 711 alert("ERROR:" + errorThrown); 712 }, 713 success: function (response) { 714 console.log(response); 715 if (response == 1) { 716 alert('ima attr');
717 location.href = '?page=proizvod&id=' + id; 718 return; 719 } 720 else { 721 var data = { 722 action : 'addtocartrequestb2b', 723 id: id, 724 name: ime, 725 price: cena, 726 rebate: rebate, 727 tax: tax, 728 pic: slika, 729 qty: kolicina, 730 attr: attr, 731 unitname: unitname, 732 unitstep: unitstep 733 }; 734 $.ajax({ 735 type: "POST", 736 data: data, 737 url: "index.php", 738 error: function (XMLHttpRequest, textStatus, errorThrown) { 739 alert("ERROR:" + errorThrown); 740 }, 741 success: function (response) { 742 //alert(response); 743 var coun = JSON.parse(response); 744 var a = JSON.parse(response); 745 var shopcartitemcount = a[0].shopcartitemcount; 746 var lastaddedproductqty = a[0].lastaddedproductqty; 747 var newshopcartcount = parseInt(shopcartitemcount); 748 $(".cms_shopcartCount").text(newshopcartcount); 749 750 751 752 var viewtype = ''; 753 //check if function called from B2BLineProductBox for Regular Type 754 $( ".product_add_to_shopcart_requestB2B" ).each(function() { 755 if( ($( this ).attr('prodid')==id) && ($( this ).attr('attr')==attr)){ 756 if($( this ).hasClass('dualcode')){ 757 viewtype='B2BLine'; 758 } 759 } 760 761 }); 762 763 //if function called from B2BLineProductBox set check icon 764 if(viewtype='B2BLine'){ 765 //show quantity from shopcart 766 $( ".cms_product_with_attribut_quantity_in_chart_request" ).each(function() { 767 if( ($( this ).attr('prodid')==id) && ($( this ).attr('attr')==attr)){ 768 $( this ).text(lastaddedproductqty); 769 } 770 771 }); 772 $( ".jq_productLineOK" ).each(function() { 773 if( ($( this ).attr('prodid')==id) && ($( this ).attr('attr')==attr)){ 774 $( this ).html('<i class="fa fa-2x fa-check-square" aria-hidden="true" style="color:#00970C"></i>'); 775 } 776 777 }); 778 } 779 780 var msg = ""; 781 switch (langcode) { 782 case 'lat': 783 msg = 'Proizvod '+ime+' je dodat u korpu.'; 784 break; 785 case 'eng': 786 msg = 'Product '+ime+' has been added to the cart.'; 787 break; 788 case 'cir': 789 msg = 'ÐÑоизвод '+ime+' Ñе Ð´Ð¾Ð´Ð°Ñ Ñ ÐºÐ¾ÑпÑ.'; 790 break; 791 default: 792 msg = 'Proizvod '+ime+' je dodat u korpu.'; 793 } 794 alertify.success(msg); 795 } 796 }); 797 } 798 } 799 }); 800 801 802} 803 804//prazni $_SESSION['shopcart']; 805function emptyCart(){ 806 var data = { 807 action : 'emptycart' 808 }; 809 $.ajax({ 810 type: "POST", 811 data: data, 812 url: "index.php", 813 error: function (XMLHttpRequest, textStatus, errorThrown) { 814 alert("ERROR:" + errorThrown); 815 }, 816 success: function (response) { 817 var msg = "Ispraznjena korpa"; 818 alertify.success(msg); 819 } 820 }); 821} 822function changeProdQtyInCart(cartPosition, qty){ 823 var data = { 824 action : 'changeProdQtyInCart', 825 cartposition: cartPosition, 826 qty: qty 827 }; 828 $.ajax({ 829 type: "POST", 830 data: data, 831 url: "index.php", 832 error: function (XMLHttpRequest, textStatus, errorThrown) { 833 alert("ERROR:" + errorThrown); 834 }, 835 success: function (response) { 836 if(response == 1){ 837 var msg = "chaned"; 838 alertify.success(msg); 839 } 840 else{ 841 var msg = "error prod in cart not exist"; 842 alertify.error(msg); 843 } 844 845 } 846 }); 847} 848function removeProdInCart(cartPosition){ 849 var data = { 850 action : 'removeProdInCart', 851 cartposition: cartPosition 852 }; 853 $.ajax({ 854 type: "POST", 855 data: data, 856 url: "index.php", 857 error: function (XMLHttpRequest, textStatus, errorThrown) { 858 alert("ERROR:" + errorThrown); 859 }, 860 success: function (response) { 861 if(response == 1){ 862 window.location.reload(); 863 } 864 else{ 865 window.location.reload(); 866 //var msg = "error prod in cart not exist"; 867 //alertify.error(msg); 868 } 869 870 } 871 }); 872}
873function removeProdInCartRequest(cartPosition){ 874 var data = { 875 action : 'removeProdInCartRequest', 876 cartposition: cartPosition 877 }; 878 $.ajax({ 879 type: "POST", 880 data: data, 881 url: "index.php", 882 error: function (XMLHttpRequest, textStatus, errorThrown) { 883 alert("ERROR:" + errorThrown); 884 }, 885 success: function (response) { 886 if(response == 1){ 887 var msg = "chaned"; 888 window.location.reload(); 889 alertify.success(msg); 890 } 891 else{ 892 window.location.reload(); 893 //var msg = "error prod in cart not exist"; 894 //alertify.error(msg); 895 } 896 897 } 898 }); 899} 900function removeProdInCartB2B(cartPosition){ 901 var data = { 902 action : 'removeProdInCartB2B', 903 cartposition: cartPosition 904 }; 905 $.ajax({ 906 type: "POST", 907 data: data, 908 url: "index.php", 909 error: function (XMLHttpRequest, textStatus, errorThrown) { 910 alert("ERROR:" + errorThrown); 911 }, 912 success: function (response) { 913 if(response == 1){ 914 var msg = "chaned"; 915 window.location.reload(); 916 alertify.success(msg); 917 } 918 else{ 919 window.location.reload(); 920 //var msg = "error prod in cart not exist"; 921 //alertify.error(msg); 922 } 923 924 } 925 }); 926} 927function addProdToWatched(prodid){ 928 var data = { 929 action : 'addProdToWatched', 930 prodid: prodid 931 }; 932 $.ajax({ 933 type: "POST", 934 data: data, 935 url: "index.php", 936 error: function (XMLHttpRequest, textStatus, errorThrown) { 937 alert("ERROR:" + errorThrown); 938 }, 939 success: function (response) { 940 if(response == 1){ 941 var msg = "chaned"; 942 alertify.success(msg); 943 } 944 else{ 945 var msg = "error"; 946 alertify.error(msg); 947 } 948 949 } 950 }); 951} 952 953function createReservation(){ 954 var data = { 955 action : 'createReservation' 956 }; 957 $.ajax({ 958 type: "POST", 959 data: data, 960 url: "index.php", 961 error: function (XMLHttpRequest, textStatus, errorThrown) { 962 alert("ERROR:" + errorThrown); 963 }, 964 success: function (response) { 965 if(response == 1){ 966 var msg = "added success"; 967 alertify.success(msg); 968 } 969 else{ 970 var msg = "error create"; 971 alertify.error(msg); 972 } 973 974 } 975 }); 976} 977 978function addToCompare(prodid, img){ 979 var data = { 980 action : 'addToCompare', 981 prodid: prodid 982 }; 983 $.ajax({ 984 type: "POST", 985 data: data, 986 url: "index.php", 987 error: function (XMLHttpRequest, textStatus, errorThrown) { 988 alert("ERROR:" + errorThrown); 989 }, 990 success: function (response) { 991 if(response == 1){ 992 993 createCompareSmallBox(prodid, img); 994 /* need add image to toolbox */ 995 996 var msg = "Dodato u uporedjivanje"; 997 alertify.success(msg); 998 } 999 else{ 1000 var msg = "Nije dodato u uporedjivanje"; 1001 alertify.error(msg); 1002 } 1003 window.location.reload(); 1004 } 1005 }); 1006} 1007 1008function removeFromCompare(prodid){ 1009 var data = { 1010 action : 'removeFromCompare', 1011 prodid: prodid 1012 }; 1013 $.ajax({ 1014 type: "POST", 1015 data: data, 1016 url: "index.php", 1017 error: function (XMLHttpRequest, textStatus, errorThrown) { 1018 alert("ERROR:" + errorThrown); 1019 }, 1020 success: function (response) { 1021 window.location.reload(); 1022 } 1023 }); 1024} 1025 1026function addToWishList(prodid){ 1027 var data = { 1028 action : 'addToWishList', 1029 prodid: prodid 1030 }; 1031 $.ajax({ 1032 type: "POST", 1033 data: data, 1034 url: "index.php", 1035 error: function (XMLHttpRequest, textStatus, errorThrown) { 1036 alert("ERROR:" + errorThrown); 1037 }, 1038 success: function (response) { 1039 if(response == 1){ 1040 var msg = "Proizvod je dodat u Listu želja"; 1041 alertify.success(msg); 1042 } 1043 else{ 1044 var msg = "Proizvod nije dodato u listu želja."; 1045 alertify.error(msg); 1046 } 1047 window.location.reload(); 1048 } 1049 }); 1050} 1051 1052 1053 1054function removeFromWishList(prodid){ 1055 var data = { 1056 action : 'removeFromWishList', 1057 prodid: prodid 1058 }; 1059 $.ajax({ 1060 type: "POST", 1061 data: data, 1062 url: "index.php", 1063 error: function (XMLHttpRequest, textStatus, errorThrown) { 1064 alert("ERROR:" + errorThrown); 1065 }, 1066 success: function (response) { 1067 window.location.reload(); 1068 } 1069 }); 1070} 1071 1072 1073function setArticleQtyInShopcart(cart_position, qty) { 1074 var data = { 1075 action: 'setarticleqtyinshopcart', 1076 cart_position: cart_position, 1077 qty: qty 1078 }; 1079 $.ajax({ 1080 type: "POST", 1081 data: data, 1082 url: "index.php", 1083 error: function (XMLHttpRequest, textStatus, errorThrown) { 1084 alert("ERROR:" + errorThrown); 1085 }, 1086 success: function (response) { 1087 window.location.reload(); 1088 } 1089 }); 1090} 1091
1092function setArticleQtyInShopcartRequest(cart_position, qty) { 1093 var data = { 1094 action: 'setarticleqtyinshopcartrequest', 1095 cart_position: cart_position, 1096 qty: qty 1097 }; 1098 $.ajax({ 1099 type: "POST", 1100 data: data, 1101 url: "index.php", 1102 error: function (XMLHttpRequest, textStatus, errorThrown) { 1103 alert("ERROR:" + errorThrown); 1104 }, 1105 success: function (response) { 1106 window.location.reload(); 1107 } 1108 }); 1109} 1110function setArticleQtyInShopcartB2B(cart_position, qty) { 1111 var data = { 1112 action: 'setarticleqtyinshopcartB2B', 1113 cart_position: cart_position, 1114 qty: qty 1115 }; 1116 $.ajax({ 1117 type: "POST", 1118 data: data, 1119 url: "index.php", 1120 error: function (XMLHttpRequest, textStatus, errorThrown) { 1121 alert("ERROR:" + errorThrown); 1122 }, 1123 success: function (response) { 1124 window.location.reload(); 1125 } 1126 }); 1127} 1128 1129function setOrderingPayment(paymenttype){ 1130 var data = { 1131 action: 'setorderingaddress', 1132 ime: ime, 1133 prezime: prezime, 1134 adresa: adresa, 1135 telefon: telefon, 1136 mesto: mesto, 1137 postbr: postbr, 1138 email: email 1139 }; 1140 $.ajax({ 1141 type: "POST", 1142 data: data, 1143 url: "index.php", 1144 error: function (XMLHttpRequest, textStatus, errorThrown) { 1145 alert("ERROR:" + errorThrown); 1146 }, 1147 success: function (response) { 1148 if(response == 1){ 1149 window.location.href = "order_address_delivery"; 1150 } 1151 1152 } 1153 }); 1154} 1155 1156function setOrderingAddress(ime, prezime, adresa, telefon, mesto, postbr, email){ 1157 var data = { 1158 action: 'setorderingaddress', 1159 ime: ime, 1160 prezime: prezime, 1161 adresa: adresa, 1162 telefon: telefon, 1163 mesto: mesto, 1164 postbr: postbr, 1165 email: email 1166 }; 1167 $.ajax({ 1168 type: "POST", 1169 data: data, 1170 url: "index.php", 1171 error: function (XMLHttpRequest, textStatus, errorThrown) { 1172 alert("ERROR:" + errorThrown); 1173 }, 1174 success: function (response) { 1175 if(response == 1){ 1176 window.location.href = "order_address_delivery"; 1177 } 1178 1179 } 1180 }); 1181} 1182function setOrderingAddressDelivery(ime, prezime, adresa, telefon, mesto, postbr, email){ 1183 var data = { 1184 action: 'setorderingaddressdelivery', 1185 ime: ime, 1186 prezime: prezime, 1187 adresa: adresa, 1188 telefon: telefon, 1189 mesto: mesto, 1190 postbr: postbr, 1191 email: email 1192 }; 1193 $.ajax({ 1194 type: "POST", 1195 data: data, 1196 url: "index.php", 1197 error: function (XMLHttpRequest, textStatus, errorThrown) { 1198 alert("ERROR:" + errorThrown); 1199 }, 1200 success: function (response) { 1201 if(response == 1){ 1202 window.location.href = "order_payment"; 1203 } 1204 1205 } 1206 }); 1207} 1208function removeOrderingAddress(){ 1209 var data = { 1210 action: 'deleteorderingaddress' 1211 }; 1212 $.ajax({ 1213 type: "POST", 1214 data: data, 1215 url: "index.php", 1216 error: function (XMLHttpRequest, textStatus, errorThrown) { 1217 alert("ERROR:" + errorThrown); 1218 }, 1219 success: function (response) { 1220 if(response == 1){ 1221 alertify.success('order address removed'); 1222 } 1223 if(response == 0){ 1224 alertify.error('order address was empty'); 1225 } 1226 1227 } 1228 }); 1229} 1230 1231function setOrderPayment(payment){ 1232 var data = { 1233 action: 'setorderpayment', 1234 payment: payment 1235 }; 1236 $.ajax({ 1237 type: "POST", 1238 data: data, 1239 url: "index.php", 1240 error: function (XMLHttpRequest, textStatus, errorThrown) { 1241 alert("ERROR:" + errorThrown); 1242 }, 1243 success: function (response) { 1244 if(response == 1){ 1245 window.location.href = "order_delivery"; 1246 } 1247 if(response == 0){ 1248 alertify.error('greska kod adrese'); 1249 window.location.href = 'order_address'; 1250 } 1251 1252 } 1253 }); 1254} 1255 1256function setOrderDelivery(delivery,deliveryid){ 1257 var data = { 1258 action: 'setorderdelivery', 1259 delivery: delivery, 1260 deliveryid: deliveryid 1261 }; 1262 $.ajax({ 1263 type: "POST", 1264 data: data, 1265 url: "index.php", 1266 error: function (XMLHttpRequest, textStatus, errorThrown) { 1267 alert("ERROR:" + errorThrown); 1268 }, 1269 success: function (response) { 1270 if(response == 1){ 1271 window.location.href = "order_ordering"; 1272 } 1273 if(response == 0){ 1274 alertify.error('greska kod adrese'); 1275 window.location.href = 'order_payment'; 1276 } 1277 1278 } 1279 }); 1280} 1281 1282function setOrderDeliveryB2B(delivery,deliveryid){ 1283 var data = { 1284 action: 'setorderdelivery', 1285 delivery: delivery, 1286 deliveryid: deliveryid 1287 }; 1288 $.ajax({ 1289 type: "POST", 1290 data: data, 1291 url: "index.php", 1292 error: function (XMLHttpRequest, textStatus, errorThrown) { 1293 alert("ERROR:" + errorThrown); 1294 }, 1295 success: function (response) { 1296 if(response == 1){ 1297 window.location.href = "order_ordering"; 1298 } 1299 if(response == 0){ 1300 alertify.error('greska kod adrese'); 1301 window.location.href = 'korpa'; 1302 } 1303 1304 } 1305 }); 1306} 1307 1308function userLogin(username, pass, remmemberme) { 1309 var data = { 1310 action: 'partenrnotemptycart', 1311 username: username, 1312 pass: pass 1313 }; 1314 $.ajax({ 1315 type: "POST", 1316 data: data, 1317 url: "index.php", 1318 error: function (XMLHttpRequest, textStatus, errorThrown) { 1319 alert("ERROR:" + errorThrown); 1320 }, 1321 success: function (response) { 1322 if (response == 1) { 1323 alertify.confirm("VaÅ¡a kopra Äe biti ispražnjena.", function (e) { 1324 if (e) { 1325 emptyCart(); 1326 Login(username, pass, remmemberme); 1327 } else {
1328 alertify.success('Proverite korpu'); 1329 } 1330 }); 1331 1332 } 1333 else{ 1334 Login(username, pass, remmemberme); 1335 } 1336 1337 1338 1339 } 1340 }) 1341} 1342function userRemmemberMe(username, pass, remmember_me) { 1343 var data = { 1344 action: 'remmemberme', 1345 username: username, 1346 pass: pass, 1347 remmember_me: remmember_me 1348 }; 1349 1350 $.ajax({ 1351 type: "POST", 1352 data: data, 1353 url: "index.php", 1354 error: function (XMLHttpRequest, textStatus, errorThrown) { 1355 alert("ERROR:" + errorThrown); 1356 }, 1357 success: function (response) { 1358 1359 1360 } 1361 }) 1362} 1363 1364function Login(username, pass, remmemberme){ 1365 var data = { 1366 action: 'userlogin', 1367 username: username, 1368 pass: pass 1369 }; 1370 $.ajax({ 1371 type: "POST", 1372 data: data, 1373 url: "index.php", 1374 error: function (XMLHttpRequest, textStatus, errorThrown) { 1375 alert("ERROR:" + errorThrown); 1376 }, 1377 success: function(response){ 1378 1379 if(response == 1){ 1380 userRemmemberMe(username, pass, remmemberme); 1381 alertify.success('Logovanje uspeÅ¡no'); 1382 setTimeout(function(){ 1383 window.location.reload(); 1384 },1500); 1385 } 1386 if(response == 0){ 1387 alertify.error('PogreÅ¡na mail adresa ili Å¡ifra'); 1388 } 1389 if(response == 2){ 1390 alertify.error('Email adresa nije potvrÄena'); 1391 } 1392 if(response == 3){ 1393 alertify.error('Email adresa nije potvrdÄena'); 1394 } 1395 if(response == 4){ 1396 alertify.error('Nedovoljne privilegije ili nepostojeÄe!'); 1397 } 1398 1399 } 1400 }) 1401} 1402function userLogout(){ 1403 var data = { 1404 action: 'userlogout' 1405 }; 1406 $.ajax({ 1407 type: "POST", 1408 data: data, 1409 url: "index.php", 1410 error: function (XMLHttpRequest, textStatus, errorThrown) { 1411 alert("ERROR:" + errorThrown); 1412 }, 1413 success: function(response){ 1414 window.location.href = ''; 1415 1416 } 1417 }) 1418} 1419 1420function changePassword(){ 1421 var data = { 1422 action: 'changepassword', 1423 oldpass: $("#old_pass").val(), 1424 newpass: $("#new_pass2").val() 1425 }; 1426 $.ajax({ 1427 type: "POST", 1428 data: data, 1429 url: "index.php", 1430 error: function (XMLHttpRequest, textStatus, errorThrown) { 1431 alert("ERROR:" + errorThrown); 1432 }, 1433 success: function(response){ 1434 if(response == 1){ 1435 alertify.success('Uspesno promenjena lozinka.'); 1436 $('#ChangePassword').modal('hide'); 1437 $("#old_pass").val(''); 1438 $("#new_pass1").val(''); 1439 $("#new_pass2").val(''); 1440 1441 }else{ 1442 alertify.error('Greska prilikom promene lozinke.'); 1443 } 1444 1445 } 1446 }) 1447} 1448 1449function orderPoruci(){ 1450 1451 var data = { 1452 action: 'orderporuci' 1453 }; 1454 $.ajax({ 1455 type: "POST", 1456 data: data, 1457 url: "index.php", 1458 error: function (XMLHttpRequest, textStatus, errorThrown) { 1459 alert("ERROR:" + errorThrown); 1460 }, 1461 success: function(response){ 1462 window.location.href = ''; 1463 } 1464 }) 1465} 1466 1467function orderPoruciB2B(){ 1468 var data = { 1469 action: 'orderporucib2b' 1470 }; 1471 $.ajax({ 1472 type: "POST", 1473 data: data, 1474 url: "index.php", 1475 error: function (XMLHttpRequest, textStatus, errorThrown) { 1476 alert("ERROR:" + errorThrown); 1477 }, 1478 success: function(response){ 1479 window.location.href = ''; 1480 } 1481 }) 1482} 1483 1484function userRegistration(name, lastname, email, password, passwordconf, telefon, adresa, mesto, postbr){ 1485 var data = { 1486 action: 'userregister', 1487 name: name, 1488 lastname: lastname, 1489 email: email, 1490 password: password, 1491 passwordconf: passwordconf, 1492 telefon: telefon, 1493 adresa: adresa, 1494 mesto: mesto, 1495 postbr: postbr 1496 }; 1497 $.ajax({ 1498 type: "POST", 1499 data: data, 1500 url: "index.php", 1501 error: function (XMLHttpRequest, textStatus, errorThrown) { 1502 alert("ERROR:" + errorThrown); 1503 }, 1504 success: function(response){ 1505 if(response == 1){ 1506 alertify.success('Registracija uspesna, molimo vas da potvrdite vas mail'); 1507 setTimeout(function(){ 1508 document.location.reload(); 1509 },2500); 1510 } 1511 if(response == 0){ 1512 alertify.error('e-mail adresa postoji'); 1513 } 1514 if(response == 2){ 1515 alertify.error('sifre se ne poklapaju'); 1516 } 1517 if(response == 3){ 1518 alertify.error('greska-> Query Fail'); 1519 } 1520 if(response == 4){ 1521 alertify.error('Nedovoljne privilegije ili nepostojece!'); 1522 } 1523 } 1524 }) 1525} 1526function lostPass(email){ 1527 var data = { 1528 action: 'lostpass', 1529 email: email 1530 }; 1531 $.ajax({ 1532 type: "POST", 1533 data: data, 1534 url: "index.php", 1535 error: function (XMLHttpRequest, textStatus, errorThrown) { 1536 alert("ERROR:" + errorThrown); 1537 }, 1538 success: function(response){ 1539 if(response == 1){ 1540 alertify.success('Zahtev za resetovanje lozinke je poslat na VaÅ¡ mail.'); 1541 setTimeout(function(){ 1542 document.location.reload(); 1543 },2500); 1544 } 1545 if(response == 0){ 1546 alertify.error('E-mail adresa ne postoji.'); 1547 } 1548 1549 } 1550 }) 1551} 1552
1553function addNewsletter(email){ 1554 var data = { 1555 action: 'addnewsletter', 1556 email: email 1557 }; 1558 $.ajax({ 1559 type: "POST", 1560 data: data, 1561 async: true, 1562 crossDomain: true, 1563 url: "index.php", 1564 error: function (XMLHttpRequest, textStatus, errorThrown) { 1565 alert("ERROR:" + errorThrown); 1566 }, 1567 success: function(response){ 1568 if(response == 1){ 1569 alertify.success('UspeÅ¡no dodata email adresa.'); 1570 $('.newsletterInput').val(''); 1571 } 1572 if(response == 0){ 1573 alertify.error("Email adresa veÄ postoji"); 1574 } 1575 1576 } 1577 }) 1578} 1579 1580 1581function getDocumentItems(button){ 1582 var data = { 1583 action: 'getdocumentitems', 1584 docid: $(button).attr('id') 1585 }; 1586 $.ajax({ 1587 type: "POST", 1588 data: data, 1589 url: "index.php", 1590 error: function (XMLHttpRequest, textStatus, errorThrown) { 1591 alert("ERROR:" + errorThrown); 1592 }, 1593 success: function(response){ 1594 var res = JSON.parse(response); 1595 console.log(response); 1596 1597 $('.jq_documentItemsModalTbody').html(''); 1598 1599 doctype = ''; 1600 if($(button).attr('doctype') == 'r') doctype = "Racun "; 1601 if($(button).attr('doctype') == 'e') doctype = "Rezervacija "; 1602 $('.jq_itemsModalRok').remove(); 1603 if($(button).attr('doctype') == 'p'){ 1604 doctype = "Povrat robe "; 1605 $(document.createElement('th')).addClass('jq_itemsModalRok').html('Rok').insertAfter(".jq_itemsModalQty"); 1606 } 1607 if($(button).attr('doctype') == 'k') doctype = "Knjižno odobrenje "; 1608 if($(button).attr('doctype') == 'z') doctype = "Zamena "; 1609 1610 $('.jq_documentItemsModalDoctype').html(doctype); 1611 $('.jq_documentItemsModalDocNumber').html($(button).attr('docnumber')); 1612 1613 var td = $(document.createElement('td')); 1614 1615 for(var i = 0; i< res[1].length; i++){ 1616 var tr = $(document.createElement('tr')); 1617 1618 pdvprice = res[1][i]['price']*((res[1][i]['taxvalue']+100)/100); 1619 value = pdvprice*((100-res[1][i]['rebate'])/100); 1620 1621 $($(td).clone(true)).html(res[1][i]['productname']).appendTo($(tr)); 1622 1623 var icon = ''; 1624 if($(button).attr('doctype') == 'z'){ 1625 icon = '<i class="fa fa-plus green" aria-hidden="true"></i>'; 1626 if(parseInt(res[1][i][['quantity']]) < 0) icon = '<i class="fa fa-minus red" aria-hidden="true"></i>'; 1627 } 1628 $($(td).clone(true)).html(res[1][i]['quantity']+" "+icon).appendTo($(tr)); 1629 1630 if($(button).attr('doctype') == 'p'){ 1631 var icon = '<i class="fa fa-ban red" aria-hidden="true"></i>'; 1632 if(res[1][i]['rokstatus'] == 1) icon = '<i class="fa fa-check green" aria-hidden="true"></i>'; 1633 $($(td).clone(true)).html(res[1][i]['bestbeforedate']+" "+icon).appendTo($(tr)); 1634 } 1635 $($(td).clone(true)).html(res[1][i]['rebate']).appendTo($(tr)); 1636 $($(td).clone(true)).html(pdvprice).appendTo($(tr)); 1637 $($(td).clone(true)).html(value).appendTo($(tr)); 1638 1639 1640 1641 $(tr).appendTo($('.jq_documentItemsModalTbody')); 1642 } 1643 1644 $('.jq_documentDescriprionModalHolder').html(res[2]); 1645 1646 $('#jq_documentItemsModalCont').modal('show'); 1647 } 1648 }) 1649} 1650 1651function menusubcategorydata(parentid){ 1652 var data = { 1653 action: 'menusubcategorydata', 1654 catid: parentid 1655 }; 1656 $.ajax({ 1657 type: "POST", 1658 data: data, 1659 async: true, 1660 crossDomain: true, 1661 url: "index.php", 1662 error: function (XMLHttpRequest, textStatus, errorThrown) { 1663 alert("ERROR:" + errorThrown); 1664 }, 1665 success: function(response){ 1666 var res = JSON.parse(response); 1667 console.log(res); 1668 1669 if($('.jq_leftMenuSubBody').length > 0) 1670 { /* sub */ 1671 $('.jq_leftMenuSubBody:last-child').find('.jq_smallLeftMenuItemCont').html(''); 1672 for(var i = 0; i < res.length; i++){ 1673 var clone = $('.jq_smallMenuItemHolderTemplate').clone(true).removeClass('hide').removeClass('jq_smallMenuItemHolderTemplate').attr('catid', res[i].id); 1674 $(clone).find('.jq_forwardLeftMenuName').attr('href',res[i].catobj.path ).html(res[i].name); 1675 $(clone).find('.jq_forwardLeftMenuBtn').addClass((res[i].childs > 0)? '':'hide'); 1676 1677 $(clone).appendTo($('.jq_leftMenuSubBody:last-child').find('.jq_smallLeftMenuItemCont')); 1678 } 1679 $('.jq_leftMenuBackBtn').addClass('material-icons').text('keyboard_arrow_left').css('visibility', 'visible'); 1680 TweenMax.to($('.body-container').find('.jq_leftMenuSubBody:last-child'), 0.2, { left: "0" }); 1681 }else 1682 { /* root */ 1683 $('.jq_smallLeftMenuItemCont').html(''); 1684 for(var i = 0; i < res.length; i++){ 1685 var clone = $('.jq_smallMenuItemHolderTemplate').clone(true).removeClass('hide').removeClass('jq_smallMenuItemHolderTemplate').attr('catid', res[i].id); 1686 $(clone).find('.jq_forwardLeftMenuName').attr('href',res[i].urlname ).html(res[i].name); 1687 $(clone).find('.jq_forwardLeftMenuBtn').addClass((res[i].childs > 0)? '':'hide'); 1688 1689 $(clone).appendTo($('.jq_smallLeftMenuItemCont')); 1690 } 1691 } 1692 1693 } 1694 }) 1695} 1696 1697function checkCoupon(){ 1698 var $this = $('.cms_couponInput'); 1699 var data = { 1700 action: 'getcoupon', 1701 coupon: $($this).val() 1702 }; 1703 $.ajax({ 1704 type : 'POST', 1705 url: "index.php", 1706 data : data, 1707 success : function(data){ 1708 if(data == 0){ 1709 window.location.reload(); 1710 }else{ 1711 alert('Nevalidan kupon'); 1712 } 1713 1714 }, 1715 error : function(){ 1716 alert("error"); 1717 } 1718 }); 1719} 1720 1721function removeCoupon(){ 1722 var data = { 1723 action: 'removecoupon' 1724 }; 1725 $.ajax({ 1726 type : 'POST', 1727 url: "index.php", 1728 data : data, 1729 success : function(data){ 1730 if(data == 0){ 1731 window.location.reload(); 1732 }else{ 1733 alert('Nevalidan kupon'); 1734 } 1735 1736 }, 1737 error : function(){ 1738 alert("error"); 1739 } 1740 }); 1741} 1742 1743
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.