<?php include("parent/callMe.php"); ?>
<?php  include("sessioncheck.php"); ?>
<?php
$branch=$_SESSION['branch'];
//$date=sprintf("%02d", date('Y-m-d'))."-";


$default;
    
    if($_GET["month"]!=NULL ){
      $default= $_GET["month"];
    }
    else{
      $default= date("m");
    }

    if(isset($_REQUEST['month'])) {

      $date=$_GET['session']."-".sprintf("%02d", $_GET['month']);
   } else {

      $date=date('Y-m');
   }
   
   /*$m->where("branch_id", $_SESSION['branch']);
   $messages = $m->get("edu_messages_details");*/


$msgFrom=$_REQUEST['cell'];
$sql="SELECT msg_status, msg_details, msg_sender, msg_from, msg_date, msg_count, msg_details FROM edu_messages_details WHERE branch_id='$branch' and msg_from = '$msgFrom' order by msg_id desc limit 0,500 ";
   //print_r($sql);

$WorkAssignListings=$m->query($sql);

$sql2="SELECT first_name FROM edu_student_details WHERE branch_id='$branch' and student_id=".$_REQUEST['student'];
   //print_r($sql);

$stdName=$m->query($sql2);

 
     ?>


<!DOCTYPE html>
<html lang="en">
  <head>
    
    <title>Sent Message | EduPortal</title>
    <?php include('RootMe/css_links.php');?>
   
  </head>
  

<script type="text/javascript">

function show_message(){
  
  $("#msg").slideDown('slow').delay(4000).slideUp('slow');
}

</script>

  <body class="nav-md">
    <div class="container body">
      <div class="main_container">
        <div class="col-md-3 left_col">
     
            <?php include('RootMe/sidebar.php');?>

              <?php include('RootMe/header.php');?>
     
        <!-- page content -->
          <div class="right_col" role="main">
          <div class="row" style="background-color: white;">

            <a href="dashboard.php">Dashboard </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp; 
              
             <i style="" class="fa fa-angle-double-right"></i>  &nbsp;  

               Student SMS History   

                
           
    <section class="add_sub_agent" id="table_sub_agent">
  <div class="container">

 <div class="" style="margin-top:20px;">
      <form class="" action="sent_message.php" enctype="multipart/form-data" method="get">
        <div class="panel panel-default">
          <h3 style="float: left;">Sent Messages To <?php echo $stdName[0]['first_name'];?> <small>(<?php echo count($WorkAssignListings);?> Messages Found)</small> </h3>

          <input type="hidden" value="<?php echo session_id().session_id().session_id().session_id().session_id(); ?>" name="session" />


<div class="pull-right">         

 
 
  

 

<?php 

 if($_REQUEST['class_id']!=NULL){

?>

  <a target="_blank" title="Print Students List" href="class_print.php?<?php echo session_id().session_id().session_id().session_id().session_id(); ?>&class_id=<?php echo $_GET['class_id'];?>&section=<?php echo $_GET['section'];?>">
    <img src="img/print_icon.png" height="30" width="30" />
  </a>

<?php 

   }
?>

</div>



          </span><div class="clearfix"></div> </div>
          <div class="panel-body">
          
            
            <div class="clearfix"></div>
          </div>
        </div>
      </form>
      <div class="clearfix"></div>
    </div>
    <br>

     
          
          <?php  if(isset($_SESSION['sent_msg'])){?>


            <div class="alert alert-success" id="msg">
             <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
              <strong>Success!</strong> Message is sent successfully...
            </div>


          <?php  unset($_SESSION['sent_msg']); }?>

      

          
          <?php  if(isset($_SESSION['upsuccess'])){?>


            <div class="alert alert-success" id="msg">
             <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
              <strong>Success!</strong> Student record is updated successfully...
            </div>


          <?php  unset($_SESSION['upsuccess']); }


          ?>

      


<div style="">

<table id="listofstudents" class="table table-striped table-bordered" style="width:100%">
        <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="8%">  MSG Cost  </th>
                <th width="10%"> Copy MSG  </th>
                
            </tr>
        </thead>
        <tbody>

     
     <?php 
     $count=1;
      for($i=0;$i<count($WorkAssignListings);$i++)
      { 
         
      ?>

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

                  <td style="text-align:center;"> <?php echo $count; $count++; ?> </td>
                  <td> <?php echo str_replace("||","'",$WorkAssignListings[$i]['msg_details']);?> </td>
                  <td> <?php echo $WorkAssignListings[$i]['msg_sender'];?> </td>
                  <td> <?php echo $WorkAssignListings[$i]['msg_from'];?> </td>
                  <td style="text-align:center;"> <?php 

                  echo date("d-M-Y",strtotime($WorkAssignListings[$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"  />
                  
                 
                   <!--  <img style="height:23px;with:35px;" src="https://upload.wikimedia.org/wikipedia/commons/thumb/6/6f/Email-not-available.svg/2000px-Email-not-available.svg.png" />
 -->
                  
                   </td>

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

                   <td style="text-align:center;">
                    <a href="messages.php?msg=<?php echo $WorkAssignListings[$i]['msg_details'];?>"> Copy </a> </td>

              </tr>





              <?php
      } ?>



           
            
           
        </tbody>
        
    </table>
</div>

    <br><br>


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

           
          </div>
        </div>

            </div>
          </div>
        </div>
        <!-- /page content -->
  
<?php include('RootMe/js_linksscript.php');?>

<!-- Links for Datatable-->
 

<script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>
    <script>
        $(document).ready(function() {
        $('#listofstudents').DataTable();
        } 
        );
    </script>

  </body>
</html>
