Subversion Repositories SmartDukaan

Rev

Rev 20674 | Rev 20884 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 20674 Rev 20865
Line 405... Line 405...
405
    var pin = $(this).data('pin');
405
    var pin = $(this).data('pin');
406
     var add_id = $(this).data('id');
406
     var add_id = $(this).data('id');
407
     
407
     
408
    $('#loadingModal').modal('show');
408
    $('#loadingModal').modal('show');
409
    $.ajax({
409
    $.ajax({
410
    method: "GET",
410
	    method: "GET",
411
    url: apihost+"shippings/isServicable/"+pin
411
	    url: apihost+"shippings/isServicable/"+pin
412
  })
-
 
413
    .done(function( msg ) {
412
  	}).done(function( msg ) {
414
        console.log(msg);
-
 
415
        $('#loadingModal').modal('hide');
413
        $('#loadingModal').modal('hide');
416
        if(msg== 'true'){
414
        if(msg== 'true'){
417
            $('.myaddress').removeClass('addressselect');
415
            $('.myaddress').removeClass('addressselect');
418
            $('#address'+add_id).addClass('addressselect');
416
            $('#address'+add_id).addClass('addressselect');
419
            	
417
            	
Line 440... Line 438...
440
            $('#message').removeClass('hidden');
438
            $('#message').removeClass('hidden');
441
            $("input:radio").removeAttr("checked");
439
            $("input:radio").removeAttr("checked");
442
            $('.myaddress').removeClass('addressselect');
440
            $('.myaddress').removeClass('addressselect');
443
            setTimeout(function() {
441
            setTimeout(function() {
444
                $('#message').addClass('hidden');
442
                $('#message').addClass('hidden');
445
            }, 2000);
443
            }, 3500);
446
        }
444
        }
447
        
-
 
448
        // alert(msg);
-
 
449
    });
445
    });
450
    var creditTicketSize = parseInt(localStorage.getItem('creditTicketSize'));
-
 
451
    var creditLimit = parseInt(localStorage.getItem('creditLimit'));
-
 
452
    var cart_details = localStorage.getItem('cart_details');
-
 
453
    var totalPayable = parseInt(localStorage.getItem('totalPayable'));
-
 
454
    
-
 
455
    var creditAvailable = $(this).attr('credit_available');
-
 
456
    if($('span#CreditError').html()!=''){
-
 
457
    	localStorage.setItem('CreditError',$('span#CreditError').html());
-
 
458
    }	
-
 
459
    if(creditAvailable=='false'){
-
 
460
    	$('button.confirmcredit').prop( "disabled", true );
-
 
461
    	$('button.confirmcredit').attr('style', 'margin: 10px 20px 0px 0px; background-color: #B4CAB4; color: #fff;');
-
 
462
    	$('span#CreditError').html('');
-
 
463
    }else{
-
 
464
    	var errorSpanText = localStorage.getItem('CreditError');
-
 
465
    	if(cart_details == undefined || creditTicketSize>totalPayable || totalPayable>=creditLimit){
-
 
466
    		$('button.confirmcredit').prop( "disabled", true );
-
 
467
        	$('button.confirmcredit').attr('style', 'margin: 10px 20px 0px 0px; background-color: #B4CAB4; color: #fff;');
-
 
468
        	$('span#CreditError').html(errorSpanText);
-
 
469
    	}else{
-
 
470
    		$('button.confirmcredit').prop( "disabled", false );
-
 
471
        	$('button.confirmcredit').attr('style', 'margin: 10px 20px 0px 0px;background-color: #5cb85c;color: #fff;');
-
 
472
    	}
-
 
473
    }
-
 
474
}); 
446
}); 
475
 
447
 
