' . "\n";
- include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
+ include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php';
- // Other attributes. Fields from hook formObjectOptions and Extrafields.
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
- $object=$object_evt;
- print '
';
- print '
';
- print '
';
+ // Other attributes. Fields from hook formObjectOptions and Extrafields.
+ include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
+ $object = $object_evt;
+ print '
';
+ print '
';
+ print '
';
- print '';
+ print '';
- print dol_get_fiche_end();
+ print dol_get_fiche_end();
+ }
}
$arrayofselected = is_array($toselect) ? $toselect : array();
@@ -612,7 +669,7 @@ print '';
print '';
print '';
-$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_card.php?action=create'.(!empty($confOrBooth->id)?'&conforboothid='.$confOrBooth->id:'').$withProjectUrl.'&backtopage='.urlencode($_SERVER['PHP_SELF'].(!empty($confOrBooth->id)?'?conforboothid='.$confOrBooth->id:'').$withProjectUrl), '', $permissiontoadd);
+$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_card.php?action=create'.(!empty($confOrBooth->id)?'&conforboothid='.$confOrBooth->id:'').(!empty($projectstatic->id)?'&fk_project='.$projectstatic->id:'').$withProjectUrl.'&backtopage='.urlencode($_SERVER['PHP_SELF'].(!empty($confOrBooth->id)?'?conforboothid='.$confOrBooth->id:'').$withProjectUrl), '', $permissiontoadd);
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
diff --git a/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php b/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php
index 7d6339a2ed0..fcdd3c296e1 100644
--- a/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php
+++ b/htdocs/eventorganization/lib/eventorganization_conferenceorbooth.lib.php
@@ -106,6 +106,80 @@ function conferenceorboothPrepareHead($object, $with_project = 0)
return $head;
}
+/**
+ * Prepare array of tabs for ConferenceOrBooth Project tab
+ *
+ * @param $object Project Project
+ * @return array
+ */
+function conferenceorboothProjectPrepareHead($object)
+{
+
+ global $db, $langs, $conf;
+
+ $langs->load("eventorganization");
+
+ $h = 0;
+ $head = array();
+
+ $head[$h][0] = dol_buildpath("/eventorganization/conferenceorbooth_list.php", 1).'?projectid='.$object->id;
+ $head[$h][1] = $langs->trans("ConferenceOrBooth");
+ $head[$h][2] = 'conferenceorbooth';
+ // Enable caching of conf or booth count attendees
+ $nbAttendees = 0;
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
+ $cachekey = 'count_conferenceorbooth_project_'.$object->id;
+ $dataretrieved = dol_getcache($cachekey);
+ if (!is_null($dataretrieved)) {
+ $nbAttendees = $dataretrieved;
+ } else {
+ require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php';
+ $conforbooth=new ConferenceOrBooth($db);
+ $result = $conforbooth->fetchAll('', '', 0, 0, array('t.fk_project'=>$object->id));
+ if (!is_array($result) && $result<0) {
+ setEventMessages($conforbooth->error, $conforbooth->errors, 'errors');
+ } else {
+ $nbConferenceOrBooth = count($result);
+ }
+ dol_setcache($cachekey, $nbConferenceOrBooth, 120); // If setting cache fails, this is not a problem, so we do not test result.
+ }
+ if ($nbConferenceOrBooth > 0) {
+ $head[$h][1] .= ''.$nbConferenceOrBooth.'';
+ }
+ $h++;
+
+ $head[$h][0] = dol_buildpath("/eventorganization/conferenceorboothattendee_list.php", 1).'?fk_project='.$object->id.'&withproject=1';
+ $head[$h][1] = $langs->trans("Attendees");
+ $head[$h][2] = 'attendees';
+ // Enable caching of conf or booth count attendees
+ $nbAttendees = 0;
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
+ $cachekey = 'count_attendees_conferenceorbooth_project_'.$object->id;
+ $dataretrieved = dol_getcache($cachekey);
+ if (!is_null($dataretrieved)) {
+ $nbAttendees = $dataretrieved;
+ } else {
+ require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php';
+ $attendees=new ConferenceOrBoothAttendee($db);
+ $result = $attendees->fetchAll('', '', 0, 0, array('t.fk_project'=>$object->id));
+ if (!is_array($result) && $result<0) {
+ setEventMessages($attendees->error, $attendees->errors, 'errors');
+ } else {
+ $nbAttendees = count($result);
+ }
+ dol_setcache($cachekey, $nbAttendees, 120); // If setting cache fails, this is not a problem, so we do not test result.
+ }
+ if ($nbAttendees > 0) {
+ $head[$h][1] .= ''.$nbAttendees.'';
+ }
+
+ complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorboothproject@eventorganization');
+
+ complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorboothproject@eventorganization', 'remove');
+
+ return $head;
+}
+
/**
* Prepare array of tabs for ConferenceOrBoothAttendees
diff --git a/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.key.sql b/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.key.sql
index 3b9cc52e68f..0633e3cc2a2 100644
--- a/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.key.sql
+++ b/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.key.sql
@@ -21,10 +21,12 @@ ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_evento
ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT fx_eventorganization_conferenceorboothattendee_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe(rowid);
ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_fk_actioncomm (fk_actioncomm);
ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT fx_eventorganization_conferenceorboothattendee_fk_actioncomm FOREIGN KEY (fk_actioncomm) REFERENCES llx_actioncomm(id);
+ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_fk_project (fk_project);
+ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD CONSTRAINT fx_eventorganization_conferenceorboothattendee_fk_project FOREIGN KEY (fk_project) REFERENCES llx_projet(rowid);
ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_email (email);
ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD INDEX idx_eventorganization_conferenceorboothattendee_status (status);
-- END MODULEBUILDER INDEXES
-ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD UNIQUE INDEX uk_eventorganization_conferenceorboothattendee(fk_soc, fk_actioncomm, email);
+ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD UNIQUE INDEX uk_eventorganization_conferenceorboothattendee(fk_soc, fk_project, fk_actioncomm, email);
diff --git a/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.sql b/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.sql
index 026295627d0..6d01cf4bba1 100644
--- a/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.sql
+++ b/htdocs/install/mysql/tables/llx_eventorganization_conferenceorboothattendee.sql
@@ -19,7 +19,8 @@ CREATE TABLE llx_eventorganization_conferenceorboothattendee(
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
ref varchar(128) NOT NULL,
fk_soc integer,
- fk_actioncomm integer NOT NULL,
+ fk_actioncomm integer,
+ fk_project integer NOT NULL,
email varchar(100),
date_subscription datetime,
amount double DEFAULT NULL,
diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang
index d2840be73f2..7c07b853a6b 100644
--- a/htdocs/langs/en_US/eventorganization.lang
+++ b/htdocs/langs/en_US/eventorganization.lang
@@ -110,7 +110,8 @@ ListOfConferencesOrBooths=List of conferences or booths
SuggestConference = Suggest a new conference
SuggestBooth = Suggest a booth
ViewAndVote = View and vote for suggested events
-PublicAttendeeSubscriptionPage = Public link for registration to the event
+PublicAttendeeSubscriptionGlobalPage = Public link for registration to the event
+PublicAttendeeSubscriptionPage = Public link for registration to this event only
MissingOrBadSecureKey = The security key is invalid or missing
EvntOrgWelcomeMessage = This form allows you to register as a new participant to the conference : '%s'
EvntOrgDuration = This conference starts on %s and ends on %s.
diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php
index 0387843cf94..506b7215211 100644
--- a/htdocs/public/eventorganization/attendee_subscription.php
+++ b/htdocs/public/eventorganization/attendee_subscription.php
@@ -80,20 +80,35 @@ $societe = GETPOST("societe");
// Getting id from Post and decoding it
$id = GETPOST('id', 'int');
+$type = GETPOST('type', 'alpha');
$conference = new ConferenceOrBooth($db);
-$resultconf = $conference->fetch($id);
-if ($resultconf < 0) {
- print 'Bad value for parameter id';
- exit;
+$project = new Project($db);
+
+if ($type=='conf') {
+ $resultconf = $conference->fetch($id);
+ if ($resultconf < 0) {
+ print 'Bad value for parameter id';
+ exit;
+ }
+ $resultproject = $project->fetch($conference->fk_project);
+ if ($resultproject < 0) {
+ $error++;
+ $errmsg .= $project->error;
+ }
+}
+if ($type=='global') {
+ $project = new Project($db);
+ if (empty($id)) {
+ $id = GETPOST('fk_project', 'int');
+ }
+ $resultproject = $project->fetch($id);
+ if ($resultproject < 0) {
+ $error++;
+ $errmsg .= $project->error;
+ }
}
-$project = new Project($db);
-$resultproject = $project->fetch($conference->fk_project);
-if ($resultproject < 0) {
- $error++;
- $errmsg .= $project->error;
-}
// Security check
@@ -206,7 +221,7 @@ if ($reshook < 0) {
}
// Action called when page is submitted
-if (empty($reshook) && $action == 'add' && $conference->status == 2) {
+if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conference->status!=2 || !empty($project->id) && $project->status==Project::STATUS_VALIDATED)) {
$error = 0;
$urlback = '';
@@ -235,7 +250,15 @@ if (empty($reshook) && $action == 'add' && $conference->status == 2) {
if (!$error) {
// Check if attendee already exists (by email and for this event)
$confattendee = new ConferenceOrBoothAttendee($db);
- $resultfetchconfattendee = $confattendee->fetchAll('', '', 0, 0, array('t.fk_actioncomm'=>$id, 'customsql'=>'t.email="'.$email.'"'));
+
+ if ($type=='global') {
+ $filter = array('t.fk_project'=>$id, 'customsql'=>'t.email="'.$email.'"');
+ }
+ if ($action='conf') {
+ $filter = array('t.fk_actioncomm'=>$id, 'customsql'=>'t.email="'.$email.'"');
+ }
+
+ $resultfetchconfattendee = $confattendee->fetchAll('', '', 0, 0, $filter);
if ($resultfetchconfattendee > 0 && count($resultfetchconfattendee)>0) {
// Found confattendee
$confattendee = array_shift($resultfetchconfattendee);
@@ -243,6 +266,7 @@ if (empty($reshook) && $action == 'add' && $conference->status == 2) {
// Need to create a confattendee
$confattendee->date_subscription = dol_now();
$confattendee->email = $email;
+ $confattendee->fk_project = $project->id;
$confattendee->fk_actioncomm = $id;
$resultconfattendee = $confattendee->create($user);
if ($resultconfattendee < 0) {
@@ -470,16 +494,21 @@ print '