diff --git a/ChangeLog b/ChangeLog index a5dcdbed28b..c31068aaa08 100644 --- a/ChangeLog +++ b/ChangeLog @@ -65,6 +65,8 @@ For users: - Fix: Add actions events not implemented. - 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/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index d6599f204f1..14aea7c89c7 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'); @@ -170,6 +173,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) { @@ -222,7 +226,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) @@ -359,6 +363,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); @@ -378,7 +383,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,''); @@ -401,7 +408,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 ' '; @@ -414,6 +421,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 @@ -435,7 +447,20 @@ if ($object->fetch($id) >= 0) print ' '; print ''; // Source - print ''; + print ''; + print ' '; + print ''; + + // Date sending + print ''; + print ' '; + print ''; + //Statut + print ''; + print $formmailing->selectDestinariesStatus($search_dest_status,'search_dest_status',1); + print ''; + //Search Icon + print ''; print ''; print '  '; print ''; @@ -497,7 +522,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 ''; @@ -506,12 +531,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..1b2b26d7fd0 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 d803de28357..217997ef830 100644 --- a/htdocs/comm/mailing/fiche.php +++ b/htdocs/comm/mailing/fiche.php @@ -840,7 +840,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/comm/propal.php b/htdocs/comm/propal.php index 63220ce415e..dbc76feeeef 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1982,21 +1982,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); @@ -2012,6 +2015,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 f327eb0252d..8e8fb94c0c7 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -2378,16 +2378,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); @@ -2408,6 +2410,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 e03f381ba22..450e9e86762 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -3615,16 +3615,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); @@ -3645,6 +3647,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 9d80ced54e3..75f6e80c111 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/core/class/html.formmailing.class.php b/htdocs/core/class/html.formmailing.class.php new file mode 100644 index 00000000000..98a76c84686 --- /dev/null +++ b/htdocs/core/class/html.formmailing.class.php @@ -0,0 +1,84 @@ +. +*/ + +/** + * \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; + } + + /** + * 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 selectDestinariesStatus($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 3c0238da902..f215b2d7110 100644 --- a/htdocs/core/modules/mailings/pomme.modules.php +++ b/htdocs/core/modules/mailings/pomme.modules.php @@ -144,12 +144,12 @@ class mailing_pomme extends MailingTargets { global $conf, $langs; $langs->load("companies"); - + $cibles = array(); // La requete doit retourner: id, email, fk_contact, lastname, firstname $sql = "SELECT u.rowid as id, u.email as email, null as fk_contact,"; - $sql.= " u.lastname as lastname, 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.")"; diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index 9a52ce47788..89d0995fb45 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 551aa7b94a5..00d4e35df8e 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -1623,15 +1623,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); @@ -1654,6 +1657,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 ff77552ac69..0c975158474 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -1988,14 +1988,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); @@ -2019,6 +2022,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 568ea79df5c..fde8b63e299 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -2239,15 +2239,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); @@ -2270,6 +2273,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/install/mysql/migration/3.5.0-3.6.0.sql b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql index bc2a62ea929..3934401267b 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 @@ -1200,5 +1200,4 @@ ALTER TABLE llx_c_type_resource ADD UNIQUE INDEX uk_c_type_resource_id (label, c -- Fix: Missing instruction not correctly done into 3.5 -- VPGSQL8.2 ALTER TABLE llx_facture_fourn ALTER fk_mode_reglement DROP NOT NULL; --- VPGSQL8.2 ALTER TABLE llx_facture_fourn ALTER fk_cond_reglement DROP NOT NULL; - +-- VPGSQL8.2 ALTER TABLE llx_facture_fourn ALTER fk_cond_reglement DROP NOT NULL; \ No newline at end of file diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index cee5c72abea..fe985fa163e 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -8,6 +8,7 @@ * Copyright (C) 2013-2014 Cedric GROSS * Copyright (C) 2013 Marcos GarcĂ­a * Copyright (C) 2011-2014 Alexandre Spangaro + * Copyright (C) 2014 Henry Florian * * 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 @@ -939,7 +940,7 @@ class Product extends CommonObject /** * Delete a language for this product * - * @param string $langtodelete Language to delete + * @param string $langtodelete Language code to delete * @return int <0 if KO, >0 if OK */ function delMultiLangs($langtodelete) @@ -947,7 +948,7 @@ class Product extends CommonObject $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_lang"; $sql.= " WHERE fk_product=".$this->id." AND lang='".$this->db->escape($langtodelete)."'"; - dol_syslog("Delete translation sql=".$sql); + dol_syslog(get_class($this).'::delMultiLangs sql='.$sql); $result = $this->db->query($sql); if ($result) { @@ -955,7 +956,8 @@ class Product extends CommonObject } else { - $this->error="Error: ".$this->db->error()." - ".$sql; + $this->error=$this->db->lasterror(); + dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR); return -1; } } diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php index f273eef35bf..cd7e4cdcb3c 100644 --- a/htdocs/product/traduction.php +++ b/htdocs/product/traduction.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2007 Rodolphe Quiedeville * Copyright (C) 2010-2012 Destailleur Laurent + * Copyright (C) 2014 Henry Florian * * 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 @@ -62,7 +63,7 @@ if ($action == 'delete' && GETPOST('langtodelete','alpha')) $product->delMultiLangs(GETPOST('langtodelete','alpha')); } -// Validation de l'ajout +// Add translation if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && ($user->rights->produit->creer || $user->rights->service->creer)) @@ -93,11 +94,11 @@ $cancel != $langs->trans("Cancel") && else { $action = 'add'; - $mesg = '
'.$product->error.'
'; + setEventMessage($product->error,'errors'); } } -// Validation de l'edition +// Edit translation if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && ($user->rights->produit->creer || $user->rights->service->creer)) @@ -129,7 +130,28 @@ $cancel != $langs->trans("Cancel") && else { $action = 'edit'; - $mesg = '
'.$product->error.'
'; + setEventMessage($product->error,'errors'); + } +} + +// Delete translation +if ($action == 'vdelete' && +$cancel != $langs->trans("Cancel") && +($user->rights->produit->creer || $user->rights->service->creer)) +{ + $product = new Product($db); + $product->fetch($id); + $langtodelete=GETPOST('langdel','alpha'); + + + if ( $product->delMultiLangs($langtodelete) > 0 ) + { + $action = ''; + } + else + { + $action = 'edit'; + setEventMessage($product->error,'errors'); } } @@ -151,10 +173,6 @@ $titre=$langs->trans("CardProduct".$product->type); $picto=($product->type==1?'service':'product'); dol_fiche_head($head, 'translation', $titre, 0, $picto); -if (! empty($mesg)) { - dol_htmloutput_mesg($mesg); -} - print ''; // Reference @@ -194,7 +212,7 @@ if ($action == 'edit') $doleditor->Create(); print ''; - print ''; + print ''; print '
'.$langs->trans("Delete").'
'; } } 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);