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.135.202.168
<?php
require_once("/var/www/html/aws/aws-autoloader.php");
require_once(__DIR__ . "/../../aws/aws-autoloader.php");
use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;
include("/var/www/config.php");
include("leadLogs.php");
$main_src = substr($_SERVER['SCRIPT_FILENAME'], 0, strlen($_SERVER['SCRIPT_FILENAME']) - 7);
$pdf_writer_class = $main_src . "/tcpdf/tcpdf.php";
require_once $pdf_writer_class;
class MYPDF extends TCPDF{
public $aobj_context;
public $degreegrp;
public function setData($aobj_context){
$this->aobj_context = $aobj_context;
}
public function Header($aobj_context){
$this->univcode = $this->aobj_context->mobj_data["univcode"];
$bMargin = $this->getBreakMargin();
$auto_page_break = $this->AutoPageBreak;
$this->SetAutoPageBreak(false, 0);
$this->SetTitle("Fee Report");
$img_path = $this->aobj_context->main_src . "/img/".$this->univcode."_logo.jpg";
if (file_exists($img_path)) {
$this->Image($img_path, 10,3,30,10);
}
$this->SetFont('Times', 'B', 12);
$this->Ln(5);
$this->Cell(0, 4, $this->aobj_context->funivname, 0, 1, 'C');
$this->SetFont('Times', 'B', 10);
$this->Cell(0, 4, $this->aobj_context->add, 0, 1, 'C');
$this->SetFont('Times', '', 10);
$this->Cell(0, 4, $this->aobj_context->s_state, 0, 1, 'C');
// telephone number
$this->SetFont('Times', '', 9);
$this->Cell(0, 4, "TEL- ".$this->aobj_context->telno." ". $website, 0, 1, 'C');
$this->SetAutoPageBreak($auto_page_break, $bMargin);
}
public function Footer(){
$this->SetY(-15);
$this->SetFont('helvetica', 'I', 8);
$this->Cell(0, 10, 'Page ' . $this->getAliasNumPage() . '/' . $this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
}
}
class ReprtObject{
public function DefaultConstructor($aobj_context){
$this->aobj_context = $aobj_context;
// $this->aobj_context->mobj_db = $aobj_context;
// $aobj_context->pobj_db = $aobj_context;
// $aobj_context = new stdClass();
$univcode = $aobj_context->mobj_data["univcode"];
$this->ip = $_SERVER["REMOTE_ADDR"];
$get_date = "select DATE_FORMAT(now(), '%d/%m/%Y') as now_date";
// var_dump($this->aobj_context->mobj_db);die();
$obj = $this->aobj_context->mobj_db->GetRow($get_date);
$get_coll_name = "select funivname, funivcode, funivadd2,
funivadd1 AS 'state', pdf_logo_path, ftdvs_helplineno as telno,
fadmdec
FROM control";
$lobj_get_coll_name = $this->aobj_context->pobj_db->GetRow($get_coll_name);
$aobj_context->funivname = $lobj_get_coll_name['funivname'];
$aobj_context->s_state = $lobj_get_coll_name['state'];
$aobj_context->add = $lobj_get_coll_name['funivadd2'];
$aobj_context->telno = $lobj_get_coll_name['telno'];
$aobj_context->pdf_logo_path = $lobj_get_coll_name['pdf_logo_path'];
$aobj_context->funivcode = $lobj_get_coll_name['funivcode'];
$aobj_context->admdec = $lobj_get_coll_name['fadmdec'];
$this->current_date = $obj['now_date'];
$this->pdf = new MYPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'ISO-8859-1', false);
$this->pdf->setData($aobj_context);
}
public function Report($aobj_context){
$appNo = $aobj_context->mobj_data["app_no"];
$univcode = $aobj_context->mobj_data["univcode"];
$query = "select a.fappno,a.fleadid, a.fname, fmobile, femail, if(fgender = 'F', 'Female', 'Male')as fgender,
date_format(fdob, '%d/%m/%Y')as fdob, fcatecode, fnation as nationality,
ffatname
, fmotname, freligion, faadhaarno, concat(a.fdegree, ' - ', fdescpn)as fdegree,
concat(fadd1, ', ', fadd2, ', ', fadd3)as fadd,
s.fname as fstate, fcountry, fpincode,
ifnull(a.faadhaarpath,'') as faadhaarpaths,
ifnull(a.ftenpath,'') as ftenpaths,
ifnull(a.ftwthpath,'') as ftwthpaths,
ifnull(a.ftcpath,'') as ftcpaths,
ifnull(a.fmigpath,'') as fmigpaths,
ifnull(a.fugpath,'') as fugpaths,
ifnull(a.fstdpicpath, '') as fstdpicpath
from adm_stud a inner join adm_state s on s.fid = a.fstate
inner join degree d on d.fdegree = a.fdegree
where fappno ='{$appNo}' group by a.fappno";
$per_details = $this->aobj_context->pobj_db->GetRow($query);
if (!empty($per_details['faadhaarpaths'])) {
// Assuming faadhaarpaths contains the Bitbucket URL
$file_url = "https://qp-tran.s3.ap-south-1.amazonaws.com/".$per_details['faadhaarpaths'];
// Download the file from Bitbucket
$output_file = $this->aobj_context->main_src ."uploads/".$univcode . '_' . $appNo . '.pdf';
// Example function to download file from URL using cURL
function downloadFile($url, $output_file) {
$ch = curl_init($url);
$fp = fopen($output_file, 'wb');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
}
// Download the file from Bitbucket
downloadFile($file_url, $output_file);
// Check if the file was downloaded successfully
if (file_exists($output_file) && is_readable($output_file)) {
// Initialize TCPDF
$pdf = $this->pdf;
$pdf->AddPage();
// Add content to PDF
$pdf->SetFont('Times', '', 12);
$pdf->Cell(0, 10, 'Downloaded File Content:', 0, 1);
$pdf->MultiCell(0, 10, file_get_contents($output_file));
// Output the PDF (save to file)
$pdf->Output($output_file, 'F');
// Optionally, force download the generated PDF
header('Content-Description: File Transfer');
header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename="' . basename($output_file) . '"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($output_file));
readfile($output_file);
exit;
} else {
echo "Error downloading or accessing downloaded file.";
}
} else {
echo "File path from Bitbucket is empty or not found.";
}
}
}
function testReport($aobj_context){
$univcode = $aobj_context->mobj_data["univcode"];
$application_context = new ReprtObject($aobj_context);
$application_context->DefaultConstructor($aobj_context);
$application_context->Report($aobj_context);
}
?>
|