mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
debug rebuild_merge_pdf
This commit is contained in:
parent
3fc800b1b2
commit
35e935f4be
|
|
@ -54,17 +54,38 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
|
|||
function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filter, $dateafterdate, $datebeforedate, $paymentdateafter, $paymentdatebefore, $usestdout, $regenerate = '', $filesuffix = '', $paymentbankid = '', $thirdpartiesid = [], $fileprefix = 'mergedpdf', $donotmerge = 0, $mode = 'invoice')
|
||||
{
|
||||
if ($mode == 'invoice') {
|
||||
require_once DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php";
|
||||
require_once DOL_DOCUMENT_ROOT."/core/modules/facture/modules_facture.php";
|
||||
|
||||
$table = "facture";
|
||||
$dir_output = $conf->facture->dir_output;
|
||||
$date = "datef";
|
||||
|
||||
if ($diroutputpdf == 'auto') {
|
||||
$diroutputpdf = $conf->invoice->dir_output.'/temp';
|
||||
}
|
||||
} elseif ($mode == 'order') {
|
||||
require_once DOL_DOCUMENT_ROOT."/commande/class/commande.class.php";
|
||||
require_once DOL_DOCUMENT_ROOT."/core/modules/commande/modules_commande.php";
|
||||
|
||||
$table = "commande";
|
||||
$dir_output = $conf->commande->dir_output;
|
||||
$dir_output = $conf->order->dir_output;
|
||||
$date = "date";
|
||||
|
||||
if ($diroutputpdf == 'auto') {
|
||||
$diroutputpdf = $conf->order->dir_output.'/temp';
|
||||
}
|
||||
} elseif ($mode == 'proposal') {
|
||||
require_once DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php";
|
||||
require_once DOL_DOCUMENT_ROOT."/core/modules/propale/modules_propale.php";
|
||||
|
||||
$table = "propal";
|
||||
$dir_output = $conf->propal->dir_output;
|
||||
$date = "date";
|
||||
|
||||
if ($diroutputpdf == 'auto') {
|
||||
$diroutputpdf = $conf->propal->dir_output.'/temp';
|
||||
}
|
||||
} else {
|
||||
print "Bad value for mode";
|
||||
return -1;
|
||||
|
|
@ -219,12 +240,12 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte
|
|||
$filename = $dir_output.'/'.$fac->ref.'/'.$fac->ref.'.pdf';
|
||||
if ($regenerate || !dol_is_file($filename)) {
|
||||
if ($usestdout) {
|
||||
print "Build PDF for invoice ".$obj->ref." - Lang = ".$outputlangs->defaultlang."\n";
|
||||
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 invoice ".$obj->ref." already exists\n";
|
||||
print "PDF for document ".$obj->ref." already exists\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -235,9 +256,9 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte
|
|||
if ($result <= 0) {
|
||||
$error++;
|
||||
if ($usestdout) {
|
||||
print "Error: Failed to build PDF for invoice ".($fac->ref ? $fac->ref : ' id '.$obj->rowid)."\n";
|
||||
print "Error: Failed to build PDF for document ".($fac->ref ? $fac->ref : ' id '.$obj->rowid)."\n";
|
||||
} else {
|
||||
dol_syslog("Failed to build PDF for invoice ".($fac->ref ? $fac->ref : ' id '.$obj->rowid), LOG_ERR);
|
||||
dol_syslog("Failed to build PDF for document ".($fac->ref ? $fac->ref : ' id '.$obj->rowid), LOG_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,10 +43,9 @@ if (substr($sapi_type, 0, 3) == 'cgi') {
|
|||
require_once $path."../../htdocs/master.inc.php";
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functionscli.lib.php';
|
||||
// After this $db is an opened handler to database. We close it at end of file.
|
||||
require_once DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php";
|
||||
require_once DOL_DOCUMENT_ROOT."/core/modules/facture/modules_facture.php";
|
||||
require_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php";
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice2.lib.php';
|
||||
|
||||
/**
|
||||
* @var Conf $conf
|
||||
* @var DoliDB $db
|
||||
|
|
@ -84,14 +83,14 @@ if (!empty($dolibarr_main_db_readonly)) {
|
|||
}
|
||||
|
||||
|
||||
$diroutputpdf = $conf->invoice->dir_output.'/temp';
|
||||
|
||||
$newlangid = 'en_EN'; // To force a new lang id
|
||||
$filter = array();
|
||||
$regenerate = ''; // Ask regenerate (contains name of model to use)
|
||||
$option = '';
|
||||
$fileprefix = 'mergedpdf';
|
||||
$nomerge = 0;
|
||||
$mode = 'invoice';
|
||||
|
||||
$dateafterdate = '';
|
||||
$datebeforedate = '';
|
||||
$paymentdateafter = '';
|
||||
|
|
@ -116,6 +115,13 @@ foreach ($argv as $key => $value) {
|
|||
print 'Use prefix for filename '.$fileprefix.".\n";
|
||||
}
|
||||
|
||||
if (preg_match('/^mode=/i', $value)) {
|
||||
$found = true;
|
||||
$valarray = explode('=', $value);
|
||||
$mode = $valarray[1];
|
||||
print 'Use mode '.$fileprefix.".\n";
|
||||
}
|
||||
|
||||
$reg = array();
|
||||
if (preg_match('/^regenerate=(.*)/i', $value, $reg)) {
|
||||
if (!in_array($reg[1], array('', '0', 'no'))) {
|
||||
|
|
@ -254,10 +260,11 @@ if (in_array('bank', $filter) && in_array('nopayment', $filter)) {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
$diroutputpdf = 'auto';
|
||||
|
||||
// Define SQL and SQL request to select invoices
|
||||
// Use $filter, $dateafterdate, datebeforedate, $paymentdateafter, $paymentdatebefore
|
||||
|
||||
$result = rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filter, $dateafterdate, $datebeforedate, $paymentdateafter, $paymentdatebefore, 1, $regenerate, $option, (string) $paymentonbankid, $thirdpartiesid, $fileprefix, $nomerge);
|
||||
$result = rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filter, $dateafterdate, $datebeforedate, $paymentdateafter, $paymentdatebefore, 1, $regenerate, $option, (string) $paymentonbankid, $thirdpartiesid, $fileprefix, $nomerge, $mode);
|
||||
|
||||
// -------------------- END OF YOUR CODE --------------------
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user