|
noalyss
Version-6.7.2
|
this file match the tables jrn & jrnx the purpose is to remove or save accountant writing to these table. More...
Public Member Functions | |
| __construct ($p_cn) | |
| constructor set automatically the attributes user and periode | |
| display_jrnx_detail ($p_table) | |
| display_jrnx_detail : get the data from get_jrnx_data and return a string with HTML code | |
| get () | |
| retrieve data from jrnx and jrn | |
| get_data ($p_grpt) | |
| Get data from jrnx where p_grpt=jrnx(j_grpt) | |
| get_info () | |
| retrieve info from the jrn_info, create 2 new arrays obj->info->command and obj->info->other the columns are the idx | |
| get_internal () | |
| Return the internal value, the property jr_id must be set before. | |
| get_jrnx_detail () | |
| retrieve data from jrnx | |
| get_ledger () | |
| return the jrn_def_id from jrn | |
| get_quant () | |
| retrieve data from the table QUANT_* | |
| insert_jrn () | |
| Insert into the table Jrn, the amount is computed from jrnx thanks the group id ($p_grpt) | |
| insert_jrnx () | |
| Insert into the table Jrn The needed data are : | |
| insert_related_action ($p_string) | |
| operation_update_comment ($p_text) | |
| add a comment to the operation (jrn.jr_text) | |
| operation_update_date_limit ($p_text) | |
| add a limit of payment to the operation (jrn.jr_ech) | |
| save_info ($p_info, $p_type) | |
| Save into jrn_info. | |
| seek_group () | |
| retrieve the grpt_id from jrn for a jr_id | |
| seek_internal ($p_internal) | |
| search an operation thankx it internal code | |
| set_pj () | |
| set the pj of a operation in jrn. the jr_id must be set | |
| update_comment ($p_text) | |
| add a comment to the line (jrnx.j_text) | |
Static Public Member Functions | |
| static | test_me () |
Data Fields | |
| $amount | |
| $date | |
| $date_paid | |
| $db | |
| $debit | |
| $grpt | |
| $jr_id | |
| $jrn | |
| $jrn_id | |
| $periode | |
| $poste | |
| $user | |
this file match the tables jrn & jrnx the purpose is to remove or save accountant writing to these table.
Definition at line 33 of file class_acc_operation.php.
| Acc_Operation::__construct | ( | $ | p_cn | ) |
constructor set automatically the attributes user and periode
| $p_cn | the databse connection |
Definition at line 51 of file class_acc_operation.php.
| Acc_Operation::display_jrnx_detail | ( | $ | p_table | ) |
display_jrnx_detail : get the data from get_jrnx_data and return a string with HTML code
| table(=0 | no code for table,1 code for table,2 code for CSV) |
Definition at line 300 of file class_acc_operation.php.
References $a, $l, $r, get_jrnx_detail(), h(), poste, and trim().
{
$show=$this->get_jrnx_detail();
$r='';
$r_notable='';
$csv="";
foreach ($show as $l)
{
$border="";
if ( $l['j_poste'] == $this->poste || ($l['j_qcode']==$this->qcode && trim($this->qcode) != ''))
$border=' class="highlight"';
$r.='<tr '.$border.'>';
$r.='<td>';
$a=$l['j_qcode'];
$r_notable.=$a;
$r.=$a;
$csv.='"'.$a.'";';
$r.='</td>';
$r.='<td '.$border.'>';
$a=$l['j_poste'];
$r_notable.=$a;
$r.=$a;
$csv.='"'.$a.'";';
$r.='</td>';
$r.='<td '.$border.'>';
// $a=($l['vw_name']=="")?$l['j_qcode']:$l['pcm_lib'];
$a=(strlen(trim($l['j_qcode']))==0)?$l['pcm_lib']:$l['vw_name'];
$r_notable.=$a;
$r.=h($a);
$csv.='"'.$a.'";';
$r.='</td>';
$r.='<td '.$border.'>';
$a=$l['j_montant'];
$r_notable.=$a;
$r.=$a;
$csv.=$a.';';
$r.='</td>';
$r.='<td '.$border.'>';
$a=$l['debit'];
$r_notable.=$a;
$r.=$a;
$csv.='"'.$a.'"';
$csv.="\r\n";
$r.='</td>';
$r.='<td '.$border.'>';
$a=($l['letter']!=-1)?$l['letter']:'';
$r_notable.=$a;
$r.=$a;
$csv.='"'.$a.'"';
$csv.="\r\n";
$r.='</td>';
$r.='</tr>';
}
switch ($p_table)
{
case 1:
return $r;
break;
case 0:
return $r_notable;
break;
case 2:
return $csv;
}
return "ERROR PARAMETRE";
}
retrieve data from jrnx and jrn
Reimplemented in Acc_Fin, Acc_Purchase, Acc_Sold, Acc_Misc, and Acc_Detail.
Definition at line 477 of file class_acc_operation.php.
| Acc_Operation::get_data | ( | $ | p_grpt | ) |
Get data from jrnx where p_grpt=jrnx(j_grpt)
| connection |
Array
(
[op_date] => 01.12.2009
[class_cred0] => 7000008
[mont_cred0] => 8880.0000
[op_cred0] => 754
[text_cred0] =>
[jr_internal] => 23VEN-01-302
[comment] =>
[ech] =>
[jr_id] => 302
[jr_def_id] => 2
[class_deb0] => 4000005
[mont_deb0] => 10744.8000
[text_deb0] =>
[op_deb0] => 755
[class_cred1] => 4511
[mont_cred1] => 1864.8000
[op_cred1] => 756
[text_cred1] =>
)
Definition at line 408 of file class_acc_operation.php.
References $cred, $deb, $Res, db, Database\fetch_array(), and Database\num_row().
{
$Res=$this->db->exec_sql("select
to_char(j_date,'DD.MM.YYYY') as j_date,
j_text,
j_debit,
j_poste,
coalesce(j_qcode,'-') as qcode,
j_montant,
j_id,
jr_comment,
to_char(jr_ech,'DD.MM.YYYY') as jr_ech,
to_char(jr_date,'DD.MM.YYYY') as jr_date,
jr_id,jr_internal,jr_def_id,jr_pj
from jrnx inner join jrn on j_grpt=jr_grpt_id where j_grpt=$1",array($p_grpt));
$MaxLine=Database::num_row($Res);
if ( $MaxLine == 0 ) return null;
$deb=0;
$cred=0;
for ( $i=0; $i < $MaxLine; $i++)
{
$l_line=Database::fetch_array($Res,$i);
$l_array['op_date']=$l_line['j_date'];
if ( $l_line['j_debit'] == 't' )
{
$l_class=sprintf("class_deb%d",$deb);
$l_montant=sprintf("mont_deb%d",$deb);
$l_text=sprintf("text_deb%d",$deb);
$l_qcode=sprintf("qcode_deb%d",$deb);
$l_array[$l_class]=$l_line['j_poste'];
$l_array[$l_montant]=$l_line['j_montant'];
$l_array[$l_text]=$l_line['j_text'];
$l_array[$l_qcode]=$l_line['qcode'];
$l_id=sprintf("op_deb%d",$deb);
$l_array[$l_id]=$l_line['j_id'];
$deb++;
}
if ( $l_line['j_debit'] == 'f' )
{
$l_class=sprintf("class_cred%d",$cred);
$l_montant=sprintf("mont_cred%d",$cred);
$l_array[$l_class]=$l_line['j_poste'];
$l_array[$l_montant]=$l_line['j_montant'];
$l_id=sprintf("op_cred%d",$cred);
$l_array[$l_id]=$l_line['j_id'];
$l_text=sprintf("text_cred%d",$cred);
$l_array[$l_text]=$l_line['j_text'];
$l_qcode=sprintf("qcode_cred%d",$cred);
$l_array[$l_qcode]=$l_line['qcode'];
$cred++;
}
$l_array['jr_internal']=$l_line['jr_internal'];
$l_array['comment']=$l_line['jr_comment'];
$l_array['ech']=$l_line['jr_ech'];
$l_array['jr_id']=$l_line['jr_id'];
$l_array['jr_def_id']=$l_line['jr_def_id'];
}
return array($l_array,$deb,$cred);
}
retrieve info from the jrn_info, create 2 new arrays obj->info->command and obj->info->other the columns are the idx
Definition at line 527 of file class_acc_operation.php.
References $array, db, and jr_id.
{
$this->info=new stdClass();
// other info
$array=$this->db->get_value("select ji_value from jrn_info where
jr_id=$1 and id_type=$2",array($this->jr_id,'OTHER'));
$this->info->other= $array;
// Bon de commande
$array=$this->db->get_value("select ji_value from jrn_info where
jr_id=$1 and id_type=$2",array($this->jr_id,'BON_COMMANDE'));
$this->info->command= $array;
}
Return the internal value, the property jr_id must be set before.
Definition at line 222 of file class_acc_operation.php.
References $Res, db, Database\fetch_array(), jr_id, and Database\num_row().
{
if ( ! isset($this->jr_id) )
throw new Exception('jr_id is not set',1);
$Res=$this->db->exec_sql("select jr_internal from jrn where jr_id=".$this->jr_id);
if ( Database::num_row($Res) == 0 ) return null;
$l_line=Database::fetch_array($Res);
$this->jr_internal= $l_line['jr_internal'];
return $this->jr_internal;
}
retrieve data from jrnx
Definition at line 248 of file class_acc_operation.php.
References $all, $g_user, $res, $sql, db, Database\fetch_all(), jr_id, and Database\num_row().
Referenced by display_jrnx_detail().
{
global $g_user;
$filter_sql=$g_user->get_ledger_sql('ALL',3);
$filter_sql=str_replace('jrn_def_id','jr_def_id',$filter_sql);
if ( $this->jr_id==0 ) return;
$sql=" select jr_date,j_qcode,j_poste,j_montant,jr_internal,case when j_debit = 'f' then 'C' else 'D' end as debit,jr_comment as description,
vw_name,pcm_lib,j_debit,coalesce(comptaproc.get_letter_jnt(j_id),-1) as letter,jr_def_id ".
" from jrnx join jrn on (jr_grpt_id=j_grpt)
join tmp_pcmn on (j_poste=pcm_val)
left join vw_fiche_attr on (j_qcode=quick_code)
where
jr_id=$1 and $filter_sql order by j_debit desc";
$res=$this->db->exec_sql($sql,array($this->jr_id));
if ( Database::num_row ($res) == 0 ) return array();
$all=Database::fetch_all($res);
return $all;
}
retrieve data from the table QUANT_*
Definition at line 489 of file class_acc_operation.php.
References $ret, db, get_ledger(), and jr_id.
{
$ledger_id=$this->get_ledger();
if ( $ledger_id=='') throw new Exception(_('Journal non trouvé'));
$oledger=new Acc_Ledger($this->db,$ledger_id);
// retrieve info from jrn_info
switch($oledger->get_type())
{
case 'VEN':
$ret=new Acc_Sold($this->db,$this->jr_id);
break;
case 'ACH':
$ret=new Acc_Purchase($this->db,$this->jr_id);
break;
case 'FIN':
$ret=new Acc_Fin($this->db,$this->jr_id);
break;
default:
$ret=new Acc_Misc($this->db,$this->jr_id);
break;
}
$ret->get();
if ( empty($ret->det->array))
{
$ret=new Acc_Misc($this->db,$this->jr_id);
$ret->get();
}
$ret->get_info();
return $ret;
}
Insert into the table Jrn, the amount is computed from jrnx thanks the group id ($p_grpt)
Definition at line 186 of file class_acc_operation.php.
References $diff, $Res, db, echo, jr_id, jrn, and trim().
{
$p_comment=$this->desc;
$diff=$this->db->get_value("select check_balance ($1)",array($this->grpt));
if ( $diff != 0 )
{
echo "Erreur : balance incorrecte :diff = $diff";
return false;
}
$echeance=( isset( $this->echeance) && strlen(trim($this->echeance)) != 0)?$this->echeance:null;
if ( ! isset($this->mt) )
{
$this->mt=microtime(true);
}
// if amount == -1then the triggers will throw an error
//
$Res=$this->db->exec_sql("insert into jrn (jr_def_id,jr_montant,jr_comment,".
"jr_date,jr_ech,jr_grpt_id,jr_tech_per,jr_mt) values (".
"$1,$2,$3,".
"to_date($4,'DD.MM.YYYY'),to_date($5,'DD.MM.YYYY'),$6,$7,$8)",
array ($this->jrn, $this->amount,$p_comment,
$this->date,$echeance,$this->grpt,$this->periode,$this->mt)
);
if ( $Res == false) return false;
$this->jr_id=$this->db->get_current_seq('s_jrn');
return $this->jr_id;
}
Insert into the table Jrn The needed data are :
Definition at line 88 of file class_acc_operation.php.
References $debit, $Res, db, jrn, poste, type, and user.
Referenced by Acc_Ledger_Purchase\insert_no_deductible().
{
if ( $this->poste == "") { return false; throw new Exception (__FILE__.':'.__LINE__.' Poste comptable vide');}
/* for negative amount the operation is reversed */
if ( $this->amount < 0 )
{
$this->type=($this->type=='d')?'c':'d';
}
$this->amount=abs($this->amount);
$debit=($this->type=='c')?'false':'true';
$this->desc=(isset($this->desc))?$this->desc:'';
$Res=$this->db->exec_sql("select insert_jrnx
($1::text,abs($2)::numeric,$3::account_type,$4::integer,$5::integer,$6::bool,$7::text,$8::integer,upper($9),$10::text)",
array(
$this->date, //$1
round($this->amount,2), //$2
$this->poste, //$3
$this->grpt, //$4
$this->jrn, //$5
$debit, //$6
$this->user, //$7
$this->periode, //$8
$this->qcode, // $9
$this->desc)); //$10
if ( $Res===false) return $Res;
$this->jrnx_id=$this->db->get_current_seq('s_jrn_op');
return $this->jrnx_id;
}
| Acc_Operation::insert_related_action | ( | $ | p_string | ) |
Definition at line 565 of file class_acc_operation.php.
| Acc_Operation::operation_update_comment | ( | $ | p_text | ) |
| Acc_Operation::operation_update_date_limit | ( | $ | p_text | ) |
add a limit of payment to the operation (jrn.jr_ech)
Definition at line 279 of file class_acc_operation.php.
| Acc_Operation::save_info | ( | $ | p_info, |
| $ | p_type | ||
| ) |
Save into jrn_info.
| $p_info | msg to save |
| $p_type | is OTHER or BON_COMMAND |
Definition at line 546 of file class_acc_operation.php.
References db, jr_id, and trim().
{
if ( ! in_array($p_type,array('OTHER','BON_COMMANDE'))) return;
if (trim($p_info)=="") {
$this->db->exec_sql('delete from jrn_info where jr_id=$1 and id_type=$2',array($this->jr_id,$p_type));
return;
}
$exist=$this->db->get_value('select count(ji_id) from jrn_info where jr_id=$1 and id_type=$2',array($this->jr_id,$p_type));
if ( $exist == "0" ) {
//insert into jrn_info
$this->db->exec_sql('insert into jrn_info(jr_id,id_type,ji_value) values ($1,$2,$3)',
array($this->jr_id,$p_type,$p_info));
} elseif ( $exist == 1) {
//update
$this->db->exec_sql('update jrn_info set ji_value=$3 where jr_id=$1 and id_type=$2',
array($this->jr_id,$p_type,$p_info));
}
}
| Acc_Operation::seek_internal | ( | $ | p_internal | ) |
search an operation thankx it internal code
| internal | code |
Definition at line 236 of file class_acc_operation.php.
References $res, $Res, db, Database\fetch_result(), jr_id, and Database\num_row().
{
$res=$this->db->exec_sql('select jr_id from jrn where jr_internal=$1',
array($p_internal));
if ( Database::num_row($Res) == 0 ) return -1;
$this->jr_id=Database::fetch_result($Res,0,0);
return 0;
}
set the pj of a operation in jrn. the jr_id must be set
Definition at line 120 of file class_acc_operation.php.
References $seq, $sql, db, jr_id, jrn, and trim().
{
if ( strlen(trim($this->pj)) == 0 )
{
$sql="update jrn set jr_pj_number=$1 where jr_id=$2";
$this->db->exec_sql($sql,array(null,$this->jr_id));
return '';
}
/* is pj uniq ? */
if ( $this->db->count_sql("select jr_id from jrn where jr_pj_number=$1 and jr_def_id=$2",
array($this->pj,$this->jrn)
) == 0 )
{
$sql="update jrn set jr_pj_number=$1 where jr_id=$2";
$this->db->exec_sql($sql,array($this->pj,$this->jr_id));
}
else
{
/* get pref */
$pref=$this->db->get_value("select jrn_def_pj_pref from jrn_def where jrn_def_id=$1",
array($this->jrn));
/* try another seq */
$flag=0;
$limit=100;
while ( $flag == 0 )
{
/* limit the search to $limit */
if ( $limit < 1 )
{
$this->pj='';
$flag=2;
break;
}
$seq=$this->db->get_next_seq('s_jrn_pj'.$this->jrn);
$this->pj=$pref.$seq;
/* check if the new pj numb exist */
$c=$this->db->count_sql("select jr_id from jrn where jr_pj_number=$1 and jr_def_id=$2",
array($this->pj,$this->jrn)
);
if ( $c == 0 )
{
$flag=1;
break;
}
$limit--;
}
/* a pj numb is found */
if ( $flag == 1 )
{
$sql="update jrn set jr_pj_number=$1 where jr_id=$2";
$this->db->exec_sql($sql,array($this->pj,$this->jr_id));
}
}
return $this->pj;
}
| static Acc_Operation::test_me | ( | ) | [static] |
Definition at line 576 of file class_acc_operation.php.
| Acc_Operation::update_comment | ( | $ | p_text | ) |
| Acc_Operation::$amount |
amount of the operatoin
Definition at line 44 of file class_acc_operation.php.
| Acc_Operation::$date |
the date
Definition at line 42 of file class_acc_operation.php.
| Acc_Operation::$date_paid |
Definition at line 46 of file class_acc_operation.php.
| Acc_Operation::$db |
database connx
Definition at line 35 of file class_acc_operation.php.
| Acc_Operation::$debit |
| Acc_Operation::$grpt |
the group id
Definition at line 45 of file class_acc_operation.php.
| Acc_Operation::$jr_id |
pk of jrn
Definition at line 36 of file class_acc_operation.php.
| Acc_Operation::$jrn |
the ledger to use
Definition at line 40 of file class_acc_operation.php.
| Acc_Operation::$jrn_id |
jrn_def_id
Definition at line 37 of file class_acc_operation.php.
| Acc_Operation::$periode |
periode to use
Definition at line 43 of file class_acc_operation.php.
| Acc_Operation::$poste |
account
Definition at line 41 of file class_acc_operation.php.
| Acc_Operation::$user |
current user
Definition at line 39 of file class_acc_operation.php.