Enhance product management and coupon features

- Added styling for input group add-ons and additional fields in SCSS.
- Updated shop coupon view to include a new column for usage count.
- Display coupon code and amount in order details if applicable.
- Improved product edit template to handle custom fields with required validation.
- Modified product save logic to include custom field requirements.
- Enhanced decimal normalization function for better input handling.
- Implemented checkbox normalization for form submissions.
- Updated custom fields in product templates to reflect required status.
- Fixed URL for fetching changelog updates.
This commit is contained in:
2025-08-19 20:35:24 +02:00
parent 325aabc0e8
commit 4897ef132a
16 changed files with 172 additions and 57 deletions

View File

@@ -12,11 +12,11 @@ $grid -> search = [
[ 'name' => 'Wysłany', 'db' => 'send', 'type' => 'select', 'replace' => [ 'array' => [ 0 => 'nie', 1 => 'tak' ] ] ]
];
$grid -> columns_view = [
[
[
'name' => 'Lp.',
'th' => [ 'class' => 'g-lp' ],
'td' => [ 'class' => 'g-center' ],
'autoincrement' => true
'autoincrement' => true
], [
'name' => 'Aktywny',
'db' => 'status',
@@ -24,6 +24,11 @@ $grid -> columns_view = [
'td' => [ 'class' => 'g-center' ],
'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ],
'sort' => true
], [
'name' => 'Użyto X razy',
'db' => 'used_count',
'td' => [ 'class' => 'g-center' ],
'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ],
], [
'name' => 'Nazwa',
'db' => 'name',
@@ -60,22 +65,22 @@ $grid -> columns_view = [
'db' => 'date_used',
'td' => [ 'class' => 'g-center' ],
'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ]
], [
'name' => 'Edytuj',
'action' => [ 'type' => 'edit', 'url' => '/admin/shop_coupon/coupon_edit/id=[id]' ],
], [
'name' => 'Edytuj',
'action' => [ 'type' => 'edit', 'url' => '/admin/shop_coupon/coupon_edit/id=[id]' ],
'th' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
'td' => [ 'class' => 'g-center' ]
], [
'name' => 'Usuń',
'action' => [ 'type' => 'delete', 'url' => '/admin/shop_coupon/coupon_delete/id=[id]' ],
], [
'name' => 'Usuń',
'action' => [ 'type' => 'delete', 'url' => '/admin/shop_coupon/coupon_delete/id=[id]' ],
'th' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
'td' => [ 'class' => 'g-center' ]
]
];
$grid -> buttons = [
[
'label' => 'Dodaj kupon',
'url' => '/admin/shop_coupon/coupon_edit/',
[
'label' => 'Dodaj kupon',
'url' => '/admin/shop_coupon/coupon_edit/',
'icon' => 'fa-plus-circle',
'class' => 'btn-success'
]

View File

@@ -44,6 +44,9 @@ ob_start();
<div class="panel">
<div class="panel-body">
<div>Kwota zamówienia <b><?= $this -> order[ 'summary' ];?> zł</b></div>
<? if ( $this -> coupon ):?>
<div>Kod rabatowy: <span style="color: #cc0000;"><?= $this -> coupon -> name;?> - <?= $this -> coupon -> amount;?> <?= $this -> coupon -> type == 1 ? '%' : 'zł';?></span></div>
<? endif;?>
<br>
<div><?= strip_tags( $this -> order[ 'transport' ] );?>: <b><?= $this -> order[ 'transport_cost' ];?> zł</b></div>
<? if ( $this -> order['transport_id'] == 2 and $this -> order[ 'inpost_paczkomat' ] ):?>

View File

@@ -663,12 +663,19 @@ ob_start();
<div>
<a href="#" class="btn btn-success" id="add_custom_field"><i class="fa fa-plus"></i> dodaj niestandardowe pole</a>
<div class="additional_fields">
<? if ( is_array( $this -> product['custom_fields'] ) ) : foreach ( $this -> product['custom_fields'] as $field ):?>
<div class="form-group row">
<? if ( is_array( $this->product['custom_fields'] ) ) : foreach ( $this->product['custom_fields'] as $field ):?>
<? $isRequired = !empty($field['is_required']); ?>
<div class="form-group row custom-field-row">
<label class="col-lg-4 control-label">Nazwa pola:</label>
<div class="col-lg-8">
<div class="input-group">
<input type="text" class="form-control" name="custom_field_name[]" value="<?= $field['name']; ?>">
<input type="text" class="form-control" name="custom_field_name[]" value="<?= htmlspecialchars($field['name']); ?>">
<span class="input-group-addon">
<label style="margin:0; font-weight:normal;">
<input type="checkbox" class="custom-field-required" <?= $isRequired ? 'checked' : '' ?> name="custom_field_required[]" />
wymagane
</label>
</span>
<span class="input-group-addon btn btn-info" onclick="remove_custom_filed( $( this ) );">usuń</span>
</div>
</div>
@@ -740,17 +747,23 @@ echo $grid->draw();
$(function() {
$( 'body' ).on( 'click', '#add_custom_field', function() {
$('body').on('click', '#add_custom_field', function() {
var html = '';
html += '<div class="form-group row">';
html += '<div class="form-group row custom-field-row">';
html += '<label class="col-lg-4 control-label">Nazwa pola:</label>';
html += '<div class="col-lg-8">';
html +='<div class="input-group">';
html += '<div class="input-group">';
html += '<input type="text" class="form-control" name="custom_field_name[]" value="">';
html += '<span class="input-group-addon">';
html += '<label style="margin:0; font-weight:normal;">';
html += '<input type="checkbox" class="custom-field-required" name="custom_field_required[]"> wymagane';
html += '</label>';
html += '</span>';
html += '<span class="input-group-addon btn btn-info" onclick="remove_custom_filed( $( this ) );">usuń</span>';
html += '</div>';
html += '</div>';
html += '</div>';
$( '.additional_fields' ).append( html );
$('.additional_fields').append(html);
});
$('body').on('click', '#product-preview', function() {

View File

@@ -64,7 +64,7 @@ echo $grid -> draw();
?>
<?
ob_start();
echo $versions = file_get_contents( 'https://shoppro.project-dc.pl/updates/changelog.php' );
echo $versions = file_get_contents( 'http://www.shoppro.project-dc.pl/updates/changelog.php' );
$out = ob_get_clean();
$grid = new \gridEdit;