{% extends '@admin/default_frame.twig' %}
{% set menus = ['setting', 'system', 'migrate'] %}
{% block title %}データ移行{% endblock %}
{% block sub_title %}{% endblock %}
{% form_theme form '@admin/Form/bootstrap_4_horizontal_layout.html.twig' %}
{% block stylesheet %}
<style>
.icon-edit{
width: 20%;
text-align: center;
color: black;
}
.icon-edit i{
margin-right: 15px;
color: black;
cursor: pointer;
}
th,td{
padding: 10px !important;
}
.control-label{
font-weight: bold;
margin-bottom: 30px;
text-align: center;
}
form{
margin-top:30px;
}
.checkbox-inline{
margin-bottom: 15px;
}
.form-check-label{
margin-left: 10px;
}
.form-content{
border: 1px solid #ddd;
padding: 20px;
}
.col-auto{
text-align: center;
}
.btn-ec-migrate{
color: white !important;
}
#btnMigrate{
color: #fff;
background-color: #C04949;
}
</style>
{% endblock stylesheet %}
{% block javascript %}
<script>
$('a[data-bs-toggle="modal"]').click(function(){
if($('#backup_migrate_data input:checked').length == 0){
alert('データを選択してください。');
return false;
}
$('#migrateModal').modal();
$('#backup_mode').val($(this).data('mode'));
});
$('#btnMigrate').click(function(){
//$('.btn-ec-sub',$(this).closest('.modal')).remove();
$('.restore_alert').text('データ移行中。この処理には数分かかる場合があります。画面をリロードせずにこのままお待ち下さい。');
$form = $('#formMigrate');
$.ajax({
url: $form.attr('action'),
type: $form.attr('method'),
method: 'POST',
data: $form.serialize(),
dataType: 'json'
}).done(function(data) {
location.reload();
}).fail(function(data) {
alert('データ移行中にエラーが発生しました。');
}).always(function(data) {
});
});
</script>
{% endblock javascript %}
{% block main %}
<div class="container-fluid">
<div class="card rounded border-0 mb-4 d-block p-5">
<div class="card-body p-0">
<form id="formMigrate" method="post" action="{{ url('admin_setting_system_migrate') }}">
{{ form_widget(form._token) }}
<div class="form-group row">
<div class="col-sm-3 col-lg-3 offset-sm-5 form-content">
<h2 class="control-label">データ選択</h2>
{{ form_widget(form.migrate_data) }}
{{ form_errors(form.migrate_data) }}
{{ form_widget(form.mode) }}
{{ form_errors(form.mode) }}
</div>
</div>
</form>
<div class="text-center mt-5">
<a class="btn btn-ec-migrate btn-ec-conversion" type="button" id="btnMigratePtoT" data-mode="1" data-bs-toggle="modal" data-bs-target="#migrateModal">本番DBからテストDBにデータを移行</a>
<a class="btn btn-ec-migrate btn-ec-conversion" type="button" id="btnMigrateTtoP" data-mode="2" data-bs-toggle="modal" data-bs-target="#migrateModal">テストDBから本番DBにデータを移行</a>
</div>
</div>
</div>
<div class="modal fade" id="migrateModal" tabindex="-1" role="dialog" aria-labelledby="discontinuance" aria-hidden="true" data-keyboard="false" data-backdrop="static">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title fw-bold">データ移行</h5>
<button class="close" type="button" data-bs-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body text-left">
<p class="text-left restore_alert">移行先のデータは上書きされますがよろしいですか?</p>
</div>
<div class="modal-footer">
<button class="btn btn-ec-sub" type="button" data-bs-dismiss="modal">{{ 'admin.common.cancel'|trans }}</button>
<a class="btn btn-ec-action btn-ec-sub" type="button" id="btnMigrate">はい</a>
</div>
</div>
</div>
</div>
</div>
{% endblock %}