Browse Source

應收帳款增加生管權限、新增T8 Authorization跟應付function

main
Ellin 1 year ago
parent
commit
c623d6e299
  1. 50
      wms/T8_Authorization_curl.php
  2. 26
      wms/account-receivable-new-index.php
  3. 16
      wms/account-receivable-renovate-index.php
  4. 49
      wms/purchase-api.php
  5. 36
      wms/purchase-apply-index.php

50
wms/T8_Authorization_curl.php

@ -0,0 +1,50 @@
<?php
function get_Auth($groupId='TEST',$accountId='M0122',$password='90493119')
{
$user_id = $accountId;
$user_password = $password;
$api_key = "A21181F1EE4966D3";
$GroupId = $groupId;
// 伺服器時間扣兩分鐘會比較穩定
// $now = gmdate("YmdHis");
$now = gmdate("YmdHis", strtotime("-2 minutes"));
$data = "$user_id." . $now;
$sign = hash_hmac('SHA256', $data, $api_key, false);
// 各種API連線網址
// $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",
"GroupId: $GroupId"
];
$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 {
$result = json_decode($response, true);
if ($result['Status'] == 'Success')
return $result['Data']['CHI_Authorization'];
if ($result['Status'] == 'Error')
return $result['ErrorMsg'];
print_r($result);
}
curl_close($ch);
}

26
wms/account-receivable-new-index.php

