public function PdfAction()
 {
     $pdf = new TCPDF('L');
     $pdf->SetPrintHeader(true);
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     // set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     // set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     // set image scale factor
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     // set some language-dependent strings (optional)
     if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
         require_once dirname(__FILE__) . '/lang/eng.php';
         $pdf->setLanguageArray($l);
     }
     // set font
     $pdf->SetFont('helvetica', '', 8);
     // add a page
     $pdf->AddPage();
     //get report data into $data variable
     $project = $this->getServiceLocator()->get('ProjectTable');
     $data = $project->getWsr();
     $view = new PhpRenderer();
     $resolver = new TemplateMapResolver();
     //set the path of the pdf.phtml file
     $resolver->setMap(array('PDFTemplate' => '/var/www/html/WSRAutomation/module/Application/view/application/index/pdf.phtml'));
     $view->setResolver($resolver);
     $viewModel = new ViewModel();
     $viewModel->setTemplate('PDFTemplate')->setVariables(array('projects' => $data, 'view' => 'pdf'));
     $html = $view->render($viewModel);
     $pdf->writeHTML($html, true, 0, true, 0);
     $pdf->Output('WsrReport.pdf', 'I');
 }
Example #2
2
 /**
  * @param Layout $default_layout
  */
 public function __construct(Layout $default_layout)
 {
     $this->pdf = new \TCPDF('P', 'pt', 'A4', true, 'UTF-8');
     $this->pdf->SetTitle($default_layout->getReportTitle());
     $this->pdf->SetCreator('Thinreports Generator');
     $this->pdf->SetAutoPageBreak(false);
     $this->pdf->SetMargins(0, 0, 0, true);
     $this->pdf->SetCellPadding(0);
     $this->pdf->SetCellMargins(0, 0, 0, 0);
     $this->pdf->SetPrintHeader(false);
     $this->pdf->SetPrintFooter(false);
     $this->default_layout = $default_layout;
     $this->default_page_format = $this->buildPageFormat($default_layout);
 }
Example #3
2
function student_kolizijapdf()
{
    global $userid;
    require_once 'lib/tcpdf/tcpdf.php';
    $semestar = intval($_REQUEST['semestar']);
    if ($semestar == 1) {
        $tekst_semestar = "zimskom";
    } else {
        $tekst_semestar = "ljetnjem";
    }
    // Prikupljam podatke iz baze
    // Za koju godinu se prijavljuje?
    $q1 = myquery("select id, naziv from akademska_godina where aktuelna=1");
    $q2 = myquery("select id, naziv from akademska_godina where id>" . mysql_result($q1, 0, 0) . " order by id limit 1");
    if (mysql_num_rows($q2) < 1) {
        //	nicemessage("U ovom trenutku nije aktiviran upis u sljedeću akademsku godinu.");
        //	return;
        // Pretpostavljamo da se upisuje u aktuelnu?
        $zagodinu = mysql_result($q1, 0, 0);
        $agnaziv = mysql_result($q1, 0, 1);
        $q3 = myquery("select id from akademska_godina where id<{$zagodinu} order by id desc limit 1");
        $proslagodina = mysql_result($q3, 0, 0);
    } else {
        $proslagodina = mysql_result($q1, 0, 0);
        $zagodinu = mysql_result($q2, 0, 0);
        $agnaziv = mysql_result($q2, 0, 1);
    }
    // Koji je odsjek?
    $q4 = myquery("select s.id, s.naziv, i.naziv, ss.semestar from studij as s, student_studij as ss, institucija as i where ss.student={$userid} and ss.studij=s.id and s.institucija=i.id and ss.akademska_godina={$proslagodina} order by semestar desc limit 1");
    if (mysql_num_rows($q4) < 1) {
        // Očito da su aktuelna i prošla godina loše određene
        $q4 = myquery("select s.id, s.naziv, i.naziv, ss.semestar, ss.akademska_godina from studij as s, student_studij as ss, institucija as i where ss.student={$userid} and ss.studij=s.id and s.institucija=i.id order by akademska_godina desc, semestar desc limit 1");
        if (mysql_num_rows($q4) < 1) {
            biguglyerror("Nikada niste bili nas student!");
            return;
        }
        $proslagodina = mysql_result($q4, 0, 4);
        if (mysql_num_rows($q2) < 1) {
            biguglyerror("Nije kreirana nova akademska godina u koju se upisujete.");
            print "Kontaktirajte administratora.";
            return;
        }
        $q2 = myquery("select id, naziv from akademska_godina where id>{$proslagodina} order by id limit 1");
        $zagodinu = mysql_result($q2, 0, 0);
        $agnaziv = mysql_result($q2, 0, 1);
    }
    $studij = mysql_result($q4, 0, 0);
    $studij_naziv = mysql_result($q4, 0, 1);
    $institucija_naziv = mysql_result($q4, 0, 2);
    $godina_studija = ceil(mysql_result($q4, 0, 3) / 2);
    // Da li je student popunio ugovor za drugi odsjek?
    $tekst_mijenja = "";
    $q7 = myquery("select s.id, s.naziv, i.naziv from studij as s, ugovoroucenju as uou, institucija as i where uou.student={$userid} and uou.studij=s.id and s.institucija=i.id and uou.akademska_godina={$zagodinu}");
    if (mysql_num_rows($q7) > 1 && $studij != mysql_result($q7, 0, 0)) {
        $institucija_naziv = mysql_result($q7, 0, 2);
        $tekst_mijenja = "predao sam zahtjev za promjenu studija na " . mysql_result($q7, 0, 1) . ". S tim u vezi, ";
    }
    // Zapis u tabeli kolizija
    $predmeti_kolizija = $predmeti_ects = array();
    $q10 = myquery("select p.id, p.naziv, p.ects from kolizija as k, predmet as p where k.student={$userid} and k.akademska_godina={$zagodinu} and k.semestar={$semestar} and k.predmet=p.id");
    if (mysql_num_rows($q10) < 1) {
        biguglyerror("Vi niste popunili Zahtjev za koliziju za {$agnaziv} godinu!");
        print "Ako je ovo greska, kontaktirajte administratora.";
        return;
    }
    while ($r10 = mysql_fetch_row($q10)) {
        $predmeti_kolizija[$r10[0]] = $r10[1];
        $predmeti_ects[$r10[0]] = $r10[2];
    }
    if ($semestar == 1) {
        $s2 = 1;
    } else {
        $s2 = 0;
    }
    // Predmeti koje nije polozio
    $predmeti_prenos = array();
    $q20 = myquery("select p.id, p.naziv, p.ects from student_predmet as sp, ponudakursa as pk, predmet as p where sp.student={$userid} and sp.predmet=pk.id and pk.predmet=p.id and pk.akademska_godina={$proslagodina} and pk.semestar MOD 2={$s2} and pk.semestar<{$godina_studija}*2+1 and (select count(*) from konacna_ocjena as ko where ko.student={$userid} and ko.predmet=p.id and ko.ocjena != 5)=0");
    while ($r20 = mysql_fetch_row($q20)) {
        if (array_key_exists($r20[0], $predmeti_kolizija)) {
            continue;
        }
        $predmeti_prenos[$r20[0]] = $r20[1];
        $predmeti_ects[$r20[0]] = $r20[2];
    }
    // Podaci o studentu
    $q30 = myquery("select ime, prezime, brindexa, spol from osoba where id={$userid}");
    $ime = mysql_result($q30, 0, 0);
    $prezime = mysql_result($q30, 0, 1);
    $brindexa = mysql_result($q30, 0, 2);
    $spol = mysql_result($q30, 0, 3);
    if ($spol == "") {
        $spol = spol(mysql_result($q30, 0, 0));
    }
    if ($spol == "M") {
        $student = "student";
        $polozio = "položio";
    } else {
        $student = "studentica";
        $polozio = "položila";
    }
    ?>
<html>
<head>
<title>Zahtjev za koliziju</title>
</head>
<body>
<p>Univerzitet u Sarajevu<br>
Elektrotehnički fakultet Sarajevo<br>
<?php 
    echo $institucija_naziv;
    ?>
</p>

<p>&nbsp;</p>

<p>Student: <?php 
    echo "{$ime} {$prezime} ({$brindexa})";
    ?>
</p>

<p>&nbsp;</p>

<p><b>Predmet: ZAHTJEV ZA KOLIZIJU</b></p>

<p>&nbsp;</p>

<p>Ja, <?php 
    echo "{$ime} {$prezime}";
    ?>
, <?php 
    echo $student;
    ?>
 studija <?php 
    echo $studij_naziv;
    ?>
, <?php 
    echo $godina_studija;
    ?>
. godina, broj indexa <?php 
    echo $brindexa;
    ?>
, <?php 
    echo $tekst_mijenja;
    ?>
 molim Vas da mi u skladu sa Zakonom o visokom obrazovanju Kantona Sarajevo, u <?php 
    echo $tekst_semestar;
    ?>
 semestru akademske <?php 
    echo $agnaziv;
    ?>
 godine odobrite slušanje sljedećih predmeta sa <?php 
    echo $godina_studija + 1;
    ?>
. godine studija u koliziji:</p>

<ul>
<?php 
    foreach ($predmeti_kolizija as $id => $predmet) {
        print "<li>{$predmet} (" . $predmeti_ects[$id] . " ECTS)</li>\n";
    }
    ?>
</ul>

<p>&nbsp;</p>

<p>Obzirom da sa <?php 
    echo $godina_studija;
    ?>
. godine studija nisam <?php 
    echo $polozio;
    ?>
 sljedeće predmete:</p>

<ul>
<?php 
    foreach ($predmeti_prenos as $id => $predmet) {
        print "<li>{$predmet} (" . $predmeti_ects[$id] . " ECTS)</li>\n";
    }
    ?>
</ul>

te da se jedan predmet prenosi, nije prekoračen maksimalan broj od 30 ECTS kredita po semestru.</p>

<p>&nbsp;</p>

<p>U nadi da ćete udovoljiti mom zahtjevu,</p>

<p>&nbsp;</p>

<table border="0"><tr><td width="100%">&nbsp;</td><td align="right"><p>&nbsp;</p><p>_____________________________________</p></td></tr>
<tr><td width="100%">&nbsp;</td><td align="center"><?php 
    echo "{$ime} {$prezime}";
    ?>
</td></tr></table>
</body>
</html>
<?php 
    return;
    $q5 = myquery("select uu.id, s.id, s.naziv, s.naziv_en, uu.semestar, s.tipstudija from ugovoroucenju as uu, studij as s where uu.student={$userid} and uu.akademska_godina={$zagodinu} and uu.studij=s.id order by semestar desc limit 1");
    if (mysql_num_rows($q5) < 1) {
        niceerror("Nije kreiran ugovor o učenju za studenta.");
        return;
    }
    $ugovorid = mysql_result($q5, 0, 0);
    $studij = mysql_result($q5, 0, 1);
    $studijbos = mysql_result($q5, 0, 2);
    $studijbos = substr($studijbos, 0, strpos($studijbos, "(") - 1);
    $studijeng = mysql_result($q5, 0, 3);
    $sem2 = mysql_result($q5, 0, 4);
    $tipstudija = mysql_result($q5, 0, 5);
    $sem1 = $sem2 - 1;
    $godina = $sem2 / 2;
    // Ostali podaci o osobi
    $q10 = myquery("select ime, prezime, brindexa from osoba where id={$userid}");
    $imeprezime = mysql_result($q10, 0, 0) . " " . mysql_result($q10, 0, 1);
    $brindexa = mysql_result($q10, 0, 2);
    // Najnoviji plan za odabrani studij
    $q6 = myquery("select godina_vazenja from plan_studija where studij={$studij} order by godina_vazenja desc limit 1");
    if (mysql_num_rows($q6) < 1) {
        niceerror("Nepostojeći studij");
        return;
    }
    $najnoviji_plan = mysql_result($q6, 0, 0);
    // Da li je ponovac?
    $q20 = myquery("select semestar from student_studij where student={$userid} and studij={$studij} and akademska_godina={$proslagodina} order by semestar desc limit 1");
    if ($sem1 > mysql_result($q20, 0, 0)) {
        $ponovac = 0;
    } else {
        $ponovac = 1;
    }
    // Odredjujemo da li ima prenesenih predmeta
    // TODO: ovo sada ne radi za izborne predmete
    $q20 = myquery("select p.sifra, p.naziv, p.ects, ps.semestar from predmet as p, plan_studija as ps where ps.godina_vazenja={$najnoviji_plan} and ps.studij={$studij} and (ps.semestar=" . ($sem1 - 1) . " or ps.semestar=" . ($sem1 - 2) . ") and ps.obavezan=1 and ps.predmet=p.id and (select count(*) from konacna_ocjena as ko where ko.student={$userid} and ko.predmet=p.id)=0");
    if (mysql_num_rows($q20) > 1) {
        niceerror("Nemate uslove za upis {$godina}. godine studija");
        print "Sačekajte da prikupite uslov ili popunite Ugovor za prethodnu godinu studija.";
        return;
    }
    if (mysql_num_rows($q20) == 1) {
        $ima_preneseni = 1;
        $preneseni_sifra = mysql_result($q20, 0, 0);
        $preneseni_naziv = mysql_result($q20, 0, 1);
        $preneseni_ects = mysql_result($q20, 0, 2);
        $preneseni_semestar = mysql_result($q20, 0, 3);
    } else {
        $ima_preneseni = 0;
    }
    // Privremeni hack za master
    if ($tipstudija == 3) {
        $mscfile = "-msc";
    } else {
        if ($tipstudija == 2) {
            $mscfile = "";
        }
    }
    // Ako čovjek upisuje prvu godinu nečeka (mastera), broj indexa je netačan!
    if ($godina == 1) {
        $brindexa = "";
    }
    // ----- Pravljenje PDF dokumenta
    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
    // set document information
    $pdf->SetCreator("Zamger");
    $pdf->SetTitle('Domestic Learning Agreement / Ugovor o ucenju');
    // set default monospaced font
    $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
    //set margins
    $pdf->SetMargins(0, 0, 0);
    //set auto page breaks
    $pdf->SetAutoPageBreak(false);
    //set image scale factor
    $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
    //$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO*2.083333);
    $pdf->setJPEGQuality(100);
    //set some language-dependent strings
    $pdf->setLanguageArray($l);
    // ---------------------------------------------------------
    // set font
    $pdf->SetFont('freesans', 'B', 9);
    $pdf->SetHeaderData("", 0, "", "");
    $pdf->SetPrintHeader(false);
    $pdf->SetPrintFooter(false);
    // add a page
    $pdf->AddPage();
    //	$pdf->Image("images/content/150dpi/ETF-Domestic-contract-PGS-ALL-0.png",210,297,0,0,'','','',true,150);
    $pdf->Image("images/content/150dpi/domestic-contract{$mscfile}-0.png", 0, 0, 210, 0, '', '', '', true, 150);
    $pdf->SetXY(175, 34);
    $pdf->Cell(23, 0, $agnaziv, 0, 0, 'C');
    $pdf->SetXY(175, 42);
    $pdf->Cell(23, 0, $godina . ".", 0, 0, 'C');
    $pdf->SetXY(175, 50);
    $pdf->Cell(23, 0, $sem1 . ". & " . $sem2, 0, 0, 'C');
    $pdf->SetXY(70, 48);
    $pdf->Cell(100, 0, $studijeng, 0, 0);
    $pdf->SetXY(70, 52);
    $pdf->Cell(100, 0, $studijbos, 0, 0);
    $pdf->SetXY(70, 62);
    $pdf->Cell(100, 0, $imeprezime);
    $pdf->SetXY(70, 69);
    $pdf->Cell(100, 0, $brindexa);
    // PRVI SEMESTAR
    $pdf->AddPage();
    $pdf->Image("images/content/150dpi/domestic-contract{$mscfile}-1.png", 0, 0, 210);
    $pdf->SetXY(175, 34);
    $pdf->Cell(23, 0, $agnaziv, 0, 0, 'C');
    $pdf->SetXY(175, 42);
    $pdf->Cell(23, 0, $godina . ".", 0, 0, 'C');
    $pdf->SetXY(175, 50);
    $pdf->Cell(23, 0, $sem1 . ".", 0, 0, 'C');
    $pdf->SetXY(70, 48);
    $pdf->Cell(100, 0, $studijeng, 0, 0);
    $pdf->SetXY(70, 52);
    $pdf->Cell(100, 0, $studijbos, 0, 0);
    $pdf->SetXY(70, 62);
    $pdf->Cell(100, 0, $imeprezime);
    $pdf->SetXY(70, 69);
    $pdf->Cell(100, 0, $brindexa);
    // Spisak obaveznih predmeta na neparnom semestru
    // Ako je ponovac, ne prikazujemo predmete koje je polozio
    if ($ponovac == 1) {
        $q100 = myquery("select p.sifra, p.naziv, p.ects from predmet as p, plan_studija as ps where ps.godina_vazenja={$najnoviji_plan} and ps.studij={$studij} and ps.semestar={$sem1} and ps.obavezan=1 and ps.predmet=p.id and (select count(*) from konacna_ocjena as ko where ko.student={$userid} and ko.predmet=p.id)=0");
    } else {
        // Ako nije, trebamo prikazati one koje je položio u koliziji
        $q100 = myquery("select p.sifra, p.naziv, p.ects from predmet as p, plan_studija as ps where ps.godina_vazenja={$najnoviji_plan} and ps.studij={$studij} and ps.semestar={$sem1} and ps.obavezan=1 and ps.predmet=p.id");
    }
    $ykoord = 95;
    $ects = 0;
    while ($r100 = mysql_fetch_row($q100)) {
        $pdf->SetXY(13, $ykoord);
        $pdf->Cell(100, 0, $r100[0]);
        $pdf->SetXY(50, $ykoord);
        $pdf->Cell(100, 0, $r100[1]);
        $e = "{$r100['2']}";
        if (!strchr($e, ".")) {
            $e .= ".0";
        }
        $pdf->SetXY(170, $ykoord);
        $pdf->Cell(100, 0, $e);
        $ykoord += 4;
        $ects += $r100[2];
    }
    // Da li je prenesen predmet na neparnom semestru?
    if ($ima_preneseni && $preneseni_semestar % 2 == 1) {
        $pdf->SetXY(13, $ykoord);
        $pdf->Cell(100, 0, $preneseni_sifra);
        $pdf->SetXY(50, $ykoord);
        $pdf->Cell(100, 0, $preneseni_naziv);
        $e = "{$preneseni_ects}";
        if (!strchr($e, ".")) {
            $e .= ".0";
        }
        $pdf->SetXY(170, $ykoord);
        $pdf->Cell(100, 0, $e);
        $ykoord += 4;
        $ects += $preneseni_ects;
    }
    // Spisak izbornih predmeta
    if ($ponovac == 1) {
        $q110 = myquery("select p.sifra, p.naziv, p.ects from predmet as p, ugovoroucenju_izborni as uoui, ugovoroucenju as uu where uoui.ugovoroucenju=uu.id and uu.student={$userid} and uu.akademska_godina={$zagodinu} and uoui.predmet=p.id and uu.semestar={$sem1} and (select count(*) from konacna_ocjena as ko where ko.student={$userid} and ko.predmet=p.id)=0");
    } else {
        $q110 = myquery("select p.sifra, p.naziv, p.ects from predmet as p, ugovoroucenju_izborni as uoui, ugovoroucenju as uu where uoui.ugovoroucenju=uu.id and uu.student={$userid} and uu.akademska_godina={$zagodinu} and uoui.predmet=p.id and uu.semestar={$sem1}");
    }
    $ykoord = 123;
    while ($r110 = mysql_fetch_row($q110)) {
        $pdf->SetXY(13, $ykoord);
        $pdf->Cell(100, 0, $r110[0]);
        $pdf->SetXY(50, $ykoord);
        $pdf->Cell(100, 0, $r110[1]);
        $e = "{$r110['2']}";
        if (!strchr($e, ".")) {
            $e .= ".0";
        }
        $pdf->SetXY(170, $ykoord);
        $pdf->Cell(100, 0, $e);
        $ykoord += 4;
        $ects += $r110[2];
    }
    // Suma ects
    if (!strchr($ects, ".")) {
        $ects .= ".0";
    }
    $pdf->SetXY(170, 135);
    $pdf->Cell(100, 0, $ects);
    // DRUGI SEMESTAR
    $pdf->AddPage();
    $pdf->Image("images/content/150dpi/domestic-contract{$mscfile}-2.png", 0, 0, 210);
    $pdf->SetXY(175, 34);
    $pdf->Cell(23, 0, $agnaziv, 0, 0, 'C');
    $pdf->SetXY(175, 42);
    $pdf->Cell(23, 0, $godina . ".", 0, 0, 'C');
    $pdf->SetXY(175, 50);
    $pdf->Cell(23, 0, $sem2 . ".", 0, 0, 'C');
    $pdf->SetXY(70, 48);
    $pdf->Cell(100, 0, $studijeng, 0, 0);
    $pdf->SetXY(70, 52);
    $pdf->Cell(100, 0, $studijbos, 0, 0);
    $pdf->SetXY(70, 62);
    $pdf->Cell(100, 0, $imeprezime);
    $pdf->SetXY(70, 69);
    $pdf->Cell(100, 0, $brindexa);
    // Spisak obaveznih predmeta na parnom semestru
    if ($ponovac == 1) {
        $q100 = myquery("select p.sifra, p.naziv, p.ects from predmet as p, plan_studija as ps where ps.godina_vazenja={$najnoviji_plan} and ps.studij={$studij} and ps.semestar={$sem2} and ps.obavezan=1 and ps.predmet=p.id and (select count(*) from konacna_ocjena as ko where ko.student={$userid} and ko.predmet=p.id)=0");
    } else {
        $q100 = myquery("select p.sifra, p.naziv, p.ects from predmet as p, plan_studija as ps where ps.godina_vazenja={$najnoviji_plan} and ps.studij={$studij} and ps.semestar={$sem2} and ps.obavezan=1 and ps.predmet=p.id");
    }
    $ykoord = 95;
    $ects = 0;
    while ($r100 = mysql_fetch_row($q100)) {
        $pdf->SetXY(13, $ykoord);
        $pdf->Cell(100, 0, $r100[0]);
        $pdf->SetXY(50, $ykoord);
        $pdf->Cell(100, 0, $r100[1]);
        $e = "{$r100['2']}";
        if (!strchr($e, ".")) {
            $e .= ".0";
        }
        $pdf->SetXY(170, $ykoord);
        $pdf->Cell(100, 0, $e);
        $ykoord += 4;
        $ects += $r100[2];
    }
    // Da li je prenesen predmet na parnom semestru?
    if ($ima_preneseni && $preneseni_semestar % 2 == 0) {
        $pdf->SetXY(13, $ykoord);
        $pdf->Cell(100, 0, $preneseni_sifra);
        $pdf->SetXY(50, $ykoord);
        $pdf->Cell(100, 0, $preneseni_naziv);
        $e = "{$preneseni_ects}";
        if (!strchr($e, ".")) {
            $e .= ".0";
        }
        $pdf->SetXY(170, $ykoord);
        $pdf->Cell(100, 0, $e);
        $ykoord += 4;
        $ects += $preneseni_ects;
    }
    // Spisak izbornih predmeta
    if ($ponovac == 1) {
        $q110 = myquery("select p.sifra, p.naziv, p.ects from predmet as p, ugovoroucenju_izborni as uoui, ugovoroucenju as uu where uoui.ugovoroucenju=uu.id and uu.student={$userid} and uu.akademska_godina={$zagodinu} and uoui.predmet=p.id and uu.semestar={$sem2} and (select count(*) from konacna_ocjena as ko where ko.student={$userid} and ko.predmet=p.id)=0");
    } else {
        $q110 = myquery("select p.sifra, p.naziv, p.ects from predmet as p, ugovoroucenju_izborni as uoui, ugovoroucenju as uu where uoui.ugovoroucenju=uu.id and uu.student={$userid} and uu.akademska_godina={$zagodinu} and uoui.predmet=p.id and uu.semestar={$sem2}");
    }
    $ykoord = 123;
    while ($r110 = mysql_fetch_row($q110)) {
        $pdf->SetXY(13, $ykoord);
        $pdf->Cell(100, 0, $r110[0]);
        $pdf->SetXY(50, $ykoord);
        $pdf->Cell(100, 0, $r110[1]);
        $e = "{$r110['2']}";
        if (!strchr($e, ".")) {
            $e .= ".0";
        }
        $pdf->SetXY(170, $ykoord);
        $pdf->Cell(100, 0, $e);
        $ykoord += 4;
        $ects += $r110[2];
    }
    // Suma ects
    if (!strchr($ects, ".")) {
        $ects .= ".0";
    }
    $pdf->SetXY(170, 135);
    $pdf->Cell(100, 0, $ects);
    // ---------------------------------------------------------
    //Close and output PDF document
    $pdf->Output('ugovor_o_ucenju.pdf', 'I');
    //============================================================+
    // END OF FILE
    //============================================================+
}
Example #4
1
function izvjestaj_prijemni_brzi_unos()
{
    require_once 'lib/tcpdf/tcpdf.php';
    $termin = intval($_REQUEST['termin']);
    $osoba = intval($_REQUEST['osoba']);
    $q10 = myquery("select ime, prezime, imeoca, jmbg from osoba where id={$osoba}");
    if (mysql_num_rows($q10) < 1) {
        biguglyerror("Nepostojeća osoba");
        zamgerlog("nepostojeca osoba {$osoba}", 3);
        return;
    }
    $ime = mysql_result($q10, 0, 0);
    $prezime = mysql_result($q10, 0, 1);
    $imeoca = mysql_result($q10, 0, 2);
    $jmbg = mysql_result($q10, 0, 3);
    $q20 = myquery("select sifra, jezik from prijemni_obrazac where osoba={$osoba} and prijemni_termin={$termin}");
    if (mysql_num_rows($q20) < 1) {
        biguglyerror("Ne postoji obrazac za ovu osobu");
        zamgerlog("za osobu u{$osoba} ne postoji obrazac na terminu {$termin}", 3);
        return;
    }
    $sifra = mysql_result($q20, 0, 0);
    $jezik = mysql_result($q20, 0, 1);
    $datum = date("d. m. Y.");
    $vrijeme = date("h:i");
    // ----- Pravljenje PDF dokumenta
    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
    // set document information
    $pdf->SetCreator("Zamger");
    $pdf->SetTitle('Sifra kandidata i pregled vaznijih datuma');
    // set default monospaced font
    $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
    //set margins
    $pdf->SetMargins(0, 0, 0);
    //set auto page breaks
    $pdf->SetAutoPageBreak(false);
    //set image scale factor
    $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
    //$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO*2.083333);
    $pdf->setJPEGQuality(100);
    //set some language-dependent strings
    $pdf->setLanguageArray($l);
    // ---------------------------------------------------------
    // set font
    $pdf->SetFont('freesans', '', 48);
    $pdf->SetHeaderData("", 0, "", "");
    $pdf->SetPrintHeader(false);
    $pdf->SetPrintFooter(false);
    // add a page
    $pdf->AddPage();
    //	$pdf->Image("images/content/150dpi/ETF-Domestic-contract-PGS-ALL-0.png",210,297,0,0,'','','',true,150);
    if ($jezik == "en") {
        $pdf->Image("images/content/150dpi/obrazac_sa_sifrom_en.png", 0, 0, 210, 0, '', '', '', true, 150);
        $en_offset = 7;
    } else {
        $pdf->Image("images/content/150dpi/obrazac_sa_sifrom.png", 0, 0, 210, 0, '', '', '', true, 150);
        $en_offset = 0;
    }
    $pdf->SetXY(130, 15);
    $pdf->Cell(23, 0, $sifra, 0, 0, 'C');
    $pdf->SetFont('freesans', '', 16);
    $pdf->SetXY(80, 62 + $en_offset);
    $pdf->Cell(23, 0, "{$ime} ({$imeoca}) {$prezime}");
    $pdf->SetXY(80, 73 + $en_offset);
    $pdf->Cell(23, 0, $jmbg);
    $pdf->SetFont('freesans', '', 14);
    $pdf->SetXY(40, 113 + $en_offset);
    $pdf->Cell(23, 0, $datum);
    $pdf->SetXY(130, 113 + $en_offset);
    $pdf->Cell(23, 0, $vrijeme);
    // ---------------------------------------------------------
    //Close and output PDF document
    $pdf->Output('obrazac_sa_sifrom.pdf', 'I');
    //============================================================+
    // END OF FILE
    //============================================================+
}
Example #5
0
 /**
  * @param Layout|null $default_layout
  */
 public function __construct(Layout $default_layout = null)
 {
     $this->pdf = new \TCPDF('P', 'pt', 'A4', true, 'UTF-8');
     $this->pdf->SetCreator('Thinreports Generator');
     $this->pdf->SetAutoPageBreak(false);
     $this->pdf->SetMargins(0, 0, 0, true);
     $this->pdf->SetCellPadding(0);
     $this->pdf->SetCellMargins(0, 0, 0, 0);
     $this->pdf->SetPrintHeader(false);
     $this->pdf->SetPrintFooter(false);
     if ($default_layout !== null) {
         $this->pdf->SetTitle($default_layout->getReportTitle());
         $this->registerPageFormat($default_layout);
     }
     $this->initDrawer();
 }
