noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
Acc_Plan_SQL Class Reference

this class is above tmp_pcmn_sql and is a view of tmp_pcmn More...

+ Inheritance diagram for Acc_Plan_SQL:
+ Collaboration diagram for Acc_Plan_SQL:

Public Member Functions

 __construct ($p_cn, $p_id=-1)
 
 count ($p_where="", $p_array=null)
 
 delete ()
 
 exist ()
 Count the number of record with the id ,.
 
 get_limit_fiche_qcode ()
 
 get_pk_value ()
 
 insert ()
 
 load ()
 Load the current row return false if not found.
 
 seek ($cond='', $p_array=null)
 retrieve array of object thanks a condition
 
 set_limit_fiche_qcode ($limit_fiche_qcode)
 
 update ()
 
- Public Member Functions inherited from Data_SQL
 __construct (DatabaseCore $p_cn, $p_id=-1)
 
 __get ($cols)
 
 __set ($cols, $p_value)
 
 __toString ()
 
 collect_objects ($cond='', $p_array=null)
 return an array of objects.
 
 from_array ($p_array)
 Transform an array into object.
 
 get ($cols)
 get the value thanks the colum name and not the alias (name).
 
 get_a_virtual_col ()
 return array of virtual cols (alias calculated, formatted cols)
 
 get_cn ()
 
 get_info ()
 
 get_name ()
 
 get_object ($p_ret, $idx)
 
 get_primary_key ()
 
 get_type ()
 
 getp ($cols)
 set the value thanks the alias name instead of the colum name if not found try the column name
 
 next ($ret, $i)
 get_seek return the next object, the return of the query must have all the column of the object including the virtual columns
 
 save ()
 Insert or update : if the row already exists, update otherwise insert.
 
 set ($cols, $p_value)
 set the value thanks the colum name and not the alias (name)
 
 set_cn ($cn)
 
 set_name ($name)
 
 set_pk_value ($p_value)
 
 set_primary_key ($primary_key)
 
 set_type ($type)
 
 set_virtual_col ($col_name, $sql_expression)
 add a virtual column (formatted column, sum of 2 col, ...)
 
 setp ($cols, $p_value)
 set the value thanks the alias name instead of the colum name, if not found try the column name
 
 to_array ($prefix="")
 Turn an object (row) into an array, and the key could be prefixed with $prefix.
 
 to_row ($p_array)
 update the data member of current object with the value from the array.
 
 verify ()
 

Data Fields

 $sql
 
- Data Fields inherited from Data_SQL
 $cn
 
 $date_format
 Type of the data.
 
 $default
 defaullt date format
 
 $name
 Database connection.
 
 $primary_key
 Array of logical and real name.
 
 $table
 
 $type
 Column name of the primary key.
 

Private Attributes

 $limit_fiche_qcode
 

Additional Inherited Members

- Protected Attributes inherited from Data_SQL
 $a_virtual_col
 

Detailed Description

this class is above tmp_pcmn_sql and is a view of tmp_pcmn

See also
Tmp_Pcmn_SQL
Acc_Plan_MTable
Examples
test_manage_table_sql.php.

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

Constructor & Destructor Documentation

◆ __construct()

Acc_Plan_SQL::__construct ( $p_cn,
$p_id = -1 )

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

38 {
39 $this->table = "accounting_card";
40 $this->primary_key = "id";
41 $this->limit_fiche_qcode=0;
42 $this->name = array(
43 "id" => "id",
44 "pcm_val"=>"pcm_val",
45 "parent_accounting"=>"parent_accounting",
46 "pcm_lib"=>"pcm_lib",
47 "pcm_type"=>"pcm_type",
48 "fiche_qcode"=>"fiche_qcode",
49 "pcm_direct_use"=>"pcm_direct_use"
50 );
51
52 $this->type = array(
53 "id" => "numeric",
54 "pcm_val" => "text",
55 "parent_accounting" => "text",
56 "pcm_lib" => "text",
57 "pcm_type" => "text",
58 "fiche_qcode"=>"string",
59 "pcm_direct_use"=>"text"
60 );
61
62 $this->default = array(
63 "id" => "auto",
64 "fiche_qcode"=>"auto"
65 );
66 $this->sql="
67 SELECT pcm_val,
68 pcm_lib,
69 pcm_val_parent as parent_accounting,
70 pcm_type,
71 id,
72 pcm_direct_use,
73 (select string_agg(m.fiche_qcode,' , ')
74 from (select a.ad_value as fiche_qcode
75 from fiche_detail as a
76 join fiche_detail as b on (a.ad_id=23 and a.f_id=b.f_id and b.ad_id=5)
77 where b.ad_value=pcm_val::text order by a.ad_value %s)as m) as fiche_qcode
78 FROM public.tmp_pcmn
79
80";
81 parent::__construct($p_cn,$p_id);
82 }
$from_poste name
$input_from type
$all table

References $p_id, name, table, and type.

Member Function Documentation

◆ count()

Acc_Plan_SQL::count ( $p_where = "",
$p_array = null )

Reimplemented from Data_SQL.

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

85 {
86 throw new Exception("not implemented");
87 }

References $p_array.

◆ delete()

Acc_Plan_SQL::delete ( )

Reimplemented from Data_SQL.

Definition at line 89 of file acc_plan_sql.class.php.

90 {
91 $obj=new Tmp_Pcmn_SQL($this->cn,$this->id);
92 if ( $this->cn->get_value("select count(*) from jrnx where j_poste=$1",[$obj->pcm_val]) > 0)
93 {
94 throw new Exception(_("Impossible d'effacer : ce poste est utilisé"));
95 }
96 if ( $this->cn->get_value("select count(*) from tmp_pcmn where pcm_val_parent=$1",[$obj->pcm_val]) > 0)
97 {
98 throw new Exception(_("Impossible d'effacer : ce poste est utilisé"));
99 }
100 return $obj->delete();
101
102 }
catch(Exception $e) $obj
$input_from cn
_("actif, passif,charge,...")

References $obj, _, and cn.

◆ exist()

Acc_Plan_SQL::exist ( )

Count the number of record with the id ,.

Returns
integer 0 doesn't exist , 1 exists

Reimplemented from Data_SQL.

Definition at line 104 of file acc_plan_sql.class.php.

105 {
106 $obj=new Tmp_Pcmn_SQL($this->cn,$this->id);
107 return $obj->exist();
108 }

References $obj, and cn.

◆ get_limit_fiche_qcode()

Acc_Plan_SQL::get_limit_fiche_qcode ( )

Definition at line 173 of file acc_plan_sql.class.php.

174 {
176 }

References $limit_fiche_qcode.

Referenced by load(), and seek().

◆ get_pk_value()

Acc_Plan_SQL::get_pk_value ( )

Reimplemented from Data_SQL.

Definition at line 121 of file acc_plan_sql.class.php.

122 {
123 return $this->id;
124 }

References $id.

◆ insert()

Acc_Plan_SQL::insert ( )

Reimplemented from Data_SQL.

Definition at line 110 of file acc_plan_sql.class.php.

111 {
112 $obj=new Tmp_Pcmn_SQL($this->cn);
113 $obj->set("pcm_val",$this->pcm_val);
114 $obj->set("pcm_lib",$this->pcm_lib);
115 $obj->set("pcm_type",$this->pcm_type);
116 $obj->set("pcm_val_parent",$this->parent_accounting);
117 $obj->set("pcm_direct_use",$this->pcm_direct_use);
118 $obj->insert();
119 $this->id=$obj->id;
120 }

References $obj, and cn.

◆ load()

Acc_Plan_SQL::load ( )

Load the current row return false if not found.

if ( $this->get_limit_fiche_qcode() != 0 )
{
$sql=sprintf($this->sql," limit ".$this->get_limit_fiche_qcode());
} else
{
$sql=sprintf($this->sql," ");
}
$result=$this->cn->get_array($sql. " where id=$1",array ($this->$pk));
if ($this->cn->count()==0)
{
$this->$pk=-1;
return false;
}
foreach ($result[0] as $key=> $value)
{
$this->$key=$value;
}
return true;
$primary_key
Array of logical and real name.
Returns
bool

Reimplemented from Data_SQL.

Definition at line 125 of file acc_plan_sql.class.php.

125 :bool
126 {
128 if ( $this->get_limit_fiche_qcode() != 0 )
129 {
130 $sql=sprintf($this->sql," limit ".$this->get_limit_fiche_qcode());
131 } else
132 {
133 $sql=sprintf($this->sql," ");
134 }
135 $result=$this->cn->get_array($sql. " where id=$1",array ($this->$pk));
136 if ($this->cn->count()==0)
137 {
138 $this->$pk=-1;
139 return false;
140 }
141
142 foreach ($result[0] as $key=> $value)
143 {
144 $this->$key=$value;
145 }
146 return true;
147 }

References Data_SQL\$primary_key, $result, $sql, $value, cn, and get_limit_fiche_qcode().

+ Here is the call graph for this function:

◆ seek()

Acc_Plan_SQL::seek ( $cond = '',
$p_array = null )

retrieve array of object thanks a condition

Parameters
$condcondition (where clause) (optional by default all the rows are fetched) you can use this parameter for the order or subselect
$p_arrayarray for the SQL stmt
See also
Database\exec_sql get_object Database\num_row
Returns
the return value of exec_sql

Reimplemented from Data_SQL.

Definition at line 149 of file acc_plan_sql.class.php.

150 {
151 if ( $this->get_limit_fiche_qcode() != 0 )
152 {
153 $sql=sprintf($this->sql," limit ".$this->get_limit_fiche_qcode());
154 } else
155 {
156 $sql=sprintf($this->sql," ");
157 }
158 $ret=$this->cn->exec_sql($sql." ".$cond,$p_array);
159 return $ret;
160 }

References $p_array, $ret, $sql, cn, and get_limit_fiche_qcode().

+ Here is the call graph for this function:

◆ set_limit_fiche_qcode()

Acc_Plan_SQL::set_limit_fiche_qcode ( $limit_fiche_qcode)

Definition at line 178 of file acc_plan_sql.class.php.

179 {
180 $this->limit_fiche_qcode=$limit_fiche_qcode;
181 }

References $limit_fiche_qcode.

◆ update()

Acc_Plan_SQL::update ( )

Reimplemented from Data_SQL.

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

163 {
164 $obj=new Tmp_Pcmn_SQL($this->cn,$this->id);
165 $obj->set("pcm_val",$this->pcm_val);
166 $obj->set("pcm_lib",$this->pcm_lib);
167 $obj->set("pcm_type",$this->pcm_type);
168 $obj->set("pcm_val_parent",$this->parent_accounting);
169 $obj->set("pcm_direct_use",$this->pcm_direct_use);
170
171 $obj->update();
172 }

References $obj, and cn.

Field Documentation

◆ $limit_fiche_qcode

Acc_Plan_SQL::$limit_fiche_qcode
private

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

Referenced by get_limit_fiche_qcode(), and set_limit_fiche_qcode().

◆ $sql

Acc_Plan_SQL::$sql

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

Referenced by load(), and seek().


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