Merge branch '540-paperless-warranty' into 'master'
Resolve "Paperless Warranty" Closes #540 See merge request jankstudio/resq!649
This commit is contained in:
commit
3f2467f8f7
7 changed files with 244 additions and 1 deletions
|
|
@ -57,3 +57,8 @@ access_keys:
|
||||||
acls:
|
acls:
|
||||||
- id: customer.register
|
- id: customer.register
|
||||||
label: Register Customer
|
label: Register Customer
|
||||||
|
- id: municipality
|
||||||
|
label: Municipality
|
||||||
|
acls:
|
||||||
|
- id: municipality.list
|
||||||
|
label: List
|
||||||
|
|
|
||||||
|
|
@ -166,3 +166,9 @@ capi_cwarr_register:
|
||||||
controller: App\Controller\CAPI\CustomerWarrantyController::register
|
controller: App\Controller\CAPI\CustomerWarrantyController::register
|
||||||
methods: [POST]
|
methods: [POST]
|
||||||
|
|
||||||
|
|
||||||
|
# municipality
|
||||||
|
capi_municipality_list:
|
||||||
|
path: /capi/municipality
|
||||||
|
controller: App\Controller\CAPI\MunicipalityController::getAll
|
||||||
|
methods: [GET]
|
||||||
|
|
|
||||||
|
|
@ -199,6 +199,8 @@ class CustomerWarrantyController extends APIController
|
||||||
'vmodel' => $warr->getVehicleModelYear(),
|
'vmodel' => $warr->getVehicleModelYear(),
|
||||||
'dealer_name' => $warr->getDealerName(),
|
'dealer_name' => $warr->getDealerName(),
|
||||||
'dealer_address' => $warr->getDealerAddress(),
|
'dealer_address' => $warr->getDealerAddress(),
|
||||||
|
'province_id' => $warr->getProvinceID(),
|
||||||
|
'municipality_id' => $warr->getMunicipalityID(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -224,6 +226,8 @@ class CustomerWarrantyController extends APIController
|
||||||
'vmodel' => '',
|
'vmodel' => '',
|
||||||
'dealer_name' => '',
|
'dealer_name' => '',
|
||||||
'dealer_address' => '',
|
'dealer_address' => '',
|
||||||
|
'province_id' => '',
|
||||||
|
'municipality_id' => '',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -263,6 +267,8 @@ class CustomerWarrantyController extends APIController
|
||||||
'vmodel' => $other_data['vmodel'],
|
'vmodel' => $other_data['vmodel'],
|
||||||
'dealer_name' => $other_data['dealer_name'],
|
'dealer_name' => $other_data['dealer_name'],
|
||||||
'dealer_address' => $other_data['dealer_address'],
|
'dealer_address' => $other_data['dealer_address'],
|
||||||
|
'province_id' => $other_data['province_id'],
|
||||||
|
'municipality_id' => $other_data['municipality_id'],
|
||||||
];
|
];
|
||||||
|
|
||||||
return new APIResponse(true, 'Warranty found.', $data);
|
return new APIResponse(true, 'Warranty found.', $data);
|
||||||
|
|
@ -422,6 +428,12 @@ class CustomerWarrantyController extends APIController
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// NOTE: behaviour has been changed. we now save customer details too
|
||||||
|
$cust->setFirstName($req->request->get('first_name'))
|
||||||
|
->setLastName($req->request->get('last_name'))
|
||||||
|
->setEmail($req->request->get('email'))
|
||||||
|
->setPrivacyPromo($priv_promo)
|
||||||
|
->setPhoneMobile($req->request->get('contact_num'));
|
||||||
// only update privacy promo
|
// only update privacy promo
|
||||||
$cust->setPrivacyPromo($priv_promo);
|
$cust->setPrivacyPromo($priv_promo);
|
||||||
}
|
}
|
||||||
|
|
@ -461,7 +473,11 @@ class CustomerWarrantyController extends APIController
|
||||||
->setDealerName($req->request->get('dealer_name'))
|
->setDealerName($req->request->get('dealer_name'))
|
||||||
->setDealerAddress($req->request->get('dealer_address'))
|
->setDealerAddress($req->request->get('dealer_address'))
|
||||||
->setCustomer($cust)
|
->setCustomer($cust)
|
||||||
->setValidated(false);
|
->setValidated(false)
|
||||||
|
|
||||||
|
// and more new fields
|
||||||
|
->setProvinceID($req->request->get('province_id'))
|
||||||
|
->setMunicipalityID($req->request->get('municipality_id'));
|
||||||
|
|
||||||
// TODO: check for date purchase and date expire
|
// TODO: check for date purchase and date expire
|
||||||
|
|
||||||
|
|
|
||||||
63
src/Controller/CAPI/MunicipalityController.php
Normal file
63
src/Controller/CAPI/MunicipalityController.php
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller\CAPI;
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Doctrine\ORM\Query;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Catalyst\APIBundle\Controller\APIController;
|
||||||
|
use Catalyst\APIBundle\Response\APIResponse;
|
||||||
|
|
||||||
|
use App\Entity\Municipality;
|
||||||
|
|
||||||
|
use Catalyst\APIBundle\Access\Generator as ACLGenerator;
|
||||||
|
|
||||||
|
class MunicipalityController extends APIController
|
||||||
|
{
|
||||||
|
protected $acl_gen;
|
||||||
|
|
||||||
|
public function __construct(ACLGenerator $acl_gen)
|
||||||
|
{
|
||||||
|
$this->acl_gen = $acl_gen;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAll(EntityManagerInterface $em)
|
||||||
|
{
|
||||||
|
$this->denyAccessUnlessGranted('municipality.list', null, 'No access.');
|
||||||
|
|
||||||
|
$muns = $em->getRepository(Municipality::class)->findBy([], ['province_name' => 'ASC', 'name' => 'ASC']);
|
||||||
|
|
||||||
|
$result = [];
|
||||||
|
$provinces = [];
|
||||||
|
foreach ($muns as $m)
|
||||||
|
{
|
||||||
|
$pid = $m->getProvinceID();
|
||||||
|
$pname = $m->getProvinceName();
|
||||||
|
$mid = $m->getID();
|
||||||
|
$mname = $m->getName();
|
||||||
|
|
||||||
|
if (!isset($provinces[$pid]))
|
||||||
|
{
|
||||||
|
$provinces[$pid] = [
|
||||||
|
'id' => $pid,
|
||||||
|
'name' => $pname,
|
||||||
|
'municipalities' => [],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// error_log("$pid - $pname - $mid - $mname");
|
||||||
|
|
||||||
|
$provinces[$pid]['municipalities'][$mid] = [
|
||||||
|
'id' => $mid,
|
||||||
|
'name' => $mname,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'provinces' => $provinces,
|
||||||
|
];
|
||||||
|
|
||||||
|
return new APIResponse(true, 'Municipalities loaded.', $data);
|
||||||
|
}
|
||||||
|
}
|
||||||
69
src/Entity/Municipality.php
Normal file
69
src/Entity/Municipality.php
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Entity
|
||||||
|
* @ORM\Table(name="municipality")
|
||||||
|
*/
|
||||||
|
class Municipality
|
||||||
|
{
|
||||||
|
// unique id
|
||||||
|
/**
|
||||||
|
* @ORM\Id
|
||||||
|
* @ORM\Column(type="string", length=11)
|
||||||
|
*/
|
||||||
|
protected $code;
|
||||||
|
|
||||||
|
// name
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", length=100)
|
||||||
|
*/
|
||||||
|
protected $name;
|
||||||
|
|
||||||
|
// province id
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", length=11)
|
||||||
|
*/
|
||||||
|
protected $province_id;
|
||||||
|
|
||||||
|
// province name
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", length=100)
|
||||||
|
*/
|
||||||
|
protected $province_name;
|
||||||
|
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getID()
|
||||||
|
{
|
||||||
|
return $this->code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setName($name)
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getProvinceID()
|
||||||
|
{
|
||||||
|
return $this->province_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getProvinceName()
|
||||||
|
{
|
||||||
|
return $this->province_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -222,6 +222,16 @@ class Warranty
|
||||||
*/
|
*/
|
||||||
protected $customer;
|
protected $customer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", length=11, nullable=true)
|
||||||
|
*/
|
||||||
|
protected $province_id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", length=11, nullable=true)
|
||||||
|
*/
|
||||||
|
protected $municipality_id;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->date_create = new DateTime();
|
$this->date_create = new DateTime();
|
||||||
|
|
@ -626,4 +636,26 @@ class Warranty
|
||||||
{
|
{
|
||||||
return $this->customer;
|
return $this->customer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setProvinceID($province_id)
|
||||||
|
{
|
||||||
|
$this->province_id = $province_id;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getProvinceID()
|
||||||
|
{
|
||||||
|
return $this->province_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setMunicipalityID($municipality_id)
|
||||||
|
{
|
||||||
|
$this->municipality_id = $municipality_id;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMunicipalityID()
|
||||||
|
{
|
||||||
|
return $this->municipality_id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
52
utils/municipalities.sql
Normal file
52
utils/municipalities.sql
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue