Export PDF from ANC , add a progress_bar
This commit is contained in:
parent
78fd828aa4
commit
83404ed02e
3 changed files with 25 additions and 11 deletions
|
|
@ -34,10 +34,13 @@ if ($result != null)
|
|||
echo '<span style="display:block">';
|
||||
echo _('Tout sélectionner')." ".ICheckBox::toggle_checkbox('export_pdf_bt1','export_anc_receipt_pdf');
|
||||
echo '</span>';
|
||||
$task_id=uniqid();
|
||||
echo $grandLivre->show_button();
|
||||
printf ('<form method="GET" id="export_anc_receipt_pdf" action="export.php" style="display:inline" onsubmit="smoke.signal(\'%s\', function(e){}, {duration: 3000,classname: \'custom-class\'});return true;">',
|
||||
_("Le traitement est en cours , merci de patienter sans recharger la page"));
|
||||
|
||||
printf ('<form method="GET" id="export_anc_receipt_pdf" action="export.php" style="display:inline" onsubmit="progress_bar_start(\'%s\',\'%s\');return true;">',
|
||||
$task_id,
|
||||
_("Le traitement est en cours , merci de patienter sans recharger la page")
|
||||
);
|
||||
echo HtmlInput::hidden("task_id",$task_id);
|
||||
echo $grandLivre->button_export_pdf();
|
||||
echo $grandLivre->display_html();
|
||||
echo $grandLivre->button_export_pdf();
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
// Copyright Author Dany De Bontridder danydb@aevalys.eu
|
||||
require_once NOALYSS_INCLUDE.'/class/pdf_operation.class.php';
|
||||
require_once NOALYSS_INCLUDE.'/lib/progress_bar.class.php';
|
||||
/**
|
||||
* @brief Export DOCUMENT from Analytic accountancy, can transform into PDF
|
||||
* and add a stamp on each pages
|
||||
|
|
@ -118,16 +119,20 @@ class Document_Export
|
|||
* a stamp. If an error occurs then $this->feedback won't be empty
|
||||
* @param $p_array contents all the jr_id
|
||||
*/
|
||||
function export_all($p_array)
|
||||
function export_all($p_array, Progress_Bar $progress)
|
||||
{
|
||||
$this->check_file();
|
||||
if ( count($p_array)==0) return;
|
||||
ob_start();
|
||||
$cnt_feedback=0;
|
||||
global $cn;
|
||||
|
||||
// follow progress
|
||||
$step=round(20/count($p_array));
|
||||
|
||||
$cn->start();
|
||||
foreach ($p_array as $value)
|
||||
{
|
||||
$progress->increment($step);
|
||||
// For each file save it into the temp folder,
|
||||
$file = $cn->get_array('select jr_pj,jr_pj_name,jr_pj_number,jr_pj_type from jrn '
|
||||
. ' where jr_id=$1', array($value));
|
||||
|
|
@ -173,7 +178,7 @@ class Document_Export
|
|||
continue;
|
||||
}
|
||||
|
||||
|
||||
$progress->increment($step);
|
||||
//
|
||||
// remove extension
|
||||
$ext = strrpos($filename, ".");
|
||||
|
|
@ -210,6 +215,7 @@ class Document_Export
|
|||
}
|
||||
rename ($this->store_convert . '/' . $file_pdf.'.2',$this->store_convert . '/' . $file_pdf);
|
||||
}
|
||||
$progress->increment($step);
|
||||
// output
|
||||
$output = $this->store_convert . '/stamp_' . $file_pdf;
|
||||
|
||||
|
|
@ -238,7 +244,7 @@ class Document_Export
|
|||
// concatenate detail operation with the output
|
||||
$stmt = PDFTK . " " . $detail_operation->get_pdf_filename()." ".$output.
|
||||
' output ' . $output2;
|
||||
|
||||
$progress->increment($step);
|
||||
passthru($stmt, $status);
|
||||
if ($status <> 0)
|
||||
{
|
||||
|
|
@ -258,10 +264,12 @@ class Document_Export
|
|||
// Move the PDF into another temp directory
|
||||
$this->move_file($output, 'stamp_' . $file_pdf);
|
||||
}
|
||||
|
||||
$progress->set_value(93);
|
||||
// concatenate all pdf into one
|
||||
$this->concatenate_pdf();
|
||||
|
||||
$progress->set_value(100);
|
||||
|
||||
ob_clean();
|
||||
$this->send_pdf();
|
||||
|
||||
|
|
|
|||
|
|
@ -23,12 +23,14 @@
|
|||
if (!defined('ALLOWED'))
|
||||
die('Appel direct ne sont pas permis');
|
||||
|
||||
|
||||
// unlock session
|
||||
session_write_close();
|
||||
/**
|
||||
* export all the selected documents for Ana Accountancy in PDF
|
||||
*/
|
||||
require_once NOALYSS_INCLUDE.'/class/document_export.class.php';
|
||||
require_once NOALYSS_INCLUDE.'/lib/http_input.class.php';
|
||||
require_once NOALYSS_INCLUDE.'/lib/progress_bar.class.php';
|
||||
$http=new HttpInput();
|
||||
$ck = $http->get('ck',"string", 0);
|
||||
if ($ck == 0)
|
||||
|
|
@ -37,5 +39,6 @@ if ($ck == 0)
|
|||
exit();
|
||||
}
|
||||
$anc=new Document_Export();
|
||||
|
||||
$anc->export_all($ck);
|
||||
$task_id=$http->request("task_id");
|
||||
$progress=new Progress_Bar($task_id);
|
||||
$anc->export_all($ck,$progress);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue