<?php require __DIR__ . '/../layouts/header.php'; ?>

<div class="d-flex justify-content-between align-items-center mb-4">
    <div>
        <h1 class="fw-bold mb-0"><?= e(trans('publishing_workflow')) ?></h1>
        <div class="text-muted"><?= e((string) $submission['submission_no']) ?> — <?= e((string) $submission['title']) ?></div>
    </div>
    <a href="<?= e(base_path('submissions/show?id=' . (int) $submission['id'])) ?>" class="btn btn-outline-secondary rounded-3"><?= e(trans('back')) ?></a>
</div>

<div class="card border-0 shadow-sm rounded-4 mb-4">
    <div class="card-body">
        <div class="mb-2"><strong><?= e(trans('status')) ?>:</strong> <?= e((string) $submission['status']) ?></div>
        <div class="mb-2"><strong><?= e(trans('camera_ready_file')) ?>:</strong> <?= e((string) ($proceeding['camera_ready_path'] ?? '')) ?></div>
        <div class="mb-2"><strong><?= e(trans('doi')) ?>:</strong> <?= e((string) ($proceeding['doi'] ?? '')) ?></div>
        <div class="mb-0"><strong><?= e(trans('publication_status')) ?>:</strong> <?= !empty($proceeding['is_published']) ? e(trans('published')) : e(trans('not_published')) ?></div>
    </div>
</div>

<?php if (!empty($proceeding)): ?>
    <div class="card border-0 shadow-sm rounded-4">
        <div class="card-body">
            <div class="row g-3">
                <div class="col-md-6">
                    <form method="post" action="<?= e(base_path('publishing/publish')) ?>">
                        <input type="hidden" name="_csrf" value="<?= e(csrf_token()) ?>">
                        <input type="hidden" name="submission_id" value="<?= e((string) $submission['id']) ?>">
                        <div class="mb-3">
                            <label class="form-label"><?= e(trans('doi')) ?></label>
                            <input type="text" name="doi" class="form-control rounded-3" value="<?= e((string) ($proceeding['doi'] ?? '')) ?>">
                        </div>
                        <button type="submit" class="btn btn-success rounded-3"><?= e(trans('publish_paper')) ?></button>
                    </form>
                </div>

                <div class="col-md-6 d-flex align-items-end">
                    <form method="post" action="<?= e(base_path('publishing/unpublish')) ?>">
                        <input type="hidden" name="_csrf" value="<?= e(csrf_token()) ?>">
                        <input type="hidden" name="submission_id" value="<?= e((string) $submission['id']) ?>">
                        <button type="submit" class="btn btn-outline-danger rounded-3"><?= e(trans('unpublish_paper')) ?></button>
                    </form>
                </div>
            </div>
        </div>
    </div>
<?php else: ?>
    <div class="alert alert-info rounded-4"><?= e(trans('no_data')) ?></div>
<?php endif; ?>

<?php require __DIR__ . '/../layouts/footer.php'; ?>
