From e81637b60811babd93e5b8e2d1ba2ce598c821d9 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Wed, 21 Apr 2021 16:37:02 +0200 Subject: [PATCH] wip on getting the existing attendee --- htdocs/langs/en_US/eventorganization.lang | 3 +- .../attendee_subscription.php | 32 ++++++++++++------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 863cec82164..6ef39e81ff6 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -105,8 +105,7 @@ ViewAndVote = View and vote for suggested events PublicAttendeeSubscriptionPage = Public link of registration to a conference MissingOrBadSecureKey = The security key is invalid or missing EvntOrgWelcomeMessage = This form allows you to register as a new participant to the conference -EvntOrgStartDuration = This conference starts on -EvntOrgEndDuration = and ends on +EvntOrgDuration = This conference starts on %s and ends on %s ConferenceAttendeeFee = Conference attendee fee for the event : '%s' occurring from %s to %s # # SubscriptionOk page diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 91bc2da646b..2bacd3a1951 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -284,14 +284,24 @@ if (empty($reshook) && $action == 'add') { } else { // creation of an attendee $confattendee = new ConferenceOrBoothAttendee($db); - $confattendee->fk_soc = $thirdparty->id; - $confattendee->date_subscription = dol_now(); - $confattendee->email = GETPOST("email"); - $confattendee->fk_actioncomm = $id; - $resultconfattendee = $confattendee->create($user); - if ($resultconfattendee < 0) { - $error++; - $errmsg .= $confattendee->error; + $resultfetchattendee = $confattendee->fetchAll('','', 1, 0, array('t.fk_soc'=>$thirdparty->id, 't.fk_actioncomm'=>$id)); + if ($resultfetchattendee == 0 || count($resultfetchattendee) == 0) { + // Need to create an attendee + $confattendee->fk_soc = $thirdparty->id; + $confattendee->date_subscription = dol_now(); + $confattendee->email = GETPOST("email"); + $confattendee->fk_actioncomm = $id; + $resultconfattendee = $confattendee->create($user); + if ($resultconfattendee < 0) { + $error++; + $errmsg .= $confattendee->error; + } + print 'created attendee'; + } else { + // Found an attendee + print 'found attendee'; + var_dump($resultfetchattendee); + $confattendee = $resultfetchattendee[0]; } } } @@ -312,6 +322,7 @@ if (empty($reshook) && $action == 'add') { $facture->paye = 0; $facture->date = dol_now(); $facture->cond_reglement_id = $confattendee->cond_reglement_id; + if (empty($facture->cond_reglement_id)) { $paymenttermstatic = new PaymentTerm($confattendee->db); $facture->cond_reglement_id = $paymenttermstatic->getDefaultId(); @@ -437,10 +448,7 @@ print '
'; // Welcome message print $langs->trans("EvntOrgWelcomeMessage"); print $id.".".'
'; -print $langs->trans("EvntOrgStartDuration"); -print dol_print_date($conference->datep).' '; -print $langs->trans("EvntOrgEndDuration"); -print ' '.dol_print_date($conference->datef)."."; +print $langs->trans("EvntOrgDuration", dol_print_date($conference->datep), dol_print_date($conference->datef)); print '
'; dol_htmloutput_errors($errmsg);