<h2 style="padding: 10px; background-color: whitesmoke; text-align: center;">ایجاد مخاطب جدید</h2>

<?php
use WeboneSMS\WeboneSMS\Services\ViewService;
$notices = ViewService::get_flash();
foreach($notices as $notice) {
    wp_admin_notice($notice['message'], $notice['args']);
}
?>

<form method="POST" action="<?php echo add_query_arg(['action' => $_GET['action'] ?? 'create']); ?>">
    <table class="form-table">
        <tbody>
            <tr>
                <th scope="row">
                    <label for="input_name">نام</label>
                </th>
                <td>
                    <input type="text" name="name" id="input_name" value="<?php echo isset($data['contact']) ? $data['contact']['name'] : '' ?>" required style="min-width: 300px;"/>
                </td>
            </tr>
            <tr>
                <th scope="row">
                    <label for="input_mobile">شماره موبایل</label>
                </th>
                <td>
                    <input type="tel" name="mobile" id="input_mobile" value="<?php echo isset($data['contact']) ? $data['contact']['mobile'] : '' ?>" required style="min-width: 300px; direction: ltr;"/>
                </td>
            </tr>
            <tr>
                <th scope="row">وضعیت</th>
                <td>
                    <input type="radio" name="is_active" value="1" required <?php echo isset($data['contact']) && $data['contact']['is_active'] ? 'checked' : '' ?> />
                    <label>فعال</label>
                    <br/>
                    <input type="radio" name="is_active" value="0" required <?php echo isset($data['contact']) && !$data['contact']['is_active'] ? 'checked' : '' ?> />
                    <label>غیرفعال</label>
                </td>
            </tr>
        </tbody>
    </table>
    <button type="submit" class="button button-primary">
        &nbsp;
        ایجاد
        &nbsp;
    </button>
</form>

<h2 style="padding: 10px; background-color: whitesmoke; text-align: center;">مخاطبین ایجاد شده</h2>

<?php
    $data['table']->display();
?>