(function() {
  'use strict';

  angular.module('Monitour.pages.password')
    .controller('passwordCtrl', passwordCtrl);

  /** @ngInject */
  function passwordCtrl($scope, ForgotpasswordService, $translate, $state, SweetAlert) {
        
		var vm = this;

        vm.forgot = forgot;

        vm.sentence = {static: 'Your total platrom needs for'};

      // should be resolved by the router, and injected in this controller
      // that way, words are ready when the controller is instantiated
      // and when the link function of the directive is triggered
       vm.sentence.options = ['Calls', 'Sms', 'Programable Voice', 'Call Flows', 'Voice Mail'];
		
 
        function forgot() {
            vm.dataLoading = true;
			console.log(vm.email);
			var forgotpassword =  { user: vm.email};
            ForgotpasswordService.Forgot(forgotpassword)
                .then(function (response) {
					console.log(response.data.status);
                    if (response.data.status == 1) {
						  SweetAlert.swal({
            title: 'Success your Email details were correct!',
            text: '<span style="text-align:left; padding-bottom:15px; font-size:10px;">Please check your email<span style="color:#08c"> for the pin </span> to reset your password.</span>',
            html: true
        });
		
		
                $state.go('pin', { 'user':  vm.email });        
            
				 
                    } else {
						 vm.pindiv  = false;
                        SweetAlert.swal({
            title: 'Your Email details were incorrect!',
            text: '<span style="text-align:left; padding-bottom:15px; font-size:10px;">Please try again,<span style="color:#08c">with the correct </span> email address and password.</span>',
            html: true
        });
                        vm.dataLoading = 2;
                    }
                });
        }
		
		
		
    }

})();