Viewing file: prePrintCarOil2.php (16 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;
$Username = $valid_user;
/** Config Table for This Page */
$myTable1 = "personal_tb";
$myTable2 = "formcaroffice";
$myTable3 = "province";
$myTable4 = "training_tb";
/** Table --> tech_plan_tb */
$query1 = " SELECT * FROM $myTable2 WHERE carId='$carId' AND Teacher_code='$Teacher_code' ";
$result1 = $dbObj->execQuery($query1);
$rs1 = $dbObj->fetchArray($result1);
// find àª×éÍà¾ÅÔ§§ autocar_tb
$query11 = " SELECT * FROM autocar_tb WHERE carId='$carId' ";
$result11 = $dbObj->execQuery($query11);
$rs11 = $dbObj->fetchArray($result11);
//--------------
$query = " SELECT * FROM formcaroffice Where Teacher_code='$Teacher_code' Group By CarNo ";
$result = $dbObj->execQuery($query);
$rs3 = $dbObj->fetchArray($result);
//$Teacher_code = $rss['Teacher_code'];
/** Table --> techplan_method_tb */
$query2 = " SELECT * FROM $myTable3 WHERE ProvinceId='$rs1[ProvinceId]' ";
$result2 = $dbObj->execQuery($query2);
$rs2 = $dbObj->fetchArray($result2);
//---------------
$query = " SELECT * FROM autocar_tb at , formcaroffice fc WHERE at.carId=fc.carId and fc.CarNo='$CarNo' ";
$result5 = $dbObj->execQuery($query);
$numrows = $dbObj->_numrows;
//---------------
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('L' , 'mm' , 'A4');
//Set thai font
$pdf->SetThaiFont();
$pdf->AddPage();
//-- Load Form Image to Background
$pdf->Image('../form/caroil2.jpg', 0, 0, 297, 210);
//-- Set Font
$pdf->SetFont('AngsanaNew','',13);
//-- ·Õè
if(!empty($CarNo)){
$pdf->SetXY(22,33.5);
$pdf->Cell(45,5,$CarNo,0,0,'C');
}
else{
$pdf->SetXY(22,33.5);
$pdf->Cell(45,5,'-',0,0,'C');
}
//-- Çѹ·Õè¢Íãªéö Çѹ·Õè
$query1 = " SELECT * FROM formcaroffice WHERE CarNo='$CarNo' ";
$result1 = $dbObj->execQuery($query1);
$rs = $dbObj->fetchObject($result1);
$sday = $rs->Date_start ;
$yearthai = explode("-",$sday);
$day = intval($yearthai[2]);
$month = getMonthTh(intval($yearthai[1]));
$year = intval($yearthai[0]+543);
if(!empty($day)){
$pdf->SetXY(105,33.5);
$pdf->Cell(20,5,"$day "." "." $month "." "." $year",0,0,'C');
}
else{
$pdf->SetXY(105,33.5);
$pdf->Cell(20,5,'-',0,0,'C');
}
//-- ÊÔé¹ÊØ´Çѹ·Õè
$sday = $rs->Date_finish;
$yearthai = explode("-",$sday);
$day = intval($yearthai[2]);
$month = getMonthTh(intval($yearthai[1]));
$year = intval($yearthai[0]+543);
if(!empty($day)){
$pdf->SetXY(160,33.5);
$pdf->Cell(20,5,"$day "." "." $month "." "." $year",0,0,'C');
}
else{
$pdf->SetXY(105,33.5);
$pdf->Cell(20,5,'-',0,0,'C');
}
//-- àÇÅÒÍÍ¡à´Ô¹·Ò§
$Time_start = $rs->Time_start;
if(!empty($Time_start)){
$pdf->SetXY(218,33.5);
$pdf->Cell(10,5,$Time_start,0,0,'C');
}
else{
$pdf->SetXY(218,33.5);
$pdf->Cell(10,5,'-',0,0,'C');
}
//-- àÇÅÒ¶Ö§
$Time_finish = $rs->Time_finish;
if(!empty($Time_finish)){
$pdf->SetXY(260.5,33.5);
$pdf->Cell(10,5,$Time_finish,0,0,'C');
}
else{
$pdf->SetXY(260.5,33.5);
$pdf->Cell(10,5,'-',0,0,'C');
}
//-- ª×èͼÙé¢Íãªé
$Teacher_code = $Teacher_code ;
$sql11 = " Select *, prefixName as First_name FROM personal_tb LEFT JOIN prefix ON personal_tb.First_name = prefix.prefixId Where Teacher_code='$Teacher_code' ";
$result11 = mysql_query($sql11);
$rs11 = mysql_fetch_array($result11);
if(!empty($Teacher_code)){
$pdf->SetXY(42,40);
$pdf->Cell(30,5,$rs11[First_name]." ".$rs11[Teacher_name]." ".$rs11[Teacher_lastname],0,0,'C');
}
else{
$pdf->SetXY(42,40);
$pdf->Cell(30,5,'-',0,0,'C');
}
//-- à¾×èÍ
$Training_name = $rs->Training_name;
$cutstr = substr($Training_name,0,70);
if(!empty($Training_name)){
$pdf->SetXY(141.5,40);
if(strlen($Training_name)>70) {
$pdf->Cell(80,5,$cutstr.'--',0,0,'C');
}
else {
$pdf->Cell(80,5,$cutstr,0,0,'C');
}
}
else{
$pdf->SetXY(141.5,40);
$pdf->Cell(80,5,'-',0,0,'C');
}
//-- ¨Ñ§ËÇÑ´
$query2 = " SELECT * FROM $myTable3 WHERE provinceId='$rs3[provinceId]' ";
$result2 = $dbObj->execQuery($query2);
$rs2 = $dbObj->fetchArray($result2);
if(!empty($rs2[provinceName])){
$pdf->SetXY(243,40);
$pdf->Cell(30,5,$rs2[provinceName],0,0,'C');
}
else{
$pdf->SetXY(243,40);
$pdf->Cell(30,5,'-',0,0,'C');
}
//-- àŢ˹éһѷÁì
$sql = " SELECT min(Mile_start) Mile_start FROM autocar_tb at , formcaroffice fc WHERE at.carId=fc.carId and fc.CarNo='$CarNo' ";
$result1 = mysql_query($sql);
$rss = mysql_fetch_array($result1);
if(!empty($rss['Mile_start'])){
$pdf->SetXY(57,46.5);
$pdf->Cell(15,5,number_format($rss['Mile_start'],'','',','),0,0,'C');
}
else{
$pdf->SetXY(57,46.5);
$pdf->Cell(15,5,'-',0,0,'C');
}
//-- ¶Ö§àŢ˹éһѷÁì
$sql = " SELECT max(Mile_finish) Mile_finish FROM autocar_tb at , formcaroffice fc WHERE at.carId=fc.carId and fc.CarNo='$CarNo' ";
$result1 = mysql_query($sql);
$rss = mysql_fetch_array($result1);
if(!empty($rss['Mile_finish'])){
$pdf->SetXY(112,46.5);
$pdf->Cell(15,5,number_format($rss['Mile_finish'],'','',','),0,0,'C');
}
else{
$pdf->SetXY(112,46.5);
$pdf->Cell(15,5,'-',0,0,'C');
}
//-- ÃÇÁÃÐÂзҧ
$sql1 = " SELECT SUM(Num_Mile) AS SumB4 FROM autocar_tb at , formcaroffice fc WHERE at.carId=fc.carId and fc.CarNo='$CarNo' ";
$result1 = mysql_query($sql1);
$rss1 = mysql_fetch_array($result1);
if(!empty($rss1['SumB4'])){
$pdf->SetXY(155.5,46.5);
$pdf->Cell(15,5,number_format($rss1['SumB4'],'','',',')." ¡Á.",0,0,'C');
}
else{
$pdf->SetXY(155.5,46.5);
$pdf->Cell(15,5,'-',0,0,'C');
}
//-- ¨Ó¹Ç¹¤èÒàª×éÍà¾ÅÔ§
$sql1 = " SELECT SUM(Num_Lish) AS SumB5 FROM autocar_tb at , formcaroffice fc WHERE at.carId=fc.carId and fc.CarNo='$CarNo' ";
$result1 = mysql_query($sql1);
$rss1 = mysql_fetch_array($result1);
if(!empty($rss1['SumB5'])){
$pdf->SetXY(205,46.5);
$pdf->Cell(15,5,number_format($rss1['SumB5'],'','',','),0,0,'C');
}
else{
$pdf->SetXY(205,46.5);
$pdf->Cell(15,5,'-',0,0,'C');
}
//-- à»ç¹à§Ô¹
$sql1 = " SELECT SUM(PriceOill) AS SumB6 FROM autocar_tb at , formcaroffice fc WHERE at.carId=fc.carId and fc.CarNo='$CarNo' ";
$result1 = mysql_query($sql1);
$rss1 = mysql_fetch_array($result1);
if(!empty($rss1['SumB6'])){
$pdf->SetXY(248,46.5);
$pdf->Cell(15,5,number_format($rss1['SumB6'],'2','.',','),0,0,'C');
}
else{
$pdf->SetXY(248,46.5);
$pdf->Cell(15,5,'-',0,0,'C');
}
//-- ¤ÍÅÑÁ¹ìàÇÅÒ
if($numrows){
$i = 1;
while( $rs7 = $dbObj->fetchArray($result5) ) {
//---------------------------------------------
$sday = $rs7['DateCar'];
$yearthai = explode("-",$sday);
$day = intval($yearthai[2]);
$month = getMonthTh(intval($yearthai[1]));
$year = intval($yearthai[0]+543);
//---------------------------------------------
$CarmoId = $rs7["CarmoId"];
$sql = "Select * From automobile_tb Where CarmoId ='$CarmoId'";
$result1 = mysql_query($sql) or die("Error".mysql_error());
$rs2 = mysql_fetch_array($result1);
//---------------------------------------------
$query11 = " SELECT * FROM autocar_tb WHERE carId='$rs7[carId]' ";
$result11 = $dbObj->execQuery($query11);
$rs11 = $dbObj->fetchArray($result11);
$sday1 = $rs11['DateCar'];
$yearthai1 = explode("-",$sday1);
$day1 = intval($yearthai1[2]);
$month1 = intval($yearthai1[1]);
$year1 = intval($yearthai1[0]+543);
$m1 = getShortMonthTH($month1);
//---------------------------------------------
$name1 = $rs7["name1"];
$sql = "SELECT *, prefixName as First_name FROM personal_tb LEFT JOIN prefix ON personal_tb.First_name = prefix.prefixId Where Teacher_code ='$name1'";
$result1 = mysql_query($sql) or die("Error".mysql_error());
$rs33 = mysql_fetch_array($result1);
//---------------------------------------------
switch($i){
case "1" : $pdf->Text(34,77.5,"$day"." "."$month"." "."$year");
$pdf->Text(63,77.5,$rs7['Time_start']." ¹.");
$pdf->Text(80,77.5,$rs2['CodeNo']);
$pdf->Text(112,77.5,number_format($rs7['Mile_start'],'','',','));
$pdf->Text(135,77.5,"$day1"." "."$m1"." "."$year1");
$pdf->Text(165,77.5,number_format($rs7['Mile_finish'],'','',','));
$pdf->Text(197,77.5,$rs7['Num_Mile']);
$pdf->Text(220,77.5,$rs7['Num_Lish']);
$pdf->Text(240,77.5,$rs33['First_name']." ".$rs33['Teacher_name']." ".$rs33['Teacher_lastname']);
break;
case "2" : $pdf->Text(34,84,"$day"." "."$month"." "."$year");
$pdf->Text(63,84,$rs7['Time_start']." ¹.");
$pdf->Text(80,84,$rs2['CodeNo']);
$pdf->Text(112,84,number_format($rs7['Mile_start'],'','',','));
$pdf->Text(135,84,"$day1"." "."$m1"." "."$year1");
$pdf->Text(165,84,number_format($rs7['Mile_finish'],'','',','));
$pdf->Text(197,84,$rs7['Num_Mile']);
$pdf->Text(220,84,$rs7['Num_Lish']);
$pdf->Text(240,84,$rs33['First_name']." ".$rs33['Teacher_name']." ".$rs33['Teacher_lastname']);
break;
case "3" : $pdf->Text(34,91,"$day"." "."$month"." "."$year");
$pdf->Text(63,91,$rs7['Time_start']." ¹.");
$pdf->Text(80,91,$rs2['CodeNo']);
$pdf->Text(112,91,number_format($rs7['Mile_start'],'','',','));
$pdf->Text(135,91,"$day1"." "."$m1"." "."$year1");
$pdf->Text(165,91,number_format($rs7['Mile_finish'],'','',','));
$pdf->Text(197,91,$rs7['Num_Mile']);
$pdf->Text(220,91,$rs7['Num_Lish']);
$pdf->Text(240,91,$rs33['First_name']." ".$rs33['Teacher_name']." ".$rs33['Teacher_lastname']);
break;
case "4" : $pdf->Text(34,98,"$day"." "."$month"." "."$year");
$pdf->Text(63,98,$rs7['Time_start']." ¹.");
$pdf->Text(80,98,$rs2['CodeNo']);
$pdf->Text(112,98,number_format($rs7['Mile_start'],'','',','));
$pdf->Text(135,98,"$day1"." "."$m1"." "."$year1");
$pdf->Text(165,98,number_format($rs7['Mile_finish'],'','',','));
$pdf->Text(197,98,$rs7['Num_Mile']);
$pdf->Text(220,98,$rs7['Num_Lish']);
$pdf->Text(240,98,$rs33['First_name']." ".$rs33['Teacher_name']." ".$rs33['Teacher_lastname']);
break;
case "5" : $pdf->Text(34,104.5,"$day"." "."$month"." "."$year");
$pdf->Text(63,104.5,$rs7['Time_start']." ¹.");
$pdf->Text(80,104.5,$rs2['CodeNo']);
$pdf->Text(112,104.5,number_format($rs7['Mile_start'],'','',','));
$pdf->Text(135,104.5,"$day1"." "."$m1"." "."$year1");
$pdf->Text(165,104.5,number_format($rs7['Mile_finish'],'','',','));
$pdf->Text(197,104.5,$rs7['Num_Mile']);
$pdf->Text(220,104.5,$rs7['Num_Lish']);
$pdf->Text(240,104.5,$rs33['First_name']." ".$rs33['Teacher_name']." ".$rs33['Teacher_lastname']);
break;
case "6" : $pdf->Text(34,111,"$day"." "."$month"." "."$year");
$pdf->Text(63,111,$rs7['Time_start']." ¹.");
$pdf->Text(80,111,$rs2['CodeNo']);
$pdf->Text(112,111,number_format($rs7['Mile_start'],'','',','));
$pdf->Text(135,111,"$day1"." "."$m1"." "."$year1");
$pdf->Text(165,111,number_format($rs7['Mile_finish'],'','',','));
$pdf->Text(197,111,$rs7['Num_Mile']);
$pdf->Text(220,111,$rs7['Num_Lish']);
$pdf->Text(240,111,$rs33['First_name']." ".$rs33['Teacher_name']." ".$rs33['Teacher_lastname']);
break;
case "7" : $pdf->Text(34,117.5,"$day"." "."$month"." "."$year");
$pdf->Text(63,117.5,$rs7['Time_start']." ¹.");
$pdf->Text(80,117.5,$rs2['CodeNo']);
$pdf->Text(112,117.5,number_format($rs7['Mile_start'],'','',','));
$pdf->Text(135,117.5,"$day1"." "."$m1"." "."$year1");
$pdf->Text(165,117.5,number_format($rs7['Mile_finish'],'','',','));
$pdf->Text(197,117.5,$rs7['Num_Mile']);
$pdf->Text(220,117.5,$rs7['Num_Lish']);
$pdf->Text(240,117.5,$rs33['First_name']." ".$rs33['Teacher_name']." ".$rs33['Teacher_lastname']);
break;
case "8" : $pdf->Text(34,124,"$day"." "."$month"." "."$year");
$pdf->Text(63,124,$rs7['Time_start']." ¹.");
$pdf->Text(80,124,$rs2['CodeNo']);
$pdf->Text(112,124,number_format($rs7['Mile_start'],'','',','));
$pdf->Text(135,124,"$day1"." "."$m1"." "."$year1");
$pdf->Text(165,124,number_format($rs7['Mile_finish'],'','',','));
$pdf->Text(197,124,$rs7['Num_Mile']);
$pdf->Text(220,124,$rs7['Num_Lish']);
$pdf->Text(240,124,$rs33['First_name']." ".$rs33['Teacher_name']." ".$rs33['Teacher_lastname']);
break;
case "9" : $pdf->Text(34,131,"$day"." "."$month"." "."$year");
$pdf->Text(63,131,$rs7['Time_start']." ¹.");
$pdf->Text(80,131,$rs2['CodeNo']);
$pdf->Text(112,131,number_format($rs7['Mile_start'],'','',','));
$pdf->Text(135,131,"$day1"." "."$m1"." "."$year1");
$pdf->Text(165,131,number_format($rs7['Mile_finish'],'','',','));
$pdf->Text(197,131,$rs7['Num_Mile']);
$pdf->Text(220,131,$rs7['Num_Lish']);
$pdf->Text(240,131,$rs33['First_name']." ".$rs33['Teacher_name']." ".$rs33['Teacher_lastname']);
break;
case "10" : $pdf->Text(34,138,"$day"." "."$month"." "."$year");
$pdf->Text(63,138,$rs7['Time_start']." ¹.");
$pdf->Text(80,138,$rs2['CodeNo']);
$pdf->Text(112,138,number_format($rs7['Mile_start'],'','',','));
$pdf->Text(135,138,"$day1"." "."$m1"." "."$year1");
$pdf->Text(165,138,number_format($rs7['Mile_finish'],'','',','));
$pdf->Text(197,138,$rs7['Num_Mile']);
$pdf->Text(220,138,$rs7['Num_Lish']);
$pdf->Text(240,138,$rs33['First_name']." ".$rs33['Teacher_name']." ".$rs33['Teacher_lastname']);
break;
}
$i++;
}
}
$pdf->SetFont('AngsanaNew','B',13);
//--------------------
$sql = " SELECT min(Mile_start) Mile_start FROM autocar_tb at , formcaroffice fc WHERE at.carId=fc.carId and fc.CarNo='$CarNo' ";
$result1 = mysql_query($sql);
$rss = mysql_fetch_array($result1);
$pdf->SetXY(110,140);
$pdf->Cell(15,5,number_format($rss['Mile_start'],'','',','),0,0,'C');
//--------------------
$sql = " SELECT max(Mile_finish) Mile_finish FROM autocar_tb at , formcaroffice fc WHERE at.carId=fc.carId and fc.CarNo='$CarNo' ";
$result1 = mysql_query($sql);
$rss = mysql_fetch_array($result1);
$pdf->SetXY(163,140);
$pdf->Cell(15,5,number_format($rss['Mile_finish'],'','',','),0,0,'C');
//--------------------
$sql1 = " SELECT SUM(Num_Mile) AS SumB4 FROM autocar_tb at , formcaroffice fc WHERE at.carId=fc.carId and fc.CarNo='$CarNo' ";
$result1 = mysql_query($sql1);
$rss1 = mysql_fetch_array($result1);
$pdf->SetXY(193,140);
$pdf->Cell(15,5,number_format($rss1['SumB4'],'','',','),0,0,'C');
//--------------------
$sql1 = " SELECT SUM(Num_Lish) AS SumB5 FROM autocar_tb at , formcaroffice fc WHERE at.carId=fc.carId and fc.CarNo='$CarNo' ";
$result1 = mysql_query($sql1);
$rss1 = mysql_fetch_array($result1);
$pdf->SetXY(216,140);
$pdf->Cell(15,5,number_format($rss1['SumB5'],'','',','),0,0,'C');
//--------------------
//Create file
$pdf->Output();
?>
|