<?php // Configuration variables
session_start();
include 'dbc.php';


$userid=$_SESSION["userid"];
$from_date=$_POST["from_date"];
$cell=$_POST["cell"];
$month_name=$_POST["month_name"];

 $sql5 = "select * from rec_fee where date = '$from_date' and user_id='$userid'";
   $std_ledger15=mysql_query($sql5) or die("Error : " . mysql_error());

while($row5 = mysql_fetch_array($std_ledger15))
 
  {
 $amounts5=$amounts5 + $row5["paid_fee"];
 $anbal=$anbal + $row5["anbal"];
 $admbal=$admbal + $row5["admbal"];
 $regbal=$regbal + $row5["regbal"];
 $acbal=$acbal + $row5["acbal"];
 $securitybal=$securitybal + $row5["securitybal"];
 $netrec=$amounts5 +$anbal +$admbal +$regbal +$acbal +$securitybal;
  }
$sql = "select * from admission where today = '$from_date' and user_id='$userid'";
   $std_ledger1=mysql_query($sql) or die("Error : " . mysql_error());

while($row = mysql_fetch_array($std_ledger1))
 
  {
 $totaladm=$totaladm + 1;
 
  }
$sql1 = "select * from admission where user_id='$userid'";
   $std_ledger11=mysql_query($sql1) or die("Error : " . mysql_error());

while($row1 = mysql_fetch_array($std_ledger11))
 
  {
  $tbal=$tbal + $row1["bal"];
 $total=$total + 1;
 
  }
$sql2 = "select * from issueslip where monthname='$month_name' and status='unpaid' and user_id='$userid'";
   $std_ledger12=mysql_query($sql2) or die("Error : " . mysql_error());

while($row2 = mysql_fetch_array($std_ledger12))
 
  {
 $amounts2=$amounts2 + $row2["mfee"];
$totaldef=$totaldef + 1;
 
  }


	$type = "xml"; 
$id = "rchalainsch"; 
$pass = "alain786"; 
$lang = "English"; 
$mask = "AlainSchool";     
// Data for text message 
$to = $cell; 
$message =  $userid . ":<br>FINANCE SUMMARY DATE:" . $from_date . ":<br> TOTAL STUDENT:" . $total . ":<br>NEW ADMISSIONS:" . $totaladm . ":<br>FEE:" . $amounts5 . ":<br>ANNUAL:" . $anbal .":<br>NET FEE RECEIPT:" . $netrec .  ":<br>FEE DEFAULTERS:" . $amounts2 . "/" . $totaldef . ":<br>REMAINING PRE BAL:" . $tbal; 
$message1 =  $message; 

$message = urlencode($message);   
// Prepare data for POST request 
$data = "id=".$id."&pass=".$pass."&msg=".$message."&to=".$to."&lang=".$lang."&mask=".$mask."&type=".$type;   
// Send the POST request with cURL 
$ch = curl_init('http://www.outreach.pk/api/sendsms.php/sendsms/url'); 
curl_setopt($ch, CURLOPT_POST, true); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
$result = curl_exec($ch); 
//This is the result from Outreach 

curl_close($ch); 
	$sql16 = "Insert into notice (id,date,month_name,sname,notice,total,user_id,cell_1) values (null,'$from_date','$my','Finance Summary','$message1','1','$userid','$to')";
mysql_query($sql16) or die("Error : " . mysql_error());

	
	echo "Message Send";

 

?> 
<a href="daily_fee_collection_period.php">Back</a>