
PK 
<?php
ob_start();
//error_reporting(E_ALL ^ E_NOTICE);
@session_start();
ini_set('allow_url_include',1);
date_default_timezone_set("Asia/Kolkata");
set_time_limit(600);
ini_set('max_execution_time',600);
require_once '../includes/settings/PDODB.php';
include '../includes/modules/functions.php';
$function = new FUNCTIONS();
if(empty($_SESSION['adminId'])){
header("Location: ../index.php");
exit();
}
if(isset($_POST['btnPay']) && !empty($_POST)){
//print_r($_POST); //exit;
$from_date1 = !empty($_POST['from_date'])?$_POST['from_date']:"";
$from_date = date("Y-m-d", strtotime($from_date1));
$to_date1 = !empty($_POST['to_date'])?$_POST['to_date']:"";
$to_date = date('Y-m-d', strtotime($to_date1));
//print_r("<br> start date = ".$from_date." end date = ".$to_date); exit;
$balanceFee = !empty($_POST['balanceFee'])?trim($_POST['balanceFee']):"";
$totalPayableFee = !empty($_POST['totalPayableFee'])?trim($_POST['totalPayableFee']):"";
$oneTimePayment = !empty($_POST['oneTimePayment'])?trim($_POST['oneTimePayment']):"";
$particular = !empty($_POST['particular'])?trim($_POST['particular']):"";
$isdiscount = !empty($_POST['isdiscount'])?trim($_POST['isdiscount']):"";
$course_discount_rate = !empty($_POST['course_discount_rate'])?trim($_POST['course_discount_rate']):"";
$exclude_gst_price = !empty($_POST['exclude_gst_price'])?trim($_POST['exclude_gst_price']):"";
$include_gst_price = !empty($_POST['include_gst_price'])?trim($_POST['include_gst_price']):"";
$paymentOptions = !empty($_POST['paymentOptions'])?trim($_POST['paymentOptions']):"";
$batchTiming = !empty($_POST['batchTiming'])?trim($_POST['batchTiming']):"";
$installmentOptions = !empty($_POST['installmentOptions'])?trim($_POST['installmentOptions']):"";
$paymentMode = !empty($_POST['paymentMode'])?trim($_POST['paymentMode']):"";
$downPayment = !empty($_POST['downPayment'])?trim($_POST['downPayment']):"";
$transaction_id = !empty($_POST['transaction_id'])?trim($_POST['transaction_id']):"";
$bankname = !empty($_POST['bankname'])?trim($_POST['bankname']):"";
$chequeno = !empty($_POST['chequeno'])?trim($_POST['chequeno']):"";
$studentid = !empty($_POST['studentid'])?trim($_POST['studentid']):"";
$visitStudentdata = $function->getStudentVisit($id=$studentid,$isRegistation=2,$isActive=1,$orderBy='ASC');
$username = !empty($visitStudentdata[0]['username'])?trim($visitStudentdata[0]['username']):"";
$mobileno = !empty($visitStudentdata[0]['mobileno'])?trim($visitStudentdata[0]['mobileno']):"";
$uemail = !empty($visitStudentdata[0]['uemail'])?trim($visitStudentdata[0]['uemail']):"";
$dob = !empty($visitStudentdata[0]['dob'])?trim($visitStudentdata[0]['dob']):"";
$studentAddress = !empty($visitStudentdata[0]['studentAddress'])?trim($visitStudentdata[0]['studentAddress']):"";
$state = !empty($visitStudentdata[0]['state'])?trim($visitStudentdata[0]['state']):"";
$courseName = !empty($visitStudentdata[0]['courseName'])?trim($visitStudentdata[0]['courseName']):"";
$healthIssue = !empty($visitStudentdata[0]['healthIssue'])?trim($visitStudentdata[0]['healthIssue']):"";
$emergencyPhoneNo = !empty($visitStudentdata[0]['emergencyPhoneNo'])?trim($visitStudentdata[0]['emergencyPhoneNo']):"";
$relationWith = !empty($visitStudentdata[0]['relationWith'])?trim($visitStudentdata[0]['relationWith']):"";
$currentPastStudent = !empty($visitStudentdata[0]['currentPastStudent'])?trim($visitStudentdata[0]['currentPastStudent']):"";
$whichCourse = !empty($visitStudentdata[0]['whichCourse'])?trim($visitStudentdata[0]['whichCourse']):"";
$gstNo = !empty($visitStudentdata[0]['gstNo'])?trim($visitStudentdata[0]['gstNo']):"";
$companyName = !empty($visitStudentdata[0]['companyName'])?trim($visitStudentdata[0]['companyName']):"";
$companyAddress = !empty($visitStudentdata[0]['companyAddress'])?trim($visitStudentdata[0]['companyAddress']):"";
$companyState = !empty($visitStudentdata[0]['companyState'])?trim($visitStudentdata[0]['companyState']):"";
$error_msg = "";
$pdodb = PDODB::getInstance();
$sql = "INSERT INTO `tn_student` SET username='".$username."', mobileno='".$mobileno."', uemail='".$uemail."', dob='".$dob."', studentAddress='".$studentAddress."', state='".$state."', courseName='".$courseName."', healthIssue='".$healthIssue."', emergencyPhoneNo='".$emergencyPhoneNo."', relationWith='".$relationWith."', currentPastStudent='".$currentPastStudent."', whichCourse='".$whichCourse."', gstNo='".$gstNo."', companyName='".$companyName."', companyAddress='".$companyAddress."', companyState='".$companyState."'";
//exit;
$result = $pdodb->query($sql);
$insert_sid = $pdodb->lastInsertId();
$sqlvisit = "UPDATE `tn_studentvisit` SET isRegistation=1 WHERE id = '".$studentid."'";
$resultvisit = $pdodb->query($sqlvisit);
if (!empty($oneTimePayment)) {
//echo "oneTimePayment "; //exit;
if (!empty($gstNo)) {
//echo "with gst"; //exit;
$sql2 = "INSERT INTO `tn_order` SET studentId='".$insert_sid."',courseId='".$courseName."',totalFee='".$oneTimePayment."', gstNo='".$gstNo."', companyName='".$companyName."', companyAddress='".$companyAddress."', companyState='".$companyState."', startDate='".$from_date."', endDate='".$to_date."'";
//echo $sql2; exit;
$result2 = $pdodb->query($sql2);
$insert_oid = $pdodb->lastInsertId();
$sql3 = "INSERT INTO `tn_invoice` SET amount='".$oneTimePayment."', orderId='".$insert_oid."', gstNo='".$gstNo."', uId='".$insert_sid."', companyName='".$companyName."', companyAddress='".$companyAddress."', companyState='".$companyState."', isGst='1'";
$result3 = $pdodb->query($sql3);
$insert_invoice = $pdodb->lastInsertId();
$invoiceNo = "TFN/COM/2024/00".$insert_invoice;
$sqlupt = "UPDATE `tn_invoice` SET invoiceNo='".$invoiceNo."' WHERE id = '".$insert_invoice."'";
$resultupt = $pdodb->query($sqlupt);
if ($result2 == true && $result3 == true && $resultupt == true) {
$sql4 = "INSERT INTO `tn_accounts` SET uid='".$insert_sid."', debit='".$oneTimePayment."', particular='Invoice generated', invoice='".$invoiceNo."', gstNo='".$gstNo."', companyName='".$companyName."', companyAddress='".$companyAddress."', companyState='".$companyState."'";
//echo $sql2; exit;
$result4 = $pdodb->query($sql4);
$sql5 = "INSERT INTO `tn_accounts` SET uid='".$insert_sid."',orderid='".$insert_oid."',transaction_id='".$transaction_id."', credit='".$oneTimePayment."', particular='".$particular."', paymentMode='".$paymentMode."', bankname='".$bankname."', chequeno='".$chequeno."', invoice='".$invoiceNo."', gstNo='".$gstNo."', companyName='".$companyName."', companyAddress='".$companyAddress."', companyState='".$companyState."'";
//echo $sql2; exit;
$result5 = $pdodb->query($sql5);
if ($result5 == true) {
$error_msg = "Registation Succesfully Done";
}
}
} else {
//echo "without gst"; //exit;
$sql2 = "INSERT INTO `tn_order` SET studentId='".$insert_sid."',courseId='".$courseName."',totalFee='".$oneTimePayment."', studentName='".$username."', studentAddress='".$studentAddress."', studentState='".$state."', startDate='".$from_date."', endDate='".$to_date."'";
$result2 = $pdodb->query($sql2);
$insert_oid = $pdodb->lastInsertId();
$sql3 = "INSERT INTO `tn_invoice` SET amount='".$oneTimePayment."', orderId='".$insert_oid."', studentName='".$username."', uId='".$insert_sid."', studentAddress='".$studentAddress."', studentState='".$state."', isGst='2'";
$result3 = $pdodb->query($sql3);
$insert_invoice = $pdodb->lastInsertId();
$invoiceNo = "TFN/COM/2024/00".$insert_invoice;
$sqlupt = "UPDATE `tn_invoice` SET invoiceNo='".$invoiceNo."' WHERE id = '".$insert_invoice."'";
$resultupt = $pdodb->query($sqlupt);
if ($result2 == true && $result3 == true && $resultupt == true) {
$sql4 = "INSERT INTO `tn_accounts` SET uid='".$insert_sid."', debit='".$oneTimePayment."', particular='Invoice generated', invoice='".$invoiceNo."', studentName='".$username."', studentAddress='".$studentAddress."', studentState='".$state."'";
//echo $sql2; exit;
$result4 = $pdodb->query($sql4);
$sql5 = "INSERT INTO `tn_accounts` SET uid='".$insert_sid."',orderid='".$insert_oid."',transaction_id='".$transaction_id."', credit='".$oneTimePayment."', particular='".$particular."', paymentMode='".$paymentMode."', bankname='".$bankname."', chequeno='".$chequeno."', invoice='".$invoiceNo."', studentName='".$username."', studentAddress='".$studentAddress."', studentState='".$state."'";
//echo $sql2; exit;
$result5 = $pdodb->query($sql5);
if ($result5 == true) {
$error_msg = "Registation Succesfully Done";
}
}
}
} elseif (!empty($downPayment)) {
//echo "downPayment "; //exit;
if (!empty($gstNo)) {
//echo "with gst"; exit;
$sql2 = "INSERT INTO `tn_order` SET studentId='".$insert_sid."',courseId='".$courseName."', nosofInstallment='".$installmentOptions."', isInstallment='1',totalFee='".$totalPayableFee."',downPayment='".$downPayment."', balanceFee='".$balanceFee."', gstNo='".$gstNo."', companyName='".$companyName."', companyAddress='".$companyAddress."', companyState='".$companyState."', startDate='".$from_date."', endDate='".$to_date."'";
$result2 = $pdodb->query($sql2);
$insert_oid = $pdodb->lastInsertId();
$sql3 = "INSERT INTO `tn_invoice` SET amount='".$downPayment."', orderId='".$insert_oid."', gstNo='".$gstNo."', uId='".$insert_sid."', companyName='".$companyName."', companyAddress='".$companyAddress."', companyState='".$companyState."', isGst='1'";
$result3 = $pdodb->query($sql3);
$insert_invoice = $pdodb->lastInsertId();
$invoiceNo = "TFN/COM/2024/00".$insert_invoice;
$sqlupt = "UPDATE `tn_invoice` SET invoiceNo='".$invoiceNo."' WHERE id = '".$insert_invoice."'";
$resultupt = $pdodb->query($sqlupt);
for($i=1;$i<=$installmentOptions;$i++){
$installmentAmt = round($balanceFee/$installmentOptions);
$todaydate = date('d-m-Y');
$dt = strtotime($todaydate);
$dueDate = date("d-m-Y", strtotime("+".$i." month", $dt));
$sqlinstlmnt = "INSERT INTO `tn_installments` SET uId='".$insert_sid."',orderId='".$insert_oid."',amount='".$installmentAmt."',dueDate='".$dueDate."'";
$resultinstlmnt = $pdodb->query($sqlinstlmnt);
}
if ($result2 == true && $result3 == true && $resultupt == true) {
$sql4 = "INSERT INTO `tn_accounts` SET uid='".$insert_sid."', debit='".$downPayment."', particular='Invoice generated', invoice='".$invoiceNo."', gstNo='".$gstNo."', companyName='".$companyName."', companyAddress='".$companyAddress."', companyState='".$companyState."'";
//echo $sql2; exit;
$result4 = $pdodb->query($sql4);
$sql5 = "INSERT INTO `tn_accounts` SET uid='".$insert_sid."',orderid='".$insert_oid."',transaction_id='".$transaction_id."', credit='".$downPayment."', particular='".$particular."', paymentMode='".$paymentMode."', bankname='".$bankname."', chequeno='".$chequeno."', invoice='".$invoiceNo."', gstNo='".$gstNo."', companyName='".$companyName."', companyAddress='".$companyAddress."', companyState='".$companyState."'";
//echo $sql2; exit;
$result5 = $pdodb->query($sql5);
if ($result5 == true) {
$error_msg = "Registation Succesfully Done";
}
}
} else {
//echo "without gst"; exit;
$sql2 = "INSERT INTO `tn_order` SET studentId='".$insert_sid."',courseId='".$courseName."', nosofInstallment='".$installmentOptions."', isInstallment='1', totalFee='".$totalPayableFee."', downPayment='".$downPayment."', balanceFee='".$balanceFee."', studentName='".$username."', studentAddress='".$studentAddress."', studentState='".$state."', startDate='".$from_date."', endDate='".$to_date."'";
$result2 = $pdodb->query($sql2);
$insert_oid = $pdodb->lastInsertId();
$sql3 = "INSERT INTO `tn_invoice` SET amount='".$downPayment."', orderId='".$insert_oid."', studentName='".$username."', uId='".$insert_sid."', studentAddress='".$studentAddress."', studentState='".$state."', isGst='2'";
$result3 = $pdodb->query($sql3);
$insert_invoice = $pdodb->lastInsertId();
$invoiceNo = "TFN/COM/2024/00".$insert_invoice;
$sqlupt = "UPDATE `tn_invoice` SET invoiceNo='".$invoiceNo."' WHERE id = '".$insert_invoice."'";
$resultupt = $pdodb->query($sqlupt);
for($i=1;$i<=$installmentOptions;$i++){
$installmentAmt = round($balanceFee/$installmentOptions);
$todaydate = date('d-m-Y');
$dt = strtotime($todaydate);
$dueDate = date("d-m-Y", strtotime("+".$i." month", $dt));
$sqlinstlmnt = "INSERT INTO `tn_installments` SET uId='".$insert_sid."',orderId='".$insert_oid."',amount='".$installmentAmt."',dueDate='".$dueDate."'";
$resultinstlmnt = $pdodb->query($sqlinstlmnt);
}
if ($result2 == true && $result3 == true && $resultupt == true) {
$sql4 = "INSERT INTO `tn_accounts` SET uid='".$insert_sid."', debit='".$downPayment."', particular='Invoice generated', invoice='".$invoiceNo."', studentName='".$username."', studentAddress='".$studentAddress."', studentState='".$state."'";
//echo $sql2; exit;
$result4 = $pdodb->query($sql4);
$sql5 = "INSERT INTO `tn_accounts` SET uid='".$insert_sid."',orderid='".$insert_oid."',transaction_id='".$transaction_id."', credit='".$downPayment."', particular='".$particular."', paymentMode='".$paymentMode."', bankname='".$bankname."', chequeno='".$chequeno."', invoice='".$invoiceNo."', studentName='".$username."', studentAddress='".$studentAddress."', studentState='".$state."'";
//echo $sql2; exit;
$result5 = $pdodb->query($sql5);
if ($result5 == true) {
$error_msg = "Registation Succesfully Done";
}
}
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>INSPINIA | Basic Form</title>
<?php include_once '../layout/style.php'; ?>
<style type="text/css">
.control-label span { color: red; }
</style>
</head>
<body>
<div id="wrapper">
<?php $currentPage = 'visit-student-list'; include_once '../layout/side-bar.php'; ?>
<div id="page-wrapper" class="gray-bg">
<?php include_once '../layout/header.php'; ?>
<div class="row wrapper border-bottom white-bg page-heading">
<div class="col-lg-8">
<h2><?=!empty($error_msg)?$error_msg:'';?></h2>
</div>
</div>
</div>
</div>
<?php include_once '../layout/script.php'; ?>
</body>
</html>


PK 99