Task #0001417: Reconnexion souple
connect Signed-off-by: sparkyx <danydb@noalyss.eu>
This commit is contained in:
parent
8ea668ed86
commit
c123c78eb8
13 changed files with 97 additions and 56 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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%" ,
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -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'});
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -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>';
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue