Fix: Deletion of translation has disappeared.
This commit is contained in:
parent
e1a461b3d6
commit
e2afa6853b
@ -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
|
||||
*/
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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 "<br>".($s?$s.' ':'')." <b>".$langs->trans('Language_'.$key).":</b><br>";
|
||||
print "<br>".($s?$s.' ':'')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?id='.$product->id.'&action=delete&langtodelete='.$key.'">'.img_delete('', '')."</a><br>";
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td width="15%">'.$langs->trans('Label').'</td><td>'.$product->multilangs[$key]["label"].'</td></tr>';
|
||||
print '<tr><td width="15%">'.$langs->trans('Description').'</td><td>'.$product->multilangs[$key]["description"].'</td></tr>';
|
||||
@ -257,8 +263,8 @@ if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service
|
||||
print '<input type="hidden" name="id" value="'.$_GET["id"].'">';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td valign="top" width="15%" class="fieldrequired">'.$langs->trans('Translation').'</td><td>';
|
||||
print $formadmin->select_language('','forcelangprod',0,$product->multilangs);
|
||||
print '<tr><td valign="top" width="15%" class="fieldrequired">'.$langs->trans('Language').'</td><td>';
|
||||
print $formadmin->select_language('','forcelangprod',0,$product->multilangs,1);
|
||||
print '</td></tr>';
|
||||
print '<tr><td valign="top" width="15%" class="fieldrequired">'.$langs->trans('Label').'</td><td><input name="libelle" size="40"></td></tr>';
|
||||
print '<tr><td valign="top" width="15%">'.$langs->trans('Description').'</td><td>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user