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

Handle the table payment_method. More...

+ Collaboration diagram for Acc_Payment:

Public Member Functions

 __construct ($p_cn, $p_init=0)
 
 blank ()
 return an html with a form to add a new middle of payment More...
 
 form ()
 return a string with a form (into a table) More...
 
 from_array ($p_array)
 convert an array into an Acc_Payment object More...
 
 get_all ()
 retrieve all the data for all ledgers More...
 
 get_info ()
 
 get_parameter ($p_string)
 
 get_valide ()
 retrieve all the data for a ledger but filter on the valid record (jrn and fd not null More...
 
 load ()
 
 select ($p_select, $p_amount, $p_date, $p_comm)
 show several lines with radio button to select the payment method we want to use, the $_POST['e_mp'] will be set More...
 
 set_parameter ($p_string, $p_value)
 

Private Attributes

 $jrn_def_id
 
 $mp_fd_id
 
 $mp_jrn_def_if
 
 $mp_lib
 
 $mp_qcode
 

Static Private Attributes

static $variable
 

Detailed Description

Handle the table payment_method.

Note
the private data member are accessed via
  • mp_id ==> id ( Primary key )
  • mp_lib ==> lib (label)
  • mp_jrn_def_id ==> ledger (Number of the ledger where to save)
  • mp_fd_id ==> fiche_def (fiche class to use)
  • mp_qcode ==> qcode (quick_code of the card)

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

Constructor & Destructor Documentation

◆ __construct()

Acc_Payment::__construct (   $p_cn,
  $p_init = 0 
)

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

54 {
55 $this->cn=$p_cn;
56 $this->mp_id=$p_init;
57 }
$input_from cn
Definition: balance.inc.php:66

References cn.

Member Function Documentation

◆ blank()

Acc_Payment::blank ( )

return an html with a form to add a new middle of payment

Definition at line 303 of file acc_payment.class.php.

304 {
305 //label
306 $lib=new IText('mp_lib');
307 $f_lib=$lib->input();
308
309 $ledger_source=new ISelect('jrn_def_id');
310 $ledger_source->value=$this->cn->make_array("select jrn_def_id,jrn_Def_name from
311 jrn_def where jrn_def_type in ('ACH','VEN') order by jrn_def_name");
312 $f_source=$ledger_source->input();
313
314 // type of card
315 $tcard=new ISelect('mp_fd_id');
316 $tcard->value=$this->cn->make_array('select fd_id,fd_label from fiche_def join fiche_def_ref '.
317 ' using (frd_id) where frd_id in (25,4) order by fd_label');
318 $f_type_fiche=$tcard->input();
319 $ledger_record=new ISelect('mp_jrn_def_id');
320 $ledger_record->value=$this->cn->make_array("select jrn_def_id,jrn_Def_name from
321 jrn_def where jrn_def_type in ('ODS','FIN')");
322 $f_ledger_record=$ledger_record->input();
323
324 // the card
325 $qcode=new ICard();
326 $qcode->noadd=true;
327 $qcode->name='mp_qcode';
328 $list=$this->cn->make_list('select fd_id from fiche_def where frd_id in (25,4)');
329 $qcode->typecard=$list;
330 $qcode->dblclick='fill_ipopcard(this);';
331
332 $f_qcode=$qcode->input();
333 $msg="Ajout d'un nouveau moyen de paiement";
334 ob_start();
335 require_once NOALYSS_TEMPLATE.'/new_mod_payment.php';
336 $r=ob_get_contents();
337 ob_end_clean();
338 return $r;
339 }
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
Input HTML for the card show buttons, in the file, you have to add card.js How to use :
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
Html Input.
Definition: itext.class.php:30

References $list, $msg, $qcode, $r, and cn.

◆ form()

Acc_Payment::form ( )

return a string with a form (into a table)

Parameters
none
Returns
a html string

Definition at line 156 of file acc_payment.class.php.

157 {
158 //label
159 $lib=new IText('mp_lib');
160 $lib->value=$this->mp_lib;
161 $f_lib=$lib->input();
162
163
164 $ledger_source=new ISelect('jrn_def_id');
165 $ledger_source->value=$this->cn->make_array("select jrn_def_id,jrn_Def_name from
166 jrn_def where jrn_def_type in ('ACH','VEN') order by jrn_def_name");
167 $ledger_source->selected=$this->jrn_def_id;
168 $f_source=$ledger_source->input();
169
170 // type of card
171 $tcard=new ISelect('mp_fd_id');
172 $tcard->value=$this->cn->make_array('select fd_id,fd_label from fiche_def join fiche_def_ref '.
173 ' using (frd_id) where frd_id in (25,4) order by fd_label');
174 $tcard->selected=$this->mp_fd_id;
175
176 $f_type_fiche=$tcard->input();
177 $ledger_record=new ISelect('mp_jrn_def_id');
178 $ledger_record->value=$this->cn->make_array("select jrn_def_id,jrn_Def_name from
179 jrn_def where jrn_def_type in ('ODS','FIN')");
180 $ledger_record->selected=$this->mp_jrn_def_id;
181 $f_ledger_record=$ledger_record->input();
182
183 // the card
184 $qcode=new ICard();
185 $qcode->noadd=true;
186 $qcode->name='mp_qcode';
187 $list=$this->cn->make_list('select fd_id from fiche_def where frd_id in (25,4)');
188 $qcode->typecard=$list;
189 $qcode->dblclick='fill_ipopcard(this);';
190 $qcode->value=$this->mp_qcode;
191
192 $f_qcode=$qcode->input();
193
194 $msg="Modification de ".$this->mp_lib;
195 ob_start();
196 require_once NOALYSS_TEMPLATE.'/new_mod_payment.php';
197 $r=ob_get_contents();
198 ob_end_clean();
199 return $r;
200
201 }

References $jrn_def_id, $list, $mp_fd_id, $mp_lib, $mp_qcode, $msg, $qcode, $r, and cn.

◆ from_array()

Acc_Payment::from_array (   $p_array)

convert an array into an Acc_Payment object

Parameters
arrayto convert

Definition at line 292 of file acc_payment.class.php.

293 {
294 $a_index=array_values(self::$variable);
295 // $idx=array('mp_id','mp_lib','mp_fd_id','mp_jrn_def_id','mp_qcode','jrn_def_id');
296 foreach ($a_index as $l) {
297 if (isset($p_array[$l])) $this->$l=$p_array[$l];
298 }
299 }

References $l, $p_array, and $variable.

◆ get_all()

Acc_Payment::get_all ( )

retrieve all the data for all ledgers

Parameters
non
Returns
an array of row

Definition at line 111 of file acc_payment.class.php.

112 {
113 $sql='select mp_id,mp_lib '.
114 ' from payment_method order by mp_lib';
115 $array=$this->cn->get_array($sql);
116 $ret=array();
117 if ( !empty($array) )
118 {
119 foreach ($array as $row)
120 {
121 $t=new Acc_Payment($this->cn,$row['mp_id']);
122 $t->load();
123 $ret[]=$t;
124 }
125 }
126 return $ret;
127 }
Handle the table payment_method.

References $array, $ret, $row, $sql, and cn.

◆ get_info()

Acc_Payment::get_info ( )

Definition at line 82 of file acc_payment.class.php.

83 {
84 return var_export(self::$variable,true);
85 }

References $variable.

◆ get_parameter()

Acc_Payment::get_parameter (   $p_string)

Definition at line 58 of file acc_payment.class.php.

59 {
60 if ( array_key_exists($p_string,self::$variable) )
61 {
62 $idx=self::$variable[$p_string];
63 return $this->$idx;
64 }
65 else
66 {
67 throw new Exception("Attribut inexistant $p_string");
68 }
69 }
$idx

References $idx, and $variable.

◆ get_valide()

Acc_Payment::get_valide ( )

retrieve all the data for a ledger but filter on the valid record (jrn and fd not null

Parameters
non
Returns
an array of row

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

134 {
135 $sql='select mp_id '.
136 ' from payment_method '.
137 ' where jrn_def_id=$1 and mp_jrn_def_id is not null and '.
138 ' (mp_fd_id is not null or mp_qcode is not null)';
139 $array=$this->cn->get_array($sql,array($this->jrn_def_id));
140 $ret=array();
141 if ( !empty($array) )
142 {
143 foreach ($array as $row)
144 {
145 $t=new Acc_Payment($this->cn,$row['mp_id']);
146 $t->load();
147 $ret[]=$t;
148 }
149 }
150 return $ret;
151 }
margin jrn_def_id

References $array, $ret, $row, $sql, cn, and jrn_def_id.

Referenced by select().

◆ load()

Acc_Payment::load ( )

Definition at line 87 of file acc_payment.class.php.

87 :bool
88 {
89 $sql='select mp_id,mp_lib,mp_fd_id,mp_jrn_def_id,mp_qcode,jrn_def_id from payment_method '.
90 ' where mp_id = $1';
91 $res=$this->cn->exec_sql(
92 $sql,
93 array($this->mp_id)
94 );
95
96 if ( Database::num_row($res) == 0 ) return false;
97
99 $a_index=array_values(self::$variable);
100 foreach ($a_index as $idx)
101 {
102 $this->$idx=$row[$idx];
103 }
104 return true;
105 }
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 $idx, $res, $row, $sql, $variable, cn, DatabaseCore\fetch_array(), and DatabaseCore\num_row().

+ Here is the call graph for this function:

◆ select()

Acc_Payment::select (   $p_select,
  $p_amount,
  $p_date,
  $p_comm 
)

show several lines with radio button to select the payment method we want to use, the $_POST['e_mp'] will be set

Todo:
this class is used only for storage of the defined payment method, not the payment itself, it must be moved to another class 'Operation_Payment'
Parameters
$p_selectedif the id choose
$p_datedate of payment
$p_amountamount already paid
$p_commlabel of payment
Returns
html string

Definition at line 212 of file acc_payment.class.php.

213 {
214 $r='';
215 $array=$this->get_valide();
216 $r.=HtmlInput::hidden('gDossier',dossier::id());
217
218 if ( empty($array)==false ) {
219 $date_pay=new IDate('mp_date');
220 $date_pay->value=$p_date;
221 $r.=sprintf(_("Date %s"),
222 $date_pay->input());
223 $acompte=new INum('acompte');
224 $acompte->value=$p_amount;
225 $r.=_(" Acompte à déduire");
226 $r.=$acompte->input();
227 $r.='<p>';
228 $e_comm_paiement=new IText('e_comm_paiement');
229 $e_comm_paiement->value=$p_comm;
230 $e_comm_paiement->table = 0;
231 $e_comm_paiement->setReadOnly(false);
232 $e_comm_paiement->size = 60;
233 $e_comm_paiement->tabindex = 3;
234 $r.=_(" Libellé du paiement");
235 $r.=$e_comm_paiement->input();
236 $r.='</p>';
237 }
238
239 $r.='<ol>';
240 $r.='<li ><input type="radio" name="e_mp" value="0" checked>'._('Paiement encodé plus tard');
241 $http=new HttpInput();
242 if ( empty($array ) == false )
243 {
244 foreach ($array as $row)
245 {
246 $f='';
247 /* if the qcode is null the propose a search button to select
248 the card */
249 if ( $row->mp_qcode==NULL)
250 {
251 $a=new ICard();
252 $a->jrn=$row->mp_jrn_def_id;
253 $a->set_attribute('typecard',$row->mp_fd_id);
254 $a->name='e_mp_qcode_'.$row->mp_id;
255 $a->set_dblclick("fill_ipopcard(this);");
256 $a->set_callback('filter_card');
257 $a->set_function('fill_data');
258 $a->set_attribute('ipopup','ipopcard');
259 $a->set_attribute('label',$a->name.'_label');
260 if ( $p_select == $row->mp_id ) {
261 $a->value=$http->request("e_mp_qcode_".$p_select, "string","");
262 }
263 $s=new ISpan();
264 $s->name=$a->name.'_label';
265 $f=_(" paiement par ").$a->input().$s->input().$a->search();
266
267 }
268 else
269 {
270 /* if the qcode is not null then add a hidden variable with
271 the qcode */
272
273 $fiche=new Fiche($this->cn);
274 $fiche->get_by_qcode($row->mp_qcode);
275 $f=HtmlInput::hidden('e_mp_qcode_'.$row->mp_id,$row->mp_qcode);
276
277 // $f.=$fiche->strAttribut(ATTR_DEF_NAME);
278 }
279 $check=( $p_select == $row->mp_id)?" checked " : "unchecked";
280 $r.='<li><input type="radio" name="e_mp" value="'.$row->mp_id.'" '.$check.'>';
281 $r.=$row->mp_lib.' '.$f;
282
283 }
284 }
285 $r.='</ol>';
286 return $r;
287 }
$input_from id
Definition: balance.inc.php:63
get_valide()
retrieve all the data for a ledger but filter on the valid record (jrn and fd not null
define Class fiche and fiche def, those class are using class attribut. When adding or modifing new c...
Definition: fiche.class.php:38
static hidden($p_name, $p_value, $p_id="")
manage the http input (get , post, request) and extract from an array
Html Input : Input a date format dd.mm.yyyy The property title should be set to indicate what it is e...
Definition: idate.class.php:34
This class handles only the numeric input, the input will call a javascript to change comma to period...
Definition: inum.class.php:42
Html Input.
Definition: ispan.class.php:32
$acompte
$check

References $a, $acompte, $array, $check, $f, $fiche, $http, $p_date, $r, $row, $s, cn, get_valide(), HtmlInput\hidden(), and id.

+ Here is the call graph for this function:

◆ set_parameter()

Acc_Payment::set_parameter (   $p_string,
  $p_value 
)

Definition at line 70 of file acc_payment.class.php.

71 {
72 if ( array_key_exists($p_string,self::$variable) )
73 {
74 $idx=self::$variable[$p_string];
75 $this->$idx=$p_value;
76 }
77 else
78 throw new Exception("Attribut inexistant $p_string");
79
80
81 }

References $idx, and $variable.

Field Documentation

◆ $jrn_def_id

Acc_Payment::$jrn_def_id
private

Definition at line 50 of file acc_payment.class.php.

Referenced by form().

◆ $mp_fd_id

Acc_Payment::$mp_fd_id
private

Definition at line 51 of file acc_payment.class.php.

Referenced by form().

◆ $mp_jrn_def_if

Acc_Payment::$mp_jrn_def_if
private

Definition at line 49 of file acc_payment.class.php.

◆ $mp_lib

Acc_Payment::$mp_lib
private

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

Referenced by form().

◆ $mp_qcode

Acc_Payment::$mp_qcode
private

Definition at line 48 of file acc_payment.class.php.

Referenced by form().

◆ $variable

Acc_Payment::$variable
staticprivate
Initial value:
=array("id"=>"mp_id",
"lib"=>"mp_lib",
"qcode"=>"mp_qcode",
"ledger_target"=>"mp_jrn_def_id",
"ledger_source"=>"jrn_def_id",
"fiche_def"=>"mp_fd_id")

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


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