26require_once NOALYSS_INCLUDE.
'/header_print.php';
32#[AllowDynamicProperties]
55 $r.=dossier::hidden();
65 $periode_start=$this->
db->make_array(
"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $p_filter_year order by p_start,p_end");
67 $periode_end=$this->
db->make_array(
"select p_id,to_char(p_end,'DD-MM-YYYY') from parm_periode $p_filter_year order by p_end,p_start");
69 $w->label=_(
"Depuis");
73 $w->label=_(
" jusque ");
81 $mod->value=$this->
db->make_array(
"select b_id, b_name from bilan order by b_name");
82 $mod->label=_(
"Choix du bilan");
83 $r.=
td($mod->input(
'b_id'));
93 $to_periode->value=$this->
db->get_value(
"select to_char(max(p_end),'DD.MM.YYYY') from parm_periode $p_filter_year");
98 $mod->value=$this->
db->make_array(
"select b_id, b_name from bilan order by b_name");
100 $r.=_(
"Choix du bilan");
101 $r.=$mod->input(
'b_id');
106 $msg=_(
"Configurer le report ");
126 $exercice=$this->
db->get_value(
"select max( p_exercice) from parm_periode
127 where p_start >= to_date($1,'DD.MM.YYYY')
128 and p_end <= to_date($2,'DD.MM.YYYY') ",
134 sum(amount_deb) as amount_debit,
135 sum(amount_cred) as amount_credit
140 case when j_debit='t' then j_montant else 0 end as amount_deb,
141 case when j_debit='f' then j_montant else 0 end as amount_cred
143 where ".$filter_sql.
"
145 ) as m on (j_poste=pcm_val)
148 group by pcm_val,pcm_lib";
166 $solde_signed=bcsub(
$line[
'amount_debit'],
$line[
'amount_credit']);
169 ($solde_signed < 0 && $p_deb ==
'D' ) ||
170 ($solde_signed > 0 && $p_deb ==
'C' )
173 $ret.=
'<li> '.HtmlInput::history_account(
$line[
'pcm_val'],_(
'Anomalie pour le compte ').
$line[
'pcm_val'].
' '.
h(
$line[
'pcm_lib']).
174 " D: ".
$line[
'amount_debit'].
175 " C: ".
$line[
'amount_credit'].
" diff ".(abs($solde_signed)),
"",
$exercice);
182 echo
'<legend>'.$p_message.
'</legend>';
185 echo
'<ol>'.$ret.
'</ol>';
186 echo
'<span class="error">'._(
"Nbres anomalies").
' : '.
$count.
'</span>';
189 echo _(
"Pas d'anomalie détectée");
199 echo
'<h3>'._(
"Comptes normaux").
'</h3>';
200 $this->
warning(_(
'Actif avec un solde crediteur'),
'ACT',
'D');
201 $this->
warning(_(
'Passif avec un solde debiteur'),
'PAS',
'C');
202 $this->
warning(_(
'Compte de resultat : Charge avec un solde crediteur'),
'CHA',
'D');
203 $this->
warning(_(
'Compte de resultat : produit avec un solde debiteur'),
'PRO',
'C');
205 echo
'<h3>'._(
"Comptes inverses").
' </h3>';
206 $this->
warning(_(
'Compte inverse : actif avec un solde debiteur'),
'ACTINV',
'C');
207 $this->
warning(_(
'Compte inverse : passif avec un solde crediteur'),
'PASINV',
'D');
208 $this->
warning(_(
'Compte inverse : Charge avec un solde debiteur'),
'CHAINV',
'C');
209 $this->
warning(_(
'Compte inverse : produit avec un solde crediteur'),
'PROINV',
'D');
210 echo
'<h3'._(
"Solde").
' </h3>';
218 $sqlAccount=
"select sum(amount_deb) as amount_debit ,
219 sum(amount_cred) as amount_credit
222 case when j_debit='t' then j_montant else 0 end as amount_deb,
223 case when j_debit='f' then j_montant else 0 end as amount_cred
228 ) as JP1 join tmp_pcmn on (JP1.j_poste=pcm_val)
229 where pcm_type=$1 or pcm_type=$2";
232 if ( ! $this->
db->is_prepare(
"sqlAccount") ) $this->
db->prepare(
"sqlAccount",$sqlAccount);
237 $res=$this->
db->execute(
"sqlAccount",array(
'ACT',
'ACTINV'));
245 $total_actif=abs(bcsub($debit_actif,$credit_actif));
247 echo
tr(
td(_(
'Total actif')).
td($total_actif,
'style="text-align:right"'));
250 $res=$this->
db->execute(
"sqlAccount",array(
'PAS',
'PASINV'));
257 $total_passif=abs(bcsub($debit_passif,$credit_passif));
260 echo
tr(
td(_(
'Total passif')).
td($total_passif,
'style="text-align:right"'));
261 if ( $total_actif != $total_passif )
263 $diff=bcsub($total_actif,$total_passif);
264 echo
tr(
td(
' Difference Actif - Passif ').
td(
$diff,
'style="text-align:right"'),
'style="font-weight:bolder"');
268 $res=$this->
db->execute(
"sqlAccount",array(
'CHA',
'CHAINV'));
275 $total_charge=abs(bcsub($debit_charge,$credit_charge));
276 echo
tr(
td(_(
'Total charge ')).
td($total_charge,
'style="text-align:right"'));
280 $res=$this->
db->execute(
"sqlAccount",array(
'PRO',
'PROINV'));
287 $total_pro=abs(bcsub($debit_pro,$credit_pro));
288 echo
tr(
td(_(
'Total produit')).
td($total_pro,
'style="text-align:right"'));
290 $diff=bcsub($total_pro,$total_charge);
292 echo
tr(
td(_(
"Difference Produit - Charge"),
'style="padding-right:20px"').
td(
$diff,
'style="text-align:right"'),
'style="font-weight:bolder"');
303 $http=new \HttpInput();
304 $this->b_id=
$http->get(
"b_id",
"number",
"");
307 $this->
from=
$http->get(
"from_periode",
"number",-1);
308 $this->
to=
$http->get(
"to_periode",
"number",-1);
310 $this->
from=
$http->get(
"from_periode",
"date",
"");
311 $this->
to=
$http->get(
"to_periode",
"date",
"");
320 if ( $this->b_id==
"")
321 throw new Exception(_(
"le formulaire id n'est pas donnee"));
323 $sql=
"select b_name,b_file_template,b_file_form,lower(b_type) as b_type from bilan where".
328 throw new Exception (_(
'Aucun enregistrement trouve'));
330 $this->b_name=
$array[
'b_name'];
331 $this->b_file_template=
$array[
'b_file_template'];
332 $this->b_file_form=
$array[
'b_file_form'];
333 $this->b_type=
$array[
'b_type'];
339 echo $Ex->getMessage();
347 $form=fopen($this->b_file_form,
'r');
351 throw new Exception(_(
'Echec ouverture fichier '.$this->b_file_form));
359 $templ=fopen($this->b_file_template,
'r');
360 if ( $templ ==
false)
363 throw new Exception(_(
'Echec ouverture fichier '.$this->b_file_template));
380 while (! feof ($p_handle))
382 $buffer=trim(fgets($p_handle));
390 if ( strpos($buffer,
'#') ===
true )
398 if ( eval(
"$b;") ===
false )
399 echo(__FILE__.__LINE__.
"Code failed with $b");
416 $dirname=tempnam($_ENV[
'TMP'],
'bilan_');
424 $file_base=NOALYSS_HOME.DIRECTORY_SEPARATOR.$this->b_file_template;
425 $work_file=basename($file_base);
426 if ( copy ($file_base,$work_file) ==
false )
428 echo _(
"erreur Ouverture fichier");
429 throw new Exception(_(
'Echec ouverture fichier '.$file_base));
434 if ($zip->open($work_file) === TRUE)
436 $zip->extractTo(
$dirname.DIRECTORY_SEPARATOR);
440 echo __FILE__.
":".__LINE__.
"cannot unzip model ".$file_base;
446 $p_file=fopen(
'content.xml',
'r');
448 if ( $p_file ==
false)
450 throw new Exception(_(
'Echec ouverture fichier '.$p_file));
454 $regex=
"/<<\\$[A-Z]*[0-9]*>>/";
457 $header_txt=mb_convert_encoding(
header_txt($this->
db),
'UTF-8',
'ISO8859-1');
458 $header_txt=iconv(
'ISO-8859-1',
'UTF-8//IGNORE',
header_txt($this->
db));
462 while ( !feof($p_file) )
464 $line_rtf=fgets($p_file);
469 $line_rtf=preg_replace(
'/<<header>>/',$header_txt,$line_rtf);
476 while (preg_match_all($regex,$line_rtf,$f2) > 0 )
479 foreach ($f2 as $f2_array)
481 foreach ($f2_array as $f2_str)
491 if( ! isset($this->$f2_value))
494 $a =
"!!".$f2_value.
"!!";
495 if( substr($f2_value, 0, 1) ==
"N" )
497 $ret = $this->
db->get_array(
"SELECT pcm_lib AS acct_name FROM tmp_pcmn WHERE pcm_val::text LIKE ".
498 " substr($1, 2)||'%' ORDER BY pcm_val ASC LIMIT 1",array($f2_value));
499 if(
$ret[0][
'acct_name'])
501 $a =
$ret[0][
'acct_name'];
511 if (
$a==
'-0' )
$a=0;
514 if ( is_numeric(
$a) )
517 $searched=
'office:value-type="string"><text:p>'.$f2_str;
518 $replaced=
'office:value-type="float" office:value="'.$a.
'"><text:p>'.$f2_str;
521 $searched=
'office:value-type="string" calcext:value-type="string"><text:p>'.$f2_str;
522 $replaced=
'office:value-type="float" office:value="'.$a.
'" calcext:value-type="float"><text:p>'.$f2_str;
547 if ( $this->b_type==
'html')
551 $pattern=
'/<<header>>/';
557 $pattern=
'/<<header>>/';
562 if ($this->b_type ==
"rtf") {
565 while ( !feof($p_file) )
567 $line_rtf=fgets($p_file);
569 $line_rtf=preg_replace($pattern,$header_txt,$line_rtf);
573 if (preg_match_all(
"/".$lt.$lt.
"\\$[a-zA-Z]*[0-9]*".$gt.$gt.
"/",$line_rtf,$f2) > 0)
578 foreach ($f2 as $f2_str)
586 $f2_value=$f2_value[0];
589 if( ! isset($this->$f2_value))
591 $a =
"!!".$f2_value.
"!!";
592 if( substr($f2_value, 0, 1) ==
"N" )
594 $ret = $this->
db->get_array(
"SELECT pcm_lib AS acct_name FROM tmp_pcmn WHERE ".
595 " pcm_val::text LIKE substr($1, 2)||'%' ORDER BY pcm_val ASC LIMIT 1",
597 if(
$ret[0][
'acct_name'])
600 if ( $this->b_type !=
"rtf") {
$a = mb_convert_encoding((
$ret[0][
'acct_name']),
'ISO-8859-1',
'UTF-8');}
613 if (
$a==
'-0' )
$a=0;
644 switch ($this->b_type)
672 switch ($this->b_type)
676 header(
'Content-type: application/rtf');
677 header(
'Content-Disposition: attachment; filename="'.$this->b_name.
'.rtf"');
683 header(
'Content-type: application/txt');
684 header(
'Content-Disposition: attachment; filename="'.$this->b_name.
'.txt"');
690 header(
'Content-type: application/html');
691 header(
'Content-Disposition: attachment; filename="'.$this->b_name.
'.html"');
697 header(
"Pragma: public");
698 header(
"Expires: Mon, 26 Jul 1997 05:00:00 GMT");
699 header(
"Cache-Control: must-revalidate");
700 if ( $this->b_type ==
'odt' )
702 header(
'Content-type: application/vnd.oasis.opendocument.text');
703 header(
'Content-Disposition: attachment;filename="'.$this->b_name.
'.odt"',FALSE);
705 if ( $this->b_type ==
'ods' )
707 header(
'Content-type: application/vnd.oasis.opendocument.spreadsheet');
708 header(
'Content-Disposition: attachment;filename="'.$this->b_name.
'.ods"',FALSE);
711 header(
"Accept-Ranges: bytes");
716 $dirname=@tempnam($_ENV[
'TMP'].DIRECTORY_SEPARATOR.
'tmp',
'bilan_');
723 $file_base=NOALYSS_HOME.DIRECTORY_SEPARATOR.$this->b_file_template;
724 $work_file=basename($file_base);
725 if ( copy ($file_base,$work_file) ==
false )
727 throw new Exception ( _(
"Ouverture fichier impossible"));
734 if ($zip->open($work_file) === TRUE)
736 $zip->extractTo(
$dirname.DIRECTORY_SEPARATOR);
741 echo __FILE__.
":".__LINE__.
"cannot unzip model ".$file_base;
749 $p_file=fopen(
$dirname.DIRECTORY_SEPARATOR.
'content.xml',
'wb');
750 if ( $p_file ==
false )
752 throw new Exception ( _(
"erreur Ouverture fichier").
' content.xml');
755 $a=fwrite($p_file,$p_result);
758 throw new Exception ( _(
"erreur écriture fichier").
' content.xml');
762 $res = $zip->open($this->b_name.
".".$this->b_type, ZipArchive::CREATE);
765 throw new Exception (__FILE__.
":".__LINE__.
"cannot recreate zip");
767 $zip->add_recurse_folder(
$dirname.DIRECTORY_SEPARATOR);
772 $fdoc=fopen(
$dirname.DIRECTORY_SEPARATOR.$this->b_name.
'.'.$this->b_type,
'r');
773 if ( $fdoc ==
false )
775 throw new Exception (_(
"erreur Ouverture fichier"));
777 $buffer=fread ($fdoc,filesize(
$dirname.DIRECTORY_SEPARATOR.$this->b_name.
'.'.$this->b_type));
788 if ( isset(
$_GET[
'result']))
793 $a->get_request_get();
800 $templ=
$a->file_open_template();
801 $r=
$a->generate_odt($templ);
811 $a->get_request_get();
813 echo
'<form method="get">';
814 echo
$a->display_form();
830 throw new Exception (_(
"Date invalide"));
833 $sql_periode=
" to_char(jrnx.j_date,'YYYYMMDD')>= '$from'
834 and to_char(jrnx.j_date,'YYYYMMDD') <='$to' ";
format_date($p_date, $p_from_format='YYYY-MM-DD', $p_to_format='DD.MM.YYYY')
format the date, when taken from the database the format is MM-DD-YYYY
sql_filter_per($p_cn, $p_from, $p_to, $p_form='p_id', $p_field='jr_tech_per')
Create the condition to filter on the j_tech_per thanks a from and to date.
noalyss_strlentrim($p_string)
echo_warning($p_string)
warns
noalyss_str_replace($search, $replace, $string)
tr($p_string, $p_extra='')
record_log($p_message)
Record an error message into the log file of the server.
td($p_string='', $p_extra='')
surround the string with td
if(!function_exists( 'tracedebug')) convert_to_rtf($p_string)
encode the string for RTF, return a string
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
h( $row[ 'oa_description'])
catch(Exception $e) $exercice
foreach($array as $idx=> $m) $w
Manage the account from the table jrn, jrnx or tmp_pcmn.
this class handle the different bilan, from the table bilan, parse the form and replace in the templa...
generate_plain($p_file)
generate the plain file (rtf,txt, or html)
load()
load from the database the document data
send($p_result)
send the result of generate plain to the browser
get_request_get()
get data from the $_GET
verify()
verify that the saldo is good for the type of account
generate_odt()
generate the ods document
warning($p_message, $p_type, $p_deb)
check and warn if an accound has the wrong saldo
generate()
generate the document and send it to the browser
file_open_template()
open the file with the template
display_form($p_filter_year="")
return a string with the form for selecting the periode and the type of bilan
compute_formula($p_handle)
Compute all the formula.
filter_date()
compute the where clause for filtering with the date
file_open_form()
open the file of the form
static fetch_array($ret, $p_indice=0, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_array
static num_row($ret)
wrapper for the function pg_num_rows
static id()
return the 'gDossier' value after a check
Html Input : Input a date format dd.mm.yyyy The property title should be set to indicate what it is e...
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
static parse_formula($p_cn, $p_label, $p_formula, $p_start, $p_end, $p_eval=true, $p_type_date=0, $p_sql="")
For the periode tables parm_periode and jrn_periode.
if( $delta< 0) elseif( $delta==0)