Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- function format_heading(str_heading, lang) {
- var line = str_heading.toString();
- line = line.split("/");
- if (lang == "en") {
- return line[0];
- } else if (lang == "th") {
- return line[1];
- }
- }
- function ThaiBaht(Number, currency) {
- var i;
- var DecimalLen;
- // Arrays of Thai words
- var TxtNumArr = new Array("ศูนย์", "หนึ่ง", "สอง", "สาม", "สี่", "ห้า", "หก", "เจ็ด", "แปด", "เก้า", "สิบ");
- var TxtDigitArr = new Array("", "สิบ", "ร้อย", "พัน", "หมื่น", "แสน", "ล้าน", "สิบ", "ร้อย", "พัน", "หมื่น", "แสน", "ล้าน");
- var BahtText = "";
- // Remove Currency and Symbol
- for (i = 0; i < Number.length; i++) {
- Number = Number.replace(currency, "");
- Number = Number.replace(",", ""); // Remove comma
- Number = Number.replace(" ", ""); // Remove White-space
- Number = Number.replace("บาท", ""); // Remove Baht in Thai
- Number = Number.replace("฿", ""); // Remove Thai Currency Symbol
- }
- //ตรวจสอบดูว่าใช่ตัวเลขที่ถูกต้องหรือเปล่า ด้วย isNaN == true ถ้าเป็นข้อความ == false ถ้าเป็นตัวเลข
- if (isNaN(Number)) {
- return "Invalid input data.";
- } else {
- // Max input validation.
- if ((Number - 0) > 99999999.9999) {
- return "Input out of range. Max = 99999999.9999";
- } else {
- // Split int & decimal.
- Number = Number.toString();
- Number = Number.split(".");
- // Begin input parsing logic.
- if (Number[1].length > 0) {
- Number[1] = Number[1].substring(0, 2);
- }
- var NumberLen = Number[0].length - 0;
- var oldTmp = 0;
- for (i = 0; i < NumberLen; i++) {
- tmp = Number[0].substring(i, i + 1) - 0;
- if (tmp != 0) {
- if ((i == (NumberLen - 1) || i == (NumberLen - 7)) && (tmp == 1) && oldTmp != 0) {
- BahtText += "เอ็ด"; // special word for amount end with 1 eg. 11, 21,31,.....91
- } else
- if (((i == (NumberLen - 2)) && (tmp == 2)) || ((i == (NumberLen - 8)) && (tmp == 2))) {
- BahtText += "ยี่"; // special word for amount ranging in the twenty
- } else
- if (((i == (NumberLen - 2)) && (tmp == 1)) || ((i == (NumberLen - 8)) && (tmp == 1))) {
- BahtText += "";
- } else {
- BahtText += TxtNumArr[tmp];
- }
- BahtText += TxtDigitArr[NumberLen - i - 1];
- } else if ((i == (NumberLen - 7)) && (tmp == 0)) {
- BahtText += TxtDigitArr[NumberLen - i - 1];
- }
- oldTmp = tmp;
- }
- BahtText += "บาท"; // add "baht"
- oldTmp = 0;
- if ((Number[1] == "0") || (Number[1] == "00")) {
- BahtText += "ถ้วน"; // add "Only"
- } else {
- DecimalLen = Number[1].length - 0;
- for (i = 0; i < DecimalLen; i++) {
- tmp = Number[1].substring(i, i + 1) - 0;
- if (tmp !== 0) {
- if ((i == (DecimalLen - 1)) && (tmp == 1) && oldTmp != 0) {
- BahtText += "เอ็ด"; // special word for amount end with 1 eg. 11, 21,31,.....91
- } else
- if ((i == (DecimalLen - 2)) && (tmp == 2)) {
- BahtText += "ยี่"; // special word for amount ranging in the twenty
- } else
- if ((i == (DecimalLen - 2)) && (tmp == 1)) {
- BahtText += "";
- } else {
- BahtText += TxtNumArr[tmp];
- }
- BahtText += TxtDigitArr[DecimalLen - i - 1];
- }
- oldTmp = tmp;
- }
- BahtText += "สตางค์"; // add "Satang" (cent eq)
- }
- return BahtText;
- }
- }
- }
- </script>
- <style>
- /* style sheet for "A4" printing */
- @media print {
- #A5page {
- page-break-after: always;
- }
- }
- @media print and (width: 21cm) and (height: 29.7cm) {
- @page {
- margin: 2cm;
- }
- }
- /* style sheet for "A5" printing */
- #PDF_LetterHead {
- width: 652px;
- }
- #pCompany_logo {
- width: 140px;
- }
- body {
- font-weight: 100;
- }
- .A5_paper {
- break-after: always;
- /*
- width: 8.27in;
- height: 5.83in;
- */
- }
- .A4_paper {
- height: 11.65in;
- }
- .page_divider {
- margin-left: 50px;
- margin-right: 50px;
- margin-bottom: 20px;
- margin-top: 0px;
- color: lightgray;
- }
- .field_data {
- text-align: left;
- vertical-align: text-top;
- font-size: 10px;
- padding: 0px 0px 0px 0px;
- font-weight: 100;
- }
- .field_label {
- text-transform: uppercase;
- text-align: left;
- vertical-align: text-top;
- font-size: 10px;
- padding: 0px 0px 0px 0px;
- width: 20%;
- font-weight: 100;
- }
- .underline {
- border-bottom: 1;
- border-bottom-color: gray;
- border-bottom-width: thin;
- }
- .div_label {
- text-align: left;
- vertical-align: text-top;
- font-size: 10px;
- padding: 0px 0px 0px 0px;
- font-weight: 150;
- text-transform: uppercase;
- }
- .div_data {
- text-align: center;
- vertical-align: middle;
- font-size: 10px;
- padding: 0px 0px 0px 0px;
- font-weight: 100;
- }
- .fixtablelayout {
- width: 100%;
- border-collapse: collapse;
- table-layout: fixed;
- font-size: 10px;
- font-weight: 100;
- overflow: hidden;
- }
- table {
- width: 100%;
- border-collapse: collapse;
- font-weight: 100;
- }
- p {
- word-wrap: break-word;
- }
- tr {
- line-height: 1;
- overflow: hidden;
- }
- hr {
- margin-top: 0px;
- margin-bottom: 5px;
- }
- td {
- font-weight: 100;
- overflow: hidden;
- }
- .div_cLogo {
- padding: 1px 0px 5px 0px;
- vertical-align: text-top;
- text-align: center;
- }
- .div_cBranch {
- padding: 0px 0px 0px 0px;
- vertical-align: middle;
- text-align: center;
- font-size: 8px;
- }
- .min_2px_hight {
- min-height: 2px;
- width: 100%;
- }
- .tr_doctype_label {
- border-collapse: collapse;
- border-radius: 5px 5px 5px 5px;
- background-color: lightgray;
- padding: 2px 0px 2px 0px;
- }
- .tbl_header {
- text-align: center;
- }
- </style>
- <div id="PDF_LetterHead">
- <table width="100%" height="65" id="pDoc_header" cellpadding="0" cellspacing="0" border="0">
- <tbody>
- <tr width="100%" height="100%" id="pHeader">
- <td id="pHeader_company">
- <table width="465" height="100%" id="pCompany" cellpadding="0" cellspacing="0" border="0">
- <tbody>
- <tr>
- <td id="pCompany_logo">
- <div class="div_cLogo">
- <img width="130" src="http://erp.th.ps-groups.com:8000/files/PSIM_Logo_Big.png">
- </div>
- <div class="div_cBranch"> <small>สำนักงานใหญ่</small>
- </div>
- </td>
- <td id="cAddress">
- <div><b style="font-size: 10px;"> บริษัท พีเอส-กรุ๊ปส์ อิมพอร์ต แอนด์ เอ็กซ์พอร์ต จำกัด </b>
- </div>
- <div><b style="font-size: 9px;"> PS-GROUPS IMPORT AND EXPORT COMPANY LIMITED </b>
- </div>
- <div class="min_2px_hight"></div>
- <div><small style="font-size: 8px;"> 551/64 ถนนสาธุประดิษฐ์ แขวงช่องนนทรี เขตยานนาวา กรุงเทพฯ 10120 </small>
- </div>
- <div><small style="font-size: 8px;"> 551/64 Sathupradit Road, Chongnonsee, Yannawa. Bangkok 10120 </small>
- </div>
- <div><small style="font-size: 8px;"> TEL: (66) 2 417-9473 | FAX: (66) 2 405-7097 EMAIL: trade@ps-groups.com</small>
- </div>
- </td>
- </tr>
- </tbody>
- </table>
- </td>
- <td id="pHeader_doc" style="padding:7px 0px 0px 0px;">
- <table width="100%" id="pDocTitle" cellpadding="0" cellspacing="0" border="0">
- <tbody>
- <tr>
- <td class="tr_doctype_label">
- <div class="div_data"> เอกสารต้นฉบับ </div>
- <div class="div_data"><small> ORIGINAL DOCUMENT </small>
- </div>
- </td>
- </tr>
- <tr height="12px">
- <td style="vertical-align: middle; font-size: 8px;" id="pDocTitle_name">
- <div class="div_data min_2px_hight" style="font-size:10px;">
- <script>
- if (typeof doc != "undefined") {
- (format_heading((doc.select_print_heading || ''), 'th') || 'Heading TH') + ' / ' + (format_heading((doc.select_print_heading || ''), 'en') || 'Heading ENG')
- }
- </script>
- </div>
- </td>
- </tr>
- <tr width="100%">
- <td class="center">
- <div id="tax_id" style="font-size: 9px; text-align:center; color:gray;">
- <small>
- <span>เลขประจำตัวผู้เสียภาษีอากร : 0-1055-56036-37-2 </span>
- </small>
- </div>
- </td>
- </tr>
- </tbody>
- </table>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- <div id="page_div">
- <hr>
- </div>
- <div id="tax-invoice_content">
- <div id="doc_info">
- <table width="100%" cellpadding="0" cellspacing="0" class="fixtablelayout">
- <tbody>
- <tr>
- <td colspan="3" style="vertical-align: top; width: 50%;">
- <div style="padding: 0px;">
- <table cellpadding="0" cellspacing="0" style="width: 100%;">
- <tbody>
- <tr>
- <td class="field_label">{{ _("ชื่อ") }}
- <br><small style="color:gray;"> {{ _("Name") }} </small>
- </td>
- <td class="field_data">
- {{ doc.customer_name }}
- <br>(เลขประจำตัวผู้เสียภาษี: {{ doc.vat_id }} )
- <script>
- // doc.customer_name + '<br>(เลขประจำตัวผู้เสียภาษี: ' + doc.vat_id + ' )';
- </script>
- </td>
- </tr>
- </tbody>
- </table>
- <table cellpadding="0" cellspacing="0" style="width: 100%;">
- <tbody>
- <tr>
- <td class="field_label">{{ _("ที่อยู่") }}
- <br><small style="color:gray;"> {{ _("Address") }} </small>
- </td>
- <td class="field_data">
- {{ doc.address_display }}
- <script>
- //doc.address_display
- </script>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- </td>
- <td style="vertical-align: top; width: 30%;">
- <div style="padding: 0px;">
- <table cellpadding="0" cellspacing="0" style="width: 100%;">
- <tbody>
- <tr>
- <td class="field_label" style="width: 37%;">
- {{ _("เลขที่") }}
- <br>
- <small style="color:gray;"> {{ _("Tax Invoice #<br>Receipt #") }} </small>
- </td>
- <td class="field_data" style="width: 63%;">
- {{ doc.name }}
- <script>
- //doc.name;
- </script>
- </td>
- </tr>
- </tbody>
- </table>
- <table cellpadding="0" cellspacing="0" style="width: 100%;">
- <tbody>
- <tr>
- <td class="field_label" style="width: 37%;">
- {{ _("วันที่") }}
- <br>
- <small style="color:gray;"> {{ _("Date") }} </small>
- </td>
- <td class="field_data" style="width: 63%;">
- {{ doc.get_formatted("posting_date") }}
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- <div id="doc_items">
- <table class="fixtablelayout" cellpadding="0" cellspacing="0" >
- <tbody>
- <hr style="color: lightgray;">
- <tr class="div_label">
- <th class="tbl_header" width="50%" align="center"><b> รายการ </b>
- <br><small style="color:gray;"> Description </small>
- </th>
- <th class="tbl_header" width="10%" align="center"><b> จำนวน </b>
- <br><small style="color:gray;"> Quantity </small>
- </th>
- <th class="tbl_header" width="20%" align="center"><b> หน่วยละ </b>
- <br><small style="color:gray;"> Unit Price </small>
- </th>
- <th class="tbl_header" width="20%" align="center"><b> จำนวนเงิน </b>
- <br><small style="color:gray;"> Amount </small>
- </th>
- </tr>
- {%- for row in doc.entries -%}
- <tr>
- <td width="50%" align="left" style="vertical-align:top;">
- {{ row.item_name }} {% if row.description != row.item_name -%}
- <br>
- <i><small style="color:gray;"> {{ row.description }} </small></i>
- {%- endif %}
- </td>
- <td width="10%" align="center" style="vertical-align:top;">{{ row.qty }} {{ row.uom or row.stock_uom }}</td>
- <td width="20%" align="right" style="vertical-align:top;">{{ row.get_formatted("rate", doc) }}</td>
- <td width="20%" align="right" style="vertical-align:top;">{{ row.get_formatted("amount", doc) }}</td>
- </tr>
- {%- endfor -%}
- </tbody>
- </table>
- </div>
- <div><hr></div>
- <div id="doc_summary">
- <table class="fixtablelayout" cellpadding="0" cellspacing="0" >
- <tbody>
- <tr>
- <td class="field_label" width="20%">{{ _("Total of ") }}</td>
- <td class="field_label" style="text-align: center; width: 35%;">
- <div>- <script> (doc.entries.length) </script>
- <script>if (doc.entries.length > 1){ ('items.')}else{ ('item.')}</script> -</div>
- <div><i style="color:lightgray;">(E. &O. E)</i></div>
- </td>
- <td class="field_label" style="text-align: right; width: 17%;">{{ _("Net Total") }}</td>
- <td class="field_label underline" style="text-align: right; width: 28%;">{{ doc.get_formatted("net_total_export") }}</td>
- </tr>
- {%- for row in doc.other_charges -%}
- {% if not row.included_in_print_rate -%}
- <tr>
- <td class="field_label underline" style="text-align: right; width: 70%;" colspan="3">{{ row.description }}</td>
- <td class="field_label" style="text-align: right; width: 30%;">{{ row.get_formatted("tax_amount", doc) }}</td>
- </tr>
- {%- endif %}
- {%- endfor -%}
- {% if doc.discount_amount -%}
- <tr>
- <td align="right" colspan="3" width="70%">{{ _("Discount") }}</td>
- <td align="right">{{ doc.get_formatted("discount_amount", doc) }}</td>
- </tr>
- {%- endif %}
- <tr>
- <td align="right" colspan="3" width="70%"><b> {{ _("Grand Total") }} </b>
- </td>
- <td align="right">{{ doc.get_formatted("grand_total_export", doc) }}</td>
- </tr>
- <tr>
- <td align="left" width="20%"><b> {{ _("จำนวนเงินเป็นตัวอักษร") }} </b></td>
- <td align="center" width="50%" colspan="4">
- --
- <script>
- ThaiBaht(format_currency(doc.grand_total_export, doc.currency), doc.currency)
- </script>
- --
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- <div>
- <hr>
- </div>
- <div id="doc_footer" class="field_data">
- <small style="text-font:8px; color=gray">
- <span>หมายเหตุ</span><br />
- <span>1. โปรดตรวจสอบความถูกต้องของรายการและรายละเอียดในเอกสารฉบับนี้ภายใน 7 วัน มิฉะนั้น ทางบริษัทจะถือว่าเอกสารฉบับนี้ถูกต้องและสมบูรณ์</span><br />
- <span>2. ใบกำกับภาษีนี้จะสมบูรณ์เมื่อมีลายมือชื่อของผู้มีอำนาจลงนาม</span><br />
- <span>3. ในกรณีที่เป้นเช็คใบกำกับภาษีนี้จะสมบูรณ์เมื่อธนาคารเรียกเก็บเงินได้ครบถ้วน</span>
- </small>
- </div>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement