noalyss Version-9
Public Member Functions | Private Member Functions | Private Attributes
contact Class Reference

Class contact (customer, supplier...) More...

+ Inheritance diagram for contact:
+ Collaboration diagram for contact:

Public Member Functions

 __construct ($p_cn, $p_id=0)
 constructor More...
 
 build_sql ($array)
 Build the SQL query thanks the parameter. More...
 
 filter_active (bool $p_active)
 
 filter_category ($pn_category)
 
 filter_company ($p_company=null)
 
 filter_search ($p_search="")
 
 getFilter ()
 
 Summary ($p_search="", $p_action="", $p_sql="", $p_nothing=false)
 display a summary of the contact card, More...
 
- Public Member Functions inherited from Fiche
 __construct ($p_cn, $p_id=0)
 
 __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. More...
 
 blank ($p_fiche_def)
 insert a new record show a blank card to be filled More...
 
 build_sql ($array)
 create the sql statement for retrieving all the card More...
 
 button_csv ($p_from, $p_to)
 Return a string with the HTML code to display a button to export the history in CSV. More...
 
 button_pdf ($p_from, $p_to)
 Return a string with the HTML code to display a button to export the history in PDF. More...
 
 count_by_modele ($p_frd_id, $p_search="", $p_sql="")
 Count the nb of card with the reference card id frd_id. More...
 
 delete ()
 
 Display ($p_readonly, $p_in="")
 Display object instance, getAttribute sort the attribute and add missing ones. More...
 
 display_row ()
 display card as a table row , the tag TR must be added More...
 
 empty_attribute ($p_attr)
 check if an attribute is empty More...
 
 filter_history ($p_table_id)
 Filter in javascript the table with the history. More...
 
 Get ()
 Synonum of fiche::getAttribut. More...
 
 get_all_account ()
 
 get_amount_side ($p_amount)
 return the letter C if amount is > 0, D if < 0 or = More...
 
 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. More...
 
 get_bk_account ()
 get the available bank_account filtered by the security More...
 
 get_bk_balance ($p_cond="")
 get the bank balance with receipt or not in Euro More...
 
 get_bk_balance_currency ($p_cond="")
 Get the sum in Currency. More...
 
 get_by_category ($p_offset=-1, $p_search="", $p_order='')
 get all the card thanks the fiche_def_ref More...
 
 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. More...
 
 get_categorie ()
 get the fd_id of the card : fd_id, it set the attribute fd_id More...
 
 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) More...
 
 get_gestion_title ()
 
 get_id ()
 
 get_quick_code ()
 return the quick_code of a card More...
 
 get_row ($p_from, $p_to)
 Get data for poste. More...
 
 get_row_date ($p_from, $p_to, $op_let=0)
 Get data for poste. More...
 
 get_solde_detail ($p_cond="")
 give the balance of an card More...
 
 getAttribut ()
 get all the attribute of a card, add missing ones and sort the array ($this->attribut) by ad_id More...
 
 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. More...
 
 getDisplayMode ()
 
 getLabelCategory ()
 
 getName ()
 return the name of a card More...
 
 HtmlTable ($p_array=null, $op_let=0, $from_div=1)
 HtmlTable, display a HTML of a card for the asked period. More...
 
 HtmlTableDetail ($p_array=null, $op_let=0)
 HtmlTable, display a HTML of a card for the asked period. More...
 
 HtmlTableHeader ($p_array=null)
 Display HTML Table Header (button) More...
 
 insert ($p_fiche_def, $p_array=null, $transaction=true)
 insert a new record thanks an array , either as parameter or $_POST More...
 
 is_used ()
 check if a card is used More...
 
 load ()
 Synonum of fiche::getAttribut. More...
 
 move_to ($p_fdid)
 move a card to another cat. More...
 
 remove ($silent=false)
 remove a card, check if not used first, must be synchro with is_used More...
 
 save ($p_fiche_def=0)
 Save a card, call insert or update. More...
 
 seek ($p_attribut, $p_value)
 find the card with the p_attribut equal to p_value, it is not case sensitive More...
 
 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 More...
 
 setDisplayMode ($p_mode)
 how the card is display : either in a window or a greated container More...
 
 ShowTable ()
 
 strAttribut ($p_ad_id, $p_return=1)
 
 Summary ($p_search="", $p_action="", $p_sql="", $p_amount=false)
 show the default screen More...
 
 to_array ()
 turn a card into an array , then it can be saved thanks update or insert More...
 
 update ($p_array=null)
 update a card with an array More...
 

