Merged revisions 4067-4068 via svnmerge from
svn+ssh://danydb@svn/svn/phpcompta/branches/rel550 ........ r4067 | danydb | 2011-04-12 21:36:10 +0200 (Tue, 12 Apr 2011) | 2 lines 0000249: Balance : uniquement les comptes non soldés ........ r4068 | danydb | 2011-04-12 21:53:20 +0200 (Tue, 12 Apr 2011) | 2 lines 0000249: Balance : uniquement les comptes non soldés ........
This commit is contained in:
parent
382424d04b
commit
66f22175dd
8 changed files with 272 additions and 14 deletions
|
|
@ -93,7 +93,7 @@ switch( $_GET['act'])
|
|||
break;
|
||||
case 'PDF/fiche_balance':
|
||||
$user->can_request(IMPFIC,0);
|
||||
require_once('export_fiche_balance_csv.php');
|
||||
require_once('export_fiche_balance_pdf.php');
|
||||
exit();
|
||||
break;
|
||||
case 'CSV/report':
|
||||
|
|
|
|||
|
|
@ -126,11 +126,12 @@ if (HtmlInput::default_value('lvl3',false,$_GET) !== false)
|
|||
echo '<li>'.$ck_lev1->input().'Niveau 1</li>';
|
||||
echo '<li>'.$ck_lev2->input().'Niveau 2</li>';
|
||||
echo '<li>'.$ck_lev3->input().'Niveau 3</li>';
|
||||
|
||||
|
||||
|
||||
echo '</ul>';
|
||||
|
||||
$unsold=new ICheckBox('unsold');
|
||||
if (HtmlInput::default_value('unsold',false,$_GET) !== false)
|
||||
$unsold->selected=true;
|
||||
|
||||
|
||||
$from_poste=new IPoste();
|
||||
$from_poste->name="from_poste";
|
||||
|
|
@ -156,7 +157,9 @@ echo $from_span->input();
|
|||
echo " jusque :".$to_poste->input();
|
||||
echo $to_span->input();
|
||||
echo "</div>";
|
||||
|
||||
echo '<div>';
|
||||
echo "Uniquement comptes non soldés ".$unsold->input();
|
||||
echo '</div>';
|
||||
echo HtmlInput::submit("view","Visualisation");
|
||||
echo '</form>';
|
||||
echo '<hr>';
|
||||
|
|
@ -189,7 +192,7 @@ if ( isset ($_GET['view'] ) )
|
|||
|
||||
echo HtmlInput::hidden("from_poste",$_GET['from_poste']).
|
||||
HtmlInput::hidden("to_poste",$_GET['to_poste']);
|
||||
echo HtmlInput::get_to_hidden(array('lvl1','lvl2','lvl3'));
|
||||
echo HtmlInput::get_to_hidden(array('lvl1','lvl2','lvl3','unsold'));
|
||||
|
||||
echo "</form></TD>";
|
||||
|
||||
|
|
@ -210,6 +213,7 @@ if ( isset ($_GET['view'] ) )
|
|||
|
||||
echo HtmlInput::hidden("from_poste",$_GET['from_poste']).
|
||||
HtmlInput::hidden("to_poste",$_GET['to_poste']);
|
||||
echo HtmlInput::get_to_hidden(array('unsold'));
|
||||
|
||||
echo "</form></TD>";
|
||||
|
||||
|
|
@ -241,7 +245,8 @@ if ( isset($_GET['view'] ) )
|
|||
}
|
||||
$bal->from_poste=$_GET['from_poste'];
|
||||
$bal->to_poste=$_GET['to_poste'];
|
||||
|
||||
if ( isset($_GET['unsold']))
|
||||
$bal->unsold=true;
|
||||
$row=$bal->get_row($_GET['from_periode'],
|
||||
$_GET['to_periode']);
|
||||
$periode=new Periode($cn);
|
||||
|
|
|
|||
|
|
@ -33,12 +33,14 @@ class Acc_Balance
|
|||
var $jrn; /*!< idx of a table of ledger create by user->get_ledger */
|
||||
var $from_poste; /*!< from_poste filter on the post */
|
||||
var $to_poste; /*!< to_poste filter on the post*/
|
||||
var $unsold; /*!< if true only the no solded account (saldo != 0) */
|
||||
function Acc_Balance($p_cn)
|
||||
{
|
||||
$this->db=$p_cn;
|
||||
$this->jrn=null;
|
||||
$from_poste="";
|
||||
$to_poste="";
|
||||
$unsold=false;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -135,6 +137,7 @@ class Acc_Balance
|
|||
$a['sum_cred']=round($r['sum_cred'],2);
|
||||
$a['solde_deb']=round(( $a['sum_deb'] >= $a['sum_cred'] )? $a['sum_deb']- $a['sum_cred']:0,2);
|
||||
$a['solde_cred']=round(( $a['sum_deb'] <= $a['sum_cred'] )?$a['sum_cred']-$a['sum_deb']:0,2);
|
||||
if ($this->unsold==true && $a['solde_cred']==0 && $a['solde_deb']==0) continue;
|
||||
$array[$i]=$a;
|
||||
$tot_cred+= $a['sum_cred'];
|
||||
$tot_deb+= $a['sum_deb'];
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ case 2:
|
|||
|
||||
$bal->from_poste=$_GET['from_poste'];
|
||||
$bal->to_poste=$_GET['to_poste'];
|
||||
if (isset($_GET['unsold'])) $bal->unsold=true;
|
||||
|
||||
$row=$bal->get_row($_GET['from_periode'],
|
||||
$_GET['to_periode']);
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ $gDossier=dossier::id();
|
|||
|
||||
$cn=new Database($gDossier);
|
||||
$rep=new Database();
|
||||
include ('class_user.php');
|
||||
require_once ('class_user.php');
|
||||
$User=new User($cn);
|
||||
$User->Check();
|
||||
|
||||
|
|
@ -74,6 +74,7 @@ case 2:
|
|||
|
||||
$bal->from_poste=$_GET['from_poste'];
|
||||
$bal->to_poste=$_GET['to_poste'];
|
||||
if (isset($_GET['unsold'])) $bal->unsold=true;
|
||||
|
||||
$array=$bal->get_row($from_periode,$to_periode);
|
||||
|
||||
|
|
@ -126,8 +127,9 @@ for ($i=0;$i<count($array);$i++)
|
|||
|
||||
foreach (array(3,2,1) as $ind)
|
||||
{
|
||||
if ( ! isset($_GET['lvl'.$ind]))continue;
|
||||
$r=$array[$i];
|
||||
if ( ! isset($_GET['lvl'.$ind]))continue;
|
||||
|
||||
if (${'lvl'.$ind.'_old'} == '') ${'lvl'.$ind.'_old'}=substr($r['poste'],0,$ind);
|
||||
if ( ${'lvl'.$ind.'_old'} != substr($r['poste'],0,$ind))
|
||||
{
|
||||
|
|
@ -145,7 +147,6 @@ for ($i=0;$i<count($array);$i++)
|
|||
{
|
||||
${'nlvl'.$ind}[$a]=0;
|
||||
}
|
||||
// xdebug_print_function_stack();exit();
|
||||
}
|
||||
}
|
||||
foreach(array('sum_cred','sum_deb','solde_deb','solde_cred') as $a)
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ require_once('class_dossier.php');
|
|||
require_once('ac_common.php');
|
||||
|
||||
/* balance */
|
||||
if ( $_GET['histo'] == 4 )
|
||||
if ( $_GET['histo'] == 4 || $_GET['histo'] == 5)
|
||||
{
|
||||
$fd=new Fiche_Def($cn,$_REQUEST['cat']);
|
||||
if ( $fd->hasAttribute(ATTR_DEF_ACCOUNT) == false )
|
||||
|
|
@ -60,6 +60,11 @@ if ( $_GET['histo'] == 4 )
|
|||
$oCard=new Fiche($cn,$aCard[$i]['f_id']);
|
||||
$solde=$oCard->get_solde_detail($filter);
|
||||
if ( $solde['debit'] == 0 && $solde['credit']==0) continue;
|
||||
/* only not purged card */
|
||||
if ($_GET['histo'] == 5 && $solde['solde'] ==0) continue;
|
||||
$side='';
|
||||
if(bcsub($solde['credit'],$solde['debit']) < 0) $side='Deb.';
|
||||
if(bcsub($solde['credit'],$solde['debit']) > 0) $side='Cred.';
|
||||
|
||||
printf('"%s";"%s";%s;%s;%s;"%s"',
|
||||
$oCard->strAttribut(ATTR_DEF_QUICKCODE),
|
||||
|
|
@ -67,7 +72,7 @@ if ( $_GET['histo'] == 4 )
|
|||
nb($solde['debit']),
|
||||
nb($solde['credit']),
|
||||
nb(abs($solde['solde'])),
|
||||
(($solde['solde']<0)?'CRED':'DEB'));
|
||||
$side);
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
240
include/export_fiche_balance_pdf.php
Normal file
240
include/export_fiche_balance_pdf.php
Normal file
|
|
@ -0,0 +1,240 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of PhpCompta.
|
||||
*
|
||||
* PhpCompta is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PhpCompta is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with PhpCompta; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/* $Revision$ */
|
||||
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
|
||||
/*!\file
|
||||
* \brief Called by impress->category, export in PDF the history of a category
|
||||
* of card
|
||||
*/
|
||||
|
||||
// Security we check if user does exist and his privilege
|
||||
require_once('class_user.php');
|
||||
require_once('class_database.php');
|
||||
require_once('class_pdf.php');
|
||||
require_once('class_lettering.php');
|
||||
require_once('class_dossier.php');
|
||||
require_once('ac_common.php');
|
||||
|
||||
/* Security */
|
||||
$gDossier=dossier::id();
|
||||
$cn=new Database($gDossier);
|
||||
$User=new User($cn);
|
||||
$User->Check();
|
||||
$User->check_dossier($gDossier);
|
||||
$User->can_request(IMPFIC,0);
|
||||
|
||||
$pdf=new PDF($cn);
|
||||
$pdf->setDossierInfo(" Periode : ".$_GET['start']." - ".$_GET['end']);
|
||||
$pdf->AliasNbPages();
|
||||
$pdf->AddPage();
|
||||
$name=$cn->get_value('select fd_label from fiche_def where fd_id=$1',array($_GET['cat']));
|
||||
$pdf->SetFont('DejaVu','BI',14);
|
||||
$pdf->Cell(0,8,$name,0,1,'C');
|
||||
$pdf->SetTitle($name,1);
|
||||
$pdf->SetAuthor('Phpcompta');
|
||||
/* balance */
|
||||
if ( $_GET['histo'] == 4 || $_GET['histo']==5)
|
||||
{
|
||||
$fd=new Fiche_Def($cn,$_REQUEST['cat']);
|
||||
if ( $fd->hasAttribute(ATTR_DEF_ACCOUNT) == false )
|
||||
{
|
||||
$pdf->Cell(0,10, "Cette catégorie n'ayant pas de poste comptable n'a pas de balance");
|
||||
//Save PDF to file
|
||||
$fDate=date('dmy-Hi');
|
||||
$pdf->Output("category-$fDate.pdf", 'I');
|
||||
exit;
|
||||
}
|
||||
$aCard=$cn->get_array("select f_id,ad_value from fiche join fiche_Detail using (f_id) where ad_id=1 and fd_id=$1 order by 2 ",array($_REQUEST['cat']));
|
||||
|
||||
if ( empty($aCard))
|
||||
{
|
||||
$pdf->Cell(0,10, "Aucune fiche trouvée");//Save PDF to file
|
||||
$fDate=date('dmy-Hi');
|
||||
$pdf->Output("category-$fDate.pdf", 'I');
|
||||
exit;
|
||||
}
|
||||
$pdf->SetFont('DejaVuCond','',7);
|
||||
$pdf->Cell(30,7,'Quick Code',0,0,'L',0);
|
||||
$pdf->Cell(80,7,'Libellé',0,0,'L',0);
|
||||
$pdf->Cell(20,7,'Débit',0,0,'R',0);
|
||||
$pdf->Cell(20,7,'Crédit',0,0,'R',0);
|
||||
$pdf->Cell(20,7,'Solde',0,0,'R',0);
|
||||
$pdf->Cell(20,7,'D/C',0,0,'C',0);
|
||||
$pdf->Ln();
|
||||
$idx=0;
|
||||
for ($i=0;$i < count($aCard);$i++)
|
||||
{
|
||||
if ( isDate($_REQUEST['start']) == null || isDate ($_REQUEST['end']) == null ) exit;
|
||||
$filter= " (j_date >= to_date('".$_REQUEST['start']."','DD.MM.YYYY') ".
|
||||
" and j_date <= to_date('".$_REQUEST['end']."','DD.MM.YYYY')) ";
|
||||
$oCard=new Fiche($cn,$aCard[$i]['f_id']);
|
||||
$solde=$oCard->get_solde_detail($filter);
|
||||
if ( $solde['debit'] == 0 && $solde['credit']==0) continue;
|
||||
/* only not purged card */
|
||||
if ($_GET['histo'] == 5 && $solde['debit'] == $solde['credit']) continue;
|
||||
|
||||
if ( $idx % 2 == 0 )
|
||||
{
|
||||
$pdf->SetFillColor(220,221,255);
|
||||
$fill=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$pdf->SetFillColor(0,0,0);
|
||||
$fill=0;
|
||||
}
|
||||
$idx++;
|
||||
$side='';
|
||||
if(bcsub($solde['credit'],$solde['debit']) < 0) $side='Deb.';
|
||||
if(bcsub($solde['credit'],$solde['debit']) > 0) $side='Cred.';
|
||||
|
||||
$pdf->Cell(30,7,$oCard->strAttribut(ATTR_DEF_QUICKCODE),0,0,'L',$fill);
|
||||
$pdf->Cell(80,7,$oCard->strAttribut(ATTR_DEF_NAME),0,0,'L',$fill);
|
||||
$pdf->Cell(20,7,sprintf('%.02f',$solde['debit']),0,0,'R',$fill);
|
||||
$pdf->Cell(20,7,sprintf('%.02f',$solde['credit']),0,0,'R',$fill);
|
||||
$pdf->Cell(20,7,sprintf('%.02f',abs($solde['solde'])),0,0,'R',$fill);
|
||||
$pdf->Cell(20,7,$side,0,0,'C',$fill);
|
||||
$pdf->Ln();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$array=Fiche::get_fiche_def($cn,$_GET['cat'],'name_asc');
|
||||
/*
|
||||
* You show now the result
|
||||
*/
|
||||
if ($array == null )
|
||||
{
|
||||
exit();
|
||||
}
|
||||
$tab=array(13,25,55,20,20,12,20);
|
||||
$align=array('L','L','L','R','R','R','R');
|
||||
|
||||
foreach($array as $row_fiche)
|
||||
{
|
||||
$row=new Fiche($cn,$row_fiche['f_id']);
|
||||
$letter=new Lettering_Card($cn);
|
||||
$letter->set_parameter('quick_code',$row->strAttribut(ATTR_DEF_QUICKCODE));
|
||||
$letter->set_parameter('start',$_GET['start']);
|
||||
$letter->set_parameter('end',$_GET['end']);
|
||||
// all
|
||||
if ( $_GET['histo'] == 0 )
|
||||
{
|
||||
$letter->get_all();
|
||||
}
|
||||
|
||||
// lettered
|
||||
if ( $_GET['histo'] == 1 )
|
||||
{
|
||||
$letter->get_letter();
|
||||
}
|
||||
// unlettered
|
||||
if ( $_GET['histo'] == 2 )
|
||||
{
|
||||
$letter->get_unletter();
|
||||
}
|
||||
/* skip if nothing to display */
|
||||
if (count($letter->content) == 0 ) continue;
|
||||
$pdf->SetFont('DejaVuCond','',10);
|
||||
$fiche=new Fiche($cn,$row_fiche['f_id']);
|
||||
$pdf->Cell(0,7,$fiche->strAttribut(ATTR_DEF_NAME),1,1,'C');
|
||||
|
||||
$pdf->SetFont('DejaVuCond','',7);
|
||||
|
||||
$pdf->Cell($tab[0],7,'Date');
|
||||
$pdf->Cell($tab[1],7,'ref');
|
||||
$pdf->Cell($tab[1],7,'Int.');
|
||||
$pdf->Cell($tab[2],7,'Comm');
|
||||
$pdf->Cell(40,7,'Montant',0,0,'C');
|
||||
$pdf->Cell($tab[5],7,'Let.',0,0,'R');
|
||||
$pdf->Cell($tab[6],7,'Som. Let.',0,0,'R');
|
||||
$pdf->ln();
|
||||
|
||||
$amount_deb=0;
|
||||
$amount_cred=0;
|
||||
for ($i=0;$i<count($letter->content);$i++)
|
||||
{
|
||||
if ( $i % 2 == 0 )
|
||||
{
|
||||
$pdf->SetFillColor(220,221,255);
|
||||
$fill=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$pdf->SetFillColor(0,0,0);
|
||||
$fill=0;
|
||||
}
|
||||
$pdf->SetFont('DejaVuCond','',7);
|
||||
$row=$letter->content[$i];
|
||||
$str_date=shrink_date($row['j_date_fmt']);
|
||||
|
||||
$pdf->Cell($tab[0],4,$str_date,0,0,$align[0],$fill);
|
||||
$pdf->Cell($tab[1],4,$row['jr_pj_number'],0,0,$align[1],$fill);
|
||||
$pdf->Cell($tab[1],4,$row['jr_internal'],0,0,$align[1],$fill);
|
||||
$pdf->Cell($tab[2],4,$row['jr_comment'],0,0,$align[2],$fill);
|
||||
if ( $row['j_debit'] == 't')
|
||||
{
|
||||
$pdf->Cell($tab[3],4,sprintf('%10.2f',$row['j_montant']),0,0,$align[4],$fill);
|
||||
$amount_deb+=$row['j_montant'];
|
||||
$pdf->Cell($tab[4],4,"",0,0,'C',$fill);
|
||||
}
|
||||
else
|
||||
{
|
||||
$pdf->Cell($tab[3],4,"",0,0,'C',$fill);
|
||||
$pdf->Cell($tab[4],4,sprintf('%10.2f',$row['j_montant']),0,0,$align[4],$fill);
|
||||
$amount_cred+=$row['j_montant'];
|
||||
}
|
||||
if ($row['letter'] != -1 )
|
||||
{
|
||||
$pdf->Cell($tab[5],4,$row['letter'],0,0,$align[5],$fill);
|
||||
// get sum for this lettering
|
||||
$sql="select sum(j_montant) from jrnx where j_debit=$1 and j_id in ".
|
||||
" (select j_id from jnt_letter join letter_deb using (jl_id) where jl_id=$2 union ".
|
||||
" select j_id from jnt_letter join letter_cred using (jl_id) where jl_id=$3)";
|
||||
$sum=$cn->get_value($sql,array($row['j_debit'],$row['letter'],$row['letter']));
|
||||
$pdf->Cell($tab[6],4,sprintf('%.2f',$sum),'0','0','R',$fill);
|
||||
}
|
||||
else
|
||||
$pdf->Cell($tab[5],4,"",0,0,'R',$fill);
|
||||
$pdf->Ln();
|
||||
}
|
||||
$pdf->SetFillColor(0,0,0);
|
||||
$pdf->SetFont('DejaVuCond','B',8);
|
||||
$debit =sprintf('Debit : % 12.2f',$amount_deb);
|
||||
$credit=sprintf('Credit : % 12.2f',$amount_cred);
|
||||
if ( $amount_deb>$amount_cred) $s='solde débiteur';
|
||||
else $s='solde crediteur';
|
||||
$solde =sprintf('%s : % 12.2f',$s,(abs(round($amount_cred-$amount_deb,2))));
|
||||
|
||||
$pdf->Cell(0,6,$debit,0,0,'R');
|
||||
$pdf->ln(4);
|
||||
$pdf->Cell(0,6,$credit,0,0,'R');
|
||||
$pdf->ln(4);
|
||||
$pdf->Cell(0,6,$solde,0,0,'R');
|
||||
$pdf->ln(4);
|
||||
|
||||
$pdf->Ln();
|
||||
}
|
||||
}
|
||||
//Save PDF to file
|
||||
$fDate=date('dmy-Hi');
|
||||
$pdf->Output("category-$fDate.pdf", 'I');
|
||||
exit;
|
||||
|
|
@ -58,6 +58,7 @@ $histo->value=array(
|
|||
array('value'=>2,'label'=>_('Historique non Lettré')),
|
||||
array('value'=>3,'label'=>_('Résumé')),
|
||||
array('value'=>4,'label'=>_('Balance')),
|
||||
array('value'=>5,'label'=>_('Balance non soldée' ))
|
||||
);
|
||||
$histo->javascript='onchange="if (this.value==3) {
|
||||
g("trstart").style.display="none";g("trend").style.display="none";}
|
||||
|
|
@ -113,7 +114,7 @@ if ( $_GET['histo'] == 3 )
|
|||
}
|
||||
$export_pdf='<FORM METHOD="get" ACTION="export.php" style="display:inline">';
|
||||
$export_pdf.=HtmlInput::hidden('cat',$_GET['cat']);
|
||||
$export_pdf.=HtmlInput::hidden('act',"PDF/fiche").
|
||||
$export_pdf.=HtmlInput::hidden('act',"PDF/fiche_balance").
|
||||
$export_pdf.=HtmlInput::hidden('start',$_GET['start']);
|
||||
$export_pdf.=HtmlInput::hidden('end',$_GET['end']);
|
||||
$export_pdf.=HtmlInput::hidden('histo',$_GET['histo']);
|
||||
|
|
@ -133,7 +134,7 @@ $export_csv.='</FORM>';
|
|||
|
||||
echo $export_pdf;
|
||||
// Balance
|
||||
if ( $_GET['histo'] == 4 )
|
||||
if ( $_GET['histo'] == 4 || $_GET['histo']==5 )
|
||||
{
|
||||
if ( isDate($_REQUEST['start']) == null || isDate ($_REQUEST['end']) == null )
|
||||
{
|
||||
|
|
@ -170,6 +171,8 @@ if ( $_GET['histo'] == 4 )
|
|||
$oCard=new Fiche($cn,$aCard[$i]['f_id']);
|
||||
$solde=$oCard->get_solde_detail($filter);
|
||||
if ( $solde['debit'] == 0 && $solde['credit']==0) continue;
|
||||
/* only not purged card */
|
||||
if ($_GET['histo'] == 5 && $solde['debit'] == $solde['credit']) continue;
|
||||
$class='';
|
||||
if ( $idx%2 == 0) $class='class="odd"';
|
||||
$idx++;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue