2
0
forked from Wavyzz/dolibarr

work on event

This commit is contained in:
Florian HENRY
2021-09-03 15:40:33 +02:00
parent bb6dda087c
commit 96f9f8ae98
10 changed files with 228 additions and 53 deletions

View File

@@ -246,7 +246,7 @@ class ConferenceOrBooth extends ActionComm
$result = parent::fetch($id, $ref, $ref_ext, $email_msgid);
$link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_subscription.php?id='.urlencode($id);
$link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_subscription.php?id='.urlencode($id).'&type=conf';
$encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2);
$link_subscription .= '&securekey='.urlencode($encodedsecurekey);

View File

@@ -103,7 +103,8 @@ class ConferenceOrBoothAttendee extends CommonObject
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>2, 'index'=>1, 'comment'=>"Reference of object"),
'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'Attendee', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"LinkToThirparty",),
'fk_actioncomm' => array('type'=>'integer:ActionComm:comm/action/class/actioncomm.class.php:1', 'label'=>'ConferenceOrBooth', 'enabled'=>'1', 'position'=>53, 'notnull'=>1, 'visible'=>0, 'index'=>1,),
'fk_actioncomm' => array('type'=>'integer:ActionComm:comm/action/class/actioncomm.class.php:1', 'label'=>'ConferenceOrBooth', 'enabled'=>'1', 'position'=>53, 'notnull'=>0, 'visible'=>0, 'index'=>1,),
'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>'1', 'position'=>54, 'notnull'=>1, 'visible'=>0, 'index'=>1,),
'email' => array('type'=>'mail', 'label'=>'Email', 'enabled'=>'1', 'position'=>55, 'notnull'=>1, 'visible'=>1, 'index'=>1,),
'date_subscription' => array('type'=>'datetime', 'label'=>'DateSubscription', 'enabled'=>'1', 'position'=>56, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'1',),
'amount' => array('type'=>'price', 'label'=>'AmountOfSubscriptionPaid', 'enabled'=>'1', 'position'=>57, 'notnull'=>0, 'visible'=>1, 'default'=>'null', 'isameasure'=>'1', 'help'=>"AmountOfSubscriptionPaid",),
@@ -403,7 +404,7 @@ class ConferenceOrBoothAttendee extends CommonObject
$sql = 'SELECT ';
$sql .= $this->getFieldList('t');
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as a on a.id=t.fk_actioncomm";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm as a on a.id=t.fk_actioncomm";
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
$sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')';
} else {

View File

@@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php';
require_once DOL_DOCUMENT_ROOT.'/eventorganization/lib/eventorganization_conferenceorbooth.lib.php';
if ($conf->categorie->enabled) {
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
}
@@ -266,7 +267,7 @@ if ($projectid > 0) {
//print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
$head = project_prepare_head($project);
print dol_get_fiche_head($head, 'eventorganisation', $langs->trans("Project"), -1, ($project->public ? 'projectpub' : 'project'));
print dol_get_fiche_head($head, 'eventorganisation', $langs->trans("ConferenceOrBoothTab"), -1, ($project->public ? 'projectpub' : 'project'));
// Project card
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
@@ -440,10 +441,10 @@ if ($projectid > 0) {
// Link to the subscribe
print '<tr><td>';
//print '<span class="opacitymedium">';
print $langs->trans("PublicAttendeeSubscriptionPage");
print $langs->trans("PublicAttendeeSubscriptionGlobalPage");
//print '</span>';
print '</td><td>';
$link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_subscription.php?id='.$project->id;
$link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_subscription.php?id='.$project->id.'&type=global';
$encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$project->id, 2);
$link_subscription .= '&securekey='.urlencode($encodedsecurekey);
//print '<div class="urllink">';
@@ -465,6 +466,12 @@ if ($projectid > 0) {
print dol_get_fiche_end();
}
if (!empty($project->id)) {
$head = conferenceorboothProjectPrepareHead($project);
$tab = 'conferenceorbooth';
print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($project->public ? 'projectpub' : 'project'), 0, '', '');
}
// Build and execute select
// --------------------------------------------------------------------
$sql = 'SELECT ';

View File

@@ -370,6 +370,7 @@ if ($action == 'create') {
if ($confOrBooth->id > 0) {
print '<input type="hidden" name="conforboothid" value="'.$confOrBooth->id.'">';
}
print '<input type="hidden" name="fk_project" value="'.GETPOST('fk_project', 'int').'">';
print '<input type="hidden" name="action" value="add">';
if ($backtopage) {

View File

@@ -42,7 +42,7 @@ require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattend
//dol_include_once('/othermodule/class/otherobject.class.php');
// Load translation files required by the page
$langs->loadLangs(array("eventorganization", "other"));
$langs->loadLangs(array("eventorganization", "other", "projects"));
$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
@@ -59,6 +59,7 @@ $conf_or_booth_id = GETPOST('conforboothid', 'int');
$withproject = GETPOST('withproject', 'int');
$project_ref = GETPOST('project_ref', 'alpha');
$fk_project = GETPOST('fk_project', 'int');
$withProjectUrl='';
@@ -215,9 +216,19 @@ if ($conf_or_booth_id > 0) {
$result = $confOrBooth->fetch($conf_or_booth_id);
if ($result < 0) {
setEventMessages(null, $confOrBooth->errors, 'errors');
} else {
$fk_project = $confOrBooth->fk_project;
}
}
if ($fk_project > 0) {
$result = $projectstatic->fetch($fk_project);
if ($result < 0) {
setEventMessages(null, $projectstatic->errors, 'errors');
}
}
// Build and execute select
// --------------------------------------------------------------------
$sql = 'SELECT ';
@@ -234,7 +245,9 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje
$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
$sql = preg_replace('/,\s*$/', '', $sql);
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as a on a.id=t.fk_actioncomm AND a.id=".((int) $confOrBooth->id);
if (!empty($confOrBooth->id)) {
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as a on a.id=t.fk_actioncomm AND a.id=".((int) $confOrBooth->id);
}
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
}
@@ -247,6 +260,9 @@ if ($object->ismultientitymanaged == 1) {
} else {
$sql .= " WHERE 1 = 1";
}
if (!empty($projectstatic->id)) {
$sql .= " AND t.fk_project=".((int) $projectstatic->id);
}
foreach ($search as $key => $val) {
if (array_key_exists($key, $object->fields)) {
if ($key == 'status' && $search[$key] == -1) {
@@ -336,8 +352,9 @@ $morejs = array();
$morecss = array();
llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'classforhorizontalscrolloftabs');
if ($confOrBooth->id > 0) {
$result = $projectstatic->fetch($confOrBooth->fk_project);
if ($projectstatic->id > 0 || $confOrBooth > 0) {
if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) {
$projectstatic->fetchComments();
}
@@ -456,7 +473,7 @@ if ($confOrBooth->id > 0) {
print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">';
print '<table class="border tableforfield" width="100%">';
// Description
print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
@@ -506,10 +523,44 @@ if ($confOrBooth->id > 0) {
// Show message
$message = '<a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=ical'.($conf->entity > 1 ? "&entity=".$conf->entity : "");
$message .= '&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...');
$message .= "&project=".$projectstatic->id.'&module='.urlencode('@eventorganization').'&status='.ConferenceOrBooth::STATUS_CONFIRMED.'">'.$langs->trans('DownloadICSLink').'</a>';
$message .= "&project=".$projectstatic->id.'&module='.urlencode('@eventorganization').'&status='.ConferenceOrBooth::STATUS_CONFIRMED.'">'.$langs->trans('DownloadICSLink').img_picto('', 'download', 'class="paddingleft"').'</a>';
print $message;
print "</td></tr>";
// Link to the submit vote/register page
print '<tr><td>';
//print '<span class="opacitymedium">';
print $form->textwithpicto($langs->trans("SuggestOrVoteForConfOrBooth"), $langs->trans("EvntOrgRegistrationHelpMessage"));
//print '</span>';
print '</td><td>';
$linksuggest = $dolibarr_main_url_root.'/public/project/index.php?id='.$projectstatic->id;
$encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$projectstatic->id, 2);
$linksuggest .= '&securekey='.urlencode($encodedsecurekey);
//print '<div class="urllink">';
//print '<input type="text" value="'.$linksuggest.'" id="linkregister" class="quatrevingtpercent paddingrightonly">';
print '<div class="tdoverflowmax200 inline-block valignmiddle"><a target="_blank" href="'.$linksuggest.'" class="quatrevingtpercent">'.$linksuggest.'</a></div>';
print '<a target="_blank" href="'.$linksuggest.'">'.img_picto('', 'globe').'</a>';
//print '</div>';
//print ajax_autoselect("linkregister");
print '</td></tr>';
// Link to the subscribe
print '<tr><td>';
//print '<span class="opacitymedium">';
print $langs->trans("PublicAttendeeSubscriptionGlobalPage");
//print '</span>';
print '</td><td>';
$link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_subscription.php?id='.$projectstatic->id.'&type=global';
$encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$projectstatic->id, 2);
$link_subscription .= '&securekey='.urlencode($encodedsecurekey);
//print '<div class="urllink">';
//print '<input type="text" value="'.$linkregister.'" id="linkregister" class="quatrevingtpercent paddingrightonly">';
print '<div class="tdoverflowmax200 inline-block valignmiddle"><a target="_blank" href="'.$link_subscription.'" class="quatrevingtpercent">'.$link_subscription.'</a></div>';
print '<a target="_blank" href="'.$link_subscription.'">'.img_picto('', 'globe').'</a>';
//print '</div>';
//print ajax_autoselect("linkregister");
print '</td></tr>';
print '</table>';
print '</div>';
@@ -520,38 +571,44 @@ if ($confOrBooth->id > 0) {
print dol_get_fiche_end();
print '<br>';
if (!empty($fk_project)) {
$head = conferenceorboothProjectPrepareHead($projectstatic);
$tab = 'attendees';
print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($project->public ? 'projectpub' : 'project'), 0, '', '');
}
}
$head = conferenceorboothPrepareHead($confOrBooth, $withproject);
print dol_get_fiche_head($head, 'attendees', $langs->trans("ConferenceOrBooth"), -1, $object->picto);
if ($confOrBooth->id > 0) {
$head = conferenceorboothPrepareHead($confOrBooth, $withproject);
print dol_get_fiche_head($head, 'attendees', $langs->trans("ConferenceOrBooth"), -1, $object->picto);
//$help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
$title = $langs->trans("ConferenceOrBooth") . ' - ' . $langs->trans("Attendees") . ' - ' . $confOrBooth->id;
//$help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
$title = $langs->trans("ConferenceOrBooth") . ' - ' . $langs->trans("Attendees") . ' - ' . $confOrBooth->id;
$object_evt=$object;
$object=$confOrBooth;
$object_evt = $object;
$object = $confOrBooth;
dol_banner_tab($object, 'ref', '', 0);
dol_banner_tab($object, 'ref', '', 0);
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent tableforfield">'."\n";
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent tableforfield">' . "\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 '</table>';
print '</div>';
print '</div>';
// Other attributes. Fields from hook formObjectOptions and Extrafields.
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
$object = $object_evt;
print '</table>';
print '</div>';
print '</div>';
print '<div class="clearboth"></div>';
print '<div class="clearboth"></div>';
print dol_get_fiche_end();
print dol_get_fiche_end();
}
}
$arrayofselected = is_array($toselect) ? $toselect : array();
@@ -612,7 +669,7 @@ print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
$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);

View File

@@ -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] .= '<span class="badge marginleftonlyshort">'.$nbConferenceOrBooth.'</span>';
}
$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] .= '<span class="badge marginleftonlyshort">'.$nbAttendees.'</span>';
}
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

View File

@@ -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);

View File

@@ -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,

View File

@@ -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.

View File

@@ -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 '<div id="divsubscribe">';
print '<div class="center subscriptionformhelptext justify">';
// Welcome message
print $langs->trans("EvntOrgWelcomeMessage", $conference->label);
print $langs->trans("EvntOrgWelcomeMessage", $project->title . ' '. $conference->label);
print '<br>';
print $langs->trans("EvntOrgDuration", dol_print_date($conference->datep), dol_print_date($conference->datef));
if ($conference->id) {
print $langs->trans("EvntOrgDuration", dol_print_date($conference->datep), dol_print_date($conference->datef));
} else {
print $langs->trans("EvntOrgDuration", dol_print_date($project->date_start), dol_print_date($project->date_end));
}
print '</div>';
print '<br>';
dol_htmloutput_errors($errmsg);
if ($conference->status!=2) {
if (!empty($conference->id) && $conference->status!=2 || !empty($project->id) && $project->status==Project::STATUS_VALIDATED) {
print $langs->trans("ConferenceIsNotConfirmed");
} else {
// Print form
@@ -487,7 +516,9 @@ if ($conference->status!=2) {
print '<input type="hidden" name="token" value="' . newToken() . '" / >';
print '<input type="hidden" name="entity" value="' . $entity . '" />';
print '<input type="hidden" name="action" value="add" />';
print '<input type="hidden" name="id" value="' . $id . '" />';
print '<input type="hidden" name="id" value="' . $conference->id . '" />';
print '<input type="hidden" name="type" value="' . $type . '" />';
print '<input type="hidden" name="fk_project" value="' . $project->id . '" />';
print '<input type="hidden" name="securekey" value="' . $securekeyreceived . '" />';
print '<br>';