       @people[id] = new CheckinPerson($("#person_#{id}"))
     $('#add-a-guest').click(@addGuest)
     $('.checkin-print .btn').click(@print)
-    @sp = new SonicProtocol(true)
+    @sp = new SonicProtocol()
     @sp.listen()
     @
-
 
   selectPerson: (e) =>
     e.preventDefault()

    )
    ssocket.send message.split('').join('.')

checkin = new Checkin().render()

        alert("should print #{labels.length} label(s) - NOT YET IMPLEMENTED")
        location.replace('/checkin')


class CheckinPerson

  constructor: (@elm) ->
    @id = @elm.data('id')
    @button = $(".checkin-select-person[data-id='#{@id}']")
    @times = {}
    for time in @elm.find('.checkin-time')
      @times[$(time).data('id')] = new CheckinTime($(time), this)
    @elm.find('.same-as-last-week').click(@sameAsLastWeek)

  load: (data) =>
    for checkin_time_id, records of data
      @times[checkin_time_id]?.load(records)

  show: =>
    @elm.show()
    @button.addClass('active')
    t.show() for _, t of @times

  hide: =>
    @elm.hide()
    t.hide() for _, t of @times
    @button.removeClass('active')

  sameAsLastWeek: (e) =>
    e.preventDefault()
    elm = $(e.delegateTarget)
    for id in elm.data('ids').split(',')
      [time_id, group_id] = id.split('-')
      @times[time_id]?.load([{group_id: group_id}])

  classSelected: (id) =>
    @elm.find('.checkin-same').hide()
    @selected = true
    @button.find('.status').removeClass('fa-chevron-right').addClass('fa-check text-green')
    checkin.personCheckedIn(@id, @selections())

  classUnselected: (id) =>
    count = (t for _, t of @times when t.selected).length
    if count == 0
      @elm.find('.checkin-same').show()
      @selected = false
      @button.find('.status').removeClass('fa-check text-green').addClass('fa-chevron-right')
    checkin.personCheckedIn(@id, @selections())

  selections: =>
    obj = {}
    for id, time of @times
      obj[id] = time.selected
    obj


class CheckinTime
