Merge branch '168-legacy-jo-migration' into 'master'
Resolve "Legacy JO Migration" Closes #168 See merge request jankstudio/resq!203
This commit is contained in:
commit
28fdba3872
12 changed files with 1798 additions and 6 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -6,6 +6,7 @@
|
|||
/vendor/
|
||||
/sql/
|
||||
/pem/
|
||||
/migration/
|
||||
###< symfony/framework-bundle ###
|
||||
|
||||
*.swp
|
||||
|
|
|
|||
966
src/Command/ImportLegacyJobOrderCommand.php
Normal file
966
src/Command/ImportLegacyJobOrderCommand.php
Normal file
|
|
@ -0,0 +1,966 @@
|
|||
<?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\Common\Persistence\ObjectManager;
|
||||
|
||||
use App\Entity\Warranty;
|
||||
use App\Entity\BatterySize;
|
||||
use App\Entity\BatteryModel;
|
||||
use App\Entity\VehicleManufacturer;
|
||||
use App\Entity\Vehicle;
|
||||
use App\Entity\PlateNumber;
|
||||
|
||||
use App\Ramcar\LegacyBattery;
|
||||
use App\Ramcar\LegacyVehicleManufacturer;
|
||||
use App\Ramcar\LegacyTransactionType;
|
||||
use App\Ramcar\LegacyVehicle;
|
||||
use App\Ramcar\LegacyOrigin;
|
||||
|
||||
use App\Ramcar\WarrantyClass;
|
||||
use App\Ramcar\WarrantyStatus;
|
||||
|
||||
use DateTime;
|
||||
|
||||
|
||||
class ImportLegacyJobOrderCommand extends Command
|
||||
{
|
||||
protected $em;
|
||||
protected $bmodel_hash;
|
||||
protected $bsize_hash;
|
||||
protected $vmfg_hash;
|
||||
protected $vehicle_hash;
|
||||
protected $jo_hash;
|
||||
|
||||
protected $row_fields;
|
||||
protected $data_fields;
|
||||
protected $row_max_field_size;
|
||||
protected $data_max_field_size;
|
||||
|
||||
public function __construct(ObjectManager $om)
|
||||
{
|
||||
$this->em = $om;
|
||||
|
||||
$this->loadBatteryModels();
|
||||
$this->loadBatterySizes();
|
||||
$this->loadVehicleManufacturers();
|
||||
$this->loadVehicles();
|
||||
|
||||
$this->jo_hash = [];
|
||||
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('legacy:import_jo')
|
||||
->setDescription('Import a CSV file with legacy job orders.')
|
||||
->setHelp('Updates job order, plate number and warranty database from imported CSV entries.')
|
||||
->addArgument('file', InputArgument::REQUIRED, 'Path to the CSV file.');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$csv_file = $input->getArgument('file');
|
||||
$output->writeln("parsing $csv_file...\n");
|
||||
|
||||
/*
|
||||
CSV column order:
|
||||
0 - Internal ID
|
||||
1 - Type
|
||||
2 - Transaction Number
|
||||
3 - Primary Information : Date of Transaction
|
||||
4 - Primary Information : Job Order Number
|
||||
5 - Primary Information : MEH : Transaction Type
|
||||
6 - Primary Information : Reference JO Number
|
||||
7 - Primary Information : Type of Service
|
||||
8 - Primary Information : Warranty Status
|
||||
9 - Primary Information : Transaction Origin
|
||||
10 - Primary Information : Existing Battery
|
||||
11 - Primary Information : Existing Battery Type
|
||||
12 - Primary Information : Recommended Battery
|
||||
13 - Primary Infromation : Alternative Battery
|
||||
14 - Primary Information : Vehicle Plate Number
|
||||
15 - Primary Information : Brand
|
||||
16 - Primary Information : Make
|
||||
17 - Primary Information : Model
|
||||
18 - Primary Information : Vehicle Color
|
||||
19 - Primary Information : Caller Name
|
||||
20 - First Name
|
||||
21 - Middle Name
|
||||
22 - Last Name
|
||||
23 - Primary Information : Caller Contact
|
||||
24 - Primary Information : Caller Mobile No.
|
||||
25 - Primary Information : Caller Landline No.
|
||||
26 - Primary Information : Invoice / Company Name
|
||||
27 - Primary Information : New Name?
|
||||
28 - Primary Information : New Invoice / Company Name
|
||||
29 - Primary Information : Delivery Instructions
|
||||
30 - Primary Information : Agent Notes - Tier 1
|
||||
31 - Primary Information : Delivery Date
|
||||
32 - Primary Information : Delivery Time
|
||||
33 - Primary Information : Advance Order
|
||||
34 - Primary Information : Stages
|
||||
35 - Primary Information : Reason for Cancellation
|
||||
36 - Primary Information : Specify the Reason for Cancellation
|
||||
37 - Primary Information : Payment Method
|
||||
38 - Primary Information : Change for:
|
||||
39 - Primary Information : Prepared by
|
||||
40 - Current Battery Details : Serial No.:
|
||||
41 - Current Battery Details : DR No.:
|
||||
42 - Current Battery Details : Date of Replacement
|
||||
43 - Current Battery Details : Battery Brand
|
||||
44 - Current Battery Details : Type
|
||||
45 - Current Battery Details : Issued By:
|
||||
46 - Current Battery Details : Issued By Direct
|
||||
47 - Original Battery Details : Serial No.
|
||||
48 - Original Battery Details : OR No.:
|
||||
49 - Original Battery Details : Date of Purchase
|
||||
50 - Original Battery Details : Battery Brand:
|
||||
51 - Original Battery Details : Battery Type:
|
||||
52 - Original Battery Details : Purchased From:
|
||||
53 - Original Battery Details : Purchase from Direct
|
||||
54 - Original Battery Details : Current Warranty Expiration Date
|
||||
55 - Original Battery Details : Trade-In Battery
|
||||
56 - Dispatching : Agent Notes : Tier 2
|
||||
57 - Dispatching : Notes (Customer Classification)
|
||||
58 - Dispatching : Pending
|
||||
59 - Dispatching : Pending - Awaiting Stocks
|
||||
60 - Dispatching : Date started from Awaiting Stock
|
||||
61 - Dispatching : 4TH Due
|
||||
62 - Dispatching : 8TH Due
|
||||
63 - Dispatching : 12TH Due
|
||||
64 - Dispatching : 14TH Due
|
||||
65 - Dispatching : Currently Assigned Enrollee
|
||||
66 - Dispatching : Non-HUB?
|
||||
67 - Dispatching : HUB Catered?
|
||||
68 - Dispatching : Thru Annex?
|
||||
69 - Dispatching : HUB List
|
||||
70 - Dispatching : Annex List
|
||||
71 - Dispatching : Exempted to 6%
|
||||
72 - Dispatching : Rider Name List
|
||||
73 - Dispatching : Rider Name
|
||||
74 - Dispatching : Rider Contact Information
|
||||
75 - DIspatching : Dispatch Time
|
||||
76 - Dispatching : Dispatch Date
|
||||
77 - Dispatching : Dispatched By
|
||||
78 - Dispatching : Time of Arrival
|
||||
79 - Dispatching : Time Job Completed
|
||||
80 - Dispatching : For Line Up?
|
||||
81 - DIspatching : Order
|
||||
82 - Vehicle Location : Address
|
||||
83 - Vehicle Location : Landmark
|
||||
84 - Customer Service Record : Purchase Date
|
||||
85 - Customer Service Record : Battery / Item
|
||||
86 - Customer Service Record : Battery / Item Warranty in Months
|
||||
87 - Customer Service Record : Warranty Inquiry (Expiration Date)
|
||||
88 - JO : Amount
|
||||
89 - JO : TAX
|
||||
90 - JO : Discount
|
||||
91 - JO : Final Amount
|
||||
92 - Line Details : Item
|
||||
93 - Line Details : Quantity
|
||||
94 - Line Details : Item Rate
|
||||
95 - Line Details : Price Level
|
||||
96 - Line Details : Item Base Price
|
||||
97 - Line Details : Price Level Amount Deductions
|
||||
98 - Line Details : Final Amount
|
||||
99 - Line Details : No Trade-In
|
||||
100 - Line Details : Reason for No Trade-In
|
||||
101 - Line Details : Battery Class
|
||||
102 - Line Details : Discount Items
|
||||
103 - Line Details : Discount Code
|
||||
104 - Line Details : Percentage
|
||||
105 - Line Details : Converted Rate
|
||||
106 - Line Details : Discount Amount
|
||||
107 - Line Details : Warranty Classification
|
||||
108 - Line Details : Warranty in Months
|
||||
109 - Line Details : Warranty Expiration Date
|
||||
110 - Line Details : Serial Number
|
||||
111 - Line Details : Invoice/DR Number
|
||||
112 - Line Details : Repalcement
|
||||
113 - Line Details : Employee / Card No. / Referred by
|
||||
114 - Line Details : Amount
|
||||
115 - Line Details : Gross Amount
|
||||
116 - Line Details : Gross Amount
|
||||
117 - Time Stamp : Date / Time (JO Open)
|
||||
118 - Time Stamp : Date / Time JO Saved
|
||||
119 - Time Stamp : Ticket Handle TIme (in mins)
|
||||
120 - Time Stamp : Idle Time
|
||||
121 - Time Stamp : Date and Time (Dispatched By)
|
||||
122 - Time Stamp : In-Transit Date and Time
|
||||
123 - TIme Stamp : Completion Date and TIme
|
||||
124 - TIme Stamp : Dispatch By to In-Transit Time (Time difference in Mins)
|
||||
125 - Time Stamp : In-Transit to Completed (Time difference in Mins)
|
||||
126 - Time Stamp : Raw Ticket Handle TIme (Decimal)
|
||||
127 - Time Stamp : Raw Idle Time (Decimal)
|
||||
128 - Account
|
||||
129 - Status
|
||||
130 - Tracking Numbers
|
||||
131 - Memo
|
||||
132 - Posting
|
||||
133 - Notes
|
||||
134 - Originally Assigned Enrollee
|
||||
135 - Remarks
|
||||
136 - Follow Up Transactions
|
||||
137 - CARD TYPE
|
||||
138 - CARD NO.
|
||||
139 - Ongoing Editing
|
||||
140 - Current User
|
||||
141 - Cancellation Date
|
||||
142 - Cancellation Time
|
||||
143 - Ticket Completion Date
|
||||
144 - Ticket Completion Time
|
||||
145 - Date Created
|
||||
146 - Time Created
|
||||
147 - PREVIOUS STAGE
|
||||
148 - DISPATCHED BY EDITED?
|
||||
149 - Previous Dispatched By
|
||||
150 - POST SERVICE
|
||||
151 - Pending (2)
|
||||
152 - COMPLETED MANUALLY
|
||||
153 - THRU HUB NOTE
|
||||
154 - CURRENTLY ASSIGNED ENROLLEE (free-form)
|
||||
155 - IN-TRANSIT ALLOWANCE
|
||||
156 - COPY FROM JO #
|
||||
157 - NO. OF POSSIBLE DUPLICATE
|
||||
158 - Call Status
|
||||
159 - DISTRIBUTOR OUTLETS
|
||||
160 - CURRENTLY ASSIGNED ENROLLEE (free-form)
|
||||
161 - HUB LIST
|
||||
162 - HUB LIST 2
|
||||
163 - Enrollee
|
||||
164 - Currently Assigned Enrollee
|
||||
165 - Payment:
|
||||
*/
|
||||
|
||||
// attempt to open file
|
||||
try
|
||||
{
|
||||
$fh = fopen($csv_file, "r");
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception('The file "' . $csv_file . '" could be read.');
|
||||
}
|
||||
|
||||
// get entity manager
|
||||
$em = $this->em;
|
||||
|
||||
$trans_types = [];
|
||||
$service_types = [];
|
||||
$no_sizes = [];
|
||||
|
||||
// files
|
||||
$plate_outfile = fopen('/tmp/plate_numbers.csv', 'a');
|
||||
$warr_outfile = fopen('/tmp/warranty.csv', 'a');
|
||||
$jo_outfile = fopen('/tmp/legacy_jo.csv', 'a');
|
||||
$jorow_outfile = fopen('/tmp/legacy_jo_row.csv', 'a');
|
||||
|
||||
$this->initializeMaxFieldCounters();
|
||||
|
||||
// loop through rows
|
||||
$save_plates = [];
|
||||
$row_num = 0;
|
||||
while (($fields = fgetcsv($fh)) !== false)
|
||||
{
|
||||
$row_num++;
|
||||
// $output->writeln("Parsing row " . $row_num . "...");
|
||||
|
||||
// ignore first 5 rows
|
||||
if ($row_num <= 5)
|
||||
continue;
|
||||
|
||||
// check column count
|
||||
if (count($fields) != 166)
|
||||
{
|
||||
echo "*** wrong field count on row $row_num\n";
|
||||
print_r($fields);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->processLegacyTransaction($fields);
|
||||
|
||||
// skip taxes
|
||||
if ($fields[14] == 'Bureau of Internal Revenue')
|
||||
{
|
||||
// $output->writeln('Skipping BIR line');
|
||||
continue;
|
||||
}
|
||||
|
||||
// clean plate numbers
|
||||
$id = $fields[0];
|
||||
$plate_num = Warranty::cleanPlateNumber($fields[14]);
|
||||
if (!$plate_num)
|
||||
{
|
||||
// $output->writeln('Invalid plate number - ' . $fields[14]);
|
||||
$this->jo_hash[$id]['data']['plate_number'] = null;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
$this->jo_hash[$id]['data']['plate_number'] = $plate_num;
|
||||
|
||||
|
||||
// let's track purchases first
|
||||
if ($fields[5] != 'PURCHASE')
|
||||
continue;
|
||||
|
||||
// check if battery is found
|
||||
$found_battery = $this->findBattery($fields[92], $batt_model, $batt_size);
|
||||
if (!$found_battery)
|
||||
{
|
||||
// $output->writeln('battery not found - ' . $fields[92]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// find matching vehicle
|
||||
$found_vehicle = $this->findVehicle($fields[15], $fields[16], $fields[17], $vehicle);
|
||||
if (!$found_vehicle)
|
||||
{
|
||||
// $output->writeln('vehicle not found - ' . $fields[15] . ' - ' . $fields[16]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// consolidate transaction and service types
|
||||
$trans_types[$fields[5]] = 1;
|
||||
$service_types[$fields[7]] = $fields[5];
|
||||
|
||||
fwrite($plate_outfile, $plate_num . ',' . $vehicle['id'] . "\n");
|
||||
|
||||
if (isset($fields[107]))
|
||||
{
|
||||
// echo 'warranty class - ' . $fields[107] . "\n";
|
||||
|
||||
|
||||
$warr_class = WarrantyClass::convertFromLegacy($fields[107]);
|
||||
if ($warr_class)
|
||||
{
|
||||
$batt_model_id = $batt_model;
|
||||
$batt_size_id = $batt_size;
|
||||
|
||||
// model and size
|
||||
$line = $batt_model_id . ',' . $batt_size_id . ',';
|
||||
|
||||
// echo 'wclass - ' . $warr_class . "\n";
|
||||
// echo 'serial - ' . $fields[110] . "\n";
|
||||
// echo 'expiry - ' . $fields[109] . "\n";
|
||||
|
||||
// serial
|
||||
if (isset($fields[110]) && strlen(trim($fields[110])) > 0)
|
||||
$line .= $fields[110] . ',';
|
||||
else
|
||||
$line .= '\N,';
|
||||
|
||||
// warranty class
|
||||
$line .= $warr_class . ',';
|
||||
|
||||
// plate number
|
||||
$line .= $plate_num . ',';
|
||||
|
||||
$date_today = new DateTime();
|
||||
|
||||
// status
|
||||
// check if expired
|
||||
if (isset($fields[109]) && strlen(trim($fields[109])) > 0)
|
||||
{
|
||||
$ex_date = DateTime::createFromFormat('m/d/Y', $fields[109]);
|
||||
$ex_tstamp = $ex_date->getTimestamp();
|
||||
$today_tstamp = $date_today->getTimestamp();
|
||||
if ($today_tstamp > $ex_tstamp)
|
||||
$status = WarrantyStatus::EXPIRED;
|
||||
else
|
||||
$status = WarrantyStatus::ACTIVE;
|
||||
}
|
||||
$line .= $status . ',';
|
||||
|
||||
// date create
|
||||
$line .= $date_today->format('Ymd') . ',';
|
||||
|
||||
// date purchase
|
||||
if (isset($fields[84]) && strlen(trim($fields[84])) > 0)
|
||||
{
|
||||
$pur_date = DateTime::createFromFormat('m/d/Y', $fields[84]);
|
||||
$line .= $pur_date->format('Ymd') . ',';
|
||||
}
|
||||
else
|
||||
$line .= '\N,';
|
||||
|
||||
|
||||
// date expire
|
||||
if (isset($fields[109]) && strlen(trim($fields[109])) > 0)
|
||||
$line .= $ex_date->format('Ymd') . ',';
|
||||
else
|
||||
$line .= '\N,';
|
||||
|
||||
// date claim
|
||||
$line .= '\N';
|
||||
|
||||
fwrite($warr_outfile, $line . "\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
// check if we marked it already
|
||||
if (isset($save_plates[$plate_num]))
|
||||
continue;
|
||||
|
||||
// check if already there
|
||||
$find_plate = $em->getRepository(PlateNumber::class)->find($plate_num);
|
||||
if ($find_plate)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// save to db
|
||||
$o_plate = new PlateNumber();
|
||||
$o_plate->setID($plate_num)
|
||||
->setVehicle($vehicle['object']);
|
||||
|
||||
$em->persist($o_plate);
|
||||
|
||||
$save_plates[$plate_num] = true;
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
// plate
|
||||
echo '14 - ' . $fields[14] . "\n";
|
||||
|
||||
// transaction
|
||||
echo '5 - ' . $fields[5] . "\n";
|
||||
echo '7 - ' . $fields[7] . "\n";
|
||||
|
||||
// name
|
||||
echo '22 - ' . $fields[22] . "\n";
|
||||
echo '20 - ' . $fields[20] . "\n";
|
||||
echo '21 - ' . $fields[21] . "\n";
|
||||
|
||||
// number
|
||||
echo '23 - ' . $fields[23] . "\n";
|
||||
echo '24 - ' . $fields[24] . "\n";
|
||||
echo '25 - ' . $fields[25] . "\n";
|
||||
|
||||
// vehicle
|
||||
echo '15 - ' . $fields[15] . "\n";
|
||||
echo '16 - ' . $fields[16] . "\n";
|
||||
echo '17 - ' . $fields[17] . "\n";
|
||||
echo '18 - ' . $fields[18] . "\n";
|
||||
|
||||
|
||||
// battery
|
||||
echo '10 - ' . $fields[10] . "\n";
|
||||
echo '11 - ' . $fields[11] . "\n";
|
||||
echo '50 - ' . $fields[50] . "\n";
|
||||
echo '51 - ' . $fields[51] . "\n";
|
||||
echo '40 - ' . $fields[40] . "\n";
|
||||
echo '43 - ' . $fields[43] . "\n";
|
||||
echo '44 - ' . $fields[44] . "\n";
|
||||
echo '47 - ' . $fields[47] . "\n";
|
||||
echo '54 - ' . $fields[54] . "\n";
|
||||
|
||||
// customer service record
|
||||
echo '84 - ' . $fields[84] . "\n";
|
||||
echo '85 - ' . $fields[85] . "\n";
|
||||
echo '86 - ' . $fields[86] . "\n";
|
||||
echo '87 - ' . $fields[87] . "\n";
|
||||
*/
|
||||
// echo '92 - ' . $fields[92] . "\n";
|
||||
|
||||
/*
|
||||
echo '110 - ' . $fields[110] . "\n";
|
||||
*/
|
||||
}
|
||||
|
||||
// print_r($this->jo_hash);
|
||||
|
||||
// $em->flush();
|
||||
|
||||
// print_r($trans_types);
|
||||
// print_r($service_types);
|
||||
// print_r($no_sizes);
|
||||
// print_r($b_models);
|
||||
// print_r($batteries);
|
||||
|
||||
// save to db
|
||||
// print_r($batteries);
|
||||
// print_r($this->vehicle_hash);
|
||||
// print_r($no_makes);
|
||||
|
||||
/*
|
||||
print_r($this->data_max_field_size);
|
||||
print_r($this->row_max_field_size);
|
||||
*/
|
||||
|
||||
// save job order
|
||||
foreach ($this->jo_hash as $jo)
|
||||
{
|
||||
$id = $jo['data']['id'];
|
||||
|
||||
$line = $this->exportJOData($jo['data']);
|
||||
fwrite($jo_outfile, $line . "\n");
|
||||
|
||||
foreach ($jo['rows'] as $jo_row)
|
||||
fputcsv($jorow_outfile, $jo_row);
|
||||
}
|
||||
|
||||
|
||||
fclose($plate_outfile);
|
||||
fclose($warr_outfile);
|
||||
fclose($jo_outfile);
|
||||
fclose($jorow_outfile);
|
||||
}
|
||||
|
||||
protected function initializeMaxFieldCounters()
|
||||
{
|
||||
$this->data_fields = [
|
||||
'trans_type',
|
||||
'origin',
|
||||
|
||||
'car_brand',
|
||||
'car_make',
|
||||
'car_model',
|
||||
'car_color',
|
||||
|
||||
'cust_name',
|
||||
'cust_first_name',
|
||||
'cust_middle_name',
|
||||
'cust_last_name',
|
||||
'cust_contact',
|
||||
'cust_mobile',
|
||||
'cust_landline',
|
||||
|
||||
'delivery_instructions',
|
||||
'agent_notes_1',
|
||||
'delivery_date',
|
||||
'delivery_time',
|
||||
'advance_order',
|
||||
'stage',
|
||||
'cancel_reason',
|
||||
'cancel_reason_specify',
|
||||
'payment_method',
|
||||
|
||||
'prepared_by',
|
||||
|
||||
'dispatch_time',
|
||||
'dispatch_date',
|
||||
'dispatched_by',
|
||||
|
||||
'address',
|
||||
'landmark',
|
||||
'date_purchase',
|
||||
];
|
||||
|
||||
$this->row_fields = [
|
||||
'item',
|
||||
'qty',
|
||||
'price',
|
||||
'price_level',
|
||||
'status',
|
||||
'account',
|
||||
'enrollee',
|
||||
];
|
||||
|
||||
// initialize max field size counter
|
||||
$this->data_max_field_size = [
|
||||
'trans_type' => 0,
|
||||
'origin' => 0,
|
||||
|
||||
'car_brand' => 0,
|
||||
'car_make' => 0,
|
||||
'car_model' => 0,
|
||||
'car_color' => 0,
|
||||
|
||||
'cust_name' => 0,
|
||||
'cust_first_name' => 0,
|
||||
'cust_middle_name' => 0,
|
||||
'cust_last_name' => 0,
|
||||
'cust_contact' => 0,
|
||||
'cust_mobile' => 0,
|
||||
'cust_landline' => 0,
|
||||
|
||||
'delivery_instructions' => 0,
|
||||
'agent_notes_1' => 0,
|
||||
'delivery_date' => 0,
|
||||
'delivery_time' => 0,
|
||||
'advance_order' => 0,
|
||||
'stage' => 0,
|
||||
'cancel_reason' => 0,
|
||||
'cancel_reason_specify' => 0,
|
||||
'payment_method' => 0,
|
||||
|
||||
'prepared_by' => 0,
|
||||
|
||||
'dispatch_time' => 0,
|
||||
'dispatch_date' => 0,
|
||||
'dispatched_by' => 0,
|
||||
|
||||
'address' => 0,
|
||||
'landmark' => 0,
|
||||
'date_purchase' => 0,
|
||||
];
|
||||
|
||||
$this->row_max_field_size = [
|
||||
'item' => 0,
|
||||
'qty' => 0,
|
||||
'price' => 0,
|
||||
'price_level' => 0,
|
||||
'status' => 0,
|
||||
'account' => 0,
|
||||
'enrollee' => 0,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
protected function processLegacyTransaction($fields)
|
||||
{
|
||||
// echo "trans type - " . $fields[5] . "\n";
|
||||
// echo "origin - " . $fields[9] . "\n";
|
||||
// echo "stage - " . $fields[34] . "\n";
|
||||
// echo "payment method - " . $fields[37] . "\n";
|
||||
// echo "price level - " . $fields[95] . "\n";
|
||||
|
||||
$id = $fields[0];
|
||||
|
||||
$trans_type = LegacyTransactionType::translate($fields[5]);
|
||||
$origin = LegacyOrigin::translate($fields[9]);
|
||||
|
||||
// consolidate based on jo id
|
||||
if (!isset($this->jo_hash[$id]))
|
||||
{
|
||||
$this->jo_hash[$id] = [
|
||||
// 'raw' => [],
|
||||
'data' => [],
|
||||
'rows' => [],
|
||||
];
|
||||
|
||||
$date_trans = DateTime::createFromFormat('m/d/Y', $fields[3]);
|
||||
|
||||
// labelled data
|
||||
$this->jo_hash[$id]['data'] = [
|
||||
'id' => $id,
|
||||
'date_trans' => $date_trans->format('Ymd'),
|
||||
'trans_type' => $trans_type,
|
||||
'origin' => $fields[9],
|
||||
|
||||
'car_brand' => $fields[15],
|
||||
'car_make' => $fields[16],
|
||||
'car_model' => $fields[17],
|
||||
'car_color' => $fields[18],
|
||||
|
||||
'cust_name' => $fields[19],
|
||||
'cust_first_name' => $fields[20],
|
||||
'cust_middle_name' => $fields[21],
|
||||
'cust_last_name' => $fields[22],
|
||||
'cust_contact' => $fields[23],
|
||||
'cust_mobile' => $fields[24],
|
||||
'cust_landline' => $fields[25],
|
||||
|
||||
'delivery_instructions' => $fields[29],
|
||||
'agent_notes_1' => $fields[30],
|
||||
'delivery_date' => $fields[31],
|
||||
'delivery_time' => $fields[32],
|
||||
'advance_order' => $fields[33],
|
||||
'stage' => $fields[34],
|
||||
'cancel_reason' => $fields[35],
|
||||
'cancel_reason_specify' => $fields[36],
|
||||
'payment_method' => $fields[37],
|
||||
|
||||
'prepared_by' => $fields[39],
|
||||
|
||||
'dispatch_time' => $fields[75],
|
||||
'dispatch_date' => $fields[76],
|
||||
'dispatched_by' => $fields[77],
|
||||
|
||||
'address' => $fields[82],
|
||||
'landmark' => $fields[83],
|
||||
'date_purchase' => $fields[84],
|
||||
];
|
||||
|
||||
|
||||
// max field size
|
||||
foreach ($this->data_fields as $data_field)
|
||||
{
|
||||
$len = strlen($this->jo_hash[$id]['data'][$data_field]);
|
||||
// echo "$data_field - $len vs " . $this->data_max_field_size[$data_field] . "\n";
|
||||
|
||||
if ($len > $this->data_max_field_size[$data_field])
|
||||
$this->data_max_field_size[$data_field] = $len;
|
||||
}
|
||||
/*
|
||||
// raw
|
||||
for ($x = 0; $x < 88; $x++)
|
||||
$this->jo_hash[$id]['raw'][$x] = $fields[$x];
|
||||
*/
|
||||
}
|
||||
|
||||
$row = [];
|
||||
/*
|
||||
for ($x = 88; $x <= 165; $x++)
|
||||
$row[$x - 88] = $fields[$x];
|
||||
*/
|
||||
$row = [
|
||||
'id' => $id,
|
||||
'item' => $fields[92],
|
||||
'qty' => $fields[93],
|
||||
'price' => $fields[114],
|
||||
'price_level' => $fields[95],
|
||||
'status' => $fields[129],
|
||||
'account' => $fields[128],
|
||||
'enrollee' => $fields[134],
|
||||
];
|
||||
$this->jo_hash[$id]['rows'][] = $row;
|
||||
|
||||
// max row field size
|
||||
foreach ($this->row_fields as $row_field)
|
||||
{
|
||||
$len = strlen($row[$row_field]);
|
||||
if ($len > $this->row_max_field_size[$row_field])
|
||||
$this->row_max_field_size[$row_field] = $len;
|
||||
}
|
||||
}
|
||||
|
||||
protected function exportJOData($data)
|
||||
{
|
||||
$line_data = [];
|
||||
|
||||
foreach ($data as $field => $value)
|
||||
{
|
||||
$enc_value = str_replace('\\', '\\\\', $value);
|
||||
$line_data[] = str_replace('|', '\\|', $enc_value);
|
||||
}
|
||||
|
||||
return implode('|', $line_data);
|
||||
}
|
||||
|
||||
protected function loadBatteryModels()
|
||||
{
|
||||
$this->bmodel_hash = [];
|
||||
|
||||
$models = $this->em->getRepository(BatteryModel::class)->findAll();
|
||||
foreach ($models as $model)
|
||||
{
|
||||
// clean name
|
||||
// $name = strtoupper(trim(str_replace(' ', '', $model->getName())));
|
||||
$name = $this->simplifyName($model->getName());
|
||||
|
||||
$this->bmodel_hash[$name] = $model->getID();
|
||||
}
|
||||
}
|
||||
|
||||
protected function loadBatterySizes()
|
||||
{
|
||||
$this->bsize_hash = [];
|
||||
|
||||
$sizes = $this->em->getRepository(BatterySize::class)->findAll();
|
||||
foreach ($sizes as $size)
|
||||
{
|
||||
// clean name
|
||||
// $name = strtoupper(trim(str_replace(' ', '', $size->getName())));
|
||||
$name = $this->simplifyName($size->getName());
|
||||
|
||||
$this->bsize_hash[$name] = $size->getID();
|
||||
}
|
||||
}
|
||||
|
||||
protected function loadVehicleManufacturers()
|
||||
{
|
||||
$this->vmfg_hash = [];
|
||||
|
||||
$mfgs = $this->em->getRepository(VehicleManufacturer::class)->findAll();
|
||||
foreach ($mfgs as $mfg)
|
||||
{
|
||||
$name = $this->simplifyName($mfg->getName(), false);
|
||||
|
||||
$this->vmfg_hash[$name] = $mfg->getID();
|
||||
}
|
||||
}
|
||||
|
||||
protected function loadVehicles()
|
||||
{
|
||||
$this->vehicle_hash = [];
|
||||
|
||||
$vs = $this->em->getRepository(Vehicle::class)->findAll();
|
||||
foreach ($vs as $v)
|
||||
{
|
||||
$make = $this->simplifyName($v->getMake(), false);
|
||||
|
||||
$mfg_id = $v->getManufacturer()->getID();
|
||||
if (!isset($this->vehicle_hash[$mfg_id]))
|
||||
$this->vehicle_hash[$mfg_id] = [];
|
||||
|
||||
if (!isset($this->vehicle_hash[$mfg_id][$make]))
|
||||
$this->vehicle_hash[$mfg_id][$make] = [];
|
||||
|
||||
$this->vehicle_hash[$mfg_id][$make][] = [
|
||||
'id' => $v->getID(),
|
||||
'year_from' => $v->getModelYearFrom(),
|
||||
'year_to' => $v->getModelYearTo(),
|
||||
'object' => $v,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
protected function simplifyName($text, $replace_spaces = true)
|
||||
{
|
||||
if ($replace_spaces)
|
||||
$clean_text = strtoupper(trim(str_replace(' ', '', $text)));
|
||||
else
|
||||
$clean_text = strtoupper(trim($text));
|
||||
|
||||
return $clean_text;
|
||||
}
|
||||
|
||||
protected function findBattery($batt_field, &$batt_model, &$batt_size)
|
||||
{
|
||||
// split battery into model and size
|
||||
// echo "trying match - " . $fields[92] . "\n";
|
||||
$res = preg_match("/^(.+)(GOLD|EXCEL|ENDURO|\(Trade-In\))/", $batt_field, $matches);
|
||||
if (!$res)
|
||||
{
|
||||
// echo "no match - " . $fields[92] . "\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($matches[2] == '(Trade-In)')
|
||||
return false;
|
||||
|
||||
$batt_model = $this->bmodel_hash[$matches[2]];
|
||||
// $batt_model = $matches[2];
|
||||
|
||||
// TODO: what to do about (Trade-In)
|
||||
|
||||
// check if we have the size
|
||||
$found_size = $this->simplifyName($matches[1]);
|
||||
if (!isset($this->bsize_hash[$found_size]))
|
||||
{
|
||||
// try legacy battery lookup
|
||||
$legacy_size = LegacyBattery::translate($found_size);
|
||||
if ($legacy_size == null)
|
||||
{
|
||||
// echo "no size - $found_size\n";
|
||||
if (isset($no_sizes[$found_size]))
|
||||
$no_sizes[$found_size]++;
|
||||
else
|
||||
$no_sizes[$found_size] = 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
$found_size = $legacy_size;
|
||||
}
|
||||
$batt_size = $this->bsize_hash[$found_size];
|
||||
// $batt_size = $found_size;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function findVehicle($vmfg_field, $vmake_field, $vmodel_field, &$vehicle)
|
||||
{
|
||||
// debug vehicles with no matching makes
|
||||
$no_makes = [];
|
||||
|
||||
// vehicle manufacturers
|
||||
$found_vmfg = $this->simplifyName($vmfg_field, false);
|
||||
if (!isset($this->vmfg_hash[$found_vmfg]))
|
||||
{
|
||||
$legacy_vmfg = LegacyVehicleManufacturer::translate($found_vmfg);
|
||||
if ($legacy_vmfg == null)
|
||||
{
|
||||
// echo "vmfg not found - $vmfg_field\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
$found_vmfg = $legacy_vmfg;
|
||||
}
|
||||
$vmfg_id = $this->vmfg_hash[$found_vmfg];
|
||||
|
||||
// vehicle make
|
||||
$found_make = $this->simplifyName($vmake_field, false);
|
||||
if (!isset($this->vehicle_hash[$vmfg_id][$found_make]))
|
||||
{
|
||||
$legacy_make = LegacyVehicle::translate($found_vmfg, $found_make);
|
||||
if ($legacy_make == null)
|
||||
{
|
||||
$no_makes[$found_make] = $found_vmfg . ' - ' . $found_make;
|
||||
// echo "vmake not found - $vmfg_field - $vmake_field\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
$found_make = $legacy_make;
|
||||
|
||||
// need to do this again because translate could change vmfg
|
||||
$vmfg_id = $this->vmfg_hash[$found_vmfg];
|
||||
}
|
||||
$make_list = $this->vehicle_hash[$vmfg_id][$found_make];
|
||||
|
||||
// check if there's only one in the make list
|
||||
if (count($make_list) == 1)
|
||||
{
|
||||
$vehicle = $make_list[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
// see which model matches
|
||||
$clean_model = trim(strtoupper($vmodel_field));
|
||||
|
||||
// no model specified, take first one
|
||||
$model_length = strlen($clean_model);
|
||||
if ($model_length == 0 || $clean_model == 'NONE')
|
||||
{
|
||||
$vehicle = $make_list[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
// one year or range specified
|
||||
// we only take the first
|
||||
$cut_model = substr($clean_model, 0, 4);
|
||||
foreach ($make_list as $make)
|
||||
{
|
||||
// no year
|
||||
if ($make['year_from'] == 0 && $make['year_to'] == 0)
|
||||
{
|
||||
$vehicle = $make;
|
||||
return true;
|
||||
}
|
||||
|
||||
// no year from
|
||||
if ($make['year_from'] == 0)
|
||||
{
|
||||
if ($make['year_to'] >= $cut_model)
|
||||
{
|
||||
$vehicle = $make;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// no year to
|
||||
if ($make['year_to'] == 0)
|
||||
{
|
||||
if ($make['year_from'] <= $cut_model)
|
||||
{
|
||||
$vehicle = $make;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// has year from and to
|
||||
if ($make['year_from'] <= $cut_model && $make['year_to'] >= $cut_model)
|
||||
{
|
||||
$vehicle = $make;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// echo "model search - $vmfg_id - $found_vmfg - $found_make - $vmodel_field\n";
|
||||
|
||||
// we get the first one, because we have no idea where it falls under
|
||||
$vehicle = $make_list[0];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
358
src/Entity/LegacyJobOrder.php
Normal file
358
src/Entity/LegacyJobOrder.php
Normal file
|
|
@ -0,0 +1,358 @@
|
|||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use DateTime;
|
||||
|
||||
/*
|
||||
CSV column order:
|
||||
0 - Internal ID
|
||||
1 - Type
|
||||
2 - Transaction Number
|
||||
3 - Primary Information : Date of Transaction
|
||||
4 - Primary Information : Job Order Number
|
||||
5 - Primary Information : MEH : Transaction Type
|
||||
6 - Primary Information : Reference JO Number
|
||||
7 - Primary Information : Type of Service
|
||||
8 - Primary Information : Warranty Status
|
||||
9 - Primary Information : Transaction Origin
|
||||
10 - Primary Information : Existing Battery
|
||||
11 - Primary Information : Existing Battery Type
|
||||
12 - Primary Information : Recommended Battery
|
||||
13 - Primary Infromation : Alternative Battery
|
||||
14 - Primary Information : Vehicle Plate Number
|
||||
15 - Primary Information : Brand
|
||||
16 - Primary Information : Make
|
||||
17 - Primary Information : Model
|
||||
18 - Primary Information : Vehicle Color
|
||||
19 - Primary Information : Caller Name
|
||||
20 - First Name
|
||||
21 - Middle Name
|
||||
22 - Last Name
|
||||
23 - Primary Information : Caller Contact
|
||||
24 - Primary Information : Caller Mobile No.
|
||||
25 - Primary Information : Caller Landline No.
|
||||
26 - Primary Information : Invoice / Company Name
|
||||
27 - Primary Information : New Name?
|
||||
28 - Primary Information : New Invoice / Company Name
|
||||
29 - Primary Information : Delivery Instructions
|
||||
30 - Primary Information : Agent Notes - Tier 1
|
||||
31 - Primary Information : Delivery Date
|
||||
32 - Primary Information : Delivery Time
|
||||
33 - Primary Information : Advance Order
|
||||
34 - Primary Information : Stages
|
||||
35 - Primary Information : Reason for Cancellation
|
||||
36 - Primary Information : Specify the Reason for Cancellation
|
||||
37 - Primary Information : Payment Method
|
||||
38 - Primary Information : Change for:
|
||||
39 - Primary Information : Prepared by
|
||||
40 - Current Battery Details : Serial No.:
|
||||
41 - Current Battery Details : DR No.:
|
||||
42 - Current Battery Details : Date of Replacement
|
||||
43 - Current Battery Details : Battery Brand
|
||||
44 - Current Battery Details : Type
|
||||
45 - Current Battery Details : Issued By:
|
||||
46 - Current Battery Details : Issued By Direct
|
||||
47 - Original Battery Details : Serial No.
|
||||
48 - Original Battery Details : OR No.:
|
||||
49 - Original Battery Details : Date of Purchase
|
||||
50 - Original Battery Details : Battery Brand:
|
||||
51 - Original Battery Details : Battery Type:
|
||||
52 - Original Battery Details : Purchased From:
|
||||
53 - Original Battery Details : Purchase from Direct
|
||||
54 - Original Battery Details : Current Warranty Expiration Date
|
||||
55 - Original Battery Details : Trade-In Battery
|
||||
56 - Dispatching : Agent Notes : Tier 2
|
||||
57 - Dispatching : Notes (Customer Classification)
|
||||
58 - Dispatching : Pending
|
||||
59 - Dispatching : Pending - Awaiting Stocks
|
||||
60 - Dispatching : Date started from Awaiting Stock
|
||||
61 - Dispatching : 4TH Due
|
||||
62 - Dispatching : 8TH Due
|
||||
63 - Dispatching : 12TH Due
|
||||
64 - Dispatching : 14TH Due
|
||||
65 - Dispatching : Currently Assigned Enrollee
|
||||
66 - Dispatching : Non-HUB?
|
||||
67 - Dispatching : HUB Catered?
|
||||
68 - Dispatching : Thru Annex?
|
||||
69 - Dispatching : HUB List
|
||||
70 - Dispatching : Annex List
|
||||
71 - Dispatching : Exempted to 6%
|
||||
72 - Dispatching : Rider Name List
|
||||
73 - Dispatching : Rider Name
|
||||
74 - Dispatching : Rider Contact Information
|
||||
75 - DIspatching : Dispatch Time
|
||||
76 - Dispatching : Dispatch Date
|
||||
77 - Dispatching : Dispatched By
|
||||
78 - Dispatching : Time of Arrival
|
||||
79 - Dispatching : Time Job Completed
|
||||
80 - Dispatching : For Line Up?
|
||||
81 - DIspatching : Order
|
||||
82 - Vehicle Location : Address
|
||||
83 - Vehicle Location : Landmark
|
||||
84 - Customer Service Record : Purchase Date
|
||||
85 - Customer Service Record : Battery / Item
|
||||
86 - Customer Service Record : Battery / Item Warranty in Months
|
||||
87 - Customer Service Record : Warranty Inquiry (Expiration Date)
|
||||
88 - JO : Amount
|
||||
89 - JO : TAX
|
||||
90 - JO : Discount
|
||||
91 - JO : Final Amount
|
||||
92 - Line Details : Item
|
||||
93 - Line Details : Quantity
|
||||
94 - Line Details : Item Rate
|
||||
95 - Line Details : Price Level
|
||||
96 - Line Details : Item Base Price
|
||||
97 - Line Details : Price Level Amount Deductions
|
||||
98 - Line Details : Final Amount
|
||||
99 - Line Details : No Trade-In
|
||||
100 - Line Details : Reason for No Trade-In
|
||||
101 - Line Details : Battery Class
|
||||
102 - Line Details : Discount Items
|
||||
103 - Line Details : Discount Code
|
||||
104 - Line Details : Percentage
|
||||
105 - Line Details : Converted Rate
|
||||
106 - Line Details : Discount Amount
|
||||
107 - Line Details : Warranty Classification
|
||||
108 - Line Details : Warranty in Months
|
||||
109 - Line Details : Warranty Expiration Date
|
||||
110 - Line Details : Serial Number
|
||||
111 - Line Details : Invoice/DR Number
|
||||
112 - Line Details : Repalcement
|
||||
113 - Line Details : Employee / Card No. / Referred by
|
||||
114 - Line Details : Amount
|
||||
115 - Line Details : Gross Amount
|
||||
116 - Line Details : Gross Amount
|
||||
117 - Time Stamp : Date / Time (JO Open)
|
||||
118 - Time Stamp : Date / Time JO Saved
|
||||
119 - Time Stamp : Ticket Handle TIme (in mins)
|
||||
120 - Time Stamp : Idle Time
|
||||
121 - Time Stamp : Date and Time (Dispatched By)
|
||||
122 - Time Stamp : In-Transit Date and Time
|
||||
123 - TIme Stamp : Completion Date and TIme
|
||||
124 - TIme Stamp : Dispatch By to In-Transit Time (Time difference in Mins)
|
||||
125 - Time Stamp : In-Transit to Completed (Time difference in Mins)
|
||||
126 - Time Stamp : Raw Ticket Handle TIme (Decimal)
|
||||
127 - Time Stamp : Raw Idle Time (Decimal)
|
||||
128 - Account
|
||||
129 - Status
|
||||
130 - Tracking Numbers
|
||||
131 - Memo
|
||||
132 - Posting
|
||||
133 - Notes
|
||||
134 - Originally Assigned Enrollee
|
||||
135 - Remarks
|
||||
136 - Follow Up Transactions
|
||||
137 - CARD TYPE
|
||||
138 - CARD NO.
|
||||
139 - Ongoing Editing
|
||||
140 - Current User
|
||||
141 - Cancellation Date
|
||||
142 - Cancellation Time
|
||||
143 - Ticket Completion Date
|
||||
144 - Ticket Completion Time
|
||||
145 - Date Created
|
||||
146 - Time Created
|
||||
147 - PREVIOUS STAGE
|
||||
148 - DISPATCHED BY EDITED?
|
||||
149 - Previous Dispatched By
|
||||
150 - POST SERVICE
|
||||
151 - Pending (2)
|
||||
152 - COMPLETED MANUALLY
|
||||
153 - THRU HUB NOTE
|
||||
154 - CURRENTLY ASSIGNED ENROLLEE (free-form)
|
||||
155 - IN-TRANSIT ALLOWANCE
|
||||
156 - COPY FROM JO #
|
||||
157 - NO. OF POSSIBLE DUPLICATE
|
||||
158 - Call Status
|
||||
159 - DISTRIBUTOR OUTLETS
|
||||
160 - CURRENTLY ASSIGNED ENROLLEE (free-form)
|
||||
161 - HUB LIST
|
||||
162 - HUB LIST 2
|
||||
163 - Enrollee
|
||||
164 - Currently Assigned Enrollee
|
||||
165 - Payment:
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="legacy_job_order")
|
||||
*/
|
||||
class LegacyJobOrder
|
||||
{
|
||||
// legacy internal id
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date")
|
||||
*/
|
||||
protected $trans_date;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=10)
|
||||
*/
|
||||
protected $trans_type;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=30)
|
||||
*/
|
||||
protected $origin;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=20)
|
||||
*/
|
||||
protected $car_brand;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=50)
|
||||
*/
|
||||
protected $car_make;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=20)
|
||||
*/
|
||||
protected $car_model;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=40)
|
||||
*/
|
||||
protected $car_color;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=90)
|
||||
*/
|
||||
protected $cust_name;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=35)
|
||||
*/
|
||||
protected $cust_first_name;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=15)
|
||||
*/
|
||||
protected $cust_middle_name;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=35)
|
||||
*/
|
||||
protected $cust_last_name;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=25)
|
||||
*/
|
||||
protected $cust_contact;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=10)
|
||||
*/
|
||||
protected $cust_mobile;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=25)
|
||||
*/
|
||||
protected $cust_landline;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=2000)
|
||||
*/
|
||||
protected $delivery_instructions;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=4000)
|
||||
*/
|
||||
protected $agent_notes_1;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=10)
|
||||
*/
|
||||
protected $delivery_date;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=10)
|
||||
*/
|
||||
protected $delivery_time;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=3)
|
||||
*/
|
||||
protected $advance_order;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=30)
|
||||
*/
|
||||
protected $stage;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=40)
|
||||
*/
|
||||
protected $cancel_reason;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=2000)
|
||||
*/
|
||||
protected $cancel_reason_specify;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=30)
|
||||
*/
|
||||
protected $payment_method;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=30)
|
||||
*/
|
||||
protected $prepared_by;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=10)
|
||||
*/
|
||||
protected $dispatch_time;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=10)
|
||||
*/
|
||||
protected $dispatch_date;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=30)
|
||||
*/
|
||||
protected $dispatched_by;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=200)
|
||||
*/
|
||||
protected $address;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=320)
|
||||
*/
|
||||
protected $landmark;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=10)
|
||||
*/
|
||||
protected $date_purchase;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=20)
|
||||
*/
|
||||
protected $plate_number;
|
||||
|
||||
|
||||
|
||||
public function setID($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getID()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
}
|
||||
72
src/Entity/LegacyJobOrderRow.php
Normal file
72
src/Entity/LegacyJobOrderRow.php
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use DateTime;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="legacy_job_order_row")
|
||||
*/
|
||||
class LegacyJobOrderRow
|
||||
{
|
||||
// legacy internal id
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\Column(type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
protected $job_order_id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=40)
|
||||
*/
|
||||
protected $item;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=10)
|
||||
*/
|
||||
protected $qty;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="decimal", precision=9, scale=2)
|
||||
*/
|
||||
protected $price;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=30)
|
||||
*/
|
||||
protected $price_level;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=10)
|
||||
*/
|
||||
protected $status;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=20)
|
||||
*/
|
||||
protected $account;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=70)
|
||||
*/
|
||||
protected $enrollee;
|
||||
|
||||
public function setID($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getID()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
}
|
||||
49
src/Entity/PlateNumber.php
Normal file
49
src/Entity/PlateNumber.php
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use DateTime;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="plate_number")
|
||||
*/
|
||||
class PlateNumber
|
||||
{
|
||||
// the plate number
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\Column(type="string", length=20)
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
// the vehicle entity
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Vehicle")
|
||||
* @ORM\JoinColumn(name="vehicle_id", referencedColumnName="id", nullable=true)
|
||||
*/
|
||||
protected $vehicle;
|
||||
|
||||
public function setID($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getID()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setVehicle(Vehicle $vehicle)
|
||||
{
|
||||
$this->vehicle = $vehicle;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getVehicle()
|
||||
{
|
||||
return $this->vehicle;
|
||||
}
|
||||
}
|
||||
|
|
@ -29,7 +29,7 @@ class Warranty
|
|||
|
||||
// serial number
|
||||
/**
|
||||
* @ORM\Column(type="string", length=50)
|
||||
* @ORM\Column(type="string", length=50, nullable=true)
|
||||
*/
|
||||
protected $serial;
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ class Warranty
|
|||
|
||||
// plate
|
||||
/**
|
||||
* @ORM\Column(type="string", length=10)
|
||||
* @ORM\Column(type="string", length=20)
|
||||
*/
|
||||
protected $plate_number;
|
||||
|
||||
|
|
@ -79,7 +79,7 @@ class Warranty
|
|||
|
||||
// date expires
|
||||
/**
|
||||
* @ORM\Column(type="date")
|
||||
* @ORM\Column(type="date", nullable=true)
|
||||
*/
|
||||
protected $date_expire;
|
||||
|
||||
|
|
@ -133,9 +133,23 @@ class Warranty
|
|||
// remove invalid characters
|
||||
$clean_plate = preg_replace("/[^A-Z0-9]/", '', $clean_plate);
|
||||
|
||||
// check if format is correct
|
||||
// AAA123 or AAA1234
|
||||
$res = preg_match("/^[A-Z]{3}[0-9]{3,4}$/", $clean_plate);
|
||||
// check for 4 to 5 digit diplomatic plate
|
||||
$res = preg_match("/^[0-9]{4,5}$/", $clean_plate);
|
||||
if ($res)
|
||||
return $clean_plate;
|
||||
|
||||
// ABC-1234 or ABC-123 or ABC-12 format
|
||||
$res = preg_match("/^[A-Z]{3}[0-9]{2,4}$/", $clean_plate);
|
||||
if ($res)
|
||||
return $clean_plate;
|
||||
|
||||
// AB-123 or AB-12345 or AB-1234 format (motorcycles)
|
||||
$res = preg_match("/^[A-Z]{2}[0-9]{3,5}$/", $clean_plate);
|
||||
if ($res)
|
||||
return $clean_plate;
|
||||
|
||||
// 1234-AB format (motorcycles)
|
||||
$res = preg_match("/^[0-9]{4}[A-Z]{2}$/", $clean_plate);
|
||||
if ($res)
|
||||
return $clean_plate;
|
||||
|
||||
|
|
|
|||
71
src/Ramcar/LegacyBattery.php
Normal file
71
src/Ramcar/LegacyBattery.php
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
namespace App\Ramcar;
|
||||
|
||||
class LegacyBattery
|
||||
{
|
||||
static public function translate($id)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case '1SM/NS50/D23L':
|
||||
return '1SM/D23/NS50';
|
||||
case '1SM/NS50/D23R':
|
||||
return '1SM/D23/NS50/R';
|
||||
case '1SM/NS50XL/D23L':
|
||||
return '1SM/D23/NS50';
|
||||
case '2HN/NS60ARS/B24RS':
|
||||
return 'B24/NS60/R';
|
||||
case '2HN/NS60/B24L':
|
||||
return 'B24/NS60';
|
||||
case '2SM/MG50/D26L':
|
||||
return '2SM/D26/N50';
|
||||
case '2SM/MG50/D26R':
|
||||
return '2SM/D26/N50/R';
|
||||
case '2SM/N50/D26L':
|
||||
return '2SM/D26/N50';
|
||||
case '2SM/N50XL/D26L':
|
||||
return '2SM/D26/N50';
|
||||
case '3SM/MG70/D31L':
|
||||
return '3SM/D31/N70';
|
||||
case '3SM/MG70/D31R':
|
||||
return '3SM/D31/N70/R';
|
||||
case '3SM/N70/D31L':
|
||||
return '3SM/D31/N70';
|
||||
case '3SM/N70XL/D31L':
|
||||
return '3SM/D31/N70';
|
||||
case '4SN/NS40/B20L':
|
||||
// return 'NS40/B20';
|
||||
return 'B20/NS40';
|
||||
case '4SN/NS40R/B20R':
|
||||
return 'B20/NS40/R';
|
||||
case 'DIN55R':
|
||||
return 'DIN55/R';
|
||||
case 'DIN66R':
|
||||
return 'DIN66/R';
|
||||
case 'GROUP34/78':
|
||||
return 'G34';
|
||||
case 'GROUP65':
|
||||
return 'G65';
|
||||
case 'N100/6SM':
|
||||
case 'N120/2D':
|
||||
case 'N150/4D':
|
||||
case 'N200/8D':
|
||||
return null;
|
||||
case 'N50/2SM':
|
||||
return '2SM/D26/N50';
|
||||
case 'N70/3SM':
|
||||
return '3SM/D31/N70';
|
||||
case 'NS40':
|
||||
return 'B20/NS40';
|
||||
case 'NS50/1SM':
|
||||
return '1SM/D23/NS50';
|
||||
case 'NS60/N40/1SN':
|
||||
return 'B24/NS60';
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
41
src/Ramcar/LegacyOrigin.php
Normal file
41
src/Ramcar/LegacyOrigin.php
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
namespace App\Ramcar;
|
||||
|
||||
class LegacyOrigin extends NameValue
|
||||
{
|
||||
const DIRECT = 'direct';
|
||||
const FACEBOOK = 'facebook';
|
||||
const HOTLINE = 'hotline';
|
||||
const ONLINE = 'online';
|
||||
const WEBSITE = 'website';
|
||||
|
||||
const COLLECTION = [
|
||||
'direct' => 'Direct',
|
||||
'facebook' => 'Facebook',
|
||||
'hotline' => 'Hotline',
|
||||
'online' => 'Online',
|
||||
'website' => 'Website',
|
||||
];
|
||||
|
||||
public static function translate($origin)
|
||||
{
|
||||
$clean_origin = strtolower(trim($origin));
|
||||
|
||||
switch ($clean_origin)
|
||||
{
|
||||
case 'direct':
|
||||
return self::DIRECT;
|
||||
case 'facebook':
|
||||
return self::FACEBOOK;
|
||||
case 'hotline':
|
||||
return self::HOTLINE;
|
||||
case 'online (24 hour window time)':
|
||||
return self::ONLINE;
|
||||
case 'website':
|
||||
return self::WEBSITE;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
37
src/Ramcar/LegacyTransactionType.php
Normal file
37
src/Ramcar/LegacyTransactionType.php
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace App\Ramcar;
|
||||
|
||||
class LegacyTransactionType extends NameValue
|
||||
{
|
||||
const PURCHASE = 'purchase';
|
||||
const POST_SERVICE = 'post';
|
||||
const RESQ_SERVICE = 'resq';
|
||||
const SERVICE = 'service';
|
||||
|
||||
const COLLECTION = [
|
||||
'purchase' => 'Purchase',
|
||||
'post' => 'Post Service',
|
||||
'resq' => 'Res-q Service',
|
||||
'service' => 'Service',
|
||||
];
|
||||
|
||||
public static function translate($type)
|
||||
{
|
||||
$clean_type = strtolower(trim($type));
|
||||
|
||||
switch ($clean_type)
|
||||
{
|
||||
case 'post service':
|
||||
return self::POST_SERVICE;
|
||||
case 'purchase':
|
||||
return self::PURCHASE;
|
||||
case 'res-q services':
|
||||
return self::RESQ_SERVICE;
|
||||
case 'service':
|
||||
return self::SERVICE;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
139
src/Ramcar/LegacyVehicle.php
Normal file
139
src/Ramcar/LegacyVehicle.php
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
<?php
|
||||
|
||||
namespace App\Ramcar;
|
||||
|
||||
class LegacyVehicle
|
||||
{
|
||||
static public function translate(&$mfg, $make)
|
||||
{
|
||||
// specific cases
|
||||
if ($mfg == 'PROTON')
|
||||
{
|
||||
if ($make == '1.6')
|
||||
return 'WIRA 1.6';
|
||||
}
|
||||
|
||||
if ($mfg == 'DODGE' && $make == 'RAM')
|
||||
{
|
||||
$mfg = 'CHRYSLER';
|
||||
return 'RAM';
|
||||
}
|
||||
|
||||
if ($mfg == 'GMC' && $make == 'TAHOE')
|
||||
{
|
||||
$mfg = 'CHEVROLET';
|
||||
return 'TAHOE 5.3 V8 4X2 AT';
|
||||
}
|
||||
|
||||
|
||||
// general cases
|
||||
switch($make)
|
||||
{
|
||||
// Toyota
|
||||
case 'INNOVA GAS E':
|
||||
return 'INNOVA (E-TYPE)';
|
||||
case 'INNOVA GAS G':
|
||||
return 'INNOVA (G-TYPE)';
|
||||
case 'INNOVA GAS V':
|
||||
return 'INNOVA (V-TYPE)';
|
||||
case 'INNOVA GAS J':
|
||||
return 'INNOVA (J-TYPE)';
|
||||
case 'RAV-4':
|
||||
return 'RAV 4';
|
||||
case 'PRADO':
|
||||
return 'LAND CRUISER / PRADO (GASOLINE)';
|
||||
case 'STARLET':
|
||||
return 'STARLET (STARLET)';
|
||||
case 'COROLLA':
|
||||
return 'COROLLA ALL MODELS / ALTIS*';
|
||||
case 'TOYOTA BB':
|
||||
return 'BB';
|
||||
|
||||
// Isuzu
|
||||
case 'MUX':
|
||||
return 'MU-X 2.5LI 4X2/3.0LI 4X4';
|
||||
|
||||
// Mazda
|
||||
case 'CX-5':
|
||||
return 'CX5';
|
||||
case 'MAZADA 3 / 2 / 6 ISTOP':
|
||||
return 'MAZDA 3 / 2 / 6 ISTOP';
|
||||
|
||||
// Chevrolet
|
||||
case 'SUBURVAN 5.3 V9 4X2 AT':
|
||||
return 'SUBURBAN 5.3 V9 4X2 AT';
|
||||
case 'SUBURVAN 5.3 V8 4X2 AT':
|
||||
return 'SUBURBAN 5.3 V8 4X2 AT';
|
||||
case 'TRAILBLAZER 2014':
|
||||
case 'TRAILBLAZER 2013 LOW':
|
||||
return 'TRAILBLAZER';
|
||||
|
||||
// Subaru
|
||||
case 'FORESTER 2.0 AND 2.5':
|
||||
return 'FORESTER 2.0';
|
||||
|
||||
// Chery
|
||||
case 'CHERY QQ3':
|
||||
return 'CHERRY QQ3';
|
||||
case 'CHERY A5':
|
||||
return 'CHERRY A5';
|
||||
|
||||
// Mitsubishi
|
||||
case 'ADVENTURE GAS':
|
||||
return 'ADVENTURE GX';
|
||||
case 'MIRAGE':
|
||||
return 'MIRAGE G4';
|
||||
case 'L300 (DIESEL)':
|
||||
return 'L300 FB (DIESEL)';
|
||||
|
||||
// Kia
|
||||
case 'SORENTO 7-SEATER AT':
|
||||
return 'SORENTO';
|
||||
|
||||
// Honda
|
||||
case 'ACCORD 3.5 S - V AT V6 (BRILLIANT WHITE PEARL)':
|
||||
return 'ACCORD 3.5 S - V AT V6';
|
||||
case 'BRIO-AMAZE':
|
||||
return 'BRIO';
|
||||
case 'NEW CIVIC 1.8 V AT':
|
||||
return 'CIVIC 1.8';
|
||||
case 'STEPWGN':
|
||||
return 'WAGON';
|
||||
case 'CR-V 1.5 I-DTEC':
|
||||
return 'CRV';
|
||||
case 'NEW CIVIC 1.8 V MT':
|
||||
return 'CIVIC 1.8';
|
||||
|
||||
// Nissan
|
||||
case 'ALMIRA':
|
||||
return 'ALMERA';
|
||||
|
||||
// Volkswagen
|
||||
case 'POLO HATCH 1.6 MPI AT (GAS)':
|
||||
return 'POLO NOTCH 1.6 MPI AT (GAS)';
|
||||
|
||||
// Hyundai
|
||||
case 'MATRIX 1.6 GAS':
|
||||
return 'MATRIX (1.6 GAS)';
|
||||
case 'GETZ 1.1 GAS':
|
||||
return 'GETZ GAS 1.1 MT';
|
||||
|
||||
// Mini
|
||||
case 'MINI COOPER':
|
||||
return 'COOPER';
|
||||
|
||||
// Bentley
|
||||
case 'CONTINENTAL GT/GTC':
|
||||
return 'CONTINENTAL GT/GTC 6.0 W12';
|
||||
|
||||
// Ford
|
||||
case 'ECOSPORT':
|
||||
return 'ECOSPORT 1.5';
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
23
src/Ramcar/LegacyVehicleManufacturer.php
Normal file
23
src/Ramcar/LegacyVehicleManufacturer.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace App\Ramcar;
|
||||
|
||||
class LegacyVehicleManufacturer
|
||||
{
|
||||
static public function translate($id)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 'PROTONWIRA':
|
||||
case 'PROTON WIRA':
|
||||
return 'PROTON';
|
||||
case 'CHERRY CARS':
|
||||
case 'CHERY CARS':
|
||||
return 'CHERY';
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -13,4 +13,25 @@ class WarrantyClass extends NameValue
|
|||
'commercial' => 'Commercial',
|
||||
'tnv' => 'TNV',
|
||||
];
|
||||
|
||||
public static function convertFromLegacy($legacy_wclass)
|
||||
{
|
||||
switch($legacy_wclass)
|
||||
{
|
||||
case '1YEAR':
|
||||
case '1YR':
|
||||
case 'Old Private':
|
||||
case 'PRIAVTE':
|
||||
case 'PRIVATE':
|
||||
return self::WTY_PRIVATE;
|
||||
|
||||
case 'COMMERCIAL':
|
||||
return self::WTY_COMMERCIAL;
|
||||
|
||||
case 'GRAB':
|
||||
return self::WTY_TNV;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue