Fix: supprimait les autres modles si on leur avait donn le mme nom

This commit is contained in:
Regis Houssin 2006-06-09 09:03:41 +00:00
parent c8c3a10e0d
commit caac021d2e
8 changed files with 40 additions and 16 deletions

View File

@ -55,7 +55,9 @@ if ($_GET["action"] == 'set')
if ($_GET["action"] == 'del')
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom='".$_GET["value"]."'";
$type='creditnote';
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE nom = '".$_GET["value"]."' AND type = '".$type."'";
if ($db->query($sql))
{
@ -75,7 +77,8 @@ if ($_GET["action"] == 'setdoc')
// On active le modele
$type='creditnote';
$sql_del = "delete from ".MAIN_DB_PREFIX."document_model where nom = '".$_GET["value"]."'";
$sql_del = "delete from ".MAIN_DB_PREFIX."document_model";
$sql_del .= " WHERE nom = '".$_GET["value"]."' AND type = '".$type."'";
$result1=$db->query($sql_del);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom,type) VALUES ('".$_GET["value"]."','".$type."')";
$result2=$db->query($sql);

View File

@ -58,7 +58,9 @@ if ($_GET["action"] == 'set')
if ($_GET["action"] == 'del')
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom='".$_GET["value"]."'";
$type='order';
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE nom = '".$_GET["value"]."' AND type = '".$type."'";
if ($db->query($sql))
{
@ -78,7 +80,8 @@ if ($_GET["action"] == 'setdoc')
// On active le modele
$type='order';
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model where nom = '".$_GET["value"]."'";
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql_del .= " WHERE nom = '".$_GET["value"]."' AND type = '".$type."'";
$result1=$db->query($sql_del);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom,type) VALUES ('".$_GET["value"]."','".$type."')";
$result2=$db->query($sql);

View File

@ -58,7 +58,9 @@ if ($_GET["action"] == 'set')
if ($_GET["action"] == 'del')
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom='".$_GET["value"]."'";
$type='shipping';
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE nom = '".$_GET["value"]."' AND type = '".$type."'";
if ($db->query($sql))
{
@ -78,7 +80,8 @@ if ($_GET["action"] == 'setdoc')
// On active le modele
$type='shipping';
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model where nom = '".$_GET["value"]."'";
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql_del .= " WHERE nom = '".$_GET["value"]."' AND type = '".$type."'";
$result1=$db->query($sql_del);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom,type) VALUES ('".$_GET["value"]."','".$type."')";
$result2=$db->query($sql);

View File

@ -58,7 +58,9 @@ if ($_GET["action"] == 'set')
if ($_GET["action"] == 'del')
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom='".$_GET["value"]."'";
$type='invoice';
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE nom = '".$_GET["value"]."' AND type = '".$type."'";
if ($db->query($sql))
{
@ -78,7 +80,8 @@ if ($_GET["action"] == 'setdoc')
// On active le modele
$type='invoice';
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model where nom = '".$_GET["value"]."'";
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql_del .= " WHERE nom = '".$_GET["value"]."' AND type = '".$type."'";
$result1=$db->query($sql_del);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom,type) VALUES ('".$_GET["value"]."','".$type."')";
$result2=$db->query($sql);

View File

@ -56,7 +56,9 @@ if ($_GET["action"] == 'set')
if ($_GET["action"] == 'del')
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom='".$_GET["value"]."'";
$type='ficheinter';
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE nom = '".$_GET["value"]."' AND type = '".$type."'";
if ($db->query($sql))
{
@ -76,7 +78,8 @@ if ($_GET["action"] == 'setdoc')
// On active le modele
$type='ficheinter';
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model where nom = '".$_GET["value"]."'";
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql_del .= " WHERE nom = '".$_GET["value"]."' AND type = '".$type."'";
$result1=$db->query($sql_del);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom,type) VALUES ('".$_GET["value"]."','".$type."')";
$result2=$db->query($sql);

View File

@ -58,7 +58,9 @@ if ($_GET["action"] == 'set')
if ($_GET["action"] == 'del')
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom='".$_GET["value"]."'";
$type='supplier_order';
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE nom = '".$_GET["value"]."' AND type = '".$type."'";
if ($db->query($sql))
{
@ -78,7 +80,8 @@ if ($_GET["action"] == 'setdoc')
// On active le modele
$type='supplier_order';
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model where nom = '".$_GET["value"]."'";
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql_del .= " WHERE nom = '".$_GET["value"]."' AND type = '".$type."'";
$result1=$db->query($sql_del);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom,type) VALUES ('".$_GET["value"]."','".$type."')";
$result2=$db->query($sql);

View File

@ -58,7 +58,9 @@ if ($_GET["action"] == 'set')
if ($_GET["action"] == 'del')
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom='".$_GET["value"]."'";
$type='delivery';
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE nom = '".$_GET["value"]."' AND type = '".$type."'";
if ($db->query($sql))
{
@ -78,7 +80,8 @@ if ($_GET["action"] == 'setdoc')
// On active le modele
$type='delivery';
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model where nom = '".$_GET["value"]."'";
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql_del .= " WHERE nom = '".$_GET["value"]."' AND type = '".$type."'";
$result1=$db->query($sql_del);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom,type) VALUES ('".$_GET["value"]."','".$type."')";
$result2=$db->query($sql);

View File

@ -76,7 +76,9 @@ if ($_GET["action"] == 'set')
}
if ($_GET["action"] == 'del')
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom='".$_GET["value"]."'";
$type='propal';
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE nom = '".$_GET["value"]."' AND type = '".$type."'";
if ($db->query($sql))
{
@ -96,7 +98,8 @@ if ($_GET["action"] == 'setdoc')
// On active le modele
$type='propal';
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model where nom = '".$_GET["value"]."'";
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql_del .= " WHERE nom = '".$_GET["value"]."' AND type = '".$type."'";
$result1=$db->query($sql_del);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom,type) VALUES ('".$_GET["value"]."','".$type."')";
$result2=$db->query($sql);