Add criteria to warranty raffle filter. #720

This commit is contained in:
Korina Cordero 2022-11-22 07:39:45 +00:00
parent 907bee0d70
commit bec964ffa4
2 changed files with 26 additions and 2 deletions

View file

@ -1260,6 +1260,7 @@ class ReportController extends Controller
foreach ($wr_data as $wr_entry) foreach ($wr_data as $wr_entry)
{ {
$valid = $wr_filter->isValidRaffleEntry($wr_entry); $valid = $wr_filter->isValidRaffleEntry($wr_entry);
if ($valid)
$filtered_data[] = $wr_entry; $filtered_data[] = $wr_entry;
} }

View file

@ -2,12 +2,35 @@
namespace App\Service; namespace App\Service;
use App\Ramcar\WarrantyClass;
class WarrantyRaffleFilter class WarrantyRaffleFilter
{ {
public function isValidRaffleEntry($entry) public function isValidRaffleEntry($entry)
{ {
// entry is an associative array // entry is an associative array
// error_log('entry ' . $entry['first_name']); // Serial Number of Battery (NOT blank)
if (empty($entry['serial']))
return false;
// Plate Number (NOT blank)
if (empty($entry['plate_number']))
return false;
// Warranty Class (ONLY private)
if ($entry['warranty_class'] != WarrantyClass::WTY_PRIVATE)
return false;
// either contact number of mobile number is present
if ((empty($entry['contact_number'])) &&
(empty($entry['mobile_number'])))
return false;
// First Name & Last Name have to be present
if ((empty($entry['first_name'])) ||
(empty($entry['last_name'])))
return false;
return true; return true;
} }
} }