request("p_jrn","number",0);
//--------------------------------------------------------------------------------
// Encode a new financial operation
//--------------------------------------------------------------------------------
if ( $ledger_id == 0)
{
$Ledger=new Acc_Ledger_Fin($cn,0);
$def_ledger=$Ledger->get_first('fin');
if ( empty ($def_ledger))
{
exit(_('Pas de journal disponible'));
}
$ledger_id=$def_ledger['jrn_def_id'];
}
$Ledger=new Acc_Ledger_Fin($cn,$ledger_id);
$Ledger->load();
$jrn_priv=$g_user->get_ledger_access($Ledger->id);
// Check privilege
if ( $jrn_priv == 'X')
{
NoAccess();
exit -1;
}
$p_msg="";
//----------------------------------------
// Confirm the operations
//----------------------------------------
if ( isset($_POST['save']))
{
try
{
$Ledger->verify_operation($_POST);
}
catch (Exception $e)
{
alert($e->getMessage());
$p_msg=$e->getMessage();
$correct=1;
}
if ( ! isset ($correct ))
{
echo '
';
echo h1(_('Confirmation'),'');
echo_warning(_("Attention, cette opération n'est pas encore sauvée : vous devez encore confirmer"));
echo '';
echo '
';
return;
}
}
//----------------------------------------
// Confirm and save the operations
// into the database
//----------------------------------------
if ( isset($_POST['confirm']))
{
try
{
$Ledger->verify_operation($_POST);
}
catch (Exception $e)
{
alert($e->getMessage());
$p_msg=$e->getMessage();
$correct=1;
}
if ( !isset($correct))
{
echo '';
$a= $Ledger->insert($_POST);
echo '
'._('Enregistrement').'
';
echo '
';
echo $a;
echo '
';
echo '
';
echo $Ledger->button_new_operation();
return;
}
}
//----------------------------------------
// Correct the operations
//----------------------------------------
if ( isset($_POST['correct']))
{
$correct=1;
}
//----------------------------------------
// Blank form
//----------------------------------------
if ( $p_msg !="" ) echo '