get_first('ODS');
if ( empty ($first_ledger))
{
exit('Pas de journal disponible');
}
$ledger->id = ($ledger->id == -1) ? $first_ledger['jrn_def_id'] : $id_ledger;
/**\brief show a form for quick_writing */
$def = -1;
$ledger->with_concerned = true;
if ($g_user->check_jrn($ledger->id) == 'X')
{
NoAccess();
exit - 1;
}
$p_msg="";
if (!isset($_POST['summary']) && !isset($_POST['save']))
{
require('operation_ods_new.inc.php');
return;
}
elseif (isset($_POST['summary']))
{
try {
$ledger->verify($_POST);
require_once NOALYSS_INCLUDE.'/operation_ods_confirm.inc.php';
} catch (Exception $e)
{
echo alert($e->getMessage());
$p_msg=$e->getMessage();
require('operation_ods_new.inc.php');
}
return;
}
elseif (isset($_POST['save']))
{
$array = $_POST;
echo '
';
try
{
$ledger->save($array);
$jr_id = $cn->get_value('select jr_id from jrn where jr_internal=$1', array($ledger->internal));
echo '
Opération enregistrée Piece ' . h($ledger->pj) . '
';
if (strcmp($ledger->pj, $_POST['e_pj']) != 0)
{
echo '
' . _('Attention numéro pièce existante, elle a du être adaptée') . '
';
}
printf('
%s
', $jr_id, dossier::id(), $ledger->internal);
// show feedback
echo '
'; echo '
' . $ledger->get_name() . '
'; echo '';
echo $ledger->confirm($_POST, true);
// extourne
if (isset($_POST['reverse_ck']))
{
$p_date=HtmlInput::default_value_post('reverse_date', '');
if (isDate($p_date)==$p_date)
{
// reverse the operation
try
{
$ledger->reverse($p_date);
echo '
';
echo _('Extourné au ').$p_date;
echo '
';
}
catch (Exception $e)
{
echo '
'._('Opération non extournée').
$e->getMessage().
'
';
}
}
else
{
// warning because date is invalid
echo '
'._('Date invalide, opération non extournée').'
';
}
}
echo $ledger->button_new_operation();
}
catch (Exception $e)
{
require('operation_ods_new.inc.php');
alert($e->getMessage());
$p_msg=$e->getMessage();
}
echo '
';
return;
}
return;