[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 117/323: Export PDF from ANC , add a progress
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 117/323: Export PDF from ANC , add a progress_bar |
Date: |
Wed, 14 Mar 2018 17:38:35 -0400 (EDT) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 83404ed02e083aed50a7d4ffdbe0c4602ece5920
Author: Dany De Bontridder <address@hidden>
Date: Sat Feb 3 15:28:52 2018 +0100
Export PDF from ANC , add a progress_bar
---
include/anc_great_ledger.inc.php | 9 ++++++---
include/class/document_export.class.php | 18 +++++++++++++-----
include/export/export_anc_receipt_pdf.php | 9 ++++++---
3 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/include/anc_great_ledger.inc.php b/include/anc_great_ledger.inc.php
index 0ecb747..3cf291b 100644
--- a/include/anc_great_ledger.inc.php
+++ b/include/anc_great_ledger.inc.php
@@ -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();
diff --git a/include/class/document_export.class.php
b/include/class/document_export.class.php
index e0a96f3..ac632dd 100644
--- a/include/class/document_export.class.php
+++ b/include/class/document_export.class.php
@@ -19,6 +19,7 @@
// Copyright Author Dany De Bontridder address@hidden
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();
diff --git a/include/export/export_anc_receipt_pdf.php
b/include/export/export_anc_receipt_pdf.php
index 890f950..d6d6b47 100644
--- a/include/export/export_anc_receipt_pdf.php
+++ b/include/export/export_anc_receipt_pdf.php
@@ -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);
- [Noalyss-commit] [noalyss] 108/323: Remove grant / revoke command, (continued)
- [Noalyss-commit] [noalyss] 108/323: Remove grant / revoke command, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 107/323: Add licence + template name, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 106/323: fix: cannot create new folder due to a typo error, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 91/323: FollowUp : improve esthetic, use inplace_edit for commenting on files, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 112/323: Change theme : corner for menu2 , no more border-radius for menu1, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 110/323: Correction couleur pour Inswitch_place Correction couleur pour Module sécurité, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 116/323: Improve progress_bar : add a blocking div, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 115/323: translate, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 119/323: Missing lib, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 118/323: Progress Bar : use GET , which is faster than POST, use 2 decimal in progress because if the step is < 1 , it doesn't work, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 117/323: Export PDF from ANC , add a progress_bar,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 16/323: Bug 1516 : réécriture du module période, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 111/323: History of analytic account the same way as the history for card or accounting, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 120/323: New LOGO, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 122/323: cosmetic menu level2, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 124/323: Fix : logo and new style by default, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 125/323: fix : managetable correct position, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 114/323: New : code for progress bar, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 129/323: Small bug : new structure for table version, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 126/323: fix : typo default theme Classic7, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 121/323: use icon_action::icon_magnify instead of icon, Dany De Bontridder, 2018/03/14