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.144.25.130
<?php
$main_src = substr($_SERVER['SCRIPT_FILENAME'], 0, strlen($_SERVER['SCRIPT_FILENAME']) - 7);
//$pdf_writer_class =$main_src."/tarka_pdf/fpdf.php";
$pdf_writer_class = $main_src . "/tcpdf/tcpdf.php";
require_once $pdf_writer_class;
// ini_set('memory_limit','900M');
// ini_set('max_execution_time',0);
class MYPDF extends TCPDF
{
public $aobj_context;
public function setData($aobj_context)
{
$this->aobj_context = $aobj_context;
$this->Degree = $aobj_context->mobj_data["deggrp"];
$this->rtype = $aobj_context->mobj_data["val"];
$this->univcode = $aobj_context->mobj_data["univcode"];
}
public function Header()
{
// var_dump($Degree);
// get the current page break margin
$bMargin = $this->getBreakMargin();
// get current auto-page-break mode
$auto_page_break = $this->AutoPageBreak;
// disable auto-page-break
$this->SetAutoPageBreak(false, 0);
// set bacground image
// $this->SetMargins(6,30,5,true);
$this->SetFillColor(248, 248, 255);
$img_path = $this->aobj_context->main_src . "/img/logo.jpg";
if (file_exists($img_path)) {
$this->Image($img_path, 6, 6, 20, 20);
}
$this->SetFont('Times', 'B', 13);
$this->SetY(5);
$this->Cell(0, 4, $this->aobj_context->FUNIVNAME, 0, 1, 'C');
//state
$this->SetFont('Times', '', 11);
$this->Cell(0, 4, $this->aobj_context->s_state, 0, 1, 'C');
$this->SetFont('Times', 'BU', 12);
$this->Ln(1);
$this->Cell(0, 5, $this->rtype, '0', 1, 'C');
$this->SetFont('Times', 'B', 12);
$this->Cell(0, 6, "Degree Group Range: " . $this->aobj_context->mobj_data["deggrpfrm"] . ' - ' . $this->aobj_context->mobj_data["deggrpto"] , "0", 1, "C");
$this->Cell(0, 6, "College Code Range: " . $this->aobj_context->mobj_data["collfrm"] . ' - ' . $this->aobj_context->mobj_data["collto"] , "0", 1, "C");
// restore auto-page-break status
$this->SetAutoPageBreak($auto_page_break, $bMargin);
// set the starting point for the page content
}
public function Footer()
{
$this->SetY(-15);
$this->SetFont('helvetica', 'I', 8);
$this->Cell(50, 10, 'IP : ' . $_SERVER["REMOTE_ADDR"], 0, 0, 'L');
$this->Cell(80, 10, 'Date : ' . date("d-m-Y H:i:s"), 0, 0, 'C');
$this->Cell(100, 10, 'Page ' . $this->getPageNumGroupAlias() . '/' . $this->getPageGroupAlias(), 0, 1, 'R');
}
}
class CollegeList
{
public function DefaultConstructor($aobj_context)
{
$this->aobj_context = $aobj_context;
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$this->ip = $_SERVER["REMOTE_ADDR"];
$get_date = "select DATE_FORMAT(now(), '%d/%m/%Y') as now_date";
$obj = $this->aobj_context->pobj_db->GetRow($get_date);
$get_coll_name = "select FUNIVNAME as 'FUNIVNAME',FUNIVCODE,
FUNIVADD1 as 'state', pdf_logo_path,
ifnull(FEXAMAPPREQ,'F') as FEXAMAPPREQ 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->pdf_logo_path = $lobj_get_coll_name['pdf_logo_path'];
$aobj_context->FUNIVCODE = $lobj_get_coll_name['FUNIVCODE'];
$this->current_date = $obj['now_date'];
$this->pdf = new MYPDF('L');
$this->pdf->setData($aobj_context);
}
public function tableHeader($pdf)
{
// $pdf->SetFont('Times','B',10);
// $pdf->Cell(0,8,"Exam Center List","0",'1','C');
$pdf->Ln(3);
$pdf->SetFont('Times', 'B', 10);
$pdf->Cell(8, 6, "Sl.", "LRT", 0);
$pdf->Cell(10, 6, "Colg", "LRT", 0, "C");
$pdf->Cell(100, 6, "College", "LRT", 0, "C");
$pdf->Cell(55, 6, "Principal", "LRT", 0, "C");
$pdf->Cell(20, 6, "Mobile", "LRT", 0, "C");
$pdf->Cell(55, 6, "Email", "LRT", 0, "C");
$pdf->Cell(20, 6, "Alt", "LRT", 1, "C");
$pdf->Cell(8, 6, "No", "LRB", 0, "C");
$pdf->Cell(10, 6, "Code", "LRB", 0, "C"); //w h txt brd pos align
$pdf->Cell(100, 6, "Name", "LBR", 0, "C");
$pdf->Cell(55, 6, "Name", "LBR", 0, "C");
$pdf->Cell(20, 6, "No.", "LBR", 0, "C");
$pdf->Cell(55, 6, "", "LBR", 0, "C");
$pdf->Cell(20, 6, "Contact", "LBR", 1, "C");
$pdf->SetFont('Times', '', 10);
}
public function writeReport($collegelist)
{
$pdf = $this->pdf;
$pdf->SetMargins(15, 32);
$pdf->startPageGroup();
$pdf->AddPage("L");
$pdf->SetFont('Times', '', 10);
$this->tableHeader($pdf);
foreach ($collegelist as $key => $value) {
$sl_no++;
$pdf->SetFont('Times', '', 10);
$x = $pdf->GetX();
$y = $pdf->GetY();
$pdf->SetX($x + 18);
$pdf->MultiCell(100, 6, $value['fcollname'], "LRT", "L");
$y1 = $pdf->GetY();
$h = $y1 - $y;
$pdf->SetXY($x, $y);
$pdf->Cell(8, $h, $sl_no, "LRT", 0, 'C');
$pdf->cell(10, $h, $value['fcollcode'], "LRT", 0, "C");
$pdf->SetXY($x + 118, $y);
$pdf->cell(55, $h, $value['fprincipalname'], "LRT", 0, "L");
$pdf->cell(20, $h, $value['fmobile'], "LRT", 0, "C");
$pdf->cell(55, $h, $value['femail'], "LRT", 0, "L");
$pdf->cell(20, $h, $value['faltmobile'], "LRT", 1, "R");
if ($pdf->getY() > 175) {
$pdf->cell(268, 1, '', 'T', 1, 'L');
$pdf->AddPage("L");
$this->tableHeader($pdf);
}
}
$pdf->cell(268, 1, '', 'T', 1, 'L');
}
public function tableHeaderForTaggedColg($pdf)
{
$pdf->Ln(3);
$pdf->SetFont('Times', 'B', 10);
$pdf->Cell(10, 8, "Sl.", "LRT", 0);
$pdf->Cell(112, 8, "Center", "1", 0, "C");
$pdf->Cell(112, 8, "Tagged College", "1", 1, "C");
$pdf->Cell(10, 6, "No", "LRB", 0, "C");
$pdf->Cell(12, 6, "Code", "LRB", 0, "C"); //w h txt brd pos align
$pdf->Cell(78, 6, "Name", "LBR", 0, "C");
$pdf->Cell(22, 6, "Contact", "LBR", 0, "C");
$pdf->Cell(12, 6, "Code", "LRB", 0, "C");
$pdf->Cell(78, 6, "Name", "LBR", 0, "C");
$pdf->Cell(22, 6, "Contact", "LBR", 1, "C");
$pdf->SetFont('Times', '', 10);
}
public function TaggedReport($taggedcollegelist)
{
$pdf = $this->pdf;
$pdf->SetMargins(25, 32);
$pdf->startPageGroup();
$pdf->AddPage("L");
$pdf->SetFont('Times', '', 10);
$this->tableHeaderForTaggedColg($pdf);
$sl_no = 0;
$first = false;
$oldCode = "";
$newCode = "";
$count = 0;
//MultiCell($w, $h, $txt, $border=0, $align='J', $fill=0, $ln=1, $x='', $y='', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0)
foreach ($taggedcollegelist as $key => $value) {
$newCode = $value['cnt_code'];
$colname1 = substr($value['center_name'], 0, 41);
$colname2 = substr($value['center_name'], 41);
$colname3 = substr($value['tagged_colg_name'], 0, 41);
$colname4 = substr($value['tagged_colg_name'], 41);
$pdf->SetFont('Times', '', 10);
if ($newCode != $oldCode) {
$sl_no++;
$pdf->Cell(10, 6, $sl_no, "LRT", 0, "C");
$pdf->cell(12, 6, $value['cnt_code'], "LRT", 0, "C");
$pdf->cell(78, 6, $colname1, "LRT", 0, "L");
$pdf->cell(22, 6, $value['cnt_contact'], "LRT", 0, "C");
} else {
$pdf->Cell(10, 6, "", "LR", 0);
$pdf->cell(12, 6, "", "LR", 0, "C");
$pdf->cell(78, 6, "", "LR", 0, "L");
$pdf->cell(22, 6, "", "LR", 0, "C");
}
$pdf->cell(12, 6, $value['tagged_code'], "LRT", 0, "C");
$pdf->cell(78, 6, $colname3, "LRT", 0, "L");
$pdf->cell(22, 6, $value['tagged_contact'], "LRT", 1, "C");
if ($pdf->getY() > 165) {
$pdf->cell(234, "", "", "T", 1);
$pdf->AddPage("L");
$this->tableHeaderForTaggedColg($pdf);
}
if ($colname2 || $colname4) {
if ($colname4) {
if ($newCode != $oldCode) {
$pdf->Cell(10, 6, "", "LR", 0);
$pdf->cell(12, 6, "", "LR", 0, "C");
$pdf->cell(78, 6, $colname2, "LR", 0, "L");
$pdf->cell(22, 6, "", "LR", 0, "C");
} else {
$pdf->Cell(10, 6, "", "LR", 0);
$pdf->cell(12, 6, "", "LR", 0, "C");
$pdf->cell(78, 6, "", "LR", 0, "L");
$pdf->cell(22, 6, "", "LR", 0, "C");
}
$pdf->cell(12, 6, "", "LBR", 0, "C");
$pdf->cell(78, 6, $colname4, "LBR", 0, "L");
$pdf->cell(22, 6, "", "LBR", 1, "C");
} else {
if ($newCode != $oldCode) {
$pdf->Cell(10, 6, "", "LR", 0);
$pdf->cell(12, 6, "", "LR", 0, "C");
$pdf->cell(78, 6, $colname2, "LR", 0, "L");
$pdf->cell(22, 6, "", "LR", 0, "C");
} else {
$pdf->Cell(10, 6, "", "LR", 0);
$pdf->cell(12, 6, "", "LR", 0, "C");
$pdf->cell(78, 6, "", "LR", 0, "L");
$pdf->cell(22, 6, "", "LR", 0, "C");
}
$pdf->cell(12, 6, "", "LBR", 0, "C");
$pdf->cell(78, 6, "", "LBR", 0, "L");
$pdf->cell(22, 6, "", "LBR", 1, "C");
}
}
$oldCode = $newCode;
if ($pdf->getY() > 165) {
$pdf->cell(234, "", "", "T", 1);
$pdf->AddPage("L");
$this->tableHeaderForTaggedColg($pdf);
}
// $first=false;
}
$pdf->cell(234, "", "", "T", 1);
}
public function SendOutput()
{
ob_end_clean();
$this->pdf->Output("{$this->rtype}_{$this->univcode}.pdf", "I");
}
}
function PrintCollegeList($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data["univcode"];
$Degree = $aobj_context->mobj_data["deggrp"];
$rtype = $aobj_context->mobj_data["val"];
$deggrpfrm = $aobj_context->mobj_data["deggrpfrm"];
$deggrpto = $aobj_context->mobj_data["deggrpto"];
$collfrm = $aobj_context->mobj_data["collfrm"];
$collto = $aobj_context->mobj_data["collto"];
// $query = "select distinct b.fexamcodet as fcollcode, concat(a.fcollname,', ',a.ftown) as fcollname, lcase(a.fcolladd1) as fcolladd1 ,lcase(a.fcolladd2) as fcolladd2,
// ifnull(a.fprincipalname,'') fprincipalname, ifnull(a.fphone,'') landline, ifnull(a.fmobile,'') fmobile, ifnull(a.femail,'') femail,ifnull(a.faltmobile,'') faltmobile
// from college a inner join degcntr b on a.fcollcode = b.fexamcodet
// where b.fdeggrp BETWEEN '{$deggrpfrm}' AND '{$deggrpto}' and a.fcollcode BETWEEN '{$collfrm}' AND '{$collto}'";
if ($deggrpfrm == '0' && $deggrpto == 'zzzzz') {
$query = "select fcollcode, fcollname, ftown as town, lcase(fcolladd1) as fcolladd1 ,lcase(fcolladd2) as fcolladd2,
ifnull(fprincipalname,'') fprincipalname, ifnull(fphone,'') landline, ifnull(fmobile,'') fmobile, ifnull(femail,'') femail,ifnull(faltmobile,'') faltmobile
from college";
} else if ($deggrpfrm == $deggrpto) {
$query = "select fcollcode, fcollname, ftown as town, lcase(fcolladd1) as fcolladd1 ,lcase(fcolladd2) as fcolladd2,
ifnull(fprincipalname,'') fprincipalname, ifnull(fphone,'') landline, ifnull(fmobile,'') fmobile, ifnull(femail,'') femail,ifnull(faltmobile,'') faltmobile
from college where ifnull(ffaculty,'') like '%{$deggrpfrm}%'";
} else {
$query = "select fcollcode, fcollname, ftown as town, lcase(fcolladd1) as fcolladd1 ,lcase(fcolladd2) as fcolladd2,
ifnull(fprincipalname,'') fprincipalname, ifnull(fphone,'') landline, ifnull(fmobile,'') fmobile, ifnull(femail,'') femail,ifnull(faltmobile,'') faltmobile
from college where ifnull(ffaculty,'') like '%{$deggrpfrm}%' OR ifnull(ffaculty,'') like '%{$deggrpto}%'";
}
$result = $aobj_context->pobj_db->GetAll($query);
$class_obj = new CollegeList();
$class_obj->univcode = $univcode;
$class_obj->rtype = $rtype;
$query = "select * from deggrp where fdeggrp BETWEEN '{$deggrpfrm}' AND '{$deggrpto}' '";
$results = $aobj_context->pobj_db->GetRow($query);
$aobj_context->mobj_data["deggrp"] = $results['fdeggrp'] . ' - ' . $results['fdescpn'];
$class_obj->DefaultConstructor($aobj_context);
// If No data found Generate Blank Report
if (count($result) > 0) {
$class_obj->writeReport($result);
}
$class_obj->SendOutput();
}
function PrintCenterList($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data["univcode"];
$Degree = $aobj_context->mobj_data["deggrp"];
$rtype = $aobj_context->mobj_data["val"];
$deggrpfrm = $aobj_context->mobj_data["deggrpfrm"];
$deggrpto = $aobj_context->mobj_data["deggrpto"];
$collfrm = $aobj_context->mobj_data["collfrm"];
$collto = $aobj_context->mobj_data["collto"];
$query = "select * from deggrp where fdeggrp = '{$Degree}'";
$results = $aobj_context->pobj_db->GetRow($query);
$year = $results['fyear'];
$examtype = $results['fexamtype'];
$query = "select distinct b.fexamcodet as fcollcode, concat(a.fcollname, a.ftown) as fcollname,
a.fmobile, ifnull(a.fprincipalname,'') fprincipalname, ifnull(a.femail,'') femail,
ifnull(a.faltmobile,'') faltmobile, ifnull(a.fphone,'') landline
from college a inner join degcntr b on a.fcollcode = b.fexamcodet
where b.fdeggrp = '{$Degree}' and a.fcollcode BETWEEN '{$collfrm}' AND '{$collto}' and b.fyear = '{$year}' and b.fexamtype = '{$examtype}'
order by b.fexamcodet";
$result = $aobj_context->pobj_db->GetAll($query);
$class_obj = new CollegeList();
$class_obj->univcode = $univcode;
$class_obj->rtype = $rtype;
$aobj_context->mobj_data["deggrp"] = $results['fdeggrp'] . ' - ' . $results['fdescpn'];
$class_obj->DefaultConstructor($aobj_context);
if (count($result) > 0) {
$class_obj->writeReport($result);
}
$class_obj->SendOutput();
}
function PrintTaggedColleges($aobj_context)
{
$univcode = $aobj_context->mobj_data["univcode"];
$Degree = $aobj_context->mobj_data["deggrp"];
$format = $aobj_context->mobj_data["format"];
$rtype = $aobj_context->mobj_data["val"];
$deggrpfrm = $aobj_context->mobj_data["deggrpfrm"];
$deggrpto = $aobj_context->mobj_data["deggrpto"];
$collfrm = $aobj_context->mobj_data["collfrm"];
$collto = $aobj_context->mobj_data["collto"];
$query = "select * from deggrp where fdeggrp = '{$Degree}'";
$results = $aobj_context->pobj_db->GetRow($query);
$year = $results['fyear'];
$examtype = $results['fexamtype'];
$query = "SELECT c2.fcollcode as cnt_code, concat(c2.fcollname,', Const.: ',c2.ftown) as center_name,
c1.fcollcode as tagged_code, concat(c1.fcollname, ', Const.:', c1.ftown) as tagged_colg_name,
ifnull(c2.fmobile,'') cnt_contact,ifnull(c1.fmobile,'') tagged_contact
FROM degcntr dg inner join college c1 on dg.fcollcode = c1.fcollcode
INNER JOIN college c2 ON dg.fexamcodet = c2.fcollcode
where dg.fdeggrp = '{$Degree}' and c2.fcollcode BETWEEN '{$collfrm}' AND '{$collto}' and dg.fyear = '{$year}' and dg.fexamtype = '{$examtype}'
ORDER BY c2.fcollcode, c1.fcollcode;";
// var_dump($query);
$result = $aobj_context->pobj_db->GetAll($query);
if ($format == 'tables') {
if ($result) {
echo $aobj_context->mobj_output->ToJSONEnvelope($result, 0, "success");
return;
} else {
$arr['msg'] = "No data found";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
} else {
$class_obj = new CollegeList();
$class_obj->univcode = $univcode;
$class_obj->rtype = $rtype;
$class_obj->DefaultConstructor($aobj_context);
$aobj_context->mobj_data["deggrp"] = $results['fdeggrp'] . ' - ' . $results['fdescpn'];
// If No data found Generate Blank Report
if (count($result) > 0) {
$class_obj->TaggedReport($result);
}
$class_obj->SendOutput();
}
}
|