Work on task #10579 : Simplify code using editor

This commit is contained in:
Laurent Destailleur
2010-09-02 19:10:34 +00:00
parent 554abc46c7
commit 7917c17844
8 changed files with 82 additions and 207 deletions

View File

@@ -764,16 +764,9 @@ elseif ($fichinterid)
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
// Editeur wysiwyg
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS)
{
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('np_desc',$objp->description,164,'dolibarr_details');
$doleditor->Create();
}
else
{
print '<textarea name="np_desc" cols="70" class="flat" rows="'.ROWS_2.'">'.dol_htmlentitiesbr_decode($objp->description).'</textarea>';
}
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('np_desc',$objp->description,164,'dolibarr_details','',false,true,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS,ROWS_2,70);
$doleditor->Create();
print '</td>';
// Date d'intervention
@@ -826,16 +819,9 @@ elseif ($fichinterid)
print '<tr '.$bc[$var].">\n";
print '<td>';
// editeur wysiwyg
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS)
{
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('np_desc',$_POST["np_desc"],100,'dolibarr_details');
$doleditor->Create();
}
else
{
print '<textarea class="flat" cols="70" name="np_desc" rows="'.ROWS_2.'">'.$_POST["np_desc"].'</textarea>';
}
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('np_desc',$_POST["np_desc"],100,'dolibarr_details','',false,true,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS,ROWS_2,70);
$doleditor->Create();
print '</td>';
// Date intervention

View File

@@ -1105,19 +1105,13 @@ if ($id > 0 || ! empty($ref))
}
// Description - Editor wysiwyg
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS)
{
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('eldesc',$commandline->description,200,'dolibarr_details');
$doleditor->Create();
}
else
{
$nbrows=ROWS_2;
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
print '<textarea name="eldesc" class="flat" cols="70" rows="'.$nbrows.'">'.dol_htmlentitiesbr_decode($commandline->description).'</textarea>';
}
print '</td>';
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$nbrows=ROWS_2;
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
$doleditor=new DolEditor('eldesc',$commandline->description,200,'dolibarr_details','',false,true,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS,70,$nbrows);
$doleditor->Create();
print '</td>';
print '<td>';
$html->select_tva('tva_tx',$commandline->tva_tx);
print '</td>';
@@ -1164,18 +1158,12 @@ if ($id > 0 || ! empty($ref))
|| (empty($conf->product->enabled) && empty($conf->service->enabled))) print '<br>';
// Editor wysiwyg
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS)
{
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('dp_desc',$_POST["dp_desc"],100,'dolibarr_details');
$doleditor->Create();
}
else
{
$nbrows=ROWS_2;
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
print '<textarea class="flat" cols="70" name="dp_desc" rows="'.$nbrows.'">'.$_POST["dp_desc"].'</textarea>';
}
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$nbrows=ROWS_2;
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
$doleditor=new DolEditor('dp_desc',$_POST["dp_desc"],100,'dolibarr_details','',false,true,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70);
$doleditor->Create();
print '</td>';
print '<td align="center">';
//if($soc->tva_assuj == "0")
@@ -1224,18 +1212,11 @@ if ($id > 0 || ! empty($ref))
if (! $conf->global->PRODUIT_USE_SEARCH_TO_SELECT) print '<br>';
// Editor wysiwyg
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS)
{
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('np_desc',$_POST["np_desc"],100,'dolibarr_details');
$doleditor->Create();
}
else
{
$nbrows=ROWS_2;
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
print '<textarea cols="70" name="np_desc" rows="'.$nbrows.'" class="flat">'.$_POST["np_desc"].'</textarea>';
}
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$nbrows=ROWS_2;
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
$doleditor=new DolEditor('np_desc',$_POST["np_desc"],100,'dolibarr_details','',false,true,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70);
$doleditor->Create();
print '</td>';
print '<td align="right"><input type="text" size="2" name="pqty" value="'.($_POST["pqty"]?$_POST["pqty"]:'1').'"></td>';

View File

@@ -984,18 +984,11 @@ else
}
// Description - Editor wysiwyg
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS)
{
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('label',$fac->lignes[$i]->description,200,'dolibarr_details');
$doleditor->Create();
}
else
{
$nbrows=ROWS_2;
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
print '<textarea name="label" class="flat" cols="70" rows="'.$nbrows.'">'.dol_htmlentitiesbr_decode($fac->lignes[$i]->description).'</textarea>';
}
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$nbrows=ROWS_2;
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
$doleditor=new DolEditor('label',$fac->lignes[$i]->description,200,'dolibarr_details','',false,true,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70);
$doleditor->Create();
print '</td>';
// VAT
@@ -1121,18 +1114,12 @@ else
|| (empty($conf->product->enabled) && empty($conf->service->enabled))) print '<br>';
// Editor wysiwyg
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS)
{
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('label',$_POST["label"],100,'dolibarr_details');
$doleditor->Create();
}
else
{
$nbrows=ROWS_2;
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
print '<textarea class="flat" cols="60" name="label" rows="'.$nbrows.'">'.$_POST["label"].'</textarea>';
}
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$nbrows=ROWS_2;
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
$doleditor=new DolEditor('label',$_POST["label"],100,'dolibarr_details','',false,true,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70);
$doleditor->Create();
print '</td>';
print '<td align="right">';
print $html->select_tva('tauxtva',$conf->defaulttx,$societe,$mysoc);

