Browse Source

價審

main
Cheng 1 year ago
parent
commit
df7e24efb4
  1. 646
      wms/cont/MICalculator.php
  2. 1019
      wms/cont/query_form.php
  3. 4
      wms/cont/sign_list.php
  4. 293
      wms/contract/api/postContractNewApplyData.php

646
wms/cont/MICalculator.php

@ -1,322 +1,324 @@
<?php
require_once '../../workflow/lib/DB.php';
class MICalculator
{
/**
* 計算MI
*
* @param array $param
* @return void
*/
public function cal(array $param)
{
$elevator_type = $param['elevator_type'];
$func = $elevator_type . "_price";
if (method_exists($this, $elevator_type . "_price")) {
return call_user_func([$this, $func], $param);
}
return self::error();
}
/**
* 客梯報價 maintain_kind='A'
* 1.每月2次保養價格*1.25倍
* 2.全包價格按半包價+1500元/臺
* 3.簽5年長約免費送M1係統的+2600元/臺"
* @return void
*/
public function A_price(array $item)
{
$floors = $item['floors'];
$maintain_times = $item['maintain_times'];
$sql_get_price = "
select
elevator_type,
base_price,
floors_price,
min_floors,
min_maintain_times,
maintain_months,
maintain_kind,
maintain_period,
is_m1_bundle,
all_inclusive_fee,
maintenance_fee_coefficient,
m1_bundle_fee
from maintain_mi_option where
elevator_type='" . $item['elevator_type'] . "'
and " . $item['floors'] . " between min_floors and max_floors
and " . $item['speed'] . " between min_speed and max_speed
and " . $item['persons'] . " between min_persons and max_persons
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times
and maintain_months= " . $item['maintain_months'] . "
and maintain_kind='" . $item['maintain_kind'] . "'
and is_m1_bundle='" . $item['is_m1_bundle'] . "'
";
list($row) = DB::result($sql_get_price);
if (empty($row)) return self::error();
#1基礎價格
$floors = $item['floors'] - $row['min_floors'];
$price1 = $row['base_price'] + ($floors) * $row['floors_price'];
// echo $price1;
#判斷是否全包
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1;
// echo $price2;
#判斷是否五年M1套餐
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2;
// echo $price3;
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3);
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times
$price4 = $price3;
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) {
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient'];
}
return self::success($price4);
}
/**
* 貨梯報價
*
* @return void
*/
public function B_price($item)
{
$floors = $item['floors'];
$maintain_times = $item['maintain_times'];
$sql_get_price = "
select
elevator_type,
base_price,
floors_price,
min_floors,
min_maintain_times,
maintain_months,
maintain_kind,
maintain_period,
is_m1_bundle,
all_inclusive_fee,
maintenance_fee_coefficient,
m1_bundle_fee
from maintain_mi_option where
elevator_type='" . $item['elevator_type'] . "'
and " . $item['floors'] . " between min_floors and max_floors
and " . $item['weight'] . " between min_weight and max_weight
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times
and maintain_months= " . $item['maintain_months'] . "
and maintain_kind='" . $item['maintain_kind'] . "'
and is_m1_bundle='" . $item['is_m1_bundle'] . "'
";
list($row) = DB::result($sql_get_price);
if (empty($row)) return self::error();
#1基礎價格
$floors = $item['floors'] - $row['min_floors'];
$price1 = $row['base_price'] + ($floors) * $row['floors_price'];
// echo $price1;
#判斷是否全包
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1;
// echo $price2;
#判斷是否五年M1套餐
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2;
// echo $price3;
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3);
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times
$price4 = $price3;
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) {
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient'];
}
return self::success($price4);
}
/**
* 病床梯報價
*
* @return void
*/
public function C_price($item)
{
$floors = $item['floors'];
$maintain_times = $item['maintain_times'];
$sql_get_price = "
select
elevator_type,
base_price,
floors_price,
min_floors,
min_maintain_times,
maintain_months,
maintain_kind,
maintain_period,
is_m1_bundle,
all_inclusive_fee,
maintenance_fee_coefficient,
m1_bundle_fee
from maintain_mi_option where
elevator_type='" . $item['elevator_type'] . "'
and " . $item['floors'] . " between min_floors and max_floors
and " . $item['weight'] . " between min_weight and max_weight
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times
and maintain_months= " . $item['maintain_months'] . "
and maintain_kind='" . $item['maintain_kind'] . "'
and is_m1_bundle='" . $item['is_m1_bundle'] . "'
";
list($row) = DB::result($sql_get_price);
if (empty($row)) return self::error();
#1基礎價格
$floors = $item['floors'] - $row['min_floors'];
$price1 = $row['base_price'] + ($floors) * $row['floors_price'];
// echo $price1;
#判斷是否全包
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1;
// echo $price2;
#判斷是否五年M1套餐
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2;
// echo $price3;
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3);
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times
$price4 = $price3;
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) {
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient'];
}
return self::success($price4);
}
/**
* 無機房報價
*
* @return void
*/
public function D_price($item)
{
$floors = $item['floors'];
$maintain_times = $item['maintain_times'];
$sql_get_price = "
select
elevator_type,
base_price,
floors_price,
min_floors,
min_maintain_times,
maintain_months,
maintain_kind,
maintain_period,
is_m1_bundle,
all_inclusive_fee,
maintenance_fee_coefficient,
m1_bundle_fee
from maintain_mi_option where
elevator_type='" . $item['elevator_type'] . "'
and " . $item['floors'] . " between min_floors and max_floors
and " . $item['persons'] . " between min_persons and max_persons
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times
and maintain_months= " . $item['maintain_months'] . "
and maintain_kind='" . $item['maintain_kind'] . "'
and is_m1_bundle='" . $item['is_m1_bundle'] . "'
";
list($row) = DB::result($sql_get_price);
if (empty($row)) return self::error();
#1基礎價格
$floors = $item['floors'] - $row['min_floors'];
$price1 = $row['base_price'] + ($floors) * $row['floors_price'];
// echo $price1;
#判斷是否全包
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1;
// echo $price2;
#判斷是否五年M1套餐
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2;
// echo $price3;
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3);
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times
$price4 = $price3;
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) {
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient'];
}
return self::success($price4);
}
/**
*家用梯報價
*
* @return void
*/
public function E_price(array $item)
{
$floors = $item['floors'];
$maintain_times = $item['maintain_times'];
$sql_get_price = "
select
elevator_type,
base_price,
floors_price,
min_floors,
min_maintain_times,
maintain_months,
maintain_kind,
maintain_period,
is_m1_bundle,
all_inclusive_fee,
maintenance_fee_coefficient,
m1_bundle_fee
from maintain_mi_option where
elevator_type='" . $item['elevator_type'] . "'
and " . $item['floors'] . " between min_floors and max_floors
and " . $item['persons'] . " between min_persons and max_persons
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times
and maintain_period= " . $item['maintain_period'] . "
and maintain_kind='" . $item['maintain_kind'] . "'
and is_m1_bundle='" . $item['is_m1_bundle'] . "'
";
list($row) = DB::result($sql_get_price);
if (empty($row)) return self::error();
#1基礎價格
$floors = $item['floors'] - $row['min_floors'];
$price1 = $row['base_price'] + ($floors) * $row['floors_price'];
// echo $price1;
#判斷是否全包
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1;
// echo $price2;
#判斷是否五年M1套餐
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2;
// echo $price3;
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3);
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times
$price4 = $price3;
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) {
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient'];
}
return self::success($price4);
}
public function error()
{
return [
'status' => 'fail',
'message' => '無此項目,請聯係業務部創建MI'
];
}
public function success($price)
{
return [
'status' => 'ok',
'price' => $price
];
}
}
<?php
require_once '../../workflow/lib/DB.php';
class MICalculator
{
/**
* 計算MI
*
* @param array $param
* @return void
*/
public function cal(array $param)
{
$elevator_type = $param['elevator_type'];
$func = $elevator_type . "_price";
if (method_exists($this, $elevator_type . "_price")) {
return call_user_func([$this, $func], $param);
}
return self::error();
}
/**
* 客梯報價 maintain_kind='A'
* 1.每月2次保養價格*1.25倍
* 2.全包價格按半包價+1500元/臺
* 3.簽5年長約免費送M1係統的+2600元/臺"
* @return void
*/
public function A_price(array $item)
{
$floors = $item['floors'];
$maintain_times = $item['maintain_times'];
$sql_get_price = "
select
elevator_type,
base_price,
floors_price,
min_floors,
min_maintain_times,
maintain_months,
maintain_kind,
maintain_period,
is_m1_bundle,
all_inclusive_fee,
maintenance_fee_coefficient,
m1_bundle_fee
from maintain_mi_option where
elevator_type='" . $item['elevator_type'] . "'
and " . $item['floors'] . " between min_floors and max_floors
and " . $item['speed'] . " between min_speed and max_speed
and " . $item['persons'] . " between min_persons and max_persons
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times
and maintain_months= " . $item['maintain_months'] . "
and maintain_kind='" . $item['maintain_kind'] . "'
and is_m1_bundle='" . $item['is_m1_bundle'] . "'
";
list($row) = DB::result($sql_get_price);
if (empty($row)) return self::error();
#1基礎價格
$floors = $item['floors'] - $row['min_floors'];
$price1 = $row['base_price'] + ($floors) * $row['floors_price'];
// echo $price1;
#判斷是否全包
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1;
// echo $price2;
#判斷是否五年M1套餐
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2;
// echo $price3;
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3);
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times
$price4 = $price3;
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) {
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient'];
}
return self::success($price4);
}
/**
* 貨梯報價
*
* @return void
*/
public function B_price($item)
{
$floors = $item['floors'];
$maintain_times = $item['maintain_times'];
$sql_get_price = "
select
elevator_type,
base_price,
floors_price,
min_floors,
min_maintain_times,
maintain_months,
maintain_kind,
maintain_period,
is_m1_bundle,
all_inclusive_fee,
maintenance_fee_coefficient,
m1_bundle_fee
from maintain_mi_option where
elevator_type='" . $item['elevator_type'] . "'
and " . $item['floors'] . " between min_floors and max_floors
and " . $item['weight'] . " between min_weight and max_weight
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times
and maintain_months= " . $item['maintain_months'] . "
and maintain_kind='" . $item['maintain_kind'] . "'
and is_m1_bundle='" . $item['is_m1_bundle'] . "'
";
list($row) = DB::result($sql_get_price);
if (empty($row)) return self::error();
#1基礎價格
$floors = $item['floors'] - $row['min_floors'];
$price1 = $row['base_price'] + ($floors) * $row['floors_price'];
// echo $price1;
#判斷是否全包
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1;
// echo $price2;
#判斷是否五年M1套餐
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2;
// echo $price3;
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3);
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times
$price4 = $price3;
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) {
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient'];
}
return self::success($price4);
}
/**
* 病床梯報價
*
* @return void
*/
public function C_price($item)
{
$floors = $item['floors'];
$maintain_times = $item['maintain_times'];
$sql_get_price = "
select
elevator_type,
base_price,
floors_price,
min_floors,
min_maintain_times,
maintain_months,
maintain_kind,
maintain_period,
is_m1_bundle,
all_inclusive_fee,
maintenance_fee_coefficient,
m1_bundle_fee
from maintain_mi_option where
elevator_type='" . $item['elevator_type'] . "'
and " . $item['floors'] . " between min_floors and max_floors
and " . $item['weight'] . " between min_weight and max_weight
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times
and maintain_months= " . $item['maintain_months'] . "
and maintain_kind='" . $item['maintain_kind'] . "'
and is_m1_bundle='" . $item['is_m1_bundle'] . "'
";
list($row) = DB::result($sql_get_price);
if (empty($row)) return self::error();
#1基礎價格
$floors = $item['floors'] - $row['min_floors'];
$price1 = $row['base_price'] + ($floors) * $row['floors_price'];
// echo $price1;
#判斷是否全包
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1;
// echo $price2;
#判斷是否五年M1套餐
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2;
// echo $price3;
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3);
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times
$price4 = $price3;
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) {
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient'];
}
return self::success($price4);
}
/**
* 無機房報價
*
* @return void
*/
public function D_price($item)
{
$floors = $item['floors'];
$maintain_times = $item['maintain_times'];
$sql_get_price = "
select
elevator_type,
base_price,
floors_price,
min_floors,
min_maintain_times,
maintain_months,
maintain_kind,
maintain_period,
is_m1_bundle,
all_inclusive_fee,
maintenance_fee_coefficient,
m1_bundle_fee
from maintain_mi_option where
elevator_type='" . $item['elevator_type'] . "'
and " . $item['floors'] . " between min_floors and max_floors
and " . $item['persons'] . " between min_persons and max_persons
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times
and maintain_months= " . $item['maintain_months'] . "
and maintain_kind='" . $item['maintain_kind'] . "'
and is_m1_bundle='" . $item['is_m1_bundle'] . "'
";
list($row) = DB::result($sql_get_price);
if (empty($row)) return self::error();
#1基礎價格
$floors = $item['floors'] - $row['min_floors'];
$price1 = $row['base_price'] + ($floors) * $row['floors_price'];
// echo $price1;
#判斷是否全包
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1;
// echo $price2;
#判斷是否五年M1套餐
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2;
// echo $price3;
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3);
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times
$price4 = $price3;
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) {
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient'];
}
return self::success($price4);
}
/**
*家用梯報價
*
* @return void
*/
public function E_price(array $item)
{
$floors = $item['floors'];
$maintain_times = $item['maintain_times'];
$sql_get_price = "
select
elevator_type,
base_price,
floors_price,
min_floors,
min_maintain_times,
maintain_months,
maintain_kind,
maintain_period,
is_m1_bundle,
all_inclusive_fee,
maintenance_fee_coefficient,
m1_bundle_fee
from maintain_mi_option where
elevator_type='" . $item['elevator_type'] . "'
and " . $item['floors'] . " between min_floors and max_floors
and " . $item['persons'] . " between min_persons and max_persons
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times
and maintain_period= " . $item['maintain_period'] . "
and maintain_kind='" . $item['maintain_kind'] . "'
and is_m1_bundle='" . $item['is_m1_bundle'] . "'
";
echo $sql_get_price;
list($row) = DB::result($sql_get_price);
if (empty($row)) return self::error();
#1基礎價格
$floors = $item['floors'] - $row['min_floors'];
$price1 = $row['base_price'] + ($floors) * $row['floors_price'];
// echo $price1;
#判斷是否全包
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1;
// echo $price2;
#判斷是否五年M1套餐
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2;
// echo $price3;
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3);
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times
$price4 = $price3;
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) {
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient'];
}
return self::success($price4);
}
public function error()
{
return [
'status' => 'fail',
'message' => '無此項目,請聯係業務部創建MI'
];
}
public function success($price)
{
return [
'status' => 'ok',
'price' => $price
];
}
}