function prepareStockStatusReport($conn)
{
    $lan = $_POST['lan'];
    if ($lan == 'en-GB') {
        $MonthList = array('1' => 'January', '2' => 'February', '3' => 'March', '4' => 'April', '5' => 'May', '6' => 'June', '7' => 'July', '8' => 'August', '9' => 'September', '10' => 'October', '11' => 'November', '12' => 'December');
    } else {
        $MonthList = array('1' => 'Janvier', '2' => 'F�vrier', '3' => 'Mars', '4' => 'Avril', '5' => 'Mai', '6' => 'Juin', '7' => 'Juillet', '8' => 'Ao�t', '9' => 'Septembre', '10' => 'Octobre', '11' => 'Novembre', '12' => 'D�cembre');
    }
    require_once 'tcpdf/tcpdf.php';
    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
    $pdf->SetPrintHeader(false);
    $pdf->SetPrintFooter(false);
    $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
    $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
    $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
    $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
    $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
    $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
    if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
        require_once dirname(__FILE__) . '/lang/eng.php';
        $pdf->setLanguageArray($l);
    }
    $pdf->SetFont('dejavusans', '', 12);
    $pdf->AddPage();
    ini_set('magic_quotes_gpc', 'off');
    $html = htmlentities($_POST['html'], ENT_QUOTES, "UTF-8");
    $html = html_entity_decode($html, ENT_QUOTES, "UTF-8");
    $alavel = htmlentities($_POST['alavel'], ENT_QUOTES, "UTF-8");
    $alavel = html_entity_decode($alavel, ENT_QUOTES, "UTF-8");
    $filePath = SITEDOCUMENT . 'administrator/components/com_jcode/source/report/pdfslice/stock_status.svg';
    if (file_exists($filePath)) {
        unlink($filePath);
    }
    $file = fopen($filePath, "w");
    fwrite($file, $html);
    fclose($file);
    $pdf->ImageSVG($file = 'pdfslice/stock_status.svg', $x = 8, $y = 20, $w = 180, $h = '', $link = '', $align = 'left', $palign = 'center', $border = 0, $fitonpage = false);
    $html2 = <<<EOF
    <!-- EXAMPLE OF CSS STYLE -->
    <style>
    </style>
    <body>
        <div id="barchartlegend">
            {$alavel}
        </div>
    </body>
EOF;
    echo $html2;
    $pdf->writeHTMLCell($w = 150, $h = 30, $x = 15, $y = 0, $html2, $border = 0, $ln = 0, $fill = false, $reseth = true, $align = 'C', $autopadding = true);
    $filePath = SITEDOCUMENT . 'administrator/components/com_jcode/source/report/pdfslice/StockStatusChart.pdf';
    if (file_exists($filePath)) {
        unlink($filePath);
    }
    $pdf->Output('pdfslice/StockStatusChart.pdf', 'F');
}
function prepareFundingStatusReport($conn)
{
    require_once 'tcpdf/tcpdf.php';
    //$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
    $pdf = new TCPDF('L', PDF_UNIT, 'Letter', true, 'UTF-8', false);
    $pdf->SetPrintHeader(false);
    $pdf->SetPrintFooter(false);
    $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
    $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
    $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
    $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
    $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
    $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
    if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
        require_once dirname(__FILE__) . '/lang/eng.php';
        $pdf->setLanguageArray($l);
    }
    $pdf->SetFont('dejavusans', '', 7);
    $pdf->AddPage($orientation = L, $format = 'Letter', $keepmargins = true, $tocpage = false);
    ini_set('magic_quotes_gpc', 'off');
    $html = htmlentities($_POST['html'], ENT_QUOTES, "UTF-8");
    $html = html_entity_decode($html, ENT_QUOTES, "UTF-8");
    $alavel = htmlentities($_POST['alavel'], ENT_QUOTES, "UTF-8");
    $alavel = html_entity_decode($alavel, ENT_QUOTES, "UTF-8");
    $filePath = SITEDOCUMENT . 'administrator/components/com_jcode/source/report/pdfslice/funding_status.svg';
    if (file_exists($filePath)) {
        unlink($filePath);
    }
    $file = fopen($filePath, "w");
    fwrite($file, $html);
    fclose($file);
    $pdf->ImageSVG($file = 'pdfslice/funding_status.svg', $x = 3, $y = 20, $w = 1291, $h = 400, $link = '', $align = '', $palign = 'center', $border = 0, $fitonpage = false);
    $html2 = <<<EOF
    <!-- EXAMPLE OF CSS STYLE -->
    <style>
    </style>
    <body>
        <div id="barchartlegend">
            {$alavel}
        </div>
    </body>
EOF;
    echo $html2;
    $pdf->writeHTMLCell($w = 150, $h = 30, $x = 15, $y = 130, $html2, $border = 0, $ln = 0, $fill = false, $reseth = true, $align = 'middle', $autopadding = true);
    $filePath = SITEDOCUMENT . 'administrator/components/com_jcode/source/report/pdfslice/FundingStatusChart.pdf';
    if (file_exists($filePath)) {
        unlink($filePath);
    }
    $pdf->Output('pdfslice/FundingStatusChart.pdf', 'F');
}
 public function postAdicionar()
 {
     $pdf = new TCPDF();
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor('GestBiblio - Sistema de Gestão de Bibliotecas');
     $pdf->SetTitle('Comprovante de Imprestimo');
     $pdf->SetPrintHeader(false);
     $pdf->SetPrintFooter(false);
     $pdf->AddPage();
     $html = '';
     $pdf->Text(90, 140, 'This is a test');
     $filename = storage_path() . '/test.pdf';
     $pdf->output($filename, 'F');
     return Response::view($filename);
 }
Example #9
0
 /**
  * [พิมพ์ post]
  * @param  [type] $id [description]
  * @return [type]     [description]
  */
 public function printPost($id)
 {
     if (Session::get('c3') == 1) {
         $sql = ' select c.*, concat(n.pname,n.fname," ",n.lname) as fullname from c_blog_posts c left join n_datageneral n on n.cid=c.created_by';
         $sql .= ' where postID =' . e($id) . ' ';
         $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
         $pdf->SetPrintHeader(false);
         $pdf->SetPrintFooter(false);
         // set header and footer fonts
         $pdf->setHeaderFont(array('angsanaupc', '', PDF_FONT_SIZE_MAIN));
         $pdf->setFooterFont(array('angsanaupc', '', PDF_FONT_SIZE_DATA));
         // set default monospaced font
         $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
         // set margins
         $pdf->SetMargins(15, 15, 15);
         $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
         $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
         $pdf->AddPage();
         $pdf->SetFont('angsanaupc', 'B', 16, '', true);
         $pdf->SetXY(15, 15);
         $pdf->MultiCell(180, 0, 'ใบประสานงานขอรถ', 0, 'C', 0, 1, '', '', true);
         $data = DB::select($sql);
         $pdf->SetFont('angsanaupc', '', 14, '', true);
         $tbl = '<br /><br /><table style="width: 100%; padding:2px;" cellspacing="0">';
         foreach ($data as $key => $value) {
             $tbl = $tbl . '<tr>
                   <td style="border: 0px solid #000000; text-align:left"> เรื่อง ' . $value->postTitle . '</td>
               </tr>';
             $tbl = $tbl . '<tr>
                   <td style="border: 0px solid #000000; text-align:left"> สร้างโดย ' . $value->fullname . ' วันที่ ' . date("d-m", strtotime($value->postDate)) . '-' . (date("Y", strtotime($value->postDate)) + 543) . ' เวลา ' . date("H:i:s", strtotime($value->postDate)) . '</td>
               </tr>';
             $tbl = $tbl . '<tr>
                   <td style="border: 0px solid #000000; text-align:left"> ' . $value->postDesc . '</td>
               </tr>';
         }
         $tbl = $tbl . '</table>';
         $pdf->writeHTML($tbl, true, false, false, false, '');
         $filename = storage_path() . '/report_post.pdf';
         $contents = $pdf->output($filename, 'I');
         $headers = array('Content-Type' => 'application/pdf');
         return Response::make($contents, 200, $headers);
     } else {
         return Redirect::to('contact');
     }
 }
 /**
  * Sets up a new PDF object with the necessary settings
  *
  * @return  FPDF            A new PDF object
  */
 protected function initialize_pdf()
 {
     global $CFG;
     require_once $CFG->dirroot . '/local/elisreports/lib/tcpdf/tcpdf.php';
     $newpdf = new TCPDF('L', 'in', 'letter');
     //prevent the library from automatically outputting
     //header or footer bars
     $newpdf->SetPrintHeader(false);
     $newpdf->SetPrintFooter(false);
     $newpdf->setMargins(self::marginx, self::marginy);
     $newpdf->SetFont('freesans', '', 9);
     $newpdf->AddPage();
     $newpdf->SetFont('freesans', '', 16);
     $newpdf->MultiCell(0, 0.2, $this->report->title, 0, 'C');
     $newpdf->Ln(0.2);
     $newpdf->SetFont('freesans', '', 8);
     $newpdf->SetFillColor(225, 225, 225);
     return $newpdf;
 }
Example #11
0
 /**
  * {@inheritdoc}
  */
 public function setHeader($text)
 {
     $this->generator->SetPrintHeader($text);
 }
Example #12
0
<?php

$footer = "ważna do <b>" . file_get_contents("config/data.txt") . "</b>";
require_once 'lib/tcpdf.php';
$pdf = new TCPDF("P", "mm", "A4");
$pdf->SetCreator("Legitk(s)i");
$pdf->SetFontSubsetting(false);
$pdf->SetPrintFooter(false);
$pdf->SetPrintHeader(false);
$pdf->SetAutoPageBreak(TRUE, 0);
/* SIZE CONFIG - in mm */
$leftMargin = 5;
$topMargin = 5;
$cellsPerPage = 10;
$cellWidth = 80;
$cellHeight = 50;
//$cellWidth=85; $cellHeight=54; //<-- -1mm for border (A4 is 297mm heigh)
$cellWidth = 78;
$cellHeight = 49;
$handle = fopen("config/ludzie.txt", "r");
if ($handle) {
    $i = -1;
    while (($line = fgets($handle)) !== false) {
        $i = ($i + 1) % $cellsPerPage;
        if ($i == 0) {
            //page change
            $x = $leftMargin;
            $y = $topMargin;
            $pdf->AddPage();
        }
        if ($i % 2 == 0) {
Example #13
0
 public function tax_continuous_type4($id = null, $year = null)
 {
     if (Session::get('level') != '') {
         $y = Input::get('y3');
         if ($y != '') {
             $year = $y;
             $id = 'all';
         }
         $pdf = new TCPDF();
         $pdf->SetPrintHeader(false);
         $pdf->SetPrintFooter(false);
         $n = DB::select('select * from s_general_data');
         foreach ($n as $k) {
             $name = $k->name;
             $address = $k->address;
             $address2 = $k->address2;
             $tax_id2 = $k->tax_id2;
             $director = $k->director;
         }
         $sql = ' select concat(n.pname,"",n.fname," ",n.lname) as name, s.cid, s.tax_id,sum(s.salary+s.r_other) as salary, sum(s.r_c) as r_c, sum(s.special_m+s.pts+s.pts2) as special, sum(s.tax) as tax ,sum(s.kbk) as kbk from s_salary_ocsc_detail s left join n_datageneral n on n.cid=s.cid left join n_position_salary p on p.cid=n.cid where  s.cid=5350400051484  and  year(s.order_date)=' . $year . ' group by s.cid order by n.datainfoID asc ';
         $result = DB::select($sql);
         foreach ($result as $key) {
             $pdf->AddPage('P', 'A4');
             $pdf->SetFont('freeserif', 'B', 11, '', true);
             $pdf->MultiCell(185, 5, 'เลขที่ งป. ........................./ ' . ($year == 'null' ? $this->yearThai() : $year + 543), 0, 'R', 0, 1, '', '', true);
             $pdf->SetFont('freeserif', 'B', 16, '', true);
             $pdf->SetY(25);
             $pdf->SetX(18);
             $pdf->MultiCell(177, 5, 'หนังสือรับรองการหักภาษี ณ ที่จ่าย', 0, 'C', 0, 1, '', '', true);
             $pdf->SetY(34);
             $pdf->SetX(18);
             $pdf->MultiCell(177, 5, 'ตามมาตรา 50 ทวิ แห่งประมวลรัษฎากร', 0, 'C', 0, 1, '', '', true);
             //===== แนวตั้ง =====//
             $linever1 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0));
             $pdf->Line(18, 190, 18, 50, $linever1);
             $linever2 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0));
             $pdf->Line(80, 190, 80, 50, $linever2);
             $linever3 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0));
             $pdf->Line(110, 190, 110, 50, $linever3);
             $linever4 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0));
             $pdf->Line(135, 190, 135, 50, $linever4);
             $linever5 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0));
             $pdf->Line(165, 190, 165, 50, $linever5);
             $linever6 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0));
             $pdf->Line(195, 190, 195, 50, $linever6);
             //===== แนวนอน =====//
             $linetop = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0));
             $pdf->Line(18, 50, 195, 50, $linetop);
             $linetop2 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0));
             $pdf->Line(80, 63, 195, 63, $linetop2);
             $linetop3 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0));
             $pdf->Line(18, 120, 80, 120, $linetop3);
             $linetop4 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0));
             $pdf->Line(80, 180, 195, 180, $linetop4);
             $linetop5 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0));
             $pdf->Line(18, 190, 195, 190, $linetop5);
             //======= text in box 1 ========//
             $pdf->SetFont('freeserif', '', 13, '', true);
             $pdf->SetY(52);
             $pdf->SetX(19);
             $pdf->MultiCell(62, 5, 'ชื่อและที่อยู่ของผู้มีหน้าที่หักภาษี ณ ที่จ่าย บุคคลคณะบุคคล นิติบุคคล ส่วนราชการ องค์การ รัฐวิสาหกิจ ฯลฯ ', 0, 'L', 0, 1, '', '', true);
             $pdf->SetFont('freeserif', 'B', 13, '', true);
             $pdf->SetY(82);
             $pdf->SetX(19);
             $pdf->MultiCell(62, 5, $address2, 0, 'L', 0, 1, '', '', true);
             $pdf->SetFont('freeserif', 'B', 13, '', true);
             $pdf->SetY(105);
             $pdf->SetX(19);
             $pdf->MultiCell(40, 5, $tax_id2, 0, 'L', 0, 1, '', '', true);
             //======= text in box 2 ========//
             $pdf->SetFont('freeserif', '', 13, '', true);
             $pdf->SetY(122);
             $pdf->SetX(19);
             $pdf->MultiCell(62, 5, 'ชื่อและที่อยู่ของผู้ถูกหักภาษี ณ ที่จ่าย', 0, 'L', 0, 1, '', '', true);
             $pdf->SetFont('freeserif', 'B', 12, '', true);
             $pdf->SetY(137);
             $pdf->SetX(21);
             $pdf->MultiCell(59, 5, $key->name, 0, 'L', 0, 1, '', '', true);
             $pdf->SetFont('freeserif', '', 13, '', true);
             $pdf->SetY(145);
             $pdf->SetX(19);
             $pdf->MultiCell(62, 5, $address, 0, 'L', 0, 1, '', '', true);
             $pdf->SetFont('freeserif', 'B', 13, '', true);
             $pdf->SetY(165);
             $pdf->SetX(19);
             $pdf->MultiCell(62, 5, 'เลขประจำตัวผู้เสียภาษีของผู้ถูกหักภาษี ณ ที่จ่าย', 0, 'L', 0, 1, '', '', true);
             $pdf->SetFont('freeserif', '', 12, '', true);
             $pdf->SetY(178);
             $pdf->SetX(22);
             $pdf->MultiCell(62, 5, $key->cid, 0, 'L', 0, 1, '', '', true);
             //======= text in box 3 header content ========//
             $pdf->SetFont('freeserif', 'B', 13, '', true);
             $pdf->SetY(54);
             $pdf->SetX(83);
             $pdf->MultiCell(32, 5, 'เงินได้ที่จ่าย', 0, 'L', 0, 1, '', '', true);
             $pdf->SetFont('freeserif', 'B', 13, '', true);
             $pdf->SetY(54);
             $pdf->SetX(111);
             $pdf->MultiCell(32, 5, 'ปีภาษีที่จ่าย', 0, 'L', 0, 1, '', '', true);
             $pdf->SetFont('freeserif', 'B', 13, '', true);
             $pdf->SetY(54);
             $pdf->SetX(138);
             $pdf->MultiCell(32, 5, 'จำนวนเงิน', 0, 'L', 0, 1, '', '', true);
             $pdf->SetFont('freeserif', 'B', 13, '', true);
             $pdf->SetY(54);
             $pdf->SetX(167);
             $pdf->MultiCell(32, 5, 'ภาษีที่หักไว้', 0, 'L', 0, 1, '', '', true);
             //============= text in content ================//
             $pdf->SetFont('freeserif', '', 12, '', true);
             //-----col 1
             $pdf->SetY(70);
             $pdf->SetX(80);
             $pdf->MultiCell(30, 5, 'เงินเดือน ค่าจ้าง บำนาญ เบี้ยเลี้ยง โบนัส ตามมาตรา 40(1)', 0, 'L', 0, 1, '', '', true);
             $pdf->SetY(95);
             $pdf->SetX(80);
             $pdf->MultiCell(31, 5, 'เงินประจำตำแหน่ง', 0, 'L', 0, 1, '', '', true);
             $pdf->SetY(104);
             $pdf->SetX(80);
             $pdf->MultiCell(27, 5, 'เงินค่าตอบแทนพิเศษ พตส ค่าครองชีพ', 0, 'L', 0, 1, '', '', true);
             //-----col 2
             $pdf->SetY(70);
             $pdf->SetX(116);
             $pdf->MultiCell(31, 5, $year == 'null' ? $this->yearThai() : $year + 543, 0, 'L', 0, 1, '', '', true);
             //-----col 3
             $pdf->SetY(70);
             $pdf->SetX(135);
             $pdf->MultiCell(30, 5, number_format($key->salary, 2), 0, 'R', 0, 1, '', '', true);
             $pdf->SetY(95);
             $pdf->SetX(135);
             $pdf->MultiCell(30, 5, number_format($key->r_c, 2), 0, 'R', 0, 1, '', '', true);
             $pdf->SetY(104);
             $pdf->SetX(135);
             $pdf->MultiCell(30, 5, number_format($key->special, 2), 0, 'R', 0, 1, '', '', true);
             //-----col 4
             $pdf->SetY(70);
             $pdf->SetX(165);
             $pdf->MultiCell(30, 5, number_format($key->tax, 2), 0, 'R', 0, 1, '', '', true);
             //============= text in box 4 footer sum ============//
             $pdf->SetFont('freeserif', 'B', 13, '', true);
             $pdf->SetY(182);
             $pdf->SetX(89);
             $pdf->MultiCell(32, 5, 'รวม', 0, 'L', 0, 1, '', '', true);
             $pdf->SetFont('freeserif', '', 12, '', true);
             $pdf->SetY(182);
             $pdf->SetX(135);
             $pdf->MultiCell(30, 5, number_format($key->salary + $key->special + $key->r_c, 2), 0, 'R', 0, 1, '', '', true);
             $pdf->SetFont('freeserif', '', 12, '', true);
             $pdf->SetY(182);
             $pdf->SetX(165);
             $pdf->MultiCell(30, 5, number_format($key->tax, 2), 0, 'R', 0, 1, '', '', true);
             //============= text footer ================//
             $pdf->SetFont('freeserif', '', 12, '', true);
             $pdf->SetY(195);
             $pdf->SetX(22);
             $pdf->MultiCell(32, 5, 'ผู้จ่ายเงิน', 0, 'L', 0, 1, '', '', true);
             $pdf->SetY(195);
             $pdf->SetX(39);
             $pdf->MultiCell(5, 5, '', 1, 'L', 0, 1, '', '', true);
             $pdf->SetY(195);
             $pdf->SetX(44);
             $pdf->MultiCell(30, 5, '(1) หัก ณ ที่จ่าย', 0, 'L', 0, 1, '', '', true);
             $pdf->SetY(195);
             $pdf->SetX(73);
             $pdf->MultiCell(5, 5, '', 1, 'L', 0, 1, '', '', true);
             $pdf->SetY(195);
             $pdf->SetX(78);
             $pdf->MultiCell(35, 5, '(2) ออกให้ตลอดไป', 0, 'L', 0, 1, '', '', true);
             $pdf->SetY(195);
             $pdf->SetX(112);
             $pdf->MultiCell(5, 5, '', 1, 'L', 0, 1, '', '', true);
             $pdf->SetY(195);
             $pdf->SetX(117);
             $pdf->MultiCell(35, 5, '(3) ออกให้ครั้งเดียว', 0, 'L', 0, 1, '', '', true);
             $pdf->SetY(205);
             $pdf->SetX(39);
             $pdf->MultiCell(5, 5, ' /', 1, 'L', 0, 1, '', '', true);
             $pdf->SetY(205);
             $pdf->SetX(44);
             $pdf->MultiCell(100, 5, '(4) เงินสบทบกองทุนประกันสังคม ' . '  ' . number_format($key->kbk, 2) . ' บาท', 0, 'L', 0, 1, '', '', true);
             $pdf->SetFont('freeserif', 'B', 12, '', true);
             $pdf->SetY(220);
             $pdf->SetX(18);
             $pdf->MultiCell(177, 5, 'ข้าพเจ้าขอรับรองว่า ข้อความและตัวเลขดังกล่าวข้างต้นนี้ถูกต้องตามความเป็นจริงทุกประการ', 0, 'R', 0, 1, '', '', true);
             $pdf->SetFont('freeserif', '', 12, '', true);
             $pdf->SetY(235);
             $pdf->SetX(32);
             $pdf->MultiCell(170, 5, 'ลงชื่อ...........................................................ผู้มีหน้าที่หักภาษี ณ ที่จ่าย', 0, 'C', 0, 1, '', '', true);
             $pdf->SetY(245);
             $pdf->SetX(32);
             $pdf->MultiCell(140, 5, $director, 0, 'C', 0, 1, '', '', true);
             $pdf->SetY(255);
             $pdf->SetX(32);
             $pdf->MultiCell(140, 5, 'ทันตแพทย์เชี่ยวชาญ ปฎิบัติราชการแทน', 0, 'C', 0, 1, '', '', true);
             $pdf->SetY(265);
             $pdf->SetX(32);
             $pdf->MultiCell(140, 5, 'ผู้อำนวยการโรงพยาบาลโนนไทย', 0, 'C', 0, 1, '', '', true);
         }
         $filename = storage_path() . '/report_tax_continuous_emp4.pdf';
         // Response::download($filename);
         $contents = $pdf->output($filename, 'I');
         $headers = array('Content-Type' => 'application/pdf');
         return Response::make($contents, 200, $headers);
     } else {
         return View::make('login.index');
     }
 }
