Set yokohama branch to mirror copy in live server #yokohama

This commit is contained in:
Kendrick Chan 2023-07-14 02:27:48 +08:00
parent ee9031a8f3
commit aaf2d9b70c
61 changed files with 108 additions and 5921 deletions

View file

@ -348,10 +348,6 @@ access_keys:
label: Customer Source Report label: Customer Source Report
- id: report.hub.filter - id: report.hub.filter
label: Hub Filter Report label: Hub Filter Report
- id: report.warranty.raffle
label: Warranty Raffle Report
- id: report.jo.raffle
label: JO Raffle Report
- id: service - id: service
label: Other Services label: Other Services
@ -586,17 +582,3 @@ access_keys:
label: Update label: Update
- id: ownership_type.delete - id: ownership_type.delete
label: Delete label: Delete
- id: customer_location
label: Customer Location Access
acls:
- id: cust_location.menu
label: Menu
- id: cust_location.list
label: List
- id: cust_location.add
label: Add
- id: cust_location.update
label: Update
- id: cust_location.delete
label: Delete

View file

@ -69,56 +69,3 @@ access_keys:
acls: acls:
- id: dealer.list - id: dealer.list
label: List label: List
- id: warrantyserial
label: Warranty Serial
acls:
- id: warrantyserial.upload
label: Upload
- id: tapi_vmanufacturer
label: Third Party Vehicle Manufacturer Access
acls:
- id: tapi_vmanufacturer.list
label: List Third Party Vehicle Manufacturers
- id: tapi_vehicle
label: Third Party Vehicle Make Access
acls:
- id: tapi_vehicle.list
label: List Third Party Vehicles
- id: tapi_promo
label: Third Party Promo Access
acls:
- id: tapi_promo.list
label: List Third Party Promos
- id: tapi_battery
label: Third Party Battery Access
acls:
- id: tapi_battery_compatible.list
label: List Third Party Compatible Batteries
- id: tapi_jo
label: Third Party Job Order Access
acls:
- id: tapi_jo.request
label: Third Party Request Job Order
- id: tapi_jo.get.estimate
label: Third Party Get Estimate
- id: tapi_jo.get.ongoing
label: Third Party Get Ongoing Job Order
- id: tapi_jo.cancel
label: Third Party Cancel Job Order
- id: tapi_jo.get.invoice
label: Third Party Get Job Order Invoice
- id: tapi_jo.location.support
label: Third Party Check Location Support
- id: tapi_jo.nearest_hub.get
label: Third Party Get Nearest Hub and Slots
- id: tapi_jo.schedule_option.status
label: Third Party Schedule Option Status
- id: tapi_jo.get.info
label: Third Party Get Job Order Info
- id: tapi_service
label: Third Party Service Access
acls:
- id: tapi_service.list
label: List Third Party Services

View file

@ -249,7 +249,3 @@ main_menu:
acl: ownership_type.menu acl: ownership_type.menu
label: Ownership Types label: Ownership Types
parent: database parent: database
- id: customer_location_list
acl: cust_location.menu
label: Customer Locations
parent: database

View file

@ -43,10 +43,6 @@ security:
pattern: ^\/rapi\/ pattern: ^\/rapi\/
security: false security: false
test_capi:
pattern: ^\/test_capi\/
security: false
warranty_api: warranty_api:
pattern: ^\/capi\/ pattern: ^\/capi\/
stateless: true stateless: true
@ -63,14 +59,6 @@ security:
provider: api_key_user_provider provider: api_key_user_provider
user_checker: Catalyst\AuthBundle\Service\UserChecker user_checker: Catalyst\AuthBundle\Service\UserChecker
third_party_api:
pattern: ^\/tapi\/
stateless: true
simple_preauth:
authenticator: Catalyst\APIBundle\Security\APIKeyAuthenticator
provider: api_key_user_provider
user_checker: Catalyst\AuthBundle\Service\UserChecker
main: main:
provider: user_provider provider: user_provider
form_login: form_login:

View file

@ -3,10 +3,6 @@ capi_test:
path: /capi/test path: /capi/test
controller: App\Controller\CAPI\TestController::test controller: App\Controller\CAPI\TestController::test
capi_test_warranty_serial:
path: /test_capi/test/warranty_serial
controller: App\Controller\CAPI\TestController::warrantySerial
# battery api # battery api
@ -188,9 +184,3 @@ capi_dealer_list:
path: /capi/dealers path: /capi/dealers
controller: App\Controller\CAPI\DealerController::getAll controller: App\Controller\CAPI\DealerController::getAll
methods: [GET] methods: [GET]
# warranty serial api
capi_warranty_serial_upload:
path: /capi/warranty_serial/upload
controller: App\Controller\CAPI\WarrantySerialController::uploadWarrantySerialFile
methods: [POST]

View file

@ -1,35 +0,0 @@
customer_location_list:
path: /customer-locations
controller: App\Controller\CustomerLocationController::index
methods: [GET]
customer_location_rows:
path: /customer-locations/rowdata
controller: App\Controller\CustomerLocationController::datatableRows
methods: [POST]
customer_location_add_form:
path: /customer-locations/newform
controller: App\Controller\CustomerLocationController::addForm
methods: [GET]
customer_location_add_submit:
path: /customer-locations
controller: App\Controller\CustomerLocationController::addSubmit
methods: [POST]
customer_location_update_form:
path: /customer-locations/{id}
controller: App\Controller\CustomerLocationController::updateForm
methods: [GET]
customer_location_update_submit:
path: /customer-locations/{id}
controller: App\Controller\CustomerLocationController::updateSubmit
methods: [POST]
customer_location_delete:
path: /customer-locations/{id}
controller: App\Controller\CustomerLocationController::deleteSubmit
methods: [DELETE]

View file

@ -147,23 +147,3 @@ rep_hub_filter_submit:
path: /report/hub_filter_report path: /report/hub_filter_report
controller: App\Controller\ReportController::hubFilterSubmit controller: App\Controller\ReportController::hubFilterSubmit
methods: [POST] 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]

View file

@ -1,60 +0,0 @@
# third party api
# job order
tapi_jo_request:
path: /tapi/job_order
controller: App\Controller\TAPI\JobOrderController::requestJobOrder
methods: [POST]
tapi_estimate:
path: /tapi/estimate
controller: App\Controller\TAPI\JobOrderController::getEstimate
methods: [POST]
tapi_jo_invoice:
path: /tapi/job_order/invoice/{jo_id}
controller: App\Controller\TAPI\JobOrderController:getJOInvoice
methods: [GET]
tapi_jo_cancel:
path: /tapi/job_order/cancel
controller: App\Controller\TAPI\JobOrderController:cancelJobOrder
methods: [POST]
tapi_jo_info:
path: /tapi/job_order/{jo_id}/info
controller: App\Controller\TAPI\JobOrderController::getJobOrderInfo
methods: [GET]
tapi_location_support:
path: /tapi/location_support
controller: App\Controller\TAPI\JobOrderController:locationSupport
methods: [POST]
tapi_nearest_hub_slots:
path: /tapi/hub_slots
controller: App\Controller\TAPI\JobOrderController::getNearestHubAndSlots
methods: [POST]
# vehicle manufacturer and vehicle
tapi_vehicle_mfg_list:
path: /tapi/vehicle/mfgs
controller: App\Controller\TAPI\VehicleController::listVehicleManufacturers
methods: [GET]
tapi_vehicle_make_list:
path: /tapi/vehicle/mfgs/{mfg_id}/makes
controller: App\Controller\TAPI\VehicleController::listVehicleMakes
methods: [GET]
# battery
tapi_battery_list:
path: /tapi/vehicles/{vid}/compatible_batteries
controller: App\Controller\TAPI\BatteryController::getCompatibleBatteries
methods: [GET]
# promos
tapi_promo_list:
path: /tapi/promos
controller: App\Controller\TAPI\PromoController::listPromos
methods: [GET]

View file

@ -111,10 +111,6 @@ services:
$cvu_mfg_id: "%env(CVU_MFG_ID)%" $cvu_mfg_id: "%env(CVU_MFG_ID)%"
$cvu_brand_id: "%env(CVU_BRAND_ID)%" $cvu_brand_id: "%env(CVU_BRAND_ID)%"
App\Command\LoadWarrantySerialCommand:
arguments:
$callback_url: "%env(WARRANTY_SERIAL_CALLBACK_URL)%"
# rider tracker service # rider tracker service
App\Service\RiderTracker: App\Service\RiderTracker:
arguments: arguments:
@ -277,14 +273,6 @@ services:
arguments: arguments:
$em: "@doctrine.orm.entity_manager" $em: "@doctrine.orm.entity_manager"
# warranty logger for raffle
App\Service\WarrantyRaffleLogger:
arguments:
$em: "@doctrine.orm.entity_manager"
# warranty raffle filter
App\Service\WarrantyRaffleFilter: ~
# promo logger # promo logger
App\Service\PromoLogger: App\Service\PromoLogger:
arguments: arguments:
@ -318,13 +306,3 @@ services:
App\Service\WarrantyBulkUploader: App\Service\WarrantyBulkUploader:
arguments: arguments:
$em: "@doctrine.orm.entity_manager" $em: "@doctrine.orm.entity_manager"
# warranty serial file logger
App\Service\WarrantySerialUploadLogger:
arguments:
$em: "@doctrine.orm.entity_manager"
# warranty serial load logger
App\Service\WarrantySerialLoadLogger:
arguments:
$em: "@doctrine.orm.entity_manager"

View file

@ -1,54 +0,0 @@
<?php
namespace App\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\WarrantySerialQueue;
class CountTotalPendingWarrantySerialFilesCommand extends Command
{
protected $em;
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
parent::__construct();
}
protected function configure()
{
$this->setName('warrantyserial:count')
->setDescription('Count number of pending warranty serial files.')
->setHelp('Count number of pending warranty serial files.');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$em = $this->em;
$status = 'pending';
$db = $em->getConnection();
$ws_query_sql = 'SELECT COUNT(*) AS total FROM warranty_serial_queue
WHERE status = :status';
$ws_query_stmt = $db->prepare($ws_query_sql);
$ws_query_stmt->bindValue('status', $status);
$ws_results = $ws_query_stmt->executeQuery();
$results = $ws_results->fetchAssociative();
$output->write($results['total']);
return 0;
}
}

View file

