js連線小票印表機
var div = dojo.create("div");
var table = dojo.create("table", {cellpadding: "3", cellspacing: "5", style: "min-width:250px; max-width:300px; font:15px arial,sans-serif;"}, div);
var tBody = dojo.create("tbody", {style: {verticalAlign: "initial"}}, table);
var tr = dojo.create("tr", null, tBody);
var td = dojo.create("td", {align: "left", colspan: "3"}, tr);
dojo.create("span", {style: "font:bold 18px arial,sans-serif;", innerHTML: app.gym.name}, td);
if(app.gym.phone && app.gym.phone.length>0)
{
tr = dojo.create("tr", null, tBody);
var td = dojo.create("td", {align: "left", style: "font:15px arial,sans-serif;", colspan: "3"}, tr);
dojo.create("span", {style: "margin-right:10px;", innerHTML: "電話"}, td);
dojo.create("span", {innerHTML: app.gym.phone}, td);
}
tr = dojo.create("tr", null, tBody);
dojo.create("td", {align: "left", style: "border-bottom:1px solid black; width:100%; height:5px; margin-bottom:5px; ", colspan: "3"}, tr);
tr = dojo.create("tr", null, tBody);
var td = dojo.create("td", {align: "left", style: "font:15px arial,sans-serif;", colspan: "3"}, tr);
dojo.create("span", {style: "margin-right:10px;", innerHTML: "收款員"}, td);
dojo.create("span", {innerHTML: app.user.displayName}, td);
tr = dojo.create("tr", null, tBody);
dojo.create("td", {align: "left", style: "border-bottom:1px solid black; width:100%; height:5px; margin-bottom:5px; ", colspan: "3"}, tr);
tr = dojo.create("tr", null, tBody);
td = dojo.create("td", {style: "width:50%;", innerHTML: "單價"}, tr);
td = dojo.create("td", {style: "width:20%;", innerHTML: "數量"}, tr);
td = dojo.create("td", {style: "width:30%;", innerHTML: "金額"}, tr);
tr = dojo.create("tr", null, tBody);
dojo.create("td", {align: "left", style: "border-bottom:1px solid black; width:100%; height:5px; margin-bottom:5px; ", colspan: "3"}, tr);
var conPrice = 0;
var sumPrice = 0;
for(var i=0; i<this.app.shoppingCart.products.length; i++)
{
var product = this.app.shoppingCart.products[i];
tr = dojo.create("tr", null, tBody);
td = dojo.create("td", {align: "left", colspan: "3", innerHTML: product.name}, tr);
tr = dojo.create("tr", {style: "margin-bottom:5px;"}, tBody);
td = dojo.create("td", {style: "width:50%;", innerHTML: isCardPay?product.memberPrice:product.retailPrice}, tr);
td = dojo.create("td", {style: "width:20%;", innerHTML: isCardPay?(product.cardPrice/product.memberPrice):(product.price/product.retailPrice)}, tr);
td = dojo.create("td", {style: "width:30%;", innerHTML: isCardPay?product.cardPrice:product.price}, tr);
conPrice += isCardPay?product.cardPrice:product.price;
sumPrice += product.price;
}
tr = dojo.create("tr", null, tBody);
dojo.create("td", {align: "left", style: "border-bottom:1px solid black; width:100%; height:5px; margin-bottom:5px; ", colspan: "3"}, tr);
tr = dojo.create("tr", null, tBody);
td = dojo.create("td", {align: "left", innerHTML: "原價"}, tr);
dojo.create("span", {innerHTML: sumPrice}, td);
td = dojo.create("td", {align: "left", colspan: "2", innerHTML: "折扣"}, tr);
dojo.create("span", {innerHTML: String(10/parseFloat(sumPrice/conPrice)).substring(0,3)}, td);
tr = dojo.create("tr", null, tBody);
dojo.create("td", {align: "left", style: "border-bottom:1px solid black; width:100%; height:5px; margin-bottom:5px; ", colspan: "3"}, tr);
tr = dojo.create("tr", null, tBody);
td = dojo.create("td", {align: "left", style: "font:bold 18px arial,sans-serif;", colspan: "3", innerHTML: "實收金額: "}, tr);
dojo.create("span", {innerHTML: conPrice}, td);
tr = dojo.create("tr", null, tBody);
dojo.create("td", {align: "left", style: "border-bottom:1px solid black; width:100%; height:5px; margin-bottom:5px; ", colspan: "3"}, tr);
tr = dojo.create("tr", null, tBody);
td = dojo.create("td", {align: "left", colspan: "3", innerHTML: "日期"}, tr);
dojo.create("span", {innerHTML: dojo.date.locale.format(new Date(), {datePattern: "yyyy-MM-dd", timePattern:'hh:mm:ss'})}, td);
tr = dojo.create("tr", null, tBody);
dojo.create("td", {align: "left", style: "border-bottom:1px solid black; width:100%; height:5px; margin-bottom:5px; ", colspan: "3"}, tr);
tr = dojo.create("tr", null, tBody);
td = dojo.create("td", {align: "left", colspan: "3", innerHTML: "謝謝光臨!"}, tr);
tr = dojo.create("tr", null, tBody);
td = dojo.create("td", {align: "left", colspan: "3", innerHTML: "www.didayuandong.com"}, tr);
var content = div.innerHTML;
var fea = "location=no,toobar=no,resizable=no,status=no,menubar=no,scrollbars=no,dependent=no,width=230px,height=530px,dialog=yes";
var newWin = window.open(window.location.protocol+"//"+window.location.host+"/gris/print.html","購買商品",fea);
newWin.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'+
'<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Print</title>'+
'<style media="print">.noprint { display: none }.PageNext{ PAGE-BREAK-AFTER: always }</style>'+
'<script>function doPrint(){if(document.all){document.execCommand(\'print\');window.close();}else{window.print();window.close();}}</script>'+
'<br>'+content + '<br><form><input class="noprint" type="button" value="列印" onclick="doPrint()"></form>');
newWin.focus();
var table = dojo.create("table", {cellpadding: "3", cellspacing: "5", style: "min-width:250px; max-width:300px; font:15px arial,sans-serif;"}, div);
var tBody = dojo.create("tbody", {style: {verticalAlign: "initial"}}, table);
var tr = dojo.create("tr", null, tBody);
var td = dojo.create("td", {align: "left", colspan: "3"}, tr);
dojo.create("span", {style: "font:bold 18px arial,sans-serif;", innerHTML: app.gym.name}, td);
if(app.gym.phone && app.gym.phone.length>0)
{
tr = dojo.create("tr", null, tBody);
var td = dojo.create("td", {align: "left", style: "font:15px arial,sans-serif;", colspan: "3"}, tr);
dojo.create("span", {style: "margin-right:10px;", innerHTML: "電話"}, td);
dojo.create("span", {innerHTML: app.gym.phone}, td);
}
tr = dojo.create("tr", null, tBody);
dojo.create("td", {align: "left", style: "border-bottom:1px solid black; width:100%; height:5px; margin-bottom:5px; ", colspan: "3"}, tr);
tr = dojo.create("tr", null, tBody);
var td = dojo.create("td", {align: "left", style: "font:15px arial,sans-serif;", colspan: "3"}, tr);
dojo.create("span", {style: "margin-right:10px;", innerHTML: "收款員"}, td);
dojo.create("span", {innerHTML: app.user.displayName}, td);
tr = dojo.create("tr", null, tBody);
dojo.create("td", {align: "left", style: "border-bottom:1px solid black; width:100%; height:5px; margin-bottom:5px; ", colspan: "3"}, tr);
tr = dojo.create("tr", null, tBody);
td = dojo.create("td", {style: "width:50%;", innerHTML: "單價"}, tr);
td = dojo.create("td", {style: "width:20%;", innerHTML: "數量"}, tr);
td = dojo.create("td", {style: "width:30%;", innerHTML: "金額"}, tr);
tr = dojo.create("tr", null, tBody);
dojo.create("td", {align: "left", style: "border-bottom:1px solid black; width:100%; height:5px; margin-bottom:5px; ", colspan: "3"}, tr);
var conPrice = 0;
var sumPrice = 0;
for(var i=0; i<this.app.shoppingCart.products.length; i++)
{
var product = this.app.shoppingCart.products[i];
tr = dojo.create("tr", null, tBody);
td = dojo.create("td", {align: "left", colspan: "3", innerHTML: product.name}, tr);
tr = dojo.create("tr", {style: "margin-bottom:5px;"}, tBody);
td = dojo.create("td", {style: "width:50%;", innerHTML: isCardPay?product.memberPrice:product.retailPrice}, tr);
td = dojo.create("td", {style: "width:20%;", innerHTML: isCardPay?(product.cardPrice/product.memberPrice):(product.price/product.retailPrice)}, tr);
td = dojo.create("td", {style: "width:30%;", innerHTML: isCardPay?product.cardPrice:product.price}, tr);
conPrice += isCardPay?product.cardPrice:product.price;
sumPrice += product.price;
}
tr = dojo.create("tr", null, tBody);
dojo.create("td", {align: "left", style: "border-bottom:1px solid black; width:100%; height:5px; margin-bottom:5px; ", colspan: "3"}, tr);
tr = dojo.create("tr", null, tBody);
td = dojo.create("td", {align: "left", innerHTML: "原價"}, tr);
dojo.create("span", {innerHTML: sumPrice}, td);
td = dojo.create("td", {align: "left", colspan: "2", innerHTML: "折扣"}, tr);
dojo.create("span", {innerHTML: String(10/parseFloat(sumPrice/conPrice)).substring(0,3)}, td);
tr = dojo.create("tr", null, tBody);
dojo.create("td", {align: "left", style: "border-bottom:1px solid black; width:100%; height:5px; margin-bottom:5px; ", colspan: "3"}, tr);
tr = dojo.create("tr", null, tBody);
td = dojo.create("td", {align: "left", style: "font:bold 18px arial,sans-serif;", colspan: "3", innerHTML: "實收金額: "}, tr);
dojo.create("span", {innerHTML: conPrice}, td);
tr = dojo.create("tr", null, tBody);
dojo.create("td", {align: "left", style: "border-bottom:1px solid black; width:100%; height:5px; margin-bottom:5px; ", colspan: "3"}, tr);
tr = dojo.create("tr", null, tBody);
td = dojo.create("td", {align: "left", colspan: "3", innerHTML: "日期"}, tr);
dojo.create("span", {innerHTML: dojo.date.locale.format(new Date(), {datePattern: "yyyy-MM-dd", timePattern:'hh:mm:ss'})}, td);
tr = dojo.create("tr", null, tBody);
dojo.create("td", {align: "left", style: "border-bottom:1px solid black; width:100%; height:5px; margin-bottom:5px; ", colspan: "3"}, tr);
tr = dojo.create("tr", null, tBody);
td = dojo.create("td", {align: "left", colspan: "3", innerHTML: "謝謝光臨!"}, tr);
tr = dojo.create("tr", null, tBody);
td = dojo.create("td", {align: "left", colspan: "3", innerHTML: "www.didayuandong.com"}, tr);
var content = div.innerHTML;
var fea = "location=no,toobar=no,resizable=no,status=no,menubar=no,scrollbars=no,dependent=no,width=230px,height=530px,dialog=yes";
var newWin = window.open(window.location.protocol+"//"+window.location.host+"/gris/print.html","購買商品",fea);
newWin.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'+
'<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Print</title>'+
'<style media="print">.noprint { display: none }.PageNext{ PAGE-BREAK-AFTER: always }</style>'+
'<script>function doPrint(){if(document.all){document.execCommand(\'print\');window.close();}else{window.print();window.close();}}</script>'+
'<br>'+content + '<br><form><input class="noprint" type="button" value="列印" onclick="doPrint()"></form>');
newWin.focus();
相關文章
- 印表機離線了怎麼連線 印表機離線的連線方法
- 印表機無法連線怎麼辦 印表機連線不了的方法
- 印表機離線了怎麼重新連線 印表機離線重新連線的方法
- 無線印表機怎麼連線電腦 WIN10連線無線印表機的方法Win10
- 手機怎麼連印表機列印東西 手機連線印表機步驟
- win10連線usb印表機的方法_win10如何連線usb印表機Win10
- 電腦怎麼連線印表機裝置 電腦連線印表機操作步驟
- 如何用ip地址連線共享印表機 用ip地址連線共享印表機的方法
- 惠普136w印表機怎麼連線wifi hp136w印表機無線連線教程WiFi
- 筆記本怎麼連印表機 筆記本與印表機連線的教程筆記
- win10網路印表機怎麼連線 win10連線網路印表機的步驟Win10
- win10連線不上網路印表機怎麼辦 為什麼連線不上印表機Win10
- win10連線區域網印表機的步驟_win10如何連線區域網印表機Win10
- win10怎麼遠端連線網路印表機_win10遠端連線印表機的方法Win10
- 印表機離線如何處理 印表機離線的方法
- 印表機usb連線電腦無法識別怎麼辦 印表機usb連線電腦無法識別的方法
- 一臺印表機怎麼連線兩臺電腦 印表機如何串聯多臺電腦
- 共享印表機有密碼怎麼連線 win10共享印表機需要密碼密碼Win10
- win10為什麼連不上共享印表機 wind10無法連線共享印表機的方法Win10
- windows11怎麼連線印表機 win11電腦怎麼新增印表機Windows
- 印表機離線怎麼回事 印表機離線的解決方法
- win10連不上印表機怎麼回事_win10系統連線不上印表機如何解決Win10
- win10怎麼訪問網路印表機_w10如何連線網路印表機Win10
- Wiin10怎麼共享印表機?Win10系統共享印表機設定連線方法Win10
- win10連線共享印表機需要密碼如何設定Win10密碼
- 連線共享印表機0x0000011b錯誤怎麼辦 連線共享印表機0x0000011b錯誤的方法
- 網路印表機無法連線的原因與解決辦法
- Win10系統怎麼設定連線網路印表機?Win10
- win10搜不到win7共享印表機 win10連線不上win7印表機的方法Win10Win7
- Win10電腦關機後USB連線印表機埠消失怎麼辦?Win10
- win10系統連線惠普6960無線印表機的方法【圖文詳解】Win10
- win10共享印表機給xp憑證問題_xp連線win10印表機憑證不足解決方法Win10
- windows無法連線到印表機怎麼辦 印表機錯誤0x0000011b完美解決方法Windows
- win10 guest共享無法連線到印表機怎麼設定Win10
- win10連線共享印表機錯誤709怎麼解決Win10
- Win10連線HPDesKJet印表機只能列印校準頁如何解決Win10
- 換了wifi怎麼重新設定印表機 wifi換了印表機連不上WiFi
- Win10系統連線共享印表機提示操作失敗如何解決Win10