Example #14
0
/**
 * Creates the PDF version (downloadable) of the whole feedback produced by the teacher/tutor
 *
 * @param unknown $draft            
 * @param unknown $student            
 * @param unknown $context            
 * @param unknown $cmid            
 * @return boolean
 */
function emarking_create_response_pdf($draft, $student, $context, $cmid)
{
    global $CFG, $DB;
    require_once $CFG->libdir . '/pdflib.php';
    $fs = get_file_storage();
    if (!($submission = $DB->get_record('emarking_submission', array('id' => $draft->submissionid)))) {
        return false;
    }
    if (!($pages = $DB->get_records('emarking_page', array('submission' => $submission->id, 'student' => $student->id), 'page ASC'))) {
        return false;
    }
    if (!($emarking = $DB->get_record('emarking', array('id' => $submission->emarking)))) {
        return false;
    }
    $numpages = count($pages);
    $sqlcomments = "SELECT ec.id,\n\t\t\tec.posx,\n\t\t\tec.posy,\n\t\t\tec.rawtext,\n\t\t\tec.pageno,\n\t\t\tgrm.maxscore,\n\t\t\tec.levelid,\n\t\t\tec.width,\n\t\t\tec.colour,\n\t\t\tec.textformat,\n\t\t\tgrl.score AS score,\n\t\t\tgrl.definition AS leveldesc,\n\t\t\tgrc.id AS criterionid,\n\t\t\tgrc.description AS criteriondesc,\n\t\t\tu.id AS markerid, CONCAT(u.firstname,' ',u.lastname) AS markername\n\t\t\tFROM {emarking_comment} AS ec\n\t\t\tINNER JOIN {emarking_page} AS ep ON (ec.draft = :draft AND ec.page = ep.id)\n\t\t\tLEFT JOIN {user} AS u ON (ec.markerid = u.id)\n\t\t\tLEFT JOIN {gradingform_rubric_levels} AS grl ON (ec.levelid = grl.id)\n\t\t\tLEFT JOIN {gradingform_rubric_criteria} AS grc ON (grl.criterionid = grc.id)\n\t\t\tLEFT JOIN (\n\t\t\tSELECT grl.criterionid, max(score) AS maxscore\n\t\t\tFROM {gradingform_rubric_levels} AS grl\n\t\t\tGROUP BY grl.criterionid\n\t\t\t) AS grm ON (grc.id = grm.criterionid)\n\t\t\tWHERE ec.pageno > 0\n\t\t\tORDER BY ec.pageno";
    $params = array('draft' => $draft->id);
    $comments = $DB->get_records_sql($sqlcomments, $params);
    $commentsperpage = array();
    foreach ($comments as $comment) {
        if (!isset($commentsperpage[$comment->pageno])) {
            $commentsperpage[$comment->pageno] = array();
        }
        $commentsperpage[$comment->pageno][] = $comment;
    }
    // Parameters for PDF generation
    $iconsize = 5;
    $tempdir = emarking_get_temp_dir_path($emarking->id);
    if (!file_exists($tempdir)) {
        mkdir($tempdir);
    }
    // create new PDF document
    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
    // set document information
    $pdf->SetCreator(PDF_CREATOR);
    $pdf->SetAuthor($student->firstname . ' ' . $student->lastname);
    $pdf->SetTitle($emarking->name);
    $pdf->SetSubject('Exam feedback');
    $pdf->SetKeywords('feedback, emarking');
    $pdf->SetPrintHeader(false);
    $pdf->SetPrintFooter(false);
    // set default header data
    $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 036', PDF_HEADER_STRING);
    // set header and footer fonts
    $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
    $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
    // set default monospaced font
    $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
    // set margins
    $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
    $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
    $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
    // set auto page breaks
    $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
    // set image scale factor
    $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
    // set some language-dependent strings (optional)
    if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
        require_once dirname(__FILE__) . '/lang/eng.php';
        $pdf->setLanguageArray($l);
    }
    // ---------------------------------------------------------
    // set font
    $pdf->SetFont('times', '', 16);
    foreach ($pages as $page) {
        // add a page
        $pdf->AddPage();
        // get the current page break margin
        $bMargin = $pdf->getBreakMargin();
        // get current auto-page-break mode
        $auto_page_break = $pdf->getAutoPageBreak();
        // disable auto-page-break
        $pdf->SetAutoPageBreak(false, 0);
        // set bacground image
        $pngfile = $fs->get_file_by_id($page->file);
        $img_file = emarking_get_path_from_hash($tempdir, $pngfile->get_pathnamehash());
        $pdf->Image($img_file, 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0);
        // restore auto-page-break status
        // $pdf->SetAutoPageBreak($auto_page_break, $bMargin);
        // set the starting point for the page content
        $pdf->setPageMark();
        $dimensions = $pdf->getPageDimensions();
        if (isset($commentsperpage[$page->page])) {
            foreach ($commentsperpage[$page->page] as $comment) {
                $content = $comment->rawtext;
                $posx = (int) ((double) $comment->posx * $dimensions['w']);
                $posy = (int) ((double) $comment->posy * $dimensions['h']);
                if ($comment->textformat == 1) {
                    // text annotation
                    $pdf->Annotation($posx, $posy, 6, 6, $content, array('Subtype' => 'Text', 'StateModel' => 'Review', 'State' => 'None', 'Name' => 'Comment', 'NM' => 'Comment' . $comment->id, 'T' => $comment->markername, 'Subj' => 'example', 'C' => array(0, 0, 255)));
                } elseif ($comment->textformat == 2) {
                    $content = $comment->criteriondesc . ': ' . round($comment->score, 1) . '/' . round($comment->maxscore, 1) . "\n" . $comment->leveldesc . "\n" . get_string('comment', 'mod_emarking') . ': ' . $content;
                    // text annotation
                    $pdf->Annotation($posx, $posy, 6, 6, $content, array('Subtype' => 'Text', 'StateModel' => 'Review', 'State' => 'None', 'Name' => 'Comment', 'NM' => 'Mark' . $comment->id, 'T' => $comment->markername, 'Subj' => 'grade', 'C' => array(255, 255, 0)));
                } elseif ($comment->textformat == 3) {
                    $pdf->Image($CFG->dirroot . "/mod/emarking/img/check.gif", $posx, $posy, $iconsize, $iconsize, '', '', '', false, 300, '', false, false, 0);
                } elseif ($comment->textformat == 4) {
                    $pdf->Image($CFG->dirroot . "/mod/emarking/img/crossed.gif", $posx, $posy, $iconsize, $iconsize, '', '', '', false, 300, '', false, false, 0);
                }
            }
        }
    }
    // ---------------------------------------------------------
    // COGIDO PARA IMPRIMIR RÚBRICA
    if ($emarking->downloadrubricpdf) {
        $cm = new StdClass();
        $rubricdesc = $DB->get_recordset_sql("SELECT\n\t\td.name AS rubricname,\n\t\ta.id AS criterionid,\n\t\ta.description ,\n\t\tb.definition,\n\t\tb.id AS levelid,\n\t\tb.score,\n\t\tIFNULL(E.id,0) AS commentid,\n\t\tIFNULL(E.pageno,0) AS commentpage,\n\t\tE.rawtext AS commenttext,\n\t\tE.markerid AS markerid,\n\t\tIFNULL(E.textformat,2) AS commentformat,\n\t\tIFNULL(E.bonus,0) AS bonus,\n\t\tIFNULL(er.id,0) AS regradeid,\n\t\tIFNULL(er.motive,0) AS motive,\n\t\ter.comment AS regradecomment,\n\t\tIFNULL(er.markercomment, '') AS regrademarkercomment,\n\t\tIFNULL(er.accepted,0) AS regradeaccepted\n\t\tFROM {course_modules} AS c\n\t\tINNER JOIN {context} AS mc ON (c.id = :coursemodule AND c.id = mc.instanceid)\n\t\tINNER JOIN {grading_areas} AS ar ON (mc.id = ar.contextid)\n\t\tINNER JOIN {grading_definitions} AS d ON (ar.id = d.areaid)\n\t\tINNER JOIN {gradingform_rubric_criteria} AS a ON (d.id = a.definitionid)\n\t\tINNER JOIN {gradingform_rubric_levels} AS b ON (a.id = b.criterionid)\n\t\tLEFT JOIN (\n\t\tSELECT ec.*, d.id AS draftid\n\t\tFROM {emarking_comment} AS ec\n\t\tINNER JOIN {emarking_draft} AS d ON (d.id = :draft AND ec.draft = d.id)\n\t\t) AS E ON (E.levelid = b.id)\n\t\tLEFT JOIN {emarking_regrade} AS er ON (er.criterion = a.id AND er.draft = E.draftid)\n\t\tORDER BY a.sortorder ASC, b.score ASC", array('coursemodule' => $cmid, 'draft' => $draft->id));
        $table = new html_table();
        $data = array();
        foreach ($rubricdesc as $rd) {
            if (!isset($data[$rd->criterionid])) {
                $data[$rd->criterionid] = array($rd->description, $rd->definition . " (" . round($rd->score, 2) . " ptos. )");
            } else {
                array_push($data[$rd->criterionid], $rd->definition . " (" . round($rd->score, 2) . " ptos. )");
            }
        }
        $table->data = $data;
        // add extra page with rubrics
        $pdf->AddPage();
        $pdf->Write(0, 'Rúbrica', '', 0, 'L', true, 0, false, false, 0);
        $pdf->SetFont('helvetica', '', 8);
        $tbl = html_writer::table($table);
        $pdf->writeHTML($tbl, true, false, false, false, '');
    }
    // ---------------------------------------------------------
    $pdffilename = 'response_' . $emarking->id . '_' . $draft->id . '.pdf';
    $pathname = $tempdir . '/' . $pdffilename;
    if (@file_exists($pathname)) {
        unlink($pathname);
    }
    // Close and output PDF document
    $pdf->Output($pathname, 'F');
    // Copiar archivo desde temp a �rea
    $file_record = array('contextid' => $context->id, 'component' => 'mod_emarking', 'filearea' => 'response', 'itemid' => $student->id, 'filepath' => '/', 'filename' => $pdffilename, 'timecreated' => time(), 'timemodified' => time(), 'userid' => $student->id, 'author' => $student->firstname . ' ' . $student->lastname, 'license' => 'allrightsreserved');
    // Si el archivo ya existía entonces lo borramos
    if ($fs->file_exists($context->id, 'mod_emarking', 'response', $student->id, '/', $pdffilename)) {
        $previousfile = $fs->get_file($context->id, 'mod_emarking', 'response', $student->id, '/', $pdffilename);
        $previousfile->delete();
    }
    $fileinfo = $fs->create_file_from_pathname($file_record, $pathname);
    return true;
}
function generateFacilityReport($conn)
{
    global $gTEXT;
    require_once 'tcpdf/tcpdf.php';
    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
    $pdf->SetPrintHeader(false);
    $pdf->SetPrintFooter(false);
    $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
    $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
    $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
    $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
    $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
    if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
        require_once dirname(__FILE__) . '/lang/eng.php';
        $pdf->setLanguageArray($l);
    }
    $pdf->setFontSubsetting(false);
    $pdf->AddPage();
    $pdf->SetFillColor(255, 255, 255);
    $monthId = $_POST['MonthId'];
    $year = $_POST['Year'];
    $country = $_POST['CountryId'];
    // $itemGroupId=$_POST['ItemGroupId'];
    $CountryName = $_POST['CountryName'];
    $MonthName = $_POST['MonthName'];
    $ItemGroupName = $_POST['ItemGroupName'];
    $regionId = $_POST['RegionId'];
    $RegionName = $_POST['RegionName'];
    $districtId = $_POST['DistrictId'];
    $DistrictName = $_POST['DistrictName'];
    $ownerTypeId = $_POST['OwnerTypeId'];
    $OwnerTypeName = $_POST['OwnerTypeName'];
    $condition = "";
    if ($regionId) {
        $condition .= " and  x.RegionId = {$regionId} ";
    }
    if ($districtId) {
        $condition .= " and x.DistrictId = {$districtId} ";
    }
    if ($ownerTypeId) {
        $condition .= " and  x.OwnerTypeId = {$ownerTypeId} ";
    }
    $aColumns = array('SL', 'FacilityCode', 'FacilityName', 'bEntered', 'CreatedDt', 'bSubmitted', 'LastSubmittedDt', 'bAccepted', 'AcceptedDt', 'bPublished', 'PublishedDt');
    $sIndexColumn = "FacilityId";
    $sTable = "t_cfm_masterstockstatus";
    $sLimit = "limit 300";
    if (isset($_POST['iDisplayStart']) && $_POST['iDisplayLength'] != '-1') {
        $sLimit = "LIMIT " . intval($_POST['iDisplayStart']) . ", " . intval($_POST['iDisplayLength']);
    }
    $sOrder = "";
    if (isset($_POST['iSortCol_0'])) {
        $sOrder = "ORDER BY  ";
        for ($i = 0; $i < intval($_POST['iSortingCols']); $i++) {
            if ($_POST['bSortable_' . intval($_POST['iSortCol_' . $i])] == "true") {
                $sOrder .= "`" . $aColumns[intval($_POST['iSortCol_' . $i])] . "` " . ($_POST['sSortDir_' . $i] === 'asc' ? 'asc' : 'desc') . ", ";
            }
        }
        $sOrder = substr_replace($sOrder, "", -2);
        if ($sOrder == "ORDER BY") {
            $sOrder = "";
        }
    }
    /*$sWhere="";
    	for ($i = 0; $i < count($aColumns); $i++) {
    		
    		if (isset($_POST['bSearchable_' . $i]) && $_POST['bSearchable_' . $i] == "true" && $_POST['sSearch'] != '') {
    			
    			if ($sWhere == "") {
    				$sWhere = "WHERE ";
    			} else {
    				$sWhere .= " OR ";
    			}
    			$sWhere .= "`" . $aColumns[$i] . "` LIKE '%" . mysql_real_escape_string($_POST['sSearch']) . "%' ";
    		}
    	}*/
    $sWhere = "";
    if ($_POST['sSearch'] != "") {
        $sWhere = " WHERE (b.FacilityCode LIKE '%" . mysql_real_escape_string($_POST['sSearch']) . "%'\n        OR " . " b.FacilityName LIKE '%" . mysql_real_escape_string($_POST['sSearch']) . "%' )";
    }
    safe_query("SET @rank=0;");
    $serial = "@rank:=@rank+1 AS SL";
    $sQuery = "SELECT SQL_CALC_FOUND_ROWS " . $serial . ", b.FacilityId, b.FacilityCode, b.FacilityName,\n\t\t\t\tIFNULL( a.FacilityId,0) bEntered,\t\t\t\t\n\t\t\t\tDATE_FORMAT(a.CreatedDt, '%d-%b-%Y %h:%i %p') CreatedDt,\t\n\t\t\t\tIF(c.StatusId = '2', '1', '0') bSubmitted,\n\t\t\t\tDATE_FORMAT(a.LastSubmittedDt, '%d-%b-%Y %h:%i %p')  LastSubmittedDt,\n\t\t\t\tIF(c.StatusId = '3', '1', '0') bAccepted,\n\t\t\t\tDATE_FORMAT(a.AcceptedDt, '%d-%b-%Y %h:%i %p')  AcceptedDt,\n\t\t\t\tIF(c.StatusId = '5', '1', '0') bPublished,\n\t\t\t\tDATE_FORMAT(a.PublishedDt, '%d-%b-%Y %h:%i %p')  PublishedDt\n\t\t\t\tFROM  t_cfm_masterstockstatus a \n\t\t\t\tRIGHT JOIN (SELECT x.FacilityId, x.FacilityCode, x.FacilityName \n\t\t\t\tFROM t_facility x \n\t\t\t\tWHERE x.CountryId = {$country}  {$condition}) b\n\t\t\t\tON a.FacilityId = b.FacilityId AND  MonthId = {$monthId} \n\t\t\t\tAND Year = '{$year}' AND a.CountryId = {$country} \n\t\t\t\tLEFT JOIN t_status c ON a.StatusId = c.StatusId \n\t\t\t\t{$sWhere}\n\t\t\t\t{$sOrder};";
    mysql_query("SET character_set_results=utf8");
    $r = safe_query($sQuery);
    $total = mysql_num_rows($r);
    $h = 1;
    $col = '';
    $i = 1;
    if ($total > 0) {
        $h = 1;
        while ($rec = mysql_fetch_array($r)) {
            $narr = array();
            for ($i = 0; $i < count($aColumns); $i++) {
                if ($aColumns[$i] == "bEntered") {
                    $narr[] = $rec[$aColumns[$i]] == "0" ? '<span class="label label-danger"> No </span>' : '<span class="label label-success"> Yes </span>';
                } else {
                    if ($aColumns[$i] == "bSubmitted") {
                        $narr[] = $rec[$aColumns[$i]] == "0" ? '<span class="label label-danger"> No </span>' : '<span class="label label-success"> Yes </span>';
                    } else {
                        if ($aColumns[$i] == "bAccepted") {
                            $narr[] = $rec[$aColumns[$i]] == "0" ? '<span class="label label-danger">  No  </span>' : '<span class="label label-success">  Yes  </span>';
                            if ($rec[$aColumns[$i]] == "1") {
                                $narr[5] = '<span class="label label-success">  Yes  </span>';
                            }
                        } else {
                            if ($aColumns[$i] == "bPublished") {
                                $narr[] = $rec[$aColumns[$i]] == "0" ? '<span class="label label-danger">  No  </span>' : '<span class="label label-success">  Yes  </span>';
                                if ($rec[$aColumns[$i]] == "1") {
                                    $narr[5] = '<span class="label label-success">  Yes  </span>';
                                    $narr[7] = '<span class="label label-success">  Yes  </span>';
                                }
                            } else {
                                if ($aColumns[$i] != ' ') {
                                    $narr[] = $rec[$aColumns[$i]];
                                }
                            }
                        }
                    }
                }
            }
            $col .= '<tr style="page-break-inside:avoid;">';
            for ($i = 0; $i < count($narr); $i++) {
                $col .= '<td>' . $narr[$i] . '</td>';
            }
            $col .= '</tr>';
        }
        //echo $col;
        $lan = $_POST['lan'];
        if ($lan == 'en-GB') {
            $SITETITLE = SITETITLEENG;
        } else {
            $SITETITLE = SITETITLEFRN;
        }
        $html = '<style>
    </style>
    <head></head>
    <body>
		 <h3 style="text-align:center;"><b>' . $SITETITLE . '</b></h3>
        <h4 style="text-align:center;"><b>' . $ItemGroupName . ' ' . $gTEXT['Facility Reporting Status of'] . ' ' . $CountryName . ' ' . $gTEXT['on'] . ' ' . $MonthName . ',' . $year . '</b></h4>
        <h4>' . $gTEXT['Region'] . ': ' . $RegionName . ', ' . $gTEXT['District'] . ': ' . $DistrictName . ', ' . $gTEXT['Owner Type'] . ': ' . $OwnerTypeName . '</h4>
    </body>';
        $pdf->SetFont('dejavusans', '', 10);
        $pdf->writeHTMLCell(0, 0, 10, 10, $html, '', 0, 0, false, 'C', true);
        $html = '
    <!-- EXAMPLE OF CSS STYLE -->
    <style>
     td{
         height: 6px;
         line-height:3px;
     }
     th{
     height: 20;
    }
    </style>
    <body>    
    <table width="600px" border="0.5" style="margin:0 auto;">
    <tr style="page-break-inside:avoid;">
            <th width="25px" align="center"><b>SL</b></th>
            <th width="60px" align="left"><b>' . $gTEXT['Facility Code'] . '</b></th>
            <th width="70px" align="left"><b>' . $gTEXT['Facility Name'] . '</b></th>
            <th width="60px" align="center"><b>' . $gTEXT['Entered'] . '</b></th>
            <th width="65px" align="left"><b>' . $gTEXT['Entry Date'] . '</b></th>
            <th width="60px" align="center"><b>' . $gTEXT['Submitted'] . '</b></th>
            <th width="65px" align="right"><b>' . $gTEXT['Submitted Date'] . '</b></th>
            <th width="60px" align="center"><b>' . $gTEXT['Accepted'] . '</b></th>
            <th width="65px" align="left"><b>' . $gTEXT['Accepted Date'] . '</b></th>
            <th width="60px" align="center"><b>' . $gTEXT['Published'] . '</b></th>
            <th width="60px" align="right"><b>' . $gTEXT['Published Date'] . '</b></th>
         </tr>' . $col . '</table></body>';
        //echo $html;
        $pdf->SetFont('dejavusans', '', 7);
        $pdf->writeHTMLCell(0, 0, 10, 45, $html, '', 1, 1, false, 'L', true);
        $filePath = SITEDOCUMENT . 'administrator/components/com_jcode/source/report/pdfslice/FacilityReportingStatus.pdf';
        if (file_exists($filePath)) {
            unlink($filePath);
        }
        $pdf->Output('pdfslice/FacilityReportingStatus.pdf', 'F');
        echo trim('FacilityReportingStatus.pdf');
    } else {
        echo 'Processing Error';
    }
}
 function _pdf_create($content = null, $fileName = null)
 {
     // create pdf by tcpdf
     $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor('Nicola Asuni');
     $pdf->SetTitle('TCPDF Example 001');
     $pdf->SetSubject('TCPDF Tutorial');
     $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
     $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128));
     //$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     //$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     $pdf->SetPrintFooter(false);
     $pdf->SetPrintHeader(false);
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     $pdf->setFontSubsetting(true);
     $pdf->SetFont('times', '', 11, '', true);
     $pdf->AddPage();
     $pdf->writeHTMLCell(0, 0, '', '', $content, 0, 1, 0, true, '', true);
     $pdf->Output(IMAGE_LOCATION . $fileName . '.pdf', 'F');
 }
