 # All this logic will automatically be available in application.js.
 # You can use CoffeeScript in this file: http://coffeescript.org/
 printer_local_storage_key = "last-printer-used"
+cid_local_storage_key = "cid"
 
 $ ->
   printer_name = localStorage.getItem(printer_local_storage_key)
+  cid = localStorage.getItem(cid_local_storage_key)
+
+
+  if (cid)
+    $('#print_username').val(cid)
 
   if $('#print_printer').length
 

    $('#new_print').on 'submit', (e) ->
      e.preventDefault()
      form = new FormData(this)

      $.ajax
        url: this.action,

      .success (data) ->
        $('.printer-feedback-alert').hide()
        $('.printer-feedback-success').show()
        localStorage.setItem(cid_local_storage_key, newCid)
      .error (err) ->
        errors = err.responseJSON.errors
        $('.printer-feedback-alert .msg').html($('<ul/>').html(errors.map (err) -> $('<li/>').text(err)))
