Viewing file: prePrintMoneyAgreePDF.php (8.59 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;
if(isset($_REQUEST["maNo"])) $maNo = iconv("UTF-8", "WINDOWS-874",trim($_REQUEST["maNo"]));
/** Personal Data **/
$query = "SELECT * 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 Teacher_code = '".$_REQUEST["Teacher_code"]."'";
$result = $dbObj->execQuery($query);
$rs1 = $dbObj->fetchArray($result);
if(isset($_REQUEST["maNo"])){
/** Training Data **/
$query = "SELECT * FROM formcontract LEFT JOIN formaoffice ON formcontract.maNo = formaoffice.maNo WHERE formcontract.Teacher_code = '".$Teacher_code."' and formcontract.contId = '".$contId."' ";
$result2 = $dbObj->execQuery($query);
$rs2 = $dbObj->fetchArray($result2);
}
/** Personal Data(Faculty Head) **/
$query = "SELECT * 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 = '".$rs1["Faculty_code"]."' AND TeacherId = '1'";
$result = $dbObj->execQuery($query);
$rs3 = $dbObj->fetchArray($result);
/** College Data **/
$sql = "Select * From college Where collegeStatus ='1'";
$result = mysql_query($sql) or die("Error".mysql_error());
$rs4 = mysql_fetch_array($result);
$collegeName = $rs4["collegeName"];
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";
}
//Create new pdf file
$pdf = new FPDF();
//Set thai font
$pdf->SetThaiFont();
$pdf->AddPage();
//-- Load Form Image to Background
$pdf->Image('../form/moneyAgree-1.jpg', 0, 0, 205, 297);
//-- Set Font
$pdf->SetFont('AngsanaNew','',15);
//-- ส่วนราชการ
$pdf->Text(40,46.5,$rs4['collegeName']);
//-- 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['maNo'])){
$pdf->SetXY(23.5,48.8);
$pdf->Cell(34,5,$rs2['maNo'],0,0,'C');
}
else{
$pdf->SetXY(23.5,48.8);
$pdf->Cell(34,5,'-',0,0,'C');
}
$pdf->Text(30,66.7,'ผู้อำนวยการ '.$rs4['collegeName']);
//-- Body
$pdf->SetXY(31,69.5);
$pdf->Cell(88.3,5,$rs1['prefixName'].' '.$rs1['Teacher_name'].' '.$rs1['Teacher_lastname'],0,0,'C');
$pdf->SetXY(131.5,69.5);
$pdf->Cell(63,5,$rs1['Position_name'],0,0,'C');
$pdf->SetXY(28.9,76.5);
$pdf->Cell(166,5,$rs3['Faculty_name'].' '.$rs4['collegeName'].' สถาบันพระบรมราชชนก',0,0,'C');
//-- พร้อมด้วย
if(!empty($rs2['WithMon'])){
$pdf->SetXY(43.5,83.5);
$pdf->Cell(100,5,$rs2['WithMon'],0,0,'C');
}
else{
$pdf->SetXY(43.5,83.5);
$pdf->Cell(100,5,'-',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(20,90.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(20,90.3);
$pdf->Cell(130,5,$rs2['Training_name'],0,0,'C');
}
//-- จังหวัด
$province = $rs2['provinceId'];
$query = " SELECT * FROM province Where provinceId = '".$province."' ";
$result = mysql_query($query);
$rs4 = mysql_fetch_array($result);
if(!empty($rs4['provinceName'])){
$pdf->SetXY(133.5,90.5);
$pdf->Cell(80,5,$rs4['provinceName'],0,0,'C');
}
else{
$pdf->SetXY(133.5,90.5);
$pdf->Cell(120,5,'-',0,0,'C');
}
//-- ระหว่างวันที่
$date = explode("-",$rs2['Date_start']);
$day = intval($date[2]);
$month = getMonthTh(intval($date[1]));
$year = intval($date[0]);
if(!empty($day)){
$pdf->SetXY(45,97);
$pdf->Cell(40,5,"$day "." "." $month "." "." $year",0,0,'C');
}
else{
$pdf->Text(45,97,' - - -');
}
//-- ถึงวันที่
$date = explode("-",$rs2['Date_finish']);
$day = intval($date[2]);
$month = getMonthTh(intval($date[1]));
$year = intval($date[0]);
if(!empty($day)){
$pdf->SetXY(105,97);
$pdf->Cell(40,5,"$day "." "." $month "." "." $year",0,0,'C');
}
else{
$pdf->Text(105,97,' - - -');
}
//-- มีกำหนด
if(!empty($rs2['Day'])){
$pdf->SetXY(168,97);
$pdf->Cell(20,5,$rs2['Day'],0,0,'C');
}
else{
$pdf->SetXY(117,97);
$pdf->Cell(120,5,'-',0,0,'C');
}
//-- จำนวนเงิน
if(!empty($rs2["Budget"])){
$pdf->SetXY(35,104);
$pdf->Cell(50,5,number_format($rs2["Budget"],'2','.',','),0,0,'C');
}
else{
$pdf->SetXY(35,104);
$pdf->Cell(50,5,'-',0,0,'C');
}
//-- จำนวนเงินตัวอักษร
if(!empty($rs2["Budget"])){
$pdf->SetXY(95,104);
$pdf->Cell(120,5,convertNumberToString($rs2['Budget']).'ถ้วน',0,0,'C');
}
else{
$pdf->SetXY(95,104);
$pdf->Cell(120,5,'-',0,0,'C');
}
//-- signature
//-- ผู้ขอ
$pdf->SetXY(118,148.8);
$pdf->Cell(88.3,5,$rs1['prefixName'].' '.$rs1['Teacher_name'].' '.$rs1['Teacher_lastname'],0,0,'C');
$pdf->SetXY(131.5,155.8);
$pdf->Cell(63,5,$rs1['Position_name'],0,0,'C');
//-- หัวหน้าฝ่าย
$pdf->SetXY(35,175.5);
$pdf->Cell(60,5,$rs3['prefixName'].' '.$rs3['Teacher_name'].' '.$rs3['Teacher_lastname'],0,0,'C');
$pdf->SetXY(45,182.5);
$pdf->Cell(55,5,$rs3['Position_name'],0,0,'C');
$pdf->SetXY(40.3,182.3);
$pdf->Cell(50.5,5,$rs4['prefixName'].' '.$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();
?>
|