<?php include('includes/config.php');?>

<?php include('includes/session_check.php');?>

<?php   





$from;

$to;



 

      if($_REQUEST['from']!=" " && $_REQUEST['from']!=NULL ) {

        $from=date("Y-m-d",strtotime($_REQUEST['from']));  



      }else {

        $from=date("Y-m-01");  

      }

     

      if($_REQUEST['to']!=" " && $_REQUEST['to']!=NULL   ) {

        $to=date("Y-m-d",strtotime($_REQUEST['to']));

      }else {

        $to=date("Y-m-t");  

      } 

    



function time_elapsed_string($datetime, $full = false) {



        $now = new DateTime;



        $ago = new DateTime($datetime);



        $diff = $now->diff($ago);



        $diff->w = floor($diff->d / 7);



        $diff->d -= $diff->w * 7;







        $string = array(



            'y' => 'year',



            'm' => 'month',



            'w' => 'week',



            'd' => 'day',



            'h' => 'hour',



            'i' => 'minute',



            's' => 'second',



        );



        foreach ($string as $k => &$v) {



            if ($diff->$k) {



                $v = $diff->$k . ' ' . $v . ($diff->$k > 1 ? 's' : '');



            } else {



                unset($string[$k]);



            }



        }







        if (!$full) $string = array_slice($string, 0, 1);



        return $string ? implode(', ', $string) . ' ago' : 'just now';



    }



   

$curr_date = date("Y-m-d");

$previous_date=Date('Y-m-d', strtotime("-45 days"));





if($_GET['type']=="att"){

  $qr=" and attendance_msg='1' ";

}



if($_GET['type']=="fee"){

  $qr=" and fee_msg='1' ";

}



if($_GET['type']=="result"){

  $qr=" and result_msg='1' ";

}



if($_GET['type']=="other"){

  $qr=" and other_msg='1' ";

}







$sql="select * from edu_adminmessages_details where msg_date BETWEEN '" .$from. "' AND '" .$to. "'  ".$qr." order by msg_id desc limit 0,100";

// echo $sql; 



$messages = $db->query($sql);







?>







<!DOCTYPE html>

<html lang="en">

  <head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <!-- Meta, title, CSS, favicons, etc. -->

    <meta charset="utf-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1">



    <title>View Admin Messages | Admin Panal</title>



    <!-- Bootstrap -->

    <link href="../vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">

    <!-- Font Awesome -->

    <link href="../vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">

    <!-- NProgress -->

    <link href="../vendors/nprogress/nprogress.css" rel="stylesheet">

    <!-- iCheck -->

    <link href="../vendors/iCheck/skins/flat/green.css" rel="stylesheet">

    <!-- Datatables -->

    <link href="../vendors/datatables.net-bs/css/dataTables.bootstrap.min.css" rel="stylesheet">

    <link href="../vendors/datatables.net-buttons-bs/css/buttons.bootstrap.min.css" rel="stylesheet">

    <link href="../vendors/datatables.net-fixedheader-bs/css/fixedHeader.bootstrap.min.css" rel="stylesheet">

    <link href="../vendors/datatables.net-responsive-bs/css/responsive.bootstrap.min.css" rel="stylesheet">

    <link href="../vendors/datatables.net-scroller-bs/css/scroller.bootstrap.min.css" rel="stylesheet">



    <!-- Custom Theme Style -->

    <link href="../build/css/custom.min.css" rel="stylesheet">

  </head>



  <body class="nav-md">

    <div class="container body">

      <div class="main_container">



        <div class="col-md-3 left_col">



    



     

        <?php include('includes/sidebar.php');?>





        <?php include('includes/header.php');?>

  



        <!-- page content -->

        <div class="right_col" role="main">

          <div class="">

            <div class="page-title">

              <div class="title_left">

                <h3>View Admin Messages<small> (<?php echo count($messages);?> records)</small></h3>

              </div>



              <div class="title_right">

                <div class="col-md-5 col-sm-5 col-xs-12 form-group pull-right top_search">

                  <div class="input-group">

                    <input type="text" class="form-control" placeholder="Search for...">

                    <span class="input-group-btn">

                      <button class="btn btn-default" type="button">Go!</button>

                    </span>

                  </div>

                </div>

              </div>

            </div>



            <div class="clearfix"></div>



            <div class="row">

              <div class="col-md-12 col-sm-12 col-xs-12">

                <div class="x_panel">

                  <div class="x_title">

                    

                    <ul class="nav navbar-right panel_toolbox">

                      <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>

                      </li>

                      <li class="dropdown">

                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>

                        <ul class="dropdown-menu" role="menu">

                          <li><a href="#">Settings 1</a>

                          </li>

                          <li><a href="#">Settings 2</a>

                          </li>

                        </ul>

                      </li>

                      <li><a class="close-link"><i class="fa fa-close"></i></a>

                      </li>

                    </ul>

                    <div class="clearfix"></div>

                  </div>

                  <div class="x_content">









                     <form action="sent_messages.php?<?php echo session_id().session_id().session_id().session_id().session_id(); ?>">

                 



                

                     





           <div class="col-md-3" style="padding:8px; float:left;"  id="col1">

                 <div class="form-group ">



                 <label class="required"> From Date</label>

                 <input name="from"  id="from" value="<?php echo $from;?>" type="date" class="form-control"style=""  >

                       

                  </div>

                  </div>                      

             



                  <div class="col-md-3" style="padding:8px; float:left;"  id="col2">



                       <div class="form-group ">



                          <label class="required"> To Date</label>

                              <input name="to" id="to" value="<?php echo $to;?>" type="date" class="form-control" style=""  >

                       

                          </div>

                  </div>







                

                  <div class="col-md-1 " style="padding:8px;">

                <div class="form-group ">

                   <input type="hidden" name="addaccountAdmin" value="1">

                <button type="submit" class="search-button btn btn-primary .btn-default Search_btn transition-effect btn_new_btn" style="margin-top: 24px;background-color:#2A3F54;">Search</button>

                </div>

              </div> 

              

                            



            </form>



