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 : 3.144.242.149


Current Path : /var/www/html/univadmin/tdvsreports/
Upload File :
Current File : /var/www/html/univadmin/tdvsreports/generatetadabill.php

<?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;
ini_set('max_execution_time', '300');
include('getnumword.php');

class MYPDF extends TCPDF
{
    public function Header($resbill)
    {
        // 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);
        $this->SetTitle("VALUATION BILL");

        // set bacground image
        $this->SetFillColor(248, 248, 255);
        $img_path = $this->aobj_context->main_src . "/img/".$this->aobj_context->FUNIVCODE."_logo.jpg";
        
        if (file_exists($img_path)) {
            $this->Image($img_path, 6, 6, 25, 25);
        }

        $this->SetFont('Times', 'B', 14);
        $this->SetY(5);
        $this->Cell(0, 7, $this->aobj_context->FUNIVNAME, 0, 1, 'C');
        //state
        $this->SetFont('Times', 'B', 11);
        $this->Cell(0, 4, $this->aobj_context->s_state, 0, 1, 'C');

        $this->SetFont('Times', 'B', 13);
        if($this->aobj_context->FUNIVCODE == '033' || $this->aobj_context->FUNIVCODE == '040')
        {
            $this->Cell(0, 7, 'REMUNERATION BILL', '0', 1, 'C');
        }else
            $this->Cell(0, 7, 'TRAVELLING ALLOWANCE AND REMUNERATION BILL', '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);
        // var_dump();
        if($this->CurOrientation == 'P')
        {
            $this->Cell(60, 10, 'IP : ' . $_SERVER["REMOTE_ADDR"], 0, 0, 'L');
            $this->Cell(60, 10, 'Date : ' . date("d-m-Y h:i:s A"), 0, 0, 'C');
            $this->Cell(60, 10, 'Page ' . $this->getPageNumGroupAlias() . '/' . $this->getPageGroupAlias(), 0, 1, 'R');
        }
        else {
            $this->Cell(90, 10, 'IP : ' . $_SERVER["REMOTE_ADDR"], 0, 0, 'L');
            $this->Cell(90, 10, 'Date : ' . date("d-m-Y h:i:s A"), 0, 0, 'C');
            $this->Cell(90, 10, 'Page ' . $this->getPageNumGroupAlias() . '/' . $this->getPageGroupAlias(), 0, 1, 'R');
        }
    }
}

class ReprtObject
{
    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->mobj_db->GetRow($get_date);
        $this->reportType = $aobj_context->mobj_data["rtype"];

        $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 = $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'];
        $deggrp = $this->aobj_context->mobj_data["deggrp"];

       $get_coll_name = "select concat(fdeggrp, ' - ', fdescpn) as fdeggrp 
        from deggrp where fdeggrp = '{$deggrp}'";
        $lobj_get_degree = $this->aobj_context->pobj_db->GetRow($get_coll_name);
        
        $aobj_context->deggrp = $lobj_get_degree['fdeggrp'];
        $this->pdf = new MYPDF('P');
        $this->pdf->aobj_context = $aobj_context;
    }

    

