Skip to content

Commit

Permalink
fix warning
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Dec 23, 2024
1 parent 5f06584 commit 89cddfa
Showing 1 changed file with 27 additions and 29 deletions.
56 changes: 27 additions & 29 deletions htdocs/core/lib/invoice2.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,40 +242,38 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte
$fac = new Expedition($db);
}

if ($fac) {
$result = $fac->fetch($obj->rowid);
if ($result > 0) {
$outputlangs = $langs;
if (!empty($newlangid)) {
if ($outputlangs->defaultlang != $newlangid) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlangid);
}
$result = $fac->fetch($obj->rowid);
if ($result > 0) {
$outputlangs = $langs;
if (!empty($newlangid)) {
if ($outputlangs->defaultlang != $newlangid) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlangid);
}
$filename = $dir_output.'/'.$fac->ref.'/'.$fac->ref.'.pdf';
if ($regenerate || !dol_is_file($filename)) {
if ($usestdout) {
print "Build PDF for document ".$obj->ref." - Lang = ".$outputlangs->defaultlang."\n";
}
$result = $fac->generateDocument($regenerate ? $regenerate : $fac->model_pdf, $outputlangs);
} else {
if ($usestdout) {
print "PDF for document ".$obj->ref." already exists\n";
}
}

// Add file into files array
$files[] = $filename;
}

if ($result <= 0) {
$error++;
$filename = $dir_output.'/'.$fac->ref.'/'.$fac->ref.'.pdf';
if ($regenerate || !dol_is_file($filename)) {
if ($usestdout) {
print "Build PDF for document ".$obj->ref." - Lang = ".$outputlangs->defaultlang."\n";
}
$result = $fac->generateDocument($regenerate ? $regenerate : $fac->model_pdf, $outputlangs);
} else {
if ($usestdout) {
print "Error: Failed to build PDF for document ".($fac->ref ? $fac->ref : ' id '.$obj->rowid)."\n";
} else {
dol_syslog("Failed to build PDF for document ".($fac->ref ? $fac->ref : ' id '.$obj->rowid), LOG_ERR);
print "PDF for document ".$obj->ref." already exists\n";
}
}

// Add file into files array
$files[] = $filename;
}

if ($result <= 0) {
$error++;
if ($usestdout) {
print "Error: Failed to build PDF for document ".($fac->ref ? $fac->ref : ' id '.$obj->rowid)."\n";
} else {
dol_syslog("Failed to build PDF for document ".($fac->ref ? $fac->ref : ' id '.$obj->rowid), LOG_ERR);
}
}

$cpt++;
Expand Down

0 comments on commit 89cddfa

Please sign in to comment.