diff --git a/src/Controller/SAPBatteryController.php b/src/Controller/SAPBatteryController.php index b947834b..389f3eb1 100644 --- a/src/Controller/SAPBatteryController.php +++ b/src/Controller/SAPBatteryController.php @@ -105,6 +105,7 @@ class SAPBatteryController extends Controller $row['id'] = $orow[0]->getID(); $row['brand_name'] = $orow['brand_name']; $row['size_name'] = $orow['size_name']; + $row['flag_new'] = $orow[0]->isNew(); // add row metadata $row['meta'] = [ @@ -163,8 +164,10 @@ class SAPBatteryController extends Controller if (empty($id)) $error_array['id'] = 'SAP code is required.'; + $flag_new = $req->request->get('flag_new', false); // set and save values - $row->setID($id); + $row->setID($id) + ->setNew($flag_new); // custom validation for battery brand $brand = $em->getRepository(SAPBatteryBrand::class) @@ -258,8 +261,10 @@ class SAPBatteryController extends Controller if (empty($id)) $error_array['id'] = 'SAP code is required.'; + $flag_new = $req->request->get('flag_new', false); // set and save values - $row->setID($id); + $row->setID($id) + ->setNew($flag_new); // custom validation for battery brand $brand = $em->getRepository(SAPBatteryBrand::class) diff --git a/src/Entity/SAPBattery.php b/src/Entity/SAPBattery.php index c57dce8d..55ed0b5a 100644 --- a/src/Entity/SAPBattery.php +++ b/src/Entity/SAPBattery.php @@ -45,10 +45,16 @@ class SAPBattery */ protected $size; + // flag/tag to indicate this SAP battery is the latest/newest + /** + * @ORM\Column(type="boolean") + */ + protected $flag_new; public function __construct() { - $this->date_create = new DateTime(); + $this->date_create = new DateTime(); + $this->flag_latest = false; } public function setID($id) @@ -93,4 +99,15 @@ class SAPBattery { return $this->size; } + + public function setNew($new = false) + { + $this->flag_new = $new; + return $this; + } + + public function isNew() + { + return $this->flag_new; + } } diff --git a/templates/sap-battery/form.html.twig b/templates/sap-battery/form.html.twig index c2bf3fec..2cf2ac95 100644 --- a/templates/sap-battery/form.html.twig +++ b/templates/sap-battery/form.html.twig @@ -1,7 +1,7 @@ {% extends 'base.html.twig' %} {% block body %} - +