Files
shopPRO/admin/templates/update/main-view.php
Jacek Pyziak a531fabeaf fix: changelog encoding (mojibake) + limit display to 5 versions back
Rebuilt changelog data from manifest JSON files to fix garbled Polish
characters. Converted changelog.php from static HTML to PHP script that
filters entries by instance version (?ver= parameter).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 13:46:09 +01:00

141 lines
4.6 KiB
PHP

<div class="panel">
<div class="panel-heading">
<span class="panel-title">Aktualizacja systemu</span>
</div>
<div class="panel-body">
<div class="form-group">
<label class="control-label col-lg-4">Twoja wersja systemu</label>
<div class="col-lg-8">
<p class="form-control-static"><?= $this->ver; ?></p>
</div>
</div>
<div class="form-group">
<label class="control-label col-lg-4">Aktualna wersja systemu</label>
<div class="col-lg-8">
<p class="form-control-static"><?= $this->new_ver; ?></p>
</div>
</div>
<div class="progress-box hidden">
<div class="version">
<h3>Aktualizacja <span class="version_curent">0</span> / <span class="version_diff">0</span></h3>
</div>
<div class="progress">
<div class="progress-bar progress-bar-info progress-bar-striped active" role="progressbar"
aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%">
</div>
</div>
</div>
<? if ( $this->ver < $this->new_ver ): ?>
<div class="row mt15">
<div class="form-group col-lg-6 text-right">
<a href="#" class="btn btn-system btn-sm mb5" id="confirm">Aktualizuj do wyższej wersji</a>
</div>
<div class="form-group col-lg-6">
<a href="#" class="btn btn-system btn-sm mb5" id="confirmUpdateAll">Aktualizuj do najwyższej wersji</a>
</div>
</div>
<div class="text-danger text-center">* Przed aktualizacją systemu zalecane jest wykonanie pełnej kopii zapasowej.</div>
<? endif; ?>
</div>
</div>
<? if ( !empty( $this->log ) ): ?>
<div class="panel">
<div class="panel-heading">
<span class="panel-title">Log ostatniej aktualizacji</span>
</div>
<div class="panel-body">
<pre style="max-height: 400px; overflow-y: auto; font-size: 12px;"><?= htmlspecialchars( $this->log ); ?></pre>
</div>
</div>
<? endif; ?>
<div class="panel">
<div class="panel-heading">
<span class="panel-title">Changelog</span>
</div>
<div class="panel-body">
<?= @file_get_contents( 'https://shoppro.project-dc.pl/updates/changelog.php?ver=' . $this->ver ); ?>
</div>
</div>
<script type="text/javascript">
$(function() {
var version_current = <?= $this->ver; ?>;
var version_new = <?= $this->new_ver; ?>;
var version_diff = Math.round( ( version_new - version_current ) * 1000 );
var width = 0;
var ac_lp = 0;
$( '#confirm' ).on( 'click', function( e ) {
e.preventDefault();
$.confirm({
title: 'Potwierdź',
content: 'Na pewno chcesz dokonać aktualizacji systemu?',
buttons: {
tak: function() {
document.location.href = '/admin/update/update/';
},
nie: function() {}
}
});
});
$( '#confirmUpdateAll' ).on( 'click', function( e ) {
e.preventDefault();
$.confirm({
title: 'Potwierdź',
content: 'Na pewno chcesz dokonać aktualizacji systemu do najwyższej wersji?',
buttons: {
tak: function() {
$( '.progress-box' ).removeClass( 'hidden' );
$( '#confirm' ).css( 'pointer-events', 'none' );
$( '#confirmUpdateAll' ).css( 'pointer-events', 'none' );
$( '.version_diff' ).html( version_diff );
updateAll( version_current, version_new, version_diff, width, ac_lp );
},
nie: function() {}
}
});
});
function updateAll( version_current, version_new, version_diff, width, ac_lp ) {
$.ajax({
url: '/admin/update/updateAll/',
type: 'POST',
data: { version_current: version_current },
success: function( data ) {
var response = jQuery.parseJSON( data );
if ( response.status == true ) {
ac_lp = ac_lp + 1;
$( '.version_curent' ).html( ac_lp );
width = width + ( ( 1 / version_diff ) * 100 );
$( '.progress-bar' ).css( 'width', width + '%' );
if ( response.version < version_new ) {
updateAll( response.version, version_new, version_diff, width, ac_lp );
} else {
$.alert({
title: 'Informacja',
content: 'Aktualizacja przebiegła pomyślnie.',
onClose: function() {
window.location.href = '/admin/update/main_view/';
}
});
}
} else {
$.alert({
title: 'Błąd',
content: 'W trakcie aktualizacji systemu wystąpił błąd. Proszę spróbować ponownie.',
onClose: function() {
window.location.href = '/admin/update/main_view/';
}
});
}
}
});
}
});
</script>