function SaveRatingReview() { FreezeScreen(); $.ajax({ url: '/MyProfile/SaveRatingReview', type: 'Post', data: { Body: $("#review").val(), Name: $("#name").val(), RatingSum: $("input[name='star']:checked").val(), }, cache: false, success: function (data) { UnFreezeScreen(); if (data) { swal({ title: '', text: "تم التقيم بنجاح", type: 'success', confirmButtonText: Resources.SharedResource.Ok }, function () { if (affiliate != null) { window.location = "/Home/Index?a=" + affiliate; } else { window.location = '/'; } }); } else { swal({ title: '', text: 'حدث خطأ غير معروف', type: 'error', confirmButtonText: Resources.SharedResource.Ok }, function () { location.reload(); }); } } }); } function LoadQuickDonationForm() { $.ajax({ url: '/Home/QuickDonationPopup', type: 'Get', cache: false, success: function (data) { $('#divQuickDonation').empty; $('#divQuickDonation').html(data); } }); } Noty.overrideDefaults({ theme: 'limitless', layout: 'topRight', type: 'alert', timeout: 2500 }); //$(document).ajaxStart(function () { // FreezeScreen(); //}).ajaxStop(function () { UnFreezeScreen(); }); $(document).ready(function () { var stickyOffset = $('.sticky').offset().top; $(window).scroll(function () { var sticky = $('.sticky'), scroll = $(window).scrollTop(); if (scroll > stickyOffset) { sticky.addClass('navbar-fixed-top'); //$('#myCarousel2').addClass('smy'); } else sticky.removeClass('navbar-fixed-top'); }); LoadQuickDonationForm(); }); $(document).ready(function () { jQuery.extend(jQuery.validator.messages, { required: "هذا الحقل مطلوب.", remote: "من فضلك أصلح الخطأ", email: "أدخل بريد الكتروني صحيح.", url: "أدخل رابط صحيح.", date: "أدخل تاريخ صحيح.", number: "أدخل عدد صحيح.", digits: "أدخل أرقام فقط.", creditcard: "أدخل رقم بطاقة أئتمانية صحيح", equalTo: "أدخل نفس القيمة من فضلك", accept: "Please enter a value with a valid extension.", maxlength: jQuery.validator.format("أدخل ما لا يزيد عن {0} حروف."), minlength: jQuery.validator.format("أدخل على الأقل {0} حروف."), rangelength: jQuery.validator.format("أدخل عدد ما بين {0} و {1} حروف ."), range: jQuery.validator.format("أدخل قيمة ما بين {0} و {1}."), max: jQuery.validator.format("أدخل قيمة أقل او تساوي {0}."), min: jQuery.validator.format("أدخل قيمة أكبر او تساوي {0}.") }); }); function getParameterByName(name, url) { if (!url) url = window.location.href; name = name.replace(/[\[\]]/g, '\\$&'); var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), results = regex.exec(url); if (!results) return null; if (!results[2]) return ''; return decodeURIComponent(results[2].replace(/\+/g, ' ')); } function EnglishCharsOnlyWithSpace(fld, e) { var strCheck = '0123456789acbdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.@@_/:- '; var whichCode = e.which ? e.which : e.keyCode; if (whichCode == 13 || whichCode == 8 || whichCode == 9) return true; key = String.fromCharCode(whichCode); if (strCheck.indexOf(key) == -1) return false; return true; } function isNumber(evt) { evt = (evt) ? evt : window.event; var charCode = (evt.which) ? evt.which : evt.keyCode; if (charCode > 31 && (charCode < 48 || charCode > 57)) { return false; } return true; } function isNumberWithInternationMobile(evt, txt, val) { val = toEnglishNumber(val); $(txt).val(val); evt = (evt) ? evt : window.event; var charCode = (evt.which) ? evt.which : evt.keyCode; if (charCode > 31 && (charCode < 48 || charCode > 57)) { return false; } return true; } function toEnglishNumber(strNum) { var pn = ["۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹"]; var en = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]; var an = ["٠", "١", "٢", "٣", "٤", "٥", "٦", "٧", "٨", "٩"]; var cache = strNum; for (var i = 0; i < 10; i++) { var regex_fa = new RegExp(pn[i], 'g'); var regex_ar = new RegExp(an[i], 'g'); cache = cache.replace(regex_fa, en[i]); cache = cache.replace(regex_ar, en[i]); } return cache; } function isDecimalNumber(evt) { var charCode = (evt.which) ? evt.which : event.keyCode if (charCode != 45 && (charCode != 46 || $(this).val().indexOf('.') != -1) && (charCode < 48 || charCode > 57)) return false; return true; } $(document).on('keyup', '.form-control', function (e) { var val = toEnglishNumber($(this).val()) $(this).val(val) }); function StopOwl() { try { owl.trigger('stop.owl.autoplay') } catch (e) { } } function ChangeShareProject(id, val, amount) { setTimeout(function () { $("#parent_" + id + "").children().removeClass("tag-selected"); $("#btnShare_" + id + "_" + val).addClass("tag-selected"); }, 100); if (id != 0) { StopOwl(); $('#txtShare_' + id).val(val); if (amount != 0) { $('#txtAmount_' + id).val(amount); $('#toolCount_' + id).css("visibility", "visible"); $('#txtAmount_' + id).attr("readonly", true); } else { $('#txtAmount_' + id).val(""); $('#txtAmount_' + id).attr("readonly", false); $('#toolCount_' + id).css("visibility", "hidden"); } $('#txtOneShareVal_' + id).val(amount); $('#toolCount_' + id).show(); $('#txtQuantity_' + id).val('1'); } else { $('.txtAmountamount').val(""); $('.pull-left').hide(); $(".txtShareCss").val(0); } } function ChangeShare(id, val, amount) { setTimeout(function () { $("#parent_" + id + "").children().removeClass("tag-selected"); $("#btnShare_" + id + "_" + val).addClass("tag-selected"); }, 100); if (id != 0) { StopOwl(); $('#txtShare_' + id).val(val); if (amount != 0) { $('#txtAmount_' + id).val(amount); $('#toolCount_' + id).css("visibility", "visible"); $('#txtAmount_' + id).attr("readonly", true); } else { $('#txtAmount_' + id).val(""); $('#txtAmount_' + id).attr("readonly", false); $('#toolCount_' + id).css("visibility", "hidden"); } $('#txtOneShareVal_' + id).val(amount); $('#toolCount_' + id).show(); $('#txtQuantity_' + id).val('1'); } else { $('.txtAmountamount').val(""); $('.pull-left').hide(); $(".txtShareCss").val(0); } } function ChangeShareInnierGift(id, val, amount, donationOpen) { setTimeout(function () { $(".text-center").children().removeClass("tag-selected"); $(".optTag").removeClass("tag-selected"); $("#btnShare_" + id + "_" + val).addClass("tag-selected"); }, 100); if (donationOpen == "True") { $(".txtAmountamount").attr("readonly", false); } else { $(".txtAmountamount").attr("readonly", true); } if (id != 0) { StopOwl(); $('#txtShare_' + id).val(val); $('#txtAmount_' + id).val(amount); $('#txtOneShareVal_' + id).val(amount); $('#toolCount_' + id).show(); $('#txtQuantity_' + id).val('1'); } else { $('.txtAmountamount').val(""); $('.pull-left').hide(); $(".txtShareCss").val(0); } owlGift.data('owl.carousel').options.loop = false; owlGift.data('owl.carousel').options.autoplay = false; owlGift.data('owl.carousel').options.nav = false; owlGift.trigger('refresh.owl.carousel'); } function ChangeQuantityByEnter(evt, id, amount) { StopOwl(); evt = (evt) ? evt : window.event; var charCode = (evt.which) ? evt.which : evt.keyCode; if (charCode > 31 && (charCode < 48 || charCode > 57)) { return false; } if (charCode == 13) { var quantity = Number($('#txtQuantity_' + id).val()); $('#txtQuantity_' + id).val(quantity); $('#txtAmount_' + id).val(quantity * amount); } return true; } function ChangeQuantityWhenLeave(id, amount) { StopOwl(); var quantity = Number($('#txtQuantity_' + id).val()); $('#txtQuantity_' + id).val(quantity); $('#txtAmount_' + id).val(quantity * amount); } function ChangeQuantity(id, type, amount) { StopOwl(); var quantity = Number($('#txtQuantity_' + id).val()); type = Number(type); if (type == 1) { quantity += 1; $('#txtQuantity_' + id).val(quantity); } else { quantity -= 1; if (quantity > 1) { $('#txtQuantity_' + id).val(quantity); } else { quantity = 1; $('#txtQuantity_' + id).val('1'); } } $('#txtAmount_' + id).val(quantity * amount); } function ChangeItemCartAmount(id) { var amount = Number($('#txtAmount_' + id).val()); if (amount == null || isNaN(amount) || amount == undefined || amount <= 0) { new Noty({ layout: 'bottomCenter', text: 'ادخل المبلغ', type: 'error' }).show(); return; } FreezeScreen(); $.ajax({ url: '/MyProfile/ChangeCartItemAmount', type: 'Post', data: { Id: id, Amount: amount }, cache: false, success: function (data) { UnFreezeScreen(); if (data) { if (affiliate != null) { window.location = "/MyProfile/Cart?a=" + affiliate; } else { window.location = "/MyProfile/Cart"; } } } }); } function ChangeItemCartQuantityWithEnter(evt, id) { evt = (evt) ? evt : window.event; var charCode = (evt.which) ? evt.which : evt.keyCode; if (charCode > 31 && (charCode < 48 || charCode > 57)) { return false; } if (charCode == 13) { var quantity = Number($('#txtQty_' + id).val()); FreezeScreen(); $.ajax({ url: '/MyProfile/ChangeCartItemQuantity', type: 'Post', data: { Id: id, Quantity: quantity }, cache: false, success: function (data) { UnFreezeScreen(); if (data) { if (affiliate != null) { window.location = "/MyProfile/Cart?a=" + affiliate; } else { window.location = "/MyProfile/Cart"; } } else { if ($('#txtIsProduct_' + id).val() == 'True') { swal({ title: '', text: 'الكمية المطلوبة غير متوفرة في المخزن ', type: 'error', showConfirmButton: true, confirmButtonText: Resources.SharedResource.Ok }); } } } }); } return true; } function ChangeItemCartQuantity(id, type) { var Quantity = Number($('#txtQty_' + id).val()); if (type == 1) { Quantity += 1; } else { Quantity -= 1; } FreezeScreen(); $.ajax({ url: '/MyProfile/ChangeCartItemQuantity', type: 'Post', data: { Id: id, Quantity: Quantity }, cache: false, success: function (data) { UnFreezeScreen(); if (data) { if (affiliate != null) { window.location = "/MyProfile/Cart?a=" + affiliate; } else { window.location = "/MyProfile/Cart"; } } else { if ($('#txtIsProduct_' + id).val() == 'True') { swal({ title: '', text: 'الكمية المطلوبة غير متوفرة في المخزن ', type: 'error', showConfirmButton: true, confirmButtonText: Resources.SharedResource.Ok }); } } } }); } function AddToCartQuick(categoryId, amount) { StopOwl(); categoryId = Number(categoryId); if (categoryId == null || isNaN(categoryId) || categoryId == undefined || categoryId <= 0) { new Noty({ layout: 'bottomCenter', text: 'ادخل نوع التبرع', type: 'error' }).show(); return; } amount = Number(amount); if (amount == null || isNaN(amount) || amount == undefined || amount <= 0) { new Noty({ layout: 'bottomCenter', text: 'ادخل المبلغ', type: 'error' }).show(); return; } if (amount < Number($("#MinQuickDonation").val())) { new Noty({ layout: 'bottomCenter', text: 'اقل مبلغ للتبرع هو : ' + $("#MinQuickDonation").val(), type: 'error' }).show(); return; } FreezeScreen(); $.ajax({ url: '/MyProfile/AddToCart', type: 'Post', data: { CategoryId: categoryId, Amount: amount, Quantity: 1, DonateTypeId: 5 }, cache: false, success: function (data) { UnFreezeScreen(); if (data) { AddToCardPixel(categoryId, $("#CategoryId option:selected").text(), amount, 1); swal({ title: '', text: 'تم اضافة التبرع الي السلة', type: 'success', showConfirmButton: false, timer: 1000, confirmButtonText: Resources.SharedResource.Ok }); setTimeout(function () { if (affiliate != null) { window.location = "/MyProfile/Cart?a=" + affiliate; } else { window.location = "/MyProfile/Cart"; } }, 100); } } }); } function AddToCart(type, projectId) { StopOwl(); if (projectId == null || isNaN(projectId) || projectId == undefined || projectId <= 0) { return; } if ($('#txtPercentagePaidAmount_' + projectId).val() == true) { new Noty({ layout: 'bottomCenter', text: 'تم اكتمال المشروع لا يمكن التبرع مرة اخري', type: 'error' }).show(); return; } var shareId = 0; var quantity = 1; var amount = 0; var donateType = Number($('#txtDonateType_' + projectId).val()); if (donateType == 1 || donateType == 3) { shareId = Number($('#txtShare_' + projectId).val()); if (shareId == null || isNaN(shareId) || shareId == undefined || shareId <= 0) { new Noty({ layout: 'bottomCenter', text: 'اختر الفئة', type: 'error' }).show(); return; } } var DonationOpen = $('#txtDonationOpen_' + projectId + '_' + shareId).val(); if (donateType == 1 || donateType == 3) { if (DonationOpen == "value") { amount = Number($('#txtAmount_' + projectId).val()); } else { amount = Number($('#txtOneShareVal_' + projectId).val()); } } else { amount = Number($('#txtAmount_' + projectId).val()); } if (amount == null || isNaN(amount) || amount == undefined || amount <= 0) { new Noty({ layout: 'bottomCenter', text: 'ادخل المبلغ', type: 'error' }).show(); return; } if (donateType == 3 || donateType == 1) { quantity = Number($('#txtQuantity_' + projectId).val()) if (quantity == null || isNaN(quantity) || quantity == undefined || quantity <= 0) { new Noty({ layout: 'bottomCenter', text: 'ادخل الكمية', type: 'error' }).show(); return; } } FreezeScreen(); $.ajax({ url: '/MyProfile/AddToCart', type: 'Post', data: { ProjectId: projectId, ProjectShareId: shareId, Quantity: quantity, Amount: amount, DonateTypeId: donateType, DonationOpen: DonationOpen == "value" ? true : false, IsProduct: $('#txtIsProduct_' + projectId).val() != 'True' ? false : true, }, cache: false, success: function (data) { UnFreezeScreen(); if (data) { AddToCardPixel(projectId, $('#txtProjectName_' + projectId).val(), amount, quantity); swal({ title: '', text: $('#txtIsProduct_' + projectId).val() != 'True' ? 'تم اضافة التبرع الي السلة' : 'تم اضافة المنتج الى السلة', type: 'success', showConfirmButton: false, timer: 1000, confirmButtonText: Resources.SharedResource.Ok }); setTimeout(function () { if (type == 1) { //location.reload(); } else { if (affiliate != null) { window.location = "/MyProfile/Cart?a=" + affiliate; } else { window.location = "/MyProfile/Cart"; } } }, 100); } else { if ($('#txtIsProduct_' + projectId).val() == 'True') { swal({ title: '', text: 'الكمية المطلوبة غير متوفرة في المخزن ', type: 'error', showConfirmButton: true, confirmButtonText: Resources.SharedResource.Ok }); } } } }); } function AddToCartCertificate() { type = $("#projectTypeId").val(); projectId = $("#projectId").val(); StopOwl(); if (projectId == null || isNaN(projectId) || projectId == undefined || projectId <= 0) { return; } if ($('#txtPercentagePaidAmount_' + projectId).val() == true) { new Noty({ layout: 'bottomCenter', text: 'تم اكتمال المشروع لا يمكن التبرع مرة اخري', type: 'error' }).show(); return; } var shareId = 0; var quantity = 1; var amount = 0; var donateType = Number($('#txtDonateType_' + projectId).val()); if (donateType == 1 || donateType == 3) { shareId = Number($('#txtShare_' + projectId).val()); if (shareId == null || isNaN(shareId) || shareId == undefined || shareId <= 0) { new Noty({ layout: 'bottomCenter', text: 'اختر الفئة', type: 'error' }).show(); return; } } var DonationOpen = $('#txtDonationOpen_' + projectId + '_' + shareId).val(); if (donateType == 1 || donateType == 3) { if (DonationOpen == "value") { amount = Number($('#txtAmount_' + projectId).val()); } else { amount = Number($('#txtOneShareVal_' + projectId).val()); } } else { amount = Number($('#txtAmount_' + projectId).val()); } if (amount == null || isNaN(amount) || amount == undefined || amount <= 0) { new Noty({ layout: 'bottomCenter', text: 'ادخل المبلغ', type: 'error' }).show(); return; } if (donateType == 3 || donateType == 1) { quantity = Number($('#txtQuantity_' + projectId).val()) if (quantity == null || isNaN(quantity) || quantity == undefined || quantity <= 0) { new Noty({ layout: 'bottomCenter', text: 'ادخل الكمية', type: 'error' }).show(); return; } } if ($("#CertificateName").val() == null || $("#CertificateName").val() == "" || onlySpaces($("#CertificateName").val())) { new Noty({ layout: 'bottomCenter', text: 'اسم الشخص في الشهادة الوقفية', type: 'error' }).show(); return; } FreezeScreen(); $.ajax({ url: '/MyProfile/AddToCart', type: 'Post', data: { ProjectId: projectId, ProjectShareId: shareId, Quantity: quantity, Amount: amount, CertificateName: $("#CertificateName").val(), IsSendCertificatenSms: $('#IsSendCertificatenSms').is(":checked"), DonateTypeId: donateType, DonationOpen: DonationOpen == "value" ? true : false, IsProduct: $('#txtIsProduct_' + projectId).val() != 'True' ? false : true, }, cache: false, success: function (data) { UnFreezeScreen(); if (data) { AddToCardPixel(projectId, $('#txtProjectName_' + projectId).val(), amount, quantity); swal({ title: '', text: $('#txtIsProduct_' + projectId).val() != 'True' ? 'تم اضافة التبرع الي السلة' : 'تم اضافة المنتج الى السلة', type: 'success', showConfirmButton: false, timer: 1000, confirmButtonText: Resources.SharedResource.Ok }); setTimeout(function () { if (type == 1) { $('.bs-modal-CertificateInfo').modal('hide'); } else { if (affiliate != null) { window.location = "/MyProfile/Cart?a=" + affiliate; } else { window.location = "/MyProfile/Cart"; } } }, 100); } else { if ($('#txtIsProduct_' + projectId).val() == 'True') { swal({ title: '', text: 'الكمية المطلوبة غير متوفرة في المخزن ', type: 'error', showConfirmButton: true, confirmButtonText: Resources.SharedResource.Ok }); } } } }); } function onlySpaces(str) { return str.trim().length === 0; } function AddBillToCart(BillDeductionId, amount, shareId, projectId) { StopOwl(); if (projectId == null || isNaN(projectId) || projectId == undefined || projectId <= 0) { return; } if (BillDeductionId == null || isNaN(BillDeductionId) || BillDeductionId == undefined || BillDeductionId <= 0) { return; } if (amount == null || isNaN(amount) || amount == undefined || amount <= 0) { new Noty({ layout: 'bottomCenter', text: 'ادخل المبلغ', type: 'error' }).show(); return; } FreezeScreen(); $.ajax({ url: '/MyProfile/AddBillToCart', type: 'Post', data: { ProjectId: projectId, ProjectShareId: shareId, BillDeductionId: BillDeductionId, Amount: amount, }, cache: false, success: function (data) { UnFreezeScreen(); if (data) { AddToCardPixel(projectId, $('#txtProjectName_' + projectId).val(), amount, 1); swal({ title: '', text: 'تم اضافة الفاتورة الي السلة', type: 'success', showConfirmButton: false, timer: 1000, confirmButtonText: Resources.SharedResource.Ok }); } } }); } function AddAllBillToCart() { swal({ title: "", text: 'هل انت متاكد من اضافة جميع الإستقطاعات الغير مدفوعة الى السلة', type: "warning", showCancelButton: true, confirmButtonColor: "#DD6B55", cancelButtonText: "الغاء", confirmButtonText: "نعم", closeOnCancel: true, closeOnConfirm: true }, function (isConfirm) { if (isConfirm) { FreezeScreen(); $.ajax({ url: '/MyProfile/AddAllBillToCart', type: 'Post', cache: false, success: function (data) { UnFreezeScreen(); swal({ title: '', text: 'تم اضافة جميع الإستقطاعات الي السلة', type: 'success', timer: 1000, showConfirmButton: false, confirmButtonText: Resources.SharedResource.Ok }, function () { if (affiliate != null) { window.location = "/MyProfile/Cart?a=" + affiliate; } else { window.location = "/MyProfile/Cart"; } }); } }); } }); } function ChangeDeductionStatus(statusId) { swal({ title: "", text: (statusId == 2 ? 'هل انت متاكد من ايقاف دفع الإستقطاعات' : 'هل انت متاكد من تفعيل دفع الإستقطاعات'), type: "warning", showCancelButton: true, confirmButtonColor: "#DD6B55", cancelButtonText: "الغاء", confirmButtonText: "نعم", closeOnCancel: true, closeOnConfirm: true }, function (isConfirm) { if (isConfirm) { FreezeScreen(); $.ajax({ url: '/MyProfile/ChangeDeductionStatus?statusId=' + statusId, type: 'Post', cache: false, success: function (data) { UnFreezeScreen(); swal({ title: '', text: 'تمت العملية بنجاح', type: 'success', timer: 1000, showConfirmButton: false, confirmButtonText: Resources.SharedResource.Ok }, function () { location.reload(); }); } }); } }); } function AddToCartGift() { var form = $("#frmGiftDonation"); if (!form.valid()) { return; } var projectId = $("#projectId").val(); var type = $("#typeId").val(); StopOwl(); if (projectId == null || isNaN(projectId) || projectId == undefined || projectId <= 0) { return; } var shareId = Number($('#txtShare_' + projectId).val()); var donationOpen = $("#txtDonationOpen_" + projectId + "_" + shareId).val(); var quantity = 1; var amount = 0; var donateType = Number($('#txtDonateType_' + projectId).val()); if (donateType == 1 || donateType == 3) { if (shareId == null || isNaN(shareId) || shareId == undefined || shareId <= 0) { new Noty({ layout: 'bottomCenter', text: 'اختر الفئة', type: 'error' }).show(); return; } } if (donateType == 1 || donateType == 3) { if (donationOpen == "value") { amount = Number($('#txtAmount_' + projectId).val()); } else { amount = Number($('#txtOneShareVal_' + projectId).val()); } } else { amount = Number($('#txtAmount_' + projectId).val()); } if (amount == null || isNaN(amount) || amount == undefined || amount <= 0) { new Noty({ layout: 'bottomCenter', text: 'ادخل المبلغ', type: 'error' }).show(); return; } if (donateType == 3 || donateType == 1) { quantity = Number($('#txtQuantity_' + projectId).val()) if (quantity == null || isNaN(quantity) || quantity == undefined || quantity <= 0) { new Noty({ layout: 'bottomCenter', text: 'ادخل الكمية', type: 'error' }).show(); return; } } if ($("#SendToName").val() == null || $("#SendToName").val() == "") { new Noty({ layout: 'bottomCenter', text: 'ادخل اسم المهدى إليه', type: 'error' }).show(); return; } if ($("#SendToMobile").val() == null || $("#SendToMobile").val() == "") { new Noty({ layout: 'bottomCenter', text: 'ادخل رقم جوال المهدى إليه', type: 'error' }).show(); return; } var SendToMobile = GetValidPhoneNumber("SendToMobile"); if (SendToMobile === '') { return; } SendToMobile = SendToMobile.replace("+", ""); if ($("#SenderName").val() == null || $("#SenderName").val() == "") { new Noty({ layout: 'bottomCenter', text: 'ادخل اسم المرسل', type: 'error' }).show(); return; } FreezeScreen(); $.ajax({ url: '/MyProfile/AddToCart', type: 'Post', data: { ProjectId: projectId, ProjectShareId: shareId, Quantity: quantity, Amount: amount, DonateTypeId: donateType, SendToName: $("#SendToName").val(), SendToMobile: SendToMobile, SenderName: $("#SenderName").val(), MessageDateTime: $('#MessageDateTime').val(), WantCopyForYou: $('#WantCopyForYou').is(":checked"), TypeSending: $("input[name='TypeSending']:checked").val(), DonationOpen: donationOpen == 'value' ? true : false, GiftProject: true, }, cache: false, success: function (data) { UnFreezeScreen(); if (data) { AddToCardPixel(projectId, $('#txtProjectName_' + projectId).val(), amount, quantity); swal({ title: '', text: 'تم اضافة التبرع الي السلة', type: 'success', showConfirmButton: false, timer: 1000, confirmButtonText: Resources.SharedResource.Ok }); $('.bs-modal-giftInfo').modal('hide'); setTimeout(function () { if (type == 1) { //location.reload(); } else { if (affiliate != null) { window.location = "/MyProfile/Cart?a=" + affiliate; } else { window.location = "/MyProfile/Cart"; } } }, 100); } } }); } function AddToCartDeduction() { var form = $("#frmCartDeduction"); if (!form.valid()) { return; } var projectId = $("#projectId").val(); var type = $("#typeId_Deduction").val(); StopOwl(); if (projectId == null || isNaN(projectId) || projectId == undefined || projectId <= 0) { return; } var shareId = 0; var quantity = 1; var amount = 0; var donateType = Number($('#txtDonateType_' + projectId).val()); if (donateType == 1 || donateType == 3 || donateType == 6) { shareId = Number($('#txtShare_' + projectId).val()); if (shareId == null || isNaN(shareId) || shareId == undefined || shareId <= 0) { new Noty({ layout: 'bottomCenter', text: 'اختر الفئة', type: 'error' }).show(); return; } } if (donateType == 1 || donateType == 3 || donateType == 6) { amount = Number($('#txtOneShareVal_' + projectId).val()); } else { amount = Number($('#txtAmount_' + projectId).val()); } if (amount == null || isNaN(amount) || amount == undefined || amount <= 0) { new Noty({ layout: 'bottomCenter', text: 'ادخل المبلغ', type: 'error' }).show(); return; } if (donateType == 3 || donateType == 1 || donateType == 6) { quantity = Number($('#txtQuantity_' + projectId).val()) if (quantity == null || isNaN(quantity) || quantity == undefined || quantity <= 0) { new Noty({ layout: 'bottomCenter', text: 'ادخل الكمية', type: 'error' }).show(); return; } } if ($("#DayNumber").val() == '') { new Noty({ layout: 'bottomCenter', text: 'اختر يوم الاستقطاع الشهري', type: 'error' }).show(); return; } FreezeScreen(); $.ajax({ url: '/MyProfile/AddToCart', type: 'Post', data: { ProjectId: projectId, ProjectShareId: shareId, Quantity: quantity, Amount: amount, DonateTypeId: donateType, DayNumber: $("#DayNumber").val(), DeductionProject: true, }, cache: false, success: function (data) { UnFreezeScreen(); if (data) { AddToCardPixel(projectId, $('#txtProjectName_' + projectId).val(), amount, quantity); swal({ title: '', text: 'تم اضافة التبرع الي السلة', type: 'success', showConfirmButton: false, timer: 1000, confirmButtonText: Resources.SharedResource.Ok }); $('.bs-modal-DeductionInfo').modal('hide'); setTimeout(function () { if (type == 1) { //location.reload(); } else { if (affiliate != null) { window.location = "/MyProfile/Cart?a=" + affiliate; } else { window.location = "/MyProfile/Cart"; } } }, 100); } } }); } function PopupGift(type, projectId) { StopOwl(); if (projectId == null || isNaN(projectId) || projectId == undefined || projectId <= 0) { return; } var shareId = Number($('#txtShare_' + projectId).val()); var donationOpen = $("#txtDonationOpen_" + projectId + "_" + shareId).val(); var quantity = 1; var amount = 0; var donateType = Number($('#txtDonateType_' + projectId).val()); if (donateType == 1 || donateType == 3) { if (shareId == null || isNaN(shareId) || shareId == undefined || shareId <= 0) { new Noty({ layout: 'bottomCenter', text: 'اختر الفئة', type: 'error' }).show(); return; } } if (donateType == 1 || donateType == 3) { if (donationOpen == "value") { amount = Number($('#txtAmount_' + projectId).val()); } else { amount = Number($('#txtOneShareVal_' + projectId).val()); } } else { amount = Number($('#txtAmount_' + projectId).val()); } if (amount == null || isNaN(amount) || amount == undefined || amount <= 0) { new Noty({ layout: 'bottomCenter', text: 'ادخل المبلغ', type: 'error' }).show(); return; } if (donateType == 3 || donateType == 1) { quantity = Number($('#txtQuantity_' + projectId).val()) if (quantity == null || isNaN(quantity) || quantity == undefined || quantity <= 0) { new Noty({ layout: 'bottomCenter', text: 'ادخل الكمية', type: 'error' }).show(); return; } } $("#projectId").val(projectId); $("#typeId").val(type); $('.bs-modal-giftInfo').modal('toggle'); $('.bs-modal-giftInfo').modal('show'); } function PopupCertificate(type, projectId) { StopOwl(); if (projectId == null || isNaN(projectId) || projectId == undefined || projectId <= 0) { return; } if ($('#txtPercentagePaidAmount_' + projectId).val() == true) { new Noty({ layout: 'bottomCenter', text: 'تم اكتمال المشروع لا يمكن التبرع مرة اخري', type: 'error' }).show(); return; } var shareId = 0; var quantity = 1; var amount = 0; var donateType = Number($('#txtDonateType_' + projectId).val()); if (donateType == 1 || donateType == 3) { shareId = Number($('#txtShare_' + projectId).val()); if (shareId == null || isNaN(shareId) || shareId == undefined || shareId <= 0) { new Noty({ layout: 'bottomCenter', text: 'اختر الفئة', type: 'error' }).show(); return; } } var DonationOpen = $('#txtDonationOpen_' + projectId + '_' + shareId).val(); if (donateType == 1 || donateType == 3) { if (DonationOpen == "value") { amount = Number($('#txtAmount_' + projectId).val()); } else { amount = Number($('#txtOneShareVal_' + projectId).val()); } } else { amount = Number($('#txtAmount_' + projectId).val()); } if (amount == null || isNaN(amount) || amount == undefined || amount <= 0) { new Noty({ layout: 'bottomCenter', text: 'ادخل المبلغ', type: 'error' }).show(); return; } if (donateType == 3 || donateType == 1) { quantity = Number($('#txtQuantity_' + projectId).val()) if (quantity == null || isNaN(quantity) || quantity == undefined || quantity <= 0) { new Noty({ layout: 'bottomCenter', text: 'ادخل الكمية', type: 'error' }).show(); return; } } $("#projectId").val(projectId); $("#projectTypeId").val(type); $('.bs-modal-CertificateInfo').modal('toggle'); $('.bs-modal-CertificateInfo').modal('show'); } function PopupDeduction(type, projectId) { StopOwl(); if (projectId == null || isNaN(projectId) || projectId == undefined || projectId <= 0) { return; } var shareId = 0; var quantity = 1; var amount = 0; var donateType = Number($('#txtDonateType_' + projectId).val()); if (donateType == 1 || donateType == 3 || donateType == 6) { shareId = Number($('#txtShare_' + projectId).val()); if (shareId == null || isNaN(shareId) || shareId == undefined || shareId <= 0) { new Noty({ layout: 'bottomCenter', text: 'اختر الفئة', type: 'error' }).show(); return; } } if (donateType == 1 || donateType == 3) { amount = Number($('#txtOneShareVal_' + projectId).val()); } if (donateType == 1 || donateType == 3 || donateType == 6) { amount = Number($('#txtOneShareVal_' + projectId).val()); } else { amount = Number($('#txtAmount_' + projectId).val()); } if (amount == null || isNaN(amount) || amount == undefined || amount <= 0) { new Noty({ layout: 'bottomCenter', text: 'ادخل المبلغ', type: 'error' }).show(); return; } if (donateType == 3 || donateType == 1 || donateType == 6) { quantity = Number($('#txtQuantity_' + projectId).val()) if (quantity == null || isNaN(quantity) || quantity == undefined || quantity <= 0) { new Noty({ layout: 'bottomCenter', text: 'ادخل الكمية', type: 'error' }).show(); return; } } $("#projectId").val(projectId); $("#typeId_Deduction").val(type); $('.bs-modal-DeductionInfo').modal('toggle'); $('.bs-modal-DeductionInfo').modal('show'); } function AddComment() { if ($("#txtcomment").val() == null || $("#txtcomment").val() == "") { new Noty({ layout: 'bottomCenter', text: 'ادخل التعليق', type: 'error' }).show(); return; } FreezeScreen(); $.ajax({ url: '/Association/AddCommentToProject?Comment=' + $("#txtcomment").val() + "&ProjectId=" + $("#txtProjectId").val(), type: 'Post', cache: false, success: function (data) { UnFreezeScreen(); $("#txtcomment").val(""); } }); } function AddToCardPixel(projectOrCategoryId, projectOrCategoryName, amount, quantity) { let hashedUserPhone = ""; if ($("#SnapchatPixelEnable").val() == 'true') { if ($("#UserPhone").val() == '') { snaptr('track', 'ADD_CART', { 'item_ids': projectOrCategoryId, 'price': amount, 'number_items': quantity, 'currency': 'SAR', 'item_category': projectOrCategoryName }); } else { hashedUserPhone = CryptoJS.SHA256($("#UserPhone").val().replace(/[^\d+]+/g, '').replace(/^\+/, '')).toString(); snaptr('track', 'ADD_CART', { 'item_ids': projectOrCategoryId, 'price': amount, 'number_items': quantity, 'currency': 'SAR', 'item_category': projectOrCategoryName, 'user_hashed_phone_number': hashedUserPhone }); } } if ($("#FacebookPixelEnable").val() == 'true') { fbq('track', 'AddToCart', { content_name: projectOrCategoryName, content_ids: projectOrCategoryId, value: amount, currency: 'SAR' }); } if ($("#GoogleAnalyticsEnable").val() == 'true') { gtag('event', 'add_to_cart', { "currency": "SAR", "value": amount, "items": [ { 'id': projectOrCategoryId, 'name': projectOrCategoryName, 'price': amount, 'quantity': quantity } ] }); } if ($("#GoogleTagEnabled").val() == 'true') { dataLayer.push({ ecommerce: null }); dataLayer.push({ 'event': 'addToCart', 'phone_hashed': hashedUserPhone, 'ecommerce': { 'currencyCode': 'SAR', 'add': { // 'add' actionFieldObject measures. 'products': [{ // adding a product to a shopping cart. 'name': projectOrCategoryName, 'id': projectOrCategoryId, 'price': amount, 'quantity': quantity }] } } }); } if ($("#TiktokPixelEnabled").val() == 'true') { ttq.track('AddToCart', { "contents": [ { "content_id": projectOrCategoryId, // string. ID of the product. Example: "1077218". "content_name": projectOrCategoryName, // string. The name of the page or product. Example: "shirt". "quantity": quantity, // number. The number of items. Example: 4. "price": amount // number. The price of a single item. Example: 25. } ], "value": amount, // number. Value of the order or items sold. Example: 100. "currency": "SAR" // string. The 4217 currency code. Example: "USD". }); } } function StartCheckout(totalAmount, quantity, itemIds) { if ($("#SnapchatPixelEnable").val() == 'true') { if ($("#UserPhone").val() == '') { snaptr('track', 'START_CHECKOUT', { 'item_ids': itemIds, 'price': totalAmount, 'number_items': quantity, 'currency': 'SAR' }); } else { let hashedUserPhone = CryptoJS.SHA256($("#UserPhone").val().replace(/[^\d+]+/g, '').replace(/^\+/, '')).toString(); snaptr('track', 'START_CHECKOUT', { 'item_ids': itemIds, 'price': totalAmount, 'number_items': quantity, 'currency': 'SAR', 'user_hashed_phone_number': hashedUserPhone }); } } if ($("#FacebookPixelEnable").val() == 'true') { fbq('track', 'InitiateCheckout', { num_items: quantity, content_ids: itemIds, value: totalAmount, currency: 'SAR' }); } if ($("#TiktokPixelEnabled").val() == 'true') { ttq.track('InitiateCheckout', { "value": totalAmount, // number. Value of the order or items sold. Example: 100. "currency": "SAR" // string. The 4217 currency code. Example: "USD". }); } } function CompletePayment(totalAmount, cardItems, operationCode, itemIds, quantity) { let hashedUserPhone = ""; if ($("#SnapchatPixelEnable").val() == 'true') { if ($("#UserPhone").val() == '') { snaptr('track', 'PURCHASE', { 'currency': 'SAR', 'price': totalAmount, 'transaction_id': operationCode, 'item_ids': itemIds, 'number_items': quantity }); } else { hashedUserPhone = CryptoJS.SHA256($("#UserPhone").val().replace(/[^\d+]+/g, '').replace(/^\+/, '')).toString() snaptr('track', 'PURCHASE', { 'currency': 'SAR', 'price': totalAmount, 'transaction_id': operationCode, 'item_ids': itemIds, 'number_items': quantity, 'user_hashed_phone_number': hashedUserPhone }); } } if ($("#FacebookPixelEnable").val() == 'true') { fbq('track', 'Purchase', { content_ids: itemIds, contents: cardItems, value: totalAmount, currency: 'SAR', num_items: quantity }); } if ($("#GoogleAnalyticsEnable").val() == 'true') { ga('ec:setAction', 'purchase', { 'id': operationCode, 'revenue': totalAmount, 'tax': '0.0', 'shipping': '0.0', }); gtag('event', 'purchase', { "transaction_id": operationCode, "value": totalAmount, "currency": "SAR", "tax": 0, "shipping": 0, "items": cardItems, }); } if ($("#GoogleTagEnabled").val() == 'true') { dataLayer.push({ ecommerce: null }); dataLayer.push({ 'phone_hashed': hashedUserPhone, 'ecommerce': { 'currencyCode': 'SAR', 'purchase': { 'actionField': { 'id': operationCode, 'revenue': totalAmount, 'shipping': '0', }, } } }); } if ($("#TiktokPixelEnabled").val() == 'true') { var contents = selectProperties(cardItems); ttq.track('CompletePayment', { "contents": contents, "value": totalAmount, // number. Value of the order or items sold. Example: 100. "currency": "SAR" // string. The 4217 currency code. Example: "USD". }); } } function selectProperties(jsonList) { return jsonList.map(function (item) { return { content_id: item.id, content_name: item.name, quantity: item.quantity, price: item.price }; }); } function ViewPage(id, title, name, nameEncode) { if ($("#GoogleAnalyticsEnable").val() == 'true') { gtag('event', 'view_item', { currency: "SAR", value: 0, "items": [ { "item_id": id, "item_name": nameEncode, price: 0, quantity: 1 } ] }); } if ($("#GoogleTagEnabled").val() == 'true') { let hashedUserPhone = CryptoJS.SHA256($("#UserPhone").val().replace(/[^\d+]+/g, '').replace(/^\+/, '')).toString(); dataLayer.push({ ecommerce: null }); dataLayer.push({ 'phone_hashed': hashedUserPhone, 'ecommerce': { 'detail': { 'actionField': { 'list': title }, 'products': [{ 'name': name, 'id': id, }] } } }); } if ($("#TiktokPixelEnabled").val() == 'true') { ttq.track('ViewContent', { "contents": [ { "content_id": id, // string. ID of the product. Example: "1077218". "content_name": title, // string. The name of the page or product. Example: "shirt". } ], "value": "0", // number. Value of the order or items sold. Example: 100. "currency": "SAR" // string. The 4217 currency code. Example: "USD". }); } } function SearchItems(searchKeyword) { if ($("#SnapchatPixelEnable").val() == 'true') { if ($("#UserPhone").val() == '') { snaptr('track', 'SEARCH', { 'search_string': searchKeyword }); } else { let hashedUserPhone = CryptoJS.SHA256($("#UserPhone").val().replace(/[^\d+]+/g, '').replace(/^\+/, '')).toString(); snaptr('track', 'SEARCH', { 'search_string': searchKeyword, 'user_hashed_phone_number': hashedUserPhone }); } } if ($("#FacebookPixelEnable").val() == 'true') { fbq('track', 'Search'); } if ($("#TiktokPixelEnabled").val() == 'true') { ttq.track('Search', { "value": "0", "currency": "SAR", "query": searchKeyword }); } }