Add trade-in prices in entity, controller and templates #70
This commit is contained in:
parent
6120139598
commit
ef85141587
4 changed files with 94 additions and 5 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class TradeInType extends NameValue
|
|||
|
||||
const COLLECTION = [
|
||||
'premium' => 'Premium',
|
||||
'motolite' => 'Non-premium',
|
||||
'motolite' => 'Motolite',
|
||||
'other' => 'Other',
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
<div class="m-content">
|
||||
<!--Begin::Section-->
|
||||
<div class="row">
|
||||
<div class="col-xl-6">
|
||||
<div class="col-xl-9">
|
||||
<div class="m-portlet m-portlet--mobile">
|
||||
<div class="m-portlet__head">
|
||||
<div class="m-portlet__head-caption">
|
||||
|
|
@ -36,7 +36,7 @@
|
|||
<div class="m-portlet__body">
|
||||
<div class="form-group m-form__group row">
|
||||
<label class="col-lg-3 col-form-label" data-field="name">
|
||||
Name:
|
||||
Name
|
||||
</label>
|
||||
<div class="col-lg-9">
|
||||
<input type="text" name="name" class="form-control m-input" value="{{ obj.getName() }}">
|
||||
|
|
@ -44,6 +44,33 @@
|
|||
<span class="m-form__help">Display name for this size</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group m-form__group row no-border">
|
||||
<label class="col-lg-3 col-form-label" data-field="name">
|
||||
Trade-in Motolite
|
||||
</label>
|
||||
<div class="col-lg-9">
|
||||
<input type="text" name="tip_motolite" class="form-control m-input" value="{{ obj.getTIPriceMotolite }}">
|
||||
<div class="form-control-feedback hide" data-field="tip_motolite"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group m-form__group row no-border">
|
||||
<label class="col-lg-3 col-form-label" data-field="tip_premium">
|
||||
Trade-in Premium
|
||||
</label>
|
||||
<div class="col-lg-9">
|
||||
<input type="text" name="tip_premium" class="form-control m-input" value="{{ obj.getTIPricePremium }}">
|
||||
<div class="form-control-feedback hide" data-field="tip_premium"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group m-form__group row no-border">
|
||||
<label class="col-lg-3 col-form-label" data-field="tip_other">
|
||||
Trade-in Other
|
||||
</label>
|
||||
<div class="col-lg-9">
|
||||
<input type="text" name="tip_other" class="form-control m-input" value="{{ obj.getTIPriceOther }}">
|
||||
<div class="form-control-feedback hide" data-field="tip_other"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="m-portlet__foot m-portlet__foot--fit">
|
||||
<div class="m-form__actions m-form__actions--solid m-form__actions--right">
|
||||
|
|
|
|||
Loading…
Reference in a new issue