From 9d380a8b8acd5bc1cb4527d906d6c7195634e804 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 25 Aug 2017 16:38:45 +0200 Subject: [PATCH] NEW Can edit the language into the email templates editor. --- htdocs/admin/mails_templates.php | 95 ++++++++++++---------- htdocs/core/class/html.formadmin.class.php | 7 +- 2 files changed, 54 insertions(+), 48 deletions(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index f0cbb91c6c3..5e309eab48c 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -45,6 +45,7 @@ $langs->load("errors"); $langs->load("admin"); $langs->load("main"); $langs->load("mails"); +$langs->load("languages"); $action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view'; $confirm=GETPOST('confirm','alpha'); @@ -85,17 +86,17 @@ $tabsqlsort[25]="label ASC"; // Nom des champs en resultat de select pour affichage du dictionnaire $tabfield=array(); -$tabfield[25]= "label,type_template,private,position,topic,content"; +$tabfield[25]= "label,type_template,lang,private,position,topic,content"; if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) $tabfield[25].=',content_lines'; // Nom des champs d'edition pour modification d'un enregistrement $tabfieldvalue=array(); -$tabfieldvalue[25]= "label,type_template,private,position,topic,content"; +$tabfieldvalue[25]= "label,type_template,lang,private,position,topic,content"; if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) $tabfieldvalue[25].=',content_lines'; // Nom des champs dans la table pour insertion d'un enregistrement $tabfieldinsert=array(); -$tabfieldinsert[25]= "label,type_template,private,position,topic,content"; +$tabfieldinsert[25]= "label,type_template,lang,private,position,topic,content"; if (! empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) $tabfieldinsert[25].=',content_lines'; $tabfieldinsert[25].=',entity'; // Must be at end because not into other arrays @@ -144,16 +145,16 @@ $sourceList=array(); // We save list of template email Dolibarr can manage. This list can found by a grep into code on "->param['models']" $elementList = array(); -if ($conf->propal->enabled) $elementList['propal_send']=$langs->trans('MailToSendProposal'); -if ($conf->commande->enabled) $elementList['order_send']=$langs->trans('MailToSendOrder'); -if ($conf->facture->enabled) $elementList['facture_send']=$langs->trans('MailToSendInvoice'); -if ($conf->expedition->enabled) $elementList['shipping_send']=$langs->trans('MailToSendShipment'); -if ($conf->ficheinter->enabled) $elementList['fichinter_send']=$langs->trans('MailToSendIntervention'); +if ($conf->propal->enabled) $elementList['propal_send']=$langs->trans('MailToSendProposal'); +if ($conf->commande->enabled) $elementList['order_send']=$langs->trans('MailToSendOrder'); +if ($conf->facture->enabled) $elementList['facture_send']=$langs->trans('MailToSendInvoice'); +if ($conf->expedition->enabled) $elementList['shipping_send']=$langs->trans('MailToSendShipment'); +if ($conf->ficheinter->enabled) $elementList['fichinter_send']=$langs->trans('MailToSendIntervention'); if ($conf->supplier_proposal->enabled) $elementList['supplier_proposal_send']=$langs->trans('MailToSendSupplierRequestForQuotation'); -if ($conf->fournisseur->enabled) $elementList['order_supplier_send']=$langs->trans('MailToSendSupplierOrder'); -if ($conf->fournisseur->enabled) $elementList['invoice_supplier_send']=$langs->trans('MailToSendSupplierInvoice'); -if ($conf->societe->enabled) $elementList['thirdparty']=$langs->trans('MailToThirdparty'); -if ($conf->contrat->enabled) $elementList['contract']=$langs->trans('MailToSendContract'); +if ($conf->fournisseur->enabled) $elementList['order_supplier_send']=$langs->trans('MailToSendSupplierOrder'); +if ($conf->fournisseur->enabled) $elementList['invoice_supplier_send']=$langs->trans('MailToSendSupplierInvoice'); +if ($conf->societe->enabled) $elementList['thirdparty']=$langs->trans('MailToThirdparty'); +if ($conf->contrat->enabled) $elementList['contract']=$langs->trans('MailToSendContract'); $parameters=array('elementList'=>$elementList); $reshook=$hookmanager->executeHooks('emailElementlist',$parameters); // Note that $action and $object may have been modified by some hooks @@ -204,7 +205,7 @@ if (empty($reshook)) if ($value == 'content') $value='content-'.$rowid; if ($value == 'content_lines') $value='content_lines-'.$rowid; - if (! isset($_POST[$value]) || $_POST[$value]=='') + if (! isset($_POST[$value]) || ($_POST[$value]=='' && $value!='lang')) { $ok=0; $fieldnamekey=$listfield[$f]; @@ -434,16 +435,13 @@ if ($action == 'delete') //var_dump($elementList); -$sql="SELECT rowid as rowid, label, type_template, private, position, topic, content_lines, content, active"; +$sql="SELECT rowid as rowid, label, type_template, lang, private, position, topic, content_lines, content, active"; $sql.=" FROM ".MAIN_DB_PREFIX."c_email_templates"; $sql.=" WHERE entity IN (".getEntity('email_template').")"; if ($search_label) $sql.=natural_search('label', $search_label); - -if ($search_country_id > 0) +if (empty($conf->global->MAIN_MULTILANGS)) { - if (preg_match('/ WHERE /',$sql)) $sql.= " AND "; - else $sql.=" WHERE "; - $sql.= " c.rowid = ".$search_country_id; + $sql.= " AND (lang = '".$langs->defaultlang."' OR lang IS NULL)"; } if ($sortfield) @@ -469,21 +467,21 @@ $sql.=$db->plimit($listlimit+1,$offset); $fieldlist=explode(',',$tabfield[$id]); -print '
'; -print ''; -print ''; - -print ''; - // Form to add a new line $alabelisused=0; $var=false; $fieldlist=explode(',',$tabfield[$id]); -if ($action != 'edit') -{ - // Line for title +//if ($action != 'edit') +//{ + print ''; + print ''; + print ''; + + print '
'; + + // Line for title print ''; foreach ($fieldlist as $field => $value) { @@ -593,12 +591,13 @@ if ($action != 'edit') $colspan=count($fieldlist)+1; //print ''; // Keep   to have a line with enough height -} -print '
 
'; -print '
'; + print ''; -print '
'; + print ''; + + print '
'; +//} print '
'; print ''; @@ -732,15 +731,15 @@ if ($resql) // Show value for field if ($showfield) { - print ''; // To create an artificial CR for the current tr we are on + print ''; + print ''; // To create an artificial CR for the current tr we are on $okforextended = true; - if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) - $okforextended = false; - $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_6, '90%'); - print $doleditor->Create(1); - print ''; - print ''; - + if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $okforextended = false; + $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (! empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_6, '90%'); + print $doleditor->Create(1); + print ''; + print ''; + print ''; } } } @@ -764,12 +763,16 @@ if ($resql) { $valuetoshow = isset($elementList[$valuetoshow])?$elementList[$valuetoshow]:$valuetoshow; } + if ($value == 'lang' && $valuetoshow) + { + $valuetoshow = $valuetoshow.' - '.$langs->trans("Language_".$valuetoshow); + } $class='tddict'; // Show value for field if ($showfield) { - print ''.$valuetoshow.''; + print ''.$valuetoshow.''; } } } @@ -884,7 +887,15 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') if ($fieldlist[$field] == 'lang') { print ''; - print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT,'lang'); + if (! empty($conf->global->MAIN_MULTILANGS)) + { + print $formadmin->select_language($langs->defaultlang,'lang'); + } + else + { + //print $langs->defaultlang.' - '.$langs->trans('Language_'.$langs->defaultlang); + print ''; + } print ''; } // Le type de template diff --git a/htdocs/core/class/html.formadmin.class.php b/htdocs/core/class/html.formadmin.class.php index 16a16719366..459f256918c 100644 --- a/htdocs/core/class/html.formadmin.class.php +++ b/htdocs/core/class/html.formadmin.class.php @@ -85,16 +85,11 @@ class FormAdmin asort($langs_available); - $uncompletelanguages=array('da_DA','fi_FI','hu_HU','is_IS','pl_PL','ro_RO','ru_RU','sv_SV','tr_TR','zh_CN'); foreach ($langs_available as $key => $value) { $valuetoshow=$value; if ($showcode) $valuetoshow=$key.' - '.$value; - - if ($showwarning && in_array($key,$uncompletelanguages)) - { - //$value.=' - '.$langs->trans("TranslationUncomplete",$key); - } + if ($filter && is_array($filter)) { if ( ! array_key_exists($key, $filter))