Add checking for sap code for warranty creation. #654
This commit is contained in:
parent
b0e743b6e7
commit
f89e8548a9
1 changed files with 23 additions and 7 deletions
|
|
@ -231,13 +231,23 @@ 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 . '\')';
|
||||
// check for sap_code. Not all batteries have sap_code
|
||||
if (empty($sap_code))
|
||||
{
|
||||
$value_string = '(' . $model_id . ',' . $size_id . ',\'' . $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 . '\')';
|
||||
|
||||
$sql_statement = 'INSERT INTO `warranty` (bty_model_id,bty_size_id,sap_bty_id,warranty_class,plate_number,status,date_create,date_purchase,date_expire,first_name,last_name,mobile_number,flag_activated,vehicle_id,customer_id, create_source) VALUES ' . $value_string . ';' . "\n";
|
||||
$sql_statement = 'INSERT INTO `warranty` (bty_model_id,bty_size_id,warranty_class,plate_number,status,date_create,date_purchase,date_expire,first_name,last_name,mobile_number,flag_activated,vehicle_id,customer_id, create_source) VALUES ' . $value_string . ';' . "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$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 . '\')';
|
||||
|
||||
$sql_statement = 'INSERT INTO `warranty` (bty_model_id,bty_size_id,sap_bty_id,warranty_class,plate_number,status,date_create,date_purchase,date_expire,first_name,last_name,mobile_number,flag_activated,vehicle_id,customer_id, create_source) VALUES ' . $value_string . ';' . "\n";
|
||||
}
|
||||
|
||||
error_log($sql_statement);
|
||||
|
||||
|
|
@ -327,7 +337,13 @@ class FulfillOpenJobOrderCommand extends Command
|
|||
|
||||
protected function cleanPlateNumber($plate)
|
||||
{
|
||||
return strtoupper(str_replace(' ', '', $plate));
|
||||
// trim plate number down to 20 characters
|
||||
$trim_plate = str_replace(' ','', $plate);
|
||||
|
||||
// truncate plate number down to 20 (max length)
|
||||
$trunc_plate = substr($trim_plate, 0, 20);
|
||||
|
||||
return strtoupper($trunc_plate);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue