diff --git a/html/ajax.php b/html/ajax.php index d955a0749..542cec329 100644 --- a/html/ajax.php +++ b/html/ajax.php @@ -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']) ) diff --git a/html/ajax_card.php b/html/ajax_card.php index 92ea7ec1c..dbb36c0f6 100644 --- a/html/ajax_card.php +++ b/html/ajax_card.php @@ -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); } diff --git a/html/ajax_history.php b/html/ajax_history.php index 19ba4b4d7..f8f34d48e 100644 --- a/html/ajax_history.php +++ b/html/ajax_history.php @@ -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"; diff --git a/html/ajax_ledger.php b/html/ajax_ledger.php index dc4f4d3d2..63ec3df8d 100644 --- a/html/ajax_ledger.php +++ b/html/ajax_ledger.php @@ -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(); diff --git a/html/ajax_misc.php b/html/ajax_misc.php index 913a5e359..d5ed12b59 100644 --- a/html/ajax_misc.php +++ b/html/ajax_misc.php @@ -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); diff --git a/html/ajax_poste.php b/html/ajax_poste.php index 95b8ffc14..5641ab5e1 100644 --- a/html/ajax_poste.php +++ b/html/ajax_poste.php @@ -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) diff --git a/html/ajax_todo_list.php b/html/ajax_todo_list.php index e00e2bacb..0e723c074 100644 --- a/html/ajax_todo_list.php +++ b/html/ajax_todo_list.php @@ -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'])) diff --git a/html/direct.php b/html/direct.php index bae501119..7f7274df5 100644 --- a/html/direct.php +++ b/html/direct.php @@ -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 "
| Quickcode'.$info.' | '. @@ -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 ". diff --git a/include/class_acc_ledger_fin.php b/include/class_acc_ledger_fin.php index 9292efa3a..67c0ca2f0 100644 --- a/include/class_acc_ledger_fin.php +++ b/include/class_acc_ledger_fin.php @@ -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'". diff --git a/include/class_acc_ledger_purchase.php b/include/class_acc_ledger_purchase.php index 8e300ee90..8e7652846 100644 --- a/include/class_acc_ledger_purchase.php +++ b/include/class_acc_ledger_purchase.php @@ -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; diff --git a/include/class_acc_ledger_sold.php b/include/class_acc_ledger_sold.php index daa97aae6..d0079220c 100644 --- a/include/class_acc_ledger_sold.php +++ b/include/class_acc_ledger_sold.php @@ -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; diff --git a/include/class_acc_operation.php b/include/class_acc_operation.php index bce51680f..11d42fd64 100644 --- a/include/class_acc_operation.php +++ b/include/class_acc_operation.php @@ -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, diff --git a/include/class_acc_reconciliation.php b/include/class_acc_reconciliation.php index ad9bad7b2..bacc663e0 100644 --- a/include/class_acc_reconciliation.php +++ b/include/class_acc_reconciliation.php @@ -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) { diff --git a/include/class_anticipation.php b/include/class_anticipation.php index 3e008033a..6fe2b1b86 100644 --- a/include/class_anticipation.php +++ b/include/class_anticipation.php @@ -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(); diff --git a/include/class_calendar.php b/include/class_calendar.php index 4c9bb554a..edeb2ee42 100644 --- a/include/class_calendar.php +++ b/include/class_calendar.php @@ -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; } /** diff --git a/include/class_fiche.php b/include/class_fiche.php index 18b781c30..974d7d6c1 100644 --- a/include/class_fiche.php +++ b/include/class_fiche.php @@ -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); diff --git a/include/class_impress.php b/include/class_impress.php index b99e75157..6ebaed193 100644 --- a/include/class_impress.php +++ b/include/class_impress.php @@ -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); diff --git a/include/export_balance_csv.php b/include/export_balance_csv.php index 7cdbbd527..bd6e9d910 100644 --- a/include/export_balance_csv.php +++ b/include/export_balance_csv.php @@ -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
|---|