phpcompta-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpcompta-dev] r4884 - in phpcompta/trunk: html include


From: phpcompta-dev
Subject: [Phpcompta-dev] r4884 - in phpcompta/trunk: html include
Date: Wed, 13 Jun 2012 14:52:32 +0200 (CEST)

Author: danydb
Date: 2012-06-13 14:52:31 +0200 (Wed, 13 Jun 2012)
New Revision: 4884

Modified:
   phpcompta/trunk/html/ajax.php
   phpcompta/trunk/html/ajax_card.php
   phpcompta/trunk/html/ajax_history.php
   phpcompta/trunk/html/ajax_ledger.php
   phpcompta/trunk/html/ajax_misc.php
   phpcompta/trunk/html/ajax_poste.php
   phpcompta/trunk/html/ajax_todo_list.php
   phpcompta/trunk/html/direct.php
   phpcompta/trunk/html/extension.raw.php
   phpcompta/trunk/html/fid.php
   phpcompta/trunk/html/fid_card.php
   phpcompta/trunk/html/popup.php
   phpcompta/trunk/html/recherche.php
   phpcompta/trunk/html/show_document.php
   phpcompta/trunk/html/show_document_modele.php
   phpcompta/trunk/html/show_pj.php
   phpcompta/trunk/html/user_pref.php
   phpcompta/trunk/include/ajax_auto_anc_card.php
   phpcompta/trunk/include/ajax_bank_saldo.php
   phpcompta/trunk/include/ajax_get_receipt.php
   phpcompta/trunk/include/ajax_mod_periode.php
   phpcompta/trunk/include/class_acc_account_ledger.php
   phpcompta/trunk/include/class_acc_balance.php
   phpcompta/trunk/include/class_acc_ledger.php
   phpcompta/trunk/include/class_acc_ledger_fin.php
   phpcompta/trunk/include/class_acc_ledger_purchase.php
   phpcompta/trunk/include/class_acc_ledger_sold.php
   phpcompta/trunk/include/class_acc_operation.php
   phpcompta/trunk/include/class_acc_reconciliation.php
   phpcompta/trunk/include/class_anticipation.php
   phpcompta/trunk/include/class_calendar.php
   phpcompta/trunk/include/class_fiche.php
   phpcompta/trunk/include/class_impress.php
   phpcompta/trunk/include/export_balance_csv.php
   phpcompta/trunk/include/export_balance_pdf.php
   phpcompta/trunk/include/export_fiche_balance_pdf.php
   phpcompta/trunk/include/export_fiche_pdf.php
   phpcompta/trunk/include/export_gl_pdf.php
   phpcompta/trunk/include/export_ledger_csv.php
   phpcompta/trunk/include/export_ledger_pdf.php
   phpcompta/trunk/include/extension_choice.inc.php
   phpcompta/trunk/include/impress_poste.inc.php
   phpcompta/trunk/include/opening.inc.php
   phpcompta/trunk/include/param_pcmn.inc.php
   phpcompta/trunk/include/param_sec.inc.php
   phpcompta/trunk/include/preod.inc.php
   phpcompta/trunk/include/report.inc.php
   phpcompta/trunk/include/search.inc.php
   phpcompta/trunk/include/user_common.php
   phpcompta/trunk/include/verif_bilan.inc.php
Log:
Code quality : use as often as possible global $g_user instead of recreating a 
new User object

Modified: phpcompta/trunk/html/ajax.php
===================================================================
--- phpcompta/trunk/html/ajax.php       2012-06-12 22:21:33 UTC (rev 4883)
+++ phpcompta/trunk/html/ajax.php       2012-06-13 12:52:31 UTC (rev 4884)
@@ -15,8 +15,9 @@
 mb_internal_encoding("UTF-8");
 
 $cn=new Database(dossier::id());
-$user=new User($cn);
-$user->check(true);
+global $g_user;
+$g_user=new User($cn);
+$g_user->check(true);
 
 /* if a code has been asked */
 if (isset($_REQUEST['plugin_code']) )

Modified: phpcompta/trunk/html/ajax_card.php
===================================================================
--- phpcompta/trunk/html/ajax_card.php  2012-06-12 22:21:33 UTC (rev 4883)
+++ phpcompta/trunk/html/ajax_card.php  2012-06-13 12:52:31 UTC (rev 4884)
@@ -87,9 +87,10 @@
 ajax_disconnected($_REQUEST['ctl']);
 
 $cn=new Database($gDossier);
-$user=new User($cn);
-$user->check(true);
-$user->check_dossier($gDossier,true);
+global $g_user;
+$g_user=new User($cn);
+$g_user->check(true);
+$g_user->check_dossier($gDossier,true);
 $html=var_export($_REQUEST,true);
 switch($op)
 {
@@ -97,7 +98,7 @@
     /* Remove a attribut */
     /* ------------------------------------------------------------ */
 case 'rmfa':
-    if ($user->check_action(FICCAT)==0)exit();
+    if ($g_user->check_action(FICCAT)==0)exit();
         ob_start();
     if( ! isset($_GET['ad_id']) || isNumber($_GET['ad_id']) ==0)
         throw new Exception ( "Parametre ad_id est invalide",11);
@@ -130,7 +131,7 @@
     if ( $qcode != '')
     {
         $f->get_by_qcode($qcode);
-       $can_modify=$user->check_action(FIC);
+       $can_modify=$g_user->check_action(FIC);
        if ( isset($ro) )
          {
            $can_modify=0;
@@ -176,7 +177,7 @@
     /* Blank card */
     /* ------------------------------------------------------------ */
 case 'bc':
-    if ( $user->check_action(FICADD)==1 )
+    if ( $g_user->check_action(FICADD)==1 )
     {
         $r='';
        $r=HtmlInput::anchor_close($ctl);
@@ -285,7 +286,7 @@
 case 'sc':
   $html=HtmlInput::anchor_close($ctl);
   $html.=h2info('Nouvelle fiche');
-    if ( $user->check_action(FICADD)==1 )
+    if ( $g_user->check_action(FICADD)==1 )
     {
         $f=new Fiche($cn);
         $f->insert($fd_id,$_POST);
@@ -375,7 +376,7 @@
     $html=$r;
     break;
 case 'ac':
-    if ( $user->check_action(FICCAT)==1 )
+    if ( $g_user->check_action(FICCAT)==1 )
     {
 
         
/*----------------------------------------------------------------------
@@ -433,7 +434,7 @@
      *
      *----------------------------------------------------------------------*/
     $html='';
-    if ( $user->check_action(FICCAT) == 1 )
+    if ( $g_user->check_action(FICCAT) == 1 )
     {
                $script=create_script("removeDiv('$ctl')");
                $html.=$script;
@@ -468,7 +469,7 @@
   $html=HtmlInput::anchor_close($ctl);
   $html.=h2info('Détail fiche');
 
-  if ( $user->check_action(FICADD)==0 )
+  if ( $g_user->check_action(FICADD)==0 )
     {
       $html.=alert(_('Action interdite'),true);
     }

Modified: phpcompta/trunk/html/ajax_history.php
===================================================================
--- phpcompta/trunk/html/ajax_history.php       2012-06-12 22:21:33 UTC (rev 
4883)
+++ phpcompta/trunk/html/ajax_history.php       2012-06-13 12:52:31 UTC (rev 
4884)
@@ -38,12 +38,10 @@
  *if $_SESSION['g_user'] is not set : echo a warning
  */
 ajax_disconnected($div);
-
-//var_dump($_GET);
-$cn=new Database(dossier::id());
-$user=new User($cn);
+global $g_user;
+$g_user=new User($cn);
 /* security */
-if ( $user->check_dossier(dossier::id(),true) == 'X' ) exit();
+if ( $g_user->check_dossier(dossier::id(),true) == 'X' ) exit();
 
 $from_div=(isset ($_REQUEST['ajax']))?1:0;
 
@@ -55,7 +53,7 @@
     $exercice=new Exercice($cn);
     $old='';
     $fiche=new Fiche($cn,$_GET['f_id']);
-    $year=$user->get_exercice();
+    $year=$g_user->get_exercice();
     if ( $year == 0 )
       {
         $html="erreur aucune période par défaut, allez dans préférence pour en 
choisir une";
@@ -125,7 +123,7 @@
 if ( isset($_REQUEST['pcm_val']))
   {
     $poste=new Acc_Account_Ledger($cn,$_REQUEST['pcm_val']);
-    $year=$user->get_exercice();
+    $year=$g_user->get_exercice();
     if ( $year == 0 )
       {
         $html="erreur aucune période par défaut, allez dans préférence pour en 
choisir une";

Modified: phpcompta/trunk/html/ajax_ledger.php
===================================================================
--- phpcompta/trunk/html/ajax_ledger.php        2012-06-12 22:21:33 UTC (rev 
4883)
+++ phpcompta/trunk/html/ajax_ledger.php        2012-06-13 12:52:31 UTC (rev 
4884)
@@ -64,9 +64,10 @@
 $g_parameter=new Own($cn);
 
 // check if the user is valid and can access this folder
-$User=new User($cn);
-$User->check();
-if ( $User->check_dossier(dossier::id(),true)=='X' )
+global $g_user;
+$g_user=new User($cn);
+$g_user->check();
+if ( $g_user->check_dossier(dossier::id(),true)=='X' )
 {
     ob_start();
     require_once ('template/ledger_detail_forbidden.php');
@@ -90,7 +91,7 @@
 $op=new Acc_Operation($cn);
 $op->jr_id=$_REQUEST['jr_id'];
 $ledger=$op->get_ledger();
-$access=$User->get_ledger_access($ledger);
+$access=$g_user->get_ledger_access($ledger);
 if ( $access == 'X' )
 {
     ob_start();

Modified: phpcompta/trunk/html/ajax_misc.php
===================================================================
--- phpcompta/trunk/html/ajax_misc.php  2012-06-12 22:21:33 UTC (rev 4883)
+++ phpcompta/trunk/html/ajax_misc.php  2012-06-13 12:52:31 UTC (rev 4884)
@@ -57,22 +57,21 @@
        exit();
 extract($_REQUEST);
 set_language();
-
+global $g_user;
 $cn = new Database($gDossier);
-$user = new User($cn);
-$user->check(true);
-$user->check_dossier($gDossier, true);
+$g_user = new User($cn);
+$g_user->check(true);
+$g_user->check_dossier($gDossier, true);
 $html = var_export($_REQUEST, true);
-global $g_user;
-$g_user=$user;
+
 switch ($op)
 {
        case "remove_anc":
-         if ($user->check_module('ANCODS') == 0) exit();
+         if ($g_user->check_module('ANCODS') == 0) exit();
                        $cn->exec_sql("delete from operation_analytique where 
oa_group=$1", array($_GET['oa']));
                break;
        case "rm_stock":
-         if ($user->check_module('STOCK') == 0) exit();
+         if ($g_user->check_module('STOCK') == 0) exit();
                require_once('constant.security.php');
                $cn->exec_sql('delete from stock_goods where sg_id=$1', 
array($s_id));
                $html = escape_xml($s_id);
@@ -133,7 +132,7 @@
        case 'rem_cat_doc':
                require_once('class_document_type.php');
                // if user can not return error message
-               if ($user->check_action(PARCATDOC) == 0)
+               if ($g_user->check_action(PARCATDOC) == 0)
                {
                        $html = "nok";
                        header('Content-type: text/xml; charset=UTF-8');
@@ -264,8 +263,8 @@
         */
        case 'dl':
                require_once('class_lettering.php');
-               $exercice = $user->get_exercice();
-        if ($user->check_module("LETCARD") == 0 && 
$user->check_module("LETACC") == 0) exit();
+               $exercice = $g_user->get_exercice();
+        if ($g_user->check_module("LETCARD") == 0 && 
$g_user->check_module("LETACC") == 0) exit();
                $periode = new Periode($cn);
                list($first_per, $last_per) = $periode->get_limit($exercice);
 

Modified: phpcompta/trunk/html/ajax_poste.php
===================================================================
--- phpcompta/trunk/html/ajax_poste.php 2012-06-12 22:21:33 UTC (rev 4883)
+++ phpcompta/trunk/html/ajax_poste.php 2012-06-13 12:52:31 UTC (rev 4884)
@@ -59,9 +59,10 @@
 if ( $cont != 0 ) exit();
 $cn=new Database(dossier::id());
 include_once ("class_user.php");
-$User=new User($cn);
-$User->Check();
-if  ($User->get_folder_access(dossier::id()) == 'X') exit();
+global $g_user;
+$g_user=new User($cn);
+$g_user->Check();
+if  ($g_user->get_folder_access(dossier::id()) == 'X') exit();
 $xml="";
 
 switch ($op)

Modified: phpcompta/trunk/html/ajax_todo_list.php
===================================================================
--- phpcompta/trunk/html/ajax_todo_list.php     2012-06-12 22:21:33 UTC (rev 
4883)
+++ phpcompta/trunk/html/ajax_todo_list.php     2012-06-13 12:52:31 UTC (rev 
4884)
@@ -41,9 +41,10 @@
 mb_internal_encoding("UTF-8");
 
 $cn= Dossier::connect();
-$user=new User($cn);
-$user->check(true);
-$user->check_dossier(Dossier::id(),true);
+global $g_user;
+$g_user=new User($cn);
+$g_user->check(true);
+$g_user->check_dossier(Dossier::id(),true);
 ajax_disconnected('add_todo_list');
 
 if (isset($_REQUEST['show']))

Modified: phpcompta/trunk/html/direct.php
===================================================================
--- phpcompta/trunk/html/direct.php     2012-06-12 22:21:33 UTC (rev 4883)
+++ phpcompta/trunk/html/direct.php     2012-06-13 12:52:31 UTC (rev 4884)
@@ -2,10 +2,11 @@
 require_once ("class_database.php");
 require_once 'class_user.php';
 $cn=new Database($_GET['gDossier']);
-$user=new User($cn);
-$user->Check();
-$user->check_dossier($_GET['gDossier']);
-$res=$cn->exec_sql("select code,description from get_profile_menu($1) where 
code ~* $2 or description ~* $3 limit 
8",array($user->login,$_POST['acs'],$_POST['acs']));
+global $g_user;
+$g_user=new User($cn);
+$g_user->Check();
+$g_user->check_dossier($_GET['gDossier']);
+$res=$cn->exec_sql("select code,description from get_profile_menu($1) where 
code ~* $2 or description ~* $3 limit 
8",array($g_user->login,$_POST['acs'],$_POST['acs']));
 $nb=Database::num_row($res);
        echo "<ul>";
 for ($i = 0;$i< $nb;$i++)

Modified: phpcompta/trunk/html/extension.raw.php
===================================================================
--- phpcompta/trunk/html/extension.raw.php      2012-06-12 22:21:33 UTC (rev 
4883)
+++ phpcompta/trunk/html/extension.raw.php      2012-06-13 12:52:31 UTC (rev 
4884)
@@ -36,9 +36,10 @@
 require_once ('class_user.php');
 
 $cn=new Database(dossier::id());
-$user=new User($cn);
-$user->check();
-$only_plugin=$user->check_dossier(dossier::id());
+global $g_user;
+$g_user=new User($cn);
+$g_user->check();
+$only_plugin=$g_user->check_dossier(dossier::id());
 
 $ext=new Extension($cn);
 

Modified: phpcompta/trunk/html/fid.php
===================================================================
--- phpcompta/trunk/html/fid.php        2012-06-12 22:21:33 UTC (rev 4883)
+++ phpcompta/trunk/html/fid.php        2012-06-13 12:52:31 UTC (rev 4884)
@@ -44,9 +44,10 @@
 require_once('class_user.php');
 
 $cn=new Database(dossier::id());
-$user=new User($cn);
-$user->check();
-$user->check_dossier(dossier::id());
+global $g_user;
+$g_user=new User($cn);
+$g_user->check();
+$g_user->check_dossier(dossier::id());
 
 $fLabel=(isset($_REQUEST['l']))?$_REQUEST['l']:'none';
 $fTva_id=(isset($_REQUEST['t']))?$_REQUEST['t']:'none';

Modified: phpcompta/trunk/html/fid_card.php
===================================================================
--- phpcompta/trunk/html/fid_card.php   2012-06-12 22:21:33 UTC (rev 4883)
+++ phpcompta/trunk/html/fid_card.php   2012-06-13 12:52:31 UTC (rev 4884)
@@ -50,9 +50,10 @@
 $filter_card='';
 
 require_once('class_user.php');
-$user=new User($cn);
-$user->check();
-$user->check_dossier(dossier::id());
+global $g_user;
+$g_user=new User($cn);
+$g_user->check();
+$g_user->check_dossier(dossier::id());
 
 switch ($d)
 {

Modified: phpcompta/trunk/html/popup.php
===================================================================
--- phpcompta/trunk/html/popup.php      2012-06-12 22:21:33 UTC (rev 4883)
+++ phpcompta/trunk/html/popup.php      2012-06-13 12:52:31 UTC (rev 4884)
@@ -10,14 +10,14 @@
 echo '<div style="float:left;">'.HtmlInput::print_window();
 
 html_page_start($_SESSION['g_theme']);
-
+global $g_user;
 if ( basename($_GET['ajax']) == 'ajax_history.php' )
   {
     $href=dossier::get();
     $cn=new Database(dossier::id());
     /* current year  */
-    $user=new User($cn);
-    $exercice=$user->get_exercice();
+    $g_user=new User($cn);
+    $exercice=$g_user->get_exercice();
 
     /* get date limit */
     $periode=new Periode($cn);

Modified: phpcompta/trunk/html/recherche.php
===================================================================
--- phpcompta/trunk/html/recherche.php  2012-06-12 22:21:33 UTC (rev 4883)
+++ phpcompta/trunk/html/recherche.php  2012-06-13 12:52:31 UTC (rev 4884)
@@ -38,9 +38,10 @@
 
 $cn=new Database($gDossier);
 include_once ('class_user.php');
-$User=new User($cn);
-$User->Check();
-$act=$User->check_dossier($gDossier);
+global $g_user;
+$g_user=new User($cn);
+$g_user->Check();
+$act=$g_user->check_dossier($gDossier);
 // AC CODE = SEARCH
 if ($act =='P')
 {

Modified: phpcompta/trunk/html/show_document.php
===================================================================
--- phpcompta/trunk/html/show_document.php      2012-06-12 22:21:33 UTC (rev 
4883)
+++ phpcompta/trunk/html/show_document.php      2012-06-13 12:52:31 UTC (rev 
4884)
@@ -32,14 +32,15 @@
 $action=(isset($_REQUEST['a']))?$_REQUEST['a']:'sh';
 
 require_once ('class_user.php');
-$User=new User(new Database());
-$User->Check();
-$User->check_dossier($gDossier);
+global $g_user;
+$g_user=new User(new Database());
+$g_user->Check();
+$g_user->check_dossier($gDossier);
 
 /* Show the document */
 if ( $action == 'sh')
 {
-    if ( $User->check_action(VIEWDOC)==1)
+    if ( $g_user->check_action(VIEWDOC)==1)
     {
         // retrieve the document
         $doc=new Document($cn,$_REQUEST['d_id']);
@@ -49,7 +50,7 @@
 /* remove the document */
 if ( $action == 'rm' )
 {
-    if ($User->check_action(RMDOC)==1)
+    if ($g_user->check_action(RMDOC)==1)
     {
         $doc=new Document($cn,$_REQUEST['d_id']);
         $doc->remove();
@@ -62,7 +63,7 @@
 if ( $action == 'rmop' )
 {
        $dt_id=$cn->get_value("select ag_id from action_gestion_operation where 
ago_id=$1",$_REQUEST['id']);
-    if ($User->check_action(RMDOC)==1 && $User->can_write_action($dt_id)==true)
+    if ($g_user->check_action(RMDOC)==1 && 
$g_user->can_write_action($dt_id)==true)
     {
                $cn->exec_sql("delete from action_gestion_operation where 
ago_id=$1",
                                array($_REQUEST['id']));
@@ -75,7 +76,7 @@
 if ( $action == 'rmcomment' )
 {
        $dt_id=$cn->get_value("select ag_id from action_gestion_comment where 
agc_id=$1",$_REQUEST['id']);
-    if ($User->check_action(RMDOC)==1 && $User->can_write_action($dt_id)==true)
+    if ($g_user->check_action(RMDOC)==1 && 
$g_user->can_write_action($dt_id)==true)
     {
                $cn->exec_sql("delete from action_gestion_comment where 
agc_id=$1",
                                array($_REQUEST['id']));
@@ -87,7 +88,7 @@
 /* remove the action from action_gestion_operation*/
 if ( $action == 'rmaction' )
 {
-    if ($User->check_action(RMDOC)==1 && 
$User->can_write_action($_REQUEST['id']) == true && 
$User->can_write_action($_REQUEST['ag_id'])== true )
+    if ($g_user->check_action(RMDOC)==1 && 
$g_user->can_write_action($_REQUEST['id']) == true && 
$g_user->can_write_action($_REQUEST['ag_id'])== true )
     {
                $cn->exec_sql("delete from action_gestion_related where 
aga_least=$1 and aga_greatest=$2",
                                array($_REQUEST['id'],$_REQUEST['ag_id']));

Modified: phpcompta/trunk/html/show_document_modele.php
===================================================================
--- phpcompta/trunk/html/show_document_modele.php       2012-06-12 22:21:33 UTC 
(rev 4883)
+++ phpcompta/trunk/html/show_document_modele.php       2012-06-13 12:52:31 UTC 
(rev 4884)
@@ -32,11 +32,10 @@
 
 
 require_once ('class_user.php');
-$User=new User($cn);
-/*!\todo Add security here
- */
-$User->Check();
-if ( $User->check_module("CFGDOC") == 0 ) exit();
+global $g_user;
+$g_user=new User($cn);
+$g_user->Check();
+if ( $g_user->check_module("CFGDOC") == 0 ) exit();
 // retrieve the document
 $r=$cn->exec_sql("select md_id,md_lob,md_filename,md_mimetype
                  from document_modele where 
md_id=$1",array($_REQUEST['md_id']));

Modified: phpcompta/trunk/html/show_pj.php
===================================================================
--- phpcompta/trunk/html/show_pj.php    2012-06-12 22:21:33 UTC (rev 4883)
+++ phpcompta/trunk/html/show_pj.php    2012-06-13 12:52:31 UTC (rev 4884)
@@ -41,9 +41,10 @@
 
 
 include_once ('class_user.php');
-$User=new User($cn);
-$User->Check();
-$User->check_dossier($gDossier);
+global $g_user;
+$g_user=new User($cn);
+$g_user->Check();
+$g_user->check_dossier($gDossier);
 
 // retrieve the jrn
 $r=$cn->exec_sql("select jr_def_id from jrn where jr_grpt_id=$jr_grpt_id");
@@ -55,7 +56,7 @@
 $a=Database::fetch_array($r,0);
 $jrn=$a['jr_def_id'];
 
-if ($User->check_jrn($jrn) == 'X' )
+if ($g_user->check_jrn($jrn) == 'X' )
 {
     /* Cannot Access */
     NoAccess();

Modified: phpcompta/trunk/html/user_pref.php
===================================================================
--- phpcompta/trunk/html/user_pref.php  2012-06-12 22:21:33 UTC (rev 4883)
+++ phpcompta/trunk/html/user_pref.php  2012-06-13 12:52:31 UTC (rev 4884)
@@ -43,21 +43,19 @@
     $cn=new Database();
 }
 
+global $g_user;
 
-$User=new User($cn);
-$User->Check();
-
 // Met a jour le theme utilisateur (style)
 if ( isset ( $_POST['style_user']) )
 {
-    $User->update_global_pref('THEME',$_POST['style_user']);
+    $g_user->update_global_pref('THEME',$_POST['style_user']);
     $_SESSION['g_theme']=$_POST['style_user'];
 
 }
 // Update the language
 if ( isset($_POST ['lang']))
 {
-    $User->update_global_pref('LANG',$_POST['lang']);
+    $g_user->update_global_pref('LANG',$_POST['lang']);
     $_SESSION['g_lang']=$_POST['lang'];
 }
 
@@ -66,7 +64,7 @@
 // Met a jour le pagesize
 if ( isset ( $_POST['p_size']) )
 {
-    $User->update_global_pref('PAGESIZE',$_POST['p_size']);
+    $g_user->update_global_pref('PAGESIZE',$_POST['p_size']);
     $_SESSION['g_pagesize']=$_POST['p_size'];
 
 }
@@ -80,7 +78,7 @@
 if ( isset ($_POST['val']) )
 {
     // Change the mini report
-    if ( isset ($_POST['minirap']))   
$User->set_mini_report($_POST['minirap']);
+    if ( isset ($_POST['minirap']))   
$g_user->set_mini_report($_POST['minirap']);
 }
 // show the top menu depending of the use_style
 // comta style

Modified: phpcompta/trunk/include/ajax_auto_anc_card.php
===================================================================
--- phpcompta/trunk/include/ajax_auto_anc_card.php      2012-06-12 22:21:33 UTC 
(rev 4883)
+++ phpcompta/trunk/include/ajax_auto_anc_card.php      2012-06-13 12:52:31 UTC 
(rev 4884)
@@ -2,9 +2,8 @@
 require_once ("class_database.php");
 require_once 'class_user.php';
 $cn=new Database($_GET['gDossier']);
-$user=new User($cn);
-$user->Check();
-$user->check_dossier($_GET['gDossier']);
+
+
 if ( isset($_REQUEST['pa_id']) )
 {   
     $res=$cn->exec_sql("select po_name,po_description from  poste_analytique 
where pa_id=$1 ~* and (po_description ~* $2 or po_name ~* $3 order by po_id 
limit 12",

Modified: phpcompta/trunk/include/ajax_bank_saldo.php
===================================================================
--- phpcompta/trunk/include/ajax_bank_saldo.php 2012-06-12 22:21:33 UTC (rev 
4883)
+++ phpcompta/trunk/include/ajax_bank_saldo.php 2012-06-13 12:52:31 UTC (rev 
4884)
@@ -49,10 +49,7 @@
     }
 }
 
-$cn=new Database(dossier::id());
-$user=new User($cn);
-$user->check();
-if ( $user->check_jrn($_GET['j'])=='X' ) return '{"saldo":"0"}';
+if ( $g_user->check_jrn($_GET['j'])=='X' ) return '{"saldo":"0"}';
 /*  make a filter on the exercice */
 
 $filter_year="  j_tech_per in (select p_id from parm_periode ".

Modified: phpcompta/trunk/include/ajax_get_receipt.php
===================================================================
--- phpcompta/trunk/include/ajax_get_receipt.php        2012-06-12 22:21:33 UTC 
(rev 4883)
+++ phpcompta/trunk/include/ajax_get_receipt.php        2012-06-13 12:52:31 UTC 
(rev 4884)
@@ -50,10 +50,8 @@
 {
     exit();
 }
-$cn=new Database(dossier::id());
-$User=new User($cn);
-$User->Check();
 
+
 $Ledger=new Acc_Ledger($cn,$l);
 $prop=$Ledger->get_propertie();
 $pj_seq=$Ledger->guess_pj();

Modified: phpcompta/trunk/include/ajax_mod_periode.php
===================================================================
--- phpcompta/trunk/include/ajax_mod_periode.php        2012-06-12 22:21:33 UTC 
(rev 4883)
+++ phpcompta/trunk/include/ajax_mod_periode.php        2012-06-13 12:52:31 UTC 
(rev 4884)
@@ -24,7 +24,7 @@
 
 /* !\file
  * \brief display or save a periode
- * variable received $op, $cn $user
+ * variable received $op, $cn $g_user
  */
 $err = 0;
 $html = '';

Modified: phpcompta/trunk/include/class_acc_account_ledger.php
===================================================================
--- phpcompta/trunk/include/class_acc_account_ledger.php        2012-06-12 
22:21:33 UTC (rev 4883)
+++ phpcompta/trunk/include/class_acc_account_ledger.php        2012-06-13 
12:52:31 UTC (rev 4884)
@@ -110,8 +110,8 @@
      */
     function get_row_date($p_from,$p_to,$let=0,$solded=0)
     {
-        $user=new User($this->db);
-        $filter_sql=$user->get_ledger_sql('ALL',3);
+        global $g_user;
+        $filter_sql=$g_user->get_ledger_sql('ALL',3);
         $sql_let='';
         switch ($let)
         {

Modified: phpcompta/trunk/include/class_acc_balance.php
===================================================================
--- phpcompta/trunk/include/class_acc_balance.php       2012-06-12 22:21:33 UTC 
(rev 4883)
+++ phpcompta/trunk/include/class_acc_balance.php       2012-06-13 12:52:31 UTC 
(rev 4884)
@@ -60,7 +60,7 @@
      */
     function get_row($p_from_periode,$p_to_periode)
     {
-
+        global $g_user;
         // filter on requested periode
         
$per_sql=sql_filter_per($this->db,$p_from_periode,$p_to_periode,'p_id','j_tech_per');
 
@@ -72,7 +72,6 @@
         /* if several ledgers are asked then we filter here  */
         if ($this->jrn!== null)
         {
-            $user=new User($this->db);
             /**
              address@hidden
              address@hidden the get_ledger here is not valid and useless we 
just need a list of the 
@@ -100,8 +99,7 @@
             $to_poste=" $and j_poste::text <= '".$this->to_poste."'";
             $and=" and ";
         }
-        $user=new User($this->db);
-        $filter_sql=$user->get_ledger_sql('ALL',3);
+        $filter_sql=$g_user->get_ledger_sql('ALL',3);
 
         // build query
         $sql="select j_poste,sum(deb) as sum_deb, sum(cred) as sum_cred from

Modified: phpcompta/trunk/include/class_acc_ledger.php
===================================================================
--- phpcompta/trunk/include/class_acc_ledger.php        2012-06-12 22:21:33 UTC 
(rev 4883)
+++ phpcompta/trunk/include/class_acc_ledger.php        2012-06-13 12:52:31 UTC 
(rev 4884)
@@ -170,10 +170,10 @@
      */
     function reverse($p_date)
     {
+        global $g_user;
         if ( ! isset ($this->jr_id) || $this->jr_id=='')
             throw new Exception ("this->jr_id is not set ou opération 
inconnue");
 
-        $user=new User($this->db);
         /* check if the date is valid */
         if ( isDate($p_date) == null )
             throw new Exception (_('Date invalide').$p_date);
@@ -250,7 +250,7 @@
                   from
                   jrnx
                   where   j_id=$6 returning j_id";
-            
$Res=$this->db->exec_sql($sql,array($p_date,$grp_new,$p_internal,$user->id,$per->p_id,$row));
+            
$Res=$this->db->exec_sql($sql,array($p_date,$grp_new,$p_internal,$g_user->id,$per->p_id,$row));
             // Check return code
             if ( $Res == false)
                 throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql 
]"));
@@ -356,7 +356,7 @@
      */
     function get_row($p_from,$p_to,$p_limit=-1,$p_offset=-1)
     {
-               global $g_user;
+       global $g_user;
         $periode=sql_filter_per($this->db,$p_from,$p_to,'p_id','jr_tech_per');
 
         $cond_limite=($p_limit!=-1)?" limit ".$p_limit." offset ".$p_offset:"";
@@ -514,7 +514,7 @@
      */
     function get_rowSimple($p_from,$p_to,$trunc=0,$p_limit=-1,$p_offset=-1)
     {
-               global $g_user;
+       global $g_user;
         // Grand-livre : id= 0
         //---
         $jrn=($this->id == 0 )?"and ".$g_user->get_ledger_sql():"and 
jrn_def_id = ".$this->id;
@@ -612,8 +612,7 @@
      */
     public function list_operation_to_reconcile($sql)
     {
-        global $g_parameter;
-        $user=new User($this->db);
+        global $g_parameter,$g_user;
         $gDossier=dossier::id();
         $limit=" LIMIT 25";
         // Sort
@@ -786,9 +785,8 @@
      */
     public function list_operation($sql,$offset,$p_paid=0)
     {
-        global $g_parameter;
+        global $g_parameter,$g_user;
                $table=new Sort_Table();
-        $user=new User($this->db);
         $gDossier=dossier::id();
         $amount_paid=0.0;
         $amount_unpaid=0.0;
@@ -1273,8 +1271,8 @@
      */
     function select_ledger($p_type="ALL",$p_access=3)
     {
-        $user=new User($this->db);
-        $array=$user->get_ledger($p_type,$p_access);
+        global $g_user;
+        $array=$g_user->get_ledger($p_type,$p_access);
 
         if ( $array == null ) return null;
         $idx=0;
@@ -1505,8 +1503,7 @@
      */
     function input($p_array=null,$p_readonly=0)
     {
-        global $g_parameter;
-        $user = new User($this->db);
+        global $g_parameter,$g_user;
 
         if ( $p_readonly == 1 )
             return $this->confirm($p_array);
@@ -1521,7 +1518,7 @@
         $add_js.='get_last_date();';
 
         $ret="";
-               if ( $user->check_action(FICADD) == 1)
+               if ( $g_user->check_action(FICADD) == 1)
                {
                        /* Add button */
                        $f_add_button=new IButton('add_card');
@@ -1555,11 +1552,11 @@
         //--
         if ($this->check_periode() == true)
         {
-            $l_user_per=$user->get_periode();
+            $l_user_per=$g_user->get_periode();
             $def=(isset($periode))?$periode:$l_user_per;
 
             $period=new IPeriod("period");
-            $period->user=$user;
+            $period->user=$g_user;
             $period->cn=$this->db;
             $period->value=$def;
             $period->type=OPEN;
@@ -1620,7 +1617,7 @@
         $ret.=HtmlInput::hidden('jrn_type',$this->get_type());
         $info= HtmlInput::infobulle(0);
         $info_poste=HtmlInput::infobulle(9);
-               if  ($user->check_action(FICADD)==1)    
$ret.=$f_add_button->input();
+       if  ($g_user->check_action(FICADD)==1)  $ret.=$f_add_button->input();
         $ret.='<table id="quick_item" style="width:100%">';
         $ret.='<tr>'.
               '<th style="text-align:left">Quickcode'.$info.'</th>'.
@@ -1758,14 +1755,13 @@
     function verify($p_array)
     {
         extract ($p_array);
-        $user=new User($this->db);
+        global $g_user;
         $tot_cred=0;
         $tot_deb=0;
                $msg=array();
 
         /* check if we can write into this ledger */
-        $user=new User($this->db);
-        if ( $user->check_jrn($p_jrn) != 'W' )
+        if ( $g_user->check_jrn($p_jrn) != 'W' )
             throw new Exception (_('Accès interdit'),20);
 
         /* check for a double reload */
@@ -2094,8 +2090,8 @@
      */
     public function get_first($p_type,$p_access=3)
     {
-        $user=new User($this->db);
-        $all=$user->get_ledger($p_type,$p_access);
+        global $g_user;
+        $all=$g_user->get_ledger($p_type,$p_access);
         return $all[0];
     }
 
@@ -2323,10 +2319,10 @@
      */
     function  search_form($p_type,$all_type_ledger=1,$div="")
     {
-        $user=new User($this->db);
+        global $g_user;
         $r='';
         /* security : filter ledger on user */
-        $filter_ledger=$user->get_ledger($p_type,3);
+        $filter_ledger=$g_user->get_ledger($p_type,3);
 
         
$selected=(isset($_REQUEST['r_jrn'.$div]))?$_REQUEST['r_jrn'.$div]:null;
         $f_ledger=HtmlInput::select_ledger($filter_ledger,$selected,$div);
@@ -2340,7 +2336,7 @@
         }
         else
         {
-            $period=$user->get_periode();
+            $period=$g_user->get_periode();
             $per=new Periode($this->db,$period);
             $exercice=$per->get_exercice();
             list($per_start,$per_end)=$per->get_limit($exercice);
@@ -2509,8 +2505,8 @@
                        if ( isset($qcodesearch_op)) $qcode=$qcodesearch_op;
             $accounting=(isset($accounting))?$accounting:"";
                        $periode=new Periode($this->db);
-                       $user=new User($this->db);
-                       $p_id=$user->get_periode();
+                       $g_user=new User($this->db);
+                       $p_id=$g_user->get_periode();
                        if ( $p_id != null )
                        {
                                
list($date_start,$date_end)=$periode->get_date_limit($p_id);
@@ -2529,7 +2525,7 @@
         $fil_paid='';
 
         $and='';
-        $user=new User($this->db);
+        $g_user=new User($this->db);
        $p_action=$ledger_type;
        if ( $p_action == '') $p_action='ALL';
         if ( $r_jrn == -1 )
@@ -2539,7 +2535,7 @@
             if ( $p_action == 'quick_writing') $p_action='ODS';
 
 
-            $fil_ledger=$user->get_ledger_sql($p_action,3);
+            $fil_ledger=$g_user->get_ledger_sql($p_action,3);
             $and=' and ';
         }
         else
@@ -2547,7 +2543,7 @@
 
             if ( $p_action == 'quick_writing') $p_action='ODS';
 
-            $aLedger=$user->get_ledger($p_action,3);
+            $aLedger=$g_user->get_ledger($p_action,3);
             $fil_ledger='';
             $sp='';
             for ($i=0;$i < count($aLedger) ;$i ++)
@@ -2638,11 +2634,11 @@
             $and =" and ";
         }
 
-        $User=new User(new Database());
-        $User->Check();
-        $User->check_dossier(dossier::id());
+        $g_user=new User(new Database());
+        $g_user->Check();
+        $g_user->check_dossier(dossier::id());
 
-        if ( $User->admin == 0 && $User->is_local_admin()==0 )
+        if ( $g_user->admin == 0 && $g_user->is_local_admin()==0 )
         {
             $fil_sec=$and." jr_def_id in ( select uj_jrn_id ".
                      " from user_sec_jrn where ".
@@ -2698,8 +2694,8 @@
      */
     function get_last($p_limit)
     {
-        $user=new User($this->db);
-        $filter_ledger=$user->get_ledger_sql('ALL',3);
+        global $g_user;
+        $filter_ledger=$g_user->get_ledger_sql('ALL',3);
         $filter_ledger=str_replace('jrn_def_id','jr_def_id',$filter_ledger);
         $sql="select jr_id,jr_pj_number,jr_date,to_char(jr_date,'DD.MM.YYYY') 
as jr_date_fmt,jr_montant, jr_comment,jr_internal from jrn ".
              " where $filter_ledger ".

Modified: phpcompta/trunk/include/class_acc_ledger_fin.php
===================================================================
--- phpcompta/trunk/include/class_acc_ledger_fin.php    2012-06-12 22:21:33 UTC 
(rev 4883)
+++ phpcompta/trunk/include/class_acc_ledger_fin.php    2012-06-13 12:52:31 UTC 
(rev 4884)
@@ -51,14 +51,14 @@
      */
     public function verify($p_array)
     {
+        global $g_user;
         extract ($p_array);
         /* check for a double reload */
         if ( isset($mt) && $this->db->count_sql('select jr_mt from jrn where 
jr_mt=$1',array($mt)) != 0 )
             throw new Exception (_('Double Encodage'),5);
 
         /* check if we can write into this ledger */
-        $user=new User($this->db);
-        if ( $user->check_jrn($p_jrn) != 'W' )
+        if ( $g_user->check_jrn($p_jrn) != 'W' )
             throw new Exception (_('Accès interdit'),20);
 
         /* check if there is a bank account linked to the ledger */
@@ -187,23 +187,22 @@
      */
     function input($p_array=null,$notused=0)
     {
-        global $g_parameter;
+        global $g_parameter,$g_user;
         if ( $p_array != null)
             extract ($p_array);
 
         $pview_only=false;
-        $user = new User($this->db);
 
         $f_add_button=new IButton('add_card');
         $f_add_button->label=_('Créer une nouvelle fiche');
         $f_add_button->set_attribute('ipopup','ipop_newcard');
         $f_add_button->set_attribute('jrn',$this->id);
         $f_add_button->javascript=" 
this.jrn=\$('p_jrn').value;select_card_type(this);";
-        
$str_add_button=($user->check_action(FICADD)==1)?$f_add_button->input():"";
+        
$str_add_button=($g_user->check_action(FICADD)==1)?$f_add_button->input():"";
 
         // The first day of the periode
         $pPeriode=new Periode($this->db);
-        list 
($l_date_start,$l_date_end)=$pPeriode->get_date_limit($user->get_periode());
+        list 
($l_date_start,$l_date_end)=$pPeriode->get_date_limit($g_user->get_periode());
         if (  $g_parameter->MY_DATE_SUGGEST=='Y' )
             $op_date=( ! isset($e_date) ) ?$l_date_start:$e_date;
         else
@@ -223,12 +222,12 @@
         {
             // Periode
             //--
-            $l_user_per=(isset($periode))?$periode:$user->get_periode();
+            $l_user_per=(isset($periode))?$periode:$g_user->get_periode();
             $period=new IPeriod();
             $period->cn=$this->db;
             $period->type=OPEN;
             $period->value=$l_user_per;
-            $period->user=$user;
+            $period->user=$g_user;
             $period->name='periode';
             try
             {
@@ -874,6 +873,7 @@
      */
     function show_ledger()
     {
+        global $g_user;
         echo dossier::hidden();
         $hid=new IHidden();
 
@@ -886,11 +886,10 @@
         $hid->value="l";
         echo $hid->input();
 
-        $User=new User($this->db);
 
         $w=new ISelect();
         // filter on the current year
-        $filter_year=" where p_exercice='".$User->get_exercice()."'";
+        $filter_year=" where p_exercice='".$g_user->get_exercice()."'";
 
         $periode_start=$this->db->make_array("select 
p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by 
p_start,p_end",1);
         // User is already set User=new User($this->db);
@@ -948,13 +947,13 @@
         else
         {
             $filter_per=" and jr_tech_per in (select p_id from parm_periode 
where p_exercice::integer=".
-                        $User->get_exercice().")";
+                        $g_user->get_exercice().")";
         }
         /* security  */
         if( $this->id != -1)
-            $available_ledger=" and jr_def_id= ".$this->id." and 
".$User->get_ledger_sql();
+            $available_ledger=" and jr_def_id= ".$this->id." and 
".$g_user->get_ledger_sql();
         else
-            $available_ledger=" and ".$User->get_ledger_sql();
+            $available_ledger=" and ".$g_user->get_ledger_sql();
         // Show list of sell
         // Date - date of payment - Customer - amount
         $sql=SQL_LIST_ALL_INVOICE.$filter_per." and jr_def_type='FIN'".

Modified: phpcompta/trunk/include/class_acc_ledger_purchase.php
===================================================================
--- phpcompta/trunk/include/class_acc_ledger_purchase.php       2012-06-12 
22:21:33 UTC (rev 4883)
+++ phpcompta/trunk/include/class_acc_ledger_purchase.php       2012-06-13 
12:52:31 UTC (rev 4884)
@@ -60,11 +60,10 @@
      */
     public function verify($p_array)
     {
-        global $g_parameter;
+        global $g_parameter,$g_user;
         extract ($p_array);
         /* check if we can write into this ledger */
-        $user=new User($this->db);
-        if ( $user->check_jrn($p_jrn) != 'W' )
+        if ( $g_user->check_jrn($p_jrn) != 'W' )
             throw new Exception (_('Accès interdit'),20);
 
 
@@ -880,10 +879,9 @@
      */
     public function input($p_array=null,$p_readonly=0)
     {
-        global $g_parameter;
+        global $g_parameter,$g_user;
         if ( $p_array != null ) extract($p_array);
 
-        $user = new User($this->db);
         $flag_tva=$g_parameter->MY_TVA_USE;
         /* Add button */
         $f_add_button=new IButton('add_card');
@@ -900,14 +898,14 @@
         $f_add_button2->javascript="  
this.jrn=\$('p_jrn').value;select_card_type(this);";
                $str_add_button="";
                $str_add_button2="";
-               if ($user->check_action(FICADD)==1)
+               if ($g_user->check_action(FICADD)==1)
                {
                        $str_add_button=$f_add_button->input();
                        $str_add_button2=$f_add_button2->input();
                }
         // The first day of the periode
         $oPeriode=new Periode($this->db);
-        list 
($l_date_start,$l_date_end)=$oPeriode->get_date_limit($user->get_periode());
+        list 
($l_date_start,$l_date_end)=$oPeriode->get_date_limit($g_user->get_periode());
         if (  $g_parameter->MY_DATE_SUGGEST=='Y' )
             $op_date=( ! isset($e_date) ) ?$l_date_start:$e_date;
         else
@@ -940,11 +938,11 @@
         {
             // Periode
             //--
-            $l_user_per=$user->get_periode();
+            $l_user_per=$g_user->get_periode();
             $def=(isset($periode))?$periode:$l_user_per;
 
             $period=new IPeriod("period");
-            $period->user=$user;
+            $period->user=$g_user;
             $period->cn=$this->db;
             $period->value=$def;
             $period->type=OPEN;

Modified: phpcompta/trunk/include/class_acc_ledger_sold.php
===================================================================
--- phpcompta/trunk/include/class_acc_ledger_sold.php   2012-06-12 22:21:33 UTC 
(rev 4883)
+++ phpcompta/trunk/include/class_acc_ledger_sold.php   2012-06-13 12:52:31 UTC 
(rev 4884)
@@ -58,15 +58,14 @@
      */
     public function verify($p_array)
     {
-        global $g_parameter;
+        global $g_parameter,$g_user;
         extract ($p_array);
         /* check for a double reload */
         if (  isset($mt) && $this->db->count_sql('select jr_mt from jrn where 
jr_mt=$1',array($mt)) != 0 )
             throw new Exception (_('Double Encodage'),5);
 
         /* check if we can write into this ledger */
-        $user=new User($this->db);
-        if ( $user->check_jrn($p_jrn) != 'W' )
+        if ( $g_user->check_jrn($p_jrn) != 'W' )
             throw new Exception (_('Accès interdit'),20);
 
         /* check if there is a customer */
@@ -1001,9 +1000,9 @@
     */
     function input($p_array=null,$p_readonly=0)
     {
-        global $g_parameter;
+        global $g_parameter,$g_user;
         if ( $p_array != null ) extract($p_array);
-        $user = new User($this->db);
+
         $flag_tva=$g_parameter->MY_TVA_USE;
         /* Add button */
         $f_add_button=new IButton('add_card');
@@ -1021,14 +1020,14 @@
 
                $str_add_button="";
                $str_add_button2="";
-               if ($user->check_action(FICADD)==1)
+               if ($g_user->check_action(FICADD)==1)
                {
                        $str_add_button=$f_add_button->input();
                        $str_add_button2=$f_add_button2->input();
                }
         // The first day of the periode
         $oPeriode=new Periode($this->db);
-        list 
($l_date_start,$l_date_end)=$oPeriode->get_date_limit($user->get_periode());
+        list 
($l_date_start,$l_date_end)=$oPeriode->get_date_limit($g_user->get_periode());
         if (  $g_parameter->MY_DATE_SUGGEST=='Y' )
             $op_date=( ! isset($e_date) ) ?$l_date_start:$e_date;
         else
@@ -1058,11 +1057,11 @@
         //--
         if ($this->check_periode() == true)
         {
-            $l_user_per=$user->get_periode();
+            $l_user_per=$g_user->get_periode();
             $def=(isset($periode))?$periode:$l_user_per;
 
             $period=new IPeriod("period");
-            $period->user=$user;
+            $period->user=$g_user;
             $period->cn=$this->db;
             $period->value=$def;
             $period->type=OPEN;

Modified: phpcompta/trunk/include/class_acc_operation.php
===================================================================
--- phpcompta/trunk/include/class_acc_operation.php     2012-06-12 22:21:33 UTC 
(rev 4883)
+++ phpcompta/trunk/include/class_acc_operation.php     2012-06-13 12:52:31 UTC 
(rev 4884)
@@ -50,11 +50,11 @@
      */
     function __construct($p_cn)
     {
+        global $g_user;
         $this->db=$p_cn;
         $this->qcode="";
         $this->user=$_SESSION['g_user'];
-        $user=new User($this->db);
-        $this->periode=$user->get_periode();
+        $this->periode=$g_user->get_periode();
         $this->jr_id=0;
     }
     /**
@@ -247,8 +247,8 @@
      */
     function get_jrnx_detail()
     {
-        $user=new User($this->db);
-        $filter_sql=$user->get_ledger_sql('ALL',3);
+        global $g_user;
+        $filter_sql=$g_user->get_ledger_sql('ALL',3);
         $filter_sql=str_replace('jrn_def_id','jr_def_id',$filter_sql);
         if ( $this->jr_id==0 ) return;
         $sql=" select  jr_date,j_qcode,j_poste,j_montant,jr_internal,case when 
j_debit = 'f' then 'C' else 'D' end as debit,jr_comment as description,

Modified: phpcompta/trunk/include/class_acc_reconciliation.php
===================================================================
--- phpcompta/trunk/include/class_acc_reconciliation.php        2012-06-12 
22:21:33 UTC (rev 4883)
+++ phpcompta/trunk/include/class_acc_reconciliation.php        2012-06-13 
12:52:31 UTC (rev 4884)
@@ -281,9 +281,9 @@
      */
     function ledger_filter ()
     {
+        global $g_user;
         /* get the available ledgers for current user */
-        $user=new User($this->db);
-        $sql=$user->get_ledger_sql('ALL',3);
+        $sql=$g_user->get_ledger_sql('ALL',3);
         $sql=str_replace('jrn_def_id','jr_def_id',$sql);
         $r='';
         /* filter by this->r_jrn */
@@ -373,8 +373,8 @@
    */
     function filter_date()
     {
-      $user=new User($this->db);
-      list($start,$end)=$user->get_limit_current_exercice();
+      global $g_user;
+      list($start,$end)=$g_user->get_limit_current_exercice();
 
       if (isDate($this->start_day) ==null)
        {

Modified: phpcompta/trunk/include/class_anticipation.php
===================================================================
--- phpcompta/trunk/include/class_anticipation.php      2012-06-12 22:21:33 UTC 
(rev 4883)
+++ phpcompta/trunk/include/class_anticipation.php      2012-06-13 12:52:31 UTC 
(rev 4884)
@@ -194,7 +194,6 @@
      */
     private function form_cat_mod()
     {
-      $user=new User($this->cn);
         $a=new Forecast($this->cn,$this->f_id);
         $a->load();
         $name=new IText('an_name');
@@ -207,7 +206,7 @@
        $start_date->cn=$this->cn;
        $start_date->show_end_date=false;
        $start_date->show_start_date=true;
-       $start_date->user=$user;
+       $start_date->user=$g_user;
        $start_date->filter_year=false;
 
        $end_date=new IPeriod('end_date');
@@ -215,7 +214,7 @@
        $end_date->cn=$this->cn;
        $end_date->show_end_date=true;
        $end_date->show_start_date=false;
-       $end_date->user=$user;
+       $end_date->user=$g_user;
        $end_date->filter_year=false;
 
        $start_date->value=$a->f_start_date;
@@ -256,7 +255,7 @@
      */
     private function form_cat_new()
     {
-      $user=new User($this->cn);
+     global $g_user;
       $r="";
         $str_action=_('Nouveau');
 
@@ -268,7 +267,7 @@
        $start_date->cn=$this->cn;
        $start_date->show_end_date=false;
        $start_date->show_start_date=true;
-       $start_date->user=$user;
+       $start_date->user=$g_user;
        $start_date->filter_year=false;
 
        $end_date=new IPeriod('end_date');
@@ -276,10 +275,10 @@
        $end_date->cn=$this->cn;
        $end_date->show_end_date=true;
        $end_date->show_start_date=false;
-       $end_date->user=$user;
+       $end_date->user=$g_user;
        $end_date->filter_year=false;
 
-       $period=$user->get_periode();
+       $period=$g_user->get_periode();
        $per=new Periode($this->cn,$period);
        $year=$per->get_exercice();
 

Modified: phpcompta/trunk/include/class_calendar.php
===================================================================
--- phpcompta/trunk/include/class_calendar.php  2012-06-12 22:21:33 UTC (rev 
4883)
+++ phpcompta/trunk/include/class_calendar.php  2012-06-13 12:52:31 UTC (rev 
4884)
@@ -135,6 +135,7 @@
      */
     function get_preference()
     {
+        global $g_user;
         $cn=new Database(dossier::id());
         $today=date('d.m.Y');
         $p_id=$cn->get_value("
@@ -146,10 +147,9 @@
                 array($today));
         if ( $p_id == '')
         {
-            $user=new User($cn);
-            $p_id=$user->get_periode();
+            $p_id=$g_user->get_periode();
         }
-               $this->default_periode=$p_id;
+       $this->default_periode=$p_id;
         return  $p_id;
     }
     /**

Modified: phpcompta/trunk/include/class_fiche.php
===================================================================
--- phpcompta/trunk/include/class_fiche.php     2012-06-12 22:21:33 UTC (rev 
4883)
+++ phpcompta/trunk/include/class_fiche.php     2012-06-13 12:52:31 UTC (rev 
4884)
@@ -71,9 +71,8 @@
    */
     function get_bk_account()
     {
-
-      $user=new User($this->cn);
-      $sql_ledger=$user->get_ledger_sql('FIN',3);
+        global $g_user;
+      $sql_ledger=$g_user->get_ledger_sql('FIN',3);
       $avail=$this->cn->get_array("select jrn_def_id,jrn_def_bank from jrn_def 
where jrn_def_type='FIN' and $sql_ledger
                             order by jrn_def_name");
 
@@ -861,6 +860,7 @@
      */
     function update($p_array=null)
     {
+        global $g_user;
         if ( $p_array == null)
             $p_array=$_POST;
 
@@ -917,8 +917,7 @@
                                              " f_id=".$this->id);
                     if ( $st == 0 )
                     {
-                        $user=new User($this->cn);
-                        $exercice=$user->get_exercice();
+                        $exercice=$g_user->get_exercice();
                         if ( $exercice == 0 ) throw new Exception ('Annee 
invalide erreur');
 
                         $str_stock=sprintf('insert into 
stock_goods(f_id,sg_quantity,sg_comment,sg_code,sg_type,sg_exercice) '.
@@ -1146,13 +1145,13 @@
      */
     function get_row_date($p_from,$p_to,$op_let=0)
     {
+        global $g_user;
         if ( $this->id == 0 )
         {
             echo_error("class_fiche",__LINE__,"id is 0");
             return;
         }
-        $user=new User($this->cn);
-        $filter_sql=$user->get_ledger_sql('ALL',3);
+        $filter_sql=$g_user->get_ledger_sql('ALL',3);
         $sql_let='';
         switch ($op_let)
         {
@@ -1551,17 +1550,17 @@
      */
     function Summary($p_search="",$p_action="",$p_sql="",$p_amount=false)
     {
-
+        global $g_user;
         $str_dossier=dossier::get();
         $p_search=sql_string($p_search);
         $script=$_SERVER['PHP_SELF'];
         // Creation of the nav bar
         // Get the max numberRow
         $filter_amount='';
-        $User=new User($this->cn);
+        global $g_user;
 
         $filter_year="  j_tech_per in (select p_id from parm_periode ".
-                     "where p_exercice='".$User->get_exercice()."')";
+                     "where p_exercice='".$g_user->get_exercice()."')";
 
         if ( $p_amount) $filter_amount=' and f_id in (select f_id from jrnx 
where  '.$filter_year.')';
 
@@ -1574,8 +1573,7 @@
         // set a filter ?
         $search=$p_sql;
 
-        $user=new User($this->cn);
-        $exercice=$user->get_exercice();
+        $exercice=$g_user->get_exercice();
         $tPeriode=new Periode($this->cn);
         list($max,$min)=$tPeriode->get_limit($exercice);
 

Modified: phpcompta/trunk/include/class_impress.php
===================================================================
--- phpcompta/trunk/include/class_impress.php   2012-06-12 22:21:33 UTC (rev 
4883)
+++ phpcompta/trunk/include/class_impress.php   2012-06-13 12:52:31 UTC (rev 
4884)
@@ -43,7 +43,7 @@
      */
     static function 
parse_formula($p_cn,$p_label,$p_formula,$p_start,$p_end,$p_eval=true,$p_type_date=0)
     {
-
+        global $g_user;
         if ( Impress::check_formula($p_formula) == false)
         {
             if ( $p_eval == true)
@@ -96,8 +96,7 @@
                       {
 
                         // retrieve the first month of this periode
-                        $User=new User($p_cn);
-                        $user_periode=$User->get_periode();
+                        $user_periode=$g_user->get_periode();
                         $oPeriode=new Periode($p_cn);
                         $periode=$oPeriode->get_exercice($user_periode);
                         list($first,$last)=$oPeriode->get_limit($periode);
@@ -121,8 +120,7 @@
                             /* if none periode is found
                                then we take the first periode of the year
                             */
-                            $User=new User($p_cn);
-                            $user_periode=$User->get_periode();
+                            $user_periode=$g_user->get_periode();
 
                             $year=$oPeriode->get_exercice($user_periode);
                             list($first,$last)=$oPeriode->get_limit($year);

Modified: phpcompta/trunk/include/export_balance_csv.php
===================================================================
--- phpcompta/trunk/include/export_balance_csv.php      2012-06-12 22:21:33 UTC 
(rev 4883)
+++ phpcompta/trunk/include/export_balance_csv.php      2012-06-13 12:52:31 UTC 
(rev 4884)
@@ -48,7 +48,7 @@
     if (  isset($_GET['r_jrn']))
     {
         $selected=$_GET['r_jrn'];
-        $array_ledger=$User->get_ledger('ALL',3);
+        $array_ledger=$g_user->get_ledger('ALL',3);
         for ($e=0;$e<count($array_ledger);$e++)
         {
             if (isset ($selected[$e]))

Modified: phpcompta/trunk/include/export_balance_pdf.php
===================================================================
--- phpcompta/trunk/include/export_balance_pdf.php      2012-06-12 22:21:33 UTC 
(rev 4883)
+++ phpcompta/trunk/include/export_balance_pdf.php      2012-06-13 12:52:31 UTC 
(rev 4884)
@@ -42,8 +42,7 @@
 $cn=new Database($gDossier);
 $rep=new Database();
 require_once ('class_user.php');
-$User=new User($cn);
-$User->Check();
+$g_user->Check();
 
 $bal=new Acc_Balance($cn);
 
@@ -58,7 +57,7 @@
     if (  isset($_GET['r_jrn']))
     {
         $selected=$_GET['r_jrn'];
-        $array_ledger=$User->get_ledger('ALL',3);
+        $array_ledger=$g_user->get_ledger('ALL',3);
         for ($e=0;$e<count($array_ledger);$e++)
         {
             if (isset ($selected[$e]))

Modified: phpcompta/trunk/include/export_fiche_balance_pdf.php
===================================================================
--- phpcompta/trunk/include/export_fiche_balance_pdf.php        2012-06-12 
22:21:33 UTC (rev 4883)
+++ phpcompta/trunk/include/export_fiche_balance_pdf.php        2012-06-13 
12:52:31 UTC (rev 4884)
@@ -36,9 +36,8 @@
 /* Security */
 $gDossier=dossier::id();
 $cn=new Database($gDossier);
-$User=new User($cn);
-$User->Check();
-$User->check_dossier($gDossier);
+$g_user->Check();
+$g_user->check_dossier($gDossier);
 
 $pdf=new PDF($cn);
 $pdf->setDossierInfo("  Periode : ".$_GET['start']." - ".$_GET['end']);

Modified: phpcompta/trunk/include/export_fiche_pdf.php
===================================================================
--- phpcompta/trunk/include/export_fiche_pdf.php        2012-06-12 22:21:33 UTC 
(rev 4883)
+++ phpcompta/trunk/include/export_fiche_pdf.php        2012-06-13 12:52:31 UTC 
(rev 4884)
@@ -36,9 +36,8 @@
 /* Security */
 $gDossier=dossier::id();
 $cn=new Database($gDossier);
-$User=new User($cn);
-$User->Check();
-$User->check_dossier($gDossier);
+$g_user->Check();
+$g_user->check_dossier($gDossier);
 
 $pdf=new PDF($cn);
 $pdf->setDossierInfo("  Periode : ".$_GET['start']." - ".$_GET['end']);

Modified: phpcompta/trunk/include/export_gl_pdf.php
===================================================================
--- phpcompta/trunk/include/export_gl_pdf.php   2012-06-12 22:21:33 UTC (rev 
4883)
+++ phpcompta/trunk/include/export_gl_pdf.php   2012-06-13 12:52:31 UTC (rev 
4884)
@@ -38,9 +38,8 @@
 
 /* Security */
 $cn=new Database($gDossier);
-$User=new User($cn);
-$User->Check();
-$User->check_dossier($gDossier);
+$g_user->Check();
+$g_user->check_dossier($gDossier);
 
 $sql="select pcm_val from tmp_pcmn ";
 

Modified: phpcompta/trunk/include/export_ledger_csv.php
===================================================================
--- phpcompta/trunk/include/export_ledger_csv.php       2012-06-12 22:21:33 UTC 
(rev 4883)
+++ phpcompta/trunk/include/export_ledger_csv.php       2012-06-13 12:52:31 UTC 
(rev 4884)
@@ -37,11 +37,10 @@
 
 
 require_once ('class_user.php');
-$User=new User($cn);
-$User->Check();
-$User->check_dossier($gDossier);
+$g_user->Check();
+$g_user->check_dossier($gDossier);
 
-if ($_GET['jrn_id']!=0 &&  $User->check_jrn($_GET['jrn_id']) =='X')
+if ($_GET['jrn_id']!=0 &&  $g_user->check_jrn($_GET['jrn_id']) =='X')
 {
     NoAccess();
     exit();

Modified: phpcompta/trunk/include/export_ledger_pdf.php
===================================================================
--- phpcompta/trunk/include/export_ledger_pdf.php       2012-06-12 22:21:33 UTC 
(rev 4883)
+++ phpcompta/trunk/include/export_ledger_pdf.php       2012-06-13 12:52:31 UTC 
(rev 4884)
@@ -52,9 +52,8 @@
 $Jrn=new Acc_Ledger($cn,$_GET['jrn_id']);
 
 $Jrn->get_name();
-$User=new User($cn);
-$User->Check();
-$User->check_dossier($gDossier);
+$g_user->Check();
+$g_user->check_dossier($gDossier);
 
 // Security
 if ( $_GET['jrn_id']!=0 &&  $User->check_jrn($_GET['jrn_id']) == 'X' )

Modified: phpcompta/trunk/include/extension_choice.inc.php
===================================================================
--- phpcompta/trunk/include/extension_choice.inc.php    2012-06-12 22:21:33 UTC 
(rev 4883)
+++ phpcompta/trunk/include/extension_choice.inc.php    2012-06-13 12:52:31 UTC 
(rev 4884)
@@ -13,9 +13,10 @@
 @html_page_start($_SESSION['g_theme']);
 
 $cn=new Database(dossier::id());
-$user=new User($cn);
-$user->check();
-$only_plugin=$user->check_dossier(dossier::id());
+global $g_user;
+$g_user=new User($cn);
+$g_user->check();
+$only_plugin=$g_user->check_dossier(dossier::id());
 
 
 /* javascript file */

Modified: phpcompta/trunk/include/impress_poste.inc.php
===================================================================
--- phpcompta/trunk/include/impress_poste.inc.php       2012-06-12 22:21:33 UTC 
(rev 4883)
+++ phpcompta/trunk/include/impress_poste.inc.php       2012-06-13 12:52:31 UTC 
(rev 4884)
@@ -27,7 +27,7 @@
  * \brief Print account (html or pdf)
  *        file included from user_impress
  *
- * some variable are already defined $cn, $User ...
+ * some variable are already defined $cn, $g_user ...
  *
  */
 //-----------------------------------------------------
@@ -35,7 +35,7 @@
 //-----------------------------------------------------
 require_once('class_database.php');
 require_once('class_ipopup.php');
-global $User;
+global $g_user;
 
 echo IPoste::ipopup('ipop_account');
 echo ICard::ipopup('ipopcard');

Modified: phpcompta/trunk/include/opening.inc.php
===================================================================
--- phpcompta/trunk/include/opening.inc.php     2012-06-12 22:21:33 UTC (rev 
4883)
+++ phpcompta/trunk/include/opening.inc.php     2012-06-13 12:52:31 UTC (rev 
4884)
@@ -33,8 +33,7 @@
 require_once('class_acc_ledger.php');
 
 $sa = (isset($_REQUEST['sa'])) ? $_REQUEST['sa'] : '';
-$User = new User(new Database(dossier::id()));
-$User->Check();
+$g_user->Check();
 
 require_once 'user_menu.php';
 
@@ -103,7 +102,7 @@
        echo '<fieldset><legend> Etape 1 </legend>';
 
        echo 'Choississez le dossier où sont les soldes à importer';
-       $avail = $User->get_available_folder();
+       $avail = $g_user->get_available_folder();
 
        if (empty($avail))
        {
@@ -180,8 +179,8 @@
        echo HtmlInput::hidden('f', $_REQUEST['f']);
        echo HtmlInput::hidden('p_periode', $_REQUEST['p_periode']);
        $wLedger = new ISelect();
-       $User = new User(new Database(dossier::id()));
-       $avail = $User->get_ledger('ODS');
+       $g_user = new User(new Database(dossier::id()));
+       $avail = $g_user->get_ledger('ODS');
        /* compute select list */
        $array = array();
        $i = 0;
@@ -233,7 +232,7 @@
                $idx++;
        }
        $cn = new Database(dossier::id());
-       $User = new User($cn);
+
        $jrn = new Acc_Ledger($cn, $_REQUEST['p_jrn']);
 
        echo '<form class="print" method="post">';

Modified: phpcompta/trunk/include/param_pcmn.inc.php
===================================================================
--- phpcompta/trunk/include/param_pcmn.inc.php  2012-06-12 22:21:33 UTC (rev 
4883)
+++ phpcompta/trunk/include/param_pcmn.inc.php  2012-06-13 12:52:31 UTC (rev 
4884)
@@ -35,9 +35,6 @@
 $cn=new Database($gDossier);
 
 include_once ("class_user.php");
-$User=new User($cn);
-$User->Check();
-$User->check_dossier($gDossier);
 
 include_once ("user_menu.php");
 

Modified: phpcompta/trunk/include/param_sec.inc.php
===================================================================
--- phpcompta/trunk/include/param_sec.inc.php   2012-06-12 22:21:33 UTC (rev 
4883)
+++ phpcompta/trunk/include/param_sec.inc.php   2012-06-13 12:52:31 UTC (rev 
4884)
@@ -36,11 +36,10 @@
 
 /* Admin. Dossier */
 $cn=new Database($gDossier);
-$User=new User($cn);
+global $g_user;
+$g_user->Check();
+$g_user->check_dossier($gDossier);
 
-$User->Check();
-$User->check_dossier($gDossier);
-
 include_once ("user_menu.php");
 
 /////////////////////////////////////////////////////////////////////////

Modified: phpcompta/trunk/include/preod.inc.php
===================================================================
--- phpcompta/trunk/include/preod.inc.php       2012-06-12 22:21:33 UTC (rev 
4883)
+++ phpcompta/trunk/include/preod.inc.php       2012-06-13 12:52:31 UTC (rev 
4884)
@@ -29,7 +29,6 @@
 require_once('class_database.php');
 require_once('ac_common.php');
 require_once('class_pre_operation.php');
-$user=new User(new Database(dossier::id()));
 echo '<div class="content">';
 echo '<form method="GET">';
 $sel=new ISelect();

Modified: phpcompta/trunk/include/report.inc.php
===================================================================
--- phpcompta/trunk/include/report.inc.php      2012-06-12 22:21:33 UTC (rev 
4883)
+++ phpcompta/trunk/include/report.inc.php      2012-06-13 12:52:31 UTC (rev 
4884)
@@ -39,10 +39,7 @@
 /* Admin. Dossier */
 $rep=new Database($gDossier);
 
-$User=new User($rep);
-$User->Check();
 
-
 $cn=new Database($gDossier);
 
 $rap=new Acc_Report($cn);

Modified: phpcompta/trunk/include/search.inc.php
===================================================================
--- phpcompta/trunk/include/search.inc.php      2012-06-12 22:21:33 UTC (rev 
4883)
+++ phpcompta/trunk/include/search.inc.php      2012-06-13 12:52:31 UTC (rev 
4884)
@@ -33,9 +33,6 @@
 
 $cn=new Database($gDossier);
 include_once ('class_user.php');
-$User=new User($cn);
-$User->Check();
-$act=$User->check_dossier($gDossier);
 // display a search box
 
 
@@ -104,7 +101,7 @@
        if ( ! isset ($array['date_start']) || ! isset ($array['date_end']))
        {
                // get first date of current exercice
-               
list($array['date_start'],$array['date_end'])=$User->get_limit_current_exercice();
+               
list($array['date_start'],$array['date_end'])=$g_user->get_limit_current_exercice();
        }
 
     list($sql,$where)=$ledger->build_search_sql($array);

Modified: phpcompta/trunk/include/user_common.php
===================================================================
--- phpcompta/trunk/include/user_common.php     2012-06-12 22:21:33 UTC (rev 
4883)
+++ phpcompta/trunk/include/user_common.php     2012-06-13 12:52:31 UTC (rev 
4884)
@@ -51,7 +51,7 @@
  */
 function InsertStockGoods($p_cn,$p_j_id,$p_good,$p_quant,$p_type)
 {
-
+    global $g_user;
     // Retrieve the good account for stock
     $code=new Fiche($p_cn);
     $code->get_by_qcode($p_good);
@@ -61,8 +61,7 @@
     $Res=$p_cn->exec_sql($sql);
     $r=Database::fetch_array($Res,0);
     $f_id=$r['f_id'];
-    $user=new User($p_cn);
-    $exercice=$user->get_exercice();
+    $exercice=$g_user->get_exercice();
     if ( $exercice == 0 ) throw new Exception ('Annee invalide erreur');
 
 

Modified: phpcompta/trunk/include/verif_bilan.inc.php
===================================================================
--- phpcompta/trunk/include/verif_bilan.inc.php 2012-06-12 22:21:33 UTC (rev 
4883)
+++ phpcompta/trunk/include/verif_bilan.inc.php 2012-06-13 12:52:31 UTC (rev 
4884)
@@ -28,11 +28,10 @@
 require_once('class_acc_bilan.php');
 
 $cn=new Database(dossier::id());
-$User=new User($cn);
-$exercice=$User->get_exercice();
+$exercice=$g_user->get_exercice();
 echo '<div class="content">';
-$User->db=$cn;
-$sql_year=" and j_tech_per in (select p_id from parm_periode where 
p_exercice='".$User->get_exercice()."')";
+
+$sql_year=" and j_tech_per in (select p_id from parm_periode where 
p_exercice='".$g_user->get_exercice()."')";
 echo '<fieldset><legend>Vérification des journaux</legend>';
 echo '<ol>';
 $deb=$cn->get_value("select sum (j_montant) from jrnx where j_debit='t' 
$sql_year ");



---
PhpCompta est un logiciel de comptabilité libre en ligne (full web)
Projet opensource http://www.phpcompta.eu



reply via email to

[Prev in Thread] Current Thread [Next in Thread]