fs#135 number in cvs are formatted thanks the function ac_common::nb, it wil help
the users who are using excel
This commit is contained in:
parent
434a73df2d
commit
9c8f8b483f
5 changed files with 39 additions and 32 deletions
|
|
@ -69,16 +69,15 @@ $bal->to_poste=$_GET['to_poste'];
|
|||
|
||||
$row=$bal->get_row($_GET['from_periode'],
|
||||
$_GET['to_periode']);
|
||||
foreach ($row as $r) {
|
||||
|
||||
echo $r['poste'].';'.
|
||||
$r['label'].';'.
|
||||
$r['sum_deb'].';'.
|
||||
$r['sum_cred'].';'.
|
||||
$r['solde_deb'].';'.
|
||||
$r['solde_cred'];
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
foreach ($row as $r) {
|
||||
echo $r['poste'].';'.
|
||||
$r['label'].';'.
|
||||
nb($r['sum_deb']).';'.
|
||||
nb($r['sum_cred']).';'.
|
||||
nb($r['solde_deb']).';'.
|
||||
nb($r['solde_cred']);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ if ( $_GET['p_step'] == 0 )
|
|||
|
||||
foreach ( $Form->row as $op ) {
|
||||
echo '"'.$op['desc'].'"'.";".
|
||||
sprintf("%8.2f",$op['montant']).
|
||||
nb($op['montant']).
|
||||
"\n";
|
||||
|
||||
}
|
||||
|
|
@ -97,7 +97,7 @@ if ( $_GET['p_step'] == 0 )
|
|||
$a++;
|
||||
foreach ($e as $elt)
|
||||
{
|
||||
printf(";%s",$elt['montant']);
|
||||
printf(";%s",nb($elt['montant']));
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,14 +69,14 @@ if ( $_GET['p_simple'] == 0 )
|
|||
$desc=str_replace('"',"'",$desc);
|
||||
$desc=str_replace(";",",",$desc);
|
||||
|
||||
printf("\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";%8.4f;%8.4f\n",
|
||||
printf("\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";%s;%s\n",
|
||||
$op['j_id'],
|
||||
$op['internal'],
|
||||
$op['j_date'],
|
||||
$op['poste'],
|
||||
$desc,
|
||||
$op['deb_montant'],
|
||||
$op['cred_montant']
|
||||
nb($op['deb_montant']),
|
||||
nb($op['cred_montant'])
|
||||
);
|
||||
|
||||
}
|
||||
|
|
@ -118,17 +118,15 @@ if ( $_GET['p_simple'] == 0 )
|
|||
// the credit must be negative and written in red
|
||||
// Get the jrn type
|
||||
if ( $line['jrn_def_type'] == 'FIN' ) {
|
||||
$positive = $cn->count_sql("select * from jrn inner join jrnx on jr_grpt_id=j_grpt ".
|
||||
" where jr_id=".$line['jr_id']." and $sql_fin ".
|
||||
" and j_debit='f'");
|
||||
$positive = $cn->get_value("select qf_amount from quant_fin ".
|
||||
" where jr_id=".$line['jr_id']);
|
||||
|
||||
|
||||
echo ( $positive != 0 )?sprintf("-%8.2f",$line['montant']):sprintf("%8.2f",$line['montant']);
|
||||
echo nb($positive);
|
||||
echo ";";
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("% 8.2f",$line['montant']).";";
|
||||
echo nb($line['montant']).";";
|
||||
}
|
||||
|
||||
printf("\r\n");
|
||||
|
|
@ -150,13 +148,13 @@ if ( $_GET['p_simple'] == 0 )
|
|||
echo '"Date";"operation";"Client/Fourn.";"Commentaire";"inter.";"HTVA";'.$col_tva.'"TVAC"'."\n\r";
|
||||
foreach ($Row as $line)
|
||||
{
|
||||
printf('"%s";"%s";"%s";"%s";"%s";% 10.2f;',
|
||||
printf('"%s";"%s";"%s";"%s";"%s";%s;',
|
||||
$line['date'],
|
||||
$line['num'],
|
||||
$line['client'],
|
||||
$line['comment'],
|
||||
$line['jr_internal'],
|
||||
$line['HTVA']);
|
||||
nb($line['HTVA']));
|
||||
$a_tva_amount=array();
|
||||
foreach ($line['TVA'] as $lineTVA)
|
||||
{
|
||||
|
|
@ -175,12 +173,12 @@ if ( $_GET['p_simple'] == 0 )
|
|||
{
|
||||
$a=$line_tva['tva_id'];
|
||||
if ( isset($a_tva_amount[$a]))
|
||||
printf("% 8.2f;",$a_tva_amount[$a]);
|
||||
echo nb($a_tva_amount[$a]);
|
||||
else
|
||||
printf("0;");
|
||||
}
|
||||
}
|
||||
printf("% 9.2f\r\n",$line['TVAC']);
|
||||
echo nb ($line['TVAC']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,8 +79,8 @@ if ( ! isset ($_REQUEST['oper_detail'])) {
|
|||
'"'.$op['jr_internal'].'"'.";".
|
||||
'"'.$op['j_date_fmt'].'"'.";".
|
||||
'"'.$op['description']." ".$op['jr_pj_number'].'"'.";".
|
||||
sprintf("%8.4f",$op['deb_montant']).";".
|
||||
sprintf("%8.4f",$op['cred_montant']);
|
||||
nb($op['deb_montant']).";".
|
||||
nb($op['cred_montant']);
|
||||
printf("\n");
|
||||
|
||||
|
||||
|
|
@ -89,9 +89,9 @@ if ( ! isset ($_REQUEST['oper_detail'])) {
|
|||
$diff=abs($tot_deb-$tot_cred);
|
||||
printf(
|
||||
'"'."$solde_type".'"'.";".
|
||||
sprintf("%8.4f",$diff).";".
|
||||
sprintf("%8.4f",$tot_deb).";".
|
||||
sprintf("%8.4f",$tot_cred)."\n");
|
||||
nb($diff).";".
|
||||
nb($tot_deb).";".
|
||||
nb($tot_cred)."\n");
|
||||
}
|
||||
} else {
|
||||
/* detail of all operation */
|
||||
|
|
@ -132,7 +132,7 @@ if ( ! isset ($_REQUEST['oper_detail'])) {
|
|||
$r['jr_date'],
|
||||
$a['description'],
|
||||
$a['jr_pj_number'],
|
||||
$r['j_montant'],
|
||||
nb($r['j_montant']),
|
||||
$r['debit']);
|
||||
printf("\r\n");
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,16 @@ function td($p_string='',$p_extra=''){ return '<td '.$p_extra.'>'.$p_string.'</
|
|||
function tr($p_string,$p_extra=''){ return '<tr '.$p_extra.'>'.$p_string.'</tr>';}
|
||||
/*!\brief escape correctly php string to javascript */
|
||||
function j($p_string) { $a=preg_replace("/\r?\n/", "\\n", addslashes($p_string)); return $a;}
|
||||
/**
|
||||
* format the number for the CSV export
|
||||
*@param $p_number number
|
||||
*/
|
||||
function nb($p_number) {
|
||||
$r=sprintf('%.2f',$p_number);
|
||||
$r=str_replace('.',',',$r);
|
||||
return $r;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief log error into the /tmp/phpcompta_error.log it doesn't work on windows
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue