<?php
include "scrinit.php";
require "dbconnect.php"; 
    $usr=$_SESSION['usr'];
	$dt= $_SESSION['dt'];
	$per=$_GET['alp'];
	$sql = $dbcon->prepare("SELECT Name FROM teachers WHERE PMP = ? ");
    $sql->execute([$usr]);
    $row=$sql->fetch(PDO::FETCH_ASSOC);
    $name=$row['Name'];
	$day = date('D', strtotime($dt));
    $result = mysqli_query($con,"SELECT * FROM timetable WHERE pmp='$usr'  " ); 
    $row = mysqli_fetch_array($result);
    $id=$row['id']+1;
    $q = mysqli_query($con,"SELECT * FROM timetable WHERE id = '$id'");
    $row1 = mysqli_fetch_array($q);
    $dayf=$day.$per;
    $m=$row["$dayf"];
    $s=$row1["$dayf"];
    $ss=explode('/',$s);
    $room=$ss[0];
    $subject=$ss[1];

	require_once 'soapClient.class.php';
	$ws=new WebsmsClient($cfg);
	
	$sp=mysqli_query($con,"select smsname from sysset");
	$row=mysqli_fetch_array($sp);
	$sender = $row['smsname'];
	$credits1=$ws->getCredits();
	$r = mysqli_query($con,"SELECT toasf FROM sysset " ); 
    $rr = mysqli_fetch_array($r);
    $t=$rr['toasf'];
	$mes="SMS ALERT OMADA ASFALEIAS: ".$name." ".$room." ΤΜΗΜΑ: ".$m;
	$res=$ws->submitSM($sender,$t,$mes,"GSM");
	$credits2=$ws->getCredits();
	if($credits1 > $credits2)
	{
	    echo "Η ΔΙΑΔΙΚΑΣΙΑ ΟΛΟΚΛΗΡΩΘΗΚΕ ΜΕ ΕΠΙΤΥΧΙΑ";
	}
	
?>
