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

mother class for the lettering by account and by card use the tables jnt_letter, letter_deb and letter_cred More...

+ Inheritance diagram for Lettering:
+ Collaboration diagram for Lettering:

Public Member Functions

 __construct ( $p_init)
 constructor
 
 delete ()
 
 get_info ()
 
 get_linked ($p_jlid)
 
 get_parameter ($p_string)
 
 insert ()
 
 insert_couple ($j_id1, $j_id2)
 Use to just insert a couple of lettered operation but do not make a link between operation.
 
 load ()
 
 remove_incoherent ()
 for some reason , sometimes, a record in letter_X doesn't have his counterpart in letter_Y
 
 save ($p_array)
 save from array, letter the accounting (or card) and create a link between operation
 
 seek ($cond, $p_array=null)
 retrieve * row thanks a condition
 
 set_parameter ($p_string, $p_value)
 
 show_letter ($p_jid)
 
 show_list ($p_type)
 wrapper : it call show_all, show_lettered or show_not_lettered depending of the parameter
 
 update ()
 
 verify ()
 

Data Fields

 $content
 
 $db
 
 $end
 
 $fil_amount_max
 
 $fil_amount_min
 
 $fil_deb
 
 $linked
 
 $object_type
 
 $sql_ledger
 
 $start
 

Protected Member Functions

 show_all ()
 show all the record from jrnx and their status (linked or not) it fills the array $this->content
 
 show_lettered ()
 show only the lettered records from jrnx it fills the array $this->content
 
 show_lettered_diff ()
 show only the lettered records from jrnx it fills the array $this->content
 
 show_not_lettered ()
 show only the not lettered records from jrnx it fills the array $this->content
 

Protected Attributes

 $variable
 $variable (array) data member
 

Detailed Description

mother class for the lettering by account and by card use the tables jnt_letter, letter_deb and letter_cred

  • "account"=>"account", => the accounting of the j_id (use by Lettering_Account)
  • "quick_code"=>"quick_code", => the quick_code of the j_id (used by Lettering_Card)
  • "start"=>"start", => date of the first day
  • "end"=>"end", => date of the last day
  • "sql_ledger"=>"sql_ledger" => the sql clause to filter on the available ledgers
See also
unit-test/include/class/acc_letterTest.php
test scenario scenario/XML/ajax_display_letter.php

Definition at line 45 of file lettering.class.php.

Constructor & Destructor Documentation

◆ __construct()

Lettering::__construct ( $p_init)

constructor

Parameters
$p_initresource to database
Note
by default start and end are the 1.1.exercice to 31.12.exercice

Definition at line 72 of file lettering.class.php.

73 {
74 $this->db=$p_init;
75 $a=new Noalyss_user($p_init);
76 $exercice=$a->get_exercice();
77 if ($exercice>0)
78 {
79 $periode=new Periode($p_init);
80 $aLimite=$periode->get_limit($exercice);
81 $this->start=$aLimite[0]->first_day();
82 $this->end=$aLimite[1]->last_day();
83 }
84 else
85 {
86 $this->start='01.01.'.$exercice;
87 $this->end='31.12.'.$exercice;
88 }
89 // available ledgers
90 $this->sql_ledger=noalyss_str_replace('jrn_def_id', 'jr_def_id', $a->get_ledger_sql('ALL', 3));
91 }
noalyss_str_replace($search, $replace, $string)
catch(Exception $e) $exercice
$SecUser db

References $a, $exercice, $periode, db, and noalyss_str_replace().

+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

Lettering::delete ( )

Definition at line 488 of file lettering.class.php.

489 {
490 throw new Exception('delete not implemented');
491 }

◆ get_info()

Lettering::get_info ( )

Definition at line 226 of file lettering.class.php.

227 {
228 return var_export(self::$variable, true);
229 }

◆ get_linked()

Lettering::get_linked ( $p_jlid)

Definition at line 352 of file lettering.class.php.

