Skip to content

Commit

Permalink
NEW Add color on categories
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Sep 17, 2015
1 parent 27b1f2e commit c8e0839
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
9 changes: 9 additions & 0 deletions htdocs/categories/card.php
Expand Up @@ -29,6 +29,7 @@
require '../main.inc.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/html.formother.class.php';

$langs->load("categories");

Expand All @@ -46,6 +47,7 @@
$socid=GETPOST('socid','int');
$label=GETPOST('label');
$description=GETPOST('description');
$color=GETPOST('color');
$visible=GETPOST('visible');
$parent=GETPOST('parent');

Expand Down Expand Up @@ -124,6 +126,7 @@


$object->label = $label;
$object->color = $color;
$object->description = dol_htmlcleanlastbr($description);
$object->socid = ($socid ? $socid : 'null');
$object->visible = $visible;
Expand Down Expand Up @@ -210,6 +213,7 @@
*/

$form = new Form($db);
$formother = new FormOther($db);

llxHeader("","",$langs->trans("Categories"));

Expand Down Expand Up @@ -250,6 +254,11 @@
$doleditor->Create();
print '</td></tr>';

// Color
print '<tr><td>'.$langs->trans("Color").'</td><td>';
print $formother->select_color($color,'color');
print '</td></tr>';

// Parent category
print '<tr><td>'.$langs->trans("AddIn").'</td><td>';
print $form->select_all_categories($type, $catorigin);
Expand Down
2 changes: 1 addition & 1 deletion htdocs/categories/class/categorie.class.php
Expand Up @@ -368,7 +368,7 @@ function update($user='')

$sql = "UPDATE ".MAIN_DB_PREFIX."categorie";
$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)."'";
if (! empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER))
{
Expand Down
14 changes: 9 additions & 5 deletions htdocs/categories/edit.php
Expand Up @@ -27,6 +27,7 @@
require '../main.inc.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/html.formother.class.php';

$langs->load("categories");

Expand Down Expand Up @@ -84,15 +85,17 @@

if (empty($categorie->label))
{
$error++;
$action = 'create';
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")), 'errors');
}
if (empty($categorie->description))
{
$error++;
$action = 'create';
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Description")), 'errors');
}
if (empty($categorie->error))
if (! $error && empty($categorie->error))
{
$ret = $extrafields->setOptionalsFromPost($extralabels,$categorie);
if ($ret < 0) $error++;
Expand Down Expand Up @@ -120,6 +123,7 @@
*/

$form = new Form($db);
$formother = new FormOther($db);

llxHeader("","",$langs->trans("Categories"));

Expand All @@ -140,14 +144,14 @@
print '<table class="border" width="100%">';

// Ref
print '<tr><td class="fieldrequired">';
print '<tr><td class="fieldrequired" width="25%">';
print $langs->trans("Ref").'</td>';
print '<td><input type="text" size="25" id="label" name ="label" value="'.$object->label.'" />';
print '</tr>';

// Description
print '<tr>';
print '<td class="fieldrequired" width="25%">'.$langs->trans("Description").'</td>';
print '<td class="fieldrequired">'.$langs->trans("Description").'</td>';
print '<td >';
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);
Expand All @@ -156,9 +160,9 @@

// Color
print '<tr>';
print '<td class="fieldrequired" width="25%">'.$langs->trans("Color").'</td>';
print '<td>'.$langs->trans("Color").'</td>';
print '<td >';
print $formother->select_color($color, 'color');
print $formother->select_color($object->color, 'color');
print '</td></tr>';

// Parent category
Expand Down

0 comments on commit c8e0839

Please sign in to comment.