noalyss
Version-6.7.2
|
class for the group of the analytic account More...
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 from the database and make an object | |
myList () | |
remove () | |
remove from the database | |
set_sql_filter () | |
Set the filter (account_date) | |
show_button ($p_hidden="") | |
display the button export CSV | |
Static Public Member Functions | |
static | test_me () |
Data Fields | |
$db | |
$ga_description | |
$ga_id | |
$pa_id |
class for the group of the analytic account
Definition at line 34 of file class_anc_group.php.
Anc_Group::__construct | ( | $ | p_cn | ) |
Definition at line 41 of file class_anc_group.php.
References db.
{ $this->db=$p_cn; $this->ga_id=null; $this->ga_description=null; $this->pa_id=null; }
Definition at line 184 of file class_anc_group.php.
References $array, alert(), Anc_Print\check(), and get_result().
{ if ( $this->check() != 0) { alert('Désolé mais une des dates données n\'est pas valide'); return; } $array=$this->get_result(); if ( empty ($array) ) return ""; require_once('template/anc_balance_group.php'); }
Definition at line 219 of file class_anc_group.php.
References $array, get_result(), nb(), and printf.
{ $array=$this->get_result(); printf('"groupe";"activité";"débit";"credit";"solde"'); printf("\r\n"); bcscale(2); for ($i=0;$i<count($array);$i++) { printf('"%s";"%s";%s;%s;%s', $array[$i]['ga_id'], $array[$i]['po_name'], nb($array[$i]['sum_deb']), nb($array[$i]['sum_cred']), nb(bcsub($array[$i]['sum_cred'],$array[$i]['sum_deb'])) ); printf("\r\n"); } }
Anc_Group::get_from_array | ( | $ | p_array | ) |
Definition at line 158 of file class_anc_group.php.
References $ret, $sql, db, and set_sql_filter().
Referenced by display_html(), and export_csv().
{ $filter_date=$this->set_sql_filter(); $sql="with m as (select po_id, po_name, ga_id, case when oa_debit = 't' then oa_amount else 0 end as amount_deb, case when oa_debit = 'f' then oa_amount else 0 end as amount_cred, oa_date from operation_analytique join poste_analytique using (po_id) where pa_id=$1 $filter_date ) select sum(amount_cred) as sum_cred, sum(amount_deb)as sum_deb,po_name,ga_id,ga_description from m left join groupe_analytique using (ga_id) group by ga_id,po_name,ga_description order by ga_description,po_name"; $ret=$this->db->get_array($sql,array($this->pa_id)); return $ret; }
insert into the database an object
Definition at line 53 of file class_anc_group.php.
References $a, $sql, db, and Database\escape_string().
{ $sql=" insert into groupe_analytique (ga_id,ga_description,pa_id) values ('%s','%s',%d)"; $sql=sprintf($sql,Database::escape_string($this->ga_id), Database::escape_string($this->ga_description), $this->pa_id); try { $this->db->exec_sql($sql); } catch (Exception $a) { return '<span class="notice">Doublon !!</span>'; } return ""; }
Anc_Group::load | ( | ) |
load from the database and make an object
Definition at line 85 of file class_anc_group.php.
References $array, $res, $sql, db, and Database\fetch_all().
{ $sql="select ga_id, ga_description,pa_id from groupe_analytique where". " ga_id = ".$this->ga_id; $res=$this->db->exec_sql($sql); $array=Database::fetch_all($res); if ( ! empty($array) ) { $this->ga_id=$array['ga_id']; $this->ga_description=$array['ga_description']; $this->pa_id=$array['pa_id']; } }
Definition at line 109 of file class_anc_group.php.
References $array, $m, $obj, $r, $res, $sql, db, and Database\fetch_all().
{ $sql=" select ga_id,groupe_analytique.pa_id,pa_name,ga_description ". " from groupe_analytique ". " join plan_analytique using (pa_id)"; $r=$this->db->exec_sql($sql); $array=Database::fetch_all($r); $res=array(); if ( ! empty($array)) { foreach ($array as $m ) { $obj= new Anc_Group($this->db); $obj->get_from_array($m); $obj->pa_name=$m['pa_name']; $res[]=clone $obj; } } return $res; }
remove from the database
Definition at line 73 of file class_anc_group.php.
Set the filter (account_date)
Reimplemented from Anc_Print.
Definition at line 130 of file class_anc_group.php.
References $sql, from, from_poste, to, and to_poste.
Referenced by get_result().
{ $sql=""; $and="and "; if ( $this->from != "" ) { $sql.=" $and oa_date >= to_date('".$this->from."','DD.MM.YYYY')"; $and=" and "; } if ( $this->to != "" ) { $sql.=" $and oa_date <= to_date('".$this->to."','DD.MM.YYYY')"; $and=" and "; } if ( $this->from_poste != "" ) { $sql.=" $and upper(po_name)>= upper('".$this->from_poste."')"; $and=" and "; } if ( $this->to_poste != "" ) { $sql.=" $and upper(po_name)<= upper('".$this->to_poste."')"; $and=" and "; } return $sql; }
Anc_Group::show_button | ( | $ | p_hidden = "" | ) |
display the button export CSV
$p_hidden | is a string containing hidden items |
Definition at line 203 of file class_anc_group.php.
References $r, from, from_poste, HtmlInput\hidden(), HtmlInput\submit(), to, and to_poste.
{ $r=""; $r.= '<form method="GET" action="export.php" style="display:inline">'; $r.= HtmlInput::hidden("act","CSV:AncBalGroup"); $r.= HtmlInput::hidden("to",$this->to); $r.= HtmlInput::hidden("from",$this->from); $r.= HtmlInput::hidden("pa_id",$this->pa_id); $r.= HtmlInput::hidden("from_poste",$this->from_poste); $r.= HtmlInput::hidden("to_poste",$this->to_poste); $r.= $p_hidden; $r.= dossier::hidden(); $r.=HtmlInput::submit('bt_csv',"Export en CSV"); $r.= '</form>'; return $r; }
static Anc_Group::test_me | ( | ) | [static] |
Definition at line 237 of file class_anc_group.php.
References $cn, $r, echo, and id.
{ $cn=new Database(dossier::id()); print_r($cn); $o=new Anc_Group($cn); $r=$o->myList(); print_r($r); echo '<hr>'; print_r($o); $o->ga_id="DD' dd dDD"; $o->ga_description="Test 1"; $o->remove(); // $o->insert(); $o->ga_id="DD"; $o->ga_description="Test 1"; $o->remove(); $r=$o->myList(); print_r($r); }
Anc_Group::$db |
$db database connection
Reimplemented from Anc_Print.
Definition at line 36 of file class_anc_group.php.
Anc_Group::$ga_description |
Definition at line 38 of file class_anc_group.php.
Anc_Group::$ga_id |
Definition at line 37 of file class_anc_group.php.
Anc_Group::$pa_id |
Definition at line 39 of file class_anc_group.php.