diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index f306cf4b372..bc38958fa9e 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -172,7 +172,7 @@ function dol_shutdown()
* Return value of a param into GET or POST supervariable
*
* @param string $paramname Name of parameter to found
- * @param string $check Type of check (''=no check, 'int'=check it's numeric, 'alpha'=check it's text and sign, 'az'=check it's a-z only, 'array'=check it's array)
+ * @param string $check Type of check (''=no check, 'int'=check it's numeric, 'alpha'=check it's text and sign, 'aZ'=check it's a-z only, 'array'=check it's array)
* @param int $method Type of method (0 = get then post, 1 = only get, 2 = only post, 3 = post then get, 4 = post then get then cookie)
* @return string||string[] Value found, or '' if check fails
*/
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index a2d2ee36d9c..1ba5f7b2283 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -269,7 +269,7 @@ class Product extends CommonObject
// Barcode value
$this->barcode=trim($this->barcode);
-
+
// Check parameters
if (empty($this->libelle))
{
@@ -309,11 +309,11 @@ class Product extends CommonObject
// For automatic creation during create action (not used by Dolibarr GUI, can be used by scripts)
if ($this->barcode == -1) $this->barcode = $this->get_barcode($this,$this->barcode_type_code);
-
+
// Check more parameters
// If error, this->errors[] is filled
$result = $this->verify();
-
+
if ($result >= 0)
{
$sql = "SELECT count(*) as nb";
@@ -520,7 +520,7 @@ class Product extends CommonObject
}
$mod = new $module();
-
+
dol_syslog(get_class($this)."::check_barcode value=".$valuetotest." type=".$typefortest." module=".$module);
$result = $mod->verif($this->db, $valuetotest, $this, 0, $typefortest);
return $result;
@@ -586,7 +586,7 @@ class Product extends CommonObject
{
$result = $this->verify(); // We don't check when update called during a create because verify was already done
}
-
+
if ($result >= 0)
{
// For automatic creation
@@ -600,7 +600,7 @@ class Product extends CommonObject
$sql.= ", recuperableonly = " . $this->tva_npr;
$sql.= ", localtax1_tx = " . $this->localtax1_tx;
$sql.= ", localtax2_tx = " . $this->localtax2_tx;
-
+
$sql.= ", barcode = ". (empty($this->barcode)?"null":"'".$this->db->escape($this->barcode)."'");
$sql.= ", fk_barcode_type = ". (empty($this->barcode_type)?"null":$this->db->escape($this->barcode_type));
@@ -627,7 +627,7 @@ class Product extends CommonObject
$sql.= ", accountancy_code_sell= '" . $this->accountancy_code_sell."'";
$sql.= ", desiredstock = " . ((isset($this->desiredstock) && $this->desiredstock != '') ? $this->desiredstock : "null");
$sql.= " WHERE rowid = " . $id;
-
+
dol_syslog(get_class($this)."update sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
@@ -859,7 +859,7 @@ class Product extends CommonObject
}
/**
- * Update ou cree les traductions des infos produits
+ * Update or add a translation for a product
*
* @return int <0 if KO, >0 if OK
*/
@@ -936,6 +936,29 @@ class Product extends CommonObject
return 1;
}
+ /**
+ * Delete a language for this product
+ *
+ * @param string $langtodelete Language to delete
+ * @return int <0 if KO, >0 if OK
+ */
+ function delMultiLangs($langtodelete)
+ {
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_lang";
+ $sql.= " WHERE fk_product=".$this->id." AND lang='".$this->db->escape($langtodelete)."'";
+
+ dol_syslog("Delete translation sql=".$sql);
+ $result = $this->db->query($sql);
+ if ($result)
+ {
+ return 1;
+ }
+ else
+ {
+ $this->error="Error: ".$this->db->error()." - ".$sql;
+ return -1;
+ }
+ }
/**
* Load array this->multilangs
@@ -973,7 +996,7 @@ class Product extends CommonObject
}
else
{
- $this->error=$langs->trans("Error")." : ".$this->db->error()." - ".$sql;
+ $this->error="Error: ".$this->db->error()." - ".$sql;
return -1;
}
}
diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php
index 045b9c8cf1d..f273eef35bf 100644
--- a/htdocs/product/traduction.php
+++ b/htdocs/product/traduction.php
@@ -55,6 +55,12 @@ if ($cancel == $langs->trans("Cancel"))
$action = '';
}
+if ($action == 'delete' && GETPOST('langtodelete','alpha'))
+{
+ $product = new Product($db);
+ $product->fetch($id);
+ $product->delMultiLangs(GETPOST('langtodelete','alpha'));
+}
// Validation de l'ajout
if ($action == 'vadd' &&
@@ -209,7 +215,7 @@ else
{
$cnt_trans++;
$s=picto_from_langcode($key);
- print "
".($s?$s.' ':'')." ".$langs->trans('Language_'.$key).":
";
+ print "
".($s?$s.' ':'')." ".$langs->trans('Language_'.$key).": ".'id.'&action=delete&langtodelete='.$key.'">'.img_delete('', '')."
";
print '
';
print '| '.$langs->trans('Label').' | '.$product->multilangs[$key]["label"].' |
';
print '| '.$langs->trans('Description').' | '.$product->multilangs[$key]["description"].' |
';
@@ -257,8 +263,8 @@ if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service
print '';
print '