New: Add option "filter=bank" onto script rebuild_merge_pdf.php to
merge PDF that has one payment on a specific bank account.
This commit is contained in:
parent
a771d3f93e
commit
49735b8d39
@ -8,7 +8,8 @@ For users:
|
||||
- New: [ task #858 ] Holiday module: note on manual holiday assignation.
|
||||
- New: Add graph of bank account input/output into input-output report page.
|
||||
- New: Add script export-bank-receipts.
|
||||
|
||||
- New: Add option "filter=bank" onto script rebuild_merge_pdf.php to merge
|
||||
PDF that has one payment on a specific bank account.
|
||||
For developers:
|
||||
- New: DolGraph can build graph with three lines.
|
||||
|
||||
|
||||
@ -42,9 +42,10 @@ require_once(DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php');
|
||||
* @param int $usestdout Add information onto standard output
|
||||
* @param int $regenerate ''=Use existing PDF files, 'nameofpdf'=Regenerate all PDF files using the template
|
||||
* @param string $option Suffix to add into file name of generated PDF
|
||||
* @param string $paymentbankid Only if payment on this bank account id
|
||||
* @return int Error code
|
||||
*/
|
||||
function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filter, $dateafterdate, $datebeforedate, $paymentdateafter, $paymentdatebefore, $usestdout, $regenerate=0, $option='')
|
||||
function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filter, $dateafterdate, $datebeforedate, $paymentdateafter, $paymentdatebefore, $usestdout, $regenerate=0, $option='', $paymentbankid='')
|
||||
{
|
||||
$sql = "SELECT DISTINCT f.rowid, f.facnumber";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
|
||||
@ -71,17 +72,25 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte
|
||||
$sqlwhere.= " f.fk_statut > 0";
|
||||
$sqlwhere.= " AND pf.fk_paiement IS NULL";
|
||||
}
|
||||
if (in_array('payments',$filter))
|
||||
if (in_array('payments',$filter) || in_array('bank',$filter))
|
||||
{
|
||||
$sql.= ", ".MAIN_DB_PREFIX."paiement_facture as pf,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."paiement as p";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p";
|
||||
if (in_array('bank',$filter)) $sql.= ", ".MAIN_DB_PREFIX."bank as b";
|
||||
if (empty($sqlwhere)) $sqlwhere=' WHERE ';
|
||||
else $sqlwhere.=" AND";
|
||||
$sqlwhere.= " f.fk_statut > 0";
|
||||
$sqlwhere.= " AND f.rowid = pf.fk_facture";
|
||||
$sqlwhere.= " AND pf.fk_paiement = p.rowid";
|
||||
$sqlwhere.= " AND p.datep >= '".$db->idate($paymentdateafter)."'";
|
||||
$sqlwhere.= " AND p.datep <= '".$db->idate($paymentdatebefore)."'";
|
||||
if (in_array('payments',$filter))
|
||||
{
|
||||
$sqlwhere.= " AND p.datep >= '".$db->idate($paymentdateafter)."'";
|
||||
$sqlwhere.= " AND p.datep <= '".$db->idate($paymentdatebefore)."'";
|
||||
}
|
||||
if (in_array('bank',$filter))
|
||||
{
|
||||
$sqlwhere.= " AND p.fk_bank = b.rowid";
|
||||
$sqlwhere.= " AND b.fk_account = ".$paymentbankid;
|
||||
}
|
||||
$sqlorder = " ORDER BY p.datep ASC";
|
||||
}
|
||||
if (in_array('nodeposit',$filter))
|
||||
|
||||
@ -134,7 +134,25 @@ foreach ($argv as $key => $value)
|
||||
print 'Rebuild PDF for invoices with no payment done yet.'."\n";
|
||||
}
|
||||
|
||||
if ($value == 'filter=nodeposit')
|
||||
if ($value == 'filter=bank')
|
||||
{
|
||||
$found=true;
|
||||
$option.=(empty($option)?'':'_').'bank_'.$argv[$key+1].'_'.$argv[$key+2];
|
||||
$filter[]='bank';
|
||||
|
||||
$paymentonbankref=$argv[$key+1];
|
||||
$bankaccount=new Account($db);
|
||||
$result=$bankaccount->fetch(0,$paymentonbankref);
|
||||
if ($result <= 0)
|
||||
{
|
||||
print 'Error: Bank account with ref "'.$paymentonbankref.'" not found'."\n";
|
||||
exit;
|
||||
}
|
||||
$paymentonbankid=$bankaccount->id;
|
||||
print 'Rebuild PDF for invoices with at least one payment on financial account '.$bankaccount->ref."\n";
|
||||
}
|
||||
|
||||
if ($value == 'filter=nodeposit')
|
||||
{
|
||||
$found=true;
|
||||
$option.=(empty($option)?'':'_').'nodeposit';
|
||||
@ -173,16 +191,21 @@ if (empty($option) && count($filter) <= 0)
|
||||
exit;
|
||||
}
|
||||
// Check if there is no uncompatible choice
|
||||
if (in_array('payments',$filter) && in_array('nopayment',$filter))
|
||||
{
|
||||
usage();
|
||||
exit;
|
||||
}
|
||||
if (in_array('payments',$filter) && in_array('nopayment',$filter))
|
||||
{
|
||||
usage();
|
||||
exit;
|
||||
}
|
||||
if (in_array('bank',$filter) && in_array('nopayment',$filter))
|
||||
{
|
||||
usage();
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
// 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);
|
||||
$result=rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filter, $dateafterdate, $datebeforedate, $paymentdateafter, $paymentdatebefore, 1, $regenerate, $option, $paymentonbankid);
|
||||
|
||||
|
||||
|
||||
@ -217,9 +240,11 @@ function usage()
|
||||
print "Rebuild PDF files for some invoices and merge PDF files into one.\n";
|
||||
print "\n";
|
||||
print "To build/merge PDF for invoices in a date range:\n";
|
||||
print "Usage: ".$script_file." filter=date dateafter datebefore [lang=langcode]\n";
|
||||
print "Usage: ".$script_file." filter=date dateafter datebefore\n";
|
||||
print "To build/merge PDF for invoices with at least one payment in a date range:\n";
|
||||
print "Usage: ".$script_file." filter=payments dateafter datebefore [lang=langcode]\n";
|
||||
print "Usage: ".$script_file." filter=payments dateafter datebefore\n";
|
||||
print "To build/merge PDF for invoices with at least one payment onto a bank account:\n";
|
||||
print "Usage: ".$script_file." filter=bank bankref\n";
|
||||
print "To build/merge PDF for all invoices, use filter=all\n";
|
||||
print "Usage: ".$script_file." filter=all\n";
|
||||
print "To build/merge PDF for invoices with no payments, use filter=nopayment\n";
|
||||
@ -228,9 +253,10 @@ function usage()
|
||||
print "To exclude replacement invoices, use filter=noreplacement\n";
|
||||
print "To exclude deposit invoices, use filter=nodeposit\n";
|
||||
print "To regenerate existing PDF, use regenerate=crabe\n";
|
||||
print "To generate invoices in a language, use lang=xx_XX\n";
|
||||
print "\n";
|
||||
print "Example: ".$script_file." filter=payments 20080101 20081231 lang=fr_FR regenerate=crabe\n";
|
||||
print "Example: ".$script_file." filter=all lang=it_IT\n";
|
||||
print "Example: ".$script_file." filter=all lang=en_US\n";
|
||||
print "\n";
|
||||
print "Note that some filters can be cumulated.\n";
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user