NEW : generate invoice PDF on disount application or payment

This commit is contained in:
florian HENRY 2017-07-25 12:20:51 +02:00
parent 73c7aa378e
commit cdcbff2a85
2 changed files with 34 additions and 0 deletions

View File

@ -400,6 +400,22 @@ if (empty($reshook))
setEventMessages($discount->error, $discount->errors, 'errors');
}
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$ret = $object->fetch($id); // Reload to get new records
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
}
else if ($action == 'setref_client' && $user->rights->facture->creer)

View File

@ -337,6 +337,24 @@ class Paiement extends CommonObject
$error++;
}
}
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$outputlangs = $langs;
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $invoice->thirdparty->default_lang;
if (! empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$ret = $invoice->fetch($id); // Reload to get new records
$result = $invoice->generateDocument($invoice->modelpdf, $outputlangs);
if ($result < 0) {
setEventMessages($invoice->error, $invoice->errors, 'errors');
$error++;
}
}
}
}