var paginationRequestTake = 5; var LoadCourseFilterRequest = new Array(); var isFilter = false; var isTab = false; var SearchFilterFlag = true; var FilterLocationFlag = false; var Order = [{ column: 0, dir: 'desc' }]; var TGCoursesList = new Array(); var FreeCourseList = new Array(); var moreLocationTR = null; var getPrerequisitesRespo = null; var TotalRow = 0; var TotalCourse = 0; //var productIdFromMoreLocation = 0; var storeOrderChanged = false; var TrainingListcontainerdiv = ''; if (IsTrainingModalScript == 'True') { TrainingListcontainerdiv = '.TrainingModal'; } else { TrainingListcontainerdiv = '.ListofTraining'; } var GetPurchaseId = 0; var Lat = 0; var Long = 0; var geocoder; var FromScheduleFlag = true; var Async = true; var nMonth = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; var titleArr = []; var seDateArr = []; function successFunction(position) { var lat = position.coords.latitude; var lng = position.coords.longitude; Lat = lat; Long = lng; //alert(lat + ", " + lng); $('.browserHint').addClass('hide'); $('.ListofTraining').removeClass('hide'); BindLoadAvailableCourses(); } function errorFunction() { // $('.browserHint').addClass('hide'); // $('.ListofTraining').addClass('hide'); // if ($("#LocationModal").html() != undefined) { // $("#LocationModal").modal('show'); // } // else { // BindLoadAvailableCourses(); // } $('#pac-input').focus(); } function initialize() { geocoder = new google.maps.Geocoder(); } function setCookie(cname, cvalue, exdays) { var d = new Date(); d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); var expires = "expires=" + d.toGMTString(); document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; } function getCookie(cname) { var name = cname + "="; var decodedCookie = decodeURIComponent(document.cookie); var ca = decodedCookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } return ""; } $(document).ready(function () { if ($(TrainingListcontainerdiv + ' input[type="radio"][name="trainingFilter"]:checked').length > 0) { LoadCourseFilterRequest = new Array(); LoadCourseFilterRequest.push({ FieldName: 'CategoryType', ID: $(TrainingListcontainerdiv + ' input[type="radio"][name="trainingFilter"]:checked').val(), ConditionalParameters: 1 }); } if (IsAuthenticated == "True") { BindLoadAvailableCourses(); } else { initialize(); if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(successFunction, errorFunction); } else { alert('Geolocation is not supported by your browser.'); if (!FromScheduleFlag) { BindLoadAvailableCourses(); } } } $(document).on('click', "#dtAvailableCourses tr", function () { $("#dtAvailableCourses tr").removeClass('SelectedTR'); $(this).addClass('SelectedTR'); }) LoadFilter(TrainingListcontainerdiv + ' #tblHeaderAvailableCourses', BindLoadAvailableCourses); $(document).off('click', TrainingListcontainerdiv + ' #dtAvailableCourses .group'); $(document).on('click', TrainingListcontainerdiv + ' #dtAvailableCourses .group', function () { if ($(this).hasClass('active')) { $(TrainingListcontainerdiv + ' [data-catid="' + $(this).attr('data-catid') + '"]:not(".group")').show(); $(TrainingListcontainerdiv + ' [data-catid="' + $(this).attr('data-catid') + '"]:not(".group")').removeClass('active'); $(this).removeClass('active'); } else { $(TrainingListcontainerdiv + ' [data-catid="' + $(this).attr('data-catid') + '"]:not(".group")').hide(); $(this).addClass('active'); } }); $(document).off('click', '.CopyTrainingdatatoQAfromProd'); $(document).on('click', '.CopyTrainingdatatoQAfromProd', function () { var CourseId = $(this).attr('data-id'); var TrainingType = $(this).attr('data-type'); $.ajax({ url: "/DataCopy/TrainingContentToQAFromProd/", type: 'POST', data: { CourseId: CourseId, TrainingType: TrainingType }, success: function (data) { if (data.Status) { alert('Course content copied successfully'); } } }); }); $(document).off('click', TrainingListcontainerdiv + ' #dtAvailableCourses .sbgroup'); $(document).on('click', TrainingListcontainerdiv + ' #dtAvailableCourses .sbgroup', function () { if ($(this).hasClass('active')) { $(TrainingListcontainerdiv + ' [data-catid="' + $(this).attr('data-catid') + '"][data-subcatid="' + $(this).attr('data-subcatid') + '"]:not(".sbgroup")').show(); $(this).removeClass('active'); } else { $(TrainingListcontainerdiv + ' [data-catid="' + $(this).attr('data-catid') + '"][data-subcatid="' + $(this).attr('data-subcatid') + '"]:not(".sbgroup")').hide(); $(this).addClass('active'); } }); $(document).off('click', TrainingListcontainerdiv + ' .jsLoadMoreAvailableCourses'); $(document).on('click', TrainingListcontainerdiv + ' .jsLoadMoreAvailableCourses', function () { var prodIds = $.map($(TrainingListcontainerdiv + ' .jsLoadMoreAvailableCourses').closest('tr').prevAll('tr.jsRowData[data-subcatid="' + $(this).closest('tr').attr('data-subcatid') + '"]'), function (item) { return $(item).attr('data-id') }); if ($(this).attr('data-ispurchased') != 'True') { prodIds = $.map($(TrainingListcontainerdiv + ' .jsLoadMoreAvailableCourses').closest('tr').prevAll('tr.jsRowData[data-catid="' + $(this).closest('tr').attr('data-catid') + '"][data-subcatid="' + $(this).closest('tr').attr('data-subcatid') + '"]'), function (item) { return $(item).attr('data-id') }) } BindLoadAvailableCourses($(this), true, $(this).closest('tr').attr('data-subcatid'), $(this).closest('tr').attr('data-catid'), prodIds); }); $(document).off('click', TrainingListcontainerdiv + ' .jsCoursePreview'); $(document).on('click', TrainingListcontainerdiv + ' .jsCoursePreview', function () { // debugger var _this = $(this); $('#mdlCoursePreview .vidBase').parent().children('.courseVidDiv').remove(); $(TrainingListcontainerdiv + ' .jsPreviewActive').removeClass('jsPreviewActive'); $('.jsBtnTakeFreeCourse').addClass('jsBtnByThisCourse').removeClass('jsBtnTakeFreeCourse').html('Buy Course'); $(_this).addClass('jsPreviewActive'); $('.jsBtnByThisCourse').removeClass('hide'); var CurrentRow = $(_this).closest('tr'); if ($(CurrentRow).find('.purchaseBtn').length > 0) { var ProductId = $(CurrentRow).find('.purchaseBtn').attr('data-productid'); var SubProductId = $(CurrentRow).find('.purchaseBtn').attr('data-subproductid'); } else { var ProductId = $(CurrentRow).find('.jsAddMyListCourse').attr('data-productid'); var SubProductId = $(CurrentRow).find('.jsAddMyListCourse').attr('data-subproductid'); } if (IsAuthenticated == "False") { if ($(CurrentRow).find('.CourseProduct').length > 0) { var ProductId = $(CurrentRow).find('.CourseProduct').attr('data-productid'); var SubProductId = $(CurrentRow).find('.CourseProduct').attr('data-subproductid'); } } $('#mdlCoursePreview .jsTitle').html($(CurrentRow).find('td.jsCourseTitle').find('.dblk').text()); $('#mdlCoursePreview .jsSubTitle').html($(CurrentRow).find('td.jsCourseTitle').find('em').text()); $('#mdlCoursePreview .MainTrainingData .jsClassLocation').html(($.trim($(CurrentRow).find('td.location').html()) != '' ? $(CurrentRow).find('td.location').html().replace(new RegExp('
', 'g'), " ") : '-')); $('#mdlCoursePreview .MainTrainingData .jsClassLocation').attr('data-id', ProductId).attr('data-subcatid', $(_this).closest('tr').attr('data-subcatid')); if (SubProductId != undefined && parseInt(SubProductId) > 0) { $('#mdlCoursePreview .MainTrainingData .jsClassLocation').attr('data-subproductid', SubProductId); } else { $('#mdlCoursePreview .MainTrainingData .jsClassLocation').removeAttr('data-subproductid'); } $('#mdlCoursePreview .MainTrainingData .jsYear').html($(CurrentRow).find('td.jsYear').html()); var jsAboutCourse = $.trim($(CurrentRow).find('.jsAboutCourse').html()); if ($(jsAboutCourse).text().trim() != '' || $(jsAboutCourse).has('img').length > 0 || $(jsAboutCourse).has('a').length > 0 || $(jsAboutCourse).has('video').length > 0) { $('#mdlCoursePreview .jsDescription').html($(CurrentRow).find('.jsAboutCourse').html()); $('#mdlCoursePreview .jsDescription').removeClass('hide'); } else { $('#mdlCoursePreview .jsDescription').addClass('hide'); } if ($(_this).attr('data-ispublish') == 'True') { $('#mdlCoursePreview .jsPrice').html($(CurrentRow).find('td.jsPrice').html()); $('#mdlCoursePreview .jsPrice .OriginalPrice').removeClass('hide'); $('#mdlCoursePreview .jsPrice').parents('.form-group:first').removeClass('hide') } else { $('#mdlCoursePreview .jsPrice').parents('.form-group:first').addClass('hide') } if ($.trim($(_this).attr('data-Videopath')) != '') { var FileFullPath = $.trim($(_this).attr('data-Videopath')); if (IsOfflineMode == 'False') { AWS.config.update({ region: bucketRegion, credentials: new AWS.CognitoIdentityCredentials({ IdentityPoolId: IdentityPoolId }) }); var s3 = new AWS.S3({ apiVersion: '2012-10-17', params: { Bucket: AWSS3Bucket } }); var str = FileFullPath; var n = str.lastIndexOf('/'); var result = str.substring(n + 1); var outputfile = result.substr(0, result.lastIndexOf('.')) || result; console.log(result); var FullFileName = outputfile + '.mp4'; //var deleteparam = { // Bucket: AWSS3Bucket, // Key: fileName //} //s3.deleteObject(deleteparam, function (err, metadata) { // if (err) { // // window.console.clear(); // } //}); var params2 = { Bucket: AWSS3BucketPreview, Key: FullFileName, Expires: 6000 }; s3.getSignedUrl("getObject", params2, function (err, url) { if (err) { } else { if (url != null) { $("#mdlCoursePreview #jsVideo source").attr('src', url); var vidClone = $('#mdlCoursePreview .vidBase').children().clone(true, true); vidClone.prependTo($('#mdlCoursePreview .vidBase').parent()); var vidId = $('#mdlCoursePreview .vidBase').find('video').attr('id') + 1; $('#mdlCoursePreview .vidBase').parent().children('.courseVidDiv').children('video').attr('id', vidId); $('#mdlCoursePreview .jsDescription').removeClass('flx1'); } } }); } else { $("#mdlCoursePreview #jsVideo source").attr('src', '/Video/PlayVideo?FilePath=' + $(_this).attr('data-Videopath')); var vidClone = $('#mdlCoursePreview .vidBase').children().clone(true, true); vidClone.prependTo($('#mdlCoursePreview .vidBase').parent()); var vidId = $('#mdlCoursePreview .vidBase').find('video').attr('id') + 1; $('#mdlCoursePreview .vidBase').parent().children('.courseVidDiv').children('video').attr('id', vidId); $('#mdlCoursePreview .jsDescription').removeClass('flx1'); } } else { $('#mdlCoursePreview .jsDescription').addClass('flx1'); } if ($(_this).attr('data-ismytraining') == 'True' || $(_this).attr('data-ispurchased') == 'True') { $('.jsBtnByThisCourse').addClass('hide'); } if ($(_this).attr('data-ismytraining') != 'True' && $(_this).attr('data-isfree') == 'True') { $('.jsBtnByThisCourse').addClass('jsBtnTakeFreeCourse').removeClass('jsBtnByThisCourse').html('Add To My List'); $('.jsBtnTakeFreeCourse').on('click', function () { if ($(_this).closest('td').find('.jsAddMyListCourse').length > 0) { $(_this).closest('td').find('.jsAddMyListCourse').trigger('click'); } else if ($(_this).closest('td').find('.purchaseBtn').length > 0) { $(_this).closest('td').find('.purchaseBtn').trigger('click'); } $('#mdlCoursePreview').modal('hide'); }) } $('#mdlCoursePreview').modal('show'); }); $(document).off('click', TrainingListcontainerdiv + ' .jsAddMyListCourse'); $(document).on('click', TrainingListcontainerdiv + ' .jsAddMyListCourse', function () { //debugger; var _this = $(this); $('#moreLocationList').modal('hide'); var subProductId = 0; if ($(_this).attr('data-subproductid') != undefined) { subProductId = parseInt($(_this).attr("data-subproductid")); } $.ajax({ url: '/Courses/AddCourseInAccess', type: 'post', data: { productId: $(_this).attr('data-productid'), subProductId: subProductId }, success: function (respo) { if (respo) { if ($(_this).hasClass('morelo')) { $('#moreLocationList').modal('hide'); //console.log($('jsActiveProdToAddCart').closest('tr')); GenerateNewPurchasedTR($('.jsActiveProdToAddCart').closest('tr')); } else { GenerateNewPurchasedTR($(_this).closest('tr')); } //$(_this).remove(); } } }); }); $(document).off('click', '.jsPublishCourse'); $(document).on('click', '.jsPublishCourse', function () { $('.jsActivePublishCourse').removeClass('jsActivePublishCourse'); $(this).addClass('jsActivePublishCourse'); $('.jsEditCourseBody').load('/Courses/EditCourse/' + $(this).closest('tr').attr('data-id'), function () { $('#mdlCourseEdit').modal('show'); }) }); $(document).off('click', TrainingListcontainerdiv + ' .jsShowCourseSelling'); $(document).on('click', TrainingListcontainerdiv + ' .jsShowCourseSelling', function () { var _this = $(this); $(TrainingListcontainerdiv + ' .jsShowSellingDetailBody').load('/Courses/ShowSellingDetail/' + $(this).closest('tr').attr('data-id'), function () { $('#mdlShowSellingDetail .jsTitle').html($(_this).closest('tr').find('td.jsCourseTitle .dblk').html()); $('#mdlShowSellingDetail').modal('show'); }) }); //Filter $(document).off('click', TrainingListcontainerdiv + ' #tblHeaderAvailableCourses .btnOpenFilter'); $(document).on('click', TrainingListcontainerdiv + ' #tblHeaderAvailableCourses .btnOpenFilter', function (e) { // debugger; e.stopPropagation(); $('ul.filter_box').addClass('hide'); if ($(this).closest('th').attr('data-field') == 'CategoryId' && $(this).closest('.TrainingModal').hasClass('OnlyVideo')) { return false; } $(this).next('ul.filter_box').removeClass('hide'); if ($('body').hasClass('alignersite')) { filterboxPos(this); } }); $(document).off('click', TrainingListcontainerdiv + ' #tblHeaderAvailableCourses .filter_box'); $(document).on('click', TrainingListcontainerdiv + ' #tblHeaderAvailableCourses .filter_box', function (e) { if (!$(e.target).hasClass('sortASC') && !$(e.target).hasClass('sortDESC') && !$(e.target).hasClass('btnFilter') && !$(e.target).hasClass('btnClearfilter')) { e.stopPropagation(); $(this).removeClass('hide'); } }); $(document).off('click', TrainingListcontainerdiv + ' #tblHeaderAvailableCourses .sortASC'); $(document).on('click', TrainingListcontainerdiv + ' #tblHeaderAvailableCourses .sortASC', function (e) { $(TrainingListcontainerdiv + ' .sorting_desc').removeClass('sorting_desc'); $(TrainingListcontainerdiv + ' .sorting_asc').removeClass('sorting_asc'); $(this).closest('th').addClass('sorting_asc'); Order = [{ column: ($(this).closest('th').index() - 2), dir: 'asc' }]; storeOrderChanged = true; isFilter = true; BindLoadAvailableCourses(); $(TrainingListcontainerdiv + ' ul.filter_box').addClass('hide'); }); $(document).off('click', TrainingListcontainerdiv + ' #tblHeaderAvailableCourses .sortDESC'); $(document).on('click', TrainingListcontainerdiv + ' #tblHeaderAvailableCourses .sortDESC', function (e) { $(TrainingListcontainerdiv + ' .sorting_desc').removeClass('sorting_desc'); $(TrainingListcontainerdiv + ' .sorting_asc').removeClass('sorting_asc'); $(this).closest('th').addClass('sorting_desc'); storeOrderChanged = true; Order = [{ column: ($(this).closest('th').index() - 2), dir: 'desc' }]; isFilter = true; BindLoadAvailableCourses(); $(TrainingListcontainerdiv + ' ul.filter_box').addClass('hide'); }); //End Filter //$(document).off('click', TrainingListcontainerdiv + ' .jsDropdown'); //$(document).on('click', TrainingListcontainerdiv + ' .jsDropdown', function () { // $(this).parent('div.dropdown').removeClass('dropup'); // if ($(this).parents('#dtAvailableCourses').length > 0) { // if ($(this).parents('#dtAvailableCourses').outerHeight() <= ($(this).offset().top + $(this).next().outerHeight())) { // $(this).parent('div.dropdown').addClass('dropup'); // } // } // else { // if ($(this).parents('div#divContentAvailableCourses').outerHeight() <= ($(this).offset().top + $(this).next().outerHeight())) { // $(this).parent('div.dropdown').addClass('dropup'); // } // } //}); $(document).on('hidden.bs.dropdown', TrainingListcontainerdiv + ' .dropdown', function () { if ($(this).hasClass('dropup')) { $(this).removeClass('dropup'); } }) $(document).off('click', TrainingListcontainerdiv + ' .jsOpenPriceHistory'); $(document).on('click', TrainingListcontainerdiv + ' .jsOpenPriceHistory', function () { var _this = $(this); $('#mdlShowPriceHistory .jsShowPriceHistoryBody').load('/CoursesLibrary/ShowPriceHistory/' + $(_this).attr('data-id'), function () { $('#mdlShowPriceHistory .jsTitle').html($(_this).attr('data-title')); $('#mdlShowPriceHistory').modal('show'); }); }); $(document).off('click', TrainingListcontainerdiv + ' .jsOpenCourseUsers'); $(document).on('click', TrainingListcontainerdiv + ' .jsOpenCourseUsers', function () { var _this = $(this); $(TrainingListcontainerdiv + ' #divShowCourseUsers').load('/CoursesLibrary/ShowCourseUsers/' + $(_this).attr('data-id'), function () { $('#mdlShowCourseUsers .jsTitle').html(decodeURI($(_this).attr('data-title'))); if ($(_this).closest('tr').attr('data-subcatid') == "609") { $(TrainingListcontainerdiv + ' .userlocationtd').html('-'); } $('#mdlShowCourseUsers').modal('show'); }); }); $(document).off('click', TrainingListcontainerdiv + ' .purchaseBtn'); $(document).on('click', TrainingListcontainerdiv + ' .purchaseBtn', function () { getPrerequisitesRespo = null; FreeCourseList = new Array(); var _this = $(this); $('#mdlPrerequisiteConfirm .vidBase').parent().children('.courseVidDiv').remove(); $('.jsActiveProdToAddCart').removeClass('jsActiveProdToAddCart'); $('#mdlPrerequisiteConfirm .addToCartPrerequisites').text('Buy Course'); $('#mdlPrerequisiteConfirm .jsChangeClassLocation').addClass('hide'); $(_this).addClass('jsActiveProdToAddCart'); $("#loadingWithBG").show(); $('.addToCartPrerequisites').removeClass('hide'); if ($(".SelectedView").val() == "listview") { var jsCoursePreview = $(this).closest('td').find('.jsCoursePreview'); var CurrentRow = $(jsCoursePreview).closest('tr'); var MainCourseLatitude =0; var MainCourseLongitude = 0; $('#mdlPrerequisiteConfirm .MainTrainingData .jsTitle').html($(CurrentRow).find('td.jsCourseTitle').find('.dblk').text()); $('#mdlPrerequisiteConfirm .MainTrainingData .jsSubTitle').html($(CurrentRow).find('td.jsCourseTitle').find('em').text()); if ($(CurrentRow).find('td.location').find('a').hasClass('moreLocation')) { $('#mdlPrerequisiteConfirm .MainTrainingData .jsClassLocation').attr('data-latitude', $(CurrentRow).find('td.location').find('a.moreLocation').attr('data-latitude')); $('#mdlPrerequisiteConfirm .MainTrainingData .jsClassLocation').attr('data-longitude', $(CurrentRow).find('td.location').find('a.moreLocation').attr('data-longitude')); $('#mdlPrerequisiteConfirm .MainTrainingData .jsChangeClassLocation').removeClass('hide'); MainCourseLatitude = $(CurrentRow).find('td.location').find('a.moreLocation').attr('data-latitude'); MainCourseLongitude = $(CurrentRow).find('td.location').find('a.moreLocation').attr('data-longitude'); if ($(CurrentRow).find('td.location').find('a.moreLocation').find('.hlinkC.flxg2').length > 0) { $('#mdlPrerequisiteConfirm .MainTrainingData .jsClassLocation').html(($.trim($(CurrentRow).find('td.location').html()) != '' ? $(CurrentRow).find('td.location').find('a.moreLocation').find('.hlinkC.flxg2').html().replace(new RegExp('
', 'g'), " ") : '')); } else { $('#mdlPrerequisiteConfirm .MainTrainingData .jsClassLocation').html(($.trim($(CurrentRow).find('td.location').html()) != '' ? $(CurrentRow).find('td.location').find('a.moreLocation').html().replace(new RegExp('
', 'g'), " ") : '')); } } else { $('#mdlPrerequisiteConfirm .MainTrainingData .jsClassLocation').attr('data-latitude', $(CurrentRow).find('td.location').find('.TrainingLocation').attr('data-latitude')); $('#mdlPrerequisiteConfirm .MainTrainingData .jsClassLocation').attr('data-longitude', $(CurrentRow).find('td.location').find('.TrainingLocation').attr('data-longitude')); $('#mdlPrerequisiteConfirm .MainTrainingData .jsClassLocation').html(($.trim($(CurrentRow).find('td.location').html()) != '' ? $(CurrentRow).find('td.location').html().replace(new RegExp('
', 'g'), " ") : '-')); MainCourseLatitude = $(CurrentRow).find('td.location').find('.TrainingLocation').attr('data-latitude'); MainCourseLongitude = $(CurrentRow).find('td.location').find('.TrainingLocation').attr('data-longitude'); } $('#mdlPrerequisiteConfirm .MainTrainingData .jsYear').html($(CurrentRow).find('td.jsYear').html()); $('#mdlPrerequisiteConfirm .MainTrainingData .jsClassLocation').attr('data-id', $(_this).attr('data-productid')).attr('data-subcatid', $(_this).closest('tr').attr('data-subcatid')); if ($(jsCoursePreview).attr('data-ispublish') == 'True') { $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody .jsPrice').html($(CurrentRow).find('td.jsPrice').html()); $('#mdlPrerequisiteConfirm .MainTrainingData .jsPrice').html($(CurrentRow).find('td.jsPrice').html()); //$('#mdlPrerequisiteConfirm .MainTrainingData .jsPrice').parents('.form-group:first').removeClass('hide') } else { // $('#mdlPrerequisiteConfirm .MainTrainingData .jsPrice').parents('.form-group:first').addClass('hide') } } else { var jsCoursePreview = $(this).parent().find('.jsCoursePreview'); var CurrentRow = $(jsCoursePreview).closest('.cgroupRow'); $('#mdlPrerequisiteConfirm .MainTrainingData .jsTitle').html($(CurrentRow).find('.dblk').text()); $('#mdlPrerequisiteConfirm .MainTrainingData .jsSubTitle').html($(CurrentRow).find('em.dblksubtitle').text()); $('#mdlPrerequisiteConfirm .MainTrainingData .jsClassLocation').html(($.trim($(CurrentRow).find('.location').html()) != '' ? $(CurrentRow).find('.location').html().replace(new RegExp('
', 'g'), " ") : '-')); $('#mdlPrerequisiteConfirm .MainTrainingData .jsYear').html($(CurrentRow).find('.jsYear').html()); $('#mdlPrerequisiteConfirm .MainTrainingData .jsClassLocation').attr('data-id', $(_this).attr('data-productid')).attr('data-subcatid', $(_this).closest('.cgroupRow').attr('data-subcatid')); if ($(jsCoursePreview).attr('data-ispublish') == 'True') { $('#mdlPrerequisiteConfirm .MainTrainingData .jsPrice').html($(CurrentRow).find('td.jsPrice').html()); $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody .jsPrice').html($(CurrentRow).find('td.jsPrice').html()); //$('#mdlPrerequisiteConfirm .MainTrainingData .jsPrice').parents('.form-group:first').removeClass('hide') } else { //$('#mdlPrerequisiteConfirm .MainTrainingData .jsPrice').parents('.form-group:first').addClass('hide') } } //$('#mdlPrerequisiteConfirm .MainTrainingData .jsClassId').html($(CurrentRow).find('td.jsYear').find('span.jsClassId').html()); //$('#mdlPrerequisiteConfirm .MainTrainingData .jsTime').html($(CurrentRow).find('td.jsYear').find('span.jsTime').html()); if ($(_this).attr('data-subproductid') != undefined && parseInt((_this).attr('data-subproductid')) > 0) { $('#mdlPrerequisiteConfirm .MainTrainingData .jsClassLocation').attr('data-subproductid', $(_this).attr('data-subproductid')); } else { $('#mdlPrerequisiteConfirm .MainTrainingData .jsClassLocation').removeAttr('data-subproductid'); } var jsAboutCourse = $.trim($(CurrentRow).find('.jsAboutCourse').html()); if ($(jsAboutCourse).text().trim() != '' || $(jsAboutCourse).has('img').length > 0 || $(jsAboutCourse).has('a').length > 0 || $(jsAboutCourse).has('video').length > 0) { $('#mdlPrerequisiteConfirm .jsDescription').html($(CurrentRow).find('.jsAboutCourse').html()); $('#mdlPrerequisiteConfirm .jsDescription').removeClass('hide'); } else { $('#mdlPrerequisiteConfirm .jsDescription').addClass('hide'); } if ($.trim($(jsCoursePreview).attr('data-Videopath')) != '') { if (IsOfflineMode == 'False') { AWS.config.update({ region: bucketRegion, credentials: new AWS.CognitoIdentityCredentials({ IdentityPoolId: IdentityPoolId }) }); var s3 = new AWS.S3({ apiVersion: '2012-10-17', params: { Bucket: AWSS3Bucket } }); var str = $(jsCoursePreview).attr('data-Videopath'); var n = str.lastIndexOf('/'); var result = str.substring(n + 1); //console.log(result); //var FullFileName = outputfile + '.mp4'; //var deleteparam = { // Bucket: AWSS3Bucket, // Key: fileName //} //s3.deleteObject(deleteparam, function (err, metadata) { // if (err) { // // window.console.clear(); // } //}); var outputfile = result.substr(0, result.lastIndexOf('.')) || result; var FullFileName = outputfile + '.mp4'; var params2 = { Bucket: AWSS3BucketPreview, Key: FullFileName, Expires: 6000 }; s3.getSignedUrl("getObject", params2, function (err, url) { if (err) { } else { if (url != null) { //$('.vidBase').parent().children('.courseVidDiv').children('video').attr('src', url); $("#mdlPrerequisiteConfirm #jsVideo source").attr('src', url); var vidClone = $('#mdlPrerequisiteConfirm .vidBase').children().clone(true, true); vidClone.prependTo($('#mdlPrerequisiteConfirm .vidBase').parent()); var vidId = $('#mdlPrerequisiteConfirm .vidBase').find('video').attr('id') + 1; $('#mdlPrerequisiteConfirm .vidBase').parent().children('.courseVidDiv').children('video').attr('id', vidId); $('#mdlPrerequisiteConfirm .jsDescription').removeClass('flx1'); } } }); } else { $("#mdlPrerequisiteConfirm #jsVideo source").attr('src', '/Video/PlayVideo?FilePath=' + $(jsCoursePreview).attr('data-Videopath')); var vidClone = $('#mdlPrerequisiteConfirm .vidBase').children().clone(true, true); vidClone.prependTo($('#mdlPrerequisiteConfirm .vidBase').parent()); var vidId = $('#mdlPrerequisiteConfirm .vidBase').find('video').attr('id') + 1; $('#mdlPrerequisiteConfirm .vidBase').parent().children('.courseVidDiv').children('video').attr('id', vidId); $('#mdlPrerequisiteConfirm .jsDescription').removeClass('flx1'); } } else { $('#mdlPrerequisiteConfirm .jsDescription').addClass('flx1'); } var IsHTMLBlank = true; var jsAboutCourse = $.trim($(CurrentRow).find('.jsAboutCourse').html()); if ($(jsAboutCourse).text().trim() != '' || $(jsAboutCourse).has('img').length > 0 || $(jsAboutCourse).has('a').length > 0 || $(jsAboutCourse).has('video').length > 0) { IsHTMLBlank = false; } if (!IsHTMLBlank && $.trim($(jsCoursePreview).attr('data-Videopath')) != '') { $('#mdlPrerequisiteConfirm .PreviewOverviewTitleId').text('Preview Video/About the course'); } else if (!IsHTMLBlank != '') { $('#mdlPrerequisiteConfirm .PreviewOverviewTitleId').text('About the course'); } else if ($.trim($(jsCoursePreview).attr('data-Videopath')) != '') { $('#mdlPrerequisiteConfirm .PreviewOverviewTitleId').text('Preview Video'); } else { $('#mdlPrerequisiteConfirm .tab-content').addClass('hide'); } $('#mdlPrerequisiteConfirm #CourseHavePrerequisite').html(""); if ($(jsCoursePreview).attr('data-ismytraining') == 'True' || $(jsCoursePreview).attr('data-ispurchased') == 'True') { $('.addToCartPrerequisites').addClass('hide'); } if ($(_this).attr('data-courseprerequisiteids') != "") { $.ajax({ url: '/Courses/GetPreRequisite', data: { coursePreRequisiteIds: $(_this).attr('data-courseprerequisiteids'), productId: $(_this).attr('data-productid') }, success: function (respo) { var respoAdd = { ListOfCourses: [] } productIds = new Array(); $('#oneclick_checkout_course #productIds').val(''); respoAdd.ListOfCourses.push(respo.ListOfCourses); getPrerequisitesRespo = respo; var showConfirm = false; var product; var additionalProd = new Array(); var prere = 'prerequisite'; var cour = 'course'; var table = ''; if (respo.ListOfCourses.length > 2) { prere = 'prerequisites'; cour = 'courses'; } table += ''; table += ''; var CourseHavePrerequisite = false; for (i = 0; i < respo.ListOfCourses.length; i++) { additionalProd.push(respo.ListOfCourses[i].Id); CourseHavePrerequisite = true; var IsLocation = (respo.ListOfCourses[i].listOfCoursesLocation != null && respo.ListOfCourses[i].listOfCoursesLocation.length > 0); if (IsLocation) { var ListOfMatchedCoursesLocation = respo.ListOfCourses[i].listOfCoursesLocation.filter(x=>x.Latitude == MainCourseLatitude && x.Longitude == MainCourseLongitude); if (ListOfMatchedCoursesLocation.length > 0) { var ListOfUnMatchedCoursesLocation = respo.ListOfCourses[i].listOfCoursesLocation.filter(x=>x.Latitude != MainCourseLatitude || x.Longitude != MainCourseLongitude); if (ListOfUnMatchedCoursesLocation.length > 0) { for (var p = 0; p < ListOfUnMatchedCoursesLocation.length; p++) { ListOfMatchedCoursesLocation.push(ListOfUnMatchedCoursesLocation[p]); } } respo.ListOfCourses[i].listOfCoursesLocation = ListOfMatchedCoursesLocation; } } table += GeneratePreAddtionalTr(respo.ListOfCourses[i], "prerequisitetr"); if (parseInt($(_this).attr('data-productid')) != respo.ListOfCourses[i].Id || respo.ListOfCourses[i].listOfCoursesLocation.length > 0) { showConfirm = true; if (parseInt($(_this).attr('data-productid')) == respo.ListOfCourses[i].Id) { product = respo.ListOfCourses[i]; } } else { product = respo.ListOfCourses[i]; } } table += '
This course has the following ' + prere + '
Course NameLocationDateInstructorPrice
'; table += '
Total:
'; table += '

