IMMREX7

aku nok ndi : /home/spdtg/www/schoolmis/app/Http/
File Up :
aku nok ndi : /home/spdtg/www/schoolmis/app/Http/DdrPrint.php

<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace App\Printings;

use TCPDF;

class RecPrint extends PrintPdf {

  protected $feercpt = null;
  protected $feercptdets = null;
  protected $student = null;
  protected $pdf = null;
  protected $hight = 0;
  protected $pageno = 0;
  protected $nextpage = '';
  protected $feerecdetid = 0;
  protected $copyno = 0;
  protected $footerHight = 0;

  public function makepdf(\App\FeeRcpt $feercpt) {
    $this->feercpt = $feercpt;
    $this->feercpt->load('feeRcptDets.feehead');
    $this->feercptdets = $feercpt->feeRcptDets;
    $this->student = $feercpt->student;
    $this->main();
    return $this->pdf;
  }

  private function header($title = '') {
    $pdf = $this->pdf;
//    $this->pdf->setX(5);
    $pdf->Image(public_path("/dist/img/lps.png"), $this->lm + 2, $this->tm, 35, 30, 'PNG', '', '', true, 100, '', false, false, 0, false, false, false);
   
    $this->addCell(0, 0, "FEE RECEIPT", 0, 'C', 1, 'T', 0, 'B');
    $this->pdf->ln(5);
    $this->addCell(0, 0, "LEARNING PATHS SCHOOL", 0, 'R', 1, 'T', 0, 'B');
    $this->pdf->ln(5);
    $this->addCell(0, 0, "MOHALI", 0, 'R', 1, 'T', 0, 'B');
    $this->pdf->ln(7);
    $this->addCell(0, 0, "Sector 67 , Phone 0172-5134300, MOHALI", 0, 'R', 1, 'T', 0, '');
    $pdf->Line($this->lm, $this->lastY, $this->lm + 140, $this->lastY);
    $this->addCell(100, 0, "Receipt No.: ".$this->feercpt->id, 0, 'L', 0, 'T', 0, 'B');
    $this->addCell(40, 0, "Dated : ".$this->feercpt->rec_date, 0, 'R', 1, 'T', 0, 'B');
    $this->addMCell(0, 0, "Name: " . $this->student->name, 0, 'L', 1, 'T', 0, '');
    $this->addMCell(0, 0, "Father's Name : " . $this->student->father_name, 0, 'L', 1, 'T', 0, '');
    $this->addMCell(100, 0, "Adm No.: " . $this->student->adm_no, 0, 'L', 1, 'T', 0, '');
    $this->addCell(40, 0, "Class: " . getObjKey($this->student->classname, "class_name", ''), 0, 'L', 1, 'T', 0, '');
    $this->addMCell(0, 0, "Remarks : " . $this->feercpt->details, 0, 'L', 1, 'T', 0, '');
    $pdf->Line($this->lm, $this->lastY, $this->lm + 140, $this->lastY);
    $this->hight = $this->getNetHeight() - $this->footerHight;

//    dd($this->pdf->getX());
//    dd("here");
  }

  private function details() {
    $pdf = $this->pdf;
    $intX = 0;
    if ($this->feerecdetid != -1) {
      foreach ($this->feercptdets as $value) {
        if ($intX == 0 && ($this->feerecdetid == 0 || $this->feerecdetid == $value->id)) {
          $intX = 1;
        }
        if ($intX == 1) {
            if ($this->lastY + $this->lineHeight > $this->hight) {
              if($this->copyno == 2) {
                $this->feerecdetid = $value->id;
                $this->nextpage = "Y";
              }
              return;
            }
            $this->addCell(120, 0, $value->feehead->feehead, "0", 'L', 0, 'T', 0, '');
            $this->addCell(20, 0, number_format($value->amount, 2), "0", 'R', 1, 'T', 0, '');
          }
        }
        if ($this->lastY + $this->lineHeight > $this->hight) {
          if($this->copyno == 2) {
            $this->feerecdetid = -1;
            $this->nextpage = "Y";
          }
          return;
        }
    } 
    $pdf->Line($this->lm+120, $this->lastY, $this->lm + 140, $this->lastY);
    $this->addCell(100, 0, "Total : ", "0", 'R', 0, 'T', 0, 'B');
    $this->addCell(40, 0, number_format($this->feercpt->amount, 2), "0", 'R', 1, 'T', 0, 'B');
    $pdf->Line($this->lm+120, $this->lastY, $this->lm + 140, $this->lastY);
    $this->footer();
  }

  private function footer() {
    $pdf = $this->pdf;
    $this->SetYPos($this->getNetHeight() - $this->footerHight);
    $pdf->Line($this->lm, $this->lastY, $this->lm + 140, $this->lastY);
    $this->addMCell(0, 0, "Rs." . figToWord($this->feercpt->amount), 0, 'L', 1, 'T', 0, '');
    $this->addMCell(0, 0, $this->feercpt->pay_mode_desc, 0, 'L', 1, 'T', 0, '');
    $pdf->Line($this->lm, $this->lastY, $this->lm + 140, $this->lastY);
    $this->addCell(0, 0, "For Learning Paths School", 0, 'R', 1, 'T', 0, '');
    $this->pdf->ln(5);
    $this->addCell(0, 0, "Authorised Signatory", 0, 'R', 0, 'T', 0, '');

//    dd($this->pdf->getX());
//    dd("here");
  }

  private function setCopy($copyno) {
    $pdf = $this->pdf;
    $this->copyno = $copyno;
    if ($copyno == 1) {
      $this->pdf->line($this->lm+142,$this->tm,$this->lm+142,$this->tm+$this->getNetHeight());
      $this->setMargin("R", $this->rm + 147);
    } elseif ($copyno == 2) {
      $this->setMargin("L", $this->lm + 147);
      $this->setMargin("R", $this->rm - 147);
      $this->SetYPos($this->tm);
      $this->resetY();
    } 
    $this->header();
    $this->details();
//    $this->footer();
  }

  private function main($title = '') {
    $pdf = $this->pdf;
    $this->pageno = 0;
    $this->footerHight = 20;
    do {
      $this->pageno++;
      $this->nextpage = "N";
      $this->addNewPage("L", "A4");
      $this->setCopy(1);
      $this->setCopy(2);
    } while ($this->nextpage == "Y");
}

}

Copyright © 2021 - 2025 IMMREX7