Browse Source

新梯價審付款辦法修改

main
Cheng 1 year ago
parent
commit
601934ed62
  1. 154
      mkt/pricereview-create.php
  2. 1287
      wms/mkt/pricereview-create.php

154
mkt/pricereview-create.php

@ -5,31 +5,31 @@ include "header.php";
$data = array(); $data = array();
?> ?>
<script> <script>
function commafy(num) { function commafy(num) {
num = num + ""; num = num + "";
var re = /(-?\d+)(\d{3})/ var re = /(-?\d+)(\d{3})/
while (re.test(num)) { while (re.test(num)) {
num = num.replace(re, "$1,$2") num = num.replace(re, "$1,$2")
} }
return num; return num;
} }
function dataFormat() { function dataFormat() {
var amtAll = 0; var amtAll = 0;
$("input[name='item_price_bp']").each(function(){ $("input[name='item_price_bp']").each(function() {
amtAll += Number($(this).val().replace(/[,]+/g,"")); amtAll += Number($(this).val().replace(/[,]+/g, ""));
}); });
$('#amt').val(commafy(amtAll)); $('#amt').val(commafy(amtAll));
$('#price_lowest').val(commafy(amtAll)); $('#price_lowest').val(commafy(amtAll));
$('#price_total_broken').val(commafy($('#price_total').val().replace(/[,]+/g,"")-$('#price_lowest').val().replace(/[,]+/g,""))); $('#price_total_broken').val(commafy($('#price_total').val().replace(/[,]+/g, "") - $('#price_lowest').val().replace(/[,]+/g, "")));
var qt = parseInt($('#qty_total').val().replace(/[,]+/g,"")) || 0; var qt = parseInt($('#qty_total').val().replace(/[,]+/g, "")) || 0;
if (qt) { if (qt) {
$('#price_broken').val(commafy(($('#price_total_broken').val().replace(/[,]+/g,"")/qt).toFixed(2))); $('#price_broken').val(commafy(($('#price_total_broken').val().replace(/[,]+/g, "") / qt).toFixed(2)));
}
$('#price_rate').val((($('#price_total').val().replace(/[,]+/g, "") / $('#price_lowest').val().replace(/[,]+/g, "")) * 100).toFixed(2));
} }
$('#price_rate').val((($('#price_total').val().replace(/[,]+/g,"")/$('#price_lowest').val().replace(/[,]+/g,""))*100).toFixed(2));
}
function selFacil(o) { function selFacil(o) {
var fp = o.parent().parent(); var fp = o.parent().parent();
var f1 = fp.find('select[name=fp_kind]').val(); var f1 = fp.find('select[name=fp_kind]').val();
var f2 = fp.find('select[name=fp_seat]').val(); var f2 = fp.find('select[name=fp_seat]').val();
@ -42,8 +42,8 @@ function selFacil(o) {
var formdata = new FormData(); var formdata = new FormData();
formdata.append('fval', fAry); formdata.append('fval', fAry);
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){ xhr.onreadystatechange = function() {
if(this.readyState == 4 && this.status == 200){ if (this.readyState == 4 && this.status == 200) {
data = JSON.parse(this.responseText); data = JSON.parse(this.responseText);
if (data.st == 'err') { if (data.st == 'err') {
alert(data.err); alert(data.err);
@ -57,16 +57,16 @@ function selFacil(o) {
fp.find('input[name=item_group]').val(data.group); fp.find('input[name=item_group]').val(data.group);
var cntAll = 0; var cntAll = 0;
$("input[name='item_qty']").each(function(){ $("input[name='item_qty']").each(function() {
cntAll += Number($(this).val().replace(/[,]+/g,"")); cntAll += Number($(this).val().replace(/[,]+/g, ""));
}); });
$('#cnt').val(commafy(cntAll)); $('#cnt').val(commafy(cntAll));
$('#qty_total').val(commafy(cntAll)); $('#qty_total').val(commafy(cntAll));
var pl = parseInt($('#price_lowest').val().replace(/[,]+/g,"")) || 0; var pl = parseInt($('#price_lowest').val().replace(/[,]+/g, "")) || 0;
if (pl) { if (pl) {
$('#price_rate').val(commafy((($('#price_total').val().replace(/[,]+/g,"")/pl)*100).toFixed(2))); $('#price_rate').val(commafy((($('#price_total').val().replace(/[,]+/g, "") / pl) * 100).toFixed(2)));
} }
$('#price_broken').val(commafy(($('#price_total_broken').val().replace(/[,]+/g,"")/$('#qty_total').val()).toFixed(2))); $('#price_broken').val(commafy(($('#price_total_broken').val().replace(/[,]+/g, "") / $('#qty_total').val()).toFixed(2)));
dataFormat(); dataFormat();
/* /*
@ -85,13 +85,13 @@ function selFacil(o) {
*/ */
} }
} }
xhr.open('POST','/mkt/pricereview-facility.php',true); xhr.open('POST', '/mkt/pricereview-facility.php', true);
xhr.send(formdata); xhr.send(formdata);
} }
} }
function tt(){ function tt() {
$("input[name='item_price_bp']").keyup(function(){ $("input[name='item_price_bp']").keyup(function() {
dataFormat(); dataFormat();
/* /*
var amtAll = 0; var amtAll = 0;
@ -108,12 +108,12 @@ function tt(){
$('#price_rate').val((($('#price_total').val().replace(/[,]+/g,"")/$('#price_lowest').val().replace(/[,]+/g,""))*100).toFixed(2)); $('#price_rate').val((($('#price_total').val().replace(/[,]+/g,"")/$('#price_lowest').val().replace(/[,]+/g,""))*100).toFixed(2));
*/ */
}); });
} }
$(function(){ $(function() {
$('#tb1').on('click', 'input[name=fp_numberofstop], input[name=item_qty]', function(){ $('#tb1').on('click', 'input[name=fp_numberofstop], input[name=item_qty]', function() {
//$("input[name=item_qty]").unbind().keyup(function(){ //$("input[name=item_qty]").unbind().keyup(function(){
$(this).unbind().keyup(function(){ $(this).unbind().keyup(function() {
selFacil($(this)); selFacil($(this));
/* /*
var fp = $(this).parent().parent(); var fp = $(this).parent().parent();
@ -161,16 +161,22 @@ $(function(){
}); });
}); });
$('#tb1').on('click', 'select[name=fp_kind], select[name=fp_seat], select[name=fp_speed]', function(){ $('#tb1').on('click', 'select[name=fp_kind], select[name=fp_seat], select[name=fp_speed]', function() {
$(this).unbind().change(function(){ $(this).unbind().change(function() {
selFacil($(this)); selFacil($(this));
}); });
}); });
$('#deposit_rate').keyup(function(){ $(this).val($(this).val().replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')); }); $('#deposit_rate').keyup(function() {
$('#keep_rate').keyup(function(){ $(this).val($(this).val().replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')); }); $(this).val($(this).val().replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1'));
$('#warranty_rate').keyup(function(){ $(this).val($(this).val().replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')); }); });
/* $('#keep_rate').keyup(function() {
$(this).val($(this).val().replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1'));
});
$('#warranty_rate').keyup(function() {
$(this).val($(this).val().replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1'));
});
/*
// for 動態表格的作法:event delegation // for 動態表格的作法:event delegation
$('#tb1').on('click', $("input[name='item_qty']"), function(){ $('#tb1').on('click', $("input[name='item_qty']"), function(){
$("input[name='item_qty']").keyup(function(){ $("input[name='item_qty']").keyup(function(){
@ -183,7 +189,7 @@ $(function(){
$('#cnt').val(commafy(cntAll)); $('#cnt').val(commafy(cntAll));
$('#qty_total').val(commafy(cntAll)); $('#qty_total').val(commafy(cntAll));
// $(this).parent().next().find('input[name=item_price_bp]').val($(this).parent().parent().find('input[name=item_price_bp_base').val()*$(this).val()); // $(this).parent().next().find('input[name=item_price_bp]').val($(this).parent().parent().find('input[name=item_price_bp_base').val()*$(this).val());
var amtAll = 0; var amtAll = 0;
$("input[name='item_price_bp']").each(function(){ $("input[name='item_price_bp']").each(function(){
amtAll += Number($(this).val().replace(/[,]+/g,"")); amtAll += Number($(this).val().replace(/[,]+/g,""));
@ -198,41 +204,41 @@ $(function(){
$('#price_broken').val(commafy(($('#price_total_broken').val().replace(/[,]+/g,"")/$('#qty_total').val()).toFixed(2))); $('#price_broken').val(commafy(($('#price_total_broken').val().replace(/[,]+/g,"")/$('#qty_total').val()).toFixed(2)));
}); });
}); });
*/ */
// $('#tb1').on('click', tt); // $('#tb1').on('click', tt);
$('#tb1').on('keyup', 'input[name=item_price_bp]', function(){ $('#tb1').on('keyup', 'input[name=item_price_bp]', function() {
$(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ","));
dataFormat(); dataFormat();
}); });
$('#tb1').on('keyup', 'input[name=fp_numberofstop], input[name=item_qty], input[name=item_price]', function(){ $('#tb1').on('keyup', 'input[name=fp_numberofstop], input[name=item_qty], input[name=item_price]', function() {
//$("input[name='item_price']").keyup(function(){ //$("input[name='item_price']").keyup(function(){
$(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ","));
//}); //});
}); });
$('#tb1').on('keyup', 'input[name=pv_rate]', function(){ $('#tb1').on('keyup', 'input[name=pv_rate]', function() {
$(this).val($(this).val().replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')); $(this).val($(this).val().replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1'));
}); });
$("#price_total").on("input", function(){ $("#price_total").on("input", function() {
var pt = parseInt($(this).val().replace(/[,]+/g,"")) || 0; var pt = parseInt($(this).val().replace(/[,]+/g, "")) || 0;
$(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")); $(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ","));
//var pl = ('NaN'==$('#price_lowest').val() || ''==$('#price_lowest').val().trim())?0:parseInt($('#price_lowest').val()); //var pl = ('NaN'==$('#price_lowest').val() || ''==$('#price_lowest').val().trim())?0:parseInt($('#price_lowest').val());
var pl = parseInt($('#price_lowest').val().replace(/[,]+/g,"")) || 0; var pl = parseInt($('#price_lowest').val().replace(/[,]+/g, "")) || 0;
$('#price_total_broken').val(commafy(pt-pl)); $('#price_total_broken').val(commafy(pt - pl));
if (pl) { if (pl) {
$('#price_rate').val(((pt/pl)*100).toFixed(2)); $('#price_rate').val(((pt / pl) * 100).toFixed(2));
} }
var qt = parseInt($('#qty_total').val().replace(/[,]+/g,"")) || 0; var qt = parseInt($('#qty_total').val().replace(/[,]+/g, "")) || 0;
if (qt) { if (qt) {
$('#price_broken').val(commafy((parseInt($('#price_total_broken').val().replace(/[,]+/g,""))/qt).toFixed(0))); $('#price_broken').val(commafy((parseInt($('#price_total_broken').val().replace(/[,]+/g, "")) / qt).toFixed(0)));
} }
$('#pay1').html(commafy((pt*0.2).toFixed(0))); $('#pay1').html(commafy((pt * 0.2).toFixed(0)));
$('#pay2').html(commafy((pt*0.4).toFixed(0))); $('#pay2').html(commafy((pt * 0.4).toFixed(0)));
$('#pay3').html(commafy((pt*0.2).toFixed(0))); $('#pay3').html(commafy((pt * 0.2).toFixed(0)));
$('#pay4').html(commafy((pt*0.1).toFixed(0))); $('#pay4').html(commafy((pt * 0.1).toFixed(0)));
$('#pay5').html(commafy((pt*0.1).toFixed(0))); $('#pay5').html(commafy((pt * 0.1).toFixed(0)));
}); });
$('#btnadd').click(function(){ $('#btnadd').click(function() {
/* /*
var facilTemp = ''; var facilTemp = '';
facilTemp+= '<tr name="facil_templ">'; facilTemp+= '<tr name="facil_templ">';
@ -255,41 +261,57 @@ $(function(){
//$('#facil_templ').clone(true).insertAfter($('#tb1 tr:last').prev()); //$('#facil_templ').clone(true).insertAfter($('#tb1 tr:last').prev());
}); });
$('#submit').click(function(){ $('#submit').click(function() {
var itemFpidArr = []; var itemFpidArr = [];
$("input[name='fp_id']").each(function(){ itemFpidArr.push($(this).val()); }) $("input[name='fp_id']").each(function() {
itemFpidArr.push($(this).val());
})
$('#fp_id_all').val(itemFpidArr); $('#fp_id_all').val(itemFpidArr);
var itemSpecArr = []; var itemSpecArr = [];
$("input[name='item_spec']").each(function(){ itemSpecArr.push($(this).val()); }) $("input[name='item_spec']").each(function() {
itemSpecArr.push($(this).val());
})
$('#item_spec_all').val(itemSpecArr); $('#item_spec_all').val(itemSpecArr);
var itemGroupArr = []; var itemGroupArr = [];
$("input[name='item_group']").each(function(){ itemGroupArr.push($(this).val()); }) $("input[name='item_group']").each(function() {
itemGroupArr.push($(this).val());
})
$('#item_group_all').val(itemGroupArr); $('#item_group_all').val(itemGroupArr);
var itemQtyArr = []; var itemQtyArr = [];
$("input[name='item_qty']").each(function(){ itemQtyArr.push($(this).val().replace(/[,]+/g,"")); }) $("input[name='item_qty']").each(function() {
itemQtyArr.push($(this).val().replace(/[,]+/g, ""));
})
$('#item_qty_all').val(itemQtyArr); $('#item_qty_all').val(itemQtyArr);
var itemPriceBpArr = []; var itemPriceBpArr = [];
$("input[name='item_price_bp']").each(function(){ itemPriceBpArr.push($(this).val().replace(/[,]+/g,"")); }) $("input[name='item_price_bp']").each(function() {
itemPriceBpArr.push($(this).val().replace(/[,]+/g, ""));
})
$('#item_price_bp_all').val(itemPriceBpArr); $('#item_price_bp_all').val(itemPriceBpArr);
var itemPriceArr = []; var itemPriceArr = [];
$("input[name='item_price']").each(function(){ itemPriceArr.push($(this).val().replace(/[,]+/g,"")); }) $("input[name='item_price']").each(function() {
itemPriceArr.push($(this).val().replace(/[,]+/g, ""));
})
$('#item_price_all').val(itemPriceArr); $('#item_price_all').val(itemPriceArr);
var pvRateArr = []; var pvRateArr = [];
$("input[name='pv_rate']").each(function(){ pvRateArr.push($(this).val()); }) $("input[name='pv_rate']").each(function() {
pvRateArr.push($(this).val());
})
$('#pv_rate_all').val(pvRateArr); $('#pv_rate_all').val(pvRateArr);
var noteArr = []; var noteArr = [];
$("input[name='note']").each(function(){ noteArr.push($(this).val()); }) $("input[name='note']").each(function() {
noteArr.push($(this).val());
})
$('#note_all').val(noteArr); $('#note_all').val(noteArr);
//console.log(itemNameArr); //console.log(itemNameArr);
//return false; //return false;
}); });
}); });
</script> </script>
<div class="container"> <div class="container">
<?php <?php
include "pricereview-record-submit.php"; include "pricereview-record-submit.php";
/* /*
if($_SERVER["REQUEST_METHOD"] == "POST"){ if($_SERVER["REQUEST_METHOD"] == "POST"){
if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){ if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){
echo "<p class='error'>Please fill up the required field!</p>"; echo "<p class='error'>Please fill up the required field!</p>";
@ -298,11 +320,11 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){
} }
} }
*/ */
?> ?>
<form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data"> <form class="form-inline" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" enctype="multipart/form-data">
<div> <div>
<label for="contractno">卷號</label> <label for="contractno">卷號</label>
<input type="text" name="contractno" id="contractno" maxlength="7" required> <input type="text" name="contractno" id="contractno" maxlength="7" required>

1287
wms/mkt/pricereview-create.php

File diff suppressed because it is too large
Loading…
Cancel
Save