NEW Add color on categories

This commit is contained in:
Laurent Destailleur 2015-09-17 20:00:54 +02:00
parent 27b1f2ecc6
commit c8e0839296
3 changed files with 19 additions and 6 deletions

View File

@ -29,6 +29,7 @@
require '../main.inc.php'; require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
$langs->load("categories"); $langs->load("categories");
@ -46,6 +47,7 @@ $urlfrom = GETPOST('urlfrom','alpha');
$socid=GETPOST('socid','int'); $socid=GETPOST('socid','int');
$label=GETPOST('label'); $label=GETPOST('label');
$description=GETPOST('description'); $description=GETPOST('description');
$color=GETPOST('color');
$visible=GETPOST('visible'); $visible=GETPOST('visible');
$parent=GETPOST('parent'); $parent=GETPOST('parent');
@ -124,6 +126,7 @@ if ($action == 'add' && $user->rights->categorie->creer)
$object->label = $label; $object->label = $label;
$object->color = $color;
$object->description = dol_htmlcleanlastbr($description); $object->description = dol_htmlcleanlastbr($description);
$object->socid = ($socid ? $socid : 'null'); $object->socid = ($socid ? $socid : 'null');
$object->visible = $visible; $object->visible = $visible;
@ -210,6 +213,7 @@ if (($action == 'add' || $action == 'confirmed') && $user->rights->categorie->cr
*/ */
$form = new Form($db); $form = new Form($db);
$formother = new FormOther($db);
llxHeader("","",$langs->trans("Categories")); llxHeader("","",$langs->trans("Categories"));
@ -250,6 +254,11 @@ if ($user->rights->categorie->creer)
$doleditor->Create(); $doleditor->Create();
print '</td></tr>'; print '</td></tr>';
// Color
print '<tr><td>'.$langs->trans("Color").'</td><td>';
print $formother->select_color($color,'color');
print '</td></tr>';
// Parent category // Parent category
print '<tr><td>'.$langs->trans("AddIn").'</td><td>'; print '<tr><td>'.$langs->trans("AddIn").'</td><td>';
print $form->select_all_categories($type, $catorigin); print $form->select_all_categories($type, $catorigin);

View File

@ -368,7 +368,7 @@ class Categorie extends CommonObject
$sql = "UPDATE ".MAIN_DB_PREFIX."categorie"; $sql = "UPDATE ".MAIN_DB_PREFIX."categorie";
$sql.= " SET label = '".$this->db->escape($this->label)."',"; $sql.= " SET label = '".$this->db->escape($this->label)."',";
$sql.= " description = '".$this->db->escape($this->description)."'"; $sql.= " description = '".$this->db->escape($this->description)."',";
$sql.= " color = '".$this->db->escape($this->color)."'"; $sql.= " color = '".$this->db->escape($this->color)."'";
if (! empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) if (! empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER))
{ {

View File

@ -27,6 +27,7 @@
require '../main.inc.php'; require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
$langs->load("categories"); $langs->load("categories");
@ -84,15 +85,17 @@ if ($action == 'update' && $user->rights->categorie->creer)
if (empty($categorie->label)) if (empty($categorie->label))
{ {
$error++;
$action = 'create'; $action = 'create';
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")), 'errors'); setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")), 'errors');
} }
if (empty($categorie->description)) if (empty($categorie->description))
{ {
$error++;
$action = 'create'; $action = 'create';
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Description")), 'errors'); setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Description")), 'errors');
} }
if (empty($categorie->error)) if (! $error && empty($categorie->error))
{ {
$ret = $extrafields->setOptionalsFromPost($extralabels,$categorie); $ret = $extrafields->setOptionalsFromPost($extralabels,$categorie);
if ($ret < 0) $error++; if ($ret < 0) $error++;
@ -120,6 +123,7 @@ if ($action == 'update' && $user->rights->categorie->creer)
*/ */
$form = new Form($db); $form = new Form($db);
$formother = new FormOther($db);
llxHeader("","",$langs->trans("Categories")); llxHeader("","",$langs->trans("Categories"));
@ -140,14 +144,14 @@ dol_fiche_head('');
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref // Ref
print '<tr><td class="fieldrequired">'; print '<tr><td class="fieldrequired" width="25%">';
print $langs->trans("Ref").'</td>'; print $langs->trans("Ref").'</td>';
print '<td><input type="text" size="25" id="label" name ="label" value="'.$object->label.'" />'; print '<td><input type="text" size="25" id="label" name ="label" value="'.$object->label.'" />';
print '</tr>'; print '</tr>';
// Description // Description
print '<tr>'; print '<tr>';
print '<td class="fieldrequired" width="25%">'.$langs->trans("Description").'</td>'; print '<td class="fieldrequired">'.$langs->trans("Description").'</td>';
print '<td >'; print '<td >';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor('description',$object->description,'',200,'dolibarr_notes','',false,true,$conf->fckeditor->enabled,ROWS_6,50); $doleditor=new DolEditor('description',$object->description,'',200,'dolibarr_notes','',false,true,$conf->fckeditor->enabled,ROWS_6,50);
@ -156,9 +160,9 @@ print '</td></tr>';
// Color // Color
print '<tr>'; print '<tr>';
print '<td class="fieldrequired" width="25%">'.$langs->trans("Color").'</td>'; print '<td>'.$langs->trans("Color").'</td>';
print '<td >'; print '<td >';
print $formother->select_color($color, 'color'); print $formother->select_color($object->color, 'color');
print '</td></tr>'; print '</td></tr>';
// Parent category // Parent category