DmitrMakeev commited on
Commit
e882c31
1 Parent(s): 193a177

Update bas_vk_tab.html

Browse files
Files changed (1) hide show
  1. bas_vk_tab.html +167 -192
bas_vk_tab.html CHANGED
@@ -225,202 +225,177 @@ button:hover, #filter-clear:hover, #download-json:hover, #take-for-yourself:hove
225
  <button id="filter-clear">Очистить фильтр</button>
226
  <button id="download-xlsx">Скачать в XLSX</button>
227
  <button id="download-json">Рассылка по выбранным</button>
228
- <button id="take-for-yourself">Взять себе</button> <!-- Добавлена вторая кнопка -->
 
229
  </div>
230
  <div id="example-table"></div>
231
 
232
- <script>
233
- vkBridge.send('VKWebAppInit');
234
- document.addEventListener('DOMContentLoaded', function() {
235
- fetch('https://irdelsol-psy.hf.space/data_gc_tab_out?api_sys=fasSd345D')
236
- .then(response => response.json())
237
- .then(data => {
238
- console.log('Data received:', data); // Логирование данных
239
- // Переворачиваем массив данных
240
- data.reverse();
241
- var linkFormatter = function(cell, formatterParams, onRendered) {
242
- var curator = cell.getValue();
243
- var curatorLink = cell.getData().curator_link;
244
- return `<a href="${curatorLink}" target="_blank">${curator}</a>`;
245
- };
246
- var table = new Tabulator("#example-table", {
247
- data: data, // set table data
248
- layout: "fitColumns", // fit columns to width of table
249
- pagination: "local", // enable local pagination
250
- paginationSize: 50, // number of rows per page
251
- selectable: true, // enable row selection
252
- columns: [
253
- {title:"Номер в списке", field:"id"},
254
- {title:"Имя", field:"name", width:100},
255
- {title:"WhatsApp", field:"phone", formatter: function(cell, formatterParams, onRendered) {
256
- var phone = cell.getValue();
257
- var ws_stop = cell.getData().ws_stop;
258
- var ws_st = cell.getData().ws_st;
259
- var imageUrl1 = "https://i.ibb.co/YBvwFR6/whatsapp-2.png"; // Замените на URL первой картинки
260
- var imageUrl2 = "https://i.ibb.co/LZx71cM/1.png"; // Замените на URL второй картинки
261
- var imageUrl3 = "https://i.ibb.co/Cvn3QsK/whatsapp-3.png"; // Замените на URL второй картинки
262
- var link = `<a href="https://web.whatsapp.com/send?phone=${phone}" target="_blank">`;
263
- // Проверка условий
264
- if (ws_stop !== "1" && ws_st === "1") {
265
- console.log("Первая переменная не равна единице, вторая равна единице");
266
- return link + `<img src="${imageUrl2}" alt="WhatsApp" style="width: 98px; height: 14px;">`;
267
- } else if (ws_stop === "1" && ws_st === "1") {
268
- console.log("Обе переменные равны единице");
269
- return link + `<img src="${imageUrl3}" alt="WhatsApp" style="width: 98px; height: 14px;">`;
270
- } else {
271
- console.log("Остальные случаи");
272
- return link + `<img src="${imageUrl1}" alt="WhatsApp" style="width: 98px; height: 14px;">`;
273
- }
274
- }},
275
- {title:"ВКонтакте", field:"vk_id", formatter: function(cell, formatterParams, onRendered) {
276
- var vk_id = cell.getValue();
277
- var imageUrlvk1 = "https://i.ibb.co/BKB8R4C/2-2.png"; // Замените на URL первой картинки
278
- var imageUrlvk2 = "https://i.ibb.co/MPCGvQX/2-1.png"; // Замените на URL второй картинки
279
- var link1 = `<a href="https://vk.com" target="_blank">`;
280
- var link2 = `<a href="https://vk.com/id${vk_id}" target="_blank">`;
281
- // Проверка условий
282
- if (vk_id === "0" || vk_id === "") {
283
- // Если vk_id равен "0" или пуст
284
- return link1 + `<img src="${imageUrlvk1}" alt="Image" style="width: 98px; height: 14px;">`;
285
- } else {
286
- // Если vk_id не пуст и не равен "0"
287
- return link2 + `<img src="${imageUrlvk2}" alt="Image" style="width: 98px; height: 14px;">`;
288
- }
289
- }},
290
- {title:"Телеграм", field:"chat_id", formatter: function(cell, formatterParams, onRendered) {
291
- var chat_id = cell.getValue();
292
- var imageUrltg1 = "https://i.ibb.co/3S4Wt7m/3-2.png"; // Замените на URL первой картинки
293
- var imageUrlntg2 = "https://i.ibb.co/rZrzQhb/3-1.png"; // Замените на URL второй картинки
294
- var linktg1 = `<a href="https://t.me" target="_blank">`;
295
- var linktg2 = `<a href="https://t.me/${chat_id}" target="_blank">`;
296
- // Проверка условий
297
- if (chat_id === "0" || chat_id === "") {
298
- // Если равен "0" или пуст
299
- return linktg1 + `<img src="${imageUrltg1}" alt="Image" style="width: 98px; height: 14px;">`;
300
- } else {
301
- // Если не пуст и не равен "0"
302
- return linktg2 + `<img src="${imageUrlntg2}" alt="Image" style="width: 98px; height: 14px;">`;
303
- }
304
- }},
305
- {title:"GetCurse", field:"gc_url", formatter: function(cell, formatterParams, onRendered) {
306
- var gc_url = cell.getValue();
307
- var imageUrlvkgc1 = "https://i.ibb.co/F8825KY/1-2.png"; // Замените на URL первой картинки
308
- var imageUrlvkgc2 = "https://i.ibb.co/S3qwFKM/1-1.png"; // Замените на URL второй картинки
309
- var linkgc1 = `<a href="https://vk.com/getcourseru" target="_blank">`;
310
- var linkgc2 = `<a href="${gc_url}" target="_blank">`;
311
- // Проверка условий
312
- if (gc_url === "0" || gc_url === "") {
313
- // Если равен "0" или пуст
314
- return linkgc1 + `<img src="${imageUrlvkgc1}" alt="Image" style="width: 98px; height: 14px;">`;
315
- } else {
316
- // Если не пуст и не равен "0"
317
- return linkgc2 + `<img src="${imageUrlvkgc2}" alt="Image" style="width: 98px; height: 14px;">`;
318
- }
319
- }},
320
- {title:"Город", field:"b_city", width:95},
321
- {title:"Email", field:"email", width:95},
322
- {title:"Реплики", field:"b_mess", width:95, cellClick:function(e, cell){
323
- var data = cell.getData();
324
- const notyf = new Notyf({
325
- duration: 5000,
326
- position: {
327
- x: 'right',
328
- y: 'top',
329
- },
330
- });
331
- // Формируем текст для уведомления
332
- const message = `
333
- Имя: ${data.name}\n
334
- WhatsApp: ${data.phone}\n
335
- Реплики: ${data.b_mess}
336
- `;
337
- // Показываем уведомление
338
- notyf.open({
339
- type: 'info',
340
- message: message,
341
- });
342
- }},
343
- {title:"Куратор", field:"curator", formatter: linkFormatter},
344
- {title:"Статус покупки", field:"shop_st", formatter: function(cell, formatterParams, onRendered) {
345
- var status = cell.getValue();
346
- var color;
347
- switch (status) {
348
- case 'green':
349
- color = 'green';
350
- break;
351
- case 'red':
352
- color = 'red';
353
- break;
354
- case 'yellow':
355
- color = 'yellow';
356
- break;
357
- default:
358
- color = 'gray';
359
- }
360
- return `<div style="width: 20px; height: 20px; background-color: ${color};"></div>`;
361
- }},
362
- {title:"Вебинары-пр��сутствовал", field:"web_st", formatter:"star", formatterParams:{stars:7}, hozAlign:"center", width:90},
363
- {title:"Вебинары-досмотрел до конца", field:"b_fin", formatter:function(cell, formatterParams, onRendered){
364
- var value = cell.getValue();
365
- var icon;
366
- if (value === 'True') {
367
- icon = ' <img src="https://i.ibb.co/9sqNhYz/4-2.png" width="98" height="14" />'; // Иконка для активного статуса
368
- } else {
369
- icon = ''; // Пустая строка для неактивного статуса или если значение не определено
370
- }
371
- return icon;
372
- }},
373
- {title:"Прогрес по воронке", field:"fin_prog", formatter:"progress", formatterParams:{color:["#ff0000", "orange", "#00dd00"]}, sorter:"number", width:100},
374
- {title:"pr1", field:"pr1"},
375
- {title:"pr2", field:"pr2"},
376
- {title:"pr3", field:"pr3"},
377
- {title:"Канал трафика", field:"pr4"},
378
- {title:"Дата", field:"pr5"},
379
- {title:"Ключ PR", field:"key_pr"},
380
- {title:"Канал", field:"canal"},
381
- {title:"Дата", field:"data_t", width:150}
382
- ],
 
 
 
 
 
 
 
 
 
 
 
383
  });
384
-
385
- var fieldEl = document.getElementById("filter-field");
386
- var typeEl = document.getElementById("filter-type");
387
- var valueEl = document.getElementById("filter-value");
388
- function updateFilter() {
389
- var filterVal1 = fieldEl.value;
390
- var typeVal1 = typeEl.value;
391
- var valueVal1 = valueEl.value;
392
- table.setFilter([
393
- { field: filterVal1, type: typeVal1, value: valueVal1 }
394
- ]);
395
- }
396
- document.getElementById("filter-field").addEventListener("change", updateFilter);
397
- document.getElementById("filter-type").addEventListener("change", updateFilter);
398
- document.getElementById("filter-value").addEventListener("keyup", updateFilter);
399
- document.getElementById("filter-clear").addEventListener("click", function() {
400
- fieldEl.value = "";
401
- typeEl.value = "=";
402
- valueEl.value = "";
403
- table.clearFilter();
404
- });
405
- document.getElementById("download-xlsx").addEventListener("click", function(){
406
- table.download("xlsx", "data.xlsx", {sheetName:"My Data"});
407
- });
408
- function handleDownloadJson() {
409
- var tableData = table.getData("active");
410
- var jsonData = JSON.stringify(tableData, null, 2);
411
- console.log("Данные для рассылки:", jsonData);
412
- }
413
- function handleTakeForYourself() {
414
- var tableData = table.getData("active");
415
- var jsonData = JSON.stringify(tableData, null, 2);
416
- console.log("Данные для себя:", jsonData);
417
- }
418
- document.getElementById("download-json").addEventListener("click", handleDownloadJson);
419
- document.getElementById("take-for-yourself").addEventListener("click", handleTakeForYourself);
420
- })
421
- .catch(error => console.error('Error fetching data:', error));
422
- });
423
- </script>
424
  </body>
