查看文件: makebill.php
大小: 7.9 KB
类型: application/octet-stream
<?php require_once('../Connections/BE2.php'); ?> <? exit; if (!isset($_SESSION)){ session_start(); } if(isset($_POST['myb2cpost']) && $_POST['myb2cpost']=='mypost' ){ // $selfile=($_POST['sel_b2c']==0)?"bib2b":"bib2c"; $url='https://www.giveme.com.tw/invoice.do?action=addB2C'; if($_POST['sel_b2c']==0){ $url='https://www.giveme.com.tw/invoice.do?action=addB2B';} /* if(strlen($decoded_json['phone'])==8 ){ if(substr($decoded_json['phone'],0,1)<>'/') { $url='https://www.giveme.com.tw/invoice.do?action=addB2B'; fwrite($fp,"====addB2B==\r\n"); } } */ $logpath="/www2/skybni/log/bill_log.txt"; $fp = fopen($logpath, "a"); // b2b if($_POST['sel_b2c']==0){ $data = '{"timeStamp":"","uncode":"","idno":"","sign":"","customerName":"","phone":"","datetime":"","email":"","taxState":"0","taxType":0,"sales":0,"amount":0,"totalFee":0,"content":"","items":[]}'; } else { $data = '{"timeStamp":"","uncode":"","idno":"","sign":"","customerName":"","phone":"","orderCode":"","datetime":"","email":"","state":"0","donationCode":"","taxType":0,"sales":0,"amount":0,"totalFee":0,"content":"","items":[]}'; } $decoded_json = json_decode($data, true); //$manage = json_decode($data, true); $decoded_json["timeStamp"]=time().rand(100,999); $decoded_json["uncode"]="42656789"; $decoded_json["idno"]="A126569032"; $decoded_json["datetime"]=date('Y-m-d'); $decoded_json["email"]=$_POST['q_email']; $pwd= "AX6789"; $sign= $decoded_json['timeStamp'].$decoded_json['idno'].$pwd ;// 822344324 $sign= strtoupper(md5($sign)); $decoded_json['sign']=$sign; if($_POST['sel_b2c']==1){ $decoded_json["customerName"]=$_POST['q_customerName'];//'82401230082' if($_POST['q_donationCode']<>''){ $decoded_json["donationCode"]=$_POST['q_donationCode']; $decoded_json["state"]="1"; $decoded_json["phone"]=""; $decoded_json["email"]=""; // "content":"82403270111", }else{ $decoded_json["state"]="0"; $decoded_json["phone"]= $_POST['q_phone']; $decoded_json["email"]= $_POST['q_email']; } }else{ //content $decoded_json["content"]=$_POST['q_customerName'];//'82401230082'; $decoded_json["phone"]= $_POST['q_phone']; } mysql_select_db($database_BE2, $BE2); //$query_Rt2 =sprintf("SELECT a.*,b.p_title FROM order_datas as a,product_data as b WHERE a.dcode='%s' AND a.mem_auto=b.mem_auto ",$_POST['q_customerName'] ); $query_Rt2 = "SELECT a.*,b.p_title FROM order_datas as a,product_data as b WHERE a.mem_auto=b.mem_auto order by a.dcode desc limit 5 " ; $Rt2 = mysql_query($query_Rt2, $BE2) or die(mysql_error()); $row_Rt2 = mysql_fetch_assoc($Rt2); $totalRows_Rt2 = mysql_num_rows($Rt2); // echo $query_Rt2."<br>"; //taxState 單價是否含稅 0:含稅(默認) 1: 未稅 $sales=0; $totalFee=0; do { $arrne['name'] = $row_Rt2['p_title'] ; $arrne['money'] = intval($row_Rt2['p_money']); $arrne['number'] = intval($row_Rt2['p_count']); $sales=$sales+$row_Rt2['p_money']; array_push( $decoded_json['items'], $arrne ); } while ($row_Rt2 = mysql_fetch_assoc($Rt2)); $decoded_json["sales"]= $sales; $decoded_json["totalFee"]= $sales; $sales=$sales+$row_Rt2['p_money']; // $array = json_decode($json,true); // $string = implode(",",$decoded_json); fwrite($fp, json_encode($decoded_json) ."\r\n");// 822344324 // print json_encode($decoded_json); echo("==========end==========<br>"); // echo($json); // fwrite($fp, var_dump($decoded_json) ."\r\n");// 822344324 // 發票檔 // $pay_num=111111; // $InsertSQL2 = sprintf("INSERT INTO order_bill(dcode,mem_id,selb2c,uncode,qphone,donationcode,email,ordertime,billcode,ck) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", // $pay_num,$_SESSION['login_memid'],$_POST['sel_b2c'],$_POST["q_uncode"],$_POST["q_phone"],$_POST["q_donationCode"],$_POST["q_email"],date('Y-m-d'),"","N"); // mysql_query( $InsertSQL2, $BE2) or die(mysql_error()); // mysql_select_db($database_BE2, $BE2); fwrite($fp, "========================\r\n");// 822344324 fclose($fp); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>無標題文件</title> <script type="text/javascript" src="/js/jquery-1.9.1.min.js"></script> </head> <body> <form action="" method="POST" onsubmit="return form1check(this.form);"> <table width="511" border="1" cellpadding="1"> <tr> <td>單據號</td> <td><input name="q_customerName" type="text" id="q_customerName" value="2023072818024000013" /></td> <td><input name="q_billcomp" type="hidden" id="q_billcomp" value="天空商城有限公司" /> <input name="q_orderCode" type="hidden" id="q_orderCode" value="42656789"/></td> </tr> <tr> <td width="123" nowrap="nowrap">發票別</td> <td width="183"><input name="sel_b2c" type="radio" id="sel_b2c" value="0" checked="checked" /> B2B公司</td> <td width="183"><input name="sel_b2c" id="sel_b2c" type="radio" value="1" /> B2C個人</td> </tr> <tr> <td>載具/手機/統編</td> <td><input name="q_phone" type="text" id="q_phone" /></td> <td><input name="myb2cpost" type="hidden" id="myb2cpost" value="mypost"/></td> </tr> <tr> <td>捐贈碼 <input type="checkbox" name="ch_dona" id="ch_dona" value="1" /> <label for="ch_dona"></label></td> <td><input name="q_donationCode" type="text" id="q_donationCode" /></td> <td><input type="text" class="gui_number" name="gui_number" maxlength="8"> <input type="button" value="驗證" onclick="check_tax_number()"></td> </tr> <tr> <td>郵件</td> <td><input name="q_email" type="text" id="q_email" /></td> <td> </td> </tr> <tr> <td>消售額</td> <td><input name="q_sales" type="text" id="q_sales" readonly="readonly" /></td> <td> </td> </tr> <tr> <td>稅額</td> <td><input name="q_amount" type="text" id="q_amount" readonly="readonly" /></td> <td> </td> </tr> <tr> <td>總金額</td> <td><input name="q_totalfee" type="text" id="q_totalfee" readonly="readonly" /></td> <td> </td> </tr> <tr> <td> </td> <td align="center"><input type="submit" name="button" id="button" value="送出" /></td> <td> </td> </tr> </table> </form> <script type="text/javascript"> function form1check(){ var ck=true; // var v = document.querySelector('input[name="sel_b2c"]:checked').value;; var v = $("input[name='sel_b2c']:checked").val(); alert(v); if(v==0){ ck= check_tax_number(); } return ck; } function check_tax_number() { const gui_number = $('#q_phone').val(); //document.querySelector('sel_b2c').value; // 取欄位內容 const cx = [1, 2, 1, 2, 1, 2, 4, 1]; const cnum = gui_number.split(''); let sum = 0; function cc(num) { let total = num; if (total > 9) { let s = total.toString(); const n1 = s.substring(0, 1) * 1; const n2 = s.substring(1, 2) * 1; total = n1 + n2; } return total; } if (gui_number.length !== 8) { alert('統編錯誤,要有 8 個數字'); return false; } cnum.forEach((item, index) => { if (gui_number.charCodeAt() < 48 || gui_number.charCodeAt() > 57) { // alert('統編錯誤,要有 8 個 0-9 數字組合'); return false; } sum += cc(item * cx[index]); }); if (sum % 10 === 0) { //alert('統編正確'); return true; } else if (cnum[6] === '7' && (sum + 1) % 10 === 0) { //alert('統編正確2'); return true; } else { alert('統編錯誤'); return false; } } </script> </body> </html>
保存
取消
返回文件列表