Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
Your IP : 3.141.192.174
<?php
function uploadSSPData_bonf($aobj_context){
ini_set('max_execution_time', 600);
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
session_start();
require_once dirname(__FILE__) . '/../PHPExcel/Classes/PHPExcel/IOFactory.php';
$univcode = $aobj_context->mobj_data["univcode"];
$filename = $aobj_context->mobj_data["gfilename"];
$date = date("dmYhis");
$folderpath = $aobj_context->main_src."SSPData_bonf/".$univcode.'/';
$temp_path = $aobj_context->main_src."upload/".$filename;
if(!file_exists($temp_path))
{
$data = "Please login and try again";
echo $aobj_context->mobj_output->ToJSONEnvelope($data,-1,"failure");
return;
}
// var_dump($temp_path);
if(!file_exists($folderpath))
{
mkdir($folderpath , 0777, true);
}
$inputFileName = $temp_path;
$inputFileType = 'Excel2007';
///////////////////// Code To convert xlsx to csv \\\\\\\\\\\\\
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcelReader = $objReader->load($inputFileName);
$loadedSheetNames = $objPHPExcelReader->getSheetNames();
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcelReader, 'CSV');
$i = 0;
foreach($loadedSheetNames as $sheetIndex => $loadedSheetName)
{
if($i != 0)
break;
$objWriter->setSheetIndex($sheetIndex);
$csvFile = $folderpath.$date.$loadedSheetName.'.csv';
$objWriter->setUseBOM(true);
$objWriter->save($csvFile);
// var_dump($csvFile);
$table_name = "sspdatabonf_{$univcode}";
$drop_query = "DROP TABLE IF EXISTS {$table_name}";
$results = $aobj_context->mobj_db->Execute($drop_query);
// var_dump($results);
$create_query = "CREATE TABLE {$table_name} (
SSP_Student_ID VARCHAR(100),
Hash_of_Student_Aadhaar VARCHAR (100),
Vault_Reference_Number VARCHAR (20),
Name_As_In_Aadhaar VARCHAR (200),
DOB_As_In_Tenth DATE,
Academic_Year_code INT,
University_Registration_Number VARCHAR (100),
Student_Name VARCHAR (200),
Student_Father_Name VARCHAR (300),
Student_Mother_Name VARCHAR (300),
Student_Guardian_Name VARCHAR (200),
Gender INT,
University_SSP_Code INT,
University_Name VARCHAR (100),
College_Name VARCHAR (500),
College_SSP_Code INT,
College_Type VARCHAR (100),
College_Type_SSP_Code INT,
College_District_Name VARCHAR (100),
District_SSP_Code INT,
College_Taluk_Name VARCHAR (100),
Taluk_SSP_Code INT,
Study_Mode VARCHAR (100),
Course_Name VARCHAR (100),
Course_Code INT,
Discipline_Name VARCHAR (100),
Discipline_Code INT,
Course_Year INT,
Seat_Type_Name VARCHAR (200),
Seat_Type_SSP_Code INT,
Admission_Year INT,
Is_Lateral_Entry VARCHAR (1),
Previous_Course_Passed_Year VARCHAR(10),
Previous_Year_SSP_University_Code VARCHAR(10),
Previous_Year_SSP_University_Name VARCHAR (100),
Previous_Year_SSP_College_Code VARCHAR(10),
Previous_Year_SSP_College_Name VARCHAR (500),
Previous_Year_SSP_Course_Code VARCHAR(10),
Previous_Year_SSP_Course_Name VARCHAR (100),
Previous_Year_SSP_Discipline_Code VARCHAR(10),
Previous_Year_SSP_Discipline_Name VARCHAR (100),
Previous_Year_Course_Year VARCHAR(10),
Previous_Year_SSP_Seat_Type_Code VARCHAR(10),
Previous_Year_SSP_Seat_Type_Name VARCHAR (200),
Previous_Year_Max_Marks VARCHAR(10),
Previous_Year_Obtained_Marks VARCHAR(10),
Previous_Year_Percentage_Obtained VARCHAR(10),
PASS_or_FAIL VARCHAR (1),
Promoted VARCHAR (1),
Temp_University_Registration_Number varchar(20),
UG_PG varchar(20),
PRIMARY KEY (University_Registration_Number,University_SSP_Code)
)";
// var_dump($create_query);
// var_dump($csvfile);
$results = $aobj_context->mobj_db->Execute($create_query);
//return;
$query = "LOAD DATA LOCAL INFILE '{$csvFile}'
INTO TABLE {$table_name}
FIELDS TERMINATED BY \",\"
OPTIONALLY ENCLOSED BY '\"'
LINES TERMINATED BY '\n'
(SSP_Student_ID,
Hash_of_Student_Aadhaar,
Vault_Reference_Number,
Name_As_In_Aadhaar,
DOB_As_In_Tenth,
Academic_Year_code,
University_Registration_Number,
Student_Name,
Student_Father_Name,
Student_Mother_Name,
Student_Guardian_Name,
Gender,
University_SSP_Code,
University_Name,
College_Name,
College_SSP_Code,
College_Type,
College_Type_SSP_Code,
College_District_Name,
District_SSP_Code,
College_Taluk_Name,
Taluk_SSP_Code,
Study_Mode,
Course_Name,
Course_Code,
Discipline_Name,
Discipline_Code,
Course_Year,
Seat_Type_Name,
Seat_Type_SSP_Code,
Admission_Year,
Is_Lateral_Entry,
Previous_Course_Passed_Year,
Previous_Year_SSP_University_Code,
Previous_Year_SSP_University_Name,
Previous_Year_SSP_College_Code,
Previous_Year_SSP_College_Name,
Previous_Year_SSP_Course_Code,
Previous_Year_SSP_Course_Name,
Previous_Year_SSP_Discipline_Code,
Previous_Year_SSP_Discipline_Name,
Previous_Year_Course_Year,
Previous_Year_SSP_Seat_Type_Code,
Previous_Year_SSP_Seat_Type_Name,
Previous_Year_Max_Marks,
Previous_Year_Obtained_Marks,
Previous_Year_Percentage_Obtained,
PASS_or_FAIL,
Promoted,
Temp_University_Registration_Number,
UG_PG
)";
$results = $aobj_context->mobj_db->Execute($query);
$rows_affected = $aobj_context->mobj_db->affected_rows();
if(!$results)
{
$data = "Upload failure. Error while loading excel data to database";
echo $aobj_context->mobj_output->ToJSONEnvelope($data,-1,"failure");
return;
}
// Delete All the blank values from table
$query = "DELETE FROM {$table_name} WHERE University_Registration_Number IN ('','University_Registration_Number')";
$results = $aobj_context->mobj_db->Execute($query);
$query = "select fdbname,ffolder from dbname where funivcode = '{$univcode}'";
$results = $aobj_context->mobj_db->GetRow($query);
$db = $results['fdbname'];
$univshort = $results['ffolder'];
// var_dump($db);
$qpdelt = "delete from ssp_bonfdata where funivcode = '{$univcode}' and ifnull(finserted,'') <> 'T'";
$res = $aobj_context->mobj_db->Execute($qpdelt);
$query = "INSERT IGNORE INTO ssp_bonfdata(
SSP_Student_ID,
Hash_of_Student_Aadhaar,
Vault_Reference_Number,
Name_As_In_Aadhaar,
DOB_As_In_Tenth,
Academic_Year_code,
University_Registration_Number,
Student_Name,
Student_Father_Name,
Student_Mother_Name,
Student_Guardian_Name,
Gender,
University_SSP_Code,
University_Name,
College_Name,
College_SSP_Code,
College_Type,
College_Type_SSP_Code,
College_District_Name,
District_SSP_Code,
College_Taluk_Name,
Taluk_SSP_Code,
Study_Mode,
Course_Name,
Course_Code,
Discipline_Name,
Discipline_Code,
Course_Year,
Seat_Type_Name,
Seat_Type_SSP_Code,
Admission_Year,
Is_Lateral_Entry,
Previous_Course_Passed_Year,
Previous_Year_SSP_University_Code,
Previous_Year_SSP_University_Name,
Previous_Year_SSP_College_Code,
Previous_Year_SSP_College_Name,
Previous_Year_SSP_Course_Code,
Previous_Year_SSP_Course_Name,
Previous_Year_SSP_Discipline_Code,
Previous_Year_SSP_Discipline_Name,
Previous_Year_Course_Year,
Previous_Year_SSP_Seat_Type_Code,
Previous_Year_SSP_Seat_Type_Name,
Previous_Year_Max_Marks,
Previous_Year_Obtained_Marks,
Previous_Year_Percentage_Obtained,
PASS_or_FAIL,
Promoted,funivcode,Temp_University_Registration_Number,UG_PG
)
SELECT SSP_Student_ID,
Hash_of_Student_Aadhaar,
Vault_Reference_Number,
Name_As_In_Aadhaar,
DOB_As_In_Tenth,
Academic_Year_code,
University_Registration_Number,
Student_Name,
Student_Father_Name,
Student_Mother_Name,
Student_Guardian_Name,
Gender,
University_SSP_Code,
University_Name,
College_Name,
College_SSP_Code,
College_Type,
College_Type_SSP_Code,
College_District_Name,
District_SSP_Code,
College_Taluk_Name,
Taluk_SSP_Code,
Study_Mode,
Course_Name,
Course_Code,
Discipline_Name,
Discipline_Code,
Course_Year,
Seat_Type_Name,
Seat_Type_SSP_Code,
Admission_Year,
Is_Lateral_Entry,
Previous_Course_Passed_Year,
Previous_Year_SSP_University_Code,
Previous_Year_SSP_University_Name,
Previous_Year_SSP_College_Code,
Previous_Year_SSP_College_Name,
Previous_Year_SSP_Course_Code,
Previous_Year_SSP_Course_Name,
Previous_Year_SSP_Discipline_Code,
Previous_Year_SSP_Discipline_Name,
Previous_Year_Course_Year,
Previous_Year_SSP_Seat_Type_Code,
Previous_Year_SSP_Seat_Type_Name,
Previous_Year_Max_Marks,
Previous_Year_Obtained_Marks,
Previous_Year_Percentage_Obtained,
PASS_or_FAIL,
Promoted,'{$univcode}',Temp_University_Registration_Number,UG_PG
FROM {$table_name}";
$results = $aobj_context->mobj_db->Execute($query);
$rows_affectedi = $aobj_context->mobj_db->affected_rows();
}
if($results)
{
$data = "Uploaded";
echo $aobj_context->mobj_output->ToJSONEnvelope($data,0,"success");
return;
}
else
{
$data = "Error while updating";
echo $aobj_context->mobj_output->ToJSONEnvelope($data,-1,"error");
return;
}
}
function loadsspbonfpush($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data["univcode"];
//var_dump($univcode);
//die();
$query = "select distinct FSSPCODE,FSSPKEY
from logisys3_comexam.dbname
where funivcode = '{$univcode}'";
$result3 = $aobj_context->mobj_db->GetRow($query);
$univsspcode = $result3['FSSPCODE'];
if($result3)
{
}
else
{
$data = "SSP Uni. Code not found contact admin";
echo $aobj_context->mobj_output->ToJSONEnvelope($data,-1,"error");
return;
}
$query = "select distinct University_Name, University_SSP_Code,
sum(if(ifnull(finserted,'F') = 'F',1,0)) as not_pushed,
sum(if(ifnull(finserted,'F') = 'T',1,0)) as pushed,
count(*) as tot
from logisys3_comexam.ssp_bonfdata
where University_SSP_Code = '{$univsspcode}'";
// var_dump($query);
// die();
$result = $aobj_context->mobj_db->GetRow($query);
if($result)
{
$data = "Uploaded Pushed";
echo $aobj_context->mobj_output->ToJSONEnvelope($result,0,"success");
return;
}
else
{
$data = "No Details uploaded.";
echo $aobj_context->mobj_output->ToJSONEnvelope($data,-1,"error");
return;
}
}
?>
|