add PDF + CSV all card, balance + history
This commit is contained in:
parent
d1381a6cbf
commit
4d9eed5e5f
6 changed files with 486 additions and 286 deletions
|
|
@ -79,10 +79,10 @@ class Extension extends Menu_Ref_sql
|
|||
*/
|
||||
static function make_array($cn)
|
||||
{
|
||||
$sql="select me_code as value, me_menu as label from ".
|
||||
$sql="select DISTINCT me_code as value, me_menu as label from ".
|
||||
" menu_ref join profile_menu using (me_code)
|
||||
join profile_user using (p_id) where ".
|
||||
" user_name=$1 and me_type='PL' and me_code_dep='EXTENSION'";
|
||||
" user_name=$1 and me_type='PL' ORDER BY ME_MENU";
|
||||
$a=$cn->get_array($sql,array($_SESSION['g_user']));
|
||||
return $a;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,47 +33,158 @@ require_once('class_user.php');
|
|||
require_once('class_database.php');
|
||||
require_once('class_dossier.php');
|
||||
require_once('ac_common.php');
|
||||
$allcard=(isset($_GET['allcard']))?1:0;
|
||||
|
||||
/* balance */
|
||||
if ( $_GET['histo'] == 4 || $_GET['histo'] == 5)
|
||||
{
|
||||
$fd=new Fiche_Def($cn,$_REQUEST['cat']);
|
||||
if ( $fd->hasAttribute(ATTR_DEF_ACCOUNT) == false )
|
||||
if ( $allcard==1 && $fd->hasAttribute(ATTR_DEF_ACCOUNT) == false )
|
||||
{
|
||||
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']));
|
||||
// all card
|
||||
if ($allcard==1)
|
||||
{
|
||||
$afiche=$cn->get_array("select fd_id from vw_fiche_def where ad_id=".ATTR_DEF_ACCOUNT." order by fd_label asc");
|
||||
}
|
||||
else
|
||||
{
|
||||
$afiche[0]=array('fd_id'=>$_REQUEST['cat']);
|
||||
}
|
||||
printf('"Quick code";"Nom";"debit";"credit";"solde";"D/C";');
|
||||
printf("\n");
|
||||
for ($e = 0; $e < count($afiche); $e++)
|
||||
{
|
||||
$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($afiche[$e]['fd_id']));
|
||||
|
||||
if ( empty($aCard))
|
||||
{
|
||||
echo "Aucune fiche trouvée";//Save PDF to file
|
||||
$fDate=date('dmy-Hi');
|
||||
exit;
|
||||
}
|
||||
printf ('"Quick code";"Nom";"debit";"credit";"solde";"D/C";');
|
||||
printf ("\n");
|
||||
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['solde'] ==0) continue;
|
||||
$side='';
|
||||
if(bcsub($solde['credit'],$solde['debit']) < 0) $side='Deb.';
|
||||
if(bcsub($solde['credit'],$solde['debit']) > 0) $side='Cred.';
|
||||
if (empty($aCard))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
printf('"%s";"%s";%s;%s;%s;"%s"',
|
||||
$oCard->strAttribut(ATTR_DEF_QUICKCODE),
|
||||
$oCard->strAttribut(ATTR_DEF_NAME),
|
||||
nb($solde['debit']),
|
||||
nb($solde['credit']),
|
||||
nb(abs($solde['solde'])),
|
||||
$side);
|
||||
printf("\n");
|
||||
}
|
||||
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['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), $oCard->strAttribut(ATTR_DEF_NAME), nb($solde['debit']), nb($solde['credit']), nb(abs($solde['solde'])), $side);
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// all card
|
||||
if ($allcard == 1)
|
||||
{
|
||||
$afiche = $cn->get_array("select fd_id from vw_fiche_def where ad_id=" . ATTR_DEF_ACCOUNT . " order by fd_label asc");
|
||||
}
|
||||
else
|
||||
{
|
||||
$afiche[0] = array('fd_id' => $_REQUEST['cat']);
|
||||
}
|
||||
for ($e = 0; $e < count($afiche); $e++)
|
||||
{
|
||||
$array = Fiche::get_fiche_def($cn, $afiche[$e]['fd_id'], 'name_asc');
|
||||
|
||||
foreach ($array as $card)
|
||||
{
|
||||
$row = new Fiche($cn, $card['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;
|
||||
printf('"%s"'."\n",$row->strAttribut(ATTR_DEF_QUICKCODE), $row->strAttribut(ATTR_DEF_NAME));
|
||||
|
||||
printf('"%s";"%s";"%s";"%s";"%s";"%s";"%s"',
|
||||
_('Date'),
|
||||
_('ref'),
|
||||
_('Interne'),
|
||||
_('Comm'),
|
||||
_('Débit'),
|
||||
_('Crébit'),
|
||||
_('Prog.'),
|
||||
_('Let.'));
|
||||
printf("\n");
|
||||
$amount_deb = 0;
|
||||
$amount_cred = 0;
|
||||
$prog = 0;
|
||||
bcscale(2);
|
||||
for ($i = 0; $i < count($letter->content); $i++)
|
||||
{
|
||||
$row = $letter->content[$i];
|
||||
printf ('"%s";',$row['j_date_fmt']);
|
||||
printf ('"%s";',$row['jr_pj_number']);
|
||||
printf ('"%s";',$row['jr_internal']);
|
||||
printf ('"%s";',$row['jr_comment']);
|
||||
if ($row['j_debit'] == 't')
|
||||
{
|
||||
printf("%s;",nb($row['j_montant']));
|
||||
$amount_deb+=$row['j_montant'];
|
||||
$prog = bcadd($prog, $row['j_montant']);
|
||||
printf (";");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf(";");
|
||||
printf("%s;",nb($row['j_montant']));
|
||||
$amount_cred+=$row['j_montant'];
|
||||
$prog = bcsub($prog, $row['j_montant']);
|
||||
}
|
||||
printf ("%s;",nb($prog));
|
||||
if ($row['letter'] != -1)
|
||||
printf('"%s";',$row['letter']);
|
||||
else
|
||||
printf(";");
|
||||
printf("\n");
|
||||
}
|
||||
if ($prog < 0 )
|
||||
$msg="Solde Debit";
|
||||
elseif ($prog>0)
|
||||
$msg="Solde Credit";
|
||||
else
|
||||
$msg="soldé";
|
||||
|
||||
printf(';;;"%s";%s;%s;%s',
|
||||
$msg,nb($amount_deb),nb($amount_cred),nb($prog));
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
exit;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
|
||||
/*!\file
|
||||
* \brief Called by impress->category, export in PDF the history of a category
|
||||
* \brief Called by impress->category, export in PDF the history of a category or balance
|
||||
* of card
|
||||
*/
|
||||
|
||||
|
|
@ -50,10 +50,11 @@ $pdf->Cell(0,8,$name,0,1,'C');
|
|||
$pdf->SetTitle($name,1);
|
||||
$pdf->SetAuthor('Phpcompta');
|
||||
/* balance */
|
||||
$allcard=(isset($_GET['allcard']))?1:0;
|
||||
if ( $_GET['histo'] == 4 || $_GET['histo']==5)
|
||||
{
|
||||
$fd=new Fiche_Def($cn,$_REQUEST['cat']);
|
||||
if ( $fd->hasAttribute(ATTR_DEF_ACCOUNT) == false )
|
||||
if ($allcard==1 && $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
|
||||
|
|
@ -61,16 +62,24 @@ if ( $_GET['histo'] == 4 || $_GET['histo']==5)
|
|||
$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']));
|
||||
// all card
|
||||
if ($allcard==1)
|
||||
{
|
||||
$afiche=$cn->get_array("select fd_id from vw_fiche_def where ad_id=".ATTR_DEF_ACCOUNT." order by fd_label asc");
|
||||
}
|
||||
else
|
||||
{
|
||||
$afiche[0]=array('fd_id'=>$_REQUEST['cat']);
|
||||
}
|
||||
|
||||
if ( empty($aCard))
|
||||
if ( $allcard==0 && 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->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);
|
||||
|
|
@ -78,6 +87,14 @@ if ( $_GET['histo'] == 4 || $_GET['histo']==5)
|
|||
$pdf->Cell(20,7,'Solde',0,0,'R',0);
|
||||
$pdf->Cell(20,7,'D/C',0,0,'C',0);
|
||||
$pdf->Ln();
|
||||
for ($e = 0; $e < count($afiche); $e++)
|
||||
{
|
||||
$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($afiche[$e]['fd_id']));
|
||||
|
||||
|
||||
if (empty($aCard)) continue;
|
||||
|
||||
|
||||
$idx=0;
|
||||
for ($i=0;$i < count($aCard);$i++)
|
||||
{
|
||||
|
|
@ -113,125 +130,142 @@ if ( $_GET['histo'] == 4 || $_GET['histo']==5)
|
|||
$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');
|
||||
// all card
|
||||
if ($allcard == 1)
|
||||
{
|
||||
$afiche = $cn->get_array("select fd_id from vw_fiche_def where ad_id=" . ATTR_DEF_ACCOUNT . " order by fd_label asc");
|
||||
}
|
||||
else
|
||||
{
|
||||
$afiche[0] = array('fd_id' => $_REQUEST['cat']);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
for ($e = 0; $e < count($afiche); $e++)
|
||||
{
|
||||
$array = Fiche::get_fiche_def($cn,$afiche[$e]['fd_id'] , 'name_asc');
|
||||
/*
|
||||
* You show now the result
|
||||
*/
|
||||
if ($array == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$tab = array(13, 25, 55, 20, 20, 12, 20);
|
||||
$align = array('L', 'L', 'L', 'R', 'R', 'R', 'R');
|
||||
|
||||
// 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');
|
||||
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();
|
||||
}
|
||||
|
||||
$pdf->SetFont('DejaVuCond','',7);
|
||||
// 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->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();
|
||||
$pdf->SetFont('DejaVuCond', '', 7);
|
||||
|
||||
$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], 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();
|
||||
|
||||
$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))));
|
||||
$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(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->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->Ln();
|
||||
}
|
||||
$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');
|
||||
|
|
|
|||
|
|
@ -38,6 +38,9 @@ $categorie->value=$cn->make_array('select fd_id,fd_label from fiche_def order by
|
|||
$categorie->selected=(isset($_GET['cat']))?$_GET['cat']:0;
|
||||
$str_categorie=$categorie->input();
|
||||
|
||||
$icall=new ICheckBox("allcard",1);
|
||||
$icall->selected=(isset($_GET['allcard']))?1:0;
|
||||
$str_icall=$icall->input();
|
||||
/* periode */
|
||||
$exercice=$g_user->get_exercice();
|
||||
$iperiode=new Periode($cn);
|
||||
|
|
@ -63,8 +66,8 @@ $histo->value=array(
|
|||
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";}
|
||||
else {g("trstart").style.display="";g("trend").style.display=""}"';
|
||||
g("trstart").style.display="none";g("trend").style.display="none";g("allcard").style.display="none";}
|
||||
else {g("trstart").style.display="";g("trend").style.display="";g("allcard").style.display="";}"';
|
||||
|
||||
$histo->selected=(isset($_GET['histo']))?$_GET['histo']:3;
|
||||
$str_histo=$histo->input();
|
||||
|
|
@ -76,8 +79,8 @@ require_once('template/impress_cat_card.php');
|
|||
echo HtmlInput::submit('cat_display',_('Recherche'));
|
||||
echo '</FORM>';
|
||||
$str="if (g('histo').value==3) {
|
||||
g('trstart').style.display='none';g('trend').style.display='none';}
|
||||
else {g('trstart').style.display='';g('trend').style.display='';}";
|
||||
g('trstart').style.display='none';g('trend').style.display='none';g('allcard').style.display='none';}
|
||||
else {g('trstart').style.display='';g('trend').style.display='';g('allcard').style.display='';}";
|
||||
echo create_script($str);
|
||||
echo '<hr>';
|
||||
//-----------------------------------------------------
|
||||
|
|
@ -94,6 +97,8 @@ if ($array == null )
|
|||
echo '<h2 class="info2"> Aucune fiche trouvée</h2>';
|
||||
exit();
|
||||
}
|
||||
|
||||
$allcard=(isset($_GET['allcard']))?1:0;
|
||||
// summary
|
||||
if ( $_GET['histo'] == 3 )
|
||||
{
|
||||
|
|
@ -119,77 +124,96 @@ $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']);
|
||||
$export_pdf.=HtmlInput::request_to_hidden(array('allcard'));
|
||||
$export_pdf.=dossier::hidden();
|
||||
$export_pdf.=HtmlInput::submit('pdf','Export en PDF');
|
||||
$export_pdf.='</FORM>';
|
||||
$export_csv='<FORM METHOD="get" ACTION="export.php" style="display:inline">';
|
||||
|
||||
$export_csv='<FORM METHOD="get" ACTION="export.php" style="display:inline">';
|
||||
$export_csv.=HtmlInput::hidden('cat',$_GET['cat']);
|
||||
$export_csv.=HtmlInput::hidden('act','CSV:fiche_balance');
|
||||
$export_csv.=HtmlInput::hidden('start',$_GET['start']);
|
||||
$export_csv.=HtmlInput::hidden('end',$_GET['end']);
|
||||
$export_csv.=HtmlInput::hidden('histo',$_GET['histo']);
|
||||
$export_csv.=HtmlInput::request_to_hidden(array('allcard'));
|
||||
$export_csv.=dossier::hidden();
|
||||
$export_csv.=HtmlInput::submit('CSV','Export en CSV');
|
||||
$export_csv.='</FORM>';
|
||||
|
||||
echo $export_pdf;
|
||||
// Balance
|
||||
if ( $_GET['histo'] == 4 || $_GET['histo']==5 )
|
||||
{
|
||||
if ( isDate($_REQUEST['start']) == null || isDate ($_REQUEST['end']) == null )
|
||||
{
|
||||
echo h2('Date invalide !','class="error"');
|
||||
alert('Date invalide !');
|
||||
exit;
|
||||
}
|
||||
echo $export_pdf;
|
||||
echo $export_csv;
|
||||
|
||||
|
||||
$fd=new Fiche_Def($cn,$_REQUEST['cat']);
|
||||
if ( $fd->hasAttribute(ATTR_DEF_ACCOUNT) == false )
|
||||
if ( $allcard==1 && $fd->hasAttribute(ATTR_DEF_ACCOUNT) == false )
|
||||
{
|
||||
echo alert("Cette catégorie n'ayant pas de poste comptable n'a pas de balance");
|
||||
exit;
|
||||
}
|
||||
$ret=$cn->exec_sql("select f_id,ad_value from fiche join fiche_detail using(f_id) where fd_id=$1 and ad_id=1 order by 2 ",array($_REQUEST['cat']));
|
||||
if ( $cn->count()==0)
|
||||
{
|
||||
echo "Aucune fiche trouvée";
|
||||
exit;
|
||||
}
|
||||
echo '<table class="result" style="width:80%;margin-left:10%">';
|
||||
echo tr(
|
||||
th('Quick Code').
|
||||
th('Libellé').
|
||||
th('Débit','style="text-align:right"').
|
||||
th('Crédit','style="text-align:right"').
|
||||
th('Solde','style="text-align:right"').
|
||||
th('D/C','style="text-align:right"')
|
||||
);
|
||||
$idx=0;
|
||||
for ($i=0;$i < Database::num_row($ret);$i++)
|
||||
{
|
||||
$filter= " (j_date >= to_date('".$_REQUEST['start']."','DD.MM.YYYY') ".
|
||||
" and j_date <= to_date('".$_REQUEST['end']."','DD.MM.YYYY')) ";
|
||||
$aCard=Database::fetch_array($ret,$i);
|
||||
$oCard=new Fiche($cn,$aCard['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++;
|
||||
echo tr(
|
||||
td(HtmlInput::history_card($oCard->id,$oCard->strAttribut(ATTR_DEF_QUICKCODE))).
|
||||
td($oCard->strAttribut(ATTR_DEF_NAME)).
|
||||
td(nbm($solde['debit']),'style="text-align:right"').
|
||||
td(nbm($solde['credit']),'style="text-align:right"').
|
||||
td(nbm(abs($solde['solde'])),'style="text-align:right"').
|
||||
td((($solde['debit']<$solde['credit'])?'CRED':'DEB'),'style="text-align:right"'),
|
||||
$class
|
||||
);
|
||||
// all card
|
||||
if ($allcard==1)
|
||||
{
|
||||
$afiche=$cn->get_array("select fd_id from vw_fiche_def where ad_id=".ATTR_DEF_ACCOUNT." order by fd_label asc");
|
||||
}
|
||||
else
|
||||
{
|
||||
$afiche[0]=array('fd_id'=>$_REQUEST['cat']);
|
||||
}
|
||||
|
||||
}
|
||||
echo '</table>';
|
||||
for ($e=0;$e<count($afiche);$e++)
|
||||
{
|
||||
$ret=$cn->exec_sql("select f_id,ad_value from fiche join fiche_detail using(f_id) where fd_id=$1 and ad_id=1 order by 2 ",array($afiche[$e]['fd_id']));
|
||||
if ( $cn->count()==0)
|
||||
{
|
||||
echo "Aucune fiche trouvée";
|
||||
exit;
|
||||
}
|
||||
echo '<h2>'.$cn->get_value("select fd_label from fiche_def where fd_id=$1",array($afiche[$e]['fd_id'])).'</h2>';
|
||||
echo '<table class="result" style="width:80%;margin-left:10%">';
|
||||
echo tr(
|
||||
th('Quick Code').
|
||||
th('Libellé').
|
||||
th('Débit','style="text-align:right"').
|
||||
th('Crédit','style="text-align:right"').
|
||||
th('Solde','style="text-align:right"').
|
||||
th('D/C','style="text-align:right"')
|
||||
);
|
||||
$idx=0;
|
||||
for ($i=0;$i < Database::num_row($ret);$i++)
|
||||
{
|
||||
$filter= " (j_date >= to_date('".$_REQUEST['start']."','DD.MM.YYYY') ".
|
||||
" and j_date <= to_date('".$_REQUEST['end']."','DD.MM.YYYY')) ";
|
||||
$aCard=Database::fetch_array($ret,$i);
|
||||
$oCard=new Fiche($cn,$aCard['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++;
|
||||
echo tr(
|
||||
td(HtmlInput::history_card($oCard->id,$oCard->strAttribut(ATTR_DEF_QUICKCODE))).
|
||||
td($oCard->strAttribut(ATTR_DEF_NAME)).
|
||||
td(nbm($solde['debit']),'style="text-align:right"').
|
||||
td(nbm($solde['credit']),'style="text-align:right"').
|
||||
td(nbm(abs($solde['solde'])),'style="text-align:right"').
|
||||
td((($solde['debit']<$solde['credit'])?'CRED':'DEB'),'style="text-align:right"'),
|
||||
$class
|
||||
);
|
||||
|
||||
}
|
||||
echo '</table>';
|
||||
}
|
||||
echo $export_pdf;
|
||||
echo $export_csv;
|
||||
|
||||
|
|
@ -197,101 +221,128 @@ if ( $_GET['histo'] == 4 || $_GET['histo']==5 )
|
|||
}
|
||||
if ( isDate($_REQUEST['start']) == null || isDate ($_REQUEST['end']) == null )
|
||||
{
|
||||
echo h2('Date invalide !','class="error"');
|
||||
alert('Date invalide !');
|
||||
exit;
|
||||
}
|
||||
// for the lettering
|
||||
foreach($array as $card)
|
||||
//----------------------------------------------------------------------------
|
||||
// for the lettering / history
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
// all card
|
||||
if ($allcard==1)
|
||||
{
|
||||
$row=new Fiche($cn,$card['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;
|
||||
$detail_card=HtmlInput::card_detail($row->strAttribut(ATTR_DEF_QUICKCODE),$row->strAttribut(ATTR_DEF_NAME));
|
||||
|
||||
echo '<h2 style="font-size:14px;text-align:left;margin-left:10;padding-left:50;border:solid 1px blue;width:25%;text-decoration:underline">'.$detail_card.'</h2>';
|
||||
|
||||
echo '<table style="width:80%;padding-left:10%;padding-right:10%">';
|
||||
echo '<tr>';
|
||||
echo th(_('Date'));
|
||||
echo th(_('ref'));
|
||||
echo th(_('Interne'));
|
||||
echo th(_('Comm'));
|
||||
echo th(_('Montant'),'style="width:auto" colspan="2"');
|
||||
echo th(_('Prog.'));
|
||||
echo th(_('Let.'));
|
||||
echo '</tr>';
|
||||
$amount_deb=0;
|
||||
$amount_cred=0;
|
||||
$prog=0;
|
||||
bcscale(2);
|
||||
for ($i=0;$i<count($letter->content);$i++)
|
||||
{
|
||||
if ($i%2 == 0 )
|
||||
echo '<tr class="even">';
|
||||
else
|
||||
echo '<tr class="odd">';
|
||||
$row=$letter->content[$i];
|
||||
echo td($row['j_date_fmt']);
|
||||
echo td($row['jr_pj_number']);
|
||||
echo td(HtmlInput::detail_op($row['jr_id'],$row['jr_internal']));
|
||||
echo td($row['jr_comment']);
|
||||
if ( $row['j_debit'] == 't')
|
||||
{
|
||||
echo td(nbm($row['j_montant']),' style="text-align:right"');
|
||||
$amount_deb+=$row['j_montant'];
|
||||
$prog=bcadd($prog,$row['j_montant']);
|
||||
echo td("");
|
||||
}
|
||||
else
|
||||
{
|
||||
echo td("");
|
||||
echo td(nbm($row['j_montant']),' style="text-align:right"');
|
||||
$amount_cred+=$row['j_montant'];
|
||||
$prog=bcsub($prog,$row['j_montant']);
|
||||
}
|
||||
echo td(nbm($prog),'style="text-align:right"');
|
||||
if ($row['letter'] != -1 ) echo td($row['letter']);
|
||||
else echo td('');
|
||||
echo '</tr>';
|
||||
}
|
||||
echo '</table>';
|
||||
echo '<table>';
|
||||
echo '<tr>';
|
||||
echo td(_('Debit'));
|
||||
echo td($amount_deb,' style="font-weight:bold;text-align:right"');
|
||||
echo '</tr>';
|
||||
echo '<tr>';
|
||||
echo td(_('Credit'));
|
||||
echo td($amount_cred,' style="font-weight:bold;text-align:right"');
|
||||
echo '</tr>';
|
||||
echo '<tr>';
|
||||
if ( $amount_deb>$amount_cred) $s='solde débiteur';
|
||||
else $s='solde crediteur';
|
||||
echo td($s);
|
||||
echo td(abs(round($amount_cred-$amount_deb,2)),' style="font-weight:bold;text-align:right"');
|
||||
echo '</tr>';
|
||||
echo '</table>';
|
||||
$afiche=$cn->get_array("select fd_id from vw_fiche_def where ad_id=".ATTR_DEF_ACCOUNT." order by fd_label asc");
|
||||
}
|
||||
else
|
||||
{
|
||||
$afiche[0]=array('fd_id'=>$_REQUEST['cat']);
|
||||
}
|
||||
echo $export_csv;
|
||||
echo $export_pdf;
|
||||
|
||||
for ($e = 0; $e < count($afiche); $e++)
|
||||
{
|
||||
$array = Fiche::get_fiche_def($cn, $afiche[$e]['fd_id'], 'name_asc');
|
||||
|
||||
foreach ($array as $card)
|
||||
{
|
||||
$row = new Fiche($cn, $card['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;
|
||||
$detail_card = HtmlInput::card_detail($row->strAttribut(ATTR_DEF_QUICKCODE), $row->strAttribut(ATTR_DEF_NAME));
|
||||
|
||||
echo '<h2 style="font-size:14px;text-align:left;margin-left:10;padding-left:50;border:solid 1px blue;width:25%;text-decoration:underline">' . $detail_card . '</h2>';
|
||||
|
||||
echo '<table style="width:80%;padding-left:10%;padding-right:10%">';
|
||||
echo '<tr>';
|
||||
echo th(_('Date'));
|
||||
echo th(_('ref'));
|
||||
echo th(_('Interne'));
|
||||
echo th(_('Comm'));
|
||||
echo th(_('Montant'), 'style="width:auto" colspan="2"');
|
||||
echo th(_('Prog.'));
|
||||
echo th(_('Let.'));
|
||||
echo '</tr>';
|
||||
$amount_deb = 0;
|
||||
$amount_cred = 0;
|
||||
$prog = 0;
|
||||
bcscale(2);
|
||||
for ($i = 0; $i < count($letter->content); $i++)
|
||||
{
|
||||
if ($i % 2 == 0)
|
||||
echo '<tr class="even">';
|
||||
else
|
||||
echo '<tr class="odd">';
|
||||
$row = $letter->content[$i];
|
||||
echo td($row['j_date_fmt']);
|
||||
echo td($row['jr_pj_number']);
|
||||
echo td(HtmlInput::detail_op($row['jr_id'], $row['jr_internal']));
|
||||
echo td($row['jr_comment']);
|
||||
if ($row['j_debit'] == 't')
|
||||
{
|
||||
echo td(nbm($row['j_montant']), ' style="text-align:right"');
|
||||
$amount_deb+=$row['j_montant'];
|
||||
$prog = bcadd($prog, $row['j_montant']);
|
||||
echo td("");
|
||||
}
|
||||
else
|
||||
{
|
||||
echo td("");
|
||||
echo td(nbm($row['j_montant']), ' style="text-align:right"');
|
||||
$amount_cred+=$row['j_montant'];
|
||||
$prog = bcsub($prog, $row['j_montant']);
|
||||
}
|
||||
echo td(nbm($prog), 'style="text-align:right"');
|
||||
if ($row['letter'] != -1)
|
||||
echo td($row['letter']);
|
||||
else
|
||||
echo td('');
|
||||
echo '</tr>';
|
||||
}
|
||||
echo '</table>';
|
||||
echo '<table>';
|
||||
echo '<tr>';
|
||||
echo td(_('Debit'));
|
||||
echo td($amount_deb, ' style="font-weight:bold;text-align:right"');
|
||||
echo '</tr>';
|
||||
echo '<tr>';
|
||||
echo td(_('Credit'));
|
||||
echo td($amount_cred, ' style="font-weight:bold;text-align:right"');
|
||||
echo '</tr>';
|
||||
echo '<tr>';
|
||||
if ($amount_deb > $amount_cred)
|
||||
$s = 'solde débiteur';
|
||||
else
|
||||
$s = 'solde crediteur';
|
||||
echo td($s);
|
||||
echo td(abs(round($amount_cred - $amount_deb, 2)), ' style="font-weight:bold;text-align:right"');
|
||||
echo '</tr>';
|
||||
echo '</table>';
|
||||
}
|
||||
}
|
||||
echo $export_csv;
|
||||
echo $export_pdf;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ if ( $rapport->exist() == false ) {
|
|||
}
|
||||
|
||||
if ( $report != 0 ) {
|
||||
echo '<fieldset style="background-color:white"><legend>'.$rapport->get_name().'</legend>';
|
||||
echo '<fieldset style="width:50%;background-color:white"><legend>'.$rapport->get_name().'</legend>';
|
||||
$exercice=$g_user->get_exercice();
|
||||
if ( $exercice == 0 ) {
|
||||
alert(_('Aucune periode par defaut'));
|
||||
|
|
@ -120,7 +120,7 @@ if ( $report != 0 ) {
|
|||
echo '</fieldset>';
|
||||
echo '</div>';
|
||||
} else {
|
||||
echo '<fieldset style="background-color:white"><legend>'._('Aucun rapport défini').'</legend>';
|
||||
echo '<fieldset style="width:50%;background-color:white"><legend>'._('Aucun rapport défini').'</legend>';
|
||||
echo '<a href="user_pref.php?'.dossier::get().'">'._('Cliquez ici pour mettre à jour vos préférences').'</a>';
|
||||
echo '</fieldset>';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,5 +14,9 @@
|
|||
<tr id="trend">
|
||||
<td><?=_('Jusque')?></td>
|
||||
<td><?=$str_end?></td>
|
||||
<tr id="allcard">
|
||||
<td>Toutes les fiches</td>
|
||||
<td><?=$str_icall?></td>
|
||||
</tr>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue