diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 8f36876fddc..97293f3cbb0 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -98,10 +98,8 @@ EvntOrgCancelled = Cancelled # SuggestForm = Suggestion page RegisterPage = Page for conferences or booth -EvntOrgRegistrationWelcomeMessage = Welcome on the conference or booth suggestion page. EvntOrgRegistrationConfHelpMessage = Here, you can suggest a new conference for the project EvntOrgRegistrationBoothHelpMessage = Here, you can suggest a new booth for the project -EvntOrgVoteHelpMessage = Here, you can view and vote for the suggested events for the project ListOfSuggestedConferences = List of suggested conferences ListOfSuggestedBooths = List of suggested booths SuggestConference = Suggest a new conference @@ -114,6 +112,16 @@ EvntOrgDuration = This conference starts on %s and ends on %s. ConferenceAttendeeFee = Conference attendee fee for the event : '%s' occurring from %s to %s. BoothLocationFee = Booth location for the event : '%s' occurring from %s to %s EventType = Event type + +# +# Vote page +# +EvntOrgRegistrationWelcomeMessage = Welcome on the conference or booth suggestion page. +EvntOrgVoteHelpMessage = Here, you can view and vote for the suggested events for the project +VoteOk = Your vote has been accepted. +AlreadyVoted = You have already voted for this event. +VoteError = An error has occurred during the vote, please try again. + # # SubscriptionOk page # diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index bf140bdd600..5cbd3da966b 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -1068,7 +1068,6 @@ if ($ispaymentok) { $ispostactionok = -1; } } elseif (array_key_exists('BOO', $tmptag) && $tmptag['BOO'] > 0) { - // @todo BOOTH CASE (to copy and adapt from above) // Record payment include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $object = new Facture($db); diff --git a/htdocs/public/project/viewandvote.php b/htdocs/public/project/viewandvote.php index 7b6f8776d3a..355156d73cb 100644 --- a/htdocs/public/project/viewandvote.php +++ b/htdocs/public/project/viewandvote.php @@ -70,7 +70,7 @@ $hookmanager = new HookManager($db); $hookmanager->initHooks(array('newpayment')); // For encryption -global $dolibarr_main_instance_unique_id; +global $dolibarr_main_instance_unique_id, $dolibarr_main_url_root; // Load translation files $langs->loadLangs(array("main", "other", "dict", "bills", "companies", "errors", "paybox", "paypal", "stripe")); // File with generic data @@ -88,6 +88,14 @@ if ($securekeytocompare != $securekeyreceived) { exit; } +if (GETPOST("votestatus")=="ok") { + setEventMessage($langs->trans("VoteOk"), 'mesgs'); +} else if (GETPOST("votestatus")=="ko") { + setEventMessage($langs->trans("AlreadyVoted"), 'warnings'); +} else if (GETPOST("votestatus")=="err") { + setEventMessage($langs->trans("VoteError"), 'warnings'); +} + // Define $urlwithroot //$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); //$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file @@ -120,7 +128,6 @@ $sql = "SELECT a.id, a.fk_action, a.datep, a.datep2, a.label, a.fk_soc, a.note, $sqlforconf = $sql." AND ca.module='conference@eventorganization'"; $sqlforbooth = $sql." AND ca.module='booth@eventorganization'"; - // For conferences $result = $db->query($sqlforconf); $i = 0; @@ -133,7 +140,7 @@ while ($i < $db->num_rows($result)) { $thirdpartyname = ''; } $listOfConferences .= ''.$obj->label.''.$obj->libelle.''.$obj->datep.''.$obj->datep2.''.$thirdpartyname.''.$obj->note.''; - $listOfConferences .= ''; + $listOfConferences .= ''; $i++; } @@ -149,10 +156,56 @@ while ($i < $db->num_rows($result)) { $thirdpartyname = ''; } $listOfBooths .= ''.$obj->label.''.$obj->libelle.''.$obj->datep.''.$obj->datep2.''.$thirdpartyname.''.$obj->note.''; - $listOfBooths .= ''; + $listOfBooths .= ''; $i++; } +// Get vote result +$idvote = GETPOST("vote"); +$hashedvote = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'vote'.$idvote); + +if (strlen($idvote)) { + if ($_COOKIE['VOTE_SUGGESTED_EVENTS_'.$hashedvote]==1) { + // Has already voted + $votestatus = 'ko'; + } else { + // Has not already voted + $conforbooth = new ActionComm($db); + $resultconforbooth = $conforbooth->fetch($idvote); + if ($resultconforbooth<=0) { + $error++; + $errmsg .= $conforbooth->error; + } else { + // Cookie expiration date : start of event, or 30 days if not specified + $startdate = $conforbooth->datep; + if (strlen($startdate)) { + $timeleftbeforestartofevent = $startdate; + } else { + // Cookie duration by default + $timeleftbeforestartofevent = time()+86400*30; + } + + // Process to vote + $res = setcookie('VOTE_SUGGESTED_EVENTS_'.$hashedvote, 1, 0); + if ($res) { + $conforbooth->num_vote++; + $resupdate = $conforbooth->update($user); + if ($resupdate) { + $votestatus = 'ok'; + } else { + //Error during update + $votestatus = 'err'; + $res = setcookie('VOTE_SUGGESTED_EVENTS_'.$hashedvote, 0, 0); + } + } else { + $votestatus = 'err'; + } + } + } + header("Refresh:0;url=".dol_buildpath('/public/project/viewandvote.php?votestatus='.$votestatus.'&id='.$id.'&securekey=', 1).$securekeyreceived); +} + + /* * View */