Admin() == 0 && $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='$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='$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']:$User->get_exercice();
//-----------------------------------------------------
// Form
//-----------------------------------------------------
echo '
';
/*
* Let you change the exercice
*/
echo '';
echo '';
//-----------------------------------------------------
// 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 '
";
}// end loop
} // if
else
{
// Simple printing
//---
echo "
".
"
operation ".
"
Date
".
"
n° de pièce
".
"
internal
".
"
Commentaire
".
"
montant
".
"
";
// set a filter for the FIN
$a_parm_code=$cn->get_array("select p_value from parm_code where p_code in ('BANQUE','COMPTE_COURANT','CAISSE')");
$sql_fin="(";
$or="";
foreach ($a_parm_code as $code)
{
$sql_fin.="$or j_poste::text like '".$code['p_value']."%'";
$or=" or ";
}
$sql_fin.=")";
foreach ($Row as $line)
{
echo "
";
// 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->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'");
echo "