altocompta/include/impress_jrn.inc.php
Dany De Bontridder 5c497d5092 Merged revisions 4209,4229-4232,4234,4237-4249 via svnmerge from
svn+ssh://ns352270.ovh.net/svn/phpcompta/branches/rel600-dynamic-menu

........
  r4209 | danydb | 2011-10-13 22:06:13 +0200 (Thu, 13 Oct 2011) | 1 line
  
  Add new files
........
  r4229 | danydb | 2011-10-23 20:51:09 +0200 (Sun, 23 Oct 2011) | 1 line
  
  Dynamic menu: impress works
........
  r4230 | danydb | 2011-10-24 22:38:15 +0200 (Mon, 24 Oct 2011) | 2 lines
  
  #241 : modularity for SALE ledger
........
  r4231 | danydb | 2011-10-24 22:47:02 +0200 (Mon, 24 Oct 2011) | 2 lines
  
  #241 : modularity for PURCHASE ledger
........
  r4232 | danydb | 2011-10-25 23:03:53 +0200 (Tue, 25 Oct 2011) | 2 lines
  
  #241 : modularity for FINANCIAL ledger
........
  r4234 | danydb | 2011-10-26 01:09:02 +0200 (Wed, 26 Oct 2011) | 2 lines
  
  #241 : modularity for CARD ledger + alphanum prob
........
  r4237 | danydb | 2011-10-27 20:59:39 +0200 (Thu, 27 Oct 2011) | 2 lines
  
  #241 : modularity for lettering
........
  r4238 | danydb | 2011-10-27 21:10:19 +0200 (Thu, 27 Oct 2011) | 3 lines
  
  #241 :adapt width submenu
........
  r4239 | danydb | 2011-10-27 21:40:42 +0200 (Thu, 27 Oct 2011) | 3 lines
  
  #241 : modularity : old user_advanced.php
........
  r4240 | danydb | 2011-10-27 21:44:27 +0200 (Thu, 27 Oct 2011) | 3 lines
  
  #241 : modularity : deprecated function
........
  r4241 | danydb | 2011-10-27 21:46:26 +0200 (Thu, 27 Oct 2011) | 3 lines
  
  #241 : modularity : remove obsolete files
........
  r4242 | danydb | 2011-10-27 21:54:39 +0200 (Thu, 27 Oct 2011) | 3 lines
  
  #241 : modularity : gestion card + gestion IMP
........
  r4243 | danydb | 2011-10-27 22:28:36 +0200 (Thu, 27 Oct 2011) | 3 lines
  
  #241 : modularity : gestion customer + supplier + forecast + follow up
........
  r4244 | danydb | 2011-10-28 00:47:55 +0200 (Fri, 28 Oct 2011) | 5 lines
  
  #241 : modularity : parameter 
  company
  periode
  misc : tva , card attr, middle of payment, accounting,cat of doc, cat of card
........
  r4245 | danydb | 2011-10-28 00:51:43 +0200 (Fri, 28 Oct 2011) | 1 line
  
  update menu_ref, profile_menu
........
  r4246 | danydb | 2011-10-28 00:52:13 +0200 (Fri, 28 Oct 2011) | 1 line
  
  rewriting : change ShowMenuPcmn by menu_acc_plan
........
  r4247 | danydb | 2011-10-28 20:04:01 +0200 (Fri, 28 Oct 2011) | 1 line
  
  #241 : modularity : parameter  Document
........
  r4248 | danydb | 2011-10-28 22:00:42 +0200 (Fri, 28 Oct 2011) | 1 line
  
  #241 : modularity : préférence
........
  r4249 | danydb | 2011-10-28 22:16:44 +0200 (Fri, 28 Oct 2011) | 1 line
  
  last fix
........
2011-10-28 20:59:25 +00:00

300 lines
9.2 KiB
PHP

