'use strict';

angular.module('inventory.controllers')
  .controller('OrderTableCtrl', ['$scope', 'orderService', 'formService',
    function ($scope, orderService, formService) {
      $scope.inventoryOrders = $scope.parts.inventoryOrders;

      $scope.deliveredOrders = function (orders) {
        return orderService.selectDelivered(orders);
      };

      $scope.isDelivered = function (order) {
        return orderService.isDelivered(order.status);
      };

      $scope.openEditOrderForm = function (inventoryOrder) {
        var modalInstance = null;

        $scope.orderFormInputs = {
          id: inventoryOrder.id,
          statusChangedDate: new Date()
        };

        $scope.statusList = orderService.nextStatusList(inventoryOrder.status);

        $scope.editOrder = function () {
          orderService.edit($scope.orderFormInputs)
            .then(function () {
              $scope.reloadProduct();
              modalInstance.close();
            });
        };

        $scope.removeOrderAlert = function () {
          var removeAlertInstance = null;

          removeAlertInstance.close();

          $scope.removeAlertMessage = 'Are you sure to remove the order?';

          $scope.removeAlertFunc = function () {
            orderService.remove($scope.orderFormInputs.id)
              .then(function () {
                $scope.reloadProduct();
                removeAlertInstance.close();
              });
          };

          modalInstance = formService.openRemoveAlert($scope);
        };

        modalInstance = formService.openForm({
          templateUrl: '/views/inventories/modals/edit-order-form.html',
          scope: $scope
        });
      };
    }]);

@@ -1082,35 +1082,29 @@
 %0A%0A          
-removeAlert
+modal
 Instance.clo
@@ -1447,37 +1447,43 @@
   %7D;%0A%0A          
-modal
+removeAlert
 Instance = formS

Fix removing the order of inventory