| @@ -60,8 +60,12 @@ | ||
| 60 | 60 | <button class="mxch-mobile-nav-link" data-target="all-chats"> |
| 61 | 61 | <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg> |
| 62 | 62 | <span><?php esc_html_e('All Chats', 'mxchat'); ?></span> |
| 63 | 63 | </button> |
| 64 | + <button class="mxch-mobile-nav-link" data-target="leads"> | |
| 65 | + <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><polyline points="17 11 19 13 23 9"/></svg> | |
| 66 | + <span><?php esc_html_e('Leads', 'mxchat'); ?></span> | |
| 67 | + </button> | |
| 64 | 68 | </div> |
| 65 | 69 | <!-- Settings Section --> |
| 66 | 70 | <div class="mxch-mobile-nav-section"> |
| 67 | 71 | <div class="mxch-mobile-nav-section-title"><?php esc_html_e('Settings', 'mxchat'); ?></div> |
| @@ -120,8 +124,18 @@ | ||
| 120 | 124 | <span class="mxch-nav-link-text"><?php esc_html_e('All Chats', 'mxchat'); ?></span> |
| 121 | 125 | <span class="mxch-nav-link-badge"><?php echo esc_html($total_chats); ?></span> |
| 122 | 126 | </button> |
| 123 | 127 | </div> |
| 128 | + | |
| 129 | + <div class="mxch-nav-item" data-section="leads"> | |
| 130 | + <button class="mxch-nav-link" data-target="leads"> | |
| 131 | + <span class="mxch-nav-link-icon"> | |
| 132 | + <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><polyline points="17 11 19 13 23 9"/></svg> | |
| 133 | + </span> | |
| 134 | + <span class="mxch-nav-link-text"><?php esc_html_e('Leads', 'mxchat'); ?></span> | |
| 135 | + <span class="mxch-nav-link-badge" id="mxch-leads-nav-badge" style="display:none;">0</span> | |
| 136 | + </button> | |
| 137 | + </div> | |
| 124 | 138 | </div> |
| 125 | 139 | |
| 126 | 140 | <!-- Settings Section --> |
| 127 | 141 | <div class="mxch-nav-section"> |
| @@ -521,8 +535,201 @@ | ||
| 521 | 535 | </div> |
| 522 | 536 | </div> |
| 523 | 537 | |
| 524 | 538 | <?php wp_nonce_field('mxchat_delete_chat_history', 'mxchat_delete_chat_nonce'); ?> |
| 539 | + | |
| 540 | + <!-- Transcript delete confirm modal (shared by bulk + individual delete) --> | |
| 541 | + <div id="mxch-transcript-confirm" class="mxch-modal-overlay" style="display:none;"> | |
| 542 | + <div class="mxch-modal-content mxch-leads-confirm-box"> | |
| 543 | + <div class="mxch-modal-header"> | |
| 544 | + <h2 id="mxch-transcript-confirm-title"><?php esc_html_e('Delete conversation?', 'mxchat'); ?></h2> | |
| 545 | + <button type="button" class="mxch-modal-close" data-mxch-transcript-close>×</button> | |
| 546 | + </div> | |
| 547 | + <div class="mxch-modal-body"> | |
| 548 | + <p id="mxch-transcript-confirm-body"></p> | |
| 549 | + <label class="mxch-transcript-confirm-check"> | |
| 550 | + <input type="checkbox" id="mxch-transcript-also-delete-lead"> | |
| 551 | + <span> | |
| 552 | + <strong><?php esc_html_e('Also remove the lead from the Leads tab', 'mxchat'); ?></strong> | |
| 553 | + <em class="mxch-transcript-confirm-sublabel"><?php esc_html_e('By default, leads are kept and marked "Chat deleted" so your contact list is preserved.', 'mxchat'); ?></em> | |
| 554 | + </span> | |
| 555 | + </label> | |
| 556 | + <p class="mxch-leads-confirm-warning"><?php esc_html_e('This cannot be undone.', 'mxchat'); ?></p> | |
| 557 | + </div> | |
| 558 | + <div class="mxch-leads-confirm-actions"> | |
| 559 | + <button type="button" class="mxch-btn mxch-btn-secondary" data-mxch-transcript-close><?php esc_html_e('Cancel', 'mxchat'); ?></button> | |
| 560 | + <button type="button" class="mxch-btn mxch-btn-danger" id="mxch-transcript-confirm-go"><?php esc_html_e('Delete', 'mxchat'); ?></button> | |
| 561 | + </div> | |
| 562 | + </div> | |
| 563 | + </div> | |
| 564 | + </div> | |
| 565 | + | |
| 566 | + <!-- Leads Section --> | |
| 567 | + <div id="leads" class="mxch-section"> | |
| 568 | + <div class="mxch-content-header"> | |
| 569 | + <h1 class="mxch-content-title"><?php esc_html_e('Leads', 'mxchat'); ?></h1> | |
| 570 | + <p class="mxch-content-subtitle"><?php esc_html_e('Captured visitor emails and names from the lead-capture form, grouped by unique lead.', 'mxchat'); ?></p> | |
| 571 | + </div> | |
| 572 | + | |
| 573 | + <!-- Stats strip --> | |
| 574 | + <div class="mxch-leads-stats"> | |
| 575 | + <div class="mxch-stat-card"> | |
| 576 | + <div class="mxch-stat-icon mxch-stat-icon-primary"> | |
| 577 | + <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M23 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg> | |
| 578 | + </div> | |
| 579 | + <div class="mxch-stat-content"> | |
| 580 | + <span class="mxch-stat-value" id="mxch-leads-stat-total">0</span> | |
| 581 | + <span class="mxch-stat-label"><?php esc_html_e('Total Leads', 'mxchat'); ?></span> | |
| 582 | + </div> | |
| 583 | + </div> | |
| 584 | + <div class="mxch-stat-card"> | |
| 585 | + <div class="mxch-stat-icon mxch-stat-icon-success"> | |
| 586 | + <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="23 6 13.5 15.5 8.5 10.5 1 18"/><polyline points="17 6 23 6 23 12"/></svg> | |
| 587 | + </div> | |
| 588 | + <div class="mxch-stat-content"> | |
| 589 | + <span class="mxch-stat-value" id="mxch-leads-stat-new">0</span> | |
| 590 | + <span class="mxch-stat-label"><?php esc_html_e('New This Week', 'mxchat'); ?></span> | |
| 591 | + </div> | |
| 592 | + </div> | |
| 593 | + <div class="mxch-stat-card"> | |
| 594 | + <div class="mxch-stat-icon mxch-stat-icon-info"> | |
| 595 | + <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg> | |
| 596 | + </div> | |
| 597 | + <div class="mxch-stat-content"> | |
| 598 | + <span class="mxch-stat-value" id="mxch-leads-stat-avg">0</span> | |
| 599 | + <span class="mxch-stat-label"><?php esc_html_e('Avg Convos / Lead', 'mxchat'); ?></span> | |
| 600 | + </div> | |
| 601 | + </div> | |
| 602 | + <div class="mxch-stat-card"> | |
| 603 | + <div class="mxch-stat-icon mxch-stat-icon-warning"> | |
| 604 | + <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg> | |
| 605 | + </div> | |
| 606 | + <div class="mxch-stat-content"> | |
| 607 | + <span class="mxch-stat-value" id="mxch-leads-stat-orphan">0%</span> | |
| 608 | + <span class="mxch-stat-label"><?php esc_html_e('Orphan Leads', 'mxchat'); ?></span> | |
| 609 | + <span class="mxch-stat-sublabel" id="mxch-leads-stat-orphan-sub"><?php esc_html_e('Captured but never chatted', 'mxchat'); ?></span> | |
| 610 | + </div> | |
| 611 | + </div> | |
| 612 | + </div> | |
| 613 | + | |
| 614 | + <!-- Top pages card --> | |
| 615 | + <div class="mxch-card mxch-leads-toppages"> | |
| 616 | + <div class="mxch-card-header"> | |
| 617 | + <h3 class="mxch-card-title"> | |
| 618 | + <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 3h18v18H3z"/><path d="M3 9h18"/><path d="M9 21V9"/></svg> | |
| 619 | + <?php esc_html_e('Top Pages Capturing Leads', 'mxchat'); ?> | |
| 620 | + </h3> | |
| 621 | + <span class="mxch-leads-toppages-hint"><?php esc_html_e('Click a page to filter the list below', 'mxchat'); ?></span> | |
| 622 | + </div> | |
| 623 | + <div class="mxch-card-body"> | |
| 624 | + <div class="mxch-leads-toppages-list" id="mxch-leads-toppages-list"> | |
| 625 | + <div class="mxch-leads-empty-mini"><?php esc_html_e('No page data yet.', 'mxchat'); ?></div> | |
| 626 | + </div> | |
| 627 | + </div> | |
| 628 | + </div> | |
| 629 | + | |
| 630 | + <!-- Leads toolbar + table --> | |
| 631 | + <div class="mxch-card mxch-leads-card"> | |
| 632 | + <div class="mxch-leads-toolbar"> | |
| 633 | + <div class="mxch-leads-toolbar-left"> | |
| 634 | + <label class="mxch-bulk-select-all"> | |
| 635 | + <input type="checkbox" id="mxch-leads-select-all"> | |
| 636 | + <span><?php esc_html_e('All', 'mxchat'); ?></span> | |
| 637 | + </label> | |
| 638 | + <span class="mxch-selected-count" id="mxch-leads-selected-count">0</span> | |
| 639 | + <button type="button" class="mxch-bulk-btn mxch-bulk-delete" id="mxch-leads-delete-selected" disabled title="<?php esc_attr_e('Delete Selected', 'mxchat'); ?>"> | |
| 640 | + <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg> | |
| 641 | + <span><?php esc_html_e('Delete', 'mxchat'); ?></span> | |
| 642 | + </button> | |
| 643 | + </div> | |
| 644 | + <div class="mxch-leads-toolbar-right"> | |
| 645 | + <div class="mxch-leads-export" id="mxch-leads-export-wrap"> | |
| 646 | + <button type="button" class="mxch-btn mxch-btn-secondary mxch-btn-sm" id="mxch-leads-export-btn"> | |
| 647 | + <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg> | |
| 648 | + <?php esc_html_e('Export', 'mxchat'); ?> | |
| 649 | + <svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg> | |
| 650 | + </button> | |
| 651 | + <div class="mxch-leads-export-menu" id="mxch-leads-export-menu"> | |
| 652 | + <button type="button" data-fields="email_and_name" data-scope="all"><?php esc_html_e('All leads — email + name', 'mxchat'); ?></button> | |
| 653 | + <button type="button" data-fields="email_only" data-scope="all"><?php esc_html_e('All leads — email only', 'mxchat'); ?></button> | |
| 654 | + <button type="button" data-fields="email_and_name" data-scope="selected" disabled><?php esc_html_e('Selected — email + name', 'mxchat'); ?></button> | |
| 655 | + <button type="button" data-fields="email_only" data-scope="selected" disabled><?php esc_html_e('Selected — email only', 'mxchat'); ?></button> | |
| 656 | + </div> | |
| 657 | + </div> | |
| 658 | + </div> | |
| 659 | + </div> | |
| 660 | + | |
| 661 | + <div class="mxch-leads-filters"> | |
| 662 | + <div class="mxch-search-wrapper"> | |
| 663 | + <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg> | |
| 664 | + <input type="text" id="mxch-leads-search" class="mxch-search-input" placeholder="<?php esc_attr_e('Search by email or name...', 'mxchat'); ?>"> | |
| 665 | + </div> | |
| 666 | + <select id="mxch-leads-date-range" class="mxch-select"> | |
| 667 | + <option value="all"><?php esc_html_e('All time', 'mxchat'); ?></option> | |
| 668 | + <option value="today"><?php esc_html_e('Last 24 hours', 'mxchat'); ?></option> | |
| 669 | + <option value="7d"><?php esc_html_e('Last 7 days', 'mxchat'); ?></option> | |
| 670 | + <option value="30d"><?php esc_html_e('Last 30 days', 'mxchat'); ?></option> | |
| 671 | + <option value="90d"><?php esc_html_e('Last 90 days', 'mxchat'); ?></option> | |
| 672 | + </select> | |
| 673 | + <select id="mxch-leads-status" class="mxch-select"> | |
| 674 | + <option value="all"><?php esc_html_e('All leads', 'mxchat'); ?></option> | |
| 675 | + <option value="with"><?php esc_html_e('With conversation', 'mxchat'); ?></option> | |
| 676 | + <option value="chat_deleted"><?php esc_html_e('Chat deleted', 'mxchat'); ?></option> | |
| 677 | + <option value="orphan"><?php esc_html_e('Orphan (no chat)', 'mxchat'); ?></option> | |
| 678 | + </select> | |
| 679 | + <button type="button" class="mxch-btn mxch-btn-ghost mxch-btn-sm" id="mxch-leads-clear-filters" style="display:none;"> | |
| 680 | + <?php esc_html_e('Clear filters', 'mxchat'); ?> | |
| 681 | + </button> | |
| 682 | + <span class="mxch-leads-active-page-filter" id="mxch-leads-active-page-filter" style="display:none;"> | |
| 683 | + <span class="mxch-leads-page-chip-label"></span> | |
| 684 | + <button type="button" class="mxch-leads-page-chip-remove" aria-label="<?php esc_attr_e('Remove page filter', 'mxchat'); ?>">×</button> | |
| 685 | + </span> | |
| 686 | + </div> | |
| 687 | + | |
| 688 | + <div class="mxch-leads-table-wrap"> | |
| 689 | + <table class="mxch-leads-table" id="mxch-leads-table"> | |
| 690 | + <thead> | |
| 691 | + <tr> | |
| 692 | + <th class="mxch-leads-col-check"></th> | |
| 693 | + <th class="mxch-leads-col-lead"><?php esc_html_e('Lead', 'mxchat'); ?></th> | |
| 694 | + <th class="mxch-leads-col-count"><?php esc_html_e('Conversations', 'mxchat'); ?></th> | |
| 695 | + <th class="mxch-leads-col-last"><?php esc_html_e('Last seen', 'mxchat'); ?></th> | |
| 696 | + <th class="mxch-leads-col-page"><?php esc_html_e('Top page', 'mxchat'); ?></th> | |
| 697 | + <th class="mxch-leads-col-actions"></th> | |
| 698 | + </tr> | |
| 699 | + </thead> | |
| 700 | + <tbody id="mxch-leads-tbody"> | |
| 701 | + <tr><td colspan="6" class="mxch-leads-loading"><span class="spinner is-active"></span></td></tr> | |
| 702 | + </tbody> | |
| 703 | + </table> | |
| 704 | + </div> | |
| 705 | + | |
| 706 | + <div class="mxch-panel-footer"> | |
| 707 | + <span class="mxch-leads-count" id="mxch-leads-count">0 leads</span> | |
| 708 | + <div class="mxch-pagination-simple" id="mxch-leads-pagination"></div> | |
| 709 | + </div> | |
| 710 | + </div> | |
| 711 | + | |
| 712 | + <!-- Delete confirm modal --> | |
| 713 | + <div id="mxch-leads-confirm" class="mxch-modal-overlay" style="display:none;"> | |
| 714 | + <div class="mxch-modal-content mxch-leads-confirm-box"> | |
| 715 | + <div class="mxch-modal-header"> | |
| 716 | + <h2><?php esc_html_e('Delete leads', 'mxchat'); ?></h2> | |
| 717 | + <button type="button" class="mxch-modal-close" data-mxch-leads-close>×</button> | |
| 718 | + </div> | |
| 719 | + <div class="mxch-modal-body"> | |
| 720 | + <p id="mxch-leads-confirm-body"></p> | |
| 721 | + <p class="mxch-leads-confirm-warning"><?php esc_html_e('This cannot be undone.', 'mxchat'); ?></p> | |
| 722 | + </div> | |
| 723 | + <div class="mxch-leads-confirm-actions"> | |
| 724 | + <button type="button" class="mxch-btn mxch-btn-secondary" data-mxch-leads-close><?php esc_html_e('Cancel', 'mxchat'); ?></button> | |
| 725 | + <button type="button" class="mxch-btn mxch-btn-danger" id="mxch-leads-confirm-go"><?php esc_html_e('Delete permanently', 'mxchat'); ?></button> | |
| 726 | + </div> | |
| 727 | + </div> | |
| 728 | + </div> | |
| 729 | + | |
| 730 | + <?php wp_nonce_field('mxchat_delete_leads', 'mxchat_leads_delete_nonce'); ?> | |
| 731 | + <?php wp_nonce_field('mxchat_export_leads', 'mxchat_leads_export_nonce'); ?> | |
| 525 | 732 | </div> |
| 526 | 733 | |
| 527 | 734 | <!-- Notifications Section --> |
| 528 | 735 | <div id="notifications" class="mxch-section"> |