extends /templates/core/modal-base-flat

// DNT

block modal-header-content
  .pull-right
    if view.user.isStudent()
      button#destudent-btn.btn.btn-burgandy Destudent
    if view.user.isTeacher()
      button#deteacher-btn.btn.btn-burgandy Deteacher
  
  h3 Administer User
  h4 #{view.user.get('name') || 'Unnamed'} / #{view.user.get('email')}
  span= view.user.id

block modal-body-content

  h3.m-t-3 Grant Student Licenses
  #prepaid-form.form
    if view.state === 'creating-prepaid'
      .progress.progress-striped.active
        .progress-bar(style="width: 100%")

    else if view.state === 'made-prepaid'
      .alert.alert-success Licenses created!

    else
      .form-group
        label Number of Licenses
        input#seats-input.form-control(type="number", name="maxRedeemers")
      .form-group
        label Start Date
        input.form-control(type="date" name="startDate" value=moment().format('YYYY-MM-DD'))
      .form-group
        label End Date
        input.form-control(type="date" name="endDate" value=moment().add(1, 'year').format('YYYY-MM-DD')))
      .form-group
        button#add-seats-btn.btn.btn-primary Add Licenses

  if view.prepaids.size()
    h3.m-t-3 Existing Prepaids
    table.table.table-condensed
      tr
        th ID
        th Type
        th Start
        th End
        th Used
      for prepaid in view.prepaids.models
        tr
          td= prepaid.id
          td= prepaid.get('type')
          td
            if prepaid.get('startDate')
              = moment(prepaid.get('startDate')).utc().format('lll')
          td
            if prepaid.get('endDate')
              = moment(prepaid.get('endDate')).utc().format('lll')
          td #{(prepaid.get('redeemers') || []).length} / #{prepaid.get('maxRedeemers') || 0}

  h3 Stripe Benefit
  .form
    .form-group
      .radio
        label
          input(type="radio" name="stripe-benefit" value="" checked=view.none)
          | None
      .radio
        label
          input(type="radio" name="stripe-benefit" value="free" checked=view.free)
          | Free
      .radio
        label
          input(type="radio" name="stripe-benefit" value="free-until" checked=view.freeUntil)
          | Free Until
          input.form-control.spl(type="date" name="stripe-free-until" value=view.freeUntilDate)#free-until-date
      .radio
        label
          input(type="radio" name="stripe-benefit" value="coupon" checked=view.coupon)
          | Coupon
        select.form-control#coupon-select
          for coupon in view.coupons.models
            option(value=coupon.id selected=coupon.id===view.currentCouponID)= coupon.formatString()
    button#save-changes.btn.btn-primary Save Changes
  
  if view.classrooms.size()
    h3.m-t-3 Update Classrooms
    table#classroom-table.table
      tr
        th Name
        th # Levels
        th
      for classroom in view.classrooms.models
        tr
          td= classroom.get('name')
          td= classroom.getLevels().size()
          td
            button.btn.btn-primary.update-classroom-btn(data-classroom-id=classroom.id) Update

block modal-footer
