         </button>
       </td>
     </tr>
-  """)
+  """
+
   category = newRow.find ".category"
   populateCategories category
-  $("#new-order-table tbody").append newRow
+  $("#order-table tbody").append newRow
 
-printOrder = ->
-  window.print()
-
-$(document).on "click", ".add-item", (event) ->
-  event.preventDefault()
-  event.stopPropagation()
-  $("#add_inventory_modal").modal("show")
-
-$(document).on "click", "#add-item-row", (event) ->
-  event.preventDefault()
-  addNewOrderRow()
-
-$(document).on "click", ".delete-row", (event) ->
-  event.preventDefault()
-  $(@).parents("tr:first").remove()
-  addNewOrderRow() if $("#new-order-table tbody tr").length == 0
-
-$(document).on "click", "#print-order", (event) ->
-  printOrder()
-
-$(document).on "click", "#add-tracking-number", (event) ->
-  event.preventDefault()
+addTrackingRow = ->
   newRow = $ """
     <tr>
       <td>

  $("#shipments-table tbody").append newRow
  $("#shipments-table").show()

$(document).on "change", ".new-order-row .category", ->
  item_element = $(@).parents(".new-order-row").find ".item"
  populateItems $(@).val(), item_element

$(document).on "change", ".new-order-row .item", ->
  quantity_element = $(@).parents(".new-order-row").find ".quantity"
  selected = $(@).find('option:selected')
  populateQuantity selected, quantity_element

$(document).on "page:change", ->
  addNewOrderRow() if $("#new-order-table").length > 0

    element.append """<option value="#{id}" data-current-quantity="#{current_quantity}" data-requested-quantity="#{requested_quantity}">#{description}</option>"""

populateQuantity = (selected, element) ->
  available_quantity = selected.data("current-quantity") - selected.data("requested-quantity")
  element.attr("data-guard", "required int")
  element.attr("data-guard-int-min", "1").data("guard-int-min", 1)
  element.attr("data-guard-int-max", available_quantity).data("guard-int-max", available_quantity)

  element.val("").clearErrors()

populateQuantityAvailable = (selected, element) ->
  available_quantity = selected.data("current-quantity") - selected.data("requested-quantity")
  element.text(available_quantity)

window.setOrderRow = (order_details) ->
  row = $("#order-table tbody tr:last")
  category = row.find(".category")
  item = row.find(".item")
  quantity = row.find(".quantity")

  category.val order_details.category_id
  category.trigger "change"
  item.val order_details.item_id
  item.trigger "change"
  quantity.val order_details.quantity

callback = -> something param

window.addOrderRow = ->
  newRow = $ """
    <tr class="order-row">
      <td>
        <div class="form-group">
          <select class="category form-control" data-guard="required">
            <option value="">Select a category...</option>
          </select>
        </div>
      </td>
      <td>
        <div class="form-group">
          <select name="order_detail[#{currentNumRows}][item_id]" class="item form-control" data-guard="different required">
            <option value="">Select an item...</option>
          </select>
        </div>
      </td>
      <td>
        <div class="form-group">
          <input name="order_detail[#{currentNumRows}][quantity]" class="quantity form-control" placeholder="Select an Item..." data-guard="required" />
        </div>
      </td>
      <td class="text-muted">
        <p class="quantity-available form-control-static">
        </p>
      </td>
      <td>
        <button class="pull-right btn btn-danger btn-xs delete-row">
