001.
<?
002.
include
"databaseconnect2.php"
;
003.
004.
$bp
=
$_POST
[
"bp"
];
005.
$month
=
$_POST
[
"month"
];
006.
$year
=
$_POST
[
"year"
];
007.
$record
=
$_POST
[
"record"
];
008.
$date
=
$_POST
[
"date"
];
009.
$ym
=
$year
.
"-"
.
$month
;
010.
$ymd
=
$year
.
"-"
.
$month
.
"-"
.
$date
;
011.
012.
013.
014.
015.
echo
"<table align='center'>"
;
016.
echo
"<tr><th>DotArai Co.,Ltd.</th></tr>"
;
017.
echo
"<tr><td>131 Mu 9, Room INC1-216 Phahon Yothin Rd.,</td></tr>"
;
018.
echo
"<tr><td> Khlong Nueng, Khlong Luang, Pathum Thani 12120 </td></tr>"
;
019.
echo
"<tr><td>Tel : 0-2564-8038 Fax : 0-2564-8039 </td></tr>"
;
020.
echo
"<tr><td colspan='2'>Emai : support@dotarai.co.th</td><td>เลขประจำตัวผู้เสียภาษี :</td><td>3032001731</td></tr>"
;
021.
echo
"<tr><td>Invoice</td></tr>"
;
022.
echo
"</table>"
;
023.
024.
025.
$sql
=
"select org,street1,city,sp,pc,voice,fax from webreg__user where username='$bp'"
;
026.
$result
= mysql_query(
$sql
);
027.
echo
"<table align='center'>"
;
028.
while
(
$rows
= mysql_fetch_array(
$result
))
029.
{
030.
$da
=
date
(
"d-M-Y"
);
031.
$da2
=
date
(
"d"
)+7;
032.
$da3
=
date
(
"M-Y"
);
033.
echo
"<tr><td col span='2'>Attn :</td><td>"
.
$rows
[
'org'
].
" </td><td>Date :</td><td>"
.
$da
.
"</td></tr>"
;
034.
echo
"<tr><td></td><td> "
.
$rows
[
'street1'
].
" </td><td>Due Date :</td><td>"
.
$da2
.
"-"
.
$da3
.
"</td></tr>"
;
035.
echo
"<tr><td></td><td> "
.
$rows
[
'city'
].
" "
.
$rows
[
'sp'
].
" "
.
$rows
[
'pc'
]."</td>
036.
<td>Invoice No. :</td><td></td></tr>";
037.
038.
if
(
$rows
[
'voice'
]!=
""
)
039.
echo
"<tr><td>Tel :</td><td>0"
.
substr
(
$rows
[
'voice'
],3).
" </td><td></td><td></td></tr>"
;
040.
041.
else
if
(
$rows
[
'voice'
]==
""
)
042.
echo
"<tr><td>Tel :</td><td> </td><td></td><td></td></tr>"
;
043.
044.
if
(
$rows
[
'fax'
]!=
""
)
045.
echo
"<tr><td>Fax :</td><td>0"
.
substr
(
$rows
[
'fax'
],3).
" </td><td></td><td></td></tr>"
;
046.
047.
else
if
(
$rows
[
'fax'
]==
""
)
048.
echo
"<tr><td>Fax :</td><td> </td><td></td><td></td></tr>"
;
049.
050.
}
051.
echo
"</table>"
;
052.
echo
"<table align = 'center'>"
;
053.
echo
"<th>Item</th><th>Description</th><th>Qty</th><th>Unit Price</th><th>Baht Amount</th>"
;
054.
055.
056.
057.
058.
if
(
$_POST
[
"date"
]==
''
)
059.
{
060.
$x
=
$ym
;
061.
}
062.
else
if
(
$_POST
[
"date"
]!=
''
)
063.
{
064.
$x
=
$ymd
;
065.
}
066.
067.
068.
069.
$sql
= " select webreg__pending_order.domainname,webreg__pending_order.period,webreg__tax_invoice_item.description
070.
,webreg__tax_invoice_item.unit_amount
071.
from webreg__pending_order,webreg__tax_invoice_item
072.
where webreg__pending_order.invoice_item_id = webreg__tax_invoice_item.id
073.
and
webreg__pending_order.username=
'$bp'
and
webreg__pending_order.process_date like
'$x%'
074.
and
webreg__pending_order.status=
'Approve'
075.
076.
UNION ALL
077.
078.
select webreg__pending_renew.domainname,webreg__pending_renew.period,webreg__tax_invoice_item.description
079.
,webreg__tax_invoice_item.unit_amount
080.
from webreg__pending_renew,webreg__tax_invoice_item
081.
where webreg__pending_renew.invoice_item_id = webreg__tax_invoice_item.id
082.
and
webreg__pending_renew.username=
'$bp'
and
webreg__pending_renew.process_date like
'$x%'
083.
and
webreg__pending_renew.status=
'Approve'
084.
085.
UNION ALL
086.
087.
select webreg__pending_transfer_in.domainname,webreg__pending_transfer_in.period,
088.
webreg__tax_invoice_item.description,webreg__tax_invoice_item.unit_amount
089.
from webreg__pending_transfer_in,webreg__tax_invoice_item
090.
where webreg__pending_transfer_in.invoice_item_id = webreg__tax_invoice_item.id
091.
and
webreg__pending_transfer_in.username=
'$bp'
and
webreg__pending_transfer_in.process_date like
'$x%'
092.
and
webreg__pending_transfer_in.status=
'Approve'
";
093.
094.
$result
= mysql_query(
$sql
);
095.
$Num_Rows
= mysql_num_rows(
$result
);
096.
$Per_Page
=
$record
;
097.
$Page
=
$_GET
[
"Page"
];
098.
if
(!
$_GET
[
"Page"
])
099.
{
100.
$Page
=1;
101.
}
102.
$Prev_Page
=
$Page
-1;
103.
$Next_Page
=
$Page
+1;
104.
$Page_Start
= ((
$Per_Page
*
$Page
)-
$Per_Page
);
105.
if
(
$Num_Rows
<=
$Per_Page
)
106.
{
107.
$Num_Pages
=1;
108.
}
109.
else
if
((
$Num_Rows
%
$Per_Page
)==0)
110.
{
111.
$Num_Pages
=(
$Num_Rows
/
$Per_Page
) ;
112.
}
113.
else
114.
{
115.
$Num_Pages
=(
$Num_Rows
/
$Per_Page
)+1;
116.
$Num_Pages
= (int)
$Num_Pages
;
117.
}
118.
119.
120.
121.
122.
$sql
= " (select webreg__pending_order.domainname,webreg__pending_order.period,webreg__tax_invoice_item.description
123.
,webreg__tax_invoice_item.unit_amount
124.
from webreg__pending_order,webreg__tax_invoice_item
125.
where webreg__pending_order.invoice_item_id = webreg__tax_invoice_item.id
126.
and
webreg__pending_order.username=
'$bp'
and
webreg__pending_order.process_date like
'$x%'
127.
and
webreg__pending_order.status=
'Approve'
order by webreg__pending_order.process_date )
128.
129.
UNION ALL
130.
131.
( select webreg__pending_renew.domainname,webreg__pending_renew.period,webreg__tax_invoice_item.description
132.
,webreg__tax_invoice_item.unit_amount
133.
from webreg__pending_renew,webreg__tax_invoice_item
134.
where webreg__pending_renew.invoice_item_id = webreg__tax_invoice_item.id
135.
and
webreg__pending_renew.username=
'$bp'
and
webreg__pending_renew.process_date like
'$x%'
136.
and
webreg__pending_renew.status=
'Approve'
order by webreg__pending_renew.process_date )
137.
138.
UNION ALL
139.
140.
( select webreg__pending_transfer_in.domainname,webreg__pending_transfer_in.period,
141.
webreg__tax_invoice_item.description,webreg__tax_invoice_item.unit_amount
142.
from webreg__pending_transfer_in,webreg__tax_invoice_item
143.
where webreg__pending_transfer_in.invoice_item_id = webreg__tax_invoice_item.id
144.
and
webreg__pending_transfer_in.username=
'$bp'
and
webreg__pending_transfer_in.process_date like
'$x%'
145.
and
webreg__pending_transfer_in.status=
'Approve'
order by webreg__pending_transfer_in.process_date)
146.
LIMIT
$Page_Start
,
$Per_Page
";
147.
148.
$result
= mysql_query(
$sql
);
149.
150.
while
(
$rows
=mysql_fetch_array(
$result
))
151.
{
152.
153.
echo
"<tr><td> </td><td>"
.
$rows
[
'domainname'
].
" ("
.
$rows
[
'description'
].")</td>
154.
<td>
".$rows['period']."
</td><td>
".$rows['unit_amount']/$rows['period']."
</td><td>
".$rows['unit_amount']."
155.
</td></tr>";
156.
}
157.
echo
"</table>"
;
158.
159.
echo
"<br>"
;
160.
161.
echo
"Total "
.
$Num_Rows
.
"Record :"
.
$Num_Pages
.
" Page : "
;
162.
163.
if
(
$Prev_Page
)
164.
{
165.
echo
" <a href=
'$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'
><<
166.
Back</a> ";
167.
}
168.
169.
for
(
$i
=1;
$i
<=
$Num_Pages
;
$i
++)
170.
{
171.
if
(
$i
!=
$Page
)
172.
{
173.
echo
"[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]"
;
174.
}
175.
else
176.
{
177.
echo
"<b> $i </b>"
;
178.
}
179.
}
180.
if
(
$Page
!=
$Num_Pages
)
181.
{
182.
echo
" <a href ='
$_SERVER
[SCRIPT_NAME]?
183.
Page=
$Next_Page
'>Next>></a> ";
184.
}
185.
mysql_close(
$conn2
);
186.
?>