Browse Source

1115 M0174價審

main
10994015 1 year ago
parent
commit
e64dcd1aaf
  1. 8
      wms/contract/contract-download.php
  2. 204
      wms/contract/insertMi.php
  3. 15
      wms/contract/js/alpine.js
  4. 2
      wms/crm/crmm03-edit.php
  5. 2
      wms/crm/crmm04-edit.php
  6. 11
      wms/mkt/assets/js/alpine.js
  7. 63
      wms/mkt/pricereview-check.php
  8. 68
      wms/mkt/pricereview-check2.php
  9. 1
      wms/mkt/pricereview-create.php
  10. 5
      wms/mkt/pricereview-index.php
  11. 3
      wms/mkt/pricereview_mi-api.php

8
wms/contract/contract-download.php

@ -427,11 +427,11 @@ if (isset($_GET['id']) && $_GET['id'] != "") {
const partyAcompany = <?php echo json_encode($contract['customer']); ?>;
const partyAcontractno = <?php echo json_encode($contract['contractno']); ?>;
const partyAaddress = <?php echo json_encode($contract['contact_address']); ?>;
const totalPrice = <?php echo $contract['total_price']; ?>;
const totalPrice = <?php echo $contract['total_price']=='' ? 0 : $contract['total_price']; ?>;
const totalInstallPrice = <?php echo $install_total_price; ?>;
const totalBuyPrice = <?php echo $buy_total_price; ?>;
const secondPayDeadline = <?php echo $contract['secondPayDeadline']; ?>;
const buyfill1 = <?php echo $contract['tradedeadline']; ?>;
const secondPayDeadline = "<?php echo $contract['secondPayDeadline'] ; ?>";
const buyfill1 = '<?php echo $contract['tradedeadline']; ?>';
const installfill1 = "<?php echo $contract['test_time']; ?>";
const installfill2 = "<?php echo $contract['freedeadline']; ?>";
const buyArr = [...<?php echo json_encode($buyArr); ?>];
@ -440,7 +440,7 @@ if (isset($_GET['id']) && $_GET['id'] != "") {
let buy_pay_text = ''
const chineseArr = ['零', '一', '二', '三', '四', '五', '六', '七']
const bigChineseArr = ['零', '壹', '貳', '參', '肆', '伍', '陸', '柒', '捌', '玖', '拾'];
const num = <?php echo $qty; ?>;
const num = <?php echo $qty=='' ? 0 : $qty; ?>;
const people = <?php echo $noteArr[1]; ?>;
const floor = <?php echo $noteArr[2]; ?>;
const speed = <?php echo $noteArr[3]; ?>;

204
wms/contract/insertMi.php

@ -0,0 +1,204 @@
<?php
require_once('./conn.php');
require 'vendor/autoload.php';
ini_set('date.timezone', 'Asia/Taipei');
$id = $_GET['miid'];
use PhpOffice\PhpSpreadsheet\IOFactory;
// 指定要讀取的 Excel 文件
$filePath = './mi/mi' . $id . '.xlsx';
try {
$spreadsheet = IOFactory::load($filePath);
} catch (\PhpOffice\PhpSpreadsheet\Reader\Exception $e) {
die('Error loading file: ' . $e->getMessage());
}
// 獲取活動工作表
$sheet = $spreadsheet->getActiveSheet();
$create_at = date('Y-m-d H:i:s');
$sql_str = "INSERT INTO elevator_mi_option (elevator_type, model_no, min_weight, max_weight, min_speed, max_speed, min_floors, max_floors, base_floor, purchase_cost, material_plus, design_hour, export_fee, equip_profit, customs_shipping, unloading, transport_site, install_price, install_plus, install_coef, trial_price, trial_plus, trial_coef, free1y, crane, wooden_box, consume, consumables, quotation_no, create_at)
VALUES (:elevator_type, :model_no, :min_weight, :max_weight, :min_speed, :max_speed, :min_floors, :max_floors, :base_floor, :purchase_cost, :material_plus, :design_hour, :export_fee, :equip_profit, :customs_shipping, :unloading, :transport_site, :install_price, :install_plus, :install_coef, :trial_price, :trial_plus, :trial_coef, :free1y, :crane, :wooden_box, :consume, :consumables, :quotation_no, :create_at)";
foreach ($sheet->getRowIterator() as $key => $row) {
// 獲得單元格迭代器
$cellIterator = $row->getCellIterator();
$cellIterator->setIterateOnlyExistingCells(false); // This loops through all cells,
// even if a cell value is not set.
// By default, only cells that have a value set will be iterated.
foreach ($cellIterator as $idx => $cell) {
if ($cell !== null) {
// 打印單元格數據
// echo $cell->getValue() . '///';
}
if($idx == "A"){
$elevator_type = $cell->getValue();
echo $elevator_type;
//電梯機種
}
elseif ($idx == 'B') {
$model_no = $cell->getValue();
echo $model_no;
//產品型號
} elseif ($idx == 'C') {
$min_weight = $cell->getValue();
echo $min_weight;
//最低載重
} elseif ($idx == 'D') {
$max_weight = $cell->getValue();
$max_weight = $min_weight;
echo $max_weight;
//最高載重
} elseif ($idx == 'E') {
$min_speed = $cell->getValue();
echo $min_speed;
//最低速度
} elseif ($idx == 'F') {
$max_speed = $cell->getValue();
$max_speed = $min_speed;
echo $max_speed;
//最高速度
} elseif ($idx == 'G') {
$min_floors = '2';
echo $min_floors;
//樓層開始
} elseif ($idx == 'H') {
$max_floors = $cell->getValue();
$max_floors = (int)$min_speed / 3;
echo $max_floors;
//樓層結束
}elseif ($idx == 'I') {
$base_floor = $cell->getValue();
echo $base_floor;
//基準層
}elseif ($idx == 'J') {
$purchase_cost = $cell->getValue();
echo $purchase_cost;
//基準採購成本
}elseif ($idx == 'K') {
$material_plus = $cell->getValue();
echo $material_plus;
//+1停材料費
}elseif ($idx == 'L') {
$design_hour = $cell->getValue();
echo $design_hour;
//設計人工(小時)
}elseif ($idx == 'M') {
$export_fee = $cell->getValue();
echo $export_fee;
//出口費用
}elseif ($idx == 'N') {
$equip_profit = $cell->getValue();
echo $equip_profit;
//利潤
}elseif ($idx == 'O') {
$customs_shipping = $cell->getValue();
echo $customs_shipping;
//報關+運輸
}elseif ($idx == 'P') {
$unloading = $cell->getValue();
echo $unloading;
//工廠卸貨
}elseif ($idx == 'Q') {
$transport_site = $cell->getValue();
echo $transport_site;
//運輸至工地
}elseif ($idx == 'R') {
$install_price = $cell->getValue();
echo $install_price;
//安裝基價
}elseif ($idx == 'S') {
$install_plus = $cell->getValue();
echo $install_plus;
//+1停安裝費
}elseif ($idx == 'T') {
$install_coef = $cell->getValue();
echo $install_coef;
//+1停安裝係數
}elseif ($idx == 'U') {
$trial_price = $cell->getValue();
echo $trial_price;
//試車費用
}elseif ($idx == 'V') {
$trial_plus = $cell->getValue();
echo $trial_plus;
//+1停試車價
}elseif ($idx == 'W') {
$trial_coef = $cell->getValue();
echo $trial_coef;
//+1停試車係數
}elseif ($idx == 'X') {
$free1y = $cell->getValue();
echo $free1y;
//一年免保費
}elseif ($idx == 'Y') {
$crane = $cell->getValue();
echo $crane;
//卸貨起吊費
}elseif ($idx == 'Z') {
$wooden_box = $cell->getValue();
echo $wooden_box;
//木箱清運
}elseif ($idx == 'AA') {
$consume = $cell->getValue();
echo $consume;
//工具消耗
}elseif ($idx == 'AB') {
$consumables = $cell->getValue();
echo $consumables;
//耗材
}
}
echo "<br>"; // 換行,以分隔不同的行
$status = "Y";
if (isset($_GET['miid'])) {
try {
$quotation_no = 'Q2401002';
//VALUES (:elevator_type, :model_no, :min_weight, :max_weight, :min_speed, :max_speed, :min_floors, :max_floors, :base_floor, :purchase_cost, :material_plus, :design_hour, :export_fee, :equip_profit, :customs_shipping, :unloading, :transport_site, :install_price, :install_plus, :install_coef, :trial_price, :trial_plus, :trial_coef, :free1y, :crane, :wooden_box, :consume, :consumables, :option_price, :quotation_no, :create_at)";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':elevator_type', $elevator_type);
$stmt->bindParam(':model_no', $model_no);
$stmt->bindParam(':min_weight', $min_weight);
$stmt->bindParam(':max_weight', $max_weight);
$stmt->bindParam(':min_speed', $min_speed);
$stmt->bindParam(':max_speed', $max_speed);
$stmt->bindParam(':min_floors', $min_floors);
$stmt->bindParam(':max_floors', $max_floors);
$stmt->bindParam(':base_floor', $base_floor);
$stmt->bindParam(':purchase_cost', $purchase_cost);
$stmt->bindParam(':material_plus', $material_plus);
$stmt->bindParam(':design_hour', $design_hour);
$stmt->bindParam(':export_fee', $export_fee);
$stmt->bindParam(':equip_profit', $equip_profit);
$stmt->bindParam(':customs_shipping', $customs_shipping);
$stmt->bindParam(':unloading', $unloading);
$stmt->bindParam(':transport_site', $transport_site);
$stmt->bindParam(':install_price', $install_price);
$stmt->bindParam(':install_plus', $install_plus);
$stmt->bindParam(':install_coef', $install_coef);
$stmt->bindParam(':trial_price', $trial_price);
$stmt->bindParam(':trial_plus', $trial_plus);
$stmt->bindParam(':trial_coef', $trial_coef);
$stmt->bindParam(':free1y', $free1y);
$stmt->bindParam(':crane', $crane);
$stmt->bindParam(':wooden_box', $wooden_box);
$stmt->bindParam(':consume', $consume);
$stmt->bindParam(':consumables', $consumables);
$stmt->bindParam(':quotation_no', $quotation_no);
$stmt->bindParam(':create_at', $create_at);
// 遍歷當前行的每一個單元格
$stmt->execute();
} catch (PDOException $e) {
echo $e->getMessage();
die('Error!:' . $e->getMessage());
}
}
}

15
wms/contract/js/alpine.js

@ -734,13 +734,18 @@ const contractDownload = () => {
this.standardData.list.plaintext[10].text = '電梯保養:<br>一、乙方完工交車後,期後&nbsp;' + this.installfill2 + '&nbsp;個月內應負責免費定期保養,及履行免費保固,於免費保養期間屆至後,雙方再協商嗣後保養事宜。<br>二、如因可歸責乙方因素致安裝產品有所瑕疵時,乙方應負責修復或修繕,惟非因乙方因素致有修復產品需要時,乙方仍負責修復或修繕,惟得向甲方酌收基本材料與人工費用。<br>三、另依法令規定,非經竣工檢查合格後取得使用許可證之電梯,依法不得使用。'
this.onstandardViewData.list.plaintext[10].text = '電梯保養:<br>一、乙方完工交車後,期後&nbsp;' + this.installfill2 + '&nbsp;個月內應負責免費定期保養,及履行免費保固,於免費保養期間屆至後,雙方再協商嗣後保養事宜。<br>二、如因可歸責乙方因素致安裝產品有所瑕疵時,乙方應負責修復或修繕,惟非因乙方因素致有修復產品需要時,乙方仍負責修復或修繕,惟得向甲方酌收基本材料與人工費用。<br>三、另依法令規定,非經竣工檢查合格後取得使用許可證之電梯,依法不得使用。'
},
errorFn(){
alert("資料有誤,請先填完整資料進行保存")
},
sendBuyInputFn() {
if (this.buyfill1 == '') {
alert('請輸入交貨期限');
// alert('請輸入交貨期限');
this.errorFn();
return;
}
if (this.buyfill1 < 1) {
alert('交貨期限不得低於1日');
// alert('交貨期限不得低於1日');
this.errorFn();
return;
}
if (buyArr[1].installment == 2) {
@ -766,11 +771,13 @@ const contractDownload = () => {
sendBuyInputKeyupFn(e) {
if (e.keyCode !== 13) return
if (this.buyfill1 == '') {
alert('請輸入交貨期限');
// alert('請輸入交貨期限');
this.errorFn();
return;
}
if (this.buyfill1 < 1) {
alert('交貨期限不得低於1日');
// alert('交貨期限不得低於1日');
this.errorFn()
return;
}
if (buyArr[1].installment == 2) {

2
wms/crm/crmm03-edit.php

@ -18,7 +18,7 @@ $customer_source_opt = DB::result($sql);
$sql = "select code_name value ,content label from code where field_name='elevator_kind'";
$elevator_kind_opt = DB::result($sql);
#4.營業員
$sql = "select employee_no value ,name label from employee where depart_no in ('320','311','312','313','314','511','512','513','514','322','515')";
$sql = "select employee_no value ,name label from employee where depart_no in ('320','311','312','313','314','315','511','512','513','514','322','515')";
$salesman_opt = DB::result($sql);
#5.有望客戶狀態
$sql = "select code_name value ,content label from code where field_name='hope_customer_status'";

2
wms/crm/crmm04-edit.php

@ -18,7 +18,7 @@ $customer_source_opt = DB::result($sql);
$sql = "select code_name value ,content label from code where field_name='elevator_kind'";
$elevator_kind_opt = DB::result($sql);
#4.營業員
$sql = "select employee_no value ,name label from employee where depart_no in ('320','311','312','313','314','511','512','513','514')";
$sql = "select employee_no value ,name label from employee where depart_no in ('320','311','312','313','314','315','511','512','513','514','515')";
$salesman_opt = DB::result($sql);
#5.有望客戶狀態
$sql = "select code_name value ,content label from code where field_name='hope_customer_status'";

11
wms/mkt/assets/js/alpine.js

@ -13,7 +13,7 @@ const priceOptionIndex = ()=>{
options_arr: {
1:'標配',
2:'選配',
3:'加價'
3:'選配'
},
btntype:1,
buttons:[],
@ -134,7 +134,7 @@ const priceOptionSelect = ()=>{
options_arr: {
1:'標配',
2:'選配',
3:'加價'
3:'選配'
},
btntype:1,
buttons:[],
@ -206,7 +206,7 @@ const pricereviewOptionSelect = ()=>{
optionalArr: {
1:'標配',
2:'選配',
3:'加價',
3:'選配',
},
searchtext:'',
kind:0,
@ -281,14 +281,15 @@ const pricereviewOptionSelect = ()=>{
},
searchOptions(e){
this.reloadOptions();
let val = e.target.value.toLowerCase()
// let val = e.target.value.toLowerCase()
let val = this.searchtext.toLowerCase()
this.options = (this.options).filter(option=>{
if(option.group_name == null) option.group_name = ''
if(option.spec == null) option.spec = ''
if(option.memo == null) option.memo = ''
if(option.price == null) option.price = 0
if(option.unit == null) option.unit = ''
return option.group_name.includes(val) || option.memo.toLowerCase().includes(val) || option.spec.toLowerCase().includes(val) || option.unit.includes(val) || String(option.price).includes(val)
return option.group_name.toLowerCase().includes(val) || option.memo.toLowerCase().includes(val) || option.spec.toLowerCase().includes(val) || option.unit.includes(val) || String(option.price).includes(val)
})
}

63
wms/mkt/pricereview-check.php

@ -244,6 +244,67 @@ foreach ($res as $data) {
$pay_all_amount += $row_p["pay_amount"];
}
mysqli_free_result($res_p);
function getMI($id){
$specarr = [];
$elno = [];
require_once("./conn.php");
$sql_str = "SELECT * FROM pricereview_item WHERE mid = :id";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':id', $id);
$stmt->execute();
$price_items = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach($price_items as $item){
if($item['item_group'] == "A"){
$openfn = trim(explode("-", $item['item_spec'])[2]);
$openname = "";
$speed = "";
if(str_contains($openfn, "2U")){
$speed = str_replace("2U", "", $openfn);
$openname = "2U";
}elseif(str_contains($openfn, "4PCO")){
$speed = str_replace("4PCO","", $openfn);
$openname = "4PCO";
}elseif(str_contains($openfn, "6PCO")){
$speed = str_replace("6PCO","", $openfn);
$openname = "6PCO";
}elseif(str_contains($openfn, "2S")){
$speed = str_replace("2S","", $openfn);
$openname = "2S";
}elseif(str_contains($openfn, "CO")){
$speed = str_replace("CO","", $openfn);
$openname = "CO";
}else{
}
// specarr[] = [trim(explode("-", $item['item_spec'])[0]), explode("*", explode("-", $item['item_spec'])[1])[1]];
$specarr[] = [trim(explode("-", $item['item_spec'])[0]), explode("*", trim(explode("-", $item['item_spec'])[1]))[0], explode("*", trim(explode("-", $item['item_spec'])[1]))[1], $openname, $speed, $item['item_weight']];
$elno[] = trim("'".explode("-", $item['item_spec'])[0]. "'");
}
}
$quotation_no = "Q2401002";
$jsonel = implode(",", $elno);
$sql_str = "SELECT * FROM elevator_mi_option WHERE elevator_type IN ($jsonel) AND quotation_no = :quotation_no";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':quotation_no', $quotation_no);
$stmt->execute();
$output_el_options = $stmt->fetchAll(PDO::FETCH_ASSOC);
$el_options = [];
foreach($output_el_options as $el){
foreach($specarr as $spec){
if($el['min_weight'] == $spec['5'] && $el['min_speed'] == $spec['4']){
$el_options[] = $el;
}
}
}
}
getMI($id);
?>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script>
@ -271,6 +332,7 @@ foreach ($res as $data) {
}
console.log(data.content);
Object.keys(data.content).forEach(function(k) {
console.log(data.content);
//console.log(data.content[k][0]);
// 有值表示先前已寫入MI
if ($("#tb1").find("input[name=mi_fix]").eq(k).val() == "") {
@ -490,6 +552,7 @@ foreach ($res as $data) {
<?php
$item_amt_A_all = 0;
$idx = 1;
print_r($item_arr);
foreach ($item_arr as $item_no => $val) {
$item_amt_A_all += $val["item_price_bp"];
if ($viewmi) {

68
wms/mkt/pricereview-check2.php

@ -0,0 +1,68 @@
<?php
include "../header.php";
$id = $_GET['id'];
function getMI($id){
$specarr = [];
$elno = [];
require_once("./conn.php");
$sql_str = "SELECT * FROM pricereview_item WHERE mid = :id";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':id', $id);
$stmt->execute();
$price_items = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach($price_items as $item){
if($item['item_group'] == "A"){
$openfn = trim(explode("-", $item['item_spec'])[2]);
$openname = "";
$speed = "";
if(str_contains($openfn, "2U")){
$speed = str_replace("2U", "", $openfn);
$openname = "2U";
}elseif(str_contains($openfn, "4PCO")){
$speed = str_replace("4PCO","", $openfn);
$openname = "4PCO";
}elseif(str_contains($openfn, "6PCO")){
$speed = str_replace("6PCO","", $openfn);
$openname = "6PCO";
}elseif(str_contains($openfn, "2S")){
$speed = str_replace("2S","", $openfn);
$openname = "2S";
}elseif(str_contains($openfn, "CO")){
$speed = str_replace("CO","", $openfn);
$openname = "CO";
}else{
}
// specarr[] = [trim(explode("-", $item['item_spec'])[0]), explode("*", explode("-", $item['item_spec'])[1])[1]];
$specarr[] = [trim(explode("-", $item['item_spec'])[0]), explode("*", trim(explode("-", $item['item_spec'])[1]))[0], explode("*", trim(explode("-", $item['item_spec'])[1]))[1], $openname, $speed, $item['item_weight']];
$elno[] = trim("'".explode("-", $item['item_spec'])[0]. "'");
}
}
$quotation_no = "Q2401002";
$jsonel = implode(",", $elno);
$sql_str = "SELECT * FROM elevator_mi_option WHERE elevator_type IN ($jsonel) AND quotation_no = :quotation_no";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':quotation_no', $quotation_no);
$stmt->execute();
$output_el_options = $stmt->fetchAll(PDO::FETCH_ASSOC);
$el_options = [];
foreach($output_el_options as $el){
foreach($specarr as $spec){
if($el['min_weight'] == $spec['5'] && $el['min_speed'] == $spec['4']){
$el_options[] = $el;
}
}
}
print_r($el_options);
}
getMI($id);
?>

1
wms/mkt/pricereview-create.php

@ -753,6 +753,7 @@ $option_str .= "</tbody></table>";
var jobj = $(this); // 父視窗
$("#optionModal .modal-body td").unbind().click(function() {
var pobj = $(this).closest('td').parent();
console.log(1111111111111);
console.log(jobj.html(pobj.find('td').eq(0).html() + ' ' + pobj.find('td').eq(1).html()));
console.log(pobj.find('td').eq(0).html() + pobj.find('td').eq(2).html() + ' ' + pobj.find('td').eq(1).html());
jobj.html(pobj.find('td').eq(0).html() + ' ' + pobj.find('td').eq(1).html() + '<br />(' + pobj.find('td').eq(2).html() + ')');

5
wms/mkt/pricereview-index.php

@ -557,9 +557,12 @@ if ($data) :
<span style="font-size:13px;font-weight:600">--</span>
<?php endif; ?>
<!-- 工號M0107、M0174有所有權限 -->
<?php if (($data['status'] === 'YY' && $data['applystatus'] == 3 && ($user_id == "M0107" || $user_id == "M0060" || $user_id == "M0175" || $user_id === "TEST02")) || $user_id == "M0174" || $user_id == 'M0225') : ?>
<?php if (false &&($data['status'] === 'YY' && $data['applystatus'] == 3 && ($user_id == "M0107" || $user_id == "M0060" || $user_id == "M0175" || $user_id === "TEST02")) || $user_id == "M0174" || $user_id == 'M0225') : ?>
<a class="applybtn" href="../contract/contract-download.php?id=<?php echo $data['id'] . '&' . $para ?>">下載</a>
<?php endif; ?>
<?php if($data['status'] === 'YY'): ?>
<a class="applybtn" href="../contract/contract-download.php?id=<?php echo $data['id'] . '&' . $para ?>">下載草稿</a>
<?php endif ;?>
</td>
</tr>
<?php endforeach; ?>

3
wms/mkt/pricereview_mi-api.php

@ -178,7 +178,7 @@ try {
//print_r($opt_nosel_id_arr);
//print_r($mn_elev_arr);
//print_r($ex_arr);exit;
// echo json_encode($elev_arr);
foreach ($elev_arr as $item_no => $v) {
// 電梯MI
$sql2 = "select o.*, r.* from elevator_mi_option o, elevator_quotation_rule r ";
@ -189,6 +189,7 @@ try {
if ($v["etype"] == "MAQ100" || $v["etype"] == "MAP100") {
$sql2 .= "and (o.model_no = '" . $v["persons"] . "') ";
}
// echo $sql2;
$res_e = mysqli_query($link, $sql2);
if ($row_e = mysqli_fetch_assoc($res_e)) {
// 加價:先不納入

Loading…
Cancel
Save