<?php
if (isset($_POST['addnote'])) {
  $package = $_POST['package'];
  $content = $_POST['content'];
  if (empty($content)) {
    $message =  "<div style='color:#e6102e'><i class='fa fa-warning fa-5x'></i><p><b>Please input all empty fields</b></p></div>";

  }else{

    $select = $conn->query("SELECT * FROM stp WHERE packageid = '$vlink2'");
    $fetch = $select->fetchAll(PDO::FETCH_OBJ);
    $count = $select->rowCount();
    $serial = 1;
    if ($count > 0) {
      foreach ($fetch as $value) {
      $studentid = $value->studentid;
       $in2 = array('iden' => $studentid,
                    'package' => $package
    );
       create('notification',$in2);
    }
  }

    $in = array('package' => $package,
          'text' => $content, 
    );   
    create('announcement',$in);
    
    $message = "<div style='color:#169f85'><i class='fa fa-check-circle-o fa-5x'></i><p><b>You have successfully added an announcement</b></p></div>";

      
        
  }
}

?>
<!-- page content -->
  
                <div class="x_panel">
                  <div class="x_title">
                    <div class="row">
                      <a href="?mod=hlecturer&link2=<?php echo $vlink2 ?>&action=announcements&point=add"><button class="btn btn-default <?php if(isset($_GET['point']) && $_GET['point'] == "add"){ echo "active";} ?>">Add Announcement</button></a>
                      <a href="?mod=hlecturer&link2=<?php echo $vlink2 ?>&action=announcements&point=view"><button class="btn btn-default <?php if(isset($_GET['point']) && $_GET['point'] == "view"){ echo "active";} ?>">View Announcements</button></a>
                    </div>
                    
                    <div class="clearfix"></div>
                  </div>
                  <?php
                  if(isset($_GET['point']) && $_GET['point'] == "add"){
                    include('pages/laddannouncement.php');
                  }elseif (isset($_GET['point']) && $_GET['point'] == "view") {
                    include('pages/lviewannouncement.php');
                  }else{
                    include('pages/laddannouncement.php');  
                  }
                  ?>
                  


                            </div>
                
        <!-- /page content -->
<div class="modal fade" id="myModal22" role="dialog">
    <div class="modal-dialog modal-sm">
      <div class="modal-content">
        <div class="modal-body text-center">
        <div id="inputHere">
<?php
if (isset($message)) {
echo "$message";
}
?>
        </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Ok</button>
        </div>
      </div>
    </div>
  </div>

<?php
if (isset($message)) {
?>
<script type="text/javascript">
$(document).ready(function(e) {
$('#myModal22').modal('show');
});
</script>
<?php
}
?>

