partkeepr

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

commit 8a76ad9b008eab5363abcb4330dbdbe3f0946a69
parent eac3f387fddc3f22bb58a03024bef68165927a5b
Author: Felicitus <felicitus@felicitus.org>
Date:   Mon,  9 Apr 2012 17:29:18 +0200

Display which projects the part is used in

Diffstat:
Msrc/backend/de/RaumZeitLabor/PartKeepr/Part/Part.php | 13+++++++++++++
Msrc/backend/de/RaumZeitLabor/PartKeepr/Part/PartManager.php | 14++++++++++++++
Msrc/frontend/js/Components/Part/PartDisplay.js | 6+++++-
Msrc/frontend/js/Models/Part.js | 1+
4 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/src/backend/de/RaumZeitLabor/PartKeepr/Part/Part.php b/src/backend/de/RaumZeitLabor/PartKeepr/Part/Part.php @@ -151,6 +151,11 @@ class Part extends BaseEntity implements Serializable, Deserializable { */ private $createDate; + /** + * @OneToMany(targetEntity="de\RaumZeitLabor\PartKeepr\Project\Project", mappedBy="part") + **/ + private $projects; + public function __construct () { $this->distributors = new \Doctrine\Common\Collections\ArrayCollection(); $this->manufacturers = new \Doctrine\Common\Collections\ArrayCollection(); @@ -265,6 +270,14 @@ class Part extends BaseEntity implements Serializable, Deserializable { } /** + * Returns all projects this part is used + * @return ArrayCollection the projects + */ + public function getProjects () { + return $this->projects; + } + + /** * Sets the storage location for this part * @param \de\RaumZeitLabor\PartKeepr\StorageLocation\StorageLocation $storageLocation The storage location */ diff --git a/src/backend/de/RaumZeitLabor/PartKeepr/Part/PartManager.php b/src/backend/de/RaumZeitLabor/PartKeepr/Part/PartManager.php @@ -98,6 +98,20 @@ class PartManager extends AbstractManager { $result[$key]["attachmentCount"] = $query->getSingleScalarResult(); } + foreach ($result as $key => $item) { + $dql = "SELECT pr.name FROM de\RaumZeitLabor\PartKeepr\Project\Project pr JOIN pr.parts ppart WHERE ppart.part = :part"; + + $query = PartKeepr::getEM()->createQuery($dql); + $query->setParameter("part", $item["id"]); + + $projectNames = array(); + foreach ($query->getArrayResult() as $project) { + $projectNames[] = $project["name"]; + } + + $result[$key]["projects"] = implode(", ", $projectNames); + + } return $result; } diff --git a/src/frontend/js/Components/Part/PartDisplay.js b/src/frontend/js/Components/Part/PartDisplay.js @@ -51,7 +51,11 @@ Ext.define('PartKeepr.PartDisplay', { '<tr>', '<td class="o">'+i18n("Needs Review")+':</td>', '<td class="o">{needsReview}</td>', - '</tr>', + '</tr>', + '<tr>', + '<td class="e">'+i18n("Used in projects")+':</td>', + '<td class="e">{projects}</td>', + '</tr>', '</table>'); /** diff --git a/src/frontend/js/Models/Part.js b/src/frontend/js/Models/Part.js @@ -25,6 +25,7 @@ Ext.define("PartKeepr.Part", { { name: 'storageLocationName',type: 'string'}, { name: 'categoryName', type: 'string'}, { name: 'categoryPath', type: 'string'}, + { name: 'projects', type: 'string'}, { name: 'attachmentCount', type: 'int'}, { name: 'partUnitDefault',