/* Modules : ctrl_formAuthentification Version : 1.0.0 Date : 03.11.16 Auteur : ABA Description : Controleur pour le login */ angular.module('misCrmApp') .controller('ctrl_formAuthentification', ['dataUrls', '$scope','$rootScope', '$http', 'ngDialog', '$filter', '$location','$cookies', '$window', function(dataUrls, $scope, $rootScope,$http, ngDialog, $filter, $location, $cookies,$window) { $scope.debug = true; $scope.bDataLoaded=0; //********************* //*** FONCTIONS //********************* var fnGetParamsUrl = function(param) { var vars = {}; window.location.href.replace( location.hash, '' ).replace( /[?&]+([^=&]+)=?([^&]*)?/gi, // regexp function( m, key, value ) { // callback vars[key] = value !== undefined ? value : ''; } ); if ( param ) { return vars[param] ? vars[param] : null; } return vars; }; $scope.fnOpenDlg = function (strDlgTitle,strDlgMessage) { $rootScope.DlgTitle=strDlgTitle; $rootScope.DlgMessage=strDlgMessage; ngDialog.open({ template: '_miscrm/angular/ngDialog/tpl/DefDialog01.html', }); }; $scope.fnPostAuthentification = function() { //alert("fnPostAuthentification"); //alert($scope.formAuthentification.userName); //alert($scope.urlOnSuccess); urlPostAuthentification="index.php?page=crm_POST_Authentification"; $http({ method : 'POST', url : urlPostAuthentification, data : $.param($scope.formAuthentification), // pass in data as strings headers : { 'Content-Type': 'application/x-www-form-urlencoded' } // set the headers so angular passing info as form data (not request payload) }).then(function(response) { console.log(response); $scope.empty = false; $scope.strLoginStatus=response.data; if($scope.strLoginStatus.result=="success") { //alert($scope.strLoginStatus.result); $window.location.href = $scope.urlOnSuccess; } else { //alert($scope.strLoginStatus.result); $scope.fnOpenDlg("Erreur","Les informations de connexion n'ont pas été reconnues"); }; //$scope.fnOpenDlg("Message","Les informations sont enregistrées"); //$window.location.href = 'index.php?page=listeTelechargements'; }); } //********************* //*** MAIN //********************* }]);