fixed invoice validation, payment, and attendee validation
This commit is contained in:
parent
1511bf811c
commit
f8479b4a57
@ -374,7 +374,7 @@ if (empty($reshook) && $action == 'add') {
|
||||
if (!$error) {
|
||||
$valid = true;
|
||||
$sourcetouse = 'conferencesubscription';
|
||||
$reftouse = $confattendee->id;
|
||||
$reftouse = $facture->id;
|
||||
$redirection = $dolibarr_main_url_root.'/public/payment/newpayment.php?source='.$sourcetouse.'&ref='.$reftouse;
|
||||
if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
|
||||
if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
|
||||
|
||||
@ -114,23 +114,23 @@ if (!$action) {
|
||||
|
||||
if ($source == 'conferencesubscription') {
|
||||
// Finding the Attendee
|
||||
$attendeeid = GETPOST('ref');
|
||||
$attendee = new ConferenceOrBoothAttendee($db);
|
||||
$resultattendee = $attendee->fetch($attendeeid);
|
||||
if ($resultattendee <= 0) {
|
||||
setEventMessages(null, $attendee->errors, "errors");
|
||||
$invoiceid = GETPOST('ref');
|
||||
$invoice = new Facture($db);
|
||||
$resultinvoice = $invoice->fetch($invoiceid);
|
||||
if ($resultinvoice <= 0) {
|
||||
setEventMessages(null, $invoice->errors, "errors");
|
||||
} else {
|
||||
|
||||
$attendee->fetchObjectLinked();
|
||||
$linkedInvoices = $attendee->linkedObjectsIds['facture'];
|
||||
$invoice->fetchObjectLinked();
|
||||
$linkedAttendees = $invoice->linkedObjectsIds['conferenceorboothattendee'];
|
||||
|
||||
if (is_array($linkedInvoices)) {
|
||||
$linkedInvoices = array_values($linkedInvoices);
|
||||
if (is_array($linkedAttendees)) {
|
||||
$linkedAttendees = array_values($linkedAttendees);
|
||||
|
||||
$invoice = new Facture($db);
|
||||
$resultinvoice = $invoice->fetch($linkedInvoices[0]);
|
||||
if ($resultinvoice <= 0) {
|
||||
setEventMessages(null, $invoice->errors, "errors");
|
||||
$attendee = new ConferenceOrBoothAttendee($db);
|
||||
$resultattendee = $attendee->fetch($linkedAttendees[0]);
|
||||
if ($resultattendee <= 0) {
|
||||
setEventMessages(null, $attendee->errors, "errors");
|
||||
} else {
|
||||
$amount = price2num($invoice->total_ttc);
|
||||
// Finding the associated thirdparty
|
||||
@ -1809,7 +1809,7 @@ if ($source == 'conferencesubscription') {
|
||||
print '<tr class="CTableRow'.($var ? '1' : '2').'"><td class="CTableRow'.($var ? '1' : '2').'">'.$langs->trans("Designation");
|
||||
print '</td><td class="CTableRow'.($var ? '1' : '2').'">'.$text;
|
||||
print '<input type="hidden" name="source" value="'.dol_escape_htmltag($source).'">';
|
||||
print '<input type="hidden" name="ref" value="'.dol_escape_htmltag($attendee->id).'">';
|
||||
print '<input type="hidden" name="ref" value="'.dol_escape_htmltag($invoice->id).'">';
|
||||
print '</td></tr>'."\n";
|
||||
|
||||
// Amount
|
||||
|
||||
@ -784,7 +784,7 @@ if ($ispaymentok) {
|
||||
// Record payment
|
||||
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
$object = new Facture($db);
|
||||
$result = $object->fetch($tmptag['ATT']);
|
||||
$result = $object->fetch($ref);
|
||||
if ($result) {
|
||||
$FinalPaymentAmt = $_SESSION["FinalPaymentAmt"];
|
||||
|
||||
@ -810,6 +810,14 @@ if ($ispaymentok) {
|
||||
|
||||
// Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time)
|
||||
if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
|
||||
$resultvalidate = $object->validate($user);
|
||||
if ($resultvalidate < 0) {
|
||||
$postactionmessages[] = 'Cannot validate invoice';
|
||||
$ispostactionok = -1;
|
||||
$error++; // Not yet supported
|
||||
} else {
|
||||
|
||||
}
|
||||
$db->begin();
|
||||
|
||||
// Creation of payment line
|
||||
@ -879,7 +887,7 @@ if ($ispaymentok) {
|
||||
|
||||
// Validating the attendee
|
||||
$attendeetovalidate = new ConferenceOrBoothAttendee($db);
|
||||
$resultattendee = $attendeetovalidate->fetch($ref);
|
||||
$resultattendee = $attendeetovalidate->fetch($tmptag['ATT']);
|
||||
if ($resultattendee < 0) {
|
||||
setEventMessages(null, $attendeetovalidate->errors, "errors");
|
||||
} else {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user