Skip to content

Commit

Permalink
Merge branch 'develop' into fix_supplier_proposal_free_text
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy authored Dec 24, 2024
2 parents 990d32d + 89cddfa commit 91371c4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 30 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
2 changes: 1 addition & 1 deletion htdocs/core/lib/modulebuilder.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = '
foreach ($object->fields as $key => $val) {
$i++;
if (!empty($val['index'])) {
$texttoinsert .= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD INDEX idx_".strtolower($module).'_'.strtolower($objectname)."_".$key." (".$key.");";
$texttoinsert .= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD ".($key == 'ref' ? "UNIQUE INDEX uk_" : "INDEX idx_").strtolower($module).'_'.strtolower($objectname)."_".$key." (".$key.($key == 'ref' && array_key_exists('entity', $object->fields) ? ", entity" : "").");";
$texttoinsert .= "\n";
}
if (!empty($val['foreignkey'])) {
Expand Down

0 comments on commit 91371c4

Please sign in to comment.