

  
{"id":24194,"date":"2024-09-03T23:36:27","date_gmt":"2024-09-04T06:36:27","guid":{"rendered":"https:\/\/ezwaynetwork.webermelon.dev\/?page_id=24194"},"modified":"2025-06-04T00:32:03","modified_gmt":"2025-06-04T07:32:03","slug":"all-notifications","status":"publish","type":"page","link":"https:\/\/ezwaynetwork.webermelon.dev\/old\/all-notifications\/","title":{"rendered":"Notifications"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-page\" data-elementor-id=\"24194\" class=\"elementor elementor-24194\" data-elementor-post-type=\"page\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-604f133 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"604f133\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-97feddf\" data-id=\"97feddf\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-9e87f02 elementor-widget elementor-widget-shortcode\" data-id=\"9e87f02\" data-element_type=\"widget\" data-widget_type=\"shortcode.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\n\n<head>\n\n<style>\n    .btn,.btn:hover,.btn:focus{\n        padding: 8px 40px !important;\n        border-radius: 10px !important;\n        font-weight: 500 !important;\n\n    }\n    .btn{\n        background-color: #1583ff ;\n        color:white !important;\n        border: 1px solid !important;\n    }\n    .btn:hover{\n        background-color: #338cf1 ;\n        color:white !important;\n        border: 1px solid !important;\n    }\n    .btn-primary{\n        background-color: #FF8A00 !important;\n    }\n    .btn-primary:hover,.btn-primary:focus,.btn-primary:active,.btn-primary:disabled{\n        background-color: #ff9d29 !important;\n        border-color: #ff9d29 !important;\n    }\n    .btn-primary:focus{\n        box-shadow: 0 0 0 .25rem #ffdcb3 !important;\n    }\n    input,select{\n        padding: 5px 12px !important;\n        border-radius: 10px !important;\n        border: 1px solid #cdcdcd !important;\n        color: black\n    }\n    input:focus,select:focus{\n        border-color:transparent !important;\n        box-shadow: 0 0 0 1px #cdcdcd !important;\n    }\n<\/style>\n<\/head>\n\n<!-- Modal -->\n<div class=\"modal fade \" id=\"editNotificationModal\" tabindex=\"-1\" aria-labelledby=\"exampleModalLabel\" aria-hidden=\"true\">\n  <div class=\"modal-dialog modal-lg\">\n  <form class=\"\" id=\"edit-notification-form\">\n    <div class=\"modal-content \" style=\"border-radius:12px\">\n      <div class=\"modal-header\">\n        <h5 class=\"modal-title\" id=\"exampleModalLabel\">Edit Notification<\/h5>\n        <button type=\"button\" class=\"btn-close\" data-bs-dismiss=\"modal\" aria-label=\"Close\"><\/button>\n      <\/div>\n      <div class=\"modal-body\">\n        \n            <div class=\"mb-3 form-group\">\n                <label for=\"edit-title-input\" class=\"form-label\">Title<\/label>\n                <input type=\"text\" name=\"notification_text\" class=\"form-control\" id=\"edit-title-input\" placeholder=\"Test title\" required>\n            <\/div>\n            <div class=\"mb-3 form-group\">\n                <label for=\"edit-url-input\" class=\"form-label\">Reditect url<\/label>\n                <input type=\"url\" name=\"notification_url\" class=\"form-control\" id=\"edit-url-input\" placeholder=\"ex: http:\/\/www.example.com\" required>\n            <\/div>\n            <input id=\"notification-group-id\" name=\"notification_group_id\" type=\"hidden\"\/>\n      <\/div>\n      <div class=\"modal-footer\">\n        <button type=\"button\" class=\"btn btn-secondary\" id=\"edit-notification-close-btn\" data-bs-dismiss=\"modal\" >Close<\/button>\n        <button type=\"submit\" class=\"btn btn-primary \" id=\"edit-notification-btn\">Update<\/button>\n      <\/div>\n    <\/div>\n    <\/form>\n  <\/div>\n<\/div>\n\n<script src=\"https:\/\/cdn.jsdelivr.net\/npm\/bootstrap@5.0.2\/dist\/js\/bootstrap.bundle.min.js\" integrity=\"sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn\/tWtIaxVXM\" crossorigin=\"anonymous\"><\/script>\n\n<script>\n$(document).ready(function($) {\n    $(\"form#edit-notification-form\").on('submit', function(e) {\n        e.preventDefault();\n        var request = new FormData(this)\n        request.append(\"action\",\"edit_custom_notify\")\n        var url = \"https:\/\/ezwaynetwork.webermelon.dev\/old\/wp-admin\/admin-ajax.php\"\n\n        $.ajax(\n        {\n            url: url,\n            method:\"post\",\n            data: request,\n            processData: false,\n            contentType: false,\n            beforeSend:function(){\n            console.log('sending notification');\n            $(\"#edit-notification-btn\").attr(\"disabled\", true).html(\"Creating...\");\n            $(\"div.alert\").removeClass(\"alert-success\").hide().html(\"\")\n            },\n            success:function(data){\n            console.log(data);\n            $(\"form#edit-notification-form\")[0].reset();\n            $(\"#edit-notification-btn\").attr(\"disabled\", false).html(\"Send\");\n            $(\"div.alert\").removeClass(\"alert-warning alert-primary \").show().addClass(\"alert-success\").html(\"Notification Updated!\")\n            $(\"#editNotificationModal\").modal('hide');\n            $(\"#edit-notification-close-btn\").click()\n            \n            getSentNotifications()\n            },\n            error:function(err){\n                $(\"div.alert\").removeClass(\"alert-success alert-primary\").show().addClass(\"alert-warning\").html(\"Opps something went wrong!\")\n            console.log(err);\n            }\n        }\n        )\n    })\n})\n<\/script>        <!DOCTYPE html>\n<html>\n\n<head>\n    <meta charset=\"utf-8\">\n    <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n    <title><\/title>\n    <meta name=\"description\" content=\"\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n    <link href=\"https:\/\/cdn.jsdelivr.net\/npm\/bootstrap@5.0.2\/dist\/css\/bootstrap.min.css\" rel=\"stylesheet\"\n        integrity=\"sha384-EVSTQN3\/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC\" crossorigin=\"anonymous\">\n\n<style>\n.notification-container {\n    font-size: 14px;\n    font-family: \"Poppins\", Sans-serif;\n    color: #626262;\n}\n.notification-container table thead{\n    background-color: #efefef\n}\n.notification-container table tr th{\n    font-weight: 600;\n}\n.notification-container table tr th,.notification-container table tr td {\n    padding: 10px;\n    border-bottom:1px solid #f4f4f491;\n}\n.lowercase{\n    text-transform: lowercase;\n\n}\n.card{\n    max-width: none;\n    border-radius: 16px;\n    padding: 20px !important;\n}\n.notification-table-container{\n    border-radius: 16px;\n    overflow: hidden;\n    border: 1px solid #EFEFEF;\n}\ntable{\n    width: 100%;\n    margin: 0;\n    border: 0;\n}\n.notification-table-container .pagination-container{\n    border-radius: 14px !important;\n    overflow: hidden !important;\n    border: 1px solid #dee2e64a !important;\n    margin: 15px 0;\n    background:#dee2e64a\n}\n.pagination-container .pagination{\n    padding: 0 !important;\n    margin: 8px;\n\n}\n.pagination .page-item .page-link{\n    background-color:#F5F7F8\n}\n.pagination .page-item .page-link:hover{\n    background-color:#EFEFEF\n}\n.pagination .page-item.active .page-link{\n    background-color:#ff9d29\n}\n.pagination .page-item{\n    margin: 0;\n}\n.pagination .page-link:focus{\n    box-shadow: 0 0 0 .25rem transparent !important;\n}\n.pagination .page-link{\n    border:none !important;\n    border-radius: 9px !important;\n    color:#ff9d29;\n    margin:0px 3px  !important ;\n    padding: 6px 14px  !important;\n}\n<\/style>\n<\/head>\n    <div class=\"alert alert-success m-2 mt-2\" id=\"notification-alert\" style=\"display:none\">\n\n    <\/div>\n   <div class=\"card p-4 notification-container\" style=\"max-width:none\">\n    <div class=\"\">\n     <h3>Notifications<\/h3>\n    <\/div>\n    <div class=\"notification-table-container\">\n   <table class=\"\" id=\"notification-table\">\n        <thead class=\"table-light\">\n            <tr>\n                <th>#<\/th>\n                <th>Title<\/th>\n                <th>Link<\/th>\n                <th>Target User<\/th>\n                <th>Vistors<\/th>\n                <th class=\"text-center\">Action<\/th>\n            <\/tr>\n        <\/thead>\n        <tbody>\n\n\n\n        <\/tbody>\n    <\/table>\n    <div>\n    <nav aria-label=\"...\" class=\"d-flex justify-content-center\">\n        <div class=\"pagination-container\">\n        <ul class=\"pagination\">\n        <\/ul>\n        <\/div>\n    <\/nav>\n    <\/div>\n    <\/div>\n   <\/div>\n\n<!-- <script src=\"https:\/\/code.jquery.com\/jquery-3.7.1.min.js\" integrity=\"sha256-\/JqT3SQfawRcv\/BIHPThkBvs0OEvtFFmqPF\/lYI\/Cxo=\" crossorigin=\"anonymous\"><\/script> -->\n<script>\n       jQuery(document).ready(function($){\n            var urlParams = new URLSearchParams(window.location.search);\n        function getSentNotifications(){\n            var ajaxUrl = \"https:\/\/ezwaynetwork.webermelon.dev\/old\/wp-admin\/admin-ajax.php\";\n            var action = \"get_sent_custom_notifications\";\n        \n            \/\/ Get the current page number from the URL parameters (e.g., ?pageNo=2)\n            var currentPage = urlParams.get('pageNo') ?? 1;\n            \/\/ Get the 'limit' parameter from the URL, or default to 2 if not provided\n            var limit = urlParams.get('limit') ?? 15;\n            \/\/ Initialize the offset to 0, which will be used to determine how much data to skip\n            var offset = 0;\n            \/\/ If the current page is greater than 1, calculate the offset by multiplying\n            \/\/ the limit (items per page) by (currentPage - 1). This gives the number of items to skip.\n            if(currentPage > 1){\n                offset = limit * (currentPage - 1);\n            }\n\n\n            var params = {\n                \"action\" : action,\n                \"limit\": limit,\n                \"offset\" :offset,\n                \"currentPage\" : currentPage\n            }\n            \n            $.ajax({\n                url:ajaxUrl,\n                method: \"get\",\n                data:params,\n                beforeSend:function(){\n                    $(\"#notification-table tbody\").html(\"<tr><td colspan='5'>Loading...<\/td><\/tr>\")\n                },\n                success:function(data){\n                    $(\"#notification-table tbody\").html(\"\")\n\n                    $.each(data.notifications,function(index,notification){\n                        notificationsHtml = `<tr><td scope=\"row\">${++index}<\/td>\n                        <td style=\"max-width:250px\" class=\"\">${(notification?.text) ?? \"\"}<\/td>\n                            <td><a  style=\"text-decoration:underline\" href=\"${(notification?.full_link)}\" target=\"_blank\">Visit<\/a><\/td>\n                            <td>${(notification?.target_receipents) }<\/td>\n                            <td style=\"font-weight:600\">${(notification?.vistors) }<\/td>\n                            <td class=\"text-center\">\n                        <div>\n                            <a data-text=\"${notification?.text}\"  data-url=\"${(notification?.full_link)}\" data-notification_group_id=\"${(notification?.notification_group_id)}\" data-bs-toggle=\"modal\" data-bs-target=\"#editNotificationModal\" href=\"#edit\" data-id=\"${notification?.notification_group_id}\" style=\"\" class=\" notification-edit-btn  p-1\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 24 24\" width=\"21\" height=\"21\" color=\"#000000\" fill=\"none\">\n                            <path d=\"M15.2141 5.98239L16.6158 4.58063C17.39 3.80646 18.6452 3.80646 19.4194 4.58063C20.1935 5.3548 20.1935 6.60998 19.4194 7.38415L18.0176 8.78591M15.2141 5.98239L6.98023 14.2163C5.93493 15.2616 5.41226 15.7842 5.05637 16.4211C4.70047 17.058 4.3424 18.5619 4 20C5.43809 19.6576 6.94199 19.2995 7.57889 18.9436C8.21579 18.5877 8.73844 18.0651 9.78375 17.0198L18.0176 8.78591M15.2141 5.98239L18.0176 8.78591\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" \/>\n                            <path d=\"M11 20H17\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" \/>\n                        <\/svg><\/a>\n                            <a href=\"#delete\" data-id=\"${notification?.notification_group_id}\" style=\"color:red\" class=\" notification-delete-btn p-1\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 24 24\" width=\"21\" height=\"21\" color=\"red\" fill=\"none\">\n                            <path d=\"M19.5 5.5L18.8803 15.5251C18.7219 18.0864 18.6428 19.3671 18.0008 20.2879C17.6833 20.7431 17.2747 21.1273 16.8007 21.416C15.8421 22 14.559 22 11.9927 22C9.42312 22 8.1383 22 7.17905 21.4149C6.7048 21.1257 6.296 20.7408 5.97868 20.2848C5.33688 19.3626 5.25945 18.0801 5.10461 15.5152L4.5 5.5\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" \/>\n                            <path d=\"M3 5.5H21M16.0557 5.5L15.3731 4.09173C14.9196 3.15626 14.6928 2.68852 14.3017 2.39681C14.215 2.3321 14.1231 2.27454 14.027 2.2247C13.5939 2 13.0741 2 12.0345 2C10.9688 2 10.436 2 9.99568 2.23412C9.8981 2.28601 9.80498 2.3459 9.71729 2.41317C9.32164 2.7167 9.10063 3.20155 8.65861 4.17126L8.05292 5.5\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" \/>\n                            <path d=\"M9.5 16.5L9.5 10.5\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" \/>\n                            <path d=\"M14.5 16.5L14.5 10.5\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" \/>\n                        <\/svg><\/a><\/div>\n                            <\/td> <\/tr>`\n\n                            $(\"#notification-table tbody\").append(notificationsHtml)\n                    })\n            \n                    paginate(data?.links,currentPage)\n                    loadEditNotification()\n                    loadNotificationDelete()\n                },error:function(err){\n                    console.log(err);\n                }\n            })\n    }\n    getSentNotifications()\n    function loadNotificationDelete(){\n        $(\".notification-delete-btn\").on(\"click\",function(){\n        var id = $(this).data(\"id\")\n        var payload = {\n            action : \"delete_notification\",\n            notification_group_id: id\n        }\n        var confirmed = confirm(\"Are you sure You want to delete the record?\");\n        var clickedButton =  $(this)\n            if(confirmed){\n                $.ajax({\n                    url: \"https:\/\/ezwaynetwork.webermelon.dev\/old\/wp-admin\/admin-ajax.php\",\n                    method: \"POST\",\n                    data: payload,\n                    beforeSend: function(){\n                        console.log($(\".notification-delete-btn\"));\n                        clickedButton.html(\"Deleting..\").attr(\"disabled\",true).css({\n                            backgroundColor: \"transparent\",\n                            border: \"1px solid gray\"\n                        })\n                        $(\"#notification-alert\").hide()\n                    },\n                    success:function(data){\n                        clickedButton.text(\"Delete\").attr(\"disabled\",false).css({\n                                backgroundColor: \"transparent\"\n                            })\n                        if(data){\n                            $(\"#notification-alert\").html(\"Notification Deleted\").show(500).addClass(\"alert-success\").removeClass(\"alert-danger\")\n                            getSentNotifications()\n                        }else{\n                            $(\"#notification-alert\").html(\"Opps something went wrong!\").show(500).removeClass(\"alert-success\").addClass(\"alert-danger\")\n                        }\n                    },error:function(){\n                        clickedButton.text(\"Delete\").attr(\"disabled\",false).css({\n                            backgroundColor: \"#bb2d3b\",\n                        })\n                    }\n                })\n            }\n\n        })\n    }\n    function loadEditNotification(){\n        $('.notification-edit-btn').on(\"click\",function(){\n        var text = $(this).data('text');\n        var url = $(this).data('url');\n        var notification_group_id = $(this).data('notification_group_id');\n        \/\/    console.log(text,url,target_receipents);\/\n        $('#edit-title-input').val(text);\n        $('#edit-url-input').val(url);\n        $('#notification-group-id').val(notification_group_id);\n        })\n    }\n\n    function paginate(links,currentPage){\n        var currentUrl = window.location.href;\n        var paginationHtml = \"\";\n        $.each(links,function(index,link){\n            paginationHtml +=  `<li class=\"page-item ${link?.active ? \"active\": \"\"}\"><a class=\"page-link\" data-page=\"${link?.page}\" href=\"javascript:void(0);\">${link?.page}<\/a><\/li>`;\n        })\n        $(\".pagination-container .pagination\").html(paginationHtml)\n        loadNavigator(currentPage)\n    }\n\n    function loadNavigator(currentPage){\n        $(\".pagination-container .pagination .page-link\").on('click', function(e) {\n            e.preventDefault();\n            $(this).parent().siblings().removeClass(\"active\");\n            $(this).parent().addClass(\"active\");\n            var newPageNo = $(this).data('page');\n            if(currentPage !=newPageNo){\n            \/\/ Update the URL without reloading\n            urlParams.set('pageNo', newPageNo);\n            var newUrl = window.location.pathname + '?' + urlParams.toString();\n            history.pushState(null, null, newUrl);\n            \/\/ load notifications after changing url\n            getSentNotifications()\n        }\n        })\n\n    }\n       })\n<\/script>\n    \t\t<div class=\"elementor-shortcode\"><\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"","protected":false},"author":10033,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"pmpro_default_level":0,"site-sidebar-layout":"left-sidebar","site-content-layout":"page-builder","ast-site-content-layout":"full-width-container","site-content-style":"unboxed","site-sidebar-style":"unboxed","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"disabled","ast-breadcrumbs-content":"disabled","ast-featured-img":"disabled","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"class_list":["post-24194","page","type-page","status-publish","hentry","pmpro-has-access"],"acf":[],"_links":{"self":[{"href":"https:\/\/ezwaynetwork.webermelon.dev\/old\/wp-json\/wp\/v2\/pages\/24194","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ezwaynetwork.webermelon.dev\/old\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ezwaynetwork.webermelon.dev\/old\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ezwaynetwork.webermelon.dev\/old\/wp-json\/wp\/v2\/users\/10033"}],"replies":[{"embeddable":true,"href":"https:\/\/ezwaynetwork.webermelon.dev\/old\/wp-json\/wp\/v2\/comments?post=24194"}],"version-history":[{"count":4,"href":"https:\/\/ezwaynetwork.webermelon.dev\/old\/wp-json\/wp\/v2\/pages\/24194\/revisions"}],"predecessor-version":[{"id":24212,"href":"https:\/\/ezwaynetwork.webermelon.dev\/old\/wp-json\/wp\/v2\/pages\/24194\/revisions\/24212"}],"wp:attachment":[{"href":"https:\/\/ezwaynetwork.webermelon.dev\/old\/wp-json\/wp\/v2\/media?parent=24194"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}