Add index for plate number in warranty. Finish warranty class report. #283
This commit is contained in:
parent
743bbf9c61
commit
28b93a83d0
2 changed files with 87 additions and 11 deletions
|
|
@ -593,6 +593,7 @@ class ReportController extends Controller
|
||||||
'Warranty Expiry Date',
|
'Warranty Expiry Date',
|
||||||
'Warranty Claim Date',
|
'Warranty Claim Date',
|
||||||
'Warranty Claimed From',
|
'Warranty Claimed From',
|
||||||
|
'Warranty Privacy Policy',
|
||||||
'Is Warranty Activated?',
|
'Is Warranty Activated?',
|
||||||
]);
|
]);
|
||||||
foreach ($data as $row)
|
foreach ($data as $row)
|
||||||
|
|
@ -803,7 +804,7 @@ class ReportController extends Controller
|
||||||
foreach($customers as $crow)
|
foreach($customers as $crow)
|
||||||
{
|
{
|
||||||
$cust = $crow[0];
|
$cust = $crow[0];
|
||||||
error_log('Processing customer ' . $cust->getID());
|
//error_log('Processing customer ' . $cust->getID());
|
||||||
|
|
||||||
// get list of customer vehicles
|
// get list of customer vehicles
|
||||||
$c_vehicles = $cust->getVehicles();
|
$c_vehicles = $cust->getVehicles();
|
||||||
|
|
@ -815,20 +816,18 @@ class ReportController extends Controller
|
||||||
// find warranty for plate number
|
// find warranty for plate number
|
||||||
$clean_cv_plate = $this->cleanPlateNumber($cv->getPlateNumber());
|
$clean_cv_plate = $this->cleanPlateNumber($cv->getPlateNumber());
|
||||||
|
|
||||||
// $warranties = $em->getRepository(Warranty::class)->findBy(['plate_number' => $clean_cv_plate]);
|
$warranties = $em->getRepository(Warranty::class)->findBy(['plate_number' => $clean_cv_plate]);
|
||||||
// TODO: test this query to see if this is faster
|
|
||||||
$warr_query = $em->createQuery('select w from App\Entity\Warranty w where w.plate_number = :plate_num')
|
|
||||||
->setParameter('plate_num', $clean_cv_plate);
|
|
||||||
$warranties = $warr_query->iterate();
|
|
||||||
|
|
||||||
foreach ($warranties as $wrow)
|
foreach ($warranties as $warr)
|
||||||
{
|
{
|
||||||
$warr = $wrow[0];
|
//error_log('Found warranty for plate number ' . $warr->getPlateNumber());
|
||||||
error_log('Found warranty for plate number ' . $warr->getPlateNumber());
|
|
||||||
|
// form the result row
|
||||||
|
$results[] = $this->formWarrantyClassResult($cust, $cv, $warr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
$em->clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -840,4 +839,80 @@ class ReportController extends Controller
|
||||||
// remove spaces and make upper case
|
// remove spaces and make upper case
|
||||||
return strtoupper(str_replace(' ', '', $plate));
|
return strtoupper(str_replace(' ', '', $plate));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function formWarrantyClassResult($cust, $cv, $warr)
|
||||||
|
{
|
||||||
|
$batt_model = '';
|
||||||
|
$batt_size = '';
|
||||||
|
$sap_batt = '';
|
||||||
|
$policy = '';
|
||||||
|
$date_purchased = '';
|
||||||
|
$date_expire = '';
|
||||||
|
$date_claim = '';
|
||||||
|
|
||||||
|
$create_date = $warr->getDateCreate();
|
||||||
|
$date_create = $create_date->format('d/M/y');
|
||||||
|
|
||||||
|
if ($warr->getDatePurchase() != null)
|
||||||
|
{
|
||||||
|
$p_date = $warr->getDatePurchase();
|
||||||
|
$date_purchased = $p_date->format('d/M/y');
|
||||||
|
}
|
||||||
|
if ($warr->getDateClaim() != null)
|
||||||
|
{
|
||||||
|
$c_date = $warr->getDateClaim();
|
||||||
|
$date_claim = $c_date->format('d/M/y');
|
||||||
|
}
|
||||||
|
if ($warr->getDateExpire() != null)
|
||||||
|
{
|
||||||
|
$e_date = $warr->getDateExpire();
|
||||||
|
$date_expire = $e_date->format('d/M/y');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($warr->getBatteryModel() != null)
|
||||||
|
{
|
||||||
|
$batt_model = $warr->getBatteryModel()->getName();
|
||||||
|
}
|
||||||
|
if ($warr->getBatterySize() != null)
|
||||||
|
{
|
||||||
|
$batt_size = $warr->getBatterySize()->getName();
|
||||||
|
}
|
||||||
|
if ($warr->getSAPBattery() != null)
|
||||||
|
{
|
||||||
|
$sap_batt = $warr->getSAPBattery()->getBrand()->getName();
|
||||||
|
}
|
||||||
|
if ($warr->getPrivacyPolicy() != null)
|
||||||
|
{
|
||||||
|
$policy = $warr->getPrivacyPolicy()->getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'c_last_name' => $cust->getLastName(),
|
||||||
|
'c_first_name' => $cust->getFirstName(),
|
||||||
|
'manufacturer' => $cv->getVehicle()->getManufacturer()->getName(),
|
||||||
|
'make' => $cv->getVehicle()->getMake(),
|
||||||
|
'model_year' => $cv->getModelYear(),
|
||||||
|
'color' => $cv->getColor(),
|
||||||
|
'serial' => $warr->getSerial(),
|
||||||
|
'class' => $warr->getWarrantyClass(),
|
||||||
|
'plate_number' => $warr->getPlateNumber(),
|
||||||
|
'w_last_name' => $warr->getLastName(),
|
||||||
|
'w_first_name' => $warr->getFirstName(),
|
||||||
|
'w_mobile_num' => $warr->getMobileNumber(),
|
||||||
|
'w_batt_model' => $batt_model,
|
||||||
|
'w_batt_size' => $batt_size,
|
||||||
|
'w_sap_batt' => $sap_batt,
|
||||||
|
'w_status' => $warr->getStatus(),
|
||||||
|
'w_date_create' => $date_create,
|
||||||
|
'w_date_purchase' => $date_purchased,
|
||||||
|
'w_date_expire' => $date_expire,
|
||||||
|
'w_date_claim' => $date_claim,
|
||||||
|
'w_claimed_from' => $warr->getClaimedFrom(),
|
||||||
|
'w_privacy_policy' => $policy,
|
||||||
|
'w_activated' => ($warr->isActivated() ? 'Active' : 'Inactive'),
|
||||||
|
];
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,8 @@ use Exception;
|
||||||
* name="warranty",
|
* name="warranty",
|
||||||
* uniqueConstraints={
|
* uniqueConstraints={
|
||||||
* @ORM\UniqueConstraint(columns={"serial"})
|
* @ORM\UniqueConstraint(columns={"serial"})
|
||||||
* }
|
* },
|
||||||
|
* indexes={@ORM\Index(name="plate_number_idx", columns={"plate_number"})})
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
class Warranty
|
class Warranty
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue