commit 38c8024fe68b8b55134eaf98621ab61591fb9570
parent 333f5d8efdf196a1d6a398b9060ad78f242ffc1c
Author: Timo A. Hummel <felicitus@felicitus.org>
Date: Tue, 1 Jan 2013 23:40:40 -0800
Merge pull request #267 from mwolff79/partcondition
Added partCondition field to be used for part condition. i.e. New. Used,...
Diffstat:
8 files changed, 123 insertions(+), 14 deletions(-)
diff --git a/src/backend/PartKeepr/Part/Part.php b/src/backend/PartKeepr/Part/Part.php
@@ -150,6 +150,13 @@ class Part extends BaseEntity implements Serializable, Deserializable {
* @var boolean
*/
private $needsReview;
+
+ /**
+ * Defines the condition of the part
+ * @Column(type="string",nullable=true)
+ * @var string
+ */
+ private $partCondition;
/**
* The create date+time for this part
@@ -279,6 +286,23 @@ class Part extends BaseEntity implements Serializable, Deserializable {
public function getReviewFlag () {
return $this->needsReview;
}
+
+ /**
+ * Sets the condition for this part
+ * @param string $partCondition The part's condition
+ */
+ public function setCondition ($partCondition) {
+ $this->partCondition = $partCondition;
+ }
+
+ /**
+ * Returns the condition of this part
+ * @return string The part condition
+ */
+ public function getCondition () {
+ return $this->partCondition;
+ }
+
/**
* Set the minimum stock level for this part
@@ -491,6 +515,7 @@ class Part extends BaseEntity implements Serializable, Deserializable {
"parameters" => $this->serializeChildren($this->getParameters()),
"createDate" => $this->getCreateDate()->format("Y-m-d H:i:s"),
"needsReview" => $this->getReviewFlag(),
+ "partCondition" => $this->getCondition(),
"internalPartNumber" => $this->getInternalPartNumber(),
// Additional things we serialize to make displaying stuff in the frontend easier
"categoryName" => is_object($this->category) ? $this->category->getName() : null,
@@ -569,6 +594,9 @@ class Part extends BaseEntity implements Serializable, Deserializable {
case "needsReview":
$this->setReviewFlag($value);
break;
+ case "partCondition":
+ $this->setCondition($value);
+ break;
case "attachments":
$this->deserializeChildren($value, $this->getAttachments(), "PartKeepr\Part\PartAttachment");
foreach ($this->getAttachments() as $attachment) {
diff --git a/src/backend/PartKeepr/Part/PartManager.php b/src/backend/PartKeepr/Part/PartManager.php
@@ -47,7 +47,7 @@ class PartManager extends AbstractManager {
"minStockLevel", "comment", "st.id AS storageLocation_id", "c.categoryPath AS categoryPath",
"st.name as storageLocationName", "f.id AS footprint_id", "f.name AS footprintName",
"c.id AS category", "c.name AS categoryName", "pu.id AS partUnit", "pu.name AS partUnitName",
- "pu.is_default AS partUnitDefault"
+ "pu.is_default AS partUnitDefault", "partCondition"
);
}
@@ -483,4 +483,4 @@ class PartManager extends AbstractManager {
return PartKeepr::getEM()->createQuery($dql)->getSingleScalarResult();
}
-}-
\ No newline at end of file
+}
diff --git a/src/backend/PartKeepr/Part/PartService.php b/src/backend/PartKeepr/Part/PartService.php
@@ -163,6 +163,29 @@ class PartService extends Service implements RestfulService {
$queryBuilder->andWhere("q.id NOT IN (".implode(",", $filter).")");
}
+
+ /**
+ * Query by the review flag
+ */
+ if ($this->getParameter("needsReview") === true || $this->getParameter("needsReview") === "true") {
+ $queryBuilder->andWhere("q.needsReview = true");
+ }
+
+ /**
+ * Query by the status
+ */
+ if ($this->getParameter("status")) {
+ $queryBuilder->andWhere("LOWER(q.status) LIKE :status");
+ $queryBuilder->setParameter("status", "%".strtolower($this->getParameter("status"))."%");
+ }
+
+ /**
+ * Query by the condition
+ */
+ if ($this->getParameter("condition")) {
+ $queryBuilder->andWhere("LOWER(q.partCondition) LIKE :condition");
+ $queryBuilder->setParameter("condition", "%".strtolower($this->getParameter("condition"))."%");
+ }
}
/**
diff --git a/src/frontend/js/Components/Part/Editor/PartEditor.js b/src/frontend/js/Components/Part/Editor/PartEditor.js
@@ -19,7 +19,7 @@ Ext.define('PartKeepr.PartEditor', {
*/
initComponent: function () {
// Defines the overall height of all fields, used to calculate the anchoring for the description field
- var overallHeight = (this.partMode == "create") ? '-280' : '-215';
+ var overallHeight = (this.partMode == "create") ? '-280' : '-235';
this.nameField = Ext.create("Ext.form.field.Text", {
name: 'name',
@@ -167,6 +167,10 @@ Ext.define('PartKeepr.PartEditor', {
}]
},{
xtype: 'textfield',
+ fieldLabel: i18n("Condition"),
+ name: 'partCondition'
+ },{
+ xtype: 'textfield',
fieldLabel: i18n("Internal Part Number"),
name: 'internalPartNumber'
}];
diff --git a/src/frontend/js/Components/Part/PartDisplay.js b/src/frontend/js/Components/Part/PartDisplay.js
@@ -52,12 +52,16 @@ Ext.define('PartKeepr.PartDisplay', {
'<td class="e">{status}</td>',
'</tr>',
'<tr>',
- '<td class="o">'+i18n("Needs Review")+':</td>',
- '<td class="o">{needsReview}</td>',
+ '<td class="o">'+i18n("Condition")+':</td>',
+ '<td class="o">{partCondition}</td>',
'</tr>',
'<tr>',
- '<td class="e">'+i18n("Used in projects")+':</td>',
- '<td class="e">{[ (values.projects == "") ? "'+i18n("none")+'" : values.projects ]}</td>',
+ '<td class="e">'+i18n("Needs Review")+':</td>',
+ '<td class="e">{needsReview}</td>',
+ '</tr>',
+ '<tr>',
+ '<td class="o">'+i18n("Used in projects")+':</td>',
+ '<td class="o">{[ (values.projects == "") ? "'+i18n("none")+'" : values.projects ]}</td>',
'</tr>',
'</table>');
diff --git a/src/frontend/js/Components/Part/PartFilterPanel.js b/src/frontend/js/Components/Part/PartFilterPanel.js
@@ -48,7 +48,8 @@ Ext.define('PartKeepr.PartFilterPanel', {
this.categoryFilter,
this.partsWithoutPrice,
this.createDateFilter,
- this.partsWithoutStockRemovals
+ this.partsWithoutStockRemovals,
+ this.needsReview
]
};
@@ -64,7 +65,9 @@ Ext.define('PartKeepr.PartFilterPanel', {
this.distributorOrderNumberFilter,
this.distributorFilter,
this.manufacturerFilter,
- this.footprintFilter
+ this.footprintFilter,
+ this.statusFilter,
+ this.conditionFilter
]
};
@@ -129,6 +132,7 @@ Ext.define('PartKeepr.PartFilterPanel', {
this.createDateFilterSelect.setValue("");
this.createDateField.setValue("");
this.partsWithoutStockRemovals.setValue(false);
+ this.needsReview.setValue(false);
this.partsWithoutPrice.setValue(false);
this.distributorFilterCombo.setValue("");
@@ -139,6 +143,10 @@ Ext.define('PartKeepr.PartFilterPanel', {
this.footprintFilterCombo.setValue("");
this.footprintFilterCheckbox.setValue(false);
+
+ this.statusFilter.setValue("");
+
+ this.conditionFilter.setValue("");
this.onApply();
},
@@ -271,6 +279,11 @@ Ext.define('PartKeepr.PartFilterPanel', {
boxLabel: i18n("Show Parts without stock removals only")
});
+ this.needsReview = Ext.create("Ext.form.field.Checkbox", {
+ fieldLabel: i18n("Needs Review"),
+ boxLabel: i18n("Show Parts that need to reviewed only")
+ });
+
this.manufacturerFilterCheckbox = Ext.create("Ext.form.field.Checkbox", {
style: 'margin-right: 5px',
listeners: {
@@ -355,6 +368,18 @@ Ext.define('PartKeepr.PartFilterPanel', {
items: [ this.footprintFilterCheckbox, this.footprintFilterCombo ],
fieldLabel: i18n("Footprint")
});
+
+ /** **/
+
+ this.statusFilter = Ext.create("Ext.form.field.Text", {
+ fieldLabel: i18n("Status"),
+ anchor: '100%'
+ });
+
+ this.conditionFilter = Ext.create("Ext.form.field.Text", {
+ fieldLabel: i18n("Condition"),
+ anchor: '100%'
+ });
},
/**
@@ -393,6 +418,10 @@ Ext.define('PartKeepr.PartFilterPanel', {
} else {
delete extraParams.footprint;
}
+
+ extraParams.status = this.statusFilter.getValue();
+ extraParams.condition = this.conditionFilter.getValue();
+
extraParams.createDateRestriction = this.createDateFilterSelect.getValue();
var createDate = Ext.util.Format.date(this.createDateField.getValue(), "Y-m-d H:i:s");
@@ -405,6 +434,7 @@ Ext.define('PartKeepr.PartFilterPanel', {
extraParams.withoutStockRemovals = this.partsWithoutStockRemovals.getValue();
+ extraParams.needsReview = this.needsReview.getValue();
}
-});-
\ No newline at end of file
+});
diff --git a/src/frontend/js/Components/Part/PartsGrid.js b/src/frontend/js/Components/Part/PartsGrid.js
@@ -222,8 +222,13 @@ Ext.define('PartKeepr.PartsGrid', {
dataIndex: "",
width: 30,
renderer: this.iconRenderer
- },
- {
+ },{
+ header: '<img src="resources/diagona-icons/icons/10/102.png">',
+ dataIndex: "needsReview",
+ width: 25,
+ tooltip: "Needs Reviewed?",
+ renderer: this.reviewRenderer
+ },{
header: i18n("Name"),
dataIndex: 'name',
flex: 1,
@@ -244,6 +249,10 @@ Ext.define('PartKeepr.PartsGrid', {
dataIndex: "status",
renderer: Ext.util.Format.htmlEncode
},{
+ header: i18n("Condition"),
+ dataIndex: "partCondition",
+ renderer: Ext.util.Format.htmlEncode
+ },{
header: i18n("Stock"),
dataIndex: 'stockLevel',
editor: {
@@ -304,6 +313,18 @@ Ext.define('PartKeepr.PartsGrid', {
return ret;
},
/**
+ * Used as renderer for the review column.
+ */
+ reviewRenderer: function (val,q,rec)
+ {
+ var ret = "";
+ if (rec.get("needsReview") === true) {
+ ret += '<img src="resources/diagona-icons/icons/10/071.png" style="margin-top: 2px;" alt="'+i18n("Needs review")+'" title="'+i18n("Needs review")+'"/>';
+ }
+
+ return ret;
+ },
+ /**
* Sets the category. Triggers a store reload with a category filter.
*/
setCategory: function (category) {
diff --git a/src/frontend/js/Models/Part.js b/src/frontend/js/Models/Part.js
@@ -15,6 +15,7 @@ Ext.define("PartKeepr.Part", {
{ name: 'minStockLevel', type: 'int'},
{ name: 'createDate', type: 'datetime'},
{ name: 'needsReview', type: 'boolean'},
+ { name: 'partCondition', type: 'string'},
// Various things that don't belong to the part, but are transmitted anyways to make handling easier
{ name: 'initialStockLevel', type: 'int'},