Your IP : 216.73.216.40


Current Path : /var/www/html/mmishra/erp/views/
Upload File :
Current File : /var/www/html/mmishra/erp/views/iwd_view.php

<?php
//if (!class_exists($erpView)) {
// face detector class
	require_once __DIR__."/erp_view.php";
//}

class iwdView extends erpView {
    var $controller;
    var $model;

    public function __construct($controller, $model) {
               
		$this->controller 				= $controller;	// instantiate controller
        $this->model 					= $model;		// instantiate model
    }

    public function __destruct() {
		// throw last executed sql statement
		//if ($this->model->sqlStmt) print("<hr>" .$this->model->sqlStmt);
		
        if (!in_array($this->controller->menu, ['insurence', 'upload', 'nodeficit', 'payment', 'PGPayment', 'PGResponse', 'specimen', 'import', 'booking', 'photograph', 'photoshop']) && !in_array($this->controller->action, ['print', 'show', 'docUpload'])) {
			print(":|:" .$this->erpMenus(). ":|:" .$this->erpXupdate(). ":|:" .$this->erpError(). ":|:" .$this->erpClock(). ":|:" .$this->erpLogin());
		}
	}
	

	public function iwdReceipt($action, $studentID) {
		$app					= $this->controller->app;
		$menu					= $this->controller->menu;
		$withdrawal				= $this->controller->params[0];
		
		$enrolmentID			= $this->model->getEnrolmentIDByStudentID($studentID);
		$enrolment				= $this->model->getEnrolment($enrolmentID);

		if ($enrolment) {
			$studentID			= $enrolment['studentID'];
			$programID			= $enrolment['programID'];
			$enrolmentNo		= $enrolment['enrolmentNo'];
			$category			= $enrolment['category'];
			$enrolCategory 		= $enrolment['enrolCategory'];
			$pwdStatus			= $enrolment['pwdStatus'];
			$accountNo			= $enrolment['accountNo'];
			$holderName			= $enrolment['holderName'];
			$bankName			= $enrolment['bankName'];
			$ifscCode			= $enrolment['ifscCode'];
			$districtName		= $this->model->getDistrictNameByDistrictID($enrolment['homeDistrict']);    
			$stateName 			= $this->model->getStateNameByStateID($enrolment['homeState']);
			$countryName		= strtoupper($this->model->getCountryNameByCountryCode($enrolment['nationality']));
			
			$allotteeID		 	= $this->model->getAllotteeIDByAllotteeNo($enrolmentNo);
			$allottee			= $this->model->getAllottee($allotteeID);
			$hostelID			= $allottee['hostelID'];
			$roomID				= $allottee['roomID'];
		
			$hostelCode			= $this->model->getHostelCodeByHostelID($hostelID);

			$room				= $this->model->getRoom($roomID);
			$roomNo				= $room['roomNo'];
			$floorNo			= $room['floorNo'];
			$hostelRoom			= "$roomNo in $hostelCode (" .$this->controller->floorNos[$floorNo]. " floor)";
			
			try {
				$photo 			= $this->model->getMyUpload($studentID, 'PHO');
				$psign 			= $this->model->getMyUpload($studentID, 'SIG');
			} catch (Exception $e) {
				print $e->__toString();
			}
			$institute			= $this->model->getInstitute();
			$program 			= $this->model->getProgram($programID);

			// generate pdf file of receipt
			$pdf 				= new erpLetterPad([], $institute);
			$pdf->autoScriptToLang 	= true;
			$pdf->autoLangToFont 	= true;
			$pdf->SetDisplayMode(real, 'default');
			// create first page
			$pdf->AddPage();
			$pdf->SetTitle('ERP PDF Generator');
			$pdf->SetAuthor('IIIT-A');
			$pdf->SetAutoPageBreak(0);
			
			$pdf->SetXY(20, 38);
			$pdf->SetFont('Times', 'I', 8);
			$pdf->Cell(178, 5, "Ref. No.: IIITA/A&F/" .$_SESSION["batchYear"]. '/' .$enrolmentNo. '/' .$studentID, 0, 0, 'R');

			$pdf->SetXY(20, 45);
			$pdf->SetFont('Times', 'U', 13);
			$pdf->Cell(0, 0, 'Provisional Fee Receipt - ' .$enrolment['batchYear'], 0, 1, 'C');
			$pdf->SetFont('Times', 'I', 11);
			$pdf->Cell(0, 12, '( Under ' .$enrolment['enrolCategory']. ' Category )', 0, 1, 'C');
			$pdf->Ln(3);

			try {
				$pdf->Image(($photo ? "https://erp.iiita.ac.in/uploads/photos/{$photo}" : "https://erp.iiita.ac.in/images/dummy.jpg"), 175, 48, 22, 28);
			} catch (Exception $e) {
				$pdf->cell(175, 48, $e->getMessage(), 0, 1, 'L');
			}	
			
			$passYear = $enrolment['batchYear'] + $program['timeDuration'];

			$y = 60;
			$pdf->SetXY(20, $y);


			foreach ($this->controller->dasaCategorys as $key => $value) {
				if ($key == $enrolCategory) $feesCategory = $enrolCategory;
			} 
			if (!$feesCategory) $feesCategory = ($pwdStatus == 'Y' ? 'PWD' : $category);
		
			$candidateID	= $this->model->getCandidateIDByRollNo($this->model->getRollNoByStudentID($studentID));
			$candidate		= $this->model->getCandidate($candidateID);					
			
			$payables = $this->model->listPayables($enrolment['programID'], $feesCategory);
			foreach ($payables as $payable) {
				if ($candidate['alumni'] == 'Y' && $payable['feeheadName'] == 'Alumni Fund') {
				} else {
					$fees .= "<tr><td>" .$payable['feeheadName']. "</td><td>(" .explode(' ', $this->controller->accountTypes[$payable['accountType']])[0]. ")</td><td>" .$this->controller->paymentTerms[$payable['paymentTerm']]. "</td><td align='right' nowrap>" .$payable['currency']. ' ' .number_format($payable['feeAmount'], 2). "</td></tr>";
					if ($payable['paymentTerm'] < 9) {
						$totalFees += $payable['feeAmount'];
					} else {
						$totalFees -= $payable['feeAmount'];
					}
					$y += 5;
				}
			}
			$fees .= "<tr><td colspan='3' align='right'><br><b>Total</b></td><td align='right'><hr><b>" .($payable['currency'] ? $payable['currency'] : $this->rs). ' ' .number_format($totalFees, 2). "</b></td></tr>";

			$prepaids = $this->model->listPrepaids($programID, $feesCategory);
			foreach ($prepaids as $prepaid) {
				$paid .= "<tr><td>Fees</td><td>" .$prepaid['feeheadName']. "</td><td>Counselling</td><td>(Direct)</td><td align='right'>" .$prepaid['currency']. ' ' .number_format($prepaid['feeAmount'], 2). "</td></tr>";
				$totalPaid += $prepaid['feeAmount'];
			}
			$payments = $this->model->listPayments($studentID);
			foreach ($payments as $payment) {
				$paid .= "<tr><td>" .explode(' ', $this->controller->accountTypes[$payment['accountType']])[0]. "</td><td>" .$payment['paymentNo']. "</td><td>" .$payment['datePayment']. "</td><td>(" .$payment['paymentMode']. ")</td><td align='right' nowrap>" .($payment['currency'] ? $payment['currency'] : 'INR'). ' ' .number_format($payment['payAmount'], 2). "</td></tr>";
				$totalPaid += $payment['payAmount'];
			}
			if ($this->model->getMyExemption($studentID, 1)) {
				$paid .= "<tr><td colspan='5'>Fees payment exempted by competent authority temporarily (till " .$this->model->getMyExemption($studentID, 1). ") on written equest of student.</td></tr>";
			}
			
			if ($this->model->getMyExemption($studentID, 2)) {
				$y += 5;
				$paid .= "<tr><td colspan='5'>Mess charge payment exempted by competent authority temporarily (till " .$this->model->getMyExemption($studentID, 2). ") on written request of student.</td></tr>";
			}

			$paid .= "<tr><td colspan='4' align='right'><br><b>Total</b></td><td align='right'><hr><b>" .($payment['currency'] ? $payment['currency'] : $this->rs). ' ' .number_format($totalPaid, 2). "</b></td></tr>";

			$pdf->SetFont('Times', '', 10);
			$y = 60;
			$pdf->SetXY(20, $y);
			$pdf->WriteHTML("
			<table width='100%' cellspecing='5' cellpadding='0' style='font-size: 11px;'>
			<tr><td colspan='3' style='padding-top: 15px; padding-bottom: 5px'><h3>Student Detail</h3></td></tr>
			<tr><td width='17%' nowrap style='padding-left: 10px'>Program Name</td><td width='3%'>:</td><td width='80%'>" .$program['programCode']. "</td></tr>			
			<tr><td nowrap style='padding-left: 10px'>Batch Year</td><td>:</td><td>" .$enrolment['batchYear']. ' - ' . $passYear. "</td></tr>
			<tr><td nowrap style='padding-left: 10px'>Enrollment No.</td><td>:</td><td>" .$enrolment['enrolmentNo']. "<br></td></tr>");
			if ($enrolment['hbookNo']) $pdf->WriteHTML("<tr><td nowrap style='padding-left: 10px'>Health Booklet No.</td><td>:</td><td>" .str_pad($enrolment['hbookNo'], 5, '0', STR_PAD_LEFT). "</td></tr>");

			$pdf->WriteHTML("<tr><td colspan='3' style='padding-top: 15px; padding-bottom: 5px'><h3>Personal Detail</h3></td></tr>
			<tr><td nowrap style='padding-left: 10px'>Student Name</td><td>:</td><td>" .$enrolment['nameEnglish']. ' (' .trim($enrolment['nameHindi']). ')' .($enrolment['gender'] == 'F' ? ' D/o ' : ' S/o '). $enrolment['fatherName']. "</td><tr>
			<tr><td nowrap style='padding-left: 10px'>Address</td><td>:</td><td>" .$enrolment['homeAddress']. $districtName. '-' .$enrolment['homePIN']. ' (' .$stateName. ') ' .strtoupper($nationality). "</td></tr>
			
			<tr><td colspan='3' style='padding-top: 15px; padding-bottom: 5px'><h3>Fees Detail</h3></td></tr>
			<tr><td colspan='3' style='padding-left: 10px'><table width='100%' cellspecing='5' cellpadding='0' style='font-size: 11px;'>
			<tr><td width='55%'><b>Fee Heads</b></td><td width='10%'><b>(Account)</b></td><td width='15%' nowrap><b>Payment Term</b></td><td width='20%' nowrap align='right'><b>Amount</b></td></tr>
			$fees
			</table></td></tr>
			<tr><td colspan='3' style='padding-top: 15px; padding-bottom: 5px'><h3>Payment Detail</h3></td></tr>
			<tr><td colspan='3' style='padding-left: 10px'><table width='100%' cellspecing='5' cellpadding='0' style='font-size: 11px;'>
			<tr><td width='20%'><b>Account</b></td><td width='20%'><b>Payment No.</b></td><td width='20%'><b>Dated</b></td><td width='20%'><b>(Payment Mode)</b></td><td width='20%' nowrap align='right'><b>Amount</b></td></tr>
			$paid
			</table></td></tr>
			<tr><td colspan='2' style='padding-top: 15px; padding-bottom: 5px'><h3>Account Detail</h3></td><td><i>(for refund purposes)</i></td></tr>
			<tr><td colspan='3' style='padding-left: 10px'><table width='100%' cellspecing='5' cellpadding='0' style='font-size: 11px;'>
			<tr><td width='20%'><b>Account No.</b></td><td width='30%'><b>Holder Name</b></td><td width='30%'><b>Bank Name</b></td><td width='20%'><b>IFSC Code</b></td></tr>
			<tr><td>$accountNo</td><td>$holderName</td><td>$bankName</td><td>$ifscCode</td></tr>
			</table></td></tr>
			</table>");

			$y = 267;
			$pdf->SetTextColor(0, 0, 0);
			$pdf->SetFont('Times', 'B', 10);
			$pdf->SetXY(10, $y);
			$pdf->Cell(0, 10, '[ Seal & Signatures ]', 0, 1, 'C');
			$y += 8;
			$pdf->SetDrawColor(0, 0, 0);
			$pdf->Line(0, $y, 500, $y);

			$pdf->SetFont('Helvetica', 'B', 9);
			try {
				$pdf->Image(($psign ? 'https://erp.iiita.ac.in/uploads/signatures/' .$psign : 'https://erp.iiita.ac.in/images/fake.png'), 22, 276, 15, 8);
			} catch (Exception $e) {
				$pdf->cell(22, $y, $e->getMessage(), 0, 1, 'L');
			}	
			$y += 5;
			$pdf->SetXY(14, $y);
			$pdf->Cell(0, 10, '(Student)                                                   (Parent/Guardian)                                                    (A/c Office)', 0, 1, 'C');
			
			$y += 8;
			$pdf->Line(0, $y, 500, $y);

			$pdf->SetFont('Helvetica', 'I', 6.5);
			$pdf->SetXY(150, $y);
			$pdf->Cell(0, 5, 'Processed by: ' .$_SESSION['loginID']. ' (dated: ' .substr($enrolment['dateEnrolment'], 0, 10). ')', 0, 1, 'R');

			$outFile 		= 'receipt-' .strtolower($enrolmentNo). '.pdf';
			$pdf->Output(__DIR__ ."/../uploads/receipts/$outFile", 'F');

			$str = $this->showPDF('receipts', $outFile);
		}
			
	    return $str;
	}

}

?>