angular.module('departmentsService',[]).factory('Departments',function($http){
	
	return {
		getPaging:function(filter){
			return $http({method:'POST',url:url_server + 'departmentspaging',data:filter});
		},
		getSelect:function(){
			return $http({method:'POST',
				headers:headers,
				url:url_server + 'departments/getall',
				withCredentials: true});
			// return $http({method:'POST',url:url_server + 'departments/getall'});
		},
		getSelectFilter:function(){
			
			return $http({method:'POST',
				headers:headers,
				url:url_server + 'departments/getallfilter',
				withCredentials: true});
			// return $http({method:'POST',url:url_server + 'departments/getallfilter'});
		},
		getSelect2:function(filter){
			return $http({method:'POST',url:url_server + 'departments/search',data:filter});
		},
		show:function(id){
			return $http.get(url_server+ 'departments/'+id);
		},
		save:function(departmentsData){
			return $http({method:'POST',
							url:url_server+'departments',
							data:departmentsData});
		},
		update:function(id, departmentsData){
			return $http.put(url_server+'departments/'+id,departmentsData);
		},
		destroy:function(id){
			return $http.delete(url_server + 'departments/'+id);
		},
		getDepartmentsGroup:function(id){
			
			return $http({method:'POST',
				headers:headers,
				url:url_server + 'departments/getdepartmentsgroup',
				data:id,
				withCredentials: true});
			// return $http({method:'POST',url:url_server + 'departments/getdepartmentsgroup',data:id});
		}
	};
});
