noalyss Version-9
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
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 More...
 
 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. More...
 
 load ()
 
 remove_incoherent ()
 for some reason , sometimes, a record in letter_X doesn't have his counterpart in letter_Y More...
 
 save ($p_array)
 save from array, letter the accounting (or card) and create a link between operation More...
 
 seek ($cond, $p_array=null)
 retrieve * row thanks a condition More...
 
 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 More...
 
 update ()
 
 verify ()
 

Data Fields

 $db
 
 $end
 
 $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 More...
 
 show_lettered ()
 show only the lettered records from jrnx it fills the array $this->content More...
 
 show_lettered_diff ()
 show only the lettered records from jrnx it fills the array $this->content More...
 
 show_not_lettered ()
 show only the not lettered records from jrnx it fills the array $this->content More...
 

Protected Attributes

 $variable
 

Detailed Description

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

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

58 {
59 $this->db=$p_init;
60 $a=new Noalyss_user($p_init);
61 $exercice=$a->get_exercice();
62 if ($exercice>0)
63 {
64 $periode=new Periode($p_init);
65 $aLimite=$periode->get_limit($exercice);
66 $this->start=$aLimite[0]->first_day();
67 $this->end=$aLimite[1]->last_day();
68 }
69 else
70 {
71 $this->start='01.01.'.$exercice;
72 $this->end='31.12.'.$exercice;
73 }
74 // available ledgers
75 $this->sql_ledger=noalyss_str_replace('jrn_def_id', 'jr_def_id', $a->get_ledger_sql('ALL', 3));
76 }
noalyss_str_replace($search, $replace, $string)
Definition: ac_common.php:1553
catch(Exception $e) $exercice
For the periode tables parm_periode and jrn_periode.
$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 470 of file lettering.class.php.

471 {
472 throw new Exception('delete not implemented');
473 }

◆ get_info()

Lettering::get_info ( )

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

209 {
210 return var_export(self::$variable, true);
211 }

References $variable.

◆ get_linked()

Lettering::get_linked (   $p_jlid)

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

335 {
336 $sql="select j_id,j_date,to_char(j_date,'DD.MM.YYYY') as j_date_fmt,
337 j_montant,j_debit,jr_comment,jr_internal,jr_id,jr_def_id,jr_pj_number,
338 coalesce(comptaproc.get_letter_jnt(j_id),-1) as letter
339 from jrnx join jrn on (j_grpt = jr_grpt_id)
340 where
341 j_id in (select j_id from letter_cred where jl_id=$1
342 union all
343 select j_id from letter_deb where jl_id=$1)
344 order by j_date";
345
346 $this->linked=$this->db->get_array($sql, array($p_jlid));
347 }

References $sql, and db.

Referenced by show_letter().

◆ get_parameter()

Lettering::get_parameter (   $p_string)

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

79 {
80 if (array_key_exists($p_string, $this->variable))
81 {
82 $idx=$this->variable[$p_string];
83 return $this->$idx;
84 }
85 else
86 throw new Exception(__FILE__.":".__LINE__.$p_string.'Erreur attribut inexistant');
87 }
$idx

References $idx.

◆ insert()

Lettering::insert ( )

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

314 {
315 if ($this->verify()!=0)
316 return;
317 }

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

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

References db.

◆ load()

Lettering::load ( )

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

465 {
466
467 throw new Exception('load not implemented');
468 }

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

398 {
399 $this->db->exec_sql("delete from letter_cred lc where jl_id not in (select jl_id from letter_deb)");
400 $this->db->exec_sql("delete from letter_deb lc where jl_id not in (select jl_id from letter_cred)");
401 }

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

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

306 {
307 /*
308 $sql="select * from * where $cond";
309 return $this->cn->get_array($cond,$p_array)
310 */
311 }

◆ set_parameter()

Lettering::set_parameter (   $p_string,
  $p_value 
)

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

90 {
91 if (array_key_exists($p_string, $this->variable))
92 {
93 $idx=$this->variable[$p_string];
94 $this->$idx=$p_value;
95 }
96 else
97 throw new Exception(__FILE__.":".__LINE__.$p_string.'Erreur attribut inexistant');
98 }

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

324 {
325 $this->get_all();
326 $r="";
327 ob_start();
328 include(NOALYSS_TEMPLATE.'/letter_all.php');
329 $r=ob_get_contents();
330 ob_end_clean();
331 return $r;
332 }
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 428 of file lettering.class.php.

429 {
430 $j_debit=$this->db->get_value('select j_Debit from jrnx where j_id=$1', array($p_jid));
431 $amount_init=$this->db->get_value('select j_montant from jrnx where j_id=$1', array($p_jid));
432
433 $this->get_filter($p_jid);
434 // retrieve jnt_letter.id
435 $sql="select distinct(jl_id) from jnt_letter left outer join letter_deb using (jl_id) left outer join letter_cred using (jl_id)
436 where letter_deb.j_id = $1 or letter_cred.j_id=$2";
437 $a_jnt_id=$this->db->get_array($sql, array($p_jid, $p_jid));
438
439 if (count($a_jnt_id)==0)
440 {
441 $jnt_id=-2;
442 }
443 else
444 {
445 $jnt_id=$a_jnt_id[0]['jl_id'];
446 }
447 $this->get_linked($jnt_id);
448 ob_start();
449 require_once NOALYSS_TEMPLATE.'/letter_prop.php';
450 $r=ob_get_contents();
451 ob_end_clean();
452 $r.=HtmlInput::hidden('j_id', $p_jid);
453 $r.=HtmlInput::hidden('jnt_id', $jnt_id);
454
455 return $r;
456 }
static hidden($p_name, $p_value, $p_id="")
get_linked($p_jlid)

References $r, $sql, db, get_linked(), and HtmlInput\hidden().

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

354 {
355 $this->get_letter();
356 $r="";
357 ob_start();
358 include(NOALYSS_TEMPLATE.'/letter_all.php');
359 $r=ob_get_contents();
360 ob_end_clean();
361 return $r;
362 }

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

369 {
370 $this->get_letter_diff();
371 $r="";
372 ob_start();
373 include(NOALYSS_TEMPLATE.'/letter_all.php');
374 $r=ob_get_contents();
375 ob_end_clean();
376 return $r;
377 }

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

408 {
409
410 switch ($p_type)
411 {
412 case 'all':
413 return $this->show_all();
414 break;
415 case 'unletter':
416 return $this->show_not_lettered();
417 break;
418 case 'letter':
419 return $this->show_lettered();
420 break;
421 case 'letter_diff':
422 return $this->show_lettered_diff();
423 break;
424 }
425 throw new Exception("[$p_type] is no unknown");
426 }
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 383 of file lettering.class.php.

384 {
385 $this->get_unletter();
386 $r="";
387 ob_start();
388 include(NOALYSS_TEMPLATE.'/letter_all.php');
389 $r=ob_get_contents();
390 ob_end_clean();
391 return $r;
392 }

References $r.

Referenced by show_list().

◆ update()

Lettering::update ( )

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

459 {
460 if ($this->verify()!=0)
461 return;
462 }

References verify().

+ Here is the call graph for this function:

◆ verify()

Lettering::verify ( )

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

214 {
215 // Verify that the elt we want to add is correct
216 }

Referenced by insert(), and update().

Field Documentation

◆ $db

Lettering::$db

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

◆ $end

Lettering::$end

Definition at line 49 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"
)

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


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