diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php
index 44a12293e67..f7b900feaa4 100644
--- a/htdocs/adherents/card.php
+++ b/htdocs/adherents/card.php
@@ -40,6 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
@@ -311,8 +312,8 @@ if (empty($reshook)) {
//$object->twitter = trim(GETPOST("twitter", 'alpha'));
//$object->facebook = trim(GETPOST("facebook", 'alpha'));
//$object->linkedin = trim(GETPOST("linkedin", 'alpha'));
- $object->birth = $birthdate;
-
+ $object->birth = $birthdate;
+ $object->default_lang = GETPOST('default_lang', 'alpha');
$object->typeid = GETPOST("typeid", 'int');
//$object->note = trim(GETPOST("comment","alpha"));
$object->morphy = GETPOST("morphy", 'alpha');
@@ -457,6 +458,7 @@ if (empty($reshook)) {
$userid = GETPOST("userid", 'int');
$socid = GETPOST("socid", 'int');
+ $default_lang = GETPOST('default_lang', 'alpha');
$object->civility_id = $civility_id;
$object->firstname = $firstname;
@@ -498,7 +500,7 @@ if (empty($reshook)) {
$object->user_id = $userid;
$object->socid = $socid;
$object->public = $public;
-
+ $object->default_lang = $default_lang;
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) {
@@ -899,6 +901,7 @@ if (empty($reshook)) {
$form = new Form($db);
$formfile = new FormFile($db);
+$formadmin = new FormAdmin($db);
$formcompany = new FormCompany($db);
$title = $langs->trans("Member")." - ".$langs->trans("Card");
@@ -1363,6 +1366,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print $form->selectDate(($object->birth ? $object->birth : -1), 'birth', '', '', 1, 'formsoc');
print "\n";
+ // Default language
+ if (!empty($conf->global->MAIN_MULTILANGS)) {
+ print '
| '.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).' | '."\n";
+ print img_picto('', 'language').$formadmin->select_language($object->default_lang, 'default_lang', 0, 0, 1);
+ print ' | ';
+ print '
';
+ }
+
// Public profil
print "| ".$langs->trans("Public")." | \n";
print $form->selectyesno("public", (GETPOSTISSET("public") ? GETPOST("public", 'alphanohtml', 2) : $object->public), 1);
@@ -1803,6 +1814,19 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
// Birth Date
print ' |
| '.$langs->trans("DateOfBirth").' | '.dol_print_date($object->birth, 'day').' |
';
+ // Default language
+ if (!empty($conf->global->MAIN_MULTILANGS)) {
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+ print '| '.$langs->trans("DefaultLang").' | ';
+ //$s=picto_from_langcode($object->default_lang);
+ //print ($s?$s.' ':'');
+ $langs->load("languages");
+ $labellang = ($object->default_lang ? $langs->trans('Language_'.$object->default_lang) : '');
+ print picto_from_langcode($object->default_lang, 'class="paddingrightonly saturatemedium opacitylow"');
+ print $labellang;
+ print ' |
';
+ }
+
// Public
print '| '.$langs->trans("Public").' | '.yn($object->public).' |
';
diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php
index dec7584b68e..318dc4ac794 100644
--- a/htdocs/adherents/class/adherent.class.php
+++ b/htdocs/adherents/class/adherent.class.php
@@ -215,6 +215,12 @@ class Adherent extends CommonObject
*/
public $public;
+ /**
+ * Default language code of member (en_US, ...)
+ * @var string
+ */
+ public $default_lang;
+
/**
* @var string photo of member
*/
@@ -328,6 +334,7 @@ class Adherent extends CommonObject
'photo' => array('type' => 'varchar(255)', 'label' => 'Photo', 'enabled' => 1, 'visible' => -1, 'position' => 135),
'public' => array('type' => 'smallint(6)', 'label' => 'Public', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 145),
'datefin' => array('type' => 'datetime', 'label' => 'DateEnd', 'enabled' => 1, 'visible' => -1, 'position' => 150),
+ 'default_lang' =>array('type'=>'varchar(6)', 'label'=>'Default lang', 'enabled'=>1, 'visible'=>-1, 'position'=> 153),
'note_private' => array('type' => 'text', 'label' => 'NotePublic', 'enabled' => 1, 'visible' => 0, 'position' => 155),
'note_public' => array('type' => 'text', 'label' => 'NotePrivate', 'enabled' => 1, 'visible' => 0, 'position' => 160),
'datevalid' => array('type' => 'datetime', 'label' => 'DateValidation', 'enabled' => 1, 'visible' => -1, 'position' => 165),
@@ -710,9 +717,11 @@ class Adherent extends CommonObject
$sql .= ", photo = ".($this->photo ? "'".$this->db->escape($this->photo)."'" : "null");
$sql .= ", public = '".$this->db->escape($this->public)."'";
$sql .= ", statut = ".$this->db->escape($this->statut);
+ $sql .= ", default_lang = ".(!empty($this->default_lang) ? "'".$this->db->escape($this->default_lang)."'" : "null");
$sql .= ", fk_adherent_type = ".$this->db->escape($this->typeid);
$sql .= ", morphy = '".$this->db->escape($this->morphy)."'";
$sql .= ", birth = ".($this->birth ? "'".$this->db->idate($this->birth)."'" : "null");
+
if ($this->datefin) {
$sql .= ", datefin = '".$this->db->idate($this->datefin)."'"; // Must be modified only when deleting a subscription
}
@@ -833,6 +842,8 @@ class Adherent extends CommonObject
$luser->office_phone = $this->phone;
$luser->user_mobile = $this->phone_mobile;
+ $luser->lang = $this->default_lang;
+
$luser->fk_member = $this->id;
$result = $luser->update($user, 0, 1, 1); // Use nosync to 1 to avoid cyclic updates
@@ -868,6 +879,7 @@ class Adherent extends CommonObject
$lthirdparty->state_id = $this->state_id;
$lthirdparty->country_id = $this->country_id;
//$lthirdparty->phone_mobile=$this->phone_mobile;
+ $lthirdparty->default_lang = $this->default_lang;
$result = $lthirdparty->update($this->fk_soc, $user, 0, 1, 1, 'update'); // Use sync to 0 to avoid cyclic updates
@@ -1314,7 +1326,7 @@ class Adherent extends CommonObject
$sql .= " d.photo, d.fk_adherent_type, d.morphy, d.entity,";
$sql .= " d.datec as datec,";
$sql .= " d.tms as datem,";
- $sql .= " d.datefin as datefin,";
+ $sql .= " d.datefin as datefin, d.default_lang,";
$sql .= " d.birth as birthday,";
$sql .= " d.datevalid as datev,";
$sql .= " d.country,";
@@ -1407,6 +1419,8 @@ class Adherent extends CommonObject
$this->date_validation = $this->db->jdate($obj->datev);
$this->birth = $this->db->jdate($obj->birthday);
+ $this->default_lang = $obj->default_lang;
+
$this->note_private = $obj->note_private;
$this->note_public = $obj->note_public;
$this->morphy = $obj->morphy;
@@ -2556,6 +2570,7 @@ class Adherent extends CommonObject
$this->datefin = $now;
$this->datevalid = $now;
+ $this->default_lang = '';
$this->typeid = 1; // Id type adherent
$this->type = 'Type adherent'; // Libelle type adherent