Merge branch '717-log-warranty-activities-from-app' into 'master'
Resolve "Log warranty activities from app" Closes #717 See merge request jankstudio/resq!832
This commit is contained in:
commit
f0d14b7d77
10 changed files with 930 additions and 8 deletions
|
|
@ -348,6 +348,10 @@ access_keys:
|
|||
label: Customer Source Report
|
||||
- id: report.hub.filter
|
||||
label: Hub Filter Report
|
||||
- id: report.warranty.raffle
|
||||
label: Warranty Raffle Report
|
||||
- id: report.jo.raffle
|
||||
label: JO Raffle Report
|
||||
|
||||
- id: service
|
||||
label: Other Services
|
||||
|
|
|
|||
|
|
@ -147,3 +147,23 @@ rep_hub_filter_submit:
|
|||
path: /report/hub_filter_report
|
||||
controller: App\Controller\ReportController::hubFilterSubmit
|
||||
methods: [POST]
|
||||
|
||||
rep_warranty_raffle_form:
|
||||
path: /report/warranty_raffle_report
|
||||
controller: App\Controller\ReportController::warrantyRaffleForm
|
||||
methods: [GET]
|
||||
|
||||
rep_warranty_raffle_submit:
|
||||
path: /report/warranty_raffle_report
|
||||
controller: App\Controller\ReportController::warrantyRaffleSubmit
|
||||
methods: [POST]
|
||||
|
||||
rep_jo_raffle_form:
|
||||
path: /report/jo_raffle_report
|
||||
controller: App\Controller\ReportController::joRaffleForm
|
||||
methods: [GET]
|
||||
|
||||
rep_jo_raffle_submit:
|
||||
path: /report/jo_raffle_report
|
||||
controller: App\Controller\ReportController::joRaffleSubmit
|
||||
methods: [POST]
|
||||
|
|
|
|||
|
|
@ -277,6 +277,11 @@ services:
|
|||
arguments:
|
||||
$em: "@doctrine.orm.entity_manager"
|
||||
|
||||
# warranty logger for raffle
|
||||
App\Service\WarrantyRaffleLogger:
|
||||
arguments:
|
||||
$em: "@doctrine.orm.entity_manager"
|
||||
|
||||
# promo logger
|
||||
App\Service\PromoLogger:
|
||||
arguments:
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ use App\Service\RiderTracker;
|
|||
use App\Service\MapTools;
|
||||
use App\Service\InventoryManager;
|
||||
use App\Service\RiderAssignmentHandlerInterface;
|
||||
use App\Service\WarrantyRaffleLogger;
|
||||
use App\Service\WarrantyAPILogger;
|
||||
use App\Service\PromoLogger;
|
||||
use App\Service\HubSelector;
|
||||
|
|
@ -3362,7 +3363,7 @@ class APIController extends Controller implements LoggedController
|
|||
return $clean_serial;
|
||||
}
|
||||
|
||||
public function warrantyCheck($serial, EntityManagerInterface $em, Request $req)
|
||||
public function warrantyCheck($serial, EntityManagerInterface $em, Request $req, WarrantyRaffleLogger $raffle_logger)
|
||||
{
|
||||
// check required parameters and api key
|
||||
$required_params = [];
|
||||
|
|
@ -3371,7 +3372,7 @@ class APIController extends Controller implements LoggedController
|
|||
return $res->getReturnResponse();
|
||||
|
||||
// check if warranty serial is there
|
||||
$serial = $this->cleanSerial($serial);
|
||||
$serial = $this->cleanSerial($serial);
|
||||
$warr_serial = $em->getRepository(WarrantySerial::class)->find($serial);
|
||||
$warr = $em->getRepository(Warranty::class)->findOneBy(['serial' => $serial]);
|
||||
$batt = null;
|
||||
|
|
@ -3386,6 +3387,24 @@ class APIController extends Controller implements LoggedController
|
|||
|
||||
$today = new DateTime();
|
||||
|
||||
$user_id = $req->query->get('api_key');
|
||||
$raffle_data = [
|
||||
'user_id' => $user_id,
|
||||
'serial' => $serial,
|
||||
'warranty_id' => null,
|
||||
'action' => '',
|
||||
'bmodel_name' => '',
|
||||
'bsize_name' => '',
|
||||
'first_name' => '',
|
||||
'last_name' => '',
|
||||
'plate_number' => '',
|
||||
'contact_num' => '',
|
||||
'email' => '',
|
||||
'address' => '',
|
||||
];
|
||||
|
||||
$data_sent = [];
|
||||
|
||||
// if we have a warranty entry for the serial already
|
||||
if ($warr != null)
|
||||
{
|
||||
|
|
@ -3445,6 +3464,16 @@ class APIController extends Controller implements LoggedController
|
|||
'dealer_address' => $warr->getDealerAddress() ?? '',
|
||||
'branch_code' => $warr->getDealerBranchCode() ?? '',
|
||||
];
|
||||
|
||||
// set customer info and action for raffle log
|
||||
$raffle_data['action'] = 'serial_check_customer';
|
||||
$raffle_data['first_name'] = $customer['first_name'];
|
||||
$raffle_data['last_name'] = $customer['last_name'];
|
||||
$raffle_data['plate_number'] = $customer['plate_number'];
|
||||
$raffle_data['email'] = $customer['email'];
|
||||
$raffle_data['contact_num'] = $customer['contact_num'];
|
||||
$raffle_data['address'] = $customer['address'];
|
||||
$raffle_data['warranty_id'] = $warr->getID();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -3467,6 +3496,9 @@ class APIController extends Controller implements LoggedController
|
|||
'dealer_address' => '',
|
||||
'branch_code' => '',
|
||||
];
|
||||
|
||||
// set action for raffle log
|
||||
$raffle_data['action'] = 'serial_check_not_customer';
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -3490,6 +3522,9 @@ class APIController extends Controller implements LoggedController
|
|||
'dealer_address' => '',
|
||||
'branch_code' => '',
|
||||
];
|
||||
|
||||
// set action for raffle log
|
||||
$raffle_data['action'] = 'serial_check_customer';
|
||||
}
|
||||
|
||||
$sku = $warr_serial->getSKU();
|
||||
|
|
@ -3544,6 +3579,13 @@ class APIController extends Controller implements LoggedController
|
|||
|
||||
$res->setData($data);
|
||||
|
||||
// set the rest of the raffle log entry
|
||||
$raffle_data['bmodel_name'] = $battery['brand'];
|
||||
$raffle_data['bsize_name'] = $battery['size'];
|
||||
|
||||
// log the raffle log
|
||||
$raffle_logger->logRaffleInfo($data_sent, $raffle_data);
|
||||
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
|
|
@ -3578,7 +3620,7 @@ class APIController extends Controller implements LoggedController
|
|||
}
|
||||
|
||||
public function warrantyRegister($serial, EntityManagerInterface $em, Request $req, KernelInterface $kernel, RisingTideGateway $rt,
|
||||
TranslatorInterface $trans, WarrantyAPILogger $logger)
|
||||
TranslatorInterface $trans, WarrantyRaffleLogger $raffle_logger, WarrantyAPILogger $logger)
|
||||
{
|
||||
// check required parameters and api key
|
||||
$required_params = [
|
||||
|
|
@ -3593,7 +3635,7 @@ class APIController extends Controller implements LoggedController
|
|||
$warr_card = $req->files->get('warr_card');
|
||||
|
||||
// normalize serial
|
||||
$serial = $this->cleanSerial($serial);
|
||||
$serial = $this->cleanSerial($serial);
|
||||
// $serial = trim(strtoupper($serial));
|
||||
|
||||
// process picture uploads
|
||||
|
|
@ -3608,7 +3650,7 @@ class APIController extends Controller implements LoggedController
|
|||
'last_name' => $req->request->get('last_name'),
|
||||
'date_purchase' => $req->request->get('date_purchase'),
|
||||
];
|
||||
$action = 'create';
|
||||
$action = 'create/update';
|
||||
$source = WarrantySource::MOBILE;
|
||||
|
||||
$res = $this->checkParamsAndKey($req, $em, $required_params);
|
||||
|
|
@ -3623,7 +3665,7 @@ class APIController extends Controller implements LoggedController
|
|||
|
||||
// update warranty
|
||||
$res = $this->updateWarranty($res, $em, $rt, $trans, $req, $serial, $inv_filename, $wcard_filename,
|
||||
$logger, $log_data, $user_id, $action, $source);
|
||||
$logger, $log_data, $user_id, $action, $source, $raffle_logger);
|
||||
|
||||
$em->flush();
|
||||
|
||||
|
|
@ -3943,9 +3985,24 @@ class APIController extends Controller implements LoggedController
|
|||
}
|
||||
*/
|
||||
|
||||
protected function updateWarranty($res, $em, $rt, $trans, $req, $serial, $inv_filename = null, $wcard_filename = null,
|
||||
$logger, $log_data, $user_id, $action, $source)
|
||||
protected function updateWarranty($res, $em, $rt, $trans, $req, $serial, $inv_filename = null, $wcard_filename = null, $logger, $log_data, $user_id, $action, $source, $raffle_logger)
|
||||
{
|
||||
// prepare raffle log entry
|
||||
$raffle_data = [
|
||||
'user_id' => $user_id,
|
||||
'serial' => $serial,
|
||||
'warranty_id' => null,
|
||||
'action' => '',
|
||||
'bmodel_name' => '',
|
||||
'bsize_name' => '',
|
||||
'first_name' => '',
|
||||
'last_name' => '',
|
||||
'plate_number' => '',
|
||||
'contact_num' => '',
|
||||
'email' => '',
|
||||
'address' => '',
|
||||
];
|
||||
|
||||
// get serial
|
||||
$warr_serial = $em->getRepository(WarrantySerial::class)->find($serial);
|
||||
if ($warr_serial == null)
|
||||
|
|
@ -3978,11 +4035,16 @@ class APIController extends Controller implements LoggedController
|
|||
{
|
||||
$res->setError(true)
|
||||
->setErrorMessage('Warranty registered to a vehicle not in your list of vehicles.');
|
||||
// set action to update
|
||||
$action = 'update';
|
||||
$logger->logWarrantyInfo($log_data, $res->getErrorMessage(), $user_id, $action, $source);
|
||||
return $res;
|
||||
}
|
||||
|
||||
$sms_msg = $trans->trans('warranty_update_confirm');
|
||||
|
||||
// update raffle data action
|
||||
$raffle_data['action'] = 'warranty_update';
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -3991,6 +4053,9 @@ class APIController extends Controller implements LoggedController
|
|||
|
||||
// set warranty source
|
||||
$warr->setCreateSource($source);
|
||||
|
||||
// update raffle data action
|
||||
$raffle_data['action'] = 'warranty_create';
|
||||
}
|
||||
|
||||
// get sap battery
|
||||
|
|
@ -4088,6 +4153,30 @@ class APIController extends Controller implements LoggedController
|
|||
// error_log('sending sms to - ' . $this->session->getPhoneNumber());
|
||||
$rt->sendSMS($this->session->getPhoneNumber(), $trans->trans('message.battery_brand_allcaps'), $sms_msg);
|
||||
|
||||
// prepare the rest of the raffle log entry
|
||||
$raffle_data['warranty_id'] = $warr->getID();
|
||||
$raffle_data['bmodel_name'] = $sap_bty->getBrand()->getName();
|
||||
$raffle_data['bsize_name'] = $sap_bty->getSize()->getName();
|
||||
$raffle_data['first_name'] = $req->request->get('first_name', '');
|
||||
$raffle_data['last_name'] = $req->request->get('last_name', '');
|
||||
$raffle_data['plate_number'] = $plate;
|
||||
$raffle_data['contact_num'] = $req->request->get('contact_num', '');
|
||||
$raffle_data['email'] = $req->request->get('email', '');
|
||||
$raffle_data['address'] = $req->request->get('cust_address', '');
|
||||
|
||||
$data_sent = [
|
||||
'plate_number' => $req->request->get('plate_number'),
|
||||
'first_name' => $req->request->get('first_name'),
|
||||
'last_name' => $req->request->get('last_name'),
|
||||
'date_purchase' => $req->request->get('date_purchase'),
|
||||
'address' => $req->request->get('cust_address', ''),
|
||||
'email' => $req->request->get('email', ''),
|
||||
'contact_num' => $req->request->get('contact_num', ''),
|
||||
];
|
||||
|
||||
// log raffle data
|
||||
$raffle_logger->logRaffleInfo($data_sent, $raffle_data);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1222,6 +1222,121 @@ class ReportController extends Controller
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @Menu(selected="outlet_list")
|
||||
*/
|
||||
public function warrantyRaffleForm()
|
||||
{
|
||||
$this->denyAccessUnlessGranted('report.warranty.raffle', null, 'No access.');
|
||||
|
||||
return $this->render('report/warranty-raffle/form.html.twig');
|
||||
}
|
||||
|
||||
/**
|
||||
* @Menu(selected="outlet_list")
|
||||
*/
|
||||
public function joRaffleForm()
|
||||
{
|
||||
$this->denyAccessUnlessGranted('report.jo.raffle', null, 'No access.');
|
||||
|
||||
return $this->render('report/jo-raffle/form.html.twig');
|
||||
}
|
||||
|
||||
public function warrantyRaffleSubmit(Request $req, EntityManagerInterface $em)
|
||||
{
|
||||
// get dates
|
||||
$raw_date_start = $req->request->get('date_start');
|
||||
$raw_date_end = $req->request->get('date_end');
|
||||
|
||||
$date_start = DateTime::createFromFormat('m/d/Y', $raw_date_start);
|
||||
$date_end = DateTime::createFromFormat('m/d/Y', $raw_date_end);
|
||||
|
||||
$data = $this->getWarrantyRaffleData($req, $em, $raw_date_start, $raw_date_end);
|
||||
|
||||
$resp = new StreamedResponse();
|
||||
$resp->setCallback(function() use ($data) {
|
||||
// csv output
|
||||
$csv_handle = fopen('php://output', 'w+');
|
||||
fputcsv($csv_handle, [
|
||||
'Raffle Number',
|
||||
'Serial Number',
|
||||
'Product Name',
|
||||
'Transaction Number', // Warranty ID
|
||||
'Date',
|
||||
'Outlet',
|
||||
'Plate Number',
|
||||
'Warranty Class',
|
||||
'First Name',
|
||||
'Last Name',
|
||||
'Contact Number',
|
||||
'Address',
|
||||
'Email',
|
||||
]);
|
||||
|
||||
foreach ($data as $row)
|
||||
{
|
||||
fputcsv($csv_handle, $row);
|
||||
}
|
||||
|
||||
fclose($csv_handle);
|
||||
});
|
||||
|
||||
$filename = 'warranty_raffle_' . $date_start->format('Ymd') . '_' . $date_end->format('Ymd') . '.csv';
|
||||
$resp->setStatusCode(200);
|
||||
$resp->headers->set('Content-Type', 'text/csv; charset=utf-8');
|
||||
$resp->headers->set('Content-Disposition', 'attachment; filename="' . $filename . '"');
|
||||
|
||||
return $resp;
|
||||
}
|
||||
|
||||
|
||||
public function joRaffleSubmit(Request $req, EntityManagerInterface $em)
|
||||
{
|
||||
// get dates
|
||||
$raw_date_start = $req->request->get('date_start');
|
||||
$raw_date_end = $req->request->get('date_end');
|
||||
|
||||
$date_start = DateTime::createFromFormat('m/d/Y', $raw_date_start);
|
||||
$date_end = DateTime::createFromFormat('m/d/Y', $raw_date_end);
|
||||
|
||||
$data = $this->getJORaffleData($req, $em, $raw_date_start, $raw_date_end);
|
||||
|
||||
$resp = new StreamedResponse();
|
||||
$resp->setCallback(function() use ($data) {
|
||||
// csv output
|
||||
$csv_handle = fopen('php://output', 'w+');
|
||||
fputcsv($csv_handle, [
|
||||
'Raffle Number',
|
||||
'Serial Number',
|
||||
'Product Name',
|
||||
'Transaction Number', // JO ID
|
||||
'Date',
|
||||
'Outlet', // Hub
|
||||
'Plate Number',
|
||||
'Warranty Class',
|
||||
'First Name',
|
||||
'Last Name',
|
||||
'Contact Number',
|
||||
'Address',
|
||||
'Email',
|
||||
]);
|
||||
|
||||
foreach ($data as $row)
|
||||
{
|
||||
fputcsv($csv_handle, $row);
|
||||
}
|
||||
|
||||
fclose($csv_handle);
|
||||
});
|
||||
|
||||
$filename = 'jo_raffle_' . $date_start->format('Ymd') . '_' . $date_end->format('Ymd') . '.csv';
|
||||
$resp->setStatusCode(200);
|
||||
$resp->headers->set('Content-Type', 'text/csv; charset=utf-8');
|
||||
$resp->headers->set('Content-Disposition', 'attachment; filename="' . $filename . '"');
|
||||
|
||||
return $resp;
|
||||
}
|
||||
|
||||
protected function processPopappFile(UploadedFile $csv_file, EntityManagerInterface $em)
|
||||
{
|
||||
// attempt to open file
|
||||
|
|
@ -2598,4 +2713,174 @@ class ReportController extends Controller
|
|||
return $cust_ids;
|
||||
}
|
||||
|
||||
protected function getWarrantyRaffleData($req, $em, $raw_date_start, $raw_date_end)
|
||||
{
|
||||
$date_start = DateTime::createFromFormat('m/d/Y', $raw_date_start);
|
||||
$date_end = DateTime::createFromFormat('m/d/Y', $raw_date_end);
|
||||
|
||||
// change to this format: Y-m-d H:i:s
|
||||
$new_date_start = $date_start->format('Y-m-d H:i:s') . ' 00:00:00';
|
||||
$new_date_end = $date_end->format('Y-m-d H:i:s') . ' 23:59:59';
|
||||
|
||||
$db = $em->getConnection();
|
||||
|
||||
// get the data from warranty_raffle_log
|
||||
$wrl_sql = 'SELECT wrl.serial AS serial, wrl.warranty_id AS warranty_id,
|
||||
wrl.batt_model_name AS model_name, wrl.batt_size_name AS size_name,
|
||||
wrl.date_create AS date_create, wrl.plate_number AS plate_number,
|
||||
wrl.first_name AS first_name, wrl.last_name AS last_name,
|
||||
wrl.contact_num AS contact_num, wrl.address AS address, wrl.email AS email
|
||||
FROM warranty_raffle_log wrl
|
||||
WHERE wrl.date_create >= :date_start
|
||||
AND wrl.date_create <= :date_end';
|
||||
|
||||
$wrl_stmt = $db->prepare($wrl_sql);
|
||||
$wrl_stmt->bindValue('date_start', $new_date_start);
|
||||
$wrl_stmt->bindValue('date_end', $new_date_end);
|
||||
|
||||
$wrl_result = $wrl_stmt->executeQuery();
|
||||
|
||||
$wrl_data = [];
|
||||
// go through rows
|
||||
while($row = $wrl_result->fetchAssociative())
|
||||
{
|
||||
// check if entry has a warranty id
|
||||
$w_id = $row['warranty_id'];
|
||||
$warranty_id = '';
|
||||
$warranty_class = '';
|
||||
if ($w_id != null)
|
||||
{
|
||||
$warranty_id = $w_id;
|
||||
|
||||
// find the warranty to get the warranty class
|
||||
$w_sql = 'SELECT w.warranty_class AS warranty_class
|
||||
FROM warranty w
|
||||
WHERE w.id = :warranty_id';
|
||||
|
||||
$w_stmt = $db->prepare($w_sql);
|
||||
$w_stmt->bindValue('warranty_id' , $w_id);
|
||||
|
||||
$w_result = $w_stmt->executeQuery();
|
||||
|
||||
while ($w_row = $w_result->fetchAssociative())
|
||||
{
|
||||
$warranty_class = $w_row['warranty_class'];
|
||||
}
|
||||
}
|
||||
|
||||
$raffle_number = '';
|
||||
$hub = '';
|
||||
$battery_name = $row['model_name'] . ' / ' . $row['size_name'];
|
||||
|
||||
// get the date from the date schedule
|
||||
$date_array = explode(' ' , $row['date_create']);
|
||||
$date_create = $date_array[0];
|
||||
|
||||
$wrl_data[] = [
|
||||
'raffle_num' => $raffle_number,
|
||||
'serial' => $row['serial'],
|
||||
'product_name' => $battery_name,
|
||||
'warranty_id' => $warranty_id,
|
||||
'date' => $date_create,
|
||||
'hub' => $hub,
|
||||
'plate_number' => $row['plate_number'],
|
||||
'warranty_class' => $warranty_class,
|
||||
'first_name' => $row['first_name'],
|
||||
'last_name' => $row['last_name'],
|
||||
'contact_number' => $row['contact_num'],
|
||||
'address' => $row['address'],
|
||||
'email' => $row['email']
|
||||
];
|
||||
}
|
||||
|
||||
return $wrl_data;
|
||||
}
|
||||
|
||||
protected function getJORaffleData($req, $em, $raw_date_start, $raw_date_end)
|
||||
{
|
||||
$date_start = DateTime::createFromFormat('m/d/Y', $raw_date_start);
|
||||
$date_end = DateTime::createFromFormat('m/d/Y', $raw_date_end);
|
||||
|
||||
// change to this format: Y-m-d H:i:s
|
||||
$new_date_start = $date_start->format('Y-m-d H:i:s') . ' 00:00:00';
|
||||
$new_date_end = $date_end->format('Y-m-d H:i:s') . ' 23:59:59';
|
||||
|
||||
$db = $em->getConnection();
|
||||
|
||||
// get JOs that have been scheduled within the date range and are fulfilled
|
||||
// and service type is battery sales
|
||||
$jo_sql = 'SELECT jo.id AS jo_id, cv.warranty_code AS serial, jo.date_schedule AS date_schedule,
|
||||
h.name AS hub_name, cv.plate_number AS plate_number, jo.warranty_class AS warranty_class,
|
||||
c.first_name AS first_name, c.last_name AS last_name, c.phone_mobile AS mobile_number,
|
||||
c.email AS email
|
||||
FROM job_order jo, customer_vehicle cv, hub h, customer c
|
||||
WHERE jo.cvehicle_id = cv.id
|
||||
AND jo.customer_id = c.id
|
||||
AND jo.hub_id = h.id
|
||||
AND jo.status = :fulfilled
|
||||
AND jo.service_type = :battery_sales
|
||||
AND jo.date_schedule >= :date_start AND jo.date_schedule <= :date_end';
|
||||
$jo_stmt = $db->prepare($jo_sql);
|
||||
$jo_stmt->bindValue('fulfilled', JOStatus::FULFILLED);
|
||||
$jo_stmt->bindValue('battery_sales', ServiceType::BATTERY_REPLACEMENT_NEW);
|
||||
$jo_stmt->bindValue('date_start', $new_date_start);
|
||||
$jo_stmt->bindValue('date_end', $new_date_end);
|
||||
|
||||
$jo_result = $jo_stmt->executeQuery();
|
||||
|
||||
$jo_data = [];
|
||||
// go through rows
|
||||
while($row = $jo_result->fetchAssociative())
|
||||
{
|
||||
// need to get the battery ordered
|
||||
$jo_id = $row['jo_id'];
|
||||
|
||||
$b_sql = 'SELECT bmodel.name AS model_name, bsize.name AS size_name
|
||||
FROM battery_model bmodel, battery_size bsize, battery b,
|
||||
invoice i, invoice_item ii
|
||||
WHERE b.model_id = bmodel.id
|
||||
AND b.size_id = bsize.id
|
||||
AND ii.invoice_id = i.id
|
||||
AND ii.battery_id = b.id
|
||||
AND i.job_order_id = :jo_id';
|
||||
|
||||
$b_stmt = $db->prepare($b_sql);
|
||||
$b_stmt->bindValue('jo_id', $jo_id);
|
||||
|
||||
$b_result = $b_stmt->executeQuery();
|
||||
|
||||
$b_data = [];
|
||||
|
||||
$battery_name = '';
|
||||
while ($b_row = $b_result->fetchAssociative())
|
||||
{
|
||||
$battery_name = $b_row['model_name'] . ' / ' . $b_row['size_name'];
|
||||
}
|
||||
|
||||
// get the date from the date schedule
|
||||
$date_array = explode(' ' , $row['date_schedule']);
|
||||
$date_schedule = $date_array[0];
|
||||
|
||||
$raffle_number = '';
|
||||
$address = '';
|
||||
|
||||
$jo_data[] = [
|
||||
'raffle_num' => $raffle_number,
|
||||
'serial' => $row['serial'],
|
||||
'product_name' => $battery_name,
|
||||
'jo_id' => $jo_id,
|
||||
'date' => $date_schedule,
|
||||
'hub' => $row['hub_name'],
|
||||
'plate_number' => $row['plate_number'],
|
||||
'warranty_class' => $row['warranty_class'],
|
||||
'first_name' => $row['first_name'],
|
||||
'last_name' => $row['last_name'],
|
||||
'contact_number' => $row['mobile_number'],
|
||||
'address' => $address,
|
||||
'email' => $row['email']
|
||||
];
|
||||
}
|
||||
|
||||
return $jo_data;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
295
src/Entity/WarrantyRaffleLog.php
Normal file
295
src/Entity/WarrantyRaffleLog.php
Normal file
|
|
@ -0,0 +1,295 @@
|
|||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
use DateTime;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="warranty_raffle_log")
|
||||
*/
|
||||
class WarrantyRaffleLog
|
||||
{
|
||||
// unique id
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\Column(type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
// date created
|
||||
/**
|
||||
* @ORM\Column(type="datetime")
|
||||
*/
|
||||
protected $date_create;
|
||||
|
||||
// user that created warranty
|
||||
/**
|
||||
* @ORM\Column(type="string", length=32)
|
||||
*/
|
||||
protected $api_user;
|
||||
|
||||
// data sent
|
||||
/**
|
||||
* @ORM\Column(type="json")
|
||||
*/
|
||||
protected $data_sent;
|
||||
|
||||
// serial
|
||||
/**
|
||||
* @ORM\Column(type="string", length=20)
|
||||
*/
|
||||
protected $serial;
|
||||
|
||||
// warranty id
|
||||
/**
|
||||
* @ORM\Column(type="integer", nullable=true)
|
||||
*/
|
||||
protected $warranty_id;
|
||||
|
||||
// action done
|
||||
/**
|
||||
* @ORM\Column(type="string", length=50)
|
||||
*/
|
||||
protected $action;
|
||||
|
||||
// battery model name
|
||||
/**
|
||||
* @ORM\Column(type="string", length=80)
|
||||
*/
|
||||
protected $batt_model_name;
|
||||
|
||||
// battery size name
|
||||
/**
|
||||
* @ORM\Column(type="string", length=80)
|
||||
*/
|
||||
protected $batt_size_name;
|
||||
|
||||
// customer first name
|
||||
/**
|
||||
* @ORM\Column(type="string", length=80)
|
||||
*/
|
||||
protected $first_name;
|
||||
|
||||
// customer last name
|
||||
/**
|
||||
* @ORM\Column(type="string", length=80)
|
||||
*/
|
||||
protected $last_name;
|
||||
|
||||
// plate number
|
||||
/**
|
||||
* @ORM\Column(type="string", length=100)
|
||||
*/
|
||||
protected $plate_number;
|
||||
|
||||
// contact number
|
||||
/**
|
||||
* @ORM\Column(type="string", length=30)
|
||||
*/
|
||||
protected $contact_num;
|
||||
|
||||
// email
|
||||
/**
|
||||
* @ORM\Column(type="string", length=80)
|
||||
*/
|
||||
protected $email;
|
||||
|
||||
// customer address
|
||||
/**
|
||||
* @ORM\Column(type="string", length=280)
|
||||
*/
|
||||
protected $address;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->date_create = new DateTime();
|
||||
$this->data_sent = [];
|
||||
$this->serial = '';
|
||||
$this->api_user = '';
|
||||
$this->action = '';
|
||||
$this->batt_model_name = '';
|
||||
$this->batt_size_name = '';
|
||||
$this->first_name = '';
|
||||
$this->last_name = '';
|
||||
$this->plate_number = '';
|
||||
$this->contact_num = '';
|
||||
$this->email = '';
|
||||
$this->address = '';
|
||||
}
|
||||
|
||||
public function getID()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setDateCreate(DateTime $date_create)
|
||||
{
|
||||
$this->date_create = $date_create;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDateCreate()
|
||||
{
|
||||
return $this->date_create;
|
||||
}
|
||||
|
||||
public function setApiUser($api_user)
|
||||
{
|
||||
$this->api_user = $api_user;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getApiUser()
|
||||
{
|
||||
return $this->api_user;
|
||||
}
|
||||
|
||||
public function addDataSent($id, $value)
|
||||
{
|
||||
$this->data_sent[$id] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setDataSent($data_sent)
|
||||
{
|
||||
$this->data_sent = $data_sent;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDataSent($id)
|
||||
{
|
||||
// return null if we don't have it
|
||||
if (!isset($this->data_sent[$id]))
|
||||
return null;
|
||||
|
||||
return $this->data_sent[$id];
|
||||
}
|
||||
|
||||
public function setSerial($serial)
|
||||
{
|
||||
$this->serial = $serial;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSerial()
|
||||
{
|
||||
return $this->serial;
|
||||
}
|
||||
|
||||
public function setWarrantyID($warranty_id)
|
||||
{
|
||||
$this->warranty_id = $warranty_id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getWarrantyID()
|
||||
{
|
||||
return $this->warranty_id;
|
||||
}
|
||||
|
||||
public function setAction($action)
|
||||
{
|
||||
$this->action = $action;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAction()
|
||||
{
|
||||
return $this->action;
|
||||
}
|
||||
|
||||
public function setBattModelName($batt_model_name)
|
||||
{
|
||||
$this->batt_model_name = $batt_model_name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBattModelName()
|
||||
{
|
||||
return $this->batt_model_name;
|
||||
}
|
||||
|
||||
public function setBattSizeName($batt_size_name)
|
||||
{
|
||||
$this->batt_size_name = $batt_size_name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBattSizeName()
|
||||
{
|
||||
return $this->batt_size_name;
|
||||
}
|
||||
|
||||
public function setFirstName($first_name)
|
||||
{
|
||||
$this->first_name = $first_name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFirstName()
|
||||
{
|
||||
return $this->first_name;
|
||||
}
|
||||
|
||||
public function setLastName($last_name)
|
||||
{
|
||||
$this->last_name = $last_name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLastName()
|
||||
{
|
||||
return $this->last_name;
|
||||
}
|
||||
|
||||
public function setPlateNumber($plate_number)
|
||||
{
|
||||
$this->plate_number = $plate_number;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPlateNumber()
|
||||
{
|
||||
return $this->plate_number;
|
||||
}
|
||||
|
||||
public function setContactNumber($contact_num)
|
||||
{
|
||||
$this->contact_num = $contact_num;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getContactNumber()
|
||||
{
|
||||
return $this->contact_num;
|
||||
}
|
||||
|
||||
public function setEmail($email)
|
||||
{
|
||||
$this->email = $email;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEmail()
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function setAddress($address)
|
||||
{
|
||||
$this->cust_address = $address;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAddress()
|
||||
{
|
||||
return $this->cust_address;
|
||||
}
|
||||
}
|
||||
|
||||
41
src/Service/WarrantyRaffleLogger.php
Normal file
41
src/Service/WarrantyRaffleLogger.php
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use App\Entity\WarrantyRaffleLog;
|
||||
|
||||
class WarrantyRaffleLogger
|
||||
{
|
||||
protected $em;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
{
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
public function logRaffleInfo($data_sent, $raffle_log_data)
|
||||
{
|
||||
$log_entry = new WarrantyRaffleLog();
|
||||
|
||||
$log_entry->setApiUser($raffle_log_data['user_id'])
|
||||
->setDataSent($data_sent)
|
||||
->setSerial($raffle_log_data['serial'])
|
||||
->setWarrantyID($raffle_log_data['warranty_id'])
|
||||
->setAction($raffle_log_data['action'])
|
||||
->setBattModelName($raffle_log_data['bmodel_name'])
|
||||
->setBattSizename($raffle_log_data['bsize_name'])
|
||||
->setFirstName($raffle_log_data['first_name'])
|
||||
->setLastName($raffle_log_data['last_name'])
|
||||
->setPlateNumber($raffle_log_data['plate_number'])
|
||||
->setContactNumber($raffle_log_data['contact_num'])
|
||||
->setEmail($raffle_log_data['email'])
|
||||
->setAddress($raffle_log_data['address']);
|
||||
|
||||
$this->em->persist($log_entry);
|
||||
$this->em->flush();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -182,6 +182,16 @@
|
|||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="m-menu__item " data-redirect="true" aria-haspopup="true">
|
||||
<a href= "{{ url('rep_jo_raffle_form') }}" class="m-menu__link">
|
||||
<i class="m-menu__link-bullet m-menu__link-bullet--dot">
|
||||
<span></span>
|
||||
</i>
|
||||
<span class="m-menu__link-text">
|
||||
Job Order Raffle Report
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="m-menu__item">
|
||||
|
|
@ -257,6 +267,14 @@
|
|||
Hub Filter Report
|
||||
</span>
|
||||
</a>
|
||||
<a href="{{ url('rep_warranty_raffle_form') }}" class="m-menu__link">
|
||||
<i class="m-menu__link-bullet m-menu__link-bullet--dot">
|
||||
<span></span>
|
||||
</i>
|
||||
<span class="m-menu__link-text">
|
||||
Warranty Raffle Report
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
|
|
|||
82
templates/report/jo-raffle/form.html.twig
Normal file
82
templates/report/jo-raffle/form.html.twig
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block body %}
|
||||
<!-- BEGIN: Subheader -->
|
||||
<div class="m-subheader">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="mr-auto">
|
||||
<h3 class="m-subheader__title">Job Order Raffle Report</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- END: Subheader -->
|
||||
<div class="m-content">
|
||||
<!--Begin::Section-->
|
||||
<div class="row">
|
||||
<div class="col-xl-6">
|
||||
<div class="m-portlet m-portlet--mobile">
|
||||
<div class="m-portlet__head">
|
||||
<div class="m-portlet__head-caption">
|
||||
<div class="m-portlet__head-title">
|
||||
<span class="m-portlet__head-icon">
|
||||
<i class="fa fa-calendar"></i>
|
||||
</span>
|
||||
<h3 class="m-portlet__head-text">
|
||||
Select a date range
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<form id="row-form" autocomplete="off" class="m-form m-form--fit m-form--label-align-right m-form--group-seperator-dashed" method="post" action="{{ url('rep_jo_raffle_submit') }}">
|
||||
<div class="m-portlet__body">
|
||||
<div class="form-group m-form__group row">
|
||||
<div class="input-daterange input-group" id="date-range">
|
||||
<input role="presentation" type="text" class="form-control m-input" name="date_start" placeholder="Start date" />
|
||||
<div class="input-group-append">
|
||||
<span class="input-group-text"><i class="la la-ellipsis-h"></i></span>
|
||||
</div>
|
||||
<input role="presentation" type="text" class="form-control" name="date_end" placeholder="End date" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="m-portlet__foot m-portlet__foot--fit">
|
||||
<div class="m-form__actions m-form__actions--solid m-form__actions--right">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<button type="submit" class="btn btn-success">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script>
|
||||
$(function() {
|
||||
$("#date-range").datepicker({
|
||||
orientation: "bottom"
|
||||
});
|
||||
|
||||
$("#row-form").submit(function(e) {
|
||||
var form = $(this);
|
||||
|
||||
if (!$("[name='date_start']").val() || !$("[name='date_end']").val()) {
|
||||
e.preventDefault();
|
||||
|
||||
swal({
|
||||
title: 'Whoops!',
|
||||
text: 'Please fill in both date fields.',
|
||||
type: 'warning'
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
83
templates/report/warranty-raffle/form.html.twig
Normal file
83
templates/report/warranty-raffle/form.html.twig
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block body %}
|
||||
<!-- BEGIN: Subheader -->
|
||||
<div class="m-subheader">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="mr-auto">
|
||||
<h3 class="m-subheader__title">Warranty Raffle Report</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- END: Subheader -->
|
||||
<div class="m-content">
|
||||
<!--Begin::Section-->
|
||||
<div class="row">
|
||||
<div class="col-xl-6">
|
||||
<div class="m-portlet m-portlet--mobile">
|
||||
<div class="m-portlet__head">
|
||||
<div class="m-portlet__head-caption">
|
||||
<div class="m-portlet__head-title">
|
||||
<span class="m-portlet__head-icon">
|
||||
<i class="fa fa-calendar"></i>
|
||||
</span>
|
||||
<h3 class="m-portlet__head-text">
|
||||
Select a date range
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<form id="row-form" autocomplete="off" class="m-form m-form--fit m-form--label-align-right m-form--group-seperator-dashed" method="post" action="{{ url('rep_warranty_raffle_submit') }}">
|
||||
<div class="m-portlet__body">
|
||||
<div class="form-group m-form__group row">
|
||||
<div class="input-daterange input-group" id="date-range">
|
||||
<input role="presentation" type="text" class="form-control m-input" name="date_start" placeholder="Start date" />
|
||||
<div class="input-group-append">
|
||||
<span class="input-group-text"><i class="la la-ellipsis-h"></i></span>
|
||||
</div>
|
||||
<input role="presentation" type="text" class="form-control" name="date_end" placeholder="End date" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="m-portlet__foot m-portlet__foot--fit">
|
||||
<div class="m-form__actions m-form__actions--solid m-form__actions--right">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<button type="submit" class="btn btn-success">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script>
|
||||
$(function() {
|
||||
$("#date-range").datepicker({
|
||||
orientation: "bottom"
|
||||
});
|
||||
|
||||
$("#row-form").submit(function(e) {
|
||||
var form = $(this);
|
||||
|
||||
if (!$("[name='date_start']").val() || !$("[name='date_end']").val()) {
|
||||
e.preventDefault();
|
||||
|
||||
swal({
|
||||
title: 'Whoops!',
|
||||
text: 'Please fill in both date fields.',
|
||||
type: 'warning'
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
Loading…
Reference in a new issue