This commit is contained in:
Dorian Vabre 2021-04-16 12:10:02 +02:00
parent 71befd15f9
commit 5a445d92de

View File

@ -241,7 +241,6 @@ if (empty($reshook) && $action == 'add') {
} else { } else {
$thirdparty->name = $email; $thirdparty->name = $email;
} }
$thirdparty->address = GETPOST("address"); $thirdparty->address = GETPOST("address");
$thirdparty->zip = GETPOST("zipcode"); $thirdparty->zip = GETPOST("zipcode");
$thirdparty->town = GETPOST("town"); $thirdparty->town = GETPOST("town");
@ -270,6 +269,8 @@ if (empty($reshook) && $action == 'add') {
} }
$thirdparty->code_client = $tmpcode; $thirdparty->code_client = $tmpcode;
$readythirdparty = $thirdparty->create($user); $readythirdparty = $thirdparty->create($user);
$thirdparty->country_code = getCountry($thirdparty->country_id, 2, $db, $langs);
$thirdparty->country = getCountry($thirdparty->country_code, 0, $db, $langs);
} else { } else {
// We have an existing thirdparty ready to use // We have an existing thirdparty ready to use
$readythirdparty = 1; $readythirdparty = 1;
@ -329,24 +330,14 @@ if (empty($reshook) && $action == 'add') {
if (!$error) { if (!$error) {
// Add line to draft invoice // Add line to draft invoice
$idprodsubscription = 0; $vattouse = get_default_tva($mysoc, $thirdparty, $productforinvoicerow->id);
if (!empty($conf->global->SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) { $result = $facture->addline($label, 0, 1, $vattouse, 0, 0, $productforinvoicerow->id, 0, dol_now(), '', 0, 0, '', 'TTC', floatval($project->price_registration), 1);
$idprodsubscription = $conf->global->SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION;
}
$vattouse = get_default_tva($mysoc, $thirdparty, $idprodsubscription);
$result = $facture->addline($label, 0, 1, $vattouse, 0, 0, $idprodsubscription, 0, $datesubscription, '', 0, 0, '', 'TTC', $amount, 1);
if ($result <= 0) { if ($result <= 0) {
$confattendee->error = $facture->error; $confattendee->error = $facture->error;
$confattendee->errors = $facture->errors; $confattendee->errors = $facture->errors;
$error++; $error++;
} }
$resultfacture = $facture->create($user); if (!$error) {
if ($resultfacture < 0) {
$error++;
$errmsg .= $facture->error;
} else {
$redirection = $dolibarr_main_url_root.'/public/payment/newpayment.php?source=conferencesubscription&ref='.$confattendee->id; $redirection = $dolibarr_main_url_root.'/public/payment/newpayment.php?source=conferencesubscription&ref='.$confattendee->id;
Header("Location: ".$redirection); Header("Location: ".$redirection);
exit; exit;