From eb04d78be5e708a715340f559d50e2d1808b1152 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Thu, 27 Dec 2007 18:12:41 +0000 Subject: [PATCH] link the group analytic to the plan Analytic --- include/bud_hypo.inc.php | 2 +- include/ca_group.inc.php | 8 +++++++- include/class_anc_group.php | 16 ++++++++++++---- include/class_bud_hypo.php | 7 +++---- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/include/bud_hypo.inc.php b/include/bud_hypo.inc.php index cb733331b..d4c8905d9 100644 --- a/include/bud_hypo.inc.php +++ b/include/bud_hypo.inc.php @@ -92,7 +92,7 @@ if ( $sa == "detail" ) { $obj->load(); echo '
'; echo '
'; - echo $obj->form(); + echo $obj->form(1); echo widget::submit_button('remove','Effacer','onClick="return confirm(\'Vous confirmez cet effacement ?\')"'); echo widget::submit_button('update','Mise à jour'); diff --git a/include/ca_group.inc.php b/include/ca_group.inc.php index c7c003595..c54e64ad8 100644 --- a/include/ca_group.inc.php +++ b/include/ca_group.inc.php @@ -56,16 +56,22 @@ echo '
'; echo ''; echo dossier::hidden(); echo ''; -echo ''; +echo ''; foreach ($array as $idx=>$m) { echo ''; echo ''; + echo ''; echo ''; echo ''; echo ''; } $w=new widget("text"); +$val_pa_id=make_array($cn,"select pa_id,pa_name from plan_analytique"); +$wPa_id=new widget ("select"); +$wPa_id->value=$val_pa_id; + echo ""; +echo ""; echo "";; diff --git a/include/class_anc_group.php b/include/class_anc_group.php index 0befefc80..de0d55dd0 100644 --- a/include/class_anc_group.php +++ b/include/class_anc_group.php @@ -36,20 +36,23 @@ class Anc_Group { var $db; var $ga_id; var $ga_description; + var $pa_id; function __construct ( $p_cn ) { $this->db=$p_cn; $this->ga_id=null; $this->ga_description=null; + $this->pa_id=null; } /*! * \brief insert into the database an object */ function insert() { - $sql=" insert into groupe_analytique values ('%s','%s')"; + $sql=" insert into groupe_analytique (ga_id,ga_description,pa_id) values ('%s','%s',%d)"; $sql=sprintf($sql,pg_escape_string($this->ga_id), - pg_escape_string($this->ga_description)); + pg_escape_string($this->ga_description), + $this->pa_id); try { ExecSql($this->db,$sql); } catch (Exception $a) { @@ -73,13 +76,14 @@ class Anc_Group { * \brief load from the database and make an object */ function load() { - $sql="select ga_id, ga_description from groupe_analytique where". + $sql="select ga_id, ga_description,pa_id from groupe_analytique where". " ga_id = ".$this->ga_id; $res=ExecSql($this->db,$sql); $array=pg_fetch_all($res); if ( ! empty($array) ) { $this->ga_id=$array['ga_id']; $this->ga_description=$array['ga_description']; + $this->pa_id=$array['pa_id']; } } @@ -89,10 +93,13 @@ class Anc_Group { */ function get_from_array($p_array) { $this->ga_id=$p_array['ga_id']; + $this->pa_id=$p_array['pa_id']; $this->ga_description=$p_array['ga_description']; } function myList() { - $sql=" select ga_id,ga_description from groupe_analytique"; + $sql=" select ga_id,groupe_analytique.pa_id,pa_name,ga_description ". + " from groupe_analytique ". + " join plan_analytique using (pa_id)"; $r=ExecSql($this->db,$sql); $array=pg_fetch_all($r); $res=array(); @@ -100,6 +107,7 @@ class Anc_Group { foreach ($array as $m ) { $obj= new Anc_Group($this->db); $obj->get_from_array($m); + $obj->pa_name=$m['pa_name']; $res[]=clone $obj; } } diff --git a/include/class_bud_hypo.php b/include/class_bud_hypo.php index 1d6c40074..115d58d60 100644 --- a/include/class_bud_hypo.php +++ b/include/class_bud_hypo.php @@ -97,12 +97,11 @@ class Bud_Hypo { $sql=sprintf( "update bud_hypothese set bh_name='%s',". - " bh_saldo = %f ,bh_description='%s',pa_id=%s ". + " bh_saldo = %f ,bh_description='%s' ". " where bh_id= %d", $bh_name, $bh_saldo, $bh_description, - $pa_id, $this->bh_id ); ExecSql($this->db,$sql); @@ -139,7 +138,7 @@ class Bud_Hypo { return $result; } - function form() { + function form($p_update=0) { $wName=new widget("text","Nom","bh_name",$this->bh_name); @@ -149,7 +148,7 @@ class Bud_Hypo { $array=make_array($this->db,"select pa_id,pa_name from plan_analytique",1); $wPa_id=new widget("select","Plan Analytique","pa_id",$array); $wPa_id->selected=$this->pa_id; - + if ( $p_update != 0 ) $wPa_id->readonly=true; $wName->table=1; $wDescription->table=1; $wSaldo->table=1;
Code Description
Code Plan Description
'.$m->ga_id.''.$m->pa_name.''.$m->ga_description.' Effacer '.'
".$w->IOValue("ga_id")."".$wPa_id->IOValue("pa_id")."".$w->IOValue("ga_description"). widget::submit_button('add','Ajouter'). "