phpcompta  Version-6
 All Data Structures Namespaces Files Functions Variables Pages
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:
Anc_Print

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 ()
 
 show_button ($p_hidden="")
 display the button export CSV
 
- Public Member Functions inherited from Anc_Print
 Anc_Print ($p_cn)
 
 check ()
 
 display_form ($p_hidden="")
 Compute the form to display.
 
 get_request ()
 complete the object with the data in $_REQUEST
 
 set_sql_filter ()
 Set the filter (account_date)
 

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 35 of file class_anc_group.php.

Constructor & Destructor Documentation

Anc_Group::__construct (   $p_cn)

Definition at line 42 of file class_anc_group.php.

References db.

{
$this->db=$p_cn;
$this->ga_id=null;
$this->ga_description=null;
$this->pa_id=null;
}

Member Function Documentation

Anc_Group::display_html ( )

Definition at line 185 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');
}
Anc_Group::export_csv ( )

Definition at line 220 of file class_anc_group.php.

References $array, $i, 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)

fill the object thanks an array

Parameters
array

Definition at line 104 of file class_anc_group.php.

References $p_array.

{
$this->ga_id=$p_array['ga_id'];
$this->pa_id=$p_array['pa_id'];
$this->ga_description=$p_array['ga_description'];
}
Anc_Group::get_result ( )

Definition at line 159 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;
}
Anc_Group::insert ( )

insert into the database an object

Returns
message with error otherwise an empty string

Definition at line 54 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 86 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);
if ( ! empty($array) )
{
$this->ga_id=$array['ga_id'];
$this->ga_description=$array['ga_description'];
$this->pa_id=$array['pa_id'];
}
}
Anc_Group::myList ( )

Definition at line 110 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);
$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;
}
Anc_Group::remove ( )

remove from the database

Definition at line 74 of file class_anc_group.php.

References $sql, and db.

{
$this->ga_id=str_replace(' ','',$this->ga_id);
$this->ga_id=strtoupper($this->ga_id);
$sql=" delete from groupe_analytique where ga_id='".Database::escape_string($this->ga_id)."'";
$this->db->exec_sql($sql);
}
Anc_Group::set_sql_filter ( )

Definition at line 131 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

Parameters
$p_hiddenis a string containing hidden items
Returns
html string

Definition at line 204 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 238 of file class_anc_group.php.

References $cn, $r, and 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);
}

Field Documentation

Anc_Group::$db

Definition at line 37 of file class_anc_group.php.

Anc_Group::$ga_description

Definition at line 39 of file class_anc_group.php.

Anc_Group::$ga_id

Definition at line 38 of file class_anc_group.php.

Anc_Group::$pa_id

Definition at line 40 of file class_anc_group.php.


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