Skip to content

Commit

Permalink
- New: If multilangue is enabled, mail (from propal, invoice, etc...)
Browse files Browse the repository at this point in the history
message is pre-defaulted in Customer language
  • Loading branch information
FHenry committed Jun 18, 2014
1 parent c2fc40d commit 9bb537f
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 51 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Expand Up @@ -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.
Expand Down
20 changes: 12 additions & 8 deletions htdocs/comm/propal.php
Expand Up @@ -1974,21 +1974,24 @@
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);
Expand All @@ -2004,6 +2007,7 @@
// 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);
Expand Down
17 changes: 10 additions & 7 deletions htdocs/commande/fiche.php
Expand Up @@ -2270,16 +2270,18 @@
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);
Expand All @@ -2300,6 +2302,7 @@
// 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);
Expand Down
17 changes: 10 additions & 7 deletions htdocs/compta/facture.php
Expand Up @@ -3609,16 +3609,18 @@
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);
Expand All @@ -3639,6 +3641,7 @@
// 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);
Expand Down
30 changes: 21 additions & 9 deletions htdocs/core/class/html.formmail.class.php
Expand Up @@ -554,17 +554,29 @@ function get_form($addfileaction='addfile',$removefileaction='removefile')
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
Expand Down
14 changes: 9 additions & 5 deletions htdocs/expedition/fiche.php
Expand Up @@ -1573,15 +1573,18 @@
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);
Expand All @@ -1604,6 +1607,7 @@
// 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);
Expand Down
14 changes: 9 additions & 5 deletions htdocs/fichinter/fiche.php
Expand Up @@ -1625,15 +1625,18 @@
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);
Expand All @@ -1656,6 +1659,7 @@
// 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);
Expand Down
14 changes: 9 additions & 5 deletions htdocs/fourn/commande/fiche.php
Expand Up @@ -1975,14 +1975,17 @@
$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);
Expand All @@ -2006,6 +2009,7 @@
// 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);
Expand Down
14 changes: 9 additions & 5 deletions htdocs/fourn/facture/fiche.php
Expand Up @@ -2224,15 +2224,18 @@
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);
Expand All @@ -2255,6 +2258,7 @@
// 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);
Expand Down
9 changes: 9 additions & 0 deletions htdocs/societe/soc.php
Expand Up @@ -1895,10 +1895,19 @@

print '<br>';
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);
Expand Down

0 comments on commit 9bb537f

Please sign in to comment.