    public function Report($res3, $res4){
        $pdf = $this->pdf;
        $pdf->SetMargins(15, 25);
        $pdf->startPageGroup();
        $pdf->AddPage("P");
        
        $pdf->SetFont('Times','B',11);
        $pdf->Cell(0, 5,$resbill['fexamdate'].' EXAMINATION', '0', 1, 'C');
        $pdf->ln(3);
        $pdf->SetFont('Times','',10);

        $table1 = '<style>
                        td {
                            border: 0.5px solid black;
                        }
                        .lable {
                            font-weight: bold;
                        }
                  </style>
                <table cellpadding="3" cellspacing="0">';
                    

                $table1 .='<tr nobr="true">
                    <td width="135" style="text-align: left;"><b>Teacher Name</b></td>
                    
                    <td width="405" style="text-align: left;">'.$res3['fteachname'].'</td> 
                </tr>';

            $table1 .='<tr nobr="true">
                <td width="135" style="text-align: left;"><b>Examiner Type</b></td>
                
                <td width="165" style="text-align: left;">'.$res3['FEXAMINER'].'</td>
                
                <td width="105" style="text-align: left;"><b>Board</b></td>
                <td width="135" style="text-align: left;">'.$res3['fboard'].'</td>

            </tr>';


            if($this->aobj_context->FUNIVCODE == '040')
            {
                $table1 .='<tr nobr="true">
                    <td width="135" style="text-align: left;"><b>Department</b></td>
                    
                    <td width="405" style="text-align: left;">'.$res3['FDEPTCODE'].'</td>
                    
                </tr>';
                $table1 .='<tr nobr="true">
                    <td width="135" style="text-align: left;"><b>College</b></td>
                    
                    <td width="405" style="text-align: left;">'.$res3['FCOLLEGE'].'</td>
                    
                </tr>';
            }


            $table1 .='<tr nobr="true">
                <td width="135" style="text-align: left;"><b>Address</b></td>
                
                <td width="405" style="text-align: left;">'.$res3['faddress'].'</td>
                
            </tr>';

            $table1 .='<tr nobr="true">
            <td width="135" style="text-align: left;"><b>Mobile No</b></td>

            <td width="165" style="text-align: left;">'.$res3['fmobile'].'</td>

            <td width="105" style="text-align: left;"><b>E Mail</b></td>
            <td width="135" style="text-align: left;">'.$res3['femail'].'</td>


            </tr>';

            $table1 .='<tr nobr="true">
            <td width="135" style="text-align: left;"><b>PAN No</b></td>

            <td width="165" style="text-align: left;">'.$res3['fpanno'].'</td>

            <td width="105" style="text-align: left;"><b>Aadhar No</b></td>
            <td width="135" style="text-align: left;">'.$res3['faadharno'].'</td>


            </tr>';

            $table1 .='<tr nobr="true">
            <td width="135" style="text-align: left;"><b>Bank Account No</b></td>

            <td width="165" style="text-align: left;">'.$res3['faccno'].'</td>

            <td width="105" style="text-align: left;"><b>IFSC Code</b></td>
            <td width="135" style="text-align: left;">'.$res3['fifsccode'].'</td>


            </tr>';

            if($this->aobj_context->FUNIVCODE == '040')
            {
                $table1 .='<tr nobr="true">
                <td width="135" style="text-align: left;"><b>Date of Valuation</b></td>
                
                <td width="405" style="text-align: left;">'.$res3['fvaldates'].'</td>
                
            </tr>';
            }

                $table1 .= '</table>';

                $pdf->SetX(11);
    
                $pdf->writeHTML($table1, false, true, false, false, 'L');

        $pdf->ln(3);
       
        $pdf->SetFont('Times','B',11);
        $pdf->cell(0, 7, "Details of Remuneration", '', 1, "C");

       
        $pdf->ln(3);
        $pdf->SetFont('Times','',10);
        $table2 = '<style>
                         td {
                            border: 0.5px solid black;
                            text-align: center;
                            height: 25px;
                        }
                       
                  </style>';
        $table2 .= '<table cellpadding="3" cellspacing="0">';
        $table2 .= '<tr nobr="true">
                        <td width="53"> <b> Date </b></td>
                        <td width="137"> <b> From </b></td>
                        <td width="53"> <b> Date </b></td>
                        <td width="137"> <b> To </b></td>
                        <td width="35"> <b> DA </b></td>
                        <td width="45"><b>Distance</b></td>
                        <td width="40"> <b> Road Mileage </b></td>
                        <td width="35"> <b> Total </b></td>
                    </tr>';
        $table2 .= '<tbody>';  
        $total = 0;
                    foreach($res4 as $val){
                      $table2 .= '<tr>';
                      $table2 .= '<td width="53">'.$val['enddate'].'</td>';  
                      $table2 .= '<td width="137" style="text-align: initial;">'.$val['ffrom'].'</td>';  
                      $table2 .= '<td width="53">'.$val['enddate'].'</td>';  
                      $table2 .= '<td width="137" style="text-align: initial;">'.$val['ftoplace'].'</td>';  
                      $table2 .= '<td width="35">'.$val['fda'].'</td>'; 
                      $table2 .= '<td width="45">'.$val['fdistance'].'</td>';  
                      $table2 .= '<td width="40">'.$val['fperkm'].'</td>';  
                      $table2 .= '<td width="35">'.intval($val['fdistance']) * intval($val['fperkm']).'</td>';  
                      $table2 .= '</tr>';
                      $total+=intval($val['fdistance']) * intval($val['fperkm']);
                    //   $table2 .= '<tr>';
                    //   $table2 .= '<td width="53">'.$val['enddate'].'</td>';  
                    //   $table2 .= '<td width="137" style="text-align: initial;">'.$val['ftoplace'].'</td>';  
                    //   $table2 .= '<td width="53">'.$val['enddate'].'</td>';  
                    //   $table2 .= '<td width="137" style="text-align: initial;">'.$val['ffrom'].'</td>';  
                    //   $table2 .= '<td width="35">'.$val['fda'].'</td>'; 
                    //   $table2 .= '<td width="45">'.$val['fdistance'].'</td>'; 
                    //   $table2 .= '<td width="40">'.$val['fperkm'].'</td>';  
                    //   $table2 .= '<td width="35">'.intval($val['fdistance']) * intval($val['fperkm']).'</td>';  
                    //   $table2 .= '</tr>';
                    //   $total+=intval($val['fdistance']) * intval($val['fperkm']);
                    }
        $table2 .= '<tr><td colspan="7"><b> Grand Total </b></td><td>'.$total.'</td></tr>';
        $table2 .= '</tbody>';
        $table2 .= '</table>';
        
        $pdf->ln(3);
        $table2 .= '<ol>
                        <li> Certified that this amount is not claimed in any of the previous bills.</li>
                        <li> Certified that the order copy and attendance certificate is enclosed.</li>
                        <li> I do hereby declare that the information mentioned above is correct & true.</li>
                    </ol>';
        $pdf->SetX(11);
        $pdf->writeHTML($table2, false, true, false, false, 'L');
        $pdf->ln(3);

        $x = $pdf->GetX();
        $y = $pdf->GetY();
        $pdf->Rect($x-5,$y+13,192,40,'D');
            $pdf->Ln(5); 
            $pdf->SetFont('Times','B',11);
            $pdf->Cell(50,7,'Sign. of the Valuator',0,0,'L');

            $pdf->Cell(80,7,'Sign. of the Chairman',0,0,'C');
            // $pdf->Ln(12); 
            // $pdf->SetFont('
            $pdf->Cell(60,7,'Sign. of the Chief Custodian',0,1,'R');
            $pdf->ln(5);
            $pdf->SetFont('Times', 'BU', 15);
            $pdf->Cell(0, 5, 'For Examination Section Use Only', 0, 1, 'C');

            $pdf->ln(5);
            $pdf->SetFont('Times', '', 11);
            $pdf->Cell(0, 5, 'Payment of Rs.___________ (In Words)___________________________ is approved on ________________.', '0', 1, 'L');

            $x = $pdf->GetX();
            $y = $pdf->GetY();
            // $pdf->writeHTMLCell(180,0,$x,$y,$html, false,1, false, true, '', false);


            $pdf->Ln(5); 
            $pdf->SetFont('Times','B',11);
            
            $pdf->Cell(180,5,'Asst. Reg. / Dy. Reg. / Registrar (Evaluation)',0,1,'R');

            $x = $pdf->GetX();
            $y = $pdf->GetY();


            $pdf->Rect( $x-5,$y+10,192,35,'D');
            $pdf->ln(10);
            $pdf->SetFont('Times', 'BU', 15);
            $pdf->Cell(0, 5, 'For Finance Section Use Only', '0', 1, 'C');

            $pdf->ln(5);
            $pdf->SetFont('Times', '', 11);
            $pdf->Cell(0, 7, 'Payment of Rs.___________(In Words)______________________________ is passed on ________________.', '0', 1, 'L');

        // $html = "Payment of Rs.______________________(In Words)___________________ is passed on ________________.</p>";
            $x = $pdf->GetX();
            $y = $pdf->GetY();
            // $pdf->writeHTMLCell(180,0,$x,$y,$html, false,1, false, true, '', false);


            $pdf->Ln(5); 
            $pdf->SetFont('Times','B',11);


            $pdf->Cell(180,7,'Asst. Reg. / Dy. Reg. / Finance Officer',0,1,'R');
    }       