Example #17
0
 public function salary_sso_pdf_export()
 {
     $m = Input::get('m_sso_1');
     $y = Input::get('y_sso_1');
     $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     $pdf->SetPrintHeader(false);
     // set header and footer fonts
     $pdf->setHeaderFont(array('freeserif', 'B', PDF_FONT_SIZE_MAIN));
     $pdf->setFooterFont(array('freeserif', 'B', PDF_FONT_SIZE_DATA));
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     // set margins
     $pdf->SetMargins(10, 15, 10);
     $pdf->SetHeaderMargin(15);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     $pdf->SetFont('freeserif', '', 14, '', true);
     $n = DB::select('select * from s_general_data');
     foreach ($n as $k) {
         $name = $k->name;
     }
     $sql = ' select s.cid, concat(n.pname,"",n.fname," ",n.lname) as name, (s.salary+s.salary_other) as salary, s.salary_sso ';
     $sql .= ' from s_salary_detail s';
     $sql .= ' left join n_datageneral n on n.cid=s.cid';
     $sql .= ' where year(order_date)=' . $y . ' and month(order_date)=' . $m . ' ';
     $data = DB::Select($sql);
     $j = 0;
     $row = 0;
     $sum1 = 0;
     $sum2 = 0;
     foreach ($data as $k) {
         $row++;
         if ($j == 30) {
             $j = 0;
         }
         if ($j == 0) {
             $pdf->AddPage('', 'A4');
             //header
             $pdf->SetFont('freeserif', '', 12, '', true);
             $pdf->SetY(5);
             $pdf->SetX(160);
             $pdf->MultiCell(40, 5, 'สปส.1-10 (ส่วนที่ 2)', 0, 'R', 0, 1, '', '', true);
             $pdf->SetFont('freeserif', 'B', 14, '', true);
             $pdf->MultiCell(190, 5, 'แบบรายงานการแสดงการส่งเงินสมทบ ', 0, 'C', 0, 1, '', '', true);
             $pdf->SetFont('freeserif', '', 13, '', true);
             $pdf->SetY(18);
             $pdf->MultiCell(190, 5, 'การนำส่งเงินสมทบสำหรับค่าจ้างเดิอน ' . $this->get_monthyearThai($m, $y), 0, 'C', 0, 1, '', '', true);
             $pdf->SetFont('freeserif', 'B', 13, '', true);
             $pdf->SetY(30);
             $pdf->SetX(10);
             $pdf->MultiCell(40, 5, 'ชื่อสถานประกอบการ ', 0, 'L', 0, 1, '', '', true);
             $pdf->SetFont('freeserif', '', 13, '', true);
             $pdf->SetY(30);
             $pdf->SetX(50);
             $pdf->MultiCell(70, 5, $name, 0, 'L', 0, 1, '', '', true);
             $pdf->SetFont('freeserif', 'B', 13, '', true);
             $pdf->SetY(30);
             $pdf->SetX(140);
             $pdf->MultiCell(22, 5, 'เลขที่บัญชี', 0, 'L', 0, 1, '', '', true);
             $pdf->SetFont('freeserif', '', 13, '', true);
             $pdf->SetY(30);
             $pdf->SetX(163);
             $pdf->MultiCell(25, 5, '1090000219', 0, 'L', 0, 1, '', '', true);
             $pdf->SetFont('freeserif', 'B', 13, '', true);
             $pdf->SetY(36);
             $pdf->SetX(140);
             $pdf->MultiCell(22, 5, 'สาขา', 0, 'L', 0, 1, '', '', true);
             $pdf->SetFont('freeserif', '', 13, '', true);
             $pdf->SetY(36);
             $pdf->SetX(163);
             $pdf->MultiCell(25, 5, '300311', 0, 'L', 0, 1, '', '', true);
             $linever = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 0, 'color' => array(0, 0, 0));
             $pdf->Line(200, 43, 10, 43, $linever);
             $pdf->Line(200, 50, 10, 50, $linever);
             $pdf->SetFont('freeserif', '', 13, '', true);
             $pdf->SetY(43);
             $pdf->SetX(10);
             $pdf->MultiCell(20, 7, 'ลำดับที่', 0, 'C', 0, 1, '', '', true);
             $pdf->SetY(43);
             $pdf->SetX(30);
             $pdf->MultiCell(40, 7, 'เลขประจำตัวประชาชน', 0, 'C', 0, 1, '', '', true);
             $pdf->SetY(43);
             $pdf->SetX(70);
             $pdf->MultiCell(70, 7, 'ชื่อ-สกุล', 0, 'C', 0, 1, '', '', true);
             $pdf->SetY(43);
             $pdf->SetX(140);
             $pdf->MultiCell(30, 7, 'ค่าจ้าง', 0, 'R', 0, 1, '', '', true);
             $pdf->SetY(43);
             $pdf->SetX(170);
             $pdf->MultiCell(30, 7, 'เงินสมทบ', 0, 'R', 0, 1, '', '', true);
         }
         //end add header
         //detail
         $pdf->SetY(50 + $j * 7.5);
         $pdf->SetX(10);
         $pdf->MultiCell(20, 7, $row, 0, 'R', 0, 1, '', '', true);
         $pdf->SetY(50 + $j * 7.5);
         $pdf->SetX(30);
         $pdf->MultiCell(40, 7, $k->cid, 0, 'C', 0, 1, '', '', true);
         $pdf->SetY(50 + $j * 7.5);
         $pdf->SetX(70);
         $pdf->MultiCell(70, 7, $k->name, 0, 'L', 0, 1, '', '', true);
         $pdf->SetY(50 + $j * 7.5);
         $pdf->SetX(140);
         $pdf->MultiCell(30, 7, number_format($k->salary, 2), 0, 'R', 0, 1, '', '', true);
         $pdf->SetY(50 + $j * 7.5);
         $pdf->SetX(170);
         $pdf->MultiCell(30, 7, number_format($k->salary_sso, 2), 0, 'R', 0, 1, '', '', true);
         //end detail
         $sum1 = $sum1 + $k->salary;
         $sum2 = $sum2 + $k->salary_sso;
         $j++;
     }
     // end data
     //sum all
     $pdf->Line(200, 50 + $j * 7.5, 10, 50 + $j * 7.5, $linever);
     $pdf->Line(200, 56 + $j * 7.5, 10, 57 + $j * 7.5, $linever);
     $pdf->SetFont('freeserif', 'B', 13, '', true);
     $pdf->SetY(50 + $j * 7.5);
     $pdf->SetX(70);
     $pdf->MultiCell(70, 7, 'ยอดรวม', 0, 'C', 0, 1, '', '', true);
     $pdf->SetY(50 + $j * 7.5);
     $pdf->SetX(140);
     $pdf->MultiCell(30, 7, number_format($sum1, 2), 0, 'R', 0, 1, '', '', true);
     $pdf->SetY(50 + $j * 7.5);
     $pdf->SetX(170);
     $pdf->MultiCell(30, 7, number_format($sum2, 2), 0, 'R', 0, 1, '', '', true);
     //end sum all
     //
     $pdf->SetFont('freeserif', '', 13, '', true);
     $pdf->SetY(62 + $j * 7.5);
     $pdf->SetX(70);
     $pdf->MultiCell(90, 5, 'ลงชื่อ.............................................................', 0, 'R', 0, 1, '', '', true);
     $pdf->SetY(62 + $j * 7.5);
     $pdf->SetX(160);
     $pdf->MultiCell(43, 5, 'นายจ้าง/ผู้รับมอบอำนาจ', 0, 'R', 0, 1, '', '', true);
     $pdf->SetY(70 + $j * 7.5);
     $pdf->SetX(70);
     $pdf->MultiCell(90, 5, '(.............................................................)', 0, 'R', 0, 1, '', '', true);
     $pdf->SetY(82 + $j * 7.5);
     $pdf->SetX(70);
     $pdf->MultiCell(120, 5, 'ยื่นแบบวันที่.............เดือน..............................พ.ศ..............', 0, 'C', 0, 1, '', '', true);
     $filename = storage_path() . '/salary_sso_pdf_export.pdf';
     // Response::download($filename);
     $contents = $pdf->output($filename, 'I');
     $headers = array('Content-Type' => 'application/pdf');
     return Response::make($contents, 200, $headers);
 }
Example #18
0
/**
 * Creates the PDF version (downloadable) of the whole feedback produced by the teacher/tutor
 *
 * @param unknown $draft            
 * @param unknown $student            
 * @param unknown $context            
 * @param unknown $cmid            
 * @return boolean
 */
function emarking_create_response_pdf($draft, $student, $context, $cmid)
{
    global $CFG, $DB;
    require_once $CFG->libdir . '/pdflib.php';
    $fs = get_file_storage();
    if (!($submission = $DB->get_record('emarking_submission', array('id' => $draft->submissionid)))) {
        return false;
    }
    if (!($pages = $DB->get_records('emarking_page', array('submission' => $submission->id), 'page ASC'))) {
        return false;
    }
    if (!($emarking = $DB->get_record('emarking', array('id' => $submission->emarking)))) {
        return false;
    }
    $numpages = count($pages);
    $sqlcomments = "SELECT ec.id,\n\t\t\tec.posx,\n\t\t\tec.posy,\n\t\t\tec.rawtext,\n\t\t\tec.pageno,\n\t\t\tgrm.maxscore,\n\t\t\tec.levelid,\n\t\t\tec.width,\n\t\t\tec.colour,\n\t\t\tec.textformat,\n\t\t\tgrl.score AS score,\n\t\t\tgrl.definition AS leveldesc,\n\t\t\tgrc.id AS criterionid,\n\t\t\tgrc.description AS criteriondesc,\n\t\t\tu.id AS markerid, CONCAT(u.firstname,' ',u.lastname) AS markername\n\t\t\tFROM {emarking_comment} ec\n\t\t\tINNER JOIN {emarking_page} ep ON (ec.draft = :draft AND ec.page = ep.id)\n\t\t\tLEFT JOIN {user} u ON (ec.markerid = u.id)\n\t\t\tLEFT JOIN {gradingform_rubric_levels} grl ON (ec.levelid = grl.id)\n\t\t\tLEFT JOIN {gradingform_rubric_criteria} grc ON (grl.criterionid = grc.id)\n\t\t\tLEFT JOIN (\n\t\t\tSELECT grl.criterionid, max(score) AS maxscore\n\t\t\tFROM {gradingform_rubric_levels} grl\n\t\t\tGROUP BY grl.criterionid\n\t\t\t) AS grm ON (grc.id = grm.criterionid)\n\t\t\tWHERE ec.pageno > 0\n\t\t\tORDER BY ec.pageno";
    $params = array('draft' => $draft->id);
    $comments = $DB->get_records_sql($sqlcomments, $params);
    $commentsperpage = array();
    foreach ($comments as $comment) {
        if (!isset($commentsperpage[$comment->pageno])) {
            $commentsperpage[$comment->pageno] = array();
        }
        $commentsperpage[$comment->pageno][] = $comment;
    }
    // Parameters for PDF generation.
    $iconsize = 5;
    $tempdir = emarking_get_temp_dir_path($emarking->id);
    if (!file_exists($tempdir)) {
        emarking_initialize_directory($tempdir, true);
    }
    // Create new PDF document.
    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
    // Set document information.
    $pdf->SetCreator(PDF_CREATOR);
    $pdf->SetAuthor($student->firstname . ' ' . $student->lastname);
    $pdf->SetTitle($emarking->name);
    $pdf->SetSubject('Exam feedback');
    $pdf->SetKeywords('feedback, emarking');
    $pdf->SetPrintHeader(false);
    $pdf->SetPrintFooter(false);
    // Set default header data.
    $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 036', PDF_HEADER_STRING);
    // Set header and footer fonts.
    $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
    $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
    // Set default monospaced font.
    $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
    // Set margins.
    $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
    $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
    $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
    // Set auto page breaks.
    $pdf->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM);
    // Set image scale factor.
    $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
    // Set some language-dependent strings (optional).
    if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
        require_once dirname(__FILE__) . '/lang/eng.php';
        $pdf->setLanguageArray($l);
    }
    // Set font.
    $pdf->SetFont('times', '', 16);
    foreach ($pages as $page) {
        // Add a page.
        $pdf->AddPage();
        // Get the current page break margin.
        $bmargin = $pdf->getBreakMargin();
        // Get current auto-page-break mode.
        $autopagebreak = $pdf->getAutoPageBreak();
        // Disable auto-page-break.
        $pdf->SetAutoPageBreak(false, 0);
        // Set bacground image.
        $pngfile = $fs->get_file_by_id($page->file);
        $imgfile = emarking_get_path_from_hash($tempdir, $pngfile->get_pathnamehash());
        $pdf->Image($imgfile, 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0);
        // Restore auto-page-break status.
        // Set the starting point for the page content.
        $pdf->setPageMark();
        $dimensions = $pdf->getPageDimensions();
        if (isset($commentsperpage[$page->page])) {
            foreach ($commentsperpage[$page->page] as $comment) {
                $content = $comment->rawtext;
                $posx = (int) ((double) $comment->posx * 210);
                $posy = (int) ((double) $comment->posy * 297);
                if ($comment->textformat == 1) {
                    // Text annotation.
                    $pdf->Annotation($posx, $posy, 6, 6, $content, array('Subtype' => 'Text', 'StateModel' => 'Review', 'State' => 'None', 'Name' => 'Comment', 'NM' => 'Comment' . $comment->id, 'T' => $comment->markername, 'Subj' => 'example', 'C' => array(0, 0, 255)));
                    $pdf->Bookmark(get_string('comment', 'mod_emarking') . ' ' . $comment->id, 0, $posy);
                } else {
                    if ($comment->textformat == 2) {
                        $feedback = strlen($comment->rawtext) > 0 ? "\n" . get_string('comment', 'mod_emarking') . ': ' . $comment->rawtext : '';
                        $content = $comment->criteriondesc . ': ' . round($comment->score, 1) . '/' . round($comment->maxscore, 1) . "\n" . $comment->leveldesc . $feedback;
                        // Text annotation.
                        $pdf->Annotation($posx, $posy, 6, 6, $content, array('Subtype' => 'Text', 'StateModel' => 'Review', 'State' => 'None', 'Name' => 'Comment', 'NM' => 'Mark' . $comment->id, 'T' => $comment->markername, 'Subj' => 'grade', 'C' => array(255, 255, 0)));
                        $pdf->Bookmark($comment->criteriondesc, 0, $posy);
                    } else {
                        if ($comment->textformat == 3) {
                            $pdf->Image($CFG->dirroot . "/mod/emarking/img/check.gif", $posx, $posy, $iconsize, $iconsize, '', '', '', false, 300, '', false, false, 0);
                        } else {
                            if ($comment->textformat == 4) {
                                $pdf->Image($CFG->dirroot . "/mod/emarking/img/crossed.gif", $posx, $posy, $iconsize, $iconsize, '', '', '', false, 300, '', false, false, 0);
                            }
                        }
                    }
                }
            }
        }
    }
    $pdffilename = 'response_' . $emarking->id . '_' . $draft->id . '.pdf';
    $pathname = $tempdir . '/' . $pdffilename;
    if (@file_exists($pathname)) {
        unlink($pathname);
    }
    // Close and output PDF document.
    $pdf->Output($pathname, 'F');
    // Copiar archivo desde temp a Area.
    $filerecord = array('contextid' => $context->id, 'component' => 'mod_emarking', 'filearea' => 'response', 'itemid' => $draft->id, 'filepath' => '/', 'filename' => $pdffilename, 'timecreated' => time(), 'timemodified' => time(), 'userid' => $student->id, 'author' => $student->firstname . ' ' . $student->lastname, 'license' => 'allrightsreserved');
    // Si el archivo ya existía entonces lo borramos.
    if ($fs->file_exists($context->id, 'mod_emarking', 'response', $draft->id, '/', $pdffilename)) {
        $previousfile = $fs->get_file($context->id, 'mod_emarking', 'response', $draft->id, '/', $pdffilename);
        $previousfile->delete();
    }
    $fileinfo = $fs->create_file_from_pathname($filerecord, $pathname);
    return true;
}
 function generatePDF($action = 'return', $view)
 {
     if (!in_array($action, ['return', 'dump'])) {
         throw $this->exception('Please provide action as result or dump');
     }
     $pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     // set document information
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor('xEpan ERP');
     // $pdf->SetTitle($this['type']. ' '. $this['document_no']);
     // $pdf->SetSubject($this['type']. ' '. $this['document_no']);
     // $pdf->SetKeywords($this['type']. ' '. $this['document_no']);
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     // set font
     $pdf->SetFont('dejavusans', '', 10);
     //remove header or footer hr lines
     $pdf->SetPrintHeader(false);
     $pdf->SetPrintFooter(false);
     // add a page
     $pdf->AddPage();
     $html = $view->getHTML();
     // echo $html;
     // exit;
     // output the HTML content
     $pdf->writeHTML($html, false, false, true, false, '');
     // set default form properties
     $pdf->setFormDefaultProp(array('lineWidth' => 1, 'borderStyle' => 'solid', 'fillColor' => array(255, 255, 200), 'strokeColor' => array(255, 128, 128)));
     // reset pointer to the last page
     $pdf->lastPage();
     //Close and output PDF document
     switch ($action) {
         case 'return':
             return $pdf->Output(null, 'S');
             break;
         case 'dump':
             return $pdf->Output(null, 'I');
             exit;
             break;
     }
 }
Example #20
0
function izvjestaj_prijave()
{
    require_once 'lib/tcpdf/tcpdf.php';
    global $userid, $conf_files_path;
    // Poslani parametar
    $ispit_termin = intval($_GET['ispit_termin']);
    $predmet = intval($_GET['predmet']);
    $ag = intval($_GET['ag']);
    $student = intval($_GET['student']);
    $nasa_slova = array("č" => "c", "ć" => "c", "đ" => "d", "š" => "s", "ž" => "z", "Č" => "C", "Ć" => "C", "Đ" => "D", "Š" => "S", "Ž" => "Z");
    // Odredjujemo filename
    if ($ispit_termin > 0) {
        $q5 = myquery("select p.id, p.naziv, UNIX_TIMESTAMP(it.datumvrijeme), i.akademska_godina from predmet as p, ispit as i, ispit_termin as it where it.id={$ispit_termin} and it.ispit=i.id and i.predmet=p.id");
        $predmet = mysql_result($q5, 0, 0);
        $ag = mysql_result($q5, 0, 3);
        $filename = "prijave-" . strtr(mysql_result($q5, 0, 1), $nasa_slova) . "-" . date("d-m-Y", mysql_result($q5, 0, 2)) . ".pdf";
    } else {
        if ($predmet > 0) {
            $q5 = myquery("select naziv from predmet where id={$predmet}");
            $filename = "prijave-" . strtr(mysql_result($q5, 0, 0), $nasa_slova) . ".pdf";
        } else {
            $filename = "prijave.pdf";
        }
    }
    $upit = "SELECT o.id, o.ime, o.prezime, o.brindexa, pk.semestar, s.naziv, p.naziv, ag.naziv, ";
    // slijedi datum
    // Stampaj sve studente na terminu
    if ($ispit_termin > 0) {
        // Uzimamo datum termina
        $upit .= "UNIX_TIMESTAMP(it.datumvrijeme) from osoba as o, ispit_termin as it, student_ispit_termin as sit, student_predmet as sp, ponudakursa as pk, ispit as i, studij as s, predmet as p, akademska_godina as ag where sit.ispit_termin=it.id and sit.student=o.id and it.id={$ispit_termin} and o.id=sp.student and sp.predmet=pk.id and it.ispit=i.id and i.predmet=pk.predmet and i.akademska_godina=pk.akademska_godina and pk.studij=s.id and pk.predmet=p.id and pk.akademska_godina=ag.id order by o.prezime, o.ime";
    } else {
        if ($predmet <= 0 || $ag <= 0) {
            biguglyerror("Neispravni parametri");
            print "Da li je moguće da ste odabrali neispravan ili nepostojeći predmet?";
            return;
            // Stampaj jednog studenta
        } else {
            if ($student > 0) {
                // Uzecemo danasnji datum
                $upit .= "UNIX_TIMESTAMP(NOW()) from osoba as o, ponudakursa as pk, studij as s, predmet as p, akademska_godina as ag, student_predmet as sp where o.id={$student} and sp.student={$student} and sp.predmet=pk.id and pk.predmet={$predmet} and pk.akademska_godina={$ag} and p.id={$predmet} and ag.id={$ag} and pk.studij=s.id";
                // Sve studente koji nemaju ocjenu
            } else {
                if ($_GET['tip'] == "bez_ocjene" || $_GET['tip'] == "uslov") {
                    // Naknadno provjeravamo da li ima uslov
                    // Uzecemo danasnji datum
                    $upit .= "UNIX_TIMESTAMP(NOW()) from osoba as o, ponudakursa as pk, studij as s, predmet as p, akademska_godina as ag, student_predmet as sp where o.id=sp.student and sp.predmet=pk.id and pk.predmet={$predmet} and pk.akademska_godina={$ag} and p.id={$predmet} and ag.id={$ag} and pk.studij=s.id and (select count(*) from konacna_ocjena as ko where ko.student=o.id and ko.predmet={$predmet})=0 order by o.prezime, o.ime";
                    // Sve studente koji imaju ocjenu
                } else {
                    if ($_GET['tip'] == "sa_ocjenom") {
                        // Uzecemo danasnji datum
                        $upit .= "UNIX_TIMESTAMP(NOW()) from osoba as o, ponudakursa as pk, studij as s, predmet as p, akademska_godina as ag, student_predmet as sp where o.id=sp.student and sp.predmet=pk.id and pk.predmet={$predmet} and pk.akademska_godina={$ag} and p.id={$predmet} and ag.id={$ag} and pk.studij=s.id and (select count(*) from konacna_ocjena as ko where ko.student=o.id and ko.predmet={$predmet})>0 order by o.prezime, o.ime";
                        // Sve studente na predmetu
                    } else {
                        if ($_GET['tip'] == "sve") {
                            // Uzecemo danasnji datum
                            $upit .= "UNIX_TIMESTAMP(NOW()) from osoba as o, ponudakursa as pk, studij as s, predmet as p, akademska_godina as ag, student_predmet as sp where o.id=sp.student and sp.predmet=pk.id and pk.predmet={$predmet} and pk.akademska_godina={$ag} and p.id={$predmet} and ag.id={$ag} and pk.studij=s.id order by o.prezime, o.ime";
                            // Ovo se može desiti ako se klikne na prikaz pojedinačnog studenta, a nijedan student nije izabran
                            // (npr. ako nijedan student ne sluša predmet)
                        } else {
                            biguglyerror("Neispravni parametri");
                            print "Da li je moguće da ovaj predmet ne sluša niti jedan student?";
                            return;
                        }
                    }
                }
            }
        }
    }
    // PDF inicijalizacija
    $pdf = new TCPDF('P', 'mm', 'a5', true, 'UTF-8', false);
    $pdf->SetCreator("Zamger");
    $pdf->SetTitle('Printanje prijava');
    $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
    $pdf->SetMargins(0, 0, 0);
    $pdf->SetAutoPageBreak(false);
    $pdf->setLanguageArray($l);
    $pdf->SetFont('freesans', 'B', 9);
    $pdf->SetHeaderData("", 0, "", "");
    $pdf->SetPrintHeader(false);
    $pdf->setFooterMargin($fm = 0);
    $pdf->SetPrintFooter(false);
    //set image scale factor
    $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
    //$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO*2.083333);
    $pdf->setJPEGQuality(100);
    // Izvršenje upita
    $q10 = myquery($upit);
    while ($r10 = mysql_fetch_row($q10)) {
        $student = $r10[0];
        $imeprezime = $r10[1] . " " . $r10[2];
        $brind = $r10[3];
        $godStudija = intval(($r10[4] + 1) / 2);
        $odsjek = $r10[5];
        $nazivPr = $r10[6];
        $skolskaGod = $r10[7];
        //	$NastavnikSl=$r10[9];
        $datumIspita = date("d. m. Y.", $r10[8]);
        //	$NastavnikPr=$r10[8];
        //	$datumPrijave=$r10[12];
        $datumPrijave = $datumIspita;
        //	$datumPolaganja=$r10[10];
        $datumPolaganja = $datumIspita;
        //	$datumUsmenog=$r10[13];
        $datumUsmenog = $datumIspita;
        //	$datumDrPar=$r10[14];
        // Ispis nastavnika
        $q33 = myquery("select osoba from angazman where predmet={$predmet} and akademska_godina={$ag} and angazman_status=1");
        if (mysql_num_rows($q33) == 1) {
            // Ako imaju dva odgovorna nastavnika, ne znam kojeg da stavim
            $id_nastavnika = mysql_result($q33, 0, 0);
            $nastavnik = tituliraj($id_nastavnika, $sa_akademskim_zvanjem = false);
        } else {
            $nastavnik = "";
        }
        // Da li ima uslov?
        if ($_GET['tip'] == "uslov") {
            // Dva parcijalna ispita
            $q35 = myquery("select count(*) from ispitocjene as io, ispit as i, komponenta as k where io.student={$student} and io.ispit=i.id and i.predmet={$predmet} and i.akademska_godina={$ag} and i.komponenta=k.id and k.tipkomponente=1 and io.ocjena>=k.prolaz");
            $parcijalnih = mysql_result($q35, 0, 0);
            // Integralni ispiti
            $q37 = myquery("select count(*) from ispitocjene as io, ispit as i, komponenta as k where io.student={$student} and io.ispit=i.id and i.predmet={$predmet} and i.akademska_godina={$ag} and i.komponenta=k.id and k.tipkomponente=2 and io.ocjena>=k.prolaz");
            $integralnih = mysql_result($q37, 0, 0);
            if ($integralnih == 1 || $parcijalnih == 2) {
                // FIXME: ovo radi samo za ETF Bologna standard
                kreirajPrijavu($pdf, $imeprezime, $brind, $godStudija, $odsjek, $nazivPr, $skolskaGod, $datumIspita, $nastavnik);
            }
        } else {
            // Da li je student polozio predmet?
            $q40 = myquery("select ocjena, UNIX_TIMESTAMP(datum_u_indeksu), datum_provjeren from konacna_ocjena where student={$student} and predmet={$predmet}");
            if (mysql_num_rows($q40) > 0) {
                $ocjena = mysql_result($q40, 0, 0);
                $datum_provjeren = mysql_result($q40, 0, 2);
                if ($datum_provjeren) {
                    $datumIspita = $datumPrijave = $datumPolaganja = $datumUsmenog = date("d. m. Y.", mysql_result($q40, 0, 1));
                }
            } else {
                $ocjena = 0;
            }
            kreirajPrijavu($pdf, $imeprezime, $brind, $godStudija, $odsjek, $nazivPr, $skolskaGod, $datumIspita, $ocjena, $nastavnik);
            //		print "$pdf, $imeprezime, $brind, $godStudija, $odsjek, $nazivPr, $skolskaGod, $datumIspita ($r10[8]), $ocjena, $nastavnik<br>\n";
        }
    }
    $pdf->Output($filename, 'I');
}
function generateNumberPatientReport($conn)
{
    global $gTEXT;
    require_once 'tcpdf/tcpdf.php';
    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
    $pdf->SetPrintHeader(false);
    $pdf->SetPrintFooter(false);
    $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
    $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
    $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
    $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
    $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
    if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
        require_once dirname(__FILE__) . '/lang/eng.php';
        $pdf->setLanguageArray($l);
    }
    $pdf->AddPage();
    $pdf->SetFillColor(255, 255, 255);
    //=====================================================National Inventory Table=======================================================
    $monthId = $_POST['MonthId'];
    $year = $_POST['YearId'];
    $countryId = $_POST['CountryId'];
    $itemGroupId = $_POST['ItemGroupId'];
    $currentYearMonth = $_POST['YearId'] . "-" . $_POST['MonthId'] . "-" . "01";
    $monthList = array('1' => 'January', '2' => 'February', '3' => 'March', '4' => 'April', '5' => 'May', '6' => 'June', '7' => 'July', '8' => 'August', '9' => 'September', '10' => 'October', '11' => 'November', '12' => 'December');
    $sql = " SELECT ItemName, AMC, ClStock, FORMAT(MOS,1) MOS, Qty StockOnOrder, FORMAT(Qty/AMC,1) StockOnOrderMOS,\n                     (ifnull(FORMAT(MOS,1),0)+ifnull(FORMAT(Qty/AMC,1),0)) TotalMOS,a.ItemNo,TotalPatient\n                     FROM \n        \t\t\t\t(SELECT\n        \t\t\t\t t_cnm_masterstockstatus.CountryId,\n        \t\t\t\t  t_itemlist.ItemNo,\n        \t\t\t\t  t_itemlist.ItemName,\n        \t\t\t\t  SUM(t_cnm_stockstatus.AMC)    AMC,\n        \t\t\t\t  SUM(t_cnm_stockstatus.ClStock)    ClStock,\n        \t\t\t\t  SUM(t_cnm_stockstatus.MOS)    MOS\n        \t\t\t\tFROM t_cnm_stockstatus\n        \t\t\t\t  INNER JOIN t_cnm_masterstockstatus\n        \t\t\t\t    ON (t_cnm_stockstatus.CNMStockId = t_cnm_masterstockstatus.CNMStockId)\n        \t\t\t\t  INNER JOIN t_itemlist\n        \t\t\t\t    ON (t_cnm_stockstatus.ItemNo = t_itemlist.ItemNo)\n        \t\t\t\tWHERE (t_cnm_masterstockstatus.Year = '{$year}'\n        \t\t\t\t       AND t_cnm_masterstockstatus.MonthId ={$monthId}\n        \t\t\t\t       AND t_cnm_masterstockstatus.CountryId = {$countryId}\n        \t\t\t\t       AND t_cnm_masterstockstatus.ItemGroupId ={$itemGroupId}\n        \t\t\t\t       AND t_cnm_masterstockstatus.StatusId = 5)\n        \t\t\t\tGROUP BY t_cnm_masterstockstatus.CountryId, t_itemlist.ItemNo, t_itemlist.ItemName) a \n        \t\t\t\tLEFT JOIN (SELECT\n        \t\t\t\t    CountryId\n        \t\t\t\t    , ItemNo\n        \t\t\t\t    , SUM(Qty) Qty\n        \t\t\t\tFROM\n        \t\t\t\t    t_agencyshipment\n        \t\t\t\tWHERE (ShipmentDate > CAST('{$currentYearMonth}' AS DATETIME)  AND ShipmentStatusId = 3)\n        \t\t\t\tGROUP BY CountryId, ItemNo) b\n        \t\t\t\tON a.CountryId = b.CountryId AND a.ItemNo = b.ItemNo\n        \t\t\t\tLEFT JOIN (SELECT t_cnm_regimenpatient.CountryId,ItemNo,sum(TotalPatient) as TotalPatient\n        \t\t\t\tfrom t_cnm_regimenpatient\n        \t\t\t\tInner Join t_regimenitems ON t_cnm_regimenpatient.RegimenId=t_regimenitems.RegimenId\n        \t\t\t\tGroup By t_cnm_regimenpatient.CountryId,ItemNo) c ON a.CountryId = c.CountryId AND a.ItemNo = c.ItemNo\n        \t\t\t\t\n        \t\t\t\tHAVING MOS>0 OR StockOnOrderMOS>0 \n        \t\t\t\t;";
    $result = mysql_query($sql, $conn);
    $total = mysql_num_rows($result);
    if ($total > 0) {
        $data = array();
        $f = 0;
        $tblHTML = '';
        while ($rec = mysql_fetch_array($result)) {
            $addmonth = number_format($rec['TotalMOS']);
            $currentYearMonth = $year . "-" . $monthId . "-" . "01";
            $lastYearMonth = date("Y-m-d", strtotime(date("Y-m-d", strtotime($currentYearMonth)) . "{$addmonth} month"));
            $temp = explode('-', $lastYearMonth);
            $strMonth = numberToMonth($temp[1]);
            $lastYearMonth = $strMonth . ', ' . $temp[0];
            $data['SL'][$f] = $f;
            $data['ItemName'][$f] = $rec['ItemName'];
            $data['TotalPatient'][$f] = $rec['TotalPatient'] == 0 ? '' : number_format($rec['TotalPatient']);
            $data['ClStock'][$f] = $rec['ClStock'] == 0 ? '' : number_format($rec['ClStock']);
            $data['MOS'][$f] = $rec['MOS'] == 0 ? '' : number_format($rec['MOS'], 1);
            $data['StockOnOrder'][$f] = $rec['StockOnOrder'] == 0 ? '' : number_format($rec['StockOnOrder']);
            $data['StockOnOrderMOS'][$f] = $rec['StockOnOrderMOS'] == 0 ? '' : number_format($rec['StockOnOrderMOS'], 1);
            $data['TotalMOS'][$f] = $rec['TotalMOS'] == 0 ? '' : number_format($rec['TotalMOS'], 1);
            $tblHTML .= '<tr style="page-break-inside:avoid;">
                            <td align="center" width="30" valign="middle">' . ($data['SL'][$f] + 1) . '</td>  
                            <td align="left" width="150" valign="middle">' . $data['ItemName'][$f] . '</td>
                            <td align="right" width="60" valign="middle">' . $data['TotalPatient'][$f] . '</td>
                            <td align="right" width="60" valign="middle">' . $data['ClStock'][$f] . '</td>
                            <td align="right" width="85" valign="middle">' . $data['MOS'][$f] . '</td>
                            <td align="right" width="60" valign="middle">' . $data['StockOnOrder'][$f] . '</td>
                            <td align="right" width="80" valign="middle">' . $data['StockOnOrderMOS'][$f] . '</td>
                            <td align="right" width="60" valign="middle">' . $data['TotalMOS'][$f] . '</td>
                            <td align="right" width="80" valign="middle">' . $lastYearMonth . '</td>
                            
                    </tr>';
            $f++;
        }
        $year = $_POST['YearId'];
        $MonthName = $_POST['MonthName'];
        $CountryName = $_POST['CountryName'];
        $html = '
        <!-- EXAMPLE OF CSS STYLE -->
        <style>
        </style>
        <body>
            <h4 style="text-align:center;"><b>' . $gTEXT['Number of Patients by Product Report of '] . '  ' . $CountryName . ' on ' . $MonthName . ',' . $year . '</b></h4>
        </body>';
        $pdf->SetFont('dejavusans', '', 10);
        $pdf->writeHTMLCell(0, 0, 8, 10, $html, '', 0, 0, false, 'C', true);
        $html = '
            <!-- EXAMPLE OF CSS STYLE -->
            <style>
             td{
                 height: 6px;
                 line-height:3px;
             }
            </style>
            <body>
            <table width="600px" border="0.5" style="margin:0 auto;">
                <tr>
            		<th width="30" align="center"><b>SL#</b></th>
                    <th width="150" align="left"><b>' . $gTEXT['Product Name'] . '</b></th>
                    <th width="60" align="right"><b>' . $gTEXT['Total Patients'] . '</b></th>
            		<th width="60" align="right"><b>' . $gTEXT['Available Stock'] . '</b></th>
                    <th width="85" align="left"><b>' . $gTEXT['MOS(Available)'] . '</b></th>
                    <th width="60" align="right"><b>' . $gTEXT['Stock on Order'] . '</b></th>
            		<th width="80" align="right"><b>' . $gTEXT['MOS(Ordered)'] . '</b></th>
                    <th width="60" align="left"><b>' . $gTEXT['Total MOS'] . '</b></th>
                    <th width="80" align="right"><b>' . $gTEXT['Projected Date'] . '</b></th>
                    
         	    </tr>' . $tblHTML . '</table></body>';
        $pdf->SetFont('dejavusans', '', 7);
        $pdf->writeHTMLCell(0, 0, 10, 40, $html, '', 1, 1, false, 'L', true);
        $filePath = SITEDOCUMENT . 'administrator/components/com_jcode/source/report/pdfslice/NumberPatientReport.pdf';
        if (file_exists($filePath)) {
            unlink($filePath);
        }
        $pdf->Output('pdfslice/NumberPatientReport.pdf', 'F');
        echo 'NumberPatientReport.pdf';
    } else {
        echo 'Processing Error';
    }
}
function generateFacilityInventoryReport($conn)
{
    global $gTEXT;
    require_once 'tcpdf/tcpdf.php';
    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
    $pdf->SetPrintHeader(false);
    $pdf->SetPrintFooter(false);
    $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
    $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
    $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
    $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
    $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
    if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
        require_once dirname(__FILE__) . '/lang/eng.php';
        $pdf->setLanguageArray($l);
    }
    $pdf->setFontSubsetting(false);
    $pdf->AddPage();
    $pdf->SetFillColor(255, 255, 255);
    //=====================================================Facility Inventory Table=======================================================
    $MonthId = $_REQUEST['MonthId'];
    $YearId = $_REQUEST['YearId'];
    $mosTypeId = $_REQUEST['MosTypeId'];
    $countryId = $_REQUEST['CountryId'];
    $fLevelId = $_REQUEST['FLevelId'];
    $FacilityId = $_REQUEST['FacilityId'];
    $ItemGroupId = $_REQUEST['ItemGroupId'];
    $regionId = $_REQUEST['RegionId'];
    $districtId = $_REQUEST['DistrictId'];
    $ownerTypeId = $_REQUEST['OwnerTypeId'];
    $region = $_REQUEST['Region'];
    $district = $_REQUEST['District'];
    $ownerType = $_REQUEST['OwnerType'];
    $year = $_REQUEST['Year'];
    $CountryName = $_REQUEST['CountryName'];
    $monthName = $_REQUEST['MonthName'];
    $ItemGroupName = $_REQUEST['ItemGroupName'];
    $FacilityName = $_REQUEST['FacilityName'];
    $lan = $_REQUEST['lan'];
    if ($lan == 'en-GB') {
        $SITETITLE = SITETITLEENG;
    } else {
        $SITETITLE = SITETITLEFRN;
    }
    $column_name = array();
    $sQuery1 = "SELECT\n\t\t\t    MosTypeId\n\t\t\t    , MosTypeName\n\t\t\t    , ColorCode\n\t\t\tFROM\n\t\t\t    t_mostype_facility\n\t\t\tWHERE CountryId = {$countryId} AND FLevelId = {$fLevelId}  AND (MosTypeId = {$mosTypeId} OR {$mosTypeId} = 0)\n\t\t\tORDER BY MosTypeId;";
    $rResult1 = mysql_query($sQuery1);
    $output1 = array();
    $col = '';
    while ($row1 = mysql_fetch_array($rResult1)) {
        $output1[] = $row1;
        array_push($column_name, $row1['MosTypeName']);
    }
    $col .= '<tr><th width="180" align="left"><b>' . $gTEXT['Product Name'] . '</b></th>';
    $col .= '<th width="60" align="left"><b>' . $gTEXT['Closing Balance'] . '</b></th>';
    $col .= '<th width="45" align="left"><b>' . $gTEXT['AMC'] . '</b></th>';
    $col .= '<th width="40" align="left"><b>' . $gTEXT['MOS'] . '</b></th>';
    $f = 0;
    for ($f = 0; $f < count($output1); $f++) {
        $col .= '<th width="70" align="right"><b>' . $column_name[$f] . '</b></th>';
    }
    $col .= '</tr>';
    /*
    	$sQuery = "SELECT p.MosTypeId, ItemName, MOS FROM (SELECT
    				    a.ItemNo
    				    , b.ItemName
    				    , a.MOS
    				,(SELECT MosTypeId FROM t_mostype_facility x WHERE CountryId = $countryId AND FLevelId = $fLevelId  AND (MosTypeId = $mosTypeId OR $mosTypeId = 0) AND a.MOS >= x.MinMos AND a.MOS < x.MaxMos) MosTypeId
    				FROM t_cfm_stockstatus a, t_itemlist b,  t_cfm_masterstockstatus c
    				WHERE a.itemno = b.itemno AND a.MOS IS NOT NULL AND a.MonthId = " . $_REQUEST['MonthId'] . " AND a.Year = '" . $_REQUEST['YearId'] . "' AND a.CountryId = " . $_REQUEST['CountryId'] . " AND a.FacilityId = " . $_REQUEST['FacilityId'] . " AND a.ItemGroupId = " . $_REQUEST['ItemGroupId'] . " AND a.CFMStockId = c.CFMStockId" . " AND c.StatusId = 5 " . ") p
    				WHERE (p.MosTypeId = $mosTypeId OR $mosTypeId = 0) 
    				ORDER BY ItemName";
    */
    if ($ownerTypeId == 1 || $ownerTypeId == 2) {
        $sQuery = "SELECT p.MosTypeId, ItemName, MOS ,ClStock,AMC FROM (SELECT\n\t\t\t\t    a.ItemNo, b.ItemName, a.MOS ,a.ClStock,a.AMC\n\t\t\t\t,(SELECT MosTypeId FROM t_mostype_facility x WHERE CountryId = {$countryId} \n                AND FLevelId = {$fLevelId}  AND (MosTypeId = {$mosTypeId} OR {$mosTypeId} = 0) \n                AND a.MOS >= x.MinMos AND a.MOS < x.MaxMos ) MosTypeId\n\t\t\t\tFROM t_cfm_stockstatus a, t_itemlist b,  t_cfm_masterstockstatus c, t_facility g\n\t\t\t\tWHERE a.itemno = b.itemno AND a.MOS IS NOT NULL AND a.MonthId = " . $MonthId . " \n                AND a.Year = '" . $YearId . "' AND a.CountryId = " . $countryId . " \n                AND a.FacilityId = " . $FacilityId . " AND a.ItemGroupId = " . $ItemGroupId . "\n                AND a.CFMStockId = c.CFMStockId" . " AND c.StatusId = 5 " . "\n                AND a.FacilityId=g.FacilityId \n                AND g.OwnerTypeId = {$ownerTypeId} \n                AND  (g.RegionId = {$regionId} OR {$regionId} = 0)\n                AND (g.DistrictId = {$districtId} OR {$districtId} = 0)\n                 ) p\n                \n\t\t\t\tWHERE (p.MosTypeId = {$mosTypeId} OR {$mosTypeId} = 0) \n\t\t\t\tORDER BY ItemName";
    } else {
        $sQuery = "SELECT p.MosTypeId, ItemName, MOS ,ClStock,AMC FROM (SELECT\n\t\t\t\t    a.ItemNo, b.ItemName, a.MOS ,a.ClStock,a.AMC\n\t\t\t\t,(SELECT MosTypeId FROM t_mostype_facility x WHERE CountryId = {$countryId} \n                AND FLevelId = {$fLevelId}  AND (MosTypeId = {$mosTypeId} OR {$mosTypeId} = 0) \n                AND a.MOS >= x.MinMos AND a.MOS < x.MaxMos ) MosTypeId\n\t\t\t\tFROM t_cfm_stockstatus a, t_itemlist b,  t_cfm_masterstockstatus c, t_facility g\n\t\t\t\tWHERE a.itemno = b.itemno AND a.MOS IS NOT NULL AND a.MonthId = " . $MonthId . " \n                AND a.Year = '" . $YearId . "' AND a.CountryId = " . $countryId . " \n                AND a.FacilityId = " . $FacilityId . " AND a.ItemGroupId = " . $ItemGroupId . "\n                AND a.CFMStockId = c.CFMStockId" . " AND c.StatusId = 5 " . "\n                AND a.FacilityId=g.FacilityId\n                AND g.AgentType = {$ownerTypeId} \n                AND  (g.RegionId = {$regionId} OR {$regionId} = 0)\n                AND (g.DistrictId = {$districtId} OR {$districtId} = 0) ) p\n                \n\t\t\t\tWHERE (p.MosTypeId = {$mosTypeId} OR {$mosTypeId} = 0) \n\t\t\t\tORDER BY ItemName";
    }
    //echo $sQuery;
    mysql_query("SET character_set_results=utf8");
    $rResult = mysql_query($sQuery);
    $aData = array();
    $total = mysql_num_rows($rResult);
    if ($total > 0) {
        while ($row = mysql_fetch_array($rResult)) {
            $tmpRow = array();
            /*	foreach ($output1 as $rowMosType) {
            			if ($rowMosType['MosTypeId'] == $row['MosTypeId']) {
            				//$tmpRow[] = '<span class="glyphicon glyphicon-ok-circle" style="color:' . $rowMosType['ColorCode'] . ';font-size:2em;"></span>';
            				$tmpRow[] = '<i class="fa fa-check-circle fa-lg" style="color:' . $rowMosType['ColorCode'] . ';font-size:2.5em;"></i>';
            
            			} else
            				$tmpRow[] = '';
            		}
            		array_unshift($tmpRow, $row['ItemName'], number_format($row['MOS'], 1));
            		$aData[] = $tmpRow;*/
            $col .= '<tr style="page-break-inside:avoid;">
			           <td>' . $row['ItemName'] . '</td>
					   <td>' . $row['ClStock'] . '</td>
					   <td>' . $row['AMC'] . '</td>
			         <td> ' . number_format($row['MOS'], 1) . '</td>  ';
            foreach ($output1 as $rowMosType) {
                if ($rowMosType['MosTypeId'] == $row['MosTypeId']) {
                    /*$tmpRow[] = '<i class="fa fa-check-circle fa-lg" style="color:' . $rowMosType['ColorCode'] . ';font-size:2.5em;"></i>';
                    		$col.= '<td><span class="fa fa-check-circle fa-lg" style="color:' . $rowMosType['ColorCode'] . ';font-size:2.5em;text-align:center;"></span></td>';
                    		*/
                    $tmpRow[] = $rowMosType['ColorCode'];
                    $col .= '<td style="background-color:' . $rowMosType['ColorCode'] . '"></td>';
                } else {
                    $col .= '<td> </td>';
                }
            }
            array_unshift($tmpRow, $row['ItemName'], number_format($row['MOS'], 1));
            $aData[] = $tmpRow;
            $col .= ' </tr>';
        }
        $ItemGroupName = $_REQUEST['ItemGroupName'];
        $FacilityName = $_REQUEST['FacilityName'];
        $html_head = '
            <!-- EXAMPLE OF CSS STYLE -->
            <style>
            p {
              line-height: 0.1px;
            }
            </style>
                <body>
					<p><h3 style="text-align:center;"><b>' . $SITETITLE . '</b></h3></p></br>
                    <p><h4 style="text-align:center;"><b>' . $ItemGroupName . ' ' . $gTEXT['Facility Inventory Control Report of '] . '  ' . $CountryName . ' ' . $gTEXT['on'] . ' ' . $monthName . ',' . $year . '</b></h4></p></br>
					<p><h4 style="text-align:center;"><b>' . $gTEXT['Region'] . ': ' . $region . ', ' . $gTEXT['District'] . ': ' . $district . ', ' . $gTEXT['Report By'] . ': ' . $ownerType . '</b></h4></p></br>
                    <p style="text-align:center;"><h4><b>' . $gTEXT['Facility Name'] . ': ' . $FacilityName . '</b><h4></p></br>
                </body>';
        $pdf->SetFont('dejavusans', '', 10);
        $pdf->writeHTMLCell(0, 0, 6, 10, $html_head, '', 0, 0, false, 'C', true);
        $html = '<head>
			  <link rel="stylesheet" href="' . $jBaseUrl . 'templates/protostar/css/template.css" type="text/css" /> 
			  
			 <link href="' . $jBaseUrl . 'templates/protostar/endless/bootstrap/css/bootstrap.min.css" rel="stylesheet">
			 <link href="' . $jBaseUrl . 'templates/protostar/endless/css/font-awesome.min.css" rel="stylesheet">
			 <link href="' . $jBaseUrl . 'templates/protostar/endless/css/pace.css" rel="stylesheet">	
			 <link href="' . $jBaseUrl . 'templates/protostar/endless/css/colorbox/colorbox.css" rel="stylesheet">
			 <link href="' . $jBaseUrl . 'templates/protostar/endless/css/morris.css" rel="stylesheet"/> 	
             <link href="' . $jBaseUrl . 'templates/protostar/endless/css/endless.min.css" rel="stylesheet"> 
	        <link href="' . $jBaseUrl . 'templates/protostar/endless/css/endless-skin.css" rel="stylesheet">
	
	    	<link href="' . $jBaseUrl . 'templates/protostar/endless/bootstrap/css/font-halflings.css" rel="stylesheet">
	    	
			<link href="' . $jBaseUrl . 'administrator/components/com_jcode/source/css/custom.css" rel="stylesheet"/>
			</head>
            <!-- EXAMPLE OF CSS STYLE -->
            <style>
             td{
                 height: 6px;
                 line-height:3px;
             }
             th{
             height: 20;
            }
            </style>
            <body>
            <table width="600px" border="0.5" style="margin:0 auto;">' . $col . '</table></body>';
        $pdf->SetFont('dejavusans', '', 7);
        $pdf->writeHTMLCell(0, 0, 5, 45, $html, '', 1, 1, false, 'L', true);
        $filePath = SITEDOCUMENT . 'administrator/components/com_jcode/source/report/pdfslice/FacilityInventoryReport.pdf';
        if (file_exists($filePath)) {
            unlink($filePath);
        }
        $pdf->Output('pdfslice/FacilityInventoryReport.pdf', 'F');
        echo 'FacilityInventoryReport.pdf';
    } else {
        echo 'Processing Error';
    }
}
Example #23
0
function genPDF($proj, $local = false)
{
    // create new PDF document
    $size = array(8.5, 11);
    $pdf = new TCPDF("l", "in", $size, true, "UTF-8", false);
    // set document information
    $pdf->SetCreator(PDF_CREATOR);
    $pdf->SetAuthor("EMu Mover");
    $pdf->SetTitle("Project Title");
    $pdf->SetSubject("Project");
    $pdf->SetKeywords("EMu, Project");
    $pdf->SetPrintHeader(false);
    $pdf->SetPrintFooter(false);
    $pdf->SetMargins(0.5, 0.5, 0.5, false);
    setSpacing($pdf);
    // set font
    $pdf->SetFont("helvetica", "", 10);
    // add a page
    $pdf->AddPage();
    $pdf->SetAutoPageBreak(TRUE, 0);
    $html = "";
    $css = file_get_contents("report.css");
    $style = "<style type=\"text/css\">\n{$css}\n</style>";
    $w = $pdf->getPageWidth();
    $h = $pdf->getPageHeight();
    $m = $pdf->getMargins();
    $pdf->setCellPaddings(0.05, 0.1, 0.05, 0);
    $pdf->setCellHeightRatio(0.4);
    $w -= $m['left'] + $m['right'];
    $h -= $m['top'] + $m['bottom'];
    $sixth = $w / 6;
    $sixth = floor($sixth * 100.0) / 100.0;
    $objs = generatePDFcells($proj);
    addHeaderRow($pdf);
    //Get row heights
    $heights = array();
    foreach ($objs as $k1 => $obj) {
        $c = 0;
        $lh = 0;
        $y = $pdf->GetY();
        foreach ($obj as $k2 => $cell) {
            $cellWidth = $sixth;
            $x = $pdf->GetX();
            if ($c == 1) {
                $cellWidth = 3 * $sixth;
            }
            $pdf->writeHTMLcell($cellWidth, 0, $x, $y, $style . $cell, 0, 0, 0, 1, '', 1);
            $c++;
            $tlh = $pdf->getLastH();
            //$objs[$k1][$k2] .= "<p>$tlh</p>";
            if ($tlh > $lh) {
                $lh = $tlh;
            }
        }
        $heights[$k1] = $lh;
        $pdf->deletePage($pdf->getPage());
        $pdf->AddPage();
    }
    addIntro($pdf, $proj);
    $y = $pdf->GetY();
    addHeaderRow($pdf);
    //Now actually create the PDF
    foreach ($objs as $k1 => $obj) {
        $y = $pdf->GetY();
        if (isset($heights[$k1])) {
            if ($y + $heights[$k1] >= $h) {
                $pdf->AddPage();
                addHeaderRow($pdf);
            }
        }
        $c = 0;
        $lh = 0;
        $y = $pdf->GetY();
        foreach ($obj as $k2 => $cell) {
            $cellWidth = $sixth;
            $x = $pdf->GetX();
            if ($c == 1) {
                $cellWidth = 3 * $sixth;
            }
            $pdf->writeHTMLcell($cellWidth, $heights[$k1], $x, $y, $style . $cell, 'LTRB', 0, 0, 1, '', 1);
            $c++;
        }
        $pdf->SetY($y + $heights[$k1]);
    }
    if ($proj) {
        $info = getProjectInfo($proj);
        if ($local) {
            $fname = $info['title'] . ".pdf";
            $pdfpath = sys_get_temp_dir() . "/" . $info['title'] . "--" . date("Y-m-d") . ".pdf";
            $pdf->Output($pdfpath, "F");
            return $pdfpath;
        } else {
            header("Content-type: application/pdf");
            $val = $pdf->Output($info['title'] . "-" . date("Y-m-d") . ".pdf", "I");
            print $val;
        }
        return true;
        exit;
    } else {
        print "{$style}";
        var_dump($objs);
        return false;
    }
}
function generateShipmentReport($conn)
{
    global $gTEXT;
    require_once 'tcpdf/tcpdf.php';
    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
    $pdf->SetPrintHeader(false);
    $pdf->SetPrintFooter(false);
    $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
    $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
    $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
    $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
    $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
    if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
        require_once dirname(__FILE__) . '/lang/eng.php';
        $pdf->setLanguageArray($l);
    }
    $pdf->AddPage();
    $pdf->SetFillColor(255, 255, 255);
    //=====================================================National Inventory Table=======================================================
    /*	$months = $_POST['MonthNumber']; 
        $monthIndex = date("n");
        $yearIndex = date("Y");
        settype($yearIndex, "integer");    
        if ($monthIndex == 1){
    		$monthIndex = 12;				
    		$yearIndex = $yearIndex - 1;				
    	}else{
    	    $monthIndex = $monthIndex - 1;
    	}
        $months = $months - 1;  
          	   
        $currentYearMonth = $yearIndex."-0".$monthIndex."-"."01";    
        $currentYearMonth = date('Y-m-d', strtotime($currentYearMonth));
    	$lastYearMonth = date("Y-m-d", strtotime(date("Y-m-d", strtotime($currentYearMonth)) . "-".$months." month"));  
        */
    $StartMonthId = $_POST['StartMonthId'];
    $StartYearId = $_POST['StartYearId'];
    $EndMonthId = $_POST['EndMonthId'];
    $EndYearId = $_POST['EndYearId'];
    if ($_POST['MonthNumber'] != 0) {
        $months = $_POST['MonthNumber'];
        $monthIndex = date("m");
        $yearIndex = date("Y");
        settype($yearIndex, "integer");
        $startDate = $yearIndex . "-" . $monthIndex . "-" . "01";
        $startDate = date('Y-m-d', strtotime($startDate));
        $months--;
        $endDate = date("Y-m-d", strtotime(date("Y-m-d", strtotime($startDate)) . "+" . $months . " month"));
    } else {
        $startDate = $StartYearId . "-" . $StartMonthId . "-" . "01";
        $startDate = date('Y-m-d', strtotime($startDate));
        $d = cal_days_in_month(CAL_GREGORIAN, $EndMonthId, $EndYearId);
        $endDate = $EndYearId . "-" . $EndMonthId . "-" . $d;
        $endDate = date('Y-m-d', strtotime($endDate));
    }
    $CountryId = $_POST['ACountryId'];
    $AFundingSourceId = $_POST['AFundingSourceId'];
    $ASStatusId = $_POST['ASStatusId'];
    $ItemGroup = $_POST['ItemGroup'];
    $OwnerTypeId = $_POST['OwnerType'];
    if ($AFundingSourceId) {
        $AFundingSourceId = " AND a.FundingSourceId = '" . $AFundingSourceId . "' ";
    }
    if ($ASStatusId) {
        $ASStatusId = " AND a.ShipmentStatusId = '" . $ASStatusId . "' ";
    }
    if ($ItemGroup) {
        $ItemGroup = " AND e.ItemGroupId = '" . $ItemGroup . "' ";
    }
    if ($OwnerTypeId) {
        $OwnerTypeId = " AND f.OwnerTypeId = '" . $OwnerTypeId . "' ";
    }
    $sLimit = "";
    if (isset($_POST['iDisplayStart'])) {
        $sLimit = " LIMIT " . mysql_real_escape_string($_POST['iDisplayStart']) . ", " . mysql_real_escape_string($_POST['iDisplayLength']);
    }
    $sOrder = "";
    if (isset($_POST['iSortCol_0'])) {
        $sOrder = " ORDER BY  ";
        for ($i = 0; $i < mysql_real_escape_string($_POST['iSortingCols']); $i++) {
            $sOrder .= fnColumnToField_agencyShipment(mysql_real_escape_string($_POST['iSortCol_' . $i])) . "" . mysql_real_escape_string($_POST['sSortDir_' . $i]) . ", ";
        }
        $sOrder = substr_replace($sOrder, "", -2);
    }
    $sWhere = "";
    if ($_POST['sSearch'] != "") {
        $sWhere = "  AND (a.ItemNo LIKE '%" . mysql_real_escape_string($_POST['sSearch']) . "%'  OR " . " e.ItemName LIKE '%" . mysql_real_escape_string($_POST['sSearch']) . "%' OR " . " c.ShipmentStatusDesc LIKE '%" . mysql_real_escape_string($_POST['sSearch']) . "%')  ";
    }
    $sql = "SELECT SQL_CALC_FOUND_ROWS AgencyShipmentId, a.FundingSourceId, d.FundingSourceName, a.ShipmentStatusId, c.ShipmentStatusDesc, a.CountryId, \n            b.CountryName, a.ItemNo, e.ItemName, a.ShipmentDate, a.Qty, a.OwnerTypeId, f.OwnerTypeName \n\t\t\tFROM t_agencyshipment as a\n            INNER JOIN t_country b ON a.CountryId = b.CountryId\n            INNER JOIN t_shipmentstatus c ON a.ShipmentStatusId = c.ShipmentStatusId\n            INNER JOIN t_fundingsource d ON a.FundingSourceId= d.FundingSourceId\n            INNER JOIN t_itemlist e ON a.ItemNo = e.ItemNo\n            INNER JOIN t_owner_type f ON a.OwnerTypeId = f.OwnerTypeId \n            WHERE CAST(a.ShipmentDate AS DATETIME) BETWEEN CAST('{$startDate}' AS DATETIME) AND CAST('{$endDate}' AS DATETIME) \n            AND (a.CountryId = " . $CountryId . " OR " . $CountryId . " = 0) \n            " . $AFundingSourceId . " " . $ASStatusId . " " . $ItemGroup . " " . $OwnerTypeId . "\n\t\t\t{$sWhere} {$sOrder} {$sLimit} ";
    $result = mysql_query($sql, $conn);
    $total = mysql_num_rows($result);
    $i = 0;
    $f = 0;
    $GrandtotalQty = 0;
    $SubtotalQty = 0;
    $OldCountry = ' ';
    $NewCountry = ' ';
    $serial = 1;
    $tblHTML = '';
    if ($total > 0) {
        /* $data=array();
           $f=0; 
           $tblHTML='';
           $tempGroupId='';*/
        while ($rec = mysql_fetch_array($result)) {
            $ItemName = trim(preg_replace('/\\s+/', ' ', addslashes($rec['ItemName'])));
            $date = strtotime($rec['ShipmentDate']);
            $newdate = date('d/m/Y', $date);
            if ($OldCountry == ' ') {
                $OldCountry = addslashes($rec['CountryName']);
            }
            $NewCountry = addslashes($rec['CountryName']);
            if ($OldCountry != $NewCountry) {
                $tblHTML .= '<tr >
                       <td style="background-color:#FE9929;border-radius:2px;align:center; font-size:12px;"colspan="5">Sub Total</td>
                       <td style="background-color:#FE9929;border-radius:2px;text-align:right; font-size:12px;">' . number_format($SubtotalQty) . '</td>
    				</tr>';
                $tblHTML .= '<tr >
                     <td style="background-color:#DAEF62;border-radius:2px;align:center; font-size:12px;"colspan="6">' . $NewCountry . '</td>
                     
                     </tr>';
                $tempGroupId = $rec['CountryName'];
                $OldCountry = $NewCountry;
                $SubtotalQty = $rec['Qty'];
            } else {
                $SubtotalQty += $rec['Qty'];
            }
            if ($tempGroupId != $rec['CountryName']) {
                $tblHTML .= '<tr >
	                     <td style="background-color:#DAEF62;border-radius:2px;  align:center; font-size:12px;" colspan="6">' . $rec['CountryName'] . '</td>
	                   </tr>';
                $tempGroupId = $rec['CountryName'];
            }
            $tblHTML .= '<tr>
                             <td style="text-align: center;">' . $serial++ . '</td>
                             <td style="text-align:left;">' . $ItemName . '</td>
                	         <td style="text-align:left;">' . addslashes($rec['FundingSourceName']) . '</td>
                             <td style="text-align:left;">' . addslashes($rec['ShipmentStatusDesc']) . '</td>
                	         <td style="text-align:right;">' . $newdate . '</td>
                	         <td style="text-align:right;">' . number_format(addslashes($rec['Qty'])) . '</td>
        	           </tr>';
            $GrandtotalQty += $rec['Qty'];
            $tblHTML .= '';
            if ($total == $i + 1) {
                $tblHTML .= '<tr >
                       <td style="background-color:#FE9929;border-radius:2px;  align:center; font-size:12px;" colspan="5">Sub Total</td>
                       <td style="background-color:#FE9929;border-radius:2px;  text-align:right; font-size:12px;" ">' . number_format($SubtotalQty) . '</td>
                	</tr>';
                $tblHTML .= '<tr >
                       <td style="background-color:#FE9929;border-radius:2px;  align:center; font-size:12px;" colspan="5">Sub Total</td>
                       <td style="background-color:#FE9929;border-radius:2px;  text-align:right; font-size:12px;" ">' . number_format($SubtotalQty) . '</td>
                	</tr>';
                $tblHTML .= '<tr >
                       <td style="background-color:#50ABED;border-radius:2px;  align:center; font-size:12px;" colspan="5">Grand Total</td>
                       <td style="background-color:#50ABED;border-radius:2px;  text-align:right; font-size:12px;" ">' . number_format($GrandtotalQty) . '</td>
                	</tr>';
                $tblHTML .= '<tr >
                       <td style="background-color:#50ABED;border-radius:2px;  align:center; font-size:12px;" colspan="5">Grand Total</td>
                       <td style="background-color:#50ABED;border-radius:2px;  text-align:right; font-size:12px;" ">' . number_format($GrandtotalQty) . '</td>
                	</tr>';
            }
            $i++;
        }
        //$months = $_POST['MonthNumber'];
        $months = $_POST['MonthNumber'];
        $CountryName = $_POST['CountryName'];
        $FundingSourceName = $_POST['FundingSourceName'];
        $ItemGroupName = $_POST['ItemGroupName'];
        $ASStatusName = $_POST['ASStatusName'];
        $OwnerTypeName = $_POST['OwnerTypeName'];
        $html = '
        <!-- EXAMPLE OF CSS STYLE -->
        <style>
        p {
          line-height: 0.5px;
        }
        
        </style>
            <body>
                <p style="text-align:center;"><h4 ><b>' . $gTEXT['Shipment Reports'] . '  of ' . $CountryName . ' ' . $gTEXT['from'] . ' ' . date('M,Y', strtotime($startDate)) . ' ' . $gTEXT['to'] . ' ' . date('M,Y', strtotime($endDate)) . '</b></h4></p>
                <p style="text-align:center;"><h5><b>' . $FundingSourceName . ' - ' . $ASStatusName . ' - ' . $ItemGroupName . ' - ' . $OwnerTypeName . '</b><h5></p>
            </body>';
        $pdf->SetFont('dejavusans', '', 10);
        $pdf->writeHTMLCell(0, 0, 8, 10, $html, '', 0, 0, false, 'C', true);
        //date('M,Y', strtotime($StartYearMonth)), date('M,Y', strtotime($EndYearMonth))
        $html = '
            <!-- EXAMPLE OF CSS STYLE -->
            <style>
             td{
                 height: 6px;
                 line-height:3px;
             }
             th{
                height:20;
                font-size:10px;
            }
            </style>
            <body>
            <table width="600px" border="0.5" style="margin:0 auto;">
                <tr>
            		<th width="30" align="center"><b>SL#</b></th>
                    <th width="250" align="left"><b>' . $gTEXT['Product Name'] . '</b></th>
                    <th width="100" align="left"><b>' . $gTEXT['Funding Source'] . '</b></th>
            		<th width="90" align="left"><b>' . $gTEXT['Shipment Status'] . '</b></th>
                    <th width="100" align="right"><b>' . $gTEXT['Shipment Date'] . '</b></th>
                    <th width="90" align="right"><b>' . $gTEXT['Quantity'] . '</b></th>                    
         	    </tr>' . $tblHTML . '</table></body>';
        //echo $tblHTML;
        $pdf->SetFont('dejavusans', '', 7);
        $pdf->writeHTMLCell(0, 0, 10, 40, $html, '', 1, 1, false, 'L', true);
        $filePath = SITEDOCUMENT . 'administrator/components/com_jcode/source/report/pdfslice/ShipmentReport.pdf';
        if (file_exists($filePath)) {
            unlink($filePath);
        }
        $pdf->Output('pdfslice/ShipmentReport.pdf', 'F');
        echo 'ShipmentReport.pdf';
    } else {
        echo 'Processing Error';
    }
}
function generateCountryProfileReport($conn)
{
    global $gTEXT;
    require_once 'tcpdf/tcpdf.php';
    //require_once('fpdf/fpdi.php');
    //$pdf = new FPDI();
    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
    $pdf->SetPrintHeader(false);
    $pdf->SetPrintFooter(false);
    $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
    $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
    $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
    $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
    $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
    if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
        require_once dirname(__FILE__) . '/lang/eng.php';
        $pdf->setLanguageArray($l);
    }
    $pdf->AddPage();
    $pdf->SetFillColor(255, 255, 255);
    //=====================================================Country profile parameters table=======================================================
    $CountryId = $_REQUEST['CountryId'];
    $CountryName = $_REQUEST['CountryName'];
    $Year = $_REQUEST['Year'];
    if ($_REQUEST['lan'] == 'en-GB') {
        $PLang = 'ParamName';
    } else {
        $PLang = 'ParamNameFrench';
    }
    if (!empty($CountryId) && !empty($Year)) {
        $sql = "SELECT  a.YCProfileId, a.YCValue, Year, a.CountryId, a.ParamId, {$PLang} ParamName \n    \t\t\t\tFROM t_ycprofile a\n                    \n                    INNER JOIN t_cprofileparams c ON a.ParamId = c.ParamId\n                    WHERE a.CountryId = " . $_REQUEST['CountryId'] . " \n                    AND a.Year = " . $_REQUEST['Year'] . " \n                    AND a.ParamId NOT IN (5,7)\n                    Order By a.ParamId ";
    }
    mysql_query("SET character_set_results=utf8");
    $result = mysql_query($sql, $conn);
    //$total = mysql_num_rows($result);
    $data = array();
    $f = 0;
    $tblHTML = '';
    while ($rec = mysql_fetch_array($result)) {
        $data['SL'][$f] = $f;
        $data['ParamName'][$f] = $rec['ParamName'];
        if ($rec['YCValue'] == '') {
            $rec['YCValue'] == '';
        } else {
            if (is_numeric($rec['YCValue'])) {
                $rec['YCValue'] = number_format($rec['YCValue']);
            } else {
                $rec['YCValue'] = $rec['YCValue'];
            }
        }
        $data['YCValue'][$f] = $rec['YCValue'];
        $tblHTML .= '<tr style="page-break-inside:avoid;">
                            <td align="center" width="50" valign="middle">' . ($data['SL'][$f] + 1) . '</td>  
                            <td align="left" width="300" valign="middle">' . $data['ParamName'][$f] . '</td>
                            <td align="right" width="280" valign="middle">' . $data['YCValue'][$f] . '</td></tr>';
        $f++;
    }
    /*  $html = '
        <!-- EXAMPLE OF CSS STYLE -->
        <style>
        </style>
        <body>
            <h4 style="text-align:center;"><b>'.$gTEXT['Country Profile of'].'  '.$CountryName.' '.$Year.'</b></h4>
            <h4 style="text-align:left;"><b>'.$gTEXT['Parameter List'].'</b></h4>
        </body>';
        $pdf->SetFont('dejavusans', '', 10);
        $pdf->writeHTMLCell(0, 0, 10, 5, $html, '', 0, 0, false, 'C', true);*/
    $html = '
            <!-- EXAMPLE OF CSS STYLE -->
            <style>
             td{
                 height: 6px;
                 line-height:3px;
             }
             th{
                height:20;
                font-size:10px;
            }
            </style>
            <body>
            <div>
            <p><h4 style="text-align:center;font-size:12px;"><b>' . $gTEXT['Country Profile of'] . '  ' . $CountryName . ' ' . $Year . '</b></h4><p></br>
            <h4 style="text-align:center;font-size:12px;"><b>' . $gTEXT['Parameter List'] . '</b></h4>
            <table width=auto border="0.5" style="margin:0 auto;">
                <tr>
            		<th width="50" align="center"><b>SL#</b></th>
                    <th width="300" align="left"><b>' . $gTEXT['Parameter Name'] . '</b></th>
                    <th width="280" align="right"><b>' . $gTEXT['Value'] . '</b></th>
         	    </tr>' . $tblHTML . '</table></body></div>';
    $pdf->SetFont('dejavusans', '', 7);
    $pdf->writeHTMLCell(0, 0, 12, 5, $html, '', 1, 1, false, 'L', true);
    $pdf->endPage();
    //==================================================Regiment Patients Table======================================================//
    $CountryId = $_REQUEST['CountryId'];
    $CountryName = $_REQUEST['CountryName'];
    $Year = $_REQUEST['Year'];
    $aColumns = array('SL', 'RegimenName', 'PatientCount', 'FormulationName');
    $aColumns2 = array('SL', 'RegimenName', 'PatientCount', 'FormulationName');
    /* if($_REQUEST['lan'] == 'fr-FR'){
              $aColumns = array('SL', 'RegimenName', 'PatientCount', 'FormulationNameFrench');
              $aColumns2 = array('SL', 'RegimenName', 'PatientCount', 'FormulationNameFrench');
       }else{
              $aColumns = array('SL', 'RegimenName', 'PatientCount', 'FormulationName');
              $aColumns2 = array('SL', 'RegimenName', 'PatientCount', 'FormulationName');
       }*/
    if ($_REQUEST['lan'] == 'fr-FR') {
        $FLang = 'FormulationNameFrench';
    } else {
        $FLang = 'FormulationName';
    }
    $sIndexColumn = "YearlyRegPatientId";
    /* DB table to use */
    $sTable = "t_yearly_country_regimen_patient ";
    // Joins
    $sJoin = 'INNER JOIN t_regimen ON t_yearly_country_regimen_patient.RegimenId = t_regimen.RegimenId ';
    $sJoin .= 'INNER JOIN t_formulation ON t_regimen.FormulationId = t_formulation.FormulationId ';
    /*
     * Paging
     */
    $sLimit = "";
    if (isset($_REQUEST['iDisplayStart']) && $_REQUEST['iDisplayLength'] != '-1') {
        $sLimit = "LIMIT " . intval($_REQUEST['iDisplayStart']) . ", " . intval($_REQUEST['iDisplayLength']);
    }
    /*
     * Ordering
     */
    $sOrder = "";
    if (isset($_REQUEST['iSortCol_0'])) {
        $sOrder = "ORDER BY  ";
        for ($i = 0; $i < intval($_REQUEST['iSortingCols']); $i++) {
            if ($_REQUEST['bSortable_' . intval($_REQUEST['iSortCol_' . $i])] == "true") {
                $sOrder .= "" . $aColumns[intval($_REQUEST['iSortCol_' . $i])] . " " . ($_REQUEST['sSortDir_' . $i] === 'asc' ? 'asc' : 'desc') . ", ";
            }
        }
        $sOrder = substr_replace($sOrder, "", -2);
        if ($sOrder == "ORDER BY") {
            $sOrder = "";
        }
    }
    $sWhere = "";
    /* Individual column filtering */
    for ($i = 0; $i < count($aColumns); $i++) {
        if (isset($_REQUEST['bSearchable_' . $i]) && $_REQUEST['bSearchable_' . $i] == "true" && $_REQUEST['sSearch'] != '') {
            if ($sWhere == "") {
                $sWhere = "WHERE ";
            } else {
                $sWhere .= " OR ";
            }
            $sWhere .= "" . $aColumns[$i] . " LIKE '%" . mysql_real_escape_string($_REQUEST['sSearch']) . "%' ";
        }
    }
    /*User Data Filtering*/
    $bUserFilter = true;
    if ($bUserFilter) {
        if ($sWhere == "") {
            $sWhere = "WHERE ";
        } else {
            $sWhere .= " AND ";
        }
        $sWhere .= "t_yearly_country_regimen_patient.CountryId = " . $_REQUEST['CountryId'] . " AND t_yearly_country_regimen_patient.Year = " . $_REQUEST['Year'];
    }
    $bUseSL = true;
    $serial = '';
    /* $sQuery = "SELECT  " . str_replace(" , ", " ", implode(", ", $aColumns)) . "
    			FROM   $sTable
    			$sJoin
    			$sWhere
    			$sOrder
    			$sLimit
    			";*/
    $sQuery = "SELECT SQL_CALC_FOUND_ROWS @rank:=@rank+1 AS SL, RegimenName, PatientCount, {$FLang} FormulationName\n                FROM t_yearly_country_regimen_patient\n                INNER JOIN t_regimen ON t_yearly_country_regimen_patient.RegimenId = t_regimen.RegimenId \n                INNER JOIN t_formulation ON t_regimen.FormulationId = t_formulation.FormulationId\n                WHERE t_yearly_country_regimen_patient.CountryId = " . $_REQUEST['CountryId'] . " \n                AND t_yearly_country_regimen_patient.Year = " . $_REQUEST['Year'] . "\n                ORDER BY t_formulation.FormulationId asc";
    // echo $sQuery;mysql_query("SET character_set_results=utf8");FormulationName asc,RegimenName";
    mysql_query("SET character_set_results=utf8");
    $rResult = mysql_query($sQuery);
    $j = 1;
    $tempGroupId = '';
    $col = '';
    while ($aRow = mysql_fetch_array($rResult)) {
        // $aRow['RegimenName']=$regname;
        $row = array();
        for ($i = 0; $i < count($aColumns2); $i++) {
            if ($i == 0) {
                $row[] = $serial++;
            } else {
                $row[] = $aRow[$aColumns2[$i]];
            }
        }
        if ($tempGroupId != $aRow['FormulationName']) {
            $col .= '<tr style="page-break-inside:avoid;">
                        <td style="background-color:#DAEF62;border-radius:2px;  align:center;" colspan="3">' . $aRow['FormulationName'] . '</td>
                    </tr>';
            $tempGroupId = $aRow['FormulationName'];
        }
        $col .= '<tr style="page-break-inside:avoid;">
                    <td width="100" style="text-align: center;">' . $j . '</td>
                    <td width="250" style="text-align: left;">' . $aRow['RegimenName'] . '</td>
                    <td width="280" style="text-align: right;">' . ($aRow['PatientCount'] == '' ? '' : number_format($aRow['PatientCount'])) . '</td>
                </tr>';
        $j++;
    }
    $html = '
        <!-- EXAMPLE OF CSS STYLE -->
        <style>
         td{
             height: 6px;
             line-height:3px;
         }
         th{
            height:20;
            font-size:10px;
        }
        </style>
        <div>
        <body>
        <h4 style="text-align:center; font-size:12px;"><p><b>' . $gTEXT['ART Protocols with Patient Count'] . '</b></p></h4></br></br>
        <table width=auto border="0.5" style="margin:0 auto;">
        <tr>
            <th width="100" style="text-align: center;"><b>SL#</b></th>
            <th width="250" style="text-align: left;"><b>' . $gTEXT['RegimenCount'] . '</b></th>
            <th width="280" style="text-align: right;"><b>' . $gTEXT['Patients'] . '</b></th>
        </tr>' . $col . '</table></body></div>';
    $pdf->startPage();
    $pdf->SetFont('dejavusans', '', 7);
    $pdf->writeHTMLCell(0, 0, 12, 12, $html, '', 1, 1, false, 'L', true);
    $pdf->endPage();
    //================================================Funding Requirements======================================================================//
    $CountryId = $_REQUEST['CountryId'];
    $CountryName = $_REQUEST['CountryName'];
    $Year = $_REQUEST['Year'];
    $aColumns3 = array('ServiceTypeName', 'FundingReqSourceName', 'Y1', 'Y2', 'Y3', 'TotalRequirements');
    $aColumns4 = array('ServiceTypeName', 'FundingReqSourceName', 'Y1', 'Y2', 'Y3', 'TotalRequirements');
    if ($_REQUEST['lan'] == 'fr-FR') {
        $SeLang = 'ServiceTypeNameFrench';
        $forLang = 'FundingReqSourceNameFrench';
    } else {
        $SeLang = 'ServiceTypeName';
        $forLang = 'FundingReqSourceName';
    }
    $sIndexColumn = "FundingReqId";
    $sTable1 = "t_yearly_funding_requirements ";
    $sJoin1 = 'INNER JOIN  t_fundingreqsources ON t_fundingreqsources.FundingReqSourceId = t_yearly_funding_requirements.FormulationId  ';
    $sJoin1 .= 'INNER JOIN t_servicetype ON t_servicetype.ServiceTypeId = t_fundingreqsources.ServiceTypeId ';
    $sJoin1 .= 'INNER JOIN t_itemgroup ON t_itemgroup.ItemGroupId = t_fundingreqsources.ItemGroupId';
    $bUserFilter1 = true;
    if ($bUserFilter1) {
        if ($sWhere1 == "") {
            $sWhere1 = "WHERE ";
        } else {
            $sWhere1 .= " AND ";
        }
        $sWhere1 .= "t_yearly_funding_requirements.CountryId = " . $_REQUEST['CountryId'] . " \n                    AND t_yearly_funding_requirements.Year = " . $_REQUEST['Year'];
    }
    $sOrder = "Order By ServiceTypeName, t_fundingreqsources.FundingReqSourceId ";
    $bUseSL1 = true;
    $serial1 = '';
    /*$sQuery1 = "
    		SELECT  " . $serial1 . str_replace(" , ", " ", implode(", ", $aColumns3)) . "
    		FROM   $sTable1
    		$sJoin1
    		$sWhere1
    		$sOrder
    		$sLimit
    		";*/
    $sQuery1 = "SELECT {$SeLang} ServiceTypeName, {$forLang} FundingReqSourceName, Y1, Y2, Y3, TotalRequirements\n                    FROM t_yearly_funding_requirements\n                    {$sJoin1}\n                    {$sWhere1} \n                    {$sOrder} ";
    mysql_query("SET character_set_results=utf8");
    $rResult1 = mysql_query($sQuery1);
    $j = 1;
    $tempGroupId1 = '';
    $col1 = '';
    while ($aRow1 = mysql_fetch_array($rResult1)) {
        $row = array();
        for ($i = 0; $i < count($aColumns4); $i++) {
            $row[] = $aRow1[$aColumns4[$i]];
        }
        if ($tempGroupId1 != $aRow1['ServiceTypeName']) {
            $col1 .= '<tr >
                     <td style="background-color:#DAEF62;border-radius:2px;  align:center; font-size:10px;" colspan="6">' . $aRow1['ServiceTypeName'] . '</td>
                   </tr>';
            $tempGroupId1 = $aRow1['ServiceTypeName'];
        }
        $col1 .= '<tr>
                    <td width="100" style="text-align: center;">' . $j . '</td>
                    <td width="150" style="text-align: left;">' . $aRow1['FundingReqSourceName'] . '</td>
                    <td width="100" style="text-align: right;">' . number_format($aRow1['Y1']) . '</td>
                    <td width="100" style="text-align: right;">' . number_format($aRow1['Y2']) . '</td>
                    <td width="100" style="text-align: right;">' . number_format($aRow1['Y3']) . '</td>
                    <td width="90" style="text-align: right;">' . number_format($aRow1['TotalRequirements']) . '</td>
		      </tr>';
        $j++;
    }
    $html = '
        <!-- EXAMPLE OF CSS STYLE -->
        <style>
         td{
             height: 6px;
             line-height:3px;
         }
         th{
            height:20;
            font-size:10px;
        }
        </style>
        <div>
        <body>
        <h4 style="text-align:center; font-size:12px;"><p><b>' . $gTEXT['Funding Requirements'] . $gTEXT['MonetaryTitle'] . '</b></p></h4></br></br>
        <table width="600px" border="0.5" style="margin:0 auto;">
        <tr>
            <th width="100" style="text-align: center;"><b>SL#</b></th>
            <th width="150" style="text-align: left;"><b>' . $gTEXT['Formulation'] . '</b></th>
            <th width="100" style="text-align: right;"><b>' . $gTEXT['2014'] . '</b></th>
            <th width="100" style="text-align: right;"><b>' . $gTEXT['2015'] . '</b></th>
            <th width="100" style="text-align: right;"><b>' . $gTEXT['2016'] . '</b></th>
            <th width="90" style="text-align: right;"><b>' . $gTEXT['Total'] . '</b></th>
        </tr>' . $col1 . '</table></body></div>';
    $pdf->startPage();
    $pdf->SetFont('dejavusans', '', 7);
    $pdf->writeHTMLCell(0, 0, 12, 12, $html, '', 1, 1, false, 'L', true);
    $pdf->endPage();
    //=======================================================Pledged Funding=================================================================//
    $CountryId = $_POST['CountryId'];
    $Year = $_POST['Year'];
    $CountryName = $_POST['CountryName'];
    $RequirementYear = $_POST['RequirementYear'];
    if ($_POST['lan'] == 'fr-FR') {
        $aColumns = 'f.FundingReqSourceNameFrench FormulationName, ServiceTypeNameFrench GroupName';
    } else {
        $aColumns = 'f.FundingReqSourceName FormulationName, ServiceTypeName GroupName';
    }
    $rowData = array();
    $dynamicColumns = array();
    $dynamiccolWidths = array();
    if (!empty($CountryId) && !empty($Year)) {
        $sql = "select f.FundingSourceId,s.FundingSourceName from t_yearly_country_fundingsource f\n\t\tInner Join t_fundingsource s on s.FundingSourceId=f.FundingSourceId\n\t\twhere  CountryId='" . $CountryId . "' and Year='" . $Year . "' \n\t\tOrder By FundingSourceName asc ";
        $resultPre = mysql_query($sql);
        $total = mysql_num_rows($resultPre);
        $l = 0;
        $trecord = 0;
        if ($total > 0) {
            while ($row = mysql_fetch_object($resultPre)) {
                $FundingSourceId = $row->FundingSourceId;
                $col = array();
                $col['FundingSourceId'] = $row->FundingSourceId;
                array_push($dynamicColumns, $col);
            }
        }
        $sql = "SELECT f.ItemGroupId,f.FundingReqSourceId FormulationId, {$aColumns} \n                FROM t_fundingreqsources f\n        \t\tINNER JOIN t_servicetype ON t_servicetype.ServiceTypeId = f.ServiceTypeId\n        \t\tINNER JOIN t_itemgroup g on g.ItemGroupId=f.ItemGroupId\n        \t\tOrder By f.FundingReqSourceId ";
        mysql_query("SET character_set_results=utf8");
        $result = mysql_query($sql);
        $total = mysql_num_rows($result);
        $superGrandTotalRequirements = 0;
        $superGrandFundingTotal = array();
        $superGrandSubTotal = 0;
        $superGrandGapSurplus = 0;
        $groupsubtotal = 0;
        $groupsubTmp = -1;
        $p = 0;
        $q = 0;
        $r = 0;
        $grandTotalRequirements = 0;
        $grandFundingTotal = array();
        $grandSubTotal = 0;
        $grandGapSurplus = 0;
        while ($row = mysql_fetch_object($result)) {
            $ItemGroupId = $row->ItemGroupId;
            $FormulationId = $row->FormulationId;
            if ($p != 0 && $groupsubTmp != $row->GroupName) {
                $l = 0;
                $cellData = array();
                $cellData[$l++] = $groupsubTmp;
                $cellData[$l++] = 'Total';
                $cellData[$l++] = $grandTotalRequirements;
                for ($j = 0; $j < count($dynamicColumns); $j++) {
                    $subtotal = 0;
                    for ($k = 0; $k < count($grandFundingTotal); $k++) {
                        $subtotal += $grandFundingTotal[$k][$j];
                    }
                    $cellData[$l++] = $subtotal;
                    $superGrandFundingTotal[$r][$j] = $subtotal;
                }
                $cellData[$l++] = $grandSubTotal;
                if ($grandGapSurplus >= 0) {
                    $cellData[$l++] = number_format($grandGapSurplus);
                } else {
                    $cellData[$l++] = '(' . number_format(-1 * $grandGapSurplus) . ')';
                }
                $cellData[$l++] = $ItemGroupId;
                $cellData[$l++] = $FormulationId;
                $rowData[] = $cellData;
                $superGrandTotalRequirements += $grandTotalRequirements;
                $superGrandSubTotal += $grandSubTotal;
                $superGrandGapSurplus += $grandGapSurplus;
                $q = 0;
                $grandTotalRequirements = 0;
                $grandFundingTotal = array();
                $grandSubTotal = 0;
                $grandGapSurplus = 0;
                $r++;
            }
            $l = 0;
            $cellData = array();
            $groupsubTmp = $row->GroupName;
            $cellData[$l++] = $row->GroupName;
            $cellData[$l++] = $row->FormulationName;
            $sql = "Select * from t_yearly_funding_requirements \n                    where CountryId='" . $CountryId . "' \n                    and Year='" . $Year . "' \n                    and ItemGroupId='" . $ItemGroupId . "' \n                    and FormulationId='" . $FormulationId . "' ";
            $result2 = mysql_query($sql);
            $total2 = mysql_num_rows($result2);
            if ($total2 > 0) {
                $row2 = mysql_fetch_object($result2);
                if ($RequirementYear == 1) {
                    $totalRequirement = $row2->Y1;
                } else {
                    if ($RequirementYear == 2) {
                        $totalRequirement = $row2->Y2;
                    } else {
                        if ($RequirementYear == 3) {
                            $totalRequirement = $row2->Y3;
                        }
                    }
                }
            } else {
                $totalRequirement = 0;
            }
            $cellData[$l++] = $totalRequirement;
            $grandTotalRequirements += $totalRequirement;
            $subtotal = 0;
            for ($j = 0; $j < count($dynamicColumns); $j++) {
                $FundingSourceId = $dynamicColumns[$j]['FundingSourceId'];
                $sql = "select * from t_yearly_pledged_funding \n                where CountryId='" . $CountryId . "' \n                and Year='" . $Year . "' \n                and ItemGroupId='" . $ItemGroupId . "' \n                and FormulationId='" . $FormulationId . "' \n                and FundingSourceId='" . $FundingSourceId . "' ";
                $result3 = mysql_query($sql);
                $total3 = mysql_num_rows($result3);
                if ($total3 == 0) {
                    $subtotal += 0;
                    $cellData[$l++] = 0;
                } else {
                    $row3 = mysql_fetch_object($result3);
                    $subtotal += $row3->TotalFund;
                    $cellData[$l++] = $row3->TotalFund;
                }
                $grandFundingTotal[$q][$j] = $row3->TotalFund;
            }
            $cellData[$l++] = $subtotal;
            $grandSubTotal += $subtotal;
            $surplus = $totalRequirement - $subtotal;
            if ($surplus >= 0) {
                $cellData[$l++] = number_format($surplus);
                $grandGapSurplus += $surplus;
            } else {
                $cellData[$l++] = '(' . number_format(-1 * $surplus) . ')';
                $grandGapSurplus += $surplus;
            }
            $cellData[$l++] = $ItemGroupId;
            $cellData[$l++] = $FormulationId;
            $rowData[] = $cellData;
            if ($p == $total - 1) {
                $l = 0;
                $cellData = array();
                $cellData[$l++] = $groupsubTmp;
                $cellData[$l++] = 'Total';
                $cellData[$l++] = $grandTotalRequirements;
                for ($j = 0; $j < count($dynamicColumns); $j++) {
                    $subtotal = 0;
                    for ($k = 0; $k < count($grandFundingTotal); $k++) {
                        $subtotal += $grandFundingTotal[$k][$j];
                    }
                    $cellData[$l++] = $subtotal;
                    $superGrandFundingTotal[$r][$j] = $subtotal;
                }
                $cellData[$l++] = $grandSubTotal;
                if ($grandGapSurplus >= 0) {
                    $cellData[$l++] = number_format($grandGapSurplus);
                } else {
                    $cellData[$l++] = '(' . number_format(-1 * $grandGapSurplus) . ')';
                }
                $cellData[$l++] = $ItemGroupId;
                $cellData[$l++] = $FormulationId;
                $rowData[] = $cellData;
                $superGrandTotalRequirements += $grandTotalRequirements;
                $superGrandSubTotal += $grandSubTotal;
                $superGrandGapSurplus += $grandGapSurplus;
                $r++;
                $l = 0;
                $cellData = array();
                $cellData[$l++] = $groupsubTmp;
                $cellData[$l++] = 'Grand Total';
                $cellData[$l++] = $superGrandTotalRequirements;
                for ($j = 0; $j < count($dynamicColumns); $j++) {
                    $subtotal = 0;
                    for ($k = 0; $k < count($superGrandFundingTotal); $k++) {
                        $subtotal += $superGrandFundingTotal[$k][$j];
                    }
                    $cellData[$l++] = $subtotal;
                }
                $cellData[$l++] = $superGrandSubTotal;
                if ($superGrandGapSurplus >= 0) {
                    $cellData[$l++] = number_format($superGrandGapSurplus);
                } else {
                    $cellData[$l++] = '(' . number_format(-1 * $superGrandGapSurplus) . ')';
                }
                $cellData[$l++] = $ItemGroupId;
                $cellData[$l++] = $FormulationId;
                $rowData[] = $cellData;
            }
            $p++;
            $q++;
        }
        $rResult = array();
        $data = array();
        $k = 0;
        $x = 0;
        $f = 0;
        $groupsubtotal = 0;
        $groupsubTmp = '-1';
        $endlimit = count($rowData);
        $groupsubTmp = -1;
        $p = 0;
        while (count($rowData) > $x) {
            $groupsubTmp = $rowData[$x][1];
            if ($f) {
            }
            if ($rowData[$x][1] == 'Grand Total') {
                $rowData[$x][1] = '';
                $data[$k++] = 'Grand Total';
            } else {
                if ($groupsubTmp == 'Total') {
                    $rowData[$x][1] = '';
                    $data[$k++] = $rowData[$x][0];
                } else {
                    $f++;
                    if ($f == $endlimit) {
                        $data[$k++] = $f;
                    } else {
                        $data[$k++] = $f;
                    }
                }
            }
            $y = 0;
            while (count($rowData[$x]) > $y) {
                if ($y > 1 && $y < count($rowData[$x]) - 3) {
                    //echo  ',"'.number_format($rowData[$x][$y]).'"';
                    $data[$k++] = number_format($rowData[$x][$y]);
                } else {
                    //echo  ',"'.$rowData[$x][$y].'"';
                    $data[$k++] = $rowData[$x][$y];
                }
                $y++;
            }
            //echo ']';
            $x++;
            $rResult[] = $data;
            $k = 0;
            //break;
        }
        $tbody = '';
        $x = 0;
        $tempGroupId = '';
        while (count($rResult) > $x) {
            $tbody .= '<tr>';
            $k = 0;
            if ($tempGroupId != $rResult[$x][1]) {
                $tbody .= '<td style="background-color:#DAEF62;border-radius:2px;  align:center;" colspan="' . (count($rResult[$x]) - 3) . '">' . $rResult[$x][1] . '</td>';
                $tempGroupId = $rResult[$x][1];
                $tbody .= '</tr><tr>';
            }
            $f = 0;
            while (count($rResult[$x]) - 2 > $k) {
                if ($k == 1) {
                } else {
                    $style = '';
                    if ($rResult[$x][0] == 'Grand Total') {
                        $d = $rResult[$x][$k];
                        $style = ' style="background-color:#50ABED;color:#ffffff;border-radius:2px;  align:center;" ';
                    } else {
                        if (is_int($rResult[$x][0]) == false) {
                            $style = ' style="background-color:#FE9929;border-radius:2px;  align:center; " ';
                            $d++;
                            $f++;
                            if ($f == 1) {
                                $d = $rResult[$x][$k] . ' Total';
                            } else {
                                $d = $rResult[$x][$k];
                            }
                        } else {
                            $d = $rResult[$x][$k];
                        }
                    }
                    $tbody .= '<td ' . $style . '>';
                    $tbody .= $d;
                    $tbody .= '</td>';
                }
                $k++;
            }
            $tbody .= '</tr>';
            $x++;
        }
        $col = '';
        $col .= '<tr style="page-break-inside:avoid;">
            <th width="80" style="text-align: left;"><b>SL#</b></th>
            <th width="98" style="text-align: left;"><b>' . $gTEXT['Category'] . '</b></th>
            <th width="98" style="text-align: left;"><b>' . $gTEXT['Total Requirements'] . '</b></th>';
        /*===Funding Source List=*/
        $sql_1 = "select f.FundingSourceId,s.FundingSourceName \n                        from t_yearly_country_fundingsource f\n                \t\tInner Join t_fundingsource s on s.FundingSourceId=f.FundingSourceId\n                \t\twhere  CountryId='" . $CountryId . "' \n                        and Year='" . $Year . "' \n                \t\tOrder By FundingSourceName asc ";
        $resultPre = mysql_query($sql_1);
        $total = mysql_num_rows($resultPre);
        $k = 0;
        $odd = 1;
        while ($row = mysql_fetch_object($resultPre)) {
            if ($k % 2 == 0) {
                $col .= ' <th width="77" style="text-align: left;"><b>' . $row->FundingSourceName . '</b></th>';
                $odd = 0;
            } else {
                $col .= ' <th width="77" style="text-align: left;"><b>' . $row->FundingSourceName . '</b></th>';
                $odd = 1;
            }
            $k++;
        }
        /*===Funding Source List=*/
        $col .= '<th width="80" style="text-align: left;"><b>' . $gTEXT['Total'] . '</b></th>
				   <th width="80" style="text-align: left;"><b>' . $gTEXT['Gap/Surplus'] . '</b></th></tr>';
        $html = '
        <!-- EXAMPLE OF CSS STYLE -->
        <style>
         td{
             height: 6px;
             line-height:3px;
         }
         th{
            height:20;
            font-size:10px;
        }
        </style>
        <body>
        <h4 style="text-align:center; font-size:12px;"><p><b>' . $gTEXT['Pledged Funding'] . $gTEXT['MonetaryTitle'] . '</b></p></h4></br></br>
        <table width="600px" border="0.5" style="margin:0 auto;">' . $col . '' . $tbody . '</table></body>';
    }
    $pdf->startPage();
    $pdf->SetFont('dejavusans', '', 7);
    $pdf->writeHTMLCell(0, 0, 12, 12, $html, '', 1, 1, false, 'L', true);
    $pdf->endPage();
    $filePath = SITEDOCUMENT . 'administrator/components/com_jcode/source/report/pdfslice/CountryProfileReport.pdf';
    if (file_exists($filePath)) {
        unlink($filePath);
    }
    $pdf->Output('pdfslice/CountryProfileReport.pdf', 'F');
    echo 'CountryProfileReport.pdf';
    /*	}else{
    		echo 'Processing Error';
    	}*/
}
Example #26
0
 protected function renderPDFIntoFile($template, $filename)
 {
     require_once DIR_SYSTEM . 'tcpdf/config/lang/eng.php';
     require_once DIR_SYSTEM . 'tcpdf/tcpdf.php';
     // create new PDF document
     $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     //set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     //set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     //set image scale factor
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     //set some language-dependent strings
     $pdf->setLanguageArray($l);
     // ---------------------------------------------------------
     // set font
     $pdf->SetFont('dejavusans', '', 10);
     $pdf->SetPrintHeader(false);
     $pdf->SetPrintFooter(false);
     // add a page
     $pdf->AddPage();
     $tablecontent = $this->fetch($template);
     // output the HTML content
     $pdf->writeHTML($tablecontent, true, false, true, false, '');
     // - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     // reset pointer to the last page
     $pdf->lastPage();
     // ---------------------------------------------------------
     //Close and output PDF document
     $pdf->Output('invoice' . $filename . '.pdf', 'F');
     //============================================================+
     // END OF FILE
     //============================================================+
 }
