commit cb5a1d0596f42ef22663c4514785355800238356
parent 5c887f7d94399c072fdfd1977f00e41653baa4f5
Author: felicitus <felicitus@felicitus.org>
Date: Thu, 5 Jul 2012 22:57:06 +0200
Filter for all parts which haven't ever been removed from the stock. Quite handy to identify "useless" parts, especially in combination with the create date filter
Diffstat:
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/src/backend/PartKeepr/Part/PartService.php b/src/backend/PartKeepr/Part/PartService.php
@@ -128,6 +128,20 @@ class PartService extends Service implements RestfulService {
// Do nothing for now
}
}
+
+ if ($this->getParameter("withoutStockRemovals", false) === true || $this->getParameter("withoutStockRemovals", false) === "true") {
+ $q = PartKeepr::getEM()->createQueryBuilder();
+ $q->select("p.id")->from("PartKeepr\Part\Part", "p")->leftJoin("p.stockLevels", "sl")->where("sl.stockLevel < 0");
+ $query = $q->getQuery();
+
+ $result = $query->getResult();
+ $filter = array();
+ foreach ($result as $res) {
+ $filter[] = $res["id"];
+ }
+
+ $queryBuilder->andWhere("q.id NOT IN (".implode(",", $filter).")");
+ }
}
/**
diff --git a/src/frontend/js/Components/Part/PartFilterPanel.js b/src/frontend/js/Components/Part/PartFilterPanel.js
@@ -23,7 +23,8 @@ Ext.define('PartKeepr.PartFilterPanel', {
this.storageLocationFilter,
this.categoryFilter,
this.partsWithoutPrice,
- this.createDateFilter
+ this.createDateFilter,
+ this.partsWithoutStockRemovals
]
};
@@ -88,6 +89,11 @@ Ext.define('PartKeepr.PartFilterPanel', {
this.stockFilter.setValue({ stock: 'any'});
this.distributorOrderNumberFilter.setValue("");
+ this.createDateFilterSelect.setValue("");
+ this.createDateField.setValue("");
+ this.partsWithoutStockRemovals.setValue(false);
+ this.partsWithoutPrice.setValue(false);
+
this.onApply();
},
/**
@@ -187,6 +193,11 @@ Ext.define('PartKeepr.PartFilterPanel', {
items: [ this.createDateFilterSelect, this.createDateField ]
};
+ this.partsWithoutStockRemovals = Ext.create("Ext.form.field.Checkbox", {
+ fieldLabel: i18n("Stock Settings"),
+ boxLabel: i18n("Show Parts without stock removals only")
+ });
+
},
/**
* Applies the filter parameters to the passed extraParams object.
@@ -209,7 +220,7 @@ Ext.define('PartKeepr.PartFilterPanel', {
extraParams.createDateRestriction = this.createDateFilterSelect.getValue();
extraParams.createDate = Ext.util.Format.date(this.createDateField.getValue(), "Y-m-d H:i:s");
-
+ extraParams.withoutStockRemovals = this.partsWithoutStockRemovals.getValue();
}