Merge pull request #20016 from FHenry/14_fix_sql_extrafields

fix: in some case index do not exists and return an error
This commit is contained in:
Laurent Destailleur 2022-02-10 10:14:06 +01:00 committed by GitHub
commit 5bcf2153ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -608,10 +608,14 @@ class ExtraFields
if ($unique) {
$sql = "ALTER TABLE ".$this->db->prefix().$table." ADD UNIQUE INDEX uk_".$table."_".$attrname." (".$attrname.")";
} else {
$sql = "ALTER TABLE ".$this->db->prefix().$table." DROP INDEX uk_".$table."_".$attrname;
$sql = "ALTER TABLE ".$this->db->prefix().$table." DROP INDEX IF EXISTS uk_".$table."_".$attrname;
}
dol_syslog(get_class($this).'::update', LOG_DEBUG);
$resql = $this->db->query($sql, 1, 'dml');
/*if ($resql < 0) {
$this->error = $this->db->lasterror();
return -1;
}*/
return 1;
} else {
$this->error = $this->db->lasterror();

View File

@ -1066,11 +1066,11 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_
}
// Capital
if (!empty($fromcompany->capital) && $fromcompany->capital) {
$tmpamounttoshow = price2num($fromcompany->capital); // This field is a free string
$tmpamounttoshow = price2num($fromcompany->capital); // This field is a free string or a float
if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) {
$line3 .= ($line3 ? " - " : "").$outputlangs->transnoentities("CapitalOf", price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, $conf->currency));
} else {
$line3 .= ($line3 ? " - " : "").$outputlangs->transnoentities("CapitalOf", $tmpamounttoshow, $outputlangs);
} elseif (!empty($fromcompany->capital)) {
$line3 .= ($line3 ? " - " : "").$outputlangs->transnoentities("CapitalOf", $fromcompany->capital, $outputlangs);
}
}
// Prof Id 1