angular.module('authenticationSvc',[])
.factory('Auth',function($http){
	return{
		 Logout:function(filter){
			//return $http({method:'POST',url:url_server + '/auth',data:filter});
			var headers = {'Access-Control-Allow-Origin' : '*'};
			return $http({method:'POST',headers:headers,url: server_chat + '/logoutDevice',data:data});
		},
		registerDevice: function (data) {
     	 var headers = {'Access-Control-Allow-Origin' : '*'};
      	return $http({method:'POST',headers:headers,url: server_chat + '/registerDevice',data:data});
    	}
	}

})

angular.module('LoginService',[]).factory('Login',function($http){
	return {
		getUserLogin:function(){
			
			return $http({method:'POST',
				headers:headers,
				url:url_site+'/auth',
				data:{action:'current_user'},
				withCredentials: true});
		},
		checkLogin:function(){
			return $http({method:'POST',
				headers:headers,
				url:url_site+'/auth',
				data:{action:'ping'},
				withCredentials: true});
			// return $http.post(url_site + '/auth',{action:'ping'});
		},
		logout:function(){
			return $http.post(url_site + '/auth',{action:'logout'});
		},
		checkSession:function(){
			return $http.post(url_site + '/auth',{action:'checkSession'});
		},
		forgotPassword:function(email){	
			return $http({method:'POST',
				headers:headers,
				url:url_site+'/auth',
				data:{action:'forgotpassword',email:email},
				withCredentials: true});
			// return $http.post(url_site + '/auth',{action:'forgotpassword',email:email});
		},
		resetPassword:function(data){
			return $http({method:'POST',
				headers:headers,
				url:url_site+'/auth',
				data:{action:'resetpassword',dataResetPassword:data},
				withCredentials: true});
			// return $http.post(url_site + '/auth',{action:'resetpassword',dataResetPassword:data});
		},
		changePassword:function(data){
			return $http.post(url_site + '/auth',{action:'changepassword',dataChangePassword:data},{withCredentials: true,headers:headers});
		},
		checkPuchIn:function(){
			return $http({method:'POST',url:url_server + 'pipus/checkpuchin',withCredentials: true,headers:headers});
		},
		punchIn:function(data){
			return $http({method:'POST',url:url_server + 'pipus/puchin',withCredentials: true,data:data,headers:headers});
		},
		punchOut:function(data){
			return $http({method:'POST',url:url_server + 'pipus/punchout',withCredentials: true,data:data,headers:headers});
		},
		unplannedAbsenceAddTask:function(data){
			return $http({method:'POST',url:url_server + 'tasks/absenceaddtask',data:data,withCredentials: true,headers:headers});
		},
		punchInIssuesAddTask:function(data){
			return $http({method:'POST',url:url_server + 'tasks/punchinissuesaddtask',data:data,withCredentials: true,headers:headers});
		},
		punchOutIssuesAddTask:function(data){
			return $http({method:'POST',url:url_server + 'tasks/punchoutissuesaddtask',data:data,withCredentials: true,headers:headers});
		},
		lastPoutAddTask:function(data){
			return $http({method:'POST',url:url_server + 'tasks/lastpoutaddtask',data:data,withCredentials: true,headers:headers});
		},
		checkLastAutoPunchOut:function(){
			return $http({method:'POST',url:url_server + 'tasks/checklastautopunchout',withCredentials: true,headers:headers});
		},
		checkFirstPin:function(){
			return $http({method:'POST',url:url_server + 'pipus/checkfirstpin',withCredentials: true,headers:headers});
		},
		checkBeforePunchOut:function(){
			return $http({method:'POST',url:url_server + 'pipus/checkbeforepunchout',withCredentials: true,headers:headers});
		},
		sendConsumableList:function(data){
			return $http({method:'POST',url:url_server + 'pipus/sendconsumablelist',withCredentials: true,headers:headers,data:data});
		},
		getAdminAndManager:function(){
			return $http({method:'POST',url:url_server + 'users/getadminandmanager',withCredentials: true,headers:headers});
		},
		getConfigFileUpload:function(data){
			return $http({method:'POST',
				headers:headers,
				url:url_server+'configfileupload',
				data:data,
				withCredentials: true});
			
		},
		pipusGetPaging:function(filter){
			return $http({method:'POST',url:url_server + 'userdetailpipuspaging',data:filter,withCredentials: true,headers:headers});
		},
		getData:function(url){
			return  $http.get(url);
		},
		actionFileManager:function(data){
			return $http({method:'POST',url:url_server + 'users/actionfilemanager',data:data,withCredentials: true,headers:headers});
		},

	};
});


