'.$p_value;
- $p_buffer=preg_replace($searched, $replaced, $p_buffer,$p_limit,$count);
+ $p_buffer=preg_replace($searched, $replaced, $p_buffer, $p_limit, $count);
}
}
- if ($count == 0)
+ if ($count==0)
{
- if ( $p_type=='OOo' )
+ if ($p_type=='OOo')
{
- $p_value=str_replace('&','&',$p_value);
- $p_value=str_replace('<','<',$p_value);
- $p_value=str_replace('>','>',$p_value);
- $p_value=str_replace('"','"',$p_value);
- $p_value=str_replace("'",''',$p_value);
+ $p_value=str_replace('&', '&', $p_value);
+ $p_value=str_replace('<', '<', $p_value);
+ $p_value=str_replace('>', '>', $p_value);
+ $p_value=str_replace('"', '"', $p_value);
+ $p_value=str_replace("'", ''', $p_value);
}
- $p_buffer=preg_replace('/'.$p_pattern.'/i', $p_value, $p_buffer,$p_limit);
+ $p_buffer=preg_replace('/'.$p_pattern.'/i', $p_value, $p_buffer, $p_limit);
}
return $p_buffer;
}
diff --git a/include/class/fiche.class.php b/include/class/fiche.class.php
index 631e24c51..f2f8a01e7 100644
--- a/include/class/fiche.class.php
+++ b/include/class/fiche.class.php
@@ -53,14 +53,49 @@ class Fiche
var $fiche_def_ref; /*!< $fiche_def_ref Type */
var $row; /*! < All the row from the ledgers */
var $quick_code; /*!< quick_code of the card */
+ private $f_enable; /*!< if card is enable (fiche.f_enable) */
function __construct($p_cn,$p_id=0)
{
$this->cn=$p_cn;
$this->id=$p_id;
$this->quick_code='';
$this->attribut=array();
+ $f_enable='1';
}
- /**
+ public function get_id()
+ {
+ return $this->id;
+ }
+
+ public function get_fiche_def_ref()
+ {
+ return $this->fiche_def_ref;
+ }
+
+ public function get_f_enable()
+ {
+ return $this->f_enable;
+ }
+
+ public function set_id($id)
+ {
+ $this->id=$id;
+ return $this;
+ }
+
+ public function set_fiche_def_ref($fiche_def_ref)
+ {
+ $this->fiche_def_ref=$fiche_def_ref;
+ return $this;
+ }
+
+ public function set_f_enable($f_enable)
+ {
+ $this->f_enable=$f_enable;
+ return $this;
+ }
+
+ /**
*@brief used with a usort function, to sort an array of Fiche on the name
*/
static function cmp_name(Fiche $o1,Fiche $o2)
@@ -168,6 +203,7 @@ class Fiche
{
$row=Database::fetch_array($Ret,$i);
$this->fiche_def=$row['fd_id'];
+ $this->f_enable=$row['f_enable'];
$t=new Fiche_Attr ($this->cn);
$t->ad_id=$row['ad_id'];
$t->ad_text=$row['ad_text'];
@@ -581,7 +617,7 @@ class Fiche
{
return 'FNT';
}
-
+
/* for each attribute */
foreach ($attr as $r)
{
@@ -749,7 +785,16 @@ class Fiche
}
$ret.="".td(_($r->ad_text).$bulle,'class="'.$class.'"').td($w->input()." ".$msg)."
";
}
-
+ // Display if the card is enable or not
+ $enable_is=new InputSwitch("f_enable");
+ $enable_is->value=$this->f_enable;
+ $enable_is->readOnly=$p_readonly;
+
+ $ret.=tr(
+ td(_("Actif")).td($enable_is->input())
+ );
+
+
$ret.="";
return $ret;
@@ -801,9 +846,10 @@ class Fiche
try
{
$this->cn->start();
- $sql=sprintf("insert into fiche(f_id,fd_id)".
- " values (%d,%d)", $fiche_id, $p_fiche_def);
- $Ret=$this->cn->exec_sql($sql);
+
+ $Ret=$this->cn->exec_sql("insert into fiche(f_id,f_enable,fd_id) value ($1,$2,$3)",
+ array($fiche_id, $p_array['f_enable'],$p_fiche_def));
+
// parse the $p_array array
foreach ($p_array as $name=> $value)
{
@@ -961,6 +1007,9 @@ class Fiche
try
{
$this->cn->start();
+
+ $this->cn->exec_sql("update fiche set f_enable=$1 where f_id=$2",array($p_array['f_enable'],$this->id));
+
// parse the $p_array array
foreach ($p_array as $name=> $value)
{
diff --git a/include/class/follow_up.class.php b/include/class/follow_up.class.php
index 7a57316ee..1be594160 100644
--- a/include/class/follow_up.class.php
+++ b/include/class/follow_up.class.php
@@ -596,9 +596,9 @@ class Follow_Up
$act->save();
}
- /* Upload the documents */
+ /* upload the documents */
$doc=new Document($this->db);
- $doc->Upload($this->ag_id);
+ $doc->upload($this->ag_id);
if (trim($this->ag_comment)!='' && Document_Option::can_add_comment($this->ag_id))
{
$this->db->exec_sql("insert into action_gestion_comment (ag_id,tech_user,agc_comment) values ($1,$2,$3)"
@@ -905,9 +905,9 @@ class Follow_Up
$this->ag_ref /* 11 */
));
}
- // Upload documents
+ // upload documents
$doc=new Document($this->db);
- $doc->Upload($this->ag_id);
+ $doc->upload($this->ag_id);
/* save action details */
$http=new HttpInput();
diff --git a/include/class/user.class.php b/include/class/user.class.php
index 2190bb048..3ad5bfefb 100644
--- a/include/class/user.class.php
+++ b/include/class/user.class.php
@@ -190,7 +190,8 @@ class User
if ($res == 0)
{
- $cn->exec_sql($sql, array($_SESSION[SESSION_KEY.'g_user'], $_SERVER["REMOTE_ADDR"], $from, $_SERVER['REQUEST_URI'], 'FAIL'));
+ $cn->exec_sql($sql, array($_SESSION[SESSION_KEY.'g_user'], $_SERVER["REMOTE_ADDR"],
+ $from, $_SERVER['REQUEST_URI'], 'FAIL'));
if (!$silent)
{
echo '';
@@ -203,7 +204,8 @@ class User
else
{
if ($from == 'LOGIN')
- $cn->exec_sql($sql, array($_SESSION[SESSION_KEY.'g_user'], $_SERVER["REMOTE_ADDR"], $from, $_SERVER['REQUEST_URI'], 'SUCCESS'));
+ $cn->exec_sql($sql, array($_SESSION[SESSION_KEY.'g_user'], $_SERVER["REMOTE_ADDR"], $from,
+ $_SERVER['REQUEST_URI'], 'SUCCESS'));
$this->valid = 1;
}
@@ -249,7 +251,8 @@ class User
if ($priv)
{
// the access is granted
- $jnt=$cn->get_value("select jnt_id from jnt_use_dos where dos_id=$1 and use_id=$2", array($db_id, $this->id));
+ $jnt=$cn->get_value("select jnt_id from jnt_use_dos where dos_id=$1 and use_id=$2",
+ array($db_id, $this->id));
if ($cn->size()==0)
{
@@ -312,6 +315,11 @@ class User
function get_ledger($p_type = 'ALL', $p_access = 3,$disable=TRUE)
{
+ $p_type=strtoupper($p_type);
+ if (! in_array($p_type, ["FIN","ALL","ODS","VEN",'ACH'])) {
+ record_log(sprintf("UGL1, p_type %s",$p_type));
+ throw new Exception("UGL1"._("Type incorrecte"));
+ }
if ($disable==TRUE) {
$sql_enable="";
} else {
@@ -419,22 +427,26 @@ class User
function set_periode($p_periode)
{
- $sql = "update user_local_pref set parameter_value='$p_periode' where user_id='$this->id' and parameter_type='PERIODE'";
- $Res = $this->db->exec_sql($sql);
+ $sql = "update user_local_pref set parameter_value=$1 where user_id=$2 and parameter_type='PERIODE'";
+ $Res = $this->db->exec_sql($sql,[$p_periode,$this->id]);
}
private function set_default_periode()
{
/* get the first periode */
- $sql = 'select min(p_id) as pid from parm_periode where p_closed = false and p_start = (select min(p_start) from parm_periode)';
+ $sql = 'select min(p_id) as pid '
+ . ' from parm_periode '
+ . ' where p_closed = false and p_start = (select min(p_start) from parm_periode)';
$Res = $this->db->exec_sql($sql);
$pid = Database::fetch_result($Res, 0, 0);
/* if all the periode are closed, then we use the last closed period */
if ($pid == null)
{
- $sql = 'select min(p_id) as pid from parm_periode where p_start = (select max(p_start) from parm_periode)';
+ $sql = 'select min(p_id) as pid '
+ . 'from parm_periode '
+ . 'where p_start = (select max(p_start) from parm_periode)';
$Res2 = $this->db->exec_sql($sql);
$pid = Database::fetch_result($Res2, 0, 0);
if ($pid == null)
@@ -532,7 +544,6 @@ class User
* \brief Get the default user's preferences
* \return array of (parameter_type => parameter_value)
*/
-
function get_preference()
{
$sql = "select parameter_type,parameter_value from user_local_pref where user_id=$1";
@@ -544,7 +555,16 @@ class User
$type = $row['parameter_type'];
$l_array[$type] = $row['parameter_value'];
}
-
+ $repo=new Database();
+ $a_global_pref=$repo->get_array("select parameter_type,parameter_value from user_global_pref
+ where
+ upper(user_id) = upper($1)",[$this->login]);
+ $nb_global=count($a_global_pref);
+ for ( $i = 0 ;$i< $nb_global ; $i++) {
+ $idx=$a_global_pref[$i]['parameter_type'];
+ $value=$a_global_pref[$i]['parameter_value'];
+ $l_array[$idx]=$value;
+ }
return $l_array;
}
@@ -601,9 +621,9 @@ class User
}
return 0;
}
- if ($Count == 1)
- return 1;
- echo " Action Invalide !!! $Count select * from user_sec_act where ua_login='$p_login' and ua_act_id=$p_action_id
";
+ if ($Count == 1) return 1;
+ echo_error(_("Action invalide"));
+ record_log("User:check_action".sprintf("login %s ua_act_id %s",$this->login,$p_action_id));
exit();
}
@@ -620,7 +640,7 @@ class User
// Load everything in an array
$Res = $cn->exec_sql("select parameter_type,parameter_value from
user_global_pref
- where user_id='" . $this->login . "'");
+ where user_id=$1",[$this->login]);
$Max = Database::num_row($Res);
if ($Max == 0)
{
@@ -635,7 +655,6 @@ class User
$row = Database::fetch_array($Res, $i);
$type = $row['parameter_type'];
$line[$type] = $row['parameter_value'];
- ;
}
// save array into g_ variable
$array_pref = array('g_theme' => 'THEME',
@@ -756,18 +775,17 @@ class User
$this->audit('FAIL');
if ($p_js == 1)
{
- echo "";
+ echo create_script("alert_box(content[59])");
}
elseif ($p_js == 2) {
record_log(_("Access invalid").$p_action);
}
else
{
- echo '';
- echo '
Cette action ne vous est pas autorisée Contactez votre responsable
';
- echo '';
+ echo '',
+ htmlspecialchars(_("Cette action ne vous est pas autorisée Contactez votre responsable")),
+ '
';
+ echo '';
}
exit(-1);
}
@@ -797,7 +815,6 @@ class User
* \param $p_action requested action
* \return nothing the program exits automatically
*/
-
function can_print($p_action, $p_js = 0)
{
if ($this->check_print($p_action) == 0)
@@ -805,15 +822,15 @@ class User
$this->audit('FAIL');
if ($p_js == 1)
{
- echo "";
+ echo create_script("alert_box(content[59])");
}
else
{
- echo '';
- echo '
Cette action ne vous est pas autorisée Contactez votre responsable
';
- echo '';
+ echo '';
+ echo '
',
+ htmlspecialchars(_("Cette action ne vous est pas autorisée Contactez votre responsable")),
+ '
';
+ echo '';
}
exit(-1);
}
diff --git a/include/company.inc.php b/include/company.inc.php
index 2bd6ae279..0f585a457 100644
--- a/include/company.inc.php
+++ b/include/company.inc.php
@@ -50,7 +50,7 @@ if (isset($_POST['record_company']))
$m->MY_STOCK =$http->post("p_stock");
$m->MY_ANC_FILTER=$http->post("p_anc_filter");
try {
- $m->Update();
+ $m->update();
} catch (Exception $e) {
alert($e->getMessage());
}
diff --git a/include/export/export_document.php b/include/export/export_document.php
index fcc6ecbdb..1fd7d71b1 100644
--- a/include/export/export_document.php
+++ b/include/export/export_document.php
@@ -45,7 +45,7 @@ if ($action == 'sh')
$d_id=$http->request('d_id',"number");
// retrieve the document
$doc = new Document($cn, $d_id);
- $doc->Send();
+ $doc->send();
}
}
/* remove the document */
diff --git a/include/lib/sort_table.class.php b/include/lib/sort_table.class.php
index 6cbfcaae9..f981284e1 100644
--- a/include/lib/sort_table.class.php
+++ b/include/lib/sort_table.class.php
@@ -68,7 +68,7 @@ class Sort_Table
{
if ($p_ind < 0 || $p_ind > $this->nb)
return 'ERREUR TRI';
- $file = str_replace('extension.php', '', $_SERVER['SCRIPT_FILENAME']);
+ $file = str_replace('extension.php', '', $_SERVER['PHP_SELF']);
$base = $this->array[$p_ind]['url'];
$str = '';
diff --git a/include/lib/user_common.php b/include/lib/user_common.php
index 5a2be362a..9b05639d0 100644
--- a/include/lib/user_common.php
+++ b/include/lib/user_common.php
@@ -115,7 +115,7 @@ function navigation_bar($p_offset,$p_line,$p_size=0,$p_page=1,$p_javascript="")
$step=$p_size;
$offset=($e-1)*$step;
- $r='';
+ $r='';
$r.=" ←";
// $r.='';
$r.=" ";
@@ -181,35 +181,6 @@ function CleanUrl()
{
// Compute the url
$url=http_build_query($_GET);
- /* $get=$_GET;
- if ( isset ($get) )
- {
- foreach ($get as $name=>$value )
- {
- // we clean the parameter offset, step, page and size
- if ( ! in_array($name,array('offset','step','page','size','s','o','r_jrn')))
- {
- if (is_array($name)) {
-
- } else {
- $url.=$and.$name."=".$value;
- }
- $and="&";
- }// if
- }//foreach
- if ( isset($_GET['r_jrn']))
- {
- $r_jrn=$_GET['r_jrn'];
- if (count($r_jrn) > 0 )
- {
- foreach ($r_jrn as $key=>$value)
- {
- $url.=$and."r_jrn[$key]=".$value;
- $and="&";
- }
- }
- }
- }// if*/
return $url;
}
function redirect($p_string,$p_time=0)
@@ -219,7 +190,8 @@ function redirect($p_string,$p_time=0)
}
echo ' Connecting... ';
}
-/*!\brief remove the useless space, change comma by period and try to return
+/*!
+ * \brief remove the useless space, change comma by period and try to return
* a number
*\param $p_num number to format
*\return the formatted number
diff --git a/include/template/menu.php b/include/template/menu.php
index 5c46026a7..ab2c2b824 100644
--- a/include/template/menu.php
+++ b/include/template/menu.php
@@ -1,25 +1,31 @@