Files
2025-03-12 17:06:23 +01:00

53 lines
1.7 KiB
PHP

<?php
/**
* @var Discount $value
* @var Discount $entity
*/
if ($type == 'edit')
{
echo st_admin_table_start([
['label' => __('Klient detaliczny')],
['label' => __('Klient hurtowy')],
['label' => __('Rodzaj')],
]);
echo "<tbody>";
echo "<tr>";
echo content_tag('td', st_admin_optional_input('discount[value]', $value->getValue(), ['size' => 8, 'disabled' => null === $value->getValue()]));
echo content_tag('td', st_admin_optional_input('discount[wholesale_value]', $value->getWholesaleValue(), ['size' => 8, 'disabled' => null === $value->getWholesaleValue()]));
echo content_tag('td', st_discount_type_select_tag('discount[price_type]', $value->getPriceType()));
echo "</tr>";
echo "</tbody>";
echo st_admin_table_end();
}
elseif (null !== $entity->getValue())
{
echo $entity->getPriceType() == Discount::PERCENT_TYPE ? $entity->getValue().'%' : st_currency_default_format($entity->getValue());
}
?>
<?php if ($type == 'edit'): ?>
<script>
jQuery(function($) {
const fields = $('#discount_value, #discount_wholesale_value');
fields.change(function() {
const input = $(this);
let value = input.val();
value = stPrice.fixNumberFormat(value, $('#discount_price_type').val() == '<?php echo Discount::PERCENT_TYPE ?>' ? 0 : 2);
input.val(value);
if (input.is('#discount_value')) {
$('#discount_allow_anonymous_clients').prop('disabled', !input.prop('checked'));
}
}).change();
$('#discount_price_type').change(function() {
fields.change();
});
});
</script>
<?php endif ?>