Nouveau fichier
This commit is contained in:
parent
7cc9a27c14
commit
cbd3b5f879
112
htdocs/categories/domodif.php
Normal file
112
htdocs/categories/domodif.php
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
require "./pre.inc.php";
|
||||||
|
|
||||||
|
if (!isset ($_REQUEST["id"]) || !isset ($_REQUEST["nom"]) || !isset ($_REQUEST["description"]))
|
||||||
|
accessforbidden();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Affichage page accueil
|
||||||
|
*/
|
||||||
|
|
||||||
|
llxHeader("","",$langs->trans("Categories"));
|
||||||
|
|
||||||
|
print_titre($langs->trans("CatCreated"));
|
||||||
|
|
||||||
|
print '<table border="0" width="100%">';
|
||||||
|
|
||||||
|
print '<tr><td valign="top" width="30%">';
|
||||||
|
|
||||||
|
$cat = new Categorie ($db, $_REQUEST['id']);
|
||||||
|
|
||||||
|
$cat->label = $_REQUEST["nom"];
|
||||||
|
$cat->description = $_REQUEST["description"];
|
||||||
|
|
||||||
|
$new_cats_meres = isset ($_REQUEST['cats_meres']) ? $_REQUEST['cats_meres'] : array ();
|
||||||
|
// tableau d'id de catégories
|
||||||
|
|
||||||
|
$old_objs_meres = $cat->get_meres ();
|
||||||
|
// tableau d'objets catégorie
|
||||||
|
|
||||||
|
$old_cats_meres = array ();
|
||||||
|
foreach ($old_objs_meres as $old_obj_mere)
|
||||||
|
{ // transformation en tableau d'id
|
||||||
|
$old_cats_meres[] = $old_obj_mere->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$asupprimer = array (); // tableaux des catégories mères
|
||||||
|
$aajouter = array (); // à ajouter ou à supprimer
|
||||||
|
|
||||||
|
foreach ($old_cats_meres as $old_cat)
|
||||||
|
{
|
||||||
|
if (!in_array ($old_cat, $new_cats_meres))
|
||||||
|
{
|
||||||
|
$asupprimer[] = new Categorie ($db, $old_cat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($new_cats_meres as $new_cat)
|
||||||
|
{
|
||||||
|
if (!in_array ($new_cat, $old_cats_meres))
|
||||||
|
{
|
||||||
|
$aajouter[] = new Categorie ($db, $new_cat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$res = $cat->update ();
|
||||||
|
if ($res < 0)
|
||||||
|
{
|
||||||
|
print "<p>Impossible de modifier la catégorie ".$cat->label.".</p>";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print "<p>La catégorie ".$cat->label." a été modifiée avec succès.</p>";
|
||||||
|
|
||||||
|
foreach ($asupprimer as $old_mere)
|
||||||
|
{
|
||||||
|
$res = $old_mere->del_fille ($cat);
|
||||||
|
if ($res < 0)
|
||||||
|
{
|
||||||
|
print "<p>Impossible d'enlever la catégorie de \"".$old_mere->label."\" ($res).</p>\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print "<p>La catégorie ne fait plus partie de ".$old_mere->label.".</p>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($aajouter as $new_mere)
|
||||||
|
{
|
||||||
|
$res = $new_mere->add_fille ($cat);
|
||||||
|
if ($res < 0)
|
||||||
|
{
|
||||||
|
print "<p>Impossible d'ajouter la catégorie à \"".$new_mere->label."\" ($res).</p>";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print "<p>La catégorie fait maintenant partie de ".$new_mere->label.".</p>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print '</td></tr></table>';
|
||||||
|
|
||||||
|
$db->close();
|
||||||
|
?>
|
||||||
57
htdocs/categories/pre.inc.php
Normal file
57
htdocs/categories/pre.inc.php
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org>
|
||||||
|
* Copyright (C) 2005 Davoleau Brice <brice.davoleau@gmail.com>
|
||||||
|
* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
* $Source$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\file htdocs/categories/pre.inc.php
|
||||||
|
\ingroup product,service
|
||||||
|
\brief Fichier gestionnaire du menu gauche des produits et services
|
||||||
|
\version $Revision$
|
||||||
|
*/
|
||||||
|
|
||||||
|
require "../main.inc.php";
|
||||||
|
require_once DOL_DOCUMENT_ROOT."/categories/categorie.class.php";
|
||||||
|
|
||||||
|
$langs->load("categories");
|
||||||
|
$user->getrights("categorie");
|
||||||
|
|
||||||
|
function llxHeader ($head = "", $urlp = "", $title="")
|
||||||
|
{
|
||||||
|
global $user, $conf, $langs;
|
||||||
|
|
||||||
|
|
||||||
|
top_menu($head, $title);
|
||||||
|
|
||||||
|
$menu = new Menu();
|
||||||
|
|
||||||
|
if ($conf->categorie->enabled)
|
||||||
|
{
|
||||||
|
$menu->add(DOL_URL_ROOT."/categories/index.php", $langs->trans("Categories"));
|
||||||
|
$menu->add_submenu(DOL_URL_ROOT."/categories/liste.php", $langs->trans("List"));
|
||||||
|
$menu->add_submenu(DOL_URL_ROOT."/categories/create.php", $langs->trans("NewCat"));
|
||||||
|
}
|
||||||
|
|
||||||
|
$menu->add(DOL_URL_ROOT."/categories/stats/", $langs->trans("CatStatistics"));
|
||||||
|
left_menu($menu->liste);
|
||||||
|
}
|
||||||
|
?>
|
||||||
29
mysql/tables/llx_categorie.sql
Normal file
29
mysql/tables/llx_categorie.sql
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
-- ============================================================================
|
||||||
|
-- Copyright (C) 2005 Brice Davoleau <e1davole@iu-vannes.fr>
|
||||||
|
-- Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org>
|
||||||
|
--
|
||||||
|
-- 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
|
||||||
|
-- the Free Software Foundation; either version 2 of the License, or
|
||||||
|
-- (at your option) any later version.
|
||||||
|
--
|
||||||
|
-- This program is distributed in the hope that it will be useful,
|
||||||
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
-- GNU General Public License for more details.
|
||||||
|
--
|
||||||
|
-- You should have received a copy of the GNU General Public License
|
||||||
|
-- along with this program; if not, write to the Free Software
|
||||||
|
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
--
|
||||||
|
-- $Id$
|
||||||
|
-- $Source$
|
||||||
|
--
|
||||||
|
-- ============================================================================
|
||||||
|
|
||||||
|
create table llx_categorie
|
||||||
|
(
|
||||||
|
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
label VARCHAR(255),
|
||||||
|
description text
|
||||||
|
)type=innodb;
|
||||||
25
mysql/tables/llx_categorie_association.key.sql
Normal file
25
mysql/tables/llx_categorie_association.key.sql
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
-- ============================================================================
|
||||||
|
-- Copyright (C) 2005 Brice Davoleau <e1davole@iu-vannes.fr>
|
||||||
|
-- Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org>
|
||||||
|
--
|
||||||
|
-- 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
|
||||||
|
-- the Free Software Foundation; either version 2 of the License, or
|
||||||
|
-- (at your option) any later version.
|
||||||
|
--
|
||||||
|
-- This program is distributed in the hope that it will be useful,
|
||||||
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
-- GNU General Public License for more details.
|
||||||
|
--
|
||||||
|
-- You should have received a copy of the GNU General Public License
|
||||||
|
-- along with this program; if not, write to the Free Software
|
||||||
|
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
--
|
||||||
|
-- ============================================================================
|
||||||
|
|
||||||
|
ALTER TABLE llx_categorie_association ADD INDEX (fk_categorie_mere);
|
||||||
|
ALTER TABLE llx_categorie_association ADD INDEX (fk_categorie_fille);
|
||||||
|
|
||||||
|
ALTER TABLE llx_categorie_association ADD FOREIGN KEY (fk_categorie_mere) REFERENCES llx_categorie (rowid);
|
||||||
|
ALTER TABLE llx_categorie_association ADD FOREIGN KEY (fk_categorie_fille) REFERENCES llx_categorie (rowid);
|
||||||
25
mysql/tables/llx_categorie_association.sql
Normal file
25
mysql/tables/llx_categorie_association.sql
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
-- ============================================================================
|
||||||
|
-- Copyright (C) 2005 Brice Davoleau <e1davole@iu-vannes.fr>
|
||||||
|
-- Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org>
|
||||||
|
--
|
||||||
|
-- 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
|
||||||
|
-- the Free Software Foundation; either version 2 of the License, or
|
||||||
|
-- (at your option) any later version.
|
||||||
|
--
|
||||||
|
-- This program is distributed in the hope that it will be useful,
|
||||||
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
-- GNU General Public License for more details.
|
||||||
|
--
|
||||||
|
-- You should have received a copy of the GNU General Public License
|
||||||
|
-- along with this program; if not, write to the Free Software
|
||||||
|
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
--
|
||||||
|
-- ============================================================================
|
||||||
|
|
||||||
|
create table llx_categorie_association
|
||||||
|
(
|
||||||
|
fk_categorie_mere integer NOT NULL,
|
||||||
|
fk_categorie_fille integer NOT NULL
|
||||||
|
)type=innodb;
|
||||||
Loading…
Reference in New Issue
Block a user