From 4eca65cc59bbd9ac4f7075cf83b96d7a70a42568 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Fri, 8 Sep 2023 17:24:43 +0800 Subject: [PATCH] Add saving of data to archive table. #762 --- src/Command/GetJobOrderArchiveDataCommand.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Command/GetJobOrderArchiveDataCommand.php b/src/Command/GetJobOrderArchiveDataCommand.php index 47c3e174..7e9f969e 100644 --- a/src/Command/GetJobOrderArchiveDataCommand.php +++ b/src/Command/GetJobOrderArchiveDataCommand.php @@ -126,6 +126,8 @@ class GetJobOrderArchiveDataCommand extends Command $backup_data[] = $this->createBackupData($row); } + error_log('count ' . count($backup_data)); + // create the load file for the backup data $this->createLoadDataFileForBackupData($backup_data, $archive_table_name); @@ -238,7 +240,6 @@ class GetJobOrderArchiveDataCommand extends Command if ($row['date_fulfill'] != NULL) $date_fulfill = $row['date_schedule']; - $coordinates = $row['coordinates']; $flag_advance = $row['flag_advance']; $service_type = $row['service_type']; $source = $row['source']; @@ -248,6 +249,8 @@ class GetJobOrderArchiveDataCommand extends Command $date_cancel = $row['date_cancel']; $status = $row['status']; + + // TODO: might need to clean delivery address and delivery instructions $del_instructions = $row['delivery_instructions']; $del_address = $row['delivery_address']; @@ -312,6 +315,10 @@ class GetJobOrderArchiveDataCommand extends Command $coord_long = $row['coord_long']; $coord_lat = $row['coord_lat']; + + // coordinates needs special handling since it's a spatial column + $coordinates = 'POINT(' . $coord_lat . ' ' . $coord_long .')'; + $priority = $row['priority']; $meta = $row['meta']; @@ -471,11 +478,11 @@ class GetJobOrderArchiveDataCommand extends Command fclose($fp); $conn = $this->em->getConnection(); - $stmt = $conn->prepare('LOAD DATA LOCAL INFILE \'' . $file . '\' INTO TABLE ' . $table_name . ' + $stmt = $conn->prepare('LOAD DATA LOCAL INFILE \'' . $file . '\' INTO TABLE ' . $table_name . ' FIELDS TERMINATED BY \'|\' LINES TERMINATED BY \'\\r\\n\' (id, customer_id, cvehicle_id, rider_id, date_create, - date_schedule, date_fulfill, coordinates, flag_advance, service_type, + date_schedule, date_fulfill, @coordinates, flag_advance, service_type, source, date_cancel, status, delivery_instructions, delivery_address, create_user_id, assign_user_id, date_assign, warranty_class, process_user_id, hub_id, cancel_reason, ref_jo_id, tier1_notes, tier2_notes, @@ -485,7 +492,9 @@ class GetJobOrderArchiveDataCommand extends Command first_name, last_name, plate_number, phone_mobile, no_trade_in_reason, will_wait, reason_not_waiting, not_waiting_notes, delivery_status, emergency_type_id, ownership_type_id, cust_location_id, source_of_awareness, remarks, initial_concern, - initial_concern_notes, gender, caller_classification, inventory_count)'); + initial_concern_notes, gender, caller_classification, inventory_count) + SET coordinates=ST_GeomFromText(@coordinates)' + ); $result = $stmt->execute();