noalyss Version-9
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
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
 
 form ()
 return a string with a form (into a table)
 
 from_array ($p_array)
 convert an array into an Acc_Payment object
 
 get_all ()
 retrieve all the data for all ledgers
 
 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
 
 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
 
 set_parameter ($p_string, $p_value)
 

Private Attributes

 $cn
 Database connection.
 
 $jrn_def_id
 
 $mp_fd_id
 
 $mp_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 38 of file acc_payment.class.php.

Constructor & Destructor Documentation

◆ __construct()

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

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

55 {
56 $this->cn=$p_cn;
57 $this->mp_id=$p_init;
58 }
$input_from cn

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 304 of file acc_payment.class.php.

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

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 157 of file acc_payment.class.php.

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

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 293 of file acc_payment.class.php.

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

References $l, and $p_array.

◆ get_all()

Acc_Payment::get_all ( )

retrieve all the data for all ledgers

Parameters
non
Returns
an array of row

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

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

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

◆ get_info()

Acc_Payment::get_info ( )

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

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

◆ get_parameter()

Acc_Payment::get_parameter ( $p_string)

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

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

References $idx.

◆ 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 134 of file acc_payment.class.php.

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

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

Referenced by select().

◆ load()

Acc_Payment::load ( )

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

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

214 {
215 $r='';
216 $array=$this->get_valide();
217 $r.=HtmlInput::hidden('gDossier',dossier::id());
218
219 if ( empty($array)==false ) {
220 $date_pay=new IDate('mp_date');
221 $date_pay->value=$p_date;
222 $r.=sprintf(_("Date %s"),
223 $date_pay->input());
224 $acompte=new INum('acompte');
225 $acompte->value=$p_amount;
226 $r.=_(" Acompte à déduire");
227 $r.=$acompte->input();
228 $r.='<p>';
229 $e_comm_paiement=new IText('e_comm_paiement');
230 $e_comm_paiement->value=$p_comm;
231 $e_comm_paiement->table = 0;
232 $e_comm_paiement->setReadOnly(false);
233 $e_comm_paiement->size = 60;
234 $e_comm_paiement->tabindex = 3;
235 $r.=_(" Libellé du paiement");
236 $r.=$e_comm_paiement->input();
237 $r.='</p>';
238 }
239
240 $r.='<ol>';
241 $r.='<li ><input type="radio" name="e_mp" value="0" checked>'._('Paiement encodé plus tard');
242 $http=new HttpInput();
243 if ( empty($array ) == false )
244 {
245 foreach ($array as $row)
246 {
247 $f='';
248 /* if the qcode is null the propose a search button to select
249 the card */
250 if ( $row->mp_qcode==NULL)
251 {
252 $a=new ICard();
253 $a->jrn=$row->mp_jrn_def_id;
254 $a->set_attribute('typecard',$row->mp_fd_id);
255 $a->name='e_mp_qcode_'.$row->mp_id;
256 $a->set_dblclick("fill_ipopcard(this);");
257 $a->set_callback('filter_card');
258 $a->set_function('fill_data');
259 $a->set_attribute('ipopup','ipopcard');
260 $a->set_attribute('label',$a->name.'_label');
261 if ( $p_select == $row->mp_id ) {
262 $a->value=$http->request("e_mp_qcode_".$p_select, "string","");
263 }
264 $s=new ISpan();
265 $s->name=$a->name.'_label';
266 $f=_(" paiement par ").$a->input().$s->input().$a->search();
267
268 }
269 else
270 {
271 /* if the qcode is not null then add a hidden variable with
272 the qcode */
273
274 $fiche=new Fiche($this->cn);
275 $fiche->get_by_qcode($row->mp_qcode);
276 $f=HtmlInput::hidden('e_mp_qcode_'.$row->mp_id,$row->mp_qcode);
277
278 // $f.=$fiche->strAttribut(ATTR_DEF_NAME);
279 }
280 $check=( $p_select == $row->mp_id)?" checked " : "unchecked";
281 $r.='<li><input type="radio" name="e_mp" value="'.$row->mp_id.'" '.$check.'>';
282 $r.=$row->mp_lib.' '.$f;
283
284 }
285 }
286 $r.='</ol>';
287 return $r;
288 }
_("actif, passif,charge,...")
get_valide()
retrieve all the data for a ledger but filter on the valid record (jrn and fd not null
static hidden($p_name, $p_value, $p_id="")
$check

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

+ Here is the call graph for this function:

◆ set_parameter()

Acc_Payment::set_parameter ( $p_string,
$p_value )

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

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

References $idx.

Field Documentation

◆ $cn

Acc_Payment::$cn
private

Database connection.

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

◆ $jrn_def_id

Acc_Payment::$jrn_def_id
private

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

Referenced by form().

◆ $mp_fd_id

Acc_Payment::$mp_fd_id
private

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

Referenced by form().

◆ $mp_id

Acc_Payment::$mp_id
private

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

◆ $mp_jrn_def_if

Acc_Payment::$mp_jrn_def_if
private

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

◆ $mp_lib

Acc_Payment::$mp_lib
private

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

Referenced by form().

◆ $mp_qcode

Acc_Payment::$mp_qcode
private

Definition at line 49 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 40 of file acc_payment.class.php.


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