Skip to content

Commit

Permalink
Fix: [task Dolibarr#146] Remove table llx_categorie_association
Browse files Browse the repository at this point in the history
  • Loading branch information
hregis committed Oct 8, 2012
1 parent 99d8552 commit 5fc17b1
Show file tree
Hide file tree
Showing 11 changed files with 233 additions and 349 deletions.
325 changes: 78 additions & 247 deletions htdocs/categories/class/categorie.class.php

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions htdocs/categories/edit.php
Expand Up @@ -38,7 +38,7 @@
$nom=GETPOST('nom');
$description=GETPOST('description');
$visible=GETPOST('visible');
$catMere=GETPOST('catMere');
$parent=GETPOST('parent');

if ($id == "")
{
Expand Down Expand Up @@ -66,20 +66,20 @@
$categorie->socid = ($socid ? $socid : 'null');
$categorie->visible = $visible;

if ($catMere != "-1")
$categorie->id_mere = $catMere;
if ($parent != "-1")
$categorie->fk_parent = $parent;
else
$categorie->id_mere = "";
$categorie->fk_parent = "";


if (! $categorie->label)
if (empty($categorie->label))
{
$_GET["action"] = 'create';
$action = 'create';
$mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("Label"));
}
if (! $categorie->description)
if (empty($categorie->description))
{
$_GET["action"] = 'create';
$action = 'create';
$mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("Description"));
}
if (empty($categorie->error))
Expand Down Expand Up @@ -149,7 +149,7 @@

// Parent category
print '<tr><td>'.$langs->trans("In").'</td><td>';
print $form->select_all_categories($type,$object->id_mere,'catMere',64,$object->id);
print $form->select_all_categories($type,$object->fk_parent,'parent',64,$object->id);
print '</td></tr>';

print '</table>';
Expand Down
6 changes: 3 additions & 3 deletions htdocs/categories/fiche.php
Expand Up @@ -45,7 +45,7 @@
$nom=GETPOST('nom');
$description=GETPOST('description');
$visible=GETPOST('visible');
$catMere=GETPOST('catMere');
$parent=GETPOST('parent');

if ($origin)
{
Expand Down Expand Up @@ -113,7 +113,7 @@
$object->visible = $visible;
$object->type = $type;

if ($catMere != "-1") $object->id_mere = $catMere;
if ($parent != "-1") $object->fk_parent = $parent;

if (! $object->label)
{
Expand Down Expand Up @@ -222,7 +222,7 @@

// Parent category
print '<tr><td>'.$langs->trans("AddIn").'</td><td>';
print $form->select_all_categories($type,$catorigin);
print $form->select_all_categories($type, $catorigin);
print '</td></tr>';

print '</table>';
Expand Down
26 changes: 12 additions & 14 deletions htdocs/categories/index.php
Expand Up @@ -154,13 +154,16 @@

// Define fullpathselected ( _x_y_z ) of $section parameter
$fullpathselected='';
foreach($fulltree as $key => $val)
if (! empty($section))
{
//print $val['id']."-".$section."<br>";
if ($val['id'] == $section)
foreach($fulltree as $key => $val)
{
$fullpathselected=$val['fullpath'];
break;
//print $val['id']."-".$section."<br>";
if ($val['id'] == $section)
{
$fullpathselected=$val['fullpath'];
break;
}
}
}
//print "fullpathselected=".$fullpathselected."<br>";
Expand All @@ -169,7 +172,7 @@
$expandedsectionarray=array();
if (isset($_SESSION['dol_catexpandedsectionarray'.$type])) $expandedsectionarray=explode(',',$_SESSION['dol_catexpandedsectionarray'.$type]);

if ($section && $_GET['sectionexpand'] == 'true')
if (! empty($section) && $_GET['sectionexpand'] == 'true')
{
// We add all sections that are parent of opened section
$pathtosection=explode('_',$fullpathselected);
Expand All @@ -182,7 +185,7 @@
}
$_SESSION['dol_catexpandedsectionarray'.$type]=join(',',$expandedsectionarray);
}
if ($section && $_GET['sectionexpand'] == 'false')
if (! empty($section) && $_GET['sectionexpand'] == 'false')
{
// We removed all expanded sections that are child of the closed section
$oldexpandedsectionarray=$expandedsectionarray;
Expand All @@ -207,10 +210,7 @@
$showline=0;

// If directory is son of expanded directory, we show line
if (isset($val['id_mere']) && in_array($val['id_mere'],$expandedsectionarray)) $showline=4;
// If directory is brother of selected directory, we show line
// FIXME $ecmdirstatic not exist or not instantiate ?
//elseif (isset($val['id_mere']) && $val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) $showline=3;
if (isset($val['fk_parent']) && in_array($val['fk_parent'],$expandedsectionarray)) $showline=4;
// If directory is parent of selected directory or is selected directory, we show line
elseif (preg_match('/'.$val['fullpath'].'_/i',$fullpathselected.'_')) $showline=2;
// If we are level one we show line
Expand Down Expand Up @@ -239,8 +239,6 @@
print '<td valign="top">';
//print $val['fullpath']."(".$showline.")";
$n='2';
// FIXME $b not define ?
//if ($b == 0 || ! in_array($val['id'],$expandedsectionarray)) $n='3';
if (! in_array($val['id'],$expandedsectionarray)) $n='3';
if (! in_array($val['id'],$expandedsectionarray)) $ref=img_picto('',DOL_URL_ROOT.'/theme/common/treemenu/plustop'.$n.'.gif','',1);
else $ref=img_picto('',DOL_URL_ROOT.'/theme/common/treemenu/minustop'.$n.'.gif','',1);
Expand Down Expand Up @@ -269,7 +267,7 @@

// Description
print '<td>';
print dol_trunc($categstatic->get_desc($val['id']),48);
print dol_trunc($val['description'],48);
print '</td>';

// Link to category card
Expand Down
8 changes: 3 additions & 5 deletions htdocs/core/class/html.form.class.php
Expand Up @@ -2133,22 +2133,20 @@ function select_comptes($selected='',$htmlname='accountid',$statut=0,$filtre='',
*
* @param int $type Type de categories (0=product, 1=supplier, 2=customer, 3=member)
* @param string $selected Id of category preselected
* @param string $select_name HTML field name
* @param string $htmlname HTML field name
* @param int $maxlength Maximum length for labels
* @param int $excludeafterid Exclude all categories after this leaf in category tree.
* @return void
*/
function select_all_categories($type, $selected='', $select_name="", $maxlength=64, $excludeafterid=0)
function select_all_categories($type, $selected='', $htmlname="parent", $maxlength=64, $excludeafterid=0)
{
global $langs;
$langs->load("categories");

if ($select_name=="") $select_name="catMere";

$cat = new Categorie($this->db);
$cate_arbo = $cat->get_full_arbo($type,$excludeafterid);

$output = '<select class="flat" name="'.$select_name.'">';
$output = '<select class="flat" name="'.$htmlname.'">';
if (is_array($cate_arbo))
{
if (! count($cate_arbo)) $output.= '<option value="-1" disabled="disabled">'.$langs->trans("NoCategoriesDefined").'</option>';
Expand Down
7 changes: 7 additions & 0 deletions htdocs/install/mysql/migration/3.2.0-3.3.0.sql
Expand Up @@ -759,3 +759,10 @@ UPDATE llx_product p SET p.stock= (SELECT SUM(ps.reel) FROM llx_product_stock ps

-- Add possibility to defined position/job of a user
ALTER TABLE llx_user ADD COLUMN job varchar(128) AFTER firstname;

ALTER TABLE llx_categorie DROP INDEX uk_categorie_ref;
ALTER TABLE llx_categorie ADD COLUMN fk_parent integer DEFAULT 0 NOT NULL AFTER rowid;
ALTER TABLE llx_categorie MODIFY COLUMN label varchar(255) NOT NULL;
ALTER TABLE llx_categorie ADD UNIQUE INDEX uk_categorie_ref (entity, fk_parent, label, type);
ALTER TABLE llx_categorie ADD INDEX idx_categorie_type (type);
ALTER TABLE llx_categorie ADD INDEX idx_categorie_label (label);
7 changes: 4 additions & 3 deletions htdocs/install/mysql/tables/llx_categorie.key.sql
@@ -1,6 +1,6 @@
-- ============================================================================
-- Copyright (C) 2007-2009 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2009 Regis Houssin <regis@dolibarr.fr>
-- Copyright (C) 2007-2009 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2009-2012 Regis Houssin <regis@dolibarr.fr>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
Expand All @@ -17,6 +17,7 @@
--
-- ============================================================================

ALTER TABLE llx_categorie ADD UNIQUE INDEX uk_categorie_ref (label,type,entity);
ALTER TABLE llx_categorie ADD UNIQUE INDEX uk_categorie_ref (entity, fk_parent, label, type);

ALTER TABLE llx_categorie ADD INDEX idx_categorie_type (type);
ALTER TABLE llx_categorie ADD INDEX idx_categorie_label (label);
30 changes: 12 additions & 18 deletions htdocs/install/mysql/tables/llx_categorie.sql
@@ -1,7 +1,7 @@
-- ============================================================================
-- Copyright (C) 2005 Brice Davoleau <e1davole@iu-vannes.fr>
-- Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org>
-- Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
-- Copyright (C) 2005 Brice Davoleau <e1davole@iu-vannes.fr>
-- Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org>
-- Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
Expand All @@ -21,13 +21,15 @@
create table llx_categorie
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
label varchar(255), -- category name
type tinyint DEFAULT 1 NOT NULL, -- category type (product, supplier, customer)
entity integer DEFAULT 1 NOT NULL, -- multi company id
description text, -- description of the category
fk_soc integer DEFAULT NULL, -- attribution of the category has a company (for product only)
visible tinyint DEFAULT 1 NOT NULL, -- determine if the products are visible or not
import_key varchar(14) -- Import key
entity integer DEFAULT 1 NOT NULL, -- multi company id
fk_parent integer DEFAULT 0 NOT NULL,
label varchar(255) NOT NULL, -- category name
type tinyint DEFAULT 1 NOT NULL, -- category type (product, supplier, customer)
description text, -- description of the category
fk_soc integer DEFAULT NULL, -- attribution of the category has a company (for product only)
visible tinyint DEFAULT 1 NOT NULL, -- determine if the products are visible or not
import_key varchar(14) -- Import key

)ENGINE=innodb;

--
Expand All @@ -37,11 +39,3 @@ create table llx_categorie
-- 1 : supplier
-- 2 : customer
--

--
-- List of codes for the field entity
--
-- 1 : first company category type
-- 2 : second company category type
-- 3 : etc...
--
26 changes: 0 additions & 26 deletions htdocs/install/mysql/tables/llx_categorie_association.key.sql

This file was deleted.

24 changes: 0 additions & 24 deletions htdocs/install/mysql/tables/llx_categorie_association.sql

This file was deleted.

0 comments on commit 5fc17b1

Please sign in to comment.