<?php
    include "scrinit.php";
    $usr=$_SESSION['usr'];
	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();
	$des=$_SESSION['tel'];
	$mes=$_SESSION['sms1'];
	
	$sql = "SHOW TABLE STATUS LIKE 'smsout'";
	$result=$con->query($sql);
	$row = $result->fetch_assoc();
	$smc= $row['Auto_increment'];
	foreach ($des as $t)
	{
		if ($t <> 0)
		{
			echo $mes."  ".$t;	
		    $res=$ws->submitSM($sender,$t,$mes,"GSM");
			if ($res)
			{  $dtm = date('Y-m-d H:i:s');
			   $sql = $dbcon->prepare("insert into smsout (datetm,smscode,tel) values(?,?,?)");
	           $sql->execute([$dtm,$smc,$t]);
			}
		}
	}
	$credits2=$ws->getCredits();
	if($credits1 > $credits2)
	{
		$sql = $dbcon->prepare("insert into smsoutmes (smscode,mes,senderpmp,source) values(?,?,?,?)");
        $sql->execute([$smc,$mes,$usr,"poini"]);
	}
	
	$credits2=$ws->getCredits();
	echo "<p>";
	echo "<p>"."ΑΡΧΙΚΕΣ ΜΟΝΑΔΕΣ:".$credits1."</p>";
	echo "<p>"."ΥΠΟΛΟΙΠΟΜΕΝΕΣ ΜΟΝΑΔΕΣ:".$credits2."</p>";
	
	
	
	
?>
<br />
<a  href=<?php echo $menu;?> style="color:blue "  > <button> Επιστροφή στο Μενού   </a>
</body>
</html>