noalyss  Version-6.7.2
Public Member Functions | Static Public Member Functions | 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:
Lettering_Account Lettering_Card

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

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 class_lettering.php.


Constructor & Destructor Documentation

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 51 of file class_lettering.php.

References $a, $exercice, and db.

    {
        $this->db=$p_init;
        $a=new User($p_init);
        $exercice=$a->get_exercice();
        $this->start='01.01.'.$exercice;
        $this->end='31.12.'.$exercice;
        // available ledgers
        $this->sql_ledger=str_replace('jrn_def_id','jr_def_id',$a->get_ledger_sql('ALL',3));

    }

Member Function Documentation

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.

References $sql, and db.

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.

    {
        if ( array_key_exists($p_string,$this->variable) )
        {
            $idx=$this->variable[$p_string];
            return $this->$idx;
        }
        else
            throw new Exception (__FILE__.":".__LINE__.$p_string.'Erreur attribut inexistant');
    }

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));
        }

    }

Definition at line 383 of file class_lettering.php.

{}
Lettering::save ( p_array)

save from array

Parameters:
$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.

    {
        if ( array_key_exists($p_string,$this->variable) )
        {
            $idx=$this->variable[$p_string];
            $this->$idx=$p_value;
        }
        else
            throw new Exception (__FILE__.":".__LINE__.$p_string.'Erreur attribut inexistant');
    }
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().

    {
        $this->get_all();
        $r="";
        ob_start();
        include('template/letter_all.php');
        $r=ob_get_contents();
        ob_end_clean();
        return $r;
    }
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().

    {
        $this->get_letter();
        $r="";
        ob_start();
        include('template/letter_all.php');
        $r=ob_get_contents();
        ob_end_clean();
        return $r;
    }

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().

    {
        $this->get_letter_diff();
        $r="";
        ob_start();
        include('template/letter_all.php');
        $r=ob_get_contents();
        ob_end_clean();
        return $r;
    }
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 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");
    }

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().

    {
        $this->get_unletter();
        $r="";
        ob_start();
        include('template/letter_all.php');
        $r=ob_get_contents();
        ob_end_clean();
        return $r;
    }
static Lettering::test_me ( ) [static]

Unit test for the class.

Definition at line 393 of file class_lettering.php.

    {}

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
    }

Field Documentation

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 class_lettering.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations