diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index 98fc1078d48..9a9178fb917 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2006 Regis Houssin + * Copyright (C) 2005-2007 Regis Houssin * * 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 @@ -124,13 +124,38 @@ if ($_GET["action"] == 'setdoc') } // \todo A quoi servent les methode d'expedition ? -if ($_GET["action"] == 'setmethod') +if ($_GET["action"] == 'setmethod' || $_GET["action"] == 'setmod') { - $db->begin(); - - $value=$_GET["value"]; - $sql = "INSERT INTO ".MAIN_DB_PREFIX."expedition_methode (code,libelle,description,statut)"; - $sql.= " VALUES ('".$_GET["value"]."','".$_GET["value"]."','',1)"; + $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(); + + $sqlu = "UPDATE ".MAIN_DB_PREFIX."expedition_methode"; + $sqlu.= " SET statut=1"; + $sqlu.= " WHERE rowid=".$moduleid; + $result=$db->query($sqlu); + if ($result) + { + $db->commit(); + } + else + { + $db->rollback(); + } + } + + 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) { @@ -140,6 +165,24 @@ if ($_GET["action"] == 'setmethod') { $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') @@ -147,7 +190,7 @@ if ($_GET["action"] == 'setmod') // \todo Verifier si module numerotation choisi peut etre activé // 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; print ""; - echo $module->name; + print $module->name; print "\n"; print $module->description; @@ -240,13 +283,13 @@ if(is_dir($dir)) { print img_tick(); print ''; - print ''.$langs->trans("Disable").''; + print 'id.'">'.$langs->trans("Disable").''; } else { print ' '; - print ''.$langs->trans("Activate").''; + print 'id.'">'.$langs->trans("Activate").''; } print ''; @@ -259,7 +302,7 @@ if(is_dir($dir)) } else { - print ''.$langs->trans("Default").''; + print 'id.'">'.$langs->trans("Default").''; } print '';