MMCT TEAM
Server IP : 2a02:4780:3:1378:0:3736:a38e:10  /  Your IP : 3.135.185.223
Web Server : LiteSpeed
System : Linux sg-nme-web1278.main-hosting.eu 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64
User : u926327694 ( 926327694)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF
Directory (0755) :  /home/u926327694/domains/smsoft.in/public_html/demo/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/u926327694/domains/smsoft.in/public_html/demo/pay_fees_process_calcu.php
 

 <?php 
    // First we execute our common code to connection to the database and start the session 
    require("common.php"); 
     
    // At the top of the page we check to see whether the user is logged in or not 
    if(empty($_SESSION['user'])) 
    { 
        // If they are not, we redirect them to the login page. 
        header("Location: login.php"); 
         
        // Remember that this die statement is absolutely critical.  Without it, 
        // people can view your members-only content without logging in. 
        die("Redirecting to login.php"); 
    } 
     
    // Everything below this point in the file is secured by the login system 
     
    // We can display the user's username to them by reading it from the session array.  Remember that because 
    // a username is user submitted content we must use htmlentities on it before displaying it to the user. 
    $a=$_SESSION['user']; 
    include("config/dbconnect.php");
    $SchoolCode=$_SESSION['code'];
    $sel_school=mysqli_query($con,"select * from schools where schoolCode='$SchoolCode'");
    $schoolformatfile="pay_fees_process_calcu_preview.php";
    $smsId="";
    $smsAPI="";
    $smsURL="";
    $smsTempId="";
    $smsown_num="";
    $smsIsActive=0;
    $sms_schoolname="";
    $wpIsActive = 0;
    while($school_row=mysqli_fetch_array($sel_school))
    {
        $schoolformatfile=$school_row['Receipt_file'];
        $smsId=$school_row['smsId'];
        $smsAPI=$school_row['smsAPI'];
        $smsURL=$school_row['smsURL'];
        $smsTempId=$school_row['smsTempId'];
        $smsown_num=$school_row['feesAlertNumbers'];
        $smsIsActive=$school_row['smsIsActive'];
        $sms_schoolname=$school_row['sms_schoolname'];
        $wpIsActive = $school_row['whatsappIsActive'];
    }
  ?> 
 <html>
     <head>
         <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
         <script>
//
 $("#loading").ajaxStart(function () {
    $(this).show();
 });

 $("#loading").ajaxStop(function () {
   $(this).hide();
 });
document.location="<?php echo $schoolformatfile; ?>";     
      
  

</script>
     </head>
     <body>
         <div id="loading" style="display:none;">
    Loading Please Wait....
    <img src="ajax-loader.gif" alt="Loading" />
</div>

<div>
    <?php

          //include "config/config.php";
        
        mysqli_close($con);  
              
include "config/config.php";
$countCC=$_SESSION['subamount'];

include_once 'sms.php';
$today= $_POST["today"];
$_SESSION['today']=$today;
//$today= date("Y-m-d");
$reci=$_POST["optionsRadios"];
$_SESSION['reci']=$reci;
$hdr=array();
$h=array();
$subAr=array();
$gt=0;
$ctr=0;
$headAmt="";
$ReciptList="";
$sublist="";
$totaa=0;
$reptview="";
$reptviewBook="";

$qq3=$_POST["ReceiptHead"];
              $_SESSION['ReceiptHead']=$qq3;

 if (isset($_SESSION['subAr']))
  if ($_SESSION['subAr'] != NULL)
  {
      $subAr=$_SESSION['subAr']; 	
      

  }
if (isset($_SESSION['headAr']))
  if ($_SESSION['headAr'] != NULL){
      $headAr=$_SESSION["headAr"]; 

  }
if (isset($_SESSION['key']))
  if ($_SESSION['key'] != NULL){
      $sid=$_SESSION['key'];                  
  }


   
$paymentmode=$_POST["paymentmode"];
$_SESSION['MainMode']=$paymentmode;
$Fine=$_POST["Fine"]; 
$total=$_POST['total'];
$Grand_Total=$_POST["Grand_Total"];
$smsbl="";
$dn="";
if($paymentmode == "Cash")
{
 $Cash=$_POST["Cash"];
 $flag=1;	
 $dn=$_POST["cash_details"];	
}
if($paymentmode == "Online")
{
 
$dn=$_POST["transaction_id_date"];	
$flag=1;
}

if($paymentmode == "Cheque")
{
 $dn=$_POST["Cheque_date_number"];	
$flag=0;
}

if($paymentmode == "DD")
{
 $dn=$_POST["DD_date_number"];	
$flag=1;

}

if($paymentmode == "Challan")
{
 $dn=$_POST["Challan_date_number"];	
$flag=1;
}
if($paymentmode == "ChallanTP")
{
    $paymentmode= "Challan";
    $dn=$_POST["Challan_date_number"];	
    $flag=0;
}
//echo"<pre>"; print_r($subAr); exit;
foreach ($subAr as $id) 
{
$sub_res1=mysqli_query($con,"select * from `stud_basic2` where `Subhead_Id` = '$id' and `Stud_Id` = '$sid'");
 $sub1=mysqli_fetch_array($sub_res1);
array_push($hdr, $sub1['Head_Id']);
}


 

 foreach ($subAr as $key => $value) 
 {
        $h[$hdr[$key]][] = $value;
 }


    
    foreach ($headAr as $headId) 
    {
    		$subheadid="";
    		$c_due=0;
    		 $totaa=0;
    	for ($i=0; $i < count($h[$headId]); $i++)
    	{ 

    		
$id1=$h[$headId][$i]; //sub head
$sub_res=mysqli_query($con,"select * from `stud_basic2` where `Subhead_Id` = '$id1' and `Stud_Id` = '$sid'");
 		$sub=mysqli_fetch_array($sub_res);
 		 
 		/* $sub['Head_Id']   //Head Id
		$sub['Subhead_Id'] //Subhead ID 
		$sub['Total_Amount']  //Total Amount 
		$sub['Paid'] //Paid Amount
		$sub['Balance'] //Balance   */
        
        //for sms
        $HeadNm=mysqli_query($con,"SELECT * from `head` where `Head_Id` = '$sub[Head_Id]' ");
         $head_res_sms=mysqli_fetch_array($HeadNm);
        $smsbl= $smsbl.$head_res_sms["Name"]." / TOT:".$sub['Total_Amount'] ."/ PD: ".$sub['Paid']." / BLC :".$sub['Balance'];
        
		if($flag==1) 
		{

      if($paymentmode=='Cash')
        $Dr_Ledger_Name='Cash';


       if($paymentmode !='Cash')
        {
          $BankGet_res=mysqli_query($con,"SELECT * from `head` where `Head_Id` = '$sub[Head_Id]' ");
          $BankGet_Details=mysqli_fetch_array($BankGet_res);
          $Bank_res=mysqli_query($con,"SELECT * from `bankaccounts` where `Id` = '$BankGet_Details[Bank_Code]' ");
          $Bank_Details=mysqli_fetch_array($Bank_res);




          $AccountNumber_RightFour=substr($Bank_Details['Account_Number'], -4);
          $Dr_Ledger_Name="$Bank_Details[Bank_Name]"."-"."$AccountNumber_RightFour";
          
        }



  $Paid=$sub['Paid'];
      $Balance=$sub['Balance'];
      $Paid=$Paid+$countCC[$ctr];
       $Balance=$Balance-$countCC[$ctr];
  
    //echo "PD=".$Paid."/ID=".$id1."<br />";

      if($_SESSION['Total_Amount'.$id1]=="0")
      {
          //echo "UPDATE `stud_basic2` SET `Paid` = '$Paid', Total_Amount= '0', `Balance` = '0' WHERE `Subhead_Id` = '$id1' and  `Stud_Id`='$sid'"."<br>";
          $savedata=mysqli_query($con,"UPDATE `stud_basic2` SET `Paid` = '$Paid', Total_Amount= '0', `Balance` = '0' WHERE `Subhead_Id` = '$id1' and  `Stud_Id`='$sid'");
      }
      else
      {
          //echo "UPDATE `stud_basic2` SET `Paid` = '$Paid', `Balance` = '$Balance' WHERE `Subhead_Id` = '$id1' and `Stud_Id`='$sid'"."<br>";
          $savedata=mysqli_query($con,"UPDATE `stud_basic2` SET `Paid` = '$Paid', `Balance` = '$Balance' WHERE `Subhead_Id` = '$id1' and `Stud_Id`='$sid'");
      }
    if(!$savedata)
						{
	    			  echo("Error description: er1" . mysqli_error($con));
						}


            // Accounts Vochers Pass Start
            $subn_res=mysqli_query($con,"select `Name` from `sub_head` where `Sub_Id` = '$id1'");
            $subn=mysqli_fetch_array($subn_res);
            $ExitsOrNot_res=mysqli_query($con,"SELECT * FROM `vochers` where `Date` = '$today' and `Cr_Ledger` = '$subn[0]' 
              and `Dr_Ledger` = '$Dr_Ledger_Name' "); 
               $ExitsOrNot=mysqli_num_rows($ExitsOrNot_res); 
            $ExistedAmount=mysqli_fetch_array($ExitsOrNot_res);
            // $subn[0] - Subhead Name 
            
            if($ExitsOrNot > 0 ) // Update
            {
              $ExistedAmount['Cr_Amount']+=$countCC[$ctr];
               // `Dr_Amount` = '$ExistedAmount[Cr_Amount]'  WHERE `V_Id` = '$ExistedAmount[V_Id]'";
               if($SchoolCode != "MGMS") {
                   if(!mysqli_query($con,"UPDATE `vochers` SET `Cr_Amount` = '$ExistedAmount[Cr_Amount]', 
                    `Dr_Amount` = '$ExistedAmount[Cr_Amount]'  WHERE `V_Id` = '$ExistedAmount[V_Id]'"))
                    {
                      echo("Error description:1 " . mysqli_error($con));
                    }
               }
 
            }


            else // Insert
            {

              if(!$v_counter_res=mysqli_query($con,"select MAX(`v_counter`) from `vochers` where `Type` = 'Recipt'"))
                {
                echo("Error description:2 " . mysqli_error($con));
                 }           
            $rep_code=mysqli_fetch_array($v_counter_res);
           $v_counter=$rep_code['0']+1;
            
            if($SchoolCode != "MGMS") {
                if(!mysqli_query($con,"INSERT INTO `vochers` (`Date`, `v_counter`, `Type`, `Cr_Ledger`, `Dr_Ledger`, `Cr_Ledger_Type`, `Dr_Ledger_Type`, `Cr_Amount`, `Dr_Amount`, `Nrtn`) VALUES  ('$today','$v_counter','Recipt','$subn[0]',
                  '$Dr_Ledger_Name','Income/Revenue','Current Assets','$countCC[$ctr]','$countCC[$ctr]','Fees Collected')"))
                {
                  echo("Error description:3 " . mysqli_error($con));
                }
            }

            }

            //Accounts Vocher End




         

















		}

			$subheadid=$subheadid."/".$sub['Subhead_Id'];
        $subb_res=mysqli_query($con,"select * from `sub_head` where Sub_Id = '$sub[Subhead_Id]'");
        $subb=mysqli_fetch_array($subb_res);
        //$totaa=$totaa+$subb['Amount'];
        $totaa=$totaa+$countCC[$ctr]; //Imp 
        
        $sublist=$sublist."/".$sub['Subhead_Id'];
        $headAmt=$headAmt."/".$countCC[$ctr];


      $ctr++;

    	} // subheadloop
    		$rep_code_res=mysqli_query($con,"select * from `head` where Head_Id = '$headId'");
    		$rep_code=mysqli_fetch_array($rep_code_res);
    		/*Head Recp Name*/
    		$Recp_Book_Name=$rep_code['ReciptName'];
    		
    		if(!$rep_code_res1=mysqli_query($con,"select MAX(`ReciptCounter`) AS MaxReciptCounter, MAX(`Recp_Book_Counter`) AS MaxRecp_Book_Counter from `paid_fees` where `Recp_Book_Name` = '$Recp_Book_Name'"))
    		{
    			  echo("Error description: " . mysqli_error($con));

    		}    
    			$rep_code1=mysqli_fetch_array($rep_code_res1);
    		$cnt=$rep_code1['MaxReciptCounter']+1;
    		$Recp_Book_Counter=$rep_code1['MaxRecp_Book_Counter']+1;
    		
    		
    		$Recp_Book_No="$rep_code[ReciptName]"."-"."$cnt";
    		
    		
    	
    		
           
    		
    		
    		$ReciptCounter="$rep_code[ReciptName]"."-"."$cnt";
    		
    		
    		
    		$reptview="$ReciptCounter"."/"."$reptview";
    		
    		$reptviewBook="$Recp_Book_No"."/"."$reptviewBook";
    		

   
      $due_res=mysqli_query($con,"SELECT * FROM `head` where `Head_Id` = '$headId'");
  $due=mysqli_fetch_array($due_res);
  if($due['Last_Date'] < $today)
  {
    $date1=date_create("$due[Last_Date]");
    $date2=date_create("$today");
    $diff=date_diff($date1,$date2);
    $difff= $diff->format("%a");
    $c_due=$due['Fine_Amount']*$difff;
    
    
  }


  $g_t=$totaa+$c_due;
  $ReciptList="$ReciptList"."/"."$ReciptCounter";
    		if(mysqli_query($con,"INSERT INTO `paid_fees` 
			(`Stud_Id`,`Recipt_No`,`ReciptCounter`,`Recp_Book_Name`, `Recp_Book_No`, `Recp_Book_Counter`, `Head_Id`, `Subhead_Ids`,`Sub_Amounts`, `Paid_date`, `Mode`,`DateNumber`, `Fine_Amount`, `Online_Charge`, `Total_Amount`, `Grand_Total`, `flag`,`user`) 
			VALUES 
			('$sid','$ReciptCounter','$cnt','$Recp_Book_Name','$Recp_Book_No','$Recp_Book_Counter', '$headId', '$subheadid','$headAmt', '$today','$paymentmode','$dn', '$c_due', '0', '$totaa', '$g_t', '$flag','$a[username]')"))
    	{
//header("location:pay_fees_process_calcu.php");
    		
    	}
      else
      {
         echo("Error description: " . mysqli_error($con));
      }
      $headAmt="";
      
      $_SESSION['ReciptList']=$ReciptList;
       $_SESSION['ReciptBookNumbers']=$reptviewBook;
    
    	
    } // head loop
    
//header("Location: login.php");
// header("Location: pay_fees_process_calcu_preview.php");

//Send SMS To Student
if($smsIsActive=="1")
{
    $r1=mysqli_query($con,"select * from `stud_basic` where `Stud_Id` = '$sid'");
    $row1=mysqli_fetch_array($r1);
    //$receiver="9898244359,8050482213";
    $receiver=$row1['Phone'];
    if($smsown_num!="")
    {
        $receiver=$receiver.",".$smsown_num;
    }
    $today= date("d-m-Y");
    if($SchoolCode=="smvclg")
    {
        $msg="Dears ". $row1['Name']." We Received Rs ".$Grand_Total." on ".$today." in the Mode of ".$paymentmode." Thanking You- EVIHBL";
        //$msg="Dears ". $row1['Name']." We Received Rs ".$Grand_Total." on ".$today." in the Mode of ".$paymentmode." Thanking You. -smv pu college -smv pu college";
    }
    else
    {
        $newText = $paymentmode." ".$sms_schoolname;
        $msg="Dears ". $row1['Name']." We Received Rs ".$Grand_Total." on ".$today." in the Mode of ".$newText." Thanking You- EVIHBL";
        //$msg="Dears ". $row1['Name']." We Received Rs ".$Grand_Total." on ".$today." in the Mode of ".$newText." Thanking You";
        //$msg="Dears ". $row1['Name']." We Received Rs ".$Grand_Total." on ".$today." in the Mode of ".$paymentmode." Thanking You -".$sms_schoolname;
    }
    
    $smsResult=SendSMSToUser($smsURL,$smsAPI,$smsId,$smsTempId,$receiver,$msg);
}

if($wpIsActive=="1")
{
    $r1=mysqli_query($con,"select * from `stud_basic` where `Stud_Id` = '$sid'");
    $row1=mysqli_fetch_array($r1);
    //$receiver="9898244359,8050482213";
    $receiver=$row1['Phone'];
    if($smsown_num!="")
    {
        $receiver=$receiver.",".$smsown_num;
    }
    $today= date("d-m-Y");
    if($SchoolCode=="smvclg")
    {
        $msg="Dears ". $row1['Name']." We Received Rs ".$Grand_Total." on ".$today." in the Mode of ".$paymentmode." Thanking You- EVIHBL";
        //$msg="Dears ". $row1['Name']." We Received Rs ".$Grand_Total." on ".$today." in the Mode of ".$paymentmode." Thanking You. -smv pu college -smv pu college";
    }
    else
    {
        $newText = $paymentmode." ".$sms_schoolname;
        $msg="Dears ". $row1['Name']." We Received Rs ".$Grand_Total." on ".$today." in the Mode of ".$newText." Thanking You- EVIHBL";
        //$msg="Dears ". $row1['Name']." We Received Rs ".$Grand_Total." on ".$today." in the Mode of ".$newText." Thanking You";
        //$msg="Dears ". $row1['Name']." We Received Rs ".$Grand_Total." on ".$today." in the Mode of ".$paymentmode." Thanking You -".$sms_schoolname;
    }
    
    $smsResult=sendWhatsappWithGlobal($receiver, $msg);
}
?>



</div>
     </body>
 </html>






MMCT - 2023