-
Notifications
You must be signed in to change notification settings - Fork 1
/
function.php
238 lines (221 loc) · 8.39 KB
/
function.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<?php
# ThaiRIS (Thai Radiology Information System)
# Version: 1.8
# File last modified: 4-Oct 2020
# File name:
# http://www.thairis.net
# By ThaiRIS.Net
# Email : [email protected]
##############################################################################
# COPYRIGHT NOTICE
# Copyright 2009-2024 ThaiRIS All Rights Reserved.
#
# This script may be used and modified free of charge by anyone so long as
# this copyright notice and the comments above remain intact. By using this
# code you agree to indemnify ThaiRIS.net from any liability that might
# arise from it's use.
#
# Selling the code for this program without prior written consent is
# expressly forbidden. In other words, please ask first before you try and
# make money off this program.
#
# Obtain permission before redistributing this software over the Internet or
# in any other medium. In all cases copyright and header must remain intact.
# This Copyright is in full effect in any country that has International
##############################################################################
function ThaiEachDate($vardate)
{
$_month_name = array("01"=>"มกราคม", "02"=>"กุมภาพันธ์", "03"=>"มีนาคม",
"04"=>"เมษายน", "05"=>"พฤษภาคม", "06"=>"มิถุนายน",
"07"=>"กรกฎาคม", "08"=>"สิงหาคม", "09"=>"กันยายน",
"10"=>"ตุลาคม", "11"=>"พฤศจิกายน", "12"=>"ธันวาคม");
$yy =substr($vardate,0,4);$mm =substr($vardate,5,2);$dd =substr($vardate,8,2);
$yy += 543;
if ($yy==543)
{
$dateT = "-";
}
else
{
$dateT=$dd ." ".$_month_name[$mm]." ".$yy;
}
return $dateT;
}
function ThaiEachDate2($vardate)
{
$_month_name = array("01"=>"มค.", "02"=>"กพ.", "03"=>"มีค.",
"04"=>"เมย.", "05"=>"พค.", "06"=>"มิย.",
"07"=>"กค.", "08"=>"สค.", "09"=>"กย.",
"10"=>"ตค.", "11"=>"พย.", "12"=>"ธค.");
$yy =substr($vardate,0,4);$mm =substr($vardate,5,2);$dd =substr($vardate,8,2);
$yy += 543;
if ($yy==543)
{
$dateT = "-";
}
else
{
$dateT=$dd ." ".$_month_name[$mm]." ".$yy;
}
return $dateT;
}
function EngEachDate($vardate)
{
$_month_name = array("01"=>"Jan", "02"=>"Feb", "03"=>"Mar",
"04"=>"Apr", "05"=>"May", "06"=>"Jun",
"07"=>"Jul", "08"=>"Aug", "09"=>"Sep",
"10"=>"Oct", "11"=>"Nov", "12"=>"Dec");
$yy =substr($vardate,0,4);$mm =substr($vardate,5,2);$dd =substr($vardate,8,2);
//$yy += 543;
if ($yy==543)
{
$dateT = "-";
}
else
{
$dateT=$dd ." ".$_month_name[$mm]." ".$yy;
}
return $dateT;
}
//echo ThaiEachDate("2008-05-19");
function Date2MySQL($date)
{
$date=split("/",$date);
$date=$date[2]."-".$date[1]."-".$date[0];
return $date;
}
function AgeCal($birthday)
{
$monthText ='';
$today = date("Y-m-d");
list($byear, $bmonth, $bday) = explode("-", $birthday);
list($tyear, $tmonth, $tday) = explode("-", $today);
if ($byear < 1970)
{
$YearAdjust = 1970 - $byear;
$byear = 1970;
}
else
{
$YearAdjust = 0;
}
$mBirth = mktime (0, 0, 0, $bmonth,$bday,$byear);
$mNow = mktime (0, 0, 0, $tmonth,$tday,$tyear);
$mAge = ($mNow - $mBirth);
$Year = (date("Y",$mAge)- 1970 + $YearAdjust);
$month = (date("m",$mAge)-1 );
$Day = (date("d",$mAge)-1 );
$YearText = '';
if ($Year > 0)
{
$YearText = $Year."Y ";
}
if ($Year > 0 && $month > 0)
{
$monthText = $month."M ";
}
if ($Year == 0 && $month == 0 && $Day < 0)
{
$Age ="New Born";
}
else //($year or $month or $Day !== 0)
{
$Age = " ".$YearText. $monthText. $Day. "D ";
}
if ($birthday == "")
{
$Age = "";
}
return($Age);
}
function page_navigator($before_p,$plus_p,$total,$total_p,$chk_page){
global $urlquery_str;
$pPrev=$chk_page-1;
$pPrev=($pPrev>=0)?$pPrev:0;
$pNext=$chk_page+1;
$pNext=($pNext>=$total_p)?$total_p-1:$pNext;
$lt_page=$total_p-4;
if($chk_page>0){
echo "<a href='?s_page=$pPrev&urlquery_str=".$urlquery_str."' class='naviPN'>Prev</a>";
}
if($total_p>=11){
if($chk_page>=4){
echo "<a $nClass href='?s_page=0&urlquery_str=".$urlquery_str."'>1</a><a class='SpaceC'>. . .</a>";
}
if($chk_page<4){
for($i=0;$i<$total_p;$i++){
$nClass=($chk_page==$i)?"class='selectPage'":"";
if($i<=4){
echo "<a $nClass href='?s_page=$i&urlquery_str=".$urlquery_str."'>".intval($i+1)."</a> ";
}
if($i==$total_p-1 ){
echo "<a class='SpaceC'>. . .</a><a $nClass href='?s_page=$i&urlquery_str=".$urlquery_str."'>".intval($i+1)."</a> ";
}
}
}
if($chk_page>=4 && $chk_page<$lt_page){
$st_page=$chk_page-3;
for($i=1;$i<=5;$i++){
$nClass=($chk_page==($st_page+$i))?"class='selectPage'":"";
echo "<a $nClass href='?s_page=".intval($st_page+$i)."'>".intval($st_page+$i+1)."</a> ";
}
for($i=0;$i<$total_p;$i++){
if($i==$total_p-1 ){
$nClass=($chk_page==$i)?"class='selectPage'":"";
echo "<a class='SpaceC'>. . .</a><a $nClass href='?s_page=$i&urlquery_str=".$urlquery_str."'>".intval($i+1)."</a> ";
}
}
}
if($chk_page>=$lt_page){
for($i=0;$i<=4;$i++){
$nClass=($chk_page==($lt_page+$i-1))?"class='selectPage'":"";
echo "<a $nClass href='?s_page=".intval($lt_page+$i-1)."'>".intval($lt_page+$i)."</a> ";
}
}
}else{
for($i=0;$i<$total_p;$i++){
$nClass=($chk_page==$i)?"class='selectPage'":"";
echo "<a href='?s_page=$i&urlquery_str=".$urlquery_str."' $nClass >".intval($i+1)."</a> ";
}
}
if($chk_page<$total_p-1){
echo "<a href='?s_page=$pNext&urlquery_str=".$urlquery_str."' class='naviPN'>Next</a>";
}
}
function DateThai02($strDate)
{
$strYear = date("Y",strtotime($strDate))+543;
$strMonth= date("n",strtotime($strDate));
$strDay= date("j",strtotime($strDate));
$strHour= date("H",strtotime($strDate));
$strMinute= date("i",strtotime($strDate));
$strSeconds= date("s",strtotime($strDate));
$strMonthCut = Array("","ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค.");
$strMonthThai=$strMonthCut[$strMonth];
return "$strDay $strMonthThai $strYear, $strHour:$strMinute:$strSeconds";
}
function DateThai3($strDate) // show auto save at dictate.php
{
$strYear = date("Y",strtotime($strDate))+543;
$strMonth= date("n",strtotime($strDate));
$strDay= date("j",strtotime($strDate));
$strHour= date("H",strtotime($strDate));
$strMinute= date("i",strtotime($strDate));
$strSeconds= date("s",strtotime($strDate));
$strMonthCut = Array("","ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค.");
$strMonthThai=$strMonthCut[$strMonth];
return "$strHour:$strMinute:$strSeconds";
}
function DateEng($strDate) // show auto save at dictate.php
{
$strYear = date("Y",strtotime($strDate));
$strMonth= date("n",strtotime($strDate));
$strDay= date("j",strtotime($strDate));
$strHour= date("H",strtotime($strDate));
$strMinute= date("i",strtotime($strDate));
$strSeconds= date("s",strtotime($strDate));
$strMonthCut = Array("","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
$strMonthThai=$strMonthCut[$strMonth];
return "$strDay $strMonthThai $strYear $strHour:$strMinute:$strSeconds";
}
?>