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-7-6-18/controllers/ |
<?php
//if (!class_exists($erpController)) {
require_once __DIR__."/erp_controller.php";
//}
class aaaController extends erpController {
var $model;
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->errorText = isset($_SESSION["sessionID"]) ? "ERP reports critical error here..." : "ERP session starts with login here... <i class='far fa-hand-point-down'></i> ";
$this->moduleID = isset($_SESSION["moduleID"]) ? $_SESSION["moduleID"] : 1;
$this->userIP = $this->getIP();
$this->filterText = $_POST['filterText'];
if (!$this->errorText) {
$this->errorText = "Error and alert during data processing goes here...";
}
// 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
$this->model->saveProgram($_POST['instituteID'],$_POST['programCode'],$_POST['programName'],$_POST['degreeLevel'],$_POST['timeDuration'],$_POST['rollnoPrefix'],$_POST['entranceBoard'],$_POST['entranceName'],$_POST['intakeLimit']);
$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;
case 'mail':
// mail record data
echo $this->erpMailer('mmishra@iiita.ac.in', 'Program test mail', 'This is a test mail');
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 = $_POST['batchYear'];
$category = $_POST['category'][$i];
$headName = $_POST['headName'][$i];
$paymentTerm = $_POST['paymentTerm'][$i];
$feeAmount = $_POST['feeAmount'][$i];
if (!$feeAmount) $feeAmount = 0;
$currency = $_POST['currency'][$i];
$i++;
if ($headName) {
//echo $headID.'-'.$instituteID.'-'.$programID.'-'.$batchYear.'-'.$category.'-'.$headName.'-'.$paymentTerm.'-'.$feeAmount.'-'.$currency."<br>";
$this->model->saveFeehead($instituteID,$programID,$batchYear,$category,$headName,$paymentTerm,$feeAmount,$currency);
//$this->model->sqlLog();
} else {
$this->model->deleteFeehead();
$this->model->sqlLog();
}
}
$this->errorText = 'Fees record saved successfully.';
break;
case 'enable':
// enable record
$this->model->enableFeehead();
$this->model->sqlLog();
$this->errorText = 'Fees record enabled successfully.';
break;
case 'disable':
// disable record
$this->model->disableFeehead();
$this->model->sqlLog();
$this->errorText = 'Fees record disabled successfully.';
break;
case 'delete':
// delete record
$this->model->deleteFeehead();
$this->model->sqlLog();
$this->errorText = 'Fees record deleted 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"];
if ($programID == '*') $programID = 0;
$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,$category,$documentCode,$documentName,$specification,$selfUpload);
} else {
$this->model->deleteDocument();
}
//$this->model->sqlLog();
$i++;
}
$this->errorText = 'Document record saved successfully.';
break;
case 'enable':
// enable record
$this->model->enableDocument();
$this->model->sqlLog();
$this->errorText = 'Document record enabled successfully.';
break;
case 'disable':
// disable record
$this->model->disableDocument();
$this->model->sqlLog();
$this->errorText = 'Document record disabled successfully.';
break;
case 'delete':
// delete record
$fileName = $this->model->deleteDocument();
$this->model->sqlLog();
$this->errorText = 'Document record deleted successfully.';
break;
case 'mail':
// mail record data
echo $this->erpMailer('mmishra@iiita.ac.in', 'Applicant test mail', 'This is a test mail');
break;
}
return $this->model->tupleID;
}
public function manageImport($action, $instituteID) {
$this->model->tableID = 'aaa_candidates';
$this->model->tupleID = $instituteID;
switch ($action) {
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'];
$batchYear = date("Y");
$roundNo = $_POST['roundNo'];
$sourceFile = basename($_FILES["fileToUpload"]["name"]);
$uploadFile = strtolower("mm-${instituteID}-${batchYear}-${roundNo}-" .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)) {
$this->errorText = $uploadFile. " uploaded successfully.";
// 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);
//parse data from csv file line by line
while(($line = fgetcsv($csvFile)) !== FALSE){
$no++;
$SN = $line[0];
$rollNo = $line[1]; // RollNo
$nameEnglish = $line[2]; // Name
$category = $line[3];
$pwdStatus = $line[4]; // PwD
$gender = $line[5];
$dateBirth = $line[6]; // DOB
$homeState = $line[7]; // StateEligibility
$nationality = $line[8];
$programID = $line[9]; // AllocatedProgram
$offerCategory = $line[10]; // AllocatedCat
$AllocatedRank = $line[11];
$ChoiceNo = $line[12];
$Quota = $line[13];
$offerRound = $line[14];
$status = $line[15];
$RCName = $line[16];
$remark = $line[17]; // RemarksbyRC
$this->model->saveCandidate($instituteID,$batchYear,$roundNo,$rollNo,$nameEnglish,$category,$pwdStatus,$gender,$dateBirth,$homeState,$nationality,$programID,$offerCategory,$AllocatedRank,$ChoiceNo,$Quota,$offerRound,$status,$RCName,$remark);
$this->model->sqlLog();
}
//close opened csv file
fclose($csvFile);
$this->errorText = 'CSV ported successfully.';
} else {
$this->errorText = "Sorry, there was an error uploading " .$sourceFile;
}
} else {
$this->errorText = 'Select file to upload.';
}
break;
}
return $this->model->tupleID;
}
public function manageExemption($action, $applicantID) {
$this->model->tableID = 'aaa_exemptions';
$this->model->tupleID = $applicantID;
switch ($action) {
case 'new':
case 'edit':
$this->editLock = '';
break;
case 'open':
case 'help':
case 'trash':
break;
case 'save':
// save record
$this->model->saveExemption($_POST['applicantID'],$_POST['remark']);
$this->model->sqlLog();
$this->errorText = 'Exemption record saved successfully.';
break;
case 'delete':
// delete record
$this->errorText = 'Deletion not permitted here.';
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
$xprograms = $_POST['xProgram'];
$programs = $_POST['programID'];
$i = 0;
foreach ($programs as $programID) {
$mmprograms[$xprograms[$i]] = $programID;
$i++;
//$this->model->saveOffer($instituteID,$programID,$batchYear,$rollNo,$dateOffer,$offerCategory,$offerRound,$remark,$status,$nameEnglish,$nameHindi,$gender,$dateBirth,$phoneNo,$email,$homeAddress,$homeDistrict,$homeState,$homePIN,$commAddress,$category,$offerCategory,$religion,$nationality,$pwdStatus,$bloodGroup,$aadhaarNo,$batchYear,$programID,$fatherName,$fatherProfession,$fatherPhone,$fatherEmail,$fatherAddress,$motherName,$motherProfession,$motherPhone,$motherEmail,$motherAddress,$guardianName,$guardianProfession,$guardianPhone,$guardianEmail,$guardianAddress);
//$this->model->sqlLog();
}
foreach ($mmprograms as $key => $value) {
$this->model->setProgramID($instituteID, $key, $value);
}
$dateOffer = date("Y-m-d");
$status = 'Offered';
$dateResponse = '';
$applicantID = 0;
$studentID = 0;
$homeDistrict = 0;
$homePIN = 0;
$commPIN = 0;
$area = 0;
$xYear = 0;
$xiiYear = 0;
$ugYear = 0;
$pgYear = 0;
$rows = $this->model->listCandidates($instituteID);
foreach ($rows as $row) {
// for aaa_applicant table
$no++;
$programID = $row['programID'];
$batchYear = $row['batchYear'];
$roundNo = $row['roundNo'];
$rollNo = $row['RollNo'];
$offerCategory = $row['AllocatedCat']; // AllocatedCat
$remark = $row['RemarksbyRC']; // RemarksbyRC
// for aaa_students table
$nameEnglish = $row['Name']; // Name
$gender = ($row['Gender'] == 'Male' ? 'M' : ($row['Gender'] == 'Female' ? 'F' : 'T'));
$dt = explode('-', $row['DOB']);
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 = ($row['Category'] == 'General' ? 'GEN' : $row['Category']);
$pwdStatus = substr($row['PwD'], 0, 1);
$state = explode(" (", $row['StateEligibility']);
$homeState = $this->model->getStateIDByStateName($state[0]); // StateEligibility
$homeState = $homeState ? $homeState : 0; // StateEligibility
$nationality = substr($row['Nationality'], 0, 2);
$this->model->tupleID = $applicantID;
$this->model->saveApplicant($rollNo,$dateOffer,$programID,$batchYear,$offerCategory,$roundNo,$dateResponse,$studentID,$instituteID,$remark,$status,$nameEnglish,$nameHindi,$gender,$dateBirth,$bloodGroup,$pwdStatus,$caste,$category,$religion,$maritalStatus,$nationality,$aadhaarNo,$homeAddress,$homePIN,$homeState,$homeDistrict,$commAddress,$commPIN,$area,$phoneNo,$email,$xGrade,$xYear,$xBoard,$xiiGrade,$xiiYear,$xiiBoard,$ugGrade,$ugYear,$ugInstitute,$pgGrade,$pgYear,$pgInstitute,$fatherName,$fatherProfession,$fatherPhone,$fatherEmail,$fatherAddress,$motherName,$motherProfession,$motherPhone,$motherEmail,$motherAddress,$guardianName,$guardianProfession,$relationWith,$guardianPhone,$guardianEmail,$guardianAddress);
$this->model->sqlLog();
}
$this->model->tupleID = $instituteID;
// 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->errorText = "$no offers sent successfully.";
break;
}
return $this->model->tupleID;
}
public function manageNRI($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
$rollNo = $_POST['rollNo'];
$instituteID = $_POST['instituteID'];
$programID = $_POST['programID'];
$batchYear = $_POST['batchYear'];
$offerCategory = $_POST['offerCategory'];
$offerRound = $_POST['offerRound'];
$remark = $_POST['remark'];
$studentID = $_POST['studentID'];
$parentID = $_POST['parentID'];
$fname = '';
$mname = '';
$gname = '';
$_POST['area'] = 0;
$_POST['homeState'] = 0;
$_POST['homeDistrict'] = 0;
$_POST['homePIN'] = 0;
$_POST['commPIN'] = 0;
$_POST['xYear'] = 0;
$_POST['xiiYear'] = 0;
$_POST['ugYear'] = 0;
$_POST['pgYear'] = 0;
$_POST['fatherPhone'] = $_POST['phoneNo'];
// save parents record
$parentID = $this->model->saveParent($parentID,$fname,$_POST['fatherProfession'],$_POST['fatherPhone'],$_POST['fatherEmail'],$_POST['fatherAddress'],$mname,$_POST['motherProfession'],$_POST['motherPhone'],$_POST['motherEmail'],$_POST['motherAddress'],$gname,$_POST['guardianProfession'],$_POST['relationWith'],$_POST['guardianPhone'],$_POST['guardianEmail'],$_POST['guardianAddress']);
// save student record with parent id foreign key
$studentID = $this->model->saveStudent($studentID,$parentID,$_POST['nameEnglish'],$_POST['nameHindi'],$_POST['gender'],$_POST['dateBirth'],$_POST['bloodGroup'],$_POST['pwdStatus'],$_POST['caste'],$_POST['category'],$_POST['religion'],$_POST['maritalStatus'],$_POST['nationality'],$_POST['aadhaarNo'],$_POST['homeAddress'],$_POST['homePIN'],$_POST['homeState'],$_POST['homeDistrict'],$_POST['commAddress'],$_POST['commPIN'],$_POST['area'],$_POST['policeStation'],$_POST['phoneNo'],$_POST['email'],$_POST['remark'],$_POST['status']);
// save education record with student id foreign key
//$educationID = $this->model->saveEducation($educationID,$studentID,$_POST['xGrade'],$_POST['xYear'],$_POST['xBoard'],$_POST['xiiGrade'],$_POST['xiiYear'],$_POST['xiiBoard'],$_POST['ugGrade'],$_POST['ugYear'],$_POST['ugInstitute'],$_POST['pgGrade'],$_POST['pgYear'],$_POST['pgInstitute']);
$this->model->saveNRI($rollNo,$studentID,$instituteID,$programID,$batchYear,$offerCategory,$offerRound,$remark);
//$this->model->sqlLog();
$this->errorText = 'NRI 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 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;
break;
case 'back':
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'];
$instituteID = $_POST['instituteID'];
$programID = $_POST['programID'];
$batchYear = $_POST['batchYear'];
$offerCategory = $_POST['offerCategory'];
$offerRound = $_POST['offerRound'];
$remark = $_POST['remark'];
$studentID = $_POST['studentID'];
$educationID = $_POST['educationID'];
$parentID = $_POST['parentID'];
$fname = $_POST['fatherTitle']. ' ' .$_POST['fatherName'];
$mname = $_POST['motherTitle']. ' ' .$_POST['motherName'];
$gname = $_POST['guardianTitle']. ' ' .$_POST['guardianName'];
if ($_POST['homeDistrict'] == '') $_POST['homeDistrict'] = 0;
if ($_POST['homePIN'] == '') $_POST['homePIN'] = 0;
if ($_POST['commPIN'] == '') $_POST['commPIN'] = 0;
if ($_POST['xYear'] == '') $_POST['xYear'] = 0;
if ($_POST['xiiYear'] == '') $_POST['xiiYear'] = 0;
if ($_POST['ugYear'] == '') $_POST['ugYear'] = 0;
if ($_POST['pgYear'] == '') $_POST['pgYear'] = 0;
if ($studentID) {
// also called from manageOffer
// save parents record
$parentID = $this->model->saveParent($parentID,$fname,$_POST['fatherProfession'],$_POST['fatherPhone'],$_POST['fatherEmail'],$_POST['fatherAddress'],$mname,$_POST['motherProfession'],$_POST['motherPhone'],$_POST['motherEmail'],$_POST['motherAddress'],$gname,$_POST['guardianProfession'],$_POST['relationWith'],$_POST['guardianPhone'],$_POST['guardianEmail'],$_POST['guardianAddress']);
// save student record with parent id foreign key
$studentID = $this->model->saveStudent($studentID,$parentID,$_POST['nameEnglish'],$_POST['nameHindi'],$_POST['gender'],$_POST['dateBirth'],$_POST['bloodGroup'],$_POST['pwdStatus'],$_POST['caste'],$_POST['category'],$_POST['religion'],$_POST['maritalStatus'],$_POST['nationality'],$_POST['aadhaarNo'],$_POST['homeAddress'],$_POST['homePIN'],$_POST['homeState'],$_POST['homeDistrict'],$_POST['commAddress'],$_POST['commPIN'],$_POST['area'],$_POST['policeStation'],$_POST['phoneNo'],$_POST['email'],$_POST['remark'],$_POST['status']);
// save education record with student id foreign key
$educationID = $this->model->saveEducation($educationID,$studentID,$_POST['xGrade'],$_POST['xYear'],$_POST['xBoard'],$_POST['xiiGrade'],$_POST['xiiYear'],$_POST['xiiBoard'],$_POST['ugGrade'],$_POST['ugYear'],$_POST['ugInstitute'],$_POST['pgGrade'],$_POST['pgYear'],$_POST['pgInstitute']);
// save applicant record with student id foreign key
$this->model->saveApplicant($rollNo,$studentID,$instituteID,$programID,$batchYear,$offerCategory,$offerRound,$remark);
// sql log entry
$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 'save':
// save record
if ($_POST['paymentNo']) {
$this->model->savePayment($_POST['paymentHead'],$_POST['paymentMode'],$_POST['paymentNo'],$_POST['bankName'],$_POST['datePayment'],$_POST['amount'],$_POST['currency'],$studentID);
$this->model->sqlLog();
$this->errorText = "Payment record 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"] > 1500000) {
$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) {
//echo $applicantID.'-'.$code;
//echo "$studentID,$code,$uploadFile";
$this->model->tupleID = $this->model->saveUpload($studentID,$code,$uploadFile);
}
//$this->model->sqlLog();
$this->errorText = "Successful";
} else {
$this->errorText = "Only jpeg or pdf";
}
} else {
$this->errorText = 'Only jpeg or 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.';
$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 on click of back button
$studentID = $enrolmentID;
$enrolmentID = $this->model->getEnrolmentIDByStudentID($studentID);
$this->model->tupleID = $enrolmentID;
break;
case 'save':
// save enrollment record
$rollNo = $_POST['rollNo'];
$instituteID = $_POST['instituteID'];
$programID = $_POST['programID'];
$batchYear = $_POST['batchYear'];
$enrolCategory = $_POST['category'] .($_POST['pwdStatus'] == 'Y' ? " (PwD)" : '');
$remark = $_POST['remark'];
$studentID = $_POST['studentID'];
$educationID = $_POST['educationID'];
$parentID = $_POST['parentID'];
$fname = $_POST['fatherTitle']. ' ' .$_POST['fatherName'];
$mname = $_POST['motherTitle']. ' ' .$_POST['motherName'];
$gname = $_POST['guardianTitle']. ' ' .$_POST['guardianName'];
if ($_POST['homeDistrict'] == '') $_POST['homeDistrict'] = 0;
if ($_POST['homePIN'] == '') $_POST['homePIN'] = 0;
if ($_POST['commPIN'] == '') $_POST['commPIN'] = 0;
if ($_POST['xYear'] == '') $_POST['xYear'] = 0;
if ($_POST['xiiYear'] == '') $_POST['xiiYear'] = 0;
if ($_POST['ugYear'] == '') $_POST['ugYear'] = 0;
if ($_POST['pgYear'] == '') $_POST['pgYear'] = 0;
// data will be returned either from applicants view or enrolment view
$program = $this->model->getProgram($programID);
$enrolmentNo = $program['rollnoPrefix'] . $batchYear . ($program['lastRollno'] < 10 ? '00' : ($program['lastRollno'] < 100 ? '0' : '')) . ($program['lastRollno'] + 1);
if ($_POST['studentID']) {
//foreach ($_POST as $key => $value) {
// echo $key. '-' .$value. '<br>';
//}
// save parents record
$parentID = $this->model->saveParent($parentID,$fname,$_POST['fatherProfession'],$_POST['fatherPhone'],$_POST['fatherEmail'],$_POST['fatherAddress'],$mname,$_POST['motherProfession'],$_POST['motherPhone'],$_POST['motherEmail'],$_POST['motherAddress'],$gname,$_POST['guardianProfession'],$_POST['relationWith'],$_POST['guardianPhone'],$_POST['guardianEmail'],$_POST['guardianAddress']);
// save student record with parent id foreign key
$studentID = $this->model->saveStudent($studentID,$parentID,$_POST['nameEnglish'],$_POST['nameHindi'],$_POST['gender'],$_POST['dateBirth'],$_POST['bloodGroup'],$_POST['pwdStatus'],$_POST['caste'],$_POST['category'],$_POST['religion'],$_POST['maritalStatus'],$_POST['nationality'],$_POST['aadhaarNo'],$_POST['homeAddress'],$_POST['homePIN'],$_POST['homeState'],$_POST['homeDistrict'],$_POST['commAddress'],$_POST['commPIN'],$_POST['area'],$_POST['policeStation'],$_POST['phoneNo'],$_POST['email'],$_POST['remark'],$_POST['status']);
// save education record with student id foreign key
$educationID = $this->model->saveEducation($educationID,$studentID,$_POST['xGrade'],$_POST['xYear'],$_POST['xBoard'],$_POST['xiiGrade'],$_POST['xiiYear'],$_POST['xiiBoard'],$_POST['ugGrade'],$_POST['ugYear'],$_POST['ugInstitute'],$_POST['pgGrade'],$_POST['pgYear'],$_POST['pgInstitute']);
$this->model->saveEnrolment($enrolmentNo,$instituteID,$programID,$batchYear,$enrolCategory,$studentID,$remark);
$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 manageLDAPreg($action, $rollNo) {
$this->model->tableID = 'aaa_applicants';
$this->model->tupleID = $applicantID;
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['caste'],$_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;
}
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 = date("Y-m-d");
$remark = $_POST['remark'];
//foreach ($_POST as $key => $value) {
// echo $key. '-' .$value. '<br>';
//}
$this->model->saveWithdrawal($dateWithdraw,$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;
}
}
?>