<?= $this->extend('admin/layout/main') ?>
<?= $this->section('content') ?>
<h3 class="mb-3"><?= $marketer ? lang('App.edit') : lang('App.add_new') ?> - <?= lang('App.marketers') ?></h3>
<div class="card p-4" style="max-width:500px;">
<form method="post" action="<?= $marketer ? '/admin/marketers/' . $marketer['id'] : '/admin/marketers' ?>">
    <?= csrf_field() ?>
    <div class="mb-3">
        <label class="form-label"><?= lang('App.name') ?></label>
        <input type="text" name="name" class="form-control" value="<?= esc($marketer['name'] ?? '') ?>" required>
    </div>
    <div class="mb-3">
        <label class="form-label"><?= lang('App.email') ?></label>
        <input type="email" name="email" class="form-control" value="<?= esc($marketer['email'] ?? '') ?>">
    </div>
    <div class="mb-3">
        <label class="form-label"><?= lang('App.phone') ?></label>
        <input type="text" name="phone" class="form-control" value="<?= esc($marketer['phone'] ?? '') ?>">
    </div>
    <div class="mb-3">
        <label class="form-label"><?= lang('App.commission_type') ?></label>
        <select name="commission_type" class="form-select">
            <option value="percentage" <?= ($marketer['commission_type'] ?? '') === 'percentage' ? 'selected' : '' ?>>نسبة مئوية %</option>
            <option value="fixed" <?= ($marketer['commission_type'] ?? '') === 'fixed' ? 'selected' : '' ?>>مبلغ ثابت</option>
        </select>
    </div>
    <div class="mb-3">
        <label class="form-label"><?= lang('App.commission_value') ?></label>
        <input type="number" step="0.01" name="commission_value" class="form-control" value="<?= esc($marketer['commission_value'] ?? '') ?>" required>
    </div>
    <div class="form-check mb-3">
        <input type="checkbox" name="is_active" class="form-check-input" value="1" <?= ($marketer['is_active'] ?? 1) ? 'checked' : '' ?>>
        <label class="form-check-label"><?= lang('App.status') ?></label>
    </div>
    <button class="btn btn-dark"><?= lang('App.save') ?></button>
    <a href="/admin/marketers" class="btn btn-light"><?= lang('App.cancel') ?></a>
</form>
</div>
<?= $this->endSection() ?>