Private Member Functions

 fetch ($ps_sql)
 Fetch all rows from view, ordered by by contact_name, with offset and limit. More...
 

Private Attributes

 $filter
 

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 More...
 
static from_qcode ($p_qcode)
 create a card from a qcode and returns a card More...
 
static get_fiche_def ($p_cn, $pFd_id, $p_order='')
 get all the card from a categorie More...
 
static test_me ()
 
- Data Fields inherited from Fiche
 $attribut
 
 $cn
 
 $fiche_def
 
 $fiche_def_ref
 
 $id
 
 $quick_code
 
 $row
 
 $tot_cred
 
 $tot_deb
 

Detailed Description

Class contact (customer, supplier...)

Definition at line 30 of file contact.class.php.

Constructor & Destructor Documentation

◆ __construct()

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

constructor

Reimplemented from Fiche.

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

36 {
37 $this->fiche_def_ref=FICHE_TYPE_CONTACT;
38 parent::__construct($p_cn,$p_id) ;
39 $this->filter=[];
40 }
const FICHE_TYPE_CONTACT
Definition: constant.php:251

References $p_id, and FICHE_TYPE_CONTACT.

Member Function Documentation

◆ build_sql()

contact::build_sql (   $array)

Build the SQL query thanks the parameter.

Parameters
array$arrayif empty , we use $this->filter , otherwise $array will override it
Returns
string

Reimplemented from Fiche.

Definition at line 47 of file contact.class.php.

48 {
49 if ( empty($array) ) $array=$this->filter;
50
51 $sql_query='
52 SELECT f_id,
53 contact_fname,
54 contact_name,
55 contact_qcode,
56 contact_company,
57 contact_mobile,
58 contact_phone,
59 contact_email,
60 contact_fax
61 FROM public.v_contact
62 ';
63 $where=' where ';$and='';
64 if ( isset ($array['company'])) {
65 $sql_query.=$where.sprintf(" contact_company ilike '%%%s%%'",
66 sql_string($array['company']));
67 $where='';$and=' and ';
68 }
69 if ( isset($array['search'])) {
70 $sql_query.=$where.$and.sprintf(" f_id in (select distinct f_id from fiche_detail where ad_value ilike '%%%s%%')",
71 sql_string($array['search']));
72 $where='';$and=' and ';
73
74 }
75 if ( isset($array['category'])) {
76 $sql_query.=$where.$and.sprintf(" fd_id = %s",
77 sql_string($array['category']));
78 $where='';$and=' and ';
79 }
80 if ( isset ($array['active']) && $array['active'] == true) {
81 $sql_query .= $where.$and.sprintf(" f_enable='1' ");
82 $where='';$and=' and ';
83 }
84 return $sql_query;
85 }
sql_string($p_string)
Fix the problem with the quote char for the database.
Definition: ac_common.php:511

References $array, $filter, and sql_string().

Referenced by Summary().

+ Here is the call graph for this function:

◆ fetch()

contact::fetch (   $ps_sql)
private

Fetch all rows from view, ordered by by contact_name, with offset and limit.

See also
Contact::build_sql()
Parameters
$ps_string
Returns
array

Definition at line 167 of file contact.class.php.

167 {
168 $http=new HttpInput();
169 // Get offset and page variable
170 $offset=$http->request('offset','number',0);
171 $nb_pagesize=$_SESSION[SESSION_KEY.'g_pagesize'];
172 $limit = '';
173 $ps_sql.=' order by contact_name ';
174 if ( $nb_pagesize <0 ) {$limit='';} else {
175 $limit=sprintf(' limit %s offset %s',$nb_pagesize,$offset);
176 }
177 $ps_sql .= $limit ;
178 if (DEBUGNOALYSS > 1) {
179 var_export("Contact::fetch ($ps_sql)");
180 }
181 return $this->cn->get_array($ps_sql);
182 }
$input_from cn
Definition: balance.inc.php:66
manage the http input (get , post, request) and extract from an array

