diff --git a/src/Controller/BatterySizeController.php b/src/Controller/BatterySizeController.php index 2a546e80..6d6179a7 100644 --- a/src/Controller/BatterySizeController.php +++ b/src/Controller/BatterySizeController.php @@ -131,6 +131,14 @@ class BatterySizeController extends BaseController return $this->render('battery-size/form.html.twig', $params); } + protected function setObject($obj, $req) + { + $obj->setName($req->request->get('name')) + ->setTIPriceMotolite($req->request->get('tip_motolite')) + ->setTIPricePremium($req->request->get('tip_premium')) + ->setTIPriceOther($req->request->get('tip_other')); + } + public function addSubmit(Request $req, ValidatorInterface $validator) { $this->denyAccessUnlessGranted('bsize.add', null, 'No access.'); @@ -140,7 +148,7 @@ class BatterySizeController extends BaseController $row = new BatterySize(); // set and save values - $row->setName($req->request->get('name')); + $this->setObject($row, $req); // validate $errors = $validator->validate($row); @@ -206,7 +214,7 @@ class BatterySizeController extends BaseController throw $this->createNotFoundException('The item does not exist'); // set and save values - $row->setName($req->request->get('name')); + $this->setObject($row, $req); // validate $errors = $validator->validate($row); diff --git a/src/Entity/BatterySize.php b/src/Entity/BatterySize.php index a847e252..021e115c 100644 --- a/src/Entity/BatterySize.php +++ b/src/Entity/BatterySize.php @@ -33,9 +33,30 @@ class BatterySize */ protected $batteries; + // motolite trade-in price + /** + * @ORM\Column(type="decimal", precision=7, scale=2) + */ + protected $tip_motolite; + + // premium trade-in price + /** + * @ORM\Column(type="decimal", precision=7, scale=2) + */ + protected $tip_premium; + + // other trade-in price + /** + * @ORM\Column(type="decimal", precision=7, scale=2) + */ + protected $tip_other; + public function __construct() { $this->batteries = new ArrayCollection(); + $this->tip_motolite = 0; + $this->tip_premium = 0; + $this->tip_other = 0; } public function getID() @@ -75,4 +96,37 @@ class BatterySize return $str_batteries; } + + public function setTIPriceMotolite($price) + { + $this->tip_motolite = $price; + return $this; + } + + public function getTIPriceMotolite() + { + return $this->tip_motolite; + } + + public function setTIPricePremium($price) + { + $this->tip_premium = $price; + return $this; + } + + public function getTIPricePremium() + { + return $this->tip_premium; + } + + public function setTIPriceOther($price) + { + $this->tip_other = $price; + return $this; + } + + public function getTIPriceOther() + { + return $this->tip_other; + } } diff --git a/src/Ramcar/TradeInType.php b/src/Ramcar/TradeInType.php index fa830be0..4a2471dc 100644 --- a/src/Ramcar/TradeInType.php +++ b/src/Ramcar/TradeInType.php @@ -10,7 +10,7 @@ class TradeInType extends NameValue const COLLECTION = [ 'premium' => 'Premium', - 'motolite' => 'Non-premium', + 'motolite' => 'Motolite', 'other' => 'Other', ]; } diff --git a/templates/battery-size/form.html.twig b/templates/battery-size/form.html.twig index b20b6703..b89d5fd2 100644 --- a/templates/battery-size/form.html.twig +++ b/templates/battery-size/form.html.twig @@ -13,7 +13,7 @@
-
+
@@ -36,7 +36,7 @@
@@ -44,6 +44,33 @@ Display name for this size
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+