Viewing file: prePrintCarOilPDF.php (13.95 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 *, 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);
$query2 = " SELECT * , formcaroffice.Budget_year as year FROM formcaroffice , autocar_tb , province WHERE formcaroffice.carId = '".$_REQUEST['carId']."' and formcaroffice.carId = autocar_tb.carId and formcaroffice.provinceId = province.provinceId ";
$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 *, 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.Faculty_code = '".$rs['Faculty_code']."' and personal_tb.TeacherId = '1'";
$result4 = $dbObj->execQuery($query4);
$rs4 = $dbObj->fetchArray($result4);
$query5 = " SELECT * FROM autocar_tb WHERE carId='" . $_GET['carId'] . "' AND Teacher_code='" . $_GET['Teacher_code'] . "' ";
$result5 = $dbObj->execQuery($query5);
$rs5 = $dbObj->fetchArray($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";
}
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/caroil.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] + 543);
$pdf->Text(47,35.9,$rs3['collegeName']);
if(!empty($day)){
$pdf->SetXY(139.5,37.8);
$pdf->Cell(8,5,$day,0,0,'C');
$pdf->SetXY(156,37.8);
$pdf->Cell(22,5,$month,0,0,'C');
$pdf->SetXY(184.4,37.8);
$pdf->Cell(12,5,$year,0,0,'C');
}
else{
$pdf->Text(142,41,' - - -');
}
//-- Set Font
$pdf->SetFont('AngsanaNew','',13);
//-- Request header
if(!empty($rs2['CarNo'])){
$pdf->SetXY(32,38);
$pdf->Cell(31.5,5,$rs2['CarNo'],0,0,'C');
}
else{
$pdf->Text(47,41.5,'-');
}
$pdf->Text(37,56.3,'¼ÙéÍӹǡÒà '.$rs3['collegeName']);
//-- Body
$pdf->SetXY(52.5,58.5);
$pdf->Cell(73,5,$rs['First_name'].' '.$rs['Teacher_name'].' '.$rs['Teacher_lastname'],0,0,'C');
$pdf->SetXY(138.5,58.5);
$pdf->Cell(56,5,$rs['Position_name'],0,0,'C');
//$pdf->SetXY(36.5,65.5);
//$pdf->Cell(123,5,$rs['Faculty_name'].' '.$rs3['collegeName'],0,0,'C');
if(!empty($rs2['makeWord'])){
$pdf->SetXY(36.5,65.5);
$pdf->Cell(140,5,$rs2['makeWord'],0,0,'C');
}
else{
$pdf->SetXY(36.5,65.5);
$pdf->Cell(140,5,'-',0,0,'C');
}
if(!empty($rs2['provinceName'])){
$pdf->SetXY(130,65.5);
$pdf->Cell(100,5,$rs2['provinceName'],0,0,'C');
}
else{
$pdf->SetXY(130,65.5);
$pdf->Cell(100,5,'-',0,0,'C');
}
$str = $rs2['Training_name'];
$cutstr = substr($str,0,78);
if(!empty($rs2['Training_name'])){
$pdf->SetXY(74,72.3);
if(strlen($str)>78) {
$pdf->Cell(34,5,$cutstr.'---',0,0,'C');
}
else {
$pdf->Cell(34,5,$cutstr,0,0,'C');
}
}
else{
$pdf->SetXY(74,72.3);
$pdf->Cell(34,5,'-',0,0,'C');
}
if(!empty($rs2['Make'])){
$pdf->SetXY(170,72.3);
$pdf->Cell(12,5,$rs2['Make'],0,0,'C');
}
else{
$pdf->SetXY(170,72.3);
$pdf->Cell(12,5,'-',0,0,'C');
}
/*
if(!empty($rs2['Detail'])){
$pdf->SetXY(41.5,79.2);
$pdf->Cell(151,5,$rs2['Detail'],0,0,'C');
}
else{
$pdf->SetXY(41.5,79.2);
$pdf->Cell(151,5,'-',0,0,'C');
}
$pdf->SetFont('AngsanaNew','B',27);
switch($rs2['Training_type']){
case "1" : $pdf->Text(69.8,89.5,'/'); break;
case "2" : $pdf->Text(89.5,89.5,'/'); break;
case "3" : $pdf->Text(116,89.5,'/'); break;
case "4" : $pdf->Text(132,89.5,'/'); break;
case "5" : $pdf->Text(148,89.5,'/'); break;
case "6" : $pdf->Text(165.5,89.5,'/'); break;
case "7" : $pdf->Text(184,89.5,'/'); break;
}
switch($rs2['object']){
case "1" : $pdf->Text(59.2,96.5,'/'); break;
case "2" : $pdf->Text(76.2,96.5,'/'); break;
case "3" : $pdf->Text(93,96.5,'/'); break;
case "4" : $pdf->Text(116.5,96.5,'/'); break;
case "5" : $pdf->Text(140.2,96.5,'/'); break;
}
if($rs2["PersonIn"] == "ÃѺÇÔ·ÂÒ¡Ã" ){
$pdf->Text(28.5,111,'x');
}
$pdf->SetFont('AngsanaNew','',13);
if(!empty($rs2['year'])){
$pdf->SetXY(173.5,92.5);
$pdf->Cell(21,5,$rs2['year'],0,0,'C');
}
else{
$pdf->SetXY(138,92.5);
$pdf->Cell(22,5,'-',0,0,'C');
}
/*
if(!empty($rs2['Personly'])){
$pdf->SetXY(53.7,106.5);
$pdf->Cell(79,5,$rs2['Personly'],0,0,'C');
}
else{
$pdf->SetXY(53.7,106.5);
$pdf->Cell(79,5,'-',0,0,'C');
}
if(!empty($rs2['Place'])){
$pdf->SetXY(39,113.5);
$pdf->Cell(94,5,$rs2['Place'],0,0,'C');
}
else{
$pdf->SetXY(39,113.5);
$pdf->Cell(94,5,'-',0,0,'C');
}
if(!empty($rs2['TelNo'])){
$pdf->SetXY(146,113.5);
$pdf->Cell(48,5,$rs2['TelNo'],0,0,'C');
}
else{
$pdf->SetXY(146,113.5);
$pdf->Cell(48,5,'-',0,0,'C');
}
if(!empty($rs2['Time_startName']) && $rs2['Time_startName'] != "00:00"){
$pdf->SetXY(144,106.5);
$pdf->Cell(19.5,5,$rs2['Time_startName'].' ¹.',0,0,'C');
}
else{
$pdf->SetXY(144,106.5);
$pdf->Cell(19.5,5,'-',0,0,'C');
}
if(!empty($rs2['Time_finishName']) && $rs2['Time_finishName'] != "00:00"){
$pdf->SetXY(174,106.5);
$pdf->Cell(20,5,$rs2['Time_finishName'].' ¹.',0,0,'C');
}
else{
$pdf->SetXY(174,106.5);
$pdf->Cell(20,5,'-',0,0,'C');
}
*/
$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] + 543);
$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] + 543);
$pdf->SetXY(57.3,86);
$pdf->Cell(43,5,$day_start.' '.$month_start.' '.$year_start,0 ,0,'C');
if(!empty($rs2['Time_start'])){
$pdf->SetXY(107,86);
$pdf->Cell(16,5,$rs2['Time_start'],0,0,'C');
}
else{
$pdf->SetXY(107,86);
$pdf->Cell(16,5,'-',0,0,'C');
}
$pdf->SetXY(48,93);
$pdf->Cell(61.7,5,$day_finish.' '.$month_finish.' '.$year_finish,0,0,'C');
if(!empty($rs2['Time_finish'])){
$pdf->SetXY(107,93);
$pdf->Cell(16,5,$rs2['Time_finish'],0,0,'C');
}
else{
$pdf->SetXY(107,93);
$pdf->Cell(16,5,'-',0,0,'C');
}
$pdf->SetFont('AngsanaNew','',13);
if(!empty($rs5['Number'])){
$pdf->SetXY(55,100);
$pdf->Cell(22,5,$rs5['Number'],0,0,'C');
}
else{
$pdf->SetXY(55,100);
$pdf->Cell(22,5,'-',0,0,'C');
}
if(!empty($rs5['Volume'])){
$pdf->SetXY(82,100);
$pdf->Cell(22,5,$rs5['Volume'],0,0,'C');
}
else{
$pdf->SetXY(82,100);
$pdf->Cell(22,5,'-',0,0,'C');
}
if(!empty($rs5['Mile_start'])){
$pdf->SetXY(57,106.5);
$pdf->Cell(22,5,$rs5['Mile_start'],0,0,'C');
}
else{
$pdf->SetXY(57,106.5);
$pdf->Cell(22,5,'-',0,0,'C');
}
if(!empty($rs5['Mile_finish'])){
$pdf->SetXY(116,106.5);
$pdf->Cell(22,5,$rs5['Mile_finish'],0,0,'C');
}
else{
$pdf->SetXY(116,106.5);
$pdf->Cell(22,5,'-',0,0,'C');
}
if(!empty($rs5['Num_Mile'])){
$pdf->SetXY(157,106.5);
$pdf->Cell(22,5,$rs5['Num_Mile'],0,0,'C');
}
else{
$pdf->SetXY(157,106.5);
$pdf->Cell(22,5,'-',0,0,'C');
}
if(!empty($rs5['Num_Lish'])){
$pdf->SetXY(58,113.5);
$pdf->Cell(22,5,$rs5['Num_Lish'],0,0,'C');
}
else{
$pdf->SetXY(58,113.5);
$pdf->Cell(22,5,'-',0,0,'C');
}
if(!empty($rs5['PriceOill'])){
$pdf->SetXY(105,113.5);
$pdf->Cell(22,5,$rs5['PriceOill'],0,0,'C');
}
else{
$pdf->SetXY(105,113.5);
$pdf->Cell(22,5,'-',0,0,'C');
}
/*
switch($rs2['usecar']){
case "1" : $pdf->Text(139.7,111,'/'); break;
case "2" : $pdf->Text(160.6,111,'/'); break;
}
*/
$pdf->SetFont('AngsanaNew','',13);
if(!empty($rs2['CarmoId'])){
$query5 = "Select * From automobile_tb Where CarmoId = '".$rs2['CarmoId']."' ";
$result5 = $dbObj->execQuery($query5);
$rs5 = $dbObj->fetchArray($result5);
$pdf->SetXY(93,79.5);
$pdf->Cell(140,5,$rs5['Acc_name'].' '.$rs5['Kind'].' ·ÐàºÕ¹ '.$rs5['CodeNo'],0,0,'C');
}
else{
$pdf->SetXY(93,79.5);
$pdf->Cell(140,5,'-',0,0,'C');
}
if(!empty($rs2['name1'])){
$query5 = "Select *, prefixName as First_name FROM personal_tb LEFT JOIN prefix ON personal_tb.First_name = prefix.prefixId Where Teacher_code = '".$rs2['name1']."' ";
$result5 = $dbObj->execQuery($query5);
$rs5 = $dbObj->fetchArray($result5);
$pdf->SetXY(27.5,79.5);
$pdf->Cell(49,5,$rs5['First_name'].' '.$rs5['Teacher_name'].' '.$rs5['Teacher_lastname'],0,0,'C');
}
else{
$pdf->SetXY(27.5,79.5);
$pdf->Cell(49,5,'-',0,0,'C');
}
if(!empty($rs2['name1'])){
$query20 = "Select *, prefixName as First_name FROM personal_tb LEFT JOIN prefix ON personal_tb.First_name = prefix.prefixId Where Teacher_code = '".$rs2['name1']."' ";
$result20 = $dbObj->execQuery($query20);
$rs20 = $dbObj->fetchArray($result20);
$pdf->SetXY(28.5,148);
$pdf->Cell(49,5,$rs20['First_name'].' '.$rs20['Teacher_name'].' '.$rs20['Teacher_lastname'],0,0,'C');
}
else{
$pdf->SetXY(28.5,148);
$pdf->Cell(49,5,'-',0,0,'C');
}
/*
$pdf->SetFont('AngsanaNew','',11);
if(!empty($rs2['Datemile_start'])){
$date_start = explode("-",$rs2['Datemile_start']);
$day_start = intval($date_start[2]);
$month_start = getShortMonthTh(intval($date_start[1]));
$year_start = intval($date_start[0] + 543);
$pdf->SetXY(52,161.7);
$pdf->Cell(21.7,5,$day_start.' '.$month_start.' '.$year_start,1,0,'C');
}
else{
$pdf->SetXY(52,161.7);
$pdf->Cell(21.7,5,'-',0,0,'C');
}
if(!empty($rs2['Datemile_finish'])){
$date_finish = explode("-",$rs2['Datemile_finish']);
$day_finish = intval($date_finish[2]);
$month_finish = getShortMonthTh(intval($date_finish[1]));
$year_finish = intval($date_finish[0] + 543);
$pdf->SetXY(51.7,168.8);
$pdf->Cell(21.7,5,$day_finish.' '.$month_finish.' '.$year_finish,0,0,'C');
}
else{
$pdf->SetXY(51.7,168.8);
$pdf->Cell(21.7,5,'-',0,0,'C');
}
$pdf->SetFont('AngsanaNew','',13);
if(!empty($rs2['Mile_start'])){
$pdf->SetXY(86.5,161.7);
$pdf->Cell(22,5,$rs2['Mile_start'],0,0,'C');
}
else{
$pdf->SetXY(86.5,161.7);
$pdf->Cell(22,5,'-',0,0,'C');
}
if(!empty($rs2['Mile_finish'])){
$pdf->SetXY(86.5,168.5);
$pdf->Cell(22,5,$rs2['Mile_finish'],0,0,'C');
}
else{
$pdf->SetXY(86.5,168.5);
$pdf->Cell(22,5,'-',0,0,'C');
}
/*$pdf->SetFont('AngsanaNew','B',27);
switch($rs2['Travel']){
case "1" : $pdf->Text(73.6,71.3,'/'); break;
case "2" : $pdf->Text(125.7,71,'/'); break;
case "3" : $pdf->Text(165,71,'/'); break;
case "4" : $pdf->Text(73.6,77,'/'); break;
case "5" : $pdf->Text(125.9,77,'/'); break;
}
$pdf->SetFont('AngsanaNew','',13);
if(!empty($rs2['No_in'])){
$pdf->SetXY(48,77.9);
$pdf->Cell(99,5,$rs2['No_in'],0,0,'C');
}
else{
$pdf->Text(90,81.5,'-');
}
$pdf->SetXY(22,85);
$pdf->Cell(177,5,$rs2['Training_name'],0,0,'C');
$pdf->Text(27,95.7,$rs5['CNEU']);
$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->SetXY(52.8,133.2);
$pdf->Cell(30,5,$day_start.' '.$month_start.' '.$year_start,0,0,'C');
$pdf->SetXY(105.9,133.2);
$pdf->Cell(30,5,$day_finish.' '.$month_finish.' '.$year_finish,0,0,'C');
$pdf->SetXY(142.2,133.2);
$pdf->Cell(8,5,$rs2['Day'],0,0,'C');
if(!empty($rs2['assignMent'])){
$pdf->SetXY(126.5,140);
$pdf->Cell(71,5,$rs2['assignMent'],0,0,'C');
}
else{
$pdf->Text(160,143.5,'-');
}
if(!empty($rs2['assignmentName'])){
$pdf->SetXY(25,146.8);
$pdf->Cell(43,5,$rs2['assignmentName'],0,0,'C');
}
else{
$pdf->Text(45,150.5,'-');
}*/
//-- signature
$pdf->SetXY(142,127.3);
$pdf->Cell(51,5,$rs['First_name'].' '.$rs['Teacher_name'].' '.$rs['Teacher_lastname'],0,0,'C');
$pdf->SetXY(142,134.5);
$pdf->Cell(49,5,$rs['Position_name'],0,0,'C');
$pdf->SetXY(146,181);
$pdf->Cell(50,5,$rs4['First_name'].' '.$rs4['Teacher_name'].' '.$rs4['Teacher_lastname'],0,0,'C');
$pdf->SetXY(146.8,187.5);
$pdf->Cell(49,5,$rs4['Position_name'],0,0,'C');
//Create file
$pdf->Output();
?>
|