| 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/salary/ |
Upload File : |
<?php
require("thaipdfclass.php");
$ThaiMonth = array("มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม");
$pid = 0;
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( 0x80 | (($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"];
$finame = "d".$fi.".upd";
if (file_exists($fd.$finame)) {
$data = file($fd.$finame);
$hhh = array("H", 11, 34);
$dd = $data[0];
$hdd = explode("|", $dd);
$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->SetThaiFont();
$pdf->SetHeader('' , 1, 'R', 1);
$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);
$ccx = ($rig - $lef) / 4;
$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("AngsanaNew", "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
$cmp = u2t($cm);
// $cmp_n = strpos($cmp, "U");
$cmp = str_replace("U", "เขต", $cmp);
$cmp = str_replace("u", "เรี", $cmp);
$pdf->Cell(0, 0, $cmp, 0, 1, "C");
$pdf->Ln(9);
$pdf->Cell(0, 0, "ประจำเดือน ".$ThaiMonth[$mx]." ".$yx, 0, 1, "C");
// $pdf->Ln(9);
$xc = Count($arr) - 1;
// $pdf->Cell(0, 0, "สังกัด ".$arr[$xc], 0, 1, "C");
$pdf->Ln(4);
$pdf->SetFont("AngsanaNew", "B", 16);
$pdf->Line($lef, $pdf->GetY(), $rig, $pdf->GetY());
$y1 = $pdf->GetY();
$pdf->Ln(6);
$pdf->Text($lef + 1, $pdf->GetY(), "ชื่อ - นามสกุล : ".$arr[0]);
if ($xc == 52) {
$pdx = "วันที่จ่าย : ".Trim($arr[$xc]);
$xc--;
} else
$pdx = "";
$unt = "หน่วย : ".Trim($arr[$xc]);
// $cxx = $pdf->GetStringWidth($pdx);
$xc--;
if ($pid == 1) {
$pdf->Text($col[4] - $pdf->GetStringWidth("PID: ".$tag) - 4, $pdf->GetY(), "PID: ".$tag);
$pdf->Cell(0, 0, $pdx, 0, 1, "C");
$pdx = "";
} else {
// $pdf->Text($col[2] - 12, $pdf->GetY(), $unt);
// $pdf->Text($col[4] - $pdf->GetStringWidth($pdx." "), $pdf->GetY(), $pdx);
$pdf->Text($col[4] - $pdf->GetStringWidth($unt." "), $pdf->GetY(), $unt);
$unt = "";
}
// $pdf->Cell(0, 0, "PID : ".$arr[1], 0, 1, "R");
$pdf->Ln(8);
if (($pdx != "") && ($unt == ""))
$pdf->Text($lef + 1, $pdf->GetY(), $pdx);
if ($unt != "")
$pdf->Text($lef + 1, $pdf->GetY(), $unt);
if (($unt != "") && ($pid == 1))
$pdf->Text($lef + 1, $pdf->GetY(), "PID: ".$tag);
// $xc--;
$ttq = "จำนวนเงินโอนเข้าบัญชี ".$arr[$xc]." บาท ";
$pdf->Text($col[4] - $pdf->GetStringWidth($ttq), $pdf->GetY(), $ttq);
$pdf->Ln(4);
$pdf->Line($lef, $pdf->GetY(), $rig, $pdf->GetY());
$y2 = $pdf->GetY();
$pdf->Ln(6);
$pdf->Text($col[1] - $pdf->GetStringWidth("รายรับ") - 4, $pdf->GetY(), "รายรับ");
$pdf->Text($col[3] - $pdf->GetStringWidth("รายจ่าย") - 4, $pdf->GetY(), "รายจ่าย");
$pdf->Ln(4);
$pdf->Line($lef, $pdf->GetY(), $rig, $pdf->GetY());
$y3 = $pdf->GetY();
$pdf->Ln(6);
$pdf->SetFont("AngsanaNew", "", 16);
$pp = (int) ($hhh[2]);
$rr = (int) ($hhh[1]);
// if ($rr > $pp) { $ed = $rr; } else { $ed = $pp; }
$fl = $pdf->GetY();
$rs = 3;
for ($i = 1; $i <= $rr; $i++) {
$cc = (int) ($arr[$rs]);
if ($cc != 0) {
$pdf->Text($col[0] + 1, $pdf->GetY(), $hdd[$rs]);
$pdf->Text($col[2] - $pdf->GetStringWidth($arr[$rs]) - 2, $pdf->GetY(), GetZero($arr[$rs]));
$pdf->Ln(6);
}
$rs++;
}
$rx = (int) ($arr[$rs]);
$rs++;
$fe = $pdf->GetY();
$pdf->SetY($fl);
for ($i = 1; $i <= $pp; $i++) {
$cc = (int) ($arr[$rs]);
if ($cc != 0) {
$pdf->Text($col[2] + 1, $pdf->GetY(), $hdd[$rs]);
$pdf->Text($col[4] - $pdf->GetStringWidth($arr[$rs]) - 2, $pdf->GetY(), GetZero($arr[$rs]));
$pdf->Ln(6);
}
$rs++;
}
if ($fe > $pdf->GetY()) $pdf->SetY($fe);
$pdf->Line($lef, $pdf->GetY(), $rig, $pdf->GetY());
$y4 = $pdf->GetY();
$rs = $rr + 3;
$pdf->Ln(6);
$pdf->SetFont("AngsanaNew", "B", 16);
$pdf->Text($col[0] + 4, $pdf->GetY(), $hdd[$rs]);
$pdf->Text($col[2] - $pdf->GetStringWidth($arr[$rs]) - 2, $pdf->GetY(), GetZero($arr[$rs]));
$rs = $rs + $pp + 1;
$pdf->Text($col[2] + 4, $pdf->GetY(), $hdd[$rs]);
$pdf->Text($col[4] - $pdf->GetStringWidth($arr[$rs]) - 2, $pdf->GetY(), GetZero($arr[$rs]));
$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);
$pdf->Output("slp".$fi.".pdf", "I");
} else
echo "<center>มีบางสิ่งบางอย่างผิดพลาดจนไม่สามารถสร้างสลิ๊ปเงินเดือนได้</center>";
} else
echo "Not Found";
?>