<?php
include "scrinit.php";
	require_once 'soapClient.class.php';
	$ws=new WebsmsClient($cfg);
	$usr=$_SESSION['usr'];
	$fl='allanapl';
	$sp=mysqli_query($con,"select smsname from sysset");
	$row=mysqli_fetch_array($sp);
	$sender = $row['smsname'];
	$credits1=$ws->getCredits();
	$mes=$_SESSION['sm'];
	$des=$_SESSION['tel'];
	$sql = $dbcon->prepare("SELECT MAX(smscode) as maxcode FROM smsout ");
    $sql->execute();
    $row=$sql->fetch(PDO::FETCH_ASSOC);
    $smc=$row['maxcode']+1;
	echo "<br>";
	$i=0;
	foreach ($des as $t)
	{
		
		if (!empty($t) or $t <> 0)
		{
		$mesg=$mes[$i];
	    $res=$ws->submitSM($sender,$t,$mesg,"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]);
		}
		echo "<br>".$mesg." ".$t;
		$i++;
		}
	}
	echo "<br>";
	
	echo "ΕΧΟΥΝ ΣΤΑΛΕΙ ".$i." ΜΗΝΥΜΑΤΑ";
	$credits2=$ws->getCredits();
	echo "<p>";
	echo "<p>"."ΑΡΧΙΚΕΣ ΜΟΝΑΔΕΣ:".$credits1."</p>";
	echo "<p>"."ΥΠΟΛΟΙΠΟΜΕΝΕΣ ΜΟΝΑΔΕΣ:".$credits2."</p>";
	/*if($credits1 > $credits2)
	{
		$sql = $dbcon->prepare("insert into smsoutmes (smscode,mes,senderpmp,source) values(?,?,?,?)");
        $sql->execute([$smc,$mes,$usr,$fl]);
	}
	*/

	
?>
<br /><br />
<a  href=<?php echo $menu;?> style="color:blue "  > <button> Επιστροφή στο Μενού   </a>
</body>
</html>