Box modifications

This commit is contained in:
2016-10-18 11:10:01 -04:00
parent 3caf0bd766
commit fdc34c4ef7
109 changed files with 11033 additions and 2442 deletions
@@ -10,38 +10,33 @@
}
});
controller.$inject = ['$scope', 'inventorySvc', 'inventoryTypeSvc'];
function controller($scope, inventorySvc, inventoryTypeSvc) {
controller.$inject = ['$scope', 'inventorySvc'];
function controller($scope, inventorySvc) {
var vm = this;
vm.add = add;
vm.inventory = { };
vm.inventoryTypes = inventoryTypeSvc.inventoryTypes;
vm.programNames = [
"Admin",
"Aging",
"CC",
"CCFP",
"CIS",
"CSBG",
"Homemaker",
"HUD",
"Misdemeanor",
"Nutrition",
"Title V",
"Transportation",
"WAP",
"Workforce"
];
vm.saving = false;
vm.statusMessage = "Enter details for the inventory arrival below.";
vm.statusMessage = "Enter details for the inventory addition below.";
vm.errorMessages = [];
vm.quantity = quantity;
function zeroNaN(v) {
return isNaN(v) ? 0 : v;
}
function quantity() {
vm.inventory.quantity =
zeroNaN($scope.palletCount)
* zeroNaN($scope.casesPerPallet)
+ zeroNaN($scope.caseCount);
return vm.inventory.quantity > 0 ? vm.inventory.quantity : "";
}
$scope.$watch('vm.commodity', function (newValue) {
if (newValue)
vm.inventory.inventoryTypeId = newValue.id;
});
function add() {
vm.statusMessage = null;
vm.saving = true;
@@ -1,51 +0,0 @@
(function() {
"use strict";
window.app.directive('inventoryDistribute',
function() {
return {
templateUrl: '/inventory/template/inventoryDistribute.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
});
controller.$inject = ['$scope', 'inventorySvc'];
function controller($scope, inventorySvc) {
var vm = this;
vm.save = save;
vm.quantities = angular.copy(inventorySvc.inventories);
vm.distribution = {};
vm.saving = false;
vm.statusMessage = "Enter details for the inventory distribution below.";
vm.errorMessages = [];
function getInventoryDistributeQuantities(inventory) {
var invQty = [];
inventory.forEach(function (i) {
if (i.distributeQuantity > 0)
invQty.push({ inventoryId: i.id, quantity: i.distributeQuantity });
});
return invQty;
}
function save() {
vm.statusMessage = null;
vm.saving = true;
vm.distribution.inventoryQuantities = getInventoryDistributeQuantities(vm.quantities);
inventorySvc.distribute(vm.distribution)
.success(function () {
//Close the modal
$scope.$close();
})
.error(function(data) {
vm.errorMessages = angular.copy(data.errorMessages, vm.errorMessages);
})
.finally(function() {
vm.saving = false;
});
}
}
})();
@@ -17,6 +17,7 @@
function controller($scope, $uibModal, inventorySvc, transactionSvc) {
var vm = this;
vm.inventory = $scope.inventory;
vm.inventoryOriginal = angular.copy(vm.inventory);
vm.transactions = [];
function refreshTransactions() {
@@ -31,11 +32,15 @@
angular.copy(data.transactions, vm.transactions);
}
})
.finally(function(){vm.loadingTransactions = false;});
.finally(function() {
vm.loadingTransactions = false;
vm.inventoryOriginal = angular.copy(vm.inventory);
});
}
refreshTransactions(); // initial call
vm.save = save;
vm.cancel = cancel;
vm.deleteTransaction = deleteTransaction;
vm.removeInventory = removeInventory;
vm.saving = false;
@@ -43,6 +48,9 @@
vm.confirmDeleteTransaction = false;
vm.loadingTransactions = false;
vm.isShredReady = function () { return inventorySvc.isShredReady(vm.inventory); };
vm.isInInventory = function() { return vm.inventory.quantity > 0; }
function deleteTransaction(transactionId) {
vm.confirmDeleteTransaction = false;
transactionSvc
@@ -71,5 +79,10 @@
vm.saving = false;
});
}
function cancel() {
angular.copy(vm.inventoryOriginal, $scope.inventory);
$scope.$parent.$dismiss();
}
}
})();
@@ -0,0 +1,54 @@
(function() {
"use strict";
window.app.directive('inventoryImport',
function() {
return {
templateUrl: '/inventory/template/inventoryImport.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
};
});
controller.$inject = ['$scope', 'inventorySvc'];
function controller($scope, inventorySvc) {
var vm = this;
vm.uploading = false;
vm.file = "";
vm.statusMessage = "Import inventory items below.";
vm.errorMessages = [];
// upload later on form submit or something similar
vm.submit = function () {
if (vm.form.file.$valid && vm.file) {
vm.upload(vm.file);
}
};
// upload on file select or drop
vm.upload = function(file) {
vm.uploading = true;
inventorySvc
.importFile(file)
.then(function(resp) {
console.log("Success " + resp.config.data.file.name + "uploaded. Response: " + resp.data);
vm.uploading = false;
},
function (resp) {
if (angular.isArray(resp.data))
angular.copy(resp.data, vm.errorMessages);
else
angular.copy([resp.data], vm.errorMessages);
console.log("Error status: " + resp.status + " message: " + resp.data);
vm.uploading = false;
},
function(evt) {
var progressPercentage = parseInt(100.0 * evt.loaded / evt.total);
console.log("progress: " + progressPercentage + "% " + evt.config.data.file.name);
});
};
}
})();
@@ -27,6 +27,13 @@
inventorySvc.exportInventory()
.success(downloadSvc.success);
};
vm.import = function() {
$uibModal.open({
template: "<inventory-import />",
backdrop: "static"
});
};
}
]);
})();
@@ -11,8 +11,8 @@
}
});
controller.$inject = ['$scope', '$uibModal'];
function controller($scope, $uibModal) {
controller.$inject = ['$scope', '$uibModal', 'inventorySvc'];
function controller($scope, $uibModal, inventorySvc) {
var vm = this;
vm.inventories = $scope.inventories;
@@ -32,5 +32,7 @@
scope: angular.extend($scope.$new(true), { inventory: inventory })
});
}
vm.isShredReady = inventorySvc.isShredReady;
}
})();
@@ -11,9 +11,13 @@
}
});
controller.$inject = ['$scope'];
function controller($scope) {
controller.$inject = ['$scope', 'inventorySvc'];
function controller($scope, inventorySvc) {
var vm = this;
vm.inventory = $scope.inventory;
vm.isShredReady = function () { return inventorySvc.isShredReady(vm.inventory); };
vm.isInInventory = function() { return vm.inventory.quantity > 0; }
}
})();
@@ -21,7 +21,7 @@
vm.removeForm = {
inventoryId: vm.inventory.id,
quantity: vm.inventory.quantity,
transactionType: vm.inventory.isExpired ? "Expired" : null
transactionType: vm.inventory.shredReadyDate ? "Shreded" : null
};
vm.statusMessage = "Enter details for the inventory removal below.";
@@ -1,8 +1,8 @@
(function() {
window.app.factory("inventorySvc",
[
"$http", "$filter",
function($http, $filter) {
"$http", "$filter", 'Upload',
function($http, $filter, Upload) {
var inventories = [];
loadInventories();
@@ -15,8 +15,10 @@
inventories: inventories,
get: get,
refresh: refresh,
find: find,
exportInventory: exportInventory
load: load,
exportInventory: exportInventory,
isShredReady: isShredReady,
importFile: importFile
};
return svc;
@@ -73,15 +75,34 @@
function refresh(id) {
var existingInventory = get(id);
if (existingInventory) {
find(id)
load(id)
.success(function(inventory) {
angular.copy(inventory, existingInventory);
});
}
}
function find(id) {
return $http.post("/Inventory/Find", { id: id });
function load(id) {
return $http.post("/Inventory/Find", { id: id })
.success(function (inventory) {
var existingInventory = get(id);
if (existingInventory != null)
angular.copy(inventory, existingInventory);
else
inventories.unshift(inventory);
});
}
function importFile(file) {
return Upload.upload({
url: "/api/Import",
method: 'POST',
data: { file: file}
});
}
function isShredReady(inventory) {
return new Date(inventory.shredReadyDate) <= new Date();
}
}
]);
@@ -9,78 +9,40 @@
<fieldset ng-disabled="vm.saving">
<div class="modal-header">
<h3 class="modal-title"><i class="fa fa-cubes"></i> Inventory Arrival</h3>
<h3 class="modal-title"><i class="fa fa-cubes"></i> Inventory Addition</h3>
</div>
<div class="modal-body">
<status-message message="vm.statusMessage"></status-message>
<status-message message="vm.statusMessage" ng-hide="vm.errorMessages.length"></status-message>
<error-list errors="vm.errorMessages"></error-list>
<script type="text/ng-template" id="commodityTypeahead.html">
<script type="text/ng-template" id="programTypeahead.html">
<a>
<span ng-bind-html="match.label.name | uibTypeaheadHighlight:query"></span>
</a>
</script>
<div class="form-group" form-group-validation="Commodity">
<label for="Commodity" class="control-label">Commodity</label>
<input name="Commodity" type="text"
ng-model="vm.commodity"
@inventory.FormGroupFor(m => m.Id)
<div class="form-group" form-group-validation="ProgramName">
<label for="ProgramName" class="control-label">Program Name</label>
<input name="ProgramName" type="text"
ng-model="vm.inventory.programName"
required
uib-typeahead=
"inventoryType as inventoryType.name for inventoryType in vm.inventoryTypes
| filter:{name:$viewValue}
| limitTo:8"
typeahead-editable='false'
"programName for programName in vm.programNames
|filter:$viewValue
| limitTo:8"
class="form-control">
<i class="fa fa-search form-control-feedback"></i>
<div class="panel panel-default" ng-show="vm.commodity.id">
<div class="panel-body">
<dl class="dl-horizontal">
<dt>Commodity ID</dt>
<dd>{{vm.commodity.identifier}}</dd>
<dt>Units per Case</dt>
<dd>{{vm.commodity.unitsPerCase}} / {{vm.commodity.containerType}}</dd>
</dl>
</div>
</div>
</div>
@inventory.FormGroupFor(m => m.ExpirationDate)
<div class="form-group panel panel-default">
<div class="panel-heading"><label>Quantity</label></div>
<div class="panel-body container-fluid">
<div class="row">
<div class="col-sm-5"><label for="PalletCount">Pallets</label></div>
<div class="col-sm-3">
<input ng-model="palletCount" name="PalletCount" type="number" class="form-control" />
</div>
</div>
<div class="row">
<div class="col-sm-4 col-sm-offset-1"><label for="CasesPerPallet">Cases per Pallet</label></div>
<div class="col-sm-3">
<input ng-model="casesPerPallet" name="CasesPerPallet" type="number" class="form-control" />
</div>
</div>
<hr />
<div class="row">
<div class="col-sm-5"><label for="CaseCount">Individual Cases</label></div>
<div class="col-sm-3">
<input ng-model="caseCount" name="CaseCount" type="number" class="form-control" />
</div>
</div>
<hr />
<div class="row">
<div class="col-sm-5"><strong>Total Units</strong></div>
<div class="col-sm-3"><strong>{{vm.quantity()}}</strong></div>
</div>
</div>
</div>
@inventory.FormGroupFor(m => m.AddedDate)
@inventory.FormGroupFor(m => m.Memo)
@inventory.FormGroupFor(m => m.ProgramSubtype)
@inventory.FormGroupFor(m => m.Description)
@inventory.FormGroupFor(m => m.ShredReadyDate)
@inventory.FormGroupFor(m => m.AddedDate)
@inventory.FormGroupFor(m => m.Memo)
</div>
@@ -1,63 +0,0 @@
@using InventoryTraker.Web.Helpers
@model InventoryTraker.Web.Models.InventoryDistributeForm
@{
var distribution = Html.Angular().ModelFor("vm.distribution");
}
<form novalidate
name="vm.form"
ng-submit="vm.form.$valid && vm.save()">
<fieldset ng-disabled="vm.saving">
<div class="modal-header">
<h3 class="modal-title"><i class="fa fa-cubes"></i> Inventory Distribution</h3>
</div>
<div class="modal-body">
<status-message message="vm.statusMessage"></status-message>
<error-list errors="vm.errorMessages"></error-list>
@distribution.FormGroupFor(m => m.Destination)
@distribution.FormGroupFor(m => m.DistributedDate)
@distribution.FormGroupFor(m => m.Memo)
<table class="table table-condensed" ng-class="vm.getValidationClass()">
<thead>
<tr>
<th>Name<br/>Units per Case</th>
<th>Expiration Date</th>
<th>Available Case Qty</th>
<th>Distribute Case Qty</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="inventory in vm.quantities" inventory="inventory">
<td>
{{inventory.name}}<br/>
{{inventory.unitsPerCase}} / {{inventory.containerType}}<br/>
</td>
<td ng-class="{ danger: inventory.isExpired }">{{inventory.expirationDate | date:'shortDate'}}</td>
<td>{{inventory.quantity}}</td>
<td>
<div class="form-group col-sm-9" form-group-validation="DistributeQuantity{{inventory.name}}">
<input name="DistributeQuantity{{inventory.name}}" type="number"
class="form-control"
ng-model="inventory.distributeQuantity"
ng-max="{{inventory.quantity}}"
ng-min="0" />
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer">
<button class="btn btn-success" ng-disabled="vm.form.$invalid || vm.form.$pristine">Save</button>
<button type="button" class="btn" ng-click="$dismiss()">Cancel</button>
</div>
</fieldset>
</form>
@@ -1,4 +1,8 @@
@model InventoryTraker.Web.Models.InventoryAddForm
@using InventoryTraker.Web.Helpers
@model InventoryTraker.Web.Models.InventoryAddForm
@{
var inventory = Html.Angular().ModelFor("vm.inventory");
}
<form novalidate
name="vm.form"
ng-submit="vm.form.$valid && vm.save()">
@@ -12,11 +16,22 @@
<error-list errors="vm.errorMessages"></error-list>
<inventory-info inventory="inventory"></inventory-info>
<label class="control-label">Box Id</label>
<p class="form-control-static">{{vm.inventory.id}}</p>
<label class="control-label">Program Name</label>
<p class="form-control-static">{{vm.inventory.programName}}<span ng-show="vm.inventory.programSubtype != null"> / {{vm.inventory.programSubtype}}</span></p>
@inventory.FormGroupFor(m => m.Description)
<label class="control-label">Currently in Inventory</label>
<p class="form-control-static">{{vm.isInInventory() ? "Yes" : "No"}}</p>
@inventory.FormGroupFor(m => m.ShredReadyDate)
<label class="control-label">Added Date</label>
<p class="form-control-static">{{vm.inventory.addedDate | date:'shortDate'}}</p>
@inventory.FormGroupFor(m => m.Memo)
<div class="modal-footer">
<button ng-click="vm.removeInventory()" class="btn btn-sm pull-left"><i class="fa fa-minus-circle"></i> Remove Inventory</button>
<button type="button" class="btn btn-sm pull-left" ng-click="vm.removeInventory()"><i class="fa fa-minus-circle"></i> Remove Inventory</button>
<button class="btn btn-success" ng-disabled="vm.form.$invalid || vm.form.$pristine">Save</button>
<button type="button" class="btn" ng-click="$parent.$dismiss()">Cancel</button>
<button type="button" class="btn" ng-click="vm.cancel()">Close</button>
</div>
<hr />
@@ -29,23 +44,16 @@
<th>Type</th>
<th>Memo</th>
<th>Transaction Date</th>
<th>Add Qty</th>
<th>Remove Qty</th>
<th>Qty</th>
<th>In Inventory</th>
<th></th>
</tr>
</thead>
<tbody ng-hide="vm.loadingTransactions">
<tr ng-repeat-start="transaction in vm.transactions | orderBy:['-transactionDate', 'currentQuantity']">
<td>
{{transaction.transactionType}}
<span ng-show="transaction.destination"><i class="fa fa-map-marker" title="{{transaction.destination}}"></i></span>
</td>
<td>{{transaction.transactionType}}</td>
<td>{{transaction.memo}}</td>
<td>{{transaction.transactionDate | date:'shortDate'}}</td>
<td>{{transaction.addedQuantity}}</td>
<td>{{transaction.removedQuantity}}</td>
<td>{{transaction.currentQuantity}}</td>
<td>{{transaction.currentQuantity > 0 ? "Yes" : "No"}}</td>
<td>
<a href="" ng-show="$first"
ng-click="vm.confirmDeleteTransaction = !vm.confirmDeleteTransaction">
@@ -0,0 +1,32 @@
<form novalidate
name="vm.form"
ng-submit="vm.form.$valid && vm.submit()">
<fieldset ng-disabled="vm.uploading">
<div class="modal-header">
<h3 class="modal-title"><i class="fa fa-cubes"></i> Inventory Import</h3>
</div>
<div class="modal-body">
<status-message message="vm.statusMessage" ng-hide="vm.errorMessages.length"></status-message>
<error-list errors="vm.errorMessages"></error-list>
<div class="btn btn-default"
ngf-select
ng-model="vm.file"
name="file"
ngf-pattern="'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'"
ngf-accept="'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'">Select</div>
<div>{{vm.file.name}}</div>
</div>
<div class="modal-footer">
<button class="btn btn-success" ng-disabled="vm.form.$invalid || vm.form.$pristine">Submit</button>
<button type="button" class="btn" ng-click="$dismiss()">Cancel</button>
</div>
</fieldset>
</form>
@@ -1,19 +1,19 @@
<dl class="dl-horizontal">
<dt>Name</dt>
<dd>{{inventory.name}}</dd>
<dt>Units per Case</dt>
<dd>{{inventory.unitsPerCase}} / {{inventory.containerType}}</dd>
<dt>Added Date</dt>
<dd>{{inventory.addedDate | date:'shortDate'}}</dd>
<dt>Expiration Date</dt>
<dt>Box Id</dt>
<dd>{{inventory.id}}</dd>
<dt>Program Name</dt>
<dd>{{inventory.programName}}<span ng-show="inventory.programSubtype != null"> / {{inventory.programSubtype}}</span></dd>
<dt>Currently in Inventory</dt>
<dd>{{vm.isInInventory() ? "Yes" : "No"}}</dd>
<dt>Shred Ready Date</dt>
<dd>
<span ng-class="{ 'bg-danger': inventory.quantity && inventory.isExpired }">
{{inventory.expirationDate | date:'shortDate'}}
<span ng-show="inventory.isExpired" class="label label-danger">Expired</span>
<span ng-class="{ 'bg-danger': inventory.quantity && vm.isShredReady() }">
{{inventory.shredReadyDate | date:'shortDate'}}
<span ng-show="vm.isShredReady()" class="label label-danger">Shred Ready</span>
</span>
</dd>
<dt>Quantity (in Cases)</dt>
<dd>{{inventory.quantity}}</dd>
<dt>Added Date</dt>
<dd>{{inventory.addedDate | date:'shortDate'}}</dd>
<dt ng-show="inventory.memo">Memo</dt>
<dd ng-show="inventory.memo">{{inventory.memo}}</dd>
</dl>
@@ -8,26 +8,24 @@
<thead>
<tr>
<th class="control-column"></th>
<th>Name</th>
<th>Units per Case</th>
<th>Case Qty</th>
<th>Unit Qty</th>
<th>Exp Date</th>
<th>Id</th>
<th>Program Name</th>
<th>Description</th>
<th>Shred Ready Date</th>
<th>Added Date</th>
<th>Memo</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="inventory in vm.inventories | filter:{name: ''}">
<tr ng-repeat="inventory in vm.inventories | filter:{quantity: 1}">
<td>
<a href="" ng-click="vm.edit(inventory)" title="Details"><i class="fa fa-edit"></i></a>
</td>
<td>@inventory.BindingFor(x => x.Name)</td>
<td>@inventory.BindingFor(x => x.UnitsPerCase) / @inventory.BindingFor(x => x.ContainerType)</td>
<td>@inventory.BindingFor(x => x.Quantity)</td>
<td>{{inventory.quantity * inventory.unitsPerCase}}</td>
<td ng-class="{ danger: inventory.isExpired }">
@inventory.BindingFor(x => x.ExpirationDate, "date:'shortDate'")
<td>@inventory.BindingFor(x => x.Id)</td>
<td>@inventory.BindingFor(x => x.ProgramName)</td>
<td>@inventory.BindingFor(x => x.Description)</td>
<td ng-class="{ danger: vm.isShredReady(inventory) }">
@inventory.BindingFor(x => x.ShredReadyDate, "date:'shortDate'")
</td>
<td>@inventory.BindingFor(x => x.AddedDate, "date:'shortDate'")</td>
<td>@inventory.BindingFor(x => x.Memo)</td>
@@ -14,7 +14,7 @@
<div class="modal-body">
<status-message message="vm.statusMessage"></status-message>
<status-message message="vm.statusMessage" ng-hide="vm.errorMessages.length"></status-message>
<error-list errors="vm.errorMessages"></error-list>
<div class="panel panel-default">
@@ -27,9 +27,9 @@
<label class="radio-inline">
<input type="radio" name="TransactionType"
ng-model="vm.removeForm.transactionType"
value="Expired"
value="Shreded"
required />
Expired
Shreded
</label>
<label class="radio-inline">
<input type="radio" name="TransactionType"
@@ -40,7 +40,6 @@
</label>
</div>
@removeForm.FormGroupFor(m => m.Quantity)
@removeForm.FormGroupFor(m => m.RemovedDate)
@removeForm.FormGroupFor(m => m.Memo)