Add customer tags to customer form. #558
This commit is contained in:
parent
601b23afdf
commit
6ac92eba30
4 changed files with 40 additions and 43 deletions
|
|
@ -619,7 +619,7 @@ class Customer
|
|||
|
||||
public function addCustomerTag(CustomerTag $customer_tag)
|
||||
{
|
||||
$this->customer_tags->add($customer_tag);
|
||||
$this->customer_tags[$customer_tag->getID()] = $customer_tag;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -631,11 +631,11 @@ class Customer
|
|||
|
||||
public function getCustomerTags()
|
||||
{
|
||||
$str_customer_tags = [];
|
||||
foreach ($this->customer_tags as $customer_tag)
|
||||
$str_customer_tags[] = $customer_tag->getID();
|
||||
$str_cust_tags = [];
|
||||
foreach ($this->customer_tags as $cust_tag)
|
||||
$str_cust_tags[] = $cust_tag->getID();
|
||||
|
||||
return $str_customer_tags;
|
||||
return $str_cust_tags;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class CustomerTag
|
|||
{
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\Column(type="string", length=80, nullable=false)
|
||||
* @ORM\Column(type="string", length=80, nullable=false, unique=true)
|
||||
* @Assert\NotBlank()
|
||||
*/
|
||||
protected $id;
|
||||
|
|
@ -27,18 +27,6 @@ class CustomerTag
|
|||
*/
|
||||
protected $name;
|
||||
|
||||
// flag for car club member
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
protected $flag_car_club_member;
|
||||
|
||||
// flag for car club promo
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
protected $flag_car_club_promo;
|
||||
|
||||
// customers
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="Customer", mappedBy="customer_tags", fetch="EXTRA_LAZY")
|
||||
|
|
@ -49,8 +37,6 @@ class CustomerTag
|
|||
{
|
||||
$this->date_create = new DateTime();
|
||||
$this->customers = new ArrayCollection();
|
||||
$this->flag_car_club_member = false;
|
||||
$this->flag_car_club_promo = false;
|
||||
}
|
||||
|
||||
public function getID()
|
||||
|
|
@ -97,26 +83,4 @@ class CustomerTag
|
|||
{
|
||||
return $this->customers;
|
||||
}
|
||||
|
||||
public function setCarClubMember($flag_car_club_member = true)
|
||||
{
|
||||
$this->flag_car_club_member = $flag_car_club_member;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isCarClubMember()
|
||||
{
|
||||
return $this->flag_car_club_member;
|
||||
}
|
||||
|
||||
public function setCarClubPromo($flag_car_club_promo = true)
|
||||
{
|
||||
$this->flag_car_club_promo = $flag_car_club_promo;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isCarClubPromo()
|
||||
{
|
||||
return $this->flag_car_club_promo;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ use App\Entity\Vehicle;
|
|||
use App\Entity\Battery;
|
||||
use App\Entity\VehicleManufacturer;
|
||||
use App\Entity\BatteryManufacturer;
|
||||
use App\Entity\CustomerTag;
|
||||
|
||||
use DateTime;
|
||||
|
||||
|
|
@ -151,6 +152,9 @@ class ResqCustomerHandler implements CustomerHandlerInterface
|
|||
$params['obj'] = new Customer();
|
||||
$params['mode'] = 'create';
|
||||
|
||||
// get customer tags
|
||||
$params['customer_tags'] = $this->em->getRepository(CustomerTag::class)->findAll();
|
||||
|
||||
// get dropdown parameters
|
||||
$this->fillDropdownParameters($params);
|
||||
|
||||
|
|
@ -307,6 +311,9 @@ class ResqCustomerHandler implements CustomerHandlerInterface
|
|||
if (empty($row))
|
||||
throw new NotFoundHttpException('The item does not exist');
|
||||
|
||||
// get customer tags
|
||||
$params['customer_tags'] = $em->getRepository(CustomerTag::class)->findAll();
|
||||
|
||||
// get dropdown parameters
|
||||
$this->fillDropdownParameters($params);
|
||||
|
||||
|
|
@ -603,13 +610,26 @@ class ResqCustomerHandler implements CustomerHandlerInterface
|
|||
->setPromoEmail($req->request->get('flag_promo_email', false))
|
||||
->setDpaConsent($is_dpa_checked)
|
||||
->setResearchSms($req->request->get('flag_research_sms', false))
|
||||
->setResearchEmail($req->request->get('flag_research_email', false));
|
||||
->setResearchEmail($req->request->get('flag_research_email', false))
|
||||
->clearCustomerTags();
|
||||
|
||||
// phone numbers
|
||||
$obj->setPhoneMobile($req->request->get('phone_mobile'))
|
||||
->setPhoneLandline($req->request->get('phone_landline'))
|
||||
->setPhoneOffice($req->request->get('phone_office'))
|
||||
->setPhoneFax($req->request->get('phone_fax'));
|
||||
|
||||
// set car club flags
|
||||
$customer_tags = $req->request->get('customer_tags');
|
||||
if (!empty($customer_tags))
|
||||
{
|
||||
foreach($customer_tags as $customer_tag_id)
|
||||
{
|
||||
$customer_tag = $this->em->getRepository(CustomerTag::class)->find($customer_tag_id);
|
||||
if (!empty($customer_tag))
|
||||
$obj->addCustomerTag($customer_tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function fillDropdownParameters(&$params)
|
||||
|
|
|
|||
|
|
@ -160,6 +160,19 @@
|
|||
</span>
|
||||
<div class="form-control-feedback hide" data-field="flag_active"></div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="col-lg-12 form-group-inner">
|
||||
<div class="m-checkbox-list">
|
||||
{% for customer_tag in customer_tags %}
|
||||
<label class="m-checkbox">
|
||||
<input type="checkbox" name="customer_tags[]" value="{{ customer_tag.getID() }}"{{ customer_tag.getID() in obj.getCustomerTags() ? ' checked' : '' }}>
|
||||
{{ customer_tag.getName() }}
|
||||
<span></span>
|
||||
</label>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue