Add new flag for SAP battery. #526

This commit is contained in:
Korina Cordero 2020-12-01 09:12:21 +00:00
parent afc9eb7062
commit debc3bc8cb
4 changed files with 202 additions and 152 deletions

View file

@ -105,6 +105,7 @@ class SAPBatteryController extends Controller
$row['id'] = $orow[0]->getID(); $row['id'] = $orow[0]->getID();
$row['brand_name'] = $orow['brand_name']; $row['brand_name'] = $orow['brand_name'];
$row['size_name'] = $orow['size_name']; $row['size_name'] = $orow['size_name'];
$row['flag_new'] = $orow[0]->isNew();
// add row metadata // add row metadata
$row['meta'] = [ $row['meta'] = [
@ -163,8 +164,10 @@ class SAPBatteryController extends Controller
if (empty($id)) if (empty($id))
$error_array['id'] = 'SAP code is required.'; $error_array['id'] = 'SAP code is required.';
$flag_new = $req->request->get('flag_new', false);
// set and save values // set and save values
$row->setID($id); $row->setID($id)
->setNew($flag_new);
// custom validation for battery brand // custom validation for battery brand
$brand = $em->getRepository(SAPBatteryBrand::class) $brand = $em->getRepository(SAPBatteryBrand::class)
@ -258,8 +261,10 @@ class SAPBatteryController extends Controller
if (empty($id)) if (empty($id))
$error_array['id'] = 'SAP code is required.'; $error_array['id'] = 'SAP code is required.';
$flag_new = $req->request->get('flag_new', false);
// set and save values // set and save values
$row->setID($id); $row->setID($id)
->setNew($flag_new);
// custom validation for battery brand // custom validation for battery brand
$brand = $em->getRepository(SAPBatteryBrand::class) $brand = $em->getRepository(SAPBatteryBrand::class)

View file

@ -45,10 +45,16 @@ class SAPBattery
*/ */
protected $size; protected $size;
// flag/tag to indicate this SAP battery is the latest/newest
/**
* @ORM\Column(type="boolean")
*/
protected $flag_new;
public function __construct() public function __construct()
{ {
$this->date_create = new DateTime(); $this->date_create = new DateTime();
$this->flag_latest = false;
} }
public function setID($id) public function setID($id)
@ -93,4 +99,15 @@ class SAPBattery
{ {
return $this->size; return $this->size;
} }
public function setNew($new = false)
{
$this->flag_new = $new;
return $this;
}
public function isNew()
{
return $this->flag_new;
}
} }

View file

@ -73,6 +73,18 @@
<div class="form-control-feedback hide" data-field="size"></div> <div class="form-control-feedback hide" data-field="size"></div>
</div> </div>
</div> </div>
<div class="form-group m-form__group row">
<div class="col-lg-4">
<span class="m-switch m-switch--icon block-switch">
<label>
<input type="checkbox" name="flag_new" id="flag_new" value="1"{{ obj.isNew() ? ' checked' }}>
<label class="switch-label">New</label>
<span></span>
</label>
</span>
<div class="form-control-feedback hide" data-field="flag_new"></div>
</div>
</div>
</div> </div>
<div class="m-portlet__foot m-portlet__foot--fit"> <div class="m-portlet__foot m-portlet__foot--fit">
<div class="m-form__actions m-form__actions--solid m-form__actions--right"> <div class="m-form__actions m-form__actions--solid m-form__actions--right">

View file

@ -104,6 +104,22 @@
title: 'Size', title: 'Size',
width: 180 width: 180
}, },
{
field: 'flag_new',
title: 'New',
template: function (row, index, datatable) {
var tag = '';
if (row.flag_new === true) {
tag = '<span class="m-badge m-badge--success m-badge--wide">Yes</span>';
} else {
tag = '<span class="m-badge m-badge--danger m-badge--wide">No</span>';
}
return tag;
}
},
{ {
field: 'Actions', field: 'Actions',
width: 110, width: 110,