To get the HTML report of Invoice. Paste the following in the PLSQL Dynamic Content:
declare
V_COMPANY_NAME VARCHAR2(100):='ABC COMPANY.';
cursor c_orders is select ORDER_ID,CUSTOMER_ID,ORDER_TOTAL,ORDER_TIMESTAMP
FROM DEMO_ORDERS WHERE ORDER_ID=:P14_ORDER_ID;
r_orders c_orders%rowtype;
V_CUSTOMER_NAME VARCHAR2(100);
V_PHONE_NUMBER1 VARCHAR2(50);
begin
------------------------------- print button
htp.p('
<a id="b_exit" type="button1" class="button button3" class="exit" '||'href="'||APEX_UTIL.PREPARE_URL('f?p=&APP_ID.:1:&SESSION.::&DEBUG.::::')||'">Close</a>
<input type="button1" class="button button1" class="t-Icon t-Icon--right fa fa-print" id="print" type="button" onclick="printdiv(''div_print1'');" value="Print"/><br/>
<div id="div_print1" style="margin-top:5px; align:right;" >
');
-------------------------------
OPEN C_ORDERS;
FETCH C_ORDERS INTO R_ORDERS;
CLOSE C_ORDERS;
select CUST_FIRST_NAME||' '||CUST_LAST_NAME,PHONE_NUMBER1 INTO V_CUSTOMER_NAME,V_PHONE_NUMBER1 FROM DEMO_CUSTOMERS WHERE CUSTOMER_ID=r_orders.CUSTOMER_ID;
-------------------------------
htp.p('
<html>
<header>
<title>Order Invoice</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
img {float: left;}
h2.page-header {
margin: 0;
padding: 0;
}
h3.page-header {
align:center;
margin: 0;
padding: 0;
}
h1 {
text-align: center;
text-transform: uppercase;
}
p {text-align: center;}
.napkin2,th,td {
border: 1px solid black ;
border-collapse: collapse;
padding: 5px;
}
.napkin,th {
border: 1px solid #607d8b ;
border-collapse: collapse;
padding: 5px;
}
.p1 {
border: 0px;
text-align: left;
}
.td1 {
border: 0px;
text-align: left;
}
.td1 {
border: 0px;
text-align: left;
}
.full {
width:100%;
}
.p00 {text-align: right; border: 0px;}
.m2 {text-align:center;}
.m3{text-align: center;
.m4{text-align: center;
border: 1px solid #607d8b;}
.m4{text-align: center;
border: 1px solid #607d8b;
}
.m5{text-align: center;}
.m1,.m2,.m3.m4,.m5 {border: 0px solid #607d8b;}
.m1{padding-left: 5px;}
.m2{padding-right: 5px;}
.m3{padding-right: 5px;}
.m4{padding-right: 5px;}
.lower { padding-top: 50px;}
.low,.low1 {text-align: center;}
</style>
</header>
<body>
');
------------------------------------- IMAGE
FOR I IN
(SELECT ID,
'<img width="80px" src="'||apex_util.get_blob_file_src('P25_IMAGE',ID)||'" />' IMAGE
from DEMO_COMPANY where id=5) LOOP
htp.p('
<table align="left">
<td float="left" width=100%>'|| i.image ||'</td>
</table>');
END LOOP;
htp.p('
<h2 class="page-header" align="center">'||V_COMPANY_NAME||'</h2>
<h3 class="page-header" align="center"><u>Order Invoice</u></h3>
');
htp.p('
</article>
</section>
</br> </br>
');
-------------------------------------
htp.p('
<table class="full" align="center" width="100%">
<tr>
<td class="td1">
<table class="Patient">
<tr>
<th class="p1">Order No: </th>
<td class="p1">: '||r_orders.order_id||'</td>
</tr>
<tr>
<th class="p1">CUSTOMER NAME : </th>
<td class="p1">: '||V_CUSTOMER_NAME||'</td>
</tr>
</table>
</td>
<td class="td1">
<table class="patient2" align="right">
<tr>
<th class="p1">ORDER DATE :</th>
<td class="p1"> '||r_orders.ORDER_TIMESTAMP||'</td>
</tr>
<tr>
<th class="p1">CUSTOMER PHONE :</th>
<td class="p1"> '||V_PHONE_NUMBER1||'</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
');
-------------------------------------
htp.p('
<table class="napkin2" align="center" width=100% >
<thead>
<tr>
<th width="50px">ID</th>
<th width="400px">Products </th>
<th width="100px">Unit Price</th>
<th width="100px">Quantity</th>
<th width="100px">Amount</th>
</tr>
</thead>
');
for r in (SELECT ROWNUM ORDER_ITEM_ID,f_product(PRODUCT_ID) PRODUCT_NAME,UNIT_PRICE,QUANTITY,NVL(UNIT_PRICE,0)*NVL(QUANTITY,0) AMOUNT FROM DEMO_ORDER_ITEMS WHERE ORDER_ID=:P19_ORDER_ID) loop
htp.p('
<tbody>
<tr>
<td width="50px" align=center>'||' '||htf.escape_sc(r.ORDER_ITEM_ID)||'</td>
<td width="400px" align=left>'||' '||htf.escape_sc(r.PRODUCT_NAME)||'</td>
<td width="100px" align=right>'||' '||htf.escape_sc(to_char(r.UNIT_PRICE,'99,99,999.99'))||'</td>
<td width="100px" align=center>'||' '||htf.escape_sc(r.QUANTITY)||'</td>
<td width="100px" align=right>'||' '||htf.escape_sc(to_char(r.AMOUNT,'99,99,999.99'))||'</td>
</tr>
</tbody>
');
end loop;
htp.p('
</table>
</body>
');
htp.p('
<td class="td1">
<table class="patient2" align="right">
<tr>
<th class="p1">Total :</th>
<td class="p1"> '||to_char(r_orders.ORDER_TOTAL,'99,99,99,999.99')||'</td>
</tr>
</table>
</td>
');
htp.p('</div>');
end;