Fix: Ton of bugs into bank categ editor (W3C, update error, syntax
error...)
This commit is contained in:
parent
da40c460bb
commit
4133bfc3a4
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copytight (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
|
* Copytight (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
|
||||||
* Copytight (C) 2013 Charles-Fr BENKE <charles.fr@benke.fr>
|
* Copytight (C) 2013 Charles-Fr BENKE <charles.fr@benke.fr>
|
||||||
*
|
*
|
||||||
@ -30,28 +30,30 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
|||||||
$langs->load("banks");
|
$langs->load("banks");
|
||||||
$langs->load("categories");
|
$langs->load("categories");
|
||||||
|
|
||||||
|
$action=GETPOST('action');
|
||||||
|
|
||||||
if (!$user->rights->banque->configurer)
|
if (!$user->rights->banque->configurer)
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions ajout catégorie
|
* Add category
|
||||||
*/
|
*/
|
||||||
if ($_POST["action"] == 'add')
|
if (GETPOST('add'))
|
||||||
{
|
{
|
||||||
if ($_POST["label"])
|
if (GETPOST("label"))
|
||||||
{
|
{
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_categ (";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_categ (";
|
||||||
$sql.= "label";
|
$sql.= "label";
|
||||||
$sql.= ", entity";
|
$sql.= ", entity";
|
||||||
$sql.= ") VALUES (";
|
$sql.= ") VALUES (";
|
||||||
$sql.= "'".$db->escape($_POST["label"])."'";
|
$sql.= "'".$db->escape(GETPOST("label"))."'";
|
||||||
$sql.= ", ".$conf->entity;
|
$sql.= ", ".$conf->entity;
|
||||||
$sql.= ")";
|
$sql.= ")";
|
||||||
|
|
||||||
|
dol_syslog("sql=".$sql);
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
|
|
||||||
if (!$result)
|
if (!$result)
|
||||||
{
|
{
|
||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
@ -60,18 +62,19 @@ if ($_POST["action"] == 'add')
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Action modification catégorie
|
* Update category
|
||||||
*/
|
*/
|
||||||
if ($_POST["action"] == 'update')
|
if (GETPOST('update'))
|
||||||
{
|
{
|
||||||
if ($_POST["label"])
|
if (GETPOST("label"))
|
||||||
{
|
{
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."bank_categ ";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."bank_categ ";
|
||||||
$sql.= "set label='".$db->escape($_POST["label"])."'";;
|
$sql.= "set label='".$db->escape(GETPOST("label"))."'";
|
||||||
$sql.= " WHERE rowid = '".$_REQUEST['categid']."'";
|
$sql.= " WHERE rowid = '".GETPOST('categid')."'";
|
||||||
$sql.= " AND entity = ".$conf->entity;
|
$sql.= " AND entity = ".$conf->entity;
|
||||||
$result = $db->query($sql);
|
|
||||||
|
|
||||||
|
dol_syslog("sql=".$sql);
|
||||||
|
$result = $db->query($sql);
|
||||||
if (!$result)
|
if (!$result)
|
||||||
{
|
{
|
||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
@ -81,16 +84,16 @@ if ($_POST["action"] == 'update')
|
|||||||
/*
|
/*
|
||||||
* Action suppression catégorie
|
* 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 = "DELETE FROM ".MAIN_DB_PREFIX."bank_categ";
|
||||||
$sql.= " WHERE rowid = '".$_REQUEST['categid']."'";
|
$sql.= " WHERE rowid = '".GETPOST('categid')."'";
|
||||||
$sql.= " AND entity = ".$conf->entity;
|
$sql.= " AND entity = ".$conf->entity;
|
||||||
|
|
||||||
|
dol_syslog("sql=".$sql);
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
|
|
||||||
if (!$result)
|
if (!$result)
|
||||||
{
|
{
|
||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
@ -101,7 +104,7 @@ if ( $_REQUEST['action'] == 'delete' )
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Affichage liste des catégories
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
llxHeader();
|
llxHeader();
|
||||||
@ -109,7 +112,8 @@ llxHeader();
|
|||||||
|
|
||||||
print_fiche_titre($langs->trans("Rubriques"));
|
print_fiche_titre($langs->trans("Rubriques"));
|
||||||
|
|
||||||
|
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||||
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
|
|
||||||
print '<table class="noborder" width="100%">';
|
print '<table class="noborder" width="100%">';
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
@ -124,56 +128,57 @@ $sql.= " ORDER BY label";
|
|||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$num = $db->num_rows($result);
|
$num = $db->num_rows($result);
|
||||||
$i = 0; $total = 0;
|
$i = 0; $total = 0;
|
||||||
|
|
||||||
$var=True;
|
$var=True;
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$objp = $db->fetch_object($result);
|
$objp = $db->fetch_object($result);
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print "<tr $bc[$var]>";
|
print "<tr ".$bc[$var].">";
|
||||||
print '<td><a href="'.DOL_URL_ROOT.'/compta/bank/budget.php?bid='.$objp->rowid.'">'.$objp->rowid.'</a></td>';
|
print '<td><a href="'.DOL_URL_ROOT.'/compta/bank/budget.php?bid='.$objp->rowid.'">'.$objp->rowid.'</a></td>';
|
||||||
if (GETPOST("action") == 'edit' && GETPOST("categid")== $objp->rowid)
|
if (GETPOST("action") == 'edit' && GETPOST("categid")== $objp->rowid)
|
||||||
{
|
{
|
||||||
print "<td colspan=2>";
|
print "<td colspan=2>";
|
||||||
print '<form method="post" action="categ.php">';
|
|
||||||
print '<input type="hidden" name="action" value="update">';
|
|
||||||
print '<input type="hidden" name="categid" value="'.$objp->rowid.'">';
|
print '<input type="hidden" name="categid" value="'.$objp->rowid.'">';
|
||||||
print '<input name="label" type="text" size=45 value="'.$objp->label.'">';
|
print '<input name="label" type="text" size=45 value="'.$objp->label.'">';
|
||||||
print '<input type="submit" class="button" value="'.$langs->trans("Edit").'">';
|
print '<input type="submit" name="update" class="button" value="'.$langs->trans("Edit").'">';
|
||||||
|
|
||||||
print "</form>";
|
|
||||||
print "</td>";
|
print "</td>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print "<td >".$objp->label."</td>";
|
print "<td >".$objp->label."</td>";
|
||||||
print '<td style="text-align: center;">';
|
print '<td style="text-align: center;">';
|
||||||
print '<a href="categ.php?categid='.$objp->rowid.'&action=edit">'.img_edit().'</a> ';
|
print '<a href="'.$_SERVER["PHP_SELF"].'?categid='.$objp->rowid.'&action=edit">'.img_edit().'</a> ';
|
||||||
print '<a href="categ.php?categid='.$objp->rowid.'&action=delete">'.img_delete().'</a></td>';
|
print '<a href="'.$_SERVER["PHP_SELF"].'?categid='.$objp->rowid.'&action=delete">'.img_delete().'</a></td>';
|
||||||
}
|
}
|
||||||
print "</tr>";
|
print "</tr>";
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$db->free($result);
|
$db->free($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Affichage ligne ajout de categorie
|
|
||||||
*/
|
|
||||||
$var=!$var;
|
|
||||||
print '<form method="post" action="categ.php">';
|
|
||||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
|
||||||
print "<input type=\"hidden\" name=\"action\" value=\"add\">";
|
|
||||||
print "<tr $bc[$var]>";
|
|
||||||
print "<td> </td><td><input name=\"label\" type=\"text\" size=45></td>";
|
|
||||||
print '<td align="center"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td></tr>';
|
|
||||||
print "</form>";
|
print "</form>";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Line to add category
|
||||||
|
*/
|
||||||
|
if ($action != 'edit')
|
||||||
|
{
|
||||||
|
$var=!$var;
|
||||||
|
print '<tr '.$bc[$var].'>';
|
||||||
|
print '<td> </td><td><input name="label" type="text" size="45"></td>';
|
||||||
|
print '<td align="center"><input type="submit" name="add" class="button" value="'.$langs->trans("Add").'"></td>';
|
||||||
|
print '</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
print "</table>";
|
print "</table>";
|
||||||
|
|
||||||
|
print "</form>";
|
||||||
$db->close();
|
|
||||||
|
|
||||||
llxFooter();
|
llxFooter();
|
||||||
|
|
||||||
|
$db->close();
|
||||||
?>
|
?>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user