diff --git a/htdocs/compta/bank/categ.php b/htdocs/compta/bank/categ.php index 3086fdb0f9d..ab589e89001 100644 --- a/htdocs/compta/bank/categ.php +++ b/htdocs/compta/bank/categ.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2004-2013 Laurent Destailleur * Copytight (C) 2005-2009 Regis Houssin * Copytight (C) 2013 Charles-Fr BENKE * @@ -30,28 +30,30 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $langs->load("banks"); $langs->load("categories"); +$action=GETPOST('action'); + if (!$user->rights->banque->configurer) accessforbidden(); /* -* Actions ajout catégorie -*/ -if ($_POST["action"] == 'add') + * Add category + */ +if (GETPOST('add')) { - if ($_POST["label"]) + if (GETPOST("label")) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_categ ("; $sql.= "label"; $sql.= ", entity"; $sql.= ") VALUES ("; - $sql.= "'".$db->escape($_POST["label"])."'"; + $sql.= "'".$db->escape(GETPOST("label"))."'"; $sql.= ", ".$conf->entity; $sql.= ")"; + dol_syslog("sql=".$sql); $result = $db->query($sql); - if (!$result) { dol_print_error($db); @@ -60,18 +62,19 @@ if ($_POST["action"] == 'add') } /* -* Action modification catégorie -*/ -if ($_POST["action"] == 'update') + * Update category + */ +if (GETPOST('update')) { - if ($_POST["label"]) + if (GETPOST("label")) { $sql = "UPDATE ".MAIN_DB_PREFIX."bank_categ "; - $sql.= "set label='".$db->escape($_POST["label"])."'";; - $sql.= " WHERE rowid = '".$_REQUEST['categid']."'"; + $sql.= "set label='".$db->escape(GETPOST("label"))."'"; + $sql.= " WHERE rowid = '".GETPOST('categid')."'"; $sql.= " AND entity = ".$conf->entity; - $result = $db->query($sql); + dol_syslog("sql=".$sql); + $result = $db->query($sql); if (!$result) { dol_print_error($db); @@ -81,16 +84,16 @@ if ($_POST["action"] == 'update') /* * Action suppression catégorie */ -if ( $_REQUEST['action'] == 'delete' ) +if ($action == 'delete') { - if ( $_REQUEST['categid'] ) + if (GETPOST('categid')) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_categ"; - $sql.= " WHERE rowid = '".$_REQUEST['categid']."'"; + $sql.= " WHERE rowid = '".GETPOST('categid')."'"; $sql.= " AND entity = ".$conf->entity; + dol_syslog("sql=".$sql); $result = $db->query($sql); - if (!$result) { dol_print_error($db); @@ -101,7 +104,7 @@ if ( $_REQUEST['action'] == 'delete' ) /* - * Affichage liste des catégories + * View */ llxHeader(); @@ -109,7 +112,8 @@ llxHeader(); print_fiche_titre($langs->trans("Rubriques")); - +print '
'; +print ''; print ''; print ''; @@ -124,56 +128,57 @@ $sql.= " ORDER BY label"; $result = $db->query($sql); if ($result) { - $num = $db->num_rows($result); - $i = 0; $total = 0; + $num = $db->num_rows($result); + $i = 0; $total = 0; - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object($result); - $var=!$var; - print ""; - print ''; + $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 ''.img_edit().'  '; + print ''.img_delete().''; } print ""; - $i++; - } - $db->free($result); + $i++; + } + $db->free($result); } +print ""; + /* - * Affichage ligne ajout de categorie + * Line to add category */ -$var=!$var; -print ''; -print ''; -print ""; -print ""; -print ""; -print ''; -print ""; +if ($action != 'edit') +{ + $var=!$var; + print ''; + print ''; + print ''; + print ''; +} + print "
'.$objp->rowid.'
'.$objp->rowid.'"; - print ''; - print ''; print ''; print ''; - print ''; + print ''; - print ""; print "".$objp->label."'; - print ''.img_edit().'  '; - print ''.img_delete().'
 
 
"; - -$db->close(); +print ""; llxFooter(); + +$db->close(); ?>