|
Server : Apache/2.2.2 (Fedora) System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686 User : apache ( 48) PHP Version : 5.2.9 Disable Function : NONE Directory : /var/www/html/pathumthani_integration/pathumthani_drug/ |
Upload File : |
<?php
header("content-type: text/html; charset=TIS-620");
ob_start();
session_start();
define('FPDF_FONTPATH','fpdf/font/');
require('fpdf/fpdf.php');
require('expdf.php');
//require('kp7pdf_class.php');
//include ("../hr3/hr_report/libary/config.inc.php");
/*
require("../hr3/hr_report/barcode/core.php");
require("../hr3/hr_report/class.activitylog.php");
include ("../hr3/hr_report/timefunc.inc.php");
include ("../../config/phpconfig.php");
include("../../common/class-date-format.php");
include("../../common/std_function.inc.php");
*/
require_once("common/config.joomla.php");
$iresult = mysql_query("SET character_set_results=tis-620");
$iresult = mysql_query("SET NAMES TIS620");
function sensor($n,$length){
if(strlen($n)>$length){
$result = substr($n,0,$length);
return $result."...";
}
return $n;
}
$monthname = array( "","มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน", "กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤศจิกายน","ธันวาคม");
$monthsname = array( "","ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย.", "ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค.");
//$picture_logo = "../hr3/hr_report/krut.jpg" ;
//$hrpicture = "../hr3/hr_report/bimg/nopicture.jpg" ;
//$barcode = $_GET[barcode];
function writeimgfile($data,$hrpicture){
$f = fopen($hrpicture,"w");
fputs($f,$data);
fclose($f);
}
$npage = 260;
$pdf = new EXPDF();
$pdf->AliasNbPages();
$pdf->AddThaiFonts();
$pdf->AddPage();
$pdf->SetFont('Angsana New','B',14);
$y = 10;
$x = 20;
//$pdf->Image("$picture_logo",100,5,14,17,"JPG",'');
/*
$id = $_GET["id"];
$xsiteid = $_GET["xsiteid"];
$rev = new revolvingfund();
$rs = $rev->getView_general_by_id($id);
$xsiteid = $rs[0]["siteid"] ;
$nowdb = "cmss_" . $xsiteid ;
$rev->revolvingfund_conf($nowdb,"view_general");
*/
$pdf->SetXY($x,$y);
$pdf->Cell(175,5,"การแพร่กระจายของยาเสพติดในสถานศึกษา",0,0,'C');
## Begin
/*
$pdf->AddPage();
$pdf->SetFont('Angsana New','B',16);
$y = 18;
$x = 20;
*/
$y+=10;
$x = 13;
$size_cellEdu1=27;
$pdf->SetXY($x,$y);
$pdf->Cell($size_cellEdu1,12,"รหัสสถานศึกษา",1,0,'C');
$x = $x+$size_cellEdu1;
$pdf->SetXY($x,$y);
$size_cellEdu2 = 30;
$pdf->Cell($size_cellEdu2,12,"ชื่อสถานศึกษา",1,0,'C');
$x = $x+$size_cellEdu2;
$pdf->SetXY($x,$y);
$size_cellEdu3 = 63;
$pdf->Cell($size_cellEdu3,12,"ที่ตั้งสถานศึกษา",1,0,'C');
$x = $x+$size_cellEdu3;
$pdf->SetXY($x,$y);
$size_cellEdu4 = 25;
$pdf->Cell($size_cellEdu4,12,"นักเรียนที่ติดยา",1,0,'C');
$x = $x+$size_cellEdu4;
$pdf->SetXY($x,$y);
$size_cellEdu5 = 40;
$pdf->Cell($size_cellEdu5,6,"ระดับความรุนแรง",1,0,'C');
$pdf->SetXY($x,$y+6);
$size_cellEdu5 = 13;
$pdf->Cell($size_cellEdu5,6,"น้อย",1,0,'C');
$pdf->SetXY($x+13,$y+6);
$size_cellEdu5 = 14;
$pdf->Cell($size_cellEdu5,6,"ปานกลาง",1,0,'C');
$pdf->SetXY($x+27,$y+6);
$size_cellEdu5 = 13;
$pdf->Cell($size_cellEdu5,6,"มาก",1,0,'C');
$pdf->SetFont('Angsana New','',12);
$int_t=0;
//$y+=60;//TEST MAX
$y+=6;
$y_start = $y;
//}
$sql = "SELECT * FROM allschool AS sc JOIN ccaa AS c ON sc.moiareaid = c.areaid WHERE sc.moiareaid LIKE '13%'";
$_resultSet = mysql_query($sql);
$_check_null = false;
while($rs = mysql_fetch_assoc($_resultSet))
{
$arr_str_office = $pdf->alignstr(sensor($rs['office'],7),42);
$num_arr_str_office = count($arr_str_office); // check จำนวนบรรทัด column 1 หน่วยงาน
$maxNum_sub = $num_arr_str_office;
$x = 13;
#Begin รหัส
$y=$y_start;
$size_cellEdu1 = 27;
$y+=6;
$pdf->SetXY($x,$y);
$pdf->Cell($size_cellEdu1,6*$maxNum_sub," ",1,0,'C');
$pdf->SetXY($x,$y);
$pdf->Cell($size_cellEdu1,6,sensor($rs['id'],5),0,0,'C');
#End รหัส
#Begin ชื่อสถานศึกษา
$y=$y_start;
$size_cellEdu2 = 30;
$x = $x+$size_cellEdu1;
$y+=6;
$pdf->SetXY($x,$y);
$pdf->Cell($size_cellEdu2,6*$maxNum_sub," ",1,0,'C');
$pdf->SetXY($x,$y);
$pdf->Cell($size_cellEdu2,6,sensor($rs['office'],7),0,0,'L');
#End ชื่อสถานศึกษา
$area = $rs['moiareaid'];
$aumphur = substr($area,0,4);
$village = $rs['village_id'];
$query_a = mysql_query("SELECT * FROM ccaa WHERE areaid = $aumphur");
$rows_a = mysql_fetch_array($query_a);
$query_v = mysql_query("SELECT * FROM ccaa_village WHERE ccDigi = $village");
$rows_v = @mysql_fetch_array($query_v);
$place = $rows_a['ccName']." ".$rs['ccName']." ".$rows_v['ccName'];
#Begin ที่ตั้งสถานศึกษา
$y=$y_start;
$size_cellEdu3 = 63;
$x = $x+$size_cellEdu2;
$y+=6;
$pdf->SetXY($x,$y);
$pdf->Cell($size_cellEdu3,6*$maxNum_sub," ",1,0,'C');
$pdf->SetXY($x,$y);
$pdf->Cell($size_cellEdu3,6,$place,0,0,'C');
#End ที่ตั้งสถานศึกษา
$query_a = mysql_query("SELECT count(student_id) AS C FROM blacklist_student WHERE school_id = '".$rs['id']."'");
$rows_a = mysql_fetch_array($query_a);
#Begin จำนวนนักเรียนที่ติดยา
$y=$y_start;
$size_cellEdu4 = 25;
$x = $x+$size_cellEdu3;
$y+=6;
$pdf->SetXY($x,$y);
$pdf->Cell($size_cellEdu4,6*$maxNum_sub," ",1,0,'C');
$pdf->SetXY($x,$y);
$pdf->Cell($size_cellEdu4,6,$rows_a['C']." คน",0,0,'C');
#End จำนวนนักเรียนที่ติดยา
$_SQL_sum = "SELECT SUM(IF(drug_level='1',1,0)) AS drug_min, SUM(IF(drug_level='2',1,0)) AS drug_mid, SUM(IF(drug_level='3',1,0)) AS drug_max FROM blacklist_student WHERE school_id = '".$rs['id']."'";
$_QUERY_sum = mysql_query($_SQL_sum);
$_result_sum = mysql_fetch_assoc($_QUERY_sum);
if($_result_sum["drug_min"])
$_drug_min = $_result_sum["drug_min"];
else
$_drug_min = '0';
if($_result_sum["drug_mid"])
$_drug_mid = $_result_sum["drug_mid"];
else
$_drug_mid = '0';
if($_result_sum["drug_max"])
$_drug_max = $_result_sum["drug_max"];
else
$_drug_max = '0';
$y=$y_start;
$size_cellEdu5 = 40;
$x = $x+$size_cellEdu4;
$y+=6;
$pdf->SetXY($x,$y);
$pdf->Cell($size_cellEdu5,6*$maxNum_sub," ",1,0,'C');
$pdf->SetXY($x,$y);
$size_cellEdu5 = 13;
$pdf->Cell($size_cellEdu5,6,$_drug_min,1,0,'C');
$pdf->SetXY($x+13,$y);
$size_cellEdu5 = 14;
$pdf->Cell($size_cellEdu5,6,$_drug_mid,1,0,'C');
$pdf->SetXY($x+27,$y);
$size_cellEdu5 = 13;
$pdf->Cell($size_cellEdu5,6,$_drug_max,1,0,'C');
$y_start+=(6*$maxNum_sub);
#ลงหน้าใหม่
//if($y_start >= 269){
if($y_start >= 259){
$pdf->AddPage();
$pdf->SetFont('Angsana New','B',14);
$y = 10;
$x = 13;
$y+=6;
$size_cellEdu1=27;
$pdf->SetXY($x,$y);
$pdf->Cell($size_cellEdu1,12,"รหัสสถานศึกษา",1,0,'C');
//$y+=7;
$x = $x+$size_cellEdu1;
$size_cellEdu2=30;
$pdf->SetXY($x,$y);
$pdf->Cell($size_cellEdu2,12,"ชื่อสถานศึกษา",1,0,'C');
$x = $x+$size_cellEdu2;
$pdf->SetXY($x,$y);
$size_cellEdu3 = 63;
$pdf->Cell($size_cellEdu3,12,"ที่ตั้งสถานศึกษา",1,0,'C');
$x = $x+$size_cellEdu3;
$pdf->SetXY($x,$y);
$size_cellEdu4 = 25;
$pdf->Cell($size_cellEdu4,12,"นักเรียนที่ติดยา",1,0,'C');
$x = $x+$size_cellEdu4;
$pdf->SetXY($x,$y);
$size_cellEdu5 = 40;
$pdf->Cell($size_cellEdu5,6,"ระดับความรุนแรง",1,0,'C');
$pdf->SetXY($x,$y+6);
$size_cellEdu5 = 13;
$pdf->Cell($size_cellEdu5,6,"น้อย",1,0,'C');
$pdf->SetXY($x+13,$y+6);
$size_cellEdu5 = 14;
$pdf->Cell($size_cellEdu5,6,"ปานกลาง",1,0,'C');
$pdf->SetXY($x+27,$y+6);
$size_cellEdu5 = 13;
$pdf->Cell($size_cellEdu5,6,"มาก",1,0,'C');
$pdf->SetFont('Angsana New','',12);
$y_start = $y+6;
} // end if($y_start)
}//end while()
## End
//<meta http-equiv="Content-Type" content="text/html; charset=tis-620" />
//$y = 270;
//$pdf->c2footer();
$pdf->Output("การแพร่กระจายของยาเสพติดในสถานศึกษา.pdf",'D');
?>