476
$(document).on('click','#showmore',function(){
448
$(document).on('click','#showmore',function(){
477
    $("#showmoreaddressdropdown").toggle();
449
    $("#showmoreaddressdropdown").toggle();
478
    if($('#showmore').html() == 'Show More')
450
    if($('#showmore').html() == 'Show More')
Line 685... Line 657...
685
    })).append($('<input>', {
657
    })).append($('<input>', {
686
        'name': 'paymethod',
658
        'name': 'paymethod',
687
        'value': 'oth',
659
        'value': 'oth',
688
        'type': 'hidden'
660
        'type': 'hidden'
689
    })).append($('<input>', {
661
    })).append($('<input>', {
-
 
662
        'name': 'walletUsed',
-
 
663
        'value': walletUsed,
-
 
664
        'type': 'hidden'
-
 
665
    })).append($('<input>', {
690
        'name': 'cart_details',
666
        'name': 'cart_details',
691
        'value': localStorage.getItem('cart_details'),
667
        'value': localStorage.getItem('cart_details'),
692
        'type': 'hidden'
668
        'type': 'hidden'
693
    }));
669
    }));
694
    newForm.submit();
670
    newForm.submit();
Line 716... Line 692...
716
        'method':'post'
692
        'method':'post'
717
    }).append($('<input>', {
693
    }).append($('<input>', {
718
        'name': 'addressid',
694
        'name': 'addressid',
719
        'value': addressid,
695
        'value': addressid,
720
        'type': 'hidden'
696
        'type': 'hidden'
-
 
697
    })).append($('<input>', {
-
 
698
        'name': 'walletUsed',
-
 
699
        'value': walletUsed,
-
 
700
        'type': 'hidden'
721
    }));
701
    }));
722
    newForm.submit();
702
    newForm.submit();
723
}
703
}
724
 
704
 
725
function confirmCreditCheckout(addressid){
705
function confirmWalletCheckout(addressid){
726
	if (typeof addressid=="undefined"){
706
	if (typeof addressid=="undefined"){
727
		addressid=$("input.css-checkbox:checked").val();
707
		addressid=$("input.css-checkbox:checked").val();
728
	}
708
	}
729
	if (addressid==undefined || typeof addressid=="undefined"){
709
	if (addressid==undefined || typeof addressid=="undefined"){
730
		$('#loadingModal').modal('hide');
710
		$('#loadingModal').modal('hide');
Line 732... Line 712...
732
        $('#message').append("Please select an address...");
712
        $('#message').append("Please select an address...");
733
        $('#message').removeClass('hidden');
713
        $('#message').removeClass('hidden');
734
        setTimeout(function() {
714
        setTimeout(function() {
735
            $('#message').addClass('hidden');
715
            $('#message').addClass('hidden');
736
        }, 2000);
716
        }, 2000);
737
        $('button.confirmcredit').prop( "disabled", false );
717
        $('button.confirmwallet').prop( "disabled", false );
738
        return;
718
        return;
739
	}
719
	}
740
	
720
	
741
	var url = apihost + 'checkout/?user_id='+me+'&cod=0';
721
	var url = apihost + 'checkout/?user_id='+me+'&cod=0';
742
    var newForm = $('<form>', {
722
    var newForm = $('<form>', {
Line 745... Line 725...
745
    }).append($('<input>', {
725
    }).append($('<input>', {
746
        'name': 'addressid',
726
        'name': 'addressid',
747
        'value': addressid,
727
        'value': addressid,
748
        'type': 'hidden'
728
        'type': 'hidden'
749
    })).append($('<input>', {
729
    })).append($('<input>', {
750
        'name': 'paymethod',
730
        'name': 'walletUsed',
751
        'value': 'cap_float',
731
        'value': totalPayable,
752
        'type': 'hidden'
732
        'type': 'hidden'
753
    })).append($('<input>', {
733
    })).append($('<input>', {
754
        'name': 'cart_details',
734
        'name': 'cart_details',
755
        'value': localStorage.getItem('cart_details'),
735
        'value': localStorage.getItem('cart_details'),
756
        'type': 'hidden'
736
        'type': 'hidden'
Line 769... Line 749...
769
        $('#message').removeClass('hidden');
749
        $('#message').removeClass('hidden');
770
        setTimeout(function() {
750
        setTimeout(function() {
771
            $('#message').addClass('hidden');
751
            $('#message').addClass('hidden');
772
        }, 2000);
752
        }, 2000);
773
        $('button.confirmcheckout').prop( "disabled", false );
753
        $('button.confirmcheckout').prop( "disabled", false );
774
        $('button.confirmcredit').prop( "disabled", false );
754
        $('button.confirmwallet').prop( "disabled", false );
775
        $('button.confirmcod').prop( "disabled", false );
755
        $('button.confirmcod').prop( "disabled", false );
776
        return;
756
        return;
777
	}
757
	}
778
	$('button.confirmcredit').prop( "disabled", false );
758
	$('button.confirmwallet').prop( "disabled", false );
779
	$('button.confirmcod').prop( "disabled", false );
759
	$('button.confirmcod').prop( "disabled", false );
780
	window.history.pushState('forward', null, './');
760
	window.history.pushState('forward', null, './');
781
	if(checkoutType=='codoption'){
761
	if(checkoutType=='codoption'){
782
		$('p#confirmOrderText').html("<span>Confirm Order with <span style='color:#ff0000;'>COD</span>."
762
		$('p#confirmOrderText').html("<span>Confirm Order with <span style='color:#ff0000;'>COD</span>."
783
				+"</span><hr style='margin-top: 5px;margin-bottom: 5px;'>"
763
				+"</span><hr style='margin-top: 5px;margin-bottom: 5px;'>"
784
				+"<span><span style='color:#ff0000'>सीओडी (COD)</span> के साथ आर्डर  कन्फर्म करें। </span>");
764
				+"<span><span style='color:#ff0000'>सीओडी (COD)</span> के साथ आर्डर  कन्फर्म करें। </span>");
785
	}else{
765
	}else{
786
		$('p#confirmOrderText').html("<span>Confirm Order with <span style='color:#ff0000;'>CREDIT</span>."
766
		$('p#confirmOrderText').html("<span>Confirm Order with <span style='color:#ff0000;'>WALLET</span>."
787
				+"</span><hr style='margin-top: 5px;margin-bottom: 5px;'>"
767
				+"</span><hr style='margin-top: 5px;margin-bottom: 5px;'>"
788
				+"<span><span style='color:#ff0000'>क्रेडिट (CREDIT)</span> के साथ आर्डर  कन्फर्म करें। </span>");
768
				+"<span><span style='color:#ff0000'>वॉलेट(WALLET)</span> के साथ आर्डर  कन्फर्म करें। </span>");
789
	}
769
	}
790
	$('p#confirmOrderText').attr('addressId',addressId);
770
	$('p#confirmOrderText').attr('addressId',addressId);
791
	$('p#confirmOrderText').attr('checkoutType',checkoutType);
771
	$('p#confirmOrderText').attr('checkoutType',checkoutType);
792
	$('#myModal').modal('show');
772
	$('#myModal').modal('show');
-
 
773
	$("#myModal").on('hide.bs.modal', function(){
-
 
774
		window.history.back();
-
 
775
	})
793
	$('#loadingModal').modal('hide');
776
	$('#loadingModal').modal('hide');
794
}
777
}
795
 
778
 
796
$(document).on('click','button#changeOption',function(){
779
$(document).on('click','#changeOption',function(){
797
	$('#myModal').modal('hide');
780
	$('#myModal').modal('hide');
798
});
781
});
799
 
782
 
800
$(document).on('click','button#orderNow',function(){
783
$(document).on('click','#orderNow',function(){
801
	$('#myModal').modal('hide');
784
	$('#myModal').modal('hide');
802
	$("#cartloader").removeClass('hidden');
785
	$("#cartloader").removeClass('hidden');
803
	setTimeout(function () {history.back();}, 5000);
786
	setTimeout(function () {history.back();}, 5000);
804
	var checkout_type = $('p#confirmOrderText').attr('checkoutType');
787
	var checkout_type = $('p#confirmOrderText').attr('checkoutType');
805
	if(checkout_type=='codoption'){
788
	if(checkout_type=='codoption'){
Line 809... Line 792...
809
	        'method':'post'
792
	        'method':'post'
810
	    }).append($('<input>', {
793
	    }).append($('<input>', {
811
	        'name': 'addressid',
794
	        'name': 'addressid',
812
	        'value': $('p#confirmOrderText').attr('addressId'),
795
	        'value': $('p#confirmOrderText').attr('addressId'),
813
	        'type': 'hidden'
796
	        'type': 'hidden'
-
 
797
	    })).append($('<input>', {
-
 
798
	        'name': 'walletUsed',
-
 
799
	        'value': walletUsed,
-
 
800
	        'type': 'hidden'
814
	    }));
801
	    }));
815
		newForm.submit();
802
		newForm.submit();
816
	}else{
803
	}else{
817
		var url = apihost + 'checkout/?user_id='+me+'&cod=0';
804
		var url = apihost + 'checkout/?user_id='+me+'&cod=0';
818
	    var newForm = $('<form>', {
805
	    var newForm = $('<form>', {
Line 843... Line 830...
843
$(document).on('click','button.confirmcheckout', function(){
830
$(document).on('click','button.confirmcheckout', function(){
844
	$('button.confirmcheckout').prop( "disabled", true );
831
	$('button.confirmcheckout').prop( "disabled", true );
845
	$('#loadingModal').modal('show');
832
	$('#loadingModal').modal('show');
846
	confirmCheckout();
833
	confirmCheckout();
847
});
834
});
848
$(document).on('click','button.confirmcredit', function(){
835
$(document).on('click','button.confirmwallet', function(){
849
	$('button.confirmcredit').prop( "disabled", true );
836
	$('button.confirmwallet').prop( "disabled", true );
850
	$('#loadingModal').modal('show');
837
	$('#loadingModal').modal('show');
851
	handleConfirmOrder('creditoption');
838
	handleConfirmOrder('walletoption');
852
});
839
});
853
$(document).on('click','button.confirmcod', function(){
840
$(document).on('click','button.confirmcod', function(){
854
	$('button.confirmcod').prop( "disabled", true );
841
	$('button.confirmcod').prop( "disabled", true );
855
	$('#loadingModal').modal('show');
842
	$('#loadingModal').modal('show');
856
	handleConfirmOrder('codoption');
843
	handleConfirmOrder('codoption');
857
});
844
});
-
 
845
$(document).on('click','a.usewallet', function(){
-
 
846
	var text = $(this).html().trim();
-
 
847
	var that = this; 
-
 
848
	if(text==="Use Wallet") {
-
 
849
		walletUsed = walletPayable;
-
 
850
		$('#walletAmount').animate({"padding-left":"43px",color:"#ff0000"}, {complete:function(){
-
 
851
			$(that).html("Don't use wallet");
-
 
852
			curText=$(this).html();
-
 
853
			$(this).html("-" + curText.substr(1,curText.indexOf(")")-1));
-
 
854
			$("#netpayable").css("visibility","visible");
-
 
855
		}});
-
 
856
	} else {
-
 
857
		walletUsed = 0;
-
 
858
		$('#walletAmount').animate({"padding-left":"0px", "color":"#555555"}, {complete:function(){
-
 
859
			$(that).html("Use Wallet");
-
 
860
			curText=$(this).html();
-
 
861
			$(this).html("(" + curText.substr(1,curText.length-1) + ")");
-
 
862
			$("#netpayable").css("visibility","hidden");
-
 
863
		}});
-
 
864
	}
-
 
865
});