DmitrMakeev
commited on
Commit
•
008804b
1
Parent(s):
9f5ea82
Update data_gc_tab.html
Browse files- data_gc_tab.html +40 -30
data_gc_tab.html
CHANGED
@@ -122,7 +122,6 @@
|
|
122 |
|
123 |
</style>
|
124 |
</head>
|
125 |
-
<body>
|
126 |
<body>
|
127 |
<div id="header">
|
128 |
<h1>GetCurse - WhatsCRM</h1>
|
@@ -163,7 +162,8 @@
|
|
163 |
<input id="filter-value" type="text" placeholder="Значение фильтра">
|
164 |
|
165 |
<button id="filter-clear">Очистить фильтр</button>
|
166 |
-
|
|
|
167 |
</div>
|
168 |
<div id="example-table"></div>
|
169 |
|
@@ -173,21 +173,23 @@
|
|
173 |
.then(response => response.json())
|
174 |
.then(data => {
|
175 |
console.log('Data received:', data); // Логирование данных
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
var table = new Tabulator("#example-table", {
|
177 |
-
data: data,
|
178 |
-
layout: "fitColumns",
|
179 |
-
pagination: "local",
|
180 |
-
paginationSize: 50,
|
181 |
columns: [
|
182 |
{title:"Номер в списке", field:"id"},
|
183 |
{title:"Имя", field:"name"},
|
184 |
{title:"Телефон", field:"phone"},
|
185 |
{title:"Email", field:"email"},
|
186 |
-
{title:"Куратор", field:"curator", formatter:
|
187 |
-
var curator = cell.getValue();
|
188 |
-
var curatorLink = cell.getData().curator_link;
|
189 |
-
return <a href="${curatorLink}" target="_blank">${curator}</a>;
|
190 |
-
}},
|
191 |
{title:"Статус покупки", field:"shop_statys_full", formatter: function(cell, formatterParams, onRendered) {
|
192 |
var status = cell.getValue();
|
193 |
var color;
|
@@ -204,26 +206,26 @@
|
|
204 |
default:
|
205 |
color = 'gray';
|
206 |
}
|
207 |
-
return
|
208 |
}},
|
209 |
{title:"Ссылка на пользователя в GC", field:"ad_url", formatter: function(cell, formatterParams, onRendered) {
|
210 |
var ad_url = cell.getValue();
|
211 |
-
return
|
212 |
}},
|
213 |
{title:"Ссылка на VK", field:"vk_id", formatter: function(cell, formatterParams, onRendered) {
|
214 |
var vk_id = cell.getValue();
|
215 |
-
return
|
216 |
}},
|
217 |
{title:"Ссылка на Tg", field:"chat_id", formatter: function(cell, formatterParams, onRendered) {
|
218 |
var chatId = cell.getValue();
|
219 |
if (chatId.startsWith('@')) {
|
220 |
chatId = chatId.substring(1); // Удаление символа @ в начале
|
221 |
}
|
222 |
-
return
|
223 |
}},
|
224 |
{title:"Ссылка на WhatsApp", field:"phone", formatter: function(cell, formatterParams, onRendered) {
|
225 |
var phone = cell.getValue();
|
226 |
-
return
|
227 |
}},
|
228 |
{title:"Статус WhatsApp", field:"ws_statys"},
|
229 |
{title:"Стутус подписки", field:"ws_stop"},
|
@@ -236,39 +238,47 @@
|
|
236 |
{title:"utm_content", field:"pr5"}
|
237 |
],
|
238 |
});
|
239 |
-
//
|
240 |
var fieldEl = document.getElementById("filter-field");
|
241 |
var typeEl = document.getElementById("filter-type");
|
242 |
var valueEl = document.getElementById("filter-value");
|
|
|
|
|
243 |
function updateFilter() {
|
244 |
var filterVal = fieldEl.options[fieldEl.selectedIndex].value;
|
245 |
var typeVal = typeEl.options[typeEl.selectedIndex].value;
|
246 |
if (filterVal) {
|
247 |
table.setFilter(filterVal, typeVal, valueEl.value);
|
248 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
249 |
}
|
|
|
250 |
document.getElementById("filter-field").addEventListener("change", updateFilter);
|
251 |
document.getElementById("filter-type").addEventListener("change", updateFilter);
|
252 |
document.getElementById("filter-value").addEventListener("keyup", updateFilter);
|
|
|
253 |
document.getElementById("filter-clear").addEventListener("click", function() {
|
254 |
fieldEl.value = "";
|
255 |
typeEl.value = "=";
|
256 |
valueEl.value = "";
|
257 |
table.clearFilter();
|
258 |
});
|
259 |
-
//
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
a.click();
|
271 |
-
document.body.removeChild(a);
|
272 |
});
|
273 |
})
|
274 |
.catch(error => console.error('Error fetching data:', error));
|
|
|
122 |
|
123 |
</style>
|
124 |
</head>
|
|
|
125 |
<body>
|
126 |
<div id="header">
|
127 |
<h1>GetCurse - WhatsCRM</h1>
|
|
|
162 |
<input id="filter-value" type="text" placeholder="Значение фильтра">
|
163 |
|
164 |
<button id="filter-clear">Очистить фильтр</button>
|
165 |
+
|
166 |
+
<input type="checkbox" id="select-filtered-data-checkbox"> Выбрать отфильтрованные данные для экспорта
|
167 |
</div>
|
168 |
<div id="example-table"></div>
|
169 |
|
|
|
173 |
.then(response => response.json())
|
174 |
.then(data => {
|
175 |
console.log('Data received:', data); // Логирование данных
|
176 |
+
// Пользовательский форматтер для ссылки на куратора
|
177 |
+
var linkFormatter = function(cell, formatterParams, onRendered) {
|
178 |
+
var curator = cell.getValue();
|
179 |
+
var curatorLink = cell.getData().curator_link;
|
180 |
+
return `<a href="${curatorLink}" target="_blank">${curator}</a>`;
|
181 |
+
};
|
182 |
var table = new Tabulator("#example-table", {
|
183 |
+
data: data, // set table data
|
184 |
+
layout: "fitColumns", // fit columns to width of table
|
185 |
+
pagination: "local", // enable local pagination
|
186 |
+
paginationSize: 50, // number of rows per page
|
187 |
columns: [
|
188 |
{title:"Номер в списке", field:"id"},
|
189 |
{title:"Имя", field:"name"},
|
190 |
{title:"Телефон", field:"phone"},
|
191 |
{title:"Email", field:"email"},
|
192 |
+
{title:"Куратор", field:"curator", formatter: linkFormatter},
|
|
|
|
|
|
|
|
|
193 |
{title:"Статус покупки", field:"shop_statys_full", formatter: function(cell, formatterParams, onRendered) {
|
194 |
var status = cell.getValue();
|
195 |
var color;
|
|
|
206 |
default:
|
207 |
color = 'gray';
|
208 |
}
|
209 |
+
return `<div style="width: 20px; height: 20px; background-color: ${color};"></div>`;
|
210 |
}},
|
211 |
{title:"Ссылка на пользователя в GC", field:"ad_url", formatter: function(cell, formatterParams, onRendered) {
|
212 |
var ad_url = cell.getValue();
|
213 |
+
return `<a href="${ad_url}" target="_blank">${ad_url}</a>`;
|
214 |
}},
|
215 |
{title:"Ссылка на VK", field:"vk_id", formatter: function(cell, formatterParams, onRendered) {
|
216 |
var vk_id = cell.getValue();
|
217 |
+
return `<a href="https://vk.com/id${vk_id}" target="_blank">${vk_id}</a>`;
|
218 |
}},
|
219 |
{title:"Ссылка на Tg", field:"chat_id", formatter: function(cell, formatterParams, onRendered) {
|
220 |
var chatId = cell.getValue();
|
221 |
if (chatId.startsWith('@')) {
|
222 |
chatId = chatId.substring(1); // Удаление символа @ в начале
|
223 |
}
|
224 |
+
return `<a href="https://t.me/${chatId}" target="_blank">${chatId}</a>`;
|
225 |
}},
|
226 |
{title:"Ссылка на WhatsApp", field:"phone", formatter: function(cell, formatterParams, onRendered) {
|
227 |
var phone = cell.getValue();
|
228 |
+
return `<a href="https://web.whatsapp.com/send?phone=${phone}" target="_blank">${phone}</a>`;
|
229 |
}},
|
230 |
{title:"Статус WhatsApp", field:"ws_statys"},
|
231 |
{title:"Стутус подписки", field:"ws_stop"},
|
|
|
238 |
{title:"utm_content", field:"pr5"}
|
239 |
],
|
240 |
});
|
241 |
+
// Define variables for input elements
|
242 |
var fieldEl = document.getElementById("filter-field");
|
243 |
var typeEl = document.getElementById("filter-type");
|
244 |
var valueEl = document.getElementById("filter-value");
|
245 |
+
var selectFilteredDataCheckbox = document.getElementById("select-filtered-data-checkbox");
|
246 |
+
// Trigger setFilter function with correct parameters
|
247 |
function updateFilter() {
|
248 |
var filterVal = fieldEl.options[fieldEl.selectedIndex].value;
|
249 |
var typeVal = typeEl.options[typeEl.selectedIndex].value;
|
250 |
if (filterVal) {
|
251 |
table.setFilter(filterVal, typeVal, valueEl.value);
|
252 |
}
|
253 |
+
if (selectFilteredDataCheckbox.checked) {
|
254 |
+
var filteredData = table.getData("filtered");
|
255 |
+
var jsonData = JSON.stringify(filteredData);
|
256 |
+
window.filteredDataJSON = jsonData;
|
257 |
+
console.log("Отфильтрованные данные преобразованы в JSON:", jsonData);
|
258 |
+
}
|
259 |
}
|
260 |
+
// Update filters on value change
|
261 |
document.getElementById("filter-field").addEventListener("change", updateFilter);
|
262 |
document.getElementById("filter-type").addEventListener("change", updateFilter);
|
263 |
document.getElementById("filter-value").addEventListener("keyup", updateFilter);
|
264 |
+
// Clear filters on "Clear Filters" button click
|
265 |
document.getElementById("filter-clear").addEventListener("click", function() {
|
266 |
fieldEl.value = "";
|
267 |
typeEl.value = "=";
|
268 |
valueEl.value = "";
|
269 |
table.clearFilter();
|
270 |
});
|
271 |
+
// Handle checkbox change for exporting filtered data
|
272 |
+
selectFilteredDataCheckbox.addEventListener("change", function() {
|
273 |
+
if (this.checked) {
|
274 |
+
var filteredData = table.getData("filtered");
|
275 |
+
var jsonData = JSON.stringify(filteredData);
|
276 |
+
window.filteredDataJSON = jsonData;
|
277 |
+
console.log("Отфильтрованные данные преобразованы в JSON:", jsonData);
|
278 |
+
} else {
|
279 |
+
window.filteredDataJSON = null;
|
280 |
+
console.log("Выбор отфильтрованных данных для экспорта отменен");
|
281 |
+
}
|
|
|
|
|
282 |
});
|
283 |
})
|
284 |
.catch(error => console.error('Error fetching data:', error));
|