diff --git a/htdocs/admin/avoir.php b/htdocs/admin/avoir.php index 5662a9f7f7a..98dfe2e5898 100644 --- a/htdocs/admin/avoir.php +++ b/htdocs/admin/avoir.php @@ -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); diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index e7e9dfbf7a3..4b120ada9ba 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -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); diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index d1a0a746c5e..984cf019faf 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -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); diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 5ee1415a672..be653d43965 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -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); diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 7b705818a5d..3549a0325ac 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -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); diff --git a/htdocs/admin/fournisseur.php b/htdocs/admin/fournisseur.php index 784db70e435..4115c79aa6d 100644 --- a/htdocs/admin/fournisseur.php +++ b/htdocs/admin/fournisseur.php @@ -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); diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php index 706896731a2..d52f3fcf431 100644 --- a/htdocs/admin/livraison.php +++ b/htdocs/admin/livraison.php @@ -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); diff --git a/htdocs/admin/propale.php b/htdocs/admin/propale.php index 8595d91a66e..47e8b29cee4 100644 --- a/htdocs/admin/propale.php +++ b/htdocs/admin/propale.php @@ -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);