@ -43,7 +43,7 @@ class GenerateBatteryCompatibilityCommand extends Command
$vehicles = $vm->getVehicles(); $vehicles = $vm->getVehicles();
foreach ($vehicles as $vehicle) foreach ($vehicles as $vehicle)
{ {
$batteries = $vehicle->getActiveBatteries(); $batteries = $vehicle->getBatteries();
$comp_batt = []; $comp_batt = [];
foreach ($batteries as $battery) foreach ($batteries as $battery)
{ {

View file

@ -1,469 +0,0 @@
<?php
namespace App\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Filesystem\Filesystem;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\WarrantySerial;
use App\Entity\WarrantySerialQueue;
use App\Entity\WarrantySerialUploadLog;
use App\Entity\WarrantySerialLoadLog;
use App\Service\WarrantySerialUploadLogger;
use App\Service\WarrantySerialLoadLogger;
use PDO;
use DateTime;
class LoadWarrantySerialCommand extends Command
{
const FIELD_COUNT = 7;
const SERIAL_LENGTH = 20;
protected $em;
protected $upload_logger;
protected $load_logger;
protected $project_dir;
protected $callback_url;
protected $log_data;
protected $filesystem;
public function __construct(EntityManagerInterface $em, WarrantySerialUploadLogger $upload_logger,
WarrantySerialLoadLogger $load_logger, KernelInterface $kernel, $callback_url,
FileSystem $filesystem)
{
$this->em = $em;
$this->upload_logger = $upload_logger;
$this->load_logger = $load_logger;
$this->project_dir = $kernel->getProjectDir();
$this->callback_url = $callback_url;
$this->filesystem = $filesystem;
parent::__construct();
}
protected function configure()
{
$this->setName('warrantyserial:load')
->setDescription('Load warranty serials from file.')
->setHelp('Load warranty serials from file.');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$em = $this->em;
$this->log_data = [];
$status = 'pending';
// get the filenames from the queue table with status pending
$db = $em->getConnection();
$ws_query_sql = 'SELECT id, file_serial, file_id, api_user, orig_file_serial FROM warranty_serial_queue
WHERE status = :status ORDER BY id LIMIT 1';
$ws_query_stmt = $db->prepare($ws_query_sql);
$ws_query_stmt->bindValue('status', $status);
$ws_results = $ws_query_stmt->executeQuery();
$output_info = [];
while ($row = $ws_results->fetchAssociative())
{
$filename = $row['file_serial'];
$user_id = $row['api_user'];
$id = $row['id'];
$file_id = $row['file_id'];
$orig_filename = $row['orig_file_serial'];
$output_info[] = $this->processWarrantySerialFile($filename, $user_id, $file_id, $orig_filename);
// remove entry from queue table
$this->updateWarrantySerialQueue($id);
// delete the uploaded csv file and directory
$this->deleteDirectoryAndFile($file_id);
}
if (count($output_info) > 0)
{
// error_log(print_r($this->log_data, true));
// load log data into db
$this->load_logger->logWarrantySerialLoadInfo($this->log_data);
// send results back to third party
$this->sendResults($output_info);
}
return 0;
}
protected function processWarrantySerialFile($filename, $user_id, $file_id, $orig_filename)
{
$csv_file = $this->project_dir . '/public/warranty_serial_uploads/' . $filename;
$output_info = [];
// attempt to open file
try
{
$fh = fopen($csv_file, "r");
}
catch (Exception $e)
{
$error = 'The file ' . $csv_file . 'could not be read.';
$log_data = [
'user_id' => $user_id,
'is_uploaded' => false,
'error' => $error,
];
$this->upload_logger->logWarrantySerialUploadInfo($log_data);
$output_info = $this->setOutputInfo($filename, $file_id, true, $error, $data, $orig_filename);
return $output_info;
}
$data = [];
while(($row = fgetcsv($fh)) !== false)
{
$validation_result = $this->validateRow($row, $user_id);
if (!empty($validation_result))
{
$data[] = $validation_result;
continue;
}
// valid entry, we parse and insert
$serial = trim(strtoupper($row[0]));
// error_log('Processing ' . $serial);
$sku = trim(strtoupper($row[1]));
$dispatch_status = trim($row[2]);
$str_date_create = trim($row[3]);
$inventory_status = trim($row[4]);
$cat_id = trim($row[5]);
$cat_name = trim(strtoupper($row[6]));
// we are sure that this is a valid date at this point
$created_date = $this->convertDateCreate($str_date_create);
$meta_info = [
'dispatch_status' => $dispatch_status,
'inventory_status' => $inventory_status,
'category_id' => $cat_id,
'category_name' => $cat_name,
];
$info = json_encode($meta_info);
// prepare the data
$source = 'motiv';
if ($sku == 'N/A')
$sku = null;
// prepared statement
$db = $this->em->getConnection();
$insert_stmt = $db->prepare('INSERT INTO warranty_serial (id, sku, date_create, source, meta_info)
VALUES (:serial, :sku, :date_create, :source, :meta_info)');
$res = $insert_stmt->execute([
':serial' => $serial,
':sku' => $sku,
':date_create' => $created_date,
':source' => $source,
':meta_info' => $info,
]);
if (!$res)
{
// log the not successful insert
$err = $insert_stmt->errorInfo();
$error = $err[2];
$this->logLoadInfo($user_id, false, $serial, $error);
$data[] = [
'serial' => $serial,
'status' => 'error',
'has_error' => true,
'error_message' => $error,
];
}
else
{
// log the successful insert
$this->logLoadInfo($user_id, true, $serial, '');
$data[] = [
'serial' => $serial,
'status' => 'success',
'has_error' => false,
'error_message' => '',
];
}
}
// form what we output
$output_info = $this->setOutputInfo($filename, $file_id, false, '', $data, $orig_filename, $orig_filename);
return $output_info;
}
protected function validateRow($row, $user_id)
{
$data = [];
// possible lines:
// (1) header in csv file - ignore
// SerialNumber,Sku,DispatchStatus,CreatedDate,InventoryStatus,CategoryID,CategoryName
// (2) No available data - ignore
// (3) CH2000012071,WCHD23BL-CPN00-LX,0,2020-08-11 04:05:27.090,0,4,CHAMPION MF - valid
// (4) MG2000313690,N/A,1,2021-05-14T23:47:30.6430000+08:00,0,10,GOLD - valid
// (5) Empty line - ignore
// (6) empty sku - log
// check if empty line
if ($row == array(null))
{
// no need to log, but send back error
$error = 'Empty line';
$data = [
'serial' => '',
'status' => 'error',
'has_error' => true,
'error_message' => $error,
];
return $data;
}
// check the number of fields
if (count($row) != self::FIELD_COUNT)
{
$error = 'Invalid number of fields.';
$data = [
'serial' => '',
'status' => 'error',
'has_error' => true,
'error_message' => $error,
];
return $data;
}
// check if the line is a header
if ($row[0] == 'SerialNumber')
{
// no need to log, but send back error
$error = 'Invalid information.';
$data = [
'serial' => '',
'status' => 'error',
'has_error' => true,
'error_message' => $error,
];
return $data;
}
// check if empty serial
if (empty($row[0]))
{
// this one, we log
$error = 'Empty serial';
$this->logLoadInfo($user_id, false, '', $error);
$data = [
'serial' => '',
'status' => 'error',
'has_error' => true,
'error_message' => $error,
];
return $data;
}
// check length of serial
$serial = trim($row[0]);
if (strlen($serial) > SELF::SERIAL_LENGTH)
{
// log
$error = 'Serial length too long';
$this->logLoadInfo($user_id, false, $serial, $error);
$data = [
'serial' => $serial,
'status' => 'error',
'has_error' => true,
'error_message' => $error,
];
return $data;
}
// validate the date created
$str_date_create = trim($row[3]);
$date_create = $this->convertDateCreate($str_date_create);
if ($date_create == null)
{
// log
$error = 'Invalid date create.';
$this->logLoadInfo($user_id, false, $serial, $error);
$data = [
'serial' => $serial,
'status' => 'error',
'has_error' => true,
'error_message' => $error,
];
return $data;
}
// check if serial is a dupe
$existing_serial = $this->em->getRepository(WarrantySerial::class)->find($serial);
if ($existing_serial != null)
{
// log
$error = 'Serial already exists.';
$this->logLoadInfo($user_id, false, $serial, $error);
$data = [
'serial' => $serial,
'status' => 'error',
'has_error' => true,
'error_message' => $error,
];
return $data;
}
// valid entry, return empty
return $data;
}
protected function convertDateCreate($str_date_create)
{
// since some people cannot follow simple instructions...
// check the date format on the string
// try 2021-05-15T08:35:46+08:00 format on str_date_create
$date_create = DateTime::createFromFormat('Y-m-d\TH:i:sP', $str_date_create);
if ($date_create == false)
{
// try this format: 2021-05-15T08:47:20.3330000+08:00
// get the date, time and timezone from str_date_create
$str_date_time = substr($str_date_create, 0, 19);
$str_timezone = substr($str_date_create, 27);
$str_datetime_tz = $str_date_time . $str_timezone;
// create DateTime object
// sample: 2021-05-15T12:16:06+08:00
$date_create = DateTime::createFromFormat('Y-m-d\TH:i:sP', $str_datetime_tz);
// check if datetime object was created
// if not, someone f*cked up and we have no date create
if ($date_create == false)
{
return null;
}
}
// if you reach this part, then date string is valid. Since we'll be using
// sql to insert the entries, we return the string
$created_date = $date_create->format('Y-m-d H:i:s');
// $created_date = DateTime::createFromFormat('Y-m-d H:i:s', $str_created_date);
return $created_date;
}
protected function logLoadInfo($user_id, $is_loaded, $serial, $error)
{
$date_create = new DateTime();
$str_date_create = $date_create->format('Y-m-d H:i:s');
$this->log_data[] = [
$str_date_create,
$user_id,
$serial,
$is_loaded,
$error,
];
}
protected function updateWarrantySerialQueue($id)
{
// prepared statement
$db = $this->em->getConnection();
// lock the warranty serial queue table
$db->exec('LOCK TABLES warranty_serial_queue WRITE;');
$delete_stmt = $db->prepare('DELETE FROM warranty_serial_queue
WHERE id = :id');
$res = $delete_stmt->execute([
':id' => $id,
]);
$db->exec('UNLOCK TABLES;');
}
protected function deleteDirectoryAndFile($filedir)
{
$csv_filedir = $this->project_dir . '/public/warranty_serial_uploads/' . $filedir;
$this->filesystem->remove($csv_filedir);
}
protected function setOutputInfo($filename, $file_id, $has_error, $error_message, $entries, $orig_filename)
{
$info = [
'id' => $file_id,
'filename' => $orig_filename,
'has_error' => $has_error,
'error_message' => $error_message,
'data' => $entries,
];
return $info;
}
protected function sendResults($output_info)
{
$body = json_encode($output_info);
// error_log(print_r($body, true));
// error_log('Sending json output to ' . $this->callback_url);
$curl = curl_init();
$options = [
CURLOPT_URL => $this->callback_url,
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => $body,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
],
];
curl_setopt_array($curl, $options);
$res = curl_exec($curl);
curl_close($curl);
// check result
error_log('Result ' . $res);
}
}

View file

@ -25,7 +25,7 @@ class WarrantySMSCommand extends Command
protected function configure() protected function configure()
{ {
$this->setName('warranty:sms') $this->setName('warranty:sms')
->setDescription('Sends an SMS message to users whose warranty expired 45 days ago.') ->setDescription('Sends an SMS message to users whose warranty expired one month ago.')
->setHelp('Sends warranty SMS.') ->setHelp('Sends warranty SMS.')
->addArgument('date', InputArgument::OPTIONAL, 'Date to use as basis of expiration. Defaults to current date.'); ->addArgument('date', InputArgument::OPTIONAL, 'Date to use as basis of expiration. Defaults to current date.');
} }
@ -50,7 +50,7 @@ class WarrantySMSCommand extends Command
$date = new DateTime(); $date = new DateTime();
// -1 month // -1 month
$date->modify('-45 day'); $date->modify('-1 month');
$warrs = $this->em->getRepository(Warranty::class)->findBy(['date_expire' => $date]); $warrs = $this->em->getRepository(Warranty::class)->findBy(['date_expire' => $date]);

View file

@ -41,7 +41,6 @@ use App\Service\RiderTracker;
use App\Service\MapTools; use App\Service\MapTools;
use App\Service\InventoryManager; use App\Service\InventoryManager;
use App\Service\RiderAssignmentHandlerInterface; use App\Service\RiderAssignmentHandlerInterface;
use App\Service\WarrantyRaffleLogger;
use App\Service\WarrantyAPILogger; use App\Service\WarrantyAPILogger;
use App\Service\PromoLogger; use App\Service\PromoLogger;
use App\Service\HubSelector; use App\Service\HubSelector;
@ -823,8 +822,7 @@ class APIController extends Controller implements LoggedController
// batteries // batteries
$batt_list = []; $batt_list = [];
// $batts = $vehicle->getBatteries(); $batts = $vehicle->getBatteries();
$batts = $vehicle->getActiveBatteries();
foreach ($batts as $batt) foreach ($batts as $batt)
{ {
// TODO: Add warranty_tnv to battery information // TODO: Add warranty_tnv to battery information
@ -3357,14 +3355,14 @@ class APIController extends Controller implements LoggedController
// remove QR prefix if it exists // remove QR prefix if it exists
// $prefix = substr($clean_serial, 0, 2); $prefix = substr($clean_serial, 0, 2);
// if ($prefix == 'QR') if ($prefix == 'QR')
// $clean_serial = substr($clean_serial, 2); $clean_serial = substr($clean_serial, 2);
return $clean_serial; return $clean_serial;
} }
public function warrantyCheck($serial, EntityManagerInterface $em, Request $req, WarrantyRaffleLogger $raffle_logger) public function warrantyCheck($serial, EntityManagerInterface $em, Request $req)
{ {
// check required parameters and api key // check required parameters and api key
$required_params = []; $required_params = [];
@ -3373,7 +3371,7 @@ class APIController extends Controller implements LoggedController
return $res->getReturnResponse(); return $res->getReturnResponse();
// check if warranty serial is there // check if warranty serial is there
$serial = $this->cleanSerial($serial); $serial = $this->cleanSerial($serial);
$warr_serial = $em->getRepository(WarrantySerial::class)->find($serial); $warr_serial = $em->getRepository(WarrantySerial::class)->find($serial);
$warr = $em->getRepository(Warranty::class)->findOneBy(['serial' => $serial]); $warr = $em->getRepository(Warranty::class)->findOneBy(['serial' => $serial]);
$batt = null; $batt = null;
@ -3388,24 +3386,6 @@ class APIController extends Controller implements LoggedController
$today = new DateTime(); $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 we have a warranty entry for the serial already
if ($warr != null) if ($warr != null)
{ {
@ -3465,16 +3445,6 @@ class APIController extends Controller implements LoggedController
'dealer_address' => $warr->getDealerAddress() ?? '', 'dealer_address' => $warr->getDealerAddress() ?? '',
'branch_code' => $warr->getDealerBranchCode() ?? '', '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 else
{ {
@ -3497,9 +3467,6 @@ class APIController extends Controller implements LoggedController
'dealer_address' => '', 'dealer_address' => '',
'branch_code' => '', 'branch_code' => '',
]; ];
// set action for raffle log
$raffle_data['action'] = 'serial_check_not_customer';
} }
} }
else else
@ -3523,9 +3490,6 @@ class APIController extends Controller implements LoggedController
'dealer_address' => '', 'dealer_address' => '',
'branch_code' => '', 'branch_code' => '',
]; ];
// set action for raffle log
$raffle_data['action'] = 'serial_check_customer';
} }
$sku = $warr_serial->getSKU(); $sku = $warr_serial->getSKU();
@ -3580,13 +3544,6 @@ class APIController extends Controller implements LoggedController
$res->setData($data); $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(); return $res->getReturnResponse();
} }
@ -3621,7 +3578,7 @@ class APIController extends Controller implements LoggedController
} }
public function warrantyRegister($serial, EntityManagerInterface $em, Request $req, KernelInterface $kernel, RisingTideGateway $rt, public function warrantyRegister($serial, EntityManagerInterface $em, Request $req, KernelInterface $kernel, RisingTideGateway $rt,
TranslatorInterface $trans, WarrantyRaffleLogger $raffle_logger, WarrantyAPILogger $logger) TranslatorInterface $trans, WarrantyAPILogger $logger)
{ {
// check required parameters and api key // check required parameters and api key
$required_params = [ $required_params = [
@ -3636,7 +3593,7 @@ class APIController extends Controller implements LoggedController
$warr_card = $req->files->get('warr_card'); $warr_card = $req->files->get('warr_card');
// normalize serial // normalize serial
$serial = $this->cleanSerial($serial); $serial = $this->cleanSerial($serial);
// $serial = trim(strtoupper($serial)); // $serial = trim(strtoupper($serial));
// process picture uploads // process picture uploads
@ -3651,7 +3608,7 @@ class APIController extends Controller implements LoggedController
'last_name' => $req->request->get('last_name'), 'last_name' => $req->request->get('last_name'),
'date_purchase' => $req->request->get('date_purchase'), 'date_purchase' => $req->request->get('date_purchase'),
]; ];
$action = 'create/update'; $action = 'create';
$source = WarrantySource::MOBILE; $source = WarrantySource::MOBILE;
$res = $this->checkParamsAndKey($req, $em, $required_params); $res = $this->checkParamsAndKey($req, $em, $required_params);
@ -3666,7 +3623,7 @@ class APIController extends Controller implements LoggedController
// update warranty // update warranty
$res = $this->updateWarranty($res, $em, $rt, $trans, $req, $serial, $inv_filename, $wcard_filename, $res = $this->updateWarranty($res, $em, $rt, $trans, $req, $serial, $inv_filename, $wcard_filename,
$logger, $log_data, $user_id, $action, $source, $raffle_logger); $logger, $log_data, $user_id, $action, $source);
$em->flush(); $em->flush();
@ -3986,24 +3943,9 @@ 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, $raffle_logger) protected function updateWarranty($res, $em, $rt, $trans, $req, $serial, $inv_filename = null, $wcard_filename = null,
$logger, $log_data, $user_id, $action, $source)
{ {
// 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 // get serial
$warr_serial = $em->getRepository(WarrantySerial::class)->find($serial); $warr_serial = $em->getRepository(WarrantySerial::class)->find($serial);
if ($warr_serial == null) if ($warr_serial == null)
@ -4036,16 +3978,11 @@ class APIController extends Controller implements LoggedController
{ {
$res->setError(true) $res->setError(true)
->setErrorMessage('Warranty registered to a vehicle not in your list of vehicles.'); ->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); $logger->logWarrantyInfo($log_data, $res->getErrorMessage(), $user_id, $action, $source);
return $res; return $res;
} }
$sms_msg = $trans->trans('warranty_update_confirm'); $sms_msg = $trans->trans('warranty_update_confirm');
// update raffle data action
$raffle_data['action'] = 'warranty_update';
} }
else else
{ {
@ -4054,9 +3991,6 @@ class APIController extends Controller implements LoggedController
// set warranty source // set warranty source
$warr->setCreateSource($source); $warr->setCreateSource($source);
// update raffle data action
$raffle_data['action'] = 'warranty_create';
} }
// get sap battery // get sap battery
@ -4154,30 +4088,6 @@ class APIController extends Controller implements LoggedController
// error_log('sending sms to - ' . $this->session->getPhoneNumber()); // error_log('sending sms to - ' . $this->session->getPhoneNumber());
$rt->sendSMS($this->session->getPhoneNumber(), $trans->trans('message.battery_brand_allcaps'), $sms_msg); $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; return $res;
} }

View file

@ -155,20 +155,18 @@ class APIUserController extends Controller
// metadata // metadata
$rider_id = $req->request->get('rider_id'); $rider_id = $req->request->get('rider_id');
$rider = $em->getRepository(Rider::class)->find($rider_id); $rider = $em->getRepository(Rider::class)->find($rider_id);
if ($rider != null) // TODO: check for null rider
{
$meta = ['rider_id' => $rider_id];
// set api user in rider $meta = ['rider_id' => $rider_id];
$rider->setAPIUser($obj);
$obj->setRider($rider) // set api user in rider
->setMetadata($meta); $rider->setAPIUser($obj);
}
// set and save values // set and save values
$obj->setName($req->request->get('name')) $obj->setName($req->request->get('name'))
->setEnabled($req->request->get('enabled') ? true : false) ->setEnabled($req->request->get('enabled') ? true : false)
->setMetadata($meta)
->setRider($rider)
->clearRoles(); ->clearRoles();
// set roles // set roles

View file

@ -117,7 +117,6 @@ class BatteryController extends Controller
$row['height'] = $orow[0]->getHeight(); $row['height'] = $orow[0]->getHeight();
$row['total_height'] = $orow[0]->getTotalHeight(); $row['total_height'] = $orow[0]->getTotalHeight();
$row['image_file'] = $orow[0]->getImageFile(); $row['image_file'] = $orow[0]->getImageFile();
$row['flag_active'] = $orow[0]->isActive();
// add row metadata // add row metadata
$row['meta'] = [ $row['meta'] = [
@ -183,8 +182,7 @@ class BatteryController extends Controller
->setHeight($req->request->get('height')) ->setHeight($req->request->get('height'))
->setTotalHeight($req->request->get('total_height')) ->setTotalHeight($req->request->get('total_height'))
->setSellingPrice($req->request->get('sell_price')) ->setSellingPrice($req->request->get('sell_price'))
->setImageFile($req->request->get('image_file')) ->setImageFile($req->request->get('image_file'));
->setActive($req->request->get('flag_active', false));
// initialize error list // initialize error list
$error_array = []; $error_array = [];
@ -310,7 +308,6 @@ class BatteryController extends Controller
->setTotalHeight($req->request->get('total_height')) ->setTotalHeight($req->request->get('total_height'))
->setSellingPrice($req->request->get('sell_price')) ->setSellingPrice($req->request->get('sell_price'))
->setImageFile($req->request->get('image_file')) ->setImageFile($req->request->get('image_file'))
->setActive($req->request->get('flag_active', false))
->clearVehicles(); ->clearVehicles();
// initialize error list // initialize error list
@ -427,7 +424,7 @@ class BatteryController extends Controller
$bmodel_id = $req->query->get('model_id'); $bmodel_id = $req->query->get('model_id');
$bsize_id = $req->query->get('size_id'); $bsize_id = $req->query->get('size_id');
// find the battery using model and size and battery must be active // find the battery using model and size
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$query = $em->createQuery('SELECT b FROM App\Entity\Battery b $query = $em->createQuery('SELECT b FROM App\Entity\Battery b
JOIN b.model bm JOIN b.model bm
@ -435,8 +432,7 @@ class BatteryController extends Controller
JOIN b.manufacturer bmfg JOIN b.manufacturer bmfg
WHERE bm.id = :bm_id WHERE bm.id = :bm_id
AND bs.id = :bs_id AND bs.id = :bs_id
AND bmfg.id = :bmfg_id AND bmfg.id = :bmfg_id')
AND b.flag_active = true')
->setParameter('bmfg_id', $bmfg_id) ->setParameter('bmfg_id', $bmfg_id)
->setParameter('bm_id', $bmodel_id) ->setParameter('bm_id', $bmodel_id)
->setParameter('bs_id', $bsize_id); ->setParameter('bs_id', $bsize_id);

View file

@ -270,7 +270,7 @@ class BatteryManufacturerController extends Controller
// get row data // get row data
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$all_batts = $em->getRepository(Battery::class)->findBy(['flag_active' => true]); $all_batts = $em->getRepository(Battery::class)->findAll();
foreach ($all_batts as $battery) foreach ($all_batts as $battery)
{ {

View file

@ -102,9 +102,9 @@ class CustomerWarrantyController extends APIController
// remove QR prefix if it exists // remove QR prefix if it exists
//$prefix = substr($clean_serial, 0, 2); $prefix = substr($clean_serial, 0, 2);
//if ($prefix == 'QR') if ($prefix == 'QR')
// $clean_serial = substr($clean_serial, 2); $clean_serial = substr($clean_serial, 2);
return $clean_serial; return $clean_serial;
} }

View file

@ -1043,7 +1043,7 @@ class RiderAppController extends APIController
if ($rider == null) if ($rider == null)
return new APIResponse(false, 'No rider found.'); return new APIResponse(false, 'No rider found.');
$batts = $em->getRepository(Battery::class)->findBy(['flag_active' => true]); $batts = $em->getRepository(Battery::class)->findAll();
$models = $em->getRepository(BatteryModel::class)->findAll(); $models = $em->getRepository(BatteryModel::class)->findAll();
$sizes = $em->getRepository(BatterySize::class)->findAll(); $sizes = $em->getRepository(BatterySize::class)->findAll();

View file

@ -17,19 +17,4 @@ class TestController extends APIController
]; ];
return new APIResponse(true, 'Test successful.', $data); return new APIResponse(true, 'Test successful.', $data);
} }
public function warrantySerial(Request $req)
{
error_log('Got request');
$res = json_decode($req->getContent(), true);
// return $res;
$data = [
'result' => $res,
];
return new APIResponse(true, 'Test successful.', $data);
}
} }

View file

@ -1,182 +0,0 @@
<?php
namespace App\Controller\CAPI;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use Doctrine\ORM\Query;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use Catalyst\APIBundle\Controller\APIController;
use Catalyst\APIBundle\Response\APIResponse;
use App\Entity\WarrantySerialQueue;
use App\Service\WarrantySerialUploadLogger;
use DateTime;
use Catalyst\APIBundle\Access\Generator as ACLGenerator;
// third party API
class WarrantySerialController extends APIController
{
protected $acl_gen;
protected $upload_logger;
public function __construct(ACLGenerator $acl_gen, WarrantySerialUploadLogger $upload_logger)
{
$this->acl_gen = $acl_gen;
$this->upload_logger = $upload_logger;
}
public function uploadWarrantySerialFile(Request $req, EntityManagerInterface $em, KernelInterface $kernel)
{
$this->denyAccessUnlessGranted('warrantyserial.upload', null, 'No access.');
$required_params = [
'serial_file',
];
$user_id = $_SERVER['HTTP_X_CATA_API_KEY'];
$res = $this->checkRequiredParamsForFiles($req, $required_params, $user_id);
if ($res !== true)
return $res;
// get the csv file
$csv_file = $req->files->get('serial_file');
// process file upload
$upload_dir = $kernel->getProjectDir() . '/public/warranty_serial_uploads';
$serial_filename = $this->handleSerialFileUpload($csv_file, $upload_dir);
// insert to warranty serial queue
$res = $this->registerWarrantySerialFile($em, $csv_file, $serial_filename, $user_id);
// flush to db
$em->flush();
return $res;
}
protected function registerWarrantySerialFile($em, $file, $serial_filename, $user_id)
{
// parse the serial filename to get the file id
$parts = explode('/', $serial_filename);
$file_id = $parts[0];
$orig_filename = pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME) . '.' . $file->getClientOriginalExtension();
$ws_file = new WarrantySerialQueue();
$ws_file->setFileSerial($serial_filename)
->setStatus('pending')
->setOrigFileSerial($orig_filename)
->setFileID($file_id)
->setApiUser($user_id);
$em->persist($ws_file);
// log upload
$log_data = [
'user_id' => $user_id,
'is_uploaded' => true,
'orig_file_serial' => $orig_filename,
'uploaded_file_serial' => $serial_filename,
];
$this->upload_logger->logWarrantySerialUploadInfo($log_data);
$data = [
'id' => $file_id,
];
return new APIResponse(true, 'Warranty serial file uploaded.', $data);
}
protected function handleSerialFileUpload($file, $target_dir)
{
// create target dir if it doesn't exist
if (!file_exists($target_dir))
{
if (!mkdir($target_dir, 0744, true))
{
$log_data = [
'user_id' => $user_id,
'is_uploaded' => false,
'error' => 'Failed to create folder for warranty serial files.'
];
$this->upload_logger->logWarrantySerialUploadInfo($log_data);
return null;
}
}
// get current date
$curr_date = new DateTime();
$str_curr_date = $curr_date->format('Ymd');
$file_id = $str_curr_date . uniqid();
// move file
$filename = 'warranty_serial' . '.' . $file->getClientOriginalExtension();
$file->move($target_dir . '/' . $file_id, $filename);
return $file_id . '/' . $filename;
}
protected function checkRequiredParamsForFiles(Request $req, $params, $user_id)
{
// check required parameters
$missing = $this->checkMissingParametersForFiles($req, $params);
if (count($missing) > 0)
{
// log the error
$miss_string = implode(', ', $missing);
$log_data = [
'user_id' => $user_id,
'is_uploaded' => false,
'error' => 'Missing parameter(s): ' . $miss_string
];
$this->upload_logger->logWarrantySerialUploadInfo($log_data);
return new APIResponse(false, 'Missing parameter(s): ' . $miss_string);
}
return true;
}
protected function checkMissingParametersForFiles(Request $req, $params = [])
{
$missing = [];
// check if parameters are there
foreach ($params as $param)
{
if ($req->getMethod() == 'GET')
{
$check = $req->query->get($param);
if (empty($check))
$missing[] = $param;
}
else if ($req->getMethod() == 'POST')
{
// get files from request.
$check = $req->files->get($param);
if (empty($check))
{
$missing[] = $param;
}
}
else
return $params;
}
return $missing;
}
}

View file

@ -1,253 +0,0 @@
<?php
namespace App\Controller;
use App\Entity\CustomerLocation;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Catalyst\MenuBundle\Annotation\Menu;
class CustomerLocationController extends Controller
{
/**
* @Menu(selected="customer_location_list")
* @IsGranted("cust_location.list")
*/
public function index()
{
return $this->render('customer-location/list.html.twig');
}
/**
* @IsGranted("cust_location.list")
*/
public function datatableRows(Request $req)
{
// get query builder
$qb = $this->getDoctrine()
->getRepository(CustomerLocation::class)
->createQueryBuilder('q');
// get datatable params
$datatable = $req->request->get('datatable');
// count total records
$tquery = $qb->select('COUNT(q)');
$this->setQueryFilters($datatable, $tquery);
$total = $tquery->getQuery()
->getSingleScalarResult();
// get current page number
$page = $datatable['pagination']['page'] ?? 1;
$perpage = $datatable['pagination']['perpage'];
$offset = ($page - 1) * $perpage;
// add metadata
$meta = [
'page' => $page,
'perpage' => $perpage,
'pages' => ceil($total / $perpage),
'total' => $total,
'sort' => 'asc',
'field' => 'id'
];
// build query
$query = $qb->select('q');
$this->setQueryFilters($datatable, $query);
// check if sorting is present, otherwise use default
if (isset($datatable['sort']['field']) && !empty($datatable['sort']['field'])) {
$order = $datatable['sort']['sort'] ?? 'asc';
$query->orderBy('q.' . $datatable['sort']['field'], $order);
} else {
$query->orderBy('q.id', 'asc');
}
// get rows for this page
$obj_rows = $query->setFirstResult($offset)
->setMaxResults($perpage)
->getQuery()
->getResult();
// process rows
$rows = [];
foreach ($obj_rows as $orow) {
// add row data
$row['id'] = $orow->getID();
$row['name'] = $orow->getName();
// add row metadata
$row['meta'] = [
'update_url' => '',
'delete_url' => ''
];
// add crud urls
if ($this->isGranted('cust_location.update'))
$row['meta']['update_url'] = $this->generateUrl('customer_location_update_form', ['id' => $row['id']]);
if ($this->isGranted('cust_location.delete'))
$row['meta']['delete_url'] = $this->generateUrl('customer_location_delete', ['id' => $row['id']]);
$rows[] = $row;
}
// response
return $this->json([
'meta' => $meta,
'data' => $rows
]);
}
/**
* @Menu(selected="customer_location.list")
* @IsGranted("cust_location.add")
*/
public function addForm()
{
$cust_location = new CustomerLocation();
$params = [
'cust_location' => $cust_location,
'mode' => 'create',
];
// response
return $this->render('customer-location/form.html.twig', $params);
}
/**
* @IsGranted("cust_location.add")
*/
public function addSubmit(Request $req, EntityManagerInterface $em, ValidatorInterface $validator)
{
$cust_location = new CustomerLocation();
$this->setObject($cust_location, $req);
// validate
$errors = $validator->validate($cust_location);
// initialize error list
$error_array = [];
// add errors to list
foreach ($errors as $error) {
$error_array[$error->getPropertyPath()] = $error->getMessage();
}
// check if any errors were found
if (!empty($error_array)) {
// return validation failure response
return $this->json([
'success' => false,
'errors' => $error_array
], 422);
}
// validated! save the entity
$em->persist($cust_location);
$em->flush();
// return successful response
return $this->json([
'success' => 'Changes have been saved!'
]);
}
/**
* @Menu(selected="customer_location_list")
* @ParamConverter("cust_location", class="App\Entity\CustomerLocation")
* @IsGranted("cust_location.update")
*/
public function updateForm($id, EntityManagerInterface $em, CustomerLocation $cust_location)
{
$params = [];
$params['cust_location'] = $cust_location;
$params['mode'] = 'update';
// response
return $this->render('customer-location/form.html.twig', $params);
}
/**
* @ParamConverter("cust_location", class="App\Entity\CustomerLocation")
* @IsGranted("cust_location.update")
*/
public function updateSubmit(Request $req, EntityManagerInterface $em, ValidatorInterface $validator, CustomerLocation $cust_location)
{
$this->setObject($cust_location, $req);
// validate
$errors = $validator->validate($cust_location);
// initialize error list
$error_array = [];
// add errors to list
foreach ($errors as $error) {
$error_array[$error->getPropertyPath()] = $error->getMessage();
}
// check if any errors were found
if (!empty($error_array)) {
// return validation failure response
return $this->json([
'success' => false,
'errors' => $error_array
], 422);
}
// validated! save the entity
$em->flush();
// return successful response
return $this->json([
'success' => 'Changes have been saved!'
]);
}
/**
* @ParamConverter("cust_location", class="App\Entity\CustomerLocation")
* @IsGranted("cust_location.update")
*/
public function deleteSubmit(EntityManagerInterface $em, CustomerLocation $cust_location)
{
// delete this object
$em->remove($cust_location);
$em->flush();
// response
$response = new Response();
$response->setStatusCode(Response::HTTP_OK);
$response->send();
}
protected function setObject(CustomerLocation $obj, Request $req)
{
// set and save values
$obj->setName($req->request->get('name'))
->setCode($req->request->get('code'));
}
protected function setQueryFilters($datatable, QueryBuilder $query)
{
if (isset($datatable['query']['data-rows-search']) && !empty($datatable['query']['data-rows-search'])) {
$query->where('q.name LIKE :filter')
->setParameter('filter', '%' . $datatable['query']['data-rows-search'] . '%');
}
}
}

View file

