[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 15/46: Task #0001417: Reconnexion souple conn
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 15/46: Task #0001417: Reconnexion souple connect |
Date: |
Tue, 13 Jul 2021 05:01:53 -0400 (EDT) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit c123c78eb83dc069f5a733d00f3ade4bba441b10
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Fri Jun 11 17:12:39 2021 +0200
Task #0001417: Reconnexion souple
connect
Signed-off-by: sparkyx <danydb@noalyss.eu>
---
html/ajax_misc.php | 16 +++++++++++-
html/fid.php | 8 ++++++
html/fid_card.php | 7 +++++
html/js/acc_ledger.js | 1 +
html/js/ajax_fiche.js | 18 +++++++------
html/js/card.js | 11 ++++++--
html/js/gestion.js | 1 +
html/js/managetable.js | 1 +
html/js/noalyss_script.js | 25 +++++++++++++++++-
html/js/todo_list.js | 1 +
include/ajax/ajax_card.php | 5 +---
include/ajax/ajax_todo_list.php | 2 +-
include/lib/ac_common.php | 57 +++++++++++++----------------------------
13 files changed, 97 insertions(+), 56 deletions(-)
diff --git a/html/ajax_misc.php b/html/ajax_misc.php
index ca89223..3e5d09b 100644
--- a/html/ajax_misc.php
+++ b/html/ajax_misc.php
@@ -49,6 +49,20 @@ require_once NOALYSS_INCLUDE.'/lib/icon_action.class.php';
require_once NOALYSS_INCLUDE.'/lib/progress_bar.class.php';
$http=new HttpInput();
+/* we ask a dg box for disconnecting */
+if ($http->request('op',"string","") == 'disconnect') {
+ ajax_disconnected("reconnect_bx");
+ return ;
+}
+
+/**
+ * if not connected, session is expired then exit with a message NOCONX
+ */
+if ( ! isset($_SESSION[SESSION_KEY."g_user"])) {
+ echo "NOCONX";
+ die();
+}
+
mb_internal_encoding("UTF-8");
$var = array( 'op');
@@ -71,7 +85,7 @@ if ( ! isset($_REQUEST['gDossier'])) {
if ($cont != 0) exit();
extract($_REQUEST, EXTR_SKIP );
-if ( isset($div)) ajax_disconnected($div);
+
global $g_user, $cn, $g_parameter;
//
// If database id == 0 then we are not connected to a folder
diff --git a/html/fid.php b/html/fid.php
index 471a08d..6dc6ae9 100644
--- a/html/fid.php
+++ b/html/fid.php
@@ -38,6 +38,14 @@ require_once NOALYSS_INCLUDE.'/class/database.class.php';
require_once NOALYSS_INCLUDE.'/lib/user_common.php';
require_once NOALYSS_INCLUDE.'/lib/http_input.class.php';
require_once NOALYSS_INCLUDE.'/class/dossier.class.php';
+/**
+ * if not connected, session is expired then exit with a message NOCONX
+ */
+if ( ! isset($_SESSION[SESSION_KEY."g_user"])) {
+ echo "NOCONX";
+ die();
+}
+
$gDossier=dossier::id();
require_once('class/user.class.php');
diff --git a/html/fid_card.php b/html/fid_card.php
index 0e16ef7..57f7835 100644
--- a/html/fid_card.php
+++ b/html/fid_card.php
@@ -40,6 +40,13 @@ require_once '../include/constant.php';
require_once NOALYSS_INCLUDE.'/class/database.class.php';
require_once NOALYSS_INCLUDE.'/lib/http_input.class.php';
require_once NOALYSS_INCLUDE.'/class/dossier.class.php';
+/**
+ * if not connected, session is expired then exit with a message NOCONX
+ */
+if ( ! isset($_SESSION[SESSION_KEY."g_user"])) {
+ echo "NOCONX";
+ die();
+}
$http=new HttpInput();
diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js
index 0c68c4e..42d5f9c 100644
--- a/html/js/acc_ledger.js
+++ b/html/js/acc_ledger.js
@@ -932,6 +932,7 @@ function modifyOperation(p_value, dossier)
parameters: querystring,
onFailure: error_box,
onSuccess: function (xml, txt) {
+ if ( xml.responseText === 'NOCONX') { reconnect();return;}
var popup = {'id': id_div, 'cssclass': 'inner_box'
, 'html': "", 'drag': false};
remove_waiting_box();
diff --git a/html/js/ajax_fiche.js b/html/js/ajax_fiche.js
index e20f849..b9b7f7c 100644
--- a/html/js/ajax_fiche.js
+++ b/html/js/ajax_fiche.js
@@ -151,6 +151,8 @@ function ajaxFid(p_ctl)
*/
function successFid(request,json)
{
+ if (request.responseText === 'NOCONX') { reconnect();return;}
+
var answer=request.responseText.evalJSON(true);
var flabel=answer.flabel;
if ( answer.answer=='nok' )
@@ -226,14 +228,14 @@ function ajax_success_saldo(request,json)
* \param ctl : id of the div to show
* \param page
*/
-function _saajax_card(p_dossier,f_id,p_operation,ctl,page)
-{
- $(ctl).show();
- var
queryString="gDossier="+p_dossier+"&f_id="+f_id+"&op="+p_operation+"&p="+page+'&ctl='+ctl;
- var action = new Ajax.Request(
- "ajax_card.php" , { method:'get',
parameters:queryString,onFailure:ajax_get_failure,onSuccess:ajax_get_success}
- );
-}
+//function _saajax_card(p_dossier,f_id,p_operation,ctl,page)
+//{
+// $(ctl).show();
+// var
queryString="gDossier="+p_dossier+"&f_id="+f_id+"&op="+p_operation+"&p="+page+'&ctl='+ctl;
+// var action = new Ajax.Request(
+// "ajax_card.php" , { method:'get',
parameters:queryString,onFailure:ajax_get_failure,onSuccess:ajax_get_success}
+// );
+//}
/*!\brief callback function for ajax_get when successuf
*/
function ajax_get_success(request,json)
diff --git a/html/js/card.js b/html/js/card.js
index 735f453..7142cff 100644
--- a/html/js/card.js
+++ b/html/js/card.js
@@ -41,6 +41,9 @@ function boxsearch_card(p_dossier)
onFailure:ajax_misc_failure,
onSuccess:function(req){
remove_waiting_box();
+ if (req.responseText ==
'NOCONX') {
+ reconnect();
+ }
var y=posY+15;
var
div_style="left:10%;width:80%;"+";top:"+y+"px";
add_div({id:'boxsearch_card_div',cssclass:'inner_box',html:loading(),style:div_style,drag:true});
@@ -433,6 +436,7 @@ function result_card_search(req)
{
remove_waiting_box();
+ if ( req.responseText == 'NOCONX') { reconnect();return;}
var answer=req.responseXML;
var a=answer.getElementsByTagName('ctl');
if ( a.length == 0 )
@@ -648,6 +652,7 @@ function successFill_ipopcard(req,json)
{
try
{
+ if (req.responseText=='NOCONX') { reconnect();return; }
var answer=req.responseXML;
var a=answer.getElementsByTagName('ctl');
var html=answer.getElementsByTagName('code');
@@ -704,9 +709,9 @@ function select_card_type(obj)
var str_style="top:"+sx+"px;height:auto";
waiting_box();
- var popup={'id':
content,'cssclass':'inner_box','style':str_style,'html':"",'drag':false};
+ var popup={'id':
"content",'cssclass':'inner_box','style':str_style,'html':"",'drag':false};
- add_div(popup);
+
var queryString='gDossier='+dossier;
queryString+='&ctl='+content;
@@ -746,6 +751,8 @@ function select_card_type(obj)
parameters:queryString,
onFailure:errorFid,
onSuccess:function(req) {
+ if (req.responseText=='NOCONX') {
reconnect(); return;}
+ add_div(popup);
// Get all the category,
var
answer=req.responseXML.getElementsByTagName("fiche_cat_item");
if (answer.length == 0) {
diff --git a/html/js/gestion.js b/html/js/gestion.js
index d25a6e4..8356570 100644
--- a/html/js/gestion.js
+++ b/html/js/gestion.js
@@ -309,6 +309,7 @@ function action_add(p_dossier) {
method:'get',
parameters : {gDossier:p_dossier,'op':'action_add'},
onSuccess : function(p_xml, p_text) {
+ if (p_xml.responseText === 'NOCONX') { reconnect();return;}
remove_waiting_box();
add_div({id: 'action_add_div',
style:"top:1%;width:80%;left:10%" ,
diff --git a/html/js/managetable.js b/html/js/managetable.js
index 902816e..75ddacf 100644
--- a/html/js/managetable.js
+++ b/html/js/managetable.js
@@ -192,6 +192,7 @@ var ManageTable = function (p_table_name)
*/
this.parseXML = function (req) {
try {
+ if (req.responseText==='NOCONX') { reconnect();throw new
Error("NOCONX") ;}
var xml = req.responseXML;
var status = xml.getElementsByTagName("status");
var ctl = xml.getElementsByTagName("ctl");
diff --git a/html/js/noalyss_script.js b/html/js/noalyss_script.js
index a4dc33d..1a8cfc2 100644
--- a/html/js/noalyss_script.js
+++ b/html/js/noalyss_script.js
@@ -895,6 +895,7 @@ function show_ledger_choice(json_obj)
onFailure: ajax_misc_failure,
onSuccess: function (req, json) {
try {
+ if ( req.responseText === 'NOCONX') {
reconnect();return;}
var obj = {
id: json_obj.div + 'jrn_search',
cssclass: 'inner_box',
@@ -1214,7 +1215,7 @@ function save_periode(obj)
function fill_box(req)
{
try {
-
+ if (req.responseText=='NOCONX') { reconnect(); return;}
remove_waiting_box();
var answer = req.responseXML;
@@ -2118,6 +2119,7 @@ function view_action(ag_id, dossier, modify)
onFailure: error_box,
onSuccess: function (req) {
try {
+ if (req.responseText === 'NOCONX') {
reconnect();return;}
remove_waiting_box();
var answer = req.responseXML;
var ctl = answer.getElementsByTagName('ctl');
@@ -2879,6 +2881,7 @@ function calendar_zoom(obj)
parameters: {"notitle": notitle, "op": 'calendar_zoom',
'from': from, 'gDossier': obj.gDossier, 'in': per_periode, 'out': obj.outdiv,
'distype': obj.distype},
onFailure: ajax_misc_failure,
onSuccess: function (req, j) {
+ if (req.responseText === 'NOCONX') {
reconnect();return;}
var answer = req.responseXML;
var html = answer.getElementsByTagName('html');
if (html.length === 0)
@@ -4070,3 +4073,23 @@ function pausecomp(millis)
do { curDate = new Date(); }
while(curDate-date < millis);
}
+/**
+ * @brief propose to reconnect
+ * @returns {undefined}
+ */
+function reconnect(){
+ remove_waiting_box();
+ new Ajax.Request('ajax_misc.php',{
+ method:'get',
+ parameters:{op:"disconnect"},
+ onSuccess:function (req) {
+ var pos="position:fixed;top:0px;width:95%;height:95%";
+ var div= add_div({
+ 'id':"reconnect_bx",
+ cssclass:"inner_box",
+ style:pos
+ });
+ div.innerHTML=req.responseText;
+ }
+ });
+}
\ No newline at end of file
diff --git a/html/js/todo_list.js b/html/js/todo_list.js
index f5fdaca..c22eb30 100644
--- a/html/js/todo_list.js
+++ b/html/js/todo_list.js
@@ -45,6 +45,7 @@ function todo_list_show(p_id)
onFailure: todo_list_show_error,
onSuccess: function (req)
{
+ if ( req.responseText === 'NOCONX') {
reconnect();return;}
try
{
var
todo_div=create_div({id:'todo_list_div'+p_id,cssclass:'add_todo_list'});
diff --git a/include/ajax/ajax_card.php b/include/ajax/ajax_card.php
index d4acd9d..57c0d64 100644
--- a/include/ajax/ajax_card.php
+++ b/include/ajax/ajax_card.php
@@ -83,10 +83,7 @@ extract($_REQUEST, EXTR_SKIP );
if ( $cont != 0 ) exit();
set_language();
-/*
- *echo a warning if disconnected
- */
-ajax_disconnected($_REQUEST['ctl']);
+
$http=new HttpInput();
$cn=Dossier::connect();
global $g_user;
diff --git a/include/ajax/ajax_todo_list.php b/include/ajax/ajax_todo_list.php
index 0805569..7a8c980 100644
--- a/include/ajax/ajax_todo_list.php
+++ b/include/ajax/ajax_todo_list.php
@@ -48,7 +48,7 @@ $g_user=new User($cn);
$g_user->check(true);
$g_user->check_dossier(Dossier::id(),true);
set_language();
-ajax_disconnected('add_todo_list');
+
////////////////////////////////////////////////////////////////////////////////
// Display the note
////////////////////////////////////////////////////////////////////////////////
diff --git a/include/lib/ac_common.php b/include/lib/ac_common.php
index d51b0cb..0468101 100644
--- a/include/lib/ac_common.php
+++ b/include/lib/ac_common.php
@@ -896,46 +896,25 @@ function format_date($p_date, $p_from_format =
'YYYY-MM-DD',$p_to_format='DD.MM.
* Should a dialog box when you are disconnected from an ajax call
* propose to reload or to connect in another tab
*/
-function ajax_disconnected($div)
+function ajax_disconnected($p_div)
{
- /**
- * if $_SESSION[SESSION_KEY.'g_user'] is not set : echo a warning
- */
- if (!isset($_SESSION[SESSION_KEY.'g_user']))
- {
- $script = 'var a=$("' . $div .
'");a.style.height="70%";a.style.width="60%";';
- $script.='a.style.top=posY-20+offsetY;a.style.left=posX+offsetX;';
- $script = create_script($script);
- $html = $script;
- $html.=Icon_Action::close($div);
- $html.='<div>';
- $html.=h2(_('Données non disponibles'), 'class="title"
style="width:auto"');
- $html.=h2(_('Veuillez vous reconnecter soit dans une autre fenêtre soit
'
- . ' en cliquant sur le lien'), 'class="error"');
- // Reload button
- $reload=new IButton("reload");
- $reload->value=_("Se reconnecter pour revenir ici");
- $reload->class="button";
- $reload->javascript='window.location.reload()';
- // Link to log in another tab
- $html.='<p style="text-align:center">';
- $html.='<a href="index.php" class="button" target="_blank">'.
- _('Cliquez ici pour vous reconnecter dans une autre page').
- '</a>';
- $html.=$reload->input();
- $html.=HtmlInput::button_close($div);
- $html.='</p>';
- $html = escape_xml($html);
- header('Content-type: text/xml; charset=UTF-8');
- echo <<<EOF
-<?xml version="1.0" encoding="UTF-8"?>
-<data>
-<ctl>$div</ctl>
-<code>$html</code>
-</data>
-EOF;
- exit();
- }
+
+ echo HtmlInput::title_box(_("Déconnecté"), $p_div);
+ echo h2(_('Données non disponibles'), 'class="error" ');
+ echo h2(_('Veuillez vous reconnecter soit dans une autre fenêtre soit '
+ . ' en cliquant sur le lien'), 'class="error"');
+ // Reload button
+ $reload=new IButton("reload");
+ $reload->value=_("Se connecter");
+ $reload->class="button";
+ $reload->javascript='window.location.reload()';
+ // Link to log in another tab
+ echo '<p style="text-align:center">';
+ echo $reload->input();
+ echo HtmlInput::button_close($p_div);
+ echo '</p>';
+
+
}
/**
- [Noalyss-commit] [noalyss] 01/46: File cleaning, (continued)
- [Noalyss-commit] [noalyss] 01/46: File cleaning, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 05/46: Document : add phpunit test, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 08/46: Cosmetic : add waiting_box when exporting, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 04/46: File cleaning, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 06/46: Move function to the noalyss_script.js, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 10/46: remove direct access to superglobal, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 02/46: File cleaning, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 07/46: ocument : add phpunit test, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 11/46: protect SQL, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 16/46: Improve email sent : check if file attached, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 15/46: Task #0001417: Reconnexion souple connect,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 09/46: Add waiting_box, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 17/46: Task #0001595: CA - liste d'opérations - pas de choix de l'execice., Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 19/46: clean code : remove useless comment, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 20/46: New #0001983: CA - permettre désactivation poste, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 18/46: Bug: possible to set an empy name for an Analytic plan, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 21/46: Bug #0002011: Encodage opération – Verrouillage nombre de lignes si non vides, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 23/46: Task #0002014: Comptabilité analytique = export des pièces des opérations rapprochées, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 27/46: Task #0002014: Comptabilité analytique ordre par date Database_Core setter/getter for sql, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 24/46: Task #0001974: Duplication d'opération – Inclure l'intitulé, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 33/46: If database connx failed then reload the form, Dany De Bontridder, 2021/07/13