diff --git a/html/comptanalytic.php b/html/comptanalytic.php
index 096c784e2..1485889e5 100644
--- a/html/comptanalytic.php
+++ b/html/comptanalytic.php
@@ -44,15 +44,18 @@ html_page_start($_SESSION['g_theme']);
//-----------------------------------------------------------------
//Header
echo '
';
@@ -110,6 +114,12 @@ if ($_REQUEST['p_action'] == 'ca_od' )
require_once('ca_od.inc.php');
exit();
}
+// Impression
+if ($_REQUEST['p_action'] == 'ca_groupe' )
+ {
+ require_once('ca_groupe.inc.php');
+ exit();
+ }
// Impression
if ($_REQUEST['p_action'] == 'ca_imp' )
diff --git a/html/style-color.css b/html/style-color.css
index 368cc0fac..c0cfbf8d3 100644
--- a/html/style-color.css
+++ b/html/style-color.css
@@ -147,7 +147,6 @@ div.u_redcontent{
div.u_content{
position: float;
float:left;
- width:100%;
font-size:9px;
font-family:sans-serif;
background-color:lightgreen;
diff --git a/html/style-light.css b/html/style-light.css
index 027d1e95f..32efc6f9c 100644
--- a/html/style-light.css
+++ b/html/style-light.css
@@ -151,7 +151,6 @@ div.u_redcontent{
div.u_content{
position: float;
float:left;
- width:100%;
padding-top:7px;
width:100%;
font-size:9px;
diff --git a/include/ca_pa.inc.php b/include/ca_pa.inc.php
index 227a2f4cf..39c4446a0 100644
--- a/include/ca_pa.inc.php
+++ b/include/ca_pa.inc.php
@@ -203,6 +203,7 @@ if ( isset($_REQUEST['sa']))
$ret.=" Nom ";
$ret.=" | Montant ";
$ret.=" | Description ";
+ $ret.=" | Groupe | ";
$ret.=" Plan A ";
$ret.="";
$class="";
@@ -223,6 +224,7 @@ if ( isset($_REQUEST['sa']))
"";
$ret.=" | ".$obj->amount." | ";
$ret.="".$obj->description." | ";
+ $ret.="".$obj->ga_id." | ";
$ret.="".$new->name." | ";
$ret.="";
diff --git a/include/class_poste_analytic.php b/include/class_poste_analytic.php
index aca223528..1d9d438b6 100644
--- a/include/class_poste_analytic.php
+++ b/include/class_poste_analytic.php
@@ -33,13 +33,12 @@ require_once("class_plananalytic.php");
class Poste_analytique
{
var $id; /*!< $id is po_id */
- var $name; /*!< po_name */
- var $pa_id; /*!< pa_id fk to the plan_analytique(pa_id) */
- var $amount; /*!< po_amount just an amount */
- var $description; /*!< po_description description of
- the post */
- var $db; /*!< database connection */
-
+ var $name; /*!< po_name */
+ var $pa_id; /*!< pa_id fk to the plan_analytique(pa_id) */
+ var $amount; /*!< po_amount just an amount */
+ var $description; /*!< po_description description of the post */
+ var $db; /*!< database connection*/
+ var $ga_id; /*!< FK to the table groupe analytique */
function Poste_analytique($p_db,$p_id=0)
{
$this->db=$p_db;
@@ -55,7 +54,8 @@ class Poste_analytique
po_name ,
pa_id,
po_amount,
- po_description
+ po_description,
+ ga_id
from poste_analytique
where ".
$p_where;
@@ -69,7 +69,7 @@ class Poste_analytique
$this->pa_id=$line['pa_id'];
$this->amount=$line['po_amount'];
$this->description=$line['po_description'];
-
+ $this->ga_id=$line['ga_id'];
}
@@ -96,24 +96,29 @@ class Poste_analytique
$this->format_data();
if ( strlen($this->name) == 0)
return;
-
$sql="insert into poste_analytique (
po_name ,
pa_id,
po_amount,
- po_description
+ po_description,
+ ga_id
) values (".
"'".$this->name."',".
$this->pa_id.",".
$this->amount.",".
- "'".$this->description."')";
+ "'".$this->description."',".
+ "'".$this->ga_id."')";
+ try {
+ ExecSql($this->db,$sql);
- ExecSql($this->db,$sql);
+ } catch (Exception $e) {
+ echo_debug(__FILE__,__LINE__,$e);
+ echo "Doublon : l'enregistrement n'est pas sauve
";
+ }
}
function update()
{
-
$this->format_data();
if ( strlen($this->name) == 0)
return;
@@ -121,9 +126,15 @@ class Poste_analytique
" set po_name='".$this->name."',".
" pa_id=".$this->pa_id.",".
" po_amount=".$this->amount.",".
- " po_description='".$this->description."'".
+ " po_description='".$this->description."',".
+ " ga_id='".$this->ga_id."'".
" where po_id=".$this->id;
- ExecSql($this->db,$sql);
+ try {
+ ExecSql($this->db,$sql);
+ } catch (Exception $e) {
+ echo_debug(__FILE__,__LINE__,$e);
+ echo "Doublon : l'enregistrement n'est pas sauve
";
+ }
}
private function format_data()
@@ -150,7 +161,8 @@ class Poste_analytique
po_name ,
pa_id,
po_amount,
- po_description
+ po_description,
+ ga_id
from poste_analytique ".
" order by po_name";
@@ -169,6 +181,7 @@ class Poste_analytique
$object->pa_id=$line['pa_id'];
$object->amount=$line['po_amount'];
$object->description=$line['po_description'];
+ $object->ga_id=$line['ga_id'];
$array[]=clone $object;
}
@@ -191,6 +204,7 @@ class Poste_analytique
echo "pa_id ".$this->pa_id."
";
echo "amount ".$this->amount."
";
echo "description ".$this->description."
";
+ echo "ga_id ".$this->ga_id."
";
}
function form()
{
@@ -199,7 +213,10 @@ class Poste_analytique
$wPa_id=new widget("hidden","pa_id","pa_id",$this->pa_id);
$wAmount=new widget("text","Montant","po_amount",$this->amount);
$wDescription=new widget("text","Description","po_description",$this->description);
-
+ $wGa_id=new widget("select","Groupe","ga_id");
+ $wGa_id->value=make_array($this->db,"select ga_id,ga_id from groupe_analytique",1);
+ $wGa_id->selected=$this->ga_id;
+ $wGa_id->table=1;
$pa=new PlanAnalytic($this->db,$this->pa_id);
$pa->get();
$wPaName=new widget("text","Plan A.","",$pa->name);
@@ -233,6 +250,10 @@ class Poste_analytique
$r.=$wPaName->IOValue();
$r.="";
+ $r.="";
+ $r.=$wGa_id->IOValue();
+ $r.="
";
+
$r.="";
return $r;
@@ -244,6 +265,7 @@ class Poste_analytique
$this->pa_id=$_POST['pa_id'];
$this->amount=$_POST['po_amount'];
$this->id=$_POST['po_id'];
+ $this->ga_id=($_POST['ga_id'] == "-1" )?"":$_POST['ga_id'];
}
}
?>
diff --git a/include/postgres.php b/include/postgres.php
index 9dd8e7744..ffdaf04df 100644
--- a/include/postgres.php
+++ b/include/postgres.php
@@ -125,20 +125,23 @@ de données");
* \brief send a sql string to the database
* \param $p_connection db connection
* \param $p_string sql string
- * \param $p_exit if true exits in case of error otherwise returns false
* \return false if error otherwise true
*/
function ExecSql($p_connection, $p_string) {
echo_debug('postgres.php',__LINE__,"SQL = $p_string");
// probl. with Ubuntu & UTF8
//----
- pg_set_client_encoding($p_connection,'latin1');
- $ret=pg_query($p_connection,$p_string);
- if ( $ret == false ) {
- throw new Exception ("SQL ERROR ::: $p_string",1);
- }
+ pg_set_client_encoding($p_connection,'latin1');
+ ob_start();
+ $ret=pg_query($p_connection,$p_string);
+ if ( ! $ret ) {
+ ob_clean();
+ throw new Exception (" SQL ERROR $p_string ",1);
+ }
+ ob_flush();
return $ret;
+
}
/*!
diff --git a/include/user_menu.php b/include/user_menu.php
index 96ebd9f11..a7e937aaf 100644
--- a/include/user_menu.php
+++ b/include/user_menu.php
@@ -73,11 +73,12 @@ function u_ShowDossier($p_user,$p_admin)
$result.="Gestion";
$result.="";
$result.="";
- $result.="Paramètres";
- $result.=" | ";
- $result.="";
$result.="Analytique";
$result.=" | ";
+ $result.="";
+ $result.="Paramètres";
+ $result.=" | ";
+
/* $result.=""; */
/* $result.="Caisse Enregistreuse"; */
/* $result.=" | "; */
diff --git a/sql/upgrade.sql b/sql/upgrade.sql
index c1670251e..c4e56b68e 100644
--- a/sql/upgrade.sql
+++ b/sql/upgrade.sql
@@ -1,35 +1,109 @@
-CREATE or replace FUNCTION t_document_modele_validate() RETURNS "trigger"
- AS $$declare
- lText text;
- modified document_modele%ROWTYPE;
+begin;
+CREATE TABLE groupe_analytique
+(
+ ga_id varchar(10) NOT NULL,
+ ga_description text,
+ CONSTRAINT pk_ga_id PRIMARY KEY (ga_id)
+) ;
+
+
+CREATE OR REPLACE FUNCTION group_analytic_ins_upd()
+ RETURNS "trigger" AS
+$BODY$declare
+name text;
begin
- modified=NEW;
+raise notice 'poste_analytique_write';
+name:=upper(NEW.ga_id);
+name:=trim(name);
+name:=replace(name,' ','');
+NEW.ga_id:=name;
+return NEW;
+end;$BODY$
+ LANGUAGE 'plpgsql' VOLATILE;
+ALTER FUNCTION group_analytic_ins_upd() OWNER TO postgres;
-modified.md_filename=replace(NEW.md_filename,' ','_');
-return modified;
-end;$$
- LANGUAGE plpgsql;
+CREATE OR REPLACE FUNCTION group_analytique_del()
+ RETURNS "trigger" AS
+$BODY$begin
+update poste_analytique set ga_id=null
+where ga_id=OLD.ga_id;
+return OLD;
+end;$BODY$
+ LANGUAGE 'plpgsql' VOLATILE;
+ALTER FUNCTION group_analytique_del() OWNER TO postgres;
+CREATE OR REPLACE FUNCTION poste_analytique_ins_upd()
+ RETURNS "trigger" AS
+$BODY$declare
+name text;
+rCount record;
-
-CREATE or replace FUNCTION t_document_validate() RETURNS "trigger"
- AS $$declare
- lText text;
- modified document%ROWTYPE;
begin
- modified=NEW;
-modified.d_filename=replace(NEW.d_filename,' ','_');
-return modified;
-end;$$
- LANGUAGE plpgsql;
+name:=upper(NEW.po_name);
+name:=trim(name);
+name:=replace(name,' ','');
+NEW.po_name:=name;
+
+if NEW.ga_id is NULL then
+return NEW;
+end if;
+
+if length(trim(NEW.ga_id)) = 0 then
+ NEW.ga_id:=NULL;
+ return NEW;
+end if;
+select into rCount * from groupe_analytique where ga_id=NEW.ga_id;
+if NOT FOUND then
+ raise exception' Inexistent Group Analytic %',NEW.ga_id;
+end if;
+return NEW;
+end;$BODY$
+ LANGUAGE 'plpgsql' VOLATILE;
+
+CREATE OR REPLACE FUNCTION plan_analytic_ins_upd()
+ RETURNS "trigger" AS
+$BODY$
+declare
+ name text;
+begin
+ name:=upper(NEW.pa_name);
+ name:=trim(name);
+ name:=replace(name,' ','');
+ NEW.pa_name:=name;
+return NEW;
+end;
+$BODY$
+ LANGUAGE 'plpgsql' VOLATILE;
+
+CREATE TRIGGER t_poste_analytique_ins_upd
+ BEFORE INSERT OR UPDATE
+ ON poste_analytique
+ FOR EACH ROW
+ EXECUTE PROCEDURE poste_analytique_ins_upd();
+
+CREATE TRIGGER t_plan_analytique_ins_upd
+ BEFORE INSERT OR UPDATE
+ ON plan_analytique
+ FOR EACH ROW
+ EXECUTE PROCEDURE plan_analytic_ins_upd();
+
+CREATE TRIGGER t_group_analytic_del
+ AFTER DELETE
+ ON groupe_analytique
+ FOR EACH ROW
+ EXECUTE PROCEDURE group_analytique_del();
+
+CREATE TRIGGER t_group_analytic_ins_upd
+ BEFORE INSERT OR UPDATE
+ ON groupe_analytique
+ FOR EACH ROW
+ EXECUTE PROCEDURE group_analytic_ins_upd();
-CREATE TRIGGER document_validate
- BEFORE INSERT OR UPDATE ON document
- FOR EACH ROW
- EXECUTE PROCEDURE t_document_validate();
+drop TRIGGER t_upper_pa_name on plan_analytique;
+drop TRIGGER t_upper_po_name on poste_analytique;
+drop function upper_pa_name();
+drop function upper_po_name();
-CREATE TRIGGER document_modele_validate
- BEFORE INSERT OR UPDATE ON document_modele
- FOR EACH ROW
- EXECUTE PROCEDURE t_document_modele_validate();
+
+commit;