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

class for the group of the analytic account More...

+ Inheritance diagram for Anc_Group:
+ Collaboration diagram for Anc_Group:

Public Member Functions

 __construct ( $p_cn)
 
 display_html ()
 
 export_csv ()
 
 get_from_array ($p_array)
 fill the object thanks an array More...
 
 get_result ()
 
 insert ()
 insert into the database an object More...
 
 load ()
 load the todo_list row thanks it's ID More...
 
 myList ()
 
 remove ()
 remove from the database More...
 
 set_sql_filter ()
 Set the filter (account_date) More...
 
 show_button ($p_hidden="")
 display the button export CSV More...
 
- Public Member Functions inherited from Anc_Print
 __construct ($p_cn)
 
 check ()
 
 display_form ($p_hidden="")
 Compute the form to display. More...
 
 get_request ()
 complete the object with the data in $_REQUEST More...
 
 set_sql_filter ()
 Set the filter (account_date) More...
 

Static Public Member Functions

static test_me ()
 

Data Fields

 $db
 
 $ga_description
 
 $ga_id
 
 $pa_id
 
- Data Fields inherited from Anc_Print
 $db
 
 $from
 
 $from_poste
 
 $to
 
 $to_poste
 

Detailed Description

class for the group of the analytic account

Definition at line 31 of file anc_group.class.php.

Constructor & Destructor Documentation

◆ __construct()

Anc_Group::__construct (   $p_cn)

Reimplemented from Anc_Print.

Definition at line 38 of file anc_group.class.php.

39 {
40 parent::__construct($p_cn);
41 $this->db=$p_cn;
42 $this->ga_id=null;
43 $this->ga_description=null;
44 $this->pa_id=null;
45 }
$anc pa_id
$anc ga_id
$SecUser db

References db, ga_id, and pa_id.

Member Function Documentation

◆ display_html()

Anc_Group::display_html ( )

Definition at line 188 of file anc_group.class.php.

189 {
190 if ( $this->check() != 0)
191 {
192 alert('Désolé mais une des dates données n\'est pas valide');
193 return;
194 }
195
196 $array=$this->get_result();
197 if ( empty ($array) ) return "";
198 require_once NOALYSS_TEMPLATE.'/anc_balance_group.php';
199
200
201 }
alert($p_msg, $buffer=false)
alert in javascript
Definition: ac_common.php:738

References $array, alert(), Anc_Print\check(), and get_result().

+ Here is the call graph for this function:

◆ export_csv()

Anc_Group::export_csv ( )

Definition at line 223 of file anc_group.class.php.

224 {
225 $array=$this->get_result();
226 $cvs=new Noalyss_Csv ('anc-balance-group-export');
227 $cvs->send_header();
228 $cvs->write_header(array("groupe","activité","description","débit","credit","solde"));
229 bcscale(2);
230 for ($i=0;$i<count($array);$i++)
231 {
232 $cvs->add($array[$i]['ga_id']);
233 $cvs->add($array[$i]['po_name']);
234 $cvs->add($array[$i]['po_description']);
235 $cvs->add($array[$i]['sum_deb'],"number");
236 $cvs->add($array[$i]['sum_cred'],"number");
237 $cvs->add(bcsub($array[$i]['sum_cred'],$array[$i]['sum_deb']),"number");
238 $cvs->write();
239 }
240 }
Manage the CSV : manage files and write CSV record.

References $array, $i, and get_result().

+ Here is the call graph for this function:

◆ get_from_array()

Anc_Group::get_from_array (   $p_array)

fill the object thanks an array

Parameters
array

Definition at line 106 of file anc_group.class.php.

107 {
108 $this->ga_id=$p_array['ga_id'];
109 $this->pa_id=$p_array['pa_id'];
110 $this->ga_description=$p_array['ga_description'];
111 }

References $p_array, ga_id, and pa_id.

◆ get_result()

Anc_Group::get_result ( )

Definition at line 161 of file anc_group.class.php.

162 {
163 $filter_date=$this->set_sql_filter();
164
165 $sql="with m as (select po_id,
166 po_name,
167 po_description,
168 ga_id,
169 case when oa_debit = 't' then oa_amount
170 else 0
171 end as amount_deb,
172 case when oa_debit = 'f' then oa_amount
173 else 0
174 end as amount_cred,
175 oa_date
176 from operation_analytique
177join poste_analytique using (po_id)
178where pa_id=$1 $filter_date )
179select sum(amount_cred) as sum_cred, sum(amount_deb)as sum_deb,po_name,ga_id,ga_description,po_description
180from m left join groupe_analytique using (ga_id)
181group by ga_id,po_name,ga_description,po_description
182order by ga_description,po_name";
183 $ret=$this->db->get_array($sql,array($this->pa_id));
184
185 return $ret;
186 }
set_sql_filter()
Set the filter (account_date)

References $ret, $sql, db, pa_id, and set_sql_filter().

Referenced by display_html(), and export_csv().

+ Here is the call graph for this function:

◆ insert()

Anc_Group::insert ( )

insert into the database an object

Returns
message with error otherwise an empty string

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

52 {
53 if (strlen ($this->ga_id) > 10 ) return '<span class="notice">'.
54 _('Taille de la code trop long maximum 10 caractères').'</span>';
55 $sql=" insert into groupe_analytique (ga_id,ga_description,pa_id) values ($1,$2,$3)";
56 try
57 {
58 $this->db->exec_sql($sql,[$this->ga_id,
59 $this->ga_description,
60 $this->pa_id]);
61 return true;
62 }
63 catch (Exception $a)
64 {
65 return '<span class="notice">Doublon !!</span>';
66 return false;
67 }
68 }

References $a, $sql, db, ga_id, and pa_id.

◆ load()

Anc_Group::load ( )

load the todo_list row thanks it's ID

Returns
boolean true if found else false

Definition at line 86 of file anc_group.class.php.

86 :bool
87 {
88 $sql="select ga_id, ga_description,pa_id from groupe_analytique where".
89 " ga_id = $1";
90 $res=$this->db->exec_sql($sql,[$this->ga_id]);
92 if ( ! empty($array) )
93 {
94 $this->ga_id=$array['ga_id'];
95 $this->ga_description=$array['ga_description'];
96 $this->pa_id=$array['pa_id'];
97 return true;
98 }
99 return false;
100 }
static fetch_array($ret, $p_indice=0, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_array

References $array, $res, $sql, db, DatabaseCore\fetch_array(), ga_id, and pa_id.

+ Here is the call graph for this function:

◆ myList()

Anc_Group::myList ( )

Definition at line 112 of file anc_group.class.php.

113 {
114 $sql=" select ga_id,groupe_analytique.pa_id,pa_name,ga_description ".
115 " from groupe_analytique ".
116 " join plan_analytique using (pa_id)";
117 $r=$this->db->exec_sql($sql);
119 $res=array();
120 if ( ! empty($array))
121 {
122 foreach ($array as $m )
123 {
124 $obj= new Anc_Group($this->db);
125 $obj->get_from_array($m);
126 $obj->pa_name=$m['pa_name'];
127 $res[]=clone $obj;
128 }
129 }
130 return $res;
131 }
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
class for the group of the analytic account
static fetch_all($ret)
wrapper for the function pg_fetch_all

References $array, $m, $obj, $r, $res, $sql, db, and DatabaseCore\fetch_all().

+ Here is the call graph for this function:

◆ remove()

Anc_Group::remove ( )

remove from the database

Definition at line 73 of file anc_group.class.php.

74 {
75 $this->ga_id=noalyss_str_replace(' ','',$this->ga_id);
76 $this->ga_id=strtoupper($this->ga_id);
77 $sql=" delete from groupe_analytique where ga_id=$1";
78
79 $this->db->exec_sql($sql,array($this->ga_id));
80 }
noalyss_str_replace($search, $replace, $string)
Definition: ac_common.php:1553

References $sql, db, ga_id, and noalyss_str_replace().

+ Here is the call graph for this function:

◆ set_sql_filter()

Anc_Group::set_sql_filter ( )

Set the filter (account_date)

Returns
return the string to add to load

Reimplemented from Anc_Print.

Definition at line 133 of file anc_group.class.php.

134 {
135 $sql="";
136 $and="and ";
137 if ( $this->from != "" )
138 {
139 $sql.=" $and oa_date >= to_date('".$this->from."','DD.MM.YYYY')";
140 $and=" and ";
141 }
142 if ( $this->to != "" )
143 {
144 $sql.=" $and oa_date <= to_date('".$this->to."','DD.MM.YYYY')";
145 $and=" and ";
146 }
147 if ( $this->from_poste != "" )
148 {
149 $sql.=" $and upper(po_name)>= upper('".$this->from_poste."')";
150 $and=" and ";
151 }
152 if ( $this->to_poste != "" )
153 {
154 $sql.=" $and upper(po_name)<= upper('".$this->to_poste."')";
155 $and=" and ";
156 }
157 return $sql;
158
159 }
$anc_grandlivre from_poste
$anc_grandlivre to
$anc_grandlivre to_poste
$anc_grandlivre from

References $sql, from, from_poste, to, and to_poste.

Referenced by get_result().

◆ show_button()

Anc_Group::show_button (   $p_hidden = "")

display the button export CSV

Parameters
$p_hiddenis a string containing hidden items
Returns
html string

Definition at line 207 of file anc_group.class.php.

208 {
209 $r="";
210 $r.= '<form method="GET" action="export.php" style="display:inline">';
211 $r.= HtmlInput::hidden("act","CSV:AncBalGroup");
212 $r.= HtmlInput::hidden("to",$this->to);
213 $r.= HtmlInput::hidden("from",$this->from);
214 $r.= HtmlInput::hidden("pa_id",$this->pa_id);
215 $r.= HtmlInput::hidden("from_poste",$this->from_poste);
216 $r.= HtmlInput::hidden("to_poste",$this->to_poste);
217 $r.= $p_hidden;
218 $r.= dossier::hidden();
219 $r.=HtmlInput::submit('bt_csv',"Export en CSV");
220 $r.= '</form>';
221 return $r;
222 }
static hidden($p_name, $p_value, $p_id="")
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")

References $r, from, from_poste, HtmlInput\hidden(), pa_id, HtmlInput\submit(), to, and to_poste.

+ Here is the call graph for this function:

◆ test_me()

static Anc_Group::test_me ( )
static

Definition at line 241 of file anc_group.class.php.

242 {
243
245 print_r($cn);
246 $o=new Anc_Group($cn);
247 $r=$o->myList();
248 print_r($r);
249 echo '<hr>';
250 print_r($o);
251 $o->ga_id="DD' dd dDD";
252 $o->ga_description="Test 1";
253 $o->remove();
254 // $o->insert();
255 $o->ga_id="DD";
256 $o->ga_description="Test 1";
257 $o->remove();
258
259 $r=$o->myList();
260 print_r($r);
261 }
static connect()

References $cn, $r, and Dossier\connect().

+ Here is the call graph for this function:

Field Documentation

◆ $db

Anc_Group::$db

Definition at line 33 of file anc_group.class.php.

◆ $ga_description

Anc_Group::$ga_description

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

◆ $ga_id

Anc_Group::$ga_id

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

◆ $pa_id

Anc_Group::$pa_id

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


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