payment page structure ok, still need to confirm the attendee after the payment

This commit is contained in:
Dorian Vabre 2021-04-15 10:45:44 +02:00
parent caf74fe1cb
commit dd7c09582f
4 changed files with 193 additions and 65 deletions

View File

@ -61,8 +61,8 @@ $arrayofparameters = array(
'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_SPEAKER'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1),
'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_ATTENDES'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1),
'EVENTORGANIZATION_SECUREKEY'=>array('type'=>'securekey', 'enabled'=>1),
'SERVICE_BOOTH_LOCATION'=>array('type'=>'product', 'enabled'=>1),
'SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION'=>array('type'=>'product', 'enabled'=>1),
'SERVICE_BOOTH_LOCATION'=>array('type'=>'product', 'enabled'=>1),
'SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION'=>array('type'=>'product', 'enabled'=>1),
);
$error = 0;
@ -209,12 +209,12 @@ if ($action == 'edit') {
print '<tr class="liste_titre"><td class="titlefieldcreate">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
foreach ($arrayofparameters as $constname => $val) {
if ($val['enabled']==1) {
$setupnotempty++;
print '<tr class="oddeven"><td>';
$tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
print '<span id="helplink'.$constname.'" class="spanforparamtooltip">'.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).'</span>';
print '</td><td>';
if ($val['enabled']==1) {
$setupnotempty++;
print '<tr class="oddeven"><td>';
$tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
print '<span id="helplink'.$constname.'" class="spanforparamtooltip">'.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).'</span>';
print '</td><td>';
if ($val['type'] == 'textarea') {
print '<textarea class="flat" name="'.$constname.'" id="'.$constname.'" cols="50" rows="5" wrap="soft">' . "\n";
@ -259,13 +259,13 @@ if ($action == 'edit') {
$formcompany = new FormCompany($db);
print $formcompany->selectProspectCustomerType($conf->global->{$constname}, $constname);
} elseif ($val['type'] == 'securekey') {
print '<input required="required" type="text" class="flat" id="'.$constname.'" name="'.$constname.'" value="'.(GETPOST($constname, 'alpha') ?GETPOST($constname, 'alpha') : $conf->global->{$constname}).'" size="40">';
if (!empty($conf->use_javascript_ajax)) {
print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token'.$constname.'" class="linkobject"');
}
if (!empty($conf->use_javascript_ajax)) {
print "\n".'<script type="text/javascript">';
print '$(document).ready(function () {
print '<input required="required" type="text" class="flat" id="'.$constname.'" name="'.$constname.'" value="'.(GETPOST($constname, 'alpha') ?GETPOST($constname, 'alpha') : $conf->global->{$constname}).'" size="40">';
if (!empty($conf->use_javascript_ajax)) {
print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token'.$constname.'" class="linkobject"');
}
if (!empty($conf->use_javascript_ajax)) {
print "\n".'<script type="text/javascript">';
print '$(document).ready(function () {
$("#generate_token'.$constname.'").click(function() {
$.get( "'.DOL_URL_ROOT.'/core/ajax/security.php", {
action: \'getrandompassword\',
@ -276,25 +276,16 @@ if ($action == 'edit') {
});
});
});';
print '</script>';
}
print '</script>';
}
} elseif ($var['type'] == 'product') {
if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
print '<tr class="oddeven"><td>'.$langs->trans("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS").'</td>';
print '<td>';
$selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname);
$form->select_produits($selected, $constname, '', 0);
print '</td>';
print "</tr>\n";
}
if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
print '<tr class="oddeven"><td>'.$langs->trans("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS").'</td>';
print '<td>';
$selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname);
$form->select_produits($selected, $constname, '', 0);
print '</td>';
}
print "</tr>\n";
if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
print '<tr class="oddeven"><td>'.$langs->trans("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS").'</td>';
print '<td>';
$selected = (empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) ? '' : $conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
$form->select_produits($selected, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', '', 0);
print '</td>';
}
} else {
print '<input name="'.$constname.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.$conf->global->{$constname}.'">';
}

View File

@ -105,3 +105,7 @@ EvntOrgEndDuration = and ends on
# SubscriptionOk page
#
SubscriptionOk = Your subscription to this conference has been validated
#
# Payment page
#
PaymentConferenceAttendee = Paiement de participation à une conférence

View File

