linked invoice and attendee

This commit is contained in:
Dorian Vabre 2021-04-20 16:09:22 +02:00
parent b70e477f47
commit a500d83c0b
3 changed files with 28 additions and 17 deletions

View File

@ -3820,6 +3820,11 @@ abstract class CommonObject
$classpath = 'projet/class';
$classfile = 'project';
$classname = 'Project';
} elseif ($objecttype == 'conferenceorboothattendee') {
$classpath = 'eventorganization/class';
$classfile = 'conferenceorboothattendee';
$classname = 'ConferenceOrBoothAttendee';
$module = 'eventorganization';
}
// Here $module, $classfile and $classname are set

View File

@ -321,12 +321,13 @@ if (empty($reshook) && $action == 'add') {
$confattendee->errors[] = $confattendee->error;
}
}
$resultfacture = $facture->create($user);
if ($resultfacture <= 0) {
$confattendee->error = $facture->error;
$confattendee->errors = $facture->errors;
$error++;
} else {
$facture->add_object_linked($confattendee->element, $confattendee->id);
}
}

View File

@ -117,17 +117,30 @@ if ($source == 'conferencesubscription') {
$invoice = new Facture($db);
$resultinvoice = $invoice->fetch($decodedinvoiceid);
if ($resultinvoice <= 0) {
$mesg = $invoice->error;
$error++;
setEventMessages(null, $invoice->errors, "errors");
} else {
$invoice->fetchObjectLinked();
// Finding the thirdparty associated to the Attendee
$thirdparty = new Societe($db);
$resultthirdparty = $thirdparty->fetch($invoice->socid);
if ($resultthirdparty <= 0) {
$mesg = $thirdparty->error;
$error++;
setEventMessages(null, $thirdparty->errors, "errors");
}
$object = $thirdparty;
$linkedAttendees = $invoice->linkedObjectsIds['conferenceorboothattendee'];
if (is_array($linkedAttendees)) {
$linkedAttendees = array_values($linkedAttendees);
$attendee = new ConferenceOrBoothAttendee($db);
$resultattendee = $attendee->fetch($linkedAttendees[0]);
if ($resultattendee <= 0) {
setEventMessages(null, $attendee->errors, "errors");
}
var_dump($attendee);
exit;
}
}
}
@ -363,7 +376,7 @@ if ($action == 'dopayment') {
// A redirect is added if API call successfull
if ($source == 'conferencesubscription') {
$PAYPAL_API_OK .= '&conferencesubscription='.dol_encode('subscriptionok'.$ref, $dolibarr_main_instance_unique_id).'&invoice='.dol_encode($invoice->id, $dolibarr_main_instance_unique_id);
$PAYPAL_API_OK .= '&invoice='.dol_encode($invoice->id, $dolibarr_main_instance_unique_id);
}
$mesg = print_paypal_redirect($PAYPAL_API_PRICE, $PAYPAL_API_DEVISE, $PAYPAL_PAYMENT_TYPE, $PAYPAL_API_OK, $PAYPAL_API_KO, $FULLTAG);
@ -384,7 +397,7 @@ if ($action == 'dopayment') {
$urlko = preg_replace('/securekey=[^&]+/', '', $urlko);
if ($source == 'conferencesubscription') {
$urlok .= '&conferencesubscription='.dol_encode('subscriptionok'.$ref, $dolibarr_main_instance_unique_id).'&invoice='.dol_encode($invoice->id, $dolibarr_main_instance_unique_id);
$urlok .= '&invoice='.dol_encode($invoice->id, $dolibarr_main_instance_unique_id);
}
$mesg = '';
@ -742,7 +755,7 @@ if ($action == 'charge' && !empty($conf->stripe->enabled)) {
exit;
} else {
if ($source == 'conferencesubscription') {
$urlok .= '&conferencesubscription='.dol_encode('subscriptionok'.$ref, $dolibarr_main_instance_unique_id).'&invoice='.dol_encode($invoice->id, $dolibarr_main_instance_unique_id);
$urlok .= '&invoice='.dol_encode($invoice->id, $dolibarr_main_instance_unique_id);
}
header("Location: ".$urlok);
exit;
@ -1763,18 +1776,10 @@ if ($source == 'conferencesubscription') {
$found = true;
$langs->load("members");
if ($action != 'dopayment') { // Do not change amount if we just click on first dopayment
$amount = $project->price_registration;
if (GETPOST("amount", 'alpha')) {
$amount = GETPOST("amount", 'alpha');
}
$amount = price2num($amount, 'MT');
}
if (GETPOST('fulltag', 'alpha')) {
$fulltag = GETPOST('fulltag', 'alpha');
} else {
$fulltag = 'MEM='.$member->id.'.DAT='.dol_print_date(dol_now(), '%Y%m%d%H%M%S');
$fulltag = 'ATT='.$attendee->id.'.DAT='.dol_print_date(dol_now(), '%Y%m%d%H%M%S');
if (!empty($TAG)) {
$tag = $TAG; $fulltag .= '.TAG='.$TAG;
}