View File

@@ -2772,6 +2772,8 @@ class Product extends CommonObject
}
}
/**
* \brief Affecte les valeurs communes
*/
@@ -2838,13 +2840,16 @@ class Product extends CommonObject
$this->tpl['hidden'] = $html->selectyesno('hidden',$this->hidden);
}
// TODO creer fonction
$this->tpl['description'] = $this->description;
$this->tpl['note'] = $this->note;
/* Fix: La presentation ne doit pas etre gérée dans une classe métier
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
{
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('desc',$this->description,160,'dolibarr_notes','',false);
$this->tpl['doleditor_description'] = $doleditor;
$this->tpl['doleditor_description'] = $doleditor;
$doleditor=new DolEditor('note',$this->note,180,'dolibarr_notes','',false);
$this->tpl['doleditor_note'] = $doleditor;
@@ -2854,13 +2859,14 @@ class Product extends CommonObject
$textarea = '<textarea name="desc" rows="4" cols="90">';
$textarea.= $this->description;
$textarea.= '</textarea>';
$this->tpl['textarea_description'] = $textarea;
$this->tpl['description'] = $this->description
$textarea = '<textarea name="note" rows="8" cols="70">';
$textarea.= $this->note;
$textarea.= '</textarea>';
$this->tpl['textarea_note'] = $textarea;
}
*/
}
if ($action == 'view')

View File

@@ -694,18 +694,9 @@ if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->righ
// Description (used in invoice, propal...)
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>';
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
{
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('desc',$_POST["desc"],160,'dolibarr_notes','',false);
$doleditor->Create();
}
else
{
print '<textarea name="desc" rows="4" cols="90">';
print $_POST["desc"];
print '</textarea>';
}
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('desc',$_POST["desc"],160,'dolibarr_notes','',false,true,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,4,90);
$doleditor->Create();
print "</td></tr>";
@@ -771,18 +762,10 @@ if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->righ
// Note (invisible sur facture, propales...)
print '<tr><td valign="top">'.$langs->trans("NoteNotVisibleOnBill").'</td><td>';
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
{
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('note',$_POST["note"],180,'dolibarr_notes','',false);
$doleditor->Create();
}
else
{
print '<textarea name="note" rows="8" cols="70">';
print $_POST["note"];
print '</textarea>';
}
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('note',$_POST["note"],180,'dolibarr_notes','',false,true,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,8,70);
$doleditor->Create();
print "</td></tr>";
print '</table>';
@@ -923,19 +906,9 @@ if ($_GET["id"] || $_GET["ref"])
// Description (used in invoice, propal...)
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="2">';
print "\n";
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
{
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('desc',$product->description,160,'dolibarr_notes','',false);
$doleditor->Create();
}
else
{
print '<textarea name="desc" rows="4" cols="90">';
print dol_htmlentitiesbr_decode($product->description);
print "</textarea>";
}
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('desc',$product->description,160,'dolibarr_notes','',false,true,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,4,90);
$doleditor->Create();
print "</td></tr>";
print "\n";
@@ -1017,18 +990,9 @@ if ($_GET["id"] || $_GET["ref"])
// Note
print '<tr><td valign="top">'.$langs->trans("NoteNotVisibleOnBill").'</td><td colspan="2">';
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
{
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('note',$product->note,200,'dolibarr_notes','',false);
$doleditor->Create();
}
else
{
print '<textarea name="note" rows="8" cols="70">';
print dol_htmlentitiesbr_decode($product->note);
print "</textarea>";
}
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('note',$product->note,200,'dolibarr_notes','',false,true,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,8,70);
$doleditor->Create();
print "</td></tr>";
print '</table>';

View File

