Viewing file: prePrintPlanMemoPDF.php (5.52 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;
$query = " SELECT * FROM personal_tb , position_tb , faculty_tb WHERE personal_tb.Teacher_code='".$_REQUEST['Teacher_code']."' and personal_tb.PositionId = position_tb.PositionId and personal_tb.Faculty_code = faculty_tb.Faculty_code";
$result = $dbObj->execQuery($query);
$rs = $dbObj->fetchArray($result);
$query2 = " SELECT * , formproject.Budget_use as formproject_Budget_use , project_type_tb.Budget_total as project_type_tb_Budget_total FROM formproject , project_tb , project_type_tb , money_source_tb WHERE formproject.proId = '".$_REQUEST['proId']."' and formproject.proId = project_tb.proId and formproject.ProjectId = project_type_tb.ProjectId and project_tb.MoneyS_C = money_source_tb.MoneyS_C ";
$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 training_tb WHERE training_tb.Training_code = '".$_REQUEST['Training_code']."' ";
$result5 = $dbObj->execQuery($query5);
$rs5 = $dbObj->fetchArray($result5);*/
$query6 = " SELECT SUM(Budget_use) AS SumB1 FROM project_tb WHERE ProjectId='".$rs2['ProjectId']."' ";
$result6 = $dbObj->execQuery($query6);
$rs6 = $dbObj->fetchArray($result6);
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/plan_memo3.jpg', 0, 0, 205, 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->Text(40,46.7,$rs3['collegeName']);
if(!empty($day)){
$pdf->SetXY(138.5,48.5);
$pdf->Cell(9,5,$day,0,0,'C');
$pdf->SetXY(155,48.5);
$pdf->Cell(23,5,$month,0,0,'C');
$pdf->SetXY(183,48.5);
$pdf->Cell(12,5,$year,0,0,'C');
}
else{
$pdf->SetXY(138.5,48.5);
$pdf->Cell(9,5,'-',0,0,'C');
$pdf->SetXY(155,48.5);
$pdf->Cell(23,5,'-',0,0,'C');
$pdf->SetXY(183,48.5);
$pdf->Cell(12,5,'-',0,0,'C');
}
//-- Set Font
$pdf->SetFont('AngsanaNew','',13);
//-- Request header
if(!empty($rs2['proNo'])){
$pdf->SetXY(23.5,48.8);
$pdf->Cell(34,5,$rs2['proNo'],0,0,'C');
}
else{
$pdf->SetXY(23.5,48.8);
$pdf->Cell(34,5,'-',0,0,'C');
}
$pdf->Text(30,66.7,'ผู้อำนวยการ '.$rs3['collegeName']);
//-- Body
$pdf->SetXY(31,69.5);
$pdf->Cell(88.3,5,$rs['First_name'].' '.$rs['Teacher_name'].' '.$rs['Teacher_lastname'],0,0,'C');
$pdf->SetXY(131.5,69.5);
$pdf->Cell(63,5,$rs['Position_name'],0,0,'C');
$pdf->SetXY(28.9,76.5);
$pdf->Cell(166,5,$rs['Faculty_name'].' '.$rs3['collegeName'].' สถาบันพระบรมราชชนก',0,0,'C');
if(strlen($rs2['Training_name']) > 100){
$tmp[0] = substr($rs2['Training_name'],0,91);
$tmp[1] = substr($rs2['Training_name'],91,strlen($rs2['Training_name']));
$pdf->SetXY(65,83.3);
$pdf->Cell(130,5,$tmp[0],0,0,'C');
$pdf->SetXY(21,90.3);
$pdf->Cell(174,5,$tmp[1],0,0,'L');
}
else{
$pdf->SetXY(65,83.3);
$pdf->Cell(130,5,$rs2['Training_name'],0,0,'C');
}
$pdf->SetXY(59.7,97);
$pdf->Cell(8.7,5,$rs2['Orderlist'],0,0,'C');
$pdf->SetXY(93.7,97);
$pdf->Cell(101,5,$rs2['Project_plan'],0,0,'C');
$pdf->SetXY(39.5,104);
$pdf->Cell(26.5,5,$rs2['Year_std'],0,0,'C');
$pdf->SetXY(81,104);
$pdf->Cell(32.5,5,number_format($rs2['formproject_Budget_use'],2,'.',','),0,0,'C');
$pdf->SetXY(134.3,104);
$pdf->Cell(60.5,5,$rs2['MoneyS_M'],0,0,'C');
$pdf->SetXY(67.7,110.8);
$pdf->Cell(32.5,5,number_format($rs2['project_type_tb_Budget_total'],2,'.',','),0,0,'C');
$pdf->SetXY(151.5,110.8);
$pdf->Cell(31.9,5,number_format($rs6['SumB1'],2,'.',','),0,0,'C');
$pdf->SetXY(59.5,117.7);
$pdf->Cell(31.9,5,number_format($rs2['project_type_tb_Budget_total'] - $rs6['SumB1'],2,'.',','),0,0,'C');
//-- signature
$pdf->SetXY(133,156);
$pdf->Cell(60,5,$rs['First_name'].' '.$rs['Teacher_name'].' '.$rs['Teacher_lastname'],0,0,'C');
$pdf->SetXY(138,162.8);
$pdf->Cell(55,5,$rs['Position_name'],0,0,'C');
$pdf->SetXY(40.3,182.3);
$pdf->Cell(50.5,5,$rs4['First_name'].' '.$rs4['Teacher_name'].' '.$rs4['Teacher_lastname'],0,0,'C');
$pdf->SetXY(46,189.2);
$pdf->Cell(53,5,$rs4['Position_name'],0,0,'C');
//Create file
$pdf->Output();
?>
|