<br>

                    

                    <table id="datatable" class="table table-striped table-bordered">

                      <thead>

                        <tr>

                          <th width="5%">S.No</th>

                          <th width="40%">Messsage</th>

                          <th width="10%"> From </th>

                          <th width="10%"> Recepient </th>

                          <th width="10%" style="text-align:center;"> Date </th>

                          <th width="5%"> Status  </th>

                          <th width="10%">MSG Cost  </th>

                       

                                               

                        </tr>

                      </thead>

                      <tbody>



                        

 <?php 

     $count=1;

     for($i=0;$i<count($messages);$i++)

      {











?>

                <tr style="background-color:<?php if($messages[$i]['msg_status']=="Sent"){ echo "#DEF0D8"; }?>; ">



                         <td style="text-align:center;"> <?php echo $count; $count++; ?> </td>

                         <td> <?php echo $messages[$i]['msg_details'];?> </td>

                         <td> <?php echo $messages[$i]['msg_sender'];?> </td>

                         <td> <?php echo $messages[$i]['msg_from'];?> </td>

                         <td style="text-align:center;"> <?php 



                          echo date("d-M-Y",strtotime($messages[$i]['msg_date']));



                          //echo time_elapsed_string($WorkAssignListings[$i]['msg_date']);





                          ?>

                          

                          

                           </td>



                           <td style="text-align:center;"> 



                          <?php// if($WorkAssignListings[$i]['msg_status']=="Sent"){?>



                            <img style="height:35px;with:35px;" src="https://filipinohomes.com/images/msgsent.png"  />

                               

                                           

                           </td>



                           <td> <?php echo $messages[$i]['msg_count'];?> </td>

                          

                        </tr>

<?php } ?>

                      



                      </tbody>

                    </table>

                  </div>

                </div>

              </div>



            

             

            </div>

          </div>

        </div>

        <!-- /page content -->



 <?php include('includes/footer.php');?>





      </div>

    </div>



    <!-- jQuery -->

    <script src="../vendors/jquery/dist/jquery.min.js"></script>

    <!-- Bootstrap -->

    <script src="../vendors/bootstrap/dist/js/bootstrap.min.js"></script>

    <!-- FastClick -->

    <script src="../vendors/fastclick/lib/fastclick.js"></script>

    <!-- NProgress -->

    <script src="../vendors/nprogress/nprogress.js"></script>

    <!-- iCheck -->

    <script src="../vendors/iCheck/icheck.min.js"></script>

    <!-- Datatables -->

    <script src="../vendors/datatables.net/js/jquery.dataTables.min.js"></script>

    <script src="../vendors/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>

    <script src="../vendors/datatables.net-buttons/js/dataTables.buttons.min.js"></script>

    <script src="../vendors/datatables.net-buttons-bs/js/buttons.bootstrap.min.js"></script>

    <script src="../vendors/datatables.net-buttons/js/buttons.flash.min.js"></script>

    <script src="../vendors/datatables.net-buttons/js/buttons.html5.min.js"></script>

    <script src="../vendors/datatables.net-buttons/js/buttons.print.min.js"></script>

    <script src="../vendors/datatables.net-fixedheader/js/dataTables.fixedHeader.min.js"></script>

    <script src="../vendors/datatables.net-keytable/js/dataTables.keyTable.min.js"></script>

    <script src="../vendors/datatables.net-responsive/js/dataTables.responsive.min.js"></script>

    <script src="../vendors/datatables.net-responsive-bs/js/responsive.bootstrap.js"></script>

    <script src="../vendors/datatables.net-scroller/js/dataTables.scroller.min.js"></script>

    <script src="../vendors/jszip/dist/jszip.min.js"></script>

    <script src="../vendors/pdfmake/build/pdfmake.min.js"></script>

    <script src="../vendors/pdfmake/build/vfs_fonts.js"></script>



    <!-- Custom Theme Scripts -->

    <script src="../build/js/custom.min.js"></script>



  </body>

</html>