@ -86,15 +86,16 @@ $id = dol_decode($encodedid, $dolibarr_main_instance_unique_id);
$conference = new ConferenceOrBooth($db);
$resultconf = $conference->fetch($id);
if ($resultconf < 0) {
setEventMessages(null, $object->errors, "errors");
setEventMessages(null, $object->errors, "errors");
}
$project = new Project($db);
$resultproject = $project->fetch($conference->fk_project);
if ($resultproject < 0){
$error++;
$errmsg .= $project->error;
if ($resultproject < 0) {
$error++;
$errmsg .= $project->error;
}
var_dump($conference->fk_project);
// Getting 'securekey'.'id' from Post and decoding it
$encodedsecurekeyandid = GETPOST('securekey', 'alpha');
@ -293,32 +294,31 @@ if (empty($reshook) && $action == 'add') {
if (!$error) {
$db->commit();
global $dolibarr_main_url_root;
if (!empty(floatval($project->price_registration))){
$facture = new Facture($db);
$facture->type = 0;
$facture->socid = $thirdparty->id;
$facture->paye = 0;
//@todo price and taxes to add
$tva = get_default_tva($mysoc, $thirdparty);
$facture->date = dol_now();
$resultfacture = $facture->create($user);
if ($resultfacture < 0){
$error++;
$errmsg .= $facture->error;
} else {
$redirection = $dolibarr_main_url_root.'/public/payment/newpayment.php';
Header("Location: ".$redirection);
exit;
}
} else {
// No price has been set
// Validating the subscription
$confattendee->setStatut(1);
$redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php';
Header("Location: ".$redirection);
exit;
global $dolibarr_main_url_root;
if (!empty(floatval($project->price_registration))) {
$facture = new Facture($db);
$facture->type = 0;
$facture->socid = $thirdparty->id;
$facture->paye = 0;
//@todo price and taxes to add
$tva = get_default_tva($mysoc, $thirdparty);
$facture->date = dol_now();
$resultfacture = $facture->create($user);
if ($resultfacture < 0) {
$error++;
$errmsg .= $facture->error;
} else {
$redirection = $dolibarr_main_url_root.'/public/payment/newpayment.php?source=conferencesubscription&ref='.$confattendee->id;
Header("Location: ".$redirection);
exit;
}
} else {
// No price has been set
// Validating the subscription
$confattendee->setStatut(1);
$redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php';
Header("Location: ".$redirection);
exit;
}
//Header("Location: ".$urlback);
//exit;
@ -394,8 +394,8 @@ print '<table class="border" summary="form to subscribe" id="tablesubscribe">'."
print '<tr><td>'.$langs->trans("Email").' <FONT COLOR="red">*</FONT></td><td><input type="text" name="email" maxlength="255" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('email')).'"></td></tr>'."\n";
// Company
print '<tr id="trcompany" class="trcompany"><td>'.$langs->trans("Company");
if(!empty(floatval($project->price_registration))){
print '<FONT COLOR="red">*</FONT>';
if (!empty(floatval($project->price_registration))) {
print '<FONT COLOR="red">*</FONT>';
}
print ' </td><td><input type="text" name="societe" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('societe')).'"></td></tr>'."\n";
// Address

View File

@ -61,6 +61,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php';
require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
// Hook to be used by external payment modules (ie Payzen, ...)
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager = new HookManager($db);
@ -1724,6 +1727,136 @@ if ($source == 'donation') {
print '<input type="hidden" name="desc" value="'.dol_escape_htmltag($labeldesc).'">'."\n";
}
if ($source == 'conferencesubscription') {
// @todo cas paiement de conferenceattendee
$found = true;
$langs->load("members");
// Finding the Attendee
$attendee = new ConferenceOrBoothAttendee($db);
$result = $attendee->fetch('', $ref);
if ($result <= 0) {
$mesg = $attendee->error;
$error++;
}
$object = $attendee;
// Finding the thirdparty associated to the Attendee
$thirdparty = new Societe($db);
$resultthirdparty = $thirdparty->fetch($attendee->fk_soc);
if ($resultthirdparty <= 0) {
$mesg = $thirdparty->error;
$error++;
}
// Finding the conference
$conference = new ConferenceOrBooth($db);
$resultconf = $conference->fetch($attendee->fk_actioncomm);
if ($resultconf <= 0) {
$mesg = $conference->error;
$error++;
}
// Finding the project
$project = new Project($db);
$resultproj = $project->fetch($conference->fk_project);
if ($resultproj <= 0) {
$mesg = $project->error;
$error++;
}
if ($action != 'dopayment') { // Do not change amount if we just click on first dopayment
$amount = $project->price_registration;
if (GETPOST("amount", 'alpha')) {
$amount = GETPOST("amount", 'alpha');
}
$amount = price2num($amount, 'MT');
}
if (GETPOST('fulltag', 'alpha')) {
$fulltag = GETPOST('fulltag', 'alpha');
} else {
$fulltag = 'MEM='.$member->id.'.DAT='.dol_print_date(dol_now(), '%Y%m%d%H%M%S');
if (!empty($TAG)) {
$tag = $TAG; $fulltag .= '.TAG='.$TAG;
}
}
$fulltag = dol_string_unaccent($fulltag);
// Creditor
print '<tr class="CTableRow'.($var ? '1' : '2').'"><td class="CTableRow'.($var ? '1' : '2').'">'.$langs->trans("Creditor");
print '</td><td class="CTableRow'.($var ? '1' : '2').'"><b>'.$creditor.'</b>';
print '<input type="hidden" name="creditor" value="'.$creditor.'">';
print '</td></tr>'."\n";
// Debitor
print '<tr class="CTableRow'.($var ? '1' : '2').'"><td class="CTableRow'.($var ? '1' : '2').'">'.$langs->trans("Member");
print '</td><td class="CTableRow'.($var ? '1' : '2').'"><b>';
print $thirdparty->name;
print '</b>';
print '</td></tr>'."\n";
// Object
$text = '<b>'.$langs->trans("PaymentConferenceAttendee").'</b>';
if (GETPOST('desc', 'alpha')) {
$text = '<b>'.$langs->trans(GETPOST('desc', 'alpha')).'</b>';
}
print '<tr class="CTableRow'.($var ? '1' : '2').'"><td class="CTableRow'.($var ? '1' : '2').'">'.$langs->trans("Designation");
print '</td><td class="CTableRow'.($var ? '1' : '2').'">'.$text;
print '<input type="hidden" name="source" value="'.dol_escape_htmltag($source).'">';
print '<input type="hidden" name="ref" value="'.dol_escape_htmltag($member->ref).'">';
print '</td></tr>'."\n";
// Amount
print '<tr class="CTableRow'.($var ? '1' : '2').'"><td class="CTableRow'.($var ? '1' : '2').'">'.$langs->trans("Amount");
print '</td><td class="CTableRow'.($var ? '1' : '2').'">';
$valtoshow = $project->price_registration;
print '<b>'.price($valtoshow).'</b>';
print '<input type="hidden" name="amount" value="'.$valtoshow.'">';
print '<input type="hidden" name="newamount" value="'.$valtoshow.'">';
// Currency
print ' <b>'.$langs->trans("Currency".$currency).'</b>';
print '<input type="hidden" name="currency" value="'.$currency.'">';
print '</td></tr>'."\n";
// Tag
print '<tr class="CTableRow'.($var ? '1' : '2').'"><td class="CTableRow'.($var ? '1' : '2').'">'.$langs->trans("PaymentCode");
print '</td><td class="CTableRow'.($var ? '1' : '2').'"><b style="word-break: break-all;">'.$fulltag.'</b>';
print '<input type="hidden" name="tag" value="'.$tag.'">';
print '<input type="hidden" name="fulltag" value="'.$fulltag.'">';
print '</td></tr>'."\n";
// Shipping address
$shipToName = $thirdparty->getFullName($langs);
$shipToStreet = $thirdparty->address;
$shipToCity = $thirdparty->town;
$shipToState = $thirdparty->state_code;
$shipToCountryCode = $thirdparty->country_code;
$shipToZip = $thirdparty->zip;
$shipToStreet2 = '';
$phoneNum = $thirdparty->phone;
if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
print '<!-- Shipping address information -->';
print '<input type="hidden" name="shipToName" value="'.$shipToName.'">'."\n";
print '<input type="hidden" name="shipToStreet" value="'.$shipToStreet.'">'."\n";
print '<input type="hidden" name="shipToCity" value="'.$shipToCity.'">'."\n";
print '<input type="hidden" name="shipToState" value="'.$shipToState.'">'."\n";
print '<input type="hidden" name="shipToCountryCode" value="'.$shipToCountryCode.'">'."\n";
print '<input type="hidden" name="shipToZip" value="'.$shipToZip.'">'."\n";
print '<input type="hidden" name="shipToStreet2" value="'.$shipToStreet2.'">'."\n";
print '<input type="hidden" name="phoneNum" value="'.$phoneNum.'">'."\n";
} else {
print '<!-- Shipping address not complete, so we don t use it -->'."\n";
}
print '<input type="hidden" name="thirdparty_id" value="'.$thirdparty->id.'">'."\n";
print '<input type="hidden" name="email" value="'.$thirdparty->email.'">'."\n";
$labeldesc = $langs->trans("PaymentSubscription");
if (GETPOST('desc', 'alpha')) {
$labeldesc = GETPOST('desc', 'alpha');
}
print '<input type="hidden" name="desc" value="'.dol_escape_htmltag($labeldesc).'">'."\n";
}
if (!$found && !$mesg) {
$mesg = $langs->trans("ErrorBadParameters");