$(document).ready(function () { var table = $('#logbook').DataTable({ "processing": true, "serverSide": true, "iDisplayLength": 20, "renderer": '', "ajax": { "url": "sort.php", "type": "POST", "data": function (d) { var filterParams = getFilterParams(); d.filterParams = JSON.stringify(filterParams); return d; } }, "order": [[2, 'desc']], "rowId": function (a) { return a.id; }, "language": { "lengthMenu": "", "searchPlaceholder": "Поиск...", "info": "Показано от _START_ до _END_ из _TOTAL_ записей", "infoFiltered": "(отфильтровано из _MAX_ записей)" }, "columns": [ { "width": "2%", "data": "id", "title": "

", "render": function (data, type, full, meta) { return "" + data; } }, { "width": "4%", "data": "goId", "defaultContent": "", "title": "

ГОиЧС

", }, { "width": "7%", "data": "date", "title": "

Дата и время получения информации

", "render": function (data) { var date = new Date(data); var formattedDate = date.toLocaleString('ru-RU', { year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric' }); return formattedDate; } }, { "width": "7%", "data": "partner", "title": "

Контрагент

" }, { "width": "7%", "data": "category", "title": "

Категория

" }, { "width": "7%", "data": "reason", "title": "

Причина отключения

" }, { "width": "8%", "data": "fromWho", "title": "

Должность, ФИО лица, от которого поступила информация

" }, { "width": "25%", "data": "description", "title": "
Краткое описание ЧС, (угрозы) проишествия (Классификация)
", }, { "width": "7%", "data": "dateToSend", "title": "

Дата и время отправки

", "render": function (data) { var date = new Date(data); var formattedDate = date.toLocaleString('ru-RU', { year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric' }); return formattedDate; } }, { "width": "7%", "data": "toWho", "title": "

Кому передана информация

" }, { "width": "6%", "data": "howSend", "title": "

Как передана информация

" }, { "width": "7%", "data": "position", "title": "

Должность, ФИО сотрудника ЦДС

" } ], }); $('#logbook thead .filter-icon').on('click', function (event) { var columnIndex = $(this).data('column-index'); var buttonPosition = $(this).offset(); var modal = $('#filterModal'); modal.attr('data-column-index', columnIndex); modal.css('top', buttonPosition.top + 'px'); modal.css('left', buttonPosition.left + 'px'); getUniqueColumnValues(columnIndex); }); // $('#logbook tbody').sortable({ // axis: 'y', // update: function (event, ui) { // var newOrder = $(this).sortable('toArray', { attribute: 'id' }); // console.log(newOrder); // console.log(newOrder); // $.ajax({ // type: 'POST', // url: 'update_order.php', // data: { newOrder: newOrder }, // success: function (response) { // }, // error: function () { // } // }); // } // }); var partnerOptions = query($sql); $partnerData = array(); if ($result && $result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $partnerData[] = array( 'id' => $row['id'], 'partner' => $row['partner'] ); } } echo json_encode($partnerData); ?>; var categoryOptions = query($sql); $categoryData = array(); if ($result && $result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $categoryData[] = array( 'id' => $row['id'], 'category' => $row['category'] ); } } echo json_encode($categoryData); ?>; var reasonOptions = query($sql); $partnerData = array(); if ($result && $result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $reasonData[] = array( 'id' => $row['id'], 'reason' => $row['reason'] ); } } echo json_encode($reasonData); ?>; $(document).ready(function () { $('#addRow').on('click', function () { console.log('Adding new row...'); var newRowData = { id: '', date: '', dateToSend: '', description: '', howSend: '', fromWho: '', toWho: '', partnerId: '', categoryId: '', reasonId: '', position: '', partner: '', category: '', reason: '' }; var newRow = table.row.add(newRowData).draw(false).node(); $(newRow).addClass('new-row'); $(newRow).find('td').eq(2).html(''); $(newRow).find('td').eq(3).html(''); $(newRow).find('td').eq(4).html(''); $(newRow).find('td').eq(5).html(''); $(newRow).find('td').eq(6).html(''); $(newRow).find('td').eq(7).html(''); $(newRow).find('td').eq(8).html(''); $(newRow).find('td').eq(9).html(''); $(newRow).find('td').eq(10).html(''); var partnerSelectHTML = ''; $(newRow).find('td').eq(8).html(partnerSelectHTML); var categorySelectHTML = ''; $(newRow).find('td').eq(9).html(categorySelectHTML); var reasonSelectHTML = ''; $(newRow).find('td').eq(10).html(reasonSelectHTML); $(newRow).find('td').eq(11).html(''); console.log('New row added:', newRow); }); });