diff --git a/htdocs/public/project/index.php b/htdocs/public/project/index.php index 9b04890084e..7ff74c31cb9 100644 --- a/htdocs/public/project/index.php +++ b/htdocs/public/project/index.php @@ -85,6 +85,12 @@ $id = dol_decode(GETPOST('id'), $dolibarr_main_instance_unique_id); //$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file $urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost. +$project = new Project($db); +$resultproject = $project->fetch($id); +if ($resultproject < 0) { + $error++; + $errmsg .= $project->error; +} /* * Actions @@ -180,6 +186,7 @@ if (!empty($conf->global->PAYMENT_NEWFORM_TEXT)) { if (empty($text)) { $text .= '
'.$langs->trans("EvntOrgRegistrationWelcomeMessage").''."\n"; $text .= ''.$langs->trans("EvntOrgRegistrationHelpMessage").' '.$id.'.

'."\n"; + $text .= ''.$project->note_public.'

'."\n";; } print $text; @@ -192,103 +199,10 @@ $var = false; $object = null; - -// Free payment -if (!$source) { - $found = true; - $tag = GETPOST("tag", 'alpha'); - if (GETPOST('fulltag', 'alpha')) { - $fulltag = GETPOST('fulltag', 'alpha'); - } else { - $fulltag = "TAG=".$tag; - } - -} - - -// Payment on customer order -if ($source == 'order') { - $found = true; - $langs->load("orders"); - - require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - - $order = new Commande($db); - $result = $order->fetch('', $ref); - if ($result <= 0) { - $mesg = $order->error; - $error++; - } else { - $result = $order->fetch_thirdparty($order->socid); - } - $object = $order; - - if (GETPOST('fulltag', 'alpha')) { - $fulltag = GETPOST('fulltag', 'alpha'); - } else { - $fulltag = 'ORD='.$order->id.'.CUS='.$order->thirdparty->id; - if (!empty($TAG)) { - $tag = $TAG; $fulltag .= '.TAG='.$TAG; - } - } - $fulltag = dol_string_unaccent($fulltag); -} - - -// Payment on customer invoice -if ($source == 'invoice') { - $found = true; - $langs->load("bills"); - - require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - - $invoice = new Facture($db); - $result = $invoice->fetch('', $ref); - if ($result <= 0) { - $mesg = $invoice->error; - $error++; - } else { - $result = $invoice->fetch_thirdparty($invoice->socid); - } - $object = $invoice; - - if ($action != 'dopayment') { // Do not change amount if we just click on first dopayment - $amount = price2num($invoice->total_ttc - ($invoice->getSommePaiement() + $invoice->getSumCreditNotesUsed() + $invoice->getSumDepositsUsed())); - if (GETPOST("amount", 'alpha')) { - $amount = GETPOST("amount", 'alpha'); - } - $amount = price2num($amount); - } - - if (GETPOST('fulltag', 'alpha')) { - $fulltag = GETPOST('fulltag', 'alpha'); - } else { - $fulltag = 'INV='.$invoice->id.'.CUS='.$invoice->thirdparty->id; - if (!empty($TAG)) { - $tag = $TAG; $fulltag .= '.TAG='.$TAG; - } - } - $fulltag = dol_string_unaccent($fulltag); - - $labeldesc = $langs->trans("Invoice").' '.$invoice->ref; - if (GETPOST('desc', 'alpha')) { - $labeldesc = GETPOST('desc', 'alpha'); - } - print ''."\n"; -} - -if (!$found && !$mesg) { - $mesg = $langs->trans("ErrorBadParameters"); -} - -if ($mesg) { - print '
'.dol_escape_htmltag($mesg).'
'."\n"; -} - print "\n"; -// Show all payment mode buttons (Stripe, Paypal, ...) +// Show all action buttons print '
'; print ''; print '

'; @@ -306,522 +220,6 @@ print ''."\n"; print '
'; - -// Add more content on page for some services -if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payment mode - // Stripe - if (GETPOST('dopayment_stripe', 'alpha')) { - // Personalized checkout - print ''; - - print '
'; - - print ''."\n"; - print '
'."\n"; - - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''; - print ''."\n"; - print ''."\n"; - print ''; - print ''; - print ''; - - if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) || !empty($conf->global->STRIPE_USE_NEW_CHECKOUT)) { // Use a SCA ready method - require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; - - $service = 'StripeLive'; - $servicestatus = 1; - if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha')) { - $service = 'StripeTest'; - $servicestatus = 0; - } - - $stripe = new Stripe($db); - $stripeacc = $stripe->getStripeAccount($service); - $stripecu = null; - if (is_object($object) && is_object($object->thirdparty)) { - $stripecu = $stripe->customerStripe($object->thirdparty, $stripeacc, $servicestatus, 1); - } - - if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { - $noidempotency_key = (GETPOSTISSET('noidempotency') ? GETPOST('noidempotency', 'int') : 0); // By default noidempotency is unset, so we must use a different tag/ref for each payment. If set, we can pay several times the same tag/ref. - $paymentintent = $stripe->getPaymentIntent($amount, $currency, $tag, 'Stripe payment: '.$fulltag.(is_object($object) ? ' ref='.$object->ref : ''), $object, $stripecu, $stripeacc, $servicestatus, 0, 'automatic', false, null, 0, $noidempotency_key); - // The paymentintnent has status 'requires_payment_method' (even if paymentintent was already paid) - //var_dump($paymentintent); - if ($stripe->error) { - setEventMessages($stripe->error, null, 'errors'); - } - } - } - - //if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) || ! empty($paymentintent)) - //{ - print ' - - '; - print '
'; - - if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { - print '
'; - } - - print '
'; - print ''; - - if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { - print '
'; - } - - print '
- -
'; - - print ' - -
'; - - print '
'; - print ''; - print ''; - - print '
'; - //} - - if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { - if (empty($paymentintent)) { - print '
'.$langs->trans("Error").'
'; - } else { - print ''; - //$_SESSION["paymentintent_id"] = $paymentintent->id; - } - } - - print '
'."\n"; - - - // JS Code for Stripe - if (empty($stripearrayofkeys['publishable_key'])) { - $langs->load("errors"); - print info_admin($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Stripe")), 0, 0, 'error'); - } else { - print ''; - print ''."\n"; - print ''."\n"; - - // Code to ask the credit card. This use the default "API version". No way to force API version when using JS code. - print ''; - } - } - // This hook is used to show the embedded form to make payments with external payment modules (ie Payzen, ...) - $parameters = [ - 'paymentmethod' => $paymentmethod, - 'amount' => price2num(GETPOST("newamount"), 'MT'), - 'tag' => GETPOST("tag", 'alpha'), - 'dopayment' => GETPOST('dopayment', 'alpha') - ]; - $reshook = $hookmanager->executeHooks('doPayment', $parameters, $object, $action); -} - - htmlPrintOnlinePaymentFooter($mysoc, $langs, 1, $suffix, $object); llxFooter('', 'public');