| Server IP : 61.19.30.66 / Your IP : 216.73.216.80 Web Server : Apache/2.2.22 (Ubuntu) System : Linux klw 3.11.0-15-generic #25~precise1-Ubuntu SMP Thu Jan 30 17:39:31 UTC 2014 x86_64 User : www-data ( 33) PHP Version : 5.3.10-1ubuntu3.48 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /var/www/pension/ |
Upload File : |
<?php
// require("./xpdfclass.php");
include("./xpdfclass.php");
$ThaiMonth = array("มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม");
function PrintCenter($txt, $x, $w) {
global $pdf;
$ll = $w / 2;
$ww = $pdf->GetStringWidth($txt) / 2;
$pdf->Text($x + ($ll - $ww), $pdf->GetY(), $txt);
}
function AThaiDate() {
global $ThaiMonth;
$dd = date("Y-m-d H:i:s");
$bd = (int) substr($dd, 0, 4);
$bd = $bd + 543;
$dx = (string) $bd;
$dx = $dx.substr($dd, 4, 15);
$Year = substr($dx, 0, 4);
$Month = substr($dx, 5, 2);
$DayNo = substr($dx, 8, 2);
SetType($Month, "integer");
$Month--;
$rs = $DayNo." ".$ThaiMonth[$Month]." ".$Year;
return $rs;
}
function GetZero($v = "") {
if (($v == "0.00") || ($v == ""))
return " ";
else
return $v;
}
// UTF-8 to TIS-620
function u2t($string) {
$str = $string;
$res = "";
for ($i = 0; $i < strlen($str); $i++) {
if (ord($str[$i]) == 224) {
$unicode = ord($str[$i+2]) & 0x3F;
$unicode |= (ord($str[$i+1]) & 0x3F) << 6;
$unicode |= (ord($str[$i]) & 0x0F) << 12;
$res .= chr($unicode-0x0E00+0xA0);
$i += 2;
} else {
$res .= $str[$i];
}
}
return $res;
}
// TIS-620 to UTF-8
function t2u($tis) {
for( $i=0 ; $i< strlen($tis) ; $i++ ){
$s = substr($tis, $i, 1);
$val = ord($s);
if( $val < 0x80 ){
$utf8 .= $s;
}
elseif ((0xA1 <= $val and $val <= 0xDA) or (0xDF <= $val and $val <= 0xFB)) {
$unicode = 0x0E00 + $val - 0xA0;
$utf8 .= chr( 0xE0 | ($unicode >> 12) );
$utf8 .= chr( 0xB8 | (($unicode >> 6) & 0x3F) );
$utf8 .= chr( 0x80 | ($unicode & 0x3F) );
}
}
return $utf8;
}
$tag = $_GET["tag"];
$fd = $_GET["fd"];
$fi = $_GET["fi"];
$cm = $_GET["cm"];
$app = $_GET["app"];
if (isset($_GET["bk"])) $fbk = $_GET["bk"]; else $fbk = 2;
$finame = "d".$fi.".upd";
if (file_exists($fd.$finame)) {
$data = file($fd.$finame);
$dd = $data[0];
$hdd = explode("|", $dd);
$hx = count($hdd) - 1;
//if (count($hdd) > 54) $hfg = 1; else $hfg = 0;
if (trim($hdd[$hx]) == "A") $hfg = 1; else $hfg = 0;
$hhh = array("H", 11 + $hfg, 34);
$i = 1;
$chk = 0;
while (($i < count($data)) && ($chk == 0)) {
$dd = $data[$i];
$arr = explode("|", $dd);
if ($tag == $arr[1])
$chk = 1;
$i++;
}
if ($chk == 1) {
$pdf = new ThaiPDF();
$pdf->CreateThaiPDF();
$pdf->SetThaiFont();
$pdf->SetHeader('' , 1, 'R', 1);
// PHP 7.
//$pdf->SetFooter("by: http://".gethostname()." [".AThaiDate()."]", 0, "R", 1);
// PHP 5
//$pdf->SetFooter('by : http://'.$SERVER_NAME." [".AThaiDate()."]", 0, 'R', 1);
$pdf->SetTextColor(0,0,0);
$lef = $pdf->lMargin;
$rig = $pdf->w - $pdf->rMargin;
$tlef = $lef + 3;
$col = array(0, 0, 0, 0, 0, 0, 0);
$ccx = ($rig - $lef) / 6;
$cct = $lef;
for ($i = 0; $i < count($col); $i++) {
$col[$i] = $col[$i] + $cct;
$cct = $cct + $ccx;
}
$pdf->AddPage();
if (file_exists($fd."logo.jpg")) {
$pdf->Image($fd."logo.jpg", $tlef, $pdf->GetY() - 5, 25, 25, "jpg");
}
$pdf->SetFont("THSarabun", "B", 18);
$apx = u2t($app);
$pdf->Cell(0, 0, $apx, 0, 1, "C");
$pdf->Ln(9);
$mx = (int) SubStr($fi, 0, 2);
$mx--;
$yx = SubStr($fi, 2, 4);
// $cmp = iconv("UTF-8", "TIS-620", $cm); // encode url parse
// if ($th == "UTF-8")
$cmp = u2t($cm);
// else
// $cmp = $cm;
// $cmp = $cm;
// $cmp_n = strpos($cmp, "U");
$cmp = str_replace("U", "เขต", $cmp);
$cmp = str_replace("u", "เรี", $cmp);
$cmp = str_replace("๕", "เอี", $cmp);
$cmp = str_replace("t", "เงิ", $cmp);
$pdf->Cell(0, 0, $cmp, 0, 1, "C");
$pdf->Ln(9);
$pdf->Cell(0, 0, "ประจำเดือน ".$ThaiMonth[$mx]." ".$yx, 0, 1, "C");
$xc = Count($arr) - 1;
if ($xc > 52)
$xc = 52;
$pdf->Ln(4);
$pdf->SetFont("THSarabun", "B", 16);
$pdf->Line($lef, $pdf->GetY(), $rig, $pdf->GetY());
$y1 = $pdf->GetY();
$pdf->Ln(6);
$pdf->Text($lef + 1, $pdf->GetY(), "ชื่อ - นามสกุล : ".($arr[0]));
$cx1 = 0;
$cx2 = 0;
$ptx = "";
if ($fbk == 1) {
$ptx = "บัญชี ".substr($arr[2], 0, strlen($arr[2]) - 4)."xxxx ";
// $pdf->Text($col[4] - $pdf->GetStringWidth($ptx), $pdf->GetY(), $ptx);
}
if ($hfg == 1) {
$cx = (int) $hhh[1];
$cx0 = (int) $hhh[2];
$cx = $cx + 1;
$cx1 = (float) str_replace(",", "", $arr[3]);
$cx2 = (float) str_replace(",", "", $arr[$cx]);
$arr[3] = Number_Format(($cx1 + $cx2), 2);
$cx1 = $cx2;
$arr[$cx] = $arr[$cx +1];
$hdd[$cx] = $hdd[$cx + 1];
$arr[$cx + 1] = "";
$hdd[$cx + 1] = "";
$cx = (int) $hhh[2];
$cx2 = (float) str_replace(",", "", $arr[$cx + 17]);
$ttq = $ptx."โอนเข้าบัญชี ".Number_format($cx2, 2)." บาท ";
$pdf->Cell(0, 0, $ttq, 0, 1, "R");
$cx2 = (float) str_replace(",", "", $arr[$cx + 17]);
} else {
$cx = (int) $hhh[1];
$cx0 = (int) $hhh[2];
$ttq = $ptx."โอนเข้าบัญชี ".$arr[5+ $cx + $cx0]." บาท ";
$pdf->Cell(0, 0, $ttq, 0, 1, "R");
}
if ($xc == 52) {
$pdx = "วันที่โอนเข้าบัญชี : ".($arr[$xc + $hfg]);
$xc--;
} else
$pdx = "";
$pdf->Ln(8);
$pdf->Text($lef + 1, $pdf->GetY(), "หน่วย : ".($arr[$xc + $hfg]));
$xc--;
if ($cx1 != 0) {
$ttq = "(โอนครึ่งแรก ".Number_format($cx1, 2)." บาท โอนครึ่งหลัง ".Number_format($cx2 - $cx1, 2)." บาท)";
$pdf->Cell(0, 0, $ttq, 0, 1, "R");
}
$pdf->Ln(4);
$pdf->Line($lef, $pdf->GetY(), $rig, $pdf->GetY());
$y2 = $pdf->GetY();
$pdf->Ln(6);
$pdf->Text($lef + 10, $pdf->GetY(), "รายรับ");
$pdf->Text($col[4], $pdf->GetY(), "รายจ่าย");
$pdf->Ln(4);
$pdf->Line($lef, $pdf->GetY(), $rig, $pdf->GetY());
$y3 = $pdf->GetY();
$pdf->Ln(6);
// $pdf->SetFont("AngsanaNew", "", 16);
$pdf->SetFont("THSarabun", "", 16);
$pp = (int) ($hhh[2] / 2);
$rr = (int) ($hhh[1]);
if ($rr > $pp) { $ed = $rr; } else { $ed = $pp; }
$rs = 3;
$rp1 = $rr + $rs + 1;
$rp2 = $rp1 + $pp;
for ($i = 1; $i <= $ed; $i++) {
if ($i <= $rr) {
$pdf->Text($col[0] + 1, $pdf->GetY(), ($hdd[$rs]));
$pdf->Text($col[2] - $pdf->GetStringWidth($arr[$rs]) - 2, $pdf->GetY(), GetZero($arr[$rs]));
}
$pdf->Text($col[2], $pdf->GetY(), ($hdd[$rp1]));
$pdf->Text($col[4] - $pdf->GetStringWidth($arr[$rp1]) - 2, $pdf->GetY(), GetZero($arr[$rp1]));
$pdf->Text($col[4], $pdf->GetY(), ($hdd[$rp2]));
$pdf->Text($col[6] - $pdf->GetStringWidth($arr[$rp2]) - 2, $pdf->GetY(), GetZero($arr[$rp2]));
$rs++;
$rp1++;
$rp2++;
$pdf->Ln(6);
}
if (($pp * 2) < $hhh[2]) {
$pdf->Text($col[4], $pdf->GetY(), ($hdd[$rp2]));
$pdf->Text($col[6] - $pdf->GetStringWidth($arr[$rp2]) - 2, $pdf->GetY(), GetZero($arr[$rp2]));
$rp2++;
$pdf->Ln(6);
}
$pdf->Line($lef, $pdf->GetY(), $rig, $pdf->GetY());
$y4 = $pdf->GetY();
$rs = $rr + 3;
$pdf->Ln(6);
// $pdf->SetFont("AngsanaNew", "B", 16);
$pdf->SetFont("THSarabun", "B", 16);
$pdf->Text($col[0] + 1, $pdf->GetY(), ($hdd[$rs]));
$pdf->Text($col[2] - $pdf->GetStringWidth($arr[$rs]) - 2, $pdf->GetY(), GetZero($arr[$rs]));
$pdf->Text($col[3], $pdf->GetY(), ($hdd[$rp2]));
$pdf->Text($col[6] - $pdf->GetStringWidth($arr[$rp2]) - 2, $pdf->GetY(), GetZero($arr[$rp2]));
$pdf->Ln(3);
$pdf->Line($lef, $pdf->GetY(), $rig, $pdf->GetY());
$pdf->Line($lef, $y1, $lef, $pdf->GetY());
$pdf->Line($rig, $y1, $rig, $pdf->GetY());
$pdf->Line($col[2] - 1, $y2, $col[2] - 1, $pdf->GetY());
$pdf->Line($col[4] - 1, $y3, $col[4] - 1, $y4);
if ($pdx != "") {
$pdf->Ln(7);
$pdf->Text($col[0], $pdf->GetY(), trim($pdx));
}
if (count($arr) > 53) {
$xx = (int) ($arr[count($arr) - 1]);
$lx = strlen($arr[count($arr) - 1]);
if (($xx != 0) && ($lx < 4)) {
$pdf->Ln(7);
$pdf->Ln(7);
$pdf->Text($col[0] + 1, $pdf->GetY(), "งดหักเนื่องจากไม่เป็นไปตามหลักเกณฑ์ที่กำหนดไว้ในระเบียบกระทรวงศึกษาธิการ ว่าด้วยการหักเงินเดือนเงินบำเหน็จบำนาญ");
$pdf->Ln(7);
$pdf->Text($col[0] + 1, $pdf->GetY(), "ข้าราชการ เพื่อชำระหนี้เงินกู้ให้แก่สวัสดิการภายในส่วนราชการและสหกรณ์ พ.ศ.2551 .-");
// $pdf->SetFont("AngsanaNew", "", 16);
$pdf->SetFont("THSarabun", "", 16);
$n = 0;
$i = 53 + $hfg;
$pdf->Ln(7);
while ($i < (count($arr) - 1)) {
if ($n == 4) {
$n = 0;
$pdf->Ln(6);
}
$pdf->Text($col[$n] + 1, $pdf->GetY(), "- ".$arr[$i]);
$xx = $arr[$i + 1];
$n++;
$xf = $col[$n + 1];
$xf = $xf - $pdf->GetStringWidth($xx);
$pdf->Text($xf - 2, $pdf->GetY(), GetZero($xx));
$n++;
$i = $i + 2;
}
}
}
$pdf->Output("slp".$fi.".pdf", "I");
} else
echo "<center>มีบางสิ่งบางอย่างผิดพลาดจนไม่สามารถสร้างสลิ๊ปเงินเดือนได้</center>";
} else
echo "Not Found";
?>