task #4451 : Impression detaille et simple

This commit is contained in:
sparkyx 2005-07-27 14:42:51 +00:00
parent 471a7ae908
commit cf861005c1
5 changed files with 230 additions and 37 deletions

View file

@ -43,20 +43,24 @@ if ( $User->CheckAction($cn,IMP) == 0 ||
$Jrn=new jrn($cn,$_GET['jrn_id']);
$Jrn->GetName();
$Jrn->GetRow( $_GET['from_periode'],
$_GET['to_periode'],
$p_cent);
// Detailled printing
//---
if ( $_GET['p_simple'] == 0 )
{
$Jrn->GetRow( $_GET['from_periode'],
$_GET['to_periode'],
$p_cent);
if ( count($Jrn->row) == 0)
exit;
foreach ( $Jrn->row as $op ) {
if ( count($Jrn->row) == 0)
exit;
foreach ( $Jrn->row as $op ) {
// should clean description : remove <b><i> tag and '; char
$desc=$op['description'];
$desc=str_replace("<b>","",$desc);
$desc=str_replace("</b>","",$desc);
$desc=str_replace("<i>","",$desc);
$desc=str_replace("</i>","",$desc);
$desc=str_replace('"',"'",$desc);
$desc=$op['description'];
$desc=str_replace("<b>","",$desc);
$desc=str_replace("</b>","",$desc);
$desc=str_replace("<i>","",$desc);
$desc=str_replace("</i>","",$desc);
$desc=str_replace('"',"'",$desc);
printf("\"%s\"\t\"%s\"\t\"%s\"\t\"%s\"\t\"%s\"\t%8.4f\t%8.4f\n",
$op['j_id'],
@ -68,6 +72,48 @@ $Jrn->GetRow( $_GET['from_periode'],
$op['deb_montant']
);
}
exit;
}
exit;
else
{
$Row=$Jrn->GetRowSimple($_GET['from_periode'],
$_GET['to_periode'],
$p_cent);
////////////////////////////////////////////////////////////////////////////////
printf ('" operation "'.
'"Date"'.
'"commentaire"'.
'"internal"'.
'"montant"');
foreach ($Row as $line)
{
echo $line['num'].";";
echo $line['date'].";";
echo $line['comment'].";";
echo $line['jr_internal'].";";
// echo "<TD>".$line['pj'].";";
// If the ledger is financial :
// the credit must be negative and written in red
// Get the jrn type
if ( $line['jrn_def_type'] == 'FIN' ) {
$positive = CountSql($cn,"select * from jrn inner join jrnx on jr_grpt_id=j_grpt ".
" where jr_id=".$line['jr_id']." and (j_poste like '55%' or j_poste like '57%' )".
" and j_debit='f'");
echo ( $positive != 0 )?sprintf("-%8.2f",$line['montant']):sprintf("%8.2f",$line['montant']);
echo ";";
}
else
{
printf("% 8.2f",$line['montant']).";";
}
printf("\r\n");
}
////////////////////////////////////////////////////////////////////////////////
}
?>

View file

@ -85,8 +85,6 @@ if ( isset ($_GET['JRN_TYPE'] ) ) {
ShowMenuJrnUser($_SESSION['g_dossier'],$_GET['JRN_TYPE'],$p_jrn);
echo "</DIV>";
if ( $jrn_type=='NONE' ) include('user_action_gl.php');
if ( $jrn_type=='SALDO_FIN') include ('user_action_fin.php');
} else {
echo_debug("Selected is ".$p_jrn);
@ -103,11 +101,6 @@ if ( isset ($_GET['JRN_TYPE'] ) ) {
echo '</div>';
}
if ( $jrn_type=='FIN' )
{
//show balance of all bank accounts. Let's say their ID start with 5500
//TODO
}
// if a journal is selected show the journal's menu
if ( $p_jrn != -1 ) {

View file

@ -68,6 +68,7 @@ $sql="insert into centralized( c_j_id,
if ($Res==false) { rollback($p_cn); EndSql($p_cn); return ERROR;}
// Set correctly the number of operation id (jr_opid) for each journal
// get the existing jrn_def_id
//--
$Res = ExecSql($p_cn,"select jrn_def_id from jrn_def");
$MaxJrn=pg_NumRows($Res);
// for each jrn_def_id

View file

@ -46,7 +46,7 @@ class jrn {
}
/* function GetRow
* Purpose : Get The data for the pdf printing
* Purpose : Get The data
*
* parm :
* - connection
@ -73,10 +73,10 @@ class jrn {
// Grand livre == 0
if ( $this->id != 0 ) {
if ( $cent=='off' ) {
echo_debug(__FILE__,__LINE__,"journaux non centralisé");
// Journaux non centralisés
$Res=ExecSql($this->db,"select j_id,j_id as int_j_id,to_char(j_date,'DD.MM.YYYY') as j_date,
if ( $cent=='off' ) {
echo_debug(__FILE__,__LINE__,"journaux non centralisé");
// Journaux non centralisés
$Res=ExecSql($this->db,"select j_id,j_id as int_j_id,to_char(j_date,'DD.MM.YYYY') as j_date,
jr_internal,
case j_debit when 't' then j_montant::text else ' ' end as deb_montant,
case j_debit when 'f' then j_montant::text else ' ' end as cred_montant,
@ -221,5 +221,92 @@ class jrn {
$a=array($array,$tot_deb,$tot_cred);
return $a;
}
/* function GetRowSimple
**************************************************
* Purpose : Get simplified row
*
* parm :
* - connection
* - array
* - p_limit starting line
* - p_offset number of lines
*
* gen :
* - none
* return:
* - Array with the asked data
*
*/
function GetRowSimple($p_from,$p_to,$cent='off',$p_limit=-1,$p_offset=-1)
{
echo_debug(__FILE__,__LINE__,"GetRowSimple ( $p_from,$p_to,$cent,$p_limit,$p_offset)");
// Periode check
//---
if ( $p_from == $p_to )
$periode=" jr_tech_per = $p_from ";
else
$periode = "(jr_tech_per >= $p_from and jr_tech_per <= $p_to) ";
$cond_limite=($p_limit!=-1)?" limit ".$p_limit." offset ".$p_offset:"";
// Grand-livre : id= 0
//---
$jrn=($this->id == 0 )?"":"and jrn_def_id = ".$this->id;
// Non Centralise si cent=off
//--
if ($cent=='off')
{// Non centralisé
//---
$sql="
SELECT jrn.jr_id as jr_id ,
jrn.jr_id as num ,
jrn.jr_def_id as jr_def_id,
jrn.jr_montant as montant,
jrn.jr_comment as comment,
to_char(jrn.jr_date,'DD-MM-YYYY') as date,
jr_internal,
jrn.jr_grpt_id as grpt_id,
jrn.jr_pj_name as pj,
jrn_def_type
FROM jrn join jrn_def on (jrn_def_id=jr_def_id)
where $periode $jrn order by jr_date";
}
else
{
//Centralisé
//---
$id=($this->id == 0 ) ?"jr_c_opid as num":"jr_opid as num";
$sql="
SELECT jrn.jr_id as jr_id ,
$id ,
jrn.jr_def_id as jr_def_id,
jrn.jr_montant as montant,
jrn.jr_comment as comment,
to_char(jrn.jr_date,'DD-MM-YYYY') as date,
jr_internal,
jrn.jr_grpt_id as grpt_id,
jrn.jr_pj_name as pj,
jrn_def_type
FROM jrn join jrn_def on (jrn_def_id=jr_def_id)
where
$periode $jrn and
jr_opid is not null
order by jr_date";
}// end else $cent=='off'
//load all data into an array
//---
$Res=ExecSql($this->db,$sql);
if ( pg_NumRows($Res) == 0 )
{
return null;
}
$array=pg_fetch_all($Res);
return $array;
}// end function GetRowSimple
}

View file

@ -32,10 +32,19 @@ include("class_jrn.php");
echo_debug(__FILE__,__LINE__,$d);
$Jrn=new jrn($cn,$_POST['jrn_id']);
$Jrn->GetName();
$Jrn->GetRow( $_POST['from_periode'],
$_POST['to_periode'],
$p_cent);
if ( $_POST['p_simple']==0 )
{
$Jrn->GetRow( $_POST['from_periode'],
$_POST['to_periode'],
$p_cent);
}
else
{
$Row=$Jrn->GetRowSimple($_POST['from_periode'],
$_POST['to_periode'],
$p_cent);
// var_dump($Row);
}
$rep="";
$submit=new widget();
$hid=new widget("hidden");
@ -54,6 +63,7 @@ include("class_jrn.php");
$hid->IOValue("jrn_id",$Jrn->id).
$hid->IOValue("from_periode",$_POST['from_periode']).
$hid->IOValue("to_periode",$_POST['to_periode']);
echo $hid->IOValue("p_simple",$_POST['p_simple']);
echo "</form></TD>";
echo '<TD><form method="GET" ACTION="jrn_csv.php">'.
@ -63,31 +73,82 @@ include("class_jrn.php");
$hid->IOValue("jrn_id",$Jrn->id).
$hid->IOValue("from_periode",$_POST['from_periode']).
$hid->IOValue("to_periode",$_POST['to_periode']);
echo $hid->IOValue("p_simple",$_POST['p_simple']);
echo "</form></TD>";
echo "</TR>";
echo "</table>";
if ( count($Jrn->row ) == 0 )
if ( count($Jrn->row ) == 0
&& $Row==null)
exit;
echo "<TABLE>";
foreach ( $Jrn->row as $op ) {
echo "<TABLE class=\"result\">";
if ( $_POST['p_simple'] == 0 ) {
// detailled printing
//---
foreach ( $Jrn->row as $op ) {
echo "<TR>";
// centralized
if ( $p_cent == 'on') {
echo "<TD>".$op['j_id']."</TD>";
}
echo "<TD>".$op['internal']."</TD>".
echo "<TD>".$op['internal']."</TD>".
"<TD>".$op['j_date']."</TD>".
"<TD>".$op['poste']."</TD>".
"<TD>".$op['description']."</TD>".
"<TD>".$op['deb_montant']."</TD>".
"<TD>".$op['cred_montant']."</TD>".
"</TR>";
}
}// end loop
} // if
else
{
include_once("jrn.php");
// Simple printing
//---
echo "<TR>".
"<th> operation </td>".
"<th>Date</th>".
"<th> commentaire </th>".
"<th>internal</th>".
/* "<th>Pièce justificative</th>". */
"<th> montant</th>".
"</TR>";
foreach ($Row as $line)
{
echo "<tr>";
echo "<TD>".$line['num']."</TD>";
echo "<TD>".$line['date']."</TD>";
echo "<TD>".$line['comment']."</TD>";
echo "<TD>".$line['jr_internal']."</TD>";
// echo "<TD>".$line['pj']."</TD>";
// If the ledger is financial :
// the credit must be negative and written in red
// Get the jrn type
if ( $line['jrn_def_type'] == 'FIN' ) {
$positive = CountSql($cn,"select * from jrn inner join jrnx on jr_grpt_id=j_grpt ".
" where jr_id=".$line['jr_id']." and (j_poste like '55%' or j_poste like '57%' )".
" and j_debit='f'");
echo "<TD align=\"right\">";
echo ( $positive != 0 )?"<font color=\"red\"> - ".sprintf("%8.2f",$line['montant'])."</font>":sprintf("%8.2f",$line['montant']);
echo "</TD>";
}
else
{
echo "<TD align=\"right\">".sprintf("% 8.2f",$line['montant'])."</TD>";
}
echo "</tr>";
}
} //else
echo "</table>";
echo "</div>";
exit;
}
@ -152,7 +213,12 @@ $centralise=new widget("checkbox");
$centralise->label="Depuis les journaux centralisés";
$centralise->table=1;
print $centralise->IOValue('cent');
$a=array(
array('value'=>0,'label'=>'Detaillé'),
array('value'=>1,'label'=>'Simple')
);
$w->selected=1;
echo $w->IOValue('p_simple',$a,'Style d\'impression');
print "</TR>";
echo '</TABLE>';
print $w->Submit('bt_html','Impression');