@ -22,8 +22,6 @@ use App\Entity\BatterySize;
use App\Entity\SMSMessage; use App\Entity\SMSMessage;
use App\Entity\HubFilterLog; use App\Entity\HubFilterLog;
use App\Service\WarrantyRaffleFilter;
use Doctrine\ORM\Query; use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
@ -1224,132 +1222,6 @@ 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, WarrantyRaffleFilter $wr_filter)
{
// 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);
$wr_data = $this->getWarrantyRaffleData($req, $em, $raw_date_start, $raw_date_end);
// filter the retrieved warranty raffle data
$filtered_data = [];
foreach ($wr_data as $wr_entry)
{
$valid = $wr_filter->isValidRaffleEntry($wr_entry);
if ($valid)
$filtered_data[] = $wr_entry;
}
$resp = new StreamedResponse();
$resp->setCallback(function() use ($filtered_data) {
// csv output
$csv_handle = fopen('php://output', 'w+');
fputcsv($csv_handle, [
'Raffle Number',
'Serial Number',
'Product Name',
'Transaction Number', // Warranty Raffle Log ID
'Date',
'Outlet',
'Plate Number',
'Warranty Class',
'First Name',
'Last Name',
'Contact Number',
'Mobile Number', // number with mobile app
'Address',
'Email',
'Action Taken',
]);
foreach ($filtered_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) protected function processPopappFile(UploadedFile $csv_file, EntityManagerInterface $em)
{ {
// attempt to open file // attempt to open file
@ -2726,197 +2598,4 @@ class ReportController extends Controller
return $cust_ids; 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') . ' 00:00:00';
$new_date_end = $date_end->format('Y-m-d') . ' 23:59:59';
$db = $em->getConnection();
// get the data from warranty_raffle_log
$wrl_sql = 'SELECT wrl.id AS wrl_id, 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,
wrl.action AS action, wrl.api_user AS api_user_id
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'];
}
}
// get the mobile number of the api user using api_user_id
$api_user_id = $row['api_user_id'];
$mobile_num = '';
if ($api_user_id != null)
{
$api_sql = 'SELECT ms.phone_number AS mobile_number
FROM mobile_session ms
WHERE ms.id = :api_user_id';
$api_stmt = $db->prepare($api_sql);
$api_stmt->bindValue('api_user_id', $api_user_id);
$api_result = $api_stmt->executeQuery();
while ($api_row = $api_result->fetchAssociative())
{
$mobile_num = $api_row['mobile_number'];
}
}
$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' => $row['wrl_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'],
'mobile_number' => $mobile_num,
'address' => $row['address'],
'email' => $row['email'],
'action' => $row['action'],
];
}
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') . ' 00:00:00';
$new_date_end = $date_end->format('Y-m-d') . ' 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;
}
} }

View file

@ -1,94 +0,0 @@
<?php
namespace App\Controller\TAPI;
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\Ramcar\APIResult;
use App\Entity\Vehicle;
use Catalyst\APIBundle\Access\Generator as ACLGenerator;
class BatteryController extends APIController
{
protected $acl_gen;
public function __construct(ACLGenerator $acl_gen)
{
$this->acl_gen = $acl_gen;
}
public function getCompatibleBatteries(Request $req, $vid, EntityManagerInterface $em)
{
$this->denyAccessUnlessGranted('tapi_battery_compatible.list', null, 'No access.');
// check required parameters and api key
$required_params = [];
$msg = $this->checkRequiredParameters($req, $required_params);
if ($msg)
return new APIResponse(false, $msg);
// get vehicle
$vehicle = $em->getRepository(Vehicle::class)->find($vid);
if ($vehicle == null)
{
$message = 'Invalid vehicle id.';
return new APIResponse(false, $message);
}
// batteries
$batt_list = [];
// $batts = $vehicle->getBatteries();
$batts = $vehicle->getActiveBatteries();
foreach ($batts as $batt)
{
// TODO: Add warranty_tnv to battery information
$batt_list[] = [
'id' => $batt->getID(),
'mfg_id' => $batt->getManufacturer()->getID(),
'mfg_name' => $batt->getManufacturer()->getName(),
'model_id' => $batt->getModel()->getID(),
'model_name' => $batt->getModel()->getName(),
'size_id' => $batt->getSize()->getID(),
'size_name' => $batt->getSize()->getName(),
'price' => $batt->getSellingPrice(),
'wty_private' => $batt->getWarrantyPrivate(),
'wty_commercial' => $batt->getWarrantyCommercial(),
'image_url' => $this->getBatteryImageURL($req, $batt),
];
}
// data
$data = [
'vehicle' => [
'id' => $vehicle->getID(),
'mfg_id' => $vehicle->getManufacturer()->getID(),
'mfg_name' => $vehicle->getManufacturer()->getName(),
'make' => $vehicle->getMake(),
'model_year_from' => $vehicle->getModelYearFrom(),
'model_year_to' => $vehicle->getModelYearTo(),
],
'batteries' => $batt_list,
];
$message = 'Compatible batteries found.';
return new APIResponse(true, $message, $data);
}
// TODO: might have to put this in a common service since JobOrderController also calls this
protected function getBatteryImageURL($req, $batt)
{
// TODO: workaround for now, we get static image of battery based on model name
$filename = trim(strtolower($batt->getModel()->getName())) . '_mobile.jpg';
$file_path = $req->getSchemeAndHttpHost() . $this->generateUrl('static_battery_image') . '/' . $filename;
return $file_path;
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,45 +0,0 @@
<?php
namespace App\Controller\TAPI;
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\Promo;
use Catalyst\APIBundle\Access\Generator as ACLGenerator;
class PromoController extends APIController
{
protected $acl_gen;
public function __construct(ACLGenerator $acl_gen)
{
$this->acl_gen = $acl_gen;
}
public function listPromos(Request $req, EntityManagerInterface $em)
{
$this->denyAccessUnlessGranted('tapi_promo.list', null, 'No access.');
// check required parameters and api key
$required_params = [];
$msg = $this->checkRequiredParameters($req, $required_params);
if ($msg)
return new APIResponse(false, $msg);
$data = [];
// TODO: add call to get promos here
$message = 'Promos found.';
return new APIResponse(true, $message, $data);
}
}

View file

@ -1,79 +0,0 @@
<?php
namespace App\Controller\TAPI;
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\Service;
use Catalyst\APIBundle\Access\Generator as ACLGenerator;
class ServiceController extends APIController
{
protected $acl_gen;
public function __construct(ACLGenerator $acl_gen)
{
$this->acl_gen = $acl_gen;
}
public function listServices(Request $req, EntityManagerInterface $em)
{
$this->denyAccessUnlessGranted('tapi_service.list', null, 'No access.');
$required_params = [];
$res = $this->checkParamsAndKey($req, $em, $required_params);
if ($res->isError())
return $res->getReturnResponse();
// services
$results = $em->getRepository(Service::class)->findAll();
if (empty($results))
{
$res->setError(true)
->setErrorMessage('No services available.');
return $res->getReturnResponse();
}
$services = [];
foreach ($results as $result)
{
/*
// get partners
$partners = [];
$service_partners = $result->getPartners();
foreach($service_partners as $sp)
{
$partners[] = [
'id' => $sp->getID(),
'name' => $sp->getName(),
'branch' => $sp->getBranch(),
'address' => $sp->getAddress(),
'contact_nums' => $sp->getContactNumbers(),
'time_open' => $sp->getTimeOpen()->format("g:i A"),
'time_close' => $sp->getTimeClose()->format("g:i A"),
];
}
*/
$services[] = [
'id' => $result->getID(),
'name' => $result->getName(),
// 'partners' => $partners,
];
}
$data['services'] = $services;
$res->setData($data);
return $res->getReturnResponse();
}
}

View file

@ -1,107 +0,0 @@
<?php
namespace App\Controller\TAPI;
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\VehicleManufacturer;
use App\Entity\Vehicle;
use Catalyst\APIBundle\Access\Generator as ACLGenerator;
class VehicleController extends APIController
{
protected $acl_gen;
public function __construct(ACLGenerator $acl_gen)
{
$this->acl_gen = $acl_gen;
}
public function listVehicleManufacturers(Request $req, EntityManagerInterface $em)
{
$this->denyAccessUnlessGranted('tapi_vmanufacturer.list', null, 'No access.');
// check required parameters
$required_params = [];
$msg = $this->checkRequiredParameters($req, $required_params);
if ($msg)
return new APIResponse(false, $msg);
// get manufacturer list
$mfgs = $em->getRepository(VehicleManufacturer::class)->findBy(['flag_mobile' => true], ['name' => 'asc']);
$mfg_list = [];
foreach ($mfgs as $mfg)
{
$mfg_list[] = [
'id' => $mfg->getID(),
'name' => $mfg->getName(),
];
}
$data = [
'manufacturers' => $mfg_list
];
$message = 'Vehicle manufacturers found.';
return new APIResponse(true, $message, $data);
}
public function listVehicleMakes(Request $req, $mfg_id, EntityManagerInterface $em)
{
$this->denyAccessUnlessGranted('tapi_vehicle.list', null, 'No access.');
// check required parameters and api key
$required_params = [];
$msg = $this->checkRequiredParameters($req, $required_params);
if ($msg)
return new APIResponse(false, $msg);
// get manufacturer
$mfg = $em->getRepository(VehicleManufacturer::class)->find($mfg_id);
if ($mfg == null)
{
$message = 'Invalid vehicle manufacturer id.';
return new APIResponse(false, $message);
}
// get makes
$vehicles = $em->getRepository(Vehicle::class)->findBy(
[
'flag_mobile' => true,
'manufacturer' => $mfg_id,
],
['make' => 'asc']
);
$vlist = [];
foreach ($vehicles as $v)
{
$vlist[] = [
'id' => $v->getID(),
'make' => trim($v->getMake() . ' ' . $v->getModelYearFormatted(false)),
];
}
$data = [
'manufacturer' => [
'id' => $mfg->getID(),
'name' => $mfg->getName(),
],
'makes' => $vlist,
];
$message = 'Vehicle models found.';
return new APIResponse(true, $message, $data);
}
}

View file

@ -485,7 +485,7 @@ class VehicleController extends Controller
// get row data // get row data
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$vobj = $em->getRepository(Vehicle::class)->find($req->request->get('vehicle_id')); $vobj = $em->getRepository(Vehicle::class)->find($req->request->get('vehicle_id'));
$all_batts = $em->getRepository(Battery::class)->findBy(['flag_active' => true]); $all_batts = $em->getRepository(Battery::class)->findAll();
if (empty($vobj)) if (empty($vobj))
throw $this->createNotFoundException('The item does not exist'); throw $this->createNotFoundException('The item does not exist');
@ -495,20 +495,19 @@ class VehicleController extends Controller
$battery_index = []; $battery_index = [];
// get compatible batteries from selected manufacturer // get compatible batteries from selected manufacturer
// foreach ($vobj->getBatteries() as $battery) foreach ($vobj->getBatteries() as $battery)
foreach ($vobj->getActiveBatteries() as $battery)
{ {
$batteries[] = [ $batteries[] = [
'id' => $battery->getID(), 'id' => $battery->getID(),
'mfg_name' => $battery->getManufacturer()->getName(), 'mfg_name' => $battery->getManufacturer()->getName(),
'model_name' => $battery->getModel()->getName(), 'model_name' => $battery->getModel()->getName(),
'size_name' => $battery->getSize()->getName(), 'size_name' => $battery->getSize()->getName(),
'prod_code' => $battery->getProductCode(), 'prod_code' => $battery->getProductCode(),
'sell_price' => $battery->getSellingPrice(), 'sell_price' => $battery->getSellingPrice(),
'warr_private' => $battery->getWarrantyPrivate(), 'warr_private' => $battery->getWarrantyPrivate(),
'warr_commercial' => $battery->getWarrantyCommercial(), 'warr_commercial' => $battery->getWarrantyCommercial(),
]; ];
$battery_index[$battery->getID()] = 1; $battery_index[$battery->getID()] = 1;
} }
// add all other batteries, because they want options // add all other batteries, because they want options

View file

@ -170,9 +170,6 @@ class WarrantyController extends Controller
else else
$obj->setSerial($req->request->get('serial')); $obj->setSerial($req->request->get('serial'));
// get outlet info, sender info
$req->request->get('outlet_name', '');
// set and save values // set and save values
$obj->setWarrantyClass($req->request->get('warranty_class')) $obj->setWarrantyClass($req->request->get('warranty_class'))
->setFirstName($req->request->get('first_name')) ->setFirstName($req->request->get('first_name'))
@ -181,13 +178,7 @@ class WarrantyController extends Controller
->setDatePurchase($date_purchase) ->setDatePurchase($date_purchase)
->setClaimedFrom($req->request->get('claim_from')) ->setClaimedFrom($req->request->get('claim_from'))
->setStatus($req->request->get('status')) ->setStatus($req->request->get('status'))
->setCreateSource(WarrantySource::ADMIN_PANEL) ->setCreateSource(WarrantySource::ADMIN_PANEL);
->setOutletName($req->request->get('outlet_name', ''))
->setOutletContactNumber($req->request->get('outlet_contact_number', ''))
->setSenderName($req->request->get('sender_name', ''))
->setSenderContactNumber($req->request->get('sender_contact_number', ''))
->setOutletAddress($req->request->get('outlet_address', ''))
->setSalesInvoiceNumber($req->request->get('sales_invoice_number', ''));
if ($date_claim) if ($date_claim)
{ {
@ -289,12 +280,6 @@ class WarrantyController extends Controller
'battery_size' => $req->request->get('battery_size'), 'battery_size' => $req->request->get('battery_size'),
'sap_battery' => $req->request->get('sap_battery'), 'sap_battery' => $req->request->get('sap_battery'),
'plate_number' => $req->request->get('plate_number'), 'plate_number' => $req->request->get('plate_number'),
'outlet_name' => $req->request->get('outlet_name', ''),
'outlet_contact_number' => $req->request->get('outlet_contact_number', ''),
'sender_name' => $req->request->get('sender_name', ''),
'sender_contact_number' => $req->request->get('sender_contact_number', ''),
'outlet_address' => $req->request->get('outlet_address', ''),
'sales_invoice_number' => $req->request->get('sales_invoice_number', ''),
]; ];
$logger->logWarrantyInfo($log_data, '', $user_id, $action, $source); $logger->logWarrantyInfo($log_data, '', $user_id, $action, $source);
@ -360,13 +345,7 @@ class WarrantyController extends Controller
->setMobileNumber($req->request->get('mobile_number')) ->setMobileNumber($req->request->get('mobile_number'))
->setDatePurchase($date_purchase) ->setDatePurchase($date_purchase)
->setClaimedFrom($req->request->get('claim_from')) ->setClaimedFrom($req->request->get('claim_from'))
->setStatus($req->request->get('status')) ->setStatus($req->request->get('status'));
->setOutletName($req->request->get('outlet_name', ''))
->setOutletContactNumber($req->request->get('outlet_contact_number', ''))
->setSenderName($req->request->get('sender_name', ''))
->setSenderContactNumber($req->request->get('sender_contact_number', ''))
->setOutletAddress($req->request->get('outlet_address', ''))
->setSalesInvoiceNumber($req->request->get('sales_invoice_number', ''));
if ($date_claim) if ($date_claim)
{ {

View file

@ -147,12 +147,6 @@ class Battery
*/ */
protected $image_file; protected $image_file;
// flag if battery is active
/**
* @ORM\Column(type="boolean", options={"default": true})
*/
protected $flag_active;
public function __construct() public function __construct()
{ {
$this->vehicles = new ArrayCollection(); $this->vehicles = new ArrayCollection();
@ -165,8 +159,6 @@ class Battery
$this->total_height = 0; $this->total_height = 0;
$this->date_create = new DateTime(); $this->date_create = new DateTime();
$this->flag_active = true;
} }
public function getID() public function getID()
@ -390,15 +382,4 @@ class Battery
{ {
return $this->image_file; return $this->image_file;
} }
public function isActive()
{
return $this->flag_active;
}
public function setActive($flag_active = true)
{
$this->flag_active = $flag_active;
return $this;
}
} }

View file

@ -1,63 +0,0 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity
* @ORM\Table(name="customer_location", indexes={
* @ORM\Index(name="cust_location_idx", columns={"code"}),
* })
*/
class CustomerLocation
{
// unique id
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string", length=25)
* @Assert\NotBlank()
*/
protected $code;
/**
* @ORM\Column(type="string", length=25)
* @Assert\NotBlank()
*/
protected $name;
public function getID()
{
return $this->id;
}
public function setName($name)
{
$this->name = $name;
return $this;
}
public function getName()
{
return $this->name;
}
public function setCode($code)
{
$this->code = $code;
return $this;
}
public function getCode()
{
return $this->code;
}
}

View file

@ -422,13 +422,6 @@ class JobOrder
*/ */
protected $ownership_type; protected $ownership_type;
// customer location
/**
* @ORM\ManyToOne(targetEntity="CustomerLocation", inversedBy="job_orders")
* @ORM\JoinColumn(name="cust_location_id", referencedColumnName="id", nullable=true)
*/
protected $cust_location;
public function __construct() public function __construct()
{ {
$this->date_create = new DateTime(); $this->date_create = new DateTime();
@ -1206,15 +1199,4 @@ class JobOrder
{ {
return $this->ownership_type; return $this->ownership_type;
} }
public function setCustomerLocation(CustomerLocation $cust_location = null)
{
$this->cust_location = $cust_location;
return $this;
}
public function getCustomerLocation()
{
return $this->cust_location;
}
} }

View file

@ -4,8 +4,6 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Criteria;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
/** /**
@ -179,12 +177,4 @@ class Vehicle
{ {
return $this->cust_vehicles; return $this->cust_vehicles;
} }
public function getActiveBatteries()
{
$crit = Criteria::create();
$crit->where(Criteria::expr()->eq('flag_active', true));
return $this->batteries->matching($crit);
}
} }

View file

@ -245,42 +245,6 @@ class Warranty
*/ */
protected $dealer_branch_code; protected $dealer_branch_code;
// for non-motiv warranties created via admin panel
/**
* @ORM\Column(type="string", length=80, options={"default": ""})
*/
protected $outlet_name;
// for non-motiv warranties created via admin panel
/**
* @ORM\Column(type="string", length=30, options={"default": ""})
*/
protected $outlet_contact_num;
// for non-motiv warranties created via admin panel
/**
* @ORM\Column(type="string", length=80, options={"default": ""})
*/
protected $sender_name;
// for non-motiv warranties created via admin panel
/**
* @ORM\Column(type="string", length=30, options={"default": ""})
*/
protected $sender_contact_num;
// for non-motiv warranties created via admin panel
/**
* @ORM\Column(type="string", length=180, options={"default": ""})
*/
protected $outlet_address;
// for non-motiv warranties created via admin panel
/**
* @ORM\Column(type="string", length=30, options={"default": ""})
*/
protected $sales_invoice_num;
public function __construct() public function __construct()
{ {
$this->date_create = new DateTime(); $this->date_create = new DateTime();
@ -292,13 +256,6 @@ class Warranty
$this->odometer = 0; $this->odometer = 0;
$this->flag_validated = false; $this->flag_validated = false;
$this->create_source = 'unknown'; $this->create_source = 'unknown';
$this->outlet_name = '';
$this->outlet_contact_num = '';
$this->sender_name = '';
$this->sender_contact_num = '';
$this->outlet_address = '';
$this->sales_invoice_num = '';
} }
public function getID() public function getID()
@ -737,70 +694,4 @@ class Warranty
{ {
return $this->dealer_branch_code; return $this->dealer_branch_code;
} }
public function setOutletName($outlet_name)
{
$this->outlet_name = $outlet_name;
return $this;
}
public function getOutletName()
{
return $this->outlet_name;
}
public function setOutletContactNumber($outlet_contact_num)
{
$this->outlet_contact_num = $outlet_contact_num;
return $this;
}
public function getOutletContactNumber()
{
return $this->outlet_contact_num;
}
public function setSenderName($sender_name)
{
$this->sender_name = $sender_name;
return $this;
}
public function getSenderName()
{
return $this->sender_name;
}
public function setSenderContactNumber($sender_contact_num)
{
$this->sender_contact_num = $sender_contact_num;
return $this;
}
public function getSenderContactNumber()
{
return $this->sender_contact_num;
}
public function setOutletAddress($outlet_address)
{
$this->outlet_address = $outlet_address;
return $this;
}
public function getOutletAddress()
{
return $this->outlet_address;
}
public function setSalesInvoiceNumber($sales_invoice_num)
{
$this->sales_invoice_num = $sales_invoice_num;
return $this;
}
public function getSalesInvoiceNumber()
{
return $this->sales_invoice_num;
}
} }

View file

@ -1,295 +0,0 @@
<?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;
}
}

View file

@ -1,120 +0,0 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use DateTime;
/**
* @ORM\Entity
* @ORM\Table(name="warranty_serial_load_log")
*/
class WarrantySerialLoadLog
{
// 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 uploaded the serials
/**
* @ORM\Column(type="string", length=32)
*/
protected $api_user;
// serial
/**
* @ORM\Column(type="string", length=50)
*/
protected $serial;
// flag if loaded
/**
* @ORM\Column(type="boolean")
*/
protected $flag_loaded;
/**
* @ORM\Column(type="string", length=30, nullable=true)
*/
protected $error;
public function __construct()
{
$this->date_create = new DateTime();
$this->api_user = '';
$this->serial = '';
$this->flag_loaded = false;
$this->error = null;
}
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 setSerial($serial)
{
$this->serial = $serial;
return $this;
}
public function getSerial()
{
return $this->serial;
}
public function setLoaded($flag_loaded = true)
{
$this->flag_loaded = $flag_loaded;
return $this;
}
public function isLoaded()
{
return $this->flag_loaded;
}
public function setError($error)
{
$this->error = $error;
return $this;
}
public function getError()
{
return $this->error;
}
}

View file

@ -1,129 +0,0 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use DateTime;
/**
* @ORM\Entity
* @ORM\Table(
* name="warranty_serial_queue",
* )
*/
class WarrantySerialQueue
{
// unique id
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
// date created
/**
* @ORM\Column(type="datetime")
*/
protected $date_create;
// original filename of warranty serial
/**
* @ORM\Column(type="string", length=80, nullable=true)
*/
protected $orig_file_serial;
// warranty serial file that we created
/**
* @ORM\Column(type="string", length=80, nullable=true)
*/
protected $file_serial;
// status
/**
* @ORM\Column(type="string", length=20)
*/
protected $status;
// user that uploaded the serials
/**
* @ORM\Column(type="string", length=32)
*/
protected $api_user;
// file identifier that we send back
/**
* @ORM\Column(type="string", length=21)
*/
protected $file_id;
public function __construct()
{
$this->date_create = new DateTime();
$this->file_serial = null;
$this->orig_file_serial = null;
$this->status = '';
$this->api_user = '';
$this->file_id = '';
}
public function getID()
{
return $this->id;
}
public function setFileSerial($file = null)
{
$this->file_serial = $file;
return $this;
}
public function getFileSerial()
{
return $this->file_serial;
}
public function setStatus($status)
{
$this->status = $status;
return $this;
}
public function getStatus()
{
return $this->status;
}
public function setApiUser($api_user)
{
$this->api_user = $api_user;
return $this;
}
public function getApiUser()
{
return $this->api_user;
}
public function setFileID($file_id)
{
$this->file_id = $file_id;
return $this;
}
public function getFileID()
{
return $this->file_id;
}
public function setOrigFileSerial($file = null)
{
$this->orig_file_serial = $file;
return $this;
}
public function getOrigFileSerial()
{
return $this->orig_file_serial;
}
}

View file

@ -1,138 +0,0 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use DateTime;
/**
* @ORM\Entity
* @ORM\Table(name="warranty_serial_upload_log")
*/
class WarrantySerialUploadLog
{
// 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 uploaded the file
/**
* @ORM\Column(type="string", length=32)
*/
protected $api_user;
// original filename of warranty serial
/**
* @ORM\Column(type="string", length=80, nullable=true)
*/
protected $orig_file_serial;
// uploaded file name
/**
* @ORM\Column(type="string", length=80, nullable=true)
*/
protected $uploaded_file_serial;
// flag if uploaded
/**
* @ORM\Column(type="boolean")
*/
protected $flag_uploaded;
/**
* @ORM\Column(type="string", length=60, nullable=true)
*/
protected $error;
public function __construct()
{
$this->date_create = new DateTime();
$this->api_user = '';
$this->orig_file_serial = '';
$this->orig_file_serial = '';
$this->flag_uploaded = false;
$this->error = null;
}
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 setOrigFileSerial($file = null)
{
$this->orig_file_serial = $file;
return $this;
}
public function getOrigFileSerial()
{
return $this->orig_file_serial;
}
public function setUploadedFileSerial($file = null)
{
$this->uploaded_file_serial = $file;
return $this;
}
public function getUploadedFileSerial()
{
return $this->uploaded_file_serial;
}
public function setUploaded($flag_uploaded = true)
{
$this->flag_uploaded = $flag_uploaded;
return $this;
}
public function isUploaded()
{
return $this->flag_uploaded;
}
public function setError($error)
{
$this->error = $error;
return $this;
}
public function getError()
{
return $this->error;
}
}

View file

@ -9,7 +9,6 @@ class ModeOfPayment extends NameValue
const DEBIT_CARD = 'debit_card'; const DEBIT_CARD = 'debit_card';
const INSTALLMENT = 'installment'; const INSTALLMENT = 'installment';
const GCASH = 'gcash'; const GCASH = 'gcash';
const CREDIT_CARD_AMEX = 'credit_card_amex';
const COLLECTION = [ const COLLECTION = [
'cash' => 'Cash', 'cash' => 'Cash',
@ -17,6 +16,5 @@ class ModeOfPayment extends NameValue
'debit_card' => 'Debit Card', 'debit_card' => 'Debit Card',
'installment' => 'Installment - BDO', 'installment' => 'Installment - BDO',
'gcash' => 'GCash', 'gcash' => 'GCash',
'credit_card_amex' => 'Credit Card - AMEX',
]; ];
} }

View file

