From 71c0f08b6c56b575e7195bc118c460329ec6a20a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 May 2022 19:47:06 +0200 Subject: [PATCH] Debug v16 --- .../public/eventorganization/attendee_new.php | 240 ++++++++++-------- 1 file changed, 132 insertions(+), 108 deletions(-) diff --git a/htdocs/public/eventorganization/attendee_new.php b/htdocs/public/eventorganization/attendee_new.php index 70bad2a31dc..40e082c6f2e 100644 --- a/htdocs/public/eventorganization/attendee_new.php +++ b/htdocs/public/eventorganization/attendee_new.php @@ -92,15 +92,27 @@ if ($type == 'conf') { $errmsg .= $project->error; } } + +$currentnbofattendees = 0; if ($type == 'global') { $resultproject = $project->fetch($id); if ($resultproject < 0) { $error++; $errmsg .= $project->error; + } else { + $sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."projet"; + $sql .= " WHERE ".MAIN_DB_PREFIX."eventorganization_conferenceorboothattendee = ".((int) $project->id); + + $resql = $db->query($resql); + if ($resql) { + $obj = $db->fetch_object($resql); + if ($obj) { + $currentnbofattendees = $obj->nb; + } + } } } - // Security check $securekeyreceived = GETPOST('securekey', 'alpha'); $securekeytocompare = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 'md5'); @@ -628,6 +640,7 @@ print '
'; print $langs->trans("EvntOrgWelcomeMessage", $project->title . ' '. $conference->label); print '
'; +$maxattendees = 0; if ($conference->id) { print $langs->trans("Date").': '; print dol_print_date($conference->datep); @@ -642,138 +655,149 @@ if ($conference->id) { print ' - '; print dol_print_date($project->date_end); } + $maxattendees = $project->max_attendees; } print '
'; +if ($maxattendees && $currentnbofattendees >= $maxattendees) { + print '
'; + print '
'.$langs->trans("MaxNbOfAttendeesReached").'
'; + print '
'; +} + + print '
'; dol_htmloutput_errors($errmsg); -if (!empty($conference->id) && $conference->status==ConferenceOrBooth::STATUS_CONFIRMED || (!empty($project->id) && $project->status==Project::STATUS_VALIDATED)) { - // Print form - print '
' . "\n"; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; +if ((!empty($conference->id) && $conference->status == ConferenceOrBooth::STATUS_CONFIRMED) || (!empty($project->id) && $project->status == Project::STATUS_VALIDATED)) { + if (empty($maxattendees) || $currentnbofattendees < $maxattendees) { + // Print form + print '' . "\n"; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - print '
'; + print '
'; - print '
' . $langs->trans("FieldsWithAreMandatory", '*') . '
'; - //print $langs->trans("FieldsWithIsForPublic",'**').'
'; + print '
' . $langs->trans("FieldsWithAreMandatory", '*') . '
'; + //print $langs->trans("FieldsWithIsForPublic",'**').'
'; - print dol_get_fiche_head(''); + print dol_get_fiche_head(''); - print ''; + '; - print '' . "\n"; + print '
' . "\n"; - // Email - print '' . "\n"; - - // Company - print '' . "\n"; - - // Email company for invoice - if ($project->price_registration) { - print '' . "\n"; - } + print '' . "\n"; - // Address - print '' . "\n"; + // Company + print '' . "\n"; - // Zip / Town - print ''; + // Email company for invoice + if ($project->price_registration) { + print '' . "\n"; + } - // Country - print '' . "\n"; + + // Zip / Town + print ''; + + // Country + print ''; - // State - if (empty($conf->global->SOCIETE_DISABLE_STATE)) { - print ''; + // State + if (empty($conf->global->SOCIETE_DISABLE_STATE)) { + print ''; } + + if ($project->price_registration) { + print ''; + } + + $notetoshow = $note_public; + print ''; + + print "
' . $langs->trans("EmailAttendee") . '*'; - print img_picto('', 'email', 'class="pictofixedwidth"'); - print '
' . $langs->trans("Company"); - if (!empty(floatval($project->price_registration))) { - print '*'; - } - print ' '; - print img_picto('', 'company', 'class="pictofixedwidth"'); - print '
' . $langs->trans("EmailCompanyForInvoice") . ''; + // Email + print '
' . $langs->trans("EmailAttendee") . '*'; print img_picto('', 'email', 'class="pictofixedwidth"'); - print '
' . $langs->trans("Address") . '' . "\n"; - print '
' . $langs->trans("Company"); + if (!empty(floatval($project->price_registration))) { + print '*'; + } + print ' '; + print img_picto('', 'company', 'class="pictofixedwidth"'); + print '
' . $langs->trans('Zip') . ' / ' . $langs->trans('Town') . ''; - print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6, 1); - print ' / '; - print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 1); - print '
' . $langs->trans("EmailCompanyForInvoice") . ''; + print img_picto('', 'email', 'class="pictofixedwidth"'); + print '
' . $langs->trans('Country') . '*'; - print img_picto('', 'country', 'class="pictofixedwidth"'); - $country_id = GETPOST('country_id'); - if (!$country_id && !empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) { - $country_id = getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs); - } - if (!$country_id && !empty($conf->geoipmaxmind->enabled)) { - $country_code = dol_user_country(); - //print $country_code; - if ($country_code) { - $new_country_id = getCountry($country_code, 3, $db, $langs); - //print 'xxx'.$country_code.' - '.$new_country_id; - if ($new_country_id) { - $country_id = $new_country_id; + // Address + print '
' . $langs->trans("Address") . '' . "\n"; + print '
' . $langs->trans('Zip') . ' / ' . $langs->trans('Town') . ''; + print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6, 1); + print ' / '; + print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 1); + print '
' . $langs->trans('Country') . '*'; + print img_picto('', 'country', 'class="pictofixedwidth"'); + $country_id = GETPOST('country_id'); + if (!$country_id && !empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) { + $country_id = getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs); + } + if (!$country_id && !empty($conf->geoipmaxmind->enabled)) { + $country_code = dol_user_country(); + //print $country_code; + if ($country_code) { + $new_country_id = getCountry($country_code, 3, $db, $langs); + //print 'xxx'.$country_code.' - '.$new_country_id; + if ($new_country_id) { + $country_id = $new_country_id; + } } } - } - $country_code = getCountry($country_id, 2, $db, $langs); - print $form->select_country($country_id, 'country_id'); - print '
' . $langs->trans('State') . ''; - if ($country_code) { - print $formcompany->select_state(GETPOST("state_id"), $country_code); - } else { - print ''; + $country_code = getCountry($country_id, 2, $db, $langs); + print $form->select_country($country_id, 'country_id', '', 0, 'minwidth200 widthcentpercentminusx maxwidth300'); + print '
' . $langs->trans('State') . ''; + if ($country_code) { + print img_picto('', 'state', 'class="pictofixedwidth"'); + print $formcompany->select_state(GETPOST("state_id"), $country_code); + } else { + print ''; + } + print '
' . $langs->trans('Price') . ''; + print price($project->price_registration, 1, $langs, 1, -1, -1, $conf->currency); + print '
' . $langs->trans('Note') . ''; + if (!empty($conf->global->EVENTORGANIZATION_DEFAULT_NOTE_ON_REGISTRATION)) { + $notetoshow = str_replace('\n', "\n", $conf->global->EVENTORGANIZATION_DEFAULT_NOTE_ON_REGISTRATION); + } + print ''; print '
\n"; + + print dol_get_fiche_end(); + + // Save + print '
'; + print ''; + if (!empty($backtopage)) { + print '     '; + } + print '
'; + + + print "
\n"; + print "
"; + print ''; } - - if ($project->price_registration) { - print '' . $langs->trans('Price') . ''; - print price($project->price_registration, 1, $langs, 1, -1, -1, $conf->currency); - print ''; - } - - $notetoshow = $note_public; - print '' . $langs->trans('Note') . ''; - if (!empty($conf->global->EVENTORGANIZATION_DEFAULT_NOTE_ON_REGISTRATION)) { - $notetoshow = str_replace('\n', "\n", $conf->global->EVENTORGANIZATION_DEFAULT_NOTE_ON_REGISTRATION); - } - print ''; - print ''; - - print "\n"; - - print dol_get_fiche_end(); - - // Save - print '
'; - print ''; - if (!empty($backtopage)) { - print '     '; - } - print '
'; - - - print "\n"; - print "
"; - print ''; } else { print $langs->trans("ConferenceIsNotConfirmed"); }