EVOLUTION-NINJA
Edit File: notifications.php
<?php echo view('includes/admin_header.php') ?> <link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url('public/assets/css/jquery-ui.css'); ?>" /> <link rel="stylesheet" href="<?php echo base_url('public/assets/toastr/toastr.min.css'); ?>"> <link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url('public/assets/jqgrid/css/ui.jqgrid.css'); ?>" /> <link rel="stylesheet" type="text/css" href="<?php echo base_url('public/assets/website_assets/css/innerpage.css'); ?>" /> <link rel="stylesheet" href="<?php echo base_url('public/assets/sweet_alert/sweet-alert.css'); ?>"> <script type="text/javascript" src="<?php echo base_url('public/assets/toastr/toastr.min.js'); ?>"></script> <script type="text/ecmascript" src="<?php echo base_url('public/assets/jqgrid/js/jquery.jqGrid.min.js'); ?>"></script> <script type="text/ecmascript" src="<?php echo base_url('public/assets/jqgrid/js/i18n/grid.locale-en.js'); ?>"></script> <script src="<?php echo base_url('public/assets/js/jquery-ui.js'); ?>" type="text/javascript"></script> <script src="<?php echo base_url('public/assets/sweet_alert/sweet-alert.js'); ?>"></script> <!-- Content Wrapper. Contains page content --> <div class="content-wrapper"> <section class="content-header"> <h1 style="padding-bottom:10px;border-bottom:2px dashed #ccc;margin-bottom:20px;">Notifications</h1> </section> <section class="content"> <a href="javascript:history.back()" class="btn btn-primary" style="float: right;">Back</a> <div class="row"> <div class="col-sm-12"> <ul class="nav nav-tabs"> <li class="nav-item"> <a class="nav-link active" data-toggle="tab" href="#menu2">All Days</a> </li> <li class="nav-item"> <a class="nav-link" data-toggle="tab" href="#menu1">This Week</a> </li> <li class="nav-item"> <a class="nav-link" data-toggle="tab" href="#home">Today</a> </li> </ul> </div> <div class="col-sm-8 scroll"> <div class="get_noti"> <div class="get_noti_img"> <i class="fa fa-bell" aria-hidden="true"></i> (<b class="thisweek_notification_count"><?php echo count($notification); ?></b>) </div> <div class="get_noti_name"> <p style="font-size:16px;">Notifications</p> </div> </div> <div id="thisweek_legal_notifications"> <?php foreach ($notification as $value) { ?> <div class="accept_job"> <div class="notification_card del_box"> <h4 style="color:#000;"><?php echo $value->category_type; ?></h4> <p><?php echo $value->notification; ?></p> <p class="time"><?php echo date("d-m-Y h:i:s", strtotime($value->created_at)); ?></p> <button class="btn btn-danger delete-notification" data-notification-id="<?php echo $value->notification_id; ?>">Delete</button> </div> </div> <?php } ?> </div> </div> <div class="col-sm-4"></div> </div> </section> <!--footer --> <footer class="main-footer"> <div class="pull-right hidden-xs"> </div> <strong>Copyright © 2023-2024 AMCAD</strong> All rights reserved. </footer> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script> <script> $(document).ready(function () { // Initial load with "All Days" tab filterNotifications("All Days"); // Handle tab clicks $(".nav-link").click(function () { var tabText = $(this).text(); filterNotifications(tabText); }); function filterNotifications(tabText) { $(".notification_card").hide(); // Filter notifications based on tabText (e.g., "All Days", "This Week", "Today") if (tabText === "All Days") { $(".notification_card").show(); } else if (tabText === "This Week") { $(".notification_card").each(function () { var time = $(this).find(".time").text(); var notificationDate = new Date(time); var oneWeekAgo = new Date(); oneWeekAgo.setDate(oneWeekAgo.getDate() - 7); if (notificationDate >= oneWeekAgo) { $(this).show(); } }); } else if (tabText === "Today") { $(".notification_card").each(function () { var time = $(this).find(".time").text(); var notificationDate = new Date(time); var today = new Date(); today.setHours(0, 0, 0, 0); if (notificationDate >= today) { $(this).show(); } }); } } $(".delete-notification").click(function () { var notificationId = $(this).data("notification-id"); var $button = $(this); Swal.fire({ title: "Are you sure?", text: "Once deleted, you will not be able to recover this notification!", icon: "warning", showCancelButton: true, confirmButtonText: "Yes, delete it!", cancelButtonText: "No, cancel", reverseButtons: true, }).then((result) => { if (result.isConfirmed) { $.ajax({ type: "POST", url: "<?php echo base_url('delete'); ?>", data: { notification_id: notificationId }, success: function (response) { if (response.success) { // Update the UI to indicate deletion $button.closest(".notification_card").fadeOut('fast', function () { $(this).remove(); Swal.fire("Deleted!", "The notification has been deleted.", "success"); }); } else { Swal.fire("Error!", "Failed to delete notification.", "error"); } }, error: function () { Swal.fire("Error!", "An error occurred while processing your request.", "error"); }, }); } }); }); setTimeout(function() { // location.reload(); }, 5000); }); // $(document).ready(function() { // // Load the initial tab content on page load // loadTabContent('menu2'); // // Handle tab clicks // $('.nav-link').click(function() { // var tabName = $(this).attr('href').substring(1); // Get the tab name // loadTabContent(tabName); // }); // // Function to load tab content via AJAX // function loadTabContent(tabName) { // $.ajax({ // url: '<?php //site_url('tabs/loadTabContent') ?>/' + tabName, // method: 'get', // success: function(data) { // $('#tab-content-container').html(data); // }, // error: function() { // console.log('Error loading tab content'); // } // }); // } // }); </script> <!-- <?php //echo view('includes/admin_footer') ?> --> <style> .get_noti { padding-top: 10px; padding-bottom: 10px; background: #7E8EA5; padding-left: 15px; } .get_noti_img, .get_noti_name { display: table-cell; color: #fff; } .main-footer{ background-color: #468662; color: #fff; border-top: none; margin-left: 1px; } .get_noti_img i { background: #FCFCFC; width: 40px; height: 40px; line-height: 40px; color: #CDDBF5; border-radius: 50%; text-align: center; font-size: 18px; margin-right: 10px; } .get_noti_name { vertical-align: middle; margin-left: 10px; } .get_noti_name p { margin-bottom: 0px; } .input_text { border-left: 1px solid #acacac; border-right: 1px solid #acacac; padding: 10px; } /* .accept_job { border-top: 1px solid #acacac; border-left: 1px solid #acacac; border-right: 1px solid #acacac; padding: 10px; } */ .nav-item{ color:#CDDBF5; } .del_box{ border-bottom: 1px dashed #acacac; padding: 10px; } .scroll{ overflow-y: scroll; height: 376px; } </style>