Viewing file: prePrintRoomPDF.php (6.98 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
//PDF USING MULTIPLE PAGES
//FILE CREATED BY: Carlos Jos? V?squez S?ez
//YOU CAN CONTACT ME: carlos@magallaneslibre.com
//FROM PUNTA ARENAS, MAGALLANES
//INOVO GROUP - http://www.inovo.cl
/** Configuration */
require_once( "../configuration.php" );
// require_once( $_Config_absolute_path . "/includes/framework.php" );
// require_once( "../include/Function.php" );
// require_once( "../include/FunctionDB.php" );
// require_once( "../calendar/check.php" );
// require_once( "../calendar/cal_func.php" );
require_once( $_Config_absolute_path . "/includes/connMySQL.class.php");
require('../fpdf/fpdf.php');
/** Create Database Object */
$dbObj = new DBConn;
/** Config Table for This Page */
$myTable1 = "personal_tb";
$myTable2 = "room_rent";
/** Table --> personal_tb */
$query = "SELECT *, prefixName as First_name FROM personal_tb LEFT JOIN prefix ON personal_tb.First_name = prefix.prefixId LEFT JOIN position_tb ON personal_tb.PositionId = position_tb.PositionId LEFT JOIN faculty_tb ON personal_tb.Faculty_code = faculty_tb.Faculty_code WHERE personal_tb.Teacher_code='".$_REQUEST['Teacher_code']."'";
$result = $dbObj->execQuery($query);
$rs = $dbObj->fetchArray($result);
/** Table --> tech_plan_tb */
$query1 = " SELECT * FROM $myTable2 WHERE Rent_code='$Rent_code' ";
$result1 = $dbObj->execQuery($query1);
$rs1 = $dbObj->fetchArray($result1);
$query3 = "Select * From college Where collegeStatus ='1'";
$result3 = $dbObj->execQuery($query3);
$rs3 = $dbObj->fetchArray($result3);
function getMonthTh($mm) {
if($mm=='01') { $mm='มกราคม'; }
else if($mm=='02') { $mm='กุมภาพันธ์'; }
else if($mm=='03') { $mm='มีนาคม'; }
else if($mm=='04') { $mm='เมษายน'; }
else if($mm=='05') { $mm='พฤษภาคม';}
else if($mm=='06') { $mm='มิถุนายน'; }
else if($mm=='07') { $mm='กรกฎาคม'; }
else if($mm=='08') { $mm='สิงหาคม'; }
else if($mm=='09') { $mm='กันยายน'; }
else if($mm=='10') { $mm='ตุลาคม';}
else if($mm=='11') { $mm='พฤศจิกายน';}
else if($mm=='12') { $mm='ธันวาคม'; }
return "$mm";
}
function getShortMonthTh($mm) {
if($mm=='01') { $mm='ม.ค.'; }
else if($mm=='02') { $mm='ก.พ.'; }
else if($mm=='03') { $mm='มี.ค.'; }
else if($mm=='04') { $mm='เม.ย.'; }
else if($mm=='05') { $mm='พ.ค.';}
else if($mm=='06') { $mm='มิ.ย.'; }
else if($mm=='07') { $mm='ก.ค.'; }
else if($mm=='08') { $mm='ส.ค.'; }
else if($mm=='09') { $mm='ก.ย.'; }
else if($mm=='10') { $mm='ต.ค.';}
else if($mm=='11') { $mm='พ.ย.';}
else if($mm=='12') { $mm='ธ.ค.'; }
return "$mm";
}
//Create new pdf file
$pdf = new FPDF();
//Set thai font
$pdf->SetThaiFont();
$pdf->AddPage();
//-- Load Form Image to Background
$pdf->Image('../form/room.jpg', 0, 0, 210, 297);
//-- Set Font
$pdf->SetFont('AngsanaNew','',15);
//-- College name and Date , Top-Right Position
$date = explode("-",$rs1[Rent_date]);
$day = intval($date[2]);
$month = getMonthTh(intval($date[1]));
$year = intval($date[0] + 543);
if(!empty($day)){
$pdf->SetXY(134.5,48.8);
$pdf->Cell(8,5,$day,0,0,'C');
$pdf->SetXY(151,48.8);
$pdf->Cell(22,5,$month,0,0,'C');
$pdf->SetXY(183,48.8);
$pdf->Cell(12,5,$year,0,0,'C');
}
else{
$pdf->Text(142,41,' - - -');
}
//-- Set Font
$pdf->SetFont('AngsanaNew','',13);
//-- ส่วนราชการ
if(!empty($rs['Faculty_name'])){
$pdf->SetXY(62,42);
$pdf->Cell(50.5,5,$rs['Faculty_name'],0,0,'C');
}
// ที่
if(!empty($rs1['RoomNo'])){
$pdf->SetXY(25,49.5);
$pdf->Cell(31.5,5,$rs1['RoomNo'],0,0,'C');
}
// เรียน
$pdf->Text(35,66.5,'ผู้อำนวยการ '.$rs3['collegeName']);
// ด้วย ภาค/ฝ่าย
if(!empty($rs['Faculty_name'])){
$pdf->SetXY(85,70);
$pdf->Cell(50.5,5,$rs['Faculty_name'],0,0,'C');
}
// ห้องประชุม
$sql = " SELECT * FROM room_tb LEFT JOIN room_rent ON room_tb.Room_code=room_rent.Room_code WHERE room_rent.Room_code = '".$rs1['Room_code']."' ";
$query = mysql_query($sql);
$result = mysql_fetch_array($query);
if(!empty($result['Room_name'])){
$pdf->SetXY(85,77);
$pdf->Cell(50.5,5,$result['Room_code']." ".$result['Room_type']." : ".$result['Room_name'],0,0,'C');
}
$pdf->SetFont('AngsanaNew','',13);
// ในระหว่างวันที่
$date_start = explode("-",$rs1['Date_start']);
$day_start = intval($date_start[2]);
$month_start = getMonthTh(intval($date_start[1]));
$year_start = intval($date_start[0] + 543);
$pdf->SetXY(48,83.6);
$pdf->Cell(43,5,$day_start.' '.$month_start.' '.$year_start,0 ,0,'C');
// เวลา
if(!empty($rs1['Time_start'])){
$pdf->SetXY(95.5,83.6);
$pdf->Cell(16,5,$rs1['Time_start'],0,0,'C');
}
else{
$pdf->SetXY(95.5,83.6);
$pdf->Cell(16,5,'-',0,0,'C');
}
// ถึงวันที่
$date_finish = explode("-",$rs1['Date_finish']);
$day_finish = intval($date_finish[2]);
$month_finish = getMonthTh(intval($date_finish[1]));
$year_finish = intval($date_finish[0] + 543);
$pdf->SetXY(115,83.6);
$pdf->Cell(61.7,5,$day_finish.' '.$month_finish.' '.$year_finish,0,0,'C');
// เวลา
if(!empty($rs1['Time_finish'])){
$pdf->SetXY(175,83.6);
$pdf->Cell(16,5,$rs1['Time_finish'],0,0,'C');
}
else{
$pdf->SetXY(175,83.6);
$pdf->Cell(16,5,'-',0,0,'C');
}
// เพื่อจัดประชุม เรื่อง
$str = $rs1['Topic'];
$cutstr = substr($str,0,78);
if(!empty($rs1['Topic'])){
$pdf->SetXY(110,90.5);
if(strlen($str)>78) {
$pdf->Cell(34,5,$cutstr.'---',0,0,'C');
}
else {
$pdf->Cell(34,5,$cutstr,0,0,'C');
}
}
else{
$pdf->SetXY(110,90.5);
$pdf->Cell(34,5,'-',0,0,'C');
}
// จำนวนคน
if(!empty($rs1['Make'])){
$pdf->SetXY(40,97.2);
$pdf->Cell(12,5,$rs1['Make'],0,0,'C');
}
else{
$pdf->SetXY(160,70.3);
$pdf->Cell(12,5,'-',0,0,'C');
}
$pdf->SetFont('AngsanaNew','',20);
switch($rs1['Check_format']){
case "1" : $pdf->Text(32.5,116,'X'); break;
}
switch($rs1['Check_tool']){
case "2" : $pdf->Text(32.5,122.8,'X'); break;
}
switch($rs1['Check_food']){
case "3" : $pdf->Text(32.5,129.5,'X'); break;
}
$pdf->SetFont('AngsanaNew','',13);
// Detail_format
if(!empty($rs1['Detail_format'])){
$pdf->SetXY(55,110.2);
$pdf->Cell(50,5,$rs1['Detail_format'],0,0,'C');
}
else{
$pdf->SetXY(55,110.2);
$pdf->Cell(151,5,'-',0,0,'C');
}
// Detail_tool
if(!empty($rs1['Detail_tool'])){
$pdf->SetXY(59,116.7);
$pdf->Cell(50,5,$rs1['Detail_tool'],0,0,'C');
}
else{
$pdf->SetXY(59,116.7);
$pdf->Cell(151,5,'-',0,0,'C');
}
// Detail_food
if(!empty($rs1['Detail_food'])){
$pdf->SetXY(60,123.5);
$pdf->Cell(50,5,$rs1['Detail_food'],0,0,'C');
}
else{
$pdf->SetXY(60,123.5);
$pdf->Cell(151,5,'-',0,0,'C');
}
// ลงชื่อ
$pdf->SetXY(121,167);
$pdf->Cell(51,5,$rs['First_name'].' '.$rs['Teacher_name'].' '.$rs['Teacher_lastname'],0,0,'C');
$pdf->SetXY(125.5,174);
$pdf->Cell(49,5,$rs['Position_name'],0,0,'C');
// เนื่องจาก
if(!empty($rs1['Detail'])){
$pdf->SetXY(125,224.5);
$pdf->Cell(50,5,$rs1['Detail'],0,0,'C');
}
else{
$pdf->SetXY(125,224.5);
$pdf->Cell(50,5,'-',0,0,'C');
}
//Create file
$pdf->Output();
?>
|