@ -4,14 +4,13 @@ namespace App\Ramcar;
class TransactionOrigin extends NameValue class TransactionOrigin extends NameValue
{ {
const CALL = 'call'; const CALL = 'call';
const ONLINE = 'online'; const ONLINE = 'online';
const FACEBOOK = 'facebook'; const FACEBOOK = 'facebook';
const VIP = 'vip'; const VIP = 'vip';
const MOBILE_APP = 'mobile_app'; const MOBILE_APP = 'mobile_app';
const WALK_IN = 'walk_in'; const WALK_IN = 'walk_in';
const LAZADA = 'lazada'; const LAZADA = 'lazada';
const THIRD_PARTY = 'third_party';
const YOKOHAMA_OP_FACEBOOK = 'yokohama_op_facebook'; const YOKOHAMA_OP_FACEBOOK = 'yokohama_op_facebook';
const YOKOHAMA_TWITTER = 'yokohama_twitter'; const YOKOHAMA_TWITTER = 'yokohama_twitter';
const YOKOHAMA_INSTAGRAM = 'yokohama_instagram'; const YOKOHAMA_INSTAGRAM = 'yokohama_instagram';
@ -27,7 +26,6 @@ class TransactionOrigin extends NameValue
'mobile_app' => 'Mobile App', 'mobile_app' => 'Mobile App',
'walk_in' => 'Walk-in', 'walk_in' => 'Walk-in',
'lazada' => 'Lazada', 'lazada' => 'Lazada',
'third_party' => 'Third Party',
'yokohama_op_facebook' => 'Yokohama OP Facebook', 'yokohama_op_facebook' => 'Yokohama OP Facebook',
'yokohama_twitter' => 'Yokohama Twitter', 'yokohama_twitter' => 'Yokohama Twitter',
'yokohama_instagram' => 'Yokohama Instagram', 'yokohama_instagram' => 'Yokohama Instagram',

View file

@ -36,7 +36,7 @@ class ResqInvoiceGenerator implements InvoiceGeneratorInterface
const OTHER_SERVICES_FEE = 200; const OTHER_SERVICES_FEE = 200;
const COOLANT_FEE = 1600; const COOLANT_FEE = 1600;
const REFUEL_FEE_GAS = 320; // for 4 liters const REFUEL_FEE_GAS = 320; // for 4 liters
const REFUEL_FEE_DIESEL = 320; // for 4 liters const REFUEL_FEE_DIESEL = 340; // for 4 liters
private $security; private $security;
protected $em; protected $em;
@ -84,7 +84,7 @@ class ResqInvoiceGenerator implements InvoiceGeneratorInterface
break; break;
case ServiceType::JUMPSTART_WARRANTY: case ServiceType::JUMPSTART_WARRANTY:
$this->processJumpstartWarranty($total, $invoice); $this->processJumpstartWarranty($total, $invoice);
break;
case ServiceType::BATTERY_REPLACEMENT_NEW: case ServiceType::BATTERY_REPLACEMENT_NEW:
$this->processEntries($total, $criteria, $invoice); $this->processEntries($total, $criteria, $invoice);
/* /*

View file

@ -28,7 +28,6 @@ use App\Entity\Customer;
use App\Entity\CustomerTag; use App\Entity\CustomerTag;
use App\Entity\EmergencyType; use App\Entity\EmergencyType;
use App\Entity\OwnershipType; use App\Entity\OwnershipType;
use App\Entity\CustomerLocation;
use App\Ramcar\InvoiceCriteria; use App\Ramcar\InvoiceCriteria;
use App\Ramcar\ServiceType; use App\Ramcar\ServiceType;
@ -425,19 +424,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
} }
} }
// check if customer location is set
$cust_location_id = $req->request->get('cust_location', 0);
if ($cust_location_id == 0)
$error_array['cust_location'] = 'Customer location is required.';
else
{
// get customer location
$cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id);
if ($cust_location == null)
$error_array['cust_location'] = 'Invalid customer location';
}
// get source of awareness if any // get source of awareness if any
$soa_type = $req->request->get('source_of_awareness', ''); $soa_type = $req->request->get('source_of_awareness', '');
@ -446,13 +432,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
// get initial concern if any // get initial concern if any
$initial_concern = $req->request->get('initial_concern', ''); $initial_concern = $req->request->get('initial_concern', '');
if (empty($initial_concern))
$error_array['initial_concern'] = 'Initial concern of customer is required.';
// get initial concern notes if any // get initial concern notes if any
$initial_concern_notes = $req->request->get('initial_concern_notes', ''); $initial_concern_notes = $req->request->get('initial_concern_notes', '');
if (empty($initial_concern_notes))
$error_array['initial_concern_notes'] = 'Notes on initial concern of customer is required.';
// get gender if any // get gender if any
$gender = $req->request->get('gender', ''); $gender = $req->request->get('gender', '');
@ -507,8 +489,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
->setCallerClassification($caller_class) ->setCallerClassification($caller_class)
->setGender($gender) ->setGender($gender)
->setEmergencyType($etype) ->setEmergencyType($etype)
->setOwnershipType($owner_type) ->setOwnershipType($owner_type);
->setCustomerLocation($cust_location);
// check if user is null, meaning call to create came from API // check if user is null, meaning call to create came from API
if ($user != null) if ($user != null)
@ -711,13 +692,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
// get initial concern if any // get initial concern if any
$initial_concern = $req->request->get('initial_concern', ''); $initial_concern = $req->request->get('initial_concern', '');
if (empty($initial_concern))
$error_array['initial_concern'] = 'Initial concern of customer is required.';
// get initial concern notes if any // get initial concern notes if any
$initial_concern_notes = $req->request->get('initial_concern_notes', ''); $initial_concern_notes = $req->request->get('initial_concern_notes', '');
if (empty($initial_concern_notes))
$error_array['initial_concern_notes'] = 'Notes on initial concern of customer is required.';
// get gender if any // get gender if any
$gender = $req->request->get('gender', ''); $gender = $req->request->get('gender', '');
@ -733,19 +710,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$ownertype_id = $req->request->get('ownership_type', 0); $ownertype_id = $req->request->get('ownership_type', 0);
$owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); $owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id);
// check if customer location is set
$cust_location_id = $req->request->get('cust_location', 0);
if ($cust_location_id == 0)
$error_array['cust_location'] = 'Customer location is required.';
else
{
// get customer location
$cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id);
if ($cust_location == null)
$error_array['cust_location'] = 'Invalid customer location';
}
if (empty($error_array)) if (empty($error_array))
{ {
// get current user // get current user
@ -780,8 +744,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
->setCallerClassification($caller_class) ->setCallerClassification($caller_class)
->setGender($gender) ->setGender($gender)
->setEmergencyType($etype) ->setEmergencyType($etype)
->setOwnershipType($owner_type) ->setOwnershipType($owner_type);
->setCustomerLocation($cust_location);
// did they change invoice? // did they change invoice?
$invoice_items = $req->request->get('invoice_items', []); $invoice_items = $req->request->get('invoice_items', []);
@ -935,13 +898,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
// get initial concern if any // get initial concern if any
$initial_concern = $req->request->get('initial_concern', ''); $initial_concern = $req->request->get('initial_concern', '');
if (empty($initial_concern))
$error_array['initial_concern'] = 'Initial concern of customer is required.';
// get initial concern notes if any // get initial concern notes if any
$initial_concern_notes = $req->request->get('initial_concern_notes', ''); $initial_concern_notes = $req->request->get('initial_concern_notes', '');
if (empty($initial_concern_notes))
$error_array['initial_concern_notes'] = 'Notes on initial concern of customer is required.';
// get gender if any // get gender if any
$gender = $req->request->get('gender', ''); $gender = $req->request->get('gender', '');
@ -957,19 +916,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$ownertype_id = $req->request->get('ownership_type', 0); $ownertype_id = $req->request->get('ownership_type', 0);
$owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); $owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id);
// check if customer location is set
$cust_location_id = $req->request->get('cust_location', 0);
if ($cust_location_id == 0)
$error_array['cust_location'] = 'Customer location is required.';
else
{
// get customer location
$cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id);
if ($cust_location == null)
$error_array['cust_location'] = 'Invalid customer location';
}
if (empty($error_array)) if (empty($error_array))
{ {
// coordinates // coordinates
@ -1001,8 +947,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
->setGender($gender) ->setGender($gender)
->setCallerClassification($caller_class) ->setCallerClassification($caller_class)
->setEmergencyType($etype) ->setEmergencyType($etype)
->setOwnershipType($owner_type) ->setOwnershipType($owner_type);
->setCustomerLocation($cust_location);
// validate // validate
$errors = $this->validator->validate($obj); $errors = $this->validator->validate($obj);
@ -1102,13 +1047,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
// get initial concern if any // get initial concern if any
$initial_concern = $req->request->get('initial_concern', ''); $initial_concern = $req->request->get('initial_concern', '');
if (empty($initial_concern))
$error_array['initial_concern'] = 'Initial concern of customer is required.';
// get initial concern notes if any // get initial concern notes if any
$initial_concern_notes = $req->request->get('initial_concern_notes', ''); $initial_concern_notes = $req->request->get('initial_concern_notes', '');
if (empty($initial_concern_notes))
$error_array['initial_concern_notes'] = 'Notes on initial concern of customer is required.';
// get gender if any // get gender if any
$gender = $req->request->get('gender', ''); $gender = $req->request->get('gender', '');
@ -1124,19 +1065,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$ownertype_id = $req->request->get('ownership_type', 0); $ownertype_id = $req->request->get('ownership_type', 0);
$owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); $owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id);
// check if customer location is set
$cust_location_id = $req->request->get('cust_location', 0);
if ($cust_location_id == 0)
$error_array['cust_location'] = 'Customer location is required.';
else
{
// get customer location
$cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id);
if ($cust_location == null)
$error_array['cust_location'] = 'Invalid customer location';
}
// get current user // get current user
$user = $this->security->getUser(); $user = $this->security->getUser();
@ -1170,8 +1098,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
->setCallerClassification($caller_class) ->setCallerClassification($caller_class)
->setGender($gender) ->setGender($gender)
->setEmergencyType($etype) ->setEmergencyType($etype)
->setOwnershipType($owner_type) ->setOwnershipType($owner_type);
->setCustomerLocation($cust_location);
if ($user != null) if ($user != null)
{ {
@ -1260,13 +1187,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
// get initial concern if any // get initial concern if any
$initial_concern = $req->request->get('initial_concern', ''); $initial_concern = $req->request->get('initial_concern', '');
if (empty($initial_concern))
$error_array['initial_concern'] = 'Initial concern of customer is required.';
// get initial concern notes if any // get initial concern notes if any
$initial_concern_notes = $req->request->get('initial_concern_notes', ''); $initial_concern_notes = $req->request->get('initial_concern_notes', '');
if (empty($initial_concern_notes))
$error_array['initial_concern_notes'] = 'Notes on initial concern of customer is required.';
// get gender if any // get gender if any
$gender = $req->request->get('gender', ''); $gender = $req->request->get('gender', '');
@ -1282,19 +1205,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$ownertype_id = $req->request->get('ownership_type', 0); $ownertype_id = $req->request->get('ownership_type', 0);
$owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); $owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id);
// check if customer location is set
$cust_location_id = $req->request->get('cust_location', 0);
if ($cust_location_id == 0)
$error_array['cust_location'] = 'Customer location is required.';
else
{
// get customer location
$cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id);
if ($cust_location == null)
$error_array['cust_location'] = 'Invalid customer location';
}
if (empty($error_array)) { if (empty($error_array)) {
// coordinates // coordinates
$point = new Point($req->request->get('coord_lng'), $req->request->get('coord_lat')); $point = new Point($req->request->get('coord_lng'), $req->request->get('coord_lat'));
@ -1322,8 +1232,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
->setGender($gender) ->setGender($gender)
->setCallerClassification($caller_class) ->setCallerClassification($caller_class)
->setEmergencyType($etype) ->setEmergencyType($etype)
->setOwnershipType($owner_type) ->setOwnershipType($owner_type);
->setCustomerLocation($cust_location);
// validate // validate
$errors = $this->validator->validate($obj); $errors = $this->validator->validate($obj);
@ -1532,13 +1441,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
// get initial concern if any // get initial concern if any
$initial_concern = $req->request->get('initial_concern', ''); $initial_concern = $req->request->get('initial_concern', '');
if (empty($initial_concern))
$error_array['initial_concern'] = 'Initial concern of customer is required.';
// get initial concern notes if any // get initial concern notes if any
$initial_concern_notes = $req->request->get('initial_concern_notes', ''); $initial_concern_notes = $req->request->get('initial_concern_notes', '');
if (empty($initial_concern_notes))
$error_array['initial_concern_notes'] = 'Notes on initial concern of customer is required.';
// get gender if any // get gender if any
$gender = $req->request->get('gender', ''); $gender = $req->request->get('gender', '');
@ -1554,19 +1459,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$ownertype_id = $req->request->get('ownership_type', 0); $ownertype_id = $req->request->get('ownership_type', 0);
$owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); $owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id);
// check if customer location is set
$cust_location_id = $req->request->get('cust_location', 0);
if ($cust_location_id == 0)
$error_array['cust_location'] = 'Customer location is required.';
else
{
// get customer location
$cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id);
if ($cust_location == null)
$error_array['cust_location'] = 'Invalid customer location';
}
// get previously assigned hub, if any // get previously assigned hub, if any
$old_hub = $obj->getHub(); $old_hub = $obj->getHub();
@ -1625,7 +1517,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
->setCallerClassification($caller_class) ->setCallerClassification($caller_class)
->setEmergencyType($etype) ->setEmergencyType($etype)
->setOwnershipType($owner_type) ->setOwnershipType($owner_type)
->setCustomerLocation($cust_location)
->clearRider(); ->clearRider();
if ($user != null) if ($user != null)
@ -1769,8 +1660,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
// validated! save the entity // validated! save the entity
$em->persist($obj); $em->persist($obj);
$em->flush(); $em->flush();
$this->sendSMSHubRejection($obj, $jo);
} }
return $error_array; return $error_array;
@ -1832,13 +1721,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
// get initial concern if any // get initial concern if any
$initial_concern = $req->request->get('initial_concern', ''); $initial_concern = $req->request->get('initial_concern', '');
if (empty($initial_concern))
$error_array['initial_concern'] = 'Initial concern of customer is required.';
// get initial concern notes if any // get initial concern notes if any
$initial_concern_notes = $req->request->get('initial_concern_notes', ''); $initial_concern_notes = $req->request->get('initial_concern_notes', '');
if (empty($initial_concern_notes))
$error_array['initial_concern_notes'] = 'Notes on initial concern of customer is required.';
// get gender if any // get gender if any
$gender = $req->request->get('gender', ''); $gender = $req->request->get('gender', '');
@ -1854,19 +1739,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$ownertype_id = $req->request->get('ownership_type', 0); $ownertype_id = $req->request->get('ownership_type', 0);
$owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); $owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id);
// check if customer location is set
$cust_location_id = $req->request->get('cust_location', 0);
if ($cust_location_id == 0)
$error_array['cust_location'] = 'Customer location is required.';
else
{
// get customer location
$cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id);
if ($cust_location == null)
$error_array['cust_location'] = 'Invalid customer location';
}
if (empty($error_array)) { if (empty($error_array)) {
// rider mqtt event // rider mqtt event
// NOTE: need to send this before saving because rider will be cleared // NOTE: need to send this before saving because rider will be cleared
@ -1919,8 +1791,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
->setGender($gender) ->setGender($gender)
->setCallerClassification($caller_class) ->setCallerClassification($caller_class)
->setEmergencyType($etype) ->setEmergencyType($etype)
->setOwnershipType($owner_type) ->setOwnershipType($owner_type);
->setCustomerLocation($cust_location);
if ($user != null) if ($user != null)
{ {
@ -2492,7 +2363,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
if ($willing_to_wait == WillingToWaitContent::NOT_WILLING_TO_WAIT) if ($willing_to_wait == WillingToWaitContent::NOT_WILLING_TO_WAIT)
{ {
// reset distance limit if emergency // reset distance limit if emergency
//TODO: move to .env the emergency distance limit
$hub_criteria->setLimitDistance(500); $hub_criteria->setLimitDistance(500);
$hub_criteria->setEmergency(true); $hub_criteria->setEmergency(true);
} }
@ -2534,19 +2404,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$hub['distance'] = false; $hub['distance'] = false;
} }
// get rider counts
$rider_counts = $this->getHubRiderCounts($hub['hub']);
// counters // counters
// get only the active riders for the total rider count per hub $hub['rider_count'] = count($hub['hub']->getAvailableRiders());
// $hub['rider_count'] = count($hub['hub']->getAvailableRiders());
$hub['rider_count'] = count($hub['hub']->getActiveRiders());
$hub['redis_jo_count'] = $hub['jo_count']; $hub['redis_jo_count'] = $hub['jo_count'];
$hub['rider_logged_in'] = $rider_counts['logged_in'];
$hub['rider_in_transit'] = $rider_counts['in_transit'];
$hub['rider_available'] = $rider_counts['available'];
//$hub['redis_jo_count'] = 0; //$hub['redis_jo_count'] = 0;
// $hub['jo_count'] = count($hub['hub']->getForAssignmentJobOrders()); // $hub['jo_count'] = count($hub['hub']->getForAssignmentJobOrders());
$hub['jo_count'] = $hub['redis_jo_count']; $hub['jo_count'] = $hub['redis_jo_count'];
@ -2693,10 +2553,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$this->fillDropdownParameters($params); $this->fillDropdownParameters($params);
$this->fillFormTags($params); $this->fillFormTags($params);
// get the rider data to display for table
$rider_data = $this->getRiderDataForAssignment($obj);
$params['rider_data'] = $rider_data;
// get template to display // get template to display
$params['template'] = $this->getTwigTemplate('jo_assigning_form'); $params['template'] = $this->getTwigTemplate('jo_assigning_form');
$params['obj'] = $obj; $params['obj'] = $obj;
@ -2822,11 +2678,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
// check if emergency or not // check if emergency or not
$willing_to_wait = $obj->getWillWait(); $willing_to_wait = $obj->getWillWait();
if ($willing_to_wait == WillingToWaitContent::NOT_WILLING_TO_WAIT) if ($willing_to_wait == WillingToWaitContent::NOT_WILLING_TO_WAIT)
{
//TODO: move to .env the emergency distance limit
$hub_criteria->setLimitDistance(500);
$hub_criteria->setEmergency(true); $hub_criteria->setEmergency(true);
}
// get JO and customer id for logging purposes // get JO and customer id for logging purposes
$jo_id = $obj->getID(); $jo_id = $obj->getID();
@ -2863,20 +2715,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$hub['distance'] = false; $hub['distance'] = false;
} }
// get rider counts
$rider_counts = $this->getHubRiderCounts($hub['hub']);
// counters // counters
// get only the active riders for the total rider count per hub $hub['rider_count'] = count($hub['hub']->getAvailableRiders());
// $hub['rider_count'] = count($hub['hub']->getAvailableRiders());
$hub['rider_count'] = count($hub['hub']->getActiveRiders());
// $hub['redis_jo_count'] = $hub['jo_count']; // $hub['redis_jo_count'] = $hub['jo_count'];
$hub['redis_jo_count'] = 0; $hub['redis_jo_count'] = 0;
$hub['rider_logged_in'] = $rider_counts['logged_in'];
$hub['rider_in_transit'] = $rider_counts['in_transit'];
$hub['rider_available'] = $rider_counts['available'];
// $hub['jo_count'] = count($hub['hub']->getForAssignmentJobOrders()); // $hub['jo_count'] = count($hub['hub']->getForAssignmentJobOrders());
$hub['jo_count'] = $hub['redis_jo_count']; $hub['jo_count'] = $hub['redis_jo_count'];
@ -2976,10 +2818,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$this->fillDropdownParameters($params); $this->fillDropdownParameters($params);
$this->fillFormTags($params); $this->fillFormTags($params);
// get the rider data to display for table
$rider_data = $this->getRiderDataForAssignment($obj);
$params['rider_data'] = $rider_data;
$params['obj'] = $obj; $params['obj'] = $obj;
$params['status_cancelled'] = JOStatus::CANCELLED; $params['status_cancelled'] = JOStatus::CANCELLED;
// get template to display // get template to display
@ -3435,34 +3273,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
return false; return false;
} }
protected function getHubRiderCounts($hub)
{
$em = $this->em;
$hub_id = $hub->getID();
// get in transit rider count aka flag_available is false AND current_jo_id is not null AND rider is active
$in_transit_query = $em->createQuery('SELECT count(r.id) FROM App\Entity\Rider r JOIN r.hub h WHERE h.id = :hub_id AND r.flag_available = false AND r.current_job_order IS NOT NULL AND r.flag_active = true');
$in_transit_query->setParameters(['hub_id' => $hub_id]);
$in_transit_count = $in_transit_query->getSingleScalarResult();
// get available rider count aka flag_available is true AND current_jo_id is null AND rider is active
$available_query = $em->createQuery('SELECT count(r.id) FROM App\Entity\Rider r JOIN r.hub h WHERE h.id = :hub_id AND r.flag_available = true AND r.current_job_order IS NULL AND r.flag_active = true');
$available_query->setParameters(['hub_id' => $hub_id]);
$available_count = $available_query->getSingleScalarResult();
// on duty count = in transit + available
$logged_in_count = $in_transit_count + $available_count;
$rider_count = [
'logged_in' => $logged_in_count,
'in_transit' => $in_transit_count,
'available' => $available_count,
];
return $rider_count;
}
protected function fillDropdownParameters(&$params) protected function fillDropdownParameters(&$params)
{ {
$em = $this->em; $em = $this->em;
@ -3489,15 +3299,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
} }
$params['ownership_types'] = $ownership_types; $params['ownership_types'] = $ownership_types;
// list of customer locations
$cust_locations = $em->getRepository(CustomerLocation::class)->findBy([], ['name' => 'ASC']);
$c_locations = [];
foreach ($cust_locations as $cust_location)
{
$c_locations[$cust_location->getID()] = $cust_location->getName();
}
$params['cust_locations'] = $c_locations;
// list of hubs // list of hubs
$hubs = $em->getRepository(Hub::class)->findBy([], ['name' => 'ASC']); $hubs = $em->getRepository(Hub::class)->findBy([], ['name' => 'ASC']);
$fac_hubs = []; $fac_hubs = [];
@ -3694,49 +3495,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
]; ];
} }
protected function getRiderDataForAssignment($obj)
{
$hub = $obj->getHub();
$rider_data = [];
// get all active riders of hub
$active_riders = $hub->getActiveRiders();
// need to get first name, last name, contact number, plate number, status, image file
// status: Online (rider is logged in app), Offline (rider is not logged in app), In transit
foreach ($active_riders as $rider)
{
// in transit - flag_available = 0 AND current_job_order is not null
// online - flag_available = 1
// offline - flag_available = 0 AND current_job_order is null
$rider_status = '';
if ($rider->isAvailable())
{
$rider_status = 'Online';
}
else
{
if ($rider->getCurrentJobOrder() == null)
$rider_status = 'Offline';
else
$rider_status = 'In transit';
}
$rider_data[$rider->getID()] = [
'first_name' => $rider->getFirstName(),
'last_name' => $rider->getLastName(),
'contact_number' => $rider->getContactNumber(),
'plate_number' => $rider->getPlateNumber(),
'image_file' => $rider->getImageFile(),
'status' => $rider_status,
];
}
return $rider_data;
}
// TODO: re-enable search, figure out how to group the orWhere filters into one, so can execute that plus the pending filter // TODO: re-enable search, figure out how to group the orWhere filters into one, so can execute that plus the pending filter
// check if datatable filter is present and append to query // check if datatable filter is present and append to query
protected function setQueryFilters($datatable, &$query, $qb, $hubs, $tier, $status) protected function setQueryFilters($datatable, &$query, $qb, $hubs, $tier, $status)
@ -4151,54 +3909,4 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$this->rt->sendSMS($phone_number, $this->translator->trans('message.battery_brand_allcaps'), $message); $this->rt->sendSMS($phone_number, $this->translator->trans('message.battery_brand_allcaps'), $message);
} }
protected function sendSMSHubRejection($rejection, $jo)
{
$hub = $rejection->getHub();
// check if JO service type is NOT battery sales
if ($jo->getServiceType() !== ServiceType::BATTERY_REPLACEMENT_NEW)
return null;
// check if hub has a notification number
$notif_number = $hub->getNotifNumber();
if (empty($notif_number))
return null;
$phone_number = $this->country_code . $notif_number;
// check if reason is administrative
if ($rejection->getReason() == JORejectionReason::ADMINISTRATIVE)
return null;
// sms content
// Job Order # - can get from jo
// Order Date and Time - get from jo
// Date and Time Rejected - get from rejection
// Enrollee Name - get from rejection ($hub->getName() . ' - ' . $hub->getBranch())
// Reason of Rejection - get from rejection
// Remarks - get from rejection
// Type of Service - get from jo
$jo_id = $jo->getID();
// convert to string format the date fields (order date and time and date and time rejected)
$order_date_time = $jo->getDateCreate()->format('d M Y g:i A');
$reject_date_time = $rejection->getDateCreate()->format('d M Y g:i A');
$enrollee = $hub->getName() . ' - ' . $hub->getBranch();
$reason = JORejectionReason::getName($rejection->getReason());
$remarks = $rejection->getRemarks();
$service_type = ServiceType::getName($jo->getServiceType());
$msg = 'Job Order #: ' . $jo_id . "\n" . 'Order Date and Time: ' . $order_date_time . "\n" .
'Date and Time Rejected: ' . $reject_date_time . "\n" . 'Enrollee Name: ' . $enrollee . "\n" .
'Reason of Rejection: ' . $reason . "\n" . 'Remarks: ' . $remarks . "\n" .
'Type of Service: ' . $service_type;
// error_log($msg);
$this->rt->sendSMS($phone_number, $this->translator->trans('message.battery_brand_allcaps'), $msg);
}
} }

View file

@ -714,7 +714,7 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface
if (isset($data['error'])) if (isset($data['error']))
return $data; return $data;
$batts = $this->em->getRepository(Battery::class)->findBy(['flag_active' => true]); $batts = $this->em->getRepository(Battery::class)->findAll();
$models = $this->em->getRepository(BatteryModel::class)->findAll(); $models = $this->em->getRepository(BatteryModel::class)->findAll();
$sizes = $this->em->getRepository(BatterySize::class)->findAll(); $sizes = $this->em->getRepository(BatterySize::class)->findAll();

View file

@ -1,36 +0,0 @@
<?php
namespace App\Service;
use App\Ramcar\WarrantyClass;
class WarrantyRaffleFilter
{
public function isValidRaffleEntry($entry)
{
// entry is an associative array
// 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;
}
}

View file

@ -1,41 +0,0 @@
<?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();
}
}

View file

@ -1,53 +0,0 @@
<?php
namespace App\Service;
use Doctrine\ORM\EntityManagerInterface;
use DateTime;
class WarrantySerialLoadLogger
{
protected $em;
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
}
public function logWarrantySerialLoadInfo($log_data)
{
// cache directory
$cache_dir = __DIR__ . '/../../var/cache';
$file = $cache_dir . '/warranty_serial_load_log.tab';
// error_log('opening file for warranty serial load log - ' . $file);
$fp = fopen($file, 'w');
if ($fp === false)
{
error_log('could not open file for load data infile - ' . $file);
}
else
{
foreach ($log_data as $key => $data)
{
$line = implode('|', $data) . "\r\n";
fwrite($fp, $line);
}
}
fclose($fp);
// prepared statement
$db = $this->em->getConnection();
$stmt = $db->prepare('LOAD DATA LOCAL INFILE \''. $file . '\' INTO TABLE warranty_serial_load_log FIELDS TERMINATED BY \'|\' LINES TERMINATED BY \'\\r\\n\' (date_create, api_user, serial, flag_loaded, error)');
$result = $stmt->execute();
if (!$result)
error_log('Failed loading data.');
// TODO: delete file?
}
}

View file

@ -1,47 +0,0 @@
<?php
namespace App\Service;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\WarrantySerialUploadLog;
class WarrantySerialUploadLogger
{
protected $em;
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
}
public function logWarrantySerialUploadInfo($log_data)
{
$log_entry = new WarrantySerialUploadLog();
$user_id = $log_data['user_id'];
$is_uploaded = $log_data['is_uploaded'];
$error = '';
$orig_file_serial = '';
$uploaded_file_serial = '';
if (isset($log_data['error']))
$error = $log_data['error'];
if (isset($log_data['orig_file_serial']))
$orig_file_serial = $log_data['orig_file_serial'];
if (isset($log_data['uploaded_file_serial']))
$uploaded_file_serial = $log_data['uploaded_file_serial'];
$log_entry->setApiUser($user_id)
->setUploaded($is_uploaded)
->setOrigFileSerial($orig_file_serial)
->setUploadedFileSerial($uploaded_file_serial)
->setError($error);
$this->em->persist($log_entry);
$this->em->flush();
}
}

View file

@ -182,16 +182,6 @@
</span> </span>
</a> </a>
</li> </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> </ul>
</li> </li>
<li class="m-menu__item"> <li class="m-menu__item">
@ -267,14 +257,6 @@
Hub Filter Report Hub Filter Report
</span> </span>
</a> </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> </li>
</ul> </ul>
</li> </li>

View file

@ -101,20 +101,6 @@
<div class="form-control-feedback hide" data-field="size"></div> <div class="form-control-feedback hide" data-field="size"></div>
</div> </div>
</div> </div>
<div class="form-group m-form__group row">
<div class="col-lg-4">
<span class="m-switch m-switch--icon block-switch">
<label>
<input type="checkbox" name="flag_active" id="flag_active" value="1"{{ obj.isActive() ? ' checked' }}>
<label class="switch-label">Active</label>
<span></span>
</label>
</span>
<div class="form-control-feedback hide" data-field="flag_active"></div>
</div>
<div class="col-lg-8">
</div>
</div>
<div class="form-group m-form__group row"> <div class="form-group m-form__group row">
<div class="col-lg-6"> <div class="col-lg-6">
<label data-field="image_file"> <label data-field="image_file">

View file

@ -111,21 +111,6 @@
title: 'Brand', title: 'Brand',
width: 120 width: 120
}, },
{
field: 'flag_active',
title: 'Active',
template: function (row, index, datatable) {
var tag = '';
if (row.flag_active === true) {
tag = '<span class="m-badge m-badge--success m-badge--wide">Yes</span>';
} else {
tag = '<span class="m-badge m-badge--danger m-badge--wide">No</span>';
}
return tag;
}
},
/* /*
{ {
field: 'prod_code', field: 'prod_code',

View file

@ -1,142 +0,0 @@
{% 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">Customer Locations</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="la la-industry"></i>
</span>
<h3 class="m-portlet__head-text">
{% if mode == 'update' %}
Edit Ownership Type
<small>{{ cust_location.getName() }}</small>
{% else %}
New Customer Location
{% endif %}
</h3>
</div>
</div>
</div>
<form id="row-form" class="m-form m-form--fit m-form--label-align-right m-form--group-seperator-dashed" method="post" action="{{ mode == 'update' ? url('customer_location_update_submit', {'id': cust_location.getId()}) : url('customer_location_add_submit') }}">
<div class="m-portlet__body">
<div class="form-group m-form__group row no-border">
<label class="col-lg-3 col-form-label" data-field="code">
Code:
</label>
<div class="col-lg-9">
<input type="text" name="code" class="form-control m-input" value="{{ cust_location.getCode() }}">
<div class="form-control-feedback hide" data-field="code"></div>
</div>
</div>
<div class="form-group m-form__group row">
<label class="col-lg-3 col-form-label" data-field="name">
Name:
</label>
<div class="col-lg-9">
<input type="text" name="name" class="form-control m-input" value="{{ cust_location.getName() }}">
<div class="form-control-feedback hide" data-field="name"></div>
</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>
<a href="{{ url('customer_location_list') }}" class="btn btn-secondary">Back</a>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}
{% block scripts %}
<script>
$(function() {
$("#row-form").submit(function(e) {
var form = $(this);
e.preventDefault();
$.ajax({
method: "POST",
url: form.prop('action'),
data: form.serialize()
}).done(function(response) {
// remove all error classes
removeErrors();
swal({
title: 'Done!',
text: 'Your changes have been saved!',
type: 'success',
onClose: function() {
window.location.href = "{{ url('customer_location_list') }}";
}
});
}).fail(function(response) {
if (response.status == 422) {
var errors = response.responseJSON.errors;
var firstfield = false;
// remove all error classes first
removeErrors();
// display errors contextually
$.each(errors, function(field, msg) {
var formfield = $("[name='" + field + "']");
var label = $("label[data-field='" + field + "']");
var msgbox = $(".form-control-feedback[data-field='" + field + "']");
// add error classes to bad fields
formfield.addClass('form-control-danger');
label.addClass('has-danger');
msgbox.html(msg).addClass('has-danger').removeClass('hide');
// check if this field comes first in DOM
var domfield = formfield.get(0);
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
firstfield = domfield;
}
});
// focus on first bad field
firstfield.focus();
// scroll to above that field to make it visible
$('html, body').animate({
scrollTop: $(firstfield).offset().top - 200
}, 100);
}
});
});
// remove all error classes
function removeErrors() {
$(".form-control-danger").removeClass('form-control-danger');
$("[data-field]").removeClass('has-danger');
$(".form-control-feedback[data-field]").addClass('hide');
}
});
</script>
{% endblock %}

View file

@ -1,146 +0,0 @@
{% 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">
Customer Locations
</h3>
</div>
</div>
</div>
<!-- END: Subheader -->
<div class="m-content">
<!--Begin::Section-->
<div class="row">
<div class="col-xl-12">
<div class="m-portlet m-portlet--mobile">
<div class="m-portlet__body">
<div class="m-form m-form--label-align-right m--margin-top-20 m--margin-bottom-30">
<div class="row align-items-center">
<div class="col-xl-8 order-2 order-xl-1">
<div class="form-group m-form__group row align-items-center">
<div class="col-md-4">
<div class="m-input-icon m-input-icon--left">
<input type="text" class="form-control m-input m-input--solid" placeholder="Search..." id="data-rows-search">
<span class="m-input-icon__icon m-input-icon__icon--left">
<span><i class="la la-search"></i></span>
</span>
</div>
</div>
</div>
</div>
<div class="col-xl-4 order-1 order-xl-2 m--align-right">
<a href="{{ url('customer_location_add_form') }}" class="btn btn-focus m-btn m-btn--custom m-btn--icon m-btn--air m-btn--pill">
<span>
<i class="la la-industry"></i>
<span>New Customer Location</span>
</span>
</a>
<div class="m-separator m-separator--dashed d-xl-none"></div>
</div>
</div>
</div>
<!--begin: Datatable -->
<div id="data-rows"></div>
<!--end: Datatable -->
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block scripts %}
<script>
$(function() {
var options = {
data: {
type: 'remote',
source: {
read: {
url: '{{ url("customer_location_rows") }}',
method: 'POST'
}
},
saveState: {
cookie: false,
webstorage: false
},
pageSize: 10,
serverPaging: true,
serverFiltering: true,
serverSorting: true
},
layout: {
scroll: true
},
columns: [
{
field: 'id',
title: 'ID',
width: 30
},
{
field: 'name',
title: 'Name'
},
{
field: 'Actions',
width: 110,
title: 'Actions',
sortable: false,
overflow: 'visible',
template: function (row, index, datatable) {
var actions = '';
if (row.meta.update_url != '') {
actions += '<a href="' + row.meta.update_url + '" class="m-portlet__nav-link btn m-btn m-btn--hover-accent m-btn--icon m-btn--icon-only m-btn--pill btn-edit" data-id="' + row.name + '" title="Edit"><i class="la la-edit"></i></a>';
}
if (row.meta.delete_url != '') {
actions += '<a href="' + row.meta.delete_url + '" class="m-portlet__nav-link btn m-btn m-btn--hover-danger m-btn--icon m-btn--icon-only m-btn--pill btn-delete" data-id="' + row.name + '" title="Delete"><i class="la la-trash"></i></a>';
}
return actions;
},
}
],
search: {
onEnter: false,
input: $('#data-rows-search'),
delay: 400
}
};
var table = $("#data-rows").mDatatable(options);
$(document).on('click', '.btn-delete', function(e) {
var url = $(this).prop('href');
var id = $(this).data('id');
var btn = $(this);
e.preventDefault();
swal({
title: 'Confirmation',
html: 'Are you sure you want to delete <strong>' + id + '</strong>?',
type: 'warning',
showCancelButton: true
}).then((result) => {
if (result.value) {
$.ajax({
method: "DELETE",
url: url
}).done(function(response) {
table.row(btn.parents('tr')).remove();
table.reload();
});
}
});
});
});
</script>
{% endblock %}

View file

@ -560,24 +560,6 @@
Location Location
</h3> </h3>
</div> </div>
<div class="form-group m-form__group row">
<div class="col-lg-6">
<label for="cust_location" data-field="cust_location"> Customer Location </label>
<select class="form-control m-input" id="cust-location" name="cust_location">
<option value=""></option>
{% for id, label in cust_locations %}
{% if obj.getCustomerLocation %}
<option value="{{ id }}"{{ obj.getCustomerLocation.getID == id ? ' selected' }}>{{ label }}</option>
{% else %}
<option value="{{ id }}">{{ label }}</option>
{% endif %}
{% endfor %}
</select>
<div class="form-control-feedback hide" data-field="cust_location"></div>
</div>
<div class="col-lg-6">
</div>
</div>
<div class="form-group m-form__group row"> <div class="form-group m-form__group row">
<div class="col-lg-6"> <div class="col-lg-6">
<label data-field="delivery_address">Delivery Address</label> <label data-field="delivery_address">Delivery Address</label>
@ -772,10 +754,7 @@
<!--<th class="text-right">Distance</th> <!--<th class="text-right">Distance</th>
<th class="text-right">Travel Time</th> <th class="text-right">Travel Time</th>
--> -->
<th class="text-right">Total Rider Count</th> <th class="text-right">Available Riders</th>
<th class="text-right">On Duty</th>
<th class="text-right">In Transit</th>
<th class="text-right">Available</th>
<th class="text-right">Job Order Count</th> <th class="text-right">Job Order Count</th>
<th class="text-right">Jobs For Assignment</th> <th class="text-right">Jobs For Assignment</th>
<th class="text-right">Inventory</th> <th class="text-right">Inventory</th>
@ -785,7 +764,7 @@
</thead> </thead>
<tbody> <tbody>
<tr class="placeholder-row{{ hubs|length > 0 ? ' hide' }}"> <tr class="placeholder-row{{ hubs|length > 0 ? ' hide' }}">
<td colspan="11"> <td colspan="8">
No items to display. No items to display.
</td> </td>
</tr> </tr>
@ -798,9 +777,6 @@
<td class="text-right">{{ hub.duration ? hub.duration : '-' }}</td> <td class="text-right">{{ hub.duration ? hub.duration : '-' }}</td>
--> -->
<td class="text-right">{{ hub.rider_count }}</td> <td class="text-right">{{ hub.rider_count }}</td>
<td class="text-right">{{ hub.rider_logged_in|default('0') }}</td>
<td class="text-right">{{ hub.rider_in_transit|default('0') }}</td>
<td class="text-right">{{ hub.rider_available|default('0') }}</td>
<td class="text-right">{{ hub.redis_jo_count }}</td> <td class="text-right">{{ hub.redis_jo_count }}</td>
<td class="text-right">{{ hub.jo_count }}</td> <td class="text-right">{{ hub.jo_count }}</td>
<td class="text-right">{{ hub.inventory|default('0') }}</td> <td class="text-right">{{ hub.inventory|default('0') }}</td>
@ -906,64 +882,48 @@
</h3> </h3>
</div> </div>
<div class="form-group m-form__group row"> <div class="form-group m-form__group row">
<div class="col-lg-12"> <div class="col-lg-12">
<label>Click on a row to select a rider</label> <label>Click on a row to select a rider</label>
<div class="form-control-feedback hide" data-field="rider"></div> <div class="form-control-feedback hide" data-field="rider"></div>
<div class="table-frame" data-name="rider"> <div class="table-frame" data-name="rider">
<table id="riders-table" class="table table-compact table-hover table-clickable table-vcenter m-table"> <table id="riders-table" class="table table-compact table-hover table-clickable table-vcenter m-table">
<thead> <thead>
<tr> <tr>
<th></th> <th></th>
<th>First Name</th> <th>First Name</th>
<th>Last Name</th> <th>Last Name</th>
<th>Contact No.</th> <th>Contact No.</th>
<th>Plate Number</th> <th>Plate Number</th>
<th>Status</th> <th>Status</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<!-- {% set avail_riders = obj.getHub.getAvailableRiders|default([]) %}
{% set avail_riders = obj.getHub.getAvailableRiders|default([]) %} <tr class="placeholder-row{{ obj.getHub and avail_riders|length > 0 ? ' hide' }}">
<tr class="placeholder-row{{ obj.getHub and avail_riders|length > 0 ? ' hide' }}"> <td colspan="6">
<td colspan="6"> No riders available.
No riders available. </td>
</td> </tr>
</tr>
{% if obj.getHub %} {% if obj.getHub %}
{% for rider in avail_riders %} {% for rider in avail_riders %}
<tr data-id="{{ rider.getID }}"{{ obj.getRider and obj.getRider.getID == rider.getID ? ' class="m-table__row--primary"' }}> <tr data-id="{{ rider.getID }}"{{ obj.getRider and obj.getRider.getID == rider.getID ? ' class="m-table__row--primary"' }}>
<td> <td>
<div class="user-portrait-sm" style="background-image: url('{{ rider.getImageFile ? "/uploads/" ~ rider.getImageFile : "/assets/images/user.gif" }}');"></div> <div class="user-portrait-sm" style="background-image: url('{{ rider.getImageFile ? "/uploads/" ~ rider.getImageFile : "/assets/images/user.gif" }}');"></div>
</td> </td>
<td>{{ rider.getFirstName }}</td> <td>{{ rider.getFirstName }}</td>
<td>{{ rider.getLastName }}</td> <td>{{ rider.getLastName }}</td>
<td>{{ rider.getContactNumber }}</td> <td>{{ rider.getContactNumber }}</td>
<td>{{ rider.getPlateNumber }}</td> <td>{{ rider.getPlateNumber }}</td>
<td></td> <td></td>
</tr> </tr>
{% endfor %} {% endfor %}
{% endif %} {% endif %}
--> </tbody>
{% if obj.getHub %} </table>
{% for key, data in rider_data %} </div>
<tr data-id="{{ key }}" {{ obj.getRider and obj.getRider.getID == key ? ' class="m-table__row--primary"' }}> </div>
<td> </div>
<div class="user-portrait-sm" style="background-image: url('{{ data['image_file'] ? "/uploads/" ~ data['image_file'] : "/assets/images/user.gif" }}');"></div>
</td>
<td> {{ data['first_name'] }} </td>
<td> {{ data['last_name'] }} </td>
<td> {{ data['contact_number'] }} </td>
<td> {{ data['plate_number'] }} </td>
<td> {{ data['status'] }} </td>
</tr>
{% endfor %}
{% endif %}
</tbody>
</table>
</div>
</div>
</div>
</div> </div>
{% endif %} {% endif %}

View file

@ -1,82 +0,0 @@
{% 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 %}

View file

@ -1,83 +0,0 @@
{% 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 %}

View file

@ -233,13 +233,13 @@ $(function() {
var batteryIds = []; var batteryIds = [];
var battMfgModelSize = [] var battMfgModelSize = []
{% for batt in obj.getActiveBatteries %} {% for batt in obj.getBatteries %}
trow = { trow = {
id: "{{ batt.getID }}", id: "{{ batt.getID }}",
manufacturer: "{{ batt.getManufacturer.getName|default('') }} ", manufacturer: "{{ batt.getManufacturer.getName|default('') }} ",
model: "{{ batt.getModel.getName|default('') }}", model: "{{ batt.getModel.getName|default('') }}",
size: "{{ batt.getSize.getName|default('') }}", size: "{{ batt.getSize.getName|default('') }}",
sell_price: "{{ batt.getSellingPrice }}", sell_price: "{{ batt.getSellingPrice }}"
}; };
battRows.push(trow); battRows.push(trow);

View file

@ -182,54 +182,6 @@
<div class="form-control-feedback hide" data-field="status"></div> <div class="form-control-feedback hide" data-field="status"></div>
</div> </div>
</div> </div>
<div class="form-group m-form__group row">
<div class="col-lg-4">
<label data-field="sales_invoice_number">
Sales Invoice Number
</label>
<input type="text" name="sales_invoice_number" class="form-control m-input" value="{{ obj.getSalesInvoiceNumber }}" data-name="sales_invoice_number">
<div class="form-control-feedback hide" data-field="sales_invoice_number"></div>
</div>
<div class="col-lg-4">
<label data-field="outlet_name">
Outlet Name
</label>
<input type="text" name="outlet_name" class="form-control m-input" value="{{ obj.getOutletName }}" data-name="outlet_name">
<div class="form-control-feedback hide" data-field="outlet_name"></div>
</div>
<div class="col-lg-4">
<label data-field="outlet_contact_number">
Outlet Contact Number
</label>
<input type="text" name="outlet_contact_number" class="form-control m-input" value="{{ obj.getOutletContactNumber }}" data-name="outlet_contact_number">
<div class="form-control-feedback hide" data-field="outlet_contact_number"></div>
</div>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-12">
<label data-field="outlet_address">
Outlet Address
</label>
<textarea name="outlet_address" class="form-control m-input" data-name="outlet_address" rows="3">{{ obj.getOutletAddress }}</textarea>
<div class="form-control-feedback hide" data-field="outlet_address"></div>
</div>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-6">
<label data-field="sender_name">
Sender Name
</label>
<input type="text" name="sender_name" class="form-control m-input" value="{{ obj.getSenderName }}" data-name="sender_name">
<div class="form-control-feedback hide" data-field="sender_name"></div>
</div>
<div class="col-lg-6">
<label data-field="sender_contact_number">
Sender Contact Number
</label>
<input type="text" name="sender_contact_number" class="form-control m-input" value="{{ obj.getSenderContactNumber }}" data-name="sender_contact_number">
<div class="form-control-feedback hide" data-field="sender_contact_number"></div>
</div>
</div>
</div> </div>
</div> </div>
<div class="m-portlet__foot m-portlet__foot--fit"> <div class="m-portlet__foot m-portlet__foot--fit">

View file

@ -1,53 +0,0 @@
-- MySQL dump 10.19 Distrib 10.3.36-MariaDB, for Linux (x86_64)
--
-- Host: localhost Database: resq
-- ------------------------------------------------------
-- Server version 10.3.36-MariaDB
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `customer_location`
--
DROP TABLE IF EXISTS `customer_location`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `customer_location` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`code` varchar(25) COLLATE utf8_unicode_ci NOT NULL,
`name` varchar(25) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
KEY `cust_location_idx` (`code`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `customer_location`
--
LOCK TABLES `customer_location` WRITE;
/*!40000 ALTER TABLE `customer_location` DISABLE KEYS */;
INSERT INTO `customer_location` VALUES (1,'residence','Residence'),(2,'office','Office'),(3,'on_the_road','On the Road'),(4,'commercial','Commercial');
/*!40000 ALTER TABLE `customer_location` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2023-02-23 8:03:35

View file

@ -11,7 +11,7 @@ use MicrosoftAzure\Storage\Common\ServiceException;
// $blob_url = 'https://popappshopprodstorage.blob.core.windows.net'; // $blob_url = 'https://popappshopprodstorage.blob.core.windows.net';
$blob_url = 'https://motivstorageaccount.blob.core.windows.net'; $blob_url = 'https://motivstorageaccount.blob.core.windows.net';
$sas_token = 'sp=r&st=2022-08-30T03:39:37Z&se=2030-09-30T11:39:37Z&sv=2021-06-08&sr=c&sig=9eETL%2F%2B2mbOPtW%2Fa4dZBnC8s61NwJpPZu6tsJS7frmk%3D'; $sas_token = 'sp=r&st=2022-06-16T04:09:13Z&se=2030-06-16T12:09:13Z&spr=https&sv=2021-06-08&sr=c&sig=x26qUFEMIqg4JgTCVHoDv%2FtTqCprjogEqtOsTpBjkWA%3D';
$conn_string = "BlobEndpoint=$blob_url;\nSharedAccessSignature=$sas_token"; $conn_string = "BlobEndpoint=$blob_url;\nSharedAccessSignature=$sas_token";

View file

@ -1,10 +0,0 @@
#!/bin/bash
# get the number fo warranty serial files to process
declare -i num_files
num_files=`/var/www/resq/bin/console warrantyserial:count`
for (( i = 1; i <= num_files; i++ ))
do
/usr/bin/php /var/www/resq/bin/console warrantyserial:load
done