feat: Add Transport module with repository, controller, and views

- Implemented TransportRepository for managing transport data with methods for listing, finding, saving, and retrieving transport costs.
- Created ShopTransportController to handle transport-related actions, including listing, editing, and saving transports.
- Added views for transport management: transports list and transport edit forms.
- Introduced JavaScript for responsive tabs in transport edit view.
- Updated testing suite with comprehensive unit tests for TransportRepository and ShopTransportController.
- Increased test coverage with new assertions and scenarios for transport functionalities.
This commit is contained in:
2026-02-14 20:16:18 +01:00
parent 9c23e7f16b
commit 6543f8dc31
20 changed files with 1215 additions and 377 deletions

View File

@@ -0,0 +1,12 @@
<script type="text/javascript">
$(function() {
disable_menu();
$('#settings-tabs').easyResponsiveTabs({
width: 'auto',
fit: true,
tabidentify: 'settings-tabs',
type: 'vertical'
});
});
</script>

View File

@@ -1,139 +1,8 @@
<script type="text/javascript" src="/libraries/framework/vendor/plugins/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="/libraries/framework/vendor/plugins/ckeditor/adapters/jquery.js"></script>
<?
global $db;
$carrier_accounts[''] = '--- wybierz konto przewoźnika ---';
foreach ( $this -> apilo_carrier_account_list as $carrier_account )
{
$carrier_accounts[ $carrier_account['id'] ] = $carrier_account['name'];
}
ob_start();
?>
<div id="settings-tabs">
<ul class="resp-tabs-list settings-tabs">
<li><i class="fa fa-file"></i>Ogólne</li>
<li><i class="fa fa-wrench"></i>Powiązane metody płatności</li>
</ul>
<div class="resp-tabs-container settings-tabs">
<div>
<?= \Html::input(
array(
'label' => 'Nazwa',
'class' => 'require',
'name' => 'name',
'id' => 'name',
'readonly' => true,
'value' => $this -> transport_details['name']
)
);?>
<?= \Html::input(
array(
'label' => 'Nazwa widoczna',
'name' => 'name_visible',
'id' => 'name_visible',
'value' => $this -> transport_details['name_visible']
)
);?>
<?= \Html::input(
array(
'label' => 'Opis',
'name' => 'description',
'id' => 'description',
'value' => $this -> transport_details['description']
)
);?>
<?= \Html::input(
array(
'label' => 'Koszt (PLN)',
'class' => 'number-format require',
'name' => 'cost',
'id' => 'cost',
'value' => $this -> transport_details['cost']
)
);?>
<?= \Html::input(
array(
'label' => 'Maks. WP',
'class' => 'number-format require',
'name' => 'max_wp',
'id' => 'max_wp',
'value' => $this -> transport_details['max_wp']
)
);?>
<?= \Html::input_switch( [
'label' => 'Domyślna forma dostawy',
'name' => 'default',
'checked' => $this -> transport_details['default'] == 1 ? true : false
] );?>
<?= \Html::input_switch(
array(
'label' => 'Aktywny',
'name' => 'status',
'checked' => $this -> transport_details['status'] == 1 ? true : false
)
);?>
<?= \Html::input_switch( [
'label' => 'Darmowa dostawa',
'name' => 'delivery_free',
'checked' => $this -> transport_details['delivery_free'] == 1 ? true : false
] );?>
<?= \Html::select( [
'label' => 'Kurier z Apilo',
'name' => 'apilo_carrier_account_id',
'id' => 'apilo_carrier_account_id',
'values' => $carrier_accounts,
'value' => $this -> transport_details['apilo_carrier_account_id']
] );?>
</div>
<div>
<? if ( is_array( $this -> payments_list ) ): foreach ( $this -> payments_list as $payment_method ):?>
<div class="form-group">
<div class="col-lg-12">
<div class="list">
<input type="checkbox" class="g-checkbox" name="payment_methods[]" value="<?= $payment_method['id'];?>" <? if ( in_array( $payment_method['id'], $this -> transport_details['payment_methods'] ) ):?>checked="checked"<? endif;?> />
<span class="bold <? if ( !$payment_method['status'] ):?>text-muted<? endif;?>"><?= $payment_method['name'];?></span>
</div>
</div>
</div>
<? endforeach; endif;?>
</div>
</div>
</div>
<?
$out = ob_get_clean();
<?php
echo \Tpl::view('components/form-edit', [
'form' => $this->form,
]);
$grid = new \gridEdit;
$grid -> id = 'transport-edit';
$grid -> gdb_opt = $gdb;
$grid -> include_plugins = true;
$grid -> title = 'Edycja rodzaju transportu';
$grid -> fields = [
[
'db' => 'id',
'type' => 'hidden',
'value' => $this -> transport_details['id']
]
];
$grid -> actions = [
'save' => [ 'url' => '/admin/shop_transport/transport_save/', 'back_url' => '/admin/shop_transport/view_list/' ],
'cancel' => [ 'url' => '/admin/shop_transport/view_list/' ]
];
$grid -> external_code = $out;
$grid -> persist_edit = true;
$grid -> id_param = 'id';
echo $grid -> draw();
?>
<script type="text/javascript">
$( function()
{
disable_menu();
$( '#settings-tabs' ).easyResponsiveTabs({
width: 'auto',
fit: true,
tabidentify: 'settings-tabs',
type: 'vertical'
});
});
</script>
echo \Tpl::view('shop-transport/transport-edit-custom-script', [
'form' => $this->form,
]);

