27 require_once NOALYSS_INCLUDE.
'/lib/class_iconcerned.php';
28 require_once NOALYSS_INCLUDE.
'/lib/class_database.php';
29 require_once NOALYSS_INCLUDE.
'/class/class_dossier.php';
30 require_once NOALYSS_INCLUDE.
'/class/class_lettering.php';
72 if (
trim($jr_id2) ==
"" )
74 if ( strpos($jr_id2,
',') !== 0 )
76 $aRapt=explode(
',',$jr_id2);
77 foreach ($aRapt as $rRapt)
107 if ( $this->
jr_id==$jr_id2)
110 if ( $this->
db->count_sql(
"select jr_id from jrn where jr_id=".$this->jr_id)==0 )
112 if ( $this->
db->count_sql(
"select jr_id from jrn where jr_id=".$jr_id2)==0 )
116 if ( $this->
db->count_sql(
117 "select jra_id from jrn_rapt where jra_concerned=".$this->jr_id.
120 select jra_id from jrn_rapt where jr_id=".$this->jr_id.
121 " and jra_concerned=$jr_id2 ")
125 $Res=$this->
db->exec_sql(
"insert into jrn_rapt(jr_id,jra_concerned) values ".
126 "(".$this->
jr_id.
",$jr_id2)");
131 $source_type=$this->
db->get_value(
"select substr(jr_internal,1,1) from jrn where jr_id=$1",array($this->
jr_id));
132 $dest_type=$this->
db->get_value(
"select substr(jr_internal,1,1) from jrn where jr_id=$1",array($jr_id2));
133 if (($source_type ==
'A' || $source_type==
'V') && ($dest_type !=
'A' && $dest_type !=
'V'))
136 $date=$this->
db->get_value(
'select jr_date from jrn where jr_id=$1',array($jr_id2));
138 $this->
db->exec_sql(
'update jrn set jr_date_paid=$1 where jr_id=$2 and jr_date_paid is null ',array(
$date,$this->
jr_id));
140 if (($source_type !=
'A' && $source_type !=
'V') && ($dest_type ==
'A' || $dest_type ==
'V'))
143 $date=$this->
db->get_value(
'select jr_date from jrn where jr_id=$1',array($this->
jr_id));
145 $this->
db->exec_sql(
'update jrn set jr_date_paid=$1 where jr_id=$2 and jr_date_paid is null ',array(
$date,$jr_id2));
157 $sql=
"select j1.f_id as fiche ,coalesce(j1.j_id,-1) as jrnx_id1,coalesce(j2.j_id,-1) as jrnx_id2,
160 join jrn as jr1 on (j1.j_grpt=jr1.jr_grpt_id)
161 join jrnx as j2 on (coalesce(j1.f_id,-1)=coalesce(j2.f_id,-1) and j1.j_poste=j2.j_poste)
162 join jrn as jr2 on (j2.j_grpt=jr2.jr_grpt_id)
172 for ($i=0;$i<count(
$result);$i++)
174 if (
$result[$i][
'fiche'] != -1)
196 function remove($jr_id2)
204 if ( $this->
db->count_sql(
"select jra_id from jrn_rapt where ".
205 " jra_concerned=".$this->jr_id.
" and jr_id=$jr_id2
207 select jra_id from jrn_rapt where jra_concerned=$jr_id2 ".
208 " and jr_id=".$this->jr_id) !=0)
215 where jl_id in ( select jl_id from jnt_letter
216 join letter_cred as lc using(jl_id)
217 join letter_deb as ld using (jl_id)
219 lc.j_id in (select j_id
220 from jrnx join jrn on (j_grpt=jr_grpt_id)
221 where jr_id in ($1,$2))
223 ld.j_id in (select j_id
224 from jrnx join jrn on (j_grpt=jr_grpt_id)
225 where jr_id in ($1,$2))
230 $this->
db->exec_sql(
$sql, array($jr_id2, $this->
jr_id));
232 $Res=$this->
db->exec_sql(
"delete from jrn_rapt where ".
233 "(jra_concerned=$jr_id2 and jr_id=".$this->
jr_id.
") or
234 (jra_concerned=".$this->jr_id.
" and jr_id=$jr_id2) ");
247 $sql=
" select jr_id as cn from jrn_rapt where jra_concerned=".$this->jr_id.
249 " select jra_concerned as cn from jrn_rapt where jr_id=".$this->jr_id;
255 if ($n ==0 )
return null;
258 for ($i=0;$i<$n;$i++)
267 $sql=
"select jr_id,jr_date,jr_comment,jr_internal,jr_montant,jr_pj_number,jr_def_id,jrn_def_name,jrn_def_type
268 from jrn join jrn_def on (jrn_def_id=jr_def_id)
283 $array=$this->
db->get_array(
"select distinct jr_id,jr_date from jrn where $filter_date and $sql_jrn and jr_id not in (select jr_id from jrn_rapt union select jra_concerned from jrn_rapt) order by jr_date");
285 for ($i=0;$i<count(
$array);$i++)
290 $this->
db->prepare(
'detail_quant',
'select * from v_quant_detail where jr_id=$1');
303 $sql=$g_user->get_ledger_sql(
'ALL',3);
304 $sql=str_replace(
'jrn_def_id',
'jr_def_id',
$sql);
307 if ($this->
a_jrn != null )
310 $r=
'and jr_def_id in (';
338 $array=$this->
db->get_array(
"select distinct jr_id,jr_date from jrn where $filter_date and $sql_jrn and jr_id in (select jr_id from jrn_rapt union select jra_concerned from jrn_rapt) order by jr_date");
340 for ($i=0;$i<count(
$array);$i++)
345 for (
$e=0;
$e<count($atmp);
$e++)
351 $this->
db->prepare(
'detail_quant',
'select * from v_quant_detail where jr_id=$1');
370 for ($i=0;$i<count(
$array);$i++)
372 $first_amount=
$array[$i][
'first'][
'jr_montant'];
376 $second_amount=bcadd($second_amount,
$array[$i][
'depend'][
$e][
'jr_montant']);
378 if ( $p_equal && $first_amount==$second_amount)
382 if ( ! $p_equal && $first_amount != $second_amount)
398 list(
$start,
$end)=$g_user->get_limit_current_exercice();
408 $sql=
" (jr_date >= to_date('".$this->start_day.
"','DD.MM.YYYY')
409 and jr_date <= to_date('".$this->
end_day.
"','DD.MM.YYYY'))";
417 echo
'<tr class="odd">';
419 echo
'<td colspan="5" style="border:1px solid black;width:auto">';
420 include NOALYSS_TEMPLATE.
'/impress_reconciliation_detail.php';
437 require_once NOALYSS_INCLUDE.
'/lib/class_noalyss_csv.php';
442 for ($i = 0; $i < count(
$array); $i++)
448 $first =
$array[$i][
'first'];
451 if (isset(
$array[$i][
'depend']))
453 $a_depend =
$array[$i][
'depend'];
463 $title[]=_(
'type journal');
470 $title[]=_(
'nom journal');
471 $title[]=_(
'type journal');
487 $title[]=_(
'type journal');
497 $export->add($first[
'jr_date']);
498 $export->add($first[
'jr_internal']);
499 $export->add($first[
'jr_comment']);
500 $export->add($first[
'jr_pj_number']);
501 $export->add($first[
'jrn_def_name']);
502 $export->add($first[
'jrn_def_type']);
503 $export->add($first[
'jr_montant'],
"number");
504 if (count($a_depend) > 0)
509 $depend = $a_depend[0];
512 $export->add($depend[
'jr_date']);
513 $export->add($depend[
'jr_internal']);
514 $export->add($depend[
'jr_comment']);
515 $export->add($depend[
'jr_pj_number']);
516 $export->add($depend[
'jrn_def_name']);
517 $export->add($depend[
'jrn_def_type']);
518 $export->add($depend[
'jr_montant'],
"number");
523 for (
$e = 1;
$e < count($a_depend);
$e++)
525 $depend = $a_depend[
$e];
535 $export->add($depend[
'jr_date']);
536 $export->add($depend[
'jr_internal']);
537 $export->add($depend[
'jr_comment']);
538 $export->add($depend[
'jr_pj_number']);
539 $export->add($depend[
'jrn_def_name']);
540 $export->add($depend[
'jrn_def_type']);
541 $export->add($depend[
'jr_montant'],
"number");
578 echo
"Choix invalid";
579 throw new Exception(
"invalide");
588 var_dump(
$rap->get_reconciled_amount(
'',
false));
$acc_reconciliation end_day
static num_row($ret)
wrapper for the function pg_NumRows
only for operation retrieved thanks a quick_code manage the accounting entries for a given card ...
auto_letter($p_jrid)
try to letter same card between $p_jrid and $this->jr_id
only for operation retrieved thanks a account (jrnx.j_poste) manage the accounting entries for a give...
get_not_reconciled()
return array of not-reconciled operation Prepare and put in memory the SQL detail_quant ...
filter_date()
create a string to filter thanks the date
get_reconciled_amount($p_equal=false)
Prepare and put in memory the SQL detail_quant.
static fetch_array($ret, $p_indice=0)
wrapper for the function pg_fetch_array
insert_rapt($jr_id2)
Insert into jrn_rapt the concerned operations should not be called directly, use insert instead...
ledger_filter()
Create a sql condition to filter by security and by asked ledger based on $this->a_jrn.
global $g_user
Find the default module or the first one.
$acc_reconciliation a_jrn
function trim(s)
remove trailing and heading space
new class for managing the reconciliation it must be used instead of the function InsertRapt...
insert($jr_id2)
Insert into jrn_rapt the concerned operations.
widget()
return a widget of type js_concerned
export_csv($p_choice)
Export to CSV.
$acc_reconciliation start_day
get_reconciled()
return array of reconciled operation Prepare and put in memory the SQL detail_quant ...