Code quality : use as often as possible global $g_user instead of recreating a new User object

This commit is contained in:
Dany De Bontridder 2012-06-13 12:52:31 +00:00
parent d86a5d4a44
commit 652cf8d4c7
50 changed files with 221 additions and 255 deletions

View file

@ -15,8 +15,9 @@ if ( !isset ($_REQUEST['gDossier'])) exit();
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']) )

View file

@ -87,9 +87,10 @@ set_language();
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 @@ switch($op)
/* 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 @@ case 'dc':
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 @@ case 'dc':
/* 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 'st':
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 @@ case 'fs':
$html=$r;
break;
case 'ac':
if ( $user->check_action(FICCAT)==1 )
if ( $g_user->check_action(FICCAT)==1 )
{
/*----------------------------------------------------------------------
@ -433,7 +434,7 @@ case 'scc':
*
*----------------------------------------------------------------------*/
$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 @@ case 'upc':
$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);
}

View file

@ -38,12 +38,10 @@ mb_internal_encoding("UTF-8");
*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 @@ if ( isset($_GET['f_id']))
$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($_GET['f_id']))
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";

View file

@ -64,9 +64,10 @@ $cn=new Database(dossier::id());
$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 @@ EOF;
$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();

View file

@ -57,22 +57,21 @@ if ($cont != 0)
exit();
extract($_REQUEST);
set_language();
$cn = new Database($gDossier);
$user = new User($cn);
$user->check(true);
$user->check_dossier($gDossier, true);
$html = var_export($_REQUEST, true);
global $g_user;
$g_user=$user;
$cn = new Database($gDossier);
$g_user = new User($cn);
$g_user->check(true);
$g_user->check_dossier($gDossier, true);
$html = var_export($_REQUEST, true);
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 @@ EOF;
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 @@ EOF;
*/
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);

View file

@ -59,9 +59,10 @@ set_language();
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)

View file

@ -41,9 +41,10 @@ require_once ('class_user.php');
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']))

View file

@ -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++)

View file

@ -36,9 +36,10 @@ require_once ('constant.security.php');
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);

View file

@ -44,9 +44,10 @@ $gDossier=dossier::id();
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';

View file

@ -50,9 +50,10 @@ $d=$_REQUEST['e'];
$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)
{

View file

@ -10,14 +10,14 @@ require_once('class_periode.php');
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);

View file

