commit 9517687ee0d1baa9c9262355a80a73cde77d6851
parent 89316973ea988e7d41a2bfee256e56dfc0baa524
Author: Felicitus <privat@timohummel.com>
Date: Sun, 5 Jun 2011 20:32:17 +0200
Added a few fields to the manufacturer
Diffstat:
5 files changed, 102 insertions(+), 7 deletions(-)
diff --git a/frontend/js/Components/Manufacturer/ManufacturerEditor.js b/frontend/js/Components/Manufacturer/ManufacturerEditor.js
@@ -62,7 +62,23 @@ Ext.define('PartDB2.ManufacturerEditor', {
xtype: 'textfield',
name: 'name',
fieldLabel: i18n("Manufacturer Name")
- }, {
+ },{
+ xtype: 'textarea',
+ name: 'address',
+ fieldLabel: i18n("Address")
+ },{
+ xtype: 'textfield',
+ name: 'url',
+ fieldLabel: i18n("Website")
+ },{
+ xtype: 'textfield',
+ name: 'email',
+ fieldLabel: i18n("Email")
+ },{
+ xtype: 'textarea',
+ name: 'comment',
+ fieldLabel: i18n("Comment")
+ },{
xtype: 'fieldcontainer',
fieldLabel: i18n("Manufacturer Logos"),
items: [{
diff --git a/frontend/js/Models/Manufacturer.js b/frontend/js/Models/Manufacturer.js
@@ -3,7 +3,10 @@ PartDB2.Manufacturer = Ext.define("Manufacturer", {
fields: [
{ id: 'id', name: 'id', type: 'int' },
{ name: 'name', type: 'string'},
- { name: 'website', type: 'string'},
+ { name: 'url', type: 'string'},
+ { name: 'comment', type: 'string'},
+ { name: 'address', type: 'string'},
+ { name: 'email', type: 'string'},
],
hasMany: {model: 'ManufacturerICLogo', name: 'iclogos'},
proxy: PartDB2.getRESTProxy("Manufacturer"),
diff --git a/src/de/RaumZeitLabor/PartDB2/Manufacturer/Manufacturer.php b/src/de/RaumZeitLabor/PartDB2/Manufacturer/Manufacturer.php
@@ -20,6 +20,26 @@ class Manufacturer {
private $name;
/**
+ * @Column(type="string",nullable=true)
+ */
+ private $address;
+
+ /**
+ * @Column(type="string",nullable=true)
+ */
+ private $url;
+
+ /**
+ * @Column(type="string",nullable=true)
+ */
+ private $email;
+
+ /**
+ * @Column(type="string",nullable=true)
+ */
+ private $comment;
+
+ /**
* @OneToMany(targetEntity="de\RaumZeitLabor\PartDB2\Manufacturer\ManufacturerICLogo",mappedBy="manufacturer",cascade={"persist", "remove"})
*/
private $icLogos;
@@ -31,6 +51,42 @@ class Manufacturer {
$this->name = $name;
}
+ public function getName () {
+ return $this->name;
+ }
+
+ public function setAddress ($address) {
+ $this->address = $address;
+ }
+
+ public function getAddress () {
+ return $this->address;
+ }
+
+ public function setComment ($comment) {
+ $this->comment = $comment;
+ }
+
+ public function getComment () {
+ return $this->comment;
+ }
+
+ public function setEmail ($email) {
+ $this->email = $email;
+ }
+
+ public function getEmail () {
+ return $this->email;
+ }
+
+ public function setURL ($url) {
+ $this->url = $url;
+ }
+
+ public function getURL () {
+ return $this->url;
+ }
+
public function getICLogos () {
return $this->icLogos;
}
@@ -40,7 +96,14 @@ class Manufacturer {
}
public function serialize () {
- return array("id" => $this->id, "name" => $this->name);
+ return array(
+ "id" => $this->getId(),
+ "name" => $this->getName(),
+ "url" => $this->getURL(),
+ "address" => $this->getAddress(),
+ "email" => $this->getEmail(),
+ "comment" => $this->getComment()
+ );
}
public static function loadById ($id) {
diff --git a/src/de/RaumZeitLabor/PartDB2/Manufacturer/ManufacturerManager.php b/src/de/RaumZeitLabor/PartDB2/Manufacturer/ManufacturerManager.php
@@ -12,7 +12,7 @@ class ManufacturerManager extends Singleton {
public function getManufacturers ($start = 0, $limit = 10, $sort = "name", $dir = "asc", $filter = "") {
$qb = PartDB2::getEM()->createQueryBuilder();
- $qb->select("st.id, st.name")->from("de\RaumZeitLabor\PartDB2\Manufacturer\Manufacturer","st");
+ $qb->select("st.id, st.name, st.url, st.email, st.comment, st.address")->from("de\RaumZeitLabor\PartDB2\Manufacturer\Manufacturer","st");
if ($filter != "") {
$qb = $qb->where("st.name LIKE :filter");
diff --git a/src/de/RaumZeitLabor/PartDB2/Manufacturer/ManufacturerService.php b/src/de/RaumZeitLabor/PartDB2/Manufacturer/ManufacturerService.php
@@ -36,17 +36,30 @@ class ManufacturerService extends Service implements RestfulService {
public function create () {
$this->requireParameter("name");
- $manufacturer = ManufacturerManager::getInstance()->addManufacturer($this->getParameter("name"));
+ $manufacturer = new Manufacturer;
+
+ $this->setManufacturerData($manufacturer);
+
+ PartDB2::getEM()->persist($manufacturer);
+ PartDB2::getEM()->flush();
return array("data" => $manufacturer->serialize());
}
+ private function setManufacturerData (Manufacturer $manufacturer) {
+ $manufacturer->setName($this->getParameter("name"));
+ $manufacturer->setComment($this->getParameter("comment", ""));
+ $manufacturer->setAddress($this->getParameter("address", ""));
+ $manufacturer->setURL($this->getParameter("url", ""));
+ $manufacturer->setEmail($this->getParameter("email", ""));
+ }
+
public function update () {
$this->requireParameter("id");
$this->requireParameter("name");
$manufacturer = ManufacturerManager::getInstance()->getManufacturer($this->getParameter("id"));
- $manufacturer->setName($this->getParameter("manufacturer"));
-
+
+ $this->setManufacturerData($manufacturer);
PartDB2::getEM()->flush();
return array("data" => $manufacturer->serialize());