Viewing file: prePrintMoneyFormPDF-1.php (14.1 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 ="durable_type_tb";
/*----- 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 LEFT JOIN training_tb ON personal_tb.Teacher_code = training_tb.Teacher_code LEFT JOIN formaoffice ON training_tb.Teacher_code = formaoffice.Teacher_code WHERE training_tb.Teacher_code = '".$_REQUEST["Teacher_code"]." ' and training_tb.Training_code = '".$_REQUEST["Training_code"]." ' and formaoffice.codeId = '".$_REQUEST["codeId"]." ' ";
$result = $dbObj->execQuery($query);
$rss = $dbObj->fetchArray($result);
$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 LEFT JOIN training_tb ON personal_tb.Teacher_code = training_tb.Teacher_code LEFT JOIN formaoffice ON training_tb.Teacher_code = formaoffice.Teacher_code LEFT JOIN formofficemoney ON formaoffice.codeId = formofficemoney.codeId WHERE formofficemoney.maNo = '".$_REQUEST["maNo"]." ' and formofficemoney.Teacher_code = '".$_REQUEST["Flag"]." ' Group By formofficemoney.maNo , formofficemoney.Flag ";
$result5 = $dbObj->execQuery($query);
$rss5 = $dbObj->fetchArray($result5);
$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);
function readNumber($number, $len) {
if($number=='0') { $number = ""; }
else if($number=='1') {
if($len==2) { $number = ""; }
else { $number = "หนึ่ง"; }
}
else if($number=='2') {
if($len==2) { $number = "ยี่"; }
else { $number = "สอง"; }
}
else if($number=='3') { $number = "สาม"; }
else if($number=='4') { $number = "สี่"; }
else if($number=='5') { $number = "ห้า"; }
else if($number=='6') { $number = "หก"; }
else if($number=='7') { $number = "เจ็ด"; }
else if($number=='8') { $number = "แปด"; }
else if($number=='9') { $number = "เก้า"; }
return $number;
}
function readUnit($len) {
if($len=='1') { $len = ""; }
else if($len=='2') { $len = "สิบ"; }
else if($len=='3') { $len = "ร้อย"; }
else if($len=='4') { $len = "พัน"; }
else if($len=='5') { $len = "หมื่น"; }
else if($len=='6') { $len = "แสน"; }
else if($len=='7') { $len = "ล้าน"; }
return $len;
}
function convertNumberToString($amount) {
list($baht, $satang) = split('[.]', $amount);
while(strlen($satang) < 2)
$satang .= '0';
$str = "";
$len = strlen($baht);
$i = 0;
while($i <= strlen($baht)) {
if($len==1 && $baht[$i-1]!=0 && $baht[$i]==1)
$str .= "เอ็ด";
else
$str .= readNumber($baht[$i], $len);
if($baht[$i] != 0)
$str .= readUnit($len);
$len--;
$i++;
}
if($str != "")
$str .= "บาท";
$len = strlen($satang);
$i = 0;
while($i <= strlen($satang)) {
if($len==1 && $satang[$i-1]!=0 && $satang[$i]==1)
$str .= "เอ็ด";
else
$str .= readNumber($satang[$i], $len);
if($satang[$i] != 0)
$str .= readUnit($len);
$len--;
$i++;
}
if($satang != '00')
$str .= "สตางค์";
return $str;
}
//----------------------------------------
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/FormMoney-1.jpg', 0, 0, 210, 297);
//-- Set Font
$pdf->SetFont('AngsanaNew','',13);
//-- College name and Date , Top-Right Position
$date = explode("-",$rss5['Date']);
$day = intval($date[2]);
$month = getMonthTh(intval($date[1]));
$year = intval($date[0]);
$pdf->Text(137,72,$rs3['collegeName']);
// วันที่บนขวา
if(!empty($day)){
$pdf->SetXY(120,75);
$pdf->Cell(40,5,"$day "." "." $month "." "." $year",0,0,'C');
}
else{
$pdf->Text(122,75,' - - -');
}
//-- Set Font
$pdf->SetFont('AngsanaNew','',13);
// เรียน ผู้อำนวยการ
$pdf->Text(45,99,$rs3['collegeName']);
// ตามคำสั่งบันทึกที่
if(!empty($rss5['maNo'])){
$pdf->SetXY(27,102);
$pdf->Cell(78,5,$rss5['maNo'],0,0,'C');
}
else{
$pdf->SetXY(27,102);
$pdf->Cell(78,5,'-',0,0,'C');
}
// ลงวันที่
if(!empty($day)){
$pdf->SetXY(81,102);
$pdf->Cell(40,5,"$day"." "."$month"." "."$year",0,0,'C');
}
else{
$pdf->Text(86.8,102,' - - -');
}
//-- Body ได้อนุมัติให้ข้าพเจ้า ตำแหน่ง สังกัด
$pdf->SetXY(130,102);
$pdf->Cell(73,5,$rss5['First_name'].' '.$rss5['Teacher_name'].' '.$rss5['Teacher_lastname'],0,0,'C');
$pdf->SetXY(25,108.5);
$pdf->Cell(56,5,$rss5['Position_name'],0,0,'C');
$pdf->SetXY(85,108.5);
$pdf->Cell(123,5,$rs3['collegeName'],0,0,'C');
// พร้อมด้วย
if(!empty($rss5['WithMon'])){
$pdf->SetXY(40,115);
$pdf->Cell(140,5,$rss5['WithMon'],0,0,'C');
}
else{
$pdf->SetXY(40,115);
$pdf->Cell(140,5,'-',0,0,'C');
}
// เดินทางไปปฏิบัติการ
if(!empty($rss5['Training_name'])){
$pdf->SetXY(55,122.3);
$pdf->Cell(130,5,$rss5['Training_name'],0,0,'C');
}
else{
$pdf->SetXY(55,122.3);
$pdf->Cell(130,5,'-',0,0,'C');
}
// เรื่อง
if(!empty($rss5['Matter'])){
$pdf->SetXY(10,129);
$pdf->Cell(115,5,$rss5['Matter'],0,0,'C');
}
else{
$pdf->SetXY(55,122.3);
$pdf->Cell(115,5,'-',0,0,'C');
}
// จังหวัด
$strSQL3 = " SELECT * FROM province Where provinceId ='$rss5[provinceId]' ";
$result3 = mysql_query($strSQL3);
$rs3 = mysql_fetch_array($result3);
if(!empty($rs3['provinceName'])){
$pdf->SetXY(140,129);
$pdf->Cell(50,5,$rs3['provinceName'],0,0,'C');
}
else{
$pdf->SetXY(140,122.3);
$pdf->Cell(50,5,'-',0,0,'C');
}
$pdf->SetFont('AngsanaNew','B',27);
// โดยออกเดินทางจาก
switch($rss5['MOut']){
case "1" : $pdf->Text(45.5,140,'/'); break;
case "2" : $pdf->Text(62,140,'/'); break;
case "3" : $pdf->Text(81.7,140,'/'); break;
}
$pdf->SetFont('AngsanaNew','',13);
// วันที่เริ่มต้น
$sday = $rss5['Date_start'];
$yearthai = explode("-",$sday);
$day = intval($yearthai[2]);
$month = getMonthTh(intval($yearthai[1]));
$year = intval($yearthai[0]);
if(!empty($day)){
$pdf->SetXY(120,135.2);
$pdf->Cell(40,5,"$day "." "." $month "." "." $year",0,0,'C');
}
else{
$pdf->Text(120,135.2,' - - -');
}
// เวลาเริ่มต้น
if(!empty($rss5['Time_start']) && $rss5['Time_start'] != "00:00"){
$pdf->SetXY(172,135.2);
$pdf->Cell(19,5,$rss5['Time_start'],0,0,'C');
}
else{
$pdf->SetXY(172,135.2);
$pdf->Cell(19.5,5,'-',0,0,'C');
}
$pdf->SetFont('AngsanaNew','B',27);
// และกลับถึง
switch($rss5['MInput']){
case "1" : $pdf->Text(35,146.5,'/'); break;
case "2" : $pdf->Text(52,146.5,'/'); break;
case "3" : $pdf->Text(71.5,146.5,'/'); break;
}
$pdf->SetFont('AngsanaNew','',13);
// วันที่สิ้นสุด
$sday = $rss5['Date_finish'];
$yearthai = explode("-",$sday);
$day = intval($yearthai[2]);
$month = getMonthTh(intval($yearthai[1]));
$year = intval($yearthai[0]);
if(!empty($day)){
$pdf->SetXY(110,142);
$pdf->Cell(40,5,"$day "." "." $month "." "." $year",0,0,'C');
}
else{
$pdf->Text(110,142,' - - -');
}
// เวลาสิ้นสุด
if(!empty($rss5['Time_finish']) && $rss5['Time_finish'] != "00:00"){
$pdf->SetXY(172,142);
$pdf->Cell(20,5,$rss5['Time_finish'],0,0,'C');
}
else{
$pdf->SetXY(172,142);
$pdf->Cell(20,5,'-',0,0,'C');
}
// รวมเวลาไปราชการครั้งนี้ - วัน
if(!empty($rss5['Day'])){
$pdf->SetXY(60,149);
$pdf->Cell(20,5,$rss5['Day'],0,0,'C');
}
else{
$pdf->SetXY(60,149);
$pdf->Cell(20,5,'-',0,0,'C');
}
// รวมเวลาไปราชการครั้งนี้ - ชั่วโมง
if(!empty($rss5['Hour'])){
$pdf->SetXY(105,149);
$pdf->Cell(20,5,$rss5['Hour'],0,0,'C');
}
else{
$pdf->SetXY(105,149);
$pdf->Cell(20,5,'-',0,0,'C');
}
// รวมเวลาไปราชการครั้งนี้ - นาที
if(!empty($rss5['Minute'])){
$pdf->SetXY(155,149);
$pdf->Cell(20,5,$rss5['Minute'],0,0,'C');
}
else{
$pdf->SetXY(155,149);
$pdf->Cell(20,5,'-',0,0,'C');
}
// ค่าเบี้ยเลี้ยงเดินทาง - จำนวน
if(!empty($rss5['SMDay'])){
$pdf->SetXY(142,162.5);
$pdf->Cell(15,5,$rss5['SMDay'],0,0,'C');
}
else{
$pdf->SetXY(142,162.5);
$pdf->Cell(20,5,'-',0,0,'C');
}
// ค่าเบี้ยเลี้ยงเดินทาง - บาท
$sql1 = " SELECT SUM(Smtotal) AS SumB1 FROM formofficemoney WHERE Flag='$Flag' and maNo='$maNo' ";
$result1 = mysql_query($sql1);
$rss1 = mysql_fetch_array($result1);
if(!empty($rss1['SumB1'])){
$pdf->SetXY(175,162.5);
$pdf->Cell(15,5,number_format($rss1['SumB1'],2,'.',','),0,0,'C');
}
else{
$pdf->SetXY(175,162.5);
$pdf->Cell(20,5,'-',0,0,'C');
}
$pdf->SetFont('AngsanaNew','B',27);
// ค่าเช่าที่พัก
switch($rss5['ST']){
case "Y" : $pdf->Text(54,173.5,'/'); break;
case "M" : $pdf->Text(78,173.5,'/'); break;
}
//ค่าพาหนะ
switch($rss5['Vehicle1']){
case "1" : $pdf->Text(53,180.5,'/'); break;
}
switch($rss5['Vehicle2']){
case "2" : $pdf->Text(78,180.5,'/'); break;
}
switch($rss5['Vehicle3']){
case "3" : $pdf->Text(108,180.5,'/'); break;
}
switch($rss5['Vehicle4']){
case "4" : $pdf->Text(53,186.5,'/'); break;
}
switch($rss5['Vehicle5']){
case "5" : $pdf->Text(78,186.5,'/'); break;
}
//ค่าใช้จ่ายอื่นๆ
switch($rss5['Crges1']){
case "1" : $pdf->Text(53,193.5,'/'); break;
}
switch($rss5['Crges2']){
case "2" : $pdf->Text(91,193.5,'/'); break;
}
switch($rss5['Crges3']){
case "3" : $pdf->Text(117,193.5,'/'); break;
}
$pdf->SetFont('AngsanaNew','',13);
// ค่าเช่าที่พัก - จำนวน
if(!empty($rss5['STDay'])){
$pdf->SetXY(142,169.5);
$pdf->Cell(15,5,$rss5['STDay'],0,0,'C');
}
else{
$pdf->SetXY(142,169.5);
$pdf->Cell(20,5,'-',0,0,'C');
}
// ค่าเช่าที่พัก - บาท
$sql1 = " SELECT SUM(STtotal) AS SumB2 FROM formofficemoney WHERE Flag='$Flag' and maNo='$maNo' ";
$result1 = mysql_query($sql1);
$rss1 = mysql_fetch_array($result1);
if(!empty($rss1['SumB2'])){
$pdf->SetXY(175,169.5);
$pdf->Cell(15,5,number_format($rss1['SumB2'],2,'.',','),0,0,'C');
}
else{
$pdf->SetXY(175,169.5);
$pdf->Cell(20,5,'-',0,0,'C');
}
// ค่าพาหนะ
if(!empty($rss5['Vehicle1'])){
$pdf->Text(35,146.5,'/');
}
// ค่าพาหนะ - รวม
$sql1 = " SELECT SUM(Vehicletotal) AS SumB3 FROM formofficemoney WHERE Flag='$Flag' and maNo='$maNo' ";
$result1 = mysql_query($sql1);
$rss1 = mysql_fetch_array($result1);
if(!empty($rss1['SumB3'])){
$pdf->SetXY(175,176);
$pdf->Cell(15,5,number_format($rss1['SumB3'],2,'.',','),0,0,'C');
}
else{
$pdf->SetXY(175,176);
$pdf->Cell(20,5,'-',0,0,'C');
}
// ค่าใช้จ่ายอื่นๆ - รวม
$sql1 = " SELECT SUM(Crgestotal) AS SumB4 FROM formofficemoney WHERE Flag='$Flag' and maNo='$maNo' ";
$result1 = mysql_query($sql1);
$rss1 = mysql_fetch_array($result1);
if(!empty($rss1['SumB4'])){
$pdf->SetXY(175,189.5);
$pdf->Cell(15,5,number_format($rss1['SumB4'],2,'.',','),0,0,'C');
}
else{
$pdf->SetXY(175,189.5);
$pdf->Cell(20,5,'-',0,0,'C');
}
// รวมทั้งสิ้น
$sql1 = " SELECT SUM(Budget_use) AS SumB5 FROM formofficemoney WHERE Flag='$Flag' and maNo='$maNo' ";
$result1 = mysql_query($sql1);
$rss1 = mysql_fetch_array($result1);
if(!empty($rss1['SumB5'])){
$pdf->SetXY(140,196.5);
$pdf->Cell(45,5,number_format($rss1['SumB5'],2,'.',','),0,0,'C');
}
else{
$pdf->SetXY(140,196.5);
$pdf->Cell(45,5,'-',0,0,'C');
}
// จำนวนเงิน (ตัวอักษร)
if(!empty($rss1['SumB5'])){
$SumB5 = convertNumberToString($rss1['SumB5']);
$pdf->SetXY(50,203);
$pdf->Cell(45,5,$SumB5."ถ้วน",0,0,'C');
}
else{
$pdf->SetXY(60,203);
$pdf->Cell(45,5,'-',0,0,'C');
}
// จำนวน -ฉบับ
if(!empty($rss5['Document'])){
$pdf->SetXY(150,210);
$pdf->Cell(35,5,$rss5['Document'],0,0,'C');
}
else{
$pdf->SetXY(60,196.5);
$pdf->Cell(35,5,'-',0,0,'C');
}
// ชื่อ ตำแหน่ง sign
$pdf->SetXY(130,236.5);
$pdf->Cell(51,5,$rss5['First_name'].' '.$rss5['Teacher_name'].' '.$rss5['Teacher_lastname'],0,0,'C');
$pdf->SetXY(130.5,250);
$pdf->Cell(49,5,$rss5['Position_name'],0,0,'C');
//Create file
$pdf->Output();
?>
|