// create the module and name it scotchApp var scotchApp = angular.module('scotchApp', ['ngRoute']); // configure our routes scotchApp.config(function($routeProvider) { $routeProvider // route for the home page .when('/', { templateUrl: 'pages/home.html', controller: 'mainController' }) // route for the paymentVerify page .when('/pendingPayment/:id', { templateUrl: 'pages/verify.html', controller: 'verifyController' }) // route for the ambassador page .when('/ambassador', { templateUrl: 'pages/ambassador.html', controller: 'ambassadorController' }) // route for the confirmation page .when('/confirmation', { templateUrl: 'pages/confirmation.html', controller: 'mainController' }) }); //scotchApp.constant("BASE_URL", "http://139.59.68.74:4001/api") scotchApp.constant("BASE_URL", "http://0.0.0.0:4001/api") // create the controller and inject Angular's $scope scotchApp.controller('mainController', function($scope, $http, $location, $route, $rootScope, BASE_URL) { $scope.data = { show: true, hide: false }; $scope.infoForm = false; /*THIS CODE FOR HIDE STEP 2 FORM*/ $scope.max = 100; $scope.current = 0; $scope.payingAmnt = 0; if ($scope.data.stage == 'select') { } $scope.author = 'Swarn Singh'; $scope.data = {}; $scope.data.stage = 'Idea'; $scope.discountAmount = 0; $scope.check = false; $scope.numberCheck = false; $scope.paymentResult = {}; var data = { "amount": $scope.payingAmnt, "currency": "INR", "status": "pending" } /*open videos in modal*/ $scope.openyoutube16 = function(){ $('#videoModel').modal('show'); } $scope.openyoutube17 = function(){ $('#videoModels').modal('show'); } $scope.closeModal = function(){ var url = $('#youtubePlayer').attr('src'); $('#youtubePlayer').attr('src', ''); $('#youtubePlayer').attr('src', url); } $scope.closed = function(){ var url = $('#youtubePlayersss').attr('src'); $('#youtubePlayersss').attr('src', ''); $('#youtubePlayersss').attr('src', url); } /*open videos ends here*/ $scope.removeError = function() { $('#invalidEmail').css('display', 'none'); $('#alreadyExist').css('display', 'none'); }; $scope.emailcheck = function(val) { if (val == undefined) { $('#invalidEmail').css('display', 'block'); } else { $http({ method: 'GET', url: BASE_URL + '/applicants?filter={"where": {"email": {"like":"%25' + $scope.data.email + '%25"}}}', headers: {} }).then(function mySuccess(searchResult) { console.log("searchResult1===>", searchResult) if (searchResult.data.length == 0) { $scope.check = false; } else { $scope.check = true; $('#alreadyExist').css('display', 'block'); } }, function myError(error) {}); } }; $scope.removeNoError = function() { $('#noExist').css('display', 'none'); }; $scope.numbercheck = function(number) { $http({ method: 'GET', url: BASE_URL + '/applicants?filter={"where": {"phone": {"like":"%25' + number + '%25"}}}', data: $scope.data, headers: {} }).then(function mySuccess(searchResult) { console.log("searchResult===>", searchResult) if (searchResult.data.length == 0) { $scope.numberCheck = false; } else { $scope.numberCheck = true; $('#noExist').css('display', 'block'); } }, function myError(error) {}); }; $rootScope.tokenCall = function(val) { console.log('val-------->', val); if (val == undefined) { $('#invalidEmail').css('display', 'block'); } else { val = val.toUpperCase(); $http.get(BASE_URL + '/ambassadors?filter={"where": {"referalToken": {"like":"%25' + val + '%25"}}}') .then(function(searchResult) { if (searchResult.data.length == 0) { $scope.tokencheck = false; $scope.discountAmount = 0; } else { $scope.tokencheck = true; } },function(err){ console.log(err) }); } }; /*THIS CODE FOR ENABLED SUBMIT BUTTON AFTER UPLOAD IMAGE*/ $(document).ready( function() { $('input:submit').attr('disabled', true); $('input:file').change( function() { if ($("#picture").val()) { $('input:submit').removeAttr('disabled'); } else { $('input:submit').attr('disabled', true); } }); }); /*****THIS IS FOR STEP ONE FORM ******/ $scope.next = function() { $scope.data.status = null if ($scope.data.stage == undefined || $scope.data.name == undefined || $scope.data.email == undefined || $scope.data.number == undefined || $scope.data.city == undefined) { var x = document.getElementById("snackbar") x.className = "show"; setTimeout(function() { x.className = x.className.replace("show", ""); }, 3000); } else if ($scope.data.stage != undefined && $scope.data.name != undefined && $scope.data.email != undefined && $scope.data.number != undefined && $scope.data.city != undefined) { $scope.infoForm = true; console.log("sdasdasdsa"); $scope.data.stage = $scope.data.stage; $scope.detail = {}; $scope.data.phone = "+91" + $scope.data.number; $http({ method: 'POST', url: BASE_URL + '/information', data: $scope.data, headers: {} }).then(function mySuccess(result) { console.log("result", result) $scope.detail = result; data.applicantId = result.data.id; $scope.userId = result.data.id; }, function myError(error) {}); } } $scope.calculateAmount = function(){ if ($scope.data.stage == undefined || $scope.data.name == undefined || $scope.data.email == undefined || $scope.data.number == undefined || $scope.data.city == undefined) { var x = document.getElementById("snackbar") x.className = "show"; setTimeout(function() { x.className = x.className.replace("show", ""); }, 3000); } else if ($scope.data.stage != undefined && $scope.data.name != undefined && $scope.data.email != undefined && $scope.data.number != undefined && $scope.data.city != undefined) { $scope.infoForm = true; console.log("sdasdasdsa"); $scope.data.stage = $scope.data.stage; $scope.detail = {}; $scope.data.phone = "+91" + $scope.data.number; $http({ method: 'POST', url: BASE_URL + '/applicants', data: $scope.data, headers: {} }).then(function mySuccess(result) { console.log("result", result) $scope.detail = result; data.applicantId = result.data.id; $scope.userId = result.data.id; }, function myError(error) {}); } if ($scope.data.stage == "Idea") { console.log("$scope.data", $scope.data) $scope.ticketAmnt = 500; } if ($scope.data.stage == "Product") { $scope.ticketAmnt = 1000; } if ($scope.data.stage == "Growth") { $scope.ticketAmnt = 2000; } if($scope.tokencheck == true){ var amount = $scope.ticketAmnt $scope.discountAmount = (amount * 10)/100 console.log("finalAmount====>",$scope.payingAmnt) } var taxAmount = $scope.ticketAmnt - $scope.discountAmount $scope.taxTotal = (taxAmount * 18)/100 $scope.payingAmnt = taxAmount + $scope.taxTotal console.log("taxincludedamount----", $scope.payingAmnt) } /*****THIS IS FOR STEP THREE FORM ******/ $scope.create = function() { // if ($scope.data.name == undefined || $scope.data.email == undefined || $scope.data.number == undefined) { // var x = document.getElementById("snackbar") // x.className = "show"; // setTimeout(function() { // x.className = x.className.replace("show", ""); // }, 3000); // } else if ($scope.data.name != undefined && $scope.data.email != undefined && $scope.data.number != undefined) { // $scope.infoForm = true; // console.log("sdasdasdsa"); // $scope.data.stage = $scope.data.stage; // $scope.detail = {}; // $scope.data.phone = "+91" + $scope.data.number; // $http({ // method: 'POST', // url: BASE_URL + '/applicants', // data: $scope.data, // headers: {} // }).then(function mySuccess(result) { // console.log("=====result=====", result) // $scope.detail = result; // data.applicantId = result.data.id; // $scope.userId = result.data.id; // console.log("=====data=====", data) data.amount = $scope.payingAmnt; if ($scope.detail != null) { $http({ method: 'POST', url: BASE_URL + '/payments', data: data, headers: {} }).then(function mySuccess(paymentResult) { console.log("paymentResult",paymentResult) $scope.paymentResult = paymentResult; }, function myError(error) {}); } var i = 0; $scope.payingAmnt = $scope.payingAmnt * 100; var options = { "key": "rzp_live_mhSE1uOBlXvFyJ", "amount": $scope.payingAmnt, "name": "Startup Jalsa", "description": "amount", "currency": "INR", "status": "done", "theme": { "color": "#2196f3 ", "image_padding": "NO" }, "modal": { "ondismiss": function() {} }, "handler": function(response) { createPayment(response); } }; var rzp1 = new Razorpay(options); rzp1.open(); $scope.paymentResponse = {}; function createPayment(response) { console.log("response====from===razorpay",response) $route.reload(); $scope.paymentResponse.razorPaymentId = response.razorpay_payment_id; $scope.paymentResponse.razorOrderId = $scope.paymentResult.data.razorOrderId; $scope.paymentResponse.amount = data.amount; $scope.paymentResponse.currency = "INR"; $scope.paymentResponse.status = $scope.paymentResult.data.status; $http({ method: 'PUT', url: BASE_URL + '/payments/' + $scope.paymentResult.data.id, data: $scope.paymentResponse, headers: {} }).then(function mySuccess(searchResult) { console.log("searchResult", searchResult) $location.path("/confirmation") //$scope.showToastr() //toaster.success("Registration done successfully"); }, function myError(error) {}); } //}, function myError(error) {}); //} } // $scope.showToastr = function() { // console.log("called toast") // var x = document.getElementById("snacsskbar") // x.className = "show"; // setTimeout(function() { // x.className = x.className.replace("show", ""); // }, 3000); // } /*kk***This code for change data when click to chooses stages***/ $scope.proto = true; $scope.businessmodel = true; $scope.Idea = true; $scope.current = true; $scope.stage = function(stage) { $scope.stagekeyPress(); console.log("stage--2",stage) if (stage == 'Idea') { $scope.current = 10; $scope.proto = true; $scope.prototyp = false; $scope.market = false; $scope.risks = false; $scope.team = false; $scope.pitch = false; $scope.financials = false; $scope.businessmodel = true; $scope.data.stage = stage; // for right content $scope.Idea = true; $scope.Product = false; $scope.Growth = false; } else if (stage == 'Product') { $scope.current = 10; $scope.proto = true; $scope.prototyp = true; $scope.market = true; $scope.risks = true; $scope.team = true; $scope.pitch = true; $scope.financials = true; $scope.businessmodel = false; $scope.data.stage = stage; // for right content $scope.Idea = false; $scope.Product = true; $scope.Growth = false; } else if (stage == 'Growth') { $scope.current = 10; $scope.proto = false; $scope.prototyp = true; $scope.market = true; $scope.risks = true; $scope.team = true; $scope.pitch = true; $scope.financials = true; $scope.businessmodel = false; // for right content $scope.Idea = false; $scope.Product = false; $scope.Growth = true; $scope.data.stage = stage; } } $scope.enterbusiness = function(business) { console.log("business", business); if (name == undefined) { $scope.current = false; } else if (name != undefined) { $scope.current = true; } } /*******FOR FILL THE DATA AND SHOWS ICON GREEN*/ $scope.stagekeyPress = function() { $('.icon-circle-a').css('background-color', 'rgb(66, 181, 73)'); } $scope.sectorkeyPress = function() { $('.icon-circle-b').css('background-color', 'rgb(66, 181, 73)'); } $scope.studentkeyPress = function() { $('.icon-circle-ab').css('background-color', 'rgb(66, 181, 73)'); } $scope.namekeyPress = function(name) { console.log("name", name); if (name == undefined) { $('.icon-circle-c').css('background-color', 'rgb(102, 102, 102)'); } else { $('.icon-circle-c').css('background-color', 'rgb(66, 181, 73)'); } } $scope.emailkeyPress = function(email) { console.log("email", email); if (email == undefined) { $('.icon-circle-d').css('background-color', 'rgb(102, 102, 102)'); } else { $('.icon-circle-d').css('background-color', 'rgb(66, 181, 73)'); } } $scope.phonekeyPress = function(number) { console.log("number", number); if (number == undefined) { $('.icon-circle-e').css('background-color', 'rgb(102, 102, 102)'); } else { $('.icon-circle-e').css('background-color', 'rgb(66, 181, 73)'); } } $scope.citykeyPress = function(city) { console.log("city", city); if (city == undefined) { $('.icon-circle-f').css('background-color', 'rgb(102, 102, 102)'); } else { $('.icon-circle-f').css('background-color', 'rgb(66, 181, 73)'); } } $scope.questionkeyPress = function(q) { if (q == undefined) { $('.icon-circle-x').css('background-color', 'rgb(102, 102, 102)'); } else { $('.icon-circle-x').css('background-color', 'rgb(66, 181, 73)'); } } $scope.technologykeyPress = function(technology) { if (technology == undefined) { $('.icon-circle-h').css('background-color', 'rgb(102, 102, 102)'); } else { $('.icon-circle-h').css('background-color', 'rgb(66, 181, 73)'); } } $scope.problemkeyPress = function(problem) { if (problem == undefined) { $('.icon-circle-i').css('background-color', 'rgb(102, 102, 102)'); } else { $('.icon-circle-i').css('background-color', 'rgb(66, 181, 73)'); } } $scope.solutionkeyPress = function(solution) { if (solution == undefined) { $('.icon-circle-j').css('background-color', 'rgb(102, 102, 102)'); } else { $('.icon-circle-j').css('background-color', 'rgb(66, 181, 73)'); } } $scope.businesskeyPress = function(business) { $('.icon-circle-p').css('background-color', 'rgb(66, 181, 73)'); } $scope.prototypekeyPress = function(prototype) { if (prototype == undefined) { $('.icon-circle-k').css('background-color', 'rgb(102, 102, 102)'); } else { $('.icon-circle-k').css('background-color', 'rgb(66, 181, 73)'); } } $scope.marketkeyPress = function(market) { if (market == undefined) { $('.icon-circle-l').css('background-color', 'rgb(102, 102, 102)'); } else { $('.icon-circle-l').css('background-color', 'rgb(66, 181, 73)'); } } $scope.riskkeyPress = function(risk) { if (risk == undefined) { $('.icon-circle-m').css('background-color', 'rgb(102, 102, 102)'); } else { $('.icon-circle-m').css('background-color', 'rgb(66, 181, 73)'); } } $scope.teamkeyPress = function(team) { if (team == undefined) { $('.icon-circle-n').css('background-color', 'rgb(102, 102, 102)'); } else { $('.icon-circle-n').css('background-color', 'rgb(66, 181, 73)'); } } $scope.pitchkeyPress = function(pitch) { if (pitch == undefined) { $('.icon-circle-z').css('background-color', 'rgb(102, 102, 102)'); } else { $('.icon-circle-z').css('background-color', 'rgb(66, 181, 73)'); } } $scope.financialskeyPress = function(financial) { console.log("financial", financial); if (financial == undefined) { $('.icon-circle-q').css('background-color', 'rgb(102, 102, 102)'); } else { $('.icon-circle-q').css('background-color', 'rgb(66, 181, 73)'); } } $scope.changeReferalIconColor = function(referalToken){ if (referalToken == undefined || referalToken == '') { $('.referel-icon').css('background-color', 'rgb(102, 102, 102)'); }else { $('.referel-icon').css('background-color', 'rgb(66, 181, 73)'); } } }); scotchApp.controller('verifyController', function($scope, $http, $location, $route,BASE_URL) { $scope.pendingPaymentId = $route.current.params.id $http({ method: "GET", url: BASE_URL + '/applicants/' + $scope.pendingPaymentId, }).then(function mySuccess(response) { $scope.data = response.data; console.log("response-1", response); $scope.pendingPaymentId = $route.current.params.id; $http({ method: "GET", url: BASE_URL + '/payments?filter={"where":{"applicantId":' + $scope.pendingPaymentId + '}}', }).then(function mySuccess(response) { $scope.paymentRecord = response.data; }, function myError(response) { }); }, function myError(response) { $scope.myWelcome = response.statusText; }); $scope.checkView = false; $scope.verifyView = false; $scope.pendingPaymentId = ''; $scope.update = function() { $http({ method: 'GET', url: BASE_URL + '/payments?filter={"where":{"applicantId": ' + $scope.pendingPaymentId + '}}', headers: {} }).then(function mySuccess(searchResult) { if (searchResult.data[0].status == "created") { $scope.checkView = true; $scope.verifyView = false; $scope.amount = searchResult.data[0].amount; $scope.searchResult = searchResult.data[0]; console.log('====searchResult===', searchResult); console.log("searchResult=====",searchResult.data[0].razorOrderId) var i = 0; $scope.amount = $scope.amount * 100; var options = { "key": "rzp_live_mhSE1uOBlXvFyJ", //"key" : "rzp_test_YwHsVFiDIQ2WUQ", "amount": $scope.amount, "name": "Startup Jalsa", "description": "amount", "currency": "INR", "status": "done", "theme": { "color": "#2196f3 ", "image_padding": "NO" }, "modal": { "ondismiss": function() {} }, "handler": function(response) { createPayment(response); } }; var rzp1 = new Razorpay(options); rzp1.open(); $scope.paymentResponse = {}; function createPayment(response) { $scope.amount = $scope.amount / 100; console.log("response======retepaymen",response); $scope.paymentResponse.razorPaymentId = response.razorpay_payment_id; $scope.paymentResponse.razorOrderId = $scope.searchResult.razorOrderId; $scope.paymentResponse.amount = $scope.amount; $scope.paymentResponse.currency = $scope.searchResult.currency; $scope.paymentResponse.status = $scope.searchResult.status; $scope.paymentResponse.applicantId = $scope.searchResult.applicantId; console.log("$scope.paymentResponse", $scope.paymentResponse) $http({ method: 'PUT', url: BASE_URL + '/payments/' + $scope.searchResult.id, data: $scope.paymentResponse, headers: {} }).then(function mySuccess(searchResult) { console.log("finalsearchResult",searchResult) $location.path("/confirmation") }, function myError(error) { }); } } else { } }, function myError(error) {}); } }); scotchApp.controller('ambassadorController', function($scope, $http, $location, $route,BASE_URL) { $scope.data = {}; $scope.check = false; $scope.numberCheck = false; /*open videos in modal*/ $scope.openyoutube16 = function(){ $('#videoModel').modal('show'); } $scope.openyoutube17 = function(){ $('#videoModels').modal('show'); } $scope.closeModal = function(){ var url = $('#youtubePlayer').attr('src'); $('#youtubePlayer').attr('src', ''); $('#youtubePlayer').attr('src', url); } /*open videos ends here*/ $scope.removeError = function() { $('#invalidEmail').css('display', 'none'); $('#alreadyExist').css('display', 'none'); }; $scope.emailcheck = function(val) { if (val == undefined) { $('#invalidEmail').css('display', 'block'); } else { $http({ method: 'GET', url: BASE_URL + '/ambassadors?filter={"where": {"email": {"like":"%25' + $scope.data.email + '%25"}}}', headers: {} }).then(function mySuccess(searchResult) { console.log("searchResult1===>", searchResult) if (searchResult.data.length == 0) { $scope.check = false; } else { $scope.check = true; $('#alreadyExist').css('display', 'block'); } }, function myError(error) {}); } }; $scope.removeNoError = function() { $('#invalidNumber').css('display', 'none'); $('#noExist').css('display', 'none'); }; $scope.numbercheck = function(number) { // if (val == undefined) { // $('#invalidNumber').css('display', 'block'); // } else { $http({ method: 'GET', url: BASE_URL + '/ambassadors?filter={"where": {"mobile": {"like":"%25' + number + '%25"}}}', data: $scope.data, headers: {} }).then(function mySuccess(searchResult) { console.log("searchResult===>", searchResult) if (searchResult.data.length == 0) { $scope.numberCheck = false; } else { $scope.numberCheck = true; $('#noExist').css('display', 'block'); } }, function myError(error) {}); //} }; $scope.submit = function() { console.log($scope.data.name) var randomNumber = ""+Math.random(); var nameSpliced = $scope.data.name.slice(0,3); var numberSpliced = randomNumber.slice(2,5); $scope.data.referalToken = nameSpliced+numberSpliced; $scope.data.referalToken = $scope.data.referalToken.toUpperCase(); $http({ method: 'POST', url: BASE_URL + '/ambassadors', data: $scope.data, headers: {} }).then(function mySuccess(result) { console.log("result", result) $scope.detail = result; $('#myModal').modal('show'); $scope.data.name = ''; $scope.data.email = ''; $scope.data.mobile = ''; }, function myError(error) { console.log(error) console.log(error.data.error.message) }); console.log($scope.data) } });