@ -111,7 +111,7 @@ if (!is_null($end_date)) {
$end_date = (int)date('Ymd', strtotime($end_date));
$sql_all_contract .= " AND MainAll.BillDate <= $end_date ";
}
if ((in_array($user_id, array('M0060', 'M0175'))) || (in_array(accountidToDepartId($user_id), array('220', '210', '321')))) {
if ((in_array($user_id, array('M0060', 'M0175','M0168'))) || (in_array(accountidToDepartId($user_id), array('220', '210', '321')))) {
} else {
$sql_all_contract .= " AND (MainAll.PersonId = '$user_id'";
if (count($follower) > 0) {
@ -842,11 +842,17 @@ foreach ($final_paystage as $key => $value) {
}
}
$average_A40001 = $sum_A40001 / $sum_facility;
if($sum_facility>0){
$average_A40001 = $sum_A40001 / $sum_facility;
$average_A40008 = $sum_A40008 / $sum_facility;
$average_facility_budget = $sum_total_budget / $sum_facility;
$average_contract_budget = $sum_total_budget / $sum_contract;
$average_contract_facility = $sum_facility / $sum_contract;
}
if($sum_contract>0){
$average_contract_budget = $sum_total_budget / $sum_contract;
$average_contract_facility = $sum_facility / $sum_contract;
}
// excel 結果
@ -977,7 +983,7 @@ foreach ($arrayData as $key => &$value) {
$excel_contract_array[$key][34] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month']) && abs($excel_contract_array[$key][33]) > 10) ? round($payvalue['collect_month']) : 0;
if (isset($excel_contract_all_array[$key])) {
$excel_contract_all_array[$key][10] = $excel_contract_array[$key][33];
$excel_contract_all_array[$key][11] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? round($payvalue['collect_month']) : 0;
$excel_contract_all_array[$key][11] = $excel_contract_array[$key][34];
$total_second_collect_budget += $excel_contract_all_array[$key][10];
if ($isBoga == 1) {
$excel_contract_boga_array[$key][10] = $excel_contract_all_array[$key][10];
@ -1002,7 +1008,7 @@ foreach ($arrayData as $key => &$value) {
$excel_contract_array[$key][41] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month']) && abs($excel_contract_array[$key][40]) > 10) ? round($payvalue['collect_month']) : 0;
if (isset($excel_contract_all_array[$key])) {
$excel_contract_all_array[$key][12] = $excel_contract_array[$key][40];
$excel_contract_all_array[$key][13] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? round($payvalue['collect_month']) : 0;
$excel_contract_all_array[$key][13] = $excel_contract_array[$key][41];
$total_arrival_collect_budget += $excel_contract_all_array[$key][12];
if ($isBoga == 1) {
$excel_contract_boga_array[$key][12] = $excel_contract_all_array[$key][12];
@ -1043,7 +1049,7 @@ foreach ($arrayData as $key => &$value) {
$excel_contract_array[$key][55] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month']) && abs($excel_contract_array[$key][54]) > 10) ? round($payvalue['collect_month']) : 0;
if (isset($excel_contract_all_array[$key])) {
$excel_contract_all_array[$key][16] = $excel_contract_array[$key][54];
$excel_contract_all_array[$key][17] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? round($payvalue['collect_month']) : 0;
$excel_contract_all_array[$key][17] = $excel_contract_array[$key][55];
$total_tryrun_collect_budget += $excel_contract_all_array[$key][16];
if ($isBoga == 1) {
$excel_contract_boga_array[$key][16] = $excel_contract_all_array[$key][16];
@ -1066,7 +1072,7 @@ foreach ($arrayData as $key => &$value) {
$excel_contract_array[$key][62] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month']) && abs($excel_contract_array[$key][61]) > 10) ? round($payvalue['collect_month']) : 0;
if (isset($excel_contract_all_array[$key])) {
$excel_contract_all_array[$key][18] = $excel_contract_array[$key][61];
$excel_contract_all_array[$key][19] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? round($payvalue['collect_month']) : 0;
$excel_contract_all_array[$key][19] = $excel_contract_array[$key][62];
$total_check_collect_budget += $excel_contract_all_array[$key][18];
$excel_contract_noboga_array[$key][18] = $excel_contract_all_array[$key][18];
@ -1084,7 +1090,7 @@ foreach ($arrayData as $key => &$value) {
$excel_contract_array[$key][69] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month']) && abs($excel_contract_array[$key][68]) > 10) ? round($payvalue['collect_month']) : 0;
if (isset($excel_contract_all_array[$key])) {
$excel_contract_all_array[$key][20] = $excel_contract_array[$key][68];
$excel_contract_all_array[$key][21] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? round($payvalue['collect_month']) : 0;
$excel_contract_all_array[$key][21] = $excel_contract_array[$key][69];
$total_delivery_collect_budget += $excel_contract_all_array[$key][20];
$excel_contract_noboga_array[$key][20] = $excel_contract_all_array[$key][20];
$excel_contract_noboga_array[$key][21] = $excel_contract_all_array[$key][21];
@ -1101,7 +1107,7 @@ foreach ($arrayData as $key => &$value) {
$excel_contract_array[$key][76] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month']) && abs($excel_contract_array[$key][75]) > 10) ? round($payvalue['collect_month']) : 0;
if (isset($excel_contract_all_array[$key])) {
$excel_contract_all_array[$key][22] = $excel_contract_array[$key][75];
$excel_contract_all_array[$key][23] = (isset($payvalue['collect_month']) && !is_null($payvalue['collect_month'])) ? round($payvalue['collect_month']) : 0;
$excel_contract_all_array[$key][23] = $excel_contract_array[$key][76];
$total_final_collect_budget += $excel_contract_all_array[$key][22];
if ($isBoga == 1) {
$excel_contract_boga_array[$key][22] = $excel_contract_all_array[$key][22];

16
wms/account-receivable-renovate-index.php

@ -72,7 +72,7 @@ if (!is_null($end_date)) {
$end_date = (int)date('Ymd', strtotime($end_date));
$sql_contractNumber .= " AND MainAll.BillDate <= $end_date ";
}
if ((in_array($user_id, array('M0060', 'M0175'))) || (in_array(accountidToDepartId($user_id), array('220', '210', '321')))) {
if ((in_array($user_id, array('M0060', 'M0175','M0168'))) || (in_array(accountidToDepartId($user_id), array('220', '210', '321')))) {
} else {
$sql_contractNumber .= " AND (Leader.PersonId = '$user_id' OR MainAll.PersonId = '$user_id'";
if (count($follower) > 0) {
@ -202,9 +202,9 @@ LEFT JOIN (SELECT O.*, DE.DeptName, DE.LeaderId FROM salSalesOrder AS O LEFT JOI
LEFT JOIN comBusinessPartner AS c ON s.BizPartnerId=c.BizPartnerId
LEFT JOIN comGroupPerson AS Person ON s.PersonId = Person.PersonId
LEFT JOIN comGroupPerson AS Leader ON s.LeaderId = Leader.PersonId ";
// if (isset($str_numbers)) {
// $sql_contract .= "WHERE s.BillNo IN $str_numbers ";
// }
if (isset($str_numbers)) {
$sql_contract .= "WHERE a.BillNo IN $str_numbers ";
}
// T8 銷售訂單 作番金額
@ -849,10 +849,10 @@ foreach ($arrayData as $key => $value) {
// }
$total_data = json_encode($print_array);
$average_budget = $sum_total_budget / $sum_facility;
$average_A40002 = $sum_A40002 / $sum_facility_A40002;
$average_A40009 = $sum_A40009 / $sum_facility_A40009;
$average_A40010 = $sum_A40010 / $sum_facility_A40010;
$average_A40019 = $sum_A40019 / $sum_facility_A40019;
$average_A40002 = ($sum_facility_A40002>0)? ($sum_A40002 / $sum_facility_A40002):0;
$average_A40009 = ($sum_facility_A40009>0)? ($sum_A40009 / $sum_facility_A40009):0;
$average_A40010 = ($sum_facility_A40010>0)? ($sum_A40010 / $sum_facility_A40010):0;
$average_A40019 = ($sum_facility_A40019>0)? ($sum_A40019 / $sum_facility_A40019):0;
?>
<style>

49
wms/purchase-api.php

@ -0,0 +1,49 @@
<?php
include "./header.php";
include "T8_Authorization_curl.php";
$account_id = "M0122";
$password = "90493119";
$GroupId = 'TEST';
$validation = get_Auth($GroupId,$account_id,$password);
// print_r(get_purchaseApply($conn, '123'));
$sql_purchaseApply = "SELECT * FROM purCharge";
$result = get_purchaseApply($conn, $sql_purchaseApply);
print_r($result);
function get_purchaseApply($conn){
$sql_purchaseApply = "SELECT * FROM purCharge";
$query_purchaseApply = $conn -> prepare($sql_purchaseApply);
$query_purchaseApply -> execute();
$result = $query_purchaseApply -> fetchAll();
return $result;
}
// print_r(get_purchase_apply($validation,$GroupId,"S230300001-14"));
//費用申請單API 不能用
function get_purchase_apply($validation,$GroupId,$BillNo){
$apiurl = "http://60.244.87.101:880//twWebAPI/V1/PURFEEAPPLY/GetERPData?pkValue=$BillNo";
// echo $apiurl . "\n";
$headerParam = [
'CHI_Authorization: ' . $validation,
'GroupId:'.$GroupId
];
$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, "GET");
$response = curl_exec($ch);
if ($response === false) {
echo 'Curl error: ' . curl_error($ch);
} else {
$result = json_decode($response, true);
print_r($result);
}
curl_close($ch);
}

36
wms/purchase-apply-index.php

@ -0,0 +1,36 @@
<?php
include "./header.php";
include "T8_Authorization_curl.php";
$account_id = "M0122";
$password = "90493119";
$GroupId = 'TEST';
$validation = get_Auth();
// print_r(get_purchase_apply($validation,$GroupId,"S230300001-14"));
//費用申請單API 不能用
function get_purchase_apply($validation,$GroupId,$BillNo){
$apiurl = "http://60.244.87.101:880//twWebAPI/V1/PURFEEAPPLY/GetERPData?pkValue=$BillNo";
// echo $apiurl . "\n";
$headerParam = [
'CHI_Authorization: ' . $validation,
'GroupId:'.$GroupId
];
$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, "GET");
$response = curl_exec($ch);
if ($response === false) {
echo 'Curl error: ' . curl_error($ch);
} else {
$result = json_decode($response, true);
print_r($result);
}
curl_close($ch);
}
Loading…
Cancel
Save