268 changed files with 45944 additions and 44355 deletions
@ -0,0 +1,99 @@ |
|||
<?php |
|||
ini_set('display_errors', 'on'); |
|||
date_default_timezone_set('Asia/Taipei'); |
|||
|
|||
$referrer = isset($_REQUEST['referer']) ? $_REQUEST['referer'] : ""; |
|||
$hashReferer = "https://bpm.masada.com.twMasada@2023"; |
|||
|
|||
if ($hashReferer == $referrer) { |
|||
|
|||
include "T8_Authorization_from_bpm.php"; |
|||
|
|||
$user_id = "M0000"; |
|||
$user_password = "M012290493119"; |
|||
$validation = get_Auth("M0000", "M012290493119"); |
|||
|
|||
send_data_to_API($validation); |
|||
} else { |
|||
echo "非法訪問!"; |
|||
exit; |
|||
} |
|||
|
|||
|
|||
function send_data_to_API($validation) |
|||
{ |
|||
// $apiurl = 'http://60.244.87.101:880//twWebAPI/V1/STKASSY/PostERPData'; |
|||
$apiurl = 'http://10.10.145.2:880//twWebAPI/V1/STKASSY/PostERPData'; |
|||
// $apiurl = 'https://erp.masada.com.tw:780/twWebAPI/V1/STKASSY/PostERPData'; |
|||
|
|||
$headerParam = [ |
|||
'CHI_Authorization: ' . $validation, |
|||
'Content-Type: application/json' |
|||
]; |
|||
|
|||
$body = [ |
|||
[ |
|||
"name" => "stkAssyMast", |
|||
"rows" => [ |
|||
[ |
|||
"BillNo" => "TEST06", |
|||
"OrgId" => "1000", |
|||
"TypeId" => "CA", |
|||
"MaterialId" => "3MH00302", |
|||
"PersonId" => "M0122", |
|||
"CompId" => "1001", |
|||
"DeptId" => "220", |
|||
"SQuantity" => 1, |
|||
"SUnitId" => "SET", |
|||
"CurrentState" => 2, |
|||
"CreatorId" => "M0122" |
|||
] |
|||
] |
|||
], |
|||
[ |
|||
"name" => "stkAssySubMatInfo", |
|||
"rows" => [ |
|||
[ |
|||
"BillNo" => "TEST06", |
|||
"MaterialId" => "3MH00302P", |
|||
"ComponentBaseQty" => 1, |
|||
"UnitQty" => 1, |
|||
"SUnitId" => "SET", |
|||
"MarkerNo" => "3MH00302", |
|||
"CU_MaterialId" => "3MH00302" |
|||
], |
|||
[ |
|||
"BillNo" => "TEST06", |
|||
"MaterialId" => "MX00000001", |
|||
"ComponentBaseQty" => 1, |
|||
"UnitQty" => 3, |
|||
"SUnitId" => "PCS", |
|||
"MarkerNo" => "3MH00302", |
|||
"CU_MaterialId" => "3MH00302" |
|||
] |
|||
] |
|||
] |
|||
]; |
|||
|
|||
$json = json_encode($body); |
|||
|
|||
$ch = curl_init(); |
|||
curl_setopt($ch, CURLOPT_URL, $apiurl); |
|||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headerParam); |
|||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
|||
curl_setopt($ch, CURLOPT_POSTFIELDS, $json); |
|||
|
|||
$response = curl_exec($ch); |
|||
|
|||
if ($response === false) { |
|||
echo 'Curl error: ' . curl_error($ch); |
|||
} else { |
|||
$result = json_decode($response, true); |
|||
echo $result['Status'] . "\n"; |
|||
echo $result['ErrorMsg'] . "\n"; |
|||
print_r($result['Data']); |
|||
} |
|||
|
|||
curl_close($ch); |
|||
} |
@ -0,0 +1,43 @@ |
|||
<?php |
|||
|
|||
$user_id = "M0000"; |
|||
$user_password = "M012290493119"; |
|||
|
|||
function get_Auth($user_id = "M0000", $user_password = "M012290493119") |
|||
{ |
|||
|
|||
$now = gmdate("YmdHis"); |
|||
$data = "$user_id." . $now; |
|||
$sign = hash_hmac('SHA256', $data, 'B2D6395D2883E26C', false); |
|||
|
|||
|
|||
// $apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth'; |
|||
// $apiurl = 'http://60.244.87.101:880//twWebAPI/GetAuth'; |
|||
$apiurl = 'http://10.10.145.2:880//twWebAPI/GetAuth'; |
|||
// $apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth'; |
|||
|
|||
$headerParam = [ |
|||
"UserId: $user_id", |
|||
"Pwd: $user_password", |
|||
"TimestampUTC: $now", |
|||
"Sign: $sign" |
|||
]; |
|||
|
|||
$ch = curl_init(); |
|||
curl_setopt($ch, CURLOPT_URL, $apiurl); |
|||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headerParam); |
|||
|
|||
$response = curl_exec($ch); |
|||
if ($response === false) { |
|||
echo 'Curl error: ' . curl_error($ch); |
|||
} else { |
|||
// print_r($response); |
|||
// exit; |
|||
$result = json_decode($response, true); |
|||
$validation = $result['Data']['CHI_Authorization']; |
|||
return $validation; |
|||
} |
|||
|
|||
curl_close($ch); |
|||
} |
@ -0,0 +1,51 @@ |
|||
<?php |
|||
include "./header.php"; |
|||
require_once dirname(__DIR__) . '/common/composer/vendor/autoload.php'; |
|||
use PhpOffice\PhpSpreadsheet\Spreadsheet; |
|||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx; |
|||
$Bill = $_POST['Bill']; |
|||
$array_data = array(); |
|||
$Bill = json_decode($Bill, true); |
|||
|
|||
foreach($Bill as $key=>$value){ |
|||
// for ($i = 0; $i < 17; $i++) { |
|||
// $value[$i] = (isset($value[$i])) ? $value[$i] : 0; |
|||
// } |
|||
$array_data[$key][0] = $key; |
|||
$array_data[$key][1] = $value[1]; |
|||
$array_data[$key][2] = $value[2]; |
|||
$array_data[$key][3] = $value[4]; |
|||
$array_data[$key][4] = $value[5]; |
|||
$array_data[$key][5] = $value[7]; |
|||
$array_data[$key][6] = $value[8]; |
|||
$array_data[$key][7] = $value[6]; |
|||
$array_data[$key][8] = $value['sign'][1]; |
|||
$array_data[$key][9] = $value['second'][1]; |
|||
$array_data[$key][10] = $value['arrive'][1]; |
|||
$array_data[$key][11] = $value['install'][1]; |
|||
$array_data[$key][12] = $value['tryrun'][1]; |
|||
$array_data[$key][13] = $value['check'][1]; |
|||
$array_data[$key][14] = $value['delivery'][1]; |
|||
$array_data[$key][15] = $value['final'][1]; |
|||
$array_data[$key][16] = $value['receivable_budget']; |
|||
$array_data[$key][17] = str_replace('<br>','; ',$value['facilities']); |
|||
} |
|||
$spreadsheet = new Spreadsheet(); |
|||
$sheet = $spreadsheet->getActiveSheet(); |
|||
$colomnHeader = ['合約號','部門','經理','營業員','客戶名稱','統一編號','聯絡地址','抬頭','簽約款', |
|||
'二次款','貨抵工地款','安裝款','試車款','官檢款','交車款','尾款','目前應收','作番狀態']; |
|||
$sheet->fromArray($colomnHeader,NULL,'A1'); |
|||
$rowIndex = 2; |
|||
foreach($array_data as $key => $value){ |
|||
$sheet->fromArray([$value], NULL, 'A' . $rowIndex); |
|||
$sheet->getStyle('R' . $rowIndex)->getAlignment()->setWrapText(true); |
|||
$rowIndex++; |
|||
} |
|||
$writer = new Xlsx($spreadsheet); |
|||
$excelFileName = 'account-receivable.xlsx'; |
|||
$writer->save($excelFileName); |
|||
|
|||
?> |
|||
<script> |
|||
window.location.href = "account-receivable-index.php?<?= $token_link ?>"; |
|||
</script> |
Binary file not shown.
@ -1,61 +1,123 @@ |
|||
<?php |
|||
// 接收 referer 參數 |
|||
if (isset($_GET['referer'])) { |
|||
$referer = urldecode($_GET['referer']); |
|||
echo "HTTP_REFERER 是: $referer"; |
|||
echo "<br/>"; |
|||
date_default_timezone_set('Asia/Taipei'); |
|||
$currentTimestamp = time(); |
|||
$hashReferer = ""; |
|||
for ($i = -3; $i <= 3; $i++) { |
|||
$modifiedTimestamp = strtotime("$i seconds", $currentTimestamp); |
|||
$formattedTime = date("Y-m-d H:i:s", $modifiedTimestamp); |
|||
$hashReferer .= md5("https://bpm.masada.com.twMasada@2023".$formattedTime); |
|||
} |
|||
echo $hashReferer; |
|||
if (strpos($hashReferer, $referer)) { |
|||
echo "login"; |
|||
} |
|||
} else { |
|||
echo "沒有 HTTP_REFERER 資訊可用"; |
|||
} |
|||
echo "<br/>"; |
|||
if(isset($_SERVER['HTTP_REFERER'])) { |
|||
$referrer = $_SERVER['HTTP_REFERER']; |
|||
echo "來自於: $referrer"; |
|||
} else { |
|||
echo "沒有 referrer 資訊可用"; |
|||
} |
|||
echo "<br/>"; |
|||
if (isset($_SERVER['REMOTE_ADDR'])) { |
|||
$visitor_ip = $_SERVER['REMOTE_ADDR']; |
|||
echo "訪問者的 IP 地址是: $visitor_ip"; |
|||
} else { |
|||
echo "REMOTE_ADDR : 無法獲取訪問者的 IP 地址"; |
|||
} |
|||
echo "<br/>"; |
|||
if (isset($_SERVER['HTTP_CLIENT_IP'])) { |
|||
$visitor_ip = $_SERVER['HTTP_CLIENT_IP']; |
|||
echo "訪問者的 IP 地址是: $visitor_ip"; |
|||
} else { |
|||
echo "HTTP_CLIENT_IP : 無法獲取訪問者的 IP 地址"; |
|||
} |
|||
echo "<br/>"; |
|||
|
|||
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|||
$visitor_ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
|||
echo "訪問者的 IP 地址是: $visitor_ip"; |
|||
} else { |
|||
echo "HTTP_X_FORWARDED_FOR : 法獲取訪問者的 IP 地址"; |
|||
} |
|||
echo "<br/>"; |
|||
|
|||
|
|||
?> |
|||
<script> |
|||
var referrer = document.referrer; |
|||
console.log("前一個網頁是:" + referrer); |
|||
</script> |
|||
<?php |
|||
exit; |
|||
ini_set('display_errors', 'on'); |
|||
echo $referrer = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : "抓不到"; |
|||
|
|||
exit; |
|||
include "fun_global.php"; |
|||
include "database.php"; |
|||
print_r(manage_class("M0117")); |
|||
echo manage_class("M0117")[0]; |
|||
|
|||
// account table |
|||
$accounttype = "A"; |
|||
$accountid = ""; |
|||
$pwd = "123"; |
|||
$name = ""; |
|||
$creater = ""; |
|||
$create_at = date("Y-m-d H:i:s"); |
|||
|
|||
// 檢查 accountid 是否未重複並寫入 account 資料表 |
|||
$sql = " |
|||
SELECT DISTINCT |
|||
a.accountid, |
|||
w.contractno, |
|||
w.custom |
|||
FROM wipwholestatus AS w |
|||
LEFT JOIN ( |
|||
SELECT |
|||
accountid |
|||
FROM account |
|||
) AS a |
|||
ON a.accountid = w.contractno |
|||
WHERE a.accountid IS NULL |
|||
"; |
|||
$data = mysqli_query($link, $sql); |
|||
|
|||
$J = 0; |
|||
foreach ($data as $key => $row) : |
|||
echo $row['accountid']."<br>"; |
|||
echo $J++; |
|||
if (empty($row['accountid'])) { |
|||
|
|||
$accountid = $row['contractno']; |
|||
$name = $row['custom']; |
|||
echo $sql2 = " |
|||
INSERT INTO account ( |
|||
accounttype, |
|||
accountid, |
|||
pwd, |
|||
name, |
|||
creater, |
|||
create_at |
|||
) VALUES ( |
|||
'$accounttype', |
|||
'$accountid', |
|||
'$pwd', |
|||
'$name', |
|||
'$creater', |
|||
'$create_at' |
|||
) |
|||
"; |
|||
echo "<br/>"; |
|||
mysqli_query($link, $sql2); |
|||
} |
|||
endforeach; |
|||
// // account table |
|||
// $accounttype = "A"; |
|||
// $accountid = ""; |
|||
// $pwd = "123"; |
|||
// $name = ""; |
|||
// $creater = ""; |
|||
// $create_at = date("Y-m-d H:i:s"); |
|||
|
|||
// // 檢查 accountid 是否未重複並寫入 account 資料表 |
|||
// $sql = " |
|||
// SELECT DISTINCT |
|||
// a.accountid, |
|||
// w.contractno, |
|||
// w.custom |
|||
// FROM wipwholestatus AS w |
|||
// LEFT JOIN ( |
|||
// SELECT |
|||
// accountid |
|||
// FROM account |
|||
// ) AS a |
|||
// ON a.accountid = w.contractno |
|||
// WHERE a.accountid IS NULL |
|||
// "; |
|||
// $data = mysqli_query($link, $sql); |
|||
|
|||
// $J = 0; |
|||
// foreach ($data as $key => $row) : |
|||
// echo $row['accountid']."<br>"; |
|||
// echo $J++; |
|||
// if (empty($row['accountid'])) { |
|||
|
|||
// $accountid = $row['contractno']; |
|||
// $name = $row['custom']; |
|||
// echo $sql2 = " |
|||
// INSERT INTO account ( |
|||
// accounttype, |
|||
// accountid, |
|||
// pwd, |
|||
// name, |
|||
// creater, |
|||
// create_at |
|||
// ) VALUES ( |
|||
// '$accounttype', |
|||
// '$accountid', |
|||
// '$pwd', |
|||
// '$name', |
|||
// '$creater', |
|||
// '$create_at' |
|||
// ) |
|||
// "; |
|||
// echo "<br/>"; |
|||
// mysqli_query($link, $sql2); |
|||
// } |
|||
// endforeach; |
|||
|
Loading…
Reference in new issue