From 559a61bb13d0ad145eaf3f896143de7941d38970 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Thu, 12 May 2022 07:04:52 +0000 Subject: [PATCH] Add checking for null rider ids. #654 --- src/Command/FulfillOpenJobOrderCommand.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Command/FulfillOpenJobOrderCommand.php b/src/Command/FulfillOpenJobOrderCommand.php index 263afa29..f18c5baf 100644 --- a/src/Command/FulfillOpenJobOrderCommand.php +++ b/src/Command/FulfillOpenJobOrderCommand.php @@ -115,14 +115,21 @@ class FulfillOpenJobOrderCommand extends Command $fulfill_jo_stmt = $conn->prepare($fulfill_jo_sql); $fulfill_jo_stmt->execute([ 'fulfilled' => JOStatus::FULFILLED, - 'del_fulfilled' => DeliveryStatus::FULFILLED + 'del_fulfilled' => DeliveryStatus::FULFILLED, 'jo_id' => $jo_id, ]); // create jo event // set user to admin that has id of 1 $user_id = 1; - $jo_event_values = '(' . $user_id . ',' . $jo_id . ',\'' . $str_current_date . '\',\'' . $str_current_date . '\',\'' . JOEventType::FULFILL . '\',' . $rider_id . ')'; + + $r_id = 'NULL'; + // check if rider is null + if ($rider_id != NULL) + $r_id = $rider_id; + + // need to check rider id if null since that will change the jo_event_values + $jo_event_values = '(' . $user_id . ',' . $jo_id . ',\'' . $str_current_date . '\',\'' . $str_current_date . '\',\'' . JOEventType::FULFILL . '\',' . $r_id . ')'; $create_jo_event_sql = 'INSERT into `jo_event` (create_user_id, job_order_id, date_create, date_happen, type_id, rider_id) VALUES ' . $jo_event_values . ';' . "\n"; @@ -224,6 +231,8 @@ class FulfillOpenJobOrderCommand extends Command $sap_code = $batt_info['sap_code']; // populate the values string for the values to be inserted into warranty + // TODO: add checking for sap code. we need another value string and sql statement if sap_code is blank + // where sap_code is not inserted $value_string = '(' . $model_id . ',' . $size_id . ',\'' . $sap_code . '\',\'' . $warranty_class . '\',\'' . $plate_number . '\',\'' . $warranty_status . '\',\'' . $str_current_date . '\',\'' . $str_date_schedule . '\',\'' . $str_date_expire . '\',\'' . $first_name . '\',\'' . $last_name . '\',\'' . $mobile . '\',' . 1 . ',' . $vehicle_id . ',' . $cust_id . ',\'' . WarrantySource::ADMIN_PANEL . '\')';