MMCT TEAM
Server IP : 2a02:4780:3:2287:0:3736:a38e:8  /  Your IP : 216.73.217.17
Web Server : LiteSpeed
System : Linux sg-nme-web2187.main-hosting.eu 5.14.0-611.54.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Wed May 6 18:03:03 EDT 2026 x86_64
User : u926327694 ( 926327694)
PHP Version : 7.4.33
Disable Function : system, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF
Directory (0755) :  /home/u926327694/domains/smsoft.in/public_html/smart/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/u926327694/domains/smsoft.in/public_html/smart/whatsapp-message-track-log.php
<?php
    if(isset($_GET['school_code']) && isset($_GET['pwd']) && base64_encode("Admin@123")==$_GET['pwd'])
    {
        $school_code = $_GET['school_code'];
        include'config.php';
        date_default_timezone_set('Asia/Kolkata');
        $today_date = Date('Y-m-d');
        if($school_code != 'HMBEG' && $school_code != 'demor') {
            $sel_school=mysqli_query($con,"select * from schools where school_code='$school_code'");
            $endingDate = '';
            while($row_school=mysqli_fetch_array($sel_school))
            {
                $endingDate = $row_school['expiry_date'];
            }
            
            $oneWeekBeforeEndDate = strtotime($endingDate . ' -1 week');
            $oneWeekBeforeEndDate1 = strtotime($endingDate);
            $todayTime = strtotime("now");
            if ($todayTime >= $oneWeekBeforeEndDate && $todayTime <= $oneWeekBeforeEndDate1) {
                echo '<script>alert("Your license is expire in 7 days. Please make a payment to renew and continue using it.");</script>';
            }
            
            if ($todayTime > $oneWeekBeforeEndDate1) {
                echo '<script>alert("Your license is expired. Please make a payment to renew and continue using it.");</script>';
                exit;
            }
        }
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>WhatsApp Log Report</title>
    <link href="https://smsoft.in/demo/student_management_system/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://smsoft.in/demo/student_management_system/vendor/metisMenu/metisMenu.min.css" rel="stylesheet">
    <link href="https://smsoft.in/demo/student_management_system/vendor/datatables-plugins/dataTables.bootstrap.css" rel="stylesheet">
    <link href="https://smsoft.in/demo/student_management_system/vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet">
    <link href="https://smsoft.in/demo/student_management_system/dist/css/sb-admin-2.css" rel="stylesheet">
    <link href="https://smsoft.in/demo/student_management_system/vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <style>
        .big-checkbox {
            transform: scale(1.2);
            cursor:pointer;
        }
.others {
    color:green
}
.others1 {
    color:red
}
#wrapper {
    width: calc(100% - 10px);
    padding: 5px;
}

#viewModal pre {
    white-space: pre-wrap;      /* Preserve line breaks but wrap text */
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    margin: 0;
    background: transparent;
    border: none;
    padding: 0;
}
</style>
</head>
<body>
    <div id="wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <div class="row">
                                <div class="col-md-6">
                                    <b>WhatsApp Log Report Filter</b>
                                </div>
                                <div class="col-md-6">
                                    <?php
                                        $all_count_q1 = mysqli_query($con, "SELECT id FROM whatsapp_track_master_log WHERE school_code='$school_code'");
                                        $total_count = mysqli_num_rows($all_count_q1);
                                        
                                        // Today's count
                                        $today_count_q1 = mysqli_query($con, "SELECT id FROM whatsapp_track_master_log WHERE school_code='$school_code' AND DATE(created_on)='$today_date'");
                                        $today_count = mysqli_num_rows($today_count_q1);
                                    ?>
                                    <b>Today's Usage:</b> <?php echo $today_count; ?> &nbsp; | &nbsp;
                                    <b>Total Usage:</b> <?php echo $total_count; ?>
                                </div>
                            </div>
                        </div>
                        <div class="panel-body">
                            <form method="post" action="whatsapp-message-track-log.php?school_code=<?php echo $school_code; ?>&pwd=<?php echo $_GET['pwd']; ?>">
                                <div class="row">
                                    <?php 
                                        $start_date = isset($_POST['start_date']) ? $_POST['start_date'] : date('Y-m-d', strtotime('monday this week'));
                                        $end_date = isset($_POST['end_date']) ? $_POST['end_date'] : date('Y-m-d', strtotime('sunday this week'));
                                        $mobile_no = isset($_POST['mobile_no']) ? $_POST['mobile_no'] : '';
                                        $status = isset($_POST['status']) ? $_POST['status'] : '';
                                    ?>
                                    <div class="col-md-2">
                                        <div class="form-group">
                                            <label>From Date</label>
                                            <input type="date" name="start_date" class="form-control" value="<?php echo $start_date; ?>">
                                        </div>
                                    </div>
                                    <div class="col-md-2">
                                        <div class="form-group">
                                            <label>To Date</label>
                                            <input type="date" name="end_date" class="form-control" value="<?php echo $end_date; ?>">
                                        </div>
                                    </div>
                                    <div class="col-md-2">
                                        <div class="form-group">
                                            <label>Mobile No</label>
                                            <input type="text" name="mobile_no" class="form-control" value="<?php echo $mobile_no; ?>">
                                        </div>
                                    </div>
                                    <div class="col-md-2">
                                        <div class="form-group">
                                            <label>Status</label>
                                            <select name="status" class="form-control">
                                                <option value="">All</option>
                                                <option value="sent" <?php echo $status == "sent" ? 'selected="selected"' : ''; ?>>Sent</option>
                                                <option value="delivered" <?php echo $status == "delivered" ? 'selected="selected"' : ''; ?>>Delivered</option>
                                                <option value="read" <?php echo $status == "read" ? 'selected="selected"' : ''; ?>>Read</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="col-md-1">
                                        <div class="form-group">
                                            <label>&nbsp;</label>
                                            <button type="submit" name="btnSearch" class="btn btn-primary form-control">
                                                Search
                                            </button>
                                        </div>
                                    </div>
                    
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
            
			<?php  
			if(isset($_POST['btnSearch']))
			{
			    $where = array();
			    
                if (!empty($_GET['school_code'])) {
                    $school_code = mysqli_real_escape_string($con, $_GET['school_code']);
                    $where[] = "school_code = '$school_code'";
                }
                
                if (!empty($start_date) && !empty($end_date)) {
                    $where[] = "DATE(created_on) BETWEEN '$start_date' AND '$end_date'";
                }
                
                if(!empty($mobile_no)) {
                    $where[] = "received_mobile_no like '%$mobile_no'";
                }
                
                if (!empty($_POST['status'])) {
                
                    if ($_POST['status'] == 'read') {
                        $where[] = "is_read = 1 and is_delivered = 1 and is_sent = 1";
                    } elseif ($_POST['status'] == 'delivered') {
                        $where[] = "is_read = 0 and is_delivered = 1 and is_sent = 1";
                    } elseif ($_POST['status'] == 'sent') {
                        $where[] = "is_read = 0 and is_delivered = 0 and is_sent = 1";
                    }
                }
                
                $sql = "SELECT * FROM whatsapp_track_master_log";
                
                if (!empty($where)) {
                    $sql .= " WHERE " . implode(' AND ', $where);
                }
                
                $sql .= " ORDER BY id DESC";
                //echo $sql; exit;
                $result = mysqli_query($con, $sql);
			?>
				 
				
					<div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <div class="row">
                                <div class="col-lg-6">
                                    <b>WhatsApp Log Report (<?php echo Date('d-m-Y',strtotime($start_date))." to ".Date('d-m-Y',strtotime($end_date)); ?>)</b>
                                </div>
                                <div class="col-lg-6">
                                    
                                </div>
                            </div>
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                            <div class="table-responsive">
                            <table width="100%" class="table table-striped table-bordered table-hover" id="example">
                                <thead>
                                    <tr>
                                        <th>Date</th>
                                        <th>Recipient Name</th>
                                        <th>Mobile No</th>
                                        <th>Template Name</th>
                                        <th>Status</th>
                                        <th>Sent Time</th>
                                        <th>Delivered Time</th>
                                        <th>Read Time</th>
                                        <th>Action</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php
                                    while($row = mysqli_fetch_assoc($result))
                                    {
                                        $status_label = '<span class="label label-default">Pending</span>';
                                    
                                        if($row['is_read'] == 1){
                                            $status_label = '<span class="label label-success">Read</span>';
                                        }
                                        elseif($row['is_delivered'] == 1){
                                            $status_label = '<span class="label label-info">Delivered</span>';
                                        }
                                        elseif($row['is_sent'] == 1){
                                            $status_label = '<span class="label label-warning">Sent</span>';
                                        }
                                    ?>
                                    <tr>
                                        <td>
                                            <?php echo date('d-m-Y h:i A', strtotime($row['created_on'])); ?>
                                        </td>
                                        <td><?php echo htmlspecialchars($row['received_name']); ?></td>
                                        <td><?php echo $row['received_mobile_no']; ?></td>
                                        <td><?php echo $row['template_name']; ?></td>
                                        <td><?php echo $status_label; ?></td>
                                        <td>
                                            <?php
                                            echo !empty($row['sent_datetime'])
                                                ? date('d-m-Y h:i A', strtotime($row['sent_datetime']))
                                                : '-';
                                            ?>
                                        </td>
                                        <td>
                                            <?php
                                            echo !empty($row['delivered_datetime'])
                                                ? date('d-m-Y h:i A', strtotime($row['delivered_datetime']))
                                                : '-';
                                            ?>
                                        </td>
                                        <td>
                                            <?php
                                            echo !empty($row['read_datetime'])
                                                ? date('d-m-Y h:i A', strtotime($row['read_datetime']))
                                                : '-';
                                            ?>
                                        </td>
                                        <td>
                                            <button
                                                type="button"
                                                class="btn btn-xs btn-primary btnViewLog"
                                                data-toggle="modal"
                                                data-target="#viewModal"
                                                data-sent_by_name="<?php echo htmlspecialchars($row['sent_by_name'], ENT_QUOTES); ?>"
                                                data-message="<?php echo htmlspecialchars($row['message'], ENT_QUOTES); ?>"
                                                data-main_template="<?php echo htmlspecialchars($row['main_template'], ENT_QUOTES); ?>">
                                                View
                                            </button>
                                        </td>
                                    </tr>
                                    <?php } ?>
                                    </tbody>
                            </table>
                            </div>
                            <!-- /.table-responsive -->
                            <center>
								     
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>
				
				<?PHP
			}
			?>
    </div>
	
	<div class="modal fade" id="viewModal" tabindex="-1">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
    
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">
                        &times;
                    </button>
                    <h4 class="modal-title">WhatsApp Log Details</h4>
                </div>
    
                <div class="modal-body">
    
                    <table class="table table-bordered">
                        <tr>
                            <th width="20%">Sent By</th>
                            <td><pre id="modal_sent_by_name"></pre></td>
                        </tr>
    
                        <tr>
                            <th width="20%">Message</th>
                            <td><pre id="modal_message"></pre></td>
                        </tr>
                        
                        <tr>
                            <th width="20%">Main Template</th>
                            <td><pre id="modal_main_template"></pre></td>
                        </tr>
                    </table>
    
                </div>
    
            </div>
        </div>
    </div>
	
	
    <!-- jQuery -->
    <script src="https://smsoft.in/demo/student_management_system/vendor/jquery/jquery.min.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="https://smsoft.in/demo/student_management_system/vendor/bootstrap/js/bootstrap.min.js"></script>

    <!-- Metis Menu Plugin JavaScript -->
    <script src="https://smsoft.in/demo/student_management_system/vendor/metisMenu/metisMenu.min.js"></script>

    <!-- DataTables JavaScript -->
    
    <!-- Custom Theme JavaScript -->
    <script src="https://smsoft.in/demo/student_management_system/dist/js/sb-admin-2.js"></script>

 <script src="https://smsoft.in/demo/student_management_system/pages/report_js/jquery.dataTables.min.js"></script>
 <script src="https://smsoft.in/demo/student_management_system/pages/report_js/dataTables.bootstrap.min.js"></script>
 <script src="https://smsoft.in/demo/student_management_system/pages/report_js/dataTables.buttons.min.js"></script>
 <script src="https://smsoft.in/demo/student_management_system/pages/report_js/buttons.bootstrap.min.js"></script>
 <script src="https://smsoft.in/demo/student_management_system/pages/report_js/jszip.min.js"></script>
 <script src="https://smsoft.in/demo/student_management_system/pages/report_js/pdfmake.min.js"></script>
 <script src="https://smsoft.in/demo/student_management_system/pages/report_js/vfs_fonts.js"></script>
 <script src="https://smsoft.in/demo/student_management_system/pages/report_js/buttons.html5.min.js"></script>
 <script src="https://smsoft.in/demo/student_management_system/pages/report_js/buttons.print.min.js"></script>
 <script src="https://smsoft.in/demo/student_management_system/pages/report_js/buttons.colVis.min.js"></script>
<script>
$(document).ready(function() {
    var table = $('#example').DataTable( {
        lengthChange: false,
        buttons: [ 'copy', 'excel', 'pdf', 'colvis' ]
    } );
 
    table.buttons().container()
        .appendTo( '#example_wrapper .col-sm-6:eq(0)' );
        
        $(".is_staff_att").change(function() {
           if($(this).prop("checked")) {
               $(".staff_att_on").hide();
           } 
           else {
               $(".staff_att_on").show();
           }
        });
} );
</script>
<script>
$(document).on('click', '.btnViewLog', function () {
    $('#modal_sent_by_name').text($(this).data('sent_by_name'));
    $('#modal_message').text($(this).data('message'));
    $('#modal_main_template').text($(this).data('main_template'));
});
</script>
</body>

</html>

<?php
    } 
?>

MMCT - 2023