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+
<h1>WhatsMasterCRM</h1>
|
4 |
+
</div>
|
5 |
+
<div>
|
6 |
+
<select id="filter-field">
|
7 |
+
<option></option>
|
8 |
+
<option value="id">Номер в списке</option>
|
9 |
+
<option value="name">Имя</option>
|
10 |
+
<option value="phone">WhatsApp</option>
|
11 |
+
<option value="email">Email</option>
|
12 |
+
<option value="b_mess">Реплики</option>
|
13 |
+
<option value="curator">Куратор</option>
|
14 |
+
<option value="shop_st">Статус покупки</option>
|
15 |
+
<option value="ad_url">Ссылка на пользователя в GC</option>
|
16 |
+
<option value="vk_id">Ссылка на VK</option>
|
17 |
+
<option value="chat_id">Ссылка на Tg</option>
|
18 |
+
<option value="ws_stop">Стутус подписки</option>
|
19 |
+
<option value="web_st">Вебинары</option>
|
20 |
+
<option value="fin_prog">Прогрес по воронке</option>
|
21 |
+
<option value="pr1">pr1</option>
|
22 |
+
<option value="pr2">pr2</option>
|
23 |
+
<option value="pr3">pr3</option>
|
24 |
+
<option value="pr4">Канал трафика</option>
|
25 |
+
<option value="pr5">Дата</option>
|
26 |
+
<option value="key_pr">Ключ PR</option>
|
27 |
+
<option value="canal">Канал</option>
|
28 |
+
<option value="data_t">Дата</option>
|
29 |
+
</select>
|
30 |
+
|
31 |
+
<select id="filter-type">
|
32 |
+
<option value="=">=</option>
|
33 |
+
<option value="<"><</option>
|
34 |
+
<option value="<="><=</option>
|
35 |
+
<option value=">">></option>
|
36 |
+
<option value=">=">>=</option>
|
37 |
+
<option value="!=">!=</option>
|
38 |
+
<option value="like">like</option>
|
39 |
+
</select>
|
40 |
+
|
41 |
+
<input id="filter-value" type="text" placeholder="Значение фильтра">
|
42 |
+
|
43 |
+
<button id="filter-clear">Очистить фильтр</button>
|
44 |
+
<button id="download-xlsx">Скачать в XLSX</button>
|
45 |
+
<button id="download-json">Рассылка по выбранным</button>
|
46 |
+
<button id="take-for-yourself">Взять себе</button> <!-- Добавлена вторая кнопка -->
|
47 |
+
</div>
|
48 |
+
<div id="example-table"></div>
|
49 |
+
|
50 |
+
<script>
|
51 |
+
vkBridge.send('VKWebAppInit');
|
52 |
+
document.addEventListener('DOMContentLoaded', function() {
|
53 |
+
fetch('https://irdelsol-psy.hf.space/data_gc_tab_out?api_sys=fasSd345D')
|
54 |
+
.then(response => response.json())
|
55 |
+
.then(data => {
|
56 |
+
console.log('Data received:', data); // Логирование данных
|
57 |
+
// Переворачиваем массив данных
|
58 |
+
data.reverse();
|
59 |
+
var linkFormatter = function(cell, formatterParams, onRendered) {
|
60 |
+
var curator = cell.getValue();
|
61 |
+
var curatorLink = cell.getData().curator_link;
|
62 |
+
return `<a href="${curatorLink}" target="_blank">${curator}</a>`;
|
63 |
+
};
|
64 |
+
var table = new Tabulator("#example-table", {
|
65 |
+
data: data, // set table data
|
66 |
+
layout: "fitColumns", // fit columns to width of table
|
67 |
+
pagination: "local", // enable local pagination
|
68 |
+
paginationSize: 50, // number of rows per page
|
69 |
+
selectable: true, // enable row selection
|
70 |
+
columns: [
|
71 |
+
{title:"Номер в списке", field:"id"},
|
72 |
+
{title:"Имя", field:"name", width:100},
|
73 |
+
{title:"WhatsApp", field:"phone", formatter: function(cell, formatterParams, onRendered) {
|
74 |
+
var phone = cell.getValue();
|
75 |
+
var ws_stop = cell.getData().ws_stop;
|
76 |
+
var ws_st = cell.getData().ws_st;
|
77 |
+
var imageUrl1 = "https://i.ibb.co/YBvwFR6/whatsapp-2.png"; // Замените на URL первой картинки
|
78 |
+
var imageUrl2 = "https://i.ibb.co/LZx71cM/1.png"; // Замените на URL второй картинки
|
79 |
+
var imageUrl3 = "https://i.ibb.co/Cvn3QsK/whatsapp-3.png"; // Замените на URL второй картинки
|
80 |
+
var link = `<a href="https://web.whatsapp.com/send?phone=${phone}" target="_blank">`;
|
81 |
+
// Проверка условий
|
82 |
+
if (ws_stop !== "1" && ws_st === "1") {
|
83 |
+
console.log("Первая переменная не равна единице, вторая равна единице");
|
84 |
+
return link + `<img src="${imageUrl2}" alt="WhatsApp" style="width: 98px; height: 14px;">`;
|
85 |
+
} else if (ws_stop === "1" && ws_st === "1") {
|
86 |
+
console.log("Обе переменные равны е��инице");
|
87 |
+
return link + `<img src="${imageUrl3}" alt="WhatsApp" style="width: 98px; height: 14px;">`;
|
88 |
+
} else {
|
89 |
+
console.log("Остальные случаи");
|
90 |
+
return link + `<img src="${imageUrl1}" alt="WhatsApp" style="width: 98px; height: 14px;">`;
|
91 |
+
}
|
92 |
+
}},
|
93 |
+
{title:"ВКонтакте", field:"vk_id", formatter: function(cell, formatterParams, onRendered) {
|
94 |
+
var vk_id = cell.getValue();
|
95 |
+
var imageUrlvk1 = "https://i.ibb.co/BKB8R4C/2-2.png"; // Замените на URL первой картинки
|
96 |
+
var imageUrlvk2 = "https://i.ibb.co/MPCGvQX/2-1.png"; // Замените на URL второй картинки
|
97 |
+
var link1 = `<a href="https://vk.com" target="_blank">`;
|
98 |
+
var link2 = `<a href="https://vk.com/id${vk_id}" target="_blank">`;
|
99 |
+
// Проверка условий
|
100 |
+
if (vk_id === "0" || vk_id === "") {
|
101 |
+
// Если vk_id равен "0" или пуст
|
102 |
+
return link1 + `<img src="${imageUrlvk1}" alt="Image" style="width: 98px; height: 14px;">`;
|
103 |
+
} else {
|
104 |
+
// Если vk_id не пуст и не равен "0"
|
105 |
+
return link2 + `<img src="${imageUrlvk2}" alt="Image" style="width: 98px; height: 14px;">`;
|
106 |
+
}
|
107 |
+
}},
|
108 |
+
{title:"Город", field:"b_city", width:95},
|
109 |
+
{title:"Email", field:"email", width:95},
|
110 |
+
{title:"Реплики", field:"b_mess", width:95, cellClick:function(e, cell){
|
111 |
+
var data = cell.getData();
|
112 |
+
const notyf = new Notyf({
|
113 |
+
duration: 5000,
|
114 |
+
position: {
|
115 |
+
x: 'right',
|
116 |
+
y: 'top',
|
117 |
+
},
|
118 |
+
});
|
119 |
+
// Формируем текст для уведомления
|
120 |
+
const message = `
|
121 |
+
Имя: ${data.name}\n
|
122 |
+
WhatsApp: ${data.phone}\n
|
123 |
+
Реплики: ${data.b_mess}
|
124 |
+
`;
|
125 |
+
// Показываем уведомление
|
126 |
+
notyf.open({
|
127 |
+
type: 'info',
|
128 |
+
message: message,
|
129 |
+
});
|
130 |
+
}},
|
131 |
+
{title:"Куратор", field:"curator", formatter: linkFormatter},
|
132 |
+
{title:"Статус покупки", field:"shop_st", formatter: function(cell, formatterParams, onRendered) {
|
133 |
+
var status = cell.getValue();
|
134 |
+
var color;
|
135 |
+
switch (status) {
|
136 |
+
case 'green':
|
137 |
+
color = 'green';
|
138 |
+
break;
|
139 |
+
case 'red':
|
140 |
+
color = 'red';
|
141 |
+
break;
|
142 |
+
case 'yellow':
|
143 |
+
color = 'yellow';
|
144 |
+
break;
|
145 |
+
default:
|
146 |
+
color = 'gray';
|
147 |
+
}
|
148 |
+
return `<div style="width: 20px; height: 20px; background-color: ${color};"></div>`;
|
149 |
+
}},
|
150 |
+
{title:"Ссылка на пользователя в GC", field:"ad_url", formatter: function(cell, formatterParams, onRendered) {
|
151 |
+
var ad_url = cell.getValue();
|
152 |
+
return `<a href="${ad_url}" target="_blank">${ad_url}</a>`;
|
153 |
+
}},
|
154 |
+
{title:"Ссылка на Tg", field:"chat_id", formatter: function(cell, formatterParams, onRendered) {
|
155 |
+
var chatId = cell.getValue();
|
156 |
+
if (chatId.startsWith('@')) {
|
157 |
+
chatId = chatId.substring(1); // Удаление символа @ в начале
|
158 |
+
}
|
159 |
+
return `<a href="https://t.me/${chatId}" target="_blank">${chatId}</a>`;
|
160 |
+
}},
|
161 |
+
{title:"Вебинары-присутствовал", field:"web_st", formatter:"star", formatterParams:{stars:7}, hozAlign:"center", width:90},
|
162 |
+
{title:"Вебинары-досмотрел до конца", field:"b_fin", formatter:function(cell, formatterParams, onRendered){
|
163 |
+
var value = cell.getValue();
|
164 |
+
var icon;
|
165 |
+
if (value === 'True') {
|
166 |
+
icon = ' <img src="https://i.ibb.co/9sqNhYz/4-2.png" width="98" height="14" />'; // Иконка для активного статуса
|
167 |
+
} else {
|
168 |
+
icon = ''; // Пустая строка для неактивного статуса или если значение не определено
|
169 |
+
}
|
170 |
+
return icon;
|
171 |
+
}},
|
172 |
+
{title:"Прогрес по воронке", field:"fin_prog", formatter:"progress", formatterParams:{color:["#ff0000", "orange", "#00dd00"]}, sorter:"number", width:100},
|
173 |
+
{title:"pr1", field:"pr1"},
|
174 |
+
{title:"pr2", field:"pr2"},
|
175 |
+
{title:"pr3", field:"pr3"},
|
176 |
+
{title:"Канал трафика", field:"pr4"},
|
177 |
+
{title:"Дата", field:"pr5"},
|
178 |
+
{title:"Ключ PR", field:"key_pr"},
|
179 |
+
{title:"Канал", field:"canal"},
|
180 |
+
{title:"Дата", field:"data_t", width:150}
|
181 |
+
],
|
182 |
+
});
|
183 |
+
|
184 |
+
var fieldEl = document.getElementById("filter-field");
|
185 |
+
var typeEl = document.getElementById("filter-type");
|
186 |
+
var valueEl = document.getElementById("filter-value");
|
187 |
+
function updateFilter() {
|
188 |
+
var filterVal1 = fieldEl.value;
|
189 |
+
var typeVal1 = typeEl.value;
|
190 |
+
var valueVal1 = valueEl.value;
|
191 |
+
table.setFilter([
|
192 |
+
{ field: filterVal1, type: typeVal1, value: valueVal1 }
|
193 |
+
]);
|
194 |
+
}
|
195 |
+
document.getElementById("filter-field").addEventListener("change", updateFilter);
|
196 |
+
document.getElementById("filter-type").addEventListener("change", updateFilter);
|
197 |
+
document.getElementById("filter-value").addEventListener("keyup", updateFilter);
|
198 |
+
document.getElementById("filter-clear").addEventListener("click", function() {
|
199 |
+
fieldEl.value = "";
|
200 |
+
typeEl.value = "=";
|
201 |
+
valueEl.value = "";
|
202 |
+
table.clearFilter();
|
203 |
+
});
|
204 |
+
document.getElementById("download-xlsx").addEventListener("click", function(){
|
205 |
+
table.download("xlsx", "data.xlsx", {sheetName:"My Data"});
|
206 |
+
});
|
207 |
+
function handleDownloadJson() {
|
208 |
+
var tableData = table.getData("active");
|
209 |
+
var jsonData = JSON.stringify(tableData, null, 2);
|
210 |
+
console.log("Данные для рассылки:", jsonData);
|
211 |
+
}
|
212 |
+
function handleTakeForYourself() {
|
213 |
+
var tableData = table.getData("active");
|
214 |
+
var jsonData = JSON.stringify(tableData, null, 2);
|
215 |
+
console.log("Данные для себя:", jsonData);
|
216 |
+
}
|
217 |
+
document.getElementById("download-json").addEventListener("click", handleDownloadJson);
|
218 |
+
document.getElementById("take-for-yourself").addEventListener("click", handleTakeForYourself);
|
219 |
+
})
|
220 |
+
.catch(error => console.error('Error fetching data:', error));
|
221 |
+
});
|
222 |
+
</script>
|
223 |
+
</body>
|