@ -38,9 +38,10 @@ require_once('class_database.php');
$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')
{

View file

@ -32,14 +32,15 @@ $cn=new Database($gDossier);
$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 @@ if ( $action == 'sh')
/* 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 == 'rm' )
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 == 'rmop' )
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 @@ if ( $action == 'rmcomment' )
/* 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']));

View file

@ -32,11 +32,10 @@ $cn=new Database($gDossier);
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']));

View file

@ -41,9 +41,10 @@ $cn=new Database($gDossier);
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 @@ if ( Database::num_row($r) == 0 )
$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();

View file

@ -43,21 +43,19 @@ else
$cn=new Database();
}
$User=new User($cn);
$User->Check();
global $g_user;
// 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 @@ html_page_start($_SESSION['g_theme']);
// 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['p_size']) )
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

View file

@ -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",

View file

@ -49,10 +49,7 @@ foreach ( array('j','ctl') as $a )
}
}
$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 ".

View file

@ -50,9 +50,7 @@ if ( is_numeric($l) == false )
{
exit();
}
$cn=new Database(dossier::id());
$User=new User($cn);
$User->Check();
$Ledger=new Acc_Ledger($cn,$l);
$prop=$Ledger->get_propertie();

View file

@ -24,7 +24,7 @@ require_once('class_periode.php');
/* !\file
* \brief display or save a periode
* variable received $op, $cn $user
* variable received $op, $cn $g_user
*/
$err = 0;
$html = '';

View file

@ -110,8 +110,8 @@ class Acc_Account_Ledger
*/
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)
{

View file

@ -60,7 +60,7 @@ class Acc_Balance
*/
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 @@ class Acc_Balance
/* if several ledgers are asked then we filter here */
if ($this->jrn!== null)
{
$user=new User($this->db);
/**
*@file
*@bug the get_ledger here is not valid and useless we just need a list of the
@ -100,8 +99,7 @@ class Acc_Balance
$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

View file

@ -170,10 +170,10 @@ class Acc_Ledger extends jrn_def_sql
*/
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 @@ class Acc_Ledger extends jrn_def_sql
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 @@ class Acc_Ledger extends jrn_def_sql
*/
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 @@ class Acc_Ledger extends jrn_def_sql
*/
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 @@ class Acc_Ledger extends jrn_def_sql
*/
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 @@ class Acc_Ledger extends jrn_def_sql
*/
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 @@ class Acc_Ledger extends jrn_def_sql
*/
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 @@ class Acc_Ledger extends jrn_def_sql
*/
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 @@ class Acc_Ledger extends jrn_def_sql
$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 @@ class Acc_Ledger extends jrn_def_sql
//--
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 @@ class Acc_Ledger extends jrn_def_sql
$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 @@ class Acc_Ledger extends jrn_def_sql
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 @@ class Acc_Ledger extends jrn_def_sql
*/
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 @@ class Acc_Ledger extends jrn_def_sql
*/
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 @@ class Acc_Ledger extends jrn_def_sql
}
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 @@ class Acc_Ledger extends jrn_def_sql
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 @@ class Acc_Ledger extends jrn_def_sql
$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 @@ class Acc_Ledger extends jrn_def_sql
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 @@ class Acc_Ledger extends jrn_def_sql
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 @@ class Acc_Ledger extends jrn_def_sql
$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 @@ class Acc_Ledger extends jrn_def_sql
*/
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 ".

View file

@ -51,14 +51,14 @@ class Acc_Ledger_Fin extends Acc_Ledger
*/
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 @@ class Acc_Ledger_Fin extends Acc_Ledger
*/
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 @@ class Acc_Ledger_Fin extends Acc_Ledger
{
// 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 @@ class Acc_Ledger_Fin extends Acc_Ledger
*/
function show_ledger()
{
global $g_user;
echo dossier::hidden();
$hid=new IHidden();
@ -886,11 +886,10 @@ class Acc_Ledger_Fin extends Acc_Ledger
$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 @@ class Acc_Ledger_Fin extends Acc_Ledger
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'".

View file

@ -60,11 +60,10 @@ class Acc_Ledger_Purchase extends Acc_Ledger
*/
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 @@ class Acc_Ledger_Purchase extends Acc_Ledger
*/
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 @@ class Acc_Ledger_Purchase extends Acc_Ledger
$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 @@ class Acc_Ledger_Purchase extends Acc_Ledger
{
// 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;

View file

@ -58,15 +58,14 @@ class Acc_Ledger_Sold extends Acc_Ledger
*/
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 @@ class Acc_Ledger_Sold extends Acc_Ledger
*/
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 @@ class Acc_Ledger_Sold extends Acc_Ledger
$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 @@ class Acc_Ledger_Sold extends Acc_Ledger
//--
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;

View file

@ -50,11 +50,11 @@ class Acc_Operation
*/
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 @@ class Acc_Operation
*/
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,

View file

@ -281,9 +281,9 @@ j1.j_poste as poste
*/
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 @@ j1.j_poste as poste
*/
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)
{

View file

@ -194,7 +194,6 @@ class Anticipation
*/
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 @@ class Anticipation
$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 @@ class Anticipation
$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 @@ class Anticipation
*/
private function form_cat_new()
{
$user=new User($this->cn);
global $g_user;
$r="";
$str_action=_('Nouveau');
@ -268,7 +267,7 @@ class Anticipation
$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 @@ class Anticipation
$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();

View file

@ -135,6 +135,7 @@ class Calendar
*/
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 @@ class Calendar
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;
}
/**

View file

@ -71,9 +71,8 @@ class Fiche
*/
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 @@ class Fiche
*/
function update($p_array=null)
{
global $g_user;
if ( $p_array == null)
$p_array=$_POST;
@ -917,8 +917,7 @@ class Fiche
" 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 @@ class Fiche
*/
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 @@ class Fiche
*/
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 @@ class Fiche
// 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);

View file

@ -43,7 +43,7 @@ class Impress
*/
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 @@ class Impress
{
// 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 @@ class Impress
/* 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);

View file

@ -48,7 +48,7 @@ case 1:
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]))

View file

@ -42,8 +42,7 @@ $gDossier=dossier::id();
$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 @@ case 1:
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]))

View file

@ -36,9 +36,8 @@ require_once('ac_common.php');
/* 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']);

View file

@ -36,9 +36,8 @@ require_once('ac_common.php');
/* 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']);

View file

@ -38,9 +38,8 @@ $gDossier=dossier::id();
/* 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 ";

View file

@ -37,11 +37,10 @@ $cn=new Database($gDossier);
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();

View file

@ -52,9 +52,8 @@ $own=new Own($cn);
$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' )

View file

@ -13,9 +13,10 @@ echo '<div class="topmenu">';
@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 */

View file

@ -27,7 +27,7 @@ require_once('class_acc_operation.php');
* \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_acc_operation.php');
//-----------------------------------------------------
require_once('class_database.php');
require_once('class_ipopup.php');
global $User;
global $g_user;
echo IPoste::ipopup('ipop_account');
echo ICard::ipopup('ipopcard');

View file

@ -33,8 +33,7 @@ require_once("class_iselect.php");
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 @@ if ($sa == '')
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 @@ if ($sa == 'step3')
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 @@ if ($sa == 'step4')
$idx++;
}
$cn = new Database(dossier::id());
$User = new User($cn);
$jrn = new Acc_Ledger($cn, $_REQUEST['p_jrn']);
echo '<form class="print" method="post">';

View file

@ -35,9 +35,6 @@ require_once('class_database.php');
$cn=new Database($gDossier);
include_once ("class_user.php");
$User=new User($cn);
$User->Check();
$User->check_dossier($gDossier);
include_once ("user_menu.php");

View file

@ -36,10 +36,9 @@ $str_dossier=dossier::get();
/* Admin. Dossier */
$cn=new Database($gDossier);
$User=new User($cn);
$User->Check();
$User->check_dossier($gDossier);
global $g_user;
$g_user->Check();
$g_user->check_dossier($gDossier);
include_once ("user_menu.php");

View file

@ -29,7 +29,6 @@ require_once("class_ihidden.php");
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();

View file

@ -39,9 +39,6 @@ $str_dossier=dossier::get();
/* Admin. Dossier */
$rep=new Database($gDossier);
$User=new User($rep);
$User->Check();
$cn=new Database($gDossier);

View file

@ -33,9 +33,6 @@ require_once('class_database.php');
$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 ($_GET['viewsearch']) )
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);

View file

@ -51,7 +51,7 @@ require_once("class_acc_operation.php");
*/
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 @@ function InsertStockGoods($p_cn,$p_j_id,$p_good,$p_quant,$p_type)
$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');

View file

@ -28,11 +28,10 @@ require_once ('class_user.php');
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 ");