Browse Source

合約簽回寫入t8

main
Cheng 1 year ago
parent
commit
92e9f241b7
  1. 6
      wms/cont/sign_list.php
  2. 55
      wms/contract-repair/contract-download.php
  3. 35
      wms/contract-repair/js/alpine.js
  4. 124
      wms/contract/api/postContractData.php
  5. 38
      wms/contract/api/testT8API.php
  6. 29
      wms/contract/conn.php
  7. 15
      wms/contract/connt8.php
  8. 2
      wms/header.php

6
wms/cont/sign_list.php

@ -75,8 +75,10 @@ form_key,
status, status,
f_return_content('payment_kind',payment_kind ) payment_kind FROM $table f_return_content('payment_kind',payment_kind ) payment_kind FROM $table
where 1=1 $where ORDER BY vol_no"; where 1=1 $where ORDER BY vol_no";
// echo $sql;
$data = mysqli_query($link, $sql); $data = mysqli_query($link, $sql);
echo '<pre>';
print_r($sql);
echo '</pre>';
?> ?>
@ -225,7 +227,7 @@ if ($data) :
$oneself = ($row['salesman'] == $user_id) ? 1 : 0; $oneself = ($row['salesman'] == $user_id) ? 1 : 0;
?> ?>
<tr> <tr>
<td><?php echo $row['apply_key'] ?></td> <td><a href="query_form.php?apply_key=<?= $row['apply_key'] ?>&token=<?= $_GET['token'] ?>"><?= $row['apply_key'] ?></a></td>
<td><?php echo $row['vol_no'] ?></td> <td><?php echo $row['vol_no'] ?></td>
<td><?php echo $row['address'] ?></td> <td><?php echo $row['address'] ?></td>
<td><?php echo $row['case_name'] ?></td> <td><?php echo $row['case_name'] ?></td>

55
wms/contract-repair/contract-download.php

@ -70,32 +70,27 @@ if (!empty($_GET['apply_key'])) {
$noteArr = array(1, 1, 1, 1, 1); $noteArr = array(1, 1, 1, 1, 1);
$qty = $contract_maintance[0]['num']; $qty = $contract_maintance[0]['num'];
// echo $qty; // echo $qty;
// foreach ($contract_maintance as $idx => $amount) { foreach ($contract_maintance as $idx => $amount) {
// $isset = false; $isset = false;
// if ($amount['payment_kind'] == 5 || $amount['payment_kind'] == 6) {
// if ($amount['pay_scale'] >= 0) { if ($amount['pay_kind'] == 1 || $amount['pay_kind'] == 2 || $amount['pay_kind'] == 3) {
// $install_total_price = $install_total_price + $amount['pay_amount']; if ($amount['pay_scale'] > 0) {
// $installArr[] = ['installment' => $amount['pay_kind'], 'scale' => $amount['pay_scale'], 'amount' => $amount['pay_amount'], 'pay_period' => $amount['pay_period']]; $buy_total_price = $buy_total_price + $amount['pay_amount'];
// } foreach ($buyArr as $buy) {
// } if ($buy['installment'] == $amount['pay_kind']) {
// if ($amount['pay_kind'] == 1 || $amount['pay_kind'] == 2 || $amount['pay_kind'] == 3) { $isset = true;
// if ($amount['pay_scale'] > 0) { }
// $buy_total_price = $buy_total_price + $amount['pay_amount']; }
// foreach ($buyArr as $buy) { // if (!$isset) { {
// if ($buy['installment'] == $amount['pay_kind']) { // $buyArr[] = ['installment' => $amount['pay_kind'], 'scale' => $amount['pay_scale'], 'amount' => $amount['pay_amount'], 'pay_period' => $amount['pay_period']];
// $isset = true; // }
// } // if ($amount['pay_kind'] == 2) {
// } // $buyNo2Pay = true;
// if (!$isset) { { // }
// $buyArr[] = ['installment' => $amount['pay_kind'], 'scale' => $amount['pay_scale'], 'amount' => $amount['pay_amount'], 'pay_period' => $amount['pay_period']]; // }
// } }
// if ($amount['pay_kind'] == 2) { }
// $buyNo2Pay = true; }
// }
// }
// }
// }
// }
$sql_str = "SELECT file_name FROM contract_apply_files WHERE contract_id = :contract_id AND deleted_at IS NULL"; $sql_str = "SELECT file_name FROM contract_apply_files WHERE contract_id = :contract_id AND deleted_at IS NULL";
$sql_str = "SELECT contract_apply_files.*, contract_new_apply.id as apply_id FROM contract_apply_files LEFT JOIN contract_new_apply ON contract_apply_files.contract_id = contract_new_apply.id WHERE contract_new_apply.mid = :mid AND contract_apply_files.deleted_at IS NULL"; $sql_str = "SELECT contract_apply_files.*, contract_new_apply.id as apply_id FROM contract_apply_files LEFT JOIN contract_new_apply ON contract_apply_files.contract_id = contract_new_apply.id WHERE contract_new_apply.mid = :mid AND contract_apply_files.deleted_at IS NULL";
$stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
@ -119,7 +114,7 @@ if (!empty($_GET['apply_key'])) {
<ul> <ul>
<button :class="isbuyShow ? 'active' : ''" @click="isbuyShow = true">電梯買賣合約書</button> <button :class="isbuyShow ? 'active' : ''" @click="isbuyShow = true">電梯買賣合約書</button>
<button :class="!isbuyShow ?'active' : ''" @click="isbuyShow = false">電梯安裝合約書</button> <button :class="!isbuyShow ?'active' : ''" @click="isbuyShow = false">電梯安裝合約書</button>
<a href="..wms/cont/sign_list.php?function_name=pricereview&<?php echo $token_link; ?>">回列表</a> <a href="../cont/sign_list.php?function_name=sign_list&<?php echo $token_link; ?>">回列表</a>
</ul> </ul>
</div> </div>
<div class="inputDiv" x-show="isbuyShow && isBuyInputIng"> <div class="inputDiv" x-show="isbuyShow && isBuyInputIng">
@ -453,11 +448,11 @@ if (!empty($_GET['apply_key'])) {
const totalInstallPrice = <?php echo $install_total_price; ?>; const totalInstallPrice = <?php echo $install_total_price; ?>;
const totalBuyPrice = <?php echo $buy_total_price; ?>; const totalBuyPrice = <?php echo $buy_total_price; ?>;
// const secondPayDeadline = <?php echo $contract['secondPayDeadline']; ?>; // const secondPayDeadline = <?php echo $contract['secondPayDeadline']; ?>;
// const buyfill1 = <?php echo $contract['tradedeadline']; ?>; const buyfill1 = <?php echo $contract['pre_oreder_date']; ?>;
// const installfill1 = "<?php echo $contract_maintance['test_time']; ?>"; // const installfill1 = "<?php echo $contract_maintance['test_time']; ?>";
// const installfill2 = "<?php echo $contract_maintance['freedeadline']; ?>"; // const installfill2 = "<?php echo $contract_maintance['freedeadline']; ?>";
// const buyArr = [...<?php echo json_encode($buyArr); ?>]; const buyArr = [...<?php echo json_encode($buyArr); ?>];
// const installArr = [...<?php echo json_encode($installArr); ?>]; const installArr = [...<?php echo json_encode($installArr); ?>];
let install_pay_text = '付款方式:<br> '; let install_pay_text = '付款方式:<br> ';
let buy_pay_text = '' let buy_pay_text = ''
const chineseArr = ['零', '一', '二', '三', '四', '五', '六', '七'] const chineseArr = ['零', '一', '二', '三', '四', '五', '六', '七']

35
wms/contract-repair/js/alpine.js

@ -6,6 +6,8 @@ const contractDownload = () => {
this.buystandarData = this.deepClone(this.buydata); this.buystandarData = this.deepClone(this.buydata);
this.buyonstandardViewData = this.deepClone(this.buydata); this.buyonstandardViewData = this.deepClone(this.buydata);
}, },
buyfill1: buyfill1,
css: `table { background - color: #fff; border: none; margin - top: 30px; font - family: '標楷體'; width: 600px; } table tr: nth - child(even), table tr: nth - child(odd) { background - color: #fff; } table tr { font - size: 12pt; width: 100 %; } table tr h2 { font - size: 18pt; } table tr td { width: 100 %; height: 100 %; line - height: 2; display: flex; } table tr td.center { display: flex; justify - content: center; align - items: center; } table tr td.list { width: 100 %; height: 100 %; white - space: nowrap; display: flex; } table tr td.list span { width: 60px; min - height: 100 %; display: block; } table tr td.list > p { display: block; text - align: justify; } table tr td.list div { max - width: calc(100 % - 60px); white - space: normal; } table tr td.list div.text - justify { display: flex; width: 100 %; justify - content: space - between; } table tr.date td > div { width: 100 %; text - align: right; } table tr.date td > div.text - justify { display: flex; justify - content: space - between; } table td, table th { padding: 8px; }`, css: `table { background - color: #fff; border: none; margin - top: 30px; font - family: '標楷體'; width: 600px; } table tr: nth - child(even), table tr: nth - child(odd) { background - color: #fff; } table tr { font - size: 12pt; width: 100 %; } table tr h2 { font - size: 18pt; } table tr td { width: 100 %; height: 100 %; line - height: 2; display: flex; } table tr td.center { display: flex; justify - content: center; align - items: center; } table tr td.list { width: 100 %; height: 100 %; white - space: nowrap; display: flex; } table tr td.list span { width: 60px; min - height: 100 %; display: block; } table tr td.list > p { display: block; text - align: justify; } table tr td.list div { max - width: calc(100 % - 60px); white - space: normal; } table tr td.list div.text - justify { display: flex; width: 100 %; justify - content: space - between; } table tr.date td > div { width: 100 %; text - align: right; } table tr.date td > div.text - justify { display: flex; justify - content: space - between; } table td, table th { padding: 8px; }`,
data: { data: {
illustrate: { illustrate: {
@ -45,6 +47,22 @@ const contractDownload = () => {
] ]
} }
}, },
deepClone: function (obj) {
let clone = Array.isArray(obj) ? [] : {};
for (let key in obj) {
if (obj.hasOwnProperty(key)) {
if (typeof obj[key] === 'object' && obj[key] !== null) {
clone[key] = this.deepClone(obj[key]);
if (clone[key].text != undefined) {
} else {
clone[key] = obj[key];
}
}
}
}
return clone;
},
buydata: { buydata: {
}, },
@ -129,7 +147,22 @@ const contractDownload = () => {
return; return;
} }
} },
isBuyShow: true,
sendBuyInputFn() {
if (this.buyfilt1 == '') {
alert('請輸入交貨期限');
return;
}
if (this.buyfilt1 < 1) {
alert('交貨日期不得低於1日');
return;
}
if (buyArr[1].installment == 2) {
}
},
isBuyInputIng: true,
} }
}; };

124
wms/contract/api/postContractData.php

@ -1,8 +1,10 @@
<?php <?php
require_once("../conn.php"); require_once("../conn.php");
// require_once("../connt8.php");
include_once("./getFacilityNo.php"); include_once("./getFacilityNo.php");
include_once("./getComboNo.php"); include_once("./getComboNo.php");
include_once("./upload_chk.php"); include_once("./upload_chk.php");
ini_set('date.timezone', 'Asia/Taipei'); ini_set('date.timezone', 'Asia/Taipei');
//保養簽回 //保養簽回
if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['contracttype']) && $_POST['contracttype'] == 'b') { if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['contracttype']) && $_POST['contracttype'] == 'b') {
@ -137,7 +139,8 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
$facility_arr[] = $dailyNecessities[$elevator['spec']]; $facility_arr[] = $dailyNecessities[$elevator['spec']];
} }
echo json_encode($facility_arr); echo json_encode($facility_arr);
$facilityno = $createFacilityNo->makeBFacilityNo("T", $facility_arr, (int)$num); // 電梯做番號
$facilityno = $createFacilityNo->makeBFacilityNo("B", $facility_arr, (int)$num);
echo json_encode($facilityno); echo json_encode($facilityno);
echo '-------'; echo '-------';
$sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid"; $sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid";
@ -307,6 +310,9 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
header('Content-Type: application/json'); header('Content-Type: application/json');
$jsonData = json_encode($files); $jsonData = json_encode($files);
T8insert($_POST, $facilityno);
$conn->commit(); $conn->commit();
} catch (PDOException $e) { } catch (PDOException $e) {
$conn->rollback(); $conn->rollback();
@ -314,4 +320,120 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
echo $e->getMessage(); echo $e->getMessage();
die('Error!:' . $e->getMessage()); die('Error!:' . $e->getMessage());
} }
};
function T8insert($data, $facilityno)
{
require_once("../connt8.php");
$contractno = !empty($data['contractno']) ? $data['contractno'] : null; // 合約號
$address = !empty($data['address']) ? $data['address'] : null; // 客戶地址
$customer = !empty($data['customer']) ? $data['customer'] : null; //企業名稱
$phone = !empty($data['phone']) ? $data['phone'] : null; //客戶電話
$vat = !empty($data['vat']) ? $data['vat'] : null; //統編
$email = !empty($data['email']) ? $data['email'] : null;
$salesman = !empty($data['salesman']) ? $data['salesman'] : null; // 銷售人員
$partyA = !empty($data['partyA']) ? $data['partyA'] : null; //客戶名稱 / 業務聯絡人
$partyAaddress = !empty($data['partyAaddress']) ? $data['partyAaddress'] : null; // 業務聯絡人地址
$contract_begin_date = !empty($data['contract_begin_date']) ? $data['contract_begin_date'] : null;
$contract_end_date = !empty($data['contract_end_date']) ? $data['contract_end_date'] : null;
$num = !empty($data['num']) ? $data['num'] : null; // 電梯數量
$elevators = !empty($data['elevators']) ? json_decode($data['elevators'], true) : []; //電梯
if ($elevators['maintainance'] == 'A') {
$elevators['maintainance'] = 'C3';
} else if ($elevators['maintainance'] == 'B') {
$elevators['maintainance'] = 'C4';
} else if ($elevators['maintainance'] == 'C') {
$elevators['maintainance'] = 'C5';
}
$sql = "SELECT * FROM comCustomer WHERE BizPartnerId = :BizPartnerId";
$stmt = $conn->prepare($sql);
$stmt->bindParama(':BizPartnerId', $contractno);
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
$date = date('Y-m-sH-s-i');
$createTime = str_replace("-", '', $date);
$beginDate = str_replace("-", '', $contract_begin_date);
$endDate = str_replace("-", '', $contract_end_date);
if (empty($result)) {
// 若 客戶資料為空,新增一筆到 comCustomer
// 新增客戶資料
$sql = "INSERT INTO comCustomer(BizPartnerId,PersonId,CreatorId,IsInUsed,InvoiceAddress,CreateTime)VALUES(:BizPartnerId,:PersonId,:CreatorId,1,:InvoiceAddress,:CreateTime)";
$stmt = $connT8->prepare($sql);
$stmt->bindParam(':BizPartnerId', $contractno);
$stmt->bindParam(':PersonId', $salesman);
$stmt->bindParam(':CreatorId', $user_id);
$stmt->bindParam(':InvoiceAddress', $address);
$stmt->bindParam(':CreateTime', $createTime);
$stmt->execute();
$sql = "INSERT INTO comBusinessPartner(BizPartnerId,BizPartnerName,WorkTelNo,TaxNo,EnterpriseName,ContractAddress,EMail,CreatorId,CreateTime)VALUES(:BizPartnerId,:BizPartnerName,:WorkTelNo,:TaxNo,:EnterpriseName,:ContractAddress,:EMail,:CreatorId,:CreateTime)";
$stmt = $connT8->prepare($sql);
$stmt->bindParam(':BizPartnerId', $contractno);
$stmt->bindParam(':BizPartnerName', $partyA);
$stmt->bindParam(':WorkTelNo', $phone);
$stmt->bindParam(':TaxNo', $vat);
$stmt->bindParam(':EnterpriseName', $customer); //企業名稱
$stmt->bindParam(':ContractAddress', $partyAaddress);
$stmt->bindParam(':EMail', $email);
$stmt->bindParam(':CreatorId', $user_id);
$stmt->bindParam(':CreateTime', $createTime);
$stmt->execute();
} else {
// 若客戶資料不為空,更新該客戶資訊。
$sql = "UPDATE comCustomer SET
PersonId=:PersonId,
InvoiceAddress=:InvoiceAddress,
LastOperatorId=:LastOperatorId,
LastOperateTime=:LastOperateTime,
WHERE BizPartnerId=:BizPartnerId
";
$stmt = $connT8->prepare($sql);
$stmt->bindParam(':PersonId', $salesman);
$stmt->bindParam(':InvoiceAddress', $address);
$stmt->bindParam(':LastOperatorId', $user_id);
$stmt->bindParam(':LastOperateTime', $createTime);
$stmt->bindParam(':BizPartnerId', $contractno);
$stmt->execute();
$sql = "UPDATE comBusinessPartner SET
BizPartnerName=:BizPartnerName,
WorkTelNo=:WorkTelNo,
TaxNo=:TaxNo,
EnterpriseName=:EnterpriseName,
ContractAddress=:ContractAddress,
EMail=:EMail,
LastOperatorId=:LastOperatorId,
LastOperateTime=:LastOperateTime
";
$stmt = $connT8->prepare($sql);
$stmt->bindParam(':BizPartnerName', $partyA);
$stmt->bindParam(':WorkTelNo', $phone);
$stmt->bindParam(':TaxNo', $vat);
$stmt->bindParam(':EnterpriseName', $customer);
$stmt->bindParam(':ContractAddress', $partyAaddress);
$stmt->bindParam(':EMail', $email);
$stmt->bindParam(':LastOperatorId', $user_id);
$stmt->bindParam(':LastOperateTime', $createTime);
$stmt->execute();
}
//新增於 comProject
$sql = "INSERT INTO comProject(ProjectId,ProjectName,TypeId,ValidityFromDate,ValidityToDate,CreateTime,CreatorId,IsInUsed) VALUES(:ProjectId,:ProjectName,:TypeId,:ValidityFromDate,ValidityToDate,:CreateTime,:CreatorId,1)";
$stmt = $connT8->prepare($sql);
$stmt->bindParam(':ProjectId', $contractno);
$stmt->bindParam(':ProjectName', $customer);
$stmt->bindParam(':TypeId', $elevators['maintainance']);
$stmt->bindParam(':ValidityFromDate', $beginDate);
$stmt->bindParam(':ValidityToDate', $endDate);
$stmt->bindParam(':CreateTime', $createTime);
$stmt->bindParam(':CreatorId', $user_id);
$stmt->execute();
} }

38
wms/contract/api/testT8API.php

@ -0,0 +1,38 @@
<?php
require_once("../connt8.php");
try {
$contractno = 'M0225202300';
$user_id = 'M0225';
// $sql = "INSERT INTO comBusinessPartner (BizPartnerId,TaxNo,CreatorId) VALUES('M0225202301','0923373895','$userid')";
// $stmt = $connT8->prepare($sql);
// $stmt->execute();
$sql = "UPDATE comBusinessPartner SET WorkTelNo = '' WHERE BizPartnerId='M0225202301'";
$stmt = $connT8->prepare($sql);
$stmt->execute();
echo 'Success';
} catch (PDOException $e) {
echo '<script>alert("更新失敗")</script>';
}
// $sql = "SELECT * FROM comCustomer WHERE BizPartnerId = :BizPartnerId";
// $stmt = $conn->prepare($sql);
// $stmt->bindParam(':BizPartnerId', $contractno);
// $stmt->execute();
// $result = $stmt->fetch(PDO::FETCH_NUM);
// $arr = array();
// if (!empty($result)) {
// foreach ($result as $key => $value) {
// $arr[$key] = $value;
// }
// }
// $count = empty($result) == '' ? 0 : COUNT($result);
// echo '<pre>';
// print_r($result);
// echo '</pre>';
// echo '<br/>';
// $createTime = Date('Y-m-sH-i-s');
// echo str_replace('-', '', $createTime);