Do you want to purchase ' + product.Title + ' and the listed above?

'; if ($(_this).attr('data-additionalcourses') != undefined && $(_this).attr('data-additionalcourses') != '') {// || additionalProd.length >0 var addTable = ''; var AlignerAdditionalCourseList = ""; //Following training accessible free $.ajax({ url: '/Courses/GetAdditionalCourse', data: { additionalCourseIds: ($(_this).attr('data-additionalcourses') != undefined && $(_this).attr('data-additionalcourses') != '' ? $(_this).attr('data-additionalcourses') : '0'), productId: $(_this).attr('data-productid'), prerequestIds: additionalProd.toString() }, async: false, success: function (addrespo) { if (addrespo.ListOfCourses != null && addrespo.ListOfCourses.length > 0) { addTable += 'The course includes the following additional courses for free'; addTable += 'Course NameLocationDateInstructorPrice'; for (var j = 0; j < addrespo.ListOfCourses.length; j++) { var TotalCourseLocation = 0; var TotalListOfMatchedCoursesLocation = 0; var IsLocation = (addrespo.ListOfCourses[j].listOfCoursesLocation != null && addrespo.ListOfCourses[j].listOfCoursesLocation.length > 0); if (IsLocation) { TotalCourseLocation = addrespo.ListOfCourses[j].listOfCoursesLocation.length; var ListOfMatchedCoursesLocation = addrespo.ListOfCourses[j].listOfCoursesLocation.filter(x=>x.Latitude == MainCourseLatitude && x.Longitude == MainCourseLongitude); if (ListOfMatchedCoursesLocation.length > 0) { TotalListOfMatchedCoursesLocation = ListOfMatchedCoursesLocation.length; var ListOfUnMatchedCoursesLocation = addrespo.ListOfCourses[j].listOfCoursesLocation.filter(x=>x.Latitude != MainCourseLatitude || x.Longitude != MainCourseLongitude); if (ListOfUnMatchedCoursesLocation.length > 0) { for (var p = 0; p < ListOfUnMatchedCoursesLocation.length; p++) { ListOfMatchedCoursesLocation.push(ListOfUnMatchedCoursesLocation[p]); } } addrespo.ListOfCourses[j].listOfCoursesLocation = ListOfMatchedCoursesLocation; } } var DisplayDate = ""; var DisplayLocation = ""; if (IsLocation && addrespo.ListOfCourses[j].listOfCoursesLocation[0].IsOnline) { DisplayDate = ConvertUTCTimeToLocalTime(addrespo.ListOfCourses[j].listOfCoursesLocation[0].StartDateFullString, true) + ' - ' + ConvertUTCTimeToLocalTime(addrespo.ListOfCourses[j].listOfCoursesLocation[0].EndDateFullString, true); DisplayLocation = "Online"; } else { DisplayDate = IsLocation ? addrespo.ListOfCourses[j].listOfCoursesLocation[0].StartDateFullString + " - " + addrespo.ListOfCourses[j].listOfCoursesLocation[0].EndDateFullString : new Date(addrespo.ListOfCourses[j].CreatedDate.match(/\d+/)[0] * 1).getFullYear(); DisplayLocation = IsLocation ? (addrespo.ListOfCourses[j].listOfCoursesLocation[0].City + ', ' + addrespo.ListOfCourses[j].listOfCoursesLocation[0].StateName + ', ' + addrespo.ListOfCourses[j].listOfCoursesLocation[0].CountryName) : ""; } AlignerAdditionalCourseList += '
  • ' + (addrespo.ListOfCourses[j].SubTitle != null && addrespo.ListOfCourses[j].SubTitle != "" ? '' + addrespo.ListOfCourses[j].Title + '' : (addrespo.ListOfCourses[j].IsPreviewAvailable ? '' + addrespo.ListOfCourses[j].Title + '' : addrespo.ListOfCourses[j].Title)) + ': ' + (TotalCourseLocation > 1 ? ' ' + DisplayDate + ' ' + (addrespo.ListOfCourses[j].CategoryId != 609 ? DisplayLocation : "") + '' : DisplayDate + ' ' + (addrespo.ListOfCourses[j].CategoryId != 609 ? DisplayLocation : "") + '') + '
  • '; addTable += GeneratePreAddtionalTr(addrespo.ListOfCourses[j], "additionaltr"); respoAdd.ListOfCourses[0].push(addrespo.ListOfCourses[j]); } getPrerequisitesRespo = { ListOfCourses: respoAdd.ListOfCourses[0] }; } } }); showConfirm = true; } $("#loadingWithBG").hide(); if (showConfirm) { $('#mdlPrerequisiteConfirm #mdlPrerequisiteConfirmBodyTable').html(table); $('#mdlPrerequisiteConfirm #AlignerAdditionalCourseList').html(AlignerAdditionalCourseList); $('#mdlCoursePrerequisite #tblCoursePrerequisite').html(table); if (addTable != '') { $(addTable).insertBefore($('#mdlPrerequisiteConfirm #mdlPrerequisiteConfirmBodyTable table tr.prerequistHed')); } $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody .bottomtext .bottomcourse').html(cour); $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody tr.hide:not(.lblErrorMsg)').removeClass('hide'); //var productIdFromMoreLocation = $(_this).attr('data-subproductid'); //if (productIdFromMoreLocation > 0) { // $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody table tr[data-subproductid="' + productIdFromMoreLocation + '"]').find('input[type="checkbox"]').trigger('click'); //} else { // $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody table tr[data-productid="' + $(_this).attr('data-productid') + '"]:first').find('input[type="checkbox"]').trigger('click'); //} $("#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody").find("tr[data-id=" + $(_this).attr('data-productid') + "]").remove(); $('#mdlPrerequisiteConfirm #AlignerAdditionalCourseList').find("li[data-id=" + $(_this).attr('data-productid') + "]").remove(); $('tr[data-isfree="false"].additionaltr').each(function () { CourseHavePrerequisite = true; $(this).removeClass('additionaltr').addClass('prerequisitetr'); var AddtionalPrequest = $(this).clone(true); var AddtionalPrequest1 = $(this).clone(true); $(this).remove(); $(AddtionalPrequest).appendTo($('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody table tbody')); $(AddtionalPrequest1).appendTo($('#mdlCoursePrerequisite #tblCoursePrerequisite tbody')); }); $('#mdlPrerequisiteConfirm #AlignerAdditionalCourseList li[data-isfree="false"]').each(function () { $(this).remove(); }); if ($('tr[data-isfree="false"].prerequisitetr').length == 0) { CourseHavePrerequisite == false; } if (CourseHavePrerequisite) { $('#mdlCoursePrerequisite #tblCoursePrerequisite').find('.bottomtext').remove(); var PreRequisiteHtml = 'This course has Prerequisites'; $('#mdlPrerequisiteConfirm #CourseHavePrerequisite').html(PreRequisiteHtml); $(document).off('click', '#aCoursePrerequisite'); $(document).on('click', '#aCoursePrerequisite', function () { $('#mdlCoursePrerequisite').modal('show'); }); } $("#mdlCoursePrerequisite #tblCoursePrerequisite").find("tr[data-id=" + $(_this).attr('data-productid') + "]").remove(); if ($('#mdlPrerequisiteConfirm #AlignerAdditionalCourseList').find('li').length == 0) { $('#mdlPrerequisiteConfirm #AlignerAdditionalCourseList').closest('.jsBody').find('h4').addClass('hide'); $('#mdlPrerequisiteConfirm #AlignerAdditionalCourseList').addClass('hide'); } else { $('#mdlPrerequisiteConfirm #AlignerAdditionalCourseList').closest('.jsBody').find('h4').removeClass('hide'); $('#mdlPrerequisiteConfirm #AlignerAdditionalCourseList').removeClass('hide'); } setTimeout(function () { if ($('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody table tr.prerequistHed').next().length == 0 || $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody table tr.prerequistHed').next('tr.cart-header-row').next('tr').length == 0) { $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody table tr.prerequistHed').next('tr.cart-header-row').remove(); $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody table tr.prerequistHed').remove(); } if ($('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody table tr.AdditionalHed').next().length == 0 || $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody table tr.AdditionalHed').next('tr.cart-header-row').next('tr').length == 0) { $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody table tr.AdditionalHed').next('tr.cart-header-row').remove(); $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody table tr.AdditionalHed').remove(); } if ($('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody table tr.CalculatedTr').length == 0) { $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody .bottomtext').addClass('hide'); } }, 10); if ($('.mdlPrerequisiteConfirmBody #preRequisitesConfirm tbody tr[data-isfree="false"]').length == 0 && $.trim($('#mdlPrerequisiteConfirm .MainTrainingData .jsPrice').text()) == 'Free') { $('#mdlPrerequisiteConfirm .addToCartPrerequisites').text('Add To My List'); } //if ($('.mdlPrerequisiteConfirmBody #preRequisitesConfirm tbody tr[data-isfree="false"]').length > 0 || $.trim($('#mdlPrerequisiteConfirm .MainTrainingData .jsPrice').text()) != 'Free') { // var MainPrice = (isNaN(parseFloat($('#mdlPrerequisiteConfirm .MainTrainingData .jsPrice').html().match(/[\d\.]+/g))) ? 0 : parseFloat($('#mdlPrerequisiteConfirm .MainTrainingData .jsPrice').html().match(/[\d\.]+/g))); // $('.mdlPrerequisiteConfirmBody #preRequisitesConfirm tbody tr.CalculatedTr[data-isfree="false"]').each(function (i) { // MainPrice += (isNaN(parseFloat($(this).find('td.jsPrice').html().match(/[\d\.]+/g))) ? 0 : parseFloat($(this).find('td.jsPrice').html().match(/[\d\.]+/g))); // }); // $('.TrainingOrderTotal').html('$' + MainPrice.toFixed(2)); // $('.TrainingOrderTotal').parent('div').removeClass('hide') //} else { // $('.TrainingOrderTotal').parent('div').addClass('hide'); //} $('.TrainingOrderTotal').parent('div').addClass('hide'); if (respo.ListOfCourses.length == 1 && respo.ListOfCourses[0].Id == $(_this).attr('data-productid')) { $('#mdlPrerequisiteConfirm .addToCartPrerequisites').trigger('click'); $('#mdlPrerequisiteConfirm').modal('hide'); } else { setTimeout(function () { $('#mdlPrerequisiteConfirm').modal('show'); $('body').addClass('modal-open'); }, 500); } } else if (product.IsFree) { $.ajax({ url: '/Courses/AddCourseInAccess', type: 'post', data: { productId: $(_this).attr('data-productid'), subProductId: ($(_this).attr('data-subproductid') > 0 ? $(_this).attr('data-subproductid') : product.Id) }, success: function (respod) { if (respod) { $('input[type="radio"][name="trainingFilter"][value="610"]').prop('checked', true).change(); //window.location.reload(); } } }); } else { productIds = new Array(); $('#oneclick_checkout_course #productIds').val(''); $('#oneclick_checkout_course #tblCourseCartDetail tbody tr').remove(); AddCourseInCart(($(_this).attr('data-subproductid') > 0 ? $(_this).attr('data-subproductid') : product.Id), true); $('#checkout_div_ordertotal').hide(); $('#oneclick_checkout_course').modal('show'); } crTip(); } }); } else if ($(_this).attr('data-additionalcourses') != '') { $.ajax({ url: '/Courses/GetAdditionalCourse', data: { additionalCourseIds: $(_this).attr('data-additionalcourses'), productId: $(_this).attr('data-productid'), prerequestIds: '0' }, success: function (respo) { var respoAdd = { ListOfCourses: [] } getPrerequisitesRespo = respo; var table = ''; var showConfirm = false; var product; var AdditionalCourseList = ""; var prolist = new Array(); var CourseHavePrerequisite = false; if (respo.ListOfCourses != null && respo.ListOfCourses.length > 0) { table += ''; table += ''; table += ''; for (var i = 0; i < respo.ListOfCourses.length; i++) { var TotalCourseLocation = 0; var TotalListOfMatchedCoursesLocation = 0; var IsLocation = (respo.ListOfCourses[i].listOfCoursesLocation != null && respo.ListOfCourses[i].listOfCoursesLocation.length > 0); if (IsLocation) { TotalCourseLocation = respo.ListOfCourses[i].listOfCoursesLocation.length; var ListOfMatchedCoursesLocation = respo.ListOfCourses[i].listOfCoursesLocation.filter(x=>x.Latitude == MainCourseLatitude && x.Longitude == MainCourseLongitude); if (ListOfMatchedCoursesLocation.length > 0) { TotalListOfMatchedCoursesLocation = ListOfMatchedCoursesLocation.length; var ListOfUnMatchedCoursesLocation = respo.ListOfCourses[i].listOfCoursesLocation.filter(x=>x.Latitude != MainCourseLatitude || x.Longitude != MainCourseLongitude); if (ListOfUnMatchedCoursesLocation.length > 0) { for (var p = 0; p < ListOfUnMatchedCoursesLocation.length; p++) { ListOfMatchedCoursesLocation.push(ListOfUnMatchedCoursesLocation[p]); } } respo.ListOfCourses[i].listOfCoursesLocation = ListOfMatchedCoursesLocation; } } // var DisplayDate = IsLocation ? (respo.ListOfCourses[i].listOfCoursesLocation[0].DisplayDate != undefined && respo.ListOfCourses[i].listOfCoursesLocation[0].DisplayDate != "" ? respo.ListOfCourses[i].listOfCoursesLocation[0].DisplayDate : respo.ListOfCourses[i].listOfCoursesLocation[0].StartDateOnly + " - " + respo.ListOfCourses[i].listOfCoursesLocation[0].EndDateOnly) : new Date(respo.ListOfCourses[i].CreatedDate.match(/\d+/)[0] * 1).getFullYear(); var DisplayDate = ""; var DisplayLocation = ""; if (IsLocation && respo.ListOfCourses[i].listOfCoursesLocation[0].IsOnline) { DisplayDate = ConvertUTCTimeToLocalTime(respo.ListOfCourses[i].listOfCoursesLocation[0].StartDateFullString, true) + ' - ' + ConvertUTCTimeToLocalTime(respo.ListOfCourses[i].listOfCoursesLocation[0].EndDateFullString, true); DisplayLocation = "Online"; } else { DisplayDate = IsLocation ? respo.ListOfCourses[i].listOfCoursesLocation[0].StartDateFullString + ' - ' + respo.ListOfCourses[i].listOfCoursesLocation[0].EndDateFullString : new Date(respo.ListOfCourses[i].CreatedDate.match(/\d+/)[0] * 1).getFullYear(); DisplayLocation = IsLocation ? (respo.ListOfCourses[i].listOfCoursesLocation[0].City + ', ' + respo.ListOfCourses[i].listOfCoursesLocation[0].StateName + ', ' + respo.ListOfCourses[i].listOfCoursesLocation[0].CountryName) : ""; } AdditionalCourseList += '
  • ' + (respo.ListOfCourses[i].SubTitle != null && respo.ListOfCourses[i].SubTitle != "" ? '' + respo.ListOfCourses[i].Title + '' : (respo.ListOfCourses[i].IsPreviewAvailable ? '' + respo.ListOfCourses[i].Title + '' : respo.ListOfCourses[i].Title)) + ': ' + (TotalCourseLocation > 1 ? ' ' + DisplayDate + ' ' + (respo.ListOfCourses[i].CategoryId != 609 ? DisplayLocation : "") + '' : DisplayDate + ' ' + (respo.ListOfCourses[i].CategoryId != 609 ? DisplayLocation : "") + '') + '
  • '; table += GeneratePreAddtionalTr(respo.ListOfCourses[i], "additionaltr"); prolist.push(respo.ListOfCourses[i].Id); if (parseInt($(_this).attr('data-productid')) != respo.ListOfCourses[i].Id || respo.ListOfCourses[i].listOfCoursesLocation.length > 0) { showConfirm = true; if (parseInt($(_this).attr('data-productid')) == respo.ListOfCourses[i].Id) { product = respo.ListOfCourses[i]; } } else { prolist.push(respo.ListOfCourses[i].Id); product = respo.ListOfCourses[i]; } } table += '
    The course includes the following additional courses for free
    Course NameLocationDateInstructorPrice
    '; table += '
    Total:
    '; table += '

    '; var msg = ''; var pretable = ''; var cour = 'course'; if (respo.ListOfCourses.length > 1) { cour = 'courses'; } $.ajax({ url: '/Courses/GetPrerequisiteByAdditionalIds', data: { additionalCourseIds: prolist.toString(), notinIds: $(_this).attr('data-additionalcourses') }, async: false, success: function (reqrespo) { if (reqrespo.ListOfCourses != null && reqrespo.ListOfCourses.length > 0) { CourseHavePrerequisite = true; var prere = 'prerequisite'; if (reqrespo.ListOfCourses.length > 1) { prere = 'prerequisites'; cour = 'courses'; } pretable += 'This course has the following ' + prere + ''; pretable += 'Course NameLocationDateInstructorPrice'; for (var i = 0; i < reqrespo.ListOfCourses.length; i++) { if ($(table).find('tr[data-id="' + reqrespo.ListOfCourses[i].Id + '"].CalculatedTr').length == 0) { var IsLocation = (reqrespo.ListOfCourses[i].listOfCoursesLocation != null && reqrespo.ListOfCourses[i].listOfCoursesLocation.length > 0); if (IsLocation) { var ListOfMatchedCoursesLocation = reqrespo.ListOfCourses[i].listOfCoursesLocation.filter(x=>x.Latitude == MainCourseLatitude && x.Longitude == MainCourseLongitude); if (ListOfMatchedCoursesLocation.length > 0) { var ListOfUnMatchedCoursesLocation = reqrespo.ListOfCourses[i].listOfCoursesLocation.filter(x=>x.Latitude != MainCourseLatitude || x.Longitude != MainCourseLongitude); if (ListOfUnMatchedCoursesLocation.length > 0) { for (var p = 0; p < ListOfUnMatchedCoursesLocation.length; p++) { ListOfMatchedCoursesLocation.push(ListOfUnMatchedCoursesLocation[p]); } } reqrespo.ListOfCourses[i].listOfCoursesLocation = ListOfMatchedCoursesLocation; } } pretable += GeneratePreAddtionalTr(reqrespo.ListOfCourses[i], "prerequisitetr"); } } pretable += ''; } } }); msg = '

    Do you want to purchase ' + product.Title + ' and the ' + cour + ' listed above?

    '; $('#loadingWithBG').hide(); if (showConfirm) { $('#mdlPrerequisiteConfirm #mdlPrerequisiteConfirmBodyTable').html(table); $('#mdlPrerequisiteConfirm #AlignerAdditionalCourseList').html(AdditionalCourseList); $('#mdlCoursePrerequisite #tblCoursePrerequisite').html(pretable); if (pretable != '') { $(pretable).appendTo($('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody table tbody')); } $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody .bottomtext').html(msg); $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody tr.hide:not(.lblErrorMsg)').removeClass('hide'); //var productIdFromMoreLocation = $(_this).attr('data-subproductid'); //if (productIdFromMoreLocation > 0) { // $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody table tr[data-subproductid="' + productIdFromMoreLocation + '"]').find('input[type="checkbox"]').trigger('click'); //} else { // $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody table tr[data-productid="' + $(_this).attr('data-productid') + '"]:first').find('input[type="checkbox"]').trigger('click'); //} $("#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody").find("tr[data-id=" + $(_this).attr('data-productid') + "]").remove(); $('#mdlPrerequisiteConfirm #AlignerAdditionalCourseList').find("li[data-id=" + $(_this).attr('data-productid') + "]").remove(); $('tr[data-isfree="false"].additionaltr').each(function () { CourseHavePrerequisite = true; $(this).removeClass('additionaltr').addClass('prerequisitetr'); var AddtionalPrequest = $(this).clone(true); var AddtionalPrequest1 = $(this).clone(true); $(this).remove(); $(AddtionalPrequest).appendTo($('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody table tbody')); $(AddtionalPrequest1).appendTo($('#mdlCoursePrerequisite #tblCoursePrerequisite tbody')); }); $('#mdlPrerequisiteConfirm #AlignerAdditionalCourseList li[data-isfree="false"]').each(function () { $(this).remove(); }); if ($('tr[data-isfree="false"].prerequisitetr').length == 0) { CourseHavePrerequisite == false; } if (CourseHavePrerequisite) { $('#mdlCoursePrerequisite #tblCoursePrerequisite').find('.bottomtext').remove(); var PreRequisiteHtml = 'This course has Prerequisites'; $('#mdlPrerequisiteConfirm #CourseHavePrerequisite').html(PreRequisiteHtml); $(document).off('click', '#aCoursePrerequisite'); $(document).on('click', '#aCoursePrerequisite', function () { $('#mdlCoursePrerequisite').modal('show'); }); } $("#mdlCoursePrerequisite #tblCoursePrerequisite").find("tr[data-id=" + $(_this).attr('data-productid') + "]").remove(); if ($('#mdlPrerequisiteConfirm #AlignerAdditionalCourseList').find('li').length == 0) { $('#mdlPrerequisiteConfirm #AlignerAdditionalCourseList').closest('.jsBody').find('h4').addClass('hide'); $('#mdlPrerequisiteConfirm #AlignerAdditionalCourseList').addClass('hide'); } else { $('#mdlPrerequisiteConfirm #AlignerAdditionalCourseList').closest('.jsBody').find('h4').removeClass('hide'); $('#mdlPrerequisiteConfirm #AlignerAdditionalCourseList').removeClass('hide'); } setTimeout(function () { if ($('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody table tr.prerequistHed').next().length == 0 || $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody table tr.prerequistHed').next('tr.cart-header-row').next('tr').length == 0) { $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody table tr.prerequistHed').next('tr.cart-header-row').remove(); $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody table tr.prerequistHed').remove(); } if ($('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody table tr.AdditionalHed').next().length == 0 || $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody table tr.AdditionalHed').next('tr.cart-header-row').next('tr').length == 0) { $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody table tr.AdditionalHed').next('tr.cart-header-row').remove(); $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody table tr.AdditionalHed').remove(); } if ($('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody table tr.CalculatedTr').length == 0) { $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody .bottomtext').addClass('hide'); } }, 10); if ($('.mdlPrerequisiteConfirmBody #preRequisitesConfirm tbody tr[data-isfree="false"]').length == 0 && $.trim($('#mdlPrerequisiteConfirm .MainTrainingData .jsPrice').text()) == 'Free') { $('#mdlPrerequisiteConfirm .addToCartPrerequisites').text('Add To My List'); } //if ($('.mdlPrerequisiteConfirmBody #preRequisitesConfirm tbody tr[data-isfree="false"]').length > 0 || $.trim($('#mdlPrerequisiteConfirm .MainTrainingData .jsPrice').text()) != 'Free') { // var MainPrice = (isNaN(parseFloat($('#mdlPrerequisiteConfirm .MainTrainingData .jsPrice').html().match(/[\d\.]+/g))) ? 0 : parseFloat($('#mdlPrerequisiteConfirm .MainTrainingData .jsPrice').html().match(/[\d\.]+/g))); // $('.mdlPrerequisiteConfirmBody #preRequisitesConfirm tbody tr.CalculatedTr[data-isfree="false"]').each(function (i) { // MainPrice += (isNaN(parseFloat($(this).find('td.jsPrice').html().match(/[\d\.]+/g))) ? 0 : parseFloat($(this).find('td.jsPrice').html().match(/[\d\.]+/g))); // }); // $('.TrainingOrderTotal').html('$' + MainPrice.toFixed(2)); // $('.TrainingOrderTotal').parent('div').removeClass('hide') //} else { // $('.TrainingOrderTotal').parent('div').addClass('hide'); //} $('.TrainingOrderTotal').parent('div').addClass('hide'); if (respo.ListOfCourses.length == 1 && respo.ListOfCourses[0].Id == $(_this).attr('data-productid')) { $('#mdlPrerequisiteConfirm .addToCartPrerequisites').trigger('click'); $('#mdlPrerequisiteConfirm').modal('hide'); } else { setTimeout(function () { $('#mdlPrerequisiteConfirm').modal('show'); $('body').addClass('modal-open'); }, 500); } } else if (product.IsFree) { $.ajax({ url: '/Courses/AddCourseInAccess', type: 'post', data: { productId: $(_this).attr('data-productId'), subProductId: ($(_this).attr('data-subproductid') > 0 ? $(_this).attr('data-subproductid') : product.Id) }, success: function (respo) { if (respo) { $('input[type="radio"][name="trainingFilter"][value="610"]').prop('checked', true).change(); //window.location.reload(); } } }) } else { productIds = new Array(); $('#oneclick_checkout_course #productIds').val(''); $('#oneclick_checkout_course #tblCourseCartDetail tbody tr').remove(); AddCourseInCart(($(_this).attr('data-subproductid') > 0 ? $(_this).attr('data-subproductid') : product.Id), true); $('#checkout_div_ordertotal').hide(); $('#oneclick_checkout_course').modal('show'); } crTip(); } } }) } else { productIds = new Array(); $('#oneclick_checkout_course #productIds').val(''); $('#oneclick_checkout_course #tblCourseCartDetail tbody tr').remove(); $('#oneclick_checkout_course #ProductType').val('Course'); AddCourseInCart(($(_this).attr('data-subproductid') != '' && $(_this).attr('data-subproductid') != '0' && $(_this).attr('data-subproductid') != undefined ? $(_this).attr('data-subproductid') : ($(_this).attr('data-productid') != undefined ? $(_this).attr('data-productid') : $(_this).closest('tr').find('.jsCourseId').text())), true); $('#checkout_div_ordertotal').hide(); $('#oneclick_checkout_course').modal('show'); } }); $(document).off('click', TrainingListcontainerdiv + ' .GrouppurchaseBtn'); $(document).on('click', TrainingListcontainerdiv + ' .GrouppurchaseBtn', function () { var TGroupId = $(this).attr('data-Groupid'); var TGroupName = $(this).closest('tr').find('td.groupTitle').find('div').text(); var TGroupjsPrice = $(this).closest('tr').find('td.jsPrice').attr("data-Price"); var ClassId = $(this).closest('tr').find('a.GroupMoreLocation').attr('data-classid'); $('#GroupCourseDetails').find('.jsProductName').removeAttr('data-classid'); $('#loadingWithBG').show(); setTimeout(function () { $.ajax({ url: '/Courses/AddGroupProduct', type: 'Post', cache: false, datatype: 'json', data: { TrainingGroupId: TGroupId, IsProductFree: false }, success: function (data) { if (data.Status) { $('#loadingWithBG').hide(); var ProductId = data.Id; productIds = new Array(); var GroupCourseList = ""; var LastLatitude = 0; var LastLongitude = 0; var IsAllSameLocation = true; var LastDisplayLocation = ""; setTimeout(function () { $('#oneclick_checkout_course #productIds').val(''); $('#oneclick_checkout_course #tblCourseCartDetail tbody tr').remove(); TGCoursesList = new Array(); $('.TrainingCourse[data-sgid="' + TGroupId + '"]').each(function () { if ($(this).find('.jsPrice').text().indexOf('Bought') == -1) { var MainProductId = $(this).attr('data-id'); var SubProductId = $(this).attr('data-subproductid') != undefined ? $(this).attr('data-subproductid') : 0; //var CourseList = { 'ProductId': MainProductId, 'SubProductId': SubProductId }; TGCoursesList.push({ 'ProductId': MainProductId, 'SubProductId': SubProductId }); var DisplayLocation = ""; var IsLocation = false; var TotalCourseLocation = 0; var Latitude = 0; var Longitude = 0; if ($(this).find('td.location').find('a.moreLocation').length > 0) { IsLocation = true; TotalCourseLocation = 2; Latitude = $(this).find('td.location').find('a.moreLocation').attr('data-Latitude'); Longitude = $(this).find('td.location').find('a.moreLocation').attr('data-Longitude'); if ($(this).find('td.location').find('a.moreLocation').find('.hlinkC.flxg2').length > 0) { DisplayLocation = $(this).find('td.location').find('a.moreLocation').find('.hlinkC.flxg2').html().replace(new RegExp('
    ', 'g'), " "); } else { DisplayLocation = $(this).find('td.location').find('a.moreLocation').html().replace(new RegExp('
    ', 'g'), " "); } } else if ($(this).find('td.location').find('span.TrainingLocation').length > 0) { IsLocation = true; TotalCourseLocation = 1; Latitude = $(this).find('td.location').find('span.TrainingLocation').attr('data-Latitude'); Longitude = $(this).find('td.location').find('span.TrainingLocation').attr('data-Longitude'); DisplayLocation = $(this).find('td.location').find('span.TrainingLocation').html().replace(new RegExp('
    ', 'g'), " "); } var DisplayDate = IsLocation ? $(this).find('td.jsYear').find('span.mainDate').text() : $(this).find('td.jsYear').text(); var Title = $.trim($(this).find('td.jsCourseTitle').find('a.TitleText').find('strong.dblk').text()); var SubTitle = $.trim($(this).find('td.jsCourseTitle').find('a.TitleText').find('em').text()); var IsPreviewAvailable = $(this).find('td.jsCourseTitle').attr('data-IsPreviewAvailable'); IsPreviewAvailable = IsPreviewAvailable == 'True' ? true : false; GroupCourseList += '
  • ' + (SubTitle != "" ? '' + Title + '' : (IsPreviewAvailable ? '' + Title + '' : Title)) + ': ' + (TotalCourseLocation > 1 ? ' ' + DisplayDate + ' ' + DisplayLocation + '' : DisplayDate + ' ' + DisplayLocation + '') + '
  • '; if (IsLocation) { if (LastLatitude == 0 && LastLongitude == 0 && Latitude != 0) { LastLatitude = Latitude; LastLongitude = Longitude; LastDisplayLocation = DisplayLocation; } if (parseFloat(LastLatitude).toFixed(6) != parseFloat(Latitude).toFixed(6) || parseFloat(LastLongitude).toFixed(6) != parseFloat(Longitude).toFixed(6)) { IsAllSameLocation = false; } } } }); $('#GroupCourseDetails').find('.jsClassLocation').html(''); $('#GroupCourseDetails').find('.jsProductName').html(TGroupName); if (ClassId != undefined && ClassId != "") { $('#GroupCourseDetails').find('.jsProductName').attr('data-classid', ClassId); } $('#GroupCourseDetails').find('#course_ordertotal').text(TGroupjsPrice); $('#GroupCourseDetails').find('#GroupCourseDetailsGroupCourseList').html(GroupCourseList); $('#GroupCourseDetails').find('#btnBuyGroupCourseDetail').attr('data-ProductId', ProductId); crTip(); if (IsAllSameLocation) { if (LastDisplayLocation != '') { $('#GroupCourseDetails').find('.jsClassLocation').html(LastDisplayLocation); } $('#GroupCourseDetails').find('#GroupCourseDetailsGroupCourseList').find('.AddtionalCourseLocation').addClass('hide'); } else { $('#GroupCourseDetails').find('#GroupCourseDetailsGroupCourseList').find('.AddtionalCourseLocation').removeClass('hide'); } $('#GroupCourseDetails').modal('show'); $('#Course_oneclick_orderplaced #CartTrainingGroupId').val(TGroupId); // $('#oneclick_checkout_course #ProductType').val('TrainingGroup'); //AddCourseInCart(ProductId, true, true, TGCoursesList); //$('#checkout_div_ordertotal').hide(); //$('#oneclick_checkout_course').modal('show'); //$('#Course_oneclick_orderplaced #CartTrainingGroupId').val(TGroupId); }, ($('.TrainingCourse[data-sgid="' + TGroupId + '"]').length > 1 ? 1 : 4000)); } else { $('#loadingWithBG').hide(); } } }); }); }); $(document).off('click', TrainingListcontainerdiv + ' .jsGroupAddMyListCourse'); $(document).on('click', TrainingListcontainerdiv + ' .jsGroupAddMyListCourse', function () { var TGroupId = $(this).attr('data-Groupid'); $('#loadingWithBG').show(); $.ajax({ url: '/Courses/AddGroupProduct', type: 'Post', cache: false, datatype: 'json', data: { TrainingGroupId: TGroupId }, success: function (data) { if (data.Status) { var ProductId = data.Id; $.ajax({ url: '/Courses/AddGroupProductInAccess', type: 'Post', cache: false, datatype: 'json', data: { ProductId: ProductId }, success: function (data) { if (data.Status) { $('#Course_oneclick_orderplaced #CartTrainingGroupId').val(0); $('input[type="radio"][name="trainingFilter"][value="610"]').prop('checked', true).change(); if (FromScheduleFlag) { window.location.reload(); } } else { $('#loadingWithBG').hide(); } } }); } else { $('#loadingWithBG').hide(); } } }); }); $(document).off('click', TrainingListcontainerdiv + ' .GroupPreviewButton'); $(document).on('click', TrainingListcontainerdiv + ' .GroupPreviewButton', function () { var TGroupId = $(this).attr('data-Groupid'); var URL = '/Courses/GetTrainingGroupDetails'; if (FromScheduleFlag) { URL = '/PosOrtho/GetTrainingGroupDetailsPosOrtho'; } $('#loadingWithBG').show(); $.ajax({ url: URL, type: 'Post', cache: false, datatype: 'json', data: { TrainingGroupId: TGroupId }, success: function (data) { if (data.Status) { $('#mdlTrainingGroupPreview .jsTitle').html(data.TrainingGroup.BundleTitle); if (data.TrainingGroup.BundleSubtitle != '') { $('#mdlTrainingGroupPreview .jsSubTitle').html(data.TrainingGroup.BundleSubtitle); } else { $('#mdlTrainingGroupPreview .jsSubTitle').html('-'); } if (data.TrainingGroup.BundleClassNumber != '') { $('#mdlTrainingGroupPreview .jsClassNumber').html(data.TrainingGroup.BundleClassNumber); } else { $('#mdlTrainingGroupPreview .jsClassNumber').html('-'); } //if (data.TrainingGroup.BundleVersion != '') { // $('#mdlTrainingGroupPreview .jsVersion').html(data.TrainingGroup.BundleVersion); //} else { // $('#mdlTrainingGroupPreview .jsVersion').html('-'); //} if (data.TrainingGroup.BundleDescription != '') { $('#mdlTrainingGroupPreview .jsDescription').html(data.TrainingGroup.BundleDescription); } if (data.TrainingGroup.FileName != '') { $("#mdlTrainingGroupPreview #jsImage").attr('src', data.TrainingGroup.FileName); $("#mdlTrainingGroupPreview .vidBase").removeClass('hide'); $('#mdlTrainingGroupPreview .jsDescription').removeClass('flx1'); } else { $("#mdlTrainingGroupPreview .vidBase").addClass('hide'); $('#mdlTrainingGroupPreview .jsDescription').addClass('flx1'); } $('#loadingWithBG').hide(); $('#mdlTrainingGroupPreview .pright').click(); $("#mdlTrainingGroupPreview").modal('show'); } else { $('#loadingWithBG').hide(); } } }); }); function GeneratePreAddtionalTr(MainTraining, ClassName) { var table = ''; var IsLocation = (MainTraining.listOfCoursesLocation != null && MainTraining.listOfCoursesLocation.length > 0); table += ''; if (MainTraining.IsPreviewAvailable) { table += '' + MainTraining.Title + '' + MainTraining.SubTitle + ''; } else { table += '' + MainTraining.Title + '' + MainTraining.SubTitle + ''; } var DisplayCity = IsLocation ? (MainTraining.listOfCoursesLocation[0].DisplayCity != "" && MainTraining.listOfCoursesLocation[0].DisplayCity != null ? MainTraining.listOfCoursesLocation[0].DisplayCity : "") : ""; // var DisplayDate = IsLocation ? (MainTraining.listOfCoursesLocation[0].DisplayDate != undefined && MainTraining.listOfCoursesLocation[0].DisplayDate != "" ? MainTraining.listOfCoursesLocation[0].DisplayDate : MainTraining.listOfCoursesLocation[0].StartDateOnly + " - " + MainTraining.listOfCoursesLocation[0].EndDateOnly) : new Date(MainTraining.CreatedDate.match(/\d+/)[0] * 1).getFullYear(); var DisplayDate = ""; var DisplayLocation = ""; if (IsLocation && MainTraining.listOfCoursesLocation[0].IsOnline) { DisplayDate = ConvertUTCTimeToLocalTime(MainTraining.listOfCoursesLocation[0].StartDateFullString, true) + " - " + ConvertUTCTimeToLocalTime(MainTraining.listOfCoursesLocation[0].EndDateFullString, true); DisplayLocation = "Online"; } else { DisplayDate = IsLocation ? MainTraining.listOfCoursesLocation[0].StartDateFullString + " - " + MainTraining.listOfCoursesLocation[0].EndDateFullString : new Date(MainTraining.CreatedDate.match(/\d+/)[0] * 1).getFullYear(); DisplayLocation = IsLocation ? ((DisplayCity != "" ? DisplayCity : MainTraining.listOfCoursesLocation[0].City) + ', ' + MainTraining.listOfCoursesLocation[0].StateName + ', ' + MainTraining.listOfCoursesLocation[0].CountryName) : "-"; } if (IsLocation && MainTraining.listOfCoursesLocation.length > 1) { table += '' + (MainTraining.CategoryId != 609 ? '' + (IsLocation ? DisplayLocation : '-') + '' : "-") + ''; table += '' + DisplayDate + '' + (IsLocation ? MainTraining.listOfCoursesLocation[0].Time : '') + '' + (IsLocation ? MainTraining.listOfCoursesLocation[0].ClassId : '') + ''; table += '' + (IsLocation ? MainTraining.listOfCoursesLocation[0].InstructorName : MainTraining.AuthorName) + ''; } else { table += '' + (IsLocation && MainTraining.CategoryId != 609 ? DisplayLocation : '-') + ''; table += '' + DisplayDate + '' + (IsLocation ? MainTraining.listOfCoursesLocation[0].Time : '') + '' + (IsLocation ? MainTraining.listOfCoursesLocation[0].ClassId : '') + ''; table += '' + (IsLocation ? MainTraining.listOfCoursesLocation[0].InstructorName : MainTraining.AuthorName) + ''; } table += ''; if (MainTraining.IsFree) { table += 'Free'; } else if (IsLocation) { if (MainTraining.listOfCoursesLocation[0].SalePriceString != '' && MainTraining.listOfCoursesLocation[0].SalePriceString != null) { table += '' + MainTraining.listOfCoursesLocation[0].PriceString + ''; table += MainTraining.listOfCoursesLocation[0].SalePriceString; } else { table += ' ' + MainTraining.listOfCoursesLocation[0].PriceString; } } else { if (MainTraining.SalePriceString != '' && MainTraining.SalePriceString != null) { table += '' + MainTraining.PriceString + ''; table += ' ' + MainTraining.SalePriceString; } else { table += MainTraining.PriceString; } } table += ''; return table; } $(document).off('click', '.openPreview'); $(document).on('click', '.openPreview', function () { $('#previewCourse .vidBase').parent().children('.courseVidDiv').remove(); var _this = $(this); if ($(_this).closest('tr').length > 0) { CourseId = $(_this).closest('tr').attr('data-id'); } else { CourseId = $(_this).closest('li').attr('data-id'); } $.ajax({ url: '/Courses/GetCourseById', data: { Id: CourseId }, success: function (respo) { if (respo.Status) { $('#previewCourse .title').html(respo.Course.Title); var IsHTMLBlank = true; var jsAboutCourse = respo.Course.AboutCourse; if ($(jsAboutCourse).text().trim() != '' || $(jsAboutCourse).has('img').length > 0 || $(jsAboutCourse).has('a').length > 0 || $(jsAboutCourse).has('video').length > 0) { IsHTMLBlank = false; } if (respo.Course.AboutCourse != null && !IsHTMLBlank) { $('#previewCourse .description').removeClass('hide'); $('#previewCourse .description').html(respo.Course.AboutCourse); } else { $('#previewCourse .description').addClass('hide'); } if (respo.Course.PreviewVideoGUID != null && respo.Course.PreviewVideoGUID != '') { var str ='/Content/smilestream/assets/CourseLibraryAttachments/Courses/Video/' + respo.Course.Id + "_" + respo.Course.PreviewVideoGUID; if (IsOfflineMode == 'False') { AWS.config.update({ region: bucketRegion, credentials: new AWS.CognitoIdentityCredentials({ IdentityPoolId: IdentityPoolId }) }); var s3 = new AWS.S3({ apiVersion: '2012-10-17', params: { Bucket: AWSS3Bucket } }); var n = str.lastIndexOf('/'); var result = str.substring(n + 1); //console.log(result); //var FullFileName = outputfile + '.mp4'; //var deleteparam = { // Bucket: AWSS3Bucket, // Key: fileName //} //s3.deleteObject(deleteparam, function (err, metadata) { // if (err) { // // window.console.clear(); // } //}); var outputfile = result.substr(0, result.lastIndexOf('.')) || result; var FullFileName = outputfile + '.mp4'; var params2 = { Bucket: AWSS3BucketPreview, Key: FullFileName, Expires: 6000 }; s3.getSignedUrl("getObject", params2, function (err, url) { if (err) { } else { if (url != null) { //$('.vidBase').parent().children('.courseVidDiv').children('video').attr('src', url); $("#previewCourse #jsVideo source").attr('src', url); var vidClone = $('#previewCourse .vidBase').children().clone(true, true); vidClone.prependTo($('#previewCourse .vidBase').parent()); var vidId = $('#previewCourse .vidBase').find('video').attr('id') + 1; $('#previewCourse .vidBase').parent().children('.courseVidDiv').children('video').attr('id', vidId); $('#previewCourse .description').removeClass('flx1'); } } }); } else { $("#previewCourse #jsVideo source").attr('src', '/Video/PlayVideo?FilePath=' + str); var vidClone = $('#previewCourse .vidBase').children().clone(true, true); vidClone.prependTo($('#previewCourse .vidBase').parent()); var vidId = $('#previewCourse .vidBase').find('video').attr('id') + 1; $('#previewCourse .vidBase').parent().children('.courseVidDiv').children('video').attr('id', vidId); $('#previewCourse .description').removeClass('flx1'); } } else { $('#previewCourse .description').addClass('flx1'); } $('#previewCourse').modal('show'); } } }) }) $(document).off('click', '.addToCartPrerequisites'); $(document).on('click', '.addToCartPrerequisites', function () { // debugger; $("#loadingWithBG").show(); setTimeout(function () { $('.lblErrorMsg').addClass('hide'); var _isValid = true; if (!_isValid) { return false; } var isFree = true; if ($('.mdlPrerequisiteConfirmBody #preRequisitesConfirm tbody tr[data-isfree="false"]').length > 0 || $.trim($('#mdlPrerequisiteConfirm .MainTrainingData .jsPrice').text()) != 'Free') { isFree = false; } if (isFree) { var countInsert = 1; $('#loadingWithBG').show(); var MainTrainingDataTR = $('#mdlPrerequisiteConfirm .MainTrainingData'); var IsSubProduct = ($(MainTrainingDataTR).find('.jsClassLocation').attr('data-subproductid') != undefined && $(MainTrainingDataTR).find('.jsClassLocation').attr('data-subproductid') != '' && $(MainTrainingDataTR).find('.jsClassLocation').attr('data-subproductid') > 0); var ProductId = $(MainTrainingDataTR).find('.jsClassLocation').attr('data-id'); var SubProductId = (IsSubProduct ? $(MainTrainingDataTR).find('.jsClassLocation').attr('data-subproductid') : 0); $.ajax({ url: '/Courses/AddCourseInAccess', type: 'post', async: false, data: { productId: ProductId, subProductId: SubProductId }, success: function (respo) { if ($('.mdlPrerequisiteConfirmBody #preRequisitesConfirm tbody tr.CalculatedTr').length == 0) { if (FromScheduleFlag) { window.location.reload(); } $('#mdlPrerequisiteConfirm').modal('hide'); $('input[type="radio"][name="trainingFilter"][value="610"]').prop('checked', true).change(); } } }); $('.mdlPrerequisiteConfirmBody #preRequisitesConfirm tbody tr.CalculatedTr').each(function (i) { var _this = $(this); var IsSubProduct = ($(_this).attr('data-subproductid') != undefined && $(_this).attr('data-subproductid') != '' && $(_this).attr('data-subproductid') > 0); var ProductId = $(_this).attr('data-id'); var SubProductId = (IsSubProduct ? $(_this).attr('data-subproductid') : 0); $.ajax({ url: '/Courses/AddCourseInAccess', type: 'post', async: false, data: { productId: ProductId, subProductId: SubProductId }, success: function (respo) { if (respo) { //insertProdId.push(ProductId); if (countInsert == $('.mdlPrerequisiteConfirmBody #preRequisitesConfirm tbody tr.CalculatedTr').length) { if (FromScheduleFlag) { window.location.reload(); } $('#mdlPrerequisiteConfirm').modal('hide'); $('input[type="radio"][name="trainingFilter"][value="610"]').prop('checked', true).change(); } countInsert++; } } }); }); return false; } productIds = new Array(); $('#oneclick_checkout_course #tblCourseCartDetail tbody tr').remove(); $('#oneclick_checkout_course #productIds').val(''); var MainTrainingDataTR = $('#mdlPrerequisiteConfirm .MainTrainingData'); var IsSubProduct = ($(MainTrainingDataTR).find('.jsClassLocation').attr('data-subproductid') != undefined && $(MainTrainingDataTR).find('.jsClassLocation').attr('data-subproductid') != '' && $(MainTrainingDataTR).find('.jsClassLocation').attr('data-subproductid') > 0); var ProductId = $(MainTrainingDataTR).find('.jsClassLocation').attr('data-id'); var SubProductId = (IsSubProduct ? $(MainTrainingDataTR).find('.jsClassLocation').attr('data-subproductid') : 0); if ($.trim($('#mdlPrerequisiteConfirm .MainTrainingData .jsPrice').text()) == 'Free') { var _this = $('#mdlPrerequisiteConfirm .MainTrainingData'); FreeCourseList.push({ productId: ProductId, subproductid: SubProductId }); var tr = ''; tr += '

    ' + $(_this).find('.jsTitle').text() + '

    '; if ($(_this).find('.jsSubTitle').text() != 'null' && $(_this).find('.jsSubTitle').text() != '') { tr += '
    ' + $(_this).find('.jsSubTitle').text() + '
    '; } if (IsSubProduct) { tr += '
    '; tr += 'Course ID: ' + ProductId; tr += '
    Class Id: ' + $(_this).find('.jsClassId:first').text(); tr += '
    Date: ' + $(_this).find('.jsYear .mainDate').text() + '(' + $(_this).find('.jsTime:first').text() + ')'; tr += '
    Location: ' + $(_this).find('.jsClassLocation').text(); tr += '
    '; } else { var catId = $('#dtAvailableCourses tr[data-id="' + ProductId + '"]').attr('data-subcatid'); tr += '' + (catId == "612" || catId == "608" ? 'Course ID' : 'Class ID') + ': ' + ProductId; } tr += ''; tr += ''; tr += 'Free'; tr += ''; tr += ''; tr += 'Free'; tr += ''; tr += ''; $('#oneclick_checkout_course #tblCourseCartDetail tbody').append(tr); } else if (IsSubProduct) { AddCourseInCart(SubProductId, ($('.mdlPrerequisiteConfirmBody #preRequisitesConfirm tbody tr.CalculatedTr').length == 0)); } else { AddCourseInCart(ProductId, ($('.mdlPrerequisiteConfirmBody #preRequisitesConfirm tbody tr.CalculatedTr').length == 0)); } $('.mdlPrerequisiteConfirmBody #preRequisitesConfirm tbody tr.CalculatedTr').each(function (i) { var _this = $(this); var IsSubProduct = ($(_this).attr('data-subproductid') != undefined && $(_this).attr('data-subproductid') != '' && $(_this).attr('data-subproductid') > 0); var ProductId = $(_this).attr('data-id'); var SubProductId = (IsSubProduct ? $(_this).attr('data-subproductid') : 0); if ($(_this).attr('data-isfree') == 'true') { FreeCourseList.push({ productId: ProductId, subproductid: SubProductId }); var tr = ''; tr += '

    ' + $(_this).find('td.TrainingTitle .mainTitle').text() + '

    '; if ($(_this).find('td.TrainingTitle').find('.TrainingSubTitle').text() != 'null' && $(_this).find('td.TrainingTitle').find('.TrainingSubTitle').text() != '') { tr += '
    ' + $(_this).find('td.TrainingTitle').find('.TrainingSubTitle').text() + '
    '; } if (IsSubProduct) { tr += '
    '; tr += 'Course ID: ' + ProductId; tr += '
    Class Id: ' + $(_this).find('td.jsYear').find('.jsClassId').text(); tr += '
    Date: ' + $(_this).find('td.jsYear .mainDate').text() + ' (' + $(_this).find('td.jsYear .jsTime').text() + ')'; tr += '
    Location: ' + $(_this).find('td.location').text(); tr += '
    '; } else { tr += '' + ($(_this).attr('data-subcatid') == "612" || $(_this).attr('data-subcatid') == "608" ? 'Course ID' : 'Class ID') + ': ' + ProductId; } tr += ''; tr += ''; tr += 'Free'; tr += ''; tr += ''; tr += 'Free'; tr += ''; tr += ''; $('#oneclick_checkout_course #tblCourseCartDetail tbody').append(tr); if (i == ($('.mdlPrerequisiteConfirmBody #preRequisitesConfirm tbody tr.CalculatedTr').length - 1)) { Course_GetLatestPaymentInformation(); $('#oneclick_checkout_course #checkout_tr_localcurrency').show(); } } else if (IsSubProduct) { AddCourseInCart(SubProductId, (i == ($('.mdlPrerequisiteConfirmBody #preRequisitesConfirm tbody tr.CalculatedTr').length - 1)), false, undefined, true); } else { AddCourseInCart(ProductId, (i == ($('.mdlPrerequisiteConfirmBody #preRequisitesConfirm tbody tr.CalculatedTr').length - 1)), false, undefined, true); } }); $('#mdlPrerequisiteConfirm').modal('hide'); },100); setTimeout(function () { $("#loadingWithBG").hide(); $('#oneclick_checkout_course').modal('show'); $('body').addClass('modal-open'); }, 500); }); $(document).off('click', '.moreLocation'); $(document).on('click', '.moreLocation', function () { var FromSchedule = "1"; var URL = '/Aligner/MoreLocationPosOrtho'; if (!FilterLocationFlag && IsAuthenticated == "True") { Lat = "0"; Long = "0"; } var _this = $(this); var GroupId = $(_this).closest('tr').attr('data-sgid'); $('#buy_SubProduct').addClass('hide'); if ($(this).closest('#mdlPrerequisiteConfirm').length > 0 || $(this).closest('#GroupCourseDetails').length > 0 || $(this).closest('#mdlCoursePrerequisite').length > 0 || $(this).closest('#mdlCoursePreview').length > 0) { if ($(this).closest('#preRequisitesConfirm').length > 0) { var ProductId = $(_this).closest('tr').attr('data-id'); var SubProductId = $(_this).closest('tr').attr('data-subproductid'); var Subcatid = $(_this).closest('tr').attr('data-subcatid'); var Trainingname = $(_this).closest('tr').find('td:first').find('.mainTitle').text(); if ($(this).closest('.additionaltr').length > 0) { var SelectbtnClass = "FromPopUpAddtiinalTable"; } else { var SelectbtnClass = "FromPopUpTable"; } } else if ($(this).closest('#tblCoursePrerequisite').length > 0) { var ProductId = $(_this).closest('tr').attr('data-id'); var SubProductId = $(_this).closest('tr').attr('data-subproductid'); var Subcatid = $(_this).closest('tr').attr('data-subcatid'); var Trainingname = $(_this).closest('tr').find('td:first').find('.mainTitle').text(); if ($(this).closest('.additionaltr').length > 0) { var SelectbtnClass = "FromPopUpAddtiinalTable"; } else { var SelectbtnClass = "FromPopUpTable"; } } else { if ($(this).hasClass('AdditionalCourseMoreLocation')) { var ProductId = $(this).attr('data-id'); var SubProductId = $(this).attr('data-subproductid'); var Subcatid = $(this).attr('data-subcatid'); var Trainingname = $(this).attr('data-Title'); if ($(this).closest('#GroupCourseDetails').length > 0) { var SelectbtnClass = "FromPopUpAddtiinalTable FromAdditionalCourseGroupChangeLocation"; } else { var SelectbtnClass = "FromPopUpAddtiinalTable FromAdditionalCourseChangeLocation"; } } else if ($(this).closest('#mdlCoursePreview').length > 0) { var ProductId = $('#mdlCoursePreview .jsClassLocation').attr('data-id'); var SubProductId = $('#mdlCoursePreview .jsClassLocation').attr('data-subproductid'); var Subcatid = $('#mdlCoursePreview .jsClassLocation').attr('data-subcatid'); var Trainingname = $('#mdlCoursePreview .jsTitle').text(); var SelectbtnClass = "FromPopUpMain"; } else { var ProductId = $('#mdlPrerequisiteConfirm .jsClassLocation').attr('data-id'); var SubProductId = $('#mdlPrerequisiteConfirm .jsClassLocation').attr('data-subproductid'); var Subcatid = $('#mdlPrerequisiteConfirm .jsClassLocation').attr('data-subcatid'); var Trainingname = $('#mdlPrerequisiteConfirm .jsTitle').text(); var SelectbtnClass = "FromPopUpMain"; } } } else { var ProductId = $(_this).closest('tr').attr('data-id'); var SubProductId = $(_this).closest('tr').find('.purchaseBtn').attr('data-subproductid'); var Subcatid = $(_this).closest('tr').attr('data-subcatid'); var Trainingname = $(_this).closest('tr').find('.jsCourseTitle').find('.dblk').text(); var SelectbtnClass = "FromListing"; if (GroupId != undefined && GroupId > 0) { var SelectbtnClass = "FromListing FromGroupListing"; } } if (Subcatid != 609) { Trainingname = 'Change Location - ' + Trainingname; } $('.jsActiveProdToAddCart').removeClass('.jsActiveProdToAddCart'); $(_this).addClass('jsActiveProdToAddCart'); $.ajax({ url: URL, data: { productId: ProductId, selectAll: ($('input[type="radio"][name="trainingFilter"]:checked').val() == 602), FromSchedule: FromSchedule, Latitude: Lat, Longitude: Long }, success: function (respo) { if (respo.Status) { var table = '
    '; table += FromScheduleFlag ? '' : ''; table += '
    DateTimeLocationInstructorLanguagePrice
    ' table += '
    ' table += '' table += '' table += '' for (var i = 0; i < respo.ListOfCoursesLocation.length; i++) { table += ''; //if (!FromScheduleFlag) { table += ''; //} //var time = ""; //if (respo.ListOfCoursesLocation[i].Time != "12:00 AM - 12:00 AM") { // time = respo.ListOfCoursesLocation[i].Time; //} var startTime = respo.ListOfCoursesLocation[i].StartDateFullString; var endTime = respo.ListOfCoursesLocation[i].EndDateFullString; if (respo.ListOfCoursesLocation[i].IsOnline) { startTime = ConvertUTCTimeToLocalTime(respo.ListOfCoursesLocation[i].StartDateFullString, true); endTime = ConvertUTCTimeToLocalTime(respo.ListOfCoursesLocation[i].EndDateFullString, true); } //table += ''; table += ''; // table += ''; var _address = ''; _address += "" + respo.ListOfCoursesLocation[i].Address1.replace(/[`~!@#$%^&*()_|+\=?;:'"<>\{\}\[\]\\\/]/gi, '') + ""; if (respo.ListOfCoursesLocation[i].Address2 != null && respo.ListOfCoursesLocation[i].Address2 != "") { _address += "" + respo.ListOfCoursesLocation[i].Address2.replace(/[`~!@#$%^&*()_|+\=?;:'"<>\{\}\[\]\\\/]/gi, '') + ""; } var city = respo.ListOfCoursesLocation[i].DisplayCity != "" && respo.ListOfCoursesLocation[i].DisplayCity != null ? respo.ListOfCoursesLocation[i].DisplayCity : respo.ListOfCoursesLocation[i].City; _address += ""; _address += "" + city + ""; _address += respo.ListOfCoursesLocation[i].StateName != null ? ", " + respo.ListOfCoursesLocation[i].StateName + "" : ""; _address += ", " + respo.ListOfCoursesLocation[i].ZipCode + ""; _address += ''; _address += "" + respo.ListOfCoursesLocation[i].CountryName + ""; if (respo.ListOfCoursesLocation[i].IsOnline) { table += ''; } else { table += ''; } table += ''; table += ''; table += ''; table += ''; } table += '
    DateTimeLocationInstructorLanguagePrice
    '; table += ''; table += ''; //table += '
    ' + (respo.ListOfCoursesLocation[i].DisplayDate != '' ? respo.ListOfCoursesLocation[i].DisplayDate : respo.ListOfCoursesLocation[i].StartDateOnly + ' - ' + respo.ListOfCoursesLocation[i].EndDateOnly) + '
    '; //table += '
    '; table += '
    ' + startTime + '-' + endTime + '
    '; table += '
    '; // table += '' + time + ''; // table += '' + respo.ListOfCoursesLocation[i].ClassId + ''; // table += ''; table += '
    Online
    '; table += '
    ' + respo.ListOfCoursesLocation[i].CountryName + '" data-ClassId="' + respo.ListOfCoursesLocation[i].ClassId + '">'; table += '
    ' + city + ', ' + (respo.ListOfCoursesLocation[i].StateName != null ? respo.ListOfCoursesLocation[i].StateName + ', ' : " ") + respo.ListOfCoursesLocation[i].CountryName + '
    '; table += '
    '; table += '
    ' + respo.ListOfCoursesLocation[i].InstructorName + '
    '; table += '
    '; table += '
    ' + respo.ListOfCoursesLocation[i].Language + '
    '; table += '
    '; var price = respo.ListOfCoursesLocation[i].IsFree ? "0" : (respo.ListOfCoursesLocation[i].LocalSalePrice != '' && respo.ListOfCoursesLocation[i].SalePriceString != null ? respo.ListOfCoursesLocation[i].SalePrice : respo.ListOfCoursesLocation[i].Price); //table += '-' + (respo.ListOfCoursesLocation[i].IsFree ? "Free" : (respo.ListOfCoursesLocation[i].SalePriceString != '' && respo.ListOfCoursesLocation[i].SalePriceString != null ? ('' + respo.ListOfCoursesLocation[i].PriceString + '' + ' ' + respo.ListOfCoursesLocation[i].SalePriceString) : respo.ListOfCoursesLocation[i].PriceString)) + ''; var dataPrice = "" + (respo.ListOfCoursesLocation[i].IsFree ? "Free" : (respo.ListOfCoursesLocation[i].SalePriceString != '' && respo.ListOfCoursesLocation[i].SalePriceString != null ? ('' + respo.ListOfCoursesLocation[i].PriceString + ' ' + ' ' + respo.ListOfCoursesLocation[i].SalePriceString) : respo.ListOfCoursesLocation[i].PriceString)) + ""; if ((respo.ListOfCoursesLocation[i].OriginalPriceString != "" && respo.ListOfCoursesLocation[i].OriginalPriceString != null) || (respo.ListOfCoursesLocation[i].OriginalSalePriceString != "" && respo.ListOfCoursesLocation[i].OriginalSalePriceString != null)) { dataPrice += "" + (respo.ListOfCoursesLocation[i].OriginalSalePriceString != '' && respo.ListOfCoursesLocation[i].OriginalSalePriceString != null ? ('
    ' + respo.ListOfCoursesLocation[i].OriginalPriceString + ' ' + ' ' + respo.ListOfCoursesLocation[i].OriginalSalePriceString) : "
    " + respo.ListOfCoursesLocation[i].OriginalPriceString) + "
    "; } table += '

    ' + dataPrice+ '

    '; table += '
    '; function addiCallback() { $('.locationModal').closest('.modal').attr('id', 'moreLocationList').css({ 'overflow': 'hidden' }); if (!FromScheduleFlag) { if (SelectbtnClass == 'FromListing') { $('').prependTo($('.locationModal .modal-footer')); } } if (GroupId != undefined && GroupId > 0) { $('' + GroupId + '').prependTo($('.locationModal .modal-footer')); } $('').prependTo($('.locationModal .modal-footer')); pTooltip(); $('.locationModal .modal-content').addClass('h100p'); jsDateFormatAndTip(); } var cTitle = Trainingname; var cText = table; var cBConfirm = "btn btn-theme SelectTrainingLocation " + SelectbtnClass; var cBConfirmName = "Select"; var cMCLocation = "modal-lg locationModal"; var cAddiCallBack = addiCallback; commonConfirmPopup(cTitle, cText, cBConfirmName, 'Close', cBConfirm, 'btn btn-default', cMCLocation, cFalseCallback, cFalseCallback, cAddiCallBack); //$('#moreLocationList .SelectTrainingLocation').addClass('hide'); $('#moreLocationList .subProductPrice').html(''); } } }) }); $(document).on('shown.bs.modal', '#moreLocationList', function () { modalResponsiveCall(); }) $(document).off('click', '.SelectLocationAndBuy'); $(document).on('click', '.SelectLocationAndBuy', function () { $('#moreLocationList .SelectTrainingLocation').addClass('TriggerPurchase'); $('#moreLocationList .SelectTrainingLocation').trigger('click'); }); $(document).on('hidden.bs.modal', '#moreLocationList', function () { if ($('.modal:visible').length > 0) { $('body').addClass('modal-open'); } }); $(document).off('click', '.buySubProduct'); $(document).on('click', '.buySubProduct', function () { $('#moreLocationList .buySubProduct').attr('disabled', 'disabled'); $(this).closest('tr').find('.blankPrice').addClass('hide'); $(this).closest('tr').find('.price').removeClass('hide'); //$('#moreLocationList .jsAddMyList').removeClass('jsAddMyListCourse'); //$('#moreLocationList .jsAddMyList').removeClass('purchaseBtn'); //$('#moreLocationList .buySP').removeClass('buy_SubProduct'); //$('#moreLocationList .buySP').removeClass('purchaseBtn'); //$('#moreLocationList .jsAddMyList').removeAttr('data-courseprerequisiteids'); //$('#moreLocationList .buySP').removeAttr('data-courseprerequisiteids'); $('#moreLocationList .subProductPrice').html(''); //productIdFromMoreLocation = 0; //moreLocationTR = $(this).closest('tr').clone(); if ($(this).closest('tr').attr('data-isfree') == 'true') { //if ($('#dtAvailableCourses tr[data-id="' + $(this).closest('tr').attr('data-productid') + '"]').find('a.purchaseBtn').attr('data-courseprerequisiteids') != undefined && $('#dtAvailableCourses tr[data-id="' + $(this).closest('tr').attr('data-productid') + '"]').find('a.purchaseBtn').attr('data-courseprerequisiteids') != '') { // $('#moreLocationList .jsAddMyList').addClass('purchaseBtn'); // $('#moreLocationList .jsAddMyList').attr('data-courseprerequisiteids', $('#dtAvailableCourses tr[data-id="' + $(this).closest('tr').attr('data-productid') + '"]').find('a.purchaseBtn').attr('data-courseprerequisiteids')); // productIdFromMoreLocation = $(this).closest('tr').attr('data-subproductid'); //} else { // $('#moreLocationList .jsAddMyList').addClass('jsAddMyListCourse'); //} //$('#moreLocationList .jsAddMyList').removeClass('hide'); //$('#moreLocationList .jsAddMyList').attr('data-productid', $(this).closest('tr').attr('data-productid')); //$('#moreLocationList .jsAddMyList').attr('data-subproductid', $(this).closest('tr').attr('data-subproductid')); $('#moreLocationList .SelectTrainingLocation').removeClass('hide'); if ($('#moreLocationList .SelectTrainingLocation').hasClass('FromListing')) { $('#moreLocationList .SelectLocationAndBuy').removeClass('hide').text('Add To My List'); } $('#moreLocationList .subProductPrice').html('Free'); } else { //if ($('#dtAvailableCourses tr[data-id="' + $(this).closest('tr').attr('data-productid') + '"]').find('a.purchaseBtn').attr('data-courseprerequisiteids') != undefined && $('#dtAvailableCourses tr[data-id="' + $(this).closest('tr').attr('data-productid') + '"]').find('a.purchaseBtn').attr('data-courseprerequisiteids') != '') { // //$('#moreLocationList .buySP').addClass('purchaseBtn'); // //$('#moreLocationList .buySP').attr('data-courseprerequisiteids', $('#dtAvailableCourses tr[data-id="' + $(this).closest('tr').attr('data-productid') + '"]').find('a.purchaseBtn').attr('data-courseprerequisiteids')); // //productIdFromMoreLocation = $(this).closest('tr').attr('data-subproductid'); // //$('#moreLocationList .buySP').attr('data-productid', $(this).closest('tr').attr('data-productid')); //} else { // //$('#moreLocationList .buySP').addClass('buy_SubProduct'); //} //$('#moreLocationList .buySP').attr('data-subproductid', $(this).closest('tr').attr('data-subproductid')); //$('#moreLocationList .buySP').attr('data-productid', $(this).closest('tr').attr('data-productid')); //$('#moreLocationList .buySP').removeClass('hide'); $('#moreLocationList .SelectTrainingLocation').removeClass('hide'); if ($('#moreLocationList .SelectTrainingLocation').hasClass('FromListing')) { $('#moreLocationList .SelectLocationAndBuy').removeClass('hide'); } if ($('#moreLocationList .SelectTrainingLocation').hasClass('FromPopUpAddtiinalTable')) { $('#moreLocationList .subProductPrice').html('Free'); } else { $('#moreLocationList .subProductPrice').html($(this).closest('tr').find('.price').html()); } } modalResponsiveCall(); }); $('#mdlPrerequisiteConfirm').on('shown.bs.modal', function () { var vidId = $('#mdlPrerequisiteConfirm .vidBase').find('video').attr('id') + 1; var video = document.getElementById(vidId); }); $('#mdlPrerequisiteConfirm').on('hidden.bs.modal', function () { $('#mdlPrerequisiteConfirm .vidBase').parent().children('.courseVidDiv').remove(); }); $('#mdlTrainingGroupPreview').on('hidden.bs.modal', function () { $('#mdlTrainingGroupPreview .pright').removeClass('active').children('.fa').removeClass('fa-minus').addClass('fa-plus'); $('#mdlTrainingGroupPreview .vidPlace').slideUp('slow'); }); $(document).off('click', '.SelectTrainingLocation'); $(document).on('click', '.SelectTrainingLocation', function () { var SelectedTr = $('#moreLocationList .buySubProduct:checked').closest('tr'); if (SelectedTr.length > 0) { if ($('.SelectedTR').hasClass('TrainingCourse')) { var PreviousProductId = $('.SelectedTR').attr('data-subproductid'); if (PreviousProductId > 0) { var TrainingGroupId = $('.SelectedTR').attr('data-sgid'); var TGTotalCoursesCount = $('.TrainingCourse[data-sgid="' + TrainingGroupId + '"]').length; if (TrainingGroupId > 0 && TGTotalCoursesCount > 0) { var TGPurchasedCourseCount = $('tr.TrainingCourse[data-sgid="' + TrainingGroupId + '"] .jsPrice:contains("Bought")').length; var Percentage = parseFloat((parseInt(TGPurchasedCourseCount) * 100) / parseInt(TGTotalCoursesCount)) if (Percentage > 20) { if ($('.TrainingCourse[data-sgid="' + TrainingGroupId + '"] .jsPrice').text().indexOf('Bought') > -1) { var TrainingGroupPrice = parseFloat($('.jscgroupRow[data-gid="' + TrainingGroupId + '"]').find('.jsPrice').attr('data-price')); var SelectedCoursePrice = parseFloat($(SelectedTr).find('.pricetd .price').attr('data-price')); var PreviousCoursePrice = parseFloat($('#moreLocationList tr[data-subproductid="' + PreviousProductId + '"]').find('.price').attr('data-price')); var NewTGPrice = parseFloat(parseFloat(TrainingGroupPrice) + parseFloat(SelectedCoursePrice) - parseFloat(PreviousCoursePrice)).toFixed(2); var NewLocalPrice = $('.jscgroupRow[data-gid="' + TrainingGroupId + '"]').find('.jsPrice').text().replace(TrainingGroupPrice, NewTGPrice); $('.jscgroupRow[data-gid="' + TrainingGroupId + '"]').find('.jsPrice').text(NewLocalPrice); $('.jscgroupRow[data-gid="' + TrainingGroupId + '"]').find('.jsPrice').attr('data-price', NewTGPrice); } } } } $('.SelectedTR').attr('data-subproductid', $(SelectedTr).attr('data-subproductid')); } var SubProductId = $(SelectedTr).attr('data-subproductid'); var ProductId = $(SelectedTr).attr('data-productid'); var InstructorName = $(SelectedTr).find('td.instructor').html(); var startDate = $(SelectedTr).find('td.startDate').html(); var startTime = $(SelectedTr).find('td.startTime').find('.MainTime').text(); var ClassId = $(SelectedTr).find('td.startTime').find('.jsClassId').text(); var location = ($(SelectedTr).find('td.location').hasClass('hide') ? '-' : $(SelectedTr).find('td.location').attr('data-location')); var CourseClassId = $(SelectedTr).find('td.location').attr('data-ClassId'); var language = $(SelectedTr).find('td.language').html(); var Price = $('#moreLocationList .subProductPrice').html(); var Latitude = $(SelectedTr).attr('data-latitude'); var Longitude = $(SelectedTr).attr('data-longitude'); if ($(this).hasClass('FromListing') || $(this).hasClass('FromPopUpTable') || $(this).hasClass('FromPopUpAddtiinalTable')) { if ($(this).hasClass('FromPopUpTable') || $(this).hasClass('FromPopUpAddtiinalTable')) { var CurrentTr = $("#preRequisitesConfirm tr[data-id=" + ProductId + "]"); } else { var CurrentTr = $(TrainingListcontainerdiv + " #dtAvailableCourses tr[data-id=" + ProductId + "]"); if (FromScheduleFlag) { CurrentTr = $(TrainingListcontainerdiv + " #dtAvailableCourses tr.SelectedTR[data-id=" + ProductId + "]"); } if ($(CurrentTr).find(".purchaseBtn[data-productid=" + ProductId + "]").length > 0) { $(CurrentTr).find(".purchaseBtn[data-productid=" + ProductId + "]").attr("data-subproductid", SubProductId); } else { $(CurrentTr).find(".jsAddMyListCourse[data-productid=" + ProductId + "]").attr("data-subproductid", SubProductId); } } $(CurrentTr).find('td.authorname .authorC').html(InstructorName); $(CurrentTr).find('td.ClassId .textToolhint').html(CourseClassId); //if(FromScheduleFlag){ // $(CurrentTr).find('td.authorname .authorC').html(InstructorName); // $(CurrentTr).find('td.ClassId .textToolhint').html(CourseClassId); //} //else{ // $(CurrentTr).find('td.authorname > a').html(InstructorName); //} $(CurrentTr).find('.jsYear .mainDate').html(startDate); $(CurrentTr).find('.jsYear .jsTime').html(startTime); $(CurrentTr).find('.jsYear .jsClassId').html(ClassId); $(CurrentTr).find('td.location').find('a.moreLocation span.hlinkC').html(location); $(CurrentTr).find('td.location').find('a.moreLocation').attr('data-latitude', Latitude); $(CurrentTr).find('td.location').find('a.moreLocation').attr('data-longitude', Longitude); //$(CurrentTr).find('td.location > a').html(location); //$(CurrentTr).find('td.location a.hlink').each(function (index, item) { // $(item).html(location); //}); //if(FromScheduleFlag){ // $(CurrentTr).find('td.location a .hlinkC').each(function (index, item) { // $(item).html(location); // }) //} //else{ // $(CurrentTr).find('td.location a').each(function (index, item) { // $(item).html(location); // }) //} $(CurrentTr).attr('data-subproductid', SubProductId); $(CurrentTr).find('td.language').html(language); $(CurrentTr).find('td.jsPrice').html(Price); $(CurrentTr).find('td.jsPrice').attr('data-price', Price); $(CurrentTr).addClass('LocationChanged'); if ($(this).hasClass('FromAdditionalCourseChangeLocation')) { location = location == "-" ? "" : location; var MainCourseLatitude = $('#mdlPrerequisiteConfirm .MainTrainingData .jsClassLocation').attr('data-latitude'); var MainCourseLongitude = $('#mdlPrerequisiteConfirm .MainTrainingData .jsClassLocation').attr('data-longitude'); $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody').find('ul#AlignerAdditionalCourseList').find('li[data-id=' + ProductId + ']').attr('data-latitude', Latitude); $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody').find('ul#AlignerAdditionalCourseList').find('li[data-id=' + ProductId + ']').attr('data-longitude', Longitude); var AddtionalCourseLocationDate = $(SelectedTr).find('td.startDate').find('.timeTip').text(); $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody').find('ul#AlignerAdditionalCourseList').find('li[data-id=' + ProductId + '] .AddtionalCourseDate').text(AddtionalCourseLocationDate); if (parseFloat(Latitude).toFixed(6) == parseFloat(MainCourseLatitude).toFixed(6) && parseFloat(Longitude).toFixed(6) == parseFloat(MainCourseLongitude).toFixed(6)) { $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody').find('ul#AlignerAdditionalCourseList').find('li[data-id=' + ProductId + '] .AddtionalCourseLocation').addClass('hide'); } else { $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody').find('ul#AlignerAdditionalCourseList').find('li[data-id=' + ProductId + '] .AddtionalCourseLocation').removeClass('hide'); $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody').find('ul#AlignerAdditionalCourseList').find('li[data-id=' + ProductId + '] .AddtionalCourseLocation').text(location.replace(new RegExp('
    ', 'g'), " ")); } } else if ($(this).hasClass('FromAdditionalCourseGroupChangeLocation')) { $('#GroupCourseDetails').find('ul#GroupCourseDetailsGroupCourseList').find('li[data-id=' + ProductId + ']').attr('data-latitude', Latitude); $('#GroupCourseDetails').find('ul#GroupCourseDetailsGroupCourseList').find('li[data-id=' + ProductId + ']').attr('data-longitude', Longitude); var AddtionalCourseLocationDate = $(SelectedTr).find('td.startDate').find('.timeTip').text(); $('#GroupCourseDetails').find('ul#GroupCourseDetailsGroupCourseList').find('li[data-id=' + ProductId + '] .AddtionalCourseDate').text(AddtionalCourseLocationDate); $('#GroupCourseDetails').find('ul#GroupCourseDetailsGroupCourseList').find('li[data-id=' + ProductId + '] .AddtionalCourseLocation').text(location.replace(new RegExp('
    ', 'g'), " ")); $('#GroupCourseDetails').find('ul#GroupCourseDetailsGroupCourseList').find('li[data-id=' + ProductId + ']').attr('data-subproductid', SubProductId); var LastLatitude = 0; var LastLongitude = 0; var LastDisplayLocation = ""; var IsAllSameLocation = true; $('#GroupCourseDetails').find('ul#GroupCourseDetailsGroupCourseList').find('li').each(function () { var Latitude = $(this).attr('data-latitude'); var Longitude = $(this).attr('data-longitude'); if (Latitude != undefined && Longitude != undefined) { if (LastLatitude == 0 && LastLongitude == 0) { LastLatitude = Latitude; LastLongitude = Longitude; LastDisplayLocation = location.replace(new RegExp('
    ', 'g'), " "); } if (parseFloat(Latitude).toFixed(6) != parseFloat(LastLatitude).toFixed(6) || parseFloat(Longitude).toFixed(6) != parseFloat(LastLongitude).toFixed(6)) { IsAllSameLocation = false; } } }); if (IsAllSameLocation) { if (LastDisplayLocation != '') { $('#GroupCourseDetails').find('.jsClassLocation').html(LastDisplayLocation); } $('#GroupCourseDetails').find('#GroupCourseDetailsGroupCourseList').find('.AddtionalCourseLocation').addClass('hide'); } else { $('#GroupCourseDetails').find('.jsClassLocation').html(''); $('#GroupCourseDetails').find('#GroupCourseDetailsGroupCourseList').find('.AddtionalCourseLocation').removeClass('hide'); } } if ($('#mdlCoursePrerequisite').is(':visible')) { var PrerequisiteTr = $("#tblCoursePrerequisite tr[data-id=" + ProductId + "]"); $(PrerequisiteTr).find('td.authorname .authorC').html(InstructorName); $(PrerequisiteTr).find('td.ClassId .textToolhint').html(CourseClassId); $(PrerequisiteTr).find('.jsYear .mainDate').html(startDate); $(PrerequisiteTr).find('.jsYear .jsTime').html(startTime); $(PrerequisiteTr).find('.jsYear .jsClassId').html(ClassId); $(PrerequisiteTr).find('td.location').find('a.moreLocation').html(location); $(PrerequisiteTr).find('td.authorname a').html(InstructorName); //$(CurrentTr).find('td.location a .hlinkC').each(function (index, item) { // $(item).html(location); //}); $(PrerequisiteTr).attr('data-subproductid', SubProductId); $(PrerequisiteTr).find('td.language').html(language); $(PrerequisiteTr).find('td.jsPrice').html(Price); $(PrerequisiteTr).addClass('LocationChanged'); } if ($(this).hasClass('TriggerPurchase')) { if ($(CurrentTr).find(".purchaseBtn[data-productid=" + ProductId + "]").length > 0) { $(CurrentTr).find(".purchaseBtn[data-productid=" + ProductId + "]").trigger('click'); } else { $(CurrentTr).find(".jsAddMyListCourse[data-productid=" + ProductId + "]").trigger('click'); } } } else if ($(this).hasClass('FromPopUpMain')) { if ($('#mdlCoursePreview').is(':visible')) { var CurrentTr = $("#dtAvailableCourses tr[data-id=" + ProductId + "]"); if ($(CurrentTr).find(".purchaseBtn[data-productid=" + ProductId + "]").length > 0) { $(CurrentTr).find(".purchaseBtn[data-productid=" + ProductId + "]").attr("data-subproductid", SubProductId); } else { $(CurrentTr).find(".jsAddMyListCourse[data-productid=" + ProductId + "]").attr("data-subproductid", SubProductId); } $(CurrentTr).find('td.authorname .authorC').html(InstructorName); $(CurrentTr).find('td.ClassId .textToolhint').html(CourseClassId); //if(FromScheduleFlag){ // $(CurrentTr).find('td.authorname .authorC').html(InstructorName); // $(CurrentTr).find('td.ClassId .textToolhint').html(CourseClassId); //} //else{ // $(CurrentTr).find('td.authorname > a').html(InstructorName); //} $(CurrentTr).find('.jsYear .mainDate').html(startDate); $(CurrentTr).find('.jsYear .jsTime').html(startTime); $(CurrentTr).find('.jsYear .jsClassId').html(ClassId); $(CurrentTr).find('td.location a .hlinkC').html(location); //if(FromScheduleFlag){ // $(CurrentTr).find('td.location a .hlinkC').html(location); //} //else{ // $(CurrentTr).find('td.location > a').html(location); //} $(CurrentTr).attr('data-subproductid', SubProductId); $(CurrentTr).find('td.language').html(language); $(CurrentTr).find('td.jsPrice').html(Price); $(CurrentTr).addClass('LocationChanged'); $('#mdlCoursePreview .MainTrainingData .jsYear .mainDate').html(startDate); $('#mdlCoursePreview .MainTrainingData .jsYear .jsTime').html(startTime); $('#mdlCoursePreview .MainTrainingData .jsYear .jsClassId').html(ClassId); $('#mdlCoursePreview .MainTrainingData .jsClassLocation a .hlinkC').html(location.replace(new RegExp('
    ', 'g'), " ")); //if(FromScheduleFlag){ // $('#mdlCoursePreview .MainTrainingData .jsClassLocation a .hlinkC').html(location.replace(new RegExp('
    ', 'g'), " ")); //} //else{ // $('#mdlCoursePreview .MainTrainingData .jsClassLocation > a').html(location.replace(new RegExp('
    ', 'g'), " ")); //} $('#mdlCoursePreview .MainTrainingData .jsClassLocation').attr('data-productid', ProductId).attr('data-subproductid', SubProductId); $('#mdlCoursePreview .MainTrainingData .jsPrice').html(Price); } else { $('#mdlPrerequisiteConfirm .MainTrainingData .jsYear .mainDate').html(startDate); $('#mdlPrerequisiteConfirm .MainTrainingData .jsYear .jsTime').html(startTime); $('#mdlPrerequisiteConfirm .MainTrainingData .jsYear .jsClassId').html(ClassId); if (FromScheduleFlag) { $('#mdlPrerequisiteConfirm .MainTrainingData .jsClassLocation').html(location.replace(new RegExp('
    ', 'g'), " ").replace(new RegExp('
    ', 'g'), " ")); } else { $('#mdlPrerequisiteConfirm .MainTrainingData .jsClassLocation').html(location.replace(new RegExp('
    ', 'g'), " ").replace(new RegExp('
    ', 'g'), " ")); } $('#mdlPrerequisiteConfirm .MainTrainingData .jsClassLocation').attr('data-productid', ProductId).attr('data-subproductid', SubProductId); $('#mdlPrerequisiteConfirm .MainTrainingData .jsClassLocation').attr('data-latitude', Latitude); $('#mdlPrerequisiteConfirm .MainTrainingData .jsClassLocation').attr('data-longitude', Longitude); var MainCourseLatitude = $('#mdlPrerequisiteConfirm .MainTrainingData .jsClassLocation').attr('data-latitude'); var MainCourseLongitude = $('#mdlPrerequisiteConfirm .MainTrainingData .jsClassLocation').attr('data-longitude'); $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody').find('ul#AlignerAdditionalCourseList').find('li').each(function () { var Latitude = $(this).attr('data-latitude'); var Longitude = $(this).attr('data-longitude'); if (Latitude != undefined && Longitude != undefined) { if (parseFloat(Latitude).toFixed(6) == parseFloat(MainCourseLatitude).toFixed(6) && parseFloat(Longitude).toFixed(6) == parseFloat(MainCourseLongitude).toFixed(6)) { $(this).find('.AddtionalCourseLocation').addClass('hide'); } else { $(this).find('.AddtionalCourseLocation').removeClass('hide'); } } }); $('#mdlPrerequisiteConfirm .MainTrainingData .jsPrice').html(Price); $('#mdlPrerequisiteConfirm .mdlPrerequisiteConfirmBody .jsPrice').html(Price); } } //if ($('.mdlPrerequisiteConfirmBody #preRequisitesConfirm tbody tr[data-isfree="false"]').length > 0 || $.trim($('#mdlPrerequisiteConfirm .MainTrainingData .jsPrice').text()) != 'Free') { // var MainPrice = (isNaN(parseFloat($('#mdlPrerequisiteConfirm .MainTrainingData .jsPrice').html().match(/[\d\.]+/g))) ? 0 : parseFloat($('#mdlPrerequisiteConfirm .MainTrainingData .jsPrice').html().match(/[\d\.]+/g))); // $('.mdlPrerequisiteConfirmBody #preRequisitesConfirm tbody tr.CalculatedTr[data-isfree="false"]').each(function (i) { // MainPrice += (isNaN(parseFloat($(this).find('td.jsPrice').html().match(/[\d\.]+/g))) ? 0 : parseFloat($(this).find('td.jsPrice').html().match(/[\d\.]+/g))); // }); // $('.TrainingOrderTotal').html('$' + MainPrice.toFixed(2)); // $('.TrainingOrderTotal').parent('div').removeClass('hide') //} else { // $('.TrainingOrderTotal').parent('div').addClass('hide'); //} } if (IsAuthenticated != undefined && IsAuthenticated == "False") { $(CurrentTr).find(".CourseProduct[data-productid=" + ProductId + "]").attr("data-subproductid", SubProductId); } $('.TrainingOrderTotal').parent('div').addClass('hide'); $('#moreLocationList').modal('hide'); if (SelectedTr.length > 0 && !$(this).hasClass('FromAdditionalCourseChangeLocation') && !$(this).hasClass('FromPopUpTable') && !$(this).hasClass('FromPopUpMain')) { if (IsAuthenticated != undefined && IsAuthenticated == "False") { $('tr.SelectedTR').find('.CourseProduct').trigger('click') } else { $('tr.SelectedTR').find('.purchaseBtn').trigger('click') } } }); $(document).off('click', '.buy_SubProduct'); $(document).on('click', '.buy_SubProduct', function () { productIds = new Array(); $('.jsActiveProdToAddCart').removeClass('jsActiveProdToAddCart'); $(this).addClass('jsActiveProdToAddCart'); $('#oneclick_checkout_course #productIds').val(''); $('#oneclick_checkout_course #tblCourseCartDetail tbody tr').remove(); AddCourseInCart($('#moreLocationList .buySubProduct:checked').closest('tr').attr('data-subproductid'), true); //moreLocationTR = $('moreLocationList .buySubProduct:checked').closest('tr').clone(); $('#checkout_div_ordertotal').hide(); $('#oneclick_checkout_course').modal('show'); $('#moreLocationList').modal('hide'); }); $(document).off('click', '.preRequisiteBuySubProduct'); $(document).on('click', '.preRequisiteBuySubProduct', function () { var _this = $(this); $(_this).closest('table').find('input[type="checkbox"]').attr('disabled', 'disabled'); //$(_this).closest('tr').find('.blankPrice').addClass('hide'); //$(_this).closest('tr').find('.price').removeClass('hide'); //console.log($(_this).closest('tr').closest('table').find('tr:last')) $('' + $(_this).closest('tr').find('.price').html() + '').insertBefore($(_this).closest('tr').closest('table').find('tr:last')); $(_this).closest('tr').closest('table').find('tr.lblErrorMsg').addClass('hide'); }); $(document).on('click', '.multipleVideoList', function () { var _this = $(this); $('#divGetVideoList').load('/Courses/VideoDetail/' + $(_this).closest('tr').attr('data-id'), function () { $('#mdlVideoList .videoTitle').html($(_this).closest('tr').find('td.jsCourseTitle .dblk').html()); $('#mdlVideoList').modal('show'); }) }); $(document).on('click', '.chkMarkAsWatch', function () { var _this = $(this); $.ajax({ url: '/Courses/MarkAsWatch', data: { videoAttachmentId: $(_this).attr('data-id'), markAsWatch: ($(_this).attr('data-ischecked') == 'False' ? true : false), courseId: $(_this).attr('data-courseid') }, success: function (respo) { if (respo) { $(_this).attr('data-ischecked', ($(_this).attr('data-ischecked') == 'False' ? 'True' : 'False')); $.confirm({ text: ($(_this).is(':checked') ? "You just marked this video as watched successfully." : "You just marked this video as not watched successfully."), title: 'Success', confirm: function () { }, cancel: function () { }, confirmButton: 'Ok', cancelButton: 'Cancel', dialogClass: 'modal-dialog modal-md', confirmButtonClass: 'btn-theme', cancelButtonClass: 'btn-default hide' }) } } }) }); $(document).off('click', TrainingListcontainerdiv + ' .openRating'); $(document).on('click', TrainingListcontainerdiv + ' .openRating', function () { var _this = $(this); $.ajax({ url: '/Courses/ItemRatingByProductId', data: { productId: $(_this).closest('tr').attr('data-id') }, success: function (respo) { if (respo.Status) { var table = ''; for (var i = 0; i < respo.ListOfItemRating.length; i++) { table += ''; table += ''; table += ''; table += ''; table += ''; } table += '
    UserRatingAction
    ' + respo.ListOfItemRating[i].CustomerName + '
    '; for (var j = 0; j < 5; j++) { if (respo.ListOfItemRating[i].Rating == 0) { table += ''; } else { if ((respo.ListOfItemRating[i].Rating - j) > 0) { if ((respo.ListOfItemRating[i].Rating - j) < 1 && (respo.ListOfItemRating[i].Rating - j) != 0) { table += ''; } else { table += ''; } } else { table += ''; } } } table += '
    '; $('#mdlOpenRating .jsTitle').html($(_this).closest('tr').find('.jsCourseTitle').find('.dblk').html()); $('#mdlOpenRating .bodyTable').html(table); $('#mdlOpenRating').modal('show'); } } }); }); $(document).off('click', '.removeItemRating'); $(document).on('click', '.removeItemRating', function () { var _this = $(this); $.confirm({ title: 'Confirmation required', text: 'Are you sure you want to delete this rating?', confirm: function () { $.ajax({ url: '/Courses/DeleteItemRating', data: { itemRatingId: $(_this).closest('tr').attr('data-id') }, success: function (respo) { if (respo.Status) { $(_this).closest('tr').remove(); } } }) }, cancel: function () { }, confirmButton: 'Yes', cancelButton: 'No', confirmButtonClass: 'btn-danger', cancelButtonClass: 'btn-default', dialogClass: 'modal-dialog modal-sm' }); }); $(document).off('click', TrainingListcontainerdiv + ' .addToCartTitle'); $(document).on('click', TrainingListcontainerdiv + ' .addToCartTitle', function () { var IsHTMLBlank = true; var jsAboutCourse = $.trim($(this).closest('tr').find('.jsAboutCourse').html()); if ($(jsAboutCourse).text().trim() != '' || $(jsAboutCourse).has('img').length > 0 || $(jsAboutCourse).has('a').length > 0 || $(jsAboutCourse).has('video').length > 0) { IsHTMLBlank = false; } var PreviewVideo = $.trim($(this).closest('tr').find('.jsCoursePreview').attr('data-Videopath')); if (typeof (FromScheduleFlag) != "undefined" && FromScheduleFlag) { $(this).closest('tr').find('.jsCoursePreview').click(); } else { if ($(this).closest('tr').find('.purchaseBtn').is(":visible")) { var AdditionalCourses = $(this).closest('tr').find('.purchaseBtn').attr('data-additionalcourses'); var courseprerequisiteids = $(this).closest('tr').find('.purchaseBtn').attr('data-courseprerequisiteids'); if ((courseprerequisiteids != undefined && courseprerequisiteids != '') || (AdditionalCourses != undefined && AdditionalCourses != '')) { $(this).closest('tr').find('.purchaseBtn').click(); } else if (!IsHTMLBlank || PreviewVideo != '') { $(this).closest('tr').find('.jsCoursePreview').click(); } else { $(this).closest('tr').find('.purchaseBtn').click(); } } else if ($(this).closest('tr').find('.jsAddMyListCourse').is(':visible')) { if (!IsHTMLBlank || PreviewVideo != '') { $(this).closest('tr').find('.jsCoursePreview').click(); } else { $(this).closest('tr').find('.jsAddMyListCourse').click(); } } } }); $(document).off('change', TrainingListcontainerdiv + ' input[type="radio"][name="trainingFilter"]') $(document).on('change', TrainingListcontainerdiv + ' input[type="radio"][name="trainingFilter"]', function () { //debugger; //LoadCourseFilterRequest = new Array(); isTab = true; LoadCourseFilterRequest.push({ FieldName: 'CategoryType', ID: $(this).val(), ConditionalParameters: 1 }); if (Order[0].column == 0) { Order[0].column = 13; Order[0].dir = 'desc'; } $(TrainingListcontainerdiv + ' #tblHeaderAvailableCourses th .btnFilter:first').click(); if (parseInt($(TrainingListcontainerdiv + ' #tblHeaderAvailableCourses th[data-field="SubCategoryType"] input[type="radio"][name="name"]:checked').val()) == 0) { $(TrainingListcontainerdiv + ' #tblHeaderAvailableCourses th[data-field="SubCategoryType"]').removeClass('ActiveFilterth'); $(TrainingListcontainerdiv + ' #tblHeaderAvailableCourses th[data-field="SubCategoryType"] .btnOpenFilter').removeClass('ActiveFilter'); } //isFilter = true; //BindLoadAvailableCourses(); }); $('#previewCourse').on('hidden.bs.modal', function () { if ($('.modal:visible').length > 0) { $('body').addClass('modal-open'); } }); $(document).off('click', '.dropdown-menu') $(document).on('click', '.dropdown-menu', function (event) { event.stopPropagation(); }); $(document).off('click', TrainingListcontainerdiv + ' .jsBtnCourseSearch'); $(document).on('click', TrainingListcontainerdiv + ' .jsBtnCourseSearch', function () { if ($.trim($('#txtCourseSearchText').val()) != '') { isFilter = true; SearchFilterFlag = true; BindLoadAvailableCourses(); $(TrainingListcontainerdiv + ' .jsBtnCourseSearchClear').remove(); $('').insertAfter($(this)); } }); $(document).off('click', TrainingListcontainerdiv + ' .jsBtnCourseSearchClear'); $(document).on('click', TrainingListcontainerdiv + ' .jsBtnCourseSearchClear', function () { isFilter = true; SearchFilterFlag = false; $(TrainingListcontainerdiv + ' #txtCourseSearchText').val(''); $(TrainingListcontainerdiv + ' .jsBtnCourseSearchClear').remove(); BindLoadAvailableCourses(); }); $(document).off('keyup', TrainingListcontainerdiv + ' #txtCourseSearchText'); $(document).on('keyup', TrainingListcontainerdiv + ' #txtCourseSearchText', function (e) { if (e.keyCode == 13 && $.trim($(this).val()) == "" && $(TrainingListcontainerdiv + ' .jsBtnCourseSearch').parent().find('.jsBtnCourseSearchClear').length > 0) { $(TrainingListcontainerdiv + ' .jsBtnCourseSearchClear').click(); } else if (e.keyCode == 13 && $.trim($(this).val()) != '') { $(TrainingListcontainerdiv + ' .jsBtnCourseSearch').click(); } }); $(document).off('click', '.jsBtnByThisCourse'); $(document).on('click', '.jsBtnByThisCourse', function () { $('#mdlCoursePreview').modal('hide'); $('.jsPreviewActive').closest('tr').find('.purchaseBtn').trigger('click'); }); $('#mdlCoursePreview').on('shown.bs.modal', function () { var vidId = $('#mdlCoursePreview .vidBase').find('video').attr('id') + 1; var video = document.getElementById(vidId); pTooltip() //video.play(); }); $('#mdlCoursePreview').on('hidden.bs.modal', function () { $('#mdlCoursePreview .vidBase').parent().children('.courseVidDiv').remove(); }); $(document).on('click', '[data-dismiss="modal"]', function () { var BackFromTrainingURL = window.localStorage.getItem("BackFromTrainingURL"); window.localStorage.removeItem("BackFromTrainingURL"); if (BackFromTrainingURL != null && BackFromTrainingURL != '' && BackFromTrainingURL.length > 0) { window.location.href = BackFromTrainingURL; } }); $(document).off('click', '.jscgroupRow'); $(document).on('click', '.jscgroupRow', function (e) { if (e.target.className == 'GroupMoreLocation' || e.target.className == 'GrouppurchaseBtn') { return false; } var _this = $(this); var mainRowId = $(_this).attr('data-gid'); var subRow = $('[data-sgid="' + mainRowId + '"]:not(.TrainingTRNotGroup)'); var Search = { value: '', regex: false, } var Columns = new Array(); if ($('#tblHeaderAvailableCourses th').length > 0) { Columns = new Array(); $('#tblHeaderAvailableCourses th').each(function () { var _this = $(this); if ($(_this).attr('data-field') != undefined) { Columns.push({ data: $(_this).attr('data-field'), name: $(_this).attr('data-field'), searchable: false, orderable: true, search: Search, IsOrdered: false, }) } }); if (Order[0].column == 0) { Order[0].column = 2; //Order = [{ // column: 2, // dir: 'asc' //}]; } if (!storeOrderChanged && Order[0].column == 0) { Order[0].column = 13; } } else { Columns = [{ data: 'Title', name: 'Title', searchable: false, orderable: true, search: Search, IsOrdered: false, }]; Order = [{ column: 0, dir: 'asc' }]; } if ($(_this).hasClass('active')) { // If its needs like accordion uncomment this function // groupingRawAccordion(_this) $(_this).removeClass('active'); $(_this).find('td:nth-child(1) .fa, td:visible.forpsCol .fa').removeClass('fa-minus').addClass('fa-plus'); // $(subRow).addClass('cgSbHide'); //for (var i = subRow.length - 1; i >= 0; i--) { for (var i = 0; i < subRow.length; i++) { $('[data-sgid="' + mainRowId + '"]:eq(' + i + ')').addClass('cgSbHide').removeClass('sbactive'); if (i == subRow.length - 1) { setTimeout(function () { resultDataRpad(); }, 300); } }; } else { // If its needs like accordion uncomment this function // groupingRawAccordion(_this) var ClassId = $(_this).find('.GroupMoreLocation').attr('data-classid'); LoadCourseFilterRequest = LoadCourseFilterRequest.filter(function (obj) { return obj.FieldName !== 'GroupClassId'; }); if (ClassId != undefined && ClassId != "") { LoadCourseFilterRequest.push({ FieldName: 'GroupClassId', Text: ClassId, ConditionalParameters: 0 }); } Data = { //TrainingGroupId: mainRowId, //CategoryId: 0, Latitude: Lat, Longitude: Long, columns: Columns, order: Order, searchable: true, length: (30), start: (0), search: Search, course: { paginationRequest: { Take: paginationRequestTake }, SearchText: $(TrainingListcontainerdiv + ' #txtCourseSearchText').val(), CategoryId: 0, TrainingGroupId: mainRowId, IsPurchased: false, FilterString: JSON.stringify(LoadCourseFilterRequest), IsTrainingModal: IsTrainingModalScript, LatitudeString: Lat, LongitudeString: Long //IsPublish: true } } var URL = '/Aligner/LoadGroupTrainingPosOrtho'; if (!$(_this).next('tr').hasClass('TrainingCourse')) { $('#loadingWithBG').show(); $.ajax({ url: URL, type: 'Post', cache: false, datatype: 'json', data: Data, async: Async, //data: { TrainingGroupId: mainRowId, CategoryId: parseInt($(TrainingListcontainerdiv + ' input[type="radio"][name="trainingFilter"]:checked').val()) }, success: function (data) { $(data).insertAfter(_this); if (FromScheduleFlag) { var filterText = $('th[data-field="Title"]').find('input[type="text"]').val(); var ConditionalParameter = $('th[data-field="Title"]').find('.jsConditionalParameters :selected').val(); if (filterText != "" && ConditionalParameter != "2") { $.each($("#dtAvailableCourses tbody tr.TrainingCourse"), function () { //if ($(this).hasClass('TrainingCourse')) { var strongText = $(this).find('td[data-abtext="Seminar"]').find('.TitleText strong').text(); var emText = $(this).find('td[data-abtext="Seminar"]').find('.TitleText em').text(); if (strongText != "" && strongText != undefined && strongText.toLowerCase().indexOf(filterText.toLowerCase()) != -1) { var StartingIndex = strongText.toLowerCase().indexOf(filterText.toLowerCase()); var data = strongText.substr(0, StartingIndex) + '' + strongText.substr(StartingIndex, filterText.length) + '' + strongText.substr(StartingIndex + filterText.length, strongText.length); $(this).find('td[data-abtext="Seminar"]').find('.TitleText strong').html(data); } if (emText != "" && emText != undefined && emText.toLowerCase().indexOf(filterText.toLowerCase()) != -1) { var StartingIndex = emText.toLowerCase().indexOf(filterText.toLowerCase()); var data = emText.substr(0, StartingIndex) + '' + emText.substr(StartingIndex, filterText.length) + '' + emText.substr(StartingIndex + filterText.length, emText.length); $(this).find('td[data-abtext="Seminar"]').find('.TitleText em').html(data); } //} }) } } if (parseInt($(TrainingListcontainerdiv + ' input[type="radio"][name="trainingFilter"]:checked').val()) == 611) { $(TrainingListcontainerdiv + ' th[data-field="Rating"]').addClass('hide'); $(TrainingListcontainerdiv + ' .ratingtd').addClass('hide'); } else { $(TrainingListcontainerdiv + ' th[data-field="Rating"]').removeClass('hide'); $(TrainingListcontainerdiv + ' .ratingtd').removeClass('hide'); } if (parseInt($(TrainingListcontainerdiv + ' input[type="radio"][name="trainingFilter"]:checked').val()) == 610) { $(TrainingListcontainerdiv + ' th[data-field="CompleteStatusIds"]').removeClass('hide'); $(TrainingListcontainerdiv + ' .completetd').removeClass('hide'); } else { $(TrainingListcontainerdiv + ' th[data-field="CompleteStatusIds"]').addClass('hide'); $(TrainingListcontainerdiv + ' .completetd').addClass('hide'); } if (!Async) { //$('#loadingWithBG').hide(); } $('#loadingWithBG').hide(); //gridSortable() resultDataRpad(); var subRow = $('[data-sgid="' + mainRowId + '"]:not(.TrainingTRNotGroup)'); //for (var i = subRow.length; i >= 0; i--) { for (var i = 0; i < subRow.length; i++) { $('[data-sgid="' + mainRowId + '"]:eq(' + i + ')').removeClass('cgSbHide').addClass('sbactive'); if (i == subRow.length - 1) { setTimeout(function () { resultDataRpad(); }, 300); } }; } }); } $(_this).addClass('active'); $(_this).find('td:nth-child(1) .fa, td:visible.forpsCol .fa').removeClass('fa-plus').addClass('fa-minus'); // $(subRow).removeClass('cgSbHide'); var subRow = $('[data-sgid="' + mainRowId + '"]:not(.TrainingTRNotGroup)'); //for (var i = subRow.length; i >= 0; i--) { for (var i = 0; i < subRow.length; i++) { $('[data-sgid="' + mainRowId + '"]:eq(' + i + ')').removeClass('cgSbHide').addClass('sbactive'); if (i == subRow.length - 1) { setTimeout(function () { resultDataRpad(); }, 300); } }; } }); $(document).on('click', '.jscgroupRow .cico', function (e) { e.stopPropagation(); }); $(document).on('change', '.ddlHeaderFilterCountry', function () { var stateCtrl = $('.ddlHeaderFilterState'); $("#loadingWithBG").show(); var _this = this; var id = $(this).val(); if (id == 0) { $('.ddlHeaderFilterState option').hide(); $('.ddlHeaderFilterState option:first').show().prop('selected', true); } else { $('.ddlHeaderFilterState option').hide(); $('.ddlHeaderFilterState option:first').show().prop('selected', true); $('.ddlHeaderFilterState option[value*="-' + id + '-"]').show(); } $("#loadingWithBG").hide(); //$.ajax({ // url: "/getStateList/", // type: 'post', // // dataType: 'json', // async: "false", // data: { CountryId: id }, // success: function (data) { // $(stateCtrl).empty(); // $(stateCtrl).html(data); // $('.ddlHeaderFilterState option:first').text('All Cities'); // $("#loadingWithBG").hide(); // }, // error: function (xhr, status, error) { // $("#loadingWithBG").hide(); // //alert(xhr.responseText); // } //}); }); $(document).on('click', '.jsShowFilter', function () { if ($('.mobThFilter').hasClass('mhide')) { $('.mobThFilter').removeClass('mhide'); } else { $('.mobThFilter').addClass('mhide'); } }) $(document).on('click', '.TGProduct, .CourseProduct', function () { //empty existing Cookie setCookie("ProductBeforeLogin", '', 0); if ($(this).hasClass('TGProduct')) { setCookie("ProductBeforeLogin", 'TG-' + $(this).attr('data-Groupid'), 180); } else { if ($(this).attr("data-subproductid") != undefined && $(this).attr("data-subproductid") != "0") { setCookie("ProductBeforeLogin", 'Course-' + $(this).attr('data-productid') + '/' + $(this).attr('data-subproductid'), 180); } else { setCookie("ProductBeforeLogin", 'Course-' + $(this).attr('data-productid'), 180); } } }) $(document).off('click', '.GroupMoreLocation'); $(document).on('click', '.GroupMoreLocation', function () { var _this = $(this); var GroupId = $(this).attr('data-groupid'); var GroupTitle = $(this).closest('tr.jscgroupRow').find('.groupTitle').find('div').text(); $.ajax({ url: '/Courses/GroupMoreLocation', data: { GroupId: GroupId }, type: 'post', datatype: 'json', success: function (respo) { if (respo.Status) { var table = '
    '; table += '
    ClassIdDateLocationPrice
    ' table += '
    ' table += '' table += '' table += '' for (var i = 0; i < respo.ListOfCoursesLocation.length; i++) { table += ''; //if (!FromScheduleFlag) { table += ''; //} table += ''; //var time = ""; //if (respo.ListOfCoursesLocation[i].Time != "12:00 AM - 12:00 AM") { // time = respo.ListOfCoursesLocation[i].Time; //} var startTime = respo.ListOfCoursesLocation[i].StartDateFullString; var endTime = respo.ListOfCoursesLocation[i].EndDateFullString; if (respo.ListOfCoursesLocation[i].IsOnline) { startTime = ConvertUTCTimeToLocalTime(respo.ListOfCoursesLocation[i].StartDateFullString, true); endTime = ConvertUTCTimeToLocalTime(respo.ListOfCoursesLocation[i].EndDateFullString, true); } //var timeNew = stratTime + " - " + endTime; //table += ''; table += ''; //table += ''; var _address = ''; _address += "" + respo.ListOfCoursesLocation[i].Address1.replace(/[`~!@#$%^&*()_|+\=?;:'"<>\{\}\[\]\\\/]/gi, '') + ""; if (respo.ListOfCoursesLocation[i].Address2 != null && respo.ListOfCoursesLocation[i].Address2 != "") { _address += "" + respo.ListOfCoursesLocation[i].Address2.replace(/[`~!@#$%^&*()_|+\=?;:'"<>\{\}\[\]\\\/]/gi, '') + ""; } var city = respo.ListOfCoursesLocation[i].DisplayCity != "" && respo.ListOfCoursesLocation[i].DisplayCity != null ? respo.ListOfCoursesLocation[i].DisplayCity : respo.ListOfCoursesLocation[i].City; _address += ""; _address += "" + city + ""; _address += respo.ListOfCoursesLocation[i].StateName != null ? ", " + respo.ListOfCoursesLocation[i].StateName + "" : ""; _address += ", " + respo.ListOfCoursesLocation[i].ZipCode + ""; _address += ''; _address += "" + respo.ListOfCoursesLocation[i].CountryName + ""; if (city != "" && respo.ListOfCoursesLocation[i].ZipCode != "") { table += ''; } else { table += ''; } table += ''; table += ''; } table += '
    ClassIdDateLocationPrice
    '; table += ''; table += ''; table += '
    ' + respo.ListOfCoursesLocation[i].ClassId + '
    '; table += '
    '; //table += '
    ' + (cDate != '' ? cDate : stratTime + ' - ' + endTime) + '
    '; //table += '
    '; table += '
    ' + startTime + '-' + endTime + '
    '; table += '
    '; //table += '
    ' + timeNew + '
    '; //table += '
    ' + respo.ListOfCoursesLocation[i].CountryName + '" data-ClassId="' + respo.ListOfCoursesLocation[i].ClassId + '">'; table += '
    ' + city + ', ' + (respo.ListOfCoursesLocation[i].StateName != null ? respo.ListOfCoursesLocation[i].StateName + ', ' : " ") + respo.ListOfCoursesLocation[i].CountryName + '
    '; table += '
    -'; var price = respo.ListOfCoursesLocation[i].IsFree ? "0" : (respo.ListOfCoursesLocation[i].LocalSalePrice != '' && respo.ListOfCoursesLocation[i].SalePriceString != null ? respo.ListOfCoursesLocation[i].LocalSalePrice : respo.ListOfCoursesLocation[i].LocalPrice); table += '-' + (respo.ListOfCoursesLocation[i].IsFree ? "Free" : (respo.ListOfCoursesLocation[i].SalePriceString != '' && respo.ListOfCoursesLocation[i].SalePriceString != null ? ('' + respo.ListOfCoursesLocation[i].PriceString + '' + ' ' + respo.ListOfCoursesLocation[i].SalePriceString) : respo.ListOfCoursesLocation[i].PriceString)) + ''; table += '
    '; function addiCallback() { $('.locationModal').closest('.modal').attr('id', 'moreLocationList').css({ 'overflow': 'hidden' }); $('').prependTo($('.locationModal .modal-footer')); $('.locationModal .modal-footer dflxDiv jcFE aiCenter'); pTooltip(); $('.locationModal .modal-content').addClass('h100p'); jsDateFormatAndTip(); } var cTitle = GroupTitle; var cText = table; var cBConfirm = "btn btn-theme SelectGroupLocation"; var cBConfirmName = "Select"; var cMCLocation = "modal-lg locationModal"; var cAddiCallBack = addiCallback; commonConfirmPopup(cTitle, cText, cBConfirmName, 'Close', cBConfirm, 'btn btn-default', cMCLocation, cFalseCallback, cFalseCallback, cAddiCallBack); //$('#moreLocationList .SelectTrainingLocation').addClass('hide'); $('#moreLocationList .subProductPrice').html(''); } } }); }); $(document).off('click', '.SelectGroupLocation'); $(document).on('click', '.SelectGroupLocation', function () { var SelectedTr = $('#moreLocationList .buySubProduct:checked').closest('tr'); if (SelectedTr.length > 0) { var GroupId = $(SelectedTr).attr('data-groupId'); var SubProductId = $(SelectedTr).attr('data-subproductid'); var location = ($(SelectedTr).find('td.location').text() == "-" ? 'Change Class' : $(SelectedTr).find('td.location').attr('data-location')); var ClassId = $(SelectedTr).find('td.location').attr('data-ClassId'); var Price = $('#moreLocationList .subProductPrice').html(); var CurrentTr = $('tr[data-gid="' + GroupId + '"].jscgroupRow'); $(CurrentTr).find('a.GroupMoreLocation').html(location); $(CurrentTr).find('a.GroupMoreLocation').attr('data-classid', ClassId); $(CurrentTr).find('td.jsPrice').html(Price); $(CurrentTr).find('td.jsPrice').attr('data-price', Price); $(CurrentTr).addClass('LocationChanged'); $(CurrentTr).removeClass('active'); $(CurrentTr).find('td:nth-child(1) .fa, td:visible.forpsCol .fa').removeClass('fa-minus').addClass('fa-plus'); $('tr.TrainingCourse.cgSbRow[data-sgid="' + GroupId + '"]').remove(); $('#moreLocationList').modal('hide'); } }); }); (function ($) { $.fn.has_scrollbar = function () { var divnode = this.get(0); if (divnode.scrollHeight > divnode.clientHeight) return true; } })(jQuery); $(window).resize(function () { respoColF(); modalResponsiveCall(); }); // Raw Grouping function function groupingRawAccordion(eleThis) { $(eleThis).closest('tbody').find('tr.cgRow').removeClass('active').find('td .fa').removeClass('fa-minus').addClass('fa-plus'); $(eleThis).closest('tbody').find('tr.cgSbRow').addClass('cgSbHide'); } function modalResponsiveCall() { var winH = $(window).height(); var tableH = $('.locationModal .flex-columns .fsTable').outerHeight(); var mdlHeaderH = $('.locationModal .modal-header').outerHeight(); var mdlFooterH = $('.locationModal .modal-footer').outerHeight(); var mdlflxHeaderH = $('.locationModal .flexHeader').outerHeight(); var mdlH = tableH + mdlHeaderH + mdlFooterH + mdlflxHeaderH + 40 var mdlB = mdlHeaderH + mdlFooterH; $('.locationModal .modal-body').css({ 'height': 'calc(100% - ' + mdlB + 'px)' }); if (winH < (mdlH + 60)) { $('.locationModal, .locationModal .modal-content').css({ 'height': '100%' }); } else { $('.locationModal').removeAttr('style'); $('.locationModal .modal-content').outerHeight(mdlH); } if ($('#moreLocationList .flex-flexible').is(':visible')) { if ($('#moreLocationList .flex-flexible:visible').has_scrollbar()) { $('#moreLocationList .flexHeader table').css({ 'padding-right': '17px' }); } else { $('#moreLocationList .flexHeader table').removeAttr('style'); } } $('.locationModal .flex-columns').removeAttr('style'); } function respoColF() { //debugger; if ($('.flexNice').length > 0) { //var TrainingListcontainerdiv = $('.vidLibrary').hasClass('TrainingModal') ? '.TrainingModal':'.ListofTraining'; var contAreaW = $('.cRItem').width(); var dCBaseW = $('.dCBase').width() - 30; // console.log(dCBaseW); if (contAreaW < 1320) { var respoColW = $('#divContentAvailableCourses').find('#tblHeaderAvailableCourses').width(); $('#divContentAvailableCourses').width(dCBaseW).addClass('dtOVX'); $('#divContentAvailableCourses').children('.flexdiv').width(respoColW); // $('.respoCol').width(210); // $('.NrespoCol').width(210); //if ($('.flexNice').is(':visible')) { // if ($('.flexNice:visible').has_scrollbar()) { // $('#divContentAvailableCourses .flexHeader table').css({ 'padding-right': '15px' }); // } // else { // $('#divContentAvailableCourses .flexHeader table').removeAttr('style'); // } //} } else { $('.respoCol').removeAttr('style'); $('.NrespoCol').removeAttr('style'); $('#divContentAvailableCourses').removeAttr('style').removeClass('dtOVX'); $('#divContentAvailableCourses').children('.flexdiv').removeAttr('style'); //if ($('.flexNice').is(':visible')) { // if ($('.flexNice:visible').has_scrollbar()) { // $('#divContentAvailableCourses .flexHeader table').css({ 'padding-right': '15px' }); // } // else { // $('#divContentAvailableCourses .flexHeader table').removeAttr('style'); // } //} } } } function BindLoadAvailableCourses(loadMoreBTN, loadMore, CatId, CategoryType, ProdId, isBindFromScroll) { //debugger; var SelectedView = $('[name="jsshView"].SelectedView').val(); var Search = { value: '', regex: false, } $('.flexNice').off('scroll'); var Columns = new Array(); if ($('#tblHeaderAvailableCourses th').length > 0) { Columns = new Array(); $('#tblHeaderAvailableCourses th').each(function () { var _this = $(this); if ($(_this).attr('data-field') != undefined) { Columns.push({ data: $(_this).attr('data-field'), name: $(_this).attr('data-field'), searchable: false, orderable: true, search: Search, IsOrdered: false, }) } }); Order[0].column = 2; } else { Columns = [{ data: 'Title', name: 'Title', searchable: false, orderable: true, search: Search, IsOrdered: false, }]; Order = [{ column: 0, dir: 'asc' }]; } //console.log(Order, Columns) if (isFilter) { $('.flexNice').scrollTop(0); } if (IsOnlyVideoScript) { LoadCourseFilterRequest.push({ FieldName: 'CategoryId', ID: 612, Text: 'Video', ConditionalParameters: 0 }); } if (parseInt(PurchaseId) > 0) { LoadCourseFilterRequest.push({ FieldName: 'Id', ID: 0, Text: parseInt(PurchaseId), ConditionalParameters: 1 }); } else if (parseInt(CustomerRoleId) > 0) { LoadCourseFilterRequest.push({ FieldName: 'CustomerRoleId', ID: 0, Text: parseInt(CustomerRoleId), ConditionalParameters: 1 }); } var FromSchedule = 0; var length = 0; var start = 0; SelectedView = SelectedView != undefined ? SelectedView : "listview"; var Url = "/Aligner/LoadAvailableCourses"; if ($(TrainingListcontainerdiv + ' #dtAvailableCourses tbody tr.TrainingTRNotGroup').length > 0 && !isFilter) { length = 20; } else { length = 30; } if (isFilter) { start = 0; } else { start = $(TrainingListcontainerdiv + ' #dtAvailableCourses tbody tr.TrainingTRNotGroup').length; } if (!IsAdmin) { var ProductBeforeLogin = getCookie("ProductBeforeLogin"); if (ProductBeforeLogin != undefined && ProductBeforeLogin != "") { var Product = ProductBeforeLogin; var ProductType = Product.split('-')[0]; var Id = Product.split('-')[1]; if (ProductType == "Course") { var ProuctID = Id; if (ProuctID != undefined && ProuctID != "" && ProuctID.indexOf('/') > -1) { var data = Id.split('/'); var ProuctID = data[0]; var SubProductId = data[1]; //use filter to select Location, selected by User before Login LoadCourseFilterRequest.push({ FieldName: "OrderBySubProduct", ID: ProuctID,//ParentProductID Text: "", ConditionalParameters: SubProductId //SubProductId }) } } } } $.ajax({ url: Url, type: 'post', beforeSend: function () { $('#loadingWithBG').show(); }, data: { //draw: 1, columns: Columns, order: Order, searchable: true, length: (length), start: (start), search: Search, courses: { paginationRequest: { Take: paginationRequestTake }, SearchText: $(TrainingListcontainerdiv + ' #txtCourseSearchText').val(), LoadMore: loadMore, CategoryId: CatId, CategoryType: CategoryType, NotInIds: ProdId, IsPurchased: $(loadMoreBTN).attr('data-ispurchased'), FilterString: JSON.stringify(LoadCourseFilterRequest), IsTrainingModal: IsTrainingModalScript, LatitudeString: Lat, LongitudeString: Long //IsPublish: true }, SelectedView: SelectedView }, success: function (respo) { // debugger; if (SelectedView == "listview" || SelectedView == undefined) { if (isFilter) { if (isBindFromScroll) { $($(respo).find('tbody').html()).insertAfter($('#dtAvailableCourses tbody tr:last')); } else { $(TrainingListcontainerdiv + ' #dtAvailableCourses tbody').html($(respo).find('tbody').html()); var filterText = $('th[data-field="Title"]').find('input[type="text"]').val(); var ConditionalParameter = $('th[data-field="Title"]').find('.jsConditionalParameters :selected').val(); if (filterText != "" && ConditionalParameter != "2") { $.each($(TrainingListcontainerdiv + ' #dtAvailableCourses tbody tr'), function () { //debugger; if ($(this).hasClass('TrainingTRNotGroup')) { var strongText = $(this).find('td[data-abtext="Seminar"]').find('.addToCartTitle strong').text(); var emText = $(this).find('td[data-abtext="Seminar"]').find('.addToCartTitle em').text(); if (strongText != "" && strongText != undefined && strongText.toLowerCase().indexOf(filterText.toLowerCase()) != -1) { var StartingIndex = strongText.toLowerCase().indexOf(filterText.toLowerCase()); var data = strongText.substr(0, StartingIndex) + '' + strongText.substr(StartingIndex, filterText.length) + '' + strongText.substr(StartingIndex + filterText.length, strongText.length); $(this).find('td[data-abtext="Seminar"]').find('.addToCartTitle strong').html(data); } if (emText != "" && emText != undefined && emText.toLowerCase().indexOf(filterText.toLowerCase()) != -1) { var StartingIndex = emText.toLowerCase().indexOf(filterText.toLowerCase()); var data = emText.substr(0, StartingIndex) + '' + emText.substr(StartingIndex, filterText.length) + '' + emText.substr(StartingIndex + filterText.length, emText.length); $(this).find('td[data-abtext="Seminar"]').find('.addToCartTitle em').html(data); } } else { var divText = $(this).find('td[data-abtext="Seminar"]').find('div').text(); if (divText != "" && divText != undefined && divText.toLowerCase().indexOf(filterText.toLowerCase()) != -1) { var StartingIndex = divText.toLowerCase().indexOf(filterText.toLowerCase()); var data = divText.substr(0, StartingIndex) + '' + divText.substr(StartingIndex, filterText.length) + '' + divText.substr(StartingIndex + filterText.length, divText.length); $(this).find('td[data-abtext="Seminar"]').find('div').html('' + data + ''); } } }) } } } else { if (isBindFromScroll) { $($(respo).find('tbody').html()).insertAfter($('#dtAvailableCourses tbody tr:last')); } else { $('#pac-input').insertAfter($('.jsNLabel')); $('.browserHint').addClass('hide'); $('.ListofTraining').removeClass('hide'); $('#divresult').html(respo); locationGAddress() $('.ddlHeaderFilterState option').hide(); $('.ddlHeaderFilterState option:first').show().prop('selected', true); $('#tblHeaderAvailableCourses th[data-field="Title"]').html($('#tblHeaderAvailableCourses th[data-field="Title"]').html().replace("Title", "Seminar")); } } var data = $('#divresult').html(data); //$('tbody a').attr('href', '#'); //$('tbody a').removeAttr('target'); $('.sorting_disabled').find('.sortASC').parent().remove(); $('.sorting_disabled').find('.sortDESC').parent().remove(); setTimeout(function () { TotalRow = TotalCourse; filterRPosSetting(); // respoColF(); $(window).resize(); $('.flexNice').scroll(function () { if ($(TrainingListcontainerdiv + ' #dtAvailableCourses tbody tr').length < TotalRow) { if ($(this).scrollTop() + $(this).innerHeight() >= $(this)[0].scrollHeight) { BindLoadAvailableCourses(loadMoreBTN, loadMore, CatId, CategoryType, ProdId, true); //alert('end reached'); } } }); $('.removeMe').remove(); if (Columns.length == 1 && Order[0].column == 0) { $(TrainingListcontainerdiv + ' #tblHeaderAvailableCourses th[data-field="Title"]').addClass('sorting_asc').addClass('manual'); } else if (Columns.length == 1 && Order[0].column == 0 && $(TrainingListcontainerdiv + ' #tblHeaderAvailableCourses th[data-field="Title"]').hasClass('manual')) { $(TrainingListcontainerdiv + ' #tblHeaderAvailableCourses th[data-field="Title"]').removeClass('sorting_asc').removeClass('manual'); } }, 500); $('th[data-filterformat="Time"] .txtFilter').each(function () { if (typeof ($.timepicker) != 'undefined') { $(this).timepicker({ showButtonPanel: true, timeOnlyTitle: 'Select duration', timeFormat: 'HH:mm:ss', closeOnFormclick: true, inputReadOnly: true, beforeShow: function () { setTimeout(function () { $('.ui-datepicker-buttonpane').hide(); $('').insertAfter($('.ui-datepicker-title')); }, 10) } }); } }); // Initialize Date range picker Start if (typeof ($('input[name="daterange"]').data('daterangepicker')) == 'undefined') { setTimeout(function () { InitDateRangePicker(); },1000); } // Initialize Date range picker End $('th[data-filterformat="Year"] .txtFilter').each(function () { $(this).datepicker({ autoclose: true, //format: "yyyy", //viewMode: "years", //minViewMode: "years" }); }); $('th[data-filterformat="Decimal"] .txtFilter').each(function () { $(this).keypress(function (event) { var $this = $(this); if ((event.which != 46 || $this.val().indexOf('.') != -1) && ((event.which < 48 || event.which > 57) && (event.which != 0 && event.which != 8))) { event.preventDefault(); } var text = $(this).val(); if ((event.which == 46) && (text.indexOf('.') == -1)) { setTimeout(function () { if ($this.val().substring($this.val().indexOf('.')).length > 5) { $this.val($this.val().substring(0, $this.val().indexOf('.') + 5)); } }, 1); } if ((text.indexOf('.') != -1) && (text.substring(text.indexOf('.')).length > 4) && (event.which != 0 && event.which != 8) && ($(this)[0].selectionStart >= text.length - 4)) { event.preventDefault(); } }); $(this).bind("cut copy paste", function (e) { e.preventDefault(); }); $(this).closest('th').find('.jsConditionalParameters option[value="0"]').remove(); }); $('th[data-filterformat="Number"] .txtFilter').each(function () { $(this).keypress(function (e) { if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) { return false; } }); $(this).bind("cut copy paste", function (e) { e.preventDefault(); }); $(this).closest('th').find('.jsConditionalParameters option[value="0"]').remove(); }); $('th[data-maxlength]').each(function () { $(this).find('.txtFilter').attr('maxlength', $(this).attr('data-maxlength')); }); } $('#loadingWithBG').show(); if (LoadCourseFilterRequest.length >= 1) { Async = false; $("#dtAvailableCourses tr.jscgroupRow").each(function () { $(this).trigger('click'); }) } if (isFilter && LoadCourseFilterRequest.length >= 1) { isFilter = false; } isTab = isTab ? (LoadCourseFilterRequest.length > 2 ? false : true) : false; $('#loadingWithBG').hide(); Async = true; $('.contryTip, .tIcon, .jsPrice a, .jsActionTooltip').tooltip({ track: true, content: function () { return $(this).prop('title'); } }); $('.textToolhint').tooltip({ track: true, tooltipClass: "aligner_tooltip", content: function () { return $(this).prop('title'); } }); //debugger; if (!IsAdmin) { var ProductBeforeLogin = getCookie("ProductBeforeLogin"); if (ProductBeforeLogin != undefined && ProductBeforeLogin != "") { //debugger; var Product = ProductBeforeLogin; var ProductType = Product.split('-')[0]; var Id = Product.split('-')[1]; if (ProductType == "TG") { $('.GrouppurchaseBtn[data-groupid="' + Id + '"]').trigger('click'); } else { $('.purchaseCourse[data-productid="' + ProuctID + '"]').trigger('click'); } setCookie('ProductBeforeLogin', '', 0) } } jsDateFormatAndTip() }, error: function () { }, complete: function () { } }) } function LoadFilter(tablID, callBack) { //debugger; // below lines commented as open patient modal not works. // $(document).on('click', '#' + tablID + ' .btnFilter').off('click'); // $(document).on('click', '#' + tablID + ' .btnClearfilter').off('click'); $(document).off('click', 'body'); $(document).on('click', 'body', function (e) { //debugger; if ($(e.target).closest('.filterDrop .dropdown-menu').length || $(e.target).hasClass('select2-search__field')) { e.preventDefault(); return false; } var target = e.currentTarget; var inside = $(".btnOpenFilter"); if (target != inside && !$(e.target).hasClass('ui-datepicker-close') && !$(e.target).hasClass('daterangepicker') && !$(e.target).parents('.daterangepicker').hasClass('daterangepicker')) { $('ul.filter_box').addClass('hide'); } }); btnFilter_Click(tablID, callBack); btnClearfilter_Click(tablID, callBack); } function btnFilter_Click(tablID, callback) { $(document).on('click', tablID + ' .btnFilter', function () { //debugger; ResetDataTableFilterRequest(tablID); $(this).closest('th').find('.btnOpenFilter').next('ul.filter_box').addClass('hide'); //$(this).closest('th').find('.btnOpenFilter').addClass('ActiveFilter'); if ($(this).closest('th').find('ul li ul').find('input[type="checkbox"]:checked').length > 0 || $(this).closest('th').find('ul li ul').find('input[type="radio"]:checked').length > 0 || $.trim($(this).closest('th').find('.txtFilter').val()) != '' || $.trim($(this).closest('th').find('.input-daterange input[type="text"]').val()) != '' || ($.trim($(this).closest('th').find('select').val()) != '0' && $.trim($(this).closest('th').find('select').val()) != '') || $.trim($(this).closest('th').find('[name="daterange"]').val()) != '') { $(this).closest('th').find('.btnOpenFilter').addClass('ActiveFilter'); $(this).closest('th').addClass('ActiveFilterth'); } else { $(this).closest('th').find('.btnOpenFilter').removeClass('ActiveFilter'); $(this).closest('th').removeClass('ActiveFilterth'); } isFilter = true; callback(); }); } function btnClearfilter_Click(tablID, callback) { $(document).on('click', tablID + ' .btnClearfilter', function () { LoadCourseFilterRequest = new Array(); $(this).closest('th').find('ul li ul').find('input[type="checkbox"]').each(function () { if ($(this).is(':checked')) { $(this).trigger('click'); } }); //$('#' + tablID + ' th ul li ul') $(tablID).find('thead tr th ul li ul').find('input[type="checkbox"]').each(function () { if ($(this).is(':checked')) { LoadCourseFilterRequest.push({ FieldName: $(this).closest('th').attr('data-field'), ID: $(this).val(), Text: $(this).attr('data-text'), ConditionalParameters: $(this).closest('.jsFilterMain').find('.jsConditionalParameters').val() }) } $(this).closest('li').removeClass('hide'); }); $(this).closest('th').find('ul li ul').find('input[type="radio"]').each(function () { if ($(this).is(':checked')) { //$(this).trigger('click'); $(this).prop('checked', false); } }); $(tablID).find('thead tr th ul li ul').find('input[type="radio"]:checked').each(function () { LoadCourseFilterRequest.push({ FieldName: $(this).closest('th').attr('data-field'), ID: $(this).val(), Text: $(this).attr('data-text'), ConditionalParameters: 0 }) }); //callback(); $(this).closest('th').find('.txtFilter').val(''); $(this).closest('th').find('.jsConditionalParameters').val(0); $('th[data-filterformat="Decimal"] .txtFilter, th[data-filterformat="Number"] .txtFilter').each(function () { $(this).closest('th').find('.jsConditionalParameters').val(1); }); $(this).closest('th').find('.btnOpenFilter').next('ul.filter_box').addClass('hide'); //$('#' + tablID + ' th') $(tablID).find('thead tr th').each(function () { if ($(this).find('ul li ul input[type="checkbox"]:checked').length == 0) { if ($(this).find('.txtFilter').val() != '' && $(this).find('.txtFilter').val() != null) { LoadCourseFilterRequest.push({ FieldName: $(this).attr('data-field'), ID: 0, Text: $(this).find('.txtFilter').val(), ConditionalParameters: $(this).find('.jsFilterMain .jsConditionalParameters').val() }) } } }); $(this).closest('th').find('.ddlFilter').val($(this).closest('th').find('.ddlFilter option').first().val()); var selectElement = $(this).closest('th').find('select'); selectElement.find('option:eq(0)').prop('selected', true); if ($('.ddlHeaderFilterCountry :selected').val() != "0") { LoadCourseFilterRequest.push({ FieldName: "Location", ID: $('.ddlHeaderFilterCountry :selected').val(), Text: $('.ddlHeaderFilterCountry :selected').text(), ConditionalParameters: $('.ddlHeaderFilterState :selected').val() != 0 && $('.ddlHeaderFilterState :selected').val() != "" ? $('.ddlHeaderFilterState :selected').val().split('-')[0] : 0 }) } if ($(this).closest('th[data-field="SeminarDate"]').length > 0) { setTimeout(function () { InitDateRangePicker(); }, 1000); } else { if ($("#tblHeaderAvailableCourses .filter_box:not(.hide)").closest('th[data-field="SeminarDate"]').length > 0 || $('#tblHeaderAvailableCourses th.ActiveFilterth[data-field="SeminarDate"]').length > 0) { var dateControl; if ($("#tblHeaderAvailableCourses .filter_box:not(.hide)").closest('th[data-field="SeminarDate"]').length > 0) dateControl = $("#tblHeaderAvailableCourses .filter_box:not(.hide)").closest('th[data-field="SeminarDate"]').find('[name="daterange"]').val(); else dateControl = $('#tblHeaderAvailableCourses th.ActiveFilterth[data-field="SeminarDate"]').find('[name="daterange"]').val(); LoadCourseFilterRequest.push({ FieldName: "SeminarDate", ID: 0, Text: dateControl, ConditionalParameters: $('th[data-field="SeminarDate"]').find('.jsFilterMain .jsConditionalParameters').val() }) } } $(this).closest('th').find('.btnOpenFilter').removeClass('ActiveFilter'); $(this).closest('th').removeClass('ActiveFilterth'); LoadCourseFilterRequest.push({ FieldName: 'CategoryType', ID: $('input[type="radio"][name="trainingFilter"]:checked').val(), ConditionalParameters: 1 }); isFilter = true; callback(); //$('#' + tablID).DataTable().order([$(this).closest('th').index(), 'asc']).draw(); }); } function InitDateRangePicker() { setTimeout(function () { $('input[name="daterange"]').daterangepicker({ "ranges": { //'Today': [moment(), moment()], //'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')], //'Last 7 Days': [moment().subtract(6, 'days'), moment()], //'Last 30 Days': [moment().subtract(29, 'days'), moment()], //'This Month': [moment().startOf('month'), moment().endOf('month')], //'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')] 'This Week': [moment().startOf('week').add(1, 'days'), moment().endOf('week').add(1, 'days')], 'This Month': [moment().startOf('month'), moment().endOf('month')], 'Next 2 Months': [moment().add(1, 'month').startOf('month'), moment().add(2, 'month').endOf('month')], 'Next 3 Months': [moment().add(1, 'month').startOf('month'), moment().add(3, 'month').endOf('month')], 'Next 6 Months': [moment().add(1, 'month').startOf('month'), moment().add(6, 'month').endOf('month')], 'This Year': [moment().startOf('year'), moment().endOf('year')] // 'Custom Range': [moment().startOf(1, 'year'), moment().endOf(1, 'year')] }, "linkedCalendars": false, "alwaysShowCalendars": true, "startDate": moment(), "endDate": moment().add(1, 'month').endOf('month'), "opens": "left", 'applyClass': 'btn-theme', "autoUpdateInput": true }, function (start, end, label) { // debugger; // console.log(this); // if(this.chosenLabel == 'Next 2 Months'){ // $($($(this.container)[0]).children()[2]).find('.prev, .next').removeAttr('class').html(''); // $($($(this.container)[0]).children()[1]).find('.next, .prev').removeAttr('class').html(''); // } // else if(this.chosenLabel == 'Next 3 Months'){ // $($($(this.container)[0]).children()[2]).find('.next').removeAttr('class').html(''); // $($($(this.container)[0]).children()[1]).find('.prev').removeAttr('class').html(''); // } // else if(this.chosenLabel == 'Next 6 Months'){ // $($($(this.container)[0]).children()[2]).find('.next').removeAttr('class').html(''); // $($($(this.container)[0]).children()[1]).find('.prev').removeAttr('class').html(''); // } // else if(this.chosenLabel == 'This Year'){ // $($($(this.container)[0]).children()[2]).find('.next').removeAttr('class').html(''); // $($($(this.container)[0]).children()[1]).find('.prev').removeAttr('class').html(''); // } }); $('input[name="daterange"]').on('show.daterangepicker', function (ev, picker) { // if ($('.ranges').length > 0) { // $('.ranges').prependTo($('.daterangepicker')); // } // if ((new Date($('input[name="daterange"]').val().split('-')[0]).getMonth() + 1) == new Date($('input[name="daterange"]').val().split('-')[1]).getMonth() // || ((new Date($('input[name="daterange"]').val().split('-')[0]).getMonth() + 1) == 12 && new Date($('input[name="daterange"]').val().split('-')[1]).getMonth() == 0)) { // $($($(picker.container)[0]).children()[2]).find('.prev').removeAttr('class').html(''); // $($($(picker.container)[0]).children()[1]).find('.next').removeAttr('class').html(''); // } // if($($(picker.container[0]).children()[0]).children('ul').find('li.active').text() == 'Next 2 Months'){ // $($($(picker.container)[0]).children()[2]).find('.prev, .next').removeAttr('class').html(''); // $($($(picker.container)[0]).children()[1]).find('.next, .prev').removeAttr('class').html(''); // } // else if($($(picker.container[0]).children()[0]).children('ul').find('li.active').text() == 'Next 3 Months'){ // $($($(picker.container)[0]).children()[2]).find('.next').removeAttr('class').html(''); // $($($(picker.container)[0]).children()[1]).find('.prev').removeAttr('class').html(''); // } // else if($($(picker.container[0]).children()[0]).children('ul').find('li.active').text() == 'Next 6 Months'){ // $($($(picker.container)[0]).children()[2]).find('.next').removeAttr('class').html(''); // $($($(picker.container)[0]).children()[1]).find('.prev').removeAttr('class').html(''); // } // else if($($(picker.container[0]).children()[0]).children('ul').find('li.active').text() == 'This Year'){ // $($($(picker.container)[0]).children()[2]).find('.next').removeAttr('class').html(''); // $($($(picker.container)[0]).children()[1]).find('.prev').removeAttr('class').html(''); // } }); $('input[name="daterange"]').on('apply.daterangepicker', function (ev, picker) { // BindData(); // console.log(picker.startDate.format('YYYY-MM-DD')); // console.log(picker.endDate.format('YYYY-MM-DD')); }); $('input[name="daterange"]').on('cancel.daterangepicker', function (ev, picker) { $('input[name="daterange"]').data('daterangepicker').setStartDate(moment()); $('input[name="daterange"]').data('daterangepicker').setEndDate(moment().add(1, 'month').endOf('month')); // BindData(); }); }, 1000); } function ResetDataTableFilterRequest(tablID, setDataNull) { if (setDataNull == undefined) { LoadCourseFilterRequest = new Array(); //$('#' + tablID + ' th ul li ul') $(tablID).find('thead tr th ul li ul').find('input[type="checkbox"]:checked').each(function () { LoadCourseFilterRequest.push({ FieldName: $(this).closest('th').attr('data-field'), ID: $(this).val(), Text: $(this).attr('data-text'), ConditionalParameters: $(this).closest('.jsFilterMain').find('.jsConditionalParameters').val() }) //if (!$(this).closest('th').find('.btnOpenFilter').hasClass('ActiveFilter')) { // $(this).closest('th').find('.btnOpenFilter').addClass('ActiveFilter'); //} else { // $(this).closest('th').find('.btnOpenFilter').removeClass('ActiveFilter'); //} }); $(tablID).find('thead tr th ul li ul').find('input[type="radio"]:checked').each(function () { LoadCourseFilterRequest.push({ FieldName: $(this).closest('th').attr('data-field'), ID: $(this).val(), Text: $(this).attr('data-text'), ConditionalParameters: 0 }) }); //$('#' + tablID + ' th') $(tablID).find('thead tr th').each(function () { if ($(this).find('ul li ul input[type="checkbox"]:checked').length == 0) { if ($(this).find('.txtFilter').val() != '' && $(this).find('.txtFilter').val() != null) { LoadCourseFilterRequest.push({ FieldName: $(this).attr('data-field'), ID: 0, Text: (IsDecimalField($(this).closest('th')) && $.trim($(this).find('.txtFilter').val()) == '.' ? '0.00' : $(this).find('.txtFilter').val()), ConditionalParameters: $(this).find('.jsFilterMain .jsConditionalParameters').val() }) //if (!$(this).closest('th').find('.btnOpenFilter').hasClass('ActiveFilter')) { // $(this).closest('th').find('.btnOpenFilter').addClass('ActiveFilter'); //} else if ($.trim($(this).find('.txtFilter').val()) == '') { // $(this).closest('th').find('.btnOpenFilter').removeClass('ActiveFilter'); //} } } }); if ($("#tblHeaderAvailableCourses .filter_box:not(.hide)").closest('th[data-field="SeminarDate"]').length > 0 || $('#tblHeaderAvailableCourses th.ActiveFilterth[data-field="SeminarDate"]').length > 0) { var dateControl; if ($("#tblHeaderAvailableCourses .filter_box:not(.hide)").closest('th[data-field="SeminarDate"]').length > 0) dateControl = $("#tblHeaderAvailableCourses .filter_box:not(.hide)").closest('th[data-field="SeminarDate"]').find('[name="daterange"]').val(); else dateControl = $('#tblHeaderAvailableCourses th.ActiveFilterth[data-field="SeminarDate"]').find('[name="daterange"]').val(); LoadCourseFilterRequest.push({ FieldName: "SeminarDate", ID: 0, Text: dateControl, ConditionalParameters: $('th[data-field="SeminarDate"]').find('.jsFilterMain .jsConditionalParameters').val() }) } if ($('.ddlHeaderFilterCountry :selected').val() != "0") { LoadCourseFilterRequest.push({ FieldName: "Location", ID: $('.ddlHeaderFilterCountry :selected').val(), Text: $('.ddlHeaderFilterCountry :selected').text(), ConditionalParameters: $('.ddlHeaderFilterState :selected').val() != 0 && $('.ddlHeaderFilterState :selected').val() != "" ? $('.ddlHeaderFilterState :selected').val().split('-')[0] : 0 }) } //$('#' + tablID + ' th') $(tablID).find('thead tr th').each(function () { if ($(this).find('.ddlFilter').val() != '' && $(this).find('.ddlFilter').val() != null && $(this).find('.ddlFilter option:selected').text() != 'All') { LoadCourseFilterRequest.push({ FieldName: $(this).attr('data-field'), ID: parseInt($(this).find('.ddlFilter').val()), Text: $(this).find('.ddlFilter').val(), ConditionalParameters: $(this).find('.jsFilterMain .jsConditionalParameters').val() }) //if (!$(this).closest('th').find('.btnOpenFilter').hasClass('ActiveFilter')) { // $(this).closest('th').find('.btnOpenFilter').addClass('ActiveFilter'); //} else if ($.trim($(this).find('.ddlFilter').val()) == '' || parseInt($(this).find('.ddlFilter').val())==0) { // $(this).closest('th').find('.btnOpenFilter').removeClass('ActiveFilter'); //} } }); LoadCourseFilterRequest.push({ FieldName: 'CategoryType', ID: $('input[type="radio"][name="trainingFilter"]:checked').val() }); } else if (setDataNull) { LoadCourseFilterRequest = new Array(); } } function IsDecimalField(th) { return $(th).attr('data-filterformat') == 'Decimal'; } function GenerateNewPurchasedTR(currentTr) { //debugger; if (FreeCourseList != null && FreeCourseList.length > 0) { $('#loadingWithBG').show(); for (var i = 0; i < FreeCourseList.length; i++) { $.ajax({ url: '/Courses/AddCourseInAccess', type: 'post', async: false, data: { productId: parseInt(FreeCourseList[i].productId), subProductId: FreeCourseList[i].subproductid }, success: function (respo) { if (respo) { //console.log(i, FreeCourseList, FreeCourseList.length); if (i == (FreeCourseList.length - 1)) { FreeCourseList = new Array(); if ($('#mdlCoursePreview').is(':visible')) { $('#mdlCoursePreview').modal('hide'); } if (GetPurchaseId > 0) { window.location.href = '/Courses/courses'; } else { $('input[type="radio"][name="trainingFilter"][value="610"]').prop('checked', true).change(); } } } } }) } } else { if ($('#mdlCoursePreview').is(':visible')) { $('#mdlCoursePreview').modal('hide'); } if (GetPurchaseId > 0) { window.location.href = '/Courses/courses'; } else { $('input[type="radio"][name="trainingFilter"][value="610"]').prop('checked', true).change(); if (FromScheduleFlag) { window.location.reload(); } } } return; var _Ids = new Array(); if ($(currentTr).find('.jsActiveProdToAddCart').attr('data-courseprerequisiteids') != undefined && $(currentTr).find('.jsActiveProdToAddCart').attr('data-courseprerequisiteids') != '') { _Ids = $(currentTr).find('.jsActiveProdToAddCart').attr('data-courseprerequisiteids').split(','); } _Ids.push($(currentTr).attr('data-id')); for (i = 0; i < _Ids.length; i++) { currentTr = $('#dtAvailableCourses tr[data-id="' + _Ids[i] + '"]'); var currentTrClone = $(currentTr).clone(); var MyTrainingTr = $(currentTr); // $('#dtAvailableCourses tr.jsRowData[data-catid="' + MyPurchaseId + '"][data-subcatid="' + $(currentTr).attr('data-subcatid') + '"]:last'); if ($(MyTrainingTr).length == 0) { MyTrainingTr = $('#dtAvailableCourses tr.sbgroup[data-catid="' + MyPurchaseId + '"][data-subcatid="' + $(currentTr).attr('data-subcatid') + '"]'); } $(currentTrClone).find('td.jsCourseTitle').html('' + $(currentTrClone).find('td.jsCourseTitle').html() + ''); $(currentTrClone).find('td:last').html('') $(currentTrClone).attr('data-catid', MyPurchaseId); $(currentTrClone).find('td.jsPrice').html('Bought'); //console.log($(currentTr).prevAll('tr:not(.hide):first'),$(currentTr).next('tr:not(.hide)'),$(currentTr).next('tr:not(.hide)').find('.jsLoadMoreAvailableCourses')) if ($(currentTr).prevAll('tr:not(.hide):first').hasClass('sbgroup') && $(currentTr).next('tr:not(.hide)').hasClass('jsLoadMoreTR')) { $(currentTr).next('tr:not(.hide)').find('.jsLoadMoreAvailableCourses').trigger('click'); } else if (($(currentTr).prevAll('tr:not(.hide):first').hasClass('sbgroup') || $(currentTr).prevAll('tr:not(.hide):first').hasClass('group')) && ($(currentTr).nextAll('tr:not(.hide):first').length == 0 || $(currentTr).nextAll('tr:not(.hide):first').hasClass('sbgroup') || $(currentTr).nextAll('tr:not(.hide):first').hasClass('group'))) { if ($(currentTr).prevAll('tr:not(.hide):first').hasClass('sbgroup')) { $(currentTr).prevAll('tr:not(.hide).sbgroup:first').addClass('hide'); } else if ($(currentTr).prevAll('tr:not(.hide):first').hasClass('group')) { $(currentTr).prevAll('tr:not(.hide).group:first').addClass('hide'); } if ($(currentTr).prevAll('tr:not(.hide):first').hasClass('group') && ($(currentTr).nextAll('tr:not(.hide):first').length == 0 || $(currentTr).nextAll('tr:not(.hide):first').hasClass('group'))) { $(currentTr).prevAll('tr:not(.hide).group:first').addClass('hide'); } } if (moreLocationTR != null && $(moreLocationTR).attr('data-productid') == _Ids[i]) { $(currentTrClone).find('td.authorname').html($(moreLocationTR).find('td.instructor').html()); $(currentTrClone).find('td.jsYear').html($(moreLocationTR).find('td.startDate').html()); $(currentTrClone).find('td.language').html($(moreLocationTR).find('td.language').html()); $(currentTrClone).find('td.location').html($(moreLocationTR).find('td.location').attr('data-location')); } $(currentTrClone).insertAfter($(MyTrainingTr)); $(MyTrainingTr).removeClass('hide'); $(MyTrainingTr).prevAll('tr.group:first').removeClass('hide'); $(currentTr).addClass('hide'); } $('.contryTip').tooltip({ track: true, content: function () { return $(this).prop('title'); } }); $('.jsActionTooltip').tooltip({ track: true, content: function () { return $(this).prop('title'); } }); } function AddAdditionalCourseInOrderItem(OrderId) { //debugger; if (FreeCourseList != null && FreeCourseList.length > 0) { $('#loadingWithBG').show(); for (var i = 0; i < FreeCourseList.length; i++) { $.ajax({ url: '/Courses/AddAdditionalCourseInOrderItem', type: 'post', async: false, data: { productId: parseInt(FreeCourseList[i].productId), OrderId: OrderId, subProductId: FreeCourseList[i].subproductid }, success: function (respo) { if (respo) { console.log(FreeCourseList[i].productId + ": Added"); } } }) } $('#loadingWithBG').hide(); } } function DeleteCourses(id) { $.confirm({ text: "Are you sure you want to delete this course?", title: "Confirmation required", confirm: function (button) { $.ajax({ url: '/CoursesLibrary/GetPreRequisitedCourses', data: { productId: id }, success: function (respo) { if (respo.Status) { if (respo.ListOfCourses != null && respo.ListOfCourses.length > 0) { var removePreRequisitedIds = new Array(); var table = 'Removing this course will prerequisite from following course(s)'; for (var i = 0; i < respo.ListOfCourses.length; i++) { table += ''; removePreRequisitedIds.push(respo.ListOfCourses[i].Id); } table += '
    Course
    ' + respo.ListOfCourses[i].Title + '
    '; setTimeout(function () { $.confirm({ text: table, title: 'Confirmation', confirm: function () { $.ajax({ url: '/CoursesLibrary/DeleteCourses', type: 'post', data: { Id: id, removePrerequisiteFromIds: removePreRequisitedIds.toString() }, success: function (respos) { if (respos.status) { window.location.reload(); //BindLoadAvailableCourses(); } } }); }, cancel: function () { }, confirmButton: 'Ok', cancelButton: 'Cancel', confirmButtonClass: 'btn-theme', cancelButtonClass: 'btn-default', dialogClass: 'modal-dialog modal-md' }) }, 500); } else { $.ajax({ url: '/CoursesLibrary/DeleteCourses', type: 'post', data: { Id: id }, success: function (respos) { if (respos.status) { window.location.reload(); //BindLoadAvailableCourses(); } } }) } } } }) }, cancel: function (button) { // nothing to do }, confirmButton: "Yes", cancelButton: "No", post: true, confirmButtonClass: "btn-danger", cancelButtonClass: "btn-default", dialogClass: "modal-dialog modal-sm" }); } function AddRemoveInSmilestreamTraining(id, isSmilestreamTraining) { if (IsAdmin) { $.ajax({ url: '/CoursesLibrary/AddRemoveInSmilestreamTraining', type: 'post', data: { Id: id, IsSmilestreamTraining: isSmilestreamTraining }, success: function (respo) { if (respo.status) { $.confirm({ text: (isSmilestreamTraining ? "This course has been added successfully in smilestream training." : "This course has been removed successfully from smilestream training."), title: "Success", confirm: function (button) { }, cancel: function (button) { // nothing to do }, confirmButton: "Ok", cancelButton: "No", post: true, confirmButtonClass: "btn-danger", cancelButtonClass: "btn-default hide", dialogClass: "modal-dialog modal-sm" }); } } }) } } function pTooltip() { $('.timeTip, .countryTip').tooltip({ track: true, content: function () { return $(this).prop('title'); } }); } // Date Format and Time in Tip helper Functions function ConvertUTCTimeToLocalTime(UTCDateString, IsDisplayYear) { var offsetms = ((new Date()).getTimezoneOffset() * 60 * 1000); var convertdLocalTime = new Date(UTCDateString); var newDate = new Date(convertdLocalTime.valueOf() - offsetms); var monthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; var date_format = '12'; /* FORMAT CAN BE 12 hour (12) OR 24 hour (24)*/ var d = newDate; var hours = d.getHours(); var minutes = d.getMinutes(); var suffix = ''; if (hours > 11) { suffix += "PM"; } else { suffix += "AM"; } if (hours > 12) { hours -= 12; } else if (hours === 0) { hours = 12; } hours = ((hours < 10) ? "0" + hours : hours); if (minutes < 10) { minutes = "0" + minutes; } if (IsDisplayYear) { return monthNames[newDate.getMonth()] + " " + newDate.getDate() + ", " + newDate.getFullYear() + " " + hours + ":" + minutes + ' ' + suffix; } else { return monthNames[newDate.getMonth()] + " " + newDate.getDate() + ", " + hours + ":" + minutes + ' ' + suffix; } } function convertLocalDateToUTCDate(date) { date = new Date(date); //Local time converted to UTC var localOffset = date.getTimezoneOffset() * 60000; var localTime = date.getTime(); date = localTime + localOffset; date = new Date(date); return date; } function CheckSoonDate(UTCDateString) { //var offsetms = ((new Date()).getTimezoneOffset() * 60 * 1000); //var convertdLocalTime = new Date(UTCDateString); ////var convertdLocalTime = new Date(new Date(UTCDateString).getMinutes() + parseInt((new Date()).getTimezoneOffset())); //var newDate = new Date(convertdLocalTime.valueOf() - offsetms); //var nowDate = new Date(); //nowDate.setDate(nowDate.getDate() + 1); //if (newDate <= nowDate || newDate <= new Date()) { // return true; //} else { // return false; //} //var convertdLocalTime = new Date(new Date(UTCDateString).setMinutes(parseInt((new Date()).getTimezoneOffset()))); //if (new Date() <= convertdLocalTime && ((convertdLocalTime.getDate() - new Date().getDate()) == 1 || (convertdLocalTime.getDate() - new Date().getDate()) == 0)) { // return true; //} //else { // return false; //} var UTCDateString = new Date(UTCDateString); var localOffset = UTCDateString.getTimezoneOffset() * 60000; var localTime = UTCDateString.getTime(); UTCDateString = localTime - localOffset; UTCDateString = new Date(UTCDateString); if (new Date() <= UTCDateString && ((UTCDateString.getDate() - new Date().getDate()) == 1 || (UTCDateString.getDate() - new Date().getDate()) == 0)) { return true; } else { return false; } } function formatAMPM(date) { var hours = date.getHours(); var minutes = date.getMinutes(); var ampm = hours >= 12 ? 'PM' : 'AM'; hours = hours % 12; hours = hours ? hours : 12; // the hour '0' should be '12' //hours = hours < 10 ? '0' + hours : hours; minutes = minutes < 10 ? '0' + minutes : minutes; if (minutes > 0) { var strTime = hours + ':' + minutes + ' ' + ampm; } else { var strTime = hours + ' ' + ampm; } return strTime; } function formatSDate(date) { var nMNo = date.getMonth(); var nMShortNM = nMonth[nMNo]; var nMFYear = date.getFullYear(); var nMDate = date.getDate(); //nMDate = nMDate < 10 ? '0' + nMDate : nMDate; var strDate = nMShortNM + ' ' + nMDate + ', ' + nMFYear; return strDate; } function jsDTip() { $('.jsDTip').tooltip({ // tooltipClass: "bBG_tooltip", position: { my: "left+30 top+20", at: "left top", collision: "flipfit" }, track: true, content: function () { return $(this).prop('title'); } }); $('.jsDTip').tooltip().off("focusin focusout"); } function setTipStrFormat(ele, eleArr, elesingleDateOnly, elestartEndLength) { for (var i = 0; i < eleArr.length; i++) { var titStr = ""; if (eleArr.length > 1) { if (eleArr[0] == eleArr[1]) { titStr = eleArr[0]; } else { titStr = eleArr[0] + ' - ' + eleArr[1]; } titleArr = []; } else if ((typeof elesingleDateOnly !== typeof undefined && elesingleDateOnly !== false) || elestartEndLength == 1) { titStr = eleArr[0]; titleArr = []; } else { titStr = eleArr[0]; } $(ele).closest('.jsConvertdateParent').attr('title', titStr); }; } function setDateStrFormat(ele, eleArr, elesingleDateOnly, elestartEndLength) { for (var i = 0; i < eleArr.length; i++) { if (eleArr.length > 1) { // Month settings var month_start_no = new Date(eleArr[0]).getMonth(); var month_start_ShName = nMonth[month_start_no]; var month_end_no = new Date(eleArr[1]).getMonth(); var month_end_ShName = nMonth[month_end_no]; // Date digit settings var start_date = new Date(eleArr[0]).getDate(); var end_date = new Date(eleArr[1]).getDate(); // Year digit settings var start_year = new Date(eleArr[0]).getFullYear(); var end_year = new Date(eleArr[1]).getFullYear(); if($(ele).hasClass('hlinkC')){ var eleParent = $(ele).closest('.jshlinkCParent'); } else{ var eleParent = $(ele).closest('.jsConvertdateParent'); } if (month_start_ShName == month_end_ShName && start_date == end_date && start_year == end_year) { var commonDate = eleArr[0]; $(eleParent).children(':not(:first-child)').addClass('hide'); $(eleParent).children(':first-child').text(commonDate); } else if (month_start_ShName != month_end_ShName && start_date == end_date && start_year == end_year) { var commonDate = month_start_ShName +' ' + start_date + ' - ' + month_end_ShName + ' ' + start_date + ', ' + start_year; $(eleParent).children(':not(:first-child)').addClass('hide'); $(eleParent).children(':first-child').text(commonDate); } else if (month_start_ShName != month_end_ShName && start_date != end_date && start_year == end_year) { var commonDate = month_start_ShName + ' ' + start_date + ' - ' + month_end_ShName + ' ' + end_date + ', ' + start_year; $(eleParent).children(':not(:first-child)').addClass('hide'); $(eleParent).children(':first-child').text(commonDate); } else if (month_start_ShName != month_end_ShName && start_date == end_date && start_year != end_year) { $(ele).text(eleArr[1]); } else if (month_start_ShName == month_end_ShName && start_date == end_date && start_year != end_year) { var commonDate = month_start_ShName + ' ' + start_date + ', ' + start_year + ' - ' + end_year; $(eleParent).children(':not(:first-child)').addClass('hide'); $(eleParent).children(':first-child').text(commonDate); } else if (month_start_ShName == month_end_ShName && start_date != end_date && start_year == end_year) { var commonDate = month_start_ShName + ' ' + start_date + ' - ' + end_date + ', ' + start_year ; $(eleParent).children(':not(:first-child)').addClass('hide'); $(eleParent).children(':first-child').text(commonDate); } else if (month_start_ShName != month_end_ShName && start_date != end_date && start_year != end_year) { $(ele).text(eleArr[1]); } seDateArr = []; } else if ((typeof elesingleDateOnly !== typeof undefined && elesingleDateOnly !== false) || elestartEndLength == 1) { $(ele).text(eleArr[0]); seDateArr = []; } else { $(ele).text(eleArr[0]); } }; } function jsDateFormatAndTip() { $('.jsConvertChild').each(function () { var _this = $(this); var date = $(this).attr('data-fdate'); var singleDateOnly = $(this).attr('data-check'); if (date != null && date.length > 0) { if ($(this).closest('.jsConvertdateParent').hasClass('convertUTC')) { var localDate = ConvertUTCTimeToLocalTime(date, true); } else { var localDate = date; } var startEndLength = $(_this).closest('.jsConvertdateParent').children('.jsConvertChild').length; // For Time Tip Settings var titleStr = formatAMPM(new Date(localDate)); titleArr.push(titleStr); $(_this).closest('.jsConvertdateParent').addClass('jsDTip'); setTipStrFormat(_this, titleArr, singleDateOnly, startEndLength) // For Date Settings var seDateStr = formatSDate(new Date(localDate)); seDateArr.push(seDateStr); $(_this).text(); setDateStrFormat(_this, seDateArr, singleDateOnly, startEndLength) jsDTip() } }); } $(document).on("click", "#FilterDiv a", function () { LoadCourseFilterRequest = new Array(); if ($(this).attr('data-text') != "All") { LoadCourseFilterRequest.push({ FieldName: $(this).closest("ul").attr("data-field"), ID: $(this).attr('value'), Text: $(this).attr('data-text'), ConditionalParameters: 0 }) } else { isFilter = true; } LoadCourseFilterRequest.push({ FieldName: 'CategoryType', ID: 0 }); BindLoadAvailableCourses(); }) $(document).on('click', '.jsViewTrainingCourse', function () { var _this = $(this); var detailDiv = '.' + $(this).attr('data-div'); var mainRowId = $(_this).attr('data-gid'); var subRow = $('[data-sgid="' + mainRowId + '"]').not('.TrainingTRNotGroup'); if ($(_this).hasClass('active')) { //// If its needs like accordion uncomment this function //// groupingRawAccordion(_this) //$(_this).removeClass('active'); //$(_this).find('.fa').removeClass('fa-minus').addClass('fa-plus'); //// $(subRow).addClass('cgSbHide'); //for (var i = subRow.length - 1; i >= 0; i--) { // $('[data-sgid="' + mainRowId + '"]:eq(' + i + ')').addClass('cgSbHide'); //}; $(detailDiv).slideUp('slow'); $(_this).removeClass('active'); } else { // If its needs like accordion uncomment this function // groupingRawAccordion(_this) if (!$(_this).closest('.cgroupMain').next().hasClass(_this.attr('data-div'))) { $('#loadingWithBG').show(); $.ajax({ url: '/Courses/LoadGroupTrainingGRID', type: 'POST', cache: false, datatype: 'json', data: { TrainingGroupId: mainRowId, CategoryId: 0 }, success: function (data) { //debugger; $(data).insertAfter(_this.closest(".cgroupMain")); $(detailDiv).slideDown('slow'); $('#loadingWithBG').hide(); //gridSortable() } }); } else { $(detailDiv).slideDown('slow'); } $(_this).addClass('active'); } }); $(document).on('hidden.bs.modal', '.schedulePage #Course_oneclick_orderplaced', function () { window.location.reload(); }) //result data setting function resultDataRpad() { //var tableH = $('#divresult #dtAvailableCourses').height(); //var resultDivH = $('#divresult .flexNice').height(); //if (tableH > resultDivH) { // $('#divresult .Schedulepadding-right').addClass('schRpad'); //} //else { // $('#divresult .Schedulepadding-right').removeClass('schRpad'); //} } // Filterbox position if ($('body').hasClass('alignersite')) { function filterboxPos(eleThis) { var elepos = 0, eleIcoPos = $(eleThis).offset().left, eleThPos = $(eleThis).closest('th').offset().left, eleTableW = $(eleThis).closest('table').width(), eleFBoxW = $(eleThis).next('.filter_box').outerWidth(), eleFBoxLeft = eleIcoPos - (eleThPos + 12), eleFBoxRight = -(eleFBoxW - eleFBoxLeft) + 37; elepos = eleFBoxW + (eleIcoPos - $(eleThis).closest('table').offset().left); // console.log('eleIcoPos= ' + eleIcoPos + ', eleThPos= ' + eleIcoPos + ', eleTableW= ' + eleTableW + ', eleFBoxW= ' + eleFBoxW + ', eleFBoxLeft= ' + eleFBoxLeft); if (elepos > eleTableW) { $(eleThis).next('.filter_box').removeClass('leftPos').addClass('rightPos'); $(eleThis).next('.filter_box').css({ 'left': eleFBoxRight }); } else { $(eleThis).next('.filter_box').removeClass('rightPos').addClass('leftPos'); $(eleThis).next('.filter_box').css({ 'left': eleFBoxLeft }); } } } function crTip() { $('.crTip').tooltip({ tooltipClass: "bBG_tooltip", position: { my: "left+30 top+20", at: "left top", collision: "flipfit" }, track: true }); }