From c19eabf71115787a0cd9c5ec96a7ab21d24ac847 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 29 May 2014 14:26:27 +0200 Subject: [PATCH 01/10] Better target emailing status mangement --- htdocs/comm/mailing/cibles.php | 43 ++++++++--- htdocs/comm/mailing/class/mailing.class.php | 64 +++++++++++++++ htdocs/comm/mailing/fiche.php | 2 +- htdocs/core/class/html.formmailing.class.php | 77 +++++++++++++++++++ .../core/modules/mailings/pomme.modules.php | 2 +- 5 files changed, 177 insertions(+), 11 deletions(-) create mode 100644 htdocs/core/class/html.formmailing.class.php diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 93e66c0c497..b4a25e0cedd 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -2,6 +2,7 @@ /* Copyright (C) 2004 Rodolphe Quiedeville * Copyright (C) 2005-2013 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2014 Florian Henry * * 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 @@ -26,6 +27,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php'; require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmailing.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/emailing.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; @@ -54,6 +56,7 @@ $action=GETPOST("action"); $search_lastname=GETPOST("search_lastname"); $search_firstname=GETPOST("search_firstname"); $search_email=GETPOST("search_email"); +$search_dest_status=GETPOST('search_dest_status'); // Search modules dirs $modulesdir = dolGetModulesDirs('/mailings'); @@ -168,6 +171,7 @@ if ($_POST["button_removefilter"]) llxHeader('',$langs->trans("Mailing"),'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing'); $form = new Form($db); +$formmailing = new FormMailing($db); if ($object->fetch($id) >= 0) { @@ -220,7 +224,7 @@ if ($object->fetch($id) >= 0) $var=!$var; - $allowaddtarget=($object->statut == 0 || $object->statut == 1); + $allowaddtarget=($object->statut == 0); // Show email selectors if ($allowaddtarget && $user->rights->mailing->creer) @@ -357,6 +361,7 @@ if ($object->fetch($id) >= 0) if ($search_lastname) $sql.= " AND mc.lastname LIKE '%".$db->escape($search_lastname)."%'"; if ($search_firstname) $sql.= " AND mc.firstname LIKE '%".$db->escape($search_firstname)."%'"; if ($search_email) $sql.= " AND mc.email LIKE '%".$db->escape($search_email)."%'"; + if (!empty($search_dest_status)) $sql.= " AND mc.statut=".$db->escape($search_dest_status)." "; $sql .= $db->order($sortfield,$sortorder); $sql .= $db->plimit($conf->liste_limit+1, $offset); @@ -376,7 +381,9 @@ if ($object->fetch($id) >= 0) print ''; print ''; - $cleartext='
'.$langs->trans("ToClearAllRecipientsClickHere").': '.''; + if ($allowaddtarget) { + $cleartext='
'.$langs->trans("ToClearAllRecipientsClickHere").': '.''; + } print_barre_liste($langs->trans("MailSelectedRecipients").$cleartext,$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,"",$num,$object->nbemail,''); @@ -399,7 +406,7 @@ if ($object->fetch($id) >= 0) print_liste_field_titre($langs->trans("OtherInformations"),$_SERVER["PHP_SELF"],"",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Source"),$_SERVER["PHP_SELF"],"",$param,"",'align="center"',$sortfield,$sortorder); - // Date sendinf + // Date sending if ($object->statut < 2) { print ' '; @@ -412,6 +419,11 @@ if ($object->fetch($id) >= 0) // Statut print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"mc.statut",$param,'','align="right"',$sortfield,$sortorder); + //Search Icon + print ''; + print ' '; + print ''; + print ''; // Ligne des champs de filtres @@ -433,7 +445,20 @@ if ($object->fetch($id) >= 0) print ' '; print ''; // Source - print ''; + print ''; + print ' '; + print ''; + + // Date sending + print ''; + print ' '; + print ''; + //Statut + print ''; + print $formmailing->select_destinaries_status($search_dest_status,'search_dest_status',1); + print ''; + //Search Icon + print ''; print ''; print '  '; print ''; @@ -495,7 +520,7 @@ if ($object->fetch($id) >= 0) { print ' '; print ''.$langs->trans("MailingStatusNotSent"); - if ($user->rights->mailing->creer) { + if ($user->rights->mailing->creer && $allowaddtarget) { print ''.img_delete($langs->trans("RemoveRecipient")); } print ''; @@ -504,12 +529,12 @@ if ($object->fetch($id) >= 0) { print ''.$obj->date_envoi.''; print ''; - if ($obj->statut==-1) print $langs->trans("MailingStatusError").' '.img_error(); - if ($obj->statut==1) print $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"),'statut4'); - if ($obj->statut==2) print $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"),'statut6'); - if ($obj->statut==3) print $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"),'statut5'); + print $object::LibStatutDest($obj->statut,2); print ''; } + + //Sreach Icon + print ''; print ''; $i++; diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 99b1a2f4419..ac53567c3ca 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -60,6 +60,9 @@ class Mailing extends CommonObject var $extraparams=array(); + public $statut_dest=array(); + public $statuts=array(); + /** * Constructor @@ -75,6 +78,12 @@ class Mailing extends CommonObject $this->statuts[1] = 'MailingStatusValidated'; $this->statuts[2] = 'MailingStatusSentPartialy'; $this->statuts[3] = 'MailingStatusSentCompletely'; + + $this->statut_dest[-1] = 'MailingStatusError'; + $this->statut_dest[1] = 'MailingStatusSent'; + $this->statut_dest[2] = 'MailingStatusRead'; + $this->statut_dest[3] = 'MailingStatusNotContact'; + } /** @@ -512,5 +521,60 @@ class Mailing extends CommonObject } } + + /** + * Renvoi le libelle d'un statut donne + * + * @param int $statut Id statut + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label + */ + static public function LibStatutDest($statut,$mode=0) + { + global $langs; + $langs->load('mails'); + + if ($mode == 0) + { + return $langs->trans($this->statut_dest[$statut]); + } + if ($mode == 1) + { + return $langs->trans($this->statut_dest[$statut]); + } + if ($mode == 2) + { + if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error(); + if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"),'statut4'); + if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"),'statut6'); + if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"),'statut8'); + } + if ($mode == 3) + { + if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error(); + if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"),'statut4'); + if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"),'statut6'); + if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"),'statut8'); + } + if ($mode == 4) + { + if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error(); + if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"),'statut4'); + if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"),'statut6'); + if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"),'statut8'); + } + if ($mode == 5) + { + if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error(); + if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"),'statut4'); + if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"),'statut6'); + if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"),'statut8'); + } + + + + + } + } diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php index 6a49dd0865b..5d45877e707 100644 --- a/htdocs/comm/mailing/fiche.php +++ b/htdocs/comm/mailing/fiche.php @@ -839,7 +839,7 @@ else { print "\n\n
\n"; - if (($object->statut == 0 || $object->statut == 1) && $user->rights->mailing->creer) + if (($object->statut == 0) && $user->rights->mailing->creer) { print ''.$langs->trans("EditMailing").''; } diff --git a/htdocs/core/class/html.formmailing.class.php b/htdocs/core/class/html.formmailing.class.php new file mode 100644 index 00000000000..ccb91144a78 --- /dev/null +++ b/htdocs/core/class/html.formmailing.class.php @@ -0,0 +1,77 @@ +. +*/ + +/** + * \file htdocs/core/class/html.formmailing.class.php + * \ingroup core + * \brief File of predefined functions for HTML forms for mailing module + */ +require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php'; + +/** + * Class to offer components to list and upload files + */ +class FormMailing extends Form +{ + public $db; + public $error; + public $errors=array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + $this->db = $db; + return 1; + } + + public function select_destinaries_status($selectedid='',$htmlname='dest_status', $show_empty=0) { + + global $langs; + $langs->load("mails"); + + require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php'; + $mailing = new Mailing($this->db); + + + $array = $mailing->statut_dest; + //Cannot use form->selectarray because empty value is defaulted to -1 in this method and we use here status -1... + + $out = ''; + return $out; + } + +} \ No newline at end of file diff --git a/htdocs/core/modules/mailings/pomme.modules.php b/htdocs/core/modules/mailings/pomme.modules.php index e038cfd3ceb..90818d0c9f3 100644 --- a/htdocs/core/modules/mailings/pomme.modules.php +++ b/htdocs/core/modules/mailings/pomme.modules.php @@ -148,7 +148,7 @@ class mailing_pomme extends MailingTargets // La requete doit retourner: id, email, fk_contact, name, firstname $sql = "SELECT u.rowid as id, u.email as email, null as fk_contact,"; - $sql.= " u.lastname as name, u.firstname as firstname, u.civilite as civility_id, u.login, u.office_phone"; + $sql.= " u.lastname, u.firstname as firstname, u.civilite as civility_id, u.login, u.office_phone"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; $sql.= " WHERE u.email <> ''"; // u.email IS NOT NULL est implicite dans ce test $sql.= " AND u.entity IN (0,".$conf->entity.")"; From d15c3b2c23d68ab8ba40e9983bb41bdc496dab5f Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 29 May 2014 14:30:09 +0200 Subject: [PATCH 02/10] CRLF --- htdocs/core/class/html.formmailing.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/class/html.formmailing.class.php b/htdocs/core/class/html.formmailing.class.php index ccb91144a78..dc6c6eda79a 100644 --- a/htdocs/core/class/html.formmailing.class.php +++ b/htdocs/core/class/html.formmailing.class.php @@ -73,5 +73,4 @@ class FormMailing extends Form $out .= ''; return $out; } - } \ No newline at end of file From 0cfd4504adeaeaa46372609ed7cf34a1794b45a7 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 29 May 2014 14:48:07 +0200 Subject: [PATCH 03/10] add index on llx_mailing_cible --- htdocs/install/mysql/migration/3.5.0-3.6.0.sql | 2 ++ htdocs/install/mysql/tables/llx_mailing_cibles.key.sql | 2 ++ 2 files changed, 4 insertions(+) diff --git a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql index 176568def37..c1db2545929 100644 --- a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql +++ b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql @@ -1197,3 +1197,5 @@ create table llx_c_type_resource )ENGINE=innodb; ALTER TABLE llx_c_type_resource ADD UNIQUE INDEX uk_c_type_resource_id (label, code); + +ALTER TABLE llx_mailing_cibles ADD INDEX idx_mailing_cibles_fk_mailing_email (fk_mailing,email); \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_mailing_cibles.key.sql b/htdocs/install/mysql/tables/llx_mailing_cibles.key.sql index 721344355f4..1f005dff052 100644 --- a/htdocs/install/mysql/tables/llx_mailing_cibles.key.sql +++ b/htdocs/install/mysql/tables/llx_mailing_cibles.key.sql @@ -21,3 +21,5 @@ ALTER TABLE llx_mailing_cibles ADD UNIQUE uk_mailing_cibles (fk_mailing, email); ALTER TABLE llx_mailing_cibles ADD INDEX idx_mailing_cibles_email (email); +ALTER TABLE llx_mailing_cibles ADD INDEX idx_mailing_cibles_fk_mailing_email (fk_mailing,email); + From a88491ecc6f7652c7456b10c80e156fb187f0487 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 29 May 2014 14:51:42 +0200 Subject: [PATCH 04/10] reset last commit --- htdocs/install/mysql/tables/llx_mailing_cibles.key.sql | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/install/mysql/tables/llx_mailing_cibles.key.sql b/htdocs/install/mysql/tables/llx_mailing_cibles.key.sql index 1f005dff052..721344355f4 100644 --- a/htdocs/install/mysql/tables/llx_mailing_cibles.key.sql +++ b/htdocs/install/mysql/tables/llx_mailing_cibles.key.sql @@ -21,5 +21,3 @@ ALTER TABLE llx_mailing_cibles ADD UNIQUE uk_mailing_cibles (fk_mailing, email); ALTER TABLE llx_mailing_cibles ADD INDEX idx_mailing_cibles_email (email); -ALTER TABLE llx_mailing_cibles ADD INDEX idx_mailing_cibles_fk_mailing_email (fk_mailing,email); - From f87772f3ec3c469e91d9069b0cab23abcfbdd77b Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 29 May 2014 14:56:55 +0200 Subject: [PATCH 05/10] Add comment for travis --- htdocs/core/class/html.formmailing.class.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/core/class/html.formmailing.class.php b/htdocs/core/class/html.formmailing.class.php index dc6c6eda79a..14fbea3b0f9 100644 --- a/htdocs/core/class/html.formmailing.class.php +++ b/htdocs/core/class/html.formmailing.class.php @@ -43,6 +43,14 @@ class FormMailing extends Form return 1; } + /** + * Output a select with destinaries status + * + * @param string $selectedid the selected id + * @param string $htmlname name of controm + * @param number $show_empty show empty option + * @return string HTML select + */ public function select_destinaries_status($selectedid='',$htmlname='dest_status', $show_empty=0) { global $langs; From 0de66e838ce23ac7f270b70eb4e4810f5e14ca71 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 30 May 2014 12:01:26 +0200 Subject: [PATCH 06/10] camel case --- htdocs/comm/mailing/cibles.php | 4 ++-- htdocs/comm/mailing/class/mailing.class.php | 2 +- htdocs/core/class/html.formmailing.class.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 613c040b74c..14aea7c89c7 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -457,7 +457,7 @@ if ($object->fetch($id) >= 0) print ''; //Statut print ''; - print $formmailing->select_destinaries_status($search_dest_status,'search_dest_status',1); + print $formmailing->selectDestinariesStatus($search_dest_status,'search_dest_status',1); print ''; //Search Icon print ''; @@ -531,7 +531,7 @@ if ($object->fetch($id) >= 0) { print ''.$obj->date_envoi.''; print ''; - print $object::LibStatutDest($obj->statut,2); + print $object::libStatutDest($obj->statut,2); print ''; } diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index ac53567c3ca..1b2b26d7fd0 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -529,7 +529,7 @@ class Mailing extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label */ - static public function LibStatutDest($statut,$mode=0) + static public function libStatutDest($statut,$mode=0) { global $langs; $langs->load('mails'); diff --git a/htdocs/core/class/html.formmailing.class.php b/htdocs/core/class/html.formmailing.class.php index 14fbea3b0f9..98a76c84686 100644 --- a/htdocs/core/class/html.formmailing.class.php +++ b/htdocs/core/class/html.formmailing.class.php @@ -51,7 +51,7 @@ class FormMailing extends Form * @param number $show_empty show empty option * @return string HTML select */ - public function select_destinaries_status($selectedid='',$htmlname='dest_status', $show_empty=0) { + public function selectDestinariesStatus($selectedid='',$htmlname='dest_status', $show_empty=0) { global $langs; $langs->load("mails"); From c4912c5e25545e4f5b0bf1294d86a77d0e141aae Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 17 Jun 2014 12:20:41 +0200 Subject: [PATCH 07/10] travis --- htdocs/product/class/product.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 4654d1aabc3..f871d8197ba 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -940,14 +940,14 @@ class Product extends CommonObject /** * Update ou cree les traductions des infos produits * - * $langs_to_delete string code langue to delete - * @return int <0 if KO, >0 if OK + * @param $langstodelete string code langue to delete + * @return int <0 if KO, >0 if OK */ - function delMultiLangs($langs_to_delete) + function delMultiLangs($langstodelete) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_lang"; - $sql.= " WHERE fk_product=".$this->id." AND lang='".$langs_to_delete."'"; + $sql.= " WHERE fk_product=".$this->id." AND lang='".$langstodelete."'"; dol_syslog(get_class($this).'::delMultiLangs sql='.$sql); if (! $this->db->query($sql)) From 4b78c8e11a9b043f5ca77f2b58717671eafb5140 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 17 Jun 2014 12:21:34 +0200 Subject: [PATCH 08/10] comment method in english --- htdocs/product/class/product.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index f871d8197ba..e04d215768b 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -860,7 +860,7 @@ class Product extends CommonObject } /** - * Update ou cree les traductions des infos produits + * Update or create transltation for product * * @return int <0 if KO, >0 if OK */ @@ -938,7 +938,7 @@ class Product extends CommonObject } /** - * Update ou cree les traductions des infos produits + * Delete Translation * * @param $langstodelete string code langue to delete * @return int <0 if KO, >0 if OK From c2fc40d62a4e9cfdb6d5d70bca2ebd566740b501 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 17 Jun 2014 12:58:49 +0200 Subject: [PATCH 09/10] travis --- htdocs/product/class/product.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index e04d215768b..13492f89159 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -940,8 +940,8 @@ class Product extends CommonObject /** * Delete Translation * - * @param $langstodelete string code langue to delete - * @return int <0 if KO, >0 if OK + * @param string $langstodelete code langue to delete + * @return int <0 if KO, >0 if OK */ function delMultiLangs($langstodelete) { From 9bb537f399a37298dd658a5dc236c3d691758e96 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 18 Jun 2014 09:59:15 +0200 Subject: [PATCH 10/10] - New: If multilangue is enabled, mail (from propal, invoice, etc...) message is pre-defaulted in Customer language --- ChangeLog | 1 + htdocs/comm/propal.php | 20 +++++++++------ htdocs/commande/fiche.php | 17 +++++++------ htdocs/compta/facture.php | 17 +++++++------ htdocs/core/class/html.formmail.class.php | 30 ++++++++++++++++------- htdocs/expedition/fiche.php | 14 +++++++---- htdocs/fichinter/fiche.php | 14 +++++++---- htdocs/fourn/commande/fiche.php | 14 +++++++---- htdocs/fourn/facture/fiche.php | 14 +++++++---- htdocs/societe/soc.php | 9 +++++++ 10 files changed, 99 insertions(+), 51 deletions(-) diff --git a/ChangeLog b/ChangeLog index a17751c7fb1..35a30311aef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -66,6 +66,7 @@ For users: - Fix: Price min of composition is not supplier price min by quantity. - Fix: [ bug #1356 ] Bank accountancy number is limited to 8 numbers. - Fix: [ bug #1439 ] impossible to remove a a translation (multilanguage-feature) +- New: If multilangue is enabled, mail (from propal, invoice, etc...) message is pre-defaulted in Customer language TODO - New: Predefined product and free product use same form. diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index a9ec591cf5f..38925315fd4 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1974,21 +1974,24 @@ if ($action == 'create') { include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref, '/')); $file = $fileparams ['fullname']; + + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + $newlang = $_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; + // Build document if it not exists if (! $file || ! is_readable($file)) { - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) - $newlang = $_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; + if (! empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - + $result = propale_pdf_create($db, $object, GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { dol_print_error($db, $result); @@ -2004,6 +2007,7 @@ if ($action == 'create') { // Create form object include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $formmail = new FormMail($db); + $formmail->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang); $formmail->fromtype = 'user'; $formmail->fromid = $user->id; $formmail->fromname = $user->getFullName($langs); diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 7c1f0d30d25..0927f9b51dc 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -2270,16 +2270,18 @@ if ($action == 'create' && $user->rights->commande->creer) { include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; $fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($ref, '/')); $file = $fileparams ['fullname']; + + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + $newlang = $_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; // Build document if it not exists if (! $file || ! is_readable($file)) { - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) - $newlang = $_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; + if (! empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -2300,6 +2302,7 @@ if ($action == 'create' && $user->rights->commande->creer) { // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $formmail = new FormMail($db); + $formmail->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang); $formmail->fromtype = 'user'; $formmail->fromid = $user->id; $formmail->fromname = $user->getFullName($langs); diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index b6837d68a98..59df4f2e3be 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -3609,16 +3609,18 @@ if ($action == 'create') include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; $fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($ref, '/')); $file = $fileparams ['fullname']; + + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + $newlang = $_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; // Build document if it not exists if (! $file || ! is_readable($file)) { - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) - $newlang = $_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; + if (! empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -3639,6 +3641,7 @@ if ($action == 'create') // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $formmail = new FormMail($db); + $formmail->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang); $formmail->fromtype = 'user'; $formmail->fromid = $user->id; $formmail->fromname = $user->getFullName($langs); diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index b9f5e7e1bc1..21af36d5b76 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -554,17 +554,29 @@ class FormMail if (! empty($this->withbody)) { $defaultmessage=""; + + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $this->param['langsmodels']; + + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + // TODO A partir du type, proposer liste de messages dans table llx_c_email_template - if ($this->param["models"]=='facture_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoice"); } - elseif ($this->param["models"]=='facture_relance') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } - elseif ($this->param["models"]=='propal_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendProposal"); } - elseif ($this->param["models"]=='order_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendOrder"); } - elseif ($this->param["models"]=='order_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierOrder"); } - elseif ($this->param["models"]=='invoice_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierInvoice"); } - elseif ($this->param["models"]=='shipping_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendShipping"); } - elseif ($this->param["models"]=='fichinter_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendFichInter"); } - elseif ($this->param["models"]=='thirdparty') { $defaultmessage=$langs->transnoentities("PredefinedMailContentThirdparty"); } + if ($this->param["models"]=='facture_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendInvoice"); } + elseif ($this->param["models"]=='facture_relance') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } + elseif ($this->param["models"]=='propal_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendProposal"); } + elseif ($this->param["models"]=='order_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendOrder"); } + elseif ($this->param["models"]=='order_supplier_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendSupplierOrder"); } + elseif ($this->param["models"]=='invoice_supplier_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendSupplierInvoice"); } + elseif ($this->param["models"]=='shipping_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendShipping"); } + elseif ($this->param["models"]=='fichinter_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendFichInter"); } + elseif ($this->param["models"]=='thirdparty') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentThirdparty"); } elseif (! is_numeric($this->withbody)) { $defaultmessage=$this->withbody; } // Complete substitution array diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index 45208e77dbe..02c7a5670d1 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -1573,15 +1573,18 @@ else if ($id || $ref) include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $fileparams = dol_most_recent_file($conf->expedition->dir_output . '/sending/' . $ref, preg_quote($ref,'/')); $file=$fileparams['fullname']; + + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + $newlang = $_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; // Build document if it not exists if (! $file || ! is_readable($file)) { - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); @@ -1604,6 +1607,7 @@ else if ($id || $ref) // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); + $formmail->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang); $formmail->fromtype = 'user'; $formmail->fromid = $user->id; $formmail->fromname = $user->getFullName($langs); diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 7dae4a359ee..2af552b2537 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -1625,15 +1625,18 @@ else if ($id > 0 || ! empty($ref)) include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $fileparams = dol_most_recent_file($conf->ficheinter->dir_output . '/' . $ref, preg_quote($ref,'/')); $file=$fileparams['fullname']; + + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + $newlang = $_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; // Build document if it not exists if (! $file || ! is_readable($file)) { - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); @@ -1656,6 +1659,7 @@ else if ($id > 0 || ! empty($ref)) // Create form object include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); + $formmail->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang); $formmail->fromtype = 'user'; $formmail->fromid = $user->id; $formmail->fromname = $user->getFullName($langs); diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 22df11dd7ae..6d6b138c542 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -1975,14 +1975,17 @@ elseif (! empty($object->id)) $fileparams = dol_most_recent_file($conf->fournisseur->commande->dir_output . '/' . $ref, preg_quote($ref,'/')); $file=$fileparams['fullname']; + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + $newlang = $_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; + // Build document if it not exists if (! $file || ! is_readable($file)) { - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); @@ -2006,6 +2009,7 @@ elseif (! empty($object->id)) // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); + $formmail->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang); $formmail->fromtype = 'user'; $formmail->fromid = $user->id; $formmail->fromname = $user->getFullName($langs); diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 92c8be3469c..996af90f62f 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -2224,15 +2224,18 @@ else include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $fileparams = dol_most_recent_file($conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$ref, preg_quote($ref,'/')); $file=$fileparams['fullname']; + + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + $newlang = $_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; // Build document if it not exists if (! $file || ! is_readable($file)) { - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); @@ -2255,6 +2258,7 @@ else // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); + $formmail->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang); $formmail->fromtype = 'user'; $formmail->fromid = $user->id; $formmail->fromname = $user->getFullName($langs); diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index b88642cd83d..da6c7771eb3 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -1895,10 +1895,19 @@ else print '
'; print_titre($langs->trans($titreform)); + + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + $newlang = $_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) + $newlang = $object->client->default_lang; // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); + $formmail->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang); $formmail->fromtype = 'user'; $formmail->fromid = $user->id; $formmail->fromname = $user->getFullName($langs);