From 251fedad480b75dc2f40e9bb37f4b8087ac46f06 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 4 Jul 2015 11:57:55 +0200 Subject: [PATCH] NEW Can edit email template using WYSIWYG editor --- htdocs/admin/dict.php | 56 +++++++++++++++++----- htdocs/comm/propal/list.php | 6 +-- htdocs/commande/list.php | 9 ++-- htdocs/compta/facture/list.php | 6 +-- htdocs/core/class/html.form.class.php | 7 +-- htdocs/core/class/html.formother.class.php | 5 +- htdocs/core/menus/standard/eldy.lib.php | 2 +- 7 files changed, 64 insertions(+), 27 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index bc9e855046d..ff99ce5e4bf 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -34,6 +34,7 @@ require '../main.inc.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/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $langs->load("errors"); $langs->load("admin"); @@ -833,7 +834,6 @@ if ($action == 'delete') */ if ($id) { - // Complete requete recherche valeurs avec critere de tri $sql=$tabsql[$id]; @@ -944,7 +944,7 @@ if ($id) if ($id == 4) print ''; print ''; print ''; - print ' '; + print ''; print ''; // Line to enter new values @@ -966,25 +966,37 @@ if ($id) $reshook=$hookmanager->executeHooks('createDictionaryFieldlist',$parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $error=$hookmanager->error; $errors=$hookmanager->errors; - if ($id == 3) + if ($id == 3) unset($fieldlist[2]); + + if (empty($reshook)) { - unset($fieldlist[2]); + if ($tabname[$id] == MAIN_DB_PREFIX.'c_email_templates' && $action == 'edit') + { + fieldList($fieldlist,$obj,$tabname[$id],'hide'); + } + else + { + fieldList($fieldlist,$obj,$tabname[$id],'add'); + } } - if (empty($reshook)) fieldList($fieldlist,$obj); - if ($id == 4) print ''; - print ''; + print ''; + if ($tabname[$id] != MAIN_DB_PREFIX.'c_email_templates' || $action != 'edit') + { + print ''; + } + print ''; print ""; $colspan=count($fieldlist)+2; if ($id == 4) $colspan++; - if (! empty($alabelisused)) // Si un des champs est un libelle + if (! empty($alabelisused) && $id != 25) // If there is one label among fields, we show legend of * { print '* '.$langs->trans("LabelUsedByDefault").'.'; } - print ' '; + print ' '; // Keep   to have a line with enough height } print ''; @@ -1099,7 +1111,7 @@ if ($id) $reshook=$hookmanager->executeHooks('editDictionaryFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $error=$hookmanager->error; $errors=$hookmanager->errors; - if (empty($reshook)) fieldList($fieldlist,$obj,$tabname[$id]); + if (empty($reshook)) fieldList($fieldlist,$obj,$tabname[$id],'edit'); print ' '; print ' '; @@ -1419,14 +1431,16 @@ $db->close(); * @param array $fieldlist Array of fields * @param Object $obj If we show a particular record, obj is filled with record fields * @param string $tabname Name of SQL table + * @param string $context 'add'=Output field for the "add form", 'edit'=Output field for the "edit form", 'hide'=Output field for the "add form" but we dont want it to be rendered * @return void */ -function fieldList($fieldlist,$obj='',$tabname='') +function fieldList($fieldlist, $obj='', $tabname='', $context='') { global $conf,$langs,$db; global $form; global $region_id; global $elementList,$sourceList,$localtax_typeList; + global $bc; $formadmin = new FormAdmin($db); $formcompany = new FormCompany($db); @@ -1515,9 +1529,25 @@ function fieldList($fieldlist,$obj='',$tabname='') print ''; print ''; } - elseif (in_array($fieldlist[$field], array('libelle_facture','content'))) { + elseif (in_array($fieldlist[$field], array('libelle_facture'))) { print ''; } + elseif (in_array($fieldlist[$field], array('content'))) + { + if ($tabname == MAIN_DB_PREFIX.'c_email_templates') + { + print ''; // To create an artificial CR for the current tr we are on + } + else print ''; + if ($context != 'hide') + { + //print ''; + $doleditor = new DolEditor($fieldlist[$field], (! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:''), '', 140, 'dolibarr_mailings', 'In', 0, false, true, ROWS_5, '90%'); + print $doleditor->Create(1); + } + else print ' '; + print ''; + } elseif ($fieldlist[$field] == 'price' || preg_match('/^amount/i',$fieldlist[$field])) { print ''; } @@ -1546,6 +1576,8 @@ function fieldList($fieldlist,$obj='',$tabname='') { print ''; $size=''; + if ($fieldlist[$field]=='code') $size='size="8" '; + if ($fieldlist[$field]=='position') $size='size="4" '; if ($fieldlist[$field]=='libelle') $size='size="32" '; if ($fieldlist[$field]=='tracking') $size='size="92" '; if ($fieldlist[$field]=='accountancy_code') $size='size="10" '; diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 36484d718c7..5a5e520d455 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2013 Regis Houssin @@ -272,7 +272,7 @@ if ($result) $langs->load("commercial"); $moreforfilter.='
'; $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; - $moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user); + $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth300'); $moreforfilter.='
'; } // If the user can view prospects other than his' @@ -280,7 +280,7 @@ if ($result) { $moreforfilter.='
'; $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; - $moreforfilter.=$form->select_dolusers($search_user,'search_user',1); + $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); $moreforfilter.='
'; } // If the user can view prospects other than his' diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 0ba8600e778..d11a37564b9 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -269,7 +269,7 @@ if ($resql) $langs->load("commercial"); $moreforfilter.='
'; $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; - $moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user); + $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth300'); $moreforfilter.='
'; } // If the user can view prospects other than his' @@ -277,7 +277,7 @@ if ($resql) { $moreforfilter.='
'; $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; - $moreforfilter.=$form->select_dolusers($search_user,'search_user',1); + $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); $moreforfilter.='
'; } // If the user can view prospects other than his' @@ -331,7 +331,10 @@ if ($resql) print ''; print ''; print ''; - print ''; + print ''; + $liststatus=array('0'=>$langs->trans("StatusOrderDraftShort"), '1'=>$langs->trans("StatusOrderValidated"), '2'=>$langs->trans("StatusOrderSentShort"), '3'=>$langs->trans("StatusOrderToBill"), '4'=>$langs->trans("StatusOrderProcessed"), '-1'=>$langs->trans("StatusOrderCanceledShort")); + print $form->selectarray('viewstatut', $liststatus, $viewstatut, 1); + print ''; print ''; print ''; print "\n"; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index adb64a1f396..faefe63d9af 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -282,7 +282,7 @@ if ($resql) $langs->load("commercial"); $moreforfilter.='
'; $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; - $moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user); + $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth300'); $moreforfilter.='
'; } // If the user can view prospects other than his' @@ -290,7 +290,7 @@ if ($resql) { $moreforfilter.='
'; $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; - $moreforfilter.=$form->select_dolusers($search_user,'search_user',1); + $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); $moreforfilter.='
'; } // If the user can view prospects other than his' @@ -303,7 +303,7 @@ if ($resql) $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, '', 1); $moreforfilter.=''; } - + if ($moreforfilter) { print ''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index d5f0c367c22..bad965192e5 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1254,10 +1254,11 @@ class Form * @param string $morefilter Add more filters into sql request * @param string $show_every 0=default list, 1=add also a value "Everybody" at beginning of list * @param string $enableonlytext If option $enableonly is set, we use this text to explain into label why record is disabled. Not used if enableonly is empty. + * @param string $morecss More css * @return string HTML select string * @see select_dolgroups */ - function select_dolusers($selected='', $htmlname='userid', $show_empty=0, $exclude='', $disabled=0, $include='', $enableonly='', $force_entity=0, $maxlength=0, $showstatus=0, $morefilter='', $show_every=0, $enableonlytext='') + function select_dolusers($selected='', $htmlname='userid', $show_empty=0, $exclude='', $disabled=0, $include='', $enableonly='', $force_entity=0, $maxlength=0, $showstatus=0, $morefilter='', $show_every=0, $enableonlytext='', $morecss='') { global $conf,$user,$langs; @@ -1339,7 +1340,7 @@ class Form $nodatarole=($comboenhancement?' data-role="none"':''); } - $out.= ''; if ($show_empty) $out.= ''."\n"; if ($show_every) $out.= ''."\n"; @@ -4308,7 +4309,7 @@ class Form $retstring.=' '; } } - + if (! empty($nooutput)) return $retstring; print $retstring; diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 74a2440ca1c..8e9ca33b2a0 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -361,9 +361,10 @@ class FormOther * @param User $user Object user * @param int $showstatus 0=show user status only if status is disabled, 1=always show user status into label, -1=never show user status * @param int $showempty 1=show also an empty value + * @param string $morecss More CSS * @return string Html combo list code */ - function select_salesrepresentatives($selected,$htmlname,$user,$showstatus=0,$showempty=1) + function select_salesrepresentatives($selected,$htmlname,$user,$showstatus=0,$showempty=1,$morecss='') { global $conf,$langs; $langs->load('users'); @@ -383,7 +384,7 @@ class FormOther } } // Select each sales and print them in a select input - $out.=''; if ($showempty) $out.=''; // Get list of users allowed to be viewed diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index e054264270b..5a6eee1184a 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; * @param DoliDB $db Database handler * @param string $atarget Target (Example: '' or '_top') * @param int $type_user 0=Menu for backoffice, 1=Menu for front office - * @param array $tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty) + * @param array $tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty) * @param array $menu Object Menu to return back list of menu entries * @param int $noout Disable output (Initialise &$menu only). * @return int 0