Заказ товара '.($OrderData["name"] ?? '').' id='.$orderId.'</h3>
<p> ваша роль <b>'. ($users_group[$_SESSION["group_id"]] ?? '').'</b>
<span onclick="deleteAll();" class="btn btn-danger btn-sm me-2">очистить данные у этой закупки</span>
+<div style="float: right; margin: 20px;">
+<button class="btn btn-success btn-sm" onclick="htmlTableToExcel();">Экспорт таблицы в Excel документ</button>
+</div>
</p>';
echo'<div id=edit_div></div>';
if(!empty($store_id)) echo'<input type=hidden name=store_id_id value='.$store_id.' id=store_id_id>';
-echo'<div class="table-responsive mt-3"><table class="zak">';
+echo'<div class="table-responsive mt-3"><table id="shipmentTable" class="zak">';
$html='<thead><tr class="zg"><th class="text-right w-10">наименование
<span onclick="ajaxUpdateStoreZakup();" class="btn btn-blue btn-sm me-2">пересчитать данные</span>';
$_CONFIG["jscss"] ="<script>
+function htmlTableToExcel() {
+ const type = 'xlsx';
+ var data = document.getElementById('shipmentTable');
+ $.each(data.querySelectorAll('input'), (ind, x) => {
+ x.parentNode.textContent = x.value;
+ });
+ var excelFile = XLSX.utils.table_to_book(data, {sheet: 'sheet1'});
+ XLSX.write(excelFile, { bookType: type, bookSST: true, type: 'base64' });
+ moment.locale('ru');
+ XLSX.writeFile(excelFile, 'ShipmentTable_' + moment().format('L') + '.' + type);
+ window.location.reload();
+}
+
function ajaxUpdateStoreZakup(){
$('#modal-7 .modal-body').html('Считаем данные');
jQuery('#modal-7').modal('show', {backdrop: 'static'}); $('#modal-7 .modal-title').text('Обновляем данные');