@@ -177,17 +177,10 @@ if ($_GET["action"] == 'create')
// Description
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="3">';
if ($conf->fckeditor->enabled)
{
// Editeur wysiwyg
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('desc',$entrepot->description,180,'dolibarr_notes','In',false);
$doleditor->Create();
}
else
{
print '<textarea name="desc" cols="70" rows="5">'.dol_htmlentitiesbr_decode($entrepot->description).'</textarea>';
}
// Editeur wysiwyg
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('desc',$entrepot->description,180,'dolibarr_notes','In',false,true,$conf->fckeditor->enabled,5,70);
$doleditor->Create();
print '</td></tr>';
print '<tr><td>'.$langs->trans('Address').'</td><td colspan="3"><textarea name="address" cols="60" rows="3" wrap="soft">';
@@ -477,17 +470,10 @@ else
// Description
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="3">';
if ($conf->fckeditor->enabled)
{
// Editeur wysiwyg
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('desc',$entrepot->description,180,'dolibarr_notes','In',false);
$doleditor->Create();
}
else
{
print '<textarea name="desc" cols="70" rows="5">'.dol_htmlentitiesbr_decode($entrepot->description).'</textarea>';
}
// Editeur wysiwyg
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('desc',$entrepot->description,180,'dolibarr_notes','In',false,true,$conf->fckeditor->enabled,5,70);
$doleditor->Create();
print '</td></tr>';
print '<tr><td>'.$langs->trans('Address').'</td><td colspan="3"><textarea name="address" cols="60" rows="3" wrap="soft">';

View File

@@ -170,28 +170,14 @@ if ($_GET["action"] == 'edit')
print '<table class="border" width="100%">';
print '<tr><td valign="top" width="15%" class="fieldrequired">'.$langs->trans('Label').'</td><td><input name="libelle-'.$key.'" size="40" value="'.$product->multilangs[$key]["libelle"].'"></td></tr>';
print '<tr><td valign="top" width="15%">'.$langs->trans('Description').'</td><td>';
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
{
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('desc-'.$key.'',$product->multilangs[$key]["description"],160,'dolibarr_notes','',false);
$doleditor->Create();
}
else
{
print '<textarea name="desc-'.$key.'" rows="3" cols="80">'.dol_htmlentitiesbr_decode($product->multilangs[$key]["description"]).'</textarea>';
}
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('desc-'.$key.'',$product->multilangs[$key]["description"],160,'dolibarr_notes','',false,true,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,3,80);
$doleditor->Create();
print '</td></tr>';
print '<tr><td valign="top" width="15%">'.$langs->trans('Note').'</td><td>';
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
{
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('note-'.$key.'',$product->multilangs[$key]["note"],160,'dolibarr_notes','',false);
$doleditor->Create();
}
else
{
print '<textarea name="note-'.$key.'" rows="3" cols="80">'.dol_htmlentitiesbr_decode($product->multilangs[$key]["note"]).'</textarea>';
}
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('note-'.$key.'',$product->multilangs[$key]["note"],160,'dolibarr_notes','',false,true,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,3,80);
$doleditor->Create();
print '</td></tr>';
print '</tr>';
print '</table>';
@@ -260,28 +246,14 @@ if ($_GET["action"] == 'add' && ($user->rights->produit->creer || $user->rights-
print '</td></tr>';
print '<tr><td valign="top" width="15%" class="fieldrequired">'.$langs->trans('Label').'</td><td><input name="libelle" size="40"></td></tr>';
print '<tr><td valign="top" width="15%">'.$langs->trans('Description').'</td><td>';
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
{
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('desc','',160,'dolibarr_notes','',false);
$doleditor->Create();
}
else
{
print '<textarea name="desc" rows="3" cols="80"></textarea>';
}
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('desc','',160,'dolibarr_notes','',false,true,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,3,80);
$doleditor->Create();
print '</td></tr>';
print '<tr><td valign="top" width="15%">'.$langs->trans('Note').'</td><td>';
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
{
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('note','',160,'dolibarr_notes','',false);
$doleditor->Create();
}
else
{
print '<textarea name="note" rows="3" cols="80"></textarea>';
}
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('note','',160,'dolibarr_notes','',false,true,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,3,80);
$doleditor->Create();
print '</td></tr>';
print '</tr>';
print '</table>';

View File

@@ -69,7 +69,7 @@ if ($socid > 0)
* Affichage onglets
*/
if ($conf->notification->enabled) $langs->load("mails");
$head = societe_prepare_head($societe);
dol_fiche_head($head, 'note', $langs->trans("ThirdParty"),0,'company');
@@ -112,17 +112,10 @@ if ($socid > 0)
print "<input type=\"hidden\" name=\"action\" value=\"add\">";
print "<input type=\"hidden\" name=\"socid\" value=\"".$societe->id."\">";
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_SOCIETE)
{
// Editeur wysiwyg
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('note',$societe->note,280,'dolibarr_notes','In',true);
$doleditor->Create();
}
else
{
print '<textarea name="note" cols="70" rows="10">'.dol_htmlentitiesbr_decode($societe->note).'</textarea>';
}
// Editeur wysiwyg
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('note',$societe->note,280,'dolibarr_notes','In',true,false,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_SOCIETE,10,70);
$doleditor->Create();
}
else
{