    public function SendOutput()
    {
        // ob_end_clean();
        $this->pdf->Output("TADA_BILL.pdf", "I");
    }
}

function moneyFormatIndia($num){
    $explrestunits = "";
    if (strlen($num) > 3) {
        $lastthree = substr($num, strlen($num) - 3, strlen($num));
        $restunits = substr($num, 0, strlen($num) - 3); // extracts the last three digits
        $restunits = (strlen($restunits) % 2 == 1) ? "0" . $restunits : $restunits; // explodes the remaining digits in 2's formats, adds a zero in the beginning to maintain the 2's grouping.
        $expunit = str_split($restunits, 2);
        for ($i = 0; $i < sizeof($expunit); $i++) {
            // creates each of the 2's group and adds a comma to the end
            if ($i == 0) {
                $explrestunits .= (int) $expunit[$i] . ","; // if is first value , convert into integer
            } else {
                $explrestunits .= $expunit[$i] . ",";
            }
        }
        $thecash = $explrestunits . $lastthree;
    } else {
        $thecash = $num;
    }
    return $thecash; // writes the final format where $currency is the currency symbol.
}

function generatetadabill($aobj_context){
    
    $univcode = $aobj_context->mobj_data["univcode"];
    $fdegreegrp = $aobj_context->mobj_data["fdegreegrp"];
    $fboard = $aobj_context->mobj_data["fboard"];
    $fvalno = $aobj_context->mobj_data["fvalno"];
    $teachrngfrm = $aobj_context->mobj_data["teachrngfrm"];
    $teachrngto = $aobj_context->mobj_data["teachrngto"];
    $type = $aobj_context->mobj_data["type"];
    $fteachcode = $aobj_context->mobj_data["fteachcode"];

    if($fteachcode == '90001')
        $fteachcode = '16902';

    if($type == 'T'){
        $query_teach = "select distinct ifnull(t.fteachcode,'') as fteachcode 
        from tdvs_masteach t 
        inner join tdvs_tabsum ts on t.fteachcode = ts.fteachcode 
        inner join tdvs_masqp m on m.fqpcode = ts.fqpcode  
        where t.fteachcode = '{$fteachcode}'
        and ifnull(t.fbill,'F') = 'T'
        union
        select distinct ifnull(t.fteachcode,'') as fteachcode 
        from tdvs_masteach t 
        inner join tdvs_tabsum ts on t.fteachcode = ts.frevcode 
        inner join tdvs_masqp m on m.fqpcode = ts.fqpcode  
        where ts.frevcode = '{$fteachcode}'
        and ifnull(t.fbill,'F') = 'T'
        ";
    }else{
        $query_teach = "select distinct ifnull(t.fteachcode,'') as fteachcode 
        from tdvs_masteach t 
        inner join tdvs_tabsum ts on t.fteachcode = ts.fteachcode 
        inner join tdvs_masqp m on m.fqpcode = ts.fqpcode  
        where t.fteachcode between '{$teachrngfrm}' and '{$teachrngto}'
        and m.fdeggrp = '{$fdegreegrp}'
        and ifnull(t.fbill,'F') = 'T'";
    }

    $res_teach = $aobj_context->pobj_db->GetAll($query_teach);

    $class_obj = new ReprtObject();
    $class_obj->univcode = $univcode;
    $class_obj->DefaultConstructor($aobj_context);

    foreach($res_teach as $key => $value){
    $teachrngfrm = $value['fteachcode'];

        $query3 = "select concat(m.fteachcode,' - ',ifnull(fteachname,'')) as fteachname,ifnull(fscale,'') as fscale,
        CONCAT(ifnull(faddress1,''),' ',ifnull(faddress2,''),' ',ifnull(faddress3,''),' ',ifnull(faddress4,'')) as faddress, 
        ifnull(faadharno,'') as faadharno,
        ifnull(fpanno,'') as fpanno,ifnull(faccno,'') as faccno,
        ifnull(fifsccode,'') as fifsccode,ifnull(femail,'') as femail,
        ifnull(ffrom, '')as ffrom,
        ifnull(fmobile,'') as fmobile,ifnull(fboard,'') as fboard,
        ifnull(m.FDEPTCODE,'') as FDEPTCODE,  ifnull(m.FCOLLEGE,'') as FCOLLEGE,
        ifnull(fbankname,'') as fbankname,ifnull(FEXAMINER,'') as FEXAMINER,
        group_concat(distinct date_format(s.FENDATE,'%d/%m/%Y') SEPARATOR ', ') as fvaldates 
        from tdvs_masteach m inner join tdvs_tabsum s on m.fteachcode = s.fteachcode
        where  m.fteachcode = '{$teachrngfrm}'
        group by m.fteachcode";
        $res3 = $aobj_context->pobj_db->GetRow($query3);

        $fromplace = $res3['ffrom'];

        $query4 = "select distinct left(t.fendate, 10)as enddate, m.ffrom, f.ftoplace,
                    f.fdistance, ifnull(f.fda, '600')as fda, ifnull(f.fperkm, '')as fperkm
                    from tdvs_tabsum t 
                    inner join tdvs_masteach m on m.fteachcode = t.fteachcode
                    inner join masfare f on f.ffromplace=m.ffrom
                    where t.fteachcode='{$teachrngfrm}'
                    and ifnull(fendate, '')<> ''";
        $res4 = $aobj_context->pobj_db->GetAll($query4);

        $i=0;
        $fromdate = 0;
        $todate = 0;
        $arr = [];
        foreach($res4 as $val){
            $date = date("d", strtotime($val['enddate']));
            if($i===0){
                $fromdate = $date;
                $todate = $date;
                array_push($arr, $val);
            }

            
            $getdate = intval($date) - intval($todate);
            
            // var_dump($getdate >1 &&  $getdate >0);
            if($getdate >1 &&  $getdate >0){
                array_push($arr, $val);
            }
            $i++;
        }
        // die();
        // var_dump($arr);
        // die();

        

        $class_obj->Report($res3, $res4);
    } 
    $class_obj->SendOutput();
}