/* * Gets the current occupancy (people that have bought daypasses) for a given day. */ func GetOccupancy(w http.ResponseWriter, r *http.Request) { r.ParseForm() var auth S.AuthToken var date string for k, v := range r.Form { if k == "user" { auth.User = strings.Join(v, "") } else if k == "date" { date = strings.Join(v, "") } else { auth.Code = strings.Join(v, "") } } if !db.Authenticate(auth) { fmt.Fprintf(w, "Please login") return } fmt.Fprintf(w, db.GetOccupancy(auth, date)) //if db.HasHotel(auth) { //} else { //fmt.Fprintf(w, "You do not work for a hotel") //} }
/* * Gets the current occupancy (people that have bought daypasses) for a given day. */ func GetOccupancy(w http.ResponseWriter, r *http.Request) { w.Header().Set("Access-Control-Allow-Origin", "*") w.Header().Set("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept") r.ParseForm() var auth S.AuthToken var date string hotel := "none" for k, v := range r.Form { if k == "user" { auth.User = strings.Join(v, "") } else if k == "date" { date = strings.Join(v, "") } else if k == "code" { auth.Code = strings.Join(v, "") } else if k == "hotel" { hotel = strings.Join(v, "") } } if !db.Authenticate(auth) || hotel == "none" { fmt.Fprintf(w, "{\"Please login\"}") return } occupancyString := strconv.Itoa(db.GetOccupancy(date, hotel)) fmt.Fprintf(w, occupancyString) //if db.HasHotel(auth) { //} else { //fmt.Fprintf(w, "You do not work for a hotel") //} }