2010年2月6日 星期六
[PHP] 列印發票
<? php // Use this code to write directly to the COM1 serial port // First, you want to set the mode of the port. You need to set // it only once; it will remain the same until you reboot. // Note: the backticks on the following line will execute the // DOS 'mode' command from within PHP `mode COM1: BAUD=9600 PARITY=N data=8 stop=1 xon=off`; $fp = fopen ("COM1:", "w+"); if (!$fp) { echo "Uh-oh. Port not opened."; } else { // 初始印表機 $string = chr(27) . "@"; // 啟動同步列印 $string .= chr(27) . "z" . chr(1); // 跳過店章位置(跳四列) $string .= chr(27) . "d" . chr(4); // 列印前開錢櫃 /* if ( ) { $str .= chr(27) . "p0" . chr(50) . chr(250); } */ $string .= "88/12/01 12:30:09 #00001" . chr(13) . chr(10); $string .= "------------------------" . chr(13) . chr(10); $string .= "印表機 1 x 5600 5,600" . chr(13) . chr(10); $string .= "磁碟機 20 x 4000 80,000" . chr(13) . chr(10); $string .= "電腦桌 1 x 800 800" . chr(13) . chr(10); $string .= "------------------------" . chr(13) . chr(10); $string .= "小計: 86,400" . chr(13) . chr(10); $string .= "稅額: 4,320" . chr(13) . chr(10); $string .= "========================" . chr(13) . chr(10); $string .= "合計: 90,720" . chr(13) . chr(10); // 跳2列不印 $string .= chr(27) . "d" . chr(2); $string .= "謝謝!期待您的再次光臨!" . chr(13) . chr(10); // 跳19列到蓋店章位置 $string .= chr(27) . "d" . chr(19); // 蓋店章 $string .= chr(27) . "o"; // 跳頁 $string .= chr(12); /* // 列印後開錢櫃 if () { } */ echo $string; fputs ($fp, $string ); fclose ($fp); } ?>
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言