New: Preview of email sent is shown

This commit is contained in:
Laurent Destailleur
2010-08-29 12:54:39 +00:00
parent 5cb43e1521
commit f844640adf
10 changed files with 2503 additions and 2423 deletions

View File

@@ -19,6 +19,7 @@ For users:
- New: Delivery date accepts hours and minutes.
- New: Can add a comment on stock dispatching to be save into stock movements.
- New: Add option to send all emails sent to a bulk carbon copy.
- New: Preview of emails sent by member module is shown.
- Perf: Avoid reading database to determine country code after each
page call.
- Fix: Better Postgresql compatibility.

View File

@@ -253,14 +253,9 @@ print_fiche_titre($langs->trans("MembersTickets"),'','');
form_constantes($constantes);
print '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
print '%DOL_MAIN_URL_ROOT%, %ID%, %PRENOM%, %NOM%, %LOGIN%, %PASSWORD%, ';
print '%SOCIETE%, %ADRESSE%, %CP%, %VILLE%, %PAYS%, %EMAIL%, %NAISS%, %PHOTO%, %TYPE%, ';
print '%YEAR%, %MONTH%, %DAY%';
//print '%INFOS%'; Deprecated
print '<br>';
print '<br>';
/*
* Edition des variables globales non rattache a un theme specifique
*/

View File

@@ -99,7 +99,7 @@ if ($user->rights->adherent->cotisation->creer && $_POST["action"] == 'cotisatio
$emetteur_nom=$_POST["chqemetteur"];
$emetteur_banque=$_POST["chqbank"];
// Check if a payment is mandatory or not
if ($adht->cotisation) // Type adherent soumis a cotisation
{
if (! is_numeric($_POST["cotisation"]))
@@ -137,10 +137,13 @@ if ($user->rights->adherent->cotisation->creer && $_POST["action"] == 'cotisatio
{
$db->commit();
// Envoi mail
if ($_POST["sendmail"])
// Send confirmation Email
if ($adh->email && $_POST["sendmail"])
{
$result=$adh->send_an_email($conf->global->ADHERENT_MAIL_COTIS,$conf->global->ADHERENT_MAIL_COTIS_SUBJECT,array(),array(),array(),"","",0,-1);
$subjecttosend=$adh->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT);
$texttosend=$adh->makeSubstitution($adht->getMailOnSubscription());
$result=$adh->send_an_email($texttosend,$subjecttosend,array(),array(),array(),"","",0,-1);
if ($result < 0) $errmsg=$adh->error;
}
@@ -367,7 +370,7 @@ print '</table>';
/*
* Ajout d'une nouvelle cotisation
* Add new subscription
*/
if ($action == 'addsubscription' && $user->rights->adherent->cotisation->creer)
{
@@ -473,11 +476,23 @@ if ($action == 'addsubscription' && $user->rights->adherent->cotisation->creer)
}
else
{
$s1='<input name="sendmail" type="checkbox"'.($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL?' checked="true"':'').'>';
$s2=$langs->trans("MailFrom").': <b>'.$conf->global->ADHERENT_MAIL_FROM.'</b><br>';
$s2.=$langs->trans("MailRecipient").': <b>'.$adh->email.'</b>';
//$s2.='<br>'.$langs->trans("Content").': '.nl2br($conf->global->ADHERENT_MAIL_COTIS);
print $html->textwithpicto($s1,$s2,1);
$adht = new AdherentType($db);
$adht->fetch($adh->typeid);
$subjecttosend=$adh->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT);
$texttosend=$adh->makeSubstitution($adht->getMailOnSubscription());
$tmp='<input name="sendmail" type="checkbox"'.($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL?' checked="true"':'').'>';
$helpcontent='';
$helpcontent.='<b>'.$langs->trans("MailFrom").'</b>: '.$conf->global->ADHERENT_MAIL_FROM.'<br>'."\n";
$helpcontent.='<b>'.$langs->trans("MailRecipient").'</b>: '.$adh->email.'<br>'."\n";
$helpcontent.='<b>'.$langs->trans("Subject").'</b>:<br>'."\n";
$helpcontent.=$subjecttosend."\n";
$helpcontent.="<br>";
$helpcontent.='<b>'.$langs->trans("Content").'</b>:<br>';
$helpcontent.=dol_htmlentitiesbr($texttosend)."\n";
print $html->textwithpicto($tmp,$helpcontent,1,'help');
}
print '</td></tr>';

View File

@@ -121,28 +121,19 @@ class Adherent extends CommonObject
/**
\brief Fonction envoyant un email a l'adherent avec le texte fourni en parametre.
\param text contenu du message
\param subject sujet du message
\param filename_list tableau de fichiers attaches
\param mimetype_list tableau des types des fichiers attaches
\param mimefilename_list tableau des noms des fichiers attaches
\param addr_cc email cc
\param addr_bcc email bcc
\param deliveryreceipt demande accuse reception
\param msgishtml 1=String IS already html, 0=String IS NOT html, -1=Unknown need autodetection
\return int <0 si ko, >0 si ok
\remarks La particularite de cette fonction est de remplacer certains champs
\remarks par leur valeur pour l'adherent en l'occurrence :
\remarks %PRENOM% : est remplace par le prenom
\remarks %NOM% : est remplace par nom
\remarks %INFOS% : l'ensemble des attributs de cet adherent
\remarks %SERVEUR% : URL du serveur web
\remarks etc..
* Fonction envoyant un email a l'adherent avec le texte fourni en parametre.
* @param text contenu du message (not html entities encoded)
* @param subject subject of message
* @param filename_list tableau de fichiers attaches
* @param mimetype_list tableau des types des fichiers attaches
* @param mimefilename_list tableau des noms des fichiers attaches
* @param addr_cc email cc
* @param addr_bcc email bcc
* @param deliveryreceipt demande accuse reception
* @param msgishtml 1=String IS already html, 0=String IS NOT html, -1=Unknown need autodetection
* @return int <0 si ko, >0 si ok
*/
function send_an_email($text,$subject,
$filename_list=array(),$mimetype_list=array(),$mimefilename_list=array(),
$addr_cc="",$addr_bcc="",$deliveryreceipt=0,$msgishtml=-1, $errors_to='')
function send_an_email($text, $subject, $filename_list=array(), $mimetype_list=array(), $mimefilename_list=array(), $addr_cc="", $addr_bcc="", $deliveryreceipt=0, $msgishtml=-1, $errors_to='')
{
global $conf,$langs;
@@ -153,69 +144,16 @@ class Adherent extends CommonObject
if (dol_textishtml($text,1)) $msgishtml = 1;
}
$infos='';
if ($this->civilite_id) $infos.= $langs->trans("UserTitle").": ".$this->getCivilityLabel()."\n";
$infos.= $langs->trans("Lastname").": $this->nom\n";
$infos.= $langs->trans("Firstname").": $this->prenom\n";
$infos.= $langs->trans("Company").": $this->societe\n";
$infos.= $langs->trans("Address").": $this->adresse\n";
$infos.= $langs->trans("Zip").": $this->cp\n";
$infos.= $langs->trans("Town").": $this->ville\n";
$infos.= $langs->trans("Country").": $this->pays\n";
$infos.= $langs->trans("EMail").": $this->email\n";
$infos.= $langs->trans("Login").": $this->login\n";
$infos.= $langs->trans("Password").": $this->pass\n";
$infos.= $langs->trans("Birthday").": $this->naiss\n";
$infos.= $langs->trans("Photo").": $this->photo\n";
$infos.= $langs->trans("Public").": ".yn($this->public)."\n";
if ($msgishtml) $infos = dol_htmlentitiesbr($infos);
// Substitutions
$patterns = array (
'/%CIVILITE%/',
'/%PRENOM%/',
'/%NOM%/',
'/%INFOS%/',
'/%DOL_MAIN_URL_ROOT%/',
'/%SOCIETE%/',
'/%ADRESSE%/',
'/%CP%/',
'/%VILLE%/',
'/%PAYS%/',
'/%EMAIL%/',
'/%NAISS%/',
'/%PHOTO%/',
'/%LOGIN%/',
'/%PASSWORD%/'
);
$replace = array (
$this->getCivilityLabel(),
$this->prenom,
$this->nom,
$infos,
DOL_MAIN_URL_ROOT,
$this->societe,
$this->adresse,
$this->cp,
$this->ville,
$this->pays,
$this->email,
$this->naiss,
$this->photo,
$this->login,
$this->pass
);
$texttosend = preg_replace ($patterns, $replace, $text);
$subjectosend = preg_replace ($patterns, $replace, $subject);
$texttosend=$this->makeSubstitution($text);
$subjecttosend=$this->makeSubstitution($subject);
if ($msgishtml) $texttosend=dol_htmlentitiesbr($texttosend);
// Envoi mail confirmation
$from=$conf->email_from;
if ($conf->global->ADHERENT_MAIL_FROM) $from=$conf->global->ADHERENT_MAIL_FROM;
include_once(DOL_DOCUMENT_ROOT."/lib/CMailFile.class.php");
$mailfile = new CMailFile($subjectosend,$this->email,$from,$texttosend,
$filename_list,$mimetype_list,$mimefilename_list,
$addr_cc, $addr_bcc, $deliveryreceipt, $msgishtml);
$mailfile = new CMailFile($subjecttosend, $this->email, $from, $texttosend, $filename_list, $mimetype_list, $mimefilename_list, $addr_cc, $addr_bcc, $deliveryreceipt, $msgishtml);
if ($mailfile->sendfile())
{
return 1;
@@ -225,7 +163,57 @@ class Adherent extends CommonObject
$this->error=$langs->trans("ErrorFailedToSendMail",$from,$this->email).'. '.$mailfile->error;
return -1;
}
}
/**
* Make substitution
* @param text Text to make substitution to
* @return string Value of input text string with substitutions done
*/
function makeSubstitution($text)
{
global $langs;
$msgishtml = 0;
if (dol_textishtml($text,1)) $msgishtml = 1;
$infos='';
if ($this->civilite_id) $infos.= $langs->transnoentities("UserTitle").": ".$this->getCivilityLabel(1)."\n";
$infos.= $langs->transnoentities("Lastname").": ".$this->nom."\n";
$infos.= $langs->transnoentities("Firstname").": ".$this->prenom."\n";
$infos.= $langs->transnoentities("Company").": ".$this->societe."\n";
$infos.= $langs->transnoentities("Address").": ".$this->adresse."\n";
$infos.= $langs->transnoentities("Zip").": ".$this->cp."\n";
$infos.= $langs->transnoentities("Town").": ".$this->ville."\n";
$infos.= $langs->transnoentities("Country").": ".$this->pays."\n";
$infos.= $langs->transnoentities("EMail").": ".$this->email."\n";
$infos.= $langs->transnoentities("Login").": ".$this->login."\n";
$infos.= $langs->transnoentities("Password").": ".$this->pass."\n";
$infos.= $langs->transnoentities("Birthday").": ".$this->naiss."\n";
$infos.= $langs->transnoentities("Photo").": ".$this->photo."\n";
$infos.= $langs->transnoentities("Public").": ".yn($this->public);
// Substitutions
$substit=array(
'%DOL_MAIN_URL_ROOT%'=>DOL_MAIN_URL_ROOT,
'%INFOS%'=>$msgishtml?dol_htmlentitiesbr($infos):$infos,
'%CIVILITE%'=>$this->getCivilityLabel($msgishtml?0:1),
'%PRENOM%'=>$msgishtml?dol_htmlentitiesbr($this->prenom):$this->prenom,
'%NOM%'=>$msgishtml?dol_htmlentitiesbr($this->nom):$this->nom,
'%SOCIETE%'=>$msgishtml?dol_htmlentitiesbr($this->societe):$this->societe,
'%ADRESSE%'=>$msgishtml?dol_htmlentitiesbr($this->adresse):$this->adresse,
'%CP%'=>$msgishtml?dol_htmlentitiesbr($this->cp):$this->cp,
'%VILLE%'=>$msgishtml?dol_htmlentitiesbr($this->ville):$this->ville,
'%PAYS%'=>$msgishtml?dol_htmlentitiesbr($this->pays):$this->pays,
'%EMAIL%'=>$msgishtml?dol_htmlentitiesbr($this->email):$this->email,
'%NAISS%'=>$msgishtml?dol_htmlentitiesbr($this->naiss):$this->naiss,
'%PHOTO%'=>$msgishtml?dol_htmlentitiesbr($this->photo):$this->photo,
'%LOGIN%'=>$msgishtml?dol_htmlentitiesbr($this->login):$this->login,
'%PASSWORD%'=>$msgishtml?dol_htmlentitiesbr($this->pass):$this->pass
);
return make_substitutions($text,$substit,$langs);
}
@@ -1743,16 +1731,18 @@ class Adherent extends CommonObject
/**
* \brief Retourne le libelle de civilite du contact
* \return string Nom traduit de la civilite
* Return label of a civility of a contact
* @param nohtmlentities 0=Encode with htmlentities for HTML output, 1=No htmlentities for memory translation
* @return string Name translated of civility
*/
function getCivilityLabel()
function getCivilityLabel($nohtmlentities=0)
{
global $langs;
$langs->load("dict");
$code=$this->civilite_id;
return $langs->trans("Civility".$code)!="Civility".$code ? $langs->trans("Civility".$code) : $code;
if ($nohtmlentities) return $langs->transnoentities("Civility".$code)!="Civility".$code ? $langs->transnoentities("Civility".$code) : $code;
else return $langs->trans("Civility".$code)!="Civility".$code ? $langs->trans("Civility".$code) : $code;
}
/**

View File

@@ -272,5 +272,59 @@ class AdherentType extends CommonObject
return $result;
}
/**
* getMailOnValid
* @return Return mail model
*/
function getMailOnValid()
{
global $conf;
if (! empty($this->mail_valid))
{
return $this->mail_valid;
}
else
{
return $conf->global->ADHERENT_MAIL_VALID;
}
}
/**
* getMailOnSubscription
* @return Return mail model
*/
function getMailOnSubscription()
{
global $conf;
if (! empty($this->mail_subscription)) // Not yet developped
{
return $this->mail_subscription;
}
else
{
return $conf->global->ADHERENT_MAIL_COTIS;
}
}
/**
* getMailOnResiliate
* @return Return mail model
*/
function getMailOnResiliate()
{
global $conf;
if (! empty($this->mail_resiliate)) // Not yet developped
{
return $this->mail_resiliate;
}
else
{
return $conf->global->ADHERENT_MAIL_RESIL;
}
}
}
?>