References $http, $limit, $offset, and cn.

Referenced by Summary().

◆ filter_active()

contact::filter_active ( bool  $p_active)

Definition at line 86 of file contact.class.php.

86 {
87 if ( $p_active) {
88 $this->filter['active']=true;
89 } else {
90 $this->filter['active']=false;
91 }
92 }

◆ filter_category()

contact::filter_category (   $pn_category)

Definition at line 93 of file contact.class.php.

93 {
94 unset($this->filter['category']);
95 if ( !empty($pn_category)
96 && isNumber($pn_category)==1
97 && $pn_category != -1){
98 $this->filter['category']=$pn_category;
99 }
100 }
isNumber($p_int)
Definition: ac_common.php:215

References isNumber().

+ Here is the call graph for this function:

◆ filter_company()

contact::filter_company (   $p_company = null)

Definition at line 101 of file contact.class.php.

101 {
102 unset($this->filter['company']);
103 if ( ! empty($p_company) && $p_company != "-1") {
104 $this->filter['company']= strtoupper($p_company);
105 }
106 return $this;
107 }

◆ filter_search()

contact::filter_search (   $p_search = "")

Definition at line 108 of file contact.class.php.

108 {
109 unset($this->filter['search']);
110 if ( ! empty($p_search) ){
111 $this->filter['search']=$p_search;
112 }
113 }

Referenced by Summary().

◆ getFilter()

contact::getFilter ( )
Returns
array

Definition at line 118 of file contact.class.php.

118 : array
119 {
120 return $this->filter;
121 }

References $filter.

◆ Summary()

contact::Summary (   $p_search = "",
  $p_action = "",
  $p_sql = "",
  $p_nothing = false 
)

display a summary of the contact card,

Parameters
stringp_search : filter on card name, if empty , contact->filter will be used
stringp_action : not used
stringp_sql : extra SQL command not used
stringp_nothing (filter) not used
Returns
string to display

Reimplemented from Fiche.

Definition at line 133 of file contact.class.php.

134 {
135 $http=new HttpInput();
136 if ( !empty ($p_search) ) { $this->filter_search($p_search);}
137
138 $sql=$this->build_sql($this->filter);
139 \Noalyss\Dbg::echo_var(1,"Contact::summary ($sql)");
140 // Creation of the nav bar
141 // Get the max numberRow
142 $all_contact=$this->cn->get_value("select count(*) from ($sql) as m");
143 if ( $all_contact == 0 ) return "";
144
145 // Get offset and page variable
146 $offset=$http->request('offset','number',0);
147 $page=$http->request('page','number',1);
148
149 $bar=navigation_bar($offset,$all_contact,$_SESSION[SESSION_KEY.'g_pagesize'],$page);
150
151
152 // Get The result Array
153 $step_contact=$this->fetch($sql);
154
155
156 $contact=$this;
157 require NOALYSS_TEMPLATE.'/contact-summary.php';
158
159 }
static echo_var($n_level, $msg, $print=true)
Display the value of a var if DEBUGNOALYSS is greater than $n_level, the debugging info has a certain...
Definition: dbg.php:45
build_sql($array)
Build the SQL query thanks the parameter.
fetch($ps_sql)
Fetch all rows from view, ordered by by contact_name, with offset and limit.
filter_search($p_search="")
navigation_bar($p_offset, $p_line, $p_size=0, $p_page=1, $p_javascript="")
Create a navigation_bar (pagesize)
Definition: user_common.php:76

References $bar, $http, $offset, $page, $sql, build_sql(), cn, Noalyss\Dbg\echo_var(), fetch(), filter_search(), and navigation_bar().

+ Here is the call graph for this function:

Field Documentation

◆ $filter

contact::$filter
private

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

Referenced by build_sql(), and getFilter().


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