<?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 ask for Printing the ledger (pdf,html)
*/
require_once("class_ihidden.php");
require_once("class_iselect.php");
require_once("class_icheckbox.php");
require_once('class_exercice.php');
require_once('class_dossier.php');
load_all_script();
$gDossier=dossier::id();
global $g_user;
//-----------------------------------------------------
// Show the jrn and date
//-----------------------------------------------------
require_once('class_database.php');
if ( $g_user->Admin() == 0 && $g_user->is_local_admin()==0)
{
$sql="select jrn_def_id,jrn_def_name
from jrn_def join jrn_type on jrn_def_type=jrn_type_id
join user_sec_jrn on uj_jrn_id=jrn_def_id
where
uj_login='$g_user->login'
and uj_priv !='X'
";
$ret=$cn->make_array($sql);
}
else
{
$ret=$cn->make_array("select jrn_def_id,jrn_def_name
from jrn_def join jrn_type on jrn_def_type=jrn_type_id");
}
// Count the forbidden journaux
$NoPriv=$cn->count_sql("select jrn_def_id,jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc,uj_priv,
jrn_deb_max_line,jrn_cred_max_line
from jrn_def join jrn_type on jrn_def_type=jrn_type_id
join user_sec_jrn on uj_jrn_id=jrn_def_id
where
uj_login='$g_user->id'
and uj_priv ='X'
");
// Pour voir tout les journal ?
if ( $NoPriv == 0 )
{
$a=count($ret);
$all=array('value'=>0,'label'=>'Tous les journaux');
$ret[$a]=$all;
}
if ( count($ret) < 1 )
NoAccess();
$exercice=(isset($_GET['exercice']))?$_GET['exercice']:$g_user->get_exercice();
//-----------------------------------------------------
// Form
//-----------------------------------------------------
echo '<div class="content">';
/*
* Let you change the exercice
*/
echo '<fieldset><legend>'._('Choississez un autre exercice').'</legend>';;
echo '<form method="GET">';
echo 'Choississez un autre exercice :';
$ex=new Exercice($cn);
$wex=$ex->select('exercice',$exercice,' onchange="submit(this)"');
echo $wex->input();
echo dossier::hidden();
echo HtmlInput::get_to_hidden(array('ac','type'));
echo '</form>';
echo '</fieldset>';
echo '<FORM METHOD="GET">'.dossier::hidden();
echo HtmlInput::get_to_hidden(array('ac','type'));
echo HtmlInput::hidden('type','jrn');
echo HtmlInput::get_to_hidden(array('exercice'));
echo '<TABLE ><TR>';
$w=new ISelect();
$w->table=1;
$label="Choississez le journal";
$w->selected=(isset($_GET['jrn_id']))?$_GET['jrn_id']:'';
print td($label).$w->input("jrn_id",$ret);
print '</TR>';
print '<TR>';
// filter on the current year
$filter_year=" where p_exercice='".FormatString($exercice)."'";
$periode_start=$cn->make_array("select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end");
$w->selected=(isset($_GET['from_periode']))?$_GET['from_periode']:'';
print td('Depuis').$w->input('from_periode',$periode_start);
print '</TR>';
print '<TR>';
$periode_end=$cn->make_array("select p_id,to_char(p_end,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end");
$w->selected=(isset($_GET['to_periode']))?$_GET['to_periode']:'';
print td('Jusque ').$w->input('to_periode',$periode_end);
print "</TR><TR>";
$a=array(
array('value'=>0,'label'=>'Detaillé'),
array('value'=>1,'label'=>'Simple')
);
$w->selected=1;
print '</TR>';
print '<TR>';
$w->selected=(isset($_GET['p_simple']))?$_GET['p_simple']:'';
echo td('Style d\'impression').$w->input('p_simple',$a);
print "</TR>";
echo '</TABLE>';
print HtmlInput::submit('bt_html','Visualisation');
echo '</FORM>';
//-----------------------------------------------------
// If print is asked
// First time in html
// after in pdf or cvs
//-----------------------------------------------------
if ( isset( $_REQUEST['bt_html'] ) )
{
require_once("class_acc_ledger.php");
$d=var_export($_GET,true);
$Jrn=new Acc_Ledger($cn,$_GET['jrn_id']);
$Jrn->get_name();
if ( $_GET['p_simple']==0 )
{
$Row=$Jrn->get_row( $_GET['from_periode'],
$_GET['to_periode']
);
}
else
{
$Row=$Jrn->get_rowSimple($_GET['from_periode'],
$_GET['to_periode']
);
}
$rep="";
$hid=new IHidden();
echo '<div class="content">';
echo '<h2 class="info">'.h($Jrn->name).'</h2>';
echo "<table>";
echo '<TR>';
echo '<TD><form method="GET" ACTION="?">'.dossier::hidden().
$hid->input("type","jrn").$hid->input('p_action','impress')."</form></TD>";
echo '<TD><form method="GET" ACTION="export.php">'.dossier::hidden().
HtmlInput::submit('bt_pdf',"Export PDF").
HtmlInput::hidden('act','PDF/ledger').
$hid->input("type","jrn").
$hid->input("jrn_id",$Jrn->id).
$hid->input("from_periode",$_GET['from_periode']).
$hid->input("to_periode",$_GET['to_periode']);
echo $hid->input("p_simple",$_GET['p_simple']);
echo HtmlInput::get_to_hidden(array('ac','type'));
echo "</form></TD>";
echo '<TD><form method="GET" ACTION="export.php">'.dossier::hidden().
HtmlInput::submit('bt_csv',"Export CSV").
HtmlInput::hidden('act','CSV/ledger').
$hid->input("type","jrn").
$hid->input("jrn_id",$Jrn->id).
$hid->input("from_periode",$_GET['from_periode']).
$hid->input("to_periode",$_GET['to_periode']);
echo $hid->input("p_simple",$_GET['p_simple']);
echo HtmlInput::get_to_hidden(array('ac','type'));
echo "</form></TD>";
echo "</TR>";
echo "</table>";
if ( count($Jrn->row ) == 0
&& $Row==null)
exit;
echo '<TABLE class="result">';
if ( $_GET['p_simple'] == 0 )
{
// detailled printing
//---
foreach ( $Jrn->row as $op )
{
$class="";
if ( $op['j_date'] != '' )
{
$class="odd";
}
echo "<TR class=\"$class\">";
echo "<TD>".$op['j_date']."</TD>";
echo "<TD >".$op['jr_pj_number']."</TD>";
if ( $op['internal']!='')
echo "<TD>".HtmlInput::detail_op($op['jr_id'],$op['internal'])."</TD>";
else
echo td();
echo "<TD >".$op['poste']."</TD>".
"<TD >".$op['description']."</TD>".
"<TD style=\"text-align:right\">".nbm($op['deb_montant'])."</TD>".
"<TD style=\"text-align:right\">".nbm($op['cred_montant'])."</TD>".
"</TR>";
}// end loop
} // if
else
{
// Simple printing
//---
echo "<TR>".
"<th> operation </td>".
"<th>Date</th>".
"<th> n° de pièce </th>".
"<th>internal</th>".
th('Tiers').
"<th>Commentaire</th>".
"<th> montant</th>".
"</TR>";
// set a filter for the FIN
foreach ($Row as $line)
{
echo "<tr>";
echo "<TD>".$line['num']."</TD>";
echo "<TD>".$line['date']."</TD>";
echo "<TD>".h($line['jr_pj_number'])."</TD>";
echo "<TD>".HtmlInput::detail_op($line['jr_id'],$line['jr_internal'])."</TD>";
$tiers=$Jrn->get_tiers($line['jrn_def_type'],$line['jr_id']);
echo td($tiers);
echo "<TD>".h($line['comment'])."</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 = $cn->get_value("select qf_amount from quant_fin where jr_id=$1",
array($line['jr_id']));
if ($cn->count() != 0)
$positive = 1;
else
$positive = ($positive > 0)?1:0;
echo "<TD align=\"right\">";
echo ( $positive != 0 )?"<font color=\"red\"> - ".nbm($line['montant'])."</font>":nbm($line['montant']);
echo "</TD>";
}
else
{
echo "<TD align=\"right\">".nbm($line['montant'])."</TD>";
}
echo "</tr>";
}
} //else
echo "</table>";
// show the saldo
$solde=$Jrn->get_solde( $_GET['from_periode'],
$_GET['to_periode']
);
echo "solde d&eacute;biteur:".$solde[0]."<br>";
echo "solde cr&eacute;diteur:".$solde[1];
echo "</div>";
exit;
}
echo '</div>';
?>