angular.module('appointmentgroupsService',[]).factory('Appointmentgroups',function($http){
	return {
		getPaging:function(filter){
			return $http({method:'POST',
				headers:headers,
				url:url_server + 'appointmentgroupspaging',
				data:filter,
				withCredentials: true});
			// return $http({method:'POST',url:url_server + 'appointmentgroupspaging',data:filter});
		},
		getAppointmenType:function(show_all){
			return $http({method:'POST',
				headers:headers,
				url:url_server + 'appointmentstypes',
				data:show_all,
				withCredentials: true});
			// return $http({method:'POST',url:url_server + 'appointmentstypes', data:show_all});
		},
		getSelect:function(){
			return $http({method:'POST',url:url_server + 'appointmentgroups/getall'});
		},
		getSelect2:function(filter){
			return $http({method:'POST',url:url_server + 'appointmentgroups/search',data:filter});
		},
		show:function(id){
			return $http({method:'GET',
				headers:headers,
				url:url_server + 'appointmentgroups/'+id,
				withCredentials: true});
			// return $http.get(url_server+ 'appointmentgroups/'+id);
		},
		getallappointmenttypesbygroup:function(id){
			return $http.get(url_server+ 'appointmentgroups/getalltypesbygroup/'+id);
		},
		save:function(appointmentgroupsData){
			return $http({method:'POST',
				headers:headers,
				url:url_server + 'appointmentgroups',
				data:appointmentgroupsData,
				withCredentials: true});
			// return $http({method:'POST',
			// 				url:url_server+'appointmentgroups',
			// 				data:appointmentgroupsData});
		},
		saveAppointmentType:function(appointmentgroupsData){
			return $http({method:'POST',
				headers:headers,
				url:url_server + 'addappointmenttype',
				data:appointmentgroupsData,
				withCredentials: true});
			// return $http({method:'POST',
			// 				url:url_server+'addappointmenttype',
			// 				data:appointmentgroupsData});
		},
		update:function(id, appointmentgroupsData){
			return $http.put(url_server+'appointmentgroups/'+id,appointmentgroupsData,{headers:headers, withCredentials: true });
			// return $http.put(url_server+'appointmentgroups/'+id,appointmentgroupsData);
		},
		destroy:function(id,status){
			return $http({method:'POST',
				headers:headers,
				url:url_server +'appointmentgroups/active',
				data:{id:id, status:status},
				withCredentials: true});
			// return $http({method:'POST',
			// 				url:url_server+'appointmentgroups/active',
			// 				data:{id:id, status:status}});
		},
		getUserByAppGroupId:function(id){
			return $http({method:'POST',url:url_server + 'appointmentgroups/getusersbyappgroup/'+id});
		}
	};
});
