partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit 979af2bb98a18281ddeacd242ecb82da3f829763
parent 18eac6a6b37ae33bf09eee79c156f717cb4eb964
Author: Felicia Hummel <felicia@partkeepr.com>
Date:   Sat,  3 Jun 2017 12:24:47 +0200

- Serialize project report parts including project quantities
- Added icon to reveal information about distribution of project quantities per part
- Removed dirty indication on the report result grid

Diffstat:
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/ProjectReportResultGrid.js | 4++++
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/Renderers/QuantityRenderer.js | 12++++++++++--
Msrc/PartKeepr/ProjectBundle/Controller/ProjectReportController.php | 33++++++++++++++++++++-------------
3 files changed, 34 insertions(+), 15 deletions(-)

diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/ProjectReportResultGrid.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/ProjectReportResultGrid.js @@ -7,6 +7,10 @@ Ext.define("PartKeepr.Components.Project.ProjectReportResultGrid", { } ], + viewConfig: { + markDirty: false + }, + initComponent: function () { diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/Renderers/QuantityRenderer.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Project/Renderers/QuantityRenderer.js @@ -5,7 +5,7 @@ Ext.define("PartKeepr.Components.ProjectReport.Renderers.QuantityRenderer", { renderer: function (v, q, rec) { - var i, total; + var i, total, titleParts = [], title, projectQuantities; if (rec.get("metaPart")) { @@ -21,7 +21,15 @@ Ext.define("PartKeepr.Components.ProjectReport.Renderers.QuantityRenderer", { return total + " / " + v; } else { - return v; + projectQuantities = rec.get("projectQuantities"); + + for (i=0;i<projectQuantities.length;i++) { + + titleParts.push(projectQuantities[i].projectName + ": "+ projectQuantities[i].quantity); + } + + title = titleParts.join("&#013;&#010;"); + return '<span class="web-icon fugue-icon information-small-white" title="' + title + '"></span> '+v; } }, diff --git a/src/PartKeepr/ProjectBundle/Controller/ProjectReportController.php b/src/PartKeepr/ProjectBundle/Controller/ProjectReportController.php @@ -61,7 +61,8 @@ class ProjectReportController extends FOSRestController $aPartResults = []; foreach ($projects as $report) { - $dql = 'SELECT pp.quantity, pro.name AS projectname, pp.overage, pp.overageType, pp.remarks, pp.lotNumber, p.id FROM '; + $dql = 'SELECT pp.quantity, pro.name AS projectname, pp.overage, pp.overageType, pp.remarks, pp.lotNumber, '; + $dql .= 'p.id FROM '; $dql .= 'PartKeepr\\ProjectBundle\\Entity\\ProjectPart pp JOIN pp.part p '; $dql .= 'JOIN pp.project pro WHERE pp.project = :project'; @@ -71,7 +72,9 @@ class ProjectReportController extends FOSRestController $projectIRI = $iriConverter->getIriFromItem($report['project']); foreach ($query->getArrayResult() as $result) { - $part = $partRepository->find($result['id']); + $partId = $result['id']; + + $part = $partRepository->find($partId); /** * @var Part $part */ @@ -81,16 +84,12 @@ class ProjectReportController extends FOSRestController $overage = $result["overage"]; } - if (array_key_exists($result['id'], $aPartResults)) { + if (array_key_exists($partId, $aPartResults)) { // Only update the quantity of the part - $aPartResults[$result['id']]['quantity'] += ($result['quantity'] * $report['quantity']) + $overage; - $aPartResults[$result['id']]['projectNames'][] = $result['projectname']; - $aPartResults[$result['id']]['projects'][] = $projectIRI; - - if ($result['remarks'] != '') { - $aPartResults[$result['id']]['remarks'][] = $result['projectname'].': '.$result['remarks']; - } + $aPartResults[$partId]['quantity'] += ($result['quantity'] * $report['quantity']) + $overage; + $aPartResults[$partId]['projectNames'][] = $result['projectname']; + $aPartResults[$partId]['projects'][] = $projectIRI; } else { $serializedData = $this->get('serializer')->normalize( $part, @@ -131,9 +130,17 @@ class ProjectReportController extends FOSRestController 'remarks' => [], ]; - if ($result['remarks'] != '') { - $aPartResults[$result['id']]['remarks'] = [$result['projectname'].': '.$result['remarks']]; - } + + } + + $aPartResults[$partId]['projectQuantities'][] = [ + "project" => $projectIRI, + "projectName" => $result['projectname'], + "quantity" => ($result['quantity'] * $report['quantity']) + $overage + ]; + + if ($result['remarks'] != '') { + $aPartResults[$result['id']]['remarks'] = [$result['projectname'].': '.$result['remarks']]; } } }