mirror of
https://github.com/wasrusgen/zashita-brandbook.git
synced 2026-06-03 17:44:47 +00:00
feat: contact collection with consent, SQLite on VPS, phone/Telegram in reminder picker
This commit is contained in:
parent
8595a0ca16
commit
65bce5a642
47
mockup.html
47
mockup.html
@ -8182,6 +8182,9 @@ function _showReminderPicker(doc, contractType, intent) {
|
|||||||
{ label: 'Через неделю', val: _dateOffset(7, 9) },
|
{ label: 'Через неделю', val: _dateOffset(7, 9) },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
var savedContact = '';
|
||||||
|
try { var b2b = JSON.parse(localStorage.getItem('zashita_b2b')||'null'); if(b2b&&b2b.phone) savedContact=b2b.phone; } catch(e){}
|
||||||
|
|
||||||
var div = document.createElement('div');
|
var div = document.createElement('div');
|
||||||
div.className = 'hc-msg hc-elena';
|
div.className = 'hc-msg hc-elena';
|
||||||
div.innerHTML =
|
div.innerHTML =
|
||||||
@ -8190,6 +8193,17 @@ function _showReminderPicker(doc, contractType, intent) {
|
|||||||
'<div style="font-size:13px;margin-bottom:10px">' +
|
'<div style="font-size:13px;margin-bottom:10px">' +
|
||||||
'Хорошо! Когда напомнить загрузить <b>' + doc.label + '</b>?' +
|
'Хорошо! Когда напомнить загрузить <b>' + doc.label + '</b>?' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
|
// Поле контакта
|
||||||
|
'<div style="margin-bottom:12px;padding:10px;background:#f0f9ff;border-radius:8px">' +
|
||||||
|
'<div style="font-size:12px;font-weight:600;margin-bottom:6px">📲 Куда прислать напоминание?</div>' +
|
||||||
|
'<input id="reminder-contact" class="elena-main-inp" placeholder="Телефон +7... или Telegram @username" ' +
|
||||||
|
'value="' + savedContact + '" style="font-size:12px;margin-bottom:6px">' +
|
||||||
|
'<label style="display:flex;align-items:flex-start;gap:6px;font-size:11px;color:var(--mut);cursor:pointer">' +
|
||||||
|
'<input type="checkbox" id="reminder-consent" style="margin-top:2px;width:13px;height:13px" checked>' +
|
||||||
|
'Согласен на обработку персональных данных в соответствии с ' +
|
||||||
|
'<a href="privacy.html" target="_blank" style="color:var(--bg)">Политикой конфиденциальности</a>' +
|
||||||
|
'</label>' +
|
||||||
|
'</div>' +
|
||||||
'<div style="display:flex;flex-direction:column;gap:6px">' +
|
'<div style="display:flex;flex-direction:column;gap:6px">' +
|
||||||
dates.map(function(d){
|
dates.map(function(d){
|
||||||
return '<button style="text-align:left;padding:8px 12px;border:1.5px solid var(--line);' +
|
return '<button style="text-align:left;padding:8px 12px;border:1.5px solid var(--line);' +
|
||||||
@ -8226,7 +8240,6 @@ function _formatDate(isoStr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _setReminder(docId, docLabel, contractType, remindAt, intent) {
|
function _setReminder(docId, docLabel, contractType, remindAt, intent) {
|
||||||
// Убираем picker
|
|
||||||
var msgs = document.getElementById('rchat-msgs');
|
var msgs = document.getElementById('rchat-msgs');
|
||||||
var last = msgs ? msgs.lastElementChild : null;
|
var last = msgs ? msgs.lastElementChild : null;
|
||||||
if (last && last.className.includes('hc-elena')) last.remove();
|
if (last && last.className.includes('hc-elena')) last.remove();
|
||||||
@ -8235,6 +8248,38 @@ function _setReminder(docId, docLabel, contractType, remindAt, intent) {
|
|||||||
_addCaseNote('promise', docLabel + ' — напоминание установлено на ' + _formatDate(remindAt),
|
_addCaseNote('promise', docLabel + ' — напоминание установлено на ' + _formatDate(remindAt),
|
||||||
{ docId: docId, contractType: contractType, remindAt: remindAt });
|
{ docId: docId, contractType: contractType, remindAt: remindAt });
|
||||||
|
|
||||||
|
// Сохраняем контакт на сервер если указан и есть согласие
|
||||||
|
var contactInp = document.getElementById('reminder-contact');
|
||||||
|
var consentInp = document.getElementById('reminder-consent');
|
||||||
|
var contactVal = contactInp ? contactInp.value.trim() : '';
|
||||||
|
var hasConsent = consentInp ? consentInp.checked : false;
|
||||||
|
|
||||||
|
if (contactVal && hasConsent) {
|
||||||
|
var ctx = _buildElenaContext();
|
||||||
|
fetch(API_BASE + '/api/contact/remind', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {'Content-Type':'application/json'},
|
||||||
|
body: JSON.stringify({
|
||||||
|
phone_or_telegram: contactVal,
|
||||||
|
doc_label: docLabel,
|
||||||
|
remind_at: remindAt,
|
||||||
|
name: ctx.client_name || '',
|
||||||
|
consent: true
|
||||||
|
})
|
||||||
|
}).then(function(r){ return r.json(); }).then(function(d){
|
||||||
|
if (d.saved) {
|
||||||
|
// Сохраняем в localStorage для следующих форм
|
||||||
|
try {
|
||||||
|
var b2b = JSON.parse(localStorage.getItem('zashita_b2b') || '{}');
|
||||||
|
if (d.type === 'telegram') b2b.telegram = contactVal;
|
||||||
|
else b2b.phone = contactVal;
|
||||||
|
localStorage.setItem('zashita_b2b', JSON.stringify(b2b));
|
||||||
|
} catch(e){}
|
||||||
|
toast('✅ Контакт сохранён — пришлём напоминание ' + _formatDate(remindAt));
|
||||||
|
}
|
||||||
|
}).catch(function(){});
|
||||||
|
}
|
||||||
|
|
||||||
// Пузырь клиента
|
// Пузырь клиента
|
||||||
if (msgs) {
|
if (msgs) {
|
||||||
var uDiv = document.createElement('div');
|
var uDiv = document.createElement('div');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user