New: Can edit options of autosubscribe form for member module

This commit is contained in:
Laurent Destailleur 2011-07-03 16:55:31 +00:00
parent 76973c4029
commit b14e8ac8b4
4 changed files with 36 additions and 31 deletions

View File

@ -25,7 +25,7 @@
* \file htdocs/adherents/class/adherent.class.php * \file htdocs/adherents/class/adherent.class.php
* \ingroup member * \ingroup member
* \brief File of class to manage members of a foundation * \brief File of class to manage members of a foundation
* \version $Id$ * \version $Id: adherent.class.php,v 1.44 2011/07/03 16:55:31 eldy Exp $
*/ */
require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
@ -274,7 +274,7 @@ class Adherent extends CommonObject
$sql.= " VALUES ("; $sql.= " VALUES (";
$sql.= " '".$this->db->idate($this->datec)."'"; $sql.= " '".$this->db->idate($this->datec)."'";
$sql.= ", ".($this->login?"'".$this->db->escape($this->login)."'":"null"); $sql.= ", ".($this->login?"'".$this->db->escape($this->login)."'":"null");
$sql.= ", ".($user->id>0?$user->id:"null"); // Can be null because member can be create by a guest or a script $sql.= ", ".($user->id>0?$user->id:"null"); // Can be null because member can be createb by a guest or a script
$sql.= ", null, null, '".$this->morphy."'"; $sql.= ", null, null, '".$this->morphy."'";
$sql.= ", '".$this->typeid."'"; $sql.= ", '".$this->typeid."'";
$sql.= ", ".$conf->entity; $sql.= ", ".$conf->entity;
@ -288,6 +288,7 @@ class Adherent extends CommonObject
if ($id > 0) if ($id > 0)
{ {
$this->id=$id; $this->id=$id;
$this->ref=$id;
// Update minor fields // Update minor fields
$result=$this->update($user,1,1); // nosync is 1 to avoid update data of user $result=$this->update($user,1,1); // nosync is 1 to avoid update data of user

View File

@ -306,7 +306,7 @@ ConnectionTimeout=Connexion timeout
ResponseTimeout=Response timeout ResponseTimeout=Response timeout
SmsTestMessage=Test message from __PHONEFROM__ to __PHONETO__ SmsTestMessage=Test message from __PHONEFROM__ to __PHONETO__
ModuleMustBeEnabledFirst=Module <b>%s</b> must be enabled first before using this feature. ModuleMustBeEnabledFirst=Module <b>%s</b> must be enabled first before using this feature.
SecurityToken=Security token SecurityToken=Key to encrypt urls
# Modules # Modules
Module0Name=Users & groups Module0Name=Users & groups

View File

@ -307,7 +307,7 @@ ConnectionTimeout=Timeout de connexion
ResponseTimeout=Timeout de réponse ResponseTimeout=Timeout de réponse
SmsTestMessage=Message de test de __PHONEFROM__ vers __PHONETO__ SmsTestMessage=Message de test de __PHONEFROM__ vers __PHONETO__
ModuleMustBeEnabledFirst=Le module <b>%s</b> doit etre activé pour utiliser cette fonction. ModuleMustBeEnabledFirst=Le module <b>%s</b> doit etre activé pour utiliser cette fonction.
SecurityToken=Jeton de sécurité SecurityToken=Clé de cryptage des url
# Modules= undefined # Modules= undefined
Module0Name= Utilisateurs & groupes Module0Name= Utilisateurs & groupes

View File

@ -22,7 +22,7 @@
* \file htdocs/public/members/new.php * \file htdocs/public/members/new.php
* \ingroup member * \ingroup member
* \brief Example of form to add a new member * \brief Example of form to add a new member
* \version $Id: new.php,v 1.30 2011/07/03 16:00:19 eldy Exp $ * \version $Id: new.php,v 1.31 2011/07/03 16:55:31 eldy Exp $
* *
* Note that you can add following constant to change behaviour of page * Note that you can add following constant to change behaviour of page
* MEMBER_NEWFORM_AMOUNT Default amount for autosubscribe form * MEMBER_NEWFORM_AMOUNT Default amount for autosubscribe form
@ -110,15 +110,14 @@ function llxFooterVierge()
/* /*
* Actions * Actions
*/ */
// Action called when submited page // Action called when page is submited
if ($action == 'add') if ($action == 'add')
{ {
// test si le login existe deja // test if login already exists
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
{ {
if(! GETPOST('login')) if(! GETPOST('login'))
@ -221,34 +220,39 @@ if ($action == 'add')
$result=$adh->create($user->id); $result=$adh->create($user->id);
if ($result > 0) if ($result > 0)
{ {
if ($cotisation > 0)
{
$adh->cotisation(dol_mktime(12, 0 , 0, $remonth, $reday, $reyear), $cotisation);
}
// Send email to say it has been created and will be validated soon... // Send email to say it has been created and will be validated soon...
if ($conf->global->ADHERENT_AUTOREGISTER_MAIL && $conf->global->ADHERENT_AUTOREGISTER_MAIL_SUBJECT) if (! empty($conf->global->ADHERENT_AUTOREGISTER_MAIL) && ! empty($conf->global->ADHERENT_AUTOREGISTER_MAIL_SUBJECT))
{ {
$result=$adh->send_an_email($conf->global->ADHERENT_AUTOREGISTER_MAIL,$conf->global->ADHERENT_AUTOREGISTER_MAIL_SUBJECT,array(),array(),array(),"","",0,-1); $result=$adh->send_an_email($conf->global->ADHERENT_AUTOREGISTER_MAIL,$conf->global->ADHERENT_AUTOREGISTER_MAIL_SUBJECT,array(),array(),array(),"","",0,-1);
} }
if ($backtopage) if ($backtopage) $urlback=$backtopage;
else if ($conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION) $urlback=$conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION;
else $urlback=$_SERVER["PHP_SELF"]."?action=added";
if (! empty($conf->global->MEMBER_NEWFORM_PAYONLINE))
{ {
Header("Location: ".$backtopage); if ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'paybox')
exit; {
$urlback=DOL_MAIN_URL_ROOT.'/public/paybox/newpayment.php?source=membersubscription&ref='.$adh->ref;
if (price2num(GETPOST('amount'))) $urlback.='&amount='.price2num(GETPOST('amount'));
} }
else if ($conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION) else if ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'paypal')
{ {
// Si conf->global->MEMBER_URL_REDIRECT_SBUSCRIPTION defini, faire redirect sur page. $urlback=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=membersubscription&ref='.$adh->ref;
Header("Location: ".$conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION); if (price2num(GETPOST('amount'))) $urlback.='&amount='.price2num(GETPOST('amount'));
exit;
} }
else else
{ {
Header("Location: ".$_SERVER["PHP_SELF"]."?action=added"); dol_print_error('',"Autosubscribe form is setup to ask an online payment for a not managed online payment");
exit; exit;
} }
} }
dol_syslog("member ".$adh->ref." was created, we redirect to ".$urlback);
Header("Location: ".$urlback);
exit;
}
else else
{ {
$errmsg .= join('<br>',$adh->errors); $errmsg .= join('<br>',$adh->errors);
@ -269,7 +273,7 @@ if ($action == 'added')
print $langs->trans("NewMemberbyWeb"); print $langs->trans("NewMemberbyWeb");
print '</center>'; print '</center>';
llxFooterVierge('$Date: 2011/07/03 16:00:19 $ - $Revision: 1.30 $'); llxFooterVierge('$Date: 2011/07/03 16:55:31 $ - $Revision: 1.31 $');
exit; exit;
} }
@ -344,7 +348,7 @@ if (empty($conf->global->MEMBER_NEWFORM_FORCETYPE))
else else
{ {
$adht->fetch($conf->global->MEMBER_NEWFORM_FORCETYPE); $adht->fetch($conf->global->MEMBER_NEWFORM_FORCETYPE);
print $adht->libelle; //print $adht->libelle;
print '<input type="hidden" id="type" name="type" value="'.$conf->global->MEMBER_NEWFORM_FORCETYPE.'">'; print '<input type="hidden" id="type" name="type" value="'.$conf->global->MEMBER_NEWFORM_FORCETYPE.'">';
} }
// Moral/Physic attribute // Moral/Physic attribute
@ -498,5 +502,5 @@ print "<br></form>\n";
$db->close(); $db->close();
llxFooterVierge('$Date: 2011/07/03 16:00:19 $ - $Revision: 1.30 $'); llxFooterVierge('$Date: 2011/07/03 16:55:31 $ - $Revision: 1.31 $');
?> ?>