request('ac')."&".dossier::get();
$Ledger=new Acc_Ledger_Fin($cn,0);
//--------------------------------------------------------------------------------
// Encode a new financial operation
//--------------------------------------------------------------------------------
if ( isset($_REQUEST['p_jrn'] ) )
{
$Ledger->id=$http->request('p_jrn',"number");
}
else
{
$def_ledger=$Ledger->get_first('fin');
if ( empty ($def_ledger))
{
exit(_('Pas de journal disponible'));
}
$Ledger->id=$def_ledger['jrn_def_id'];
}
$jrn_priv=$g_user->get_ledger_access($Ledger->id);
// Check privilege
if ( $jrn_priv == 'X')
{
NoAccess();
exit -1;
}
$Ledger->load();
$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 '';
try {
$a= $Ledger->insert($_POST);
} catch (\Exception $e) {
if ( $e->getCode()==EXC_BALANCE)
echo_warning(_("enregistrement annulé: balance , voyer le fichier log"));
else
echo_warning($e->getMessage());
return;
}
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 '