353 {
354 $sql="select j_id,j_date,to_char(j_date,'DD.MM.YYYY') as j_date_fmt,
355 j_montant,j_debit,jr_comment,jr_internal,jr_id,jr_def_id,jr_pj_number,
356 coalesce(comptaproc.get_letter_jnt(j_id),-1) as letter
357 from jrnx join jrn on (j_grpt = jr_grpt_id)
358 where
359 j_id in (select j_id from letter_cred where jl_id=$1
360 union all
361 select j_id from letter_deb where jl_id=$1)
362 order by j_date";
363
364 $this->linked=$this->db->get_array($sql, array($p_jlid));
365 }

References $sql, and db.

Referenced by show_letter().

◆ get_parameter()

Lettering::get_parameter ( $p_string)

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

94 {
95 if (array_key_exists($p_string, $this->variable))
96 {
97 $idx=$this->variable[$p_string];
98 return $this->$idx;
99 }
100 else
101 throw new Exception(__FILE__.":".__LINE__.$p_string.'Erreur attribut inexistant');
102 }

References $idx.

◆ insert()

Lettering::insert ( )

Definition at line 331 of file lettering.class.php.

332 {
333 if ($this->verify()!=0)
334 return;
335 }

References verify().

+ Here is the call graph for this function:

◆ insert_couple()

Lettering::insert_couple ( $j_id1,
$j_id2 )

Use to just insert a couple of lettered operation but do not make a link between operation.

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

119 {
120
121 /* take needed data */
122 $first=$this->db->get_value('select j_debit from jrnx where j_id=$1', array($j_id1));
123 if ($this->db->count()==0)
124 throw new Exception('Opération non existante');
125
126 $second=$this->db->get_value('select j_debit from jrnx where j_id=$1', array($j_id2));
127 if ($this->db->count()==0)
128 throw new Exception('Opération non existante');
129 $sql_already="select distinct(jl_id)
130 from jnt_letter
131 left outer join letter_deb using (jl_id)
132 left outer join letter_cred using (jl_id)
133 where
134 letter_deb.j_id = $1 or letter_cred.j_id=$1";
135 $let1=0; $let2=0;
136 $already=$this->db->get_array($sql_already, array($j_id1));
137 if (count($already)>0)
138 {
139 if (count($already)==1)
140 {
141 // retrieve the letter
142 $let1=$this->db->get_value("select distinct(jl_id)
143 from jnt_letter
144 left outer join letter_deb using (jl_id)
145 left outer join letter_cred using (jl_id)
146 where
147 letter_deb.j_id = $1 or letter_cred.j_id=$1", array($j_id1));
148 }
149 else
150 {
151 return;
152 }
153 }
154
155 $already=$this->db->get_array($sql_already, array($j_id2));
156 if (count($already)>0)
157 {
158 if (count($already)==1)
159 {
160 // retrieve the letter
161 $let2=$this->db->get_value("select distinct(jl_id)
162 from jnt_letter
163 left outer join letter_deb using (jl_id)
164 left outer join letter_cred using (jl_id)
165 where
166 letter_deb.j_id = $1 or letter_cred.j_id=$1", array($j_id2));
167 }
168 else
169 {
170 return;
171 }
172 }
173 $jl_id=0;
174 // already linked together
175 if ($let1!=0&&$let1==$let2)
176 return;
177
178 // already linked
179 /* if ($let1!=0&&$let2!=0&&$let1!=$let2)
180 return;
181*/
182 // none is linked
183 if ($let1==0&&$let2==0)
184 {
185 $jl_id=$this->db->get_next_seq("jnt_letter_jl_id_seq");
186 $this->db->exec_sql('insert into jnt_letter(jl_id) values($1)', array($jl_id));
187 } elseif ($let1==0&&$let2!=0)
188 {
189 // one is linked but not the other
190 $jl_id=$let2;
191 }elseif ($let1!=0&&$let2==0) {
192 $jl_id=$let1;
193 } else {
194 throw new \Exception ("LET179 invalid");
195 }
196
197 /* insert */
198 if ($first=='t')
199 {
200 // save into letter_deb
201 if ($let1==0)
202 $ld_id=$this->db->get_value('insert into letter_deb(j_id,jl_id) values($1,$2) returning ld_id',
203 array($j_id1, $jl_id));
204 }
205 else
206 {
207 if ($let1==0)
208 $lc_id=$this->db->get_value('insert into letter_cred(j_id,jl_id) values($1,$2) returning lc_id',
209 array($j_id1, $jl_id));
210 }
211 if ($second=='t')
212 {
213 // save into letter_deb
214 if ($let2==0)
215 $ld_id=$this->db->get_value('insert into letter_deb(j_id,jl_id) values($1,$2) returning ld_id',
216 array($j_id2, $jl_id));
217 }
218 else
219 {
220 if ($let2==0)
221 $lc_id=$this->db->get_value('insert into letter_cred(j_id,jl_id) values($1,$2) returning lc_id',
222 array($j_id2, $jl_id));
223 }
224 }
if( $delta< 0) elseif( $delta==0)

References db, and elseif.

◆ load()

Lettering::load ( )

Definition at line 482 of file lettering.class.php.

483 {
484
485 throw new Exception('load not implemented');
486 }

◆ remove_incoherent()

Lettering::remove_incoherent ( )

for some reason , sometimes, a record in letter_X doesn't have his counterpart in letter_Y

Definition at line 415 of file lettering.class.php.

416 {
417 $this->db->exec_sql("delete from letter_cred lc where jl_id not in (select jl_id from letter_deb)");
418 $this->db->exec_sql("delete from letter_deb lc where jl_id not in (select jl_id from letter_cred)");
419 }

References db.

◆ save()

Lettering::save ( $p_array)

save from array, letter the accounting (or card) and create a link between operation

Parameters
$p_array
gDossier => string '13' (length=2)
letter_j_id => is an array of j_id value
ck => array of j_id to letter with j_id
j_id => row to link
$anc_grandlivre to

Definition at line 247 of file lettering.class.php.

248 {
249
250 if (!isset($p_array['letter_j_id']))
251 {
252 // if nothing selected then remove
253 $this->db->exec_sql('delete from jnt_letter where jl_id=$1', array($p_array['jnt_id']));
254 return;
255 }
256 $nb_letter_j_id=count($p_array['letter_j_id']);
257
258 if ($nb_letter_j_id == 0 ) {
259 $this->db->exec_sql('delete from jnt_letter where jl_id=$1', array($p_array['jnt_id']));
260 return;
261 }
262 try
263 {
264 $this->db->start();
265
266 $this->db->exec_sql('delete from jnt_letter where jl_id=$1', array($p_array['jnt_id']));
267
268 $jl_id=$this->db->get_next_seq("jnt_letter_jl_id_seq");
269 $this->db->exec_sql('insert into jnt_letter(jl_id) values($1)', array($jl_id));
270
271 // save the source
272 $deb=$this->db->get_value('select j_debit,j_montant from jrnx where j_id=$1', array($p_array['j_id']));
273 if ($deb=='t')
274 {
275 // save into letter_deb
276 $ld_id=$this->db->get_value('insert into letter_deb(j_id,jl_id) values($1,$2) returning ld_id',
277 array($p_array['j_id'], $jl_id));
278 }
279 else
280 {
281 $lc_id=$this->db->get_value('insert into letter_cred(j_id,jl_id) values($1,$2) returning lc_id',
282 array($p_array['j_id'], $jl_id));
283 }
284 // save dest
285 for ($i=0; $i<$nb_letter_j_id; $i++)
286 {
287 if (! isset($p_array['ck'][$i]) || $p_array['ck'][$i] == "-2" ) { continue ; }
288
289 // save the dest
290 $deb=$this->db->get_value('select j_debit,j_montant from jrnx where j_id=$1',
291 array($p_array['ck'][$i]));
292 if ($deb=='t')
293 {
294 // save into letter_deb
295 $ld_id=$this->db->get_value('insert into letter_deb(j_id,jl_id) values($1,$2) returning ld_id',
296 array($p_array['ck'][$i], $jl_id));
297 }
298 else
299 {
300 $lc_id=$this->db->get_value('insert into letter_cred(j_id,jl_id) values($1,$2) returning lc_id',
301 array($p_array['ck'][$i], $jl_id));
302 }
303 $acc_reconciliation_lettering=new Acc_Reconciliation_Lettering($this->db);
304 $acc_reconciliation_lettering->insert_reconcilied($p_array['ck'][$i], $p_array['j_id']);
305 } //end for
306
307 }
308 catch (Exception $exc)
309 {
310 echo $exc->getMessage();
311 record_log($exc);
312 $this->db->rollback();
313 return;
314 }
315
316
317 $this->db->commit();
318 }
record_log($p_message)
Record an error message into the log file of the server or in the log folder of NOALYSS Record also t...
for($i=0;$i< $nb_jrn;$i++) $deb

References $deb, $i, $p_array, db, and record_log().

+ Here is the call graph for this function:

◆ seek()

Lettering::seek ( $cond,
$p_array = null )

retrieve * row thanks a condition

Definition at line 323 of file lettering.class.php.

324 {
325 /*
326 $sql="select * from * where $cond";
327 return $this->cn->get_array($cond,$p_array)
328 */
329 }

References $p_array.

◆ set_parameter()

Lettering::set_parameter ( $p_string,
$p_value )

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

105 {
106 if (array_key_exists($p_string, $this->variable))
107 {
108 $idx=$this->variable[$p_string];
109 $this->$idx=$p_value;
110 }
111 else
112 throw new Exception(__FILE__.":".__LINE__.$p_string.'Erreur attribut inexistant');
113 }

References $idx.

◆ show_all()

Lettering::show_all ( )
protected

show all the record from jrnx and their status (linked or not) it fills the array $this->content

Definition at line 341 of file lettering.class.php.

342 {
343 $this->get_all();
344 $r="";
345 ob_start();
346 include(NOALYSS_TEMPLATE.'/letter_all.php');
347 $r=ob_get_contents();
348 ob_end_clean();
349 return $r;
350 }
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r

References $r.

Referenced by show_list().

◆ show_letter()

Lettering::show_letter ( $p_jid)

Definition at line 446 of file lettering.class.php.

447 {
448 $j_debit=$this->db->get_value('select j_Debit from jrnx where j_id=$1', array($p_jid));
449 $amount_init=$this->db->get_value('select j_montant from jrnx where j_id=$1', array($p_jid));
450
451 $this->get_filter($p_jid);
452 // retrieve jnt_letter.id
453 $sql="select distinct(jl_id) from jnt_letter left outer join letter_deb using (jl_id) left outer join letter_cred using (jl_id)
454 where letter_deb.j_id = $1 or letter_cred.j_id=$2";
455 $a_jnt_id=$this->db->get_array($sql, array($p_jid, $p_jid));
456
457 if (count($a_jnt_id)==0)
458 {
459 $jnt_id=-2;
460 }
461 else
462 {
463 $jnt_id=$a_jnt_id[0]['jl_id'];
464 }
465 $this->get_linked($jnt_id);
466 ob_start();
467 require_once NOALYSS_TEMPLATE.'/letter_prop.php';
468 $r=ob_get_contents();
469 ob_end_clean();
470 $r.=HtmlInput::hidden('j_id', $p_jid);
471 $r.=HtmlInput::hidden('jnt_id', $jnt_id);
472
473 return $r;
474 }
static hidden($p_name, $p_value, $p_id="")
get_linked($p_jlid)

References $r, $sql, db, and get_linked().

+ Here is the call graph for this function:

◆ show_lettered()

Lettering::show_lettered ( )
protected

show only the lettered records from jrnx it fills the array $this->content

Definition at line 371 of file lettering.class.php.

372 {
373 $this->get_letter();
374 $r="";
375 ob_start();
376 include(NOALYSS_TEMPLATE.'/letter_all.php');
377 $r=ob_get_contents();
378 ob_end_clean();
379 return $r;
380 }

References $r.

Referenced by show_list().

◆ show_lettered_diff()

Lettering::show_lettered_diff ( )
protected

show only the lettered records from jrnx it fills the array $this->content

Definition at line 386 of file lettering.class.php.

387 {
388 $this->get_letter_diff();
389 $r="";
390 ob_start();
391 include(NOALYSS_TEMPLATE.'/letter_all.php');
392 $r=ob_get_contents();
393 ob_end_clean();
394 return $r;
395 }

References $r.

Referenced by show_list().

◆ show_list()

Lettering::show_list ( $p_type)

wrapper : it call show_all, show_lettered or show_not_lettered depending of the parameter

Parameters
$p_typeposs. values are all, unletter, letter

Definition at line 425 of file lettering.class.php.

426 {
427
428 switch ($p_type)
429 {
430 case 'all':
431 return $this->show_all();
432 break;
433 case 'unletter':
434 return $this->show_not_lettered();
435 break;
436 case 'letter':
437 return $this->show_lettered();
438 break;
439 case 'letter_diff':
440 return $this->show_lettered_diff();
441 break;
442 }
443 throw new Exception("[$p_type] is no unknown");
444 }
show_not_lettered()
show only the not lettered records from jrnx it fills the array $this->content
show_lettered_diff()
show only the lettered records from jrnx it fills the array $this->content
show_all()
show all the record from jrnx and their status (linked or not) it fills the array $this->content
show_lettered()
show only the lettered records from jrnx it fills the array $this->content

References $p_type, show_all(), show_lettered(), show_lettered_diff(), and show_not_lettered().

+ Here is the call graph for this function:

◆ show_not_lettered()

Lettering::show_not_lettered ( )
protected

show only the not lettered records from jrnx it fills the array $this->content

Definition at line 401 of file lettering.class.php.

402 {
403 $this->get_unletter();
404 $r="";
405 ob_start();
406 include(NOALYSS_TEMPLATE.'/letter_all.php');
407 $r=ob_get_contents();
408 ob_end_clean();
409 return $r;
410 }

References $r.

Referenced by show_list().

◆ update()

Lettering::update ( )

Definition at line 476 of file lettering.class.php.

477 {
478 if ($this->verify()!=0)
479 return;
480 }

References verify().

+ Here is the call graph for this function:

◆ verify()

Lettering::verify ( )

Definition at line 231 of file lettering.class.php.

232 {
233 // Verify that the elt we want to add is correct
234 }

Referenced by insert(), and update().

Field Documentation

◆ $content

Lettering::$content

Definition at line 61 of file lettering.class.php.

◆ $db

Lettering::$db

Definition at line 56 of file lettering.class.php.

◆ $end

Lettering::$end

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

◆ $fil_amount_max

Lettering::$fil_amount_max

Definition at line 62 of file lettering.class.php.

◆ $fil_amount_min

Lettering::$fil_amount_min

Definition at line 63 of file lettering.class.php.

◆ $fil_deb

Lettering::$fil_deb

Definition at line 64 of file lettering.class.php.

◆ $linked

Lettering::$linked

Definition at line 65 of file lettering.class.php.

◆ $object_type

Lettering::$object_type

Definition at line 60 of file lettering.class.php.

◆ $sql_ledger

Lettering::$sql_ledger

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

◆ $start

Lettering::$start

Definition at line 57 of file lettering.class.php.

◆ $variable

Lettering::$variable
protected
Initial value:
=array("account"=>"account",
"quick_code"=>"quick_code",
"start"=>"start",
"end"=>"end",
"sql_ledger"=>"sql_ledger"
)

$variable (array) data member

Todo
Lettering must be rewritten and use __set and __get instead of an array + data_member

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


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