7 changed files with 592 additions and 163 deletions
@ -1,139 +1,254 @@ |
|||
<?php |
|||
require_once("../conn.php"); |
|||
include_once("./getFacilityNo.php"); |
|||
include_once("./getComboNo.php"); |
|||
include_once("./upload_chk.php"); |
|||
ini_set ( 'date.timezone' , 'Asia/Taipei' ); |
|||
|
|||
if($_SERVER['REQUEST_METHOD'] != 'POST'){ |
|||
exit(); |
|||
} |
|||
//新梯簽回 |
|||
if(isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['contracttype']) && $_POST['contracttype'] == 'm') { |
|||
try{ |
|||
$created_at = date('Y-m-d H:i:s'); |
|||
$created_by = $_POST["user_id"]; |
|||
$contractno = $_POST["contractno"]; |
|||
$customer = $_POST["customer"]; |
|||
$manager = $_POST["manager"]; |
|||
$vat = $_POST["vat"]; |
|||
$case_name = $_POST["case_name"]; |
|||
$linkman = $_POST["linkman"]; |
|||
$lm_tel = $_POST["lm_tel"]; |
|||
$address = $_POST["address"]; |
|||
$salesman = $_POST["salesman"]; |
|||
$qc = $_POST["qc"]; |
|||
$contracttype = $_POST["contracttype"]; |
|||
$files = !empty($_FILES['files']) ? $_FILES['files'] : null; |
|||
$files_id = null; |
|||
|
|||
$fail_arr = []; |
|||
if(empty($contractno)) $fail_arr[] = '合約號為必填'; |
|||
if(empty($customer)) $fail_arr[] = '客戶名稱為必填'; |
|||
if(empty($manager)) $fail_arr[] = '負責人為必填'; |
|||
if(empty($vat)) $fail_arr[] = '統編/身分證為必填'; |
|||
if(empty($case_name)) $fail_arr[] = '案名為必填'; |
|||
if(empty($linkman)) $fail_arr[] = '聯絡人為必填'; |
|||
if(empty($lm_tel)) $fail_arr[] = '聯絡人電話為必填'; |
|||
if(empty($address)) $fail_arr[] = '地址為必填'; |
|||
if(empty($salesman)) $fail_arr[] = '營業員為必填'; |
|||
if(empty($qc)) $fail_arr[] = '請選擇QC或官檢'; |
|||
if(count($fail_arr) > 0) { |
|||
header("HTTP/1.1 422 Unprocessable Entity"); |
|||
echo json_encode($fail_arr); |
|||
exit(); |
|||
} |
|||
|
|||
|
|||
$conn->beginTransaction(); |
|||
|
|||
$sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid ORDER BY create_at DESC"; |
|||
$stmt = $conn -> prepare($sql_str); |
|||
$stmt -> bindParam(":accountid",$salesman); |
|||
$stmt -> execute(); |
|||
$saleman = $stmt->fetch(PDO::FETCH_ASSOC); |
|||
$salesman_name = $saleman['name']; |
|||
if(!empty($files)){ |
|||
$englisharr = range('a', 'z'); |
|||
$files = $_FILES['files']; |
|||
$newfiles = []; |
|||
foreach( $files as $file ){ |
|||
$i = 0; //新陣列的索引編號 |
|||
foreach( $file as $key => $val ){ |
|||
$newfiles[$i]['name'] = $files['name'][$key]; |
|||
$newfiles[$i]['type'] = $files['type'][$key]; |
|||
$newfiles[$i]['tmp_name'] = $files['tmp_name'][$key]; |
|||
$newfiles[$i]['error'] = $files['error'][$key]; |
|||
$newfiles[$i]['size'] = $files['size'][$key]; |
|||
$i++; |
|||
} //foreach 第2層 end |
|||
} |
|||
$max_size = 4096*4096; //設定允許上傳檔案容量的最大值(1M) |
|||
$allow_ext = array('jpeg', 'jpg', 'png','JPG','JPEG','PNG','GIF'); //設定允許上傳檔案的類型 |
|||
$path = '../images/contracts/'; |
|||
if (!file_exists($path)) { mkdir($path); } |
|||
$msg_result = ''; //負責接收所有檔案檢測後的回傳訊息 |
|||
$datetime = (string)date('YmdHis'); |
|||
$files_id = 'm' . $datetime; // 保養=>b + 日期時間 |
|||
foreach( $newfiles as $key => $file ){ |
|||
$randNum = rand(1000,9999); |
|||
$randEnglish = $englisharr[rand(0,25)]; |
|||
$file_name = 'm' . (string)date('YmdHis') . $randNum . $randEnglish . $randNum.$file['name']; |
|||
$msg = upload_chk( $file,$path, $max_size, $allow_ext, $file_name ); |
|||
if($msg==1){ |
|||
$msg = '檔案傳送成功!'; |
|||
$sql_str = "INSERT INTO contract_back_files (files_id, file_name, file_mime, file_size, created_at, created_by) VALUES (:files_id, :file_name, :file_mime, :file_size, :created_at, :created_by)"; |
|||
$stmt = $conn -> prepare($sql_str); |
|||
$stmt -> bindParam(':files_id' ,$files_id); |
|||
$stmt -> bindParam(':file_name' ,$file_name); |
|||
$stmt -> bindParam(':file_mime' ,$file['type']); |
|||
$stmt -> bindParam(':file_size' ,$file['size']); |
|||
$stmt -> bindParam(':created_at' ,$created_at); |
|||
$stmt -> bindParam(':created_by' ,$created_by); |
|||
$stmt ->execute(); |
|||
}else{ |
|||
throw new PDOException('檔案上傳失敗:' . $msg); |
|||
} |
|||
$msg_result .= '第' . ($key+1) . '個上傳檔案的結果:' . $msg . '<br/>'; |
|||
$src_name = $path.$file['name']; |
|||
if( file_exists($src_name) ){ |
|||
//副檔名 |
|||
$extname = pathinfo($src_name, PATHINFO_EXTENSION); |
|||
//主檔名 |
|||
$basename = basename($src_name, '.'.$extname); |
|||
} |
|||
} |
|||
}else{ |
|||
$files = null; |
|||
} |
|||
|
|||
$sql_str = "INSERT INTO contract_m_signed_back (contract_no, customer, manager, vat, case_name, linkman, lm_tel, address, salesman, salesman_name, files_id, created_at, created_by, qc_official_type) VALUES (:contract_no, :customer, :manager, :vat, :case_name, :linkman, :lm_tel, :address, :salesman, :salesman_name, :files_id, :created_at, :created_by, :qc)"; |
|||
$stmt = $conn -> prepare($sql_str); |
|||
$stmt -> bindParam(":contract_no",$contractno); |
|||
$stmt -> bindParam(":customer",$customer); |
|||
$stmt -> bindParam(":manager",$manager); |
|||
$stmt -> bindParam(":vat",$vat); |
|||
$stmt -> bindParam(":case_name",$case_name); |
|||
$stmt -> bindParam(":linkman",$linkman); |
|||
$stmt -> bindParam(":lm_tel",$lm_tel); |
|||
$stmt -> bindParam(":address",$address); |
|||
$stmt -> bindParam(":salesman",$salesman); |
|||
$stmt -> bindParam(":salesman_name",$salesman_name); |
|||
$stmt -> bindParam(":files_id",$files_id); |
|||
$stmt -> bindParam(":created_at",$created_at); |
|||
$stmt -> bindParam(":created_by",$created_by); |
|||
$stmt -> bindParam(":qc",$qc); |
|||
$stmt -> execute(); |
|||
|
|||
|
|||
$result = $conn->commit(); |
|||
if($result){ |
|||
header("HTTP/1.1 201 Created"); |
|||
} |
|||
|
|||
}catch(PDOException $e){ |
|||
$conn->rollback(); |
|||
header("HTTP/1.1 500 Internal Server Error"); |
|||
die('Error!:'.$e->getMessage()); |
|||
} |
|||
} |
|||
<?php |
|||
require_once("../conn.php"); |
|||
include_once("./getFacilityNo.php"); |
|||
include_once("./getComboNo.php"); |
|||
include_once("./upload_chk.php"); |
|||
ini_set('date.timezone', 'Asia/Taipei'); |
|||
|
|||
if ($_SERVER['REQUEST_METHOD'] != 'POST') { |
|||
exit(); |
|||
} |
|||
//新梯簽回 |
|||
if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['contracttype']) && $_POST['contracttype'] == 'm') { |
|||
try { |
|||
$created_at = date('Y-m-d H:i:s'); |
|||
$created_by = $_POST["user_id"]; |
|||
$contractno = $_POST["contractno"]; |
|||
$customer = $_POST["customer"]; |
|||
$manager = $_POST["manager"]; |
|||
$vat = $_POST["vat"]; |
|||
$case_name = $_POST["case_name"]; |
|||
$linkman = $_POST["linkman"]; |
|||
$lm_tel = $_POST["lm_tel"]; |
|||
$address = $_POST["address"]; |
|||
$salesman = $_POST["salesman"]; |
|||
$qc = $_POST["qc"]; |
|||
$contracttype = $_POST["contracttype"]; |
|||
$files = !empty($_FILES['files']) ? $_FILES['files'] : null; |
|||
$files_id = null; |
|||
|
|||
$fail_arr = []; |
|||
if (empty($contractno)) $fail_arr[] = '合約號為必填'; |
|||
if (empty($customer)) $fail_arr[] = '客戶名稱為必填'; |
|||
if (empty($manager)) $fail_arr[] = '負責人為必填'; |
|||
if (empty($vat)) $fail_arr[] = '統編/身分證為必填'; |
|||
if (empty($case_name)) $fail_arr[] = '案名為必填'; |
|||
if (empty($linkman)) $fail_arr[] = '聯絡人為必填'; |
|||
if (empty($lm_tel)) $fail_arr[] = '聯絡人電話為必填'; |
|||
if (empty($address)) $fail_arr[] = '地址為必填'; |
|||
if (empty($salesman)) $fail_arr[] = '營業員為必填'; |
|||
if (empty($qc)) $fail_arr[] = '請選擇QC或官檢'; |
|||
if (count($fail_arr) > 0) { |
|||
header("HTTP/1.1 422 Unprocessable Entity"); |
|||
echo json_encode($fail_arr); |
|||
exit(); |
|||
} |
|||
|
|||
|
|||
$conn->beginTransaction(); |
|||
|
|||
$sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid ORDER BY create_at DESC"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(":accountid", $salesman); |
|||
$stmt->execute(); |
|||
$saleman = $stmt->fetch(PDO::FETCH_ASSOC); |
|||
$salesman_name = $saleman['name']; |
|||
if (!empty($files)) { |
|||
$englisharr = range('a', 'z'); |
|||
$files = $_FILES['files']; |
|||
$newfiles = []; |
|||
foreach ($files as $file) { |
|||
$i = 0; //新陣列的索引編號 |
|||
foreach ($file as $key => $val) { |
|||
$newfiles[$i]['name'] = $files['name'][$key]; |
|||
$newfiles[$i]['type'] = $files['type'][$key]; |
|||
$newfiles[$i]['tmp_name'] = $files['tmp_name'][$key]; |
|||
$newfiles[$i]['error'] = $files['error'][$key]; |
|||
$newfiles[$i]['size'] = $files['size'][$key]; |
|||
$i++; |
|||
} //foreach 第2層 end |
|||
} |
|||
$max_size = 4096 * 4096; //設定允許上傳檔案容量的最大值(1M) |
|||
$allow_ext = array('jpeg', 'jpg', 'png', 'JPG', 'JPEG', 'PNG', 'GIF'); //設定允許上傳檔案的類型 |
|||
$path = '../images/contracts/'; |
|||
if (!file_exists($path)) { |
|||
mkdir($path); |
|||
} |
|||
$msg_result = ''; //負責接收所有檔案檢測後的回傳訊息 |
|||
$datetime = (string)date('YmdHis'); |
|||
$files_id = 'm' . $datetime; // 保養=>b + 日期時間 |
|||
foreach ($newfiles as $key => $file) { |
|||
$randNum = rand(1000, 9999); |
|||
$randEnglish = $englisharr[rand(0, 25)]; |
|||
$file_name = 'm' . (string)date('YmdHis') . $randNum . $randEnglish . $randNum . $file['name']; |
|||
$msg = upload_chk($file, $path, $max_size, $allow_ext, $file_name); |
|||
if ($msg == 1) { |
|||
$msg = '檔案傳送成功!'; |
|||
$sql_str = "INSERT INTO contract_back_files (files_id, file_name, file_mime, file_size, created_at, created_by) VALUES (:files_id, :file_name, :file_mime, :file_size, :created_at, :created_by)"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':files_id', $files_id); |
|||
$stmt->bindParam(':file_name', $file_name); |
|||
$stmt->bindParam(':file_mime', $file['type']); |
|||
$stmt->bindParam(':file_size', $file['size']); |
|||
$stmt->bindParam(':created_at', $created_at); |
|||
$stmt->bindParam(':created_by', $created_by); |
|||
$stmt->execute(); |
|||
} else { |
|||
throw new PDOException('檔案上傳失敗:' . $msg); |
|||
} |
|||
$msg_result .= '第' . ($key + 1) . '個上傳檔案的結果:' . $msg . '<br/>'; |
|||
$src_name = $path . $file['name']; |
|||
if (file_exists($src_name)) { |
|||
//副檔名 |
|||
$extname = pathinfo($src_name, PATHINFO_EXTENSION); |
|||
//主檔名 |
|||
$basename = basename($src_name, '.' . $extname); |
|||
} |
|||
} |
|||
} else { |
|||
$files = null; |
|||
} |
|||
|
|||
$sql_str = "INSERT INTO contract_m_signed_back (contract_no, customer, manager, vat, case_name, linkman, lm_tel, address, salesman, salesman_name, files_id, created_at, created_by, qc_official_type) VALUES (:contract_no, :customer, :manager, :vat, :case_name, :linkman, :lm_tel, :address, :salesman, :salesman_name, :files_id, :created_at, :created_by, :qc)"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(":contract_no", $contractno); |
|||
$stmt->bindParam(":customer", $customer); |
|||
$stmt->bindParam(":manager", $manager); |
|||
$stmt->bindParam(":vat", $vat); |
|||
$stmt->bindParam(":case_name", $case_name); |
|||
$stmt->bindParam(":linkman", $linkman); |
|||
$stmt->bindParam(":lm_tel", $lm_tel); |
|||
$stmt->bindParam(":address", $address); |
|||
$stmt->bindParam(":salesman", $salesman); |
|||
$stmt->bindParam(":salesman_name", $salesman_name); |
|||
$stmt->bindParam(":files_id", $files_id); |
|||
$stmt->bindParam(":created_at", $created_at); |
|||
$stmt->bindParam(":created_by", $created_by); |
|||
$stmt->bindParam(":qc", $qc); |
|||
$stmt->execute(); |
|||
|
|||
|
|||
$result = $conn->commit(); |
|||
if ($result) { |
|||
header("HTTP/1.1 201 Created"); |
|||
} |
|||
} catch (PDOException $e) { |
|||
$conn->rollback(); |
|||
header("HTTP/1.1 500 Internal Server Error"); |
|||
die('Error!:' . $e->getMessage()); |
|||
} |
|||
} |
|||
|
|||
function T8Insert($data) |
|||
{ |
|||
require_once("../connt8.php"); |
|||
|
|||
$contractno = $data['contractno']; |
|||
$partyA = $data['customer']; |
|||
$phone = $data['lm_tel']; |
|||
$vat = $data['vat']; |
|||
$partyAaddress = $data['address']; |
|||
$user_id = $data['user_id']; |
|||
$salesman = $data['salesman']; |
|||
$createAt = date("Y-m-dH-i-s"); |
|||
$createTime = str_replace('-', '', $createAt); |
|||
|
|||
|
|||
$connT8->beginTransaction(); |
|||
|
|||
$sql = "SELECT * FROM comCustomer WHERE BizPartnerId = :BizPartnerId"; |
|||
$stmt = $conn->prepare($sql); |
|||
$stmt->bindParam(':BizPartnerId', $contractno); |
|||
$stmt->execute(); |
|||
$result = $stmt->fetch(PDO::FETCH_ASSOC); |
|||
// 新增客戶 table |
|||
if (empty($result)) { |
|||
// 若 客戶資料為空,新增一筆到 comCustomer |
|||
// 新增客戶資料 |
|||
$sql = "INSERT INTO comBusinessPartner |
|||
(BizPartnerId,BizPartnerName,BusinessAttr,CountryId,WorkTelNo,BizToDate,TaxNo,EnterpriseName,ContactAddress,EMail,CreatorId,CreateTime,BizPartnerTypeId) |
|||
VALUES(:BizPartnerId,:BizPartnerName,1,'TW',:WorkTelNo,99999999,:TaxNo,:EnterpriseName,:ContactAddress,:EMail,:CreatorId,:CreateTime,'10')"; |
|||
$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(':ContactAddress', $partyAaddress); |
|||
$stmt->bindParam(':EMail', $email); |
|||
$stmt->bindParam(':CreatorId', $user_id); |
|||
$stmt->bindParam(':CreateTime', $createTime); |
|||
|
|||
$stmt->execute(); |
|||
|
|||
$sql = "INSERT INTO comCustomer |
|||
(OrgId,BizPartnerTypeId,CurrId,BizPartnerId,PersonId,CreatorId,IsInUsed,InvoiceAddress,CreateTime,InvoiceId) |
|||
VALUES('1000','10','TWD',:BizPartnerId,:PersonId,:CreatorId,1,:InvoiceAddress,:CreateTime,'35')"; |
|||
$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(); |
|||
} 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, |
|||
ContactAddress=:ContactAddress, |
|||
EMail=:EMail, |
|||
LastOperatorId=:LastOperatorId, |
|||
LastOperateTime=:LastOperateTime |
|||
WHERE BizPartnerId = :BizPartnerId |
|||
"; |
|||
$stmt = $connT8->prepare($sql); |
|||
$stmt->bindParam(':BizPartnerName', $partyA); |
|||
$stmt->bindParam(':WorkTelNo', $phone); |
|||
$stmt->bindParam(':TaxNo', $vat); |
|||
$stmt->bindParam(':EnterpriseName', $customer); |
|||
$stmt->bindParam(':ContactAddress', $partyAaddress); |
|||
$stmt->bindParam(':EMail', $email); |
|||
$stmt->bindParam(':LastOperatorId', $user_id); |
|||
$stmt->bindParam(':LastOperateTime', $createTime); |
|||
$stmt->bindParam(':BizPartnerId', $contractno); |
|||
$stmt->execute(); |
|||
} |
|||
|
|||
$sql = "SELECT * FROM comProject WHERE ProjectId = :ProjectId"; |
|||
$stmt = $connT8->prepare($sql); |
|||
$stmt->bindParam(':ProjectId', $contractno); |
|||
$stmt->execute(); |
|||
$resultProject = $stmt->fetchAll(PDO::FETCH_ASSOC); |
|||
if (empty($resultProject)) { |
|||
//新增於 comProject。合約 table |
|||
$sql = "INSERT INTO comProject(ProjectId,ProjectName,TypeId,CreateTime,CreatorId,IsInUsed) |
|||
VALUES(:ProjectId,:ProjectName,'C0',:CreateTime,:CreatorId,1)"; |
|||
$stmt = $connT8->prepare($sql); |
|||
$stmt->bindParam(':ProjectId', $contractno); |
|||
$stmt->bindParam(':ProjectName', $customer); |
|||
$stmt->bindParam(':CreateTime', $createTime); |
|||
$stmt->bindParam(':CreatorId', $user_id); |
|||
$stmt->execute(); |
|||
} |
|||
} |
|||
|
@ -0,0 +1,309 @@ |
|||
<?php |
|||
|
|||
|
|||
include "header.php"; |
|||
include "css/view/wipwhole-index.php"; |
|||
|
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
$contractno = empty($_POST['contractno']) ? null : $_POST['contractno']; |
|||
$department_id = accountidToDepartId($user_id); |
|||
|
|||
if (in_array(accountidToDepartId($user_id), ['220'])) { |
|||
$sql_cmd = " WHERE 1=1 "; |
|||
} else { |
|||
$sql_cmd = sql_myself($user_id, "cgp.PersonId"); |
|||
} |
|||
|
|||
// 合約主檔 |
|||
$sql = " |
|||
SELECT |
|||
siam.BillNo, -- 單據號 |
|||
siad_tmp.ProjectId,-- 合約號 |
|||
siam.BillDate, -- 合約日期 |
|||
BizPartnerName, -- 客戶名稱 |
|||
cp.PersonId, -- 業務人員 |
|||
cgp.PersonName, -- 業務人員名稱 |
|||
cd.DeptName, -- 業務人員部門 |
|||
siam.UnTransAmount, -- 合約金額 |
|||
siad_tmp2.Max_CU_EstPayDate -- 最後收款日期 |
|||
FROM salIncomeApplyMaster AS siam |
|||
LEFT JOIN ( |
|||
SELECT |
|||
cc.BizPartnerId, |
|||
cbp.BizPartnerName |
|||
FROM comCustomer AS cc |
|||
LEFT JOIN comBusinessPartner AS cbp |
|||
ON cc.BizPartnerId = cbp.BizPartnerId |
|||
)cb_tmp |
|||
ON cb_tmp.BizPartnerId = siam.BizPartnerId |
|||
LEFT JOIN comPerson AS cp -- 員工主檔 |
|||
ON siam.PersonId = cp.PersonId |
|||
LEFT JOIN comGroupPerson AS cgp -- 員工明細檔 |
|||
ON cp.PersonId = cgp.PersonId |
|||
LEFT JOIN comDepartment AS cd -- 部門主檔 |
|||
ON cp.DeptId = cd.DeptId |
|||
LEFT JOIN |
|||
( |
|||
SELECT DISTINCT |
|||
siad.BillNo, |
|||
siad.ProjectId |
|||
FROM salIncomeApplyDetail AS siad |
|||
WHERE siad.ProjectId != '' |
|||
AND siad.ProjectId IS NOT NULL |
|||
)AS siad_tmp -- 合約明細 |
|||
ON siam.BillNo = siad_tmp.BillNo |
|||
LEFT JOIN |
|||
( |
|||
SELECT |
|||
siad.BillNo, |
|||
MAX(siad.CU_EstPayDate) as Max_CU_EstPayDate |
|||
FROM salIncomeApplyDetail AS siad |
|||
GROUP BY siad.BillNo |
|||
)AS siad_tmp2 -- 合約明細2 |
|||
ON siam.BillNo = siad_tmp2.BillNo |
|||
$sql_cmd |
|||
AND siam.CurrentState = '2' |
|||
"; |
|||
if (!empty($contractno)) { |
|||
$sql .= " AND siad_tmp.ProjectId = '$contractno' "; |
|||
} |
|||
// echo "<pre>"; |
|||
// echo $sql; |
|||
// echo "</pre>"; |
|||
// exit; |
|||
|
|||
$data = $conn->query($sql); |
|||
if ($data) : |
|||
?> |
|||
|
|||
<style> |
|||
table { |
|||
table-layout: fixed; |
|||
width: 100%; |
|||
} |
|||
|
|||
td { |
|||
word-wrap: break-word; |
|||
} |
|||
|
|||
img { |
|||
width: 125px; |
|||
} |
|||
|
|||
.width_style_1 { |
|||
width: 125px; |
|||
} |
|||
|
|||
table { |
|||
width: 100%; |
|||
} |
|||
|
|||
#table_index_filter { |
|||
float: right; |
|||
} |
|||
|
|||
#table_index_paginate { |
|||
float: right; |
|||
} |
|||
|
|||
label { |
|||
display: inline-flex; |
|||
margin-bottom: .5rem; |
|||
margin-top: .5rem; |
|||
|
|||
} |
|||
</style> |
|||
|
|||
<div id="myModal" class="modal"> |
|||
<div class="back"></div> |
|||
<div class="modal-content"> |
|||
<button type="button" class="close" id="myCloseBtn">X</button> |
|||
<div class='col-12' style='text-align:center'> |
|||
<div class='row'> |
|||
<div class='col-12'> |
|||
<table id="table_detail" class="table table-bordered" style="width:100%; margin:0 auto;"> |
|||
<thead> |
|||
<tr> |
|||
<th>收入代碼</th> |
|||
<th>收入名稱</th> |
|||
<th>數量</th> |
|||
<th>單價</th> |
|||
<th>金額(未稅)</th> |
|||
<th>稅金</th> |
|||
<th>含稅金額</th> |
|||
<th>專案代碼</th> |
|||
<th>作番號</th> |
|||
<th>預計請款日</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
|
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
<div style="overflow-x:auto;"> |
|||
<form id='myForm' method='post' action='contract_b-index.php?<?= $token_link ?>'> |
|||
<table class='table query-table table-striped table-bordered display compact' style='width:98%;text-align:center;margin:0 auto'> |
|||
<thead> |
|||
<tr> |
|||
<td colspan="5"> |
|||
<h3 style='text-align:center'>保養合約管理</h3> |
|||
</td> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<tr> |
|||
<th style='text-align:center;vertical-align: middle;'>合約號</th> |
|||
<td style='text-align:center;vertical-align: middle;'> |
|||
<input type="text" class='form-control' id='contractno' name='contractno' value=""> |
|||
</td> |
|||
<td style='text-align:left;vertical-align: middle;'> |
|||
<button type="submit" style='text-align:center; margin:0 auto' class="btn btn-primary btn-sm">查詢</button> |
|||
</td> |
|||
</tr> |
|||
</tbody> |
|||
</table> |
|||
</form> |
|||
</div> |
|||
|
|||
<div style="overflow-x:auto;"> |
|||
<a href="contract/contract-input.php?function_name=contract-input&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-plus"></span> |
|||
</a> |
|||
<table id="table_index" class="table table-striped table-bordered" style="width:100%"> |
|||
<thead> |
|||
<tr> |
|||
<th style='text-align:center;vertical-align: middle;width:120px;'>營業人員/契約人員</th> |
|||
<th style='text-align:center;vertical-align: middle;width:120px;'>部門</th> |
|||
<th style='text-align:center;vertical-align: middle;width:120px;'>合約號</th> |
|||
<th style='text-align:center;vertical-align: middle;width:120px;'>單據號</th> |
|||
<th style='text-align:center;vertical-align: middle;width:120px;'>客戶名稱</th> |
|||
<th style='text-align:center;vertical-align: middle;width:80px;'>單據日期</th> |
|||
<th style='text-align:center;vertical-align: middle;width:80px;'>最後收款日</th> |
|||
<th style='text-align:center;vertical-align: middle;width:120px;'>追蹤狀態</th> |
|||
<th style='text-align:center;vertical-align: middle;width:120px;'>金額</th> |
|||
<th style='text-align:center;vertical-align: middle;width:60px;'>明細</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<?php foreach ($data as $row) { ?> |
|||
<tr> |
|||
<td> |
|||
<?php |
|||
echo $row['PersonId']; |
|||
echo "<br/>"; |
|||
echo $row['PersonName']; |
|||
?> |
|||
</td> |
|||
<td> |
|||
<?php echo $row['DeptName']; ?> |
|||
</td> |
|||
<td> |
|||
<?php echo $row['ProjectId']; ?> |
|||
</td> |
|||
<td> |
|||
<?php echo $row['BillNo']; ?> |
|||
</td> |
|||
<td> |
|||
<?php echo $row['BizPartnerName']; ?> |
|||
</td> |
|||
<td> |
|||
<?php echo date('Y/m/d', strtotime($row['BillDate'])); ?> |
|||
</td> |
|||
<td> |
|||
<?php echo empty($row['Max_CU_EstPayDate']) ? '' : date('Y/m/d', strtotime($row['Max_CU_EstPayDate'])); ?> |
|||
</td> |
|||
<td> |
|||
<?php |
|||
|
|||
$date1 = new DateTime(date('Y-m-d', strtotime($row['Max_CU_EstPayDate']))); |
|||
$date2 = new DateTime(date('Y-m-d')); |
|||
$interval = $date1->diff($date2); |
|||
$months = $interval->m; |
|||
$months += $interval->y * 12; |
|||
if ($date1 <= $date2) { |
|||
echo "<span class=''>合約已過期</span>"; |
|||
} else if ($months <= 2) { |
|||
echo "<span class='text-danger'>合約快到期</span>"; |
|||
} else { |
|||
echo "<span class='text-success'>合約未到期</span>"; |
|||
} |
|||
?> |
|||
</td> |
|||
<td> |
|||
<?php echo number_format(intval($row['UnTransAmount']), 0, '', ','); ?> |
|||
</td> |
|||
<td> |
|||
<button class="btn btn-primary myBtn" type="button" onclick="showDetail('<?php echo $row['BillNo']; ?>')">明細</button> |
|||
</td> |
|||
</tr> |
|||
<?php } ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
<script> |
|||
var modal = document.getElementById("myModal"); |
|||
$(".myBtn").click(function() { |
|||
$("#myModal").show(); |
|||
}); |
|||
$("#myCloseBtn").click(function(e) { |
|||
$("#myModal").hide(); |
|||
}); |
|||
$(".back").click(function(e) { |
|||
$("#myModal").hide(); |
|||
}); |
|||
|
|||
function showDetail(billno) { |
|||
$.ajax({ |
|||
type: "POST", |
|||
dataType: "json", |
|||
url: "contract_b-index-model.php", |
|||
data: { |
|||
form_name: 'showDetail', |
|||
billno: billno |
|||
}, |
|||
complete: function(data) { |
|||
var data = data.responseJSON |
|||
var str = ""; |
|||
for (var i = 0; i < data.length; i++) { |
|||
str += "<tr>"; |
|||
str += "<td>" + data[i]['IncomeId'] + "</td>"; |
|||
str += "<td>" + data[i]['FeeTypeName'] + "</td>"; |
|||
str += "<td>" + data[i]['SQuantity'] + "</td>"; |
|||
str += "<td>" + data[i]['SPrice'] + "</td>"; |
|||
str += "<td>" + data[i]['OAmount'] + "</td>"; |
|||
str += "<td>" + data[i]['OTax'] + "</td>"; |
|||
str += "<td>" + data[i]['OAmountWithTax'] + "</td>"; |
|||
str += "<td>" + data[i]['ProjectId'] + "</td>"; |
|||
str += "<td>" + data[i]['CU_MaterialId'] + "</td>"; |
|||
str += "<td>" + data[i]['CU_EstPayDate'] + "</td>"; |
|||
str += "</tr>"; |
|||
} |
|||
if ($('#table_detail').hasClass('dataTable')) { |
|||
dttable = $('#table_detail').dataTable(); |
|||
dttable.fnClearTable(); |
|||
dttable.fnDestroy(); |
|||
} |
|||
$("#table_detail").find("tbody").html(str); |
|||
$('#table_detail').dataTable(); |
|||
} |
|||
}) |
|||
} |
|||
</script> |
|||
<?php |
|||
|
|||
else : |
|||
echo "<h2>There is no record!</h2>"; |
|||
endif; |
|||
|
|||
#代表結束連線 |
|||
mysqli_close($link); |
|||
|
|||
include "footer.php"; |
|||
?> |
Loading…
Reference in new issue