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 NOALYSS_INCLUDE.'/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_once NOALYSS_INCLUDE.'/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=$http->post('reverse_date',"string", '');
$p_msg=$http->post("ext_label");
if (isDate($p_date)==$p_date)
{
// reverse the operation
try
{
$ledger->reverse($p_date,$p_msg);
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 '
';
echo "- ";
echo $ledger->button_new_operation();
echo "
";
echo "- ";
echo $ledger->button_copy_operation();
echo "
";
echo "
";
}
catch (Exception $e)
{
require NOALYSS_INCLUDE.'/operation_ods_new.inc.php';
alert($e->getMessage());
$p_msg=$e->getMessage();
}
echo '
';
return;
}
return;