NEW Can set the max number of attendees for an organized event

This commit is contained in:
Laurent Destailleur 2022-05-04 01:53:45 +02:00
parent f1e429d333
commit d76e7224d9
4 changed files with 35 additions and 18 deletions

View File

@ -234,7 +234,7 @@ class Form
if (preg_match('/^(string|safehtmlstring|email)/', $typeofdata)) {
$tmp = explode(':', $typeofdata);
$ret .= '<input type="text" id="'.$htmlname.'" name="'.$htmlname.'" value="'.($editvalue ? $editvalue : $value).'"'.($tmp[1] ? ' size="'.$tmp[1].'"' : '').' autofocus>';
} elseif (preg_match('/^(numeric|amount)/', $typeofdata)) {
} elseif (preg_match('/^(numeric|amount|integer)/', $typeofdata)) {
$tmp = explode(':', $typeofdata);
$valuetoshow = price2num($editvalue ? $editvalue : $value);
$ret .= '<input type="text" id="'.$htmlname.'" name="'.$htmlname.'" value="'.($valuetoshow != '' ? price($valuetoshow) : '').'"'.($tmp[1] ? ' size="'.$tmp[1].'"' : '').' autofocus>';

View File

@ -375,46 +375,52 @@ if ($projectid > 0) {
print '<table class="border tableforfield centpercent">';
// Description
print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
print '<tr><td class="titlefield tdtop">'.$langs->trans("Description").'</td><td class="valuefield">';
print nl2br($project->description);
print '</td></tr>';
// Categories
if ($conf->categorie->enabled) {
print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
print '<tr><td class="titlefield valignmiddle">'.$langs->trans("Categories").'</td><td class="valuefield">';
print $form->showCategories($project->id, Categorie::TYPE_PROJECT, 1);
print "</td></tr>";
}
print '<tr><td>';
print '<tr><td class="titlefield">';
$typeofdata = 'checkbox:'.($project->accept_conference_suggestions ? ' checked="checked"' : '');
$htmltext = $langs->trans("AllowUnknownPeopleSuggestConfHelp");
print $form->editfieldkey('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '', $project, $permissiontoadd, $typeofdata, '', 0, 0, 'projectid', $htmltext);
print '</td><td>';
print '</td><td class="valuefield">';
print $form->editfieldval('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '1', $project, $permissiontoadd, $typeofdata, '', 0, 0, '', 0, '', 'projectid');
print "</td></tr>";
print '<tr><td>';
print '<tr><td class="titlefield">';
$typeofdata = 'checkbox:'.($project->accept_booth_suggestions ? ' checked="checked"' : '');
$htmltext = $langs->trans("AllowUnknownPeopleSuggestBoothHelp");
print $form->editfieldkey('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '', $project, $permissiontoadd, $typeofdata, '', 0, 0, 'projectid', $htmltext);
print '</td><td>';
print '</td><td class="valuefield">';
print $form->editfieldval('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '1', $project, $permissiontoadd, $typeofdata, '', 0, 0, '', 0, '', 'projectid');
print "</td></tr>";
print '<tr><td>';
print '<tr><td class="titlefield">';
print $form->editfieldkey($form->textwithpicto($langs->trans('PriceOfBooth'), $langs->trans("PriceOfBoothHelp")), 'price_booth', '', $project, $permissiontoadd, 'amount', '', 0, 0, 'projectid');
print '</td><td>';
print '</td><td class="valuefield">';
print $form->editfieldval($form->textwithpicto($langs->trans('PriceOfBooth'), $langs->trans("PriceOfBoothHelp")), 'price_booth', $project->price_booth, $project, $permissiontoadd, 'amount', '', 0, 0, '', 0, '', 'projectid');
print "</td></tr>";
print '<tr><td>';
print '<tr><td class="titlefield">';
print $form->editfieldkey($form->textwithpicto($langs->trans('PriceOfRegistration'), $langs->trans("PriceOfRegistrationHelp")), 'price_registration', '', $project, $permissiontoadd, 'amount', '', 0, 0, 'projectid');
print '</td><td>';
print '</td><td class="valuefield">';
print $form->editfieldval($form->textwithpicto($langs->trans('PriceOfRegistration'), $langs->trans("PriceOfRegistrationHelp")), 'price_registration', $project->price_registration, $project, $permissiontoadd, 'amount', '', 0, 0, '', 0, '', 'projectid');
print "</td></tr>";
print '<tr><td valign="middle">'.$langs->trans("EventOrganizationICSLink").'</td><td>';
print '<tr><td class="titlefield">';
print $form->editfieldkey($form->textwithpicto($langs->trans('MaxNbOfAttendees'), ''), 'max_attendees', '', $project, $permissiontoadd, 'integer:3', '', 0, 0, 'projectid');
print '</td><td class="valuefield">';
print $form->editfieldval($form->textwithpicto($langs->trans('MaxNbOfAttendees'), ''), 'max_attendees', $project->max_attendees, $project, $permissiontoadd, 'integer:3', '', 0, 0, '', 0, '', 'projectid');
print "</td></tr>";
print '<tr><td class="titlefield valignmiddle">'.$langs->trans("EventOrganizationICSLink").'</td><td class="valuefield">';
// Define $urlwithroot
$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
@ -427,11 +433,11 @@ if ($projectid > 0) {
print "</td></tr>";
// Link to the submit vote/register page
print '<tr><td>';
print '<tr><td class="titlefield">';
//print '<span class="opacitymedium">';
print $form->textwithpicto($langs->trans("SuggestOrVoteForConfOrBooth"), $langs->trans("EvntOrgRegistrationHelpMessage"));
//print '</span>';
print '</td><td>';
print '</td><td class="valuefield">';
$linksuggest = $dolibarr_main_url_root.'/public/project/index.php?id='.((int) $project->id);
$encodedsecurekey = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY').'conferenceorbooth'.((int) $project->id), 'md5');
$linksuggest .= '&securekey='.urlencode($encodedsecurekey);
@ -444,11 +450,11 @@ if ($projectid > 0) {
print '</td></tr>';
// Link to the subscribe
print '<tr><td>';
print '<tr><td class="titlefield">';
//print '<span class="opacitymedium">';
print $langs->trans("PublicAttendeeSubscriptionGlobalPage");
//print '</span>';
print '</td><td>';
print '</td><td class="valuefield">';
$link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_new.php?id='.((int) $project->id).'&type=global';
$encodedsecurekey = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY').'conferenceorbooth'.((int) $project->id), 'md5');
$link_subscription .= '&securekey='.urlencode($encodedsecurekey);

View File

@ -165,4 +165,5 @@ EmailAttendee=Attendee email
EmailCompanyForInvoice=Company email (for invoice, if different of attendee email)
ErrorSeveralCompaniesWithEmailContactUs=Several companies with this email has been found so we can't validate automaticaly your registration. Please contact us at %s for a manual validation
ErrorSeveralCompaniesWithNameContactUs=Several companies with this name has been found so we can't validate automaticaly your registration. Please contact us at %s for a manual validation
NoPublicActionsAllowedForThisEvent=No public actions are open to public for this event
NoPublicActionsAllowedForThisEvent=No public actions are open to public for this event
MaxNbOfAttendees=Max number of attendees

View File

@ -150,6 +150,11 @@ class Project extends CommonObject
*/
public $price_booth;
/**
* @var float Max attendees
*/
public $max_attendees;
public $statuts_short;
public $statuts_long;
@ -248,6 +253,7 @@ class Project extends CommonObject
'accept_booth_suggestions' =>array('type'=>'integer', 'label'=>'AllowUnknownPeopleSuggestBooth', 'enabled'=>1, 'visible'=>-1, 'position'=>147),
'price_registration' =>array('type'=>'double(24,8)', 'label'=>'PriceOfRegistration', 'enabled'=>1, 'visible'=>-1, 'position'=>148),
'price_booth' =>array('type'=>'double(24,8)', 'label'=>'PriceOfBooth', 'enabled'=>1, 'visible'=>-1, 'position'=>149),
'max_attendees' =>array('type'=>'integer', 'label'=>'MaxNbOfAttendees', 'enabled'=>1, 'visible'=>-1, 'position'=>150),
'datec' =>array('type'=>'datetime', 'label'=>'DateCreationShort', 'enabled'=>1, 'visible'=>-2, 'position'=>200),
'tms' =>array('type'=>'timestamp', 'label'=>'DateModificationShort', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>205),
'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserCreation', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>210),
@ -372,6 +378,7 @@ class Project extends CommonObject
$sql .= ", accept_booth_suggestions";
$sql .= ", price_registration";
$sql .= ", price_booth";
$sql .= ", max_attendees";
$sql .= ", email_msgid";
$sql .= ", note_private";
$sql .= ", note_public";
@ -399,6 +406,7 @@ class Project extends CommonObject
$sql .= ", ".($this->accept_booth_suggestions ? 1 : 0);
$sql .= ", ".(strcmp($this->price_registration, '') ? price2num($this->price_registration) : 'null');
$sql .= ", ".(strcmp($this->price_booth, '') ? price2num($this->price_booth) : 'null');
$sql .= ", ".(strcmp($this->max_attendees, '') ? ((int) $this->max_attendees) : 'null');
$sql .= ", ".($this->email_msgid ? "'".$this->db->escape($this->email_msgid)."'" : 'null');
$sql .= ", ".($this->note_private ? "'".$this->db->escape($this->note_private)."'" : 'null');
$sql .= ", ".($this->note_public ? "'".$this->db->escape($this->note_public)."'" : 'null');
@ -509,6 +517,7 @@ class Project extends CommonObject
$sql .= ", accept_booth_suggestions = ".($this->accept_booth_suggestions ? 1 : 0);
$sql .= ", price_registration = ".(strcmp($this->price_registration, '') ? price2num($this->price_registration) : "null");
$sql .= ", price_booth = ".(strcmp($this->price_booth, '') ? price2num($this->price_booth) : "null");
$sql .= ", max_attendees = ".(strcmp($this->max_attendees, '') ? price2num($this->max_attendees) : "null");
$sql .= ", entity = ".((int) $this->entity);
$sql .= " WHERE rowid = ".((int) $this->id);
@ -595,7 +604,7 @@ class Project extends CommonObject
$sql = "SELECT rowid, entity, ref, title, description, public, datec, opp_amount, budget_amount,";
$sql .= " tms, dateo, datee, date_close, fk_soc, fk_user_creat, fk_user_modif, fk_user_close, fk_statut as status, fk_opp_status, opp_percent,";
$sql .= " note_private, note_public, model_pdf, usage_opportunity, usage_task, usage_bill_time, usage_organize_event, email_msgid,";
$sql .= " accept_conference_suggestions, accept_booth_suggestions, price_registration, price_booth";
$sql .= " accept_conference_suggestions, accept_booth_suggestions, price_registration, price_booth, max_attendees";
$sql .= " FROM ".MAIN_DB_PREFIX."projet";
if (!empty($id)) {
$sql .= " WHERE rowid = ".((int) $id);
@ -653,6 +662,7 @@ class Project extends CommonObject
$this->accept_booth_suggestions = (int) $obj->accept_booth_suggestions;
$this->price_registration = $obj->price_registration;
$this->price_booth = $obj->price_booth;
$this->max_attendees = $obj->max_attendees;
$this->email_msgid = $obj->email_msgid;
$this->db->free($resql);