1019
wms/cont/query_form.php

File diff suppressed because it is too large

4
wms/cont/sign_list.php

@ -41,7 +41,7 @@ $res = mysqli_query($link, $sql);
$row = mysqli_fetch_row($res);
$user_department_id = $row[0];
mysqli_free_result($res);
if (in_array($user_department_id, $depart_arr) || $user_id == "M0008" || $user_id == "M0012" || $user_id == "M0006" || $user_id == "M0189" || $user_id == "TEST01" || $user_id == "TEST02" || $user_id == "TEST03" || $user_id == "TEST04") $where = "";
if (in_array($user_department_id, $depart_arr) || $user_id == "M0008" || $user_id == "M0012" || $user_id == "M0006" || $user_id == "M0189" || $user_id == "TEST01" || $user_id == "TEST02" || $user_id == "TEST03" || $user_id == "M0225") $where = "";
// 電梯廠牌
$elevator_brand_arr = [];
@ -75,6 +75,8 @@ $data = mysqli_query($link, $sql);
// echo '<pre>';
// print_r($data);
// echo '</pre>';
// echo '1';
?>
<?php

293
wms/contract/api/postContractNewApplyData.php

@ -1,14 +1,16 @@
<?php
use function Symfony\Component\String\s;
require_once("../conn.php");
include_once("./upload_chk.php");
ini_set ( 'date.timezone' , 'Asia/Taipei' );
if($_SERVER['REQUEST_METHOD'] != 'POST'){
ini_set('date.timezone', 'Asia/Taipei');
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
exit();
}
//暫存、送審
if(isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] == 0 || $_POST['status'] == 1) ){
if($_POST['regulations'] < 10){
if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] == 0 || $_POST['status'] == 1)) {
if ($_POST['regulations'] < 10) {
header("HTTP/1.1 500 傳送失敗!!試車時間不得低於10天");
exit;
}
@ -39,7 +41,7 @@ if(isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] == 0
$pays = json_decode($pays, true);
$files = !empty($_FILES['files']) ? $_FILES['files'] : null;
$submit_date = ($status == 1) ? date("Y-m-d H:i:s") : null;
@ -51,63 +53,63 @@ if(isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] == 0
$updated_by = $_POST['user_id'];
$isFirst = $_POST['isFirst'];
$conn->beginTransaction();
try{
if($isFirst == 1){
try {
if ($isFirst == 1) {
$sql_str = "INSERT INTO contract_new_apply (mid, contractno, sales_man, apply_date, apply_type, case_name, customer, manager, vat, total_price, total_items, buy_fee, install_fee, contact_address, workdeadline_a, workdeadline_b, test_time, freedeadline, trade_address, tradedeadline, secondPayDeadline, progress, status, person, personname, submit_date, created_at, created_by) VALUES (:mid, :contractno, :sales_man, :apply_date, :apply_type, :case_name, :customer, :manager, :vat, :total_price, :total_items, :buy_fee, :install_fee, :contact_address, :workdeadline_a, :workdeadline_b, :test_time, :freedeadline, :trade_address, :tradedeadline, :secondPayDeadline, :progress, :status, :person, :personname, :submit_date, :created_at, :created_by)";
$stmt = $conn -> prepare($sql_str);
$stmt ->bindParam(':mid', $mid);
$stmt ->bindParam(':contractno', $vol_no);
$stmt ->bindParam(':sales_man', $salesman);
$stmt ->bindParam(':apply_date', $apply_date);
$stmt ->bindParam(':apply_type', $apply_type);
$stmt ->bindParam(':case_name', $case_name);
$stmt ->bindParam(':customer', $customer);
$stmt ->bindParam(':manager', $manager);
$stmt ->bindParam(':vat', $vat);
$stmt ->bindParam(':total_price', $total_price);
$stmt ->bindParam(':total_items', $total_items);
$stmt ->bindParam(':buy_fee', $buy_fee);
$stmt ->bindParam(':install_fee', $install_fee);
$stmt ->bindParam(':contact_address', $contact_address);
$stmt ->bindParam(':workdeadline_a', $workdeadline_a);
$stmt ->bindParam(':workdeadline_b', $workdeadline_b);
$stmt ->bindParam(':test_time', $test_time);
$stmt ->bindParam(':freedeadline', $freedeadline);
$stmt ->bindParam(':trade_address', $trade_address);
$stmt ->bindParam(':tradedeadline', $tradedeadline);
$stmt ->bindParam(':secondPayDeadline', $secondPayDeadline);
$stmt ->bindParam(':progress', $progress);
$stmt ->bindParam(':status', $status);
$stmt ->bindParam(':person', $salesman);
$stmt ->bindParam(':personname', $salesmanname);
$stmt ->bindParam(':submit_date', $submit_date);
$stmt ->bindParam(':created_at', $created_at);
$stmt ->bindParam(':created_by', $created_by);
$stmt ->execute();
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid);
$stmt->bindParam(':contractno', $vol_no);
$stmt->bindParam(':sales_man', $salesman);
$stmt->bindParam(':apply_date', $apply_date);
$stmt->bindParam(':apply_type', $apply_type);
$stmt->bindParam(':case_name', $case_name);
$stmt->bindParam(':customer', $customer);
$stmt->bindParam(':manager', $manager);
$stmt->bindParam(':vat', $vat);
$stmt->bindParam(':total_price', $total_price);
$stmt->bindParam(':total_items', $total_items);
$stmt->bindParam(':buy_fee', $buy_fee);
$stmt->bindParam(':install_fee', $install_fee);
$stmt->bindParam(':contact_address', $contact_address);
$stmt->bindParam(':workdeadline_a', $workdeadline_a);
$stmt->bindParam(':workdeadline_b', $workdeadline_b);
$stmt->bindParam(':test_time', $test_time);
$stmt->bindParam(':freedeadline', $freedeadline);
$stmt->bindParam(':trade_address', $trade_address);
$stmt->bindParam(':tradedeadline', $tradedeadline);
$stmt->bindParam(':secondPayDeadline', $secondPayDeadline);
$stmt->bindParam(':progress', $progress);
$stmt->bindParam(':status', $status);
$stmt->bindParam(':person', $salesman);
$stmt->bindParam(':personname', $salesmanname);
$stmt->bindParam(':submit_date', $submit_date);
$stmt->bindParam(':created_at', $created_at);
$stmt->bindParam(':created_by', $created_by);
$stmt->execute();
$contract_apply_id = $conn->lastInsertId();
foreach($pays as $idx=>$pay){
foreach ($pays as $idx => $pay) {
$kind = $idx;
$sql_str = "INSERT INTO contract_new_apply_pays (contract_apply_id, mid, pay_kind, pay_scale, pay_amount, pay_period, condition_date, created_at, created_by) VALUES (:contract_apply_id, :mid, :pay_kind, :pay_scale, :pay_amount, :pay_period, :condition_date, :created_at, :created_by)";
$stmt = $conn -> prepare($sql_str);
$stmt ->bindParam(':contract_apply_id', $contract_apply_id);
$stmt ->bindParam(':mid', $mid);
$stmt ->bindParam(':pay_kind', $kind);
$stmt ->bindParam(':pay_scale', $pay['scale']);
$stmt ->bindParam(':pay_amount', $pay['amount']);
$stmt ->bindParam(':pay_period', $pay['pay_period']);
$stmt ->bindParam(':condition_date', $pay['condition_date']);
$stmt ->bindParam(':created_at', $created_at);
$stmt ->bindParam(':created_by', $created_by);
$stmt ->execute();
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':contract_apply_id', $contract_apply_id);
$stmt->bindParam(':mid', $mid);
$stmt->bindParam(':pay_kind', $kind);
$stmt->bindParam(':pay_scale', $pay['scale']);
$stmt->bindParam(':pay_amount', $pay['amount']);
$stmt->bindParam(':pay_period', $pay['pay_period']);
$stmt->bindParam(':condition_date', $pay['condition_date']);
$stmt->bindParam(':created_at', $created_at);
$stmt->bindParam(':created_by', $created_by);
$stmt->execute();
}
// -----處理檔案上傳 START-----
if(!empty($files)){
// -----處理檔案上傳 START-----
if (!empty($files)) {
$englisharr = range('a', 'z');
$files = $_FILES['files'];
$files = $_FILES['files'];
$newfiles = [];
foreach( $files as $file ){
foreach ($files as $file) {
$i = 0; //新陣列的索引編號
foreach( $file as $key => $val ){
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];
@ -115,107 +117,106 @@ if(isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] == 0
$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', 'docx', 'doc', 'pdf'); //設定允許上傳檔案的類型
}
$max_size = 4096 * 4096; //設定允許上傳檔案容量的最大值(1M)
$allow_ext = array('jpeg', 'jpg', 'png', 'JPG', 'JPEG', 'PNG', 'GIF', 'docx', 'doc', 'pdf'); //設定允許上傳檔案的類型
$path = '../images/contracts_new_files/';
if (!file_exists($path)): mkdir($path); endif;
if (!file_exists($path)) : mkdir($path);
endif;
$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){
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_apply_files (contract_id, contract_type, file_name, file_mime, file_size, created_at, created_by) VALUES (:contract_id, :contract_type, :file_name, :file_mime, :file_size, :created_at, :created_by)";
$stmt = $conn -> prepare($sql_str);
$stmt -> bindParam(':contract_id' ,$contract_apply_id);
$stmt -> bindParam(':contract_type' ,$contract_type);
$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{
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':contract_id', $contract_apply_id);
$stmt->bindParam(':contract_type', $contract_type);
$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) ){
$msg_result .= '第' . ($key + 1) . '個上傳檔案的結果:' . $msg . '<br/>';
$src_name = $path . $file['name'];
if (file_exists($src_name)) {
//副檔名
$extname = pathinfo($src_name, PATHINFO_EXTENSION);
$extname = pathinfo($src_name, PATHINFO_EXTENSION);
//主檔名
$basename = basename($src_name, '.'.$extname);
$basename = basename($src_name, '.' . $extname);
}
}
}
// -----處理檔案上傳 END-----
header("HTTP/1.1 201 success!");
$conn->commit();
}else{
} else {
$sql_str = "UPDATE contract_new_apply SET status = :status, apply_date=:apply_date, apply_type=:apply_type, case_name=:case_name, customer=:customer, manager=:manager, vat=:vat, total_price=:total_price, total_items=:total_items, buy_fee=:buy_fee, install_fee=:install_fee, contact_address=:contact_address, trade_address=:trade_address, workdeadline_a=:workdeadline_a, workdeadline_b=:workdeadline_b, test_time=:test_time, freedeadline=:freedeadline, trade_address=:trade_address, trade_address=:trade_address, tradedeadline=:tradedeadline, secondPayDeadline=:secondPayDeadline, progress=:progress, person=:person, personname=:personname, submit_date=:submit_date, updated_at=:updated_at, updated_by=:updated_by WHERE mid = :mid";
$stmt = $conn -> prepare($sql_str);
$stmt ->bindParam(':mid', $mid);
$stmt ->bindParam(':status', $status);
$stmt ->bindParam(':apply_date', $apply_date);
$stmt ->bindParam(':apply_type', $apply_type);
$stmt ->bindParam(':case_name', $case_name);
$stmt ->bindParam(':customer', $customer);
$stmt ->bindParam(':manager', $manager);
$stmt ->bindParam(':vat', $vat);
$stmt ->bindParam(':total_price', $total_price);
$stmt ->bindParam(':total_items', $total_items);
$stmt ->bindParam(':buy_fee', $buy_fee);
$stmt ->bindParam(':install_fee', $install_fee);
$stmt ->bindParam(':contact_address', $contact_address);
$stmt ->bindParam(':workdeadline_a', $workdeadline_a);
$stmt ->bindParam(':workdeadline_b', $workdeadline_b);
$stmt ->bindParam(':test_time', $test_time);
$stmt ->bindParam(':freedeadline', $freedeadline);
$stmt ->bindParam(':trade_address', $trade_address);
$stmt ->bindParam(':tradedeadline', $tradedeadline);
$stmt ->bindParam(':secondPayDeadline', $secondPayDeadline);
$stmt ->bindParam(':progress', $progress);
$stmt ->bindParam(':person', $salesman);
$stmt ->bindParam(':personname', $salesmanname);
$stmt ->bindParam(':submit_date', $submit_date);
$stmt ->bindParam(':updated_at', $updated_at);
$stmt ->bindParam(':updated_by', $updated_by);
$stmt ->execute();
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid);
$stmt->bindParam(':status', $status);
$stmt->bindParam(':apply_date', $apply_date);
$stmt->bindParam(':apply_type', $apply_type);
$stmt->bindParam(':case_name', $case_name);
$stmt->bindParam(':customer', $customer);
$stmt->bindParam(':manager', $manager);
$stmt->bindParam(':vat', $vat);
$stmt->bindParam(':total_price', $total_price);
$stmt->bindParam(':total_items', $total_items);
$stmt->bindParam(':buy_fee', $buy_fee);
$stmt->bindParam(':install_fee', $install_fee);
$stmt->bindParam(':contact_address', $contact_address);
$stmt->bindParam(':workdeadline_a', $workdeadline_a);
$stmt->bindParam(':workdeadline_b', $workdeadline_b);
$stmt->bindParam(':test_time', $test_time);
$stmt->bindParam(':freedeadline', $freedeadline);
$stmt->bindParam(':trade_address', $trade_address);
$stmt->bindParam(':tradedeadline', $tradedeadline);
$stmt->bindParam(':secondPayDeadline', $secondPayDeadline);
$stmt->bindParam(':progress', $progress);
$stmt->bindParam(':person', $salesman);
$stmt->bindParam(':personname', $salesmanname);
$stmt->bindParam(':submit_date', $submit_date);
$stmt->bindParam(':updated_at', $updated_at);
$stmt->bindParam(':updated_by', $updated_by);
$stmt->execute();
foreach($pays as $idx=>$pay){
foreach ($pays as $idx => $pay) {
$kind = $idx;
$sql_str = "UPDATE contract_new_apply_pays SET pay_scale = :pay_scale, pay_amount = :pay_amount, pay_period = :pay_period, condition_date = :condition_date, updated_at = :updated_at, updated_by = :updated_by WHERE mid = :mid AND pay_kind = :pay_kind";
$stmt = $conn -> prepare($sql_str);
$stmt ->bindParam(':mid', $mid);
$stmt ->bindParam(':pay_kind', $kind);
$stmt ->bindParam(':pay_scale', $pay['scale']);
$stmt ->bindParam(':pay_amount', $pay['amount']);
$stmt ->bindParam(':pay_period', $pay['pay_period']);
$stmt ->bindParam(':condition_date', $pay['condition_date']);
$stmt ->bindParam(':updated_at', $updated_at);
$stmt ->bindParam(':updated_by', $updated_by);
$stmt ->execute();
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid);
$stmt->bindParam(':pay_kind', $kind);
$stmt->bindParam(':pay_scale', $pay['scale']);
$stmt->bindParam(':pay_amount', $pay['amount']);
$stmt->bindParam(':pay_period', $pay['pay_period']);
$stmt->bindParam(':condition_date', $pay['condition_date']);
$stmt->bindParam(':updated_at', $updated_at);
$stmt->bindParam(':updated_by', $updated_by);
$stmt->execute();
}
header("HTTP/1.1 201 success!");
$conn->commit();
}
}catch(PDOException $e){
} catch (PDOException $e) {
$conn->rollback();
header("HTTP/1.1 500 failed!");
echo $e->getMessage();
die('Error!:'.$e->getMessage());
die('Error!:' . $e->getMessage());
}
}
//結案同意
if(isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] == 3) ){
if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] == 3)) {
$status = $_POST['status'];
$vol_no = $_POST['vol_no'];
$contract_new_apply_id = $_POST['contract_new_apply_id'];
@ -224,27 +225,27 @@ if(isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] == 3
$user_id = $_POST['review_person_id'];
$review_date = date('Y-m-d H:i:s');
$conn->beginTransaction();
try{
try {
$sql_str = "UPDATE contract_new_apply SET status = :status, progress = :progress, review_comment=:review_comment, review_person_id=:review_person_id, review_date=:review_date WHERE id = :contract_new_apply_id";
$stmt = $conn -> prepare($sql_str);
$stmt ->bindParam(':status', $status);
$stmt ->bindParam(':progress', $progress);
$stmt ->bindParam(':contract_new_apply_id', $contract_new_apply_id);
$stmt ->bindParam(':review_comment', $review_comment);
$stmt ->bindParam(':review_person_id', $user_id);
$stmt ->bindParam(':review_date', $review_date);
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':status', $status);
$stmt->bindParam(':progress', $progress);
$stmt->bindParam(':contract_new_apply_id', $contract_new_apply_id);
$stmt->bindParam(':review_comment', $review_comment);
$stmt->bindParam(':review_person_id', $user_id);
$stmt->bindParam(':review_date', $review_date);
$stmt->execute();
header("HTTP/1.1 200 success!");
$conn->commit();
}catch(PDOException $e){
} catch (PDOException $e) {
$conn->rollback();
header("HTTP/1.1 500 failed!");
echo $e->getMessage();
die('Error!:'.$e->getMessage());
die('Error!:' . $e->getMessage());
}
}
//結案不同意(退回)
if(isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] == 2) ){
if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] == 2)) {
$status = $_POST['status'];
$vol_no = $_POST['vol_no'];
$contract_new_apply_id = $_POST['contract_new_apply_id'];
@ -253,22 +254,22 @@ if(isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] == 2
$user_id = $_POST['review_person_id'];
$review_date = date('Y-m-d H:i:s');
$conn->beginTransaction();
try{
try {
$sql_str = "UPDATE contract_new_apply SET status = :status, progress = :progress, review_comment=:review_comment, review_person_id=:review_person_id, review_date=:review_date WHERE id = :contract_new_apply_id";
$stmt = $conn -> prepare($sql_str);
$stmt ->bindParam(':status', $status);
$stmt ->bindParam(':progress', $progress);
$stmt ->bindParam(':contract_new_apply_id', $contract_new_apply_id);
$stmt ->bindParam(':review_comment', $review_comment);
$stmt ->bindParam(':review_person_id', $user_id);
$stmt ->bindParam(':review_date', $review_date);
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':status', $status);
$stmt->bindParam(':progress', $progress);
$stmt->bindParam(':contract_new_apply_id', $contract_new_apply_id);
$stmt->bindParam(':review_comment', $review_comment);
$stmt->bindParam(':review_person_id', $user_id);
$stmt->bindParam(':review_date', $review_date);
$stmt->execute();
header("HTTP/1.1 200 success!");
$conn->commit();
}catch(PDOException $e){
} catch (PDOException $e) {
$conn->rollback();
header("HTTP/1.1 500 failed!");
echo $e->getMessage();
die('Error!:'.$e->getMessage());
die('Error!:' . $e->getMessage());
}
}
}

Loading…
Cancel
Save