Viewing file: prePrintAbsentPDF.php (8.15 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/connMySQL.class.php");
require('../fpdf/fpdf.php');
/** Create Database Object */
$dbObj = new DBConn;
/** Config Table for This Page */
$myTable = "personal_tb";
$myTable1 = "budget_year_tb";
$myTable2 = "history_absent_tb";
$query = " SELECT * FROM personal_tb , position_tb , faculty_tb , district , amphur , province WHERE personal_tb.Teacher_code='".$_REQUEST['Teacher_code']."' and personal_tb.PositionId = position_tb.PositionId and personal_tb.Faculty_code = faculty_tb.Faculty_code and district.districtId = personal_tb.districtId and amphur.amphurId=district.amphurId and province.provinceId=amphur.provinceId";
$result = $dbObj->execQuery($query);
$rs = $dbObj->fetchArray($result);
$query2 = " SELECT * FROM history_absent_tb , history_absent WHERE history_absent_tb.code='$code' and history_absent_tb.Absent_code = history_absent.Absent_code";
$result2 = $dbObj->execQuery($query2);
$rs2 = $dbObj->fetchArray($result2);
$query3 = "Select * From college Where collegeStatus ='1'";
$result3 = $dbObj->execQuery($query3);
$rs3 = $dbObj->fetchArray($result3);
$query4 = "Select * From personal_tb , position_tb Where personal_tb.PositionId = position_tb.PositionId and personal_tb.Faculty_code = '".$rs['Faculty_code']."' and TeacherId = '1' ";
$result4 = $dbObj->execQuery($query4);
$rs4 = $dbObj->fetchArray($result4);
$query5 = "select * from history_absent_tb where Absent_code = '".$rs2['Absent_code']."' and Teacher_code = '".$rs['Teacher_code']."' and Year = '".$rs2['Year']."' and Date_finish < '".$rs2['Date_finish']."' order by Date_finish DESC";
$result5 = $dbObj->execQuery($query5);
$rs5 = $dbObj->fetchArray($result5);
$num_rows = mysql_num_rows($result5);
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";
}
//Create new pdf file
$pdf = new FPDF();
//Set thai font
$pdf->SetThaiFont();
$pdf->AddPage();
//-- Load Form Image to BAckground
$pdf->Image('../form/absent_form_01.jpg', 0, 0, 210, 297);
//-- Set Font
$pdf->SetFont('AngsanaNew','',15);
//-- College name and Date , Top-Right Position
$date = explode("-",$rs2[Date]);
$day = intval($date[2]);
$month = getMonthTh(intval($date[1]));
$year = intval($date[0]);
$pdf->SetXY(61,32);
$pdf->Cell(130,5,$rs3['collegeName'],0,0,'R');
if(!empty($day)){
$pdf->SetXY(122,38);
$pdf->Cell(9,5,$day,0,0,'C');
$pdf->SetXY(139.7,38);
$pdf->Cell(31,5,$month,0,0,'C');
$pdf->SetXY(177.8,38);
$pdf->Cell(12,5,$year,0,0,'C');
}
else{
$pdf->Text(144,33,' - - -');
}
//-- Set Font
$pdf->SetFont('AngsanaNew','',13);
//-- Request header
if(!empty($rs2['AbsentNo'])){
$pdf->Text(34,42,$rs2['AbsentNo']);
}
else{
$pdf->Text(43,42,'-');
}
$pdf->Text(47,49.6,$rs2['Absent_type']);
$pdf->Text(38,57.5,'ผู้อำนวยการ '.$rs3['collegeName']);
//-- Body
$pdf->Text(68,64.6,$rs['First_name'].' '.$rs['Teacher_name'].' '.$rs['Teacher_lastname']);
$pdf->Text(135,64.6,$rs['Position_name']);
$pdf->Text(39,72,$rs['Faculty_name'].' '.$rs3['collegeName'].' สถาบันพระบรมราชชนก');
if($rs2['Absent_code'] == 2){
$pdf->SetFont('AngsanaNew','',16);
$pdf->Text(62,80.5,'X');
$pdf->Text(50.5,110.5,'X');
}
if($rs2['Absent_code'] == 1){
$pdf->SetFont('AngsanaNew','',16);
$pdf->Text(61.8,88,'X');
$pdf->Text(66,110.5,'X');
}
if($rs2['Absent_code'] == 4){
$pdf->SetFont('AngsanaNew','',16);
$pdf->Text(62,95.3,'X');
$pdf->Text(90.7,110.5,'X');
}
$pdf->SetFont('AngsanaNew','',13);
if(!empty($rs2['Absent_type'])){
$pdf->Text(105,87,$rs2['Absent_type']);
}
else{
$pdf->Text(110,87,'-');
}
$date_start = explode("-",$rs2['Date_start']);
$day_start = intval($date_start[2]);
$month_start = getMonthTh(intval($date_start[1]));
$year_start = intval($date_start[0]);
$date_finish = explode("-",$rs2['Date_finish']);
$day_finish = intval($date_finish[2]);
$month_finish = getMonthTh(intval($date_finish[1]));
$year_finish = intval($date_finish[0]);
$pdf->Text(50,102,$day_start.' '.$month_start.' '.$year_start);
$pdf->Text(108,102,$day_finish.' '.$month_finish.' '.$year_finish);
$pdf->Text(172,102,$rs2['Absent_times']);
if($num_rows){
$last_date_start = explode("-",$rs5['Date_start']);
$last_day_start = intval($last_date_start[2]);
$last_month_start = getMonthTh(intval($last_date_start[1]));
$last_year_start = intval($last_date_start[0]);
$last_date_finish = explode("-",$rs5['Date_finish']);
$last_day_finish = intval($last_date_finish[2]);
$last_month_finish = getMonthTh(intval($last_date_finish[1]));
$last_year_finish = intval($last_date_finish[0]);
$pdf->Text(155,109.5,$last_day_start.' '.$last_month_start.' '.$last_year_start);
$pdf->Text(44,117,$last_day_finish.' '.$last_month_finish.' '.$last_year_finish);
$pdf->Text(94,117,$rs5['Absent_times']);
}
else{
$pdf->Text(168,109,'-');
$pdf->Text(58,117,'-');
$pdf->Text(95,117,'-');
}
$pdf->Text(40,124.5,$rs['Address'].' ต.'.$rs['districtName'].' อ.'.$rs['amphurName'].' จ.'.$rs['provinceName']);
//-- Absent Tables
$pdf->SetFont('AngsanaNew','',15);
$pdf->Text(83,170.4,$rs2['Year']);
$Teacher_code = $rs["Teacher_code"];
$query11 = "Select Sum(Absent_times) as SumB1 From history_absent_tb Where Teacher_code='$Teacher_code' and Year='$Year' and Absent_code='2' and Date_finish < '".$rs2['Date_finish']."' " ;
$result11 = $dbObj->execQuery($query11);
$rs11 = $dbObj->fetchArray($result11);
$pdf->SetXY(46,182);
$pdf->Cell(20,5,number_format($rs11[SumB1],1,'.',','),0,0,'C');
$pdf->Cell(18,5,$rs2['Absent_code']==2?number_format($rs2['Absent_times'],1,'.',','):"0.0",0,0,'C');
$pdf->Cell(20.5,5,$rs2['Absent_code']==2?number_format(($rs11[SumB1]+$rs2['Absent_times']),1,'.',','):number_format($rs11[SumB1],1,'.',','),0,0,'C');
$query11 = "Select Sum(Absent_times) as SumB1 From history_absent_tb Where Teacher_code='$Teacher_code' and Year='$Year' and Absent_code='1' and Date_finish < '".$rs2['Date_finish']."' " ;
$result11 = $dbObj->execQuery($query11);
$rs11 = $dbObj->fetchArray($result11);
$pdf->SetXY(46,189);
$pdf->Cell(20,5,number_format($rs11[SumB1],1,'.',','),0,0,'C');
$pdf->Cell(18,5,$rs2['Absent_code']==1?number_format($rs2['Absent_times'],1,'.',','):"0.0",0,0,'C');
$pdf->Cell(20.5,5,$rs2['Absent_code']==1?number_format(($rs11[SumB1]+$rs2['Absent_times']),1,'.',','):number_format($rs11[SumB1],1,'.',','),0,0,'C');
$query11 = "Select Sum(Absent_times) as SumB1 From history_absent_tb Where Teacher_code='$Teacher_code' and Year='$Year' and Absent_code='4' and Date_finish < '".$rs2['Date_finish']."' " ;
$result11 = $dbObj->execQuery($query11);
$rs11 = $dbObj->fetchArray($result11);
$pdf->SetXY(46,197);
$pdf->Cell(20,5,number_format($rs11[SumB1],1,'.',','),0,0,'C');
$pdf->Cell(18,5,$rs2['Absent_code']==4?number_format($rs2['Absent_times'],1,'.',','):"0.0",0,0,'C');
$pdf->Cell(20.5,5,$rs2['Absent_code']==4?number_format(($rs11[SumB1]+$rs2['Absent_times']),1,'.',','):number_format($rs11[SumB1],1,'.',','),0,0,'C');
//-- signature
$pdf->SetFont('AngsanaNew','',13);
$pdf->SetXY(117,150.7);
$pdf->Cell(54,5,$rs['First_name'].' '.$rs['Teacher_name'].' '.$rs['Teacher_lastname'],0,0,'C');
$pdf->SetXY(125.2,196.2);
$pdf->Cell(54,5,$rs4['First_name'].' '.$rs4['Teacher_name'].' '.$rs4['Teacher_lastname'],0,0,'C');
$pdf->SetXY(127.6,203.8);
$pdf->Cell(51,5,$rs4['Position_name'],0,0,'C');
//Create file
$pdf->Output();
?>
|