29
wms/contract/conn.php

@ -22,22 +22,21 @@ $db_charset = 'utf8'; //設定字元編碼
//建立PDO的指定工作 //建立PDO的指定工作
$dsn = "mysql:host=$db_hostname;dbname=$db_name;charset=$db_charset"; $dsn = "mysql:host=$db_hostname;dbname=$db_name;charset=$db_charset";
try{ try {
//使用PDO連接到MySQL資料庫,建立PDO物件 //使用PDO連接到MySQL資料庫,建立PDO物件
$conn = new PDO($dsn, $db_username, $db_password); $conn = new PDO($dsn, $db_username, $db_password);
//當錯誤發生時會將錯誤資訊放到一個類物件裡(PDOException) //當錯誤發生時會將錯誤資訊放到一個類物件裡(PDOException)
//PDO異常處理,PDO::ATTR_ERRMODE,有以下三種值的設定 //PDO異常處理,PDO::ATTR_ERRMODE,有以下三種值的設定
//PDO::ERRMODE_SILENT: 預設模式,不主動報錯,需要以$conn->errorInfo()的形式獲取錯誤資訊 //PDO::ERRMODE_SILENT: 預設模式,不主動報錯,需要以$conn->errorInfo()的形式獲取錯誤資訊
//PDO::ERRMODE_WARNING: 引發 E_WARNING 錯誤,主動報錯 //PDO::ERRMODE_WARNING: 引發 E_WARNING 錯誤,主動報錯
//PDO::ERRMODE_EXCEPTION: 主動抛出 exceptions 異常,需要以try{}cath(){}輸出錯誤資訊。 //PDO::ERRMODE_EXCEPTION: 主動抛出 exceptions 異常,需要以try{}cath(){}輸出錯誤資訊。
//設定主動以警告的形式報錯 //設定主動以警告的形式報錯
$conn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
//如果連接錯誤,將抛出一個PDOException異常對象 //如果連接錯誤,將抛出一個PDOException異常對象
} } catch (PDOException $e) {
catch ( PDOException $e ){ //如果連結資料庫失敗則顯示錯誤訊並停止本頁的工作
//如果連結資料庫失敗則顯示錯誤訊並停止本頁的工作 die("ERROR!!!: " . $e->getMessage());
die("ERROR!!!: ". $e->getMessage());
} }
//$conn = null; //關閉資料庫的連線 //$conn = null; //關閉資料庫的連線

15
wms/contract/connt8.php

@ -0,0 +1,15 @@
<?php
require_once dirname(__FILE__) . "/../../mkt/database.php";
include "/Users/LO_2342/Desktop/httpdocs/wms/fun_global.php";
// phpinfo();
// exit();
try {
$connT8 = new PDO("sqlsrv:Server=220.130.203.251;Database=T8TEST", "M0225", "IFFBU1E=");
if ($connT8) {
$connT8->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
} catch (PDOException $e) {
// echo "fail";
// echo $e->getMessage();
die("ERROR!!!: " . $e->getMessage());
}

2
wms/header.php

@ -34,7 +34,7 @@ if (isset($_REQUEST["function_name"])) {
* 連線T8 MSSQL * 連線T8 MSSQL
*/ */
try { try {
$conn = new PDO("sqlsrv:Server=220.130.203.251;Database=T8MASADA", "masada", "ztPmPP!HRoV6SL3E"); $conn = new PDO("sqlsrv:Server=220.130.203.251;Database=T8MASADA", "M0225", "IFFBU1E=");
if ($conn) { if ($conn) {
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} }

Loading…
Cancel
Save