noalyss
Version-6.7.2
|
mother class for the lettering by account and by card use the tables jnt_letter, letter_deb and letter_cred More...
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. | |
load () | |
save ($p_array) | |
save from array | |
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 () | |
Static Public Member Functions | |
static | test_me () |
Unit test for the class. | |
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 |
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 class_lettering.php.
Lettering::__construct | ( | $ | p_init | ) |
constructor
$p_init | resource to database |
Definition at line 51 of file class_lettering.php.
Definition at line 386 of file class_lettering.php.
{ throw new Exception ('delete not implemented'); }
Definition at line 170 of file class_lettering.php.
{ return var_export(self::$variable,true); }
Lettering::get_linked | ( | $ | p_jlid | ) |
Definition at line 266 of file class_lettering.php.
Referenced by show_letter().
{ $sql="select j_id,j_date,to_char(j_date,'DD.MM.YYYY') as j_date_fmt, j_montant,j_debit,jr_comment,jr_internal,jr_id,jr_def_id, coalesce(comptaproc.get_letter_jnt(j_id),-1) as letter from jrnx join jrn on (j_grpt = jr_grpt_id) where j_id in (select j_id from letter_cred where jl_id=$1 union all select j_id from letter_deb where jl_id=$1) order by j_date"; $this->linked=$this->db->get_array($sql,array($p_jlid)); }
Lettering::get_parameter | ( | $ | p_string | ) |
Definition at line 62 of file class_lettering.php.
References $idx.
Definition at line 247 of file class_lettering.php.
References verify().
{ if ( $this->verify() != 0 ) return; }
Lettering::insert_couple | ( | $ | j_id1, |
$ | j_id2 | ||
) |
Use to just insert a couple of lettered operation.
Definition at line 85 of file class_lettering.php.
References db.
{ /* take needed data */ $first=$this->db->get_value('select j_debit from jrnx where j_id=$1',array($j_id1)); if ( $this->db->count() == 0 ) throw new Exception ('Opération non existante'); $second=$this->db->get_value('select j_debit from jrnx where j_id=$1',array($j_id2)); if ( $this->db->count() == 0 ) throw new Exception ('Opération non existante'); $sql_already="select distinct(jl_id) from jnt_letter left outer join letter_deb using (jl_id) left outer join letter_cred using (jl_id) where letter_deb.j_id = $1 or letter_cred.j_id=$1"; $let1=0;$let2=0; $already=$this->db->get_array($sql_already,array($j_id1)); if ( count ($already ) > 0) { if ( count($already)==1) { // retrieve the letter $let1=$this->db->get_value("select distinct(jl_id) from jnt_letter left outer join letter_deb using (jl_id) left outer join letter_cred using (jl_id) where letter_deb.j_id = $1 or letter_cred.j_id=$1",array($j_id1)); }else { return; } } $already=$this->db->get_array($sql_already,array($j_id2)); if ( count ($already ) > 0) { if ( count($already)==1) { // retrieve the letter $let2=$this->db->get_value("select distinct(jl_id) from jnt_letter left outer join letter_deb using (jl_id) left outer join letter_cred using (jl_id) where letter_deb.j_id = $1 or letter_cred.j_id=$1",array($j_id2)); }else { return; } } $jl_id=0; // already linked together if ( $let1 != 0 && $let1 == $let2 )return; // already linked if ( $let1 != 0 && $let2!=0 && $let1 != $let2 )return; // none is linked if ( $let1 == 0 && $let2==0) { $jl_id=$this->db->get_next_seq("jnt_letter_jl_id_seq"); $this->db->exec_sql('insert into jnt_letter(jl_id) values($1)', array($jl_id)); } // one is linked but not the other if ( $let1 == 0 && $let2 != 0 ) $jl_id=$let2; if ( $let1 != 0 && $let2 == 0 ) $jl_id=$let1; /* insert */ if ( $first == 't') { // save into letter_deb if ($let1 == 0) $ld_id=$this->db->get_value('insert into letter_deb(j_id,jl_id) values($1,$2) returning ld_id',array($j_id1,$jl_id)); } else { if ($let1 == 0)$lc_id=$this->db->get_value('insert into letter_cred(j_id,jl_id) values($1,$2) returning lc_id',array($j_id1,$jl_id)); } if ( $second == 't') { // save into letter_deb if ($let2 == 0)$ld_id=$this->db->get_value('insert into letter_deb(j_id,jl_id) values($1,$2) returning ld_id',array($j_id2,$jl_id)); } else { if ($let2 == 0)$lc_id=$this->db->get_value('insert into letter_cred(j_id,jl_id) values($1,$2) returning lc_id',array($j_id2,$jl_id)); } }
Lettering::load | ( | ) |
Definition at line 383 of file class_lettering.php.
{}
Lettering::save | ( | $ | p_array | ) |
save from array
$p_array | 'gDossier' => string '13' (length=2) 'letter_j_id' => ck => array |
Definition at line 187 of file class_lettering.php.
References $count, $deb, $p_array, and db.
{ if ( ! isset ($p_array['letter_j_id'])) return; $this->db->exec_sql('delete from jnt_letter where jl_id=$1',array($p_array['jnt_id'])); $this->db->start(); $jl_id=$this->db->get_next_seq("jnt_letter_jl_id_seq"); $this->db->exec_sql('insert into jnt_letter(jl_id) values($1)', array($jl_id)); // save the source $deb=$this->db->get_value('select j_debit,j_montant from jrnx where j_id=$1',array($p_array['j_id'])); if ( $deb == 't') { // save into letter_deb $ld_id=$this->db->get_value('insert into letter_deb(j_id,jl_id) values($1,$2) returning ld_id',array($p_array['j_id'],$jl_id)); } else { $lc_id=$this->db->get_value('insert into letter_cred(j_id,jl_id) values($1,$2) returning lc_id',array($p_array['j_id'],$jl_id)); } $count=0; // save dest for($i=0;$i<count($p_array['letter_j_id']);$i++) { if (isset ($p_array['ck'][$i]) && $p_array['ck'][$i] !="-2") { //if 1 // save the dest $deb=$this->db->get_value('select j_debit,j_montant from jrnx where j_id=$1',array($p_array['ck'][$i])); if ( $deb == 't') { $count++; // save into letter_deb $ld_id=$this->db->get_value('insert into letter_deb(j_id,jl_id) values($1,$2) returning ld_id',array($p_array['ck'][$i],$jl_id)); } else { $count++; $lc_id=$this->db->get_value('insert into letter_cred(j_id,jl_id) values($1,$2) returning lc_id',array($p_array['ck'][$i],$jl_id)); } } //end if 1 } //end for // save into jnt_letter /* if only one row we delete the joint */ if ( $count==0) { $this->db->rollback(); } $this->db->commit(); }
Lettering::seek | ( | $ | cond, |
$ | p_array = null |
||
) |
retrieve * row thanks a condition
Definition at line 240 of file class_lettering.php.
{ /* $sql="select * from * where $cond"; return $this->cn->get_array($cond,$p_array) */ }
Lettering::set_parameter | ( | $ | p_string, |
$ | p_value | ||
) |
Definition at line 72 of file class_lettering.php.
References $idx.
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 256 of file class_lettering.php.
References $r.
Referenced by show_list().
Lettering::show_letter | ( | $ | p_jid | ) |
Definition at line 349 of file class_lettering.php.
References $r, $sql, db, get_linked(), and HtmlInput\hidden().
{ $j_debit=$this->db->get_value('select j_Debit from jrnx where j_id=$1',array($p_jid)); $amount_init=$this->db->get_value('select j_montant from jrnx where j_id=$1',array($p_jid)); $this->get_filter($p_jid); // retrieve jnt_letter.id $sql="select distinct(jl_id) from jnt_letter left outer join letter_deb using (jl_id) left outer join letter_cred using (jl_id) where letter_deb.j_id = $1 or letter_cred.j_id=$2"; $a_jnt_id=$this->db->get_array($sql,array($p_jid,$p_jid)); if (count($a_jnt_id)==0 ) { $jnt_id=-2; } else { $jnt_id=$a_jnt_id[0]['jl_id']; } $this->get_linked($jnt_id); ob_start(); require_once('template/letter_prop.php'); $r=ob_get_contents(); ob_end_clean(); $r.=HtmlInput::hidden('j_id',$p_jid); $r.=HtmlInput::hidden('jnt_id',$jnt_id); return $r; }
Lettering::show_lettered | ( | ) | [protected] |
show only the lettered records from jrnx it fills the array $this->content
Definition at line 284 of file class_lettering.php.
References $r.
Referenced by show_list().
Lettering::show_lettered_diff | ( | ) | [protected] |
show only the lettered records from jrnx it fills the array $this->content
Definition at line 298 of file class_lettering.php.
References $r.
Referenced by show_list().
Lettering::show_list | ( | $ | p_type | ) |
wrapper : it call show_all, show_lettered or show_not_lettered depending of the parameter
$p_type | poss. values are all, unletter, letter |
Definition at line 329 of file class_lettering.php.
References show_all(), show_lettered(), show_lettered_diff(), and show_not_lettered().
{ switch($p_type) { case 'all': return $this->show_all(); break; case 'unletter': return $this->show_not_lettered(); break; case 'letter': return $this->show_lettered(); break; case 'letter_diff': return $this->show_lettered_diff(); break; } throw new Exception ("[$p_type] is no unknown"); }
Lettering::show_not_lettered | ( | ) | [protected] |
show only the not lettered records from jrnx it fills the array $this->content
Definition at line 314 of file class_lettering.php.
References $r.
Referenced by show_list().
static Lettering::test_me | ( | ) | [static] |
Definition at line 378 of file class_lettering.php.
References verify().
{ if ( $this->verify() != 0 ) return; }
Definition at line 174 of file class_lettering.php.
Referenced by insert(), and update().
{
// Verify that the elt we want to add is correct
}
Lettering::$variable [protected] |
array("account"=>"account", "quick_code"=>"quick_code", "start"=>"start", "end"=>"end", "sql_ledger"=>"sql_ledger" )
Definition at line 39 of file class_lettering.php.