Fix query to cater for branch code filter,fixed user login failed counter