Add CA group
This commit is contained in:
parent
9cab18d2b7
commit
c0bbf02727
8 changed files with 172 additions and 62 deletions
|
|
@ -44,15 +44,18 @@ html_page_start($_SESSION['g_theme']);
|
|||
//-----------------------------------------------------------------
|
||||
//Header
|
||||
echo '<div class="u_tmenu">';
|
||||
echo "<H2 class=\"info\">Analytique ".dossier::name()." ";
|
||||
echo '<div align="right" title="Recherche">
|
||||
echo '<div style="float:left">';
|
||||
echo "<H2 class=\"info\">Analytique ".dossier::name()."</h2> ";
|
||||
echo '</div>';
|
||||
echo '<div style="float:none;text-align:right;" title="Recherche">
|
||||
<input type="IMAGE" src="image/search.png" width="36" onclick="openRecherche(\''.$_REQUEST['PHPSESSID'].'\','.dossier::id().');">
|
||||
<A HREF="?p_action=pref&'.$str_dossier.'" title="Préférence"><IMG SRC="image/preference.png" width="36" border="0" ></A>
|
||||
<A HREF="user_compta.php?'.$str_dossier.'" title="Comptabilité"><IMG SRC="image/compta.png" width="36" border="0" ></A>
|
||||
<A HREF="parametre.php?'.$str_dossier.'" title="Paramètre"><IMG SRC="image/param.png" width="36" border="0" ></A>
|
||||
<A HREF="login.php" title="Accueil"><IMG src="image/home.png" width="36" title="Accueil" border="0" ></A>
|
||||
<A HREF="logout.php" title="Sortie"><IMG src="image/logout.png" title="Logout" width="36" border="0"></A>
|
||||
</div> </h2>';
|
||||
</div>';
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
$def=-1;
|
||||
|
|
@ -75,9 +78,10 @@ if ( isset ($_REQUEST['p_action']))
|
|||
}
|
||||
}
|
||||
echo ShowItem(array(
|
||||
array('?p_action=ca_pa&'.$str_dossier,'Plan Analytique',"Plan Analytique",0),
|
||||
array('?p_action=ca_od&'.$str_dossier,'Opérations Diverses',"Permet d'enregistrer des opérations sur la compta analytique",1),
|
||||
array('?p_action=ca_imp&'.$str_dossier,'Impression',"impression de rapport",2)
|
||||
array('?p_action=ca_pa&'.$str_dossier,'Plan Analytique',"Plan Analytique",0),
|
||||
array('?p_action=ca_od&'.$str_dossier,'Opérations Diverses',"Permet d'enregistrer des opérations sur la compta analytique",1),
|
||||
array('?p_action=ca_groupe&'.$str_dossier,'Groupe','Regroupe les postes analytiques',3),
|
||||
array('?p_action=ca_imp&'.$str_dossier,'Impression',"impression de rapport",2)
|
||||
),
|
||||
'H',"mtitle","mtitle",$def,' width="100%"');
|
||||
echo '</div>';
|
||||
|
|
@ -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' )
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -151,7 +151,6 @@ div.u_redcontent{
|
|||
div.u_content{
|
||||
position: float;
|
||||
float:left;
|
||||
width:100%;
|
||||
padding-top:7px;
|
||||
width:100%;
|
||||
font-size:9px;
|
||||
|
|
|
|||
|
|
@ -203,6 +203,7 @@ if ( isset($_REQUEST['sa']))
|
|||
$ret.="<th> Nom </td>";
|
||||
$ret.="<th> Montant </td>";
|
||||
$ret.="<th> Description </td>";
|
||||
$ret.="<th>Groupe</th>";
|
||||
$ret.="<th> Plan A </td>";
|
||||
$ret.="</tr>";
|
||||
$class="";
|
||||
|
|
@ -223,6 +224,7 @@ if ( isset($_REQUEST['sa']))
|
|||
"</td>";
|
||||
$ret.="<TD align=\"right\">".$obj->amount."</td>";
|
||||
$ret.="<TD>".$obj->description."</td>";
|
||||
$ret.="<td>".$obj->ga_id."</td>";
|
||||
$ret.="<TD>".$new->name."</td>";
|
||||
$ret.="</tr>";
|
||||
|
||||
|
|
|
|||
|
|
@ -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 "<p class=\"notice\">Doublon : l'enregistrement n'est pas sauve</p>";
|
||||
}
|
||||
|
||||
}
|
||||
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 "<p class=\"notice\">Doublon : l'enregistrement n'est pas sauve</p>";
|
||||
}
|
||||
|
||||
}
|
||||
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."<br>";
|
||||
echo "amount ".$this->amount."<br>";
|
||||
echo "description ".$this->description."<br>";
|
||||
echo "ga_id ".$this->ga_id."<br>";
|
||||
}
|
||||
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.="</tr>";
|
||||
|
||||
$r.="<tr>";
|
||||
$r.=$wGa_id->IOValue();
|
||||
$r.="</tr>";
|
||||
|
||||
$r.="</table>";
|
||||
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'];
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -73,11 +73,12 @@ function u_ShowDossier($p_user,$p_admin)
|
|||
$result.="<A class=\"mtitle\" HREF=\"commercial.php?gDossier=$id\">Gestion</A>";
|
||||
$result.="</TD>";
|
||||
$result.="<TD class=\"mtitle\">";
|
||||
$result.="<A class=\"mtitle\" HREF=\"parametre.php?gDossier=$id\">Paramètres</A>";
|
||||
$result.="</TD>";
|
||||
$result.="<TD class=\"mtitle\">";
|
||||
$result.="<A class=\"mtitle\" HREF=\"comptanalytic.php?gDossier=$id\">Analytique</A>";
|
||||
$result.="</TD>";
|
||||
$result.="<TD class=\"mtitle\">";
|
||||
$result.="<A class=\"mtitle\" HREF=\"parametre.php?gDossier=$id\">Paramètres</A>";
|
||||
$result.="</TD>";
|
||||
|
||||
/* $result.="<TD class=\"mtitle\">"; */
|
||||
/* $result.="<A class=\"mtitle\" HREF=\"caisse.php?dos=$id\">Caisse Enregistreuse</A>"; */
|
||||
/* $result.="</TD>"; */
|
||||
|
|
|
|||
128
sql/upgrade.sql
128
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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue