noalyss Version-9
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

Definition at line 36 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 63 of file lettering.class.php.

64 {
65 $this->db=$p_init;
66 $a=new Noalyss_user($p_init);
67 $exercice=$a->get_exercice();
68 if ($exercice>0)
69 {
70 $periode=new Periode($p_init);
71 $aLimite=$periode->get_limit($exercice);
72 $this->start=$aLimite[0]->first_day();
73 $this->end=$aLimite[1]->last_day();
74 }
75 else
76 {
77 $this->start='01.01.'.$exercice;
78 $this->end='31.12.'.$exercice;
79 }
80 // available ledgers
81 $this->sql_ledger=noalyss_str_replace('jrn_def_id', 'jr_def_id', $a->get_ledger_sql('ALL', 3));
82 }
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 479 of file lettering.class.php.

480 {
481 throw new Exception('delete not implemented');
482 }

◆ get_info()

Lettering::get_info ( )

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

218 {
219 return var_export(self::$variable, true);
220 }

◆ get_linked()

Lettering::get_linked ( $p_jlid)

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

344 {
345 $sql="select j_id,j_date,to_char(j_date,'DD.MM.YYYY') as j_date_fmt,
346 j_montant,j_debit,jr_comment,jr_internal,jr_id,jr_def_id,jr_pj_number,
347 coalesce(comptaproc.get_letter_jnt(j_id),-1) as letter
348 from jrnx join jrn on (j_grpt = jr_grpt_id)
349 where
350 j_id in (select j_id from letter_cred where jl_id=$1
351 union all
352 select j_id from letter_deb where jl_id=$1)
353 order by j_date";
354
355 $this->linked=$this->db->get_array($sql, array($p_jlid));
356 }

References $sql, and db.

Referenced by show_letter().

◆ get_parameter()

Lettering::get_parameter ( $p_string)

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

85 {
86 if (array_key_exists($p_string, $this->variable))
87 {
88 $idx=$this->variable[$p_string];
89 return $this->$idx;
90 }
91 else
92 throw new Exception(__FILE__.":".__LINE__.$p_string.'Erreur attribut inexistant');
93 }

References $idx.

◆ insert()

Lettering::insert ( )

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

323 {
324 if ($this->verify()!=0)
325 return;
326 }

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 109 of file lettering.class.php.

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

References db, and elseif.

◆ load()

Lettering::load ( )

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

474 {
475
476 throw new Exception('load not implemented');
477 }

◆ 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 406 of file lettering.class.php.

407 {
408 $this->db->exec_sql("delete from letter_cred lc where jl_id not in (select jl_id from letter_deb)");
409 $this->db->exec_sql("delete from letter_deb lc where jl_id not in (select jl_id from letter_cred)");
410 }

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 238 of file lettering.class.php.

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

References $deb, $i, $p_array, and db.

◆ seek()

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

retrieve * row thanks a condition

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

315 {
316 /*
317 $sql="select * from * where $cond";
318 return $this->cn->get_array($cond,$p_array)
319 */
320 }

References $p_array.

◆ set_parameter()

Lettering::set_parameter ( $p_string,
$p_value )

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

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

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 332 of file lettering.class.php.

333 {
334 $this->get_all();
335 $r="";
336 ob_start();
337 include(NOALYSS_TEMPLATE.'/letter_all.php');
338 $r=ob_get_contents();
339 ob_end_clean();
340 return $r;
341 }
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 437 of file lettering.class.php.

438 {
439 $j_debit=$this->db->get_value('select j_Debit from jrnx where j_id=$1', array($p_jid));
440 $amount_init=$this->db->get_value('select j_montant from jrnx where j_id=$1', array($p_jid));
441
442 $this->get_filter($p_jid);
443 // retrieve jnt_letter.id
444 $sql="select distinct(jl_id) from jnt_letter left outer join letter_deb using (jl_id) left outer join letter_cred using (jl_id)
445 where letter_deb.j_id = $1 or letter_cred.j_id=$2";
446 $a_jnt_id=$this->db->get_array($sql, array($p_jid, $p_jid));
447
448 if (count($a_jnt_id)==0)
449 {
450 $jnt_id=-2;
451 }
452 else
453 {
454 $jnt_id=$a_jnt_id[0]['jl_id'];
455 }
456 $this->get_linked($jnt_id);
457 ob_start();
458 require_once NOALYSS_TEMPLATE.'/letter_prop.php';
459 $r=ob_get_contents();
460 ob_end_clean();
461 $r.=HtmlInput::hidden('j_id', $p_jid);
462 $r.=HtmlInput::hidden('jnt_id', $jnt_id);
463
464 return $r;
465 }
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 362 of file lettering.class.php.

363 {
364 $this->get_letter();
365 $r="";
366 ob_start();
367 include(NOALYSS_TEMPLATE.'/letter_all.php');
368 $r=ob_get_contents();
369 ob_end_clean();
370 return $r;
371 }

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 377 of file lettering.class.php.

378 {
379 $this->get_letter_diff();
380 $r="";
381 ob_start();
382 include(NOALYSS_TEMPLATE.'/letter_all.php');
383 $r=ob_get_contents();
384 ob_end_clean();
385 return $r;
386 }

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 416 of file lettering.class.php.

417 {
418
419 switch ($p_type)
420 {
421 case 'all':
422 return $this->show_all();
423 break;
424 case 'unletter':
425 return $this->show_not_lettered();
426 break;
427 case 'letter':
428 return $this->show_lettered();
429 break;
430 case 'letter_diff':
431 return $this->show_lettered_diff();
432 break;
433 }
434 throw new Exception("[$p_type] is no unknown");
435 }
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 392 of file lettering.class.php.

393 {
394 $this->get_unletter();
395 $r="";
396 ob_start();
397 include(NOALYSS_TEMPLATE.'/letter_all.php');
398 $r=ob_get_contents();
399 ob_end_clean();
400 return $r;
401 }

References $r.

Referenced by show_list().

◆ update()

Lettering::update ( )

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

468 {
469 if ($this->verify()!=0)
470 return;
471 }

References verify().

+ Here is the call graph for this function:

◆ verify()

Lettering::verify ( )

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

223 {
224 // Verify that the elt we want to add is correct
225 }

Referenced by insert(), and update().

Field Documentation

◆ $content

Lettering::$content

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

◆ $db

Lettering::$db

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

◆ $end

Lettering::$end

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

◆ $fil_amount_max

Lettering::$fil_amount_max

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

◆ $fil_amount_min

Lettering::$fil_amount_min

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

◆ $fil_deb

Lettering::$fil_deb

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

◆ $linked

Lettering::$linked

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

◆ $object_type

Lettering::$object_type

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

◆ $sql_ledger

Lettering::$sql_ledger

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

◆ $start

Lettering::$start

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


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