Wheel_of_Fortune_Plugin/admin/partials/prize-form-fields.php

108 lines
5.4 KiB
PHP

<?php
/**
* Reusable form fields for adding/editing prizes
*/
if (!defined('ABSPATH')) exit;
// Pridobi predloge (potrebno na strani, ki vključuje to datoteko)
global $wpdb;
$email_templates = $wpdb->get_results("SELECT id, name FROM {$wpdb->prefix}wheel_email_templates ORDER BY name ASC", ARRAY_A);
?>
<tr>
<th scope="row"><label for="prize_name"><?php _e('Prize Name', 'wheel-of-fortune'); ?></label></th>
<td><input type="text" id="prize_name" name="prize_name" class="regular-text" required></td>
</tr>
<tr>
<th scope="row"><label for="prize_description"><?php _e('Description', 'wheel-of-fortune'); ?></label></th>
<td><textarea id="prize_description" name="prize_description" rows="3" class="large-text"></textarea></td>
</tr>
<tr>
<th scope="row"><label for="prize_probability"><?php _e('Probability', 'wheel-of-fortune'); ?></label></th>
<td>
<input type="number" id="prize_probability" name="prize_probability" step="any" min="0" max="1" required>
<p class="description"><?php _e('Enter a value between 0 and 1 (e.g., 0.1 for 10% chance). Use 0 for prizes that cannot be won.', 'wheel-of-fortune'); ?></p>
</td>
</tr>
<tr>
<th scope="row"><?php _e('Status', 'wheel-of-fortune'); ?></th>
<td>
<label for="prize_is_active">
<input type="checkbox" id="prize_is_active" name="prize_is_active" value="1" checked>
<?php _e('Prize is active', 'wheel-of-fortune'); ?>
</label>
</td>
</tr>
<!-- DODAJ NOVA POLJA ZA FUNDED ACCOUNT -->
<tr>
<th scope="row"><label for="funded_account_name"><?php _e('Funded Account Name', 'wheel-of-fortune'); ?></label></th>
<td>
<input type="text" id="funded_account_name" name="funded_account_name" class="regular-text">
<p class="description"><?php _e('e.g., Funded7 $50k. Used for the {funded_account_name} tag.', 'wheel-of-fortune'); ?></p>
</td>
</tr>
<tr>
<th scope="row"><label for="funded_account_value"><?php _e('Funded Account Value', 'wheel-of-fortune'); ?></label></th>
<td>
<input type="number" id="funded_account_value" name="funded_account_value" step="any" min="0">
<p class="description"><?php _e('e.g., 50000. Used for the {funded_account_value} tag.', 'wheel-of-fortune'); ?></p>
</td>
</tr>
<tr>
<th scope="row"><label for="prize_redemption_code"><?php _e('Redemption Code', 'wheel-of-fortune'); ?></label></th>
<td>
<input type="text" id="prize_redemption_code" name="prize_redemption_code" class="regular-text">
<p class="description"><?php _e('Optional code for the user to redeem the prize.', 'wheel-of-fortune'); ?></p>
</td>
</tr>
<!-- SPREMENJENA EMAIL SEKCIJA -->
<tr>
<th scope="row"><label for="prize_email_template_id"><?php _e('Email Content', 'wheel-of-fortune'); ?></label></th>
<td>
<select id="prize_email_template_id" name="email_template_id">
<option value="0"><?php _e('-- Custom Email --', 'wheel-of-fortune'); ?></option>
<?php foreach ($email_templates as $template) : ?>
<option value="<?php echo esc_attr($template['id']); ?>"><?php echo esc_html($template['name']); ?></option>
<?php endforeach; ?>
</select>
<p class="description"><?php _e('Choose a pre-written template or select "Custom Email" to write your own below.', 'wheel-of-fortune'); ?></p>
</td>
</tr>
<tbody class="custom-email-fields">
<tr>
<th scope="row"><label for="prize_email_subject"><?php _e('Email Subject', 'wheel-of-fortune'); ?></label></th>
<td>
<input type="text" id="prize_email_subject" name="prize_email_subject" class="large-text">
<p class="description"><?php _e('Subject for this prize\'s email. Only used if "Custom Email" is selected.', 'wheel-of-fortune'); ?></p>
</td>
</tr>
<tr>
<th scope="row"><label for="prize_email_template"><?php _e('Email Template', 'wheel-of-fortune'); ?></label></th>
<td>
<textarea id="prize_email_template" name="prize_email_template" rows="10" class="large-text code"></textarea>
<p class="description"><?php _e('Content for this prize\'s email. Only used if "Custom Email" is selected.', 'wheel-of-fortune'); ?></p>
<p><?php _e('Available template tags:', 'wheel-of-fortune'); ?></p>
<ul class="wheel-template-tags">
<li><code>{user_name}</code>, <code>{user_email}</code>, <code>{prize_name}</code>, <code>{prize_description}</code>, <code>{redemption_code}</code>, <code>{site_name}</code>, <code>{site_url}</code>, <code>{date}</code>, <code>{time}</code>, <strong><code>{funded_account_name}</code></strong>, <strong><code>{funded_account_value}</code></strong></li>
</ul>
</td>
</tr>
</tbody>
<tr>
<th scope="row"><label for="prize_is_discount"><?php _e('Je discount?', 'wheel-of-fortune'); ?></label></th>
<td>
<input type="checkbox" id="prize_is_discount" name="prize_is_discount" value="1">
<p class="description"><?php _e('Označi, če je nagrada popust.', 'wheel-of-fortune'); ?></p>
</td>
</tr>
<tr>
<th scope="row"><label for="prize_discount_value"><?php _e('Vrednost kupona (%)', 'wheel-of-fortune'); ?></label></th>
<td>
<input type="number" id="prize_discount_value" name="prize_discount_value" step="0.01" min="0" max="100">
<p class="description"><?php _e('Vnesi vrednost popusta v %.', 'wheel-of-fortune'); ?></p>
</td>
</tr>