425
 
 
426
  </html>
 
225
  <button id="filter-clear">Очистить фильтр</button>
226
  <button id="download-xlsx">Скачать в XLSX</button>
227
  <button id="download-json">Рассылка по выбранным</button>
228
+ <button id="take-for-yourself">Взять себе</button>
229
+ <button id="download-csv">Скачать CSV</button> <!-- Добавлена кнопка для скачивания CSV -->
230
  </div>
231
  <div id="example-table"></div>
232
 
233
+ <script>
234
+ vkBridge.send('VKWebAppInit');
235
+ document.addEventListener('DOMContentLoaded', function() {
236
+ fetch('https://irdelsol-psy.hf.space/data_gc_tab_out?api_sys=fasSd345D')
237
+ .then(response => response.json())
238
+ .then(data => {
239
+ console.log('Data received:', data);
240
+ data.reverse();
241
+
242
+ var linkFormatter = function(cell, formatterParams, onRendered) {
243
+ var curator = cell.getValue();
244
+ var curatorLink = cell.getData().curator_link;
245
+ return `<a href="${curatorLink}" target="_blank">${curator}</a>`;
246
+ };
247
+
248
+ var table = new Tabulator("#example-table", {
249
+ data: data,
250
+ layout: "fitColumns",
251
+ pagination: "local",
252
+ paginationSize: 50,
253
+ selectable: true,
254
+ columns: [
255
+ {title:"Номер в списке", field:"id"},
256
+ {title:"Имя", field:"name", width:100},
257
+ {title:"WhatsApp", field:"phone", formatter: function(cell, formatterParams, onRendered) {
258
+ var phone = cell.getValue();
259
+ var ws_stop = cell.getData().ws_stop;
260
+ var ws_st = cell.getData().ws_st;
261
+ var imageUrl1 = "https://i.ibb.co/YBvwFR6/whatsapp-2.png";
262
+ var imageUrl2 = "https://i.ibb.co/LZx71cM/1.png";
263
+ var imageUrl3 = "https://i.ibb.co/Cvn3QsK/whatsapp-3.png";
264
+ var link = `<a href="https://web.whatsapp.com/send?phone=${phone}" target="_blank">`;
265
+ if (ws_stop !== "1" && ws_st === "1") {
266
+ return link + `<img src="${imageUrl2}" alt="WhatsApp" style="width: 98px; height: 14px;">`;
267
+ } else if (ws_stop === "1" && ws_st === "1") {
268
+ return link + `<img src="${imageUrl3}" alt="WhatsApp" style="width: 98px; height: 14px;">`;
269
+ } else {
270
+ return link + `<img src="${imageUrl1}" alt="WhatsApp" style="width: 98px; height: 14px;">`;
271
+ }
272
+ }},
273
+ {title:"ВКонтакте", field:"vk_id", formatter: function(cell, formatterParams, onRendered) {
274
+ var vk_id = cell.getValue();
275
+ var imageUrlvk1 = "https://i.ibb.co/BKB8R4C/2-2.png";
276
+ var imageUrlvk2 = "https://i.ibb.co/MPCGvQX/2-1.png";
277
+ var link1 = `<a href="https://vk.com" target="_blank">`;
278
+ var link2 = `<a href="https://vk.com/id${vk_id}" target="_blank">`;
279
+ if (vk_id === "0" || vk_id === "") {
280
+ return link1 + `<img src="${imageUrlvk1}" alt="Image" style="width: 98px; height: 14px;">`;
281
+ } else {
282
+ return link2 + `<img src="${imageUrlvk2}" alt="Image" style="width: 98px; height: 14px;">`;
283
+ }
284
+ }},
285
+ {title:"Телеграм", field:"chat_id", formatter: function(cell, formatterParams, onRendered) {
286
+ var chat_id = cell.getValue();
287
+ var imageUrltg1 = "https://i.ibb.co/3S4Wt7m/3-2.png";
288
+ var imageUrlntg2 = "https://i.ibb.co/rZrzQhb/3-1.png";
289
+ var linktg1 = `<a href="https://t.me" target="_blank">`;
290
+ var linktg2 = `<a href="https://t.me/${chat_id}" target="_blank">`;
291
+ if (chat_id === "0" || chat_id === "") {
292
+ return linktg1 + `<img src="${imageUrltg1}" alt="Image" style="width: 98px; height: 14px;">`;
293
+ } else {
294
+ return linktg2 + `<img src="${imageUrlntg2}" alt="Image" style="width: 98px; height: 14px;">`;
295
+ }
296
+ }},
297
+ {title:"GetCurse", field:"gc_url", formatter: function(cell, formatterParams, onRendered) {
298
+ var gc_url = cell.getValue();
299
+ var imageUrlvkgc1 = "https://i.ibb.co/F8825KY/1-2.png";
300
+ var imageUrlvkgc2 = "https://i.ibb.co/S3qwFKM/1-1.png";
301
+ var linkgc1 = `<a href="https://vk.com/getcourseru" target="_blank">`;
302
+ var linkgc2 = `<a href="${gc_url}" target="_blank">`;
303
+ if (gc_url === "0" || gc_url === "") {
304
+ return linkgc1 + `<img src="${imageUrlvkgc1}" alt="Image" style="width: 98px; height: 14px;">`;
305
+ } else {
306
+ return linkgc2 + `<img src="${imageUrlvkgc2}" alt="Image" style="width: 98px; height: 14px;">`;
307
+ }
308
+ }},
309
+ {title:"Город", field:"b_city", width:95},
310
+ {title:"Email", field:"email", width:95},
311
+ {title:"Реплики", field:"b_mess", width:95, cellClick:function(e, cell){
312
+ var data = cell.getData();
313
+ const notyf = new Notyf({
314
+ duration: 5000,
315
+ position: {
316
+ x: 'right',
317
+ y: 'top',
318
+ },
319
+ });
320
+ const message = `
321
+ Имя: ${data.name}\n
322
+ WhatsApp: ${data.phone}\n
323
+ Реплики: ${data.b_mess}
324
+ `;
325
+ notyf.open({
326
+ type: 'info',
327
+ message: message,
328
+ });
329
+ }},
330
+ {title:"Куратор", field:"curator", formatter: linkFormatter},
331
+ {title:"Статус покупки", field:"shop_st", formatter: function(cell, formatterParams, onRendered) {
332
+ var status = cell.getValue();
333
+ var color;
334
+ switch (status) {
335
+ case 'green':
336
+ color = 'green';
337
+ break;
338
+ case 'red':
339
+ color = 'red';
340
+ break;
341
+ case 'yellow':
342
+ color = 'yellow';
343
+ break;
344
+ default:
345
+ color = 'gray';
346
+ }
347
+ return `<div style="width: 20px; height: 20px; background-color: ${color}; border-radius: 50%;"></div>`;
348
+ }},
349
+ {title:"Канал трафика", field:"pr4", width:95},
350
+ {title:"Дата", field:"pr5", width:95},
351
+ {title:"Ключ PR", field:"key_pr", width:95},
352
+ {title:"Канал", field:"canal", width:95},
353
+ {title:"Дата", field:"data_t", width:95},
354
+ ],
355
+ });
356
+
357
+ // Clear filter
358
+ document.getElementById('filter-clear').addEventListener('click', function() {
359
+ table.clearFilter(true);
360
+ });
361
+
362
+ // Download XLSX functionality
363
+ document.getElementById('download-xlsx').addEventListener('click', function() {
364
+ table.download("xlsx", "data.xlsx");
365
+ });
366
+
367
+ // Download JSON functionality
368
+ document.getElementById('download-json').addEventListener('click', function() {
369
+ var selectedRows = table.getSelectedData();
370
+ var jsonData = JSON.stringify(selectedRows);
371
+ var blob = new Blob([jsonData], { type: 'application/json' });
372
+ var url = URL.createObjectURL(blob);
373
+ var a = document.createElement('a');
374
+ a.href = url;
375
+ a.download = 'data.json';
376
+ document.body.appendChild(a);
377
+ a.click();
378
+ URL.revokeObjectURL(url);
379
+ });
380
+
381
+ // Download CSV functionality
382
+ document.getElementById('download-csv').addEventListener('click', function() {
383
+ table.download("csv", "data.csv");
384
+ });
385
+
386
+ // Take for yourself functionality
387
+ document.getElementById('take-for-yourself').addEventListener('click', function() {
388
+ var selectedRows = table.getSelectedData();
389
+ // Your logic to handle selected rows
390
+ console.log('Selected rows:', selectedRows);
391
+ });
392
+ })
393
+ .catch(error => {
394
+ console.error('Ошибка при загрузке JSON:', error);
395
  });
396
+ });
397
+ </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
398
  </body>
399
 
400
+
401
  </html>