From 7e3c392c03b6c8b0e464dacc3a823cf081bbacad Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Mon, 11 Sep 2023 15:10:08 +0800 Subject: [PATCH] Fix issues found when saving archive data. #762 --- src/Command/GetJobOrderArchiveDataCommand.php | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/Command/GetJobOrderArchiveDataCommand.php b/src/Command/GetJobOrderArchiveDataCommand.php index 7e9f969e..4a42849f 100644 --- a/src/Command/GetJobOrderArchiveDataCommand.php +++ b/src/Command/GetJobOrderArchiveDataCommand.php @@ -44,6 +44,8 @@ class GetJobOrderArchiveDataCommand extends Command $period = $input->getArgument('period'); $cutoff_date = $input->getArgument('cutoff_date'); + $cutoff_date_time = $cutoff_date . ' 23:59:59'; + $em = $this->em; $db = $em->getConnection(); @@ -112,7 +114,8 @@ class GetJobOrderArchiveDataCommand extends Command caller_classification, inventory_count FROM job_order - WHERE DATE_CREATE < DATE_SUB(:cutoff_date, INTERVAL ' . $period . ' YEAR)'; + WHERE DATE_CREATE <= DATE_SUB(:cutoff_date, INTERVAL ' . $period . ' YEAR) + ORDER BY date_create'; $query_stmt = $db->prepare($query_sql); $query_stmt->bindValue('cutoff_date', $cutoff_date, PDO::PARAM_STR); @@ -250,9 +253,8 @@ class GetJobOrderArchiveDataCommand extends Command $status = $row['status']; - // TODO: might need to clean delivery address and delivery instructions - $del_instructions = $row['delivery_instructions']; - $del_address = $row['delivery_address']; + $del_instructions = $this->cleanData($row['delivery_instructions']); + $del_address = $this->cleanData($row['delivery_address']); $create_user_id = '\N'; if ($row['create_user_id'] != NULL) @@ -284,11 +286,13 @@ class GetJobOrderArchiveDataCommand extends Command if ($row['ref_jo_id'] != NULL) $ref_jo_id = $row['ref_jo_id']; - $tier1_notes = $row['tier1_notes']; - $tier2_notes = $row['tier2_notes']; + $tier1_notes = $this->cleanData($row['tier1_notes']); + $tier2_notes = $this->cleanData($row['tier2_notes']); + $mode_of_payment = $row['mode_of_payment']; $or_name = $row['or_name']; - $landmark = $row['landmark']; + + $landmark = $this->cleanData($row['landmark']); $promo_details = $row['promo_detail']; $or_num = '\N'; @@ -367,7 +371,7 @@ class GetJobOrderArchiveDataCommand extends Command $remarks = '\N'; if ($row['remarks'] != NULL) - $remarks = $row['remarks']; + $remarks = $this->cleanData(row['remarks']); $initial_concern = '\N'; if ($row['initial_concern'] != NULL) @@ -504,4 +508,15 @@ class GetJobOrderArchiveDataCommand extends Command // TODO: delete file? } + protected function cleanData($text) + { + $clean_text = ''; + + // replace the new lines with whitespace + $clean_text = preg_replace("/[\n\r]/", ' ', $text); + + return $clean_text; + + } + }