diff --git a/html/js/scripts.js b/html/js/scripts.js
index a212591b9..6595ca986 100644
--- a/html/js/scripts.js
+++ b/html/js/scripts.js
@@ -3405,10 +3405,19 @@ var progressIdx = 0;
* @param {string} p_taskid id to monitor
* @param {int} p_dossier
*/
-function progress_bar_start(p_taskid)
+function progress_bar_start(p_taskid,p_message)
{
try {
progressIdx++;
+ // block the window
+ var message="Un instant svp";
+ if ( p_message) {
+ message=p_message;
+ }
+ add_div({id:"blocking"+progressIdx,cssclass:"smoke-base smoke-visible "});
+
+ add_div({id:"message"+progressIdx,cssclass:"inner_box",style:"z-index:1000;position:fixed;top:30%;width:40%;left:30%"});
+ $("message"+progressIdx).update(message);
// Create a div
add_div({id: "progressDiv" + progressIdx, cssclass: "progressbar", html: '0'});
// Check status every sec.
@@ -3433,8 +3442,14 @@ function progress_bar_check(p_idx, p_taskid)
try
{
var answer=req.responseText.evalJSON();
-
- var progressValue = $('progressValue');
+ var progress_div=$("progressDiv"+progressIdx);
+ var a_child=progress_div.childNodes;
+ var i=0;
+ for ( i=0;i< a_child.length;i++) {
+ if ( a_child[i].id="progressValue") {
+ var progressValue = a_child[i];
+ }
+ }
var progress = parseFloat(progressValue.innerHTML);
if ( answer.value <= progress ) {
return;
@@ -3445,7 +3460,10 @@ function progress_bar_check(p_idx, p_taskid)
if (answer.value== 100) {
clearInterval(progressBar[p_idx]);
progressValue.innerHTML="Success";
- Effect.BlindUp("progressDiv"+progressIdx,{duration:1.0,scaleContent:false})
+ Effect.BlindUp("progressDiv"+p_idx,{duration:1.0,scaleContent:false})
+ $("message"+p_idx).remove();
+ $("blocking"+p_idx).remove();
+ setTimeout(function() { $("progressDiv"+progressIdx).remove } , 1100);
}
} catch (e) {
clearInterval(progressBar[p_idx]);
diff --git a/include/lib/progress_bar.class.php b/include/lib/progress_bar.class.php
index 04e6f2416..50b1d08d1 100644
--- a/include/lib/progress_bar.class.php
+++ b/include/lib/progress_bar.class.php
@@ -108,8 +108,20 @@ class Progress_Bar
header('Content-Type: application/json');
echo json_encode(["value"=>$this->value]);
if ($this->value>=100) {
- $this->db->exec_sql("delete from progress where p_id=$1",[$this->task_id])
+ $this->db->exec_sql("delete from progress where p_id=$1",[$this->task_id]);
}
return;
}
+ /**
+ * increment value with $p_step
+ * @param int $p_step
+ */
+ function increment($p_step)
+ {
+ if ($this->value+$p_step > 100 ) {
+ $this->set_value(100);
+ return;
+ }
+ $this->set_value($this->value+$p_step);
+ }
}