noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
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
 
 get_result ()
 
 insert ()
 insert into the database an object
 
 load ()
 load the todo_list row thanks it's ID
 
 myList ()
 
 remove ()
 remove from the database
 
 set_sql_filter ()
 Set the filter (account_date)
 
 show_button ($p_hidden="")
 display the button export CSV
 
- Public Member Functions inherited from Anc_Print
 check ()
 
 display_form ($p_hidden="")
 Compute the form to display.
 
 get_request ()
 complete the object with the data in $_REQUEST
 

Static Public Member Functions

static test_me ()
 

Data Fields

 $db
 
 $ga_description
 
 $ga_id
 
 $pa_id
 
 $pa_name
 
- Data Fields inherited from Anc_Print
 $db
 
 $from
 
 $from_poste
 
 $has_data
 
 $pa_id
 
 $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 39 of file anc_group.class.php.

40 {
41 parent::__construct($p_cn);
42 $this->db=$p_cn;
43 $this->ga_id=null;
44 $this->ga_description=null;
45 $this->pa_id=null;
46 }
$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 189 of file anc_group.class.php.

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

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 224 of file anc_group.class.php.

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

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 107 of file anc_group.class.php.

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

References $p_array, ga_id, and pa_id.

◆ get_result()

Anc_Group::get_result ( )

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

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

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

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 87 of file anc_group.class.php.

87 :bool
88 {
89 $sql="select ga_id, ga_description,pa_id from groupe_analytique where".
90 " ga_id = $1";
91 $res=$this->db->exec_sql($sql,[$this->ga_id]);
93 if ( ! empty($array) )
94 {
95 $this->ga_id=$array['ga_id'];
96 $this->ga_description=$array['ga_description'];
97 $this->pa_id=$array['pa_id'];
98 return true;
99 }
100 return false;
101 }
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 113 of file anc_group.class.php.

114 {
115 $sql=" select ga_id,groupe_analytique.pa_id,pa_name,ga_description ".
116 " from groupe_analytique ".
117 " join plan_analytique using (pa_id)";
118 $r=$this->db->exec_sql($sql);
120 $res=array();
121 if ( ! empty($array))
122 {
123 foreach ($array as $m )
124 {
125 $obj= new Anc_Group($this->db);
126 $obj->get_from_array($m);
127 $obj->pa_name=$m['pa_name'];
128 $res[]=clone $obj;
129 }
130 }
131 return $res;
132 }
catch(Exception $e) $obj
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
static fetch_all($ret, $p_mode=PGSQL_ASSOC)
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 74 of file anc_group.class.php.

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

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 134 of file anc_group.class.php.

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

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

References $r, from, from_poste, pa_id, to, and to_poste.

◆ test_me()

static Anc_Group::test_me ( )
static

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

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

References $cn, and $r.

Field Documentation

◆ $db

Anc_Group::$db

$db (Database) Database connexion

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

◆ $ga_description

Anc_Group::$ga_description

$ga_description (string) name of the group

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

◆ $ga_id

Anc_Group::$ga_id

$ga_id (int) PK GROUPE_ANALYTIQUE.GA_ID

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

◆ $pa_id

Anc_Group::$pa_id

$pa_id (int) id PLAN_ANALYTIC.PA_ID

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

◆ $pa_name

Anc_Group::$pa_name

$pa_name (string) name of the Analytic Axis

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


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