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();
//-----------------------------------------------------
// Form
//-----------------------------------------------------
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 '
';
echo '
'.h($Jrn->name).'
';
echo "
";
echo '';
echo ' | ";
echo ' | ";
echo ' | ";
echo "
";
echo "
";
if ( count($Jrn->row ) == 0
&& $Row==null)
exit;
echo '
';
if ( $_GET['p_simple'] == 0 )
{
// detailled printing
//---
foreach ( $Jrn->row as $op )
{
$class="";
if ( $op['j_date'] != '' )
{
$class="odd";
}
echo "";
echo "| ".$op['j_date']." | ";
echo "".$op['jr_pj_number']." | ";
if ( $op['internal']!='')
echo "".HtmlInput::detail_op($op['jr_id'],$op['internal'])." | ";
else
echo td();
echo "".$op['poste']." | ".
"".$op['description']." | ".
"".nbm($op['deb_montant'])." | ".
"".nbm($op['cred_montant'])." | ".
"
";
}// 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 "";
echo "| ".$line['num']." | ";
echo "".$line['date']." | ";
echo "".h($line['jr_pj_number'])." | ";
echo "".HtmlInput::detail_op($line['jr_id'],$line['jr_internal'])." | ";
echo "".h($line['comment'])." | ";
// echo "".$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 = $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 "";
echo ( $positive != 0 )?" - ".nbm($line['montant'])."":nbm($line['montant']);
echo " | ";
}
else
{
echo "".nbm($line['montant'])." | ";
}
echo "
";
}
} //else
echo "
";
// show the saldo
$solde=$Jrn->get_solde( $_GET['from_periode'],
$_GET['to_periode']
);
echo "solde débiteur:".$solde[0]."
";
echo "solde créditeur:".$solde[1];
echo "
";
exit;
}
echo '
';
?>