<?php
/**
 * Admin-View: Upload-Form
 */
if ( ! defined( 'ABSPATH' ) ) { exit; }

use Itdatex\Rechnungseingang\Plugin;
use Itdatex\Rechnungseingang\UploadHandler;

$action_url = admin_url( 'admin-post.php' );
?>
<div class="wrap reing-wrap">
  <h1><?php esc_html_e( 'Rechnung hochladen', 'itdatex-e-invoice-intake' ); ?></h1>
  <p class="description"><?php esc_html_e(
      'Akzeptiert XRechnung (UBL oder UN/CEFACT), ZUGFeRD-PDF und Factur-X. Maximale Dateigroesse abhaengig von der PHP-Konfiguration.',
      'itdatex-e-invoice-intake'
  ); ?></p>

  <form method="post" enctype="multipart/form-data" action="<?php echo esc_url( $action_url ); ?>" class="reing-upload-form">
    <input type="hidden" name="action" value="<?php echo esc_attr( UploadHandler::ACTION ); ?>">
    <?php wp_nonce_field( UploadHandler::ACTION, UploadHandler::NONCE ); ?>

    <table class="form-table" role="presentation">
      <tr>
        <th scope="row"><label for="invoice_file"><?php esc_html_e( 'Datei', 'itdatex-e-invoice-intake' ); ?></label></th>
        <td>
          <input type="file" id="invoice_file" name="invoice_file" required
                 accept=".xml,.pdf,application/xml,application/pdf">
          <p class="description"><?php
            esc_html_e( 'Erlaubte Formate: .xml, .pdf', 'itdatex-e-invoice-intake' );
          ?></p>
        </td>
      </tr>
    </table>

    <?php submit_button( __( 'Hochladen und verarbeiten', 'itdatex-e-invoice-intake' ) ); ?>
  </form>
</div>