View File

@@ -0,0 +1 @@
<?= \Tpl::view('components/table-list', ['list' => $this->viewModel]); ?>

View File

@@ -1,71 +0,0 @@
<?php
global $gdb;
foreach ( $this -> apilo_carrier_account_list as $carrier_account )
{
$carrier_accounts[ $carrier_account['id'] ] = $carrier_account['name'];
}
$grid = new \grid( 'pp_shop_transports' );
$grid -> gdb_opt = $gdb;
$grid -> debug = true;
$grid -> order = [ 'column' => 'name', 'type' => 'ASC' ];
$grid -> search = [
[ 'name' => 'Nazwa', 'db' => 'name', 'type' => 'text' ],
[ 'name' => 'Aktywny', 'db' => 'status', 'type' => 'select', 'replace' => [ 'array' => [ 0 => 'nie', 1 => 'tak' ] ] ]
];
$grid -> columns_view = [
[
'name' => 'Lp.',
'th' => [ 'class' => 'g-lp' ],
'td' => [ 'class' => 'g-center' ],
'autoincrement' => true
], [
'name' => 'Domyślna FT',
'db' => 'default',
'replace' => [ 'array' => [ 0 => '<span style="color: #FF0000;">nie</span>', 1 => 'tak' ] ],
'td' => [ 'class' => 'g-center' ],
'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ],
'sort' => true
], [
'name' => 'Aktywny',
'db' => 'status',
'replace' => [ 'array' => [ 0 => '<span style="color: #FF0000;">nie</span>', 1 => 'tak' ] ],
'td' => [ 'class' => 'g-center' ],
'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ],
'sort' => true
],
[
'name' => 'Koszt',
'db' => 'cost',
'td' => [ 'class' => 'g-center' ],
'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ],
'php' => 'echo \\S::decimal( [cost] ) . " zł";',
'sort' => true
],
[
'name' => 'Maks. WP',
'db' => 'max_wp',
'td' => [ 'class' => 'g-center' ],
'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ],
'sort' => true
],
[
'name' => 'Nazwa',
'db' => 'name',
'sort' => true,
'php' => 'echo "<a href=\'/admin/shop_transport/transport_edit/id=[id]\'>[name]</a>";'
], [
'name' => 'Typ kuriera Apilo',
'db' => 'apilo_carrier_account_id',
'th' => [ 'class' => 'g-center' ],
'td' => [ 'class' => 'g-center' ],
'replace' => [ 'array' => $carrier_accounts ],
], [
'name' => 'Edytuj',
'action' => [ 'type' => 'edit', 'url' => '/admin/shop_transport/transport_edit/id=[id]' ],
'th' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
'td' => [ 'class' => 'g-center' ]
]
];
echo $grid -> draw();

View File

@@ -70,7 +70,7 @@
</a>
</li>
<li><a href="/admin/shop_attribute/view_list/"><img src="/admin/layout/icon/icon-menu/star-filled.svg">Cechy produkt&#243;w</a></li>
<li><a href="/admin/shop_transport/view_list/"><img src="/admin/layout/icon/icon-menu/bus.svg">Rodzaje transportu</a></li>
<li><a href="/admin/shop_transport/list/"><img src="/admin/layout/icon/icon-menu/bus.svg">Rodzaje transportu</a></li>
<li><a href="/admin/shop_payment_method/list/"><img src="/admin/layout/icon/icon-menu/coins-fill.svg">Metody p&#322;atno&#347;ci</a></li>
<li>
<a href="/admin/shop_statuses/list/"><i class="fa fa-bars"></i>Statusy zam&#243;wie&#324;</a>