Example #27
0
 public function view_reserve($id)
 {
     if (Session::get('level') == '1' || Session::get('level') == '3') {
         $sql = ' select * from c_reserve_cars ';
         $sql .= ' where reserve_id =' . $id . ' ';
         $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
         $pdf->SetPrintHeader(false);
         $pdf->SetPrintFooter(false);
         // set header and footer fonts
         $pdf->setHeaderFont(array('angsanaupc', '', PDF_FONT_SIZE_MAIN));
         $pdf->setFooterFont(array('angsanaupc', '', PDF_FONT_SIZE_DATA));
         // set default monospaced font
         $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
         // set margins
         $pdf->SetMargins(10, 10, 10);
         $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
         $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
         $pdf->SetFont('angsanaupc', '', 14, '', true);
         $pdf->AddPage();
         $pdf->SetXY(10, 10);
         $pdf->Image('images/krut.jpg', '', '', 20, 20, '', '', 'T', false, 300, '', false, false, 0, false, false, false);
         $pdf->SetFont('angsanaupc', 'B', 18, '', true);
         $pdf->SetXY(75, 20);
         $pdf->MultiCell(60, 0, 'บันทึกข้อความ', 0, 'C', 0, 1, '', '', true);
         $result = DB::select($sql);
         foreach ($result as $key) {
             $pdf->SetFont('angsanaupc', 'B', 14, '', true);
             $pdf->SetXY(10, 32);
             $pdf->MultiCell(25, 0, 'ส่วนราชการ', 0, 'L', 0, 1, '', '', true);
             //$pdf->SetFont('angsanaupc','',14,'',true);
             $pdf->SetXY(35, 32);
             $pdf->MultiCell(160, 0, 'ฝ่าย........................................................................................โรงพยาบาลโนนไทย อำเภอโนนไทย จังหวัดนครราชสีมา', 0, 'L', 0, 1, '', '', true);
             $pdf->SetXY(44, 31);
             $pdf->MultiCell(65, 0, $key->department, 0, 'L', 0, 1, '', '', true);
             //$pdf->SetFont('angsanaupc','B',14,'',true);
             $pdf->SetXY(10, 40);
             $pdf->MultiCell(10, 0, 'ที่', 0, 'L', 0, 1, '', '', true);
             //$pdf->SetFont('angsanaupc','B',14,'',true);
             $pdf->SetXY(20, 40);
             $pdf->MultiCell(170, 0, 'นม 0032.301/...........................................วันที่.............................................................................', 0, 'L', 0, 1, '', '', true);
             $pdf->SetXY(43, 39);
             $pdf->MultiCell(31, 0, $key->num_nm, 0, 'L', 0, 1, '', '', true);
             $pdf->SetXY(83, 39);
             $pdf->MultiCell(44, 0, $key->date_nm == '0000-00-00' ? '' : $this->get_monthyearThai($key->date_nm), 0, 'L', 0, 1, '', '', true);
             //$pdf->SetFont('angsanaupc','B',14,'',true);
             $pdf->SetXY(10, 48);
             $pdf->MultiCell(10, 0, 'เรื่อง', 0, 'L', 0, 1, '', '', true);
             //$pdf->SetFont('angsanaupc','B',14,'',true);
             $pdf->SetXY(20, 48);
             $pdf->MultiCell(60, 0, ' ขออนุมัติไปราชการ', 0, 'L', 0, 1, '', '', true);
             $style = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => '', 'phase' => 5, 'color' => array(0, 0, 0));
             $pdf->Line(10, 57, 195, 57, $style);
             //$pdf->SetFont('angsanaupc','B',14,'',true);
             $pdf->SetXY(10, 62);
             $pdf->MultiCell(70, 0, 'เรียน ผู้อำนวยการโรงพยาบาลโนนไทย', 0, 'L', 0, 1, '', '', true);
             $pdf->SetXY(20, 72);
             $pdf->MultiCell(176, 0, 'ด้วยข้าพเจ้า..........................................................................ตำแหน่ง...........................................................................................................', 0, 'L', 0, 1, '', '', true);
             $pdf->SetXY(39, 71);
             $pdf->MultiCell(55, 0, $key->req_name, 0, 'L', 0, 1, '', '', true);
             $pdf->SetXY(108, 71);
             $pdf->MultiCell(70, 0, $key->position, 0, 'L', 0, 1, '', '', true);
             $sql2 = ' select * from c_together where together_id=' . $key->together_id . ' ';
             $result2 = DB::select($sql2);
             $n = 0;
             $r = 0;
             $pdf->SetXY(10, 80);
             $pdf->MultiCell(20, 0, 'พร้อมด้วย', 0, 'L', 0, 1, '', '', true);
             if (count($result2) > 0) {
                 foreach ($result2 as $key2) {
                     $n++;
                     $r = $r + 7;
                     $pdf->SetXY(20, 84 + $r);
                     $pdf->MultiCell(176, 0, $n . '.................................................................................ตำแหน่ง.....................................................................................................................', 0, 'L', 0, 1, '', '', true);
                     $pdf->SetXY(25, 83 + $r);
                     $pdf->MultiCell(60, 0, $key2->req_name, 0, 'L', 0, 1, '', '', true);
                     $pdf->SetXY(100, 83 + $r);
                     $pdf->MultiCell(90, 0, $key2->position, 0, 'L', 0, 1, '', '', true);
                 }
             } else {
                 $pdf->SetXY(10, 85);
                 $pdf->MultiCell(20, 0, '-', 0, 'L', 0, 1, '', '', true);
             }
             $pdf->SetXY(10, 91 + $r);
             $pdf->MultiCell(186, 0, 'ขออนุมัติเดินทางไปราชการที่.............................................................................หน่วยงานผู้จัด...............................................................................', 0, 'L', 0, 1, '', '', true);
             $pdf->SetXY(50, 90 + $r);
             $pdf->MultiCell(59, 0, $key->location, 0, 'L', 0, 1, '', '', true);
             $pdf->SetXY(130, 90 + $r);
             $pdf->MultiCell(60, 0, $key->institution, 0, 'L', 0, 1, '', '', true);
             $pdf->SetXY(10, 97 + $r);
             $pdf->MultiCell(186, 0, 'เรื่อง...........................................................................................................................................................................................................................', 0, 'L', 0, 1, '', '', true);
             $pdf->SetXY(20, 96 + $r);
             $pdf->MultiCell(175, 0, $key->title, 0, 'L', 0, 1, '', '', true);
             $pdf->SetXY(10, 103 + $r);
             $pdf->MultiCell(187, 0, 'ตามหนังสือที่.........................................................................................................................ลงวันที่........................................................................', 0, 'L', 0, 1, '', '', true);
             $pdf->SetXY(32, 102 + $r);
             $pdf->MultiCell(74, 0, $key->ref_book_number, 0, 'L', 0, 1, '', '', true);
             $pdf->SetXY(136, 102 + $r);
             $pdf->MultiCell(50, 0, $key->ref_book_date == '0000-00-00' ? '' : $this->get_monthyearThai($key->ref_book_date), 0, 'L', 0, 1, '', '', true);
             $pdf->SetXY(10, 110 + $r);
             $pdf->MultiCell(186, 0, 'ทั้งนี้ตั้งแต่วันที่.........................................................................ถึงวันที่...........................................................................รวม............................วัน', 0, 'L', 0, 1, '', '', true);
             $pdf->SetXY(34, 109 + $r);
             $pdf->MultiCell(55, 0, $key->startdate == '0000-00-00' ? '' : $this->get_monthyearThai($key->startdate), 0, 'L', 0, 1, '', '', true);
             $pdf->SetXY(100, 109 + $r);
             $pdf->MultiCell(53, 0, $key->enddate == '0000-00-00' ? '' : $this->get_monthyearThai($key->enddate), 0, 'L', 0, 1, '', '', true);
             $pdf->SetXY(167, 109 + $r);
             $pdf->MultiCell(20, 0, $key->allday, 0, 'L', 0, 1, '', '', true);
             $pdf->SetXY(10, 116 + $r);
             $pdf->MultiCell(186, 0, 'สำหรับค่าใช้จ่ายในการเดินทางไปราชการขอเบิกจ่ายเงินบำรุงของโรงพยาบาล และขอใช้รถยนต์เดินทางไปราชการครั้งนี้', 0, 'L', 0, 1, '', '', true);
             $pdf->SetXY(20, 125 + $r);
             $pdf->MultiCell(6, 0, $key->usecar1 == 1 ? '/' : '', 1, 'C', 0, 1, '', '', true);
             $pdf->SetXY(29, 125 + $r);
             $pdf->MultiCell(60, 0, 'ใช้รถยนต์ของทางโรงพยาบาลโนนไทย', 0, 'L', 0, 1, '', '', true);
             $pdf->SetXY(20, 135 + $r);
             $pdf->MultiCell(6, 0, $key->usecar2 == 1 ? '/' : '', 1, 'C', 0, 1, '', '', true);
             $pdf->SetXY(29, 135 + $r);
             $pdf->MultiCell(170, 0, 'ใช้รถยนต์ส่วนตัว หมายเลขทะเบียน.......................................................................ตามหลักเกณฑ์การเบิกค่า', 0, 'L', 0, 1, '', '', true);
             $pdf->SetXY(84, 134 + $r);
             $pdf->MultiCell(40, 0, $key->usecar2_car_number, 0, 'C', 0, 1, '', '', true);
             $pdf->SetXY(29, 141 + $r);
             $pdf->MultiCell(170, 0, 'ยานพาหนะส่วนตัวในการเดินทางไปราชการ กิโลเมตรละ 4 บาท เป็นเงิน................................................บาท', 0, 'L', 0, 1, '', '', true);
             $pdf->SetXY(123, 140 + $r);
             $pdf->MultiCell(38, 0, $key->usecar2_km_money, 0, 'C', 0, 1, '', '', true);
             $pdf->SetXY(20, 149 + $r);
             $pdf->MultiCell(6, 0, $key->usecar3 == 1 ? '/' : '', 1, 'C', 0, 1, '', '', true);
             $pdf->SetXY(29, 149 + $r);
             $pdf->MultiCell(170, 0, 'อื่น ๆ (ระบุ)......................................................................................................................................................................................', 0, 'L', 0, 1, '', '', true);
             $pdf->SetXY(50, 148 + $r);
             $pdf->MultiCell(140, 0, $key->usecar3_detail, 0, 'L', 0, 1, '', '', true);
             $pdf->SetXY(29, 158 + $r);
             $pdf->MultiCell(140, 0, 'จึงเรียนมาเพื่อทราบ และโปรดพิจารณาอนุมัติด้วย จะเป็นพระคุณ', 0, 'L', 0, 1, '', '', true);
             $pdf->SetXY(95, 168 + $r);
             $pdf->MultiCell(100, 0, '(ลงชื่อ)...............................................................ผู้ขอ', 0, 'R', 0, 1, '', '', true);
             $pdf->SetXY(122, 167 + $r);
             $pdf->MultiCell(64, 0, '', 0, 'C', 0, 1, '', '', true);
             $pdf->SetXY(128, 175 + $r);
             $pdf->MultiCell(69, 0, '(............................................................)', 0, 'C', 0, 1, '', '', true);
             $pdf->SetXY(129, 174 + $r);
             $pdf->MultiCell(64, 0, $key->regis_user_req, 0, 'C', 0, 1, '', '', true);
             $h_re = DB::Select('select * from n_department_header where departmentName="' . $key->department . '" ');
             foreach ($h_re as $k_h) {
                 $header_name = $k_h->header_name;
             }
             if (!isset($header_name)) {
                 $header_name = '';
             }
             $pdf->SetXY(10, 186 + $r);
             $pdf->MultiCell(68, 0, 'เสนอ   ผู้อำนวยการโรงพยาบาลโนนไทย', 0, 'L', 0, 1, '', '', true);
             $pdf->SetXY(11, 194 + $r);
             $pdf->MultiCell(69, 0, '...................................................', 0, 'C', 0, 1, '', '', true);
             $pdf->SetXY(10, 204 + $r);
             $pdf->MultiCell(90, 0, '(ลงชื่อ).........................................................หัวหน้าฝ่าย', 0, 'L', 0, 1, '', '', true);
             $pdf->SetXY(18, 212 + $r);
             $pdf->MultiCell(69, 0, '(.........................................................)', 0, 'L', 0, 1, '', '', true);
             $pdf->SetXY(20, 211 + $r);
             $pdf->MultiCell(45, 0, $header_name, 0, 'C', 0, 1, '', '', true);
             $pdf->SetXY(120, 194 + $r);
             $pdf->MultiCell(6, 0, $key->daytrue == 1 ? '/' : '', 1, 'C', 0, 1, '', '', true);
             $pdf->SetXY(123, 194 + $r);
             $pdf->MultiCell(40, 0, 'ไม่เป็นวันทำการ', 0, 'C', 0, 1, '', '', true);
             $pdf->SetXY(120, 204 + $r);
             $pdf->MultiCell(6, 0, $key->dayflase == 1 ? '/' : '', 1, 'C', 0, 1, '', '', true);
             $pdf->SetXY(123, 204 + $r);
             $pdf->MultiCell(40, 0, 'เป็นวันทำการ', 0, 'C', 0, 1, '', '', true);
             $pdf->SetXY(105, 219 + $r);
             $pdf->MultiCell(90, 0, '(ลงชื่อ)...........................................................ผู้อนุมัติ', 0, 'R', 0, 1, '', '', true);
             $pdf->SetXY(115, 227 + $r);
             $pdf->MultiCell(90, 0, '( นายบุญชัย  ธนบัตรชัย )', 0, 'C', 0, 1, '', '', true);
             $pdf->SetXY(115, 235 + $r);
             $pdf->MultiCell(90, 0, 'ผู้อำนวยการโรงพยาบาลโนนไทย', 0, 'C', 0, 1, '', '', true);
         }
         //end foreach
         $filename = storage_path() . '/report_reserve.pdf';
         $contents = $pdf->output($filename, 'I');
         $headers = array('Content-Type' => 'application/pdf');
         return Response::make($contents, 200, $headers);
     } else {
         $data = DB::table('c_req_cars')->where('godate', '>=', date('Y-m-d'))->orderBy('godate', 'asc')->paginate(10);
         return View::make('home.index', array('data' => $data));
     }
 }
