26 require_once NOALYSS_INCLUDE.
'/class/class_user.php';
27 require_once NOALYSS_INCLUDE.
'/class/class_acc_ledger.php';
57 $this->
user=$_SESSION[
'g_user'];
58 $this->periode=$g_user->get_periode();
67 $ret=$this->
db->get_value(
'select jr_grpt_id from jrn where jr_id=$1',
91 if ( $this->poste ==
"") {
throw new Exception (__FILE__.
':'.__LINE__.
' Poste comptable vide');
return false; }
93 if ( $this->amount < 0 )
95 $this->
type=($this->
type==
'd')?
'c':
'd';
97 $this->amount=abs($this->amount);
99 $this->desc=(isset($this->desc))?$this->desc:
'';
100 $Res=$this->
db->exec_sql(
"select insert_jrnx
101 ($1::text,abs($2)::numeric,$3::account_type,$4::integer,$5::integer,$6::bool,$7::text,$8::integer,upper($9),$10::text)",
104 round($this->amount,2),
114 $this->jrnx_id=$this->
db->get_current_seq(
's_jrn_op');
115 return $this->jrnx_id;
123 if ( strlen(
trim($this->pj)) == 0 )
125 $sql=
"update jrn set jr_pj_number=$1 where jr_id=$2";
126 $this->
db->exec_sql(
$sql,array(null,$this->
jr_id));
130 if ( $this->
db->count_sql(
"select jr_id from jrn where jr_pj_number=$1 and jr_def_id=$2",
131 array($this->pj,$this->
jrn)
134 $sql=
"update jrn set jr_pj_number=$1 where jr_id=$2";
135 $this->
db->exec_sql(
$sql,array($this->pj,$this->
jr_id));
140 $pref=$this->
db->get_value(
"select jrn_def_pj_pref from jrn_def where jrn_def_id=$1",
155 $seq=$this->
db->get_next_seq(
's_jrn_pj'.$this->
jrn);
156 $this->pj=$pref.$seq;
159 $c=$this->
db->count_sql(
"select jr_id from jrn where jr_pj_number=$1 and jr_def_id=$2",
160 array($this->pj,$this->
jrn)
172 $sql=
"update jrn set jr_pj_number=$1 where jr_id=$2";
173 $this->
db->exec_sql(
$sql,array($this->pj,$this->
jr_id));
191 $diff=$this->
db->get_value(
"select check_balance ($1)",array($this->grpt));
195 echo
"Erreur : balance incorrecte :diff = $diff";
199 $echeance=( isset( $this->echeance) && strlen(
trim($this->echeance)) != 0)?$this->echeance:null;
200 if ( ! isset($this->mt) )
202 $this->mt=microtime(
true);
206 $Res=$this->
db->exec_sql(
"insert into jrn (jr_def_id,jr_montant,jr_comment,".
207 "jr_date,jr_ech,jr_grpt_id,jr_tech_per,jr_mt) values (".
209 "to_date($4,'DD.MM.YYYY'),to_date($5,'DD.MM.YYYY'),$6,$7,$8)",
210 array ($this->
jrn, $this->amount,$p_comment,
211 $this->date,$echeance,$this->grpt,$this->periode,$this->mt)
213 if (
$Res ==
false)
return false;
214 $this->
jr_id=$this->
db->get_current_seq(
's_jrn');
225 if ( ! isset($this->
jr_id) )
226 throw new Exception(
'jr_id is not set',1);
227 $Res=$this->
db->exec_sql(
"select jr_internal from jrn where jr_id=".$this->
jr_id);
230 $this->jr_internal= $l_line[
'jr_internal'];
231 return $this->jr_internal;
239 $res=$this->
db->exec_sql(
'select jr_id from jrn where jr_internal=$1',
252 $filter_sql=$g_user->get_ledger_sql(
'ALL',3);
253 $filter_sql=str_replace(
'jrn_def_id',
'jr_def_id',$filter_sql);
254 if ( $this->
jr_id==0 )
return;
255 $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,
256 vw_name,pcm_lib,j_debit,coalesce(comptaproc.get_letter_jnt(j_id),-1) as letter,jr_def_id ".
257 " from jrnx join jrn on (jr_grpt_id=j_grpt)
258 join tmp_pcmn on (j_poste=pcm_val)
259 left join vw_fiche_attr on (j_qcode=quick_code)
261 jr_id=$1 and $filter_sql order by j_debit desc";
270 $sql=
"update jrnx set j_text=$1 where j_id=$2";
271 $this->
db->exec_sql(
$sql,array($p_text,$this->jrnx_id));
276 $sql=
"update jrn set jr_comment=$1 where jr_id=$2";
277 $this->
db->exec_sql(
$sql,array($p_text,$this->
jr_id));
282 if (
isDate($p_text) == null )
286 $sql=
"update jrn set jr_ech=to_date($1,'DD.MM.YYYY') where jr_id=$2";
287 $this->
db->exec_sql(
$sql,array($p_text,$this->
jr_id));
292 $sql=
"select jr_def_id from jrn where jr_id=$1";
311 if ( $l[
'j_poste'] == $this->poste || ($l[
'j_qcode']==$this->qcode &&
trim($this->qcode) !=
''))
312 $border=
' class="highlight"';
313 $r.=
'<tr '.$border.
'>';
322 $r.=
'<td '.$border.
'>';
329 $r.=
'<td '.$border.
'>';
331 $a=(strlen(
trim($l[
'j_qcode']))==0)?$l[
'pcm_lib']:$l[
'vw_name'];
337 $r.=
'<td '.$border.
'>';
344 $r.=
'<td '.$border.
'>';
352 $r.=
'<td '.$border.
'>';
353 $a=($l[
'letter']!=-1)?$l[
'letter']:
'';
375 return "ERROR PARAMETRE";
411 $Res=$this->
db->exec_sql(
"select
412 to_char(j_date,'DD.MM.YYYY') as j_date,
416 coalesce(j_qcode,'-') as qcode,
420 to_char(jr_ech,'DD.MM.YYYY') as jr_ech,
421 to_char(jr_date,'DD.MM.YYYY') as jr_date,
422 jr_id,jr_internal,jr_def_id,jr_pj
423 from jrnx inner join jrn on j_grpt=jr_grpt_id where j_grpt=$1",array($p_grpt));
425 if ( $MaxLine == 0 )
return null;
428 for ( $i=0; $i < $MaxLine; $i++)
432 $l_array[
'op_date']=$l_line[
'j_date'];
433 if ( $l_line[
'j_debit'] ==
't' )
435 $l_class=sprintf(
"class_deb%d",
$deb);
436 $l_montant=sprintf(
"mont_deb%d",
$deb);
437 $l_text=sprintf(
"text_deb%d",
$deb);
438 $l_qcode=sprintf(
"qcode_deb%d",
$deb);
439 $l_array[$l_class]=$l_line[
'j_poste'];
440 $l_array[$l_montant]=$l_line[
'j_montant'];
441 $l_array[$l_text]=$l_line[
'j_text'];
442 $l_array[$l_qcode]=$l_line[
'qcode'];
443 $l_id=sprintf(
"op_deb%d",
$deb);
444 $l_array[$l_id]=$l_line[
'j_id'];
447 if ( $l_line[
'j_debit'] ==
'f' )
449 $l_class=sprintf(
"class_cred%d",
$cred);
450 $l_montant=sprintf(
"mont_cred%d",
$cred);
451 $l_array[$l_class]=$l_line[
'j_poste'];
452 $l_array[$l_montant]=$l_line[
'j_montant'];
453 $l_id=sprintf(
"op_cred%d",
$cred);
454 $l_array[$l_id]=$l_line[
'j_id'];
455 $l_text=sprintf(
"text_cred%d",
$cred);
456 $l_array[$l_text]=$l_line[
'j_text'];
457 $l_qcode=sprintf(
"qcode_cred%d",
$cred);
458 $l_array[$l_qcode]=$l_line[
'qcode'];
461 $l_array[
'jr_internal']=$l_line[
'jr_internal'];
462 $l_array[
'comment']=$l_line[
'jr_comment'];
463 $l_array[
'ech']=$l_line[
'jr_ech'];
464 $l_array[
'jr_id']=$l_line[
'jr_id'];
465 $l_array[
'jr_def_id']=$l_line[
'jr_def_id'];
493 if ( $ledger_id==
'')
throw new Exception(_(
'Journal non trouvé'));
499 switch($oledger->get_type())
515 if ( empty(
$ret->det->array))
530 $this->info=
new stdClass();
532 $array=$this->
db->get_value(
"select ji_value from jrn_info where
533 jr_id=$1 and id_type=$2",array($this->
jr_id,
'OTHER'));
534 $this->info->other=
$array;
537 $array=$this->
db->get_value(
"select ji_value from jrn_info where
538 jr_id=$1 and id_type=$2",array($this->
jr_id,
'BON_COMMANDE'));
539 $this->info->command=
$array;
549 if ( ! in_array(
$p_type,array(
'OTHER',
'BON_COMMANDE')))
return;
550 if (
trim($p_info)==
"") {
551 $this->
db->exec_sql(
'delete from jrn_info where jr_id=$1 and id_type=$2',array($this->
jr_id,
$p_type));
554 $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));
555 if ( $exist ==
"0" ) {
557 $this->
db->exec_sql(
'insert into jrn_info(jr_id,id_type,ji_value) values ($1,$2,$3)',
559 } elseif ( $exist == 1) {
561 $this->
db->exec_sql(
'update jrn_info set ji_value=$3 where jr_id=$1 and id_type=$2',
568 if ($p_string ==
"")
return;
569 $a_action=explode(
',',$p_string);
570 for ($i=0;$i<count($a_action);$i++)
584 throw new Exception(_(
'Acc_Operation::set_id , id invalide '));
594 if ( $this->
jr_id == 0 )
595 throw new Exception(_(
'Object invalide, id incorrect'));
597 $this->
db->get_value(
'select count(*) from jrn where jr_id=$1',
598 array($this->
jr_id)) == 0 )
599 throw new Exception(_(
'Object invalide, id incorrect'));
601 $this->
db->exec_sql(
"update jrn set jr_rapt = 'paid' where jr_id = $1",
602 array($this->
jr_id));
609 if ( $this->
jr_id == 0 )
610 throw new Exception(_(
'Object invalide, id incorrect'));
611 $amount=$this->
db->get_value(
'select jr_montant from jrn where jr_id=$1',
612 array($this->
jr_id));
617 $_SESSION[
'g_user']=NOALYSS_ADMINISTRATOR;
618 $_SESSION[
'g_pass']=
'dany';
633 parent::__construct($p_cn);
634 $this->
jr_id=$p_jrid;
635 $this->det=
new stdClass();
643 $sql=
"SELECT jr_id, jr_def_id, jr_montant, jr_comment, jr_date, jr_grpt_id,
644 jr_internal, jr_tech_date, jr_tech_per, jrn_ech, jr_ech, jr_rapt,jr_ech,
645 jr_valid, jr_opid, jr_c_opid, jr_pj, jr_pj_name, jr_pj_type,
646 jr_pj_number, jr_mt,jr_rapt,jr_date_paid
647 FROM jrn where jr_id=$1";
649 if ( count(
$array) == 0 )
throw new Exception(
'Aucune ligne trouvée');
652 $this->det->$key=
$val;
654 $sql=
"select n_text from jrn_note where jr_id=$1";
655 $this->det->note=$this->
db->get_value(
$sql,array($this->
jr_id));
656 $this->det->note=strip_tags($this->det->note);
671 parent::__construct($p_cn,$p_jrid);
672 $this->signature=
'ODS';
673 $this->det=
new stdClass();
678 $sql=
"SELECT j_id, j_date, j_montant, j_poste, j_grpt, j_rapt, j_jrn_def,
679 j_debit, j_text, j_centralized, j_internal, j_tech_user, j_tech_date,
680 j_tech_per, j_qcode,f_id
681 FROM jrnx where j_grpt = $1 order by j_debit desc,j_poste";
682 $this->det->array=$this->
db->get_array(
$sql,array($this->det->jr_grpt_id));
695 parent::__construct($p_cn,$p_jrid);
696 $this->signature=
'VEN';
697 $this->det=
new stdClass();
702 $sql=
"SELECT qs_id, qs_internal, qs_fiche, qs_quantite, qs_price, qs_vat,
703 qs_vat_code, qs_client, qs_valid, j_id,j_text,qs_vat_sided , qs_unit , j_debit
704 FROM quant_sold join jrnx using(j_id) where j_grpt=$1";
705 $this->det->array=$this->
db->get_array(
$sql,array($this->det->jr_grpt_id));
720 parent::__construct($p_cn,$p_jrid);
721 $this->signature=
'ACH';
727 $sql=
"SELECT qp_id, qp_internal, j_id, qp_fiche, qp_quantite, qp_price, qp_vat,
728 qp_vat_code, qp_nd_amount, qp_nd_tva, qp_nd_tva_recup, qp_supplier,
729 qp_valid, qp_dep_priv,j_text,qp_vat_sided,qp_unit , j_debit
730 FROM quant_purchase join jrnx using(j_id) where j_grpt=$1";
731 $this->det->array=$this->
db->get_array(
$sql,array($this->det->jr_grpt_id));
744 parent::__construct($p_cn,$p_jrid);
745 $this->signature=
'FIN';
751 $sql=
"SELECT qf_id, qf_bank, jr_id, qf_other, qf_amount
752 FROM quant_fin where jr_id = $1";
753 $this->det->array=$this->
db->get_array(
$sql,array($this->
jr_id));
static fetch_all($ret)
wrapper for the function pg_fetch_all
get_internal()
Return the internal value, the property jr_id must be set before.
get_ledger()
return the jrn_def_id from jrn
seek_group()
retrieve the grpt_id from jrn for a jr_id
this class manage data from the JRNX and JRN table
static num_row($ret)
wrapper for the function pg_NumRows
__construct($p_cn, $p_jrid=0)
this class manage data from the QUANT_PURCHASE table
Data & function about connected users.
__construct($p_cn)
constructor set automatically the attributes user and periode
insert_jrn()
Insert into the table Jrn, the amount is computed from jrnx thanks the group id ($p_grpt) ...
operation_update_date_limit($p_text)
add a limit of payment to the operation (jrn.jr_ech)
this class manage data from the QUANT_FIN table
set_pj()
set the pj of a operation in jrn. the jr_id must be set
__construct($p_cn, $p_jrid=0)
display_jrnx_detail($p_table)
display_jrnx_detail : get the data from get_jrnx_data and return a string with HTML code ...
get_jrnx_detail()
retrieve data from jrnx
get_data($p_grpt)
Get data from jrnx where p_grpt=jrnx(j_grpt)
__construct($p_cn, $p_jrid=0)
static fetch_array($ret, $p_indice=0)
wrapper for the function pg_fetch_array
class_action for manipulating actions action can be :
insert_related_action($p_string)
get_amount()
return amount of the jr_id
set_paid()
flag the operation as paid
for($i=0;$i<$nb_jrn;$i++) $deb
global $g_user
Find the default module or the first one.
Class for jrn, class acc_ledger for manipulating the ledger.
function trim(s)
remove trailing and heading space
seek_internal($p_internal)
search an operation thankx it internal code
get_info()
retrieve info from the jrn_info, create 2 new arrays obj->info->command and obj->info->other the colu...
save_info($p_info, $p_type)
Save into jrn_info.
h($p_string)
to protect again bad characters which can lead to a cross scripting attack the string to be diplayed ...
this file match the tables jrn & jrnx the purpose is to remove or save accountant writing to these ta...
this class manage data from the QUANT_SOLD table
static fetch_result($ret, $p_row=0, $p_col=0)
wrapper for the function pg_fetch_all
for($j=0;$j< $nb_row;$j++)($j%2==0)?'even' $show
__construct($p_cn, $p_jrid=0)
__construct($p_cn, $p_jrid=0)
insert_jrnx()
Insert into the table Jrn The needed data are :
operation_update_comment($p_text)
add a comment to the operation (jrn.jr_text)
update_comment($p_text)
add a comment to the line (jrnx.j_text)
get_quant()
retrieve data from the table QUANT_*