2004-10-20 22:06:49 +02:00
< ? php
2018-11-18 22:03:32 +01:00
/* Copyright ( C ) 2001 - 2002 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2001 - 2002 Jean - Louis Bergamo < jlb @ j1b . org >
* Copyright ( C ) 2006 - 2013 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2012 Regis Houssin < regis . houssin @ inodbox . com >
* Copyright ( C ) 2012 J . Fernando Lagrange < fernando @ demo - tic . org >
2019-12-08 23:02:34 +01:00
* Copyright ( C ) 2018 - 2019 Frédéric France < frederic . france @ netlogic . fr >
2019-01-28 21:39:22 +01:00
* Copyright ( C ) 2018 Alexandre Spangaro < aspangaro @ open - dsi . fr >
2021-05-07 00:43:01 +02:00
* Copyright ( C ) 2021 Waël Almoman < info @ almoman . com >
2007-09-15 04:28:29 +02:00
*
2003-01-23 16:27:50 +01:00
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2003-01-23 16:27:50 +01:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2003-01-23 16:27:50 +01:00
*/
2005-08-25 22:40:18 +02:00
/**
2009-04-02 02:34:32 +02:00
* \file htdocs / public / members / new . php
2010-07-21 13:57:52 +02:00
* \ingroup member
2009-09-29 19:18:36 +02:00
* \brief Example of form to add a new member
2011-06-26 21:29:39 +02:00
*
* Note that you can add following constant to change behaviour of page
2015-04-03 06:54:08 +02:00
* MEMBER_NEWFORM_AMOUNT Default amount for auto - subscribe form
2018-01-30 10:43:24 +01:00
* MEMBER_NEWFORM_EDITAMOUNT 0 or 1 = Amount can be edited
2022-02-18 12:36:05 +01:00
* MEMBER_MIN_AMOUNT Minimum amount
2017-02-22 06:33:52 +01:00
* MEMBER_NEWFORM_PAYONLINE Suggest payment with paypal , paybox or stripe
2011-06-26 23:51:34 +02:00
* MEMBER_NEWFORM_DOLIBARRTURNOVER Show field turnover ( specific for dolibarr foundation )
* MEMBER_URL_REDIRECT_SUBSCRIPTION Url to redirect once subscribe submitted
* MEMBER_NEWFORM_FORCETYPE Force type of member
* MEMBER_NEWFORM_FORCEMORPHY Force nature of member ( mor / phy )
* MEMBER_NEWFORM_FORCECOUNTRYCODE Force country
2008-12-03 19:47:00 +01:00
*/
2005-08-25 22:40:18 +02:00
2021-02-26 18:58:34 +01:00
if ( ! defined ( 'NOLOGIN' )) {
define ( " NOLOGIN " , 1 ); // This means this output page does not require to be logged.
}
if ( ! defined ( 'NOCSRFCHECK' )) {
define ( " NOCSRFCHECK " , 1 ); // We accept to go on this page from external web site.
}
if ( ! defined ( 'NOIPCHECK' )) {
define ( 'NOIPCHECK' , '1' ); // Do not check IP defined into conf $dolibarr_main_restrict_ip
}
if ( ! defined ( 'NOBROWSERNOTIF' )) {
define ( 'NOBROWSERNOTIF' , '1' );
}
if ( ! defined ( 'NOIPCHECK' )) {
define ( 'NOIPCHECK' , '1' ); // Do not check IP defined into conf $dolibarr_main_restrict_ip
}
2010-01-12 11:26:05 +01:00
2014-05-05 00:23:09 +02:00
// For MultiCompany module.
2014-01-07 16:29:25 +01:00
// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
2019-11-13 19:35:39 +01:00
$entity = ( ! empty ( $_GET [ 'entity' ]) ? ( int ) $_GET [ 'entity' ] : ( ! empty ( $_POST [ 'entity' ]) ? ( int ) $_POST [ 'entity' ] : 1 ));
2021-02-26 18:58:34 +01:00
if ( is_numeric ( $entity )) {
define ( " DOLENTITY " , $entity );
}
2012-05-04 13:18:29 +02:00
2012-08-22 23:24:21 +02:00
require '../../main.inc.php' ;
2020-01-27 13:42:31 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent_type.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php' ;
2008-06-17 03:01:51 +02:00
2011-07-03 18:00:18 +02:00
// Init vars
2019-11-13 19:35:39 +01:00
$errmsg = '' ;
$num = 0 ;
$error = 0 ;
$backtopage = GETPOST ( 'backtopage' , 'alpha' );
2020-09-16 19:39:50 +02:00
$action = GETPOST ( 'action' , 'aZ09' );
2009-07-15 15:32:01 +02:00
2009-04-02 02:34:32 +02:00
// Load translation files
2019-11-13 19:35:39 +01:00
$langs -> loadLangs ( array ( " main " , " members " , " companies " , " install " , " other " ));
2008-12-03 19:47:00 +01:00
2011-07-03 18:00:18 +02:00
// Security check
2021-02-26 18:58:34 +01:00
if ( empty ( $conf -> adherent -> enabled )) {
accessforbidden ( '' , 0 , 0 , 1 );
}
2011-07-03 18:00:18 +02:00
2020-10-24 13:28:38 +02:00
if ( empty ( $conf -> global -> MEMBER_ENABLE_PUBLIC )) {
2020-10-27 19:46:07 +01:00
print $langs -> trans ( " Auto subscription form for public visitors has not been enabled " );
exit ;
2011-07-03 18:00:18 +02:00
}
2008-06-17 03:01:51 +02:00
2020-10-23 18:49:06 +02:00
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager -> initHooks ( array ( 'publicnewmembercard' , 'globalcard' ));
2013-04-26 12:20:15 +02:00
$extrafields = new ExtraFields ( $db );
2018-04-10 15:39:11 +02:00
$object = new Adherent ( $db );
2018-12-15 18:11:40 +01:00
$user -> loadDefaultValues ();
2010-02-28 15:16:46 +01:00
2011-10-18 16:40:44 +02:00
/**
* Show header for new member
*
2012-01-04 14:12:00 +01:00
* @ param string $title Title
* @ param string $head Head array
* @ param int $disablejs More content into html header
* @ param int $disablehead More content into html header
* @ param array $arrayofjs Array of complementary js files
* @ param array $arrayofcss Array of complementary css files
2011-10-18 16:40:44 +02:00
* @ return void
*/
2019-01-27 15:20:16 +01:00
function llxHeaderVierge ( $title , $head = " " , $disablejs = 0 , $disablehead = 0 , $arrayofjs = '' , $arrayofcss = '' )
2011-06-26 20:53:16 +02:00
{
2020-10-27 19:46:07 +01:00
global $user , $conf , $langs , $mysoc ;
2017-06-09 12:50:56 +02:00
2020-10-27 19:46:07 +01:00
top_htmlhead ( $head , $title , $disablejs , $disablehead , $arrayofjs , $arrayofcss ); // Show html headers
2011-06-26 20:53:16 +02:00
2020-10-27 19:46:07 +01:00
print '<body id="mainbody" class="publicnewmemberform">' ;
2020-01-27 13:42:31 +01:00
2020-10-27 19:46:07 +01:00
// Define urllogo
$urllogo = DOL_URL_ROOT . '/theme/common/login_logo.png' ;
2011-06-26 20:53:16 +02:00
2020-10-27 19:46:07 +01:00
if ( ! empty ( $mysoc -> logo_small ) && is_readable ( $conf -> mycompany -> dir_output . '/logos/thumbs/' . $mysoc -> logo_small )) {
$urllogo = DOL_URL_ROOT . '/viewimage.php?cache=1&modulepart=mycompany&file=' . urlencode ( 'logos/thumbs/' . $mysoc -> logo_small );
} elseif ( ! empty ( $mysoc -> logo ) && is_readable ( $conf -> mycompany -> dir_output . '/logos/' . $mysoc -> logo )) {
$urllogo = DOL_URL_ROOT . '/viewimage.php?cache=1&modulepart=mycompany&file=' . urlencode ( 'logos/' . $mysoc -> logo );
} elseif ( is_readable ( DOL_DOCUMENT_ROOT . '/theme/dolibarr_logo.svg' )) {
$urllogo = DOL_URL_ROOT . '/theme/dolibarr_logo.svg' ;
}
2020-01-27 13:42:31 +01:00
print '<div class="center">' ;
2021-06-19 20:05:25 +02:00
2020-10-27 19:46:07 +01:00
// Output html code for logo
if ( $urllogo ) {
print '<div class="backgreypublicpayment">' ;
print '<div class="logopublicpayment">' ;
2021-06-19 19:45:13 +02:00
print '<img id="dolpaymentlogo" src="' . $urllogo . '">' ;
2020-10-27 19:46:07 +01:00
print '</div>' ;
if ( empty ( $conf -> global -> MAIN_HIDE_POWERED_BY )) {
2020-11-14 18:11:46 +01:00
print '<div class="poweredbypublicpayment opacitymedium right"><a class="poweredbyhref" href="https://www.dolibarr.org?utm_medium=website&utm_source=poweredby" target="dolibarr" rel="noopener">' . $langs -> trans ( " PoweredBy " ) . '<br><img class="poweredbyimg" src="' . DOL_URL_ROOT . '/theme/dolibarr_logo.svg" width="80px"></a></div>' ;
2020-10-27 19:46:07 +01:00
}
print '</div>' ;
}
2021-06-19 20:05:25 +02:00
2021-06-19 19:45:13 +02:00
if ( ! empty ( $conf -> global -> MEMBER_IMAGE_PUBLIC_REGISTRATION )) {
print '<div class="backimagepublicregistration">' ;
2021-06-19 20:05:25 +02:00
print '<img id="idEVENTORGANIZATION_IMAGE_PUBLIC_INTERFACE" src="' . $conf -> global -> MEMBER_IMAGE_PUBLIC_REGISTRATION . '">' ;
2021-06-19 19:45:13 +02:00
print '</div>' ;
}
2021-06-19 20:05:25 +02:00
2020-10-27 19:46:07 +01:00
print '</div>' ;
print '<div class="divmainbodylarge">' ;
2008-06-17 03:01:51 +02:00
}
2011-10-18 16:40:44 +02:00
/**
* Show footer for new member
*
* @ return void
*/
2010-01-12 11:41:29 +01:00
function llxFooterVierge ()
2008-06-17 03:01:51 +02:00
{
2020-10-27 19:46:07 +01:00
print '</div>' ;
2003-01-23 16:27:50 +01:00
2020-10-27 19:46:07 +01:00
printCommonFooter ( 'public' );
2011-10-18 16:40:44 +02:00
2020-10-27 19:46:07 +01:00
print " </body> \n " ;
print " </html> \n " ;
2011-06-26 20:53:16 +02:00
}
2009-04-02 02:34:32 +02:00
2003-01-23 16:27:50 +01:00
2007-02-28 00:47:21 +01:00
/*
2008-12-03 19:47:00 +01:00
* Actions
*/
2021-11-27 15:58:08 +01:00
2020-10-24 13:28:38 +02:00
$parameters = array ();
2020-10-23 18:49:06 +02:00
// Note that $action and $object may have been modified by some hooks
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action );
if ( $reshook < 0 ) {
2020-10-27 19:46:07 +01:00
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
2020-10-23 18:49:06 +02:00
}
2009-04-02 02:34:32 +02:00
2015-04-03 06:54:08 +02:00
// Action called when page is submitted
2020-10-23 18:49:06 +02:00
if ( empty ( $reshook ) && $action == 'add' ) {
2018-03-23 20:45:35 +01:00
$error = 0 ;
2019-11-13 19:35:39 +01:00
$urlback = '' ;
2018-03-23 20:45:35 +01:00
$db -> begin ();
2020-10-27 19:46:07 +01:00
// test if login already exists
if ( empty ( $conf -> global -> ADHERENT_LOGIN_NOT_REQUIRED )) {
if ( ! GETPOST ( 'login' )) {
$error ++ ;
$errmsg .= $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " Login " )) . " <br> \n " ;
}
$sql = " SELECT login FROM " . MAIN_DB_PREFIX . " adherent WHERE login=' " . $db -> escape ( GETPOST ( 'login' )) . " ' " ;
$result = $db -> query ( $sql );
if ( $result ) {
$num = $db -> num_rows ( $result );
}
if ( $num != 0 ) {
$error ++ ;
$langs -> load ( " errors " );
$errmsg .= $langs -> trans ( " ErrorLoginAlreadyExists " ) . " <br> \n " ;
}
2020-11-30 14:47:07 +01:00
if ( ! GETPOSTISSET ( " pass1 " ) || ! GETPOSTISSET ( " pass2 " ) || GETPOST ( " pass1 " , 'none' ) == '' || GETPOST ( " pass2 " , 'none' ) == '' || GETPOST ( " pass1 " , 'none' ) != GETPOST ( " pass2 " , 'none' )) {
2020-10-27 19:46:07 +01:00
$error ++ ;
$langs -> load ( " errors " );
$errmsg .= $langs -> trans ( " ErrorPasswordsMustMatch " ) . " <br> \n " ;
}
2021-04-17 14:18:42 +02:00
if ( ! GETPOST ( 'email' )) {
2020-10-27 19:46:07 +01:00
$error ++ ;
$errmsg .= $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " EMail " )) . " <br> \n " ;
}
}
2021-04-17 14:18:42 +02:00
if ( GETPOST ( 'typeid' ) <= 0 ) {
2020-10-27 19:46:07 +01:00
$error ++ ;
$errmsg .= $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " Type " )) . " <br> \n " ;
}
if ( ! in_array ( GETPOST ( 'morphy' ), array ( 'mor' , 'phy' ))) {
$error ++ ;
$errmsg .= $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( 'Nature' )) . " <br> \n " ;
}
2021-04-17 14:18:42 +02:00
if ( ! GETPOST ( 'lastname' )) {
2020-10-27 19:46:07 +01:00
$error ++ ;
$errmsg .= $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " Lastname " )) . " <br> \n " ;
}
2021-04-17 14:39:14 +02:00
if ( ! GETPOST ( 'firstname' )) {
2020-10-27 19:46:07 +01:00
$error ++ ;
$errmsg .= $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " Firstname " )) . " <br> \n " ;
}
2021-04-27 02:07:48 +02:00
if ( ! empty ( $conf -> global -> ADHERENT_MAIL_REQUIRED ) && empty ( GETPOST ( 'email' ))) {
2020-10-27 19:46:07 +01:00
$error ++ ;
2021-04-22 19:18:47 +02:00
$errmsg .= $langs -> trans ( 'ErrorFieldRequired' , $langs -> transnoentitiesnoconv ( 'Email' )) . " <br> \n " ;
} elseif ( GETPOST ( " email " ) && ! isValidEmail ( GETPOST ( " email " ))) {
2021-04-27 02:07:48 +02:00
$langs -> load ( 'errors' );
2020-10-27 19:46:07 +01:00
$error ++ ;
$errmsg .= $langs -> trans ( " ErrorBadEMail " , GETPOST ( " email " )) . " <br> \n " ;
}
2021-02-24 11:37:20 +01:00
$birthday = dol_mktime ( GETPOST ( " birthhour " , 'int' ), GETPOST ( " birthmin " , 'int' ), GETPOST ( " birthsec " , 'int' ), GETPOST ( " birthmonth " , 'int' ), GETPOST ( " birthday " , 'int' ), GETPOST ( " birthyear " , 'int' ));
2021-04-17 23:58:00 +02:00
if ( GETPOST ( " birthmonth " ) && empty ( $birthday )) {
2020-10-27 19:46:07 +01:00
$error ++ ;
$langs -> load ( " errors " );
$errmsg .= $langs -> trans ( " ErrorBadDateFormat " ) . " <br> \n " ;
}
if ( ! empty ( $conf -> global -> MEMBER_NEWFORM_DOLIBARRTURNOVER )) {
if ( GETPOST ( " morphy " ) == 'mor' && GETPOST ( 'budget' ) <= 0 ) {
$error ++ ;
$errmsg .= $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " TurnoverOrBudget " )) . " <br> \n " ;
}
}
2021-04-17 14:18:42 +02:00
$public = GETPOSTISSET ( 'public' ) ? 1 : 0 ;
2020-10-27 19:46:07 +01:00
if ( ! $error ) {
// email a peu pres correct et le login n'existe pas
$adh = new Adherent ( $db );
$adh -> statut = - 1 ;
$adh -> public = $public ;
2021-04-17 14:18:42 +02:00
$adh -> firstname = GETPOST ( 'firstname' );
$adh -> lastname = GETPOST ( 'lastname' );
$adh -> gender = GETPOST ( 'gender' );
$adh -> civility_id = GETPOST ( 'civility_id' );
$adh -> societe = GETPOST ( 'societe' );
$adh -> address = GETPOST ( 'address' );
$adh -> zip = GETPOST ( 'zipcode' );
$adh -> town = GETPOST ( 'town' );
$adh -> email = GETPOST ( 'email' );
2020-10-27 19:46:07 +01:00
if ( empty ( $conf -> global -> ADHERENT_LOGIN_NOT_REQUIRED )) {
2021-04-17 14:18:42 +02:00
$adh -> login = GETPOST ( 'login' );
$adh -> pass = GETPOST ( 'pass1' );
2020-10-27 19:46:07 +01:00
}
2021-04-17 14:18:42 +02:00
$adh -> photo = GETPOST ( 'photo' );
$adh -> country_id = $conf -> global -> MEMBER_NEWFORM_FORCECOUNTRYCODE ? $conf -> global -> MEMBER_NEWFORM_FORCECOUNTRYCODE : GETPOST ( 'country_id' , 'int' );
$adh -> state_id = GETPOST ( 'state_id' , 'int' );
$adh -> typeid = $conf -> global -> MEMBER_NEWFORM_FORCETYPE ? $conf -> global -> MEMBER_NEWFORM_FORCETYPE : GETPOST ( 'typeid' , 'int' );
$adh -> note_private = GETPOST ( 'note_private' );
$adh -> morphy = $conf -> global -> MEMBER_NEWFORM_FORCEMORPHY ? $conf -> global -> MEMBER_NEWFORM_FORCEMORPHY : GETPOST ( 'morphy' );
2020-10-27 19:46:07 +01:00
$adh -> birth = $birthday ;
// Fill array 'array_options' with data from add form
$extrafields -> fetch_name_optionals_label ( $adh -> table_element );
$ret = $extrafields -> setOptionalsFromPost ( null , $adh );
2021-02-26 18:58:34 +01:00
if ( $ret < 0 ) {
$error ++ ;
}
2011-06-26 20:53:16 +02:00
2022-11-14 15:32:16 +01:00
if ( ! $error ) {
$result = $adh -> create ( $user );
if ( $result > 0 ) {
require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php' ;
$object = $adh ;
$adht = new AdherentType ( $db );
$adht -> fetch ( $object -> typeid );
if ( $object -> email ) {
$subject = '' ;
$msg = '' ;
// Send subscription email
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php' ;
$formmail = new FormMail ( $db );
// Set output language
$outputlangs = new Translate ( '' , $conf );
$outputlangs -> setDefaultLang ( empty ( $object -> thirdparty -> default_lang ) ? $mysoc -> default_lang : $object -> thirdparty -> default_lang );
// Load traductions files required by page
$outputlangs -> loadLangs ( array ( " main " , " members " ));
// Get email content from template
$arraydefaultmessage = null ;
$labeltouse = $conf -> global -> ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER ;
if ( ! empty ( $labeltouse )) {
$arraydefaultmessage = $formmail -> getEMailTemplate ( $db , 'member' , $user , $outputlangs , 0 , 1 , $labeltouse );
}
2020-10-27 19:46:07 +01:00
2022-11-14 15:32:16 +01:00
if ( ! empty ( $labeltouse ) && is_object ( $arraydefaultmessage ) && $arraydefaultmessage -> id > 0 ) {
$subject = $arraydefaultmessage -> topic ;
$msg = $arraydefaultmessage -> content ;
}
2020-10-27 19:46:07 +01:00
2022-11-14 15:32:16 +01:00
$substitutionarray = getCommonSubstitutionArray ( $outputlangs , 0 , null , $object );
complete_substitutions_array ( $substitutionarray , $outputlangs , $object );
$subjecttosend = make_substitutions ( $subject , $substitutionarray , $outputlangs );
$texttosend = make_substitutions ( dol_concatdesc ( $msg , $adht -> getMailOnValid ()), $substitutionarray , $outputlangs );
2020-10-27 19:46:07 +01:00
2022-11-14 15:32:16 +01:00
if ( $subjecttosend && $texttosend ) {
$moreinheader = 'X-Dolibarr-Info: send_an_email by public/members/new.php' . " \r \n " ;
2020-10-27 19:46:07 +01:00
2022-11-14 15:32:16 +01:00
$result = $object -> send_an_email ( $texttosend , $subjecttosend , array (), array (), array (), " " , " " , 0 , - 1 , '' , $moreinheader );
}
/* if ( $result < 0 ) {
$error ++ ;
setEventMessages ( $object -> error , $object -> errors , 'errors' );
} */
2020-10-27 19:46:07 +01:00
}
2011-06-26 20:53:16 +02:00
2022-11-14 15:32:16 +01:00
// Send email to the foundation to say a new member subscribed with autosubscribe form
if ( ! empty ( $conf -> global -> MAIN_INFO_SOCIETE_MAIL ) && ! empty ( $conf -> global -> ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT ) &&
! empty ( $conf -> global -> ADHERENT_AUTOREGISTER_NOTIF_MAIL )) {
// Define link to login card
$appli = constant ( 'DOL_APPLICATION_TITLE' );
if ( ! empty ( $conf -> global -> MAIN_APPLICATION_TITLE )) {
$appli = $conf -> global -> MAIN_APPLICATION_TITLE ;
if ( preg_match ( '/\d\.\d/' , $appli )) {
if ( ! preg_match ( '/' . preg_quote ( DOL_VERSION ) . '/' , $appli )) {
$appli .= " ( " . DOL_VERSION . " ) " ; // If new title contains a version that is different than core
}
} else {
$appli .= " " . DOL_VERSION ;
2021-02-26 18:58:34 +01:00
}
} else {
$appli .= " " . DOL_VERSION ;
}
2018-03-23 20:45:35 +01:00
2022-11-14 15:32:16 +01:00
$to = $adh -> makeSubstitution ( $conf -> global -> MAIN_INFO_SOCIETE_MAIL );
$from = $conf -> global -> ADHERENT_MAIL_FROM ;
$mailfile = new CMailFile (
'[' . $appli . '] ' . $conf -> global -> ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT ,
$to ,
$from ,
$adh -> makeSubstitution ( $conf -> global -> ADHERENT_AUTOREGISTER_NOTIF_MAIL ),
array (),
array (),
array (),
" " ,
" " ,
0 ,
- 1
);
if ( ! $mailfile -> sendfile ()) {
dol_syslog ( $langs -> trans ( " ErrorFailedToSendMail " , $from , $to ), LOG_ERR );
}
2020-10-27 19:46:07 +01:00
}
2011-07-03 18:55:31 +02:00
2022-11-14 15:32:16 +01:00
if ( ! empty ( $backtopage )) {
$urlback = $backtopage ;
} elseif ( ! empty ( $conf -> global -> MEMBER_URL_REDIRECT_SUBSCRIPTION )) {
$urlback = $conf -> global -> MEMBER_URL_REDIRECT_SUBSCRIPTION ;
// TODO Make replacement of __AMOUNT__, etc...
} else {
$urlback = $_SERVER [ " PHP_SELF " ] . " ?action=added&token= " . newToken ();
2021-11-27 17:19:16 +01:00
}
2021-11-27 15:58:08 +01:00
2022-11-14 15:32:16 +01:00
if ( ! empty ( $conf -> global -> MEMBER_NEWFORM_PAYONLINE ) && $conf -> global -> MEMBER_NEWFORM_PAYONLINE != '-1' ) {
if ( empty ( $conf -> global -> MEMBER_NEWFORM_EDITAMOUNT )) { // If edition of amount not allowed
// TODO Check amount is same than the amount required for the type of member or if not defined as the defeault amount into $conf->global->MEMBER_NEWFORM_AMOUNT
// It is not so important because a test is done on return of payment validation.
}
2021-11-27 18:05:41 +01:00
2022-11-14 15:32:16 +01:00
$urlback = getOnlinePaymentUrl ( 0 , 'member' , $adh -> ref , price2num ( GETPOST ( 'amount' , 'alpha' ), 'MT' ), '' , 0 );
if ( GETPOST ( 'email' )) {
$urlback .= '&email=' . urlencode ( GETPOST ( 'email' ));
}
if ( $conf -> global -> MEMBER_NEWFORM_PAYONLINE != '-1' && $conf -> global -> MEMBER_NEWFORM_PAYONLINE != 'all' ) {
$urlback .= '&paymentmethod=' . urlencode ( $conf -> global -> MEMBER_NEWFORM_PAYONLINE );
}
} else {
if ( ! empty ( $entity )) {
$urlback .= '&entity=' . (( int ) $entity );
}
2020-10-27 19:46:07 +01:00
}
2022-11-14 15:32:16 +01:00
dol_syslog ( " member " . $adh -> ref . " was created, we redirect to " . $urlback );
2021-11-27 18:05:41 +01:00
} else {
2022-11-14 15:32:16 +01:00
$error ++ ;
$errmsg .= join ( '<br>' , $adh -> errors );
2020-10-27 19:46:07 +01:00
}
}
}
2018-03-23 20:45:35 +01:00
2020-10-27 19:46:07 +01:00
if ( ! $error ) {
$db -> commit ();
2018-03-23 20:45:35 +01:00
2020-10-27 19:46:07 +01:00
Header ( " Location: " . $urlback );
exit ;
} else {
$db -> rollback ();
}
2007-02-28 00:47:21 +01:00
}
2015-04-03 06:54:08 +02:00
// Action called after a submitted was send and member created successfully
2011-06-26 20:53:16 +02:00
// If MEMBER_URL_REDIRECT_SUBSCRIPTION is set to url we never go here because a redirect was done to this url.
// backtopage parameter with an url was set on member submit page, we never go here because a redirect was done to this url.
2020-10-23 18:49:06 +02:00
if ( empty ( $reshook ) && $action == 'added' ) {
2020-10-27 19:46:07 +01:00
llxHeaderVierge ( $langs -> trans ( " NewMemberForm " ));
2011-06-26 20:53:16 +02:00
2020-10-27 19:46:07 +01:00
// Si on a pas ete redirige
2022-05-16 13:05:17 +02:00
print '<br><br>' ;
2020-10-27 19:46:07 +01:00
print '<div class="center">' ;
print $langs -> trans ( " NewMemberbyWeb " );
print '</div>' ;
2011-06-26 20:53:16 +02:00
2020-10-27 19:46:07 +01:00
llxFooterVierge ();
exit ;
2003-01-23 16:27:50 +01:00
}
2006-03-18 00:27:30 +01:00
2007-02-28 00:47:21 +01:00
2009-04-02 02:34:32 +02:00
/*
* View
*/
2011-11-08 10:18:45 +01:00
$form = new Form ( $db );
2011-06-26 20:53:16 +02:00
$formcompany = new FormCompany ( $db );
2007-02-28 00:47:21 +01:00
$adht = new AdherentType ( $db );
2022-05-16 13:05:17 +02:00
$extrafields -> fetch_name_optionals_label ( $object -> table_element ); // fetch optionals attributes and labels
2011-06-26 20:53:16 +02:00
2007-02-28 00:47:21 +01:00
2010-02-28 15:16:46 +01:00
llxHeaderVierge ( $langs -> trans ( " NewSubscription " ));
2012-05-16 12:33:10 +02:00
2018-03-05 17:44:38 +01:00
print load_fiche_titre ( $langs -> trans ( " NewSubscription " ), '' , '' , 0 , 0 , 'center' );
2010-02-28 15:16:46 +01:00
2018-04-10 15:39:11 +02:00
print '<div align="center">' ;
print '<div id="divsubscribe">' ;
print '<div class="center subscriptionformhelptext justify">' ;
2020-10-24 13:28:38 +02:00
if ( ! empty ( $conf -> global -> MEMBER_NEWFORM_TEXT )) {
2020-10-27 19:46:07 +01:00
print $langs -> trans ( $conf -> global -> MEMBER_NEWFORM_TEXT ) . " <br> \n " ;
2020-10-24 13:28:38 +02:00
} else {
2020-10-27 19:46:07 +01:00
print $langs -> trans ( " NewSubscriptionDesc " , $conf -> global -> MAIN_INFO_SOCIETE_MAIL ) . " <br> \n " ;
2020-10-24 13:28:38 +02:00
}
2018-03-05 17:44:38 +01:00
print '</div>' ;
2003-01-23 16:27:50 +01:00
2011-06-26 20:53:16 +02:00
dol_htmloutput_errors ( $errmsg );
2022-11-14 15:32:16 +01:00
dol_htmloutput_events ();
2003-01-23 16:27:50 +01:00
2015-05-16 02:53:36 +02:00
// Print form
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST" name="newmember">' . " \n " ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '" / >' ;
2015-05-16 02:53:36 +02:00
print '<input type="hidden" name="entity" value="' . $entity . '" />' ;
print '<input type="hidden" name="action" value="add" />' ;
2021-10-19 20:03:59 +02:00
print '<input type="hidden" name="page_y" value="" />' ;
2015-05-16 02:53:36 +02:00
2017-06-09 17:29:34 +02:00
print '<br>' ;
2012-05-16 12:33:10 +02:00
2019-01-27 11:55:16 +01:00
print '<br><span class="opacitymedium">' . $langs -> trans ( " FieldsWithAreMandatory " , '*' ) . '</span><br>' ;
2011-07-03 18:00:18 +02:00
//print $langs->trans("FieldsWithIsForPublic",'**').'<br>';
2003-01-23 16:27:50 +01:00
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( '' );
2015-05-16 02:53:36 +02:00
2011-06-26 20:53:16 +02:00
print ' < script type = " text/javascript " >
jQuery ( document ) . ready ( function () {
jQuery ( document ) . ready ( function () {
2011-06-26 21:29:39 +02:00
function initmorphy ()
{
2021-09-15 19:33:30 +02:00
console . log ( " Call initmorphy " );
if ( jQuery ( " #morphy " ) . val () == \ ' phy\ ' ) {
jQuery ( " #trcompany " ) . hide ();
}
if ( jQuery ( " #morphy " ) . val () == \ ' mor\ ' ) {
jQuery ( " #trcompany " ) . show ();
}
2011-06-26 21:29:39 +02:00
};
initmorphy ();
2021-09-15 19:33:30 +02:00
jQuery ( " #morphy " ) . change ( function () {
2011-06-26 21:29:39 +02:00
initmorphy ();
});
2011-12-29 18:34:56 +01:00
jQuery ( " #selectcountry_id " ) . change ( function () {
2011-06-26 21:29:39 +02:00
document . newmember . action . value = " create " ;
document . newmember . submit ();
2011-06-26 20:53:16 +02:00
});
2021-05-07 00:13:49 +02:00
jQuery ( " #typeid " ) . change ( function () {
document . newmember . action . value = " create " ;
document . newmember . submit ();
});
2011-06-26 20:53:16 +02:00
});
});
</ script > ' ;
2003-01-23 16:27:50 +01:00
2012-03-10 13:52:08 +01:00
print '<table class="border" summary="form to subscribe" id="tablesubscribe">' . " \n " ;
2003-01-23 16:27:50 +01:00
2021-10-19 20:03:59 +02:00
// Type
2020-10-24 13:28:38 +02:00
if ( empty ( $conf -> global -> MEMBER_NEWFORM_FORCETYPE )) {
2020-10-27 19:46:07 +01:00
$listoftype = $adht -> liste_array ();
$tmp = array_keys ( $listoftype );
$defaulttype = '' ;
$isempty = 1 ;
if ( count ( $listoftype ) == 1 ) {
2020-10-24 13:28:38 +02:00
$defaulttype = $tmp [ 0 ];
$isempty = 0 ;
}
2021-10-05 10:01:37 +02:00
print '<tr><td class="titlefield">' . $langs -> trans ( " Type " ) . ' <span style="color: red">*</span></td><td>' ;
2021-05-07 00:13:49 +02:00
print $form -> selectarray ( " typeid " , $adht -> liste_array ( 1 ), GETPOST ( 'typeid' ) ? GETPOST ( 'typeid' ) : $defaulttype , $isempty );
2020-10-27 19:46:07 +01:00
print '</td></tr>' . " \n " ;
2020-05-21 15:05:19 +02:00
} else {
2020-10-27 19:46:07 +01:00
$adht -> fetch ( $conf -> global -> MEMBER_NEWFORM_FORCETYPE );
2021-04-17 14:29:23 +02:00
print '<input type="hidden" id="typeid" name="typeid" value="' . $conf -> global -> MEMBER_NEWFORM_FORCETYPE . '">' ;
2011-06-26 20:53:16 +02:00
}
2021-04-19 21:37:33 +02:00
2011-06-26 20:53:16 +02:00
// Moral/Physic attribute
2009-09-29 19:18:36 +02:00
$morphys [ " phy " ] = $langs -> trans ( " Physical " );
$morphys [ " mor " ] = $langs -> trans ( " Moral " );
2020-10-24 13:28:38 +02:00
if ( empty ( $conf -> global -> MEMBER_NEWFORM_FORCEMORPHY )) {
2023-03-05 16:55:45 +01:00
print '<tr class="morphy"><td class="titlefield">' . $langs -> trans ( 'MemberNature' ) . ' <span style="color: red">*</span></td><td>' . " \n " ;
2020-10-27 19:46:07 +01:00
print $form -> selectarray ( " morphy " , $morphys , GETPOST ( 'morphy' ), 1 );
print '</td></tr>' . " \n " ;
2020-05-21 15:05:19 +02:00
} else {
2020-10-27 19:46:07 +01:00
print '<input type="hidden" id="morphy" name="morphy" value="' . $conf -> global -> MEMBER_NEWFORM_FORCEMORPHY . '">' ;
2011-06-26 20:53:16 +02:00
}
2021-04-19 21:37:33 +02:00
2021-09-15 19:33:30 +02:00
// Company
print '<tr id="trcompany" class="trcompany"><td>' . $langs -> trans ( " Company " ) . '</td><td>' ;
print img_picto ( '' , 'company' , 'class="pictofixedwidth"' );
2021-10-19 20:03:59 +02:00
print '<input type="text" name="societe" class="minwidth150 widthcentpercentminusx" value="' . dol_escape_htmltag ( GETPOST ( 'societe' )) . '"></td></tr>' . " \n " ;
2021-09-15 19:33:30 +02:00
// Title
2017-06-09 17:29:34 +02:00
print '<tr><td class="titlefield">' . $langs -> trans ( 'UserTitle' ) . '</td><td>' ;
2019-01-27 11:55:16 +01:00
print $formcompany -> select_civility ( GETPOST ( 'civility_id' ), 'civility_id' ) . '</td></tr>' . " \n " ;
2011-06-26 20:53:16 +02:00
// Lastname
2021-10-05 10:01:37 +02:00
print '<tr><td>' . $langs -> trans ( " Lastname " ) . ' <span style="color: red">*</span></td><td><input type="text" name="lastname" class="minwidth150" value="' . dol_escape_htmltag ( GETPOST ( 'lastname' )) . '"></td></tr>' . " \n " ;
2011-06-26 20:53:16 +02:00
// Firstname
2021-10-05 10:01:37 +02:00
print '<tr><td>' . $langs -> trans ( " Firstname " ) . ' <span style="color: red">*</span></td><td><input type="text" name="firstname" class="minwidth150" value="' . dol_escape_htmltag ( GETPOST ( 'firstname' )) . '"></td></tr>' . " \n " ;
2021-09-15 19:33:30 +02:00
// EMail
2021-09-15 19:39:22 +02:00
print '<tr><td>' . $langs -> trans ( " Email " ) . ( $conf -> global -> ADHERENT_MAIL_REQUIRED ? ' <span style="color:red;">*</span>' : '' ) . '</td><td>' ;
//print img_picto('', 'email', 'class="pictofixedwidth"');
print '<input type="text" name="email" maxlength="255" class="minwidth200" value="' . dol_escape_htmltag ( GETPOST ( 'email' )) . '"></td></tr>' . " \n " ;
2021-09-15 19:33:30 +02:00
// Login
if ( empty ( $conf -> global -> ADHERENT_LOGIN_NOT_REQUIRED )) {
2021-10-05 10:01:37 +02:00
print '<tr><td>' . $langs -> trans ( " Login " ) . ' <span style="color: red">*</span></td><td><input type="text" name="login" maxlength="50" class="minwidth100"value="' . dol_escape_htmltag ( GETPOST ( 'login' )) . '"></td></tr>' . " \n " ;
2022-06-13 10:44:20 +02:00
print '<tr><td>' . $langs -> trans ( " Password " ) . ' <span style="color: red">*</span></td><td><input type="password" maxlength="128" name="pass1" class="minwidth100" value="' . dol_escape_htmltag ( GETPOST ( " pass1 " , " none " , 2 )) . '"></td></tr>' . " \n " ;
2022-08-13 12:33:00 +02:00
print '<tr><td>' . $langs -> trans ( " PasswordRetype " ) . ' <span style="color: red">*</span></td><td><input type="password" maxlength="128" name="pass2" class="minwidth100" value="' . dol_escape_htmltag ( GETPOST ( " pass2 " , " none " , 2 )) . '"></td></tr>' . " \n " ;
2021-09-15 19:33:30 +02:00
}
2018-11-18 22:03:32 +01:00
// Gender
print '<tr><td>' . $langs -> trans ( " Gender " ) . '</td>' ;
print '<td>' ;
2019-11-13 19:35:39 +01:00
$arraygender = array ( 'man' => $langs -> trans ( " Genderman " ), 'woman' => $langs -> trans ( " Genderwoman " ));
print $form -> selectarray ( 'gender' , $arraygender , GETPOST ( 'gender' ) ? GETPOST ( 'gender' ) : $object -> gender , 1 );
2018-11-18 22:03:32 +01:00
print '</td></tr>' ;
2011-06-26 20:53:16 +02:00
// Address
2009-04-02 02:34:32 +02:00
print '<tr><td>' . $langs -> trans ( " Address " ) . '</td><td>' . " \n " ;
2020-09-18 01:29:17 +02:00
print '<textarea name="address" id="address" wrap="soft" class="quatrevingtpercent" rows="' . ROWS_3 . '">' . dol_escape_htmltag ( GETPOST ( 'address' , 'restricthtml' ), 0 , 1 ) . '</textarea></td></tr>' . " \n " ;
2011-06-26 20:53:16 +02:00
// Zip / Town
print '<tr><td>' . $langs -> trans ( 'Zip' ) . ' / ' . $langs -> trans ( 'Town' ) . '</td><td>' ;
2021-10-19 20:03:59 +02:00
print $formcompany -> select_ziptown ( GETPOST ( 'zipcode' ), 'zipcode' , array ( 'town' , 'selectcountry_id' , 'state_id' ), 0 , 1 , '' , 'width75' );
2011-06-26 20:53:16 +02:00
print ' / ' ;
2019-11-13 19:35:39 +01:00
print $formcompany -> select_ziptown ( GETPOST ( 'town' ), 'town' , array ( 'zipcode' , 'selectcountry_id' , 'state_id' ), 0 , 1 );
2011-06-26 20:53:16 +02:00
print '</td></tr>' ;
// Country
2017-06-09 17:29:34 +02:00
print '<tr><td>' . $langs -> trans ( 'Country' ) . '</td><td>' ;
2021-09-15 19:33:30 +02:00
print img_picto ( '' , 'country' , 'class="pictofixedwidth"' );
$country_id = GETPOST ( 'country_id' , 'int' );
2020-10-24 13:28:38 +02:00
if ( ! $country_id && ! empty ( $conf -> global -> MEMBER_NEWFORM_FORCECOUNTRYCODE )) {
2020-10-27 19:46:07 +01:00
$country_id = getCountry ( $conf -> global -> MEMBER_NEWFORM_FORCECOUNTRYCODE , 2 , $db , $langs );
2020-10-24 13:28:38 +02:00
}
if ( ! $country_id && ! empty ( $conf -> geoipmaxmind -> enabled )) {
2020-10-27 19:46:07 +01:00
$country_code = dol_user_country ();
//print $country_code;
if ( $country_code ) {
$new_country_id = getCountry ( $country_code , 3 , $db , $langs );
//print 'xxx'.$country_code.' - '.$new_country_id;
2021-02-26 18:58:34 +01:00
if ( $new_country_id ) {
$country_id = $new_country_id ;
}
2020-10-27 19:46:07 +01:00
}
2011-07-03 20:30:48 +02:00
}
2019-11-13 19:35:39 +01:00
$country_code = getCountry ( $country_id , 2 , $db , $langs );
2019-01-27 11:55:16 +01:00
print $form -> select_country ( $country_id , 'country_id' );
2011-06-26 20:53:16 +02:00
print '</td></tr>' ;
// State
2020-10-24 13:28:38 +02:00
if ( empty ( $conf -> global -> SOCIETE_DISABLE_STATE )) {
2020-10-27 19:46:07 +01:00
print '<tr><td>' . $langs -> trans ( 'State' ) . '</td><td>' ;
2021-02-26 18:58:34 +01:00
if ( $country_code ) {
print $formcompany -> select_state ( GETPOST ( " state_id " ), $country_code );
}
2020-10-27 19:46:07 +01:00
print '</td></tr>' ;
2011-06-26 20:53:16 +02:00
}
// Birthday
2021-03-20 21:38:01 +01:00
print '<tr id="trbirth" class="trbirth"><td>' . $langs -> trans ( " DateOfBirth " ) . '</td><td>' ;
2018-09-09 11:25:59 +02:00
print $form -> selectDate ( $birthday , 'birth' , 0 , 0 , 1 , " newmember " , 1 , 0 );
2011-06-26 20:53:16 +02:00
print '</td></tr>' . " \n " ;
// Photo
2017-06-09 17:29:34 +02:00
print '<tr><td>' . $langs -> trans ( " URLPhoto " ) . '</td><td><input type="text" name="photo" class="minwidth150" value="' . dol_escape_htmltag ( GETPOST ( 'photo' )) . '"></td></tr>' . " \n " ;
2011-06-26 20:53:16 +02:00
// Public
2017-04-09 22:00:19 +02:00
print '<tr><td>' . $langs -> trans ( " Public " ) . '</td><td><input type="checkbox" name="public"></td></tr>' . " \n " ;
2018-04-10 15:39:11 +02:00
// Other attributes
2021-04-19 21:37:33 +02:00
$tpl_context = 'public' ; // define template context to public
2018-04-10 15:39:11 +02:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php' ;
2011-06-26 20:53:16 +02:00
// Comments
2009-09-29 19:18:36 +02:00
print '<tr>' ;
2017-01-22 12:13:32 +01:00
print '<td class="tdtop">' . $langs -> trans ( " Comments " ) . '</td>' ;
2020-09-18 01:29:17 +02:00
print '<td class="tdtop"><textarea name="note_private" id="note_private" wrap="soft" class="quatrevingtpercent" rows="' . ROWS_3 . '">' . dol_escape_htmltag ( GETPOST ( 'note_private' , 'restricthtml' ), 0 , 1 ) . '</textarea></td>' ;
2009-09-29 19:18:36 +02:00
print '</tr>' . " \n " ;
2021-09-15 19:33:30 +02:00
// Add specific fields used by Dolibarr foundation for example
// TODO Move this into generic feature.
2020-10-24 13:28:38 +02:00
if ( ! empty ( $conf -> global -> MEMBER_NEWFORM_DOLIBARRTURNOVER )) {
2020-10-27 19:46:07 +01:00
$arraybudget = array ( '50' => '<= 100 000' , '100' => '<= 200 000' , '200' => '<= 500 000' , '300' => '<= 1 500 000' , '600' => '<= 3 000 000' , '1000' => '<= 5 000 000' , '2000' => '5 000 000+' );
2021-10-05 10:01:37 +02:00
print '<tr id="trbudget" class="trcompany"><td>' . $langs -> trans ( " TurnoverOrBudget " ) . ' <span style="color: red">*</span></td><td>' ;
2020-10-27 19:46:07 +01:00
print $form -> selectarray ( 'budget' , $arraybudget , GETPOST ( 'budget' ), 1 );
print ' € or $' ;
2011-06-26 20:53:16 +02:00
2020-10-27 19:46:07 +01:00
print ' < script type = " text/javascript " >
2011-06-26 20:53:16 +02:00
jQuery ( document ) . ready ( function () {
initturnover ();
jQuery ( " #morphy " ) . click ( function () {
initturnover ();
});
jQuery ( " #budget " ) . change ( function () {
2011-07-03 19:38:52 +02:00
if ( jQuery ( " #budget " ) . val () > 0 ) { jQuery ( " .amount " ) . val ( jQuery ( " #budget " ) . val ()); }
2011-06-26 21:29:39 +02:00
else { jQuery ( " #budget " ) . val ( \ ' \ ' ); }
2011-06-26 20:53:16 +02:00
});
2021-04-17 14:18:42 +02:00
/* jQuery ( " #typeid " ) . change ( function () {
if ( jQuery ( " #typeid " ) . val () == 1 ) { jQuery ( " #morphy " ) . val ( \ ' mor\ ' ); }
if ( jQuery ( " #typeid " ) . val () == 2 ) { jQuery ( " #morphy " ) . val ( \ ' phy\ ' ); }
if ( jQuery ( " #typeid " ) . val () == 3 ) { jQuery ( " #morphy " ) . val ( \ ' mor\ ' ); }
if ( jQuery ( " #typeid " ) . val () == 4 ) { jQuery ( " #morphy " ) . val ( \ ' mor\ ' ); }
2011-07-03 19:45:33 +02:00
initturnover ();
2011-11-20 02:10:55 +01:00
}); */
2011-06-26 20:53:16 +02:00
function initturnover () {
if ( jQuery ( " #morphy " ) . val () == \ ' phy\ ' ) {
2011-07-03 19:38:52 +02:00
jQuery ( " .amount " ) . val ( 20 );
2011-06-26 20:53:16 +02:00
jQuery ( " #trbudget " ) . hide ();
jQuery ( " #trcompany " ) . hide ();
}
if ( jQuery ( " #morphy " ) . val () == \ ' mor\ ' ) {
2011-07-03 19:38:52 +02:00
jQuery ( " .amount " ) . val ( \ ' \ ' );
2011-06-26 20:53:16 +02:00
jQuery ( " #trcompany " ) . show ();
2013-01-04 00:23:46 +01:00
jQuery ( " #trbirth " ) . hide ();
jQuery ( " #trbudget " ) . show ();
2011-07-03 19:38:52 +02:00
if ( jQuery ( " #budget " ) . val () > 0 ) { jQuery ( " .amount " ) . val ( jQuery ( " #budget " ) . val ()); }
2011-06-26 21:29:39 +02:00
else { jQuery ( " #budget " ) . val ( \ ' \ ' ); }
2011-06-26 20:53:16 +02:00
}
}
});
</ script > ' ;
2020-10-27 19:46:07 +01:00
print '</td></tr>' . " \n " ;
2011-06-26 20:53:16 +02:00
}
2021-09-15 19:33:30 +02:00
2021-11-27 16:19:12 +01:00
if ( ! empty ( $conf -> global -> MEMBER_NEWFORM_PAYONLINE )) {
$amount = 0 ;
$typeid = $conf -> global -> MEMBER_NEWFORM_FORCETYPE ? $conf -> global -> MEMBER_NEWFORM_FORCETYPE : GETPOST ( 'typeid' , 'int' );
// Set amount for the subscription:
// - First check the amount of the member type.
$amountbytype = $adht -> amountByType ( 1 ); // Load the array of amount per type
$amount = empty ( $amountbytype [ $typeid ]) ? ( isset ( $amount ) ? $amount : 0 ) : $amountbytype [ $typeid ];
// - If not found, take the default amount
if ( empty ( $amount ) && ! empty ( $conf -> global -> MEMBER_NEWFORM_AMOUNT )) {
2020-10-27 19:46:07 +01:00
$amount = $conf -> global -> MEMBER_NEWFORM_AMOUNT ;
}
2021-11-27 16:19:12 +01:00
// - If not set, we accept ot have amount defined as parameter (for backward compatibility).
if ( empty ( $amount )) {
$amount = ( GETPOST ( 'amount' ) ? price2num ( GETPOST ( 'amount' , 'alpha' ), 'MT' , 2 ) : '' );
2020-10-27 19:46:07 +01:00
}
2021-05-07 00:13:49 +02:00
2021-11-27 16:19:12 +01:00
// Clean the amount
2021-05-07 00:13:49 +02:00
$amount = price2num ( $amount );
2020-10-27 19:46:07 +01:00
// $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe'
print '<tr><td>' . $langs -> trans ( " Subscription " ) . '</td><td class="nowrap">' ;
if ( ! empty ( $conf -> global -> MEMBER_NEWFORM_EDITAMOUNT )) {
2021-09-10 11:04:59 +02:00
print '<input type="text" name="amount" id="amount" class="flat amount width50" value="' . $amount . '">' ;
2020-10-27 19:46:07 +01:00
} else {
2021-09-10 11:04:59 +02:00
print '<input type="text" name="amount" id="amounthidden" class="flat amount width50" disabled value="' . $amount . '">' ;
print '<input type="hidden" name="amount" id="amount" class="flat amount" value="' . $amount . '">' ;
2020-10-27 19:46:07 +01:00
}
print ' ' . $langs -> trans ( " Currency " . $conf -> currency );
print '</td></tr>' ;
2011-06-26 21:29:39 +02:00
}
2021-11-27 16:19:12 +01:00
2003-01-23 16:27:50 +01:00
print " </table> \n " ;
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2015-05-16 02:53:36 +02:00
2011-06-26 20:53:16 +02:00
// Save
2015-05-16 02:53:36 +02:00
print '<div class="center">' ;
2019-11-26 12:46:40 +01:00
print '<input type="submit" value="' . $langs -> trans ( " Submit " ) . '" id="submitsave" class="button">' ;
2020-10-24 13:28:38 +02:00
if ( ! empty ( $backtopage )) {
2020-11-23 15:12:52 +01:00
print ' <input type="submit" value="' . $langs -> trans ( " Cancel " ) . '" id="submitcancel" class="button button-cancel">' ;
2011-06-26 20:53:16 +02:00
}
2014-11-24 06:43:15 +01:00
print '</div>' ;
2011-06-26 20:53:16 +02:00
2008-06-17 03:01:51 +02:00
2015-05-16 02:53:36 +02:00
print " </form> \n " ;
print " <br> " ;
print '</div></div>' ;
2011-08-27 21:15:14 +02:00
llxFooterVierge ();
2012-02-19 01:46:00 +01:00
$db -> close ();