0xV3NOMx
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 : 18.119.142.113


Current Path : /proc/thread-self/root/var/www/html/ssa/src_16042016/
Upload File :
Current File : //proc/thread-self/root/var/www/html/ssa/src_16042016/import_marks.php

<?php
class import_marks
{
public $module_name;
	function __construct($aobj_context)
	{
		session_start();
		$this->aobj_context=$aobj_context;
		$this->aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
		$this->user_id = $_SESSION['user_id'];
		$this->college_code = $_SESSION['collcode'];
		require_once($this->aobj_context->main_src."/src/format.php");
		$this->root_file_name=$this->aobj_context->main_src."/imported_files/gl_expenses";
		$this->root_file_name = $this->root_file_name . $_SESSION['user_id']."_".basename( $_FILES['module_details_uploaded_file']['name']); 
		 $this->header_arr=array("Regno","Subcode","Marks");
		$this->error_file_arr=array();	
		$this->error_cnt=0;	
	}
		//End : Constructor 
	function MoveUploadFile()
	{
	
		if(isset($_FILES['module_details_uploaded_file']['name']) && $_FILES['module_details_uploaded_file']['name'] != '')         
		{ 
			if(move_uploaded_file($_FILES['module_details_uploaded_file']['tmp_name'],$this->root_file_name))
			{
			return true;
			}
		} 
		return false;
	}
	function ReadExcelFile()
	{
		require_once($this->aobj_context->main_src."/Excel_reader/reader.php");
		$this->data = new Spreadsheet_Excel_Reader();
		$this->data->setOutputEncoding('CP1251');
		$this->data->read($this->root_file_name);
		error_reporting(E_ALL ^ E_NOTICE);
	 
		foreach($this->data->boundsheets as $k=>$v)
		{
		$this->sheet_names_arr[$v[name]]=$this->data->sheets[$k];
		}
		
			foreach($this->sheet_names_arr as $sheet_k=>$sheet_v)
			{
				$header_row=$sheet_v[cells][1];//Taking Header Cols
				 
				foreach($sheet_v[cells] as $row_k=>$row_v)
				{
					if($row_k>1)
					{
						foreach($header_row as $hk=>$hv)
						{
						$arr_val=$row_v[$hk];
						trim_array_value($arr_val);
						$this->excel_formed_sheet_arr["General"][$row_k][$hv]=$arr_val;
						}
					}
				}			
			}
		 
	}
	function ProcessExcelFile()
	{
		foreach($this->excel_formed_sheet_arr["General"] as $rk=>$rv)
		{
			 $this->Regno=trim($rv['Regno']);
			 $this->Marks=trim(($rv['Marks']));
			 $this->Subcode=trim($rv['Subcode']);
			  $this->insertValues($rv);
			 
		}
	}
	function insertValues($rv)
	{
		$update_marks="update marks set FMARKS='{$this->Marks}',
							FLOGDATE=NOW()
						where FREGNO='{$this->Regno}'
						and FSUBCODE='{$this->Subcode}'
						and FCOLLCODE='{$this->college_code}'";
		 
		$lobj_update_marks = $this->aobj_context->mobj_db->Execute($update_marks);
	 
	
	 
	if(!$lobj_update_marks)
		{
			$this->error_cnt++;
			$rv[error]=mysql_error();
			$this->error_file_arr[$this->error_cnt]=$rv;
			 
				
		}		
	 
	}
	 
	function WriteErrorSuccessDetails()
	{
	
		if(!empty($this->error_file_arr))
		{
			require_once($this->aobj_context->main_src."/Excel_Writer/Writer.php");
			require_once($this->aobj_context->main_src."/custom_src/TarkaFormatStyles.php");
			$objfrmt =& new FormatStyle(); 	// for  format classes 	      	 				
			$workbook = new Spreadsheet_Excel_Writer();

			$this->worksheet =& $workbook->addWorksheet();			
			$Title_Center =& $workbook->addFormat($objfrmt->Title_Center);					 		 	
			$Headings_Left =& $workbook->addFormat($objfrmt->Headings_Left);					 		 	
			$Data_Left =& $workbook->addFormat($objfrmt->Data_Left);					 		 	
			$row=0;
		
			$this->worksheet->write($row,0,"Following Records are not Updated",$Data_Left);
			$row+=2;
			$cell=0;
			foreach($this->header_arr as $k=>$v)
			{
			$this->worksheet->write($row,$cell, $v,$Headings_Left);$cell++; 	
			}
			$this->worksheet->write($row,$cell, "error");
			$row+=1;	
				$cell=0;
			foreach($this->error_file_arr as $ek=>$ev)
			{
				foreach($ev as $ekk=>$evv)
				{
				$this->worksheet->write($row,$cell,$evv);
				$cell++;
				}
				$cell=0;
				$row++;
				 
			}	
			

			$workbook->close();
			$workbook->send("error_details.xls"); 	
		}
		else
		{
			echo "<script>alert('successfully Done')</script>";
		}
	}
	
	 
}
function ImportMarksViaExcel($aobj_context)
{
	$obj=new import_marks($aobj_context);
	if($obj->MoveUploadFile())
	{
	 $obj->ReadExcelFile();
	 $obj->ProcessExcelFile();
	 $obj->WriteErrorSuccessDetails();
	}
	else
	{
	echo "File Mooving Failed";
	}
 } 
 function trim_array_value(&$value) 
{ 
$value = trim($value); 
}
?>