Viewing file: 2553-02-18-1.0.03-function.php (33.54 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<meta http-equiv="Content-Type" content="text/html; charset=tis-620">
<?php
function tabChoose() {
?>
<script type="text/javascript">
<!--
// START tab script
// Adapted from "Javascript + CSS + DOM Magic" by Makiko Itoh
// define variables for "if n4 (Netscape 4), if IE (IE 4.x),
// and if n6 (if Netscape 6/W3C-DOM compliant)"
var n4, ie, n6;
// detect browser support for certain key objects/methods
// and assemble a custom document object
var doc,doc2,doc3,sty;
if (document.layers) {
doc = "document.";
doc2 = ".document.";
doc3 = "";
sty = "";
n4 = true;
} else if (document.all) {
doc = "document.all.";
doc2 = "";
doc3 = "";
sty = ".style";
ie = true;
} else if (document.getElementById) {
doc = "document.getElementById('";
doc2 ="')";
doc3 ="')";
sty = "').style";
n6 = true;
}
// display block or none DIV element
function blocknone(divname,tabidname,state,tabcolor,tabbg,cursortype) {
if (n4) {
divObj = eval (doc + divname);
tabObj = eval (doc + tabidname);
}
else {
divObj = eval (doc + divname + sty);
tabObj = eval (doc + tabidname + sty);
}
divObj.display = state;
tabObj.color = tabcolor;
tabObj.backgroundColor = tabbg;
tabObj.cursor = cursortype;
}
// variables that hold the value of the currently active (open) menu
var active_tabcontent = null;
var active_tab1 = null;
// function closes all active menus and turns back to 'off' state
function closeallmenus() {
if (active_tabcontent != null) {
blocknone(active_tabcontent,active_tab1,'none','#000000','#ABCDEF','pointer');
}
}
// function controls tab content visibility
function controlsubmenu(tabcontent,tabid) {
closeallmenus();
blocknone(tabcontent,tabid,'block','#000000','#ffc','text');
active_tabcontent = tabcontent;
active_tab1 = tabid
}
//END guide tab script
-->
</script>
<?php
}
function checkFormatLogin() {
?>
<script>
function checkFormatLogin() {
x = document.forms[0];
ele = new Array(x.length-1);
i=0;
while(i < x.length-1) {
ele[i] = x.elements[i];
i++;
}
i=0;
while(i < ele.length) {
if(ele[i].value == "")
{
alert("กรุณากรอก "+ele[i].name+" !");
ele[i].focus();
return false;
}
if(ele[i].value=="0" && ele[i].type!="hidden")
{
alert("กรุณากรอก "+ele[i].name+" !");
ele[i].focus();
return false;
}
i++;
}
}
</script>
<?php
}
function checkFormat() {
?>
<script>
<?php include_once "wordArr.php";?>
function checkFormat() {
x = document.forms[0];
ele = new Array(x.length-1);
i=0;
while(i < x.length-1) {
ele[i] = x.elements[i];
i++;
}
i=0;
while(i < ele.length) {
if(ele[i].name.indexOf("_Day_ID") == -1 && ele[i].name.indexOf("_Month") == -1 && ele[i].name.indexOf("_Year_ID") == -1){
if(ele[i].value == "")
{
alert("กรุณากรอก"+wordArr[ele[i].name]+" !");
ele[i].focus();
return false;
}
if(ele[i].value=="0" && ele[i].type!="hidden")
{
alert("กรุณากรอก"+wordArr[ele[i].name]+" !");
ele[i].focus();
return false;
}
if(ele[i].type=="radio" && ele[i].checked==false && ele[i+1].type=="radio" && ele[i+1].checked==false)
{
alert("กรุณาเลือก "+wordArr[ele[i].name]+" !");
ele[i].focus();
return false;
}
}
i++;
}
return true;
/* if(confirm("กรุณาตรวจสอบข้อมูลให้เรียบร้อยก่อนบันทึก !!"))
return true ;
else
return false ; */
}
</script>
<?php
}
function checkFormatMoney() {
?>
<script>
function checkFormat() {
x = document.forms[0];
ele = new Array(x.length-1);
i=0;
while(i < x.length-1) {
ele[i] = x.elements[i];
i++;
}
i=0;
while(i < ele.length) {
if(ele[i].value == "")
{
alert("กรุณากรอก "+ele[i].name+" !");
ele[i].focus();
return false;
}
i++;
}
if(confirm("คุณต้องการบันทึกข้อมูลแน่นอนใช่หรือไม่?"))
return true ;
else
return false ;
}
</script>
<?php
}
function confirmSubmit() {
?>
<script LANGUAGE="JavaScript">
<!--// Nannette Thacker http://www.shiningstar.net
function confirmSubmit(msg)
{
var agree=confirm(msg);
//var agree=confirm("คุณต้องการลบข้อมูลแน่นอนใช่หรือไม่?");
if (agree)
return true ;
else
return false ;
}
// -->
</script>
<?php
}
function getNowDate() {
$yy = date('Y');
$mm = date('m');
$dd = date('d');
return $yy.'-'.$mm.'-'.$dd;
}
function getNowDateFw() {
$yy = date('Y');
$mm = date('m');
$dd = date('d');
return $dd.'-'.$mm.'-'.$yy;
}
function getNowDateFw2() {
$yy = date('Y');
$mm = date('m');
$dd = date('d');
return $dd.'/'.$mm.'/'.$yy;
}
function getNowDateTh() {
$yy = date('Y')+543;
$mm = date('m');
$dd = date('d');
return $yy.'-'.$mm.'-'.$dd;
}
function getNowDateTh2() {
$yy = date('Y')+543;
$mm = date('m');
$dd = date('d');
return $yy;
}
function getNowDateFwTh() {
$yy = date('Y')+543;
$mm = date('m');
$dd = date('d');
return $dd.'-'.$mm.'-'.$yy;
}
function splitDateForm($date,$sp="-") {
list($dd, $mm, $yy) = preg_split("[$sp]", $date);
$yy += 543;
return $yy.'-'.$mm.'-'.$dd;
}
function splitDateForm2($date) {
list($dd, $mm, $yy) = preg_split("[-]", $date);
return $yy.'-'.$mm.'-'.$dd;
}
function splitDateDb($date,$sp="-") {
list($yy, $mm, $dd) = preg_split("[-]", $date);
$yy -= 543;
return $dd."$sp".$mm."$sp".$yy;
}
function splitDateDb2($date) {
list($yy, $mm, $dd) = preg_split("[-]", $date);
return $dd.'-'.$mm.'-'.$yy;
}
function fullDate($date) {
list($dd, $mm, $yy) = preg_split("[-]", $date);
if($dd=='01') { $dd='1'; }
else if($dd=='02') { $dd='2'; }
else if($dd=='03') { $dd='3'; }
else if($dd=='04') { $dd='4'; }
else if($dd=='05') { $dd='5'; }
else if($dd=='06') { $dd='6'; }
else if($dd=='07') { $dd='7'; }
else if($dd=='08') { $dd='8'; }
else if($dd=='09') { $dd='9'; }
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='ธันวาคม'; }
$yy += 543;
return "$dd $mm $yy";
}
function fullDateEng($date) {
list($dd, $mm, $yy) = preg_split("[-]", $date);
if($dd=='01') { $dd='1'; }
else if($dd=='02') { $dd='2'; }
else if($dd=='03') { $dd='3'; }
else if($dd=='04') { $dd='4'; }
else if($dd=='05') { $dd='5'; }
else if($dd=='06') { $dd='6'; }
else if($dd=='07') { $dd='7'; }
else if($dd=='08') { $dd='8'; }
else if($dd=='09') { $dd='9'; }
if($mm=='01') { $mm='January'; }
else if($mm=='02') { $mm='February'; }
else if($mm=='03') { $mm='March'; }
else if($mm=='04') { $mm='April'; }
else if($mm=='05') { $mm='May'; }
else if($mm=='06') { $mm='June'; }
else if($mm=='07') { $mm='July'; }
else if($mm=='08') { $mm='August'; }
else if($mm=='09') { $mm='September'; }
else if($mm=='10') { $mm='October'; }
else if($mm=='11') { $mm='November'; }
else if($mm=='12') { $mm='December'; }
return "$mm $dd, $yy";
}
function abbreDate($date) {
list($dd, $mm, $yy) = preg_split("[-]", $date);
if($dd=='01') { $dd='1'; }
else if($dd=='02') { $dd='2'; }
else if($dd=='03') { $dd='3'; }
else if($dd=='04') { $dd='4'; }
else if($dd=='05') { $dd='5'; }
else if($dd=='06') { $dd='6'; }
else if($dd=='07') { $dd='7'; }
else if($dd=='08') { $dd='8'; }
else if($dd=='09') { $dd='9'; }
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 "$dd $mm $yy";
}
function abbreDate2($date) {
list($yy, $mm, $dd) = preg_split("[-]", $date);
if($dd=='01') { $dd='1'; }
else if($dd=='02') { $dd='2'; }
else if($dd=='03') { $dd='3'; }
else if($dd=='04') { $dd='4'; }
else if($dd=='05') { $dd='5'; }
else if($dd=='06') { $dd='6'; }
else if($dd=='07') { $dd='7'; }
else if($dd=='08') { $dd='8'; }
else if($dd=='09') { $dd='9'; }
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 "$dd $mm $yy";
}
function calTax($amount, $netAmount, $taxRate) {
if($amount > $netAmount)
return round(($amount*$taxRate) / 100, 2);
else
return 0;
}
function calTaxOnClick() {
?>
<script>
function calTaxOnClick(f) {
f.amount.value = f.baht.value,'.',f.satang.value;
if(eval(f.amount.value)>eval(f.netAmt.value) && f.taxAndCheckFlag.value==1)
f.tax.value = (f.amount.value * f.taxRate.value) / 100;
else
f.tax.value = 0;
f.netAmount.value = f.amount.value - f.tax.value;
}
</script>
<?php
}
function openWindow() {
?>
<script language = "JavaScript">
function OpenWindow(FileName,nWidth,nHeight)
{
strOption = "scrollbars=yes,left=0,top=0,width=" + nWidth + ",height=" + nHeight;
SubWin = window.open(FileName,"",strOption);
}
</script>
<?php
}
function openWindow1() {
?>
<script language = "JavaScript">
function OpenWindow1(FileName,nWidth,nHeight,nLeft,nTop)
{
strOption = "scrollbars=yes,left=" + nLeft + ",top=" + nTop + ",width=" + nWidth + ",height=" + nHeight;
//strOption = "scrollbars=yes,left=240,top=10,width=" + nWidth + ",height=" + nHeight;
SubWin = window.open(FileName,"",strOption);
}
</script>
<?php
}
function getNowDay() {
$dd = date('d');
if($dd=='01') { $dd='1'; }
else if($dd=='02') { $dd='2'; }
else if($dd=='03') { $dd='3'; }
else if($dd=='04') { $dd='4'; }
else if($dd=='05') { $dd='5'; }
else if($dd=='06') { $dd='6'; }
else if($dd=='07') { $dd='7'; }
else if($dd=='08') { $dd='8'; }
else if($dd=='09') { $dd='9'; }
return $dd;
}
function convertDayNumberToString($dd) {
if($dd=='01') { $dd='1'; }
else if($dd=='02') { $dd='2'; }
else if($dd=='03') { $dd='3'; }
else if($dd=='04') { $dd='4'; }
else if($dd=='05') { $dd='5'; }
else if($dd=='06') { $dd='6'; }
else if($dd=='07') { $dd='7'; }
else if($dd=='08') { $dd='8'; }
else if($dd=='09') { $dd='9'; }
return $dd;
}
function getNowMonth() {
return date('m');
}
function getNowMonthTh($mm) {
//$mm = date('m');
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 convertMonthNumberToString($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 convertMonthNumberToString2($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 getNowYearTh() {
return date('Y')+543;
}
function confirmSubmitInsert() {
?>
<script LANGUAGE="JavaScript">
<!--// Nannette Thacker http://www.shiningstar.net
function confirmSubmitInsert()
{
var agree=confirm("คุณต้องการบันทึกข้อมูลแน่นอนใช่หรือไม่?");
if (agree)
return true ;
else
return false ;
}
// -->
</script>
<?php
}
function ver() {
?>
<script>
function ver(form, msg)
{
var c = 0;
for (var i=0; i<form.length; i++)
{
if(form.elements[i].type == 'checkbox' && form.elements[i].name !='chkAll')
{
if(form.elements[i].checked)
c = c+1;
}
}
if(c==0)
{
//alert('เลือกอย่างน้อยหนึ่งรายการเพื่อการออกงบหน้าใบสำคัญเบิกเงินต่อ');
alert(msg);
return false;
}
}
</script>
<?php
}
function ver2() {
?>
<script>
function ver2(form, msg)
{
var c = 0;
for (var i=0; i<form.length; i++)
{
if(form.elements[i].type == 'checkbox' && form.elements[i].name !='chkAll')
{
if(form.elements[i].checked)
c = c+1;
}
}
if(c != 1)
{
alert(msg);
return false;
}else{
return true;
}
}
</script>
<?php
}
function ver3() {
?>
<script>
function ver3(form, msg)
{
var c = 0;
for (var i=0; i<form.length; i++)
{
if(form.elements[i].type == 'checkbox' && form.elements[i].name !='chkAll')
{
if(form.elements[i].checked)
c = c+1;
}
}
if(c < 1)
{
alert(msg);
return false;
}
}
</script>
<?php
}
function CA() {
?>
<script>
function CA(form)
{
for (var i=0; i<form.length; i++)
{
if(form.elements[i].type == 'checkbox')
form.elements[i].checked = form.chkAll.checked;
}
}
</script>
<?php
}
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) = preg_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 changeHTMLInInsertReceiptsList_Paper() {
?>
<script language = "JavaScript">
function changeHTML()
{
var oselect = document.getElementById('tmpReceiptsListId');
var cselectVal = oselect.options[oselect.selectedIndex].value;
var other = document.getElementById('tmpReceiptsListIdOther');
if(cselectVal=='-1') {
other.style.display = '';
document.insert.receiptsList.value = '';
}
else {
other.style.display = 'none';
document.insert.receiptsList.value = '-';
}
}
</script>
<?php
}
function changeHTMLInSubjectServedProject() {
?>
<script language = "JavaScript">
function changeHTML()
{
var oselect = document.getElementById('cashOrCheckCode');
var oselectVal = oselect.options[oselect.selectedIndex].value;
var check = document.getElementById('check');
var bank = document.getElementById('bank');
if(oselectVal == '2') {
check.style.display = '';
bank.style.display = '';
document.insert.checkNo.value = '';
document.insert.bank.value = '';
}
else {
check.style.display = 'none';
bank.style.display = 'none';
document.insert.checkNo.value = '-';
document.insert.bank.value = '-';
}
}
</script>
<?php
}
function changeHTMLInFindPaper() {
?>
<script language = "JavaScript">
function changeHTMLInFindPaper()
{
var oselect = document.getElementById('workType');
var cselectVal = oselect.options[oselect.selectedIndex].value;
var pay = document.getElementById('selectReportPay');
var receipts = document.getElementById('selectReportReceipts');
var dependOnWorkType1 = document.getElementById('dependOnWorkType1');
var dependOnWorkType2 = document.getElementById('dependOnWorkType2');
var yy = document.getElementById('yy');
var mm = document.getElementById('mm');
var dd1 = document.getElementById('dd1');
var dd2 = document.getElementById('dd2');
if(cselectVal=='0') {
pay.style.display = 'none';
receipts.style.display = 'none';
dependOnWorkType1.style.display = 'none';
dependOnWorkType2.style.display = 'none';
yy.style.display = 'none';
mm.style.display = 'none';
dd1.style.display = 'none';
dd2.style.display = 'none';
}
else if(cselectVal=='1') {
pay.style.display = '';
document.findPaper.payDocType.selectedIndex = '0';
document.findPaper.payDocType.options[document.findPaper.payDocType.selectedIndex].value = '';
receipts.style.display = 'none';
document.findPaper.receiptsDocType.options[document.findPaper.receiptsDocType.selectedIndex].value = '-';
dependOnWorkType1.style.display = 'none';
dependOnWorkType2.style.display = 'none';
yy.style.display = 'none';
mm.style.display = 'none';
dd1.style.display = 'none';
dd2.style.display = 'none';
}
else if(cselectVal=='2') {
pay.style.display = 'none';
document.findPaper.payDocType.options[document.findPaper.payDocType.selectedIndex].value = '-';
receipts.style.display = '';
document.findPaper.receiptsDocType.selectedIndex = '0';
document.findPaper.receiptsDocType.options[document.findPaper.receiptsDocType.selectedIndex].value = '';
dependOnWorkType1.style.display = 'none';
dependOnWorkType2.style.display = 'none';
yy.style.display = 'none';
mm.style.display = 'none';
dd1.style.display = 'none';
dd2.style.display = 'none';
}
}
function changeHTMLInPayDocType()
{
var oselect = document.getElementById('payDocType');
var cselectVal = oselect.options[oselect.selectedIndex].value;
var dependOnWorkType1 = document.getElementById('dependOnWorkType1');
var dependOnWorkType2 = document.getElementById('dependOnWorkType2');
var yy = document.getElementById('yy');
var mm = document.getElementById('mm');
var dd1 = document.getElementById('dd1');
var dd2 = document.getElementById('dd2');
if(cselectVal=='0') {
dependOnWorkType1.style.display = 'none';
dependOnWorkType2.style.display = 'none';
yy.style.display = 'none';
mm.style.display = 'none';
dd1.style.display = 'none';
dd2.style.display = 'none';
}
else if(cselectVal=='8') {
dependOnWorkType1.style.display = 'none';
document.findPaper.category1.options[document.findPaper.category1.selectedIndex].value = '-';
dependOnWorkType2.style.display = '';
document.findPaper.category2.selectedIndex = '0';
document.findPaper.category2.options[document.findPaper.category2.selectedIndex].value = '';
yy.style.display = 'none';
mm.style.display = 'none';
dd1.style.display = 'none';
dd2.style.display = 'none';
}
else {
dependOnWorkType1.style.display = '';
document.findPaper.category1.selectedIndex = '0';
document.findPaper.category1.options[document.findPaper.category1.selectedIndex].value = '';
dependOnWorkType2.style.display = 'none';
document.findPaper.category2.options[document.findPaper.category2.selectedIndex].value = '-';
yy.style.display = 'none';
mm.style.display = 'none';
dd1.style.display = 'none';
dd2.style.display = 'none';
}
}
function changeHTMLInReceiptsDocType()
{
var oselect = document.getElementById('receiptsDocType');
var cselectVal = oselect.options[oselect.selectedIndex].value;
var dependOnWorkType1 = document.getElementById('dependOnWorkType1');
var dependOnWorkType2 = document.getElementById('dependOnWorkType2');
var yy = document.getElementById('yy');
var mm = document.getElementById('mm');
var dd1 = document.getElementById('dd1');
var dd2 = document.getElementById('dd2');
if(cselectVal=='0') {
dependOnWorkType1.style.display = 'none';
dependOnWorkType2.style.display = 'none';
yy.style.display = 'none';
mm.style.display = 'none';
dd1.style.display = 'none';
dd2.style.display = 'none';
}
else if(cselectVal=='1') {
dependOnWorkType1.style.display = 'none';
document.findPaper.category1.options[document.findPaper.category1.selectedIndex].value = '2';
dependOnWorkType2.style.display = 'none';
document.findPaper.category2.options[document.findPaper.category2.selectedIndex].value = '-';
yy.style.display = '';
mm.style.display = '';
dd1.style.display = 'none';
dd2.style.display = 'none';
}
else {
dependOnWorkType1.style.display = '';
document.findPaper.category1.selectedIndex = '0';
document.findPaper.category1.options[document.findPaper.category1.selectedIndex].value = '';
dependOnWorkType2.style.display = 'none';
document.findPaper.category2.options[document.findPaper.category2.selectedIndex].value = '-';
yy.style.display = 'none';
mm.style.display = 'none';
dd1.style.display = 'none';
dd2.style.display = 'none';
}
}
function changeHTML1()
{
var oselect = document.getElementById('category1');
var cselectVal = oselect.options[oselect.selectedIndex].value;
var yy = document.getElementById('yy');
var mm = document.getElementById('mm');
var dd1 = document.getElementById('dd1');
var dd2 = document.getElementById('dd2');
if(cselectVal=='0') {
yy.style.display = 'none';
mm.style.display = 'none';
dd1.style.display = 'none';
dd2.style.display = 'none';
}
else if(cselectVal=='1') {
yy.style.display = '';
mm.style.display = 'none';
dd1.style.display = 'none';
dd2.style.display = 'none';
}
else if(cselectVal=='2') {
yy.style.display = '';
mm.style.display = '';
dd1.style.display = 'none';
dd2.style.display = 'none';
}
else if(cselectVal=='3') {
yy.style.display = 'none';
mm.style.display = 'none';
dd1.style.display = '';
dd2.style.display = '';
}
}
function changeHTML2()
{
var oselect = document.getElementById('category2');
var cselectVal = oselect.options[oselect.selectedIndex].value;
var yy = document.getElementById('yy');
var mm = document.getElementById('mm');
var dd1 = document.getElementById('dd1');
var dd2 = document.getElementById('dd2');
if(cselectVal=='0') {
yy.style.display = 'none';
mm.style.display = 'none';
dd1.style.display = 'none';
dd2.style.display = 'none';
}
else if(cselectVal=='1') {
yy.style.display = '';
mm.style.display = 'none';
dd1.style.display = 'none';
dd2.style.display = 'none';
}
else if(cselectVal=='2') {
yy.style.display = '';
mm.style.display = '';
dd1.style.display = 'none';
dd2.style.display = 'none';
}
else if(cselectVal=='3') {
yy.style.display = 'none';
mm.style.display = 'none';
dd1.style.display = 'none';
dd2.style.display = '';
}
}
</script>
<?php
}
function diff2Dates() {
?>
<script>
function diff2Dates(f)
{
var date1 = f.startDate.value.split("-");
var date2 = f.endDate.value.split("-");
//Set the two dates
date1 = new Date(eval(date1[2]), eval(date1[1]-1), eval(date1[0]));
date2 = new Date(eval(date2[2]), eval(date2[1]-1), eval(date2[0])); //Month is 0-11 in JavaScript
//Set 1 day in milliseconds
var one_day = 1000*60*60*24;
//Calculate difference btw the two dates, and convert to days
var diff = Math.ceil((date2.getTime()-date1.getTime())/(one_day));
if(diff < 0)
{
alert("วันที่ไม่สัมพันธ์กัน");
return false;
}
f.dayAmount.value = diff+1;
}
</script>
<?php
}
function calCoupon() {
?>
<script>
function calCoupon(f)
{
var cnt = f.loop.value;
var x = f;
var baht = f.baht.value;
var satang = f.satang.value;
var amount = parseFloat(baht+"."+satang);
var ele = new Array(cnt-1);
var i = parseInt(cnt) + 14;
var j = 0;
while(i >= 15)
{
ele[j] = x.elements[i];
i--;
j++;
}
if(f.elements[6].checked == true)
f.quantity.value = parseInt(amount / f.inPrice.value);
else if(f.elements[7].checked == true)
f.quantity.value = parseInt(amount / f.outPrice.value);
i = 5;
while(i < ele.length)
{
/*if(parseInt(amount / ele[i].value) > parseInt(ele[i-2].value - ele[i-4].value + 1))
{
alert('ควรทำการเบิกคูปองเล่มใหม่');
return false;
}*/
if(parseInt(amount / ele[i].value) == 0)
ele[i-5].value = '-';
else
ele[i-5].value = parseInt(amount / ele[i].value);
amount = amount % ele[i].value;
i = i + 6;
}
if(amount != 0)
{
i = 0;
while(i < ele.length)
{
ele[i].value = '';
i += 6;
}
}
}
</script>
<?php
}
// returns <0, 0, >0 if date a< date b,date a== date b,date a > date b respectively.
function compareDate($i_sFirstDate, $i_sSecondDate)
{
//Break the Date strings into seperate components
$arrFirstDate = explode ("-", $i_sFirstDate);
$arrSecondDate = explode ("-", $i_sSecondDate);
$intFirstDay = $arrFirstDate[0];
$intFirstMonth = $arrFirstDate[1];
$intFirstYear = $arrFirstDate[2];
$intSecondDay = $arrSecondDate[0];
$intSecondMonth = $arrSecondDate[1];
$intSecondYear = $arrSecondDate[2];
// Calculate the diference of the two dates and return the number of days.
$intDate1Jul = gregoriantojd($intFirstMonth, $intFirstDay, $intFirstYear);
$intDate2Jul = gregoriantojd($intSecondMonth, $intSecondDay, $intSecondYear);
return $intDate1Jul - $intDate2Jul;
}//end Compare Date
function calBankNoteAndCoin() {
?>
<script>
function calBankNoteAndCoin(f)
{
var amount = f.sendToCashAmt.value;
if((amount - (amount % 1000)) != 0)
f.bankNote1.value = amount - (amount % 1000);
else
f.bankNote1.value = '-';
amount %= 1000;
if((amount - (amount % 500)) != 0)
f.bankNote2.value = amount - (amount % 500);
else
f.bankNote2.value = '-';
amount %= 500;
if((amount - (amount % 100)) != 0)
f.bankNote3.value = amount - (amount % 100);
else
f.bankNote3.value = '-';
amount %= 100;
if((amount - (amount % 50)) != 0)
f.bankNote4.value = amount - (amount % 50);
else
f.bankNote4.value = '-';
amount %= 50;
if((amount - (amount % 20)) != 0)
f.bankNote5.value = amount - (amount % 20);
else
f.bankNote5.value = '-';
amount %= 20;
if((amount - (amount % 10)) != 0)
f.coin1.value = amount - (amount % 10);
else
f.coin1.value = '-';
amount %= 10;
if((amount - (amount % 5)) != 0)
f.coin2.value = amount - (amount % 5);
else
f.coin2.value = '-';
amount %= 5;
if((amount - (amount % 1)) != 0)
f.coin3.value = amount - (amount % 1);
else
f.coin3.value = '-';
amount %= 1;
if((amount - (amount % 0.50)) != 0)
f.coin4.value = (amount - (amount % 0.50)) * 100;
else
f.coin4.value = '-';
amount %= 0.50;
if((amount - (amount % 0.25)) != 0)
f.coin5.value = (amount - (amount % 0.25)) * 100;
else
f.coin5.value = '-';
amount %= 0.25;
}
</script>
<?php
}
function calSendToCashAmt() {
?>
<script>
function calSendToCashAmt()
{
var sendToCashAmt = 0;
x = document.forms[0];
ele = new Array(x.length-1);
i=0;
while(i < x.length-1) {
ele[i] = x.elements[i];
i++;
}
i = 8;
while(i < 18)
{
if(ele[i].value != '-')
{
if(i==15 || i==17)
sendToCashAmt = sendToCashAmt + (parseInt(ele[i].value) / 100);
else
sendToCashAmt = sendToCashAmt + parseInt(ele[i].value);
}
i++;
}
if(ele[8].value!='-' && (parseInt(ele[8].value) % 1000) != 0)
{
alert('จำนวนเงินสดไม่ถูกต้อง');
ele[8].focus();
return false;
}
if(ele[9].value!='-' && (parseInt(ele[9].value) % 10) != 0)
{
alert('จำนวนเงินสดไม่ถูกต้อง');
ele[9].focus();
return false;
}
if(ele[10].value!='-' && (parseInt(ele[10].value) % 500) != 0)
{
alert('จำนวนเงินสดไม่ถูกต้อง');
ele[10].focus();
return false;
}
if(ele[11].value!='-' && (parseInt(ele[11].value) % 5) != 0)
{
alert('จำนวนเงินสดไม่ถูกต้อง');
ele[11].focus();
return false;
}
if(ele[12].value!='-' && (parseInt(ele[12].value) % 100) != 0)
{
alert('จำนวนเงินสดไม่ถูกต้อง');
ele[12].focus();
return false;
}
if(ele[13].value!='-' && (parseInt(ele[13].value) % 1) != 0)
{
alert('จำนวนเงินสดไม่ถูกต้อง');
ele[13].focus();
return false;
}
if(ele[14].value!='-' && (parseInt(ele[14].value) % 50) != 0)
{
alert('จำนวนเงินสดไม่ถูกต้อง');
ele[14].focus();
return false;
}
if(ele[15].value!='-' && (parseInt(ele[15].value) % 0.50) != 0)
{
alert('จำนวนเงินสดไม่ถูกต้อง');
ele[15].focus();
return false;
}
if(ele[16].value!='-' && (parseInt(ele[16].value) % 20) != 0)
{
alert('จำนวนเงินสดไม่ถูกต้อง');
ele[16].focus();
return false;
}
if(ele[17].value!='-' && (parseInt(ele[17].value) % 0.25) != 0)
{
alert('จำนวนเงินสดไม่ถูกต้อง');
ele[17].focus();
return false;
}
if(sendToCashAmt != parseFloat(ele[3].value))
{
alert('จำนวนเงินสดไม่ถูกต้อง');
ele[8].focus();
return false;
}
if(confirm("คุณต้องการบันทึกข้อมูลแน่นอนใช่หรือไม่?"))
return true ;
else
return false ;
}
</script>
<?php
}
function openNewWindow(){
?>
<script LANGUAGE="JavaScript">
function openNewWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
</script>
<?php
}
function autotab() {
?>
<script>
function autotab(original, destination){
if (original.getAttribute && original.value.length==original.getAttribute("maxlength")) destination.focus();
}
</script>
<?php
}
function doCheckAll(){
?>
<script language="javascript">
function doCheckAll(form,do_check){
for (var i=0; i<form.length; i++)
{
if(form.elements[i].type == 'checkbox')
form.elements[i].checked = do_check;
}
}
</script>
<?php
}
function sendRequest(){
?>
<script type="text/javascript" language="JavaScript">
function sendRequest (el)
{
var silentId = document.getElementById("silent");
var innerTag = "";
if (silentId && el && el.href) {
var uri = el.href.split("?");
var cnt = null;
var pair = null;
if (uri[1]) {
cnt = uri[1].split("&");
for (var i = 0; i < cnt.length; i++) {
pair = cnt[i].split("=");
innerTag += "<input type=\"hidden\" name=\"" + pair[0] + "\" value=\"" + pair[1] + "\">";
}
silentId.action = uri[0];
silentId.innerHTML = innerTag;
setTimeout("document.forms['silent'].submit()", 100);
}
}
return false;
}
</script>
<?php
}
function time_diff($from, $to) {
list($byear,$bmonth,$bday) = explode("-",$from);
list($tyear,$tmonth,$tday) = explode("-",$to);
if($byear<1970){
$mYear_adjust = 1970-$byear;
$byear = 1970;
}else{
$mYear_adjust=0;
}
$a_year = $tyear - $byear;
$a_month = $tmonth - $bmonth;
$a_month -= ($bday>$tday)?1:0;
$byear_new = $tyear;
$bmonth_new = $tmonth;
$bmonth_new -= ($bday>$tday)?1:0;
if($a_month < 0){
$a_month += 12;
$a_year--;
}
if($tday >= $bday){
$a_day = $tday - $bday;
}else{
$tmp_timestamp = mktime(0,0,0,$bmonth_new,1,$byear_new);
$a_day = (date("t",$tmp_timestamp) - $bday)+ $tday;
}
$a_year += $mYear_adjust;
return "$a_year ,$a_month ,$a_day";
}
function GetbudYear($xdate){
list($xyear,$xmonth,$xday) = explode("-",$xdate);
if(($xmonth == "10") ||($xmonth == "11")||($xmonth == "12") ){
$xyear=$xyear+543+1;
}else{
$xyear=$xyear+543;
}
return "$xyear";
}
function doChkThis(){
?>
<script language="javascript">
function doChkThis(form,i){
if(form.elements[i].type == 'checkbox'){
if(form.elements[i].checked == true ){
var re = 'tr';
return true;
}else{
var re = 'fa';
return false;
}
}
}
</script>
<?php
}
function getWeekDay($date) {
list($dd, $mm, $yy) = preg_split("[/-]", $date);
return date("w", mktime(0, 0, 0, $mm, $dd, $yy));
}
?>
|