Server : Apache System : Linux profile 3.10.0-1160.88.1.el7.x86_64 #1 SMP Tue Mar 7 15:41:52 UTC 2023 x86_64 User : apache ( 48) PHP Version : 8.0.28 Disable Function : NONE Directory : /var/www/html/mmishra/erp-10-07-2018/controllers/ |
<?php
//if (!class_exists($erpController)) {
require_once __DIR__."/erp_controller.php";
//}
class aaaController extends erpController {
var $model;
var $channel;
public function __construct($aaaModel) {
// call parent constructor
// parent::__construct();
// initialize variables
$this->model = $aaaModel;
$this->appURL = $_SERVER["REQUEST_URI"]; // this is Request URI for log entry
$this->referer = $_SERVER["HTTP_REFERER"]; // requires for log entry, not mandatory
$this->loginID = $_SESSION["loginID"]; // current user id
$this->sessionID = $_SESSION["sessionID"]; // current session id
$this->appID = $_SESSION["appID"]; // current application id
$this->moduleID = isset($_SESSION["moduleID"]) ? $_SESSION["moduleID"] : 1;
$this->userIP = $this->getIP();
$this->filterText = $_POST['filterText'];
// maintain erp activity log for inner contents
if ($this->loginID && strpos($this->appURL, 'inner')) {
//echo 'erpa';
$this->model->erpLog($this->loginID, $this->userIP, $this->appURL, $this->referer);
}
}
public function __destruct() {
// echo $erpModel->sqlCommand;//'Destroying: ', $this->moduleID, PHP_EOL;
// log sql operation on corresponding table
// call $erpModel->erpSql($sql);
// print("Thanks.");
}
public function manageProgram($action, $programID) {
$this->model->tableID = 'aaa_programs';
$this->model->tupleID = $programID;
switch ($action) {
case 'new':
case 'edit':
$this->editLock = '';
break;
case 'open':
case 'help':
case 'trash':
break;
case 'save':
// save record
$instituteID = $_POST['instituteID'];
$programCode = $_POST['programCode'];
$programName = $_POST['programName'];
$degreeLevel = $_POST['degreeLevel'];
$timeDuration = $_POST['timeDuration'];
$rollnoPrefix = $_POST['rollnoPrefix'];
$entranceBoard = $_POST['entranceBoard'];
$entranceName = $_POST['entranceName'];
$intakeLimit = $_POST['intakeLimit'];
$lastRollno = $_POST['lastRollno'];
$this->model->saveProgram($instituteID,$programCode,$programName,$degreeLevel,$timeDuration,$rollnoPrefix,$entranceBoard,$entranceName,$intakeLimit,$lastRollno);
$this->model->sqlLog();
$this->errorText = 'Program record saved successfully.';
break;
case 'upper':
// enable record
$this->model->upperProgram();
$this->errorText = 'Program record moved up/left successfully.';
break;
case 'lower':
// disable record
$this->model->lowerProgram();
$this->errorText = 'Program record moved down/right successfully.';
break;
case 'enable':
// enable record
$this->model->enableProgram();
$this->model->sqlLog();
$this->errorText = 'Program record enabled successfully.';
break;
case 'disable':
// disable record
$this->model->disableProgram();
$this->model->sqlLog();
$this->errorText = 'Program record disabled successfully.';
break;
case 'delete':
// delete record
$this->model->deleteProgram();
$this->model->sqlLog();
$this->errorText = 'Program record deleted successfully.';
break;
}
return $this->model->tupleID;
}
public function manageFeehead($action, $headID) {
$this->model->tableID = 'aaa_feeheads';
$this->model->tupleID = $headID;
switch ($action) {
case 'new':
case 'edit':
$this->editLock = '';
break;
case 'open':
case 'help':
case 'trash':
break;
case 'save':
// save record
$i = 0;
foreach ($_POST['headID'] as $headID) {
$this->model->tupleID = $headID;
$instituteID = $_POST['instituteID'];
$programID = $_POST['programID'];
$batchYear = date("Y");
$category = $_POST['category'][$i];
$headName = $_POST['headName'][$i];
$accountType = $_POST['accountType'][$i];
$paymentTerm = $_POST['paymentTerm'][$i];
$feeAmount = $_POST['feeAmount'][$i];
$currency = $_POST['currency'][$i];
if (!$feeAmount) $feeAmount = 0;
$i++;
if ($headName) {
//echo $headID.'-'.$instituteID.'-'.$programID.'-'.$batchYear.'-'.$category.'-'.$headName.'-'.$paymentTerm.'-'.$feeAmount.'-'.$currency."<br>";
$this->model->saveFeehead($instituteID,$programID,$batchYear,$category,$headName,$accountType,$paymentTerm,$feeAmount,$currency);
} else {
$this->model->deleteFeehead();
}
$this->model->sqlLog();
}
$this->errorText = 'Fees record saved successfully.';
break;
}
return $this->model->tupleID;
}
public function manageDocument($action, $documentID) {
$this->model->tableID = 'aaa_documents';
$this->model->tupleID = $documentID;
switch ($action) {
case 'new':
case 'edit':
$this->editLock = '';
break;
case 'open':
case 'help':
case 'trash':
break;
case 'save':
$i = 0;
foreach ($_POST['documentID'] as $documentID) {
$this->model->tupleID = $documentID;
$instituteID = $_POST["instituteID"];
$programID = $_POST["programID"];
$batchYear = date("Y");
$category = $_POST["category"][$i];
$documentCode = $_POST["documentCode"][$i];
$documentName = $_POST["documentName"][$i];
$specification = $_POST["specification"][$i];
$selfUpload = $_POST["selfUpload$i"] ? 1 : 0;
if ($documentCode) {
//echo "$programID,$category,$documentCode,$documentName,$specification,$selfUpload";
$this->model->saveDocument($instituteID,$programID,$batchYear,$category,$documentCode,$documentName,$specification,$selfUpload);
} else {
$this->model->deleteDocument();
}
$this->model->sqlLog();
$i++;
}
$this->errorText = 'Document record saved successfully.';
break;
}
return $this->model->tupleID;
}
public function manageImport($action, $instituteID) {
$this->model->tableID = 'aaa_candidates';
$this->model->tupleID = $instituteID;
switch ($action) {
case 'new':
case 'open':
break;
case 'upload':
// upload file and dump record
if (isset($_FILES["fileToUpload"]["name"])) {
//validate whether uploaded file is a csv file
$csvMimes = array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain');
$instituteID = $_POST['instituteID'];
$programID = 0; // updates thru manageOffer
$degreeLevel = $_POST['programID'];
$batchYear = date("Y");
$sourceFile = basename($_FILES["fileToUpload"]["name"]);
$uploadFile = strtolower("csv-" .$instituteID. "-" .date("Y-m-d"). "-" .str_replace(' ','-',$sourceFile));
$targetFile = __DIR__. "/../uploads/" .$uploadFile;
$extName = strtolower(pathinfo(basename($_FILES["fileToUpload"]["name"]), PATHINFO_EXTENSION));
// remove existing old file
if (file_exists($targetFile)) exec("rm -f $targetFile");
if ($_FILES["fileToUpload"]["size"] > 5500000) {
$this->errorText = "Sorry, file size too large.";
// Allow certain file formats
} else if ($extName != "csv") {
$this->errorText = "Sorry, only csv format supported.";
// if everything is ok, try to upload file
} else if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $targetFile)) {
// data cleansing
//if ($_POST['purgeOld'] == 1) $this->model->purgeCandidates($instituteID, $roundNo);
//open uploaded csv file with read only mode
$csvFile = fopen($targetFile, 'r');
//skip first line
fgetcsv($csvFile);
$roundNo = 0;
//parse data from csv file line by line
while(($line = fgetcsv($csvFile)) !== FALSE){
$no++;
$sn = trim($line[0]);
$rollNo = trim($line[1]); // RollNo
$nameEnglish = trim($line[2]); // Name
$category = trim($line[3]);
$pwdStatus = trim($line[4]); // PwD
$gender = trim($line[5]);
$dateBirth = str_replace('/', '-', trim($line[6])); // DOB
$stateEligibility = trim($line[7]); // StateEligibility
$nationality = trim($line[8]);
$programName = trim($line[9]); // AllocatedProgram
$allotedCategory = trim($line[10]); // AllocatedCat
$allotedRank = trim($line[11]);
$allotedRank = $allotedRank ? $allotedRank : 0;
$choiceNo = trim($line[12]);
$choiceNo = $choiceNo ? $choiceNo : 0;
$quota = trim($line[13]);
$roundName = trim($line[14]);
$willingness = trim($willingness[15]);
$status = trim($line[16]);
$rcName = trim($line[17]);
$remark = trim($line[18]); // RemarksbyRC
if ($no == 1) {
$roundNo = $this->model->getRoundNoByInstituteID($instituteID, $degreeLevel);
$roundNo++;
}
$candidateID = $this->model->getCandidateIDByRollNo($rollNo);
$this->model->tupleID = $candidateID ? $candidateID : 0;
// if record exists, it will be updated with new roundNo
//echo "<font size=-1>$sn,$instituteID,$programID,$batchYear,$roundNo,$degreeLevel,$rollNo,$nameEnglish,$category,$pwdStatus,$gender,$dateBirth,$stateEligibility,$nationality,$programName,$allotedCategory,$allotedRank,$choiceNo,$quota,$roundName,$status,$rcName,$remark</font><br>";
$this->model->saveCandidate($instituteID,$programID,$batchYear,$roundNo,$degreeLevel,$rollNo,$nameEnglish,$category,$pwdStatus,$gender,$dateBirth,$stateEligibility,$nationality,$programName,$allotedCategory,$allotedRank,$choiceNo,$quota,$roundName,$willingness,$status,$rcName,$remark);
$this->model->sqlLog();
}
//close opened csv file
fclose($csvFile);
echo "<h3 style='color: red'>Candidate <a href='" .__DIR__."/../uploads/$uploadFile' target='new'>list</a> uploaded and $no records " .($candidateID ? "updated." : "created successfully. Please offer these candidates."). "</h3>";
$this->errorText = "$no records imported successfully. Please refresh page.";
} else {
$this->errorText = "Error, please try again.";
}
} else {
$this->errorText = 'Select file to upload.';
}
$this->model->tupleID = $instituteID;
break;
}
return $this->model->tupleID;
}
public function manageOffer($action, $instituteID) {
$this->model->tableID = 'aaa_applicants';
$this->model->tupleID = $instituteID;
switch ($action) {
case 'save':
// save record
// set programID in candidates table
$instituteID = $_POST['instituteID'];
$degreeLevel = $_POST['degreeLevel'];
$xprograms = $_POST['xProgram'];
$programIDs = $_POST['programIDs'];
$i = 0;
foreach ($programIDs as $programID) {
if ($programID) {
$mmPrograms[$xprograms[$i]] = $programID;
$i++;
}
}
// if program is selected
if ($i) {
foreach ($mmPrograms as $key => $value) {
$this->model->setProgramID($instituteID, $key, $value);
}
// make offer
$rows = $this->model->listCandidates($instituteID, $degreeLevel);
foreach ($rows as $row) {
$rollNo = $row['rollNo'];
$instituteID = $row['instituteID'];
$programID = $row['programID'];
$batchYear = $row['batchYear'];
$offerCategory = $row['allotedCategory']; // AllocatedCat
$offerRound = $row['roundNo'];
$remark = $row['remark']; // RemarksbyRC
// for aaa_students table
$nameEnglish = $row['nameEnglish']; // Name
$row['gender'] = trim($row['gender']);
$gender = strtoupper(substr($row['gender'], 0, 1));
$dob1 = str_replace('/', '-', $row['dateBirth']);
$dt = explode('-', $dob1);
if (strlen($dt[2]) == 2)
$dob = ($dt[2]>18 ? '19' : '20') . $dt[2].'-'.$dt[1].'-'.$dt[0];
else
$dob = $dt[2].'-'.$dt[1].'-'.$dt[0];
$dateBirth = $dob; // DOB
$category = ((strtolower($row['category']) == 'general' || strtolower($row['category']) == 'open') ? 'GEN' : $row['category']);
$pwdStatus = substr($row['pwdStatus'], 0, 1); // Y or N
$state = explode(" (", $row['stateEligibility']);
$homeState = $this->model->getStateIDByStateName($state[0]); // StateEligibility
$homeState = $homeState ? $homeState : 0; // StateEligibility
$nationality = strtoupper(substr($row['nationality'], 0, 2));
$phoneNo = date("hhiiss");
$applicantID = $this->model->getApplicantIDByRollNo($rollNo);
if ($applicantID) {
$this->errorText = "Offer already sent to these candidates.";
} else {
$fatherName = 'F';
$motherName = 'M';
$guardianName = 'G';
$fatherPhone = $phoneNo;
$motherPhone = $phoneNo;
$guardianPhone = $phoneNo;
$email = '@';
$fatherEmail = $email;
$motherEmail = $email;
$guardianEmail = $email;
$bloodGroup = 'A';
$homeAddress = 'H';
$commAddress = 'C';
$fatherAddress = 'F';
$motherAddress = 'M';
$guardianAddress = 'G';
$relationWith = 'Father';
$fatherProfession = 'HOM';
$motherProfession = 'HOM';
$guardianProfession = 'HOM';
$homeState = 0;
$homeDistrict = 0;
$homePIN = 0;
$commPIN = 0;
$area = 0;
$xGrade = '';
$xYear = 0;
$xBoard = '';
$xiiGrade = '';
$xiiYear = 0;
$xiiBoard = '';
$ugGrade = '';
$ugYear = 0;
$ugInstitute = '';
$pgGrade = '';
$pgYear = 0;
$pgInstitute = '';
$lastScore = 0;
$studentID = $this->model->getStudentIDByRollNo($rollNo);
if ($studentID) {
// save applicant record with studentID as foreign key
$this->model->tupleID = $applicantID;
$this->model->saveApplicant($rollNo,$studentID,$instituteID,$programID,$batchYear,$offerCategory,$offerRound,$remark);
} else {
$no++;
$studentID = 0;
$parentID = 0;
$educationID= 0;
$applicantID= 0;
// save student record with phoneNo unique key
$studentID = $this->model->saveStudent($studentID,$nameEnglish,$nameHindi,$dateBirth,$gender,$bloodGroup,$pwdStatus,$maritalStatus,$category,$subCategory,$religion,$nationality,$aadhaarNo,$phoneNo,$email,$homeAddress,$homePIN,$homeState,$homeDistrict,$area,$policeStation,$commAddress,$commPIN,$remark,$status);
// save parent record with studentID as foreign key
$this->model->saveParent($parentID,$studentID,$fatherName,$fatherProfession,$fatherPhone,$fatherEmail,$fatherAddress,$motherName,$motherProfession,$motherPhone,$motherEmail,$motherAddress,$guardianName,$guardianProfession,$relationWith,$guardianPhone,$guardianEmail,$guardianAddress);
// save education record with studentID as foreign key
$this->model->saveEducation($educationID,$studentID,$xGrade,$xYear,$xBoard,$xiiGrade,$xiiYear,$xiiBoard,$ugGrade,$ugYear,$ugInstitute,$pgGrade,$pgYear,$pgInstitute,$lastScore);
// save applicant record with studentID as foreign key
$this->model->tupleID = $applicantID;
$this->model->saveApplicant($rollNo,$studentID,$instituteID,$programID,$batchYear,$offerCategory,$offerRound,$remark);
}
// save sql log
$this->model->sqlLog();
$this->errorText = "$no offers sent successfully.";
}
}
} else {
$this->errorText = "Program not selected.";
}
// send mail to AAA incharge
//$msg = "Dear Sir/Madam<br><br>
//A total $no candidates have been offered admission at
//" .$this->model->getInstituteNameByInstituteID($instituteID) . "
//in round $roundNo. These candidates are enabled now to submit their details online through portal (https://erp.iiita.ac.in)
//using their JEE Mains Roll No. and Date of Birth (YYYY-MM-DD) as login credentials.
//<br><br>
//This is for your information please.";
//$this->erpMailer('mmishra@iiita.ac.in', 'Admission Offer To Candidates', $msg);
$this->model->tupleID = $instituteID;
break;
}
return $this->model->tupleID;
}
public function manageDASA($action, $applicantID) {
$this->model->tableID = 'aaa_applicants';
$this->model->tupleID = $applicantID;
switch ($action) {
case 'new':
break;
case 'edit':
$this->editLock = '';
$rollNo = $applicantID;
$applicantID = $this->model->getApplicantIDByRollNo($rollNo);
$this->model->tupleID = $applicantID ? $applicantID : 0;
break;
case 'open':
break;
case 'save':
// save record
// save record
$rollNo = $_POST['rollNo'];
$candidateID = $this->model->getCandidateIDByRollNo($rollNo);
if (!$candidateID) $candidateID = 0;
$candidate = $this->model->getCandidate($candidateID);
$instituteID = $_POST['instituteID'];
$programID = $_POST['programID'];
$batchYear = $_POST['batchYear'];
$offerCategory = $_POST['offerCategory'];
$offerRound = $_POST['offerRound'];
$remark = $_POST['remark'];
$status = 'Offered';
$program = $this->model->getProgram($programID);
$programName = $program['programName'];
$degreeLevel = $program['degreeLevel'];
$studentID = $_POST['studentID'];
$student = $this->model->getStudent($studentID);
$applicantID = $this->model->getApplicantIDByStudentID($studentID);
$parentID = $this->model->getParentIDByStudentID($studentID); // not allowed to change
$educationID = $this->model->getEducationIDByStudentID($studentID); // not allowed to change
$educationID = $this->model->getEducationIDByStudentID($studentID); // not allowed to change
if (!$studentID) $studentID = 0;
if (!$applicantID) $applicantID = 0;
if (!$parentID) $parentID = 0;
if (!$educationID) $educationID = 0;
//get database values of below non editable fields
$nameEnglish = $_POST['nameEnglish']; // not allowed to change
$dateBirth = $_POST['dateBirth']; // not allowed to change
$gender = $_POST['gender']; // not allowed to change
$pwdStatus = $_POST['pwdStatus']; // not allowed to change
$homeState = $_POST['homeState']; // not allowed to change
// get form values of below editable fields
$nameHindi = $_POST['nameHindi'];
$bloodGroup = $_POST['bloodGroup'];
$maritalStatus = $_POST['maritalStatus'];
$category = $_POST['category'];
$subCategory = $_POST['subCategory'];
$religion = $_POST['religion'];
$nationality = $_POST['nationality'];
$aadhaarNo = $_POST['aadhaarNo'];
$phoneNo = $_POST['phoneNo']; // unique
$email = $_POST['email'];
$homeAddress = $_POST['homeAddress'];
$homePIN = $_POST['homePIN'];
$area = $_POST['area'];
$policeStation = $_POST['policeStation'];
$homeDistrict = $_POST['homeDistrict'];
$commAddress = $_POST['commAddress'];
$commPIN = $_POST['commPIN'];
$lastScore = $_POST['lastScore'];
$xGrade = $_POST['xGrade'];
$xYear = $_POST['xYear'];
$xBoard = $_POST['xBoard'];
$xiiGrade = $_POST['xiiGrade'];
$xiiYear = $_POST['xiiYear'];
$xiiBoard = $_POST['xiiBoard'];
$ugGrade = $_POST['ugGrade'];
$ugYear = $_POST['ugYear'];
$ugInstitute = $_POST['ugInstitute'];
$pgGrade = $_POST['pgGrade'];
$pgYear = $_POST['pgYear'];
$pgInstitute = $_POST['pgInstitute'];
$fatherName = $_POST['fatherTitle']. ' ' .$_POST['fatherName'];
$fatherProfession = $_POST['fatherProfession'];
$fatherPhone = $_POST['fatherPhone'];
$fatherEmail = $_POST['fatherEmail'];
$fatherAddress = $_POST['fatherAddress'];
$motherName = $_POST['motherTitle']. ' ' .$_POST['motherName'];
$motherProfession = $_POST['motherProfession'];
$motherPhone = $_POST['motherPhone'];
$motherEmail = $_POST['motherEmail'];
$motherAddress = $_POST['motherAddress'];
$guardianName = $_POST['guardianTitle']. ' ' .$_POST['guardianName'];
$guardianProfession = $_POST['guardianProfession']; //unique
$relationWith = $_POST['relationWith'];
$guardianPhone = $_POST['guardianPhone']; //unique
$guardianEmail = $_POST['guardianEmail']; //unique
$guardianAddress = $_POST['guardianAddress']; //unique
$area = 0;
$homeState = 0;
$homeDistrict = 0;
$homePIN = 0;
$commPIN = 0;
$xYear = 0;
$xiiYear = 0;
$ugYear = 0;
$pgYear = 0;
$lastScore = 0;
// save student record with phoneNo unique key
$studentID = $this->model->saveStudent($studentID,$nameEnglish,$nameHindi,$dateBirth,$gender,$bloodGroup,$pwdStatus,$maritalStatus,$category,$subCategory,$religion,$nationality,$aadhaarNo,$phoneNo,$email,$homeAddress,$homePIN,$homeState,$homeDistrict,$area,$policeStation,$commAddress,$commPIN,$remark,$status);
// save parent record with studentID as foreign key
$this->model->saveParent($parentID,$studentID,$fatherName,$fatherProfession,$fatherPhone,$fatherEmail,$fatherAddress,$motherName,$motherProfession,$motherPhone,$motherEmail,$motherAddress,$guardianName,$guardianProfession,$relationWith,$guardianPhone,$guardianEmail,$guardianAddress);
// save education record with studentID as foreign key
$this->model->saveEducation($educationID,$studentID,$xGrade,$xYear,$xBoard,$xiiGrade,$xiiYear,$xiiBoard,$ugGrade,$ugYear,$ugInstitute,$pgGrade,$pgYear,$pgInstitute,$lastScore);
$this->model->tableID = 'aaa_candidates';
$this->model->tupleID = $candidateID;
$this->model->saveCandidate($instituteID,$programID,$batchYear,$offerRound,$degreeLevel,$rollNo,$nameEnglish,$offerCategory,$pwdStatus,$gender,$dateBirth,$homeState,$nationality,$programName,$offerCategory,0,0,'DASA','Open',$status,'IIITA',$remark);
$this->model->tableID = 'aaa_applicants';
$this->model->tupleID = $applicantID;
// save DASA applicant record with studentID as foreign key
$this->model->saveDASA($rollNo,$studentID,$instituteID,$programID,$batchYear,$offerCategory,$offerRound,$remark);
// save sql log
$this->model->sqlLog();
$this->errorText = 'DASA record saved successfully.';
break;
case 'mail':
$data = $this->model->getApplicant($applicantID);
$str = "Dear " .$data['nameEnglish']. "!
<br><br>
Congratulation!!!<br>
Your registration form with following details has been received successfully at IIIT Allahabad.
<br><br>";
$str .= "<table width='100%'>";
foreach ($data as $key => $value) {
$str .= "<tr><td nowrap>" .ucfirst($key). "</td><td>$value</td></tr>";
}
$str .= "</table>";
$this->erpMailer($data['email'], 'Online Registration - Acknowledgment', $str);
break;
}
return $this->model->tupleID;
}
public function manageCandidate($action, $candidateID) {
$this->model->tableID = 'aaa_candidates';
$this->model->tupleID = $candidateID;
switch ($action) {
case 'new':
break;
case 'edit':
$this->editLock = '';
$rollNo = $candidateID;
$candidateID = $this->model->getApplicantIDByRollNo($rollNo);
$this->model->tupleID = $candidateID ? $candidateID : 0;
break;
case 'open':
break;
case 'save':
// save record
$instituteID = $_POST['instituteID'];
$programID = $_POST['programID'];
$batchYear = $_POST['batchYear'];
$roundNo = $_POST['roundNo'];
$rollNo = $_POST['rollNo'];
$roundName = $_POST['roundName'];
$allotedCategory = $_POST['allotedCategory'];
$allotedRank = $_POST['allotedRank'];
$choiceNo = $_POST['choiceNo'];
$quota = $_POST['quota'];
$willingness = $_POST['willingness'];
$status = $_POST['status'];
$rcName = $_POST['rcName'];
$remark = $_POST['remark'];
$program = $this->model->getProgram($programID);
$degreeLevel = $program['degreeLevel'];
$programName = $program['programName'];
//get database values of below non editable fields
$nameEnglish = $_POST['nameEnglish'];
$pwdStatus = $_POST['pwdStatus'];
$alumni = $_POST['alumni'];
$gender = $_POST['gender'];
$dateBirth = $_POST['dateBirth'];
$category = $_POST['category'];
$stateEligibility = $_POST['stateEligibility'];
$nationality = $_POST['nationality'];
$phoneNo = $_POST['phoneNo'];
$email = $_POST['email'];
$enrolmentID = $this->model->getEnrolmentIDByRollNo($rollNo);
if ($enrolmentID) {
$this->errorText = "Enrollment already processed, can't change now.";
} else {
$this->model->saveCandidate($instituteID,$programID,$batchYear,$roundNo,$degreeLevel,$rollNo,$nameEnglish,$category,$pwdStatus,$gender,$dateBirth,$stateEligibility,$nationality,$programName,$allotedCategory,$allotedRank,$choiceNo,$quota,$roundName,$willingness,$status,$rcName,$alumni,$remark);
// save sql log
//$this->model->sqlLog();
$this->errorText = 'Candidate record saved successfully.';
}
break;
}
return $this->model->tupleID;
}
public function manageExemption($action, $studentID) {
$this->model->tableID = 'aaa_exemptions';
$this->model->tupleID = $studentID;
switch ($action) {
case 'new':
case 'edit':
$this->editLock = '';
break;
case 'open':
case 'help':
case 'trash':
break;
case 'save':
// save record
$documentCode = $_POST['documentCode'];
$dateRemind = $_POST['dateRemind'];
$remark = $_POST['remark'];
$this->model->saveExemption($studentID,$documentCode,$dateRemind,$remark);
//$this->model->sqlLog();
$this->errorText = 'Exemption record saved successfully.';
break;
case 'delete':
// delete record
$this->model->tupleID= $this->params[2];
$this->model->deleteExemption();
$this->errorText = 'Exemption revoked successfully.';
$this->model->tupleID = $studentID;
break;
}
return $this->model->tupleID;
}
function getGreenChannel($studentID) {
if ($studentID) {
// get payment status
$applicantID = $this->model->getApplicantIDByStudentID($studentID);
$data = $this->model->getApplicant($applicantID);
$pwdStatus = $data['pwdStatus'];
$category = $pwdStatus == 'Y' ? 'PWD' : $data['category'];
$feesDue = $this->model->getFeesAmount($data['instituteID'], $data['programID'], $category);
$messDue = $this->model->getMessCharges($data['instituteID'], $data['programID'], $category);
// collect paid amounts and heads (may be multiple transactions, so summed amount of each head)
$feesPaid = $this->model->getPayment($studentID, 1);
$messPaid = $this->model->getPayment($studentID, 2);
$balFees = 0; $balMess = 0;
// calculate balance amount
$balFees = $this->model->getMyExemption($studentID, 1) ? 0 : $feesDue['amount'] - $feesPaid;
$balMess = $this->model->getMyExemption($studentID, 2) ? 0 : $messDue['amount'] - $messPaid;
$dues = $balFees + $balMess;
//echo $dues;
// get photograph & signature files
$photo = $this->model->getMyUpload($studentID, 'PHO'); // get record
$psign = $this->model->getMyUpload($studentID, 'SIG'); // get record
if ($dues <= 0 && $photo && $psign) return TRUE;
}
return FALSE;
}
public function manageApplicant($action, $applicantID) {
$this->model->tableID = 'aaa_applicants';
$this->model->tupleID = $applicantID;
switch ($action) {
case 'edit':
// when roll no. is typed
//$rollNo = $applicantID;
//$applicantID = $this->model->getApplicantIDByRollNo($rollNo);
//$this->model->tupleID = $applicantID ? $applicantID : $rollNo;
break;
case 'back':
$studentID = $applicantID;
$applicantID = $this->model->getApplicantIDByStudentID($studentID);
$this->model->tupleID = $applicantID ? $applicantID : 0;
break;
case 'photoUpload':
case 'signUpload':
case 'feesPayment':
case 'messPayment':
// from payment/upload on click of back button
$studentID = $applicantID;
$applicantID = $this->model->getApplicantIDByStudentID($studentID);
$this->model->tupleID = $applicantID;
break;
case 'save':
// save record
$rollNo = $_POST['rollNo'];
$studentID = $_POST['studentID'];
$candidateID = $this->model->getCandidateIDByRollNo($rollNo);
$candidate = $this->model->getCandidate($candidateID);
$instituteID = $candidate['instituteID'];
$programID = $candidate['programID'];
$batchYear = $candidate['batchYear'];
$offerCategory = $candidate['allotedCategory'];
$offerRound = $candidate['roundNo'];
$remark = $candidate['remark'];
$status = 'Responded';
$student = $this->model->getStudent($studentID);
$applicantID = $this->model->getApplicantIDByStudentID($studentID);
$parentID = $this->model->getParentIDByStudentID($studentID); // not allowed to change
$educationID = $this->model->getEducationIDByStudentID($studentID); // not allowed to change
if (!$studentID) $studentID = 0;
if (!$applicantID) $applicantID = 0;
if (!$parentID) $parentID = 0;
if (!$educationID) $educationID = 0;
//get database values of below non editable fields
$nameEnglish = $student['nameEnglish']; // not allowed to change
$dateBirth = $student['dateBirth']; // not allowed to change
$gender = $student['gender']; // not allowed to change
$pwdStatus = $student['pwdStatus']; // not allowed to change
// get form values of below editable fields
$nameHindi = $_POST['nameHindi'];
$gender = $_POST['gender'];
$bloodGroup = $_POST['bloodGroup'];
$maritalStatus = $_POST['maritalStatus'];
$category = $_POST['category'];
$subCategory = $_POST['subCategory'];
$religion = $_POST['religion'];
$nationality = $_POST['nationality'];
$aadhaarNo = $_POST['aadhaarNo'];
$phoneNo = $_POST['phoneNo']; // unique
$email = $_POST['email'];
$homeAddress = $_POST['homeAddress'];
$homePIN = $_POST['homePIN'];
$area = $_POST['area'];
$policeStation = $_POST['policeStation'];
$homeState = $_POST['homeState']; // changes for CCMT/DASA etc.
$homeDistrict = $_POST['homeDistrict'];
$commAddress = $_POST['commAddress'];
$commPIN = $_POST['commPIN'];
$xGrade = $_POST['xGrade'];
$xYear = $_POST['xYear'];
$xBoard = $_POST['xBoard'];
$xiiGrade = $_POST['xiiGrade'];
$xiiYear = $_POST['xiiYear'];
$xiiBoard = $_POST['xiiBoard'];
$ugGrade = $_POST['ugGrade'];
$ugYear = $_POST['ugYear'];
$ugInstitute = $_POST['ugInstitute'];
$pgGrade = $_POST['pgGrade'];
$pgYear = $_POST['pgYear'];
$pgInstitute = $_POST['pgInstitute'];
$lastScore = $_POST['lastScore'];
$fatherName = $_POST['fatherTitle']. ' ' .$_POST['fatherName'];
$fatherProfession = $_POST['fatherProfession'];
$fatherPhone = $_POST['fatherPhone'];
$fatherEmail = $_POST['fatherEmail'];
$fatherAddress = $_POST['fatherAddress'];
$motherName = $_POST['motherTitle']. ' ' .$_POST['motherName'];
$motherProfession = $_POST['motherProfession'];
$motherPhone = $_POST['motherPhone'];
$motherEmail = $_POST['motherEmail'];
$motherAddress = $_POST['motherAddress'];
$guardianName = $_POST['guardianTitle']. ' ' .$_POST['guardianName'];
$guardianProfession = $_POST['guardianProfession']; //unique
$relationWith = $_POST['relationWith'];
$guardianPhone = $_POST['guardianPhone']; //unique
$guardianEmail = $_POST['guardianEmail']; //unique
$guardianAddress = $_POST['guardianAddress']; //unique
if (!$homePIN) $homePIN = 0;
if (!$commPIN) $commPIN = 0;
if (!$xYear) $xYear = 0;
if (!$xiiYear) $xiiYear = 0;
if (!$ugYear) $ugYear = 0;
if (!$pgYear) $pgYear = 0;
if (!$lastScore) $lastScore = 0;
if ($studentID) {
// save student record with phoneNo unique key
$studentID = $this->model->saveStudent($studentID,$nameEnglish,$nameHindi,$dateBirth,$gender,$bloodGroup,$pwdStatus,$maritalStatus,$category,$subCategory,$religion,$nationality,$aadhaarNo,$phoneNo,$email,$homeAddress,$homePIN,$homeState,$homeDistrict,$area,$policeStation,$commAddress,$commPIN,$remark,$status);
// save parent record with studentID as foreign key
$this->model->saveParent($parentID,$studentID,$fatherName,$fatherProfession,$fatherPhone,$fatherEmail,$fatherAddress,$motherName,$motherProfession,$motherPhone,$motherEmail,$motherAddress,$guardianName,$guardianProfession,$relationWith,$guardianPhone,$guardianEmail,$guardianAddress);
// save education record with studentID as foreign key
//echo "$educationID,$studentID,$xGrade,$xYear,$xBoard,$xiiGrade,$xiiYear,$xiiBoard,$ugGrade,$ugYear,$ugInstitute,$pgGrade,$pgYear,$pgInstitute,$lastScore";
$this->model->saveEducation($educationID,$studentID,$xGrade,$xYear,$xBoard,$xiiGrade,$xiiYear,$xiiBoard,$ugGrade,$ugYear,$ugInstitute,$pgGrade,$pgYear,$pgInstitute,$lastScore);
// save applicant record with studentID as foreign key
$this->model->saveApplicant($rollNo,$studentID,$instituteID,$programID,$batchYear,$offerCategory,$offerRound,$remark);
// save sql log
$this->model->sqlLog();
$this->errorText = 'Applicant record saved successfully.';
/*
$data = $this->model->getApplicant($this->model->tupleID);
$str = "Dear " .$data['nameEnglish']. "!
<br><br>
Congratulation!!!<br>
Your registration form with following details has been received successfully at IIIT Allahabad.
<br><br>";
$str .= "<table width='100%'>";
foreach ($data as $key => $value) {
$str .= "<tr><td nowrap>" .ucfirst($key). "</td><td>$value</td></tr>";
}
$str .= "</table>";
$this->erpMailer($data['email'], 'Online Registration - Acknowledgment', $str);
*/
} else {
$this->errorText = 'Student record missing.';
}
break;
}
return $this->model->tupleID;
}
public function managePayment($action, $studentID) {
$this->model->tableID = 'aaa_payments';
$this->model->tupleID = 0;
switch ($action) {
case 'online':
$pg = $this->params[0]; // ATOM or HDFC
$accountType = $this->params[1]; // 1 for fees, 2 for mess
$paymentMode = 'PG'; // online payment gateway
$currency = 'INR'; // missing in PG response
if ($pg == 'ATOM') {
$paymentNo = $_REQUEST['mmp_txn']; // transaction no.
$datePayment = date("Y-m-d"); // $_POST['date']; // date of transaction
$bankName = $_REQUEST['bank_name']; // name of bpayee bank
$status = $_REQUEST['f_code']; // status, OK for success, F for failure
$amount = $_REQUEST['amt']; // amount
if ($status == 'OK' || $status == 'Ok') {
$this->model->savePayment($studentID,$accountType,$paymentMode,$paymentNo,$bankName,$amount,$currency,$datePayment);
$this->model->sqlLog();
$this->errorText = "Transaction ID: $paymentNo => completed successfully.";
} else {
$this->errorText = $this->accountTypes[$accountType]. " payment transaction failed.";
}
} else if ($_POST['ResponseCode'] == 0) {
$paymentNo = $_POST['PaymentID']; // payment ID
$bankName = 'HDFC'; // missing in hdfc response
$amount = $_POST['Amount'];
$datePayment = $_POST['DateCreated'];
$this->model->savePayment($studentID,$accountType,$paymentMode,$paymentNo,$bankName,$amount,$currency,$datePayment);
$this->model->sqlLog();
$this->errorText = "Transaction ID: $paymentNo => " .$_POST['ResponseMessage'];
} else {
$this->errorText = $this->accountTypes[$accountType]. " payment transaction failed.";
}
break;
case 'save':
// save record
$accountType = $_POST['accountType'];
$paymentMode = $_POST['paymentMode'];
$paymentNo = $_POST['paymentNo'];
$bankName = $_POST['bankName'];
$amount = $_POST['amount'];
$currency = $_POST['currency'];
$datePayment = $_POST['datePayment'];
if ($paymentNo) {
$this->model->savePayment($studentID,$accountType,$paymentMode,$paymentNo,$bankName,$amount,$currency,$datePayment);
$this->model->sqlLog();
$this->errorText = $this->accountTypes[$accountType]. " payment saved successfully.";
} else {
$this->errorText = "Payment No. is missing.";
}
break;
//case 'mail':
// // mail record data
// $this->erpMailer('mmishra@iiita.ac.in', 'Applicant test mail', 'This is a test mail');
// break;
}
$this->model->tupleID = $studentID;
return $this->model->tupleID;
}
public function manageUpload($action, $studentID) {
$this->model->tableID = 'aaa_uploads';
$this->model->tupleID = $studentID;
switch ($action) {
case 'photoUpload':
case 'signUpload':
case 'docUpload':
$documents = $_POST['documentCode'];
$studentID = $_POST['studentID'] ? $_POST['studentID'] : $studentID;
// save record
if (isset($_FILES["fileToUpload"]["name"])) {
// Check if image file is a actual image or fake image
$sourceFile = basename($_FILES["fileToUpload"]["name"]);
$uploadFile = strtolower("mm-" .$studentID. "-" .$documents[0]. "-" .str_replace(' ','-',$sourceFile));
$targetFile = __DIR__. "/../uploads/" .$uploadFile;
$extName = strtolower(pathinfo($sourceFile, PATHINFO_EXTENSION));
if (file_exists($targetFile)) $this->errorText = "Already exists.";
if ($_FILES["fileToUpload"]["size"] > 1500000000) {
$this->errorText = "Heavy file size";
// Allow certain file formats
} else if ($extName == "jpg" || $extName == "jpeg" || $extName == "png" || $extName == "pdf") {
// if everything is ok, try to upload file
move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $targetFile);
foreach ($documents as $code) {
$this->model->tupleID = $this->model->saveUpload($studentID,$code,$uploadFile);
}
//$this->model->sqlLog();
$this->errorText = "Successful.";
} else {
$this->errorText = "Image as jpeg, Document as pdf.";
}
} else {
$this->errorText = 'Image as jpeg, Document as pdf.';
}
$this->model->tupleID = $studentID;
break;
case 'delete':
// delete record
$uploadID = $studentID; //we reach here with applicantID, however it is actually uploadID
$row = $this->model->getUpload($uploadID);
$fileName = $row['fileName'];
$this->model->tupleID = $row['uploadID'];
$this->model->deleteUpload();
$this->model->sqlLog();
shell_exec("rm -f " .__DIR__. "/../uploads/$fileNmae");
$this->errorText = 'Upload file deleted successfully.';
$studentID = $_POST['studentID'];
$this->model->tupleID = $studentID;
break;
}
return $this->model->tupleID;
}
public function manageEnrolment($action, $enrolmentID) {
$this->model->tableID = 'aaa_enrolments';
$this->model->tupleID = $enrolmentID;
switch ($action) {
case 'new':
break;
case 'edit':
$this->editLock = '';
//$rollNo = $enrolmentID;
//$applicantID = $this->model->getApplicantIDByRollNo($rollNo);
//$this->model->tupleID = $this->model->getEnrolmentIDByRollNo($rollNo);
break;
case 'open':
case 'help':
case 'trash':
break;
case 'back':
// from payment/upload pages on click of back button
//$studentID = $enrolmentID;
//$enrolmentID = 0;
//$applicantID = $this->model->getApplicantIDByStudentID($studentID);
//$enrolmentID = $this->model->getEnrolmentIDByStudentID($studentID);
//$this->model->tupleID = $enrolmentID ? $enrolmentID : $applicantID;
break;
case 'save':
// save record
$applicantID = $_POST['applicantID'];
$enrolmentID = $_POST['enrolmentID'];
$studentID = $_POST['studentID'];
$rollNo = $this->model->getRollNoByStudentID($studentID);
$candidateID = $this->model->getCandidateIDByRollNo($rollNo);
$candidate = $this->model->getCandidate($candidateID);
$instituteID = $candidate['instituteID'];
$programID = $candidate['programID'];
$batchYear = $candidate['batchYear'];
$enrolCategory = $candidate['allotedCategory'];
$offerRound = $candidate['roundNo'];
$homeState = $candidate['stateEligibility']; // changes for CCMT/DASA
$remark = $candidate['remark'];
$status = 'Enrolled';
// check whether new or old record
if ($applicantID) {
$program = $this->model->getProgram($programID);
$enrolmentID = 0;
$this->model->tupleID = $enrolmentID;
$enrolmentNo = $program['rollnoPrefix'] . $batchYear . ($program['lastRollno'] < 9 ? '00' : ($program['lastRollno'] < 99 ? '0' : '')) . ($program['lastRollno'] + 1);
} else {
$enrolmentNo = $this->model->getEnrolmentNoByStudentID($studentID);
}
$applicantID = $this->model->getApplicantIDByStudentID($studentID);
$student = $this->model->getStudent($studentID);
$parentID = $this->model->getParentIDByStudentID($studentID); // not allowed to change
$educationID = $this->model->getEducationIDByStudentID($studentID); // not allowed to change
//if (!$studentID) $studentID = 0;
//if (!$applicantID) $applicantID = 0;
if (!$parentID) $parentID = 0;
if (!$educationID) $educationID = 0;
// get form values of below editable fields
$nameEnglish = $_POST['nameEnglish']; // not allowed to change
$nameHindi = $_POST['nameHindi'];
$dateBirth = $_POST['dateBirth']; // not allowed to change
$gender = $_POST['gender']; // not allowed to change
$pwdStatus = $_POST['pwdStatus']; // not allowed to change
$bloodGroup = $_POST['bloodGroup'];
$maritalStatus = $_POST['maritalStatus'];
$category = $_POST['category'];
$subCategory = $_POST['subCategory'];
$religion = $_POST['religion'];
$nationality = $_POST['nationality'];
$aadhaarNo = $_POST['aadhaarNo'];
$phoneNo = $_POST['phoneNo']; // unique
$email = $_POST['email'];
$homeAddress = $_POST['homeAddress'];
$homePIN = $_POST['homePIN'];
$area = $_POST['area'];
$policeStation = $_POST['policeStation'];
$homeState = $_POST['homeState']; // changes for CCMT/DASA
$homeDistrict = $_POST['homeDistrict'];
$commAddress = $_POST['commAddress'];
$commPIN = $_POST['commPIN'];
$xGrade = $_POST['xGrade'];
$xYear = $_POST['xYear'];
$xBoard = $_POST['xBoard'];
$xiiGrade = $_POST['xiiGrade'];
$xiiYear = $_POST['xiiYear'];
$xiiBoard = $_POST['xiiBoard'];
$ugGrade = $_POST['ugGrade'];
$ugYear = $_POST['ugYear'];
$ugInstitute = $_POST['ugInstitute'];
$pgGrade = $_POST['pgGrade'];
$pgYear = $_POST['pgYear'];
$pgInstitute = $_POST['pgInstitute'];
$lastScore = $_POST['lastScore'];
$fatherName = $_POST['fatherTitle']. ' ' .$_POST['fatherName'];
$fatherProfession = $_POST['fatherProfession'];
$fatherPhone = $_POST['fatherPhone'];
$fatherEmail = $_POST['fatherEmail'];
$fatherAddress = $_POST['fatherAddress'];
$motherName = $_POST['motherTitle']. ' ' .$_POST['motherName'];
$motherProfession = $_POST['motherProfession'];
$motherPhone = $_POST['motherPhone'];
$motherEmail = $_POST['motherEmail'];
$motherAddress = $_POST['motherAddress'];
$guardianName = $_POST['guardianTitle']. ' ' .$_POST['guardianName'];
$guardianProfession = $_POST['guardianProfession'];
$relationWith = $_POST['relationWith'];
$guardianPhone = $_POST['guardianPhone'];
$guardianEmail = $_POST['guardianEmail'];
$guardianAddress = $_POST['guardianAddress'];
$remark = $_POST['remark']; // AAA may over write remark
if (!$homePIN) $homePIN = 0;
if (!$commPIN) $commPIN = 0;
if (!$xYear) $xYear = 0;
if (!$xiiYear) $xiiYear = 0;
if (!$ugYear) $ugYear = 0;
if (!$pgYear) $pgYear = 0;
if (!$lastScore) $lastScore = 0;
if ($studentID) {
// save student record with phoneNo unique key
$studentID = $this->model->saveStudent($studentID,$nameEnglish,$nameHindi,$dateBirth,$gender,$bloodGroup,$pwdStatus,$maritalStatus,$category,$subCategory,$religion,$nationality,$aadhaarNo,$phoneNo,$email,$homeAddress,$homePIN,$homeState,$homeDistrict,$area,$policeStation,$commAddress,$commPIN,$remark,$status);
// save parent record with studentID as foreign key
$this->model->saveParent($parentID,$studentID,$fatherName,$fatherProfession,$fatherPhone,$fatherEmail,$fatherAddress,$motherName,$motherProfession,$motherPhone,$motherEmail,$motherAddress,$guardianName,$guardianProfession,$relationWith,$guardianPhone,$guardianEmail,$guardianAddress);
// save education record with studentID as foreign key
$this->model->saveEducation($educationID,$studentID,$xGrade,$xYear,$xBoard,$xiiGrade,$xiiYear,$xiiBoard,$ugGrade,$ugYear,$ugInstitute,$pgGrade,$pgYear,$pgInstitute,$lastScore);
// save enrolment record with studentID as foreign key
//echo "($enrolmentNo,$studentID,$instituteID,$programID,$batchYear,$enrolCategory,$remark)";
$this->model->saveEnrolment($enrolmentNo,$studentID,$instituteID,$programID,$batchYear,$enrolCategory,$remark);
// save sql log
$this->model->sqlLog();
$this->errorText = $enrolmentNo. ' record saved successfully.';
} else {
$this->errorText = 'Student record missing.';
}
break;
case 'delete':
// delete record
$this->model->deleteEnrolment();
$this->model->sqlLog();
$this->errorText = 'Enrollment record deleted successfully.';
break;
case 'mail':
//send email acknowledgment to student
$data = $this->model->getEnrolment($this->model->tupleID);
$str = "Dear " .$data['nameEnglish']. "!
<br><br>
Congratulation!!!<br>
You are enrolled at IIIT Allahabad with following details.
<br><br>";
$str .= "<table width='100%'>";
foreach ($data as $key => $value) {
$str .= "<tr><td nowrap>" .ucfirst($key). "</td><td>$value</td></tr>";
}
$str .= "</table>";
$this->erpMailer($data['email'], 'Enrollment Acknowledgment', $str);
$this->errorText = 'Enrollment acknowledgment mailed to student.';
}
return $this->model->tupleID;
}
public function manageInsurence($action, $enrolmentID) {
$this->model->tableID = 'aaa_mcaips';
$this->model->tupleID = $enrolmentID;
switch ($action) {
case 'new':
case 'edit':
$this->editLock = '';
break;
case 'open':
case 'help':
case 'trash':
break;
case 'save':
// save enrollment record
if (!$_POST['spouseAge']) $_POST['spouseAge'] = 0;
if (!$_POST['spousePIN']) $_POST['spousePIN'] = 0;
if (!$_POST['child1Age']) $_POST['child1Age'] = 0;
if (!$_POST['child1PIN']) $_POST['child1PIN'] = 0;
if (!$_POST['child2Age']) $_POST['child2Age'] = 0;
if (!$_POST['child2PIN']) $_POST['child2PIN'] = 0;
//foreach ($_POST as $key => $value) {
// echo $key. '-' .$value. '<br>';
//}
$this->model->saveInsurence($enrolmentID,$_POST['spouseName'],$_POST['spouseAge'],$_POST['spousePhone'],$_POST['spouseEmail'],$_POST['spouseAddress'],$_POST['spousePIN'],$_POST['child1Name'],$_POST['child1Age'],$_POST['child1Gender'],$_POST['child1Phone'],$_POST['child1Email'],$_POST['child1Address'],$_POST['child1PIN'],$_POST['child2Name'],$_POST['child2Age'],$_POST['child2Gender'],$_POST['child2Phone'],$_POST['child2Email'],$_POST['child2Address'],$_POST['child2PIN'],$_POST['knownDiseases']);
//$this->model->sqlLog();
$this->errorText = 'MCAIP record saved successfully.';
$this->model->tupleID = $enrolmentID;
break;
case 'mail':
//send email acknowledgment to student
$data = $this->model->getInsurence($this->model->tupleID);
$str = "Dear Student!
<br><br>
Congratulation!!!<br>
You are enrolled at IIIT Allahabad with following details.
<br><br>";
$str .= "<table width='100%'>";
foreach ($data as $key => $value) {
$str .= "<tr><td nowrap>" .ucfirst($key). "</td><td>$value</td></tr>";
}
$str .= "</table>";
$this->erpMailer($data['email'], 'MCAIP Acknowledgment', $str);
$this->errorText = 'MCAIP acknowledgment mailed to student.';
}
return $this->model->tupleID;
}
public function manageSliding($action, $enrolmentID) {
$this->model->tableID = 'aaa_enrolments';
$this->model->tupleID = $enrolmentID;
switch ($action) {
case 'new':
case 'edit':
$this->editLock = '';
break;
case 'open':
case 'help':
case 'trash':
break;
case 'save':
// save enrollment record
$programID = $_POST['programID'];
$xprogramID = $_POST['xprogramID'];
if ($xprogramID == $programID) {
$this->errorText = 'Same program has been selected.';
} else {
$dateEnrolment = date("Y-m-d");
// data will be returned either from applicants view or enrolment view
$data = $this->model->getEnrolment($enrolmentID);
$program = $this->model->getProgram($data['programID']);
$enrolmentNo = $program['rollnoPrefix'] . $data['batchYear'] . ($program['lastRollno'] < 10 ? '00' : ($program['lastRollno'] < 100 ? '0' : '')) . ($program['lastRollno'] + 1);
if ($_POST['studentID']) {
//foreach ($_POST as $key => $value) {
// echo $key. '-' .$value. '<br>';
//}
$this->model->saveSliding($enrolmentNo,$dateEnrolment,$remark);
$this->model->sqlLog();
$this->errorText = $enrolmentNo. ' record saved successfully.';
} else {
$this->errorText = 'Student record missing.';
}
}
break;
}
return $this->model->tupleID;
}
public function manageWithdrawal($action, $enrolmentID) {
$this->model->tableID = 'aaa_enrolments';
$this->model->tupleID = $enrolmentID;
switch ($action) {
case 'new':
case 'edit':
$this->editLock = '';
break;
case 'open':
case 'help':
case 'trash':
break;
case 'save':
// save enrollment record
$dateWithdraw = $_POST['dateWithdraw'];
$withdrawReason = $_POST['withdrawReason'];
$remark = $_POST['remark'];
//foreach ($_POST as $key => $value) {
// echo $key. '-' .$value. '<br>';
//}
$this->model->saveWithdrawal($dateWithdraw,$withdrawReason,$remark);
//$this->model->sqlLog();
$this->errorText = 'Withdrawal saved successfully.';
break;
case 'mail':
//send email acknowledgment to student
$data = $this->model->getEnrolment($this->model->tupleID);
$str = "Dear " .$data['nameEnglish']. "!
<br><br>
Congratulation!!!<br>
You are enrolled at IIIT Allahabad with following details.
<br><br>";
$str .= "<table width='100%'>";
foreach ($data as $key => $value) {
$str .= "<tr><td nowrap>" .ucfirst($key). "</td><td>$value</td></tr>";
}
$str .= "</table>";
$this->erpMailer($data['email'], 'Enrollment Acknowledgment', $str);
$this->errorText = 'Enrollment acknowledgment mailed to student.';
}
return $this->model->tupleID;
}
public function manageLDAP($action, $enrolmentID) {
$this->model->tableID = 'aaa_enrolments';
$this->model->tupleID = $enrolmentID;
switch ($action) {
case 'new':
case 'edit':
$this->editLock = '';
break;
case 'open':
case 'help':
case 'trash':
break;
case 'save':
// save record
//$ds = ldap_connect("ldaps://172.31.1.41:636");
$ds = ldap_connect("ldap://172.31.1.41:389");
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
$q = ldap_search($ds, "ou=applicants,ou=aaa,dc=iiita,dc=ac,dc=in", "(&(uid=$rollNo)(objectclass=posixAccount))");
$info = ldap_get_entries($ds, $q);
$dn = $info[0]["dn"];
$ldapOTP = rand(111111, 999999);
if ($info["count"] == 0) {
ldap_bind($ds, "cn=Manager,dc=iiita,dc=ac,dc=in","\$dollfinn");
//$pwd1 = 'iiita' . rand(111,999);
//$pwd = '{CRYPT}' . crypt($pwd1);
$pwd = "{SHA}" . base64_encode(pack("H*", sha1($ldapOTP)));
$info1["uid"] = "$rollNo";
$info1["cn"] = "aaa applicant";
$info1["gecos"] = date("Y-m-d");
$info1["userPassword"] = "$pwd";
if (ldap_add($ds, $dn, $info1)) {
$str = "Applicant account added successfully.";
} else {
$str = "Sorry! error occured in LDAP add.";
}
} else {
$str = "LDAP account already exists.";
}
ldap_close($ds);
//$this->model->saveLDAP($_POST['RollNo'],$_POST['Name'],$_POST['DOB'],$_POST['Phone'],$_POST['Email'],$_POST['homeAddress'],$_POST['homeDistrict'],$_POST['homeState'],$_POST['subCategory'],$_POST['Religion'],$_POST['Nationality'],$_POST['PWD'],$_POST['Batch'],$_POST['Program']);
//$this->model->sqlLog();
$this->errorText = 'Applicant record created successfully.';
break;
case 'delete':
// delete record
//$ds = ldap_connect("ldaps://172.31.1.41:636");
$ds = ldap_connect("ldap://172.31.1.41:389");
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
$q = ldap_search($ds, "ou=applicants,ou=aaa,dc=iiita,dc=ac,dc=in", "(&(uid=$rollNo)(objectclass=posixAccount))");
$info = ldap_get_entries($ds, $q);
$dn = $info[0]["dn"];
ldap_bind($ds, "cn=Manager,dc=iiita,dc=ac,dc=in","\$dollfinn");
if (ldap_delete($ds, $dn)) {
$str = "Applicant account deleted successfully.";
} else {
$str = "Sorry! error occured in LDAP delete.";
}
ldap_close($ds);
//$this->model->deleteEnrolment();
//$this->model->sqlLog();
$this->errorText = 'Applicant record deleted successfully.';
break;
case 'mail':
// mail OTP
echo $this->erpMailer('mmishra@iiita.ac.in', 'IIITA Applicant OTP - confidential', 'This is a test mail');
break;
}
return $this->model->tupleID;
}
}
class payment_config_test {
var $Url = "https://paynetzuat.atomtech.in/paynetz/epi/fts";
var $Login="160";
var $Password="Test@123";
//var $MerchantName="ATOM";
var $MerchantName="NSE";
var $TxnCurr="INR";
var $TxnScAmt="0";
}
class payment_config {
var $Url = "https://payment.atomtech.in/paynetz/epi/fts";
var $Login="18589";
var $Password="IIIT@123";
var $MerchantName="IIIT";
var $TxnCurr="INR";
var $TxnScAmt="0";
}
class payment {
var $url = null;
function sendInfo($data){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_PORT , 443);
//curl_setopt($ch, CURLOPT_SSLVERSION,3);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$returnData = curl_exec($ch);
curl_close($ch);
return $returnData;
}
}
class ProcessPayment {
function __construct() {
$this->paymentConfig = new payment_config();
}
function requestMerchant() {
$payment = new payment();
$datenow = date("d/m/Y h:m:s");
$modifiedDate = str_replace(" ", "%20", $datenow);
$payment->url = $this->paymentConfig->Url;
$postFields = "";
$postFields .= "&login=".$this->paymentConfig->Login;
$postFields .= "&pass=".$this->paymentConfig->Password;
$postFields .= "&ttype=".$_POST['TType'];
$postFields .= "&prodid=".$_POST['product'];
$postFields .= "&amt=".$_POST['amount'];
$postFields .= "&txncurr=".$this->paymentConfig->TxnCurr;
$postFields .= "&txnscamt=".$this->paymentConfig->TxnScAmt;
$postFields .= "&clientcode=".urlencode(base64_encode($_POST['clientcode']));//rollno
$postFields .= "&txnid=".rand(0,999999);
$postFields .= "&date=".$modifiedDate;
$postFields .= "&custacc=".$_POST['AccountNo'];
//$postFields .= "&ru=".$_POST['ru'];
$postFields .= "&ru=https://ipay.iiita.ac.in/canara/StatusTRAN.php";
$postFields .= "&udf1=".$_POST['udf1']; //name
$postFields .= "&udf2=".$_POST['udf2']; //email
$postFields .= "&udf3=".$_POST['udf3']; //mobile
$postFields .= "&udf4=".$_POST['udf4']; //program
$postFields .= "&udf5=".$_POST['udf5']; //batch
$postFields .= "&udf9=".$_POST['udf9']; //semester
// Not required for merchant
//$postFields .= "&bankid=".$_POST['bankid'];
$sendUrl = $payment->url."?".substr($postFields,1)."\n";
$this->writeLog($sendUrl);
$returnData = $payment->sendInfo($postFields);
$this->writeLog($returnData."\n");
$xmlObjArray = $this->xmltoarray($returnData);
$url = $xmlObjArray['url'];
$postFields = "";
$postFields .= "&ttype=".$_POST['TType'];
$postFields .= "&tempTxnId=".$xmlObjArray['tempTxnId'];
$postFields .= "&token=".$xmlObjArray['token'];
$postFields .= "&txnStage=1";
$url = $payment->url."?".$postFields;
$this->writeLog($url."\n");
//echo("Location: ".$url);
header("Location: ".$url);
}
function writeLog($data){
$fileName = date("Y-m-d").".txt";
$fp = fopen("log/".$fileName, 'a+');
$data = date("Y-m-d H:i:s")." - ".$data;
fwrite($fp,$data);
fclose($fp);
}
function xmltoarray($data){
$parser = xml_parser_create('');
xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8");
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($parser, trim($data), $xml_values);
xml_parser_free($parser);
$returnArray = array();
$returnArray['url'] = $xml_values[3]['value'];
$returnArray['tempTxnId'] = $xml_values[5]['value'];
$returnArray['token'] = $xml_values[6]['value'];
return $returnArray;
}
}
?>