MMCT TEAM
Server IP : 2a02:4780:3:1378:0:3736:a38e:10  /  Your IP : 3.138.123.118
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/src/../

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/u926327694/domains/smsoft.in/public_html/demo/src/../user_fees_process_calcu.php
 <?php 
$_SESSION['flag_link']="done";
    // 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['Phone_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/config.php";
include "config/config.php";
$countCC=$_SESSION['subamount'];
include_once 'sms.php';
$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="";



 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"];
//echo $paymentmode."<br>";
$Fine=$_POST["Fine"]; 
$total=$_POST['total'];
$Grand_Total=$_POST["Grand_Total"];
//echo "G=$Grand_Total";
//echo "<br>";


//$dn="";
 
if($paymentmode == "Online")
{
 
$flag=0;	
}

 

foreach ($subAr as $id) 
{
// 	echo "subhead=$id<br>";
$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) 
    {
    // 	echo "head=$headId<br>";
       $bank_id_res=mysqli_query($con,"select `Bank_Code` from `head` where `Head_Id` = '$headId'");
    $bank_id=mysqli_fetch_array($bank_id_res);
    $bank_link_res=mysqli_query($con,"select `Link` from `bankaccounts` where `Id` = '$bank_id[0]'");
    $bank_link=mysqli_fetch_array($bank_link_res);
    preg_match('/(upi)/', $bank_link['0'], $matches, PREG_OFFSET_CAPTURE);
    if(sizeof($matches) <= 0)
    {
        ?>
        <script>
            alert("This Bank Does Not Support Online Payment, Contact School Administrator to Update a UPI Link");
            window.location="user_Pay_fees.php";
            </script>
          
        <?php
        //header("Location: user_Pay_fees.php");
          exit();
    }
   
    
    
    
        

    		$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   */

		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";
          //echo "DR Type=$Dr_Ledger_Name";


        }



// echo "$i<br>";
  $Paid=$sub['Paid'];
      $Balance=$sub['Balance'];
// echo "Before == Paid=$Paid $$ Balance = $Balance<br>";
      $Paid=$Paid+$countCC[$ctr];
       $Balance=$Balance-$countCC[$ctr];
    //   echo "Paid=$Paid $$ Balance = $Balance<br>";
      

    //   echo "$countCC[$ctr]<br>";
    if(!mysqli_query($con,"UPDATE `stud_basic2` SET `Paid` = '$Paid', `Balance` = '$Balance' WHERE `Subhead_Id` = '$id1' and 
    `Stud_Id`='$sid'"))
						{
	    			  echo("Error description: " . 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];
               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: " . mysqli_error($con));
            }
 
            }


            else // Insert
            {

              if(!$v_counter_res=mysqli_query($con,"select MAX(`v_counter`) from `vochers` where `Type` = 'Recipt'"))
                {
                        
                echo("Error description: " . mysqli_error($con));
                 }           
            $rep_code=mysqli_fetch_array($v_counter_res);
           $v_counter=$rep_code['0']+1;
 

                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: " . 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 
			//echo "<br>$subheadid";
        $sublist=$sublist."/".$sub['Subhead_Id'];
        $headAmt=$headAmt."/".$countCC[$ctr];


// 			echo "<br>HeadId=$headId<>Subhead=$subheadid<>$headAmt<br>";
      $ctr++;

    	} // subheadloop
    		$rep_code_res=mysqli_query($con,"select * from `head` where Head_Id = '$headId'");
    		$rep_code=mysqli_fetch_array($rep_code_res);
    		if(!$rep_code_res1=mysqli_query($con,"select MAX(`ReciptCounter`) from `paid_fees` where `Head_Id` = '$headId'"))
    		{
    			  echo("Error description: " . mysqli_error($con));

    		}    		
    		$rep_code1=mysqli_fetch_array($rep_code_res1);
    		$cnt=$rep_code1['0']+1;
    		
    		
    			     	/*Head Recp Name*/
    		$Recp_Book_Name=$rep_code['ReciptName'];
    		
    		
    		if(!$rep_book_res1=mysqli_query($con,"select MAX(`Recp_Book_Counter`) as count from `paid_fees` where `Recp_Book_Name` = '$Recp_Book_Name'"))
    		{
    			  echo("Error description: " . mysqli_error($con));

    		} 
    		
    		$rep_book_code=mysqli_fetch_array($rep_book_res1);
    		$Recp_Book_Counter=$rep_book_code['0']+1;
    		
    		
    		$Recp_Book_No="$rep_code[ReciptName]"."-"."$Recp_Book_Counter";
    		
    		
    		
    		$ReciptCounter="$rep_code[ReciptName]"."-"."$cnt";
    		$reptview="$ReciptCounter"."/"."$reptview";
    			$reptviewBook="$Recp_Book_No"."/"."$reptviewBook";
    		
// 			echo "<br>$ReciptCounter<br>";

   
      $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;
    //echo "$c_due";
    
  }


  $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="";

    //   echo "end<br>";

      //echo "$ReciptList<br>";
      $_SESSION['ReciptList']=$ReciptList;
    
			//echo "<br><br><br>";
    	
    } // head loop
    
//header("Location: login.php");

    $lk=$bank_link['0'];
    //echo $lk;
    
header("Location: $lk");
//header("Location: phonepaylink.php");

    //  echo $bank_link['0'];


   ?>
  


MMCT - 2023