Added customer_number and serice pin

This commit is contained in:
Frank Schubert
2021-08-26 20:33:00 +02:00
parent df127c08d9
commit d77642f9de
9 changed files with 96 additions and 6 deletions

View File

@@ -359,6 +359,30 @@ class OrderController extends mfBaseController {
$this->log->warn("Unable to save OrderProduct:".print_r($product, true));
}
// if product is not external and customer is new, create customer_number and service pin
if(!$prod->external ) {
if(!$owner->customer_number) {
$last_num = AddressModel::getLastCustomerNumber();
if($last_num) {
$new_num = $last_num + 1;
} else {
$new_num = TT_FIRST_CUSTNUM;
}
$owner->customer_number = $new_num;
$owner->save();
}
if(!$owner->spin) {
$spin = $owner->generateServicePin();
if($spin) {
$owner->spin = $spin;
$owner->save();
}
}
}
}
}