diff --git a/htdocs/compta/bank/categ.php b/htdocs/compta/bank/categ.php index 3bb34cf81aa..3086fdb0f9d 100644 --- a/htdocs/compta/bank/categ.php +++ b/htdocs/compta/bank/categ.php @@ -1,179 +1,179 @@ - - * Copyright (C) 2004-2008 Laurent Destailleur - * Copytight (C) 2005-2009 Regis Houssin - * Copytight (C) 2013 Charles-Fr BENKE - * - * 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 3 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, see . - */ - -/** - * \file htdocs/compta/bank/categ.php - * \ingroup compta - * \brief Page ajout de categories bancaires - */ - -require('../../main.inc.php'); -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - -$langs->load("banks"); -$langs->load("categories"); - -if (!$user->rights->banque->configurer) - accessforbidden(); - - - -/* -* Actions ajout catégorie -*/ -if ($_POST["action"] == 'add') -{ - if ($_POST["label"]) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_categ ("; - $sql.= "label"; - $sql.= ", entity"; - $sql.= ") VALUES ("; - $sql.= "'".$db->escape($_POST["label"])."'"; - $sql.= ", ".$conf->entity; - $sql.= ")"; - - $result = $db->query($sql); - - if (!$result) - { - dol_print_error($db); - } - } -} - -/* -* Action modification catégorie -*/ -if ($_POST["action"] == 'update') -{ - if ($_POST["label"]) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."bank_categ "; - $sql.= "set label='".$db->escape($_POST["label"])."'";; - $sql.= " WHERE rowid = '".$_REQUEST['categid']."'"; - $sql.= " AND entity = ".$conf->entity; - $result = $db->query($sql); - - if (!$result) - { - dol_print_error($db); - } - } -} -/* -* Action suppression catégorie -*/ -if ( $_REQUEST['action'] == 'delete' ) -{ - if ( $_REQUEST['categid'] ) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_categ"; - $sql.= " WHERE rowid = '".$_REQUEST['categid']."'"; - $sql.= " AND entity = ".$conf->entity; - - $result = $db->query($sql); - - if (!$result) - { - dol_print_error($db); - } - } -} - - - -/* - * Affichage liste des catégories - */ - -llxHeader(); - - -print_fiche_titre($langs->trans("Rubriques")); - - - -print ''; -print ''; -print ''; -print "\n"; - -$sql = "SELECT rowid, label"; -$sql.= " FROM ".MAIN_DB_PREFIX."bank_categ"; -$sql.= " WHERE entity = ".$conf->entity; -$sql.= " ORDER BY label"; - -$result = $db->query($sql); -if ($result) -{ - $num = $db->num_rows($result); - $i = 0; $total = 0; - - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object($result); - $var=!$var; - print ""; - print ''; - if (GETPOST("action") == 'edit' && GETPOST("categid")== $objp->rowid) - { - print ""; - } - else - { - print ""; - print ''; - } - print ""; - $i++; - } - $db->free($result); -} - -/* - * Affichage ligne ajout de categorie - */ -$var=!$var; -print ''; -print ''; -print ""; -print ""; -print ""; -print ''; -print ""; -print "
'.$langs->trans("Ref").''.$langs->trans("Label").'
'.$objp->rowid.'"; - print '
'; - print ''; - print ''; - print ''; - print ''; - - print "
"; - print "
".$objp->label."'; - print ''.img_edit().'  '; - print ''.img_delete().'
 
"; - - -$db->close(); - -llxFooter(); -?> + + * Copyright (C) 2004-2008 Laurent Destailleur + * Copytight (C) 2005-2009 Regis Houssin + * Copytight (C) 2013 Charles-Fr BENKE + * + * 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 3 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, see . + */ + +/** + * \file htdocs/compta/bank/categ.php + * \ingroup compta + * \brief Page ajout de categories bancaires + */ + +require('../../main.inc.php'); +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + +$langs->load("banks"); +$langs->load("categories"); + +if (!$user->rights->banque->configurer) + accessforbidden(); + + + +/* +* Actions ajout catégorie +*/ +if ($_POST["action"] == 'add') +{ + if ($_POST["label"]) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_categ ("; + $sql.= "label"; + $sql.= ", entity"; + $sql.= ") VALUES ("; + $sql.= "'".$db->escape($_POST["label"])."'"; + $sql.= ", ".$conf->entity; + $sql.= ")"; + + $result = $db->query($sql); + + if (!$result) + { + dol_print_error($db); + } + } +} + +/* +* Action modification catégorie +*/ +if ($_POST["action"] == 'update') +{ + if ($_POST["label"]) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."bank_categ "; + $sql.= "set label='".$db->escape($_POST["label"])."'";; + $sql.= " WHERE rowid = '".$_REQUEST['categid']."'"; + $sql.= " AND entity = ".$conf->entity; + $result = $db->query($sql); + + if (!$result) + { + dol_print_error($db); + } + } +} +/* +* Action suppression catégorie +*/ +if ( $_REQUEST['action'] == 'delete' ) +{ + if ( $_REQUEST['categid'] ) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_categ"; + $sql.= " WHERE rowid = '".$_REQUEST['categid']."'"; + $sql.= " AND entity = ".$conf->entity; + + $result = $db->query($sql); + + if (!$result) + { + dol_print_error($db); + } + } +} + + + +/* + * Affichage liste des catégories + */ + +llxHeader(); + + +print_fiche_titre($langs->trans("Rubriques")); + + + +print ''; +print ''; +print ''; +print "\n"; + +$sql = "SELECT rowid, label"; +$sql.= " FROM ".MAIN_DB_PREFIX."bank_categ"; +$sql.= " WHERE entity = ".$conf->entity; +$sql.= " ORDER BY label"; + +$result = $db->query($sql); +if ($result) +{ + $num = $db->num_rows($result); + $i = 0; $total = 0; + + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object($result); + $var=!$var; + print ""; + print ''; + if (GETPOST("action") == 'edit' && GETPOST("categid")== $objp->rowid) + { + print ""; + } + else + { + print ""; + print ''; + } + print ""; + $i++; + } + $db->free($result); +} + +/* + * Affichage ligne ajout de categorie + */ +$var=!$var; +print ''; +print ''; +print ""; +print ""; +print ""; +print ''; +print ""; +print "
'.$langs->trans("Ref").''.$langs->trans("Label").'
'.$objp->rowid.'"; + print '
'; + print ''; + print ''; + print ''; + print ''; + + print "
"; + print "
".$objp->label."'; + print ''.img_edit().'  '; + print ''.img_delete().'
 
"; + + +$db->close(); + +llxFooter(); +?>