Example #28
0
$judul = $alamat . "\n" . "TELP. " . $tlp;
$foto = "profile.jpg";
$cknama = $this->db->get_where('view_member', array('kode' => $kode))->result();
foreach ($cknama as $row) {
    $nama = $row->nama;
    $tgl = date('d-m-Y', strtotime($row->tgl_lahir));
    $tempat = $row->tempat_lahir;
    $jns = strtoupper($row->nama_tipe);
}
$ckhasil = $this->db->get_where('tbl_status_izajah', array('id' => $status))->result();
foreach ($ckhasil as $key) {
    $hasil = $key->status;
}
$obj_pdf->SetTitle($toko);
$obj_pdf->SetHeaderData("", "", "", "");
$obj_pdf->SetPrintHeader(FALSE);
$obj_pdf->SetPrintFooter(FALSE);
$obj_pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', 9));
$obj_pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$obj_pdf->SetDefaultMonospacedFont('helvetica');
$obj_pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$obj_pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$obj_pdf->SetMargins(10, 34, 10);
$obj_pdf->SetAutoPageBreak(FALSE, PDF_MARGIN_BOTTOM);
$obj_pdf->SetFont('helvetica', '', 10);
$obj_pdf->setFontSubsetting(FALSE);
$obj_pdf->SetDisplayMode('fullpage', 'SinglePage', 'UseNone');
$obj_pdf->AddPage();
$obj_pdf->SetFont("helvetica", '', 20);
$obj_pdf->Ln(107);
$obj_pdf->MultiCell(180, 10, $no, 0, 'C', 0, 1, '', '', true, 0, false, true, 10, 'B');
Example #29
0
 function generatePDF($action = 'return')
 {
     if (!in_array($action, ['return', 'dump'])) {
         throw $this->exception('Please provide action as result or dump');
     }
     $pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     // set document information
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor('xEpan ERP');
     $pdf->SetTitle($this['type'] . ' ' . $this['document_no']);
     $pdf->SetSubject($this['type'] . ' ' . $this['document_no']);
     $pdf->SetKeywords($this['type'] . ' ' . $this['document_no']);
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     // set font
     $pdf->SetFont('dejavusans', '', 10);
     //remove header or footer hr lines
     $pdf->SetPrintHeader(false);
     $pdf->SetPrintFooter(false);
     // add a page
     $pdf->AddPage();
     if ($org = $this->ref('contact_id')->get('organization')) {
         $this['contact'] = $org;
         $this['contact_id'] = '';
     }
     // getting layouts from config
     $layout_m = $this->add('xepan\\base\\Model_ConfigJsonModel', ['fields' => ['master' => 'xepan\\base\\RichText', 'detail' => 'xepan\\base\\RichText'], 'config_key' => strtoupper($this['type']) . '_LAYOUT', 'application' => 'commerce']);
     $layout_m->tryLoadAny();
     $info_config = $layout_m['master'];
     $info_layout = $this->add('GiTemplate');
     $info_layout->loadTemplateFromString($info_config);
     $detail_config = $layout_m['detail'];
     $detail_layout = $this->add('GiTemplate');
     $detail_layout->loadTemplateFromString($detail_config);
     $new = $this->add('xepan\\commerce\\Model_QSP_Master');
     $new->addHook('afterLoad', function ($m) {
         $m['round_amount'] = abs($m['round_amount']);
     });
     $new->load($this->id);
     $view = $this->app->add('xepan\\commerce\\View_QSP', ['qsp_model' => $new, 'master_template' => $info_layout, 'detail_template' => $detail_layout, 'action' => 'pdf']);
     // $view = $this->owner->add('xepan\commerce\View_QSP',['qsp_model'=>$this]);
     if ($bar_code = $this->getBarCode()) {
         $barcodeobj = new \TCPDFBarcode($bar_code, 'C128');
         // $barcode_html = $barcodeobj->getBarcodePNG(2, 30, 'black');
         $barcode_html = $barcodeobj->getBarcodePngData(1, 20, array(0, 128, 0));
         $info_layout->trySetHtml('dispatch_barcode', '<img src="data:image/png;base64, ' . base64_encode($barcode_html) . '"/>');
     }
     $html = $view->getHTML();
     // echo "string".$html;
     // echo $html;
     // exit;
     // output the HTML content
     $pdf->writeHTML($html, false, false, true, false, '');
     // set default form properties
     $pdf->setFormDefaultProp(array('lineWidth' => 1, 'borderStyle' => 'solid', 'fillColor' => array(255, 255, 200), 'strokeColor' => array(255, 128, 128)));
     // reset pointer to the last page
     $pdf->lastPage();
     //Close and output PDF document
     switch ($action) {
         case 'return':
             return $pdf->Output(null, 'S');
             break;
         case 'dump':
             return $pdf->Output(null, 'I');
             exit;
             break;
     }
 }
 /**
  * generate_pdf.
  */
 public function generate_pdf($get_by_order_id = 0)
 {
     if (!isset($_GET['pdf_invoice']) && 0 == $get_by_order_id) {
         return;
     }
     $order_id = 0 == $get_by_order_id ? $_GET['pdf_invoice'] : $get_by_order_id;
     if (!is_user_logged_in() && 0 == $get_by_order_id) {
         return;
     }
     if (!current_user_can('administrator') && !is_shop_manager() && get_current_user_id() != intval(get_post_meta($order_id, '_customer_user', true)) && 0 == $get_by_order_id) {
         return;
     }
     // Include the main TCPDF library (search for installation path).
     //require_once('tcpdf_include.php');
     require_once 'lib/tcpdf_min/tcpdf.php';
     // create new PDF document
     $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     // set document information
     $pdf->SetCreator(PDF_CREATOR);
     //$pdf->SetAuthor( 'Algoritmika Ltd.' );
     $pdf->SetTitle('Invoice');
     $pdf->SetSubject('Invoice PDF');
     $pdf->SetKeywords('invoice, PDF');
     // set default header data
     // TODO 2014.09.21
     //		$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 001', PDF_HEADER_STRING, array(0,64,255), array(0,64,128));
     //$pdf->SetHeaderData( get_option( 'wcj_pdf_invoices_seller_logo_url' ), 30, get_option( 'wcj_pdf_invoices_header_title' ), get_option( 'wcj_pdf_invoices_header_string' ), array(0,64,255), array(0,64,128));
     $pdf->SetPrintHeader(false);
     $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128));
     //$pdf->SetPrintFooter(false);
     // set header and footer fonts
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     // set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     // set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     // set image scale factor
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     /*
     // set some language-dependent strings (optional)
     if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
     	require_once(dirname(__FILE__).'/lang/eng.php');
     	$pdf->setLanguageArray($l);
     }
     */
     // ---------------------------------------------------------
     // set default font subsetting mode
     $pdf->setFontSubsetting(true);
     // Set font
     // dejavusans is a UTF-8 Unicode font, if you only need to
     // print standard ASCII chars, you can use core fonts like
     // helvetica or times to reduce file size.
     $pdf->SetFont(apply_filters('wcj_get_option_filter', 'dejavusans', get_option('wcj_pdf_invoices_general_font_family', 'dejavusans')), '', apply_filters('wcj_get_option_filter', 8, get_option('wcj_pdf_invoices_general_font_size')), '', true);
     // Add a page
     // This method has several options, check the source code documentation for more information.
     $pdf->AddPage();
     if ('yes' === get_option('wcj_pdf_invoices_general_font_shadowed', 'yes')) {
         // set text shadow effect
         $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal'));
     }
     $html = $this->get_invoice_html($order_id);
     // Print text using writeHTMLCell()
     $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
     // ---------------------------------------------------------
     // Close and output PDF document
     // This method has several options, check the source code documentation for more information.
     //		$the_order = new WC_Order( $order_id );
     //		$order_number = $the_order->get_order_number();
     /**/
     if ($get_by_order_id > 0) {
         return $pdf->Output('invoice-' . $order_id . '.pdf', 'S');
     } else {
         $file_name = 'invoice-' . $order_id . '.pdf';
         $file_path = sys_get_temp_dir() . '/' . $file_name;
         $result = file_put_contents($file_path, $pdf->Output('', 'S'));
         //echo $pdf->Output( '', 'S' );
         if (isset($_GET['save_pdf_invoice']) && '1' == $_GET['save_pdf_invoice']) {
             //$pdf->Output('invoice-' . $order_id . '.pdf', 'D');
             header("Content-Type: application/octet-stream");
             //$file = $file_name;//$_GET["file"] .".pdf";
             header("Content-Disposition: attachment; filename=" . urlencode($file_name));
             header("Content-Type: application/octet-stream");
             header("Content-Type: application/download");
             header("Content-Description: File Transfer");
         } else {
             //$pdf->Output('invoice-' . $order_id . '.pdf', 'I');
             header("Content-type: application/pdf");
             header("Content-Disposition: inline; filename=" . urlencode($file_name));
         }
         header("Content-Length: " . filesize($file_path));
         flush();
         // this doesn't really matter.
         if (false !== ($fp = fopen($file_path, "r"))) {
             while (!feof($fp)) {
                 echo fread($fp, 65536);
                 flush();
                 // this is essential for large downloads
             }
             fclose($fp);
         } else {
             die(__('Unexpected error', 'woocommerce-jetpack'));
         }
     }
     /**/
     /**
     
     
     		if ( $get_by_order_id > 0 )
     			return $pdf->Output('invoice-' . $order_id . '.pdf', 'S');
     		if ( isset( $_GET['save_pdf_invoice'] ) && '1' == $_GET['save_pdf_invoice'] )
     			$pdf->Output('invoice-' . $order_id . '.pdf', 'D');
     		else
     			$pdf->Output('invoice-' . $order_id . '.pdf', 'I');
     
     			/**/
 }