commit 305cf332308f297e0527e1cae8b4504d957f469d
parent d1df272fc985b9c45c52988ee5bf51f1ce2f35f9
Author: Timo A. Hummel <timo@netraver.de>
Date: Wed, 8 Jun 2011 22:34:37 +0200
Added filter for empty price
Diffstat:
3 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/frontend/js/Components/Part/PartsGrid.js b/frontend/js/Components/Part/PartsGrid.js
@@ -42,6 +42,8 @@ Ext.define('PartDB2.PartsGrid', {
stockModeZeroIcon: 'resources/icons/stock_zero.png',
stockModeNonzeroIcon: 'resources/icons/stock_nonzero.png',
+ partsWithoutPriceText: i18n("Parts without price"),
+
stockModes: [ "all", "nonzero", "zero", "below" ],
initComponent: function () {
@@ -106,11 +108,25 @@ Ext.define('PartDB2.PartsGrid', {
}
});
+ this.priceModeButton = Ext.create("Ext.button.Button", {
+ enableToggle: true,
+ text: this.partsWithoutPriceText,
+ handler: this.priceModeHandler,
+ scope: this
+ });
+
this.bottomToolbar.add('-');
this.bottomToolbar.add(this.categoryScopeButton);
this.bottomToolbar.add(this.stockModeButton);
+ this.bottomToolbar.add(this.priceModeButton);
this.setScopeMode("all");
},
+ priceModeHandler: function () {
+ var proxy = this.store.getProxy();
+ proxy.extraParams.withoutPrice = this.priceModeButton.pressed;
+
+ this.store.load();
+ },
categoryModeButtonHandler: function () {
if (this.categoryScope == "all") {
this.setScopeMode("selected");
diff --git a/src/de/RaumZeitLabor/PartDB2/Part/PartManager.php b/src/de/RaumZeitLabor/PartDB2/Part/PartManager.php
@@ -25,7 +25,7 @@ use de\RaumZeitLabor\PartDB2\Util\Singleton,
de\RaumZeitLabor\PartDB2\Footprint\Exceptions\FootprintNotFoundException;
class PartManager extends Singleton {
- public function getParts ($start = 0, $limit = 10, $sort = "name", $dir = "asc", $filter = "", $category = 0, $categoryScope = "all", $stockMode = "all") {
+ public function getParts ($start = 0, $limit = 10, $sort = "name", $dir = "asc", $filter = "", $category = 0, $categoryScope = "all", $stockMode = "all", $withoutPrice = false) {
$qb = PartDB2::getEM()->createQueryBuilder();
$qb->select("COUNT(p.id)")->from("de\RaumZeitLabor\PartDB2\Part\Part","p")
@@ -84,6 +84,10 @@ class PartManager extends Singleton {
break;
}
+ if ($withoutPrice === true || $withoutPrice === "true") {
+ $qb->andWhere("p.averagePrice IS NULL");
+ }
+
$totalQuery = $qb->getQuery();
diff --git a/src/de/RaumZeitLabor/PartDB2/Part/PartService.php b/src/de/RaumZeitLabor/PartDB2/Part/PartService.php
@@ -32,7 +32,8 @@ class PartService extends Service implements RestfulService {
$this->getParameter("query", ""),
$this->getParameter("category", 0),
$this->getParameter("categoryScope", "all"),
- $this->getParameter("stockMode", "all"));
+ $this->getParameter("stockMode", "all"),
+ $this->getParameter("withoutPrice", false));
}
}