View File

@@ -541,17 +541,10 @@ if ($user->rights->adherent->creer && $_POST["action"] == 'confirm_valid' && $_P
if ($result >= 0 && ! sizeof($adh->errors))
{
// Envoi mail validation (selon param du type adherent sinon generique)
// Send confirmation Email (selon param du type adherent sinon generique)
if ($adh->email && $_POST["send_mail"])
{
if (isset($adht->mail_valid) && $adht->mail_valid)
{
$result=$adh->send_an_email($adht->mail_valid,$conf->global->ADHERENT_MAIL_VALID_SUBJECT,array(),array(),array(),"","",0,2);
}
else
{
$result=$adh->send_an_email($conf->global->ADHERENT_MAIL_VALID,$conf->global->ADHERENT_MAIL_VALID_SUBJECT,array(),array(),array(),"","",0,2);
}
$result=$adh->send_an_email($adht->getMailOnValid(),$conf->global->ADHERENT_MAIL_VALID_SUBJECT,array(),array(),array(),"","",0,2);
if ($result < 0)
{
$errmsg.=$adh->error;
@@ -595,7 +588,7 @@ if ($user->rights->adherent->supprimer && $_POST["action"] == 'confirm_resign' &
{
if ($adh->email && $_POST["send_mail"])
{
$result=$adh->send_an_email($conf->global->ADHERENT_MAIL_RESIL,$conf->global->ADHERENT_MAIL_RESIL_SUBJECT,array(),array(),array(),"","",0,-1);
$result=$adh->send_an_email($adht->getMailOnResiliate(),$conf->global->ADHERENT_MAIL_RESIL_SUBJECT,array(),array(),array(),"","",0,-1);
}
if ($result < 0)
{
@@ -665,6 +658,180 @@ $adho->fetch_name_optionals_label();
$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
if ($action == 'create')
{
/* ************************************************************************** */
/* */
/* Fiche creation */
/* */
/* ************************************************************************** */
$adh->fk_departement = $_POST["departement_id"];
// We set pays_id, pays_code and label for the selected country
$adh->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id;
if ($adh->pays_id)
{
$sql = "SELECT rowid, code, libelle";
$sql.= " FROM ".MAIN_DB_PREFIX."c_pays";
$sql.= " WHERE rowid = ".$adh->pays_id;
$resql=$db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
}
else
{
dol_print_error($db);
}
$adh->pays_id=$obj->rowid;
$adh->pays_code=$obj->code;
$adh->pays=$obj->libelle;
}
$adht = new AdherentType($db);
print_fiche_titre($langs->trans("NewMember"));
if ($errmsg)
{
print '<div class="error">'.$errmsg.'</div>';
}
if ($mesg) print '<div class="ok">'.$mesg.'</div>';
print '<form name="formsoc" action="'.$_SERVER["PHP_SELF"].'" method="post" enctype="multipart/form-data">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">';
print '<table class="border" width="100%">';
// Moral-Physique
$morphys["phy"] = $langs->trans("Physical");
$morphys["mor"] = $langs->trans("Moral");
print '<tr><td><span class="fieldrequired">'.$langs->trans("Person")."</span></td><td>\n";
print $html->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$adh->morphy, 1);
print "</td>\n";
// Company
print '<tr><td>'.$langs->trans("Company").'</td><td><input type="text" name="societe" size="40" value="'.(isset($_POST["societe"])?$_POST["societe"]:$adh->societe).'"></td></tr>';
// Civility
print '<tr><td>'.$langs->trans("UserTitle").'</td><td>';
print $htmlcompany->select_civilite(isset($_POST["civilite_id"])?$_POST["civilite_id"]:$adh->civilite_id,'civilite_id').'</td>';
print '</tr>';
// Nom
print '<tr><td><span class="fieldrequired">'.$langs->trans("Lastname").'</span></td><td><input type="text" name="nom" value="'.(isset($_POST["nom"])?$_POST["nom"]:$adh->nom).'" size="40"></td>';
print '</tr>';
// Prenom
print '<tr><td><span class="fieldrequired">'.$langs->trans("Firstname").'</span></td><td><input type="text" name="prenom" size="40" value="'.(isset($_POST["prenom"])?$_POST["prenom"]:$adh->prenom).'"></td>';
print '</tr>';
// Login
print '<tr><td><span class="fieldrequired">'.$langs->trans("Login").'</span></td><td><input type="text" name="member_login" size="40" value="'.(isset($_POST["member_login"])?$_POST["member_login"]:$adh->login).'"></td></tr>';
// Mot de passe
$generated_password='';
if ($conf->global->USER_PASSWORD_GENERATED)
{
$nomclass="modGeneratePass".ucfirst($conf->global->USER_PASSWORD_GENERATED);
$nomfichier=$nomclass.".class.php";
//print DOL_DOCUMENT_ROOT."/includes/modules/security/generate/".$nomclass;
require_once(DOL_DOCUMENT_ROOT."/includes/modules/security/generate/".$nomfichier);
$genhandler=new $nomclass($db,$conf,$langs,$user);
$generated_password=$genhandler->getNewGeneratedPassword();
}
print '<tr><td><span class="fieldrequired">'.$langs->trans("Password").'</span></td><td>';
print '<input size="30" maxsize="32" type="text" name="password" value="'.$generated_password.'">';
print '</td></tr>';
// Type
print '<tr><td><span class="fieldrequired">'.$langs->trans("MemberType").'</span></td><td>';
$listetype=$adht->liste_array();
if (sizeof($listetype))
{
print $html->selectarray("typeid", $listetype, isset($_POST["typeid"])?$_POST["typeid"]:$typeid, 1);
} else {
print '<font class="error">'.$langs->trans("NoTypeDefinedGoToSetup").'</font>';
}
print "</td>\n";
// Address
print '<tr><td valign="top">'.$langs->trans("Address").'</td><td>';
print '<textarea name="adresse" wrap="soft" cols="40" rows="2">'.(isset($_POST["adresse"])?$_POST["adresse"]:$adh->adresse).'</textarea></td></tr>';
// CP / Ville
print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td><input type="text" name="cp" size="8" value="'.(isset($_POST["cp"])?$_POST["cp"]:$adh->cp).'"> <input type="text" name="ville" size="32" value="'.(isset($_POST["ville"])?$_POST["ville"]:$adh->ville).'"></td></tr>';
// Country
$adh->pays_id=$adh->pays_id?$adh->pays_id:$mysoc->pays_id;
print '<tr><td>'.$langs->trans("Country").'</td><td>';
$html->select_pays(isset($_POST["pays_id"])?$_POST["pays_id"]:$adh->pays_id,'pays_id',$conf->use_javascript_ajax?' onChange="company_save_refresh_create()"':'');
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
print '</td></tr>';
// State
print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">';
if ($adh->pays_id)
{
$htmlcompany->select_departement(isset($_POST["departement_id"])?$_POST["departement_id"]:$adh->fk_departement,$adh->pays_code);
}
else
{
print $countrynotdefined;
}
print '</td></tr>';
// Tel pro
print '<tr><td>'.$langs->trans("PhonePro").'</td><td><input type="text" name="phone" size="20" value="'.(isset($_POST["phone"])?$_POST["phone"]:$adh->phone).'"></td></tr>';
// Tel perso
print '<tr><td>'.$langs->trans("PhonePerso").'</td><td><input type="text" name="phone_perso" size="20" value="'.(isset($_POST["phone_perso"])?$_POST["phone_perso"]:$adh->phone_perso).'"></td></tr>';
// Tel mobile
print '<tr><td>'.$langs->trans("PhoneMobile").'</td><td><input type="text" name="phone_mobile" size="20" value="'.(isset($_POST["phone_mobile"])?$_POST["phone_mobile"]:$adh->phone_mobile).'"></td></tr>';
// EMail
print '<tr><td>'.($conf->global->ADHERENT_MAIL_REQUIRED?'<span class="fieldrequired">':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'</span>':'').'</td><td><input type="text" name="member_email" size="40" value="'.(isset($_POST["member_email"])?$_POST["member_email"]:$adh->email).'"></td></tr>';
// Date naissance
print "<tr><td>".$langs->trans("Birthday")."</td><td>\n";
$html->select_date(($adh->naiss ? $adh->naiss : -1),'naiss','','',1,'formsoc');
print "</td></tr>\n";
// Profil public
print "<tr><td>".$langs->trans("Public")."</td><td>\n";
print $html->selectyesno("public",$adh->public,1);
print "</td></tr>\n";
// Attribut optionnels
foreach($adho->attribute_label as $key=>$value)
{
print "<tr><td>".$value.'</td><td><input type="text" name="options_'.$key.'" size="40" value="'.(isset($_POST["options_".$key])?$_POST["options_".$key]:'').'"></td></tr>'."\n";
}
/*
// Third party Dolibarr
if ($conf->societe->enabled)
{
print '<tr><td>'.$langs->trans("LinkedToDolibarrThirdParty").'</td><td class="valeur">';
print $html->select_societes($adh->fk_soc,'socid','',1);
print '</td></tr>';
}
// Login Dolibarr
print '<tr><td>'.$langs->trans("LinkedToDolibarrUser").'</td><td class="valeur">';
print $html->select_users($adh->user_id,'userid',1);
print '</td></tr>';
*/
print "</table>\n";
print '<br>';
print '<center><input type="submit" class="button" value="'.$langs->trans("AddMember").'"></center>';
print "</form>\n";
}
if ($action == 'edit')
{
@@ -871,181 +1038,6 @@ if ($action == 'edit')
print '</div>';
}
if ($action == 'create')
{
/* ************************************************************************** */
/* */
/* Fiche creation */
/* */
/* ************************************************************************** */
$adh->fk_departement = $_POST["departement_id"];
// We set pays_id, pays_code and label for the selected country
$adh->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id;
if ($adh->pays_id)
{
$sql = "SELECT rowid, code, libelle";
$sql.= " FROM ".MAIN_DB_PREFIX."c_pays";
$sql.= " WHERE rowid = ".$adh->pays_id;
$resql=$db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
}
else
{
dol_print_error($db);
}
$adh->pays_id=$obj->rowid;
$adh->pays_code=$obj->code;
$adh->pays=$obj->libelle;
}
$adht = new AdherentType($db);
print_fiche_titre($langs->trans("NewMember"));
if ($errmsg)
{
print '<div class="error">'.$errmsg.'</div>';
}
if ($mesg) print '<div class="ok">'.$mesg.'</div>';
print '<form name="formsoc" action="'.$_SERVER["PHP_SELF"].'" method="post" enctype="multipart/form-data">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">';
print '<table class="border" width="100%">';
// Moral-Physique
$morphys["phy"] = $langs->trans("Physical");
$morphys["mor"] = $langs->trans("Moral");
print '<tr><td><span class="fieldrequired">'.$langs->trans("Person")."</span></td><td>\n";
print $html->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$adh->morphy, 1);
print "</td>\n";
// Company
print '<tr><td>'.$langs->trans("Company").'</td><td><input type="text" name="societe" size="40" value="'.(isset($_POST["societe"])?$_POST["societe"]:$adh->societe).'"></td></tr>';
// Civility
print '<tr><td>'.$langs->trans("UserTitle").'</td><td>';
print $htmlcompany->select_civilite(isset($_POST["civilite_id"])?$_POST["civilite_id"]:$adh->civilite_id,'civilite_id').'</td>';
print '</tr>';
// Nom
print '<tr><td><span class="fieldrequired">'.$langs->trans("Lastname").'</span></td><td><input type="text" name="nom" value="'.(isset($_POST["nom"])?$_POST["nom"]:$adh->nom).'" size="40"></td>';
print '</tr>';
// Prenom
print '<tr><td><span class="fieldrequired">'.$langs->trans("Firstname").'</span></td><td><input type="text" name="prenom" size="40" value="'.(isset($_POST["prenom"])?$_POST["prenom"]:$adh->prenom).'"></td>';
print '</tr>';
// Login
print '<tr><td><span class="fieldrequired">'.$langs->trans("Login").'</span></td><td><input type="text" name="member_login" size="40" value="'.(isset($_POST["member_login"])?$_POST["member_login"]:$adh->login).'"></td></tr>';
// Mot de passe
$generated_password='';
if ($conf->global->USER_PASSWORD_GENERATED)
{
$nomclass="modGeneratePass".ucfirst($conf->global->USER_PASSWORD_GENERATED);
$nomfichier=$nomclass.".class.php";
//print DOL_DOCUMENT_ROOT."/includes/modules/security/generate/".$nomclass;
require_once(DOL_DOCUMENT_ROOT."/includes/modules/security/generate/".$nomfichier);
$genhandler=new $nomclass($db,$conf,$langs,$user);
$generated_password=$genhandler->getNewGeneratedPassword();
}
print '<tr><td><span class="fieldrequired">'.$langs->trans("Password").'</span></td><td>';
print '<input size="30" maxsize="32" type="text" name="password" value="'.$generated_password.'">';
print '</td></tr>';
// Type
print '<tr><td><span class="fieldrequired">'.$langs->trans("MemberType").'</span></td><td>';
$listetype=$adht->liste_array();
if (sizeof($listetype))
{
print $html->selectarray("typeid", $listetype, isset($_POST["typeid"])?$_POST["typeid"]:$typeid, 1);
} else {
print '<font class="error">'.$langs->trans("NoTypeDefinedGoToSetup").'</font>';
}
print "</td>\n";
// Address
print '<tr><td valign="top">'.$langs->trans("Address").'</td><td>';
print '<textarea name="adresse" wrap="soft" cols="40" rows="2">'.(isset($_POST["adresse"])?$_POST["adresse"]:$adh->adresse).'</textarea></td></tr>';
// CP / Ville
print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td><input type="text" name="cp" size="8" value="'.(isset($_POST["cp"])?$_POST["cp"]:$adh->cp).'"> <input type="text" name="ville" size="32" value="'.(isset($_POST["ville"])?$_POST["ville"]:$adh->ville).'"></td></tr>';
// Country
$adh->pays_id=$adh->pays_id?$adh->pays_id:$mysoc->pays_id;
print '<tr><td>'.$langs->trans("Country").'</td><td>';
$html->select_pays(isset($_POST["pays_id"])?$_POST["pays_id"]:$adh->pays_id,'pays_id',$conf->use_javascript_ajax?' onChange="company_save_refresh_create()"':'');
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
print '</td></tr>';
// State
print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">';
if ($adh->pays_id)
{
$htmlcompany->select_departement(isset($_POST["departement_id"])?$_POST["departement_id"]:$adh->fk_departement,$adh->pays_code);
}
else
{
print $countrynotdefined;
}
print '</td></tr>';
// Tel pro
print '<tr><td>'.$langs->trans("PhonePro").'</td><td><input type="text" name="phone" size="20" value="'.(isset($_POST["phone"])?$_POST["phone"]:$adh->phone).'"></td></tr>';
// Tel perso
print '<tr><td>'.$langs->trans("PhonePerso").'</td><td><input type="text" name="phone_perso" size="20" value="'.(isset($_POST["phone_perso"])?$_POST["phone_perso"]:$adh->phone_perso).'"></td></tr>';
// Tel mobile
print '<tr><td>'.$langs->trans("PhoneMobile").'</td><td><input type="text" name="phone_mobile" size="20" value="'.(isset($_POST["phone_mobile"])?$_POST["phone_mobile"]:$adh->phone_mobile).'"></td></tr>';
// EMail
print '<tr><td>'.($conf->global->ADHERENT_MAIL_REQUIRED?'<span class="fieldrequired">':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'</span>':'').'</td><td><input type="text" name="member_email" size="40" value="'.(isset($_POST["member_email"])?$_POST["member_email"]:$adh->email).'"></td></tr>';
// Date naissance
print "<tr><td>".$langs->trans("Birthday")."</td><td>\n";
$html->select_date(($adh->naiss ? $adh->naiss : -1),'naiss','','',1,'formsoc');
print "</td></tr>\n";
// Profil public
print "<tr><td>".$langs->trans("Public")."</td><td>\n";
print $html->selectyesno("public",$adh->public,1);
print "</td></tr>\n";
// Attribut optionnels
foreach($adho->attribute_label as $key=>$value)
{
print "<tr><td>".$value.'</td><td><input type="text" name="options_'.$key.'" size="40" value="'.(isset($_POST["options_".$key])?$_POST["options_".$key]:'').'"></td></tr>'."\n";
}
/*
// Third party Dolibarr
if ($conf->societe->enabled)
{
print '<tr><td>'.$langs->trans("LinkedToDolibarrThirdParty").'</td><td class="valeur">';
print $html->select_societes($adh->fk_soc,'socid','',1);
print '</td></tr>';
}
// Login Dolibarr
print '<tr><td>'.$langs->trans("LinkedToDolibarrUser").'</td><td class="valeur">';
print $html->select_users($adh->user_id,'userid',1);
print '</td></tr>';
*/
print "</table>\n";
print '<br>';
print '<center><input type="submit" class="button" value="'.$langs->trans("AddMember").'"></center>';
print "</form>\n";
}
if ($rowid && $action != 'edit')
{
/* ************************************************************************** */
@@ -1118,11 +1110,27 @@ if ($rowid && $action != 'edit')
{
$langs->load("mails");
$adht = new AdherentType($db);
$adht->fetch($adh->typeid);
$subjecttosend=$adh->makeSubstitution($conf->global->ADHERENT_MAIL_VALID_SUBJECT);
$texttosend=$adh->makeSubstitution($adht->getMailOnValid());
$tmp=$langs->trans("SendAnEMailToMember");
$tmp.=' ('.$langs->trans("MailFrom").': <b>'.$conf->global->ADHERENT_MAIL_FROM.'</b>, ';
$tmp.=$langs->trans("MailRecipient").': <b>'.$adh->email.'</b>)';
$helpcontent='';
$helpcontent.='<b>'.$langs->trans("MailFrom").'</b>: '.$conf->global->ADHERENT_MAIL_FROM.'<br>'."\n";
$helpcontent.='<b>'.$langs->trans("MailRecipient").'</b>: '.$adh->email.'<br>'."\n";
$helpcontent.='<b>'.$langs->trans("Subject").'</b>:<br>'."\n";
$helpcontent.=$subjecttosend."\n";
$helpcontent.="<br>";
$helpcontent.='<b>'.$langs->trans("Content").'</b>:<br>';
$helpcontent.=dol_htmlentitiesbr($texttosend)."\n";
$label=$html->textwithpicto($tmp,$helpcontent,1,'help');
// Cree un tableau formulaire
$formquestion=array();
$label=$langs->trans("SendAnEMailToMember");
$label.=' ('.$langs->trans("MailFrom").': <b>'.$conf->global->ADHERENT_MAIL_FROM.'</b>, ';
$label.=$langs->trans("MailRecipient").': <b>'.$adh->email.'</b>)';
if ($adh->email) $formquestion[0]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => ($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL?true:false));
$ret=$html->form_confirm("fiche.php?rowid=$rowid",$langs->trans("ValidateMember"),$langs->trans("ConfirmValidateMember"),"confirm_valid",$formquestion);
if ($ret == 'html') print '<br>';
@@ -1131,7 +1139,7 @@ if ($rowid && $action != 'edit')
// Confirm send card by mail
if ($action == 'sendinfo')
{
$ret=$html->form_confirm("fiche.php?rowid=$rowid",$langs->trans("SendCardByMail"),$langs->trans("ConfirmSendCardByMail"),"confirm_sendinfo",'',0,1);
$ret=$html->form_confirm("fiche.php?rowid=$rowid",$langs->trans("SendCardByMail"),$langs->trans("ConfirmSendCardByMail",$adh->email),"confirm_sendinfo",'',0,1);
if ($ret == 'html') print '<br>';
}
@@ -1140,13 +1148,28 @@ if ($rowid && $action != 'edit')
{
$langs->load("mails");
$adht = new AdherentType($db);
$adht->fetch($adh->typeid);
$subjecttosend=$adh->makeSubstitution($conf->global->ADHERENT_MAIL_RESIL_SUBJECT);
$texttosend=$adh->makeSubstitution($adht->getMailOnResiliate());
$tmp=$langs->trans("SendAnEMailToMember");
$tmp.=' ('.$langs->trans("MailFrom").': <b>'.$conf->global->ADHERENT_MAIL_FROM.'</b>, ';
$tmp.=$langs->trans("MailRecipient").': <b>'.$adh->email.'</b>)';
$helpcontent='';
$helpcontent.='<b>'.$langs->trans("MailFrom").'</b>: '.$conf->global->ADHERENT_MAIL_FROM.'<br>'."\n";
$helpcontent.='<b>'.$langs->trans("MailRecipient").'</b>: '.$adh->email.'<br>'."\n";
$helpcontent.='<b>'.$langs->trans("Subject").'</b>:<br>'."\n";
$helpcontent.=$subjecttosend."\n";
$helpcontent.="<br>";
$helpcontent.='<b>'.$langs->trans("Content").'</b>:<br>';
$helpcontent.=dol_htmlentitiesbr($texttosend)."\n";
$label=$html->textwithpicto($tmp,$helpcontent,1,'help');
// Cree un tableau formulaire
$formquestion=array();
$label=$langs->trans("SendAnEMailToMember").' ('.$langs->trans("MailFrom").': <b>'.$conf->global->ADHERENT_MAIL_FROM.'</b>, ';
$label.=$langs->trans("MailRecipient").': <b>'.$adh->email.'</b>';
$label.=')';
if ($adh->email) $formquestion[0]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => ($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL?'true':'false'));
$ret=$html->form_confirm("fiche.php?rowid=$rowid",$langs->trans("ResiliateMember"),$langs->trans("ConfirmResiliateMember"),"confirm_resign",$formquestion);
if ($ret == 'html') print '<br>';
}

View File

@@ -121,8 +121,8 @@ class Form
}
/**
* \brief Old version of textwithtooltip. Kept for backward compatibility with modules for 2.6.
* \deprecated
* Old version of textwithtooltip. Kept for backward compatibility with modules for 2.6.
* @deprecated
*/
function textwithhelp($text,$htmltext,$tooltipon=1)
{
@@ -130,17 +130,17 @@ class Form
}
/**
* \brief Show a text and picto with tooltip on text or picto
* \param text Texte to show
* \param htmltext Contenu html du tooltip, code en Html / UTF8
* \param tooltipon 1=tooltip sur texte, 2=tooltip sur picto, 3=tooltip sur les 2, 4=tooltip sur les 2 et force en Ajax
* \param direction -1=Le picto est avant, 0=pas de picto, 1=le picto est apres
* \param img Code img du picto
* \param i Numero of tooltip
* \param width Width of tooltip
* \param shiftX Shift of tooltip
* \return string Code html du tooltip (texte+picto)
* \remarks Use function textwithpicto if you can.
* Show a text and picto with tooltip on text or picto
* @param text Texte to show
* @param htmltext Contenu html du tooltip, code en Html / UTF8
* @param tooltipon 1=tooltip sur texte, 2=tooltip sur picto, 3=tooltip sur les 2, 4=tooltip sur les 2 et force en Ajax
* @param direction -1=Le picto est avant, 0=pas de picto, 1=le picto est apres
* @param img Code img du picto (use img_xxx() function to get it)
* @param i Numero of tooltip
* @param width Width of tooltip
* @param shiftX Shift of tooltip
* @return string Code html du tooltip (texte+picto)
* @see Use function textwithpicto if you can.
*/
function textwithtooltip($text,$htmltext,$tooltipon=1,$direction=0,$img='',$i=1,$width='200',$shiftX='10')
{

View File

@@ -112,7 +112,7 @@ AddActionDone=Add action done
Close=Close
Close2=Close
Confirm=Confirm
ConfirmSendCardByMail=Do you really want to send this card by mail ?
ConfirmSendCardByMail=Do you really want to send content of this card by mail to <b>%s</b> ?
Delete=Delete
Remove=Remove
Resiliate=Resiliate

View File

@@ -111,7 +111,7 @@ AddActionDone=Ajouter action faite
Close=Clôturer
Close2=Fermer
Confirm=Confirmer
ConfirmSendCardByMail=Voulez vous envoyer cette fiche par mail ?
ConfirmSendCardByMail=Voulez vous envoyer le contenu de cette fiche par mail à l'adresse <b>%s</b> ?
Delete=Supprimer
Remove=Enlever
Resiliate=Résilier

View File

@@ -2853,15 +2853,16 @@ function dol_string_nohtmltag($StringHtml,$removelinefeed=1)
/**
* \brief Replace CRLF in string with a HTML BR tag.
* \param string2encode String to encode
* \param nl2brmode 0=Adding br before \n, 1=Replacing \n by br
* \param forxml false=Use <br>, true=Use <br />
* \return string String encoded
* Replace CRLF in string with a HTML BR tag.
* @param string2encode String to encode
* @param nl2brmode 0=Adding br before \n, 1=Replacing \n by br
* @param forxml false=Use <br>, true=Use <br />
* @return string String encoded
*/
function dol_nl2br($stringtoencode,$nl2brmode=0,$forxml=false)
{
if (! $nl2brmode) return nl2br($stringtoencode,$forxml);
// We use @ to avoid warning on PHP4 that does not support entity encoding from UTF8;
if (! $nl2brmode) return @nl2br($stringtoencode,$forxml);
else
{
$ret=str_replace("\r","",$stringtoencode);
@@ -2895,7 +2896,6 @@ function dol_htmlentitiesbr($stringtoencode,$nl2brmode=0,$pagecodefrom='UTF-8')
// If already HTML, CR should be <br> so we don't change \n
}
else {
// We use @ to avoid warning on PHP4 that does not support entity encoding from UTF8;
$newstring=dol_nl2br(dol_htmlentities($stringtoencode,ENT_COMPAT,$pagecodefrom),$nl2brmode);
}
// Other substitutions that htmlentities does not do
@@ -3083,28 +3083,31 @@ function dol_textishtml($msg,$option=0)
}
/**
* \brief Add substitution required by external modules then make substitutions.
* Add substitution required by external modules then make substitutions.
* There is two type of substitions:
* From substitutionarray (oldval=>newval)
* From special constants (__XXX__=>f(objet->xxx))
* \param chaine Source string in which we must do substitution
* \param substitutionarray Array substitution old value => new value value
* \param outputlangs If we want substitution from special constants, we provide a language
* \param object If we want substitution from special constants, we provide data in a source object
* \return string Output string after subsitutions
* - From $substitutionarray (oldval=>newval)
* - From special constants (__XXX__=>f(objet->xxx)) by substitutions modules
* @param chaine Source string in which we must do substitution
* @param substitutionarray Array substitution old value => new value value
* @param outputlangs If we want substitution from special constants, we provide a language
* @param object If we want substitution from special constants, we provide data in a source object
* @return string Output string after subsitutions
*/
function make_substitutions($chaine,$substitutionarray,$outputlangs,$object='')
{
global $conf,$user;
$dir=$dirroot."/includes/modules/substitutions";
$listfonc=array('numberwords'); // For the moment only one substitution module to search
foreach($listfonc as $fonc)
{
// Check if there is external substitution to do asked by plugins
// We look files into the includes/modules/substitutions directory
// By default, there is no such external plugins.
foreach ($conf->file->dol_document_root as $dirroot)
{
$dir=$dirroot."/includes/modules/substitutions";
$fonc='numberwords'; // For the moment only one file scan
if ($conf->$fonc->enabled && file_exists($dir.'/functions_'.$fonc.'.lib.php'))
// If module enabled and complete
if (! empty($conf->$fonc->enabled) && file_exists($dir.'/functions_'.$fonc.'.lib.php'))
{
dol_syslog("Library functions_".$fonc.".lib.php found into ".$dir);
require_once($dir."/functions_".$fonc.".lib.php");
@@ -3112,6 +3115,7 @@ function make_substitutions($chaine,$substitutionarray,$outputlangs,$object='')
break;
}
}
}
// Make substitition
foreach ($substitutionarray as $key => $value)
@@ -3123,12 +3127,10 @@ function make_substitutions($chaine,$substitutionarray,$outputlangs,$object='')
/**
* \brief Format output for start and end date
* \param date_start Start date
* \param date_end End date
* \param format Output format
* \remarks Updated by Matelli : added format paramter
* \remarks See http://matelli.fr/showcases/patchs-dolibarr/update-date-range-format.html for details
* Format output for start and end date
* @param date_start Start date
* @param date_end End date
* @param format Output format
*/
function print_date_range($date_start,$date_end,$format = '',$outputlangs='')
{