noalyss Version-9
Public Member Functions | Static Public Member Functions | Data Fields
Anc_Plan Class Reference

Concerns the Analytic plan (table plan_analytique) More...

+ Collaboration diagram for Anc_Plan:

Public Member Functions

 __construct ($p_cn, $p_id=0)
 
 add ()
 
 count ()
 
 delete ()
 
 exist ()
 
 form ()
 
 form_new ()
 add a new plan More...
 
 get ()
 
 get_list ($p_order=" order by pa_name")
 get the list of all existing PA More...
 
 header ()
 show the header for a table for PA More...
 
 isAppend ()
 
 update ()
 

Static Public Member Functions

static hidden ($p_array)
 return an HTML string containing hidden input type to hold the differant PA_ID More...
 
static test_me ()
 

Data Fields

 $db
 
 $description
 
 $id
 
 $name
 

Detailed Description

Concerns the Analytic plan (table plan_analytique)

Definition at line 32 of file anc_plan.class.php.

Constructor & Destructor Documentation

◆ __construct()

Anc_Plan::__construct (   $p_cn,
  $p_id = 0 
)

Definition at line 39 of file anc_plan.class.php.

40 {
41 $this->db=$p_cn;
42 $this->id=$p_id;
43 $this->name="";
44 $this->description="";
45 $this->get();
46 }
$from_poste name
$SecUser db

References $p_id, db, and name.

Member Function Documentation

◆ add()

Anc_Plan::add ( )

Definition at line 96 of file anc_plan.class.php.

97 {
98 $name=sql_string($this->name);
99 if ( strlen($name) == 0)
100 return;
101 if ( $this->isAppend() == false) return;
102 $description=sql_string($this->description);
103 $this->db->exec_sql("insert into plan_analytique(pa_name,pa_description)".
104 " values ($1,$2 )"
105 ,array($name,$description));
106 $this->id=$this->db->get_current_seq('plan_analytique_pa_id_seq');
107
108 }
sql_string($p_string)
Fix the problem with the quote char for the database.
Definition: ac_common.php:511

References $description, $name, db, isAppend(), name, and sql_string().

+ Here is the call graph for this function:

◆ count()

Anc_Plan::count ( )

Definition at line 180 of file anc_plan.class.php.

181 {
182 $a=$this->db->count_sql("select pa_id from plan_analytique");
183 return $a;
184 }

References $a, and db.

Referenced by hidden().

◆ delete()

Anc_Plan::delete ( )

Definition at line 78 of file anc_plan.class.php.

79 {
80 if ( $this->id == 0 ) return;
81 $this->db->exec_sql("delete from plan_analytique where pa_id=$1",array($this->id));
82 }

References db.

◆ exist()

Anc_Plan::exist ( )

Definition at line 185 of file anc_plan.class.php.

186 {
187 $a=$this->db->count_sql("select pa_id from plan_analytique where pa_id=$1",
188 array($this->pa_id));
189
190 return ($a==0)?false:true;
191
192 }
$anc pa_id

References $a, db, and pa_id.

◆ form()

Anc_Plan::form ( )

Definition at line 109 of file anc_plan.class.php.

110 {
112 $wName=new IText('pa_name',$this->name,"pa_name");
113 $iName=new Inplace_Edit($wName);
114 $iName->set_callback("ajax_misc.php");
115 $iName->add_json_param("gDossier",$dossier_id);
116 $iName->add_json_param("action","anc_updatedescription");
117 $iName->add_json_param("op","anc_updatedescription");
118 $iName->add_json_param("id",$this->id);
119
120
121 $wDescription=new IText('pa_description',$this->description,"pa_description");
122 $wDescription->size=50;
123 if ( $this->description == "") $wDescription->value=_("Aucune description");
124 $iDescription=new Inplace_Edit($wDescription);
125 $iDescription->add_json_param("gDossier",$dossier_id);
126 $iDescription->add_json_param("op","anc_updatedescription");
127 $iDescription->add_json_param("action","anc_updatedescription");
128 $iDescription->set_callback("ajax_misc.php");
129 $iDescription->add_json_param("id",$this->id);
130
131
132 $wId=new IHidden("pa_id",$this->id);
133 $ret="<TABLE>";
134 $ret.='<tr>'.td(_('Nom')).'<td>'.$iName->input().'</td>'.'</tr>';
135 $ret.="<tr>".td(_('Description')).'<td>'.$iDescription->input().'</td>'."</tr>";
136 $ret.="</table>";
137 $ret.=$wId->input();
138 return $ret;
139 }
$dossier_id
Definition: ajax_poste.php:43
static id()
return the 'gDossier' value after a check
Html Input.
Html Input.
Definition: itext.class.php:30
Inplace_edit class for ajax update of HtmlInput object.

References $dossier_id, $ret, Dossier\id(), and name.

+ Here is the call graph for this function:

◆ form_new()

Anc_Plan::form_new ( )

add a new plan

Definition at line 143 of file anc_plan.class.php.

144 {
145 $wName=new IText("pa_name");
146 $wDescription=new IText("pa_description");
147 $wDescription->size=80;
148
149 $ret="<TABLE>";
150 $ret.='<tr>'.td(_('Nom')).'<td>'.$wName->input().'</td>'.'</tr>';
151 $ret.="<tr>".td(_('Description')).'<td>'.$wDescription->input().'</td>'."</tr>";
152 $ret.="</table>";
153 return $ret;
154
155
156 }

References $ret.

◆ get()

Anc_Plan::get ( )

Definition at line 62 of file anc_plan.class.php.

63 {
64 if ( $this->id==0) return;
65
66 $sql="select pa_name,pa_description from plan_analytique where pa_id=$1";
67 $ret= $this->db->exec_sql($sql,array($this->id));
68 if ( Database::num_row($ret) == 0)
69 {
70 return;
71 }
73 $this->name=$a['pa_name'];
74 $this->description=$a['pa_description'];
75
76 }
static fetch_array($ret, $p_indice=0, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_array
static num_row($ret)
wrapper for the function pg_num_rows

References $a, $ret, $sql, db, DatabaseCore\fetch_array(), name, and DatabaseCore\num_row().

+ Here is the call graph for this function:

◆ get_list()

Anc_Plan::get_list (   $p_order = " order by pa_name")

get the list of all existing PA

Returns
an array of PA (not object)

Definition at line 51 of file anc_plan.class.php.

52 {
53 $array=array();
54 $sql="select pa_id as id,pa_name as name,".
55 "pa_description as description from plan_analytique $p_order";
56 $ret=$this->db->exec_sql($sql);
58 if ($array == FALSE ) return array();
59 return $array;
60 }
static fetch_all($ret)
wrapper for the function pg_fetch_all

References $array, $ret, $sql, db, and DatabaseCore\fetch_all().

Referenced by header().

+ Here is the call graph for this function:

◆ header()

Anc_Plan::header ( )

show the header for a table for PA

Returns
string like

name...

Definition at line 169 of file anc_plan.class.php.

170 {
171 $res="";
172 $a_plan=$this->get_list(" order by pa_id");
173 if ( empty($a_plan)) return "";
174 foreach ($a_plan as $r_plan)
175 {
176 $res.="<th>".h($r_plan['name'])."</th>";
177 }
178 return $res;
179 }
get_list($p_order=" order by pa_name")
get the list of all existing PA

References $a_plan, $res, and get_list().

+ Here is the call graph for this function:

◆ hidden()

static Anc_Plan::hidden (   $p_array)
static

return an HTML string containing hidden input type to hold the differant PA_ID

Parameters
$p_arraycontains a array, it is the result of the fct Anc_Plan::get_list
Returns
html string
See also
Anc_Plan::get_list

Definition at line 201 of file anc_plan.class.php.

202 {
203 $r='';
204 for ($i_anc=0;$i_anc <count($p_array);$i_anc++)
205 {
206 $r.=HtmlInput::hidden('pa_id[]',$p_array[$i_anc]['id']);
207 }
208 return $r;
209 }
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
static hidden($p_name, $p_value, $p_id="")

References $p_array, $r, count(), and HtmlInput\hidden().

Referenced by Acc_Ledger_Fin\confirm(), Acc_Ledger\confirm(), Acc_Ledger_Purchase\confirm(), and Acc_Ledger_Sale\confirm().

+ Here is the call graph for this function:

◆ isAppend()

Anc_Plan::isAppend ( )

Definition at line 157 of file anc_plan.class.php.

158 {
159 $count=$this->db->get_value("select count(pa_id) from plan_analytique");
160
161 if ( $count > 10 )
162 return false;
163 else
164 return true;
165 }
$count

References $count, and db.

Referenced by add().

◆ test_me()

static Anc_Plan::test_me ( )
static

Definition at line 210 of file anc_plan.class.php.

211 {
213 echo "<h1>Plan analytique : test</h1>";
214 echo "clean";
215 $cn->exec_sql("delete from plan_analytique");
216
217 $p=new Anc_Plan($cn);
218 echo "<h2>Add</h2>";
219 $p->name="Nouveau 1";
220 $p->description="C'est un test";
221 echo "Add<hr>";
222 $p->add();
223 $p->name="Nouveau 2";
224 $p->add();
225 $pa_id=$p->id;
226 echo $p->id."/";
227 $p->name="Nouveau 3";
228 $p->add();
229 echo $p->id."/";
230
231
232 $p->name="Nouveau 4";
233 $p->add();
234 echo $p->id;
235
236 echo "<h2>get</h2>";
237 $p->get();
238 var_dump($p);
239 echo "<h2>Update</h2> ";
240 $p->name="Update ";
241 $p->description="c'est change";
242 $p->update();
243 $p->get();
244 var_dump($p);
245 echo "<h2>get_list</h2>";
246 $a=$p->get_list();
247 var_dump($a);
248 echo "<h2>delete </h2>";
249 $p->delete();
250
251
252 }
$p
Definition: array.php:34
Concerns the Analytic plan (table plan_analytique)
static connect()

References $a, $cn, $p, $pa_id, and Dossier\connect().

+ Here is the call graph for this function:

◆ update()

Anc_Plan::update ( )

Definition at line 84 of file anc_plan.class.php.

85 {
86 if ( $this->id==0) return;
87 $name=sql_string($this->name);
88 if ( strlen($name) == 0)
89 return;
90
91 $description=sql_string($this->description);
92 $this->db->exec_sql("update plan_analytique set pa_name=$1,
93 pa_description=$2 where pa_id=$3",array($name,$description,$this->id));
94 }

References $description, $name, db, name, and sql_string().

+ Here is the call graph for this function:

Field Documentation

◆ $db

Anc_Plan::$db

database connection

Definition at line 34 of file anc_plan.class.php.

◆ $description

Anc_Plan::$description

description of the PA plan_analytique.pa_description

Definition at line 36 of file anc_plan.class.php.

Referenced by add(), and update().

◆ $id

Anc_Plan::$id

id = plan_analytique.pa_id

Definition at line 37 of file anc_plan.class.php.

◆ $name

Anc_Plan::$name

name plan_analytique.pa_name

Definition at line 35 of file anc_plan.class.php.

Referenced by add(), and update().


The documentation for this class was generated from the following file: