Fix: le choix de la méthode d'expédition était mal gérée

This commit is contained in:
Regis Houssin 2007-04-27 22:33:39 +00:00
parent 374542a341
commit 1bcf68d59c

View File

@ -4,7 +4,7 @@
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org> * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2006 Regis Houssin <regis.houssin@cap-networks.com> * Copyright (C) 2005-2007 Regis Houssin <regis.houssin@cap-networks.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -124,14 +124,22 @@ if ($_GET["action"] == 'setdoc')
} }
// \todo A quoi servent les methode d'expedition ? // \todo A quoi servent les methode d'expedition ?
if ($_GET["action"] == 'setmethod') if ($_GET["action"] == 'setmethod' || $_GET["action"] == 'setmod')
{
$module=$_GET["module"];
$moduleid=$_GET["moduleid"];
$statut=$_GET["statut"];
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."expedition_methode WHERE rowid = ".$moduleid;
$resql = $db->query($sql);
if ($resql && ($statut == 1 || $_GET["action"] == 'setmod'))
{ {
$db->begin(); $db->begin();
$value=$_GET["value"]; $sqlu = "UPDATE ".MAIN_DB_PREFIX."expedition_methode";
$sql = "INSERT INTO ".MAIN_DB_PREFIX."expedition_methode (code,libelle,description,statut)"; $sqlu.= " SET statut=1";
$sql.= " VALUES ('".$_GET["value"]."','".$_GET["value"]."','',1)"; $sqlu.= " WHERE rowid=".$moduleid;
$result=$db->query($sql); $result=$db->query($sqlu);
if ($result) if ($result)
{ {
$db->commit(); $db->commit();
@ -142,12 +150,47 @@ if ($_GET["action"] == 'setmethod')
} }
} }
if ($statut == 1 || $_GET["action"] == 'setmod')
{
$db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."expedition_methode (rowid,code,libelle,description,statut)";
$sql.= " VALUES (".$moduleid.",'".$module."','".$module."','',1)";
$result=$db->query($sql);
if ($result)
{
$db->commit();
}
else
{
$db->rollback();
}
}
else if ($statut == 0)
{
$db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."expedition_methode";
$sql.= " SET statut=0";
$sql.= " WHERE rowid=".$moduleid;
$result=$db->query($sql);
if ($result)
{
$db->commit();
}
else
{
$db->rollback();
}
}
}
if ($_GET["action"] == 'setmod') if ($_GET["action"] == 'setmod')
{ {
// \todo Verifier si module numerotation choisi peut etre activé // \todo Verifier si module numerotation choisi peut etre activé
// par appel methode canBeActivated // par appel methode canBeActivated
dolibarr_set_const($db, "EXPEDITION_ADDON",$_GET["value"]); dolibarr_set_const($db, "EXPEDITION_ADDON",$_GET["module"]);
} }
@ -229,7 +272,7 @@ if(is_dir($dir))
$var=!$var; $var=!$var;
print "<tr $bc[$var]><td>"; print "<tr $bc[$var]><td>";
echo $module->name; print $module->name;
print "</td><td>\n"; print "</td><td>\n";
print $module->description; print $module->description;
@ -240,13 +283,13 @@ if(is_dir($dir))
{ {
print img_tick(); print img_tick();
print '</td><td align="center">'; print '</td><td align="center">';
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmethod&amp;statut=0&amp;value='.$name.'">'.$langs->trans("Disable").'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmethod&amp;statut=0&amp;module='.$name.'&amp;moduleid='.$module->id.'">'.$langs->trans("Disable").'</a>';
} }
else else
{ {
print '&nbsp;</td><td align="center">'; print '&nbsp;</td><td align="center">';
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmethod&amp;statut=1&amp;value='.$name.'">'.$langs->trans("Activate").'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmethod&amp;statut=1&amp;module='.$name.'&amp;moduleid='.$module->id.'">'.$langs->trans("Activate").'</a>';
} }
print '</td>'; print '</td>';
@ -259,7 +302,7 @@ if(is_dir($dir))
} }
else else
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$name.'">'.$langs->trans("Default").'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;module='.$name.'&amp;moduleid='.$module->id.'">'.$langs->trans("Default").'</a>';
} }
print '</td>'; print '</td>';