Add payment methods to hub entity and form. #554

This commit is contained in:
Korina Cordero 2021-04-27 04:14:48 +00:00
parent 01cdd7ef03
commit 12798e00be
3 changed files with 49 additions and 0 deletions

View file

@ -22,6 +22,7 @@ use App\Service\RisingTideGateway;
use App\Service\HubSelector;
use App\Ramcar\HubCriteria;
use App\Ramcar\ModeOfPayment;
class HubController extends Controller
{
@ -131,6 +132,7 @@ class HubController extends Controller
$params = [];
$params['obj'] = new Hub();
$params['mode'] = 'create';
$params['payment_methods'] = ModeOfPayment::getCollection();
// response
return $this->render('hub/form.html.twig', $params);
@ -238,6 +240,7 @@ class HubController extends Controller
$params = [];
$params['obj'] = $obj;
$params['mode'] = 'update';
$params['payment_methods'] = ModeOfPayment::getCollection();
// response
return $this->render('hub/form.html.twig', $params);

View file

@ -74,6 +74,12 @@ class Hub
*/
protected $notif_number;
// payment methods
/**
* @ORM\Column(type="array", nullable=true)
*/
protected $payment_methods;
public function __construct()
{
$this->time_open = new DateTime();
@ -83,6 +89,7 @@ class Hub
$this->status_open = true;
$this->flag_hub_view = false;
$this->notif_number = '';
$this->payment_methods = new ArrayCollection();
}
public function getRiders()
@ -203,4 +210,27 @@ class Hub
return $this->notif_number;
}
public function getPaymentMethods()
{
return $this->payment_methods;
}
public function setPaymentMethods(array $payment_methods)
{
$this->payment_methods = new ArrayCollection();
foreach ($payment_methods as $payment_method)
{
$this->payment_methods->add($payment_method);
}
return $this;
}
public function clearPaymentMethods()
{
$this->payment_methods = new ArrayCollection();
return $this;
}
}

View file

@ -154,6 +154,22 @@
</span>
</div>
</div>
<div class="form-group m-form__group row no-border">
<div class="col-lg-6">
<label data-field="payment_method">Payment Methods</label>
<div class="m-checkbox-list">
{% for payment_method in payment_methods %}
<label class="m-checkbox">
<input type="checkbox" name="payment_methods[]" value="{{ payment_method }}"{{ payment_method in obj.getPaymentMethods ? ' checked' : '' }}>
{{ payment_method }}
<span></span>
</label>
{% endfor %}
</div>
<div class="form-control-feedback hide" data-field="payment_methods"></div>
<span class="m-form__help">Check all payment methods that apply</span>
</div>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-12">
<label>