[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 */ 18 19 require "./pre.inc.php"; 20 21 if (!isset ($_REQUEST["id"]) || !isset ($_REQUEST["nom"]) || !isset ($_REQUEST["description"])) 22 accessforbidden(); 23 24 25 /** 26 * Affichage page accueil 27 */ 28 29 llxHeader("","",$langs->trans("Categories")); 30 31 print_titre($langs->trans("CatCreated")); 32 33 print '<table border="0" width="100%">'; 34 35 print '<tr><td valign="top" width="30%">'; 36 37 $cat = new Categorie ($db, $_REQUEST['id']); 38 39 $cat->label = $_REQUEST["nom"]; 40 $cat->description = $_REQUEST["description"]; 41 42 $new_cats_meres = isset ($_REQUEST['cats_meres']) ? $_REQUEST['cats_meres'] : array (); 43 // tableau d'id de catégories 44 45 $old_objs_meres = $cat->get_meres (); 46 // tableau d'objets catégorie 47 48 $old_cats_meres = array (); 49 foreach ($old_objs_meres as $old_obj_mere) 50 { // transformation en tableau d'id 51 $old_cats_meres[] = $old_obj_mere->id; 52 } 53 54 $asupprimer = array (); // tableaux des catégories mères 55 $aajouter = array (); // à ajouter ou à supprimer 56 57 foreach ($old_cats_meres as $old_cat) 58 { 59 if (!in_array ($old_cat, $new_cats_meres)) 60 { 61 $asupprimer[] = new Categorie ($db, $old_cat); 62 } 63 } 64 65 foreach ($new_cats_meres as $new_cat) 66 { 67 if (!in_array ($new_cat, $old_cats_meres)) 68 { 69 $aajouter[] = new Categorie ($db, $new_cat); 70 } 71 } 72 73 $res = $cat->update (); 74 if ($res < 0) 75 { 76 print "<p>Impossible de modifier la catégorie ".$cat->label.".</p>"; 77 } 78 else 79 { 80 print "<p>La catégorie ".$cat->label." a été modifiée avec succès.</p>"; 81 82 foreach ($asupprimer as $old_mere) 83 { 84 $res = $old_mere->del_fille ($cat); 85 if ($res < 0) 86 { 87 print "<p>Impossible d'enlever la catégorie de \"".$old_mere->label."\" ($res).</p>\n"; 88 } 89 else 90 { 91 print "<p>La catégorie ne fait plus partie de ".$old_mere->label.".</p>\n"; 92 } 93 } 94 95 foreach ($aajouter as $new_mere) 96 { 97 $res = $new_mere->add_fille ($cat); 98 if ($res < 0) 99 { 100 print "<p>Impossible d'ajouter la catégorie à \"".$new_mere->label."\" ($res).</p>"; 101 } 102 else 103 { 104 print "<p>La catégorie fait maintenant partie de ".$new_mere->label.".</p>\n"; 105 } 106 } 107 } 108 109 print '</td></tr></table>'; 110 111 $db->close(); 112 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 12:29:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |