 app = angular.module('order_cycle', ['ngResource'])
 
-app.controller 'AdminCreateOrderCycleCtrl', ($scope, OrderCycle, Enterprise) ->
+app.controller 'AdminCreateOrderCycleCtrl', ['$scope', 'OrderCycle', 'Enterprise', ($scope, OrderCycle, Enterprise) ->
   $scope.enterprises = Enterprise.index()
   $scope.supplied_products = Enterprise.supplied_products
 


  $scope.submit = ->
    OrderCycle.update()


app.config ($httpProvider) ->
  $httpProvider.defaults.headers.common['X-CSRF-Token'] = $('meta[name=csrf-token]').attr('content')

app.factory 'OrderCycle', ($resource, $window) ->
  OrderCycle = $resource '/admin/order_cycles/:order_cycle_id.json', {}, {
    'index':  { method: 'GET', isArray: true}
		'create': { method: 'POST'}

        (exchange for exchange in this.order_cycle.incoming_exchanges when exchange.active)
      this.order_cycle.outgoing_exchanges =
        (exchange for exchange in this.order_cycle.outgoing_exchanges when exchange.active)
  }]

app.factory 'Enterprise', ['$resource', ($resource) ->
  Enterprise = $resource('/admin/enterprises/:enterprise_id.json', {}, {'index': {method: 'GET', isArray: true}})

  {
