Add WYSIWYG Editor on project's tasks description field

This commit is contained in:
kevin 2022-03-09 14:09:22 +01:00
parent 66f21fc1d0
commit 22249d15c3
2 changed files with 36 additions and 4 deletions

View File

@ -763,7 +763,20 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third
// Description
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>';
print '<td>';
print '<textarea name="description" class="quatrevingtpercent" rows="'.ROWS_4.'">'.$description.'</textarea>';
if (empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) {
print '<textarea name="description" class="quatrevingtpercent" rows="'.ROWS_4.'">'.$description.'</textarea>';
} else {
// WYSIWYG editor
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$cked_enabled = (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0);
if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) {
$nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT;
}
$doleditor = new DolEditor('description', $object->description, '', 80, 'dolibarr_details', '', false, true, $cked_enabled, $nbrows);
print $doleditor->Create();
}
print '</td></tr>';
print '<tr><td>'.$langs->trans("Budget").'</td>';

View File

@ -45,6 +45,7 @@ $confirm = GETPOST('confirm', 'alpha');
$withproject = GETPOST('withproject', 'int');
$project_ref = GETPOST('project_ref', 'alpha');
$planned_workload = ((GETPOST('planned_workloadhour', 'int') != '' || GETPOST('planned_workloadmin', 'int') != '') ? (GETPOST('planned_workloadhour', 'int') > 0 ?GETPOST('planned_workloadhour', 'int') * 3600 : 0) + (GETPOST('planned_workloadmin', 'int') > 0 ?GETPOST('planned_workloadmin', 'int') * 60 : 0) : '');
$description = GETPOST('description', 'restricthtml');
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('projecttaskcard', 'globalcard'));
@ -99,7 +100,8 @@ if ($action == 'update' && !GETPOST("cancel") && $user->rights->projet->creer) {
$object->ref = $taskref ? $taskref : GETPOST("ref", 'alpha', 2);
$object->label = GETPOST("label", "alphanohtml");
$object->description = GETPOST('description', "alphanohtml");
if (empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) $object->description = GETPOST('description', "alphanohtml");
else $object->description = GETPOST('description', "restricthtml");
$object->fk_task_parent = $task_parent;
$object->planned_workload = $planned_workload;
$object->date_start = dol_mktime(GETPOST('dateohour', 'int'), GETPOST('dateomin', 'int'), 0, GETPOST('dateomonth', 'int'), GETPOST('dateoday', 'int'), GETPOST('dateoyear', 'int'));
@ -439,7 +441,20 @@ if ($id > 0 || !empty($ref)) {
// Description
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>';
print '<td>';
print '<textarea name="description" class="quatrevingtpercent" rows="'.ROWS_4.'">'.$object->description.'</textarea>';
if (empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) {
print '<textarea name="description" class="quatrevingtpercent" rows="'.ROWS_4.'">'.$object->description.'</textarea>';
} else {
// WYSIWYG editor
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$cked_enabled = (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0);
if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) {
$nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT;
}
$description = !empty($description) ? $description : $object->description;
$doleditor = new DolEditor('description', $description, '', 80, 'dolibarr_details', '', false, true, $cked_enabled, $nbrows);
print $doleditor->Create();
}
print '</td></tr>';
print '<tr><td>'.$langs->trans("Budget").'</td>';
@ -536,7 +551,11 @@ if ($id > 0 || !empty($ref)) {
// Description
print '<td class="tdtop">'.$langs->trans("Description").'</td><td colspan="3">';
print nl2br($object->description);
if (!empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) {
print $object->description;
} else {
print nl2br($object->description);
}
print '</td></tr>';
print '</table>';