Fix of build mass pdf files
This commit is contained in:
parent
bcef81a453
commit
21343804b8
@ -32,6 +32,7 @@ require_once(DOL_DOCUMENT_ROOT."/paiement.class.php");
|
|||||||
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
|
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/includes/fpdf/fpdfi/fpdi.php");
|
require_once(DOL_DOCUMENT_ROOT."/includes/fpdf/fpdfi/fpdi.php");
|
||||||
|
|
||||||
|
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
|
|
||||||
$facid = isset($_GET["facid"])?$_GET["facid"]:'';
|
$facid = isset($_GET["facid"])?$_GET["facid"]:'';
|
||||||
@ -52,7 +53,7 @@ if ($_POST["action"] == "builddoc" && $user->rights->facture->lire)
|
|||||||
{
|
{
|
||||||
if (is_array($_POST['toGenerate']))
|
if (is_array($_POST['toGenerate']))
|
||||||
{
|
{
|
||||||
|
|
||||||
$factures = dol_dir_list($conf->facture->dir_output,'all',1,implode('\.pdf|',$_POST['toGenerate']).'\.pdf','\.meta$|\.png','date',SORT_DESC) ;
|
$factures = dol_dir_list($conf->facture->dir_output,'all',1,implode('\.pdf|',$_POST['toGenerate']).'\.pdf','\.meta$|\.png','date',SORT_DESC) ;
|
||||||
|
|
||||||
// liste les fichiers
|
// liste les fichiers
|
||||||
@ -65,47 +66,50 @@ if ($_POST["action"] == "builddoc" && $user->rights->facture->lire)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create empty PDF
|
// Create empty PDF
|
||||||
$pdf=new FPDI('P','mm','A4');
|
$pdf=new FPDI('P','mm','A4');
|
||||||
|
if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
|
||||||
|
//$pdf->SetCompression(false);
|
||||||
|
|
||||||
//$pdf->Open();
|
//$pdf->Open();
|
||||||
//$pdf->AddPage();
|
//$pdf->AddPage();
|
||||||
//$title=$langs->trans("BillsCustomersUnpayed");
|
//$title=$langs->trans("BillsCustomersUnpayed");
|
||||||
//if ($option=='late') $title=$langs->trans("BillsCustomersUnpayed");
|
//if ($option=='late') $title=$langs->trans("BillsCustomersUnpayed");
|
||||||
//$pdf->MultiCell(100, 3, $title, 0, 'J');
|
//$pdf->MultiCell(100, 3, $title, 0, 'J');
|
||||||
|
|
||||||
// Add all others
|
// Add all others
|
||||||
foreach($files as $file)
|
foreach($files as $file)
|
||||||
{
|
{
|
||||||
// Charge un document PDF depuis un fichier.
|
// Charge un document PDF depuis un fichier.
|
||||||
$pagecount = $pdf->setSourceFile($file);
|
$pagecount = $pdf->setSourceFile($file);
|
||||||
for ($i = 1; $i <= $pagecount; $i++)
|
for ($i = 1; $i <= $pagecount; $i++)
|
||||||
{
|
{
|
||||||
$tplidx = $pdf->ImportPage($i);
|
$tplidx = $pdf->importPage($i);
|
||||||
$s = $pdf->getTemplatesize($tplidx);
|
$s = $pdf->getTemplatesize($tplidx);
|
||||||
$pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L');
|
$pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L');
|
||||||
$pdf->useTemplate($tplidx);
|
$pdf->useTemplate($tplidx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create output dir if not exists
|
// Create output dir if not exists
|
||||||
create_exdir($diroutputpdf);
|
create_exdir($diroutputpdf);
|
||||||
|
|
||||||
// enregistre le fichier pdf concatene
|
// enregistre le fichier pdf concatene
|
||||||
$filename=strtolower(sanitizeFileName($langs->transnoentities("Unpayed")));
|
$filename=strtolower(sanitizeFileName($langs->transnoentities("Unpayed")));
|
||||||
if ($option=='late') $filename.='_'.strtolower(sanitizeFileName($langs->transnoentities("Late")));
|
if ($option=='late') $filename.='_'.strtolower(sanitizeFileName($langs->transnoentities("Late")));
|
||||||
if ($pagecount)
|
if ($pagecount)
|
||||||
{
|
{
|
||||||
$file=$diroutputpdf.'/'.$filename.'_'.dolibarr_print_date(mktime(),'dayhourlog').'.pdf';
|
$file=$diroutputpdf.'/'.$filename.'_'.dolibarr_print_date(mktime(),'dayhourlog').'.pdf';
|
||||||
$pdf->Output($file);
|
$pdf->Output($file);
|
||||||
if (! empty($conf->global->MAIN_UMASK))
|
if (! empty($conf->global->MAIN_UMASK))
|
||||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$mesg='<div class="error">'.$langs->trans('NoPDFAvailableForChecked').'</div>';
|
$mesg='<div class="error">'.$langs->trans('NoPDFAvailableForChecked').'</div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$mesg='<div class="error">'.$langs->trans('UnpayedNotChecked').'</div>' ;
|
$mesg='<div class="error">'.$langs->trans('UnpayedNotChecked').'</div>' ;
|
||||||
@ -128,7 +132,7 @@ llxHeader('',$title);
|
|||||||
$html = new Form($db);
|
$html = new Form($db);
|
||||||
$formfile = new FormFile($db);
|
$formfile = new FormFile($db);
|
||||||
?><script type="text/javascript">
|
?><script type="text/javascript">
|
||||||
<!--
|
<!--
|
||||||
function checkall(checked){
|
function checkall(checked){
|
||||||
var checkboxes = [];
|
var checkboxes = [];
|
||||||
checkboxes = $$('input').each(function(e){ if(e.type == 'checkbox') checkboxes.push(e) });
|
checkboxes = $$('input').each(function(e){ if(e.type == 'checkbox') checkboxes.push(e) });
|
||||||
@ -239,14 +243,14 @@ if ($result)
|
|||||||
if ($_REQUEST["search_montant_ht"]) $param.='&search_montant_ht='.urlencode($_REQUEST["search_montant_ht"]);
|
if ($_REQUEST["search_montant_ht"]) $param.='&search_montant_ht='.urlencode($_REQUEST["search_montant_ht"]);
|
||||||
if ($_REQUEST["search_montant_ttc"]) $param.='&search_montant_ttc='.urlencode($_REQUEST["search_montant_ttc"]);
|
if ($_REQUEST["search_montant_ttc"]) $param.='&search_montant_ttc='.urlencode($_REQUEST["search_montant_ttc"]);
|
||||||
if ($_REQUEST["late"]) $param.='&late='.urlencode($_REQUEST["search_late"]);
|
if ($_REQUEST["late"]) $param.='&late='.urlencode($_REQUEST["search_late"]);
|
||||||
|
|
||||||
$urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
|
$urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
|
||||||
$urlsource.=eregi_replace('&','&',$param);
|
$urlsource.=eregi_replace('&','&',$param);
|
||||||
|
|
||||||
$titre=($socid?$langs->trans("BillsCustomersUnpayedForCompany",$soc->nom):$langs->trans("BillsCustomersUnpayed"));
|
$titre=($socid?$langs->trans("BillsCustomersUnpayedForCompany",$soc->nom):$langs->trans("BillsCustomersUnpayed"));
|
||||||
if ($option == 'late') $titre.=' ('.$langs->trans("Late").')';
|
if ($option == 'late') $titre.=' ('.$langs->trans("Late").')';
|
||||||
else $titre.=' ('.$langs->trans("All").')';
|
else $titre.=' ('.$langs->trans("All").')';
|
||||||
|
|
||||||
$link='';
|
$link='';
|
||||||
if (empty($option)) $link='<a href="'.$_SERVER["PHP_SELF"].'?option=late">'.$langs->trans("ShowUnpayedLateOnly").'</a>';
|
if (empty($option)) $link='<a href="'.$_SERVER["PHP_SELF"].'?option=late">'.$langs->trans("ShowUnpayedLateOnly").'</a>';
|
||||||
elseif ($option == 'late') $link='<a href="'.$_SERVER["PHP_SELF"].'">'.$langs->trans("ShowUnpayedAll").'</a>';
|
elseif ($option == 'late') $link='<a href="'.$_SERVER["PHP_SELF"].'">'.$langs->trans("ShowUnpayedAll").'</a>';
|
||||||
@ -254,7 +258,7 @@ if ($result)
|
|||||||
//print_barre_liste($titre,$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',0); // We don't want pagination on this page
|
//print_barre_liste($titre,$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',0); // We don't want pagination on this page
|
||||||
|
|
||||||
if ($mesg) print $mesg;
|
if ($mesg) print $mesg;
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
print '<table class="liste" width="100%">';
|
print '<table class="liste" width="100%">';
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
@ -302,7 +306,7 @@ if ($result)
|
|||||||
$total_payed=0;
|
$total_payed=0;
|
||||||
|
|
||||||
print '<form id="form_generate_pdf" method="post" action="'.$_SERVER["PHP_SELF"].'?sortfield='. $_GET['sortfield'] .'&sortorder='. $_GET['sortorder'] .'">';
|
print '<form id="form_generate_pdf" method="post" action="'.$_SERVER["PHP_SELF"].'?sortfield='. $_GET['sortfield'] .'&sortorder='. $_GET['sortorder'] .'">';
|
||||||
|
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$objp = $db->fetch_object($result);
|
$objp = $db->fetch_object($result);
|
||||||
@ -313,33 +317,33 @@ if ($result)
|
|||||||
$class = "impayee";
|
$class = "impayee";
|
||||||
|
|
||||||
print '<td nowrap="nowrap">';
|
print '<td nowrap="nowrap">';
|
||||||
|
|
||||||
$facturestatic->id=$objp->facid;
|
$facturestatic->id=$objp->facid;
|
||||||
$facturestatic->ref=$objp->facnumber;
|
$facturestatic->ref=$objp->facnumber;
|
||||||
$facturestatic->type=$objp->type;
|
$facturestatic->type=$objp->type;
|
||||||
|
|
||||||
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
|
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
|
||||||
print '<td width="90" class="nobordernopadding" nowrap="nowrap">';
|
print '<td width="90" class="nobordernopadding" nowrap="nowrap">';
|
||||||
print $facturestatic->getNomUrl(1);
|
print $facturestatic->getNomUrl(1);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
print '<td width="20" class="nobordernopadding" nowrap="nowrap">';
|
print '<td width="20" class="nobordernopadding" nowrap="nowrap">';
|
||||||
if ($objp->datelimite < ($now - $conf->facture->client->warning_delay) && ! $objp->paye && $objp->fk_statut == 1) print img_warning($langs->trans("Late"));
|
if ($objp->datelimite < ($now - $conf->facture->client->warning_delay) && ! $objp->paye && $objp->fk_statut == 1) print img_warning($langs->trans("Late"));
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
print '<td width="16" align="right" class="nobordernopadding">';
|
print '<td width="16" align="right" class="nobordernopadding">';
|
||||||
|
|
||||||
$filename=sanitizeFileName($objp->facnumber);
|
$filename=sanitizeFileName($objp->facnumber);
|
||||||
$filedir=$conf->facture->dir_output . '/' . sanitizeFileName($objp->facnumber);
|
$filedir=$conf->facture->dir_output . '/' . sanitizeFileName($objp->facnumber);
|
||||||
$foundpdf=$formfile->show_documents('facture',$filename,$filedir,$urlsource,'','','','','',1,$param);
|
$foundpdf=$formfile->show_documents('facture',$filename,$filedir,$urlsource,'','','','','',1,$param);
|
||||||
print '</td></tr></table>';
|
print '</td></tr></table>';
|
||||||
|
|
||||||
// Checkbox
|
// Checkbox
|
||||||
print '<td align="center">';
|
print '<td align="center">';
|
||||||
if ($foundpdf) print '<input id="cb'.$objp->facid.'" type="checkbox" name="toGenerate[]" value="'.$objp->facnumber.'">';
|
if ($foundpdf) print '<input id="cb'.$objp->facid.'" type="checkbox" name="toGenerate[]" value="'.$objp->facnumber.'">';
|
||||||
else print ' ';
|
else print ' ';
|
||||||
print '</td>' ;
|
print '</td>' ;
|
||||||
|
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
|
|
||||||
print "<td nowrap align=\"center\">".dolibarr_print_date($objp->df)."</td>\n";
|
print "<td nowrap align=\"center\">".dolibarr_print_date($objp->df)."</td>\n";
|
||||||
@ -374,8 +378,8 @@ if ($result)
|
|||||||
}
|
}
|
||||||
|
|
||||||
print "</table>";
|
print "</table>";
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Show list of available documents
|
* Show list of available documents
|
||||||
*/
|
*/
|
||||||
@ -391,8 +395,8 @@ if ($result)
|
|||||||
print '<br>';
|
print '<br>';
|
||||||
print '<input type="hidden" name="option" value="'.$option.'">';
|
print '<input type="hidden" name="option" value="'.$option.'">';
|
||||||
$formfile->show_documents('unpayed','',$filedir,$urlsource,$genallowed,$delallowed,'','',0,0,48,1,$param);
|
$formfile->show_documents('unpayed','',$filedir,$urlsource,$genallowed,$delallowed,'','',0,0,48,1,$param);
|
||||||
print '</form>';
|
print '</form>';
|
||||||
|
|
||||||
$db->free();
|
$db->free();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user