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

class Customer are a specific kind of card More...

+ Inheritance diagram for Customer:
+ Collaboration diagram for Customer:

Public Member Functions

 __construct ($p_cn, $p_id=0)
 Constructor only a db connection is needed.
 
 get_by_account ($p_poste=0)
 Get all info contains in the view thanks to the poste elt (account)
 
 VatListing ($p_year)
 Get all the info for making a vat listing for the vat administration.
 
- Public Member Functions inherited from Fiche
 __toString ()
 
 belong_ledger ($p_jrn, $p_type="")
 Check if a fiche is used by a jrn return 1 if the fiche is in the range otherwise 0, the quick_code or the id must be set.
 
 blank ($p_fiche_def)
 insert a new record show a blank card to be filled
 
 build_sql ($array)
 create the sql statement for retrieving all the card
 
 button_csv ($p_from, $p_to)
 Return a string with the HTML code to display a button to export the history in CSV.
 
 button_pdf ($p_from, $p_to)
 Return a string with the HTML code to display a button to export the history in PDF.
 
 count_by_modele ($p_frd_id, $p_search="", $p_sql="")
 Count the nb of card with the reference card id frd_id.
 
 delete ()
 
 Display ($p_readonly, $p_in="")
 Display object instance, getAttribute sort the attribute and add missing ones.
 
 display_row ()
 display card as a table row , the tag TR must be added
 
 empty_attribute ($p_attr)
 check if an attribute is empty
 
 filter_history ($p_table_id)
 Filter in javascript the table with the history.
 
 Get ()
 Synonum of fiche::getAttribut.
 
 get_all_account ()
 
 get_amount_side ($p_amount)
 return the letter C if amount is > 0, D if < 0 or =
 
 get_bank_ledger ()
 Returns the Acc_Ledger_Fin ledger for which the card is the default bank account or null if no ledger is found.
 
 get_bk_account ()
 get the available bank_account filtered by the security
 
 get_bk_balance ($p_cond="")
 get the bank balance with receipt or not in Euro
 
 get_bk_balance_currency ($p_cond="")
 Get the sum in Currency.
 
 get_by_category ($p_offset=-1, $p_search="", $p_order='')
 get all the card thanks the fiche_def_ref
 
 get_by_qcode ($p_qcode=null, $p_all=true)
 Retrieve a card thx his quick_code complete the object,, set the id member of the object or set it to 0 if no card is found.
 
 get_categorie ()
 get the fd_id of the card : fd_id, it set the attribute fd_id
 
 get_f_enable ()
 
 get_fiche_def_ref ()
 
 get_fiche_def_ref_id ()
 retrieve the frd_id of the fiche it is the type of the card (bank, purchase...) (fiche_def_ref primary key)
 
 get_gestion_title ()
 
 get_id ()
 
 get_quick_code ()
 return the quick_code of a card
 
 get_row ($p_from, $p_to)
 Get data for poste.
 
 get_row_date ($p_from, $p_to, $op_let=0)
 Get data for poste.
 
 get_solde_detail ($p_cond="")
 give the balance of an card
 
 getAttribut ()
 get all the attribute of a card, add missing ones and sort the array ($this->attribut) by ad_id
 
 GetByDef ($p_frd_id, $p_offset=-1, $p_search="", $p_order='')
 Return array of card from the frd family deprecated , use insert get_by_category_id.
 
 getDisplayMode ()
 
 getLabelCategory ()
 
 getName ()
 return the name of a card
 
 HtmlTable ($p_array=null, $op_let=0, $from_div=1)
 HtmlTable, display a HTML of a card for the asked period.
 
 HtmlTableDetail ($p_array=null, $op_let=0)
 HtmlTable, display a HTML of a card for the asked period.
 
 HtmlTableHeader ($p_array=null)
 Display HTML Table Header (button)
 
 insert ($p_fiche_def, $p_array=null, $transaction=true)
 insert a new record thanks an array , either as parameter or $_POST
 
 is_used ()
 check if a card is used
 
 load ()
 Synonum of fiche::getAttribut.
 
 move_to ($p_fdid)
 move a card to another cat.
 
 remove ($silent=false)
 remove a card, check if not used first, must be synchro with is_used
 
 save ($p_fiche_def=0)
 Save a card, call insert or update.
 
 seek ($p_attribut, $p_value)
 find the card with the p_attribut equal to p_value, it is not case sensitive
 
 set_f_enable ($f_enable)
 
 set_fiche_def ($p_fiche_def)
 
 set_fiche_def_ref ($fiche_def_ref)
 
 set_id ($id)
 
 setAttribut ($p_ad_id, $p_value)
 set an attribute by a value, if the attribut array is empty a call to getAttribut is performed
 
 setDisplayMode ($p_mode)
 how the card is display : either in a window or a greated container
 
 ShowTable ()
 
 strAttribut ($p_ad_id, $p_return=1)
 
 Summary ($p_search="", $p_action="", $p_sql="", $p_amount=false)
 show the default screen
 
 to_array ()
 turn a card into an array , then it can be saved thanks update or insert
 
 update ($p_array=null)
 update a card with an array
 

Data Fields

 $country
 
 $cp
 
 $name
 
 $poste
 
 $street
 
 $vat_number
 
- Data Fields inherited from Fiche
 $attribut
 
 $cn
 
 $fiche_def
 
 $fiche_def_ref
 
 $id
 
 $ledger_description
 !< this variable is a mistake, it shouldn't exist, need code rewrite
 
 $ledger_name
 
 $quick_code
 
 $row
 
 $tot_cred
 
 $tot_deb
 

Additional Inherited Members

- Static Public Member Functions inherited from Fiche
static cmp_name (Fiche $o1, Fiche $o2)
 used with a usort function, to sort an array of Fiche on the name
 
static from_qcode ($p_qcode)
 create a card from a qcode and returns a card
 
static get_fiche_def ($p_cn, $pFd_id, $p_order='')
 get all the card from a categorie
 
static test_me ()
 

Detailed Description

class Customer are a specific kind of card

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

Constructor & Destructor Documentation

◆ __construct()

Customer::__construct ( $p_cn,
$p_id = 0 )

Constructor only a db connection is needed.

Reimplemented from Fiche.

Definition at line 44 of file customer.class.php.

45 {
46 $this->fiche_def_ref=FICHE_TYPE_CLIENT;
47 parent::__construct($p_cn,$p_id) ;
48
49 }
const FICHE_TYPE_CLIENT
Definition constant.php:247

References $p_id, and FICHE_TYPE_CLIENT.

Member Function Documentation

◆ get_by_account()

Customer::get_by_account ( $p_poste = 0)

Get all info contains in the view thanks to the poste elt (account)

Definition at line 53 of file customer.class.php.

54 {
55 $this->poste=($p_poste==0)?$this->poste:$p_poste;
56 $sql="select * from vw_client where poste_comptable=$1";
57 $Res=$this->cn->exec_sql($sql,array($this->poste));
58 if ( Database::num_row($Res) == 0) return null;
59 if ( Database::num_row($Res) > 1 ) throw new Exception ('Plusieurs fiches avec le même poste',1);
60 // There is only _one_ row by customer
62 $this->name=$row['name'];
63 $this->id=$row['f_id'];
64 $this->street=$row['rue'];
65 $this->cp=$row['code_postal'];
66 $this->country=$row['pays'];
67 $this->vat_number=$row['tva_num'];
68
69 }
$input_from cn
$from_poste name
static fetch_array($ret, $p_indice=0, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_array
static num_row($ret)
wrapper for the function pg_num_rows

References $Res, Fiche\$row, $sql, cn, DatabaseCore\fetch_array(), name, and DatabaseCore\num_row().

+ Here is the call graph for this function:

◆ VatListing()

Customer::VatListing ( $p_year)

Get all the info for making a vat listing for the vat administration.

Parameters
$p_year
Returns
double array structure is ( j_poste,name,vat_number,amount,tva,customer(object)

Definition at line 80 of file customer.class.php.

81 {
82 $cond_sql=" and A.j_date = B.j_date and extract(year from A.j_date) ='$p_year'";
83 /* List of customer */
84 $aCustomer=$this->cn->get_array('select f_id,name,quick_code,tva_num,poste_comptable from vw_client '.
85 " where tva_num !='' ");
86
87 /* Use the code */
88
89 // BASE ACCOUNT
90 // for belgium
91 $s=new Acc_Parm_Code($this->cn,'VENTE');
92 $s->load();
93 $SOLD=$s->p_value;
94
95 $c=new Acc_Parm_Code($this->cn,'CUSTOMER');
96 $c->load();
97 $CUSTOMER=$c->p_value;
98
99 $t=new Acc_Parm_Code($this->cn,'COMPTE_TVA');
100 $t->load();
101 $TVA=$t->p_value;
102
103 $a_Res=array();
104 /* for each customer compute VAT, Amount...*/
105 foreach ($aCustomer as $l )
106 {
107 // Seek the customer
108 //---
109 $customer=$l['quick_code'];
110 $a_Res[$customer]['name']=$l['name'];
111 $a_Res[$customer]['vat_number']=$l['tva_num'];
112 $a_Res[$customer]['amount']=0;
113 $a_Res[$customer]['tva']=0;
114 $a_Res[$customer]['poste_comptable']=$l['poste_comptable'];
115 /* retrieve only operation of sold and vat */
116 // Get all the sell operation
117 //----
118 $sql="select distinct j_grpt
119 from
120 jrnx as A
121 join jrnx as B using (j_grpt)
122 where
123 A.j_qcode = '".$l['quick_code']."' and
124 B.j_poste::text like '".$SOLD."%'
125 $cond_sql
126 ";
127
128 $Res=$this->cn->exec_sql($sql);
129 // Foreach operation
130 // where 7% or tva account are involved
131 // and store the result in an array (a_Res)
132 //---
133
134 for ($i=0; $i < Database::num_row($Res);$i++)
135 {
136 // Get each row
137 //---
139
140
141 // select the operation
142 //----
143 $Res2=$this->cn->exec_sql("select j_poste,j_montant,j_debit from jrnx where j_grpt=$1",[$row1['j_grpt']]);
145 if ($a_row==FALSE) $a_row=[];
146
147 // Store the amount in the array
148 //---
149 foreach ($a_row as $e)
150 {
151 $amount=0;
152 $tva=0;
153 if ( substr($e['j_poste'],0, strlen($SOLD))===$SOLD)
154 {
155 $amount=($e['j_debit']=='f')?$e['j_montant']:$e['j_montant']*-1;
156 }
157 if ( substr($e['j_poste'],0, strlen($TVA))===$TVA)
158 {
159 $tva=($e['j_debit']=='f')?$e['j_montant']:$e['j_montant']*-1;
160 }
161 // store sold
162 //---
163 $a_Res[$customer]['amount']=(isset($a_Res[$customer]['amount']))?$a_Res[$customer]['amount']:0;
164 $a_Res[$customer]['amount']+=$amount;
165
166 // store vat
167 //---
168 $a_Res[$customer]['tva']=(isset($a_Res[$customer]['tva']))?$a_Res[$customer]['tva']:0;
169 $a_Res[$customer]['tva']+=$tva;
170
171 // store customef info
172 //---
173 $a_Res[$customer]['customer']=$customer;
174 }
175 }// foreach $a
176 } // foreach ( customer)
177
178 return $a_Res;
179 }
static fetch_all($ret)
wrapper for the function pg_fetch_all
$t
Definition compute.php:46
$c
Definition compute.php:48

References $a_row, $amount, $c, $e, $i, $l, $Res, $s, $sql, $t, cn, DatabaseCore\fetch_all(), DatabaseCore\fetch_array(), and DatabaseCore\num_row().

+ Here is the call graph for this function:

Field Documentation

◆ $country

Customer::$country

$country Country

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

◆ $cp

Customer::$cp

$cp Zip code

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

◆ $name

Customer::$name

$name name of the company

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

◆ $poste

Customer::$poste

$poste poste comptable

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

◆ $street

Customer::$street

$street Street

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

◆ $vat_number

Customer::$vat_number

$vat_number vat number

Definition at line 39 of file customer.class.php.


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