Browse Source

Merge branch 'main' into gary

# Conflicts:
#	wms/schedule-index.php
gary
gary_chen\gary_chen 1 year ago
parent
commit
aa2b339ae4
  1. 534
      mkt/pricereview-create.php
  2. 38
      prv/pricereview-record-submit.php
  3. 77
      wms/T8_APItest.php
  4. 13
      wms/T8_Authorization.php
  5. 72804
      wms/account-receivable-bill.txt
  6. 151
      wms/account-receivable-excel.php
  7. BIN
      wms/account-receivable-facility.xlsx
  8. 1218
      wms/account-receivable-index-ing.php
  9. 466
      wms/account-receivable-index.php
  10. 54
      wms/account-receivable-test.php
  11. BIN
      wms/account-receivable-test.xlsx
  12. 31815
      wms/account_receivable_sql_file.sql
  13. 6
      wms/cont/sign_list.php
  14. 167
      wms/contract-repair/api/putContractData.php
  15. 55
      wms/contract-repair/contract-download.php
  16. 39
      wms/contract-repair/js/alpine.js
  17. 237
      wms/contract/api/postContractData.php
  18. 48
      wms/contract/api/postContractNewApplyData.php
  19. 77
      wms/contract/api/testT8API.php
  20. 29
      wms/contract/conn.php
  21. 15
      wms/contract/connt8.php
  22. 645
      wms/contract/contract-input.php
  23. 140
      wms/contract/contract-new-apply.php
  24. 7
      wms/contract/insertData.php
  25. 65
      wms/contract/js/alpine.js
  26. 8
      wms/contract/styles/style.css
  27. 2
      wms/contract/styles/style.css.map
  28. 8
      wms/contract/styles/style.scss
  29. BIN
      wms/facility-price.xlsx
  30. 18
      wms/fun_global.php
  31. 2
      wms/header.php
  32. 101
      wms/mkt/assets/js/alpine.js
  33. 1587
      wms/mkt/price_normal-index.php
  34. 24
      wms/mkt/pricereview-check.php
  35. 3711
      wms/mkt/pricereview-create.php
  36. 9
      wms/mkt/pricereview-edit.php
  37. 50
      wms/mkt/pricereview-index.php
  38. 51
      wms/mkt/pricereview-record-submit.php
  39. 2
      wms/mkt/pricereview-record-update.php
  40. 4
      wms/mkt/pricereview_mi-api.php
  41. 1657
      wms/mkt/pricereview_renovate-check.php
  42. 4003
      wms/mkt/pricereview_renovate-create.php
  43. 6
      wms/mkt/pricereview_renovate-edit.php
  44. 40
      wms/mkt/pricereview_renovate-index.php
  45. 60
      wms/mkt/pricereview_renovate-record-submit.php
  46. 60
      wms/rib-invoice-check.php
  47. 20
      wms/rib02-create.php
  48. 19
      wms/rib02-edit.php
  49. 11
      wms/rib02-submit.php
  50. 2
      wms/schedule-index.php
  51. 8
      wms/sign/list.php

534
mkt/pricereview-create.php

@ -5,291 +5,313 @@ include "header.php";
$data = array();
?>
<script>
function commafy(num) {
num = num + "";
var re = /(-?\d+)(\d{3})/
while (re.test(num)) {
num = num.replace(re, "$1,$2")
}
return num;
}
function dataFormat() {
var amtAll = 0;
$("input[name='item_price_bp']").each(function(){
amtAll += Number($(this).val().replace(/[,]+/g,""));
});
$('#amt').val(commafy(amtAll));
$('#price_lowest').val(commafy(amtAll));
$('#price_total_broken').val(commafy($('#price_total').val().replace(/[,]+/g,"")-$('#price_lowest').val().replace(/[,]+/g,"")));
var qt = parseInt($('#qty_total').val().replace(/[,]+/g,"")) || 0;
if (qt) {
$('#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));
}
function selFacil(o) {
var fp = o.parent().parent();
var f1 = fp.find('select[name=fp_kind]').val();
var f2 = fp.find('select[name=fp_seat]').val();
var f3 = fp.find('input[name=fp_numberofstop]').val();
var f4 = fp.find('select[name=fp_speed]').val();
var f5 = fp.find('input[name=item_qty]').val();
if (f1 !== '' && f2 !== '' && f3 !== '' && f4 !== '' && f5 !== '') {
let fAry = [f1, f2, f3, f4, f5];
//console.log(fAry);
var formdata = new FormData();
formdata.append('fval', fAry);
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
if(this.readyState == 4 && this.status == 200){
data = JSON.parse(this.responseText);
if (data.st == 'err') {
alert(data.err);
fp.find('input[name=item_price_bp]').val(0);
dataFormat();
return false;
}
fp.find('input[name=item_price_bp]').val(commafy(data.amt));
fp.find('input[name=fp_id]').val(data.id);
fp.find('input[name=item_spec]').val(data.model);
fp.find('input[name=item_group]').val(data.group);
var cntAll = 0;
$("input[name='item_qty']").each(function(){
cntAll += Number($(this).val().replace(/[,]+/g,""));
});
$('#cnt').val(commafy(cntAll));
$('#qty_total').val(commafy(cntAll));
var pl = parseInt($('#price_lowest').val().replace(/[,]+/g,"")) || 0;
if (pl) {
$('#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)));
dataFormat();
/*
var amtAll = 0;
$("input[name='item_price_bp']").each(function(){
amtAll += Number($(this).val().replace(/[,]+/g,""));
});
$('#amt').val(commafy(amtAll));
$('#price_lowest').val(commafy(amtAll));
$('#price_total_broken').val(commafy($('#price_total').val().replace(/[,]+/g,"")-$('#price_lowest').val().replace(/[,]+/g,"")));
var qt = parseInt($('#qty_total').val().replace(/[,]+/g,"")) || 0;
if (qt) {
$('#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));
*/
}
function commafy(num) {
num = num + "";
var re = /(-?\d+)(\d{3})/
while (re.test(num)) {
num = num.replace(re, "$1,$2")
}
xhr.open('POST','/mkt/pricereview-facility.php',true);
xhr.send(formdata);
return num;
}
}
function tt(){
$("input[name='item_price_bp']").keyup(function(){
dataFormat();
/*
function dataFormat() {
var amtAll = 0;
$("input[name='item_price_bp']").each(function(){
amtAll += Number($(this).val().replace(/[,]+/g,""));
$("input[name='item_price_bp']").each(function() {
amtAll += Number($(this).val().replace(/[,]+/g, ""));
});
$('#amt').val(commafy(amtAll));
$('#price_lowest').val(commafy(amtAll));
$('#price_total_broken').val(commafy($('#price_total').val().replace(/[,]+/g,"")-$('#price_lowest').val().replace(/[,]+/g,"")));
var qt = parseInt($('#qty_total').val().replace(/[,]+/g,"")) || 0;
$('#price_total_broken').val(commafy($('#price_total').val().replace(/[,]+/g, "") - $('#price_lowest').val().replace(/[,]+/g, "")));
var qt = parseInt($('#qty_total').val().replace(/[,]+/g, "")) || 0;
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(){
$('#tb1').on('click', 'input[name=fp_numberofstop], input[name=item_qty]', function(){
//$("input[name=item_qty]").unbind().keyup(function(){
$(this).unbind().keyup(function(){
selFacil($(this));
/*
var fp = $(this).parent().parent();
var f1 = fp.find('select[name=fp_kind]').val();
var f2 = fp.find('select[name=fp_seat]').val();
var f3 = fp.find('input[name=fp_numberofstop]').val();
var f4 = fp.find('select[name=fp_speed]').val();
var f5 = fp.find('input[name=item_qty]').val();
if (f1 !== '' && f2 !== '' && f3 !== '' && f4 !== '' && f5 !== '') {
let fAry = [f1, f2, f3, f4, f5];
var formdata = new FormData();
formdata.append('fval', fAry);
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
if(this.readyState == 4 && this.status == 200){
data = JSON.parse(this.responseText);
if (data.st == 'err') {
alert(data.err);
return false;
}
fp.find('input[name=item_price_bp]').val(commafy(data.amt));
fp.find('input[name=fp_id]').val(data.id);
fp.find('input[name=item_spec]').val(data.model);
fp.find('input[name=item_group]').val(data.group);
function selFacil(o) {
var fp = o.parent().parent();
var f1 = fp.find('select[name=fp_kind]').val();
var f2 = fp.find('select[name=fp_seat]').val();
var f3 = fp.find('input[name=fp_numberofstop]').val();
var f4 = fp.find('select[name=fp_speed]').val();
var f5 = fp.find('input[name=item_qty]').val();
if (f1 !== '' && f2 !== '' && f3 !== '' && f4 !== '' && f5 !== '') {
let fAry = [f1, f2, f3, f4, f5];
//console.log(fAry);
var formdata = new FormData();
formdata.append('fval', fAry);
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
data = JSON.parse(this.responseText);
if (data.st == 'err') {
alert(data.err);
fp.find('input[name=item_price_bp]').val(0);
dataFormat();
return false;
}
fp.find('input[name=item_price_bp]').val(commafy(data.amt));
fp.find('input[name=fp_id]').val(data.id);
fp.find('input[name=item_spec]').val(data.model);
fp.find('input[name=item_group]').val(data.group);
var cntAll = 0;
$("input[name='item_qty']").each(function(){
cntAll += Number($(this).val().replace(/[,]+/g,""));
});
$('#cnt').val(commafy(cntAll));
$('#qty_total').val(commafy(cntAll));
var pl = parseInt($('#price_lowest').val().replace(/[,]+/g,"")) || 0;
if (pl) {
$('#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)));
var cntAll = 0;
$("input[name='item_qty']").each(function() {
cntAll += Number($(this).val().replace(/[,]+/g, ""));
});
$('#cnt').val(commafy(cntAll));
$('#qty_total').val(commafy(cntAll));
var pl = parseInt($('#price_lowest').val().replace(/[,]+/g, "")) || 0;
if (pl) {
$('#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)));
dataFormat();
dataFormat();
/*
var amtAll = 0;
$("input[name='item_price_bp']").each(function(){
amtAll += Number($(this).val().replace(/[,]+/g,""));
});
$('#amt').val(commafy(amtAll));
$('#price_lowest').val(commafy(amtAll));
$('#price_total_broken').val(commafy($('#price_total').val().replace(/[,]+/g,"")-$('#price_lowest').val().replace(/[,]+/g,"")));
var qt = parseInt($('#qty_total').val().replace(/[,]+/g,"")) || 0;
if (qt) {
$('#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));
*/
}
xhr.open('POST','/mkt/pricereview-facility.php',true);
xhr.send(formdata);
}
xhr.open('POST', '/mkt/pricereview-facility.php', true);
xhr.send(formdata);
}
}
function tt() {
$("input[name='item_price_bp']").keyup(function() {
dataFormat();
/*
var amtAll = 0;
$("input[name='item_price_bp']").each(function(){
amtAll += Number($(this).val().replace(/[,]+/g,""));
});
$('#amt').val(commafy(amtAll));
$('#price_lowest').val(commafy(amtAll));
$('#price_total_broken').val(commafy($('#price_total').val().replace(/[,]+/g,"")-$('#price_lowest').val().replace(/[,]+/g,"")));
var qt = parseInt($('#qty_total').val().replace(/[,]+/g,"")) || 0;
if (qt) {
$('#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));
*/
});
});
}
$(function() {
$('#tb1').on('click', 'input[name=fp_numberofstop], input[name=item_qty]', function() {
//$("input[name=item_qty]").unbind().keyup(function(){
$(this).unbind().keyup(function() {
selFacil($(this));
/*
var fp = $(this).parent().parent();
var f1 = fp.find('select[name=fp_kind]').val();
var f2 = fp.find('select[name=fp_seat]').val();
var f3 = fp.find('input[name=fp_numberofstop]').val();
var f4 = fp.find('select[name=fp_speed]').val();
var f5 = fp.find('input[name=item_qty]').val();
if (f1 !== '' && f2 !== '' && f3 !== '' && f4 !== '' && f5 !== '') {
let fAry = [f1, f2, f3, f4, f5];
var formdata = new FormData();
formdata.append('fval', fAry);
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
if(this.readyState == 4 && this.status == 200){
data = JSON.parse(this.responseText);
if (data.st == 'err') {
alert(data.err);
return false;
}
fp.find('input[name=item_price_bp]').val(commafy(data.amt));
fp.find('input[name=fp_id]').val(data.id);
fp.find('input[name=item_spec]').val(data.model);
fp.find('input[name=item_group]').val(data.group);
var cntAll = 0;
$("input[name='item_qty']").each(function(){
cntAll += Number($(this).val().replace(/[,]+/g,""));
});
$('#cnt').val(commafy(cntAll));
$('#qty_total').val(commafy(cntAll));
var pl = parseInt($('#price_lowest').val().replace(/[,]+/g,"")) || 0;
if (pl) {
$('#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)));
$('#tb1').on('click', 'select[name=fp_kind], select[name=fp_seat], select[name=fp_speed]', function(){
$(this).unbind().change(function(){
selFacil($(this));
dataFormat();
}
}
xhr.open('POST','/mkt/pricereview-facility.php',true);
xhr.send(formdata);
}
*/
});
});
});
$('#deposit_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
$('#tb1').on('click', $("input[name='item_qty']"), function(){
$("input[name='item_qty']").keyup(function(){
$(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ","));
var cntAll = 0;
//$(this).parent().next().find('input').val(commafy($(this).val()*Number($(this).parent().next().find('input').val().replace(/[,]+/g,""))));
$("input[name='item_qty']").each(function(){
cntAll += Number($(this).val().replace(/[,]+/g,""));
$('#tb1').on('click', 'select[name=fp_kind], select[name=fp_seat], select[name=fp_speed]', function() {
$(this).unbind().change(function() {
selFacil($(this));
});
$('#cnt').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());
var amtAll = 0;
$("input[name='item_price_bp']").each(function(){
amtAll += Number($(this).val().replace(/[,]+/g,""));
$('#deposit_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
$('#tb1').on('click', $("input[name='item_qty']"), function(){
$("input[name='item_qty']").keyup(function(){
$(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ","));
var cntAll = 0;
//$(this).parent().next().find('input').val(commafy($(this).val()*Number($(this).parent().next().find('input').val().replace(/[,]+/g,""))));
$("input[name='item_qty']").each(function(){
cntAll += Number($(this).val().replace(/[,]+/g,""));
});
$('#cnt').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());
var amtAll = 0;
$("input[name='item_price_bp']").each(function(){
amtAll += Number($(this).val().replace(/[,]+/g,""));
});
$('#amt').val(commafy(amtAll));
$('#price_lowest').val(commafy(amtAll));
var pl = parseInt($('#price_lowest').val().replace(/[,]+/g,"")) || 0;
if (pl) {
$('#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)));
});
});
$('#amt').val(commafy(amtAll));
$('#price_lowest').val(commafy(amtAll));
*/
var pl = parseInt($('#price_lowest').val().replace(/[,]+/g,"")) || 0;
// $('#tb1').on('click', tt);
$('#tb1').on('keyup', 'input[name=item_price_bp]', function() {
$(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ","));
dataFormat();
});
$('#tb1').on('keyup', 'input[name=fp_numberofstop], input[name=item_qty], input[name=item_price]', function() {
//$("input[name='item_price']").keyup(function(){
$(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ","));
//});
});
$('#tb1').on('keyup', 'input[name=pv_rate]', function() {
$(this).val($(this).val().replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1'));
});
$("#price_total").on("input", function() {
var pt = parseInt($(this).val().replace(/[,]+/g, "")) || 0;
$(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 = parseInt($('#price_lowest').val().replace(/[,]+/g, "")) || 0;
$('#price_total_broken').val(commafy(pt - pl));
if (pl) {
$('#price_rate').val(commafy((($('#price_total').val().replace(/[,]+/g,"")/pl)*100).toFixed(2)));
$('#price_rate').val(((pt / pl) * 100).toFixed(2));
}
$('#price_broken').val(commafy(($('#price_total_broken').val().replace(/[,]+/g,"")/$('#qty_total').val()).toFixed(2)));
var qt = parseInt($('#qty_total').val().replace(/[,]+/g, "")) || 0;
if (qt) {
$('#price_broken').val(commafy((parseInt($('#price_total_broken').val().replace(/[,]+/g, "")) / qt).toFixed(0)));
}
$('#pay1').html(commafy((pt * 0.2).toFixed(0)));
$('#pay2').html(commafy((pt * 0.4).toFixed(0)));
$('#pay3').html(commafy((pt * 0.2).toFixed(0)));
$('#pay4').html(commafy((pt * 0.1).toFixed(0)));
$('#pay5').html(commafy((pt * 0.1).toFixed(0)));
});
});
*/
$('#btnadd').click(function() {
/*
var facilTemp = '';
facilTemp+= '<tr name="facil_templ">';
facilTemp+= '<td>'+($('tr[name=facil_templ]').length+1)+'</td>';
facilTemp+= '<td>';
facilTemp+= '<?php include_once "facility_price.php"; ?>';
facilTemp+= '</td>';
facilTemp+= '<td><input type="text" name="item_spec"></td>';
facilTemp+= '<td><input type="text" name="item_qty"></td>';
facilTemp+= '<td><input type="text" name="item_price_bp"></td>';
facilTemp+= '<td><input type="text" name="item_price"></td>';
facilTemp+= '<td><input type="text" name="pv_rate"></td>';
facilTemp+= '<td colspan="2"><input type="text" name="note"><input type="hidden" name="item_group" value="A"><input type="hidden" name="item_price_bp_base"></td>';
facilTemp+= '</tr>';
$('#tb1 tr:last').prev().after(facilTemp);
*/
$('#tb1 tr:last').prev().after($("tr[name='facil_templ']").eq(0).clone().find('input').val('').end());
$('#tb1 tr:last').prev().find('td').first().html($("tr[name='facil_templ']").length);
//$("tr[name=facil_templ]").eq($("tr[name=facil_templ]").length-1).find('td').eq(0).html($("tr[name=facil_templ]").length);
// $('#tb1').on('click', tt);
$('#tb1').on('keyup', 'input[name=item_price_bp]', function(){
$(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ","));
dataFormat();
});
$('#tb1').on('keyup', 'input[name=fp_numberofstop], input[name=item_qty], input[name=item_price]', function(){
//$("input[name='item_price']").keyup(function(){
$(this).val($(this).val().replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ","));
//});
});
$('#tb1').on('keyup', 'input[name=pv_rate]', function(){
$(this).val($(this).val().replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1'));
});
$("#price_total").on("input", function(){
var pt = parseInt($(this).val().replace(/[,]+/g,"")) || 0;
$(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 = parseInt($('#price_lowest').val().replace(/[,]+/g,"")) || 0;
$('#price_total_broken').val(commafy(pt-pl));
if (pl) {
$('#price_rate').val(((pt/pl)*100).toFixed(2));
}
var qt = parseInt($('#qty_total').val().replace(/[,]+/g,"")) || 0;
if (qt) {
$('#price_broken').val(commafy((parseInt($('#price_total_broken').val().replace(/[,]+/g,""))/qt).toFixed(0)));
}
$('#pay1').html(commafy((pt*0.2).toFixed(0)));
$('#pay2').html(commafy((pt*0.4).toFixed(0)));
$('#pay3').html(commafy((pt*0.2).toFixed(0)));
$('#pay4').html(commafy((pt*0.1).toFixed(0)));
$('#pay5').html(commafy((pt*0.1).toFixed(0)));
});
$('#btnadd').click(function(){
/*
var facilTemp = '';
facilTemp+= '<tr name="facil_templ">';
facilTemp+= '<td>'+($('tr[name=facil_templ]').length+1)+'</td>';
facilTemp+= '<td>';
facilTemp+= '<?php include_once "facility_price.php"; ?>';
facilTemp+= '</td>';
facilTemp+= '<td><input type="text" name="item_spec"></td>';
facilTemp+= '<td><input type="text" name="item_qty"></td>';
facilTemp+= '<td><input type="text" name="item_price_bp"></td>';
facilTemp+= '<td><input type="text" name="item_price"></td>';
facilTemp+= '<td><input type="text" name="pv_rate"></td>';
facilTemp+= '<td colspan="2"><input type="text" name="note"><input type="hidden" name="item_group" value="A"><input type="hidden" name="item_price_bp_base"></td>';
facilTemp+= '</tr>';
$('#tb1 tr:last').prev().after(facilTemp);
*/
$('#tb1 tr:last').prev().after($("tr[name='facil_templ']").eq(0).clone().find('input').val('').end());
$('#tb1 tr:last').prev().find('td').first().html($("tr[name='facil_templ']").length);
//$("tr[name=facil_templ]").eq($("tr[name=facil_templ]").length-1).find('td').eq(0).html($("tr[name=facil_templ]").length);
//$('#facil_templ').clone(true).insertAfter($('#tb1 tr:last').prev());
});
$('#submit').click(function() {
var itemFpidArr = [];
$("input[name='fp_id']").each(function() {
itemFpidArr.push($(this).val());
})
$('#fp_id_all').val(itemFpidArr);
var itemSpecArr = [];
$("input[name='item_spec']").each(function() {
itemSpecArr.push($(this).val());
})
$('#item_spec_all').val(itemSpecArr);
var itemGroupArr = [];
$("input[name='item_group']").each(function() {
itemGroupArr.push($(this).val());
})
$('#item_group_all').val(itemGroupArr);
var itemQtyArr = [];
$("input[name='item_qty']").each(function() {
itemQtyArr.push($(this).val().replace(/[,]+/g, ""));
})
$('#item_qty_all').val(itemQtyArr);
var itemPriceBpArr = [];
$("input[name='item_price_bp']").each(function() {
itemPriceBpArr.push($(this).val().replace(/[,]+/g, ""));
})
$('#item_price_bp_all').val(itemPriceBpArr);
var itemPriceArr = [];
$("input[name='item_price']").each(function() {
itemPriceArr.push($(this).val().replace(/[,]+/g, ""));
})
$('#item_price_all').val(itemPriceArr);
var pvRateArr = [];
$("input[name='pv_rate']").each(function() {
pvRateArr.push($(this).val());
})
$('#pv_rate_all').val(pvRateArr);
var noteArr = [];
$("input[name='note']").each(function() {
noteArr.push($(this).val());
})
$('#note_all').val(noteArr);
//console.log(itemNameArr);
//return false;
});
//$('#facil_templ').clone(true).insertAfter($('#tb1 tr:last').prev());
});
$('#submit').click(function(){
var itemFpidArr = [];
$("input[name='fp_id']").each(function(){ itemFpidArr.push($(this).val()); })
$('#fp_id_all').val(itemFpidArr);
var itemSpecArr = [];
$("input[name='item_spec']").each(function(){ itemSpecArr.push($(this).val()); })
$('#item_spec_all').val(itemSpecArr);
var itemGroupArr = [];
$("input[name='item_group']").each(function(){ itemGroupArr.push($(this).val()); })
$('#item_group_all').val(itemGroupArr);
var itemQtyArr = [];
$("input[name='item_qty']").each(function(){ itemQtyArr.push($(this).val().replace(/[,]+/g,"")); })
$('#item_qty_all').val(itemQtyArr);
var itemPriceBpArr = [];
$("input[name='item_price_bp']").each(function(){ itemPriceBpArr.push($(this).val().replace(/[,]+/g,"")); })
$('#item_price_bp_all').val(itemPriceBpArr);
var itemPriceArr = [];
$("input[name='item_price']").each(function(){ itemPriceArr.push($(this).val().replace(/[,]+/g,"")); })
$('#item_price_all').val(itemPriceArr);
var pvRateArr = [];
$("input[name='pv_rate']").each(function(){ pvRateArr.push($(this).val()); })
$('#pv_rate_all').val(pvRateArr);
var noteArr = [];
$("input[name='note']").each(function(){ noteArr.push($(this).val()); })
$('#note_all').val(noteArr);
//console.log(itemNameArr);
//return false;
});
});
</script>
<div class="container">
<?php
include "pricereview-record-submit.php";
/*
<?php
include "pricereview-record-submit.php";
/*
if($_SERVER["REQUEST_METHOD"] == "POST"){
if(empty($_POST["id"]) && empty($_POST["expert_id"]) && empty($_POST["personal_id"])){
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>
<label for="contractno">卷號</label>
<input type="text" name="contractno" id="contractno" maxlength="7" required>
@ -461,7 +483,7 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){
<td style="padding-top:0px;"><input type="text" name="item_price_bp"></td>
<td style="padding-top:0px;"><input type="text" name="item_price"></td>
<td style="padding-top:0px;"><input type="text" name="pv_rate"></td>
<td style="padding-top:0px;" colspan="2"><input type="text" name="note"><input type="hidden" name="item_group" value="A"><input type="hidden" name="fp_id"><input type="hidden" name="item_spec"></td>
<td style="padding-top:0px;" colspan="2"><input type="text" name="note"><input type="hidden" name="item_group" value="A"><input type="hidden" name="fp_id"><input type="hidden" name="item_spec"></td>
</tr>
<tr>
<td></td>

38
prv/pricereview-record-submit.php

@ -1,3 +1,5 @@
<?php
require_once "database.php";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
@ -6,26 +8,26 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$$k = htmlspecialchars(stripslashes(trim($v)));
}
$maintance_contract_id=$_POST['maintance_contract_id'];
$sitename=$_POST['sitename'];
$contractor=$_POST['contractor'];
$contractsnum=$_POST['contractsnum'];
$siteaddress=$_POST['siteaddress'];
$startdate=$_POST['startdate'];
$enddate=$_POST['enddate'];
$contractsigningperiod=$startdate.'_'.$enddate;
$pricereviewer=$_POST['pricereviewer'];
$contracttype=$_POST['contracttype'];
$Maintenanceoperationcategory=$_POST['Maintenanceoperationcategory'];
$contractsigningnature=$_POST['contractsigningnature'];
$contractsignname=$_POST['contractsignname'];
$servicefee=$_POST['servicefee'];
$managebili=$_POST['managebili'];
$maintance_contract_id = $_POST['maintance_contract_id'];
$sitename = $_POST['sitename'];
$contractor = $_POST['contractor'];
$contractsnum = $_POST['contractsnum'];
$siteaddress = $_POST['siteaddress'];
$startdate = $_POST['startdate'];
$enddate = $_POST['enddate'];
$contractsigningperiod = $startdate . '_' . $enddate;
$pricereviewer = $_POST['pricereviewer'];
$contracttype = $_POST['contracttype'];
$Maintenanceoperationcategory = $_POST['Maintenanceoperationcategory'];
$contractsigningnature = $_POST['contractsigningnature'];
$contractsignname = $_POST['contractsignname'];
$servicefee = $_POST['servicefee'];
$managebili = $_POST['managebili'];
$creater = $_POST['creater'];
$create_at = date('Y/m/d H:i:s');
$updatee_at=date('Y/m/d H:i:s');
$updatee_at = date('Y/m/d H:i:s');
$db_query = "insert into maintance_contract_info(maintance_contract_id,sitename,contractor,contractsnum,siteaddress";
$db_query .= ",contractsigningperiod,pricereviewer,contracttype,Maintenanceoperationcategory,contractsigningnature,contractsignname";
@ -36,7 +38,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$result = mysqli_query($link, $db_query);
if ($mid = mysqli_insert_id($link)) {
header("Location: pricereview-index.php?account=".$_POST['account']);
header("Location: pricereview-index.php?account=" . $_POST['account']);
if (mysqli_affected_rows($link) > 0) {
echo "<script type ='text/JavaScript'>";
echo "alert('新增成功')";

77
wms/T8_APItest.php

@ -12,72 +12,53 @@ echo "ii";
console.log(validation);
// var corsurl = 'http://cors-anywhere.herokuapp.com/';
var apiurl = 'https://erp.masada.com.tw:780/twWebAPI/V1/SALDISPATCHLIST/GetERPData?pkValue=SS20230825001';
var apiurl = 'https://erp.masada.com.tw:780/twWebAPI/V1/SALINCOMEAPPLY/PostERPData';
headerParam = {
CHI_Authorization: `${validation}`,
};
var body = [{
"name": "MasterTable",
"name": "salIncomeApplyMaster",
"rows": [{
"BillNo": "Z001",
"BillDate": 20230930,
"BillNo": "B23100061",
"BillDate": 20231220,
"OrgId": "1000",
"TypeId": "OPV",
"BizPartnerId": "03051501",
"CurrId": "RMB",
"CurrLAmount":5,
"FOrgId": "1000",
"TypeId": "RAS",
"BpOrgId": "1000",
"BizPartnerId": "B23100061",
"CurrId": "TWD",
"CurrOAmount": 1,
"CurrLAmount": 1,
"PersonId": "M0065",
"DtOrgId": "1000",
"DueToId": "B23100061",
"TaxId": "ST005",
"PersonId": "M0012",
"DeptId": "220",
"CompId": "1001",
"CreditAgeDate": 20230930,
"RecBizPartnerId": "03051501",
"CompId": "1001"
}]
},
{
"name": "DetailTable",
"name": "salIncomeApplyDetail",
"rows": [{
"BillNo": "Z001",
"RowCode": 1,
"RowNo": 1,
"ItemType": 0,
"MaterialId": "MX00000001",
"UnitId": "PCS",
"MaterialSpec": "",
"SQuantity": 10,
"SPrice": 141.18,
"OAmount": 1344.57,
"OTax": 67.23,
"OAmountWithTax": 1411.8,
"TaxId": "ST005"
},
{
"BillNo": "Z001",
"RowCode": 2,
"RowNo": 2,
"ItemType": 0,
"MaterialId": "MX00000001",
"UnitId": "PCS",
"MaterialSpec": "",
"SQuantity": 15,
"SPrice": 141.18,
"OAmount": 2016.86,
"OTax": 100.84,
"OAmountWithTax": 2117.7,
"TaxId": "ST005"
}
]
"BillNo": "B23100061",
"IncomeId": "A40004",
"TaxId": "ST005",
"RowCode": 1,
"ItemType": "1",
"SPrice": 10000,
"SQuantity": 0,
"FromSourceTag": 0,
"FromBillNo": ""
}]
}
];
var json = JSON.stringify(body);
obj = {
type: 'GET',
type: 'POST',
// url: `${corsurl}${apiurl}`,
url: `${apiurl}`,
// dataType: 'json',
dataType: 'json',
headers: headerParam,
// data: json,
data: json,
// dataType: "json",
success: function(res) {
console.log(res.Status);

13
wms/T8_Authorization.php

@ -1,7 +1,7 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<?php
$now = gmdate("YmdHis");
$data = 'M0000.' . $now;
$data = 'admin.' . $now;
$sign = hash_hmac('SHA256', $data, 'B2D6395D2883E26C', false);
?>
@ -12,10 +12,10 @@ $sign = hash_hmac('SHA256', $data, 'B2D6395D2883E26C', false);
var validation = "";
// var corsurl = 'http://cors-anywhere.herokuapp.com/';
// var apiurl = 'http://60.244.87.101:880//twWebAPI/GetAuth';
var apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth'
var apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth'
headerParam = {
UserId: 'M0000',
Pwd: 'M012290493119',
UserId: 'admin',
Pwd: 'chi',
TimestampUTC: <?= $now ?>,
Sign: '<?= $sign ?>'
};
@ -27,11 +27,12 @@ $sign = hash_hmac('SHA256', $data, 'B2D6395D2883E26C', false);
headers: headerParam,
success: function(res) {
validation = res.Data['CHI_Authorization'];
console.log("validation:",validation);
window.parent.postMessage(validation,'http://localhost:3000');
console.log("validation:", validation);
window.parent.postMessage(validation, 'http://localhost:3000');
// window.parent.postMessage(validation,'https://masada.com.tw');
}
};
jQuery.ajax(obj);
}
</script>

72804
wms/account-receivable-bill.txt

File diff suppressed because it is too large

151
wms/account-receivable-excel.php

@ -5,103 +5,82 @@ require_once dirname(__DIR__) . '/common/composer/vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
header('Content-Type: application/json');
// $Bill = file_get_contents('php://input');
// $Bill = $_POST['Bill'];
$type = $_GET['type'];
$array_data = array();
$Bill = json_decode(file_get_contents("php://input"), true);
// $Bill = json_decode($Bill, true);
// 檢查是否有 POST 資料
// if ($_SERVER["REQUEST_METHOD"] == "POST") {
// // 獲取 POST 資料
// // $postData = $_POST['Bill'];
// // 指定儲存資料的檔案路徑
// $filePath = 'Bill.txt';
// // 寫入檔案
// // 使用 FILE_APPEND 選項,以便將資料附加到檔案的末尾而不是覆寫檔案
// file_put_contents($filePath, $Bill . PHP_EOL, FILE_APPEND);
// echo '資料已成功寫入檔案。';
// } else {
// echo '請透過正確的方式訪問此頁面。';
// }
// exit();
// print_r($Bill);
// foreach ($Bill as $key => $value) {
// $value['sign'][3] = (isset($value['sign'][3])) ? $value['sign'][3] : 0;
// $value['second'][3] = (isset($value['second'][3])) ? $value['second'][3] : 0;
// $value['arrive'][3] = (isset($value['arrive'][3])) ? $value['arrive'][3] : 0;
// $value['install'][3] = (isset($value['install'][3])) ? $value['install'][3] : 0;
// $value['tryrun'][3] = (isset($value['tryrun'][3])) ? $value['tryrun'][3] : 0;
// $value['check'][3] = (isset($value['check'][3])) ? $value['check'][3] : 0;
// $value['delivery'][3] = (isset($value['delivery'][3])) ? $value['delivery'][3] : 0;
// $value['final'][3] = (isset($value['final'][3])) ? $value['final'][3] : 0;
// $array_data[$key] = [
// $key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6],
// $value['sign'][1], $value['sign'][3], $value['sign']['max'], $value['sign']['min'],
// $value['second'][1], $value['second'][3], $value['second']['max'], $value['second']['min'],
// $value['arrive'][1], $value['arrive'][3], $value['arrive']['max'], $value['arrive']['min'],
// $value['install'][1], $value['install'][3], $value['install']['max'], $value['install']['min'],
// $value['tryrun'][1], $value['tryrun'][3], $value['tryrun']['max'], $value['tryrun']['min'],
// $value['check'][1], $value['check'][3], $value['check']['max'], $value['check']['min'],
// $value['delivery'][1], $value['delivery'][3], $value['delivery']['max'], $value['delivery']['min'],
// $value['final'][1], $value['final'][3], $value['final']['max'], $value['final']['min'],
// $value['total_budget'], $value['receivable_budget'], $value['invoice_budget'], $value['received_budget'], str_replace('<br>', '; ', $value['facilities'])
// ];
// $array_data[$key] = [
// $key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6],
// $value['sign'][1], $value['second'][1], $value['arrive'][1], $value['install'][1], $value['tryrun'][1], $value['check'][1], $value['delivery'][1], $value['final'][1],
// $value['sign'][3], $value['second'][3], $value['arrive'][3], $value['install'][3], $value['tryrun'][3], $value['check'][3], $value['delivery'][3], $value['final'][3],
// $value['total_budget'], $value['receivable_budget'], $value['invoice_budget'], $value['received_budget'], str_replace('<br>', '; ', $value['facilities'])
// ];
// }
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$colomnHeader = [
'合約號', '部門', '經理', '營業員', '客戶名稱', '統一編號', '聯絡地址', '抬頭',
'簽約款', '簽約款目前應收', '簽約最大催收次數', '簽約最小應收次數',
'二次款', '二次款目前應收', '二次最大催收次數', '二次最小應收次數',
'貨抵工地款', '貨抵工地款目前應收', '貨抵工地最小催收次數', '貨抵工地最小應收次數',
'安裝款', '安裝款目前應收', '安裝最大催收次數', '安裝最小應收次數',
'試車款', '試車款目前應收', '試車最大催收次數', '試車最小應收次數',
'官檢款', '官檢款目前應收', '官檢最大催收次數', '官檢最小應收次數',
'交車款', '交車款目前應收', '交車最大催收次數', '交車最小應收次數',
'尾款', '尾款目前應收', '尾款最大催收次數', '尾款最小應收次數',
'合約總金額', '目前應收', '已開發票金額', '已收金額', '作番狀態'
];
// $colomnHeader = [
// '合約號', '部門', '經理', '營業員', '客戶名稱', '統一編號', '聯絡地址', '抬頭',
// '簽約款', '二次款', '貨抵工地款', '安裝款', '試車款', '官檢款', '交車款', '尾款',
// '目前應收簽約款', '目前應收二次款', '目前應收貨抵工地款', '目前應收安裝款', '目前應收試車款', '目前應收官檢款', '目前應收交車款', '目前應收尾款',
// '合約總金額', '目前應收', '已開發票金額', '已收金額', '作番狀態'
// ];
$sheet->fromArray($colomnHeader, NULL, 'A1');
$rowIndex = 2;
foreach ($Bill as $key => $value) {
$sheet->fromArray($value, NULL, 'A' . $rowIndex);
$column = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS'
if ($type == 'facility') {
$colomnHeader = [
'作番號','合約號', '部門', '經理', '營業員', '客戶名稱', '統一編號', '聯絡地址', '抬頭',
'訂金名稱', '訂金合約金額', '訂金應收日期', '訂金目前應收金額', '訂金已收金額', '訂金催收金額', '訂金催收次數',
'二次款名稱', '二次款合約金額', '二次款應收日期', '二次款目前應收金額', '二次款已收金額', '二次款催收金額', '二次款催收次數',
'貨抵工地款名稱', '貨抵工地款合約金額', '貨抵工地款應收日期', '貨抵工地款目前應收金額', '貨抵工地款已收金額', '貨抵工地款催收金額', '貨抵工地款催收次數',
'安裝款名稱', '安裝款合約金額', '安裝款應收日期', '安裝款目前應收金額', '安裝款已收金額', '安裝款催收金額', '安裝款催收次數',
'試車款名稱', '試車款合約金額', '試車款應收日期', '試車款目前應收金額', '試車款已收金額', '試車款催收金額', '試車款催收次數',
'官檢款名稱', '官檢款合約金額', '官檢款應收日期', '官檢款目前應收金額', '官檢款已收金額', '官檢款催收金額', '官檢款催收次數',
'交車款名稱', '交車款合約金額', '交車款應收日期', '交車款目前應收金額', '交車款已收金額', '交車款催收金額', '交車款催收次數',
'尾款名稱', '尾款金額', '尾款應收日期', '尾款應收金額', '尾款已收金額', '尾款催收金額', '尾款催收次數',
'作番狀態', '作番合約總金額', '作番總應收金額'
];
foreach ($column as $col) {
if ($col == 'AS') {
$sheet->getStyle('AS' . $rowIndex)->getAlignment()->setWrapText(true);
} else {
$sheet->fromArray($colomnHeader, NULL, 'A1');
$rowIndex = 2;
foreach ($Bill as $key => $value) {
$sheet->fromArray($value, NULL, 'A' . $rowIndex,true);
$column = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ',
'BA', 'BB', 'BC', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BK', 'BL', 'BM', 'BN', 'BO', 'BP'
];
foreach ($column as $col) {
$sheet->getColumnDimension($col)->setAutoSize(true);
}
$rowIndex++;
}
$writer = new Xlsx($spreadsheet);
$excelFileName = 'account-receivable-facility.xlsx';
$writer->save($excelFileName);
} else {
$colomnHeader = [
'合約號', '部門', '經理', '營業員', '客戶名稱', '統一編號', '聯絡地址', '抬頭',
'訂金', '訂金目前應收', '訂金最大催收次數', '訂金最小催收次數',
'二次款', '二次款目前應收', '二次款最大催收次數', '二次款最小催收次數',
'貨抵工地款', '貨抵工地款目前應收', '貨抵工地款最小催收次數', '貨抵工地款最小催收次數',
'安裝款', '安裝款目前應收', '安裝款最大催收次數', '安裝款最小催收次數',
'試車款', '試車款目前應收', '試車款最大催收次數', '試車款最小催收次數',
'官檢款', '官檢款目前應收', '官檢款最大催收次數', '官檢款最小催收次數',
'交車款', '交車款目前應收', '交車款最大催收次數', '交車款最小催收次數',
'尾款', '尾款目前應收', '尾款最大催收次數', '尾款最小催收次數',
'合約總金額', '目前應收', '已開發票金額', '已收金額', '作番總數', '作番狀態'
];
$rowIndex++;
$sheet->fromArray($colomnHeader, NULL, 'A1');
$rowIndex = 2;
foreach ($Bill as $key => $value) {
$sheet->fromArray($value, NULL, 'A' . $rowIndex);
$column = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS', 'AT'
];
foreach ($column as $col) {
if ($col == 'AT') {
$sheet->getStyle('AT' . $rowIndex)->getAlignment()->setWrapText(true);
} else {
$sheet->getColumnDimension($col)->setAutoSize(true);
}
}
$rowIndex++;
}
$writer = new Xlsx($spreadsheet);
$excelFileName = 'account-receivable-test.xlsx';
$writer->save($excelFileName);
}
$writer = new Xlsx($spreadsheet);
$excelFileName = 'account-receivable-test.xlsx';
$writer->save($excelFileName);
echo $excelFileName;
?>
<!-- <script>

BIN
wms/account-receivable-facility.xlsx

Binary file not shown.

1218
wms/account-receivable-index-ing.php

File diff suppressed because it is too large

466
wms/account-receivable-index.php

@ -39,6 +39,45 @@ LEFT JOIN salSalesOrder AS s on a.BillNo = s.BillNo
LEFT JOIN comBusinessPartner AS c ON s.BizPartnerId=c.BizPartnerId
WHERE s.ModeId = 'M' AND (s.CurrentState=2 OR s.CurrentState=4) ";
//作番大日程
$sql = "SELECT
tmp2.*,
d.name AS depart_name
FROM(
SELECT
a.manager,
a2.name as manager_name,
a.name,
a.department_id,
w.salesid,
w.contractno,
w.facilityno,
w.estimated_shipping_date,
w.real_contract_arrival_date,
w.actual_tofactory_date,
w.real_arrival_date,
w.install_end_date,
w.tryrun_end_date,
w.official_check_date,
w.delivery_date
from wipwholestatus AS w
left join account AS a
ON w.salesid = a.accountid
left join account AS a2
ON a2.accountid = a.manager
where w.status = '1' AND w.contract_type='A'
)AS tmp2
left join (
SELECT DISTINCT
department_id,
name
FROM department
) AS d
ON d.department_id = tmp2.department_id ";
//ORDER BY contractno
// 期初收款資訊
$sql_opening = "
SELECT * FROM account_received ";
@ -46,20 +85,25 @@ SELECT * FROM account_received ";
// 設定權限:看到自己的/下屬的,資訊處跟財會處可以看全部的
if (!(in_array(accountidToDepartId($user_id), array('220', '210')))) {
$sql_contract .= "AND (s.PersonId = '$user_id'";
$sql_received .= " AND (PersonId = '$user_id'";
// $sql_received .= " AND (PersonId = '$user_id'";
$sql_opening .= " OR person_id = '$user_id'";
$sql .= " WHERE salesid = '$user_id'";
if (count($follower) > 0) {
$column_str = "('$user_id'" . ",'";
$column_str .= implode("','", $follower);
$column_str .= "')";
$sql_contract .= " OR s.PersonId IN $column_str)";
$sql_received .= " OR PersonId IN $column_str)";
// $sql_received .= " OR PersonId IN $column_str)";
$sql_opening .= " OR person_id IN $column_str)";
$sql .= " OR salesid IN $column_str ORDER BY contractno";
} else {
$sql_contract .= ")";
$sql_received .= ")";
// $sql_received .= ")";
$sql_opening .= ")";
$sql .= " ORDER BY contractno";
};
}else{
$sql .= " ORDER BY contractno";
}
$contract = $conn->query($sql_contract);
@ -91,6 +135,7 @@ foreach ($contract as $cont) {
$ContactAddress = $cont['ContactAddress'];
//['sign'] 0 款項名稱 1 簽約金額 2 簽約日期 3 應收金額 min 最早應收月份 max 最晚應收月份 ['second'] 0 二次款名 1 二次款金額 2 收款日期 ['arrive'] 0 貨抵工地款名稱 1 貨抵工地款金額 2 貨抵工地收款日期 ['install'] 0 安裝款名 1 安裝金額 2 安裝收款日期
//['tryrun'] 0 試車款名 1試車金額 2 試車收款日期 ['check'] 0 官檢款名 1 官檢金額 2 官檢收款日期 ['delivery'] 0 交車款名 1 交車金額 2 交車收款日期 ['final'] 0 尾款名 1 尾款金額 2 尾款收款日期
//['facility'] [作番號][款別]0 款項名稱 1 合約金額 2 應收日期 3 應收金額 4 已收金額 5 催收金額 6 催收次數
if (!(isset($arrayData[$BillNo]))) {
// 0 部門id 1 部門名稱 2 經理名稱 3 營業員id 4 營業員名稱 5 客戶名稱 6 抬頭 7 統編 8 通訊地址
$arrayData[$BillNo] = [0, 0, 0, 0, 0, 0, 0, 0, 0];
@ -182,43 +227,11 @@ foreach ($contract as $cont) {
//取作番大日程作番與時程
// real_contract_arrival_date 預計出貨日
// real_arrival_date 實際出貨日
$sql = "SELECT
tmp2.*,
d.name AS depart_name
FROM(
SELECT
a.manager,
a2.name as manager_name,
a.name,
a.department_id,
w.salesid,
w.contractno,
w.facilityno,
w.estimated_shipping_date,
w.real_contract_arrival_date,
w.actual_tofactory_date,
w.real_arrival_date,
w.install_end_date,
w.tryrun_end_date,
w.official_check_date,
w.delivery_date
from wipwholestatus AS w
left join account AS a
ON w.salesid = a.accountid
left join account AS a2
ON a2.accountid = a.manager
where w.status = '1' AND w.contract_type='A'
)AS tmp2
left join (
SELECT DISTINCT
department_id,
name
FROM department
) AS d
ON d.department_id = tmp2.department_id ORDER BY contractno";
$wipwhole_array = mysqli_query($link, $sql);
foreach ($wipwhole_array as $wip) {
$today = strtotime(date('Ymd'));
//[合約號]['facility'] [作番號][款別]0 款項名稱 1 合約金額 2 應收日期 3 應收金額 4 已收金額 5 催收金額 6 催收次數
if (isset($arrayData[$wip['contractno']])) {
// 整理合約資料
$arrayData[$wip['contractno']][0] = $wip['department_id'];;
@ -228,14 +241,19 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']][4] = $wip['name'];
$arrayData[$wip['contractno']][10] = $wip['contractno'];
$arrayData[$wip['contractno']]['total_facility_num'] += 1;
// [合約號][作番號]['no']
$arrayData[$wip['contractno']][$wip['facilityno']]['no'] = $wip['facilityno'];
// [合約號]['facility'][作番號]['no']
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['no'] = $wip['facilityno'];
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = "";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['total_budget'] = 0;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['receivable_budget'] = 0;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['collect_budget'] = 0;
// [合約號][作番號][款別] ['con'] [金額]/[合約預計收款日期]
// [合約號][作番號][款別] ['inv'] [金額]/[發票開立日期]
// [合約號][作番號][款別] ['rec'] [金額]/[實際收款日期]
$contractstage = array('sign', 'second', 'arrive', 'install', 'tryrun', 'check', 'delivery', 'final');
foreach ($contractstage as $i) {
$arrayData[$wip['contractno']][$wip['facilityno']][$i] = ['', 0, '', 0, 0, 0, 0];
$arrayData[$wip['contractno']][$wip['facilityno']][$i]['inv']['date'] = "";
$arrayData[$wip['contractno']][$wip['facilityno']][$i]['inv']['budget'] = 0;
$arrayData[$wip['contractno']][$wip['facilityno']][$i]['rec']['date'] = "";
@ -284,6 +302,16 @@ foreach ($wipwhole_array as $wip) {
array_push($arrayData[$wip['contractno']]['second']['max'], strtotime(strval($secondtime)));
array_push($arrayData[$wip['contractno']]['second']['min'], strtotime(strval($secondtime)));
}
} elseif (isset($arrayData[$wip['contractno']]['second'][0]) && stristr($arrayData[$wip['contractno']]['second'][0], '出貨前120天')) {
if (empty($wip['real_contract_arrival_date'])) {
} else {
$estimate_delivery_time = strtotime($wip['real_contract_arrival_date']);
$secondtime = $estimate_delivery_time - (120 * 86400);
$secondtime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['second'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['second']['max'], strtotime(strval($secondtime)));
array_push($arrayData[$wip['contractno']]['second']['min'], strtotime(strval($secondtime)));
}
} elseif (isset($arrayData[$wip['contractno']]['second'][0]) && $arrayData[$wip['contractno']]['second'][0] == '寶佳出貨後10天') {
if ($wip['real_arrival_date'] != NULL) {
@ -306,39 +334,64 @@ foreach ($wipwhole_array as $wip) {
// real_contract_arrival_date 預計出貨日=預計到貨日=預計貨抵工地
// real_arrival_date 實際出貨日=實際到貨日=實際貨抵工地
//----------------------------------------寶佳的另外處理---------------------------------------------------
if ($arrayData[$wip['contractno']]['sign'][0] == "寶佳出貨前30天") {
$facility_status = "";
// if ($arrayData[$wip['contractno']]['sign'][2])
$today = strtotime(date('Ymd'));
$contractday = strtotime($arrayData[$wip['contractno']]['sign'][2]);
$month = collect_month($contractday);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['sign'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['sign'][2] = $arrayData[$wip['contractno']]['sign'][2];
if ($today > $contractday) {
$arrayData[$wip['contractno']]['sign_num'] += 1;
$facility_status = $wip['facilityno'] . " (出貨前30天" . $arrayData[$wip['contractno']]['sign'][2] . "已過) <br>";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $facility_status;
//二次款
$contractday = strtotime($arrayData[$wip['contractno']]['second'][2]);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['second'][2] = $arrayData[$wip['contractno']]['second'][2];
$month = collect_month($contractday);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['second'][6] = $month;
if ($today > $contractday) {
$arrayData[$wip['contractno']]['second_num'] += 1;
$facility_status = $wip['facilityno'] . " (出貨後10天" . $arrayData[$wip['contractno']]['second'][2] . "已過) <br>";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $facility_status;
//貨抵工地款
if ($wip['real_arrival_date'] != NULL) {
$estimate_time = strtotime($wip['real_arrival_date']);
$contractday = $estimate_time + (90 * 86400);
$month = collect_month($contractday);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $contractday));
if ($today > $contractday) {
$arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['arrive'][2] = strval(date('Y-m-d', $contractday));
$facility_status = $wip['facilityno'] . " (貨抵工地後90天" . $arrayData[$wip['contractno']]['arrive'][2] . "已過) <br>";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $facility_status;
//試車款
if ($wip['tryrun_end_date'] != NULL) {
$estimate_time = strtotime($wip['tryrun_end_date']);
$contractday = $estimate_time + (90 * 86400);
$month = collect_month($contractday);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][2] = strval(date('Ymd', $contractday));
if ($today > $contractday) {
$arrayData[$wip['contractno']]['tryrun_num'] += 1;
$arrayData[$wip['contractno']]['tryrun'][2] = strval(date('Y-m-d', $contractday));
$facility_status = $wip['facilityno'] . " (試車後90天" . $arrayData[$wip['contractno']]['tryrun'][2] . "已過) <br>";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $facility_status;
//交車款
if ($wip['delivery_date'] != NULL) {
$estimate_time = strtotime($wip['delivery_date']);
$contractday = $estimate_time + (270 * 86400);
$month = collect_month($contractday);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['delivery'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['delivery'][2] = strval(date('Ymd', $contractday));
if ($today > $contractday) {
$arrayData[$wip['contractno']]['delivery_num'] += 1;
$arrayData[$wip['contractno']]['delivery'][2] = strval(date('Y-m-d', $contractday));
$facility_status = $wip['facilityno'] . " (交車後270天" . $arrayData[$wip['contractno']]['delivery'][2] . "已過) <br>";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $facility_status;
}
}
}
@ -348,11 +401,23 @@ foreach ($wipwhole_array as $wip) {
}
} else {
$facility_status = $wip['facilityno'] . " (出貨前30天" . $arrayData[$wip['contractno']]['sign'][2] . "未到) <br>";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $facility_status;
}
$arrayData[$wip['contractno']]['facilities'] .= $facility_status;
} else {
$signtime = strtotime($arrayData[$wip['contractno']]['sign'][2]);
$month = collect_month($signtime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['sign'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['sign'][2] = strval(date('Ymd', $signtime));
if (isset($arrayData[$wip['contractno']]['second'][2]) && ($arrayData[$wip['contractno']]['second'][2] !== NULL)) {
$secondtime = strtotime($arrayData[$wip['contractno']]['second'][2]);
$month = collect_month($secondtime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['second'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['second'][2] = strval(date('Ymd', $secondtime));
}
if ($wip['delivery_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['delivery_date'] . "已移交) <br>";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (" . $wip['delivery_date'] . "已移交) <br>";
$arrayData[$wip['contractno']]['tryrun_num'] += 1;
$arrayData[$wip['contractno']]['install_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1;
@ -362,7 +427,13 @@ foreach ($wipwhole_array as $wip) {
if ($arrayData[$wip['contractno']]['delivery'][0] == "交車後270天") {
$estimate_delivery_time = strtotime($wip['delivery_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400);
$arrivetime = date('Ymd', $secondtime);
$month = collect_month($arrivetime);
if ($today > $arrivetime) {
$arrayData[$wip['contractno']]['delivery_num'] += 1;
}
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['delivery'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['delivery'][2] = strval(date('Ymd', $arrivetime));
$arrivetime = date('Ymd', $arrivetime);
$arrayData[$wip['contractno']]['delivery'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['delivery']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['delivery']['max'], strtotime(strval($arrivetime)));
@ -370,60 +441,74 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['delivery_num'] += 1;
$arrayData[$wip['contractno']]['check_num'] += 1;
$arrayData[$wip['contractno']]['delivery'][2] = strval($wip['delivery_date']);
$deliverytime = strtotime($wip['delivery_date']);
$month = collect_month($deliverytime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['delivery'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['delivery'][2] = strval(date('Ymd', $deliverytime));
array_push($arrayData[$wip['contractno']]['delivery']['min'], strtotime(strval($wip['delivery_date'])));
array_push($arrayData[$wip['contractno']]['delivery']['max'], strtotime(strval($wip['delivery_date'])));
}
if (!empty($wip['official_check_date']) && $wip['official_check_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['check']['min'], strtotime(strval($wip['official_check_date'])));
array_push($arrayData[$wip['contractno']]['check']['max'], strtotime(strval($wip['official_check_date'])));
$checktime = strtotime($wip['official_check_date']);
$month = collect_month($checktime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['check'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['check'][2] = strval(date('Ymd', $checktime));
}
if (!empty($wip['tryrun_end_date']) && $wip['tryrun_end_date'] != NULL) {
if ($arrayData[$wip['contractno']]['tryrun'][0] == "安裝試車後90天") {
$estimate_delivery_time = strtotime($wip['tryrun_end_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400);
$arrivetime = date('Ymd', $secondtime);
$tryruntime = $estimate_delivery_time + (90 * 86400);
$tryruntime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['tryrun'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['tryrun']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['tryrun']['min'], strtotime(strval($tryruntime)));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], strtotime(strval($tryruntime)));
$month = collect_month($tryruntime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][2] = strval(date('Ymd', $tryruntime));
} else {
$arrayData[$wip['contractno']]['tryrun'][2] = strval($wip['tryrun_end_date']);
array_push($arrayData[$wip['contractno']]['tryrun']['min'], strtotime(strval($wip['tryrun_end_date'])));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], strtotime(strval($wip['tryrun_end_date'])));
$tryruntime = strtotime($wip['tryrun_end_date']);
$month = collect_month($tryruntime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][2] = strval(date('Ymd', $tryruntime));
}
}
if (!empty($wip['install_end_date']) && $wip['install_end_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['install']['min'], strtotime(strval($wip['install_end_date'])));
array_push($arrayData[$wip['contractno']]['install']['max'], strtotime(strval($wip['install_end_date'])));
$installtime = strtotime($wip['install_end_date']);
$month = collect_month($installtime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['install'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['install'][2] = strval(date('Ymd', $installtime));
}
if (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) {
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
$estimate_delivery_time = strtotime($wip['real_arrival_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400);
$month = collect_month($arrivetime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $arrivetime));
$arrivetime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime)));
} else {
$arrivetime = strtotime($wip['real_arrival_date']);
$month = collect_month($arrivetime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $arrivetime));
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_arrival_date']);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_arrival_date'])));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date'])));
}
} else {
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
$estimate_delivery_time = strtotime($wip['real_contract_arrival_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400);
$arrivetime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime)));
} else {
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_contract_arrival_date']);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_contract_arrival_date'])));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_contract_arrival_date'])));
}
}
} elseif ($wip['official_check_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['official_check_date'] . "官檢完畢) <br>";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (" . $wip['official_check_date'] . "官檢完畢) <br>";
$arrayData[$wip['contractno']]['check_num'] += 1;
$arrayData[$wip['contractno']]['tryrun_num'] += 1;
$arrayData[$wip['contractno']]['install_num'] += 1;
@ -433,30 +518,48 @@ foreach ($wipwhole_array as $wip) {
if (!empty($wip['official_check_date']) && $wip['official_check_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['check']['min'], strtotime(strval($wip['official_check_date'])));
array_push($arrayData[$wip['contractno']]['check']['max'], strtotime(strval($wip['official_check_date'])));
$checktime = strtotime($wip['official_check_date']);
$month = collect_month($checktime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['check'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['check'][2] = strval(date('Ymd', $checktime));
}
if (!empty($wip['tryrun_end_date']) && $wip['tryrun_end_date'] != NULL) {
if ($arrayData[$wip['contractno']]['tryrun'][0] == "安裝試車後90天") {
if (isset($arrayData[$wip['contractno']]['tryrun'][0]) && $arrayData[$wip['contractno']]['tryrun'][0] == "安裝試車後90天") {
$estimate_delivery_time = strtotime($wip['tryrun_end_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400);
$arrivetime = date('Ymd', $secondtime);
$tryruntime = $estimate_delivery_time + (90 * 86400);
$month = collect_month($tryruntime);
$tryruntime = date('Ymd', $tryruntime);
$arrayData[$wip['contractno']]['tryrun'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['tryrun']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['tryrun']['min'], strtotime(strval($tryruntime)));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], strtotime(strval($tryruntime)));
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][2] = strval($tryruntime);
} else {
$tryruntime = strtotime($wip['tryrun_end_date']);
$month = collect_month($tryruntime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][2] = strval(date('Ymd', $tryruntime));
$arrayData[$wip['contractno']]['tryrun'][2] = strval($wip['tryrun_end_date']);
array_push($arrayData[$wip['contractno']]['tryrun']['min'], strtotime(strval($wip['tryrun_end_date'])));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], strtotime(strval($wip['tryrun_end_date'])));
}
}
if (!empty($wip['install_end_date']) && $wip['install_end_date'] != NULL) {
$installtime = strtotime($wip['install_end_date']);
$month = collect_month($installtime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['install'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['install'][2] = strval(date('Ymd', $installtime));
array_push($arrayData[$wip['contractno']]['install']['min'], strtotime(strval($wip['install_end_date'])));
array_push($arrayData[$wip['contractno']]['install']['max'], strtotime(strval($wip['install_end_date'])));
}
if (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) {
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
if (isset($arrayData[$wip['contractno']]['arrive'][0]) && $arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
$estimate_delivery_time = strtotime($wip['real_arrival_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400);
$month = collect_month($arrivetime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $arrivetime));
$arrivetime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime)));
@ -465,6 +568,10 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_arrival_date']);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_arrival_date'])));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date'])));
$arrivetime = strtotime($wip['real_arrival_date']);
$month = collect_month($arrivetime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $arrivetime));
}
} else {
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
@ -482,6 +589,7 @@ foreach ($wipwhole_array as $wip) {
}
} elseif ($wip['tryrun_end_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['tryrun_end_date'] . "試車完畢) <br>";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (" . $wip['tryrun_end_date'] . "試車完畢) <br>";
$arrayData[$wip['contractno']]['tryrun_num'] += 1;
$arrayData[$wip['contractno']]['install_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1;
@ -490,20 +598,35 @@ foreach ($wipwhole_array as $wip) {
if (!empty($wip['tryrun_end_date']) && $wip['tryrun_end_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['tryrun']['min'], strtotime(strval($wip['tryrun_end_date'])));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], strtotime(strval($wip['tryrun_end_date'])));
$tryruntime = strtotime($wip['tryrun_end_date']);
$month = collect_month($tryruntime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['tryrun'][2] = strval(date('Ymd', $tryruntime));
}
if (!empty($wip['install_end_date']) && $wip['install_end_date'] != NULL) {
array_push($arrayData[$wip['contractno']]['install']['min'], strtotime(strval($wip['install_end_date'])));
array_push($arrayData[$wip['contractno']]['install']['max'], strtotime(strval($wip['install_end_date'])));
$installtime = strtotime($wip['install_end_date']);
$month = collect_month($installtime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['install'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['install'][2] = strval(date('Ymd', $installtime));
}
if (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) {
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
$estimate_delivery_time = strtotime($wip['real_arrival_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400);
$arrivetime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime);
$month = collect_month($arrivetime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $arrivetime));
$arrivetime = date('Ymd', $arrivetime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($arrivetime);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime)));
} else {
$arrivetime = strtotime($wip['real_arrival_date']);
$month = collect_month($arrivetime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $arrivetime));
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_arrival_date']);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_arrival_date'])));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date'])));
@ -512,8 +635,8 @@ foreach ($wipwhole_array as $wip) {
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
$estimate_delivery_time = strtotime($wip['real_contract_arrival_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400);
$arrivetime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime);
$arrivetime = date('Ymd', $arrivetime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($arrivetime);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime)));
} else {
@ -524,11 +647,16 @@ foreach ($wipwhole_array as $wip) {
}
} elseif ($wip['install_end_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['install_end_date'] . "安裝完畢) <br>";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (" . $wip['install_end_date'] . "安裝完畢) <br>";
$arrayData[$wip['contractno']]['install_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
$arrayData[$wip['contractno']]['sign_num'] += 1;
if (!empty($wip['install_end_date']) && $wip['install_end_date'] != NULL) {
$installtime = strtotime($wip['install_end_date']);
$month = collect_month($installtime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['install'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['install'][2] = strval(date('Ymd', $installtime));
array_push($arrayData[$wip['contractno']]['install']['min'], strtotime(strval($wip['install_end_date'])));
array_push($arrayData[$wip['contractno']]['install']['max'], strtotime(strtotime(strval($wip['install_end_date']))));
}
@ -536,11 +664,18 @@ foreach ($wipwhole_array as $wip) {
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
$estimate_delivery_time = strtotime($wip['real_arrival_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400);
$arrivetime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime);
$month = collect_month($arrivetime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $arrivetime));
$arrivetime = date('Ymd', $arrivetime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($arrivetime);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime)));
} else {
$arrivetime = strtotime($wip['real_arrival_date']);
$month = collect_month($arrivetime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $arrivetime));
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_arrival_date']);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_arrival_date'])));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date'])));
@ -561,6 +696,7 @@ foreach ($wipwhole_array as $wip) {
}
} elseif ($wip['real_arrival_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['real_arrival_date'] . "貨抵工地) <br>";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (" . $wip['real_arrival_date'] . "貨抵工地) <br>";
$arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1;
$arrayData[$wip['contractno']]['sign_num'] += 1;
@ -568,28 +704,42 @@ foreach ($wipwhole_array as $wip) {
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
$estimate_delivery_time = strtotime($wip['real_arrival_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400);
$arrivetime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime);
$month = collect_month($arrivetime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $arrivetime));
$arrivetime = date('Ymd', $arrivetime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($arrivetime);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime)));
} else {
$arrivetime = strtotime($wip['real_arrival_date']);
$month = collect_month($arrivetime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['arrive'][2] = strval(date('Ymd', $arrivetime));
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_arrival_date']);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($wip['real_arrival_date'])));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date'])));
}
} elseif (($arrayData[$wip['contractno']]['second'] != NULL) && (isset($arrayData[$wip['contractno']]['second'][2])) && ($arrayData[$wip['contractno']]['second'][2] <= date('Ymd'))) {
$secondtime = strtotime($arrayData[$wip['contractno']]['second'][2]);
$month = collect_month($secondtime);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['second'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['second'][2] = strval(date('Ymd', $secondtime));
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (已達二次款收款條件) <br>";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (已達二次款收款條件) <br>";
$arrayData[$wip['contractno']]['second_num'] += 1;
$arrayData[$wip['contractno']]['sign_num'] += 1;
} else {
$arrayData[$wip['contractno']]['sign_num'] += 1;
if ($wip['real_contract_arrival_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['real_contract_arrival_date'] . "預計出貨日) <br>";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (" . $wip['real_contract_arrival_date'] . "預計出貨日) <br>";
} elseif ($wip['estimated_shipping_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['estimated_shipping_date'] . "預計出港日) <br>";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (" . $wip['estimated_shipping_date'] . "預計出港日) <br>";
} else {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (預計出港日待確認) <br>";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (預計出港日待確認) <br>";
}
}
}
@ -598,6 +748,7 @@ foreach ($wipwhole_array as $wip) {
// 計算每個合約的應收款、作番總數
$today_date = new DateTime(date('Y-m-d', strtotime('-1 month', strtotime(date('Y-m-d')))));
$contractstage = array('sign', 'second', 'arrive', 'install', 'tryrun', 'check', 'delivery', 'final');
foreach ($arrayData as &$value) {
if ($value['total_facility_num'] > 0) {
$value['receivable_budget'] = $value['sign'][1] * ($value['sign_num'] / $value['total_facility_num']) + ($value['second'][1] * ($value['second_num'] / $value['total_facility_num'])) +
@ -613,9 +764,24 @@ foreach ($arrayData as &$value) {
$value['delivery'][3] = $value['delivery'][1] * ($value['delivery_num'] / $value['total_facility_num']);
$value['final'][3] = $value['final'][1] * ($value['delivery_num'] / $value['total_facility_num']);
}
// 計算最大催收次數與最小催收次數
$contractstage = array('sign', 'second', 'arrive', 'install', 'tryrun', 'check', 'delivery', 'final');
// 計算每台作番金額與各階段應收金額
foreach ($value['facility'] as &$val) {
foreach ($contractstage as $stage) {
if (isset($value[$stage][0]) && !empty($value[$stage][0])) {
$val[$stage][0] = $value[$stage][0];
$val[$stage][1] = $value[$stage][1] / $value['total_facility_num'];
$val[$stage][3] = (!(isset($val[$stage][6])) || $val[$stage][6] == 0) ? 0 : $val[$stage][1];
$val['total_budget'] += $val[$stage][1];
$val['receivable_budget'] += $val[$stage][3];
}
}
}
// 計算最大催收次數與最小催收次數
foreach ($contractstage as $i) {
if (!empty($value[$i]['min']) && count($value[$i]['min']) > 0) {
$latest_timestamp = max($value[$i]['min']);
@ -689,6 +855,9 @@ foreach ($received_array as $received) {
$excel_aray = array();
$boga_array = array();
$exclude_boga_array = array();
$facility_array = array();
$facility_boga_array = array();
$facility_exclude_boga_array = array();
foreach ($arrayData as $key => $value) {
$value['sign'][3] = (isset($value['sign'][3])) ? $value['sign'][3] : 0;
$value['second'][3] = (isset($value['second'][3])) ? $value['second'][3] : 0;
@ -700,11 +869,10 @@ foreach ($arrayData as $key => $value) {
$value['final'][3] = (isset($value['final'][3])) ? $value['final'][3] : 0;
$contractstage = array('sign', 'second', 'arrive', 'install', 'tryrun', 'check', 'delivery', 'final');
foreach ($contractstage as $i) {
$value[$i]['max'] = (empty($value[$i]['max']) || !isset($value[$i]['max'])) ? 0 : $value[$i]['max'];
$value[$i]['min'] = (empty($value[$i]['min']) || !isset($value[$i]['min'])) ? 0 : $value[$i]['min'];
$value[$i]['max'] = (empty($value[$i]['max']) || is_null($value[$i]['max'])) ? 0 : $value[$i]['max'];
$value[$i]['min'] = (empty($value[$i]['min']) || is_null($value[$i]['min'])) ? 0 : $value[$i]['min'];
};
if ($value['sign'][0] == "寶佳出貨前30天") {
$boga_array[$key] = [
$key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6],
@ -716,9 +884,9 @@ foreach ($arrayData as $key => $value) {
$value['check'][1], $value['check'][3], $value['check']['max'], $value['check']['min'],
$value['delivery'][1], $value['delivery'][3], $value['delivery']['max'], $value['delivery']['min'],
$value['final'][1], $value['final'][3], $value['final']['max'], $value['final']['min'],
$value['total_budget'], $value['receivable_budget'], $value['invoice_budget'], $value['received_budget'], str_replace('<br>', '; ', $value['facilities'])
$value['total_budget'], $value['receivable_budget'], $value['invoice_budget'], $value['received_budget'], $value['total_facility_num'], str_replace('<br>', '; ', $value['facilities'])
];
}else{
} else {
$exclude_boga_array[$key] = [
$key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6],
$value['sign'][1], $value['sign'][3], $value['sign']['max'], $value['sign']['min'],
@ -729,7 +897,7 @@ foreach ($arrayData as $key => $value) {
$value['check'][1], $value['check'][3], $value['check']['max'], $value['check']['min'],
$value['delivery'][1], $value['delivery'][3], $value['delivery']['max'], $value['delivery']['min'],
$value['final'][1], $value['final'][3], $value['final']['max'], $value['final']['min'],
$value['total_budget'], $value['receivable_budget'], $value['invoice_budget'], $value['received_budget'], str_replace('<br>', '; ', $value['facilities'])
$value['total_budget'], $value['receivable_budget'], $value['invoice_budget'], $value['received_budget'], $value['total_facility_num'], str_replace('<br>', '; ', $value['facilities'])
];
}
@ -745,13 +913,69 @@ foreach ($arrayData as $key => $value) {
$value['check'][1], $value['check'][3], $value['check']['max'], $value['check']['min'],
$value['delivery'][1], $value['delivery'][3], $value['delivery']['max'], $value['delivery']['min'],
$value['final'][1], $value['final'][3], $value['final']['max'], $value['final']['min'],
$value['total_budget'], $value['receivable_budget'], $value['invoice_budget'], $value['received_budget'], str_replace('<br>', '; ', $value['facilities'])
$value['total_budget'], $value['receivable_budget'], $value['invoice_budget'], $value['received_budget'], $value['total_facility_num'], str_replace('<br>', '; ', $value['facilities'])
];
//['sign'] 0 款項名稱 1 簽約金額 2 簽約日期 3 應收金額 min 最早應收月份 max 最晚應收月份
//[合約號]['facility'] [作番號][款別]0 款項名稱 1 合約金額 2 應收日期 3 應收金額 4 已收金額 5 催收金額 6 催收次數
foreach ($value['facility'] as $valkey => $val) {
foreach ($contractstage as $stage) {
$val[$stage][0] = (!(isset($val[$stage][0])) || is_null($val[$stage][0])) ? "-" : $val[$stage][0];
$val[$stage][1] = (!(isset($val[$stage][1])) || is_null($val[$stage][1])) ? 0 : $val[$stage][1];
$val[$stage][2] = (!(isset($val[$stage][2])) || is_null($val[$stage][2])) ? "-" : $val[$stage][2];
$val[$stage][3] = (!(isset($val[$stage][3])) || is_null($val[$stage][3])) ? 0 : $val[$stage][3];
$val[$stage][4] = (!(isset($val[$stage][4])) || is_null($val[$stage][4])) ? 0 : $val[$stage][4];
$val[$stage][5] = (!(isset($val[$stage][5])) || is_null($val[$stage][5])) ? 0 : $val[$stage][5];
$val[$stage][6] = (!(isset($val[$stage][6])) || is_null($val[$stage][6])) ? 0 : $val[$stage][6];
}
$facility_array[$valkey] = [
$valkey, $key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6],
$val['sign'][0], $val['sign'][1], $val['sign'][2], $val['sign'][3], $val['sign'][4], $val['sign'][5], $val['sign'][6],
$val['second'][0], $val['second'][1], $val['second'][2], $val['second'][3], $val['second'][4], $val['second'][5], $val['second'][6],
$val['arrive'][0], $val['arrive'][1], $val['arrive'][2], $val['arrive'][3], $val['arrive'][4], $val['arrive'][5], $val['arrive'][6],
$val['install'][0], $val['install'][1], $val['install'][2], $val['install'][3], $val['install'][4], $val['install'][5], $val['install'][6],
$val['tryrun'][0], $val['tryrun'][1], $val['tryrun'][2], $val['tryrun'][3], $val['tryrun'][4], $val['tryrun'][5], $val['tryrun'][6],
$val['check'][0], $val['check'][1], $val['check'][2], $val['check'][3], $val['check'][4], $val['check'][5], $val['check'][6],
$val['delivery'][0], $val['delivery'][1], $val['delivery'][2], $val['delivery'][3], $val['delivery'][4], $val['delivery'][5], $val['delivery'][6],
$val['final'][0], $val['final'][1], $val['final'][2], $val['final'][3], $val['final'][4], $val['final'][5], $val['final'][6],
str_replace('<br>', '; ', $val['status']), $val['total_budget'], $val['receivable_budget']
];
if ($value['sign'][0] == "寶佳出貨前30天") {
$facility_boga_array[$valkey] = [
$valkey, $key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6],
$val['sign'][0], $val['sign'][1], $val['sign'][2], $val['sign'][3], $val['sign'][4], $val['sign'][5], $val['sign'][6],
$val['second'][0], $val['second'][1], $val['second'][2], $val['second'][3], $val['second'][4], $val['second'][5], $val['second'][6],
$val['arrive'][0], $val['arrive'][1], $val['arrive'][2], $val['arrive'][3], $val['arrive'][4], $val['arrive'][5], $val['arrive'][6],
$val['install'][0], $val['install'][1], $val['install'][2], $val['install'][3], $val['install'][4], $val['install'][5], $val['install'][6],
$val['tryrun'][0], $val['tryrun'][1], $val['tryrun'][2], $val['tryrun'][3], $val['tryrun'][4], $val['tryrun'][5], $val['tryrun'][6],
$val['check'][0], $val['check'][1], $val['check'][2], $val['check'][3], $val['check'][4], $val['check'][5], $val['check'][6],
$val['delivery'][0], $val['delivery'][1], $val['delivery'][2], $val['delivery'][3], $val['delivery'][4], $val['delivery'][5], $val['delivery'][6],
$val['final'][0], $val['final'][1], $val['final'][2], $val['final'][3], $val['final'][4], $val['final'][5], $val['final'][6],
str_replace('<br>', '; ', $val['status']), $val['total_budget'], $val['receivable_budget']
];
} else {
$facility_exclude_boga_array[$valkey] = [
$valkey, $key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6],
$val['sign'][0], $val['sign'][1], $val['sign'][2], $val['sign'][3], $val['sign'][4], $val['sign'][5], $val['sign'][6],
$val['second'][0], $val['second'][1], $val['second'][2], $val['second'][3], $val['second'][4], $val['second'][5], $val['second'][6],
$val['arrive'][0], $val['arrive'][1], $val['arrive'][2], $val['arrive'][3], $val['arrive'][4], $val['arrive'][5], $val['arrive'][6],
$val['install'][0], $val['install'][1], $val['install'][2], $val['install'][3], $val['install'][4], $val['install'][5], $val['install'][6],
$val['tryrun'][0], $val['tryrun'][1], $val['tryrun'][2], $val['tryrun'][3], $val['tryrun'][4], $val['tryrun'][5], $val['tryrun'][6],
$val['check'][0], $val['check'][1], $val['check'][2], $val['check'][3], $val['check'][4], $val['check'][5], $val['check'][6],
$val['delivery'][0], $val['delivery'][1], $val['delivery'][2], $val['delivery'][3], $val['delivery'][4], $val['delivery'][5], $val['delivery'][6],
$val['final'][0], $val['final'][1], $val['final'][2], $val['final'][3], $val['final'][4], $val['final'][5], $val['final'][6],
str_replace('<br>', '; ', $val['status']), $val['total_budget'], $val['receivable_budget']
];
}
}
}
$data = json_encode($excel_aray);
$boga_data = json_encode($boga_array);
$exclude_boga_data = json_encode($exclude_boga_array);
$facility_data = json_encode($facility_array);
$facility_boga_data = json_encode($facility_boga_array);
$facility_exclude_boga_data = json_encode($facility_exclude_boga_array);
?>
<style>
@ -791,16 +1015,23 @@ $exclude_boga_data = json_encode($exclude_boga_array);
}
</style>
<button type="button" onclick="downloadData()" class="btn btn-success btn-lg pull-right">全部<span class="glyphicon glyphicon-download-alt"></span></button>
<button type="button" onclick="exclude_bogaData()" class="btn btn-info btn-lg pull-right">不含寶佳<span class="glyphicon glyphicon-download-alt"></span></button>
<button type="button" onclick="bogaData()" class="btn btn-warning btn-lg pull-right">寶佳<span class="glyphicon glyphicon-download-alt"></span></button>
<?php
if (in_array(accountidToDepartId($user_id), array('220', '210')) || $user_id == 'M0060') {
?>
<a href="facility-price.php?<?= $token_link ?>" class="btn btn-primary btn-lg pull-right">合約作番明細</span></a>
<?php
}
?>
<div style="width: 98%;margin: 1%;">
<div class="btn-group btn-group-md " style="padding:10 px; width: 100%;">
<button type="button" style="width: 12%;" onclick="downloadData()" class="btn btn-success">全部<span class="glyphicon glyphicon-download-alt"></span></button>
<button type="button" style="width: 12%;" onclick="exclude_bogaData()" class="btn btn-info">不含寶佳<span class="glyphicon glyphicon-download-alt"></span></button>
<button type="button" style="width: 12%;" onclick="bogaData()" class="btn btn-warning">寶佳<span class="glyphicon glyphicon-download-alt"></span></button>
</div>
</div>
<div style="width: 98%;margin: 1%;">
<div class="btn-group btn-group-md" style="width: 100%;">
<button type="button" style="width: 12%;" onclick="downloadFacilityData('AllData')" class="btn btn-success btn-md">作番收款明細<span class="glyphicon glyphicon-download-alt"></span></button>
<button type="button" style="width: 12%;" onclick="downloadFacilityData('ExcludeData')" class="btn btn-info btn-md">不含寶佳作番收款明細<span class="glyphicon glyphicon-download-alt"></span></button>
<button type="button" style="width: 12%;" onclick="downloadFacilityData('BogaData')" class="btn btn-warning btn-md">寶佳作番收款明細<span class="glyphicon glyphicon-download-alt"></span></button>
</div>
</div>
<div style="width:98%;margin:1% ;overflow-x: auto;">
<table id="table_index" class="table table-striped table-bordered" style="width:100%;">
<thead>
@ -909,15 +1140,15 @@ if (in_array(accountidToDepartId($user_id), array('220', '210')) || $user_id ==
</div>
<script>
function showContract(BillNo) {
window.open('account-receivable-contract.php?BillNo=' + BillNo+'&<?= $token_link ?>', '發票範例', config = 'height=600, width=1200');
window.open('account-receivable-contract.php?BillNo=' + BillNo + '&<?= $token_link ?>', '發票範例', config = 'height=600, width=1200');
console.log(BillNo);
}
function test() {
var BillData = <?= $data ?>;
var BillData = <?= $boga_data ?>;
var form = document.createElement("form");
form.method = 'POST';
form.action = "account-receivable-excel.php?<?= $token_link ?>";
form.action = "account-receivable-excel.php?type=facility&<?= $token_link ?>";
var input = document.createElement("input");
input.type = "hidden";
input.name = "Bill";
@ -930,14 +1161,14 @@ if (in_array(accountidToDepartId($user_id), array('220', '210')) || $user_id ==
function downloadData() {
var xhr = new XMLHttpRequest();
var url = window.location.origin + "/wms/account-receivable-excel.php?<?= $token_link ?>";
var url = window.location.origin + "/wms/account-receivable-excel.php?type=all&<?= $token_link ?>";
xhr.open('POST', url, true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
var file_path = xhr.responseText;
var link = document.createElement('a');
var name = "應收帳款" + "<?= date('Y-m-d-Hm') ?>" + ".xlsx";
var name = "全部應收帳款" + "<?= date('Y-m-d-Hm') ?>" + ".xlsx";
link.setAttribute('href', window.location.origin + "/wms/account-receivable-test.xlsx");
link.setAttribute('download', name);
link.style.display = 'none';
@ -959,14 +1190,14 @@ if (in_array(accountidToDepartId($user_id), array('220', '210')) || $user_id ==
function bogaData() {
var xhr = new XMLHttpRequest();
var url = window.location.origin + "/wms/account-receivable-excel.php?<?= $token_link ?>";
var url = window.location.origin + "/wms/account-receivable-excel.php?type=boga&<?= $token_link ?>";
xhr.open('POST', url, true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
var file_path = xhr.responseText;
var link = document.createElement('a');
var name = "應收帳款" + "<?= date('Y-m-d-Hm') ?>" + ".xlsx";
var name = "寶佳應收帳款" + "<?= date('Y-m-d-Hm') ?>" + ".xlsx";
link.setAttribute('href', window.location.origin + "/wms/account-receivable-test.xlsx");
link.setAttribute('download', name);
link.style.display = 'none';
@ -981,17 +1212,52 @@ if (in_array(accountidToDepartId($user_id), array('220', '210')) || $user_id ==
}
function downloadFacilityData(content) {
if (content == 'AllData') {
var BillData = <?= $facility_data ?>;
var filename = "作番應收帳款" + "<?= date('Y-m-d-Hm') ?>" + ".xlsx";
}
else if(content == 'ExcludeData') {
var BillData = <?= $facility_exclude_boga_data ?>;
var filename = "不含寶佳作番應收帳款" + "<?= date('Y-m-d-Hm') ?>" + ".xlsx";
}
else if(content == 'BogaData'){
var BillData = <?= $facility_boga_data ?>;
var filename = "寶佳作番應收帳款" + "<?= date('Y-m-d-Hm') ?>" + ".xlsx";
}
var xhr = new XMLHttpRequest();
var url = window.location.origin + "/wms/account-receivable-excel.php?type=facility&<?= $token_link ?>";
xhr.open('POST', url, true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
var file_path = xhr.responseText;
var link = document.createElement('a');
link.setAttribute('href', window.location.origin + "/wms/account-receivable-facility.xlsx");
link.setAttribute('download', filename);
link.style.display = 'none';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
}
xhr.send(JSON.stringify({
Bill: BillData
}));
}
function exclude_bogaData() {
var xhr = new XMLHttpRequest();
var url = window.location.origin + "/wms/account-receivable-excel.php?<?= $token_link ?>";
var url = window.location.origin + "/wms/account-receivable-excel.php?type=exclude_boga&<?= $token_link ?>";
xhr.open('POST', url, true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
var file_path = xhr.responseText;
var link = document.createElement('a');
var name = "應收帳款" + "<?= date('Y-m-d-Hm') ?>" + ".xlsx";
var name = "不含寶佳應收帳款" + "<?= date('Y-m-d-Hm') ?>" + ".xlsx";
link.setAttribute('href', window.location.origin + "/wms/account-receivable-test.xlsx");
link.setAttribute('download', name);
link.style.display = 'none';

54
wms/account-receivable-test.php

@ -9,24 +9,36 @@
// echo $test;
include './header.php';
$sql = "SELECT
salOrderStagePay.BillNo,
salOrderStagePay.PayStage
FROM salOrderStagePay
LEFT JOIN salSalesOrder
ON salSalesOrder.BillNo = salOrderStagePay.BillNo WHERE salSalesOrder.ModeId = 'M' AND (salSalesOrder.CurrentState=2 OR salSalesOrder.CurrentState=4) ";
$query = $conn->query($sql);
$contracts = array();
foreach ($query as $row) {
if (!array_key_exists($row['BillNo'], $contracts)) {
$contracts[$row['BillNo']] = [$row['BillNo'], $row['PayStage']];
}else{
array_push($contracts[$row['BillNo']], $row['PayStage']);
}
}
foreach($contracts as $contract){
foreach($contract as $con){
echo $con.";";
}
echo "<br>";
}
// $sql = "SELECT
// salOrderStagePay.BillNo,
// salOrderStagePay.PayStage
// FROM salOrderStagePay
// LEFT JOIN salSalesOrder
// ON salSalesOrder.BillNo = salOrderStagePay.BillNo WHERE salSalesOrder.ModeId = 'M' AND (salSalesOrder.CurrentState=2 OR salSalesOrder.CurrentState=4) ";
// $query = $conn->query($sql);
// $contracts = array();
// foreach ($query as $row) {
// if (!array_key_exists($row['BillNo'], $contracts)) {
// $contracts[$row['BillNo']] = [$row['BillNo'], $row['PayStage']];
// }else{
// array_push($contracts[$row['BillNo']], $row['PayStage']);
// }
// }
// foreach($contracts as $contract){
// foreach($contract as $con){
// echo $con.";";
// }
// echo "<br>";
// }
//只有一個作番的銷售訂單
// $sql = "select salSalesOrderDetail.BillNo,count(salSalesOrderDetail.MaterialId) AS number from salSalesOrderDetail
// LEFT JOIN salSalesOrder ON salSalesOrder.BillNo=salSalesOrderDetail.BillNo
// where salSalesOrderDetail.ItemType=0 AND salSalesOrder.ModeId='M'
// group by salSalesOrderDetail.BillNo ORDER BY number";
// $query = $conn->query($sql);
// foreach($query as $row){
// if($row['number']==1){
// echo $row['BillNo']."<br>";
// }
// }

BIN
wms/account-receivable-test.xlsx

Binary file not shown.

31815
wms/account_receivable_sql_file.sql

File diff suppressed because it is too large

6
wms/cont/sign_list.php

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

167
wms/contract-repair/api/putContractData.php

@ -6,7 +6,7 @@ ini_set('date.timezone', 'Asia/Taipei');
if (isset($_POST['contracttype']) && $_POST['contracttype'] == 'r' && isset($_POST["id"]) && $_POST['id'] != "") {
try {
$create_date = date('Y-m-d H:i:s');
$repair_no = !empty($POST['repair_no']) ? $_POST['repair_no'] : null;
$repair_no = !empty($_POST['repair_no']) ? $_POST['repair_no'] : null;
$contractno = !empty($_POST['contractno']) ? $_POST['contractno'] : null;
$company = !empty($_POST['company']) ? $_POST['company'] : null;
$taxid = !empty($_POST['taxid']) ? $_POST['taxid'] : null;
@ -21,7 +21,7 @@ if (isset($_POST['contracttype']) && $_POST['contracttype'] == 'r' && isset($_PO
$fail_arr = [];
// if (empty($repair_no)) $fail_arr[] = '號為必填';
if (empty($contractno)) $fail_arr[] = '合約號為必填';
// if (empty($contractno)) $fail_arr[] = '合約號為必填';
if (empty($company)) $fail_arr[] = '客戶名稱為必填';
if (empty($taxid)) $fail_arr[] = '統一編號為必填';
if (empty($facilityno)) $fail_arr[] = '電梯號為必填';
@ -35,7 +35,7 @@ if (isset($_POST['contracttype']) && $_POST['contracttype'] == 'r' && isset($_PO
echo json_encode($fail_arr);
exit();
}
// $conn->beginTransaction();
$conn->beginTransaction();
$sql = "UPDATE contract_r_signed_back SET
repaireid = :repaireid,facilityno= :facilityno, invoice=:invoice, taxid=:taxid, address=:address,type=:type,contract_status=:contract_status,update_user=:update_user,update_date=:update_date
@ -56,135 +56,60 @@ if (isset($_POST['contracttype']) && $_POST['contracttype'] == 'r' && isset($_PO
// echo json_encode($sql);
// exit;
$stmt->execute();
t8Insert($_POST);
// header("HTTP/1.1 204 NO Content");
// $conn->commit();
$conn->commit();
} catch (PDOException $e) {
// $conn->rollback();
header("HTTPP/1.1 500 Internal Server Error");
die('Error!:' . $e->getMessage());
}
}
// if (isset($_POST['contractno']) && $_POST['contractno'] != "" && isset($_POST["id"]) && $_POST['id'] != "") {
// try {
// $created_at = date('Y-m-d H:i:s');
// $created_by = $_POST['user_id'];
// $id = $_POST["id"];
// $contract_no = !empty($_POST['contractno']) ? $_POST['contractno'] : null;
// $customer = !empty($_POST['customer']) ? $_POST['customer'] : null;
// $manager = !empty($_POST['manager']) ? $_POST['manager'] : null;
// $vat = !empty($_POST['vat']) ? $_POST['vat'] : null;
// $case_name = !empty($_POST['case_name']) ? $_POST['case_name'] : null;
// $linkman = !empty($_POST['linkman']) ? $_POST['linkman'] : null;
// $lm_tel = !empty($_POST['lm_tel']) ? $_POST['lm_tel'] : null;
// $address = !empty($_POST['address']) ? $_POST['address'] : null;
// $salesman = !empty($_POST['salesman']) ? $_POST['salesman'] : null;
// $qc = !empty($_POST['qc']) ? $_POST['qc'] : null;
// $deletefiles = !empty($_POST['deletefiles']) ? $_POST['deletefiles'] : null;
// $files_id = !empty($_POST['files_id']) ? $_POST['files_id'] : null;
// $files = !empty($_FILES['files']) ? $_FILES['files'] : null;
// $deletefilesArr = explode(',', $_POST['deletefiles']);
function t8Insert($data)
{
require_once('../../contract/connt8.php');
$create_date = date('Y-m-dH-i-s');
$repair_no = !empty($data['repair_no']) ? $data['repair_no'] : null; // 報價單號
$company = !empty($data['company']) ? $data['company'] : null; //立約人
$repaireid = !empty($data['repaireid']) ? $data['repaireid'] : null; //維保人員
$facilityno = !empty($data['facilityno']) ? $data['facilityno'] : null; // 電梯編號
$type = !empty($data['type']) ? $data['type'] : null; //工程進度
$sign_date = !empty($data['sign_date']) ? $data['sign_date'] : null; //簽訂時間
$invoice = !empty($data['invoice']) ? $data['invoice'] : null; // 發票抬頭
$taxid = !empty($data['taxid']) ? $data['taxid'] : null; //統編
$address = !empty($data['address']) ? $data['address'] : null; //工程地址
$contract_status = !empty($data['contract_status']) ? $data['contract_status'] : null;
$user_id = !empty($_data['user_id']) ? $data['user_id'] : null;
// $fail_arr = [];
// if (empty($contract_no)) $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();
// }
$sign = str_replace("-", '', $sign_date);
$create = str_replace('-', '', $create_date);
// $conn->beginTransaction();
$sql = "INSERT INTO comBusinessPartner
(BizPartnerId,BizPartnerName,BusinessAttr,CountryId,BizToDate,TaxNo,ContactAddress,CreatorId,CreateTime,BizPartnerTypeId)
VALUES(:BizPartnerId,:BizPartnerName,1,'TW',99999999,:TaxNo,:ContactAddress,:CreatorId,:CreateTime,'10')";
$stmt = $connT8->prepare($sql);
$stmt->bindParam(':BizPartnerId', $repair_no); //報價單編號
$stmt->bindParam(':BizPartnerName', $company);
$stmt->bindParam(':TaxNo', $taxid);
$stmt->bindParam(':ContactAddress', $address);
$stmt->bindParam(':CreatorId', $user_id);
$stmt->bindParam(':CreateTime', $create);
$stmt->execute();
// $sql_str = "UPDATE contract_m_signed_back SET contract_no=:contract_no, customer=:customer, manager=:manager, vat=:vat, case_name=:case_name, linkman=:linkman, lm_tel=:lm_tel, address=:address, salesman=:salesman, qc_official_type=:qc WHERE id = :id";
// $stmt = $conn->prepare($sql_str);
// $stmt->bindParam(':contract_no', $contract_no);
// $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(':qc', $qc);
// $stmt->bindParam(':id', $id);
// $stmt->execute();
// if (!empty($deletefiles)) {
// $sql_str = "DELETE FROM contract_back_files WHERE id IN ($deletefiles)";
// $stmt = $conn->prepare($sql_str);
// $stmt->execute();
// }
$sql = "INSERT INTO comCustomer
(OrgId,BizPartnerTypeId,CurrId,BizPartnerId,PersonId,CreatorId,IsInUsed,InvoiceAddress,CreateTime)
VALUES('1000','10','TWD',:BizPartnerId,:PersonId,:CreatorId,1,:InvoiceAddress,:CreateTime)";
$stmt = $connT8->prepare($sql);
$stmt->bindParam(':BizPartnerId', $repair_no);
$stmt->bindParam(':PersonId', $salesman);
$stmt->bindParam(':CreatorId', $user_id);
$stmt->bindParam(':InvoiceAddress', $address);
$stmt->bindParam(':CreateTime', $create);
$stmt->execute();
// 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 = ($files_id !== null) ? $files_id : 'm' . $datetime; // 新梯=>m + 日期時間
// 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 = "INSERT INTO ";
// $conn->commit();
// } catch (PDOException $e) {
// $conn->rollback();
// header("HTTP/1.1 500 Internal Server Error");
// die('Error!:' . $e->getMessage());
// }
// }
$connT8->commit();
}

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

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

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

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

237
wms/contract/api/postContractData.php

@ -1,8 +1,10 @@
<?php
require_once("../conn.php");
// require_once("../connt8.php");
include_once("./getFacilityNo.php");
include_once("./getComboNo.php");
include_once("./upload_chk.php");
ini_set('date.timezone', 'Asia/Taipei');
//保養簽回
if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['contracttype']) && $_POST['contracttype'] == 'b') {
@ -32,6 +34,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
$num = !empty($_POST['num']) ? $_POST['num'] : null;
$files = !empty($_FILES['files']) ? $_FILES['files'] : null;
$elevators = !empty($_POST['elevators']) ? json_decode($_POST['elevators'], true) : [];
$payType = !empty($_POST['payType']) ? $_POST['payType'] : null;
// validate
$fail_arr = [];
if ($contractno === '') return $fail_arr[] = '合約號為必填';
@ -54,6 +57,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
if ($partyAphone == '') $fail_arr[] = '業務聯繫人電話為必填';
if ($partyAemail == '') $fail_arr[] = '業務聯繫人Email為必填';
if ($num == '') $fail_arr[] = '電梯數量為必填';
if ($payType == '') $fail_arr[] = '付款方式為必填';
if (count($fail_arr) > 0) {
header("HTTP/1.1 422 Unprocessable Entity");
echo json_encode($fail_arr);
@ -137,7 +141,14 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
$facility_arr[] = $dailyNecessities[$elevator['spec']];
}
echo json_encode($facility_arr);
// 電梯做番號
$facilityno = $createFacilityNo->makeBFacilityNo("T", $facility_arr, (int)$num);
// if ($user_id == 'M0225') {
// echo '<pre>';
// print_r($facilityno);
// echo '</pre>';
// exit();
// }
echo json_encode($facilityno);
echo '-------';
$sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid";
@ -274,8 +285,8 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
} else {
$files = null;
}
$sql_str = "INSERT INTO contract_b_signed_back (contract_no, contract_type, company, customer_no, salesperson, contract_start_date, contract_end_date, total_price, customer_phone, customer_email, repairman, cycle, contact_person, contact_address, contact_phone, contact_email, elevators_number, area, address, files_id, bonus, max_bonus, created_at, created_by)
VALUES (:contract_no, :contract_type, :company, :customer_no, :salesperson, :contract_start_date, :contract_end_date, :total_price, :customer_phone, :customer_email, :repairman, :cycle, :contact_person, :contact_address, :contact_phone, :contact_email, :elevators_number, :area, :address, :files_id, :bonus, :max_bonus, :created_at, :created_by)";
$sql_str = "INSERT INTO contract_b_signed_back (contract_no, contract_type, company, customer_no, salesperson, contract_start_date, contract_end_date, total_price,payType, customer_phone, customer_email, repairman, cycle, contact_person, contact_address, contact_phone, contact_email, elevators_number, area, address, files_id, bonus, max_bonus, created_at, created_by)
VALUES (:contract_no, :contract_type, :company, :customer_no, :salesperson, :contract_start_date, :contract_end_date, :total_price, :payType ,:customer_phone, :customer_email, :repairman, :cycle, :contact_person, :contact_address, :contact_phone, :contact_email, :elevators_number, :area, :address, :files_id, :bonus, :max_bonus, :created_at, :created_by)";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(":contract_no", $contractno);
$stmt->bindParam(":contract_type", $contract_type);
@ -301,9 +312,23 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
$stmt->bindParam(":max_bonus", $max_bonus);
$stmt->bindParam(":created_at", $created_at);
$stmt->bindParam(":created_by", $user_id);
$stmt->bindParam(':payType', $payType);
$stmt->execute();
// $date = date('Y-m-sH-s-i');
// $createTime = str_replace("-", '', $date);
// $sql = "INSERT INTO comCustomer(BizPartnerId,PersonId,CreatorId,IsInUsed,InvoiceAddress,CreateTime)VALUES(:BizPartnerId,:PersonId,:CreatorId,1,:InvoiceAddress,:CreateTime)";
// $stmt = $connT8->prepare($sql);
// $stmt->bindParam(':BizPartnerId', $contractno);
// $stmt->bindParam(':PersonId', $salesman);
// $stmt->bindParam(':CreatorId', $user_id);
// $stmt->bindParam(':InvoiceAddress', $address);
// $stmt->bindParam(':CreateTime', $createTime);
// $stmt->execute();
// T8insert($_POST, $facilityno);
header('Content-Type: application/json');
$jsonData = json_encode($files);
@ -314,4 +339,212 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
echo $e->getMessage();
die('Error!:' . $e->getMessage());
}
};
function T8insert($data, $facilityno)
{
require_once("../connt8.php");
// include "../../T8_Authorization.php";
$contractno = !empty($data['contractno']) ? $data['contractno'] : null; // 合約號
$address = !empty($data['address']) ? $data['address'] : null; // 客戶地址
$customer = !empty($data['customer']) ? $data['customer'] : null; //企業名稱
$phone = !empty($data['phone']) ? $data['phone'] : null; //客戶電話
$vat = !empty($data['vat']) ? $data['vat'] : null; //統編
$email = !empty($data['email']) ? $data['email'] : null;
$salesman = !empty($data['salesman']) ? $data['salesman'] : null; // 銷售人員
$partyA = !empty($data['partyA']) ? $data['partyA'] : null; //客戶名稱 / 業務聯絡人
$partyAaddress = !empty($data['partyAaddress']) ? $data['partyAaddress'] : null; // 業務聯絡人地址
$contract_begin_date = !empty($data['contract_begin_date']) ? $data['contract_begin_date'] : null;
$contract_end_date = !empty($data['contract_end_date']) ? $data['contract_end_date'] : null;
$num = !empty($data['num']) ? $data['num'] : null; // 電梯數量
$elevators = !empty($data['elevators']) ? json_decode($data['elevators'], true) : []; //電梯
$area = !empty($data['area']) ? $data['area'] : null; //縣市 Ex. A->台北 , B-> ..。
$user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null;
$connT8->beginTransaction();
$sql = "SELECT * FROM comCustomer WHERE BizPartnerId = :BizPartnerId";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':BizPartnerId', $contractno);
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
$date = date('Y-m-sH-s-i');
$createTime = str_replace("-", '', $date);
$beginDate = str_replace("-", '', $contract_begin_date);
$endDate = str_replace("-", '', $contract_end_date);
if ($contractno == '') {
echo 'Error';
exit;
}
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)
VALUES('1000','10','TWD',:BizPartnerId,:PersonId,:CreatorId,1,:InvoiceAddress,:CreateTime)";
$stmt = $connT8->prepare($sql);
$stmt->bindParam(':BizPartnerId', $contractno);
$stmt->bindParam(':PersonId', $salesman);
$stmt->bindParam(':CreatorId', $user_id);
$stmt->bindParam(':InvoiceAddress', $address);
$stmt->bindParam(':CreateTime', $createTime);
$stmt->execute();
} 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();
}
// echo '<pre>';
// print_r($elevators['maintainance']);
// echo '</pre>';
foreach ($elevators as $index => $elevator) {
$type[] = $elevator['maintainance'];
if ($type[$index] == 'A') {
$type = 'C3';
} else if ($type[$index] == 'B') {
$type = 'C4';
} else if ($type[$index] == 'C') {
$type = 'C5';
}
}
// echo '<pre>';
// print_r($type);
// echo '</pre>';
// //新增於 comProject。合約 table
$sql = "INSERT INTO comProject(ProjectId,ProjectName,TypeId,ValidityFromDate,ValidityToDate,CreateTime,CreatorId,IsInUsed)
VALUES(:ProjectId,:ProjectName,:TypeId,:ValidityFromDate,:ValidityToDate,:CreateTime,:CreatorId,1)";
$stmt = $connT8->prepare($sql);
$stmt->bindParam(':ProjectId', $contractno);
$stmt->bindParam(':ProjectName', $customer);
$stmt->bindParam(':TypeId', $type);
$stmt->bindParam(':ValidityFromDate', $beginDate);
$stmt->bindParam(':ValidityToDate', $endDate);
$stmt->bindParam(':CreateTime', $createTime);
$stmt->bindParam(':CreatorId', $user_id);
$stmt->execute();
// // 新增電梯數
foreach ($elevators as $index => $elevator) {
// echo '<pre>';
// print_r($elevator);
// echo '</pre>';
$sql = "INSERT INTO comMaterial
(FOrgid,MaterialId,MaterialTypeId,MaterialCategoryId,CreatorId,CreateTime)
VALUES ('1000',:MaterialId,'10','E',:CreatorId,:CreateTime)";
$stmt = $connT8->prepare($sql);
$stmt->bindParam(':MaterialId', $facilityno[$index]);
$stmt->bindParam(':CreatorId', $user_id);
$stmt->bindParam(':CreateTime', $createTime);
$stmt->execute();
$sql = "INSERT INTO comMaterialGroup
(MaterialTypeId,MaterialId,MaterialName,MaterialCategoryId,IsInUsed,UnitId,CreatorId,CreateTime)
VALUES ('10',:MaterialId,:MaterialName,'E',1,'SET',:CreatorId,:CreateTime)";
$stmt = $connT8->prepare($sql);
$stmt->bindParam(':MaterialId', $facilityno[$index]);
$stmt->bindParam(':MaterialName', $customer);
$stmt->bindParam(':CreatorId', $user_id);
$stmt->bindParam(':CreateTime', $createTime);
$stmt->execute();
$sql = "INSERT INTO comMaterialPurchases
(Orgid,MaterialTypeId,MaterialId,CurrId,SUnitId,TaxId,CreatorId,CreateTime)
VALUES ('1000','10',:MaterialId,'TWD','SET','ST005',:CreatorId,:CreateTime)";
$stmt = $connT8->prepare($sql);
$stmt->bindParam(':MaterialId', $facilityno[$index]);
$stmt->bindParam(':CreatorId', $user_id);
$stmt->bindParam(':CreateTime', $createTime);
$stmt->execute();
}
?>
<!-- <script src="./js/axios/axios.min.js"></script>
<script>
const form = new FormData();
form.append('BillNo', <?php echo $contractno ?>);
form.append('BillDate', );
form.append('');
form.append('');
form.append('');
form.append('');
form.append('');
axios.post('https://127.0.0.1:780/twWebAPI/V1/SALINCOMEAPPLY/PostERPData', form).then(res => {
console.log(res.status);
if (res.status == 200) {
alert('成功');
}
}).catch(err => {
console.log(err);
let code = err.response.data;
if (code == 422) {
console.log(err);
}
if (code == 500) {
alert('儲存失敗!可能為下載錯誤:\n' + error.response.data);
}
})
</script> -->
<?php
$connT8->commit();
}

48
wms/contract/api/postContractNewApplyData.php

@ -9,7 +9,7 @@ if ($_SERVER['REQUEST_METHOD'] != 'POST') {
exit();
}
//暫存、送審
if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] == 0 || $_POST['status'] == 1)) {
if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] == 0 || $_POST['status'] == 1) && $_POST['progress'] <= 1) {
if ($_POST['regulations'] < 10) {
header("HTTP/1.1 500 傳送失敗!!試車時間不得低於10天");
exit;
@ -31,12 +31,14 @@ if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] ==
$contact_address = $_POST['address'];
$workdeadline_a = $_POST['workdeadline_a'];
$workdeadline_b = $_POST['workdeadline_b'];
$workdeadline_note = $_POST['workdeadline_note'];
$test_time = $_POST['regulations'];
$freedeadline = $_POST['freedeadline'];
$trade_address = $_POST['tradeaddress'];
$tradedeadline = $_POST['tradedeadline'];
$secondPayDeadline = $_POST['secondPayDeadline'];
$pays = $_POST['pays'];
$description = $_POST['description'];
$status = $_POST['status']; // 0:暫存 1:送審 2:退回 3:完成
$pays = json_decode($pays, true);
@ -55,7 +57,7 @@ if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] ==
$conn->beginTransaction();
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)";
$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, description) 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, :description)";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid);
$stmt->bindParam(':contractno', $vol_no);
@ -85,6 +87,7 @@ if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] ==
$stmt->bindParam(':submit_date', $submit_date);
$stmt->bindParam(':created_at', $created_at);
$stmt->bindParam(':created_by', $created_by);
$stmt->bindParam(':description', $description);
$stmt->execute();
$contract_apply_id = $conn->lastInsertId();
foreach ($pays as $idx => $pay) {
@ -160,7 +163,7 @@ if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] ==
header("HTTP/1.1 201 success!");
$conn->commit();
} 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";
$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, workdeadline_note=:workdeadline_note, 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, description=:description WHERE mid = :mid";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid', $mid);
$stmt->bindParam(':status', $status);
@ -177,6 +180,7 @@ if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] ==
$stmt->bindParam(':contact_address', $contact_address);
$stmt->bindParam(':workdeadline_a', $workdeadline_a);
$stmt->bindParam(':workdeadline_b', $workdeadline_b);
$stmt->bindParam(':workdeadline_note', $workdeadline_note);
$stmt->bindParam(':test_time', $test_time);
$stmt->bindParam(':freedeadline', $freedeadline);
$stmt->bindParam(':trade_address', $trade_address);
@ -188,6 +192,7 @@ if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] ==
$stmt->bindParam(':submit_date', $submit_date);
$stmt->bindParam(':updated_at', $updated_at);
$stmt->bindParam(':updated_by', $updated_by);
$stmt->bindParam(':description', $description);
$stmt->execute();
foreach ($pays as $idx => $pay) {
@ -205,7 +210,7 @@ if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] ==
$stmt->execute();
}
$deleted_at = date("Y-m-d H:i:s");
$removefiles = json_decode($_POST['removefiles'], true);
$removefiles = isset($_POST['removefiles']) ? json_decode($_POST['removefiles'], true) : [];
print_r($removefiles);
if(count($removefiles) > 0){
foreach($removefiles as $file){
@ -216,10 +221,6 @@ if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] ==
$stmt ->execute();
}
}
header("HTTP/1.1 201 success!");
$conn->commit();
}
@ -230,6 +231,35 @@ if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] ==
die('Error!:' . $e->getMessage());
}
}
//業務部承辦人同意
if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] == 1) && $_POST['progress'] == 2) {
$status = $_POST['status'];
$vol_no = $_POST['vol_no'];
$contract_new_apply_id = $_POST['contract_new_apply_id'];
$progress = $_POST['progress'];
$review_comment = $_POST['review_comment'];
$user_id = $_POST['review_person_id'];
$review_date = date('Y-m-d H:i:s');
$conn->beginTransaction();
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->execute();
header("HTTP/1.1 200 success!");
$conn->commit();
} catch (PDOException $e) {
$conn->rollback();
header("HTTP/1.1 500 failed!");
echo $e->getMessage();
die('Error!:' . $e->getMessage());
}
}
//結案同意
if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] == 3)) {
$status = $_POST['status'];
@ -241,7 +271,7 @@ if (isset($_POST['vol_no']) && !empty($_POST['vol_no']) && ($_POST['status'] ==
$review_date = date('Y-m-d H:i:s');
$conn->beginTransaction();
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";
$sql_str = "UPDATE contract_new_apply SET status = :status, progress = :progress, review_final_comment=:review_comment, review_final_person_id=:review_person_id, review_final_date=:review_date WHERE id = :contract_new_apply_id";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':status', $status);
$stmt->bindParam(':progress', $progress);

77
wms/contract/api/testT8API.php

@ -0,0 +1,77 @@
<?php
$now = gmdate("YmdHis");
$data = 'M0000.' . $now;
$sign = hash_hmac('SHA256', $data, 'B2D6395D2883E26C', false);
?>
<script src="https://code.jquery.com/jquery-3.4.1.js" integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU=" crossorigin="anonymous"></script>
<script>
var body = [{
"name": "salIncomeApplyMaster",
"rows": [{
"BillNo": "Z001",
"BillDate": 20160811,
"OrgId": "1000",
"FOrgId": "1000",
"TypeId": "RR",
"BpOrgId": "1000",
"BizPartnerId": "C002",
"CurrId": "RMB",
"CurrOAmount": 1,
"CurrLAmount": 1,
"PersonId": "T001",
"DtOrgId": "1000",
"DueToId": "C002",
"TaxId": "123",
"CompId": "1000"
}]
},
{
"name": "salIncomeApplyDetail",
"rows": [{
"BillNo": "Z001",
"IncomeId": "F203",
"TaxId": "ST003",
"RowCode": 1,
"ItemType": "1",
"SPrice": 50,
"SQuantity": 1,
"FromSourceTag": 0,
"FromBillNo": "123"
}]
}
]
var json = JSON.stringify(body);
console.log(json);
// obj = {
// type: 'POST',
// // url: `${corsurl}${apiurl}`,
// url: `${apiurl}`,
// dataType: 'json',
// headers: headerParam,
// data: json,
// // dataType: "json",
// success: function(res) {
// console.log(res.Status);
// console.log(res.ErrorMsg);
// console.log(res.Data);
// }
// };
// jQuery.ajax(obj);
// // }
// })
$.ajax({
url: 'https://127.0.0.1:780/twWebAPI/V1/SALINCOMEAPPLY/PostERPData',
method: 'POST',
dataType: 'json',
// headers: headerParam,
data: body,
success: function(res) {
console.log('Success');
},
error: function(err) {
console.log(err);
}
})
</script>

29
wms/contract/conn.php

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

15
wms/contract/connt8.php

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

645
wms/contract/contract-input.php

@ -5,13 +5,13 @@ include_once("./api/getFacilityNo.php");
$accounttype = "B";
$sql_str = "SELECT accountid, name FROM account WHERE accounttype = :accounttype";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':accounttype',$accounttype);
$stmt->bindParam(':accounttype', $accounttype);
$stmt->execute();
$workers = $stmt->fetchAll(PDO::FETCH_ASSOC);
$accounttype = "M";
$sql_str = "SELECT id,accountid, name FROM account WHERE accounttype = :accounttype";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':accounttype',$accounttype);
$stmt->bindParam(':accounttype', $accounttype);
$stmt->execute();
$contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
?>
@ -19,331 +19,354 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
<link rel="stylesheet" href="semantic/dist/semantic.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script defer src="./js/alpinejs/cdn.min.js"></script>
<script src="./js/axios/axios.min.js" ></script>
<script src="./js/axios/axios.min.js"></script>
<div class="contract-input-component" x-data="contractInput">
<div class="form" method="post" id="form" enctype="multipart/form-data" >
<input type="hidden" name='form_name' value="main_form" />
<div>
<table class="table table-bordered query-table table-striped table-bordered display compact" style="width:99%;margin-left:.5%">
<thead>
<tr>
<td colspan="8">
<h3 style='text-align:center'>合約入力(保養)</h3>
</td>
</tr>
</thead>
<template x-if="step==1">
<tbody style="font-weight: bolder;margin-bottom: 20px" x-show="step==1">
<tr>
<td style="vertical-align: middle">合約號</td>
<td colspan="5">
<input class="form-control" @keyup="nextStepKeyupFn($event)" type="text" name="contractno" x-model="data.contractno" >
</td>
<td colspan="2" style="vertical-align: middle">
<label for="customize">
<input type="checkbox" x-model="customize" id="customize" />自定義欄位
</label>
</td>
<div class="form" method="post" id="form" enctype="multipart/form-data">
<input type="hidden" name='form_name' value="main_form" />
<div>
<table class="table table-bordered query-table table-striped table-bordered display compact" style="width:99%;margin-left:.5%">
<thead>
<tr>
<td colspan="8">
<h3 style='text-align:center'>合約入力(保養)</h3>
</td>
</tr>
</thead>
<template x-if="step==1">
<tbody style="font-weight: bolder;margin-bottom: 20px" x-show="step==1">
<tr>
<td style="vertical-align: middle">合約號</td>
<td colspan="5">
<input class="form-control" @keyup="nextStepKeyupFn($event)" type="text" name="contractno" x-model="data.contractno">
</tr>
</tbody>
</template>
<template x-if="step==2">
<tbody style="font-weight: bolder;margin-bottom: 20px" x-show="step==2">
<tr>
<td colspan="7" style='vertical-align: middle;border-right:0px;'>
<h4>業務確認項</h4>
</td>
<td class="text-right" style='border-left:0px;'>
<button type="button" id="btn_close" class="btn btn-default" onclick="window.history.back();">返回</button>
<button type="button" id="btn_close" class="btn btn-default" onclick="window.close();">關閉分頁</button>
</td>
</tr>
<tr>
<td style="vertical-align: middle">立約人</td>
<td>
<input type="text" x-model="data.customer" />
<p class="alerttext" x-show="data.customer==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">營業員</td>
<td>
<select class="ui fluid search dropdown" name="promiser" x-model="data.salesman">
<option value="">選擇營業員</option>
<?php foreach($contractpersons as $person){ ?>
<option value="<?php echo $person['accountid'] ?>"><?php echo $person['name'] ?></option>
<?php } ?>
</select>
<p class="alerttext" x-show="data.salesman==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">合約開始時間</td>
<td>
<input class="form-control disabled_select" type="date" name="start_date" x-model="data.contract_begin_date" >
<p class="alerttext" x-show="data.contract_begin_date==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">合約終止時間</td>
<td>
<input class="form-control disabled_select" type="date" name="end_date" x-model="data.contract_end_date" >
<p class="alerttext" x-show="data.contract_end_date==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
</tr>
<tr>
<td style="vertical-align: middle">電梯台數</td>
<td>
<input class="form-control disabled_select" type="number" x-model="data.num" :disabled="data.disabled">
<p class="alerttext" x-show="data.num==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
<p class="alerttext" x-show="data.num==0 && data.num!=''"><i class="fa-solid fa-circle-xmark"></i>電梯數量需大於0</p>
</td>
</td>
<td colspan="2" style="vertical-align: middle">
<label for="customize">
<input type="checkbox" x-model="customize" id="customize" />自定義欄位
</label>
</td>
<td style="vertical-align: middle">統一編號/身分證</td>
<td>
<input class="form-control disabled_select" type="text" name="uscc" x-model="data.vat" >
<p class="alerttext" x-show="data.vat==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">維修型態</td>
<td style="vertical-align: middle">
<select class="ui search dropdown" name="" x-model="data.mtype">
<option value="" >選擇維修型態</option>
<option value="A">定期保養</option>
</select>
<p class="alerttext" x-show="data.mtype==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td></td>
<td></td>
</tr>
<tr>
<td style="vertical-align: middle">客戶電話</td>
<td>
<input class="form-control disabled_select" type="text" name="tel" x-model="data.phone" >
<p class="alerttext" x-show="data.phone==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">Email</td>
<td style="vertical-align: middle">
<input class="form-control disabled_select" type="email" name="email" x-model="data.email" >
<p class="alerttext" x-show="data.email==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">保養員</td>
<td>
<select class="ui search dropdown" name="repairer_name" x-model="data.mworker">
<option value="">選擇保養員</option>
<?php foreach($workers as $worker){ ?>
<option value="<?php echo $worker['accountid']; ?>"><?php echo $worker['name'] ?></option>
<?php } ?>
</select>
<p class="alerttext" x-show="data.mworker==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">保養頻率</td>
<td>
<select class="ui search dropdown" name="repairer_name" x-model="data.mcycle">
<option value="">選擇保養頻率</option>
<option value="bw">雙週保</option>
<option value="em">月保</option>
</select>
<p class="alerttext" x-show="data.mcycle==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
</tr>
<tr>
<td style="vertical-align: middle">業務聯繫人</td>
<td>
<input type="text" x-model="data.partyA" name="partyA" />
<p class="alerttext" x-show="data.partyA==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">業務聯繫人地址</td>
<td>
<input class="form-control disabled_select" x-model="data.partyAaddress" type="text" name="contractaddress" value="" >
<p class="alerttext" x-show="data.partyAaddress==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">業務聯繫人電話</td>
<td>
<input class="form-control disabled_select" type="text" name="contracttel" x-model="data.partyAphone" >
<p class="alerttext" x-show="data.partyAphone==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">業務聯繫人Email</td>
<td>
<input class="form-control disabled_select" type="email" name="contracttel" x-model="data.partyAemail" >
<p class="alerttext" x-show="data.partyAemail==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
</tr>
<tr>
<td style="vertical-align: middle">區域</td>
<td>
<select class="ui search dropdown" x-model="data.area">
<option value="">選擇區域</option>
<template x-for="city in cities" :key="city.code">
<option x-bind:selected="city.name === data.area" x-text="city.name" :value="city.name"></option>
</template>
</select>
<p class="alerttext" x-show="data.area==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">詳細地址</td>
<td colspan="2">
<input type="text" x-model="data.address" />
<p class="alerttext" x-show="data.address==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">附件</td>
<td colspan="2">
<input type="file" name="file[]" multiple draggable="true" @change="uploadFiles($event)" />
</td>
</tr>
</tr>
</tbody>
</template>
<template x-if="step==2">
<tbody style="font-weight: bolder;margin-bottom: 20px" x-show="step==2">
<tr>
<td colspan="7" style='vertical-align: middle;border-right:0px;'>
<h4>業務確認項</h4>
</td>
<td class="text-right" style='border-left:0px;'>
<button type="button" id="btn_close" class="btn btn-default" onclick="window.history.back();">返回</button>
<button type="button" id="btn_close" class="btn btn-default" onclick="window.close();">關閉分頁</button>
</td>
</tr>
<tr>
<td style="vertical-align: middle">立約人</td>
<td>
<input type="text" x-model="data.customer" />
<p class="alerttext" x-show="data.customer==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">營業員</td>
<td>
<select class="ui fluid search dropdown" name="promiser" x-model="data.salesman">
<option value="">選擇營業員</option>
<?php foreach ($contractpersons as $person) { ?>
<option value="<?php echo $person['accountid'] ?>"><?php echo $person['name'] ?></option>
<?php } ?>
</select>
<p class="alerttext" x-show="data.salesman==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">合約開始時間</td>
<td>
<input class="form-control disabled_select" type="date" name="start_date" x-model="data.contract_begin_date">
<p class="alerttext" x-show="data.contract_begin_date==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">合約終止時間</td>
<td>
<input class="form-control disabled_select" type="date" name="end_date" x-model="data.contract_end_date">
<p class="alerttext" x-show="data.contract_end_date==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
</tr>
<tr>
<td style="vertical-align: middle">電梯台數</td>
<td>
<input class="form-control disabled_select" type="number" x-model="data.num" :disabled="data.disabled">
<p class="alerttext" x-show="data.num==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
<p class="alerttext" x-show="data.num==0 && data.num!=''"><i class="fa-solid fa-circle-xmark"></i>電梯數量需大於0</p>
</td>
<tr>
<td style="vertical-align: middle">統一編號/身分證</td>
<td>
<input class="form-control disabled_select" type="text" name="uscc" x-model="data.vat">
<p class="alerttext" x-show="data.vat==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">維修型態</td>
<td style="vertical-align: middle">
<select class="ui search dropdown" name="" x-model="data.mtype">
<option value="">選擇維修型態</option>
<option value="A">定期保養</option>
</select>
<p class="alerttext" x-show="data.mtype==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">契約成交價</td>
<td>
<input class="form-control disabled_select" type="text" name="tel" x-model="data.total_price" :disabled="data.disabled">
<p class="alerttext" x-show="data.total_price==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
</tr>
<tr>
<td style="vertical-align: middle">客戶電話</td>
<td>
<input class="form-control disabled_select" type="text" name="tel" x-model="data.phone">
<p class="alerttext" x-show="data.phone==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">Email</td>
<td style="vertical-align: middle">
<input class="form-control disabled_select" type="email" name="email" x-model="data.email">
<p class="alerttext" x-show="data.email==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">保養員</td>
<td>
<select class="ui search dropdown" name="repairer_name" x-model="data.mworker">
<option value="">選擇保養員</option>
<?php foreach ($workers as $worker) { ?>
<option value="<?php echo $worker['accountid']; ?>"><?php echo $worker['name'] ?></option>
<?php } ?>
</select>
<p class="alerttext" x-show="data.mworker==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">保養頻率</td>
<td>
<select class="ui search dropdown" name="repairer_name" x-model="data.mcycle">
<option value="">選擇保養頻率</option>
<option value="bw">雙週保</option>
<option value="em">月保</option>
</select>
<p class="alerttext" x-show="data.mcycle==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
</tr>
<tr>
<td style="vertical-align: middle">業務聯繫人</td>
<td>
<input type="text" x-model="data.partyA" name="partyA" />
<p class="alerttext" x-show="data.partyA==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">業務聯繫人地址</td>
<td>
<input class="form-control disabled_select" x-model="data.partyAaddress" type="text" name="contractaddress" value="">
<p class="alerttext" x-show="data.partyAaddress==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">業務聯繫人電話</td>
<td>
<input class="form-control disabled_select" type="text" name="contracttel" x-model="data.partyAphone">
<p class="alerttext" x-show="data.partyAphone==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">業務聯繫人Email</td>
<td>
<input class="form-control disabled_select" type="email" name="contracttel" x-model="data.partyAemail">
<p class="alerttext" x-show="data.partyAemail==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
</tr>
<tr>
<td style="vertical-align: middle">區域</td>
<td>
<select class="ui search dropdown" x-model="data.area">
<option value="">選擇區域</option>
<template x-for="city in cities" :key="city.code">
<option x-bind:selected="city.name === data.area" x-text="city.name" :value="city.name"></option>
</template>
</select>
<p class="alerttext" x-show="data.area==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">詳細地址</td>
<td colspan="2">
<input type="text" x-model="data.address" />
<p class="alerttext" x-show="data.address==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">分期方式</td>
<td colspan="2">
<select class="ui search dropdown" x-model="data.payType">
<option value="">選擇付款方式</option>
<option value="A40006">年繳</option>
<option value="A40007">季繳</option>
<option value="A40003">月繳</option>
<option value="A40004">雙月繳</option>
<option value="A40005">半年繳</option>
</select>
<p class="alerttext" x-show="data.payType==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
</tr>
</tr>
</tbody>
</template>
<template x-if="step==3">
<template x-for="(elevator, idx) in data.elevators" :key="elevator.apply_key + elevator.register_code">
<tbody style="font-weight: bolder;margin-bottom: 20px" x-show="step==3">
<tr>
<td colspan=8><p x-text="'電梯' + Number(idx+1)"></p></td>
</tr>
<tr>
<td style="vertical-align: middle">機種</td>
<td>
<select class="ui search dropdown" name="spec" x-model="data.elevators[idx].spec" >
<option value="">選擇規格</option>
<option value="MAE100">MAE100</option>
<option value="MAM200">MAM200</option>
<option value="MAH100">MAH100</option>
<option value="MAQ100">MAQ100</option>
<option value="MAF100">MAF100</option>
<option value="MAZ100">MAZ100</option>
</select>
<p class="alerttext" x-show="!(data.elevators[idx].spec=='MAE100' || data.elevators[idx].spec=='MAM200' || data.elevators[idx].spec=='MAH100' || data.elevators[idx].spec=='MAQ100' || data.elevators[idx].spec=='MAF100' || data.elevators[idx].spec=='MAZ100')"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">載重</td>
<td>
<input type="text" x-model="data.elevators[idx].weight" />
<p class="alerttext" x-show="data.elevators[idx].weight==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">速度</td>
<td>
<input type="text" x-model="data.elevators[idx].speed" />
<p class="alerttext" x-show="data.elevators[idx].speed==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td style="vertical-align: middle">附件</td>
<td colspan="2">
<input type="file" name="file[]" multiple draggable="true" @change="uploadFiles($event)" />
</td>
</tr>
</tbody>
</template>
<template x-if="step==3">
<template x-for="(elevator, idx) in data.elevators" :key="elevator.apply_key + elevator.register_code">
<tbody style="font-weight: bolder;margin-bottom: 20px" x-show="step==3">
<tr>
<td colspan=8>
<p x-text="'電梯' + Number(idx+1)"></p>
</td>
</tr>
<tr>
<td style="vertical-align: middle">機種</td>
<td>
<select class="ui search dropdown" name="spec" x-model="data.elevators[idx].spec">
<option value="">選擇規格</option>
<option value="MAE100">MAE100</option>
<option value="MAM200">MAM200</option>
<option value="MAH100">MAH100</option>
<option value="MAQ100">MAQ100</option>
<option value="MAF100">MAF100</option>
<option value="MAZ100">MAZ100</option>
</select>
<p class="alerttext" x-show="!(data.elevators[idx].spec=='MAE100' || data.elevators[idx].spec=='MAM200' || data.elevators[idx].spec=='MAH100' || data.elevators[idx].spec=='MAQ100' || data.elevators[idx].spec=='MAF100' || data.elevators[idx].spec=='MAZ100')"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">載重</td>
<td>
<input type="text" x-model="data.elevators[idx].weight" />
<p class="alerttext" x-show="data.elevators[idx].weight==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">速度</td>
<td>
<input type="text" x-model="data.elevators[idx].speed" />
<p class="alerttext" x-show="data.elevators[idx].speed==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">人乘</td>
<td>
<input type="text" x-model="data.elevators[idx].persons" />
<p class="alerttext" x-show="data.elevators[idx].persons==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
</tr>
<tr>
<td style="vertical-align: middle">樓停</td>
<td>
<input type="number" class="form-control" x-model="data.elevators[idx].stop" />
<p class="alerttext" x-show="data.elevators[idx].stop=='' || !data.elevators[idx].stop"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">樓層</td>
<td>
<input type="text" x-model="data.elevators[idx].floors" />
<p class="alerttext" x-show="data.elevators[idx].floors=='' || !data.elevators[idx].floors"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">緯度</td>
<td>
<input type="text" x-model="data.elevators[idx].latitude" />
<p class="alerttext" x-show="data.elevators[idx].latitude=='' || !data.elevators[idx].latitude"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">人乘</td>
<td>
<input type="text" x-model="data.elevators[idx].persons" />
<p class="alerttext" x-show="data.elevators[idx].persons==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
</tr>
<tr>
<td style="vertical-align: middle">樓停</td>
<td>
<input type="number" class="form-control" x-model="data.elevators[idx].stop" />
<p class="alerttext" x-show="data.elevators[idx].stop=='' || !data.elevators[idx].stop"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">樓層</td>
<td>
<input type="text" x-model="data.elevators[idx].floors" />
<p class="alerttext" x-show="data.elevators[idx].floors=='' || !data.elevators[idx].floors"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">緯度</td>
<td>
<input type="text" x-model="data.elevators[idx].latitude" />
<p class="alerttext" x-show="data.elevators[idx].latitude=='' || !data.elevators[idx].latitude"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">經度</td>
<td>
<input type="text" x-model="data.elevators[idx].longitude" />
<p class="alerttext" x-show="data.elevators[idx].longitude=='' || !data.elevators[idx].longitude"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
</tr>
<tr>
<td style="vertical-align: middle">廠牌</td>
<td>
<input type="text" x-model="data.elevators[idx].elevator_brand" class="form-control" />
<p class="alerttext" x-show="data.elevators[idx].elevator_brand==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">
開門方式
</td>
<td style="vertical-align: middle">
<select class="ui search dropdown" name="" x-model="data.elevators[idx].opendoor">
<option value="">選擇開門方式</option>
<option value="2PCO">2PCO</option>
<option value="2S">2S</option>
<option value="2SL">2SL</option>
<option value="2SR">2SR</option>
<option value="2U">2U</option>
<option value="3S">3S</option>
<option value="4PCO">4PCO</option>
<option value="6PCO">6PCO</option>
<option value="CO">CO</option>
</select>
<p class="alerttext" x-show="data.elevators[idx].opendoor=='' || !data.elevators[idx].opendoor "><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">保養別</td>
<td>
<select class="ui search dropdown" x-model="data.elevators[idx].maintainance">
<option value="">選擇保養別</option>
<option value="A">全包</option>
<option value="B">半包</option>
<option value="C">清包</option>
</select>
<p class="alerttext" x-show="data.elevators[idx].maintainance=='' || !data.elevators[idx].maintainance"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">竣檢日</td>
<td>
<input class="form-control disabled_select" type="date" x-model="data.elevators[idx].takecertificatedate">
<p class="alerttext" x-show="data.elevators[idx].takecertificatedate=='' || !data.elevators[idx].takecertificatedate"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
</tr>
<tr>
<td style="vertical-align: middle">經度</td>
<td>
<input type="text" x-model="data.elevators[idx].longitude" />
<p class="alerttext" x-show="data.elevators[idx].longitude=='' || !data.elevators[idx].longitude"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
</tr>
<tr>
<td style="vertical-align: middle">廠牌</td>
<td>
<input type="text" x-model="data.elevators[idx].elevator_brand" class="form-control" />
<p class="alerttext" x-show="data.elevators[idx].elevator_brand==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">
開門方式
</td>
<td style="vertical-align: middle">
<select class="ui search dropdown" name="" x-model="data.elevators[idx].opendoor">
<option value="">選擇開門方式</option>
<option value="2PCO">2PCO</option>
<option value="2S">2S</option>
<option value="2SL">2SL</option>
<option value="2SR">2SR</option>
<option value="2U">2U</option>
<option value="3S">3S</option>
<option value="4PCO">4PCO</option>
<option value="6PCO">6PCO</option>
<option value="CO">CO</option>
</select>
<p class="alerttext" x-show="data.elevators[idx].opendoor=='' || !data.elevators[idx].opendoor "><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">保養別</td>
<td>
<select class="ui search dropdown" x-model="data.elevators[idx].maintainance">
<option value="">選擇保養別</option>
<option value="A">全包</option>
<option value="B">半包</option>
<option value="C">清包</option>
</select>
<p class="alerttext" x-show="data.elevators[idx].maintainance=='' || !data.elevators[idx].maintainance"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">竣檢日</td>
<td>
<input class="form-control disabled_select" type="date" x-model="data.elevators[idx].takecertificatedate">
<p class="alerttext" x-show="data.elevators[idx].takecertificatedate=='' || !data.elevators[idx].takecertificatedate"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
</tr>
<tr>
<td style="vertical-align: middle">許可證有效時間</td>
<td>
<input class="form-control disabled_select" type="date" x-model="data.elevators[idx].useful_date">
<p class="alerttext" x-show="data.elevators[idx].useful_date=='' || !data.elevators[idx].useful_date"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
</tr>
<tr><td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td></tr>
</tbody>
<td style="vertical-align: middle">許可證有效時間</td>
<td>
<input class="form-control disabled_select" type="date" x-model="data.elevators[idx].useful_date">
<p class="alerttext" x-show="data.elevators[idx].useful_date=='' || !data.elevators[idx].useful_date"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</template>
</template>
</template>
</table>
</table>
<button x-show="step==3" @click="save()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn">
<template x-if="!isLoading">
<span>存檔</span>
</template>
<template x-if="isLoading">
<div class="loader"></div>
</template>
</button>
<button x-show="step<=2" @click="nextStepFn()" type="button" class="btn btn-primary btn-lg pull-right savebtn" :disabled="isLoading">
<template x-if="!isLoading">
<span>下一步</span>
</template>
<template x-if="isLoading">
<div class="loader"></div>
</template>
</button>
<button x-show="step>1" @click="preStepFn()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn">
<template x-if="!isLoading">
<span>上一步</span>
</template>
<template x-if="isLoading">
<div class="loader"></div>
</template>
</button>
</div>
<button x-show="step==3" @click="save()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn">
<template x-if="!isLoading">
<span>存檔</span>
</template>
<template x-if="isLoading">
<div class="loader"></div>
</template>
</button>
<button x-show="step<=2" @click="nextStepFn()" type="button" class="btn btn-primary btn-lg pull-right savebtn" :disabled="isLoading">
<template x-if="!isLoading">
<span>下一步</span>
</template>
<template x-if="isLoading">
<div class="loader"></div>
</template>
</button>
<button x-show="step>1" @click="preStepFn()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn">
<template x-if="!isLoading">
<span>上一步</span>
</template>
<template x-if="isLoading">
<div class="loader"></div>
</template>
</button>
</div>
</div>
</div>
<script src="./js/jquery/jquery-3.1.1.min.js"></script>
<script src="semantic/dist/semantic.min.js" ></script>
<script src="semantic/dist/semantic.min.js"></script>
<script src="./js/alpine.js"></script>
<script>
const user_id = '<?php echo $user_id; ?>'

140
wms/contract/contract-new-apply.php

@ -9,9 +9,10 @@ if(!(isset($_GET['id']) && !empty($_GET['id']))){
}
$id = $_GET["id"];
$sql_str = "SELECT contract_new_apply.*, account.name as review_person_name
$sql_str = "SELECT contract_new_apply.*, person_account.name AS review_person_name, person_final_account.name AS review_final_person_name
FROM contract_new_apply
LEFT JOIN account ON contract_new_apply.review_person_id = account.accountid
LEFT JOIN account AS person_account ON contract_new_apply.review_person_id = person_account.accountid
LEFT JOIN account AS person_final_account ON contract_new_apply.review_final_person_id = person_final_account.accountid
WHERE contract_new_apply.mid = :mid";
$stmt = $conn->prepare($sql_str);
$stmt->bindParam(':mid',$id);
@ -101,6 +102,7 @@ if(empty($contract_new_apply)){
}
$secondPayDeadline = $contract['secondPayDeadline'] ?? 0;
$status = isset($contract['status']) ? $contract['status'] : -1;
$progress = isset($contract['progress']) ? $contract['progress'] : 0;
$person = $contract['person'];
?>
@ -138,14 +140,14 @@ $person = $contract['person'];
<!-- <input class="form-control disabled_select" type="text" x-model="data.vol_no" > -->
<!-- <p class="alerttext" x-show="data.vol_no==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> -->
</td>
<td style="vertical-align: middle">統一編號</td>
<td style="vertical-align: middle">統一編號/身分證字號</td>
<td>
<input class="form-control disabled_select" type="text" x-model="data.vat" >
<input class="form-control disabled_select" type="text" x-model="data.vat" disabled >
<p class="alerttext" x-show="data.vat==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">合約書申請日期</td>
<td>
<input class="form-control disabled_select" type="date" x-model="data.apply_date" >
<input class="form-control disabled_select" type="date" x-model="data.apply_date" disabled>
<p class="alerttext" x-show="data.apply_date==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">申請類別</td>
@ -159,17 +161,17 @@ $person = $contract['person'];
<tr>
<td style="vertical-align: middle">案件名稱</td>
<td style="vertical-align: middle" colspan="3">
<input class="form-control disabled_select" type="text" x-model="data.case_name" >
<input class="form-control disabled_select" type="text" x-model="data.case_name" disabled >
<p class="alerttext" x-show="data.case_name==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">立約人</td>
<td style="vertical-align: middle">
<input class="form-control disabled_select" type="text" x-model="data.company" >
<input class="form-control disabled_select" type="text" x-model="data.company" disabled>
<p class="alerttext" x-show="data.company==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">負責人</td>
<td style="vertical-align: middle">
<input class="form-control disabled_select" type="text" x-model="data.manager" >
<input class="form-control disabled_select" type="text" x-model="data.manager" disabled >
<p class="alerttext" x-show="data.manager==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
</tr>
@ -193,30 +195,23 @@ $person = $contract['person'];
<tr>
<td style="vertical-align: middle">聯絡地址</td>
<td style="vertical-align: middle" colspan=3>
<input class="form-control disabled_select" type="text" x-model="data.address" >
<input class="form-control disabled_select" type="text" x-model="data.address" disabled>
<p class="alerttext" x-show="data.address==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">完工期限</td>
<td style="vertical-align: middle">免保期限</td>
<td style="vertical-align: middle" colspan=3>
<div class="ui labeled input">
<div class="ui label">
貨抵工地
</div>
<input type="text" placeholder="30" style="width:45px;padding:0 12px;" x-model="data.workdeadline_a">
<div class="ui label">
天內安裝完成,甲方應於貨底工地前
</div>
<input type="text" placeholder="7" style="width:45px;padding:0 12px;" x-model="data.workdeadline_b">
<div class="ui label">
天完成並整理完善。
<div class="ui labeled input">
<input type="text" placeholder="18" style="width:45px;padding:0 12px;" x-model="data.freedeadline">
<div class="ui label">
個月
</div>
</div>
</div>
<!-- <input class="form-control disabled_select" type="text" x-model="data.deadline" > -->
<p class="alerttext" x-show="data.deadline==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
<p class="alerttext" x-show="data.freedeadline==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
</tr>
<tr>
<td style="vertical-align: middle">附則</td>
<!-- <td style="vertical-align: middle">附則</td>
<td style="vertical-align: middle" colspan=3>
<div class="ui labeled input">
<div class="ui label">
@ -228,16 +223,21 @@ $person = $contract['person'];
</div>
</div>
<p class="alerttext" x-show="data.regulations==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">免保期限</td>
<td style="vertical-align: middle" colspan=3>
<div class="ui labeled input">
<input type="text" placeholder="18" style="width:45px;padding:0 12px;" x-model="data.freedeadline">
<div class="ui label">
個月
</div>
</td> -->
<td style="vertical-align: middle">完工期限</td>
<td style="vertical-align: middle" colspan=7>
<div class="ui labeled input">
<div class="ui label">
乙方應於貨抵工地後每台
</div>
<p class="alerttext" x-show="data.freedeadline==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
<input type="text" placeholder="30" style="width:45px;padding:0 12px;" x-model="data.workdeadline_a">
<div class="ui label">
日內安裝完成
</div>
<div class="note label" x-show="data.workdeadline_note && data.workdeadline_note != 'null'" style="font-size:14px;color:#BD0606" x-text="'說明:' + data.workdeadline_note"></div>
</div>
<!-- <input class="form-control disabled_select" type="text" x-model="data.deadline" > -->
<p class="alerttext" x-show="data.deadline==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
</tr>
@ -253,7 +253,7 @@ $person = $contract['person'];
<div class="ui label">
圖色確認第
</div>
<input type="text" placeholder="90" style="width:45px;padding:0 12px;" x-model="data.tradedeadline">
<input type="text" placeholder="180" style="width:60px;padding:0 12px;" x-model="data.tradedeadline">
<div class="ui label">
天出貨
</div>
@ -286,15 +286,14 @@ $person = $contract['person'];
<td style="vertical-align: middle"><p x-text="idx+1"></p></td>
<td colspan="3" style="vertical-align: middle">
<input class="form-control disabled_select lock" type="text" x-model="item.item_spec" >
<p class="alerttext" x-show="data.tradedeadline==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
<p class="alerttext" x-show="data.item_spec==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">
<span x-text="item.item_qty + '台'" style="padding:0 20px"></span>
<p class="alerttext" x-show="data.tradedeadline==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td colspan="3" style="vertical-align: middle">
<input class="form-control disabled_select lock" type="number" x-model="item.item_price_ct" >
<p class="alerttext" x-show="data.tradedeadline==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
<p class="alerttext" x-show="data.item_price_ct==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
</tr>
</template>
@ -407,7 +406,7 @@ $person = $contract['person'];
</td>
<td>
<div class="ui labeled input">
<input type="number" placeholder="90" style="width:65px;padding:0 12px;" x-model="pays[<?php echo $pay['pay_kind'];?>].condition_date">
<input type="number" placeholder="90" style="width:65px;padding:0 12px;" x-model="pays[<?php echo $pay['pay_kind'];?>].condition_date" disabled >
<div class="ui label">
</div>
@ -415,7 +414,7 @@ $person = $contract['person'];
</td>
<td>
<div class="ui labeled input">
<input type="number" placeholder="90" style="width:65px;padding:0 12px;" x-model="pays[<?php echo $pay['pay_kind'];?>].pay_period" >
<input type="number" placeholder="90" style="width:65px;padding:0 12px;" x-model="pays[<?php echo $pay['pay_kind'];?>].pay_period" disabled >
<div class="ui label">
</div>
@ -448,13 +447,17 @@ $person = $contract['person'];
<thead style="font-weight: bolder;margin-bottom: 20px;">
<tr>
<td colspan=8>
<h4 style='text-align:center;font-weight: bolder'>附件上傳</h4>
<h4 style='text-align:center;font-weight: bolder'>其他</h4>
</td>
</tr>
</thead>
<tbody>
<tr>
<td colspan="4">附件上傳</td>
<td colspan="1">說明</td>
<td colspan="2">
<textarea name="description" x-model="data.description"></textarea>
</td>
<td colspan="1">附件上傳</td>
<td colspan="4">
<?php if($status < 1): ?>
<input type="file" name="file[]" multiple draggable="true" @change="uploadFiles($event)" />
@ -463,7 +466,9 @@ $person = $contract['person'];
<template x-if="file">
<div>
<a :href="'./images/contracts_new_files/' + file.file_name" download x-text="file.file_name" ></a>
<?php if($status <= 0): ?>
<span @click="removeFile(file.id)" style="margin-left:10px;cursor:pointer;color:#f019">X</span>
<?php endif; ?>
</div>
</template>
</template>
@ -487,7 +492,7 @@ $person = $contract['person'];
<td>結果</td>
<td colspan=2>意見</td>
<td>時間</td>
<td colspan=2><?php if($user_id === "M0174" && $status == 1): ?>審核意見<?php endif; ?></td>
<td colspan=2><?php if(($user_id === "M0174" || $user_id === "M0107" || $user_id === "M0060") && $status == 1): ?>審核意見<?php endif; ?></td>
</tr>
<tr>
<td>營業員</td>
@ -499,8 +504,8 @@ $person = $contract['person'];
</td>
<td colspan=2>---</td>
<td><?php echo ($contract['submit_date']) ?? "---"; ?> </td>
<td colspan=2 rowspan="2">
<?php if($user_id === "M0174" && $status == 1): ?>
<td colspan=2 rowspan="3">
<?php if(($user_id === "M0174" || $user_id === "M0107" || $user_id === "M0060") && $status == 1): ?>
<textarea class="form-control opinion" x-model="data.review_comment"></textarea>
<?php endif; ?>
</td>
@ -509,13 +514,24 @@ $person = $contract['person'];
<td>業務承辦人</td>
<td><span><?php echo (!isset($contract['review_person_name']) || empty($contract['review_person_name'])) ? "---" : $contract['review_person_name'] ."(".$contract['review_person_id'].")"; ?></span></td>
<td>
<?php if($status == 3): ?><span class="successtext">結案同意</span><?php endif; ?>
<?php if(($status == 1 || $status == 3) && $progress >= 2): ?><span class="successtext">同意</span><?php endif; ?>
<?php if($status == 2): ?><span class="failtext">結案不同意</span><?php endif; ?>
<?php if($status < 2): ?><span>---</span><?php endif; ?>
<?php if($status < 2 && $progress < 2): ?><span>---</span><?php endif; ?>
</td>
<td colspan=2><?php echo $contract['review_comment'] ?? "---"; ?></td>
<td><?php echo $contract['review_date'] ?? "---"; ?></td>
</tr>
<tr>
<td>業務部協理</td>
<td><span><?php echo (!isset($contract['review_final_person_name']) || empty($contract['review_final_person_name'])) ? "---" : $contract['review_final_person_name'] ."(".$contract['review_final_person_id'].")"; ?></span></td>
<td>
<?php if($status == 3): ?><span class="successtext">結案同意</span><?php endif; ?>
<?php if($status == 2): ?><span class="failtext">結案不同意</span><?php endif; ?>
<?php if($status < 2): ?><span>---</span><?php endif; ?>
</td>
<td colspan=2><?php echo $contract['review_final_comment'] ?? "---"; ?></td>
<td><?php echo $contract['review_final_date'] ?? "---"; ?></td>
</tr>
<!-- <tr>
<td colspan="2" style="font-weight:bold">業務部承辦人</td>
<td colspan="2">
@ -553,10 +569,18 @@ $person = $contract['person'];
</template>
</button>
<?php endif; ?>
<?php if($status == 1 && ($user_id == "M0107" || $user_id == "M0060" || $user_id == "M0174")): ?>
<?php if($status == 1 && (($user_id == "M0107" && $contract['progress'] <= 1 ) || ($user_id == "M0060" && $contract['progress'] == 2 ) || $user_id == "M0174")): ?>
<button x-show="true" x-on:click="agree()" :disabled="isLoading" type="button" class="btn btn-primary btn-lg pull-right savebtn">
<template x-if="!isLoading">
<span>同意(結案)</span>
<span>
<?php
if($user_id === "M0107" && $contract['progress'] <= 1 ){
echo "同意(上呈)";
}elseif($user_id === "M0060" && $contract['progress'] == 2){
echo "同意(結案)";
}
?>
</span>
</template>
<template x-if="isLoading">
<div class="loader"></div>
@ -606,13 +630,18 @@ $person = $contract['person'];
const pays = [...<?php echo json_encode($pays) ?? []; ?>];
const secondPayDeadline = '';
const tradeaddress = '<?php echo $contract['address'] ?? ''; ?>';
const tradedeadline = 90
const tradedeadline = 180
const freedeadline = 18;
const regulations = 10;
const workdeadline_a = 60;
const workdeadline_b = 7;
const workdeadline_note = '';
const total_items = <?php echo $total_items ?? ''; ?>;
const isFirst = <?php echo $isFirst; ?>;
const originfiles = [];
const description = '';
const contractstatus = null;
const progress = 0;
</script>
<?php else: ?>
<script>
@ -639,13 +668,16 @@ $person = $contract['person'];
const regulations = '<?php echo $contract['test_time'] ?? ''; ?>';
const workdeadline_a = '<?php echo $contract['workdeadline_a'] ?? ''; ?>';
const workdeadline_b = '<?php echo $contract['workdeadline_b'] ?? ''; ?>';
const workdeadline_note = '<?php echo $contract['workdeadline_note'] ?? ''; ?>';
const secondPayDeadline = <?php echo $secondPayDeadline ?? ''; ?>;
const total_items = <?php echo $contract['total_items'] ?? ''; ?>;
const contract_new_apply_id = <?php echo $contract_new_apply_id; ?>;
const originfiles = [...<?php echo json_encode($files); ?>];
const originfiles = [...<?php echo json_encode($files) ?? []; ?>];
const description = '<?php echo $contract['description']; ?>';
const contractstatus = <?php echo $contract['status']; ?>;
const progress = <?php echo $contract['progress']; ?>;
</script>
<?php endif; ?>
<?php if($status > 0 ||( $person != $user_id && $user_id != "M0174")): ?>
<script>
@ -653,12 +685,16 @@ $person = $contract['person'];
const input = document.querySelectorAll('input');
const alerttext = document.querySelectorAll('p.alerttext');
const select = document.querySelectorAll('select');
const textarea = document.querySelectorAll('textarea');
for(let i=0;i<input.length;i++){
input[i].disabled = true
}
for(let i=0;i<select.length;i++){
select[i].disabled = true
}
for(let i=0;i<textarea.length;i++){
textarea[i].disabled = true
}
for(let i=0;i<alerttext.length;i++){
alerttext[i].style.display = "none"
}

7
wms/contract/insertData.php

@ -46,10 +46,13 @@ foreach ($sheet->getRowIterator() as $key => $row) {
$memo = $cell->getValue();
echo $memo;
} elseif ($idx == 'E') {
$optional = '';
if ($cell->getValue() == "標配") {
$optional = 1;
} else {
} else if($cell->getValue() == "選配") {
$optional = 2;
}else if($cell->getValue() == "加價") {
$optional = 3;
}
echo $optional;
} elseif ($idx == 'F') {
@ -137,7 +140,7 @@ foreach ($sheet->getRowIterator() as $key => $row) {
$option_price_id = $last_id;
$option_price = $cost;
$quotation_no = 'Q2311001';
$quotation_no = 'Q2401001';
foreach ($open_kind_arr as $kind) {
$min_weight = 1;
$max_weight = 1600;

65
wms/contract/js/alpine.js

@ -964,6 +964,7 @@ const contractInput = () => {
num: '', //電梯數量
disabled: false, //資料庫是否有電梯數量資料
elevators: [], //機種、載重、人乘、樓停、樓層、速度、緯度、經度、開門方式、保養別、廠牌、竣檢日、許可證日期
payType: ''
},
customize: false,
step: 1,
@ -1020,8 +1021,11 @@ const contractInput = () => {
return
}
if (!this.customize) {
console.log(res.data);
this.data.total_price = res.data.sold_price
for (let i = 0; i < res.data.elevators.length; i++) {
this.data.total_price = Number(res.data.elevators[i].sold_price) + Number(this.data.total_price);
console.log(this.data.total_price);
}
this.data.total_price = Number(res.data.elevators[0].maintain_months) * this.data.total_price;
this.data.salesman = res.data.salesman
this.data.contract_begin_date = res.data.contract_begin_date
this.data.contract_end_date = res.data.contract_end_date
@ -1035,7 +1039,7 @@ const contractInput = () => {
let cityIndex = this.data.address.indexOf('市');
console.log(cityIndex);
if (cityIndex == -1) {
cityIndex = this.data.address.indexOf('縣');
// cityIndex = this.data.address.indexOf('縣');
}
if (cityIndex > 1) {
// 獲取''市''前面的兩個字
@ -1111,13 +1115,14 @@ const contractInput = () => {
form.append('num', this.data.num);
form.append('elevators', JSON.stringify(this.data.elevators));
form.append('contracttype', 'b');
form.append('payType', this.data.payType)
// 如果有附件檔案,可以逐一加入
for (var i = 0; i < this.data.files.length; i++) {
form.append('files[]', this.data.files[i]);
}
axios.post('./api/postContractData.php', form).then(res => {
console.log(res.status);
console.log(res);
if (res.status === 200) {
alert('儲存成功');
this.step = 1
@ -1144,6 +1149,7 @@ const contractInput = () => {
this.data.zip = ''
this.data.partyAphone = ''
this.data.partyAemail = ''
this.data.payType = ''
}
this.isLoading = false
}).catch(error => {
@ -1202,6 +1208,7 @@ const contractNewApply = () => {
address: address,
workdeadline_a: workdeadline_a, //完工期限: 幾天內安裝完成,預設30
workdeadline_b: workdeadline_b, //完工期限: 幾天內整理完善,預設7
workdeadline_note: workdeadline_note,
regulations: regulations, //附則
freedeadline: freedeadline, //免保期限(月)
tradeaddress: tradeaddress, //交貨地點
@ -1214,7 +1221,10 @@ const contractNewApply = () => {
files: [],
removefiles: [],
originfiles: originfiles,
description: description,
},
status: contractstatus,
progress: progress,
pays: {
1: {
condition_date: 0,
@ -1267,10 +1277,7 @@ const contractNewApply = () => {
alert('試車時間不能低於10天')
return;
}
if (this.data.workdeadline_a < 30) {
alert('安裝時間不能低於30天')
return;
}
this.isLoading = true
const form = new FormData();
form.append('mid', this.data.mid);
@ -1290,6 +1297,7 @@ const contractNewApply = () => {
form.append('address', this.data.address);
form.append('workdeadline_a', this.data.workdeadline_a);
form.append('workdeadline_b', this.data.workdeadline_b);
form.append('workdeadline_note', this.data.workdeadline_note);
form.append('regulations', this.data.regulations);
form.append('freedeadline', this.data.freedeadline);
form.append('tradeaddress', this.data.tradeaddress);
@ -1301,6 +1309,7 @@ const contractNewApply = () => {
form.append('status', 0);
form.append('removefiles', JSON.stringify(this.data.removefiles))
form.append('salesman_comment', this.data.salesman_comment);
form.append('description', this.data.description);
for (var i = 0; i < this.data.files.length; i++) {
form.append('files[]', this.data.files[i]);
}
@ -1329,8 +1338,10 @@ const contractNewApply = () => {
return;
}
if (this.data.workdeadline_a < 30) {
alert('安裝時間不能低於30天')
return;
while (this.data.workdeadline_note == '') {
this.data.workdeadline_note = prompt('安裝時間需低於30天,請說明原因')
}
}
this.isLoading = true
const form = new FormData();
@ -1351,6 +1362,7 @@ const contractNewApply = () => {
form.append('address', this.data.address);
form.append('workdeadline_a', this.data.workdeadline_a);
form.append('workdeadline_b', this.data.workdeadline_b);
form.append('workdeadline_note', this.data.workdeadline_note);
form.append('regulations', this.data.regulations);
form.append('freedeadline', this.data.freedeadline);
form.append('tradeaddress', this.data.tradeaddress);
@ -1361,6 +1373,7 @@ const contractNewApply = () => {
form.append('pays', JSON.stringify(this.pays));
form.append('status', 1);
form.append('review_comment', this.data.review_comment);
form.append('description', this.data.description);
for (var i = 0; i < this.data.files.length; i++) {
form.append('files[]', this.data.files[i]);
}
@ -1378,22 +1391,38 @@ const contractNewApply = () => {
})
},
agree() {
if (!confirm("確定同意嗎?")) {
return;
}
if (!confirm("確定同意嗎?")) return;
this.isLoading = true
let newprogress = 0;
let newstatus = 0;
if (this.progress <= 1) {
newprogress = 2;
} else if (this.progress == 2) {
newprogress = 3;
}
if (this.status == 1 && this.progress == 2) {
newstatus = 3
} else {
newstatus = 1
}
console.log(newstatus);
console.log(newprogress)
console.log(this.data.regulations);
this.data.regulations = 100
const form = new FormData();
form.append('contract_new_apply_id', contract_new_apply_id);
form.append('vol_no', this.data.vol_no);
form.append('status', 3);
form.append('status', newstatus);
form.append('review_comment', this.data.review_comment);
form.append('review_person_id', user_id);
form.append('progress', 2);
form.append('progress', newprogress);
axios.post('./api/postContractNewApplyData.php', form).then(res => {
if (res.status === 200) {
alert('審核成功');
console.log(res.data);
console.log(res.status);
window.location.reload();
}
this.isLoading = false
@ -1429,9 +1458,9 @@ const contractNewApply = () => {
},
removeFile(id) {
if (!confirm('確定移除該檔案嗎?')) return;
console.log(this.data.originfiles);
console.log(id);
this.data.removefiles.push(id);
this.data.originfiles.splice(id, 1);
this.data.originfiles = this.data.originfiles.filter(file => file.id != id)
}

8
wms/contract/styles/style.css

@ -574,6 +574,14 @@ main table td, main table th {
font-weight: 900;
padding: 0;
}
.contract-input-component .form table textarea, .contract-management .form table textarea, .contract-new-apply-component .form table textarea {
width: 100%;
resize: vertical;
min-height: 150px;
border: 1px #ccc solid;
outline: none;
border-radius: 6px;
}
.contract-input-component .form table .opinion, .contract-management .form table .opinion, .contract-new-apply-component .form table .opinion {
width: 100%;
min-height: 100px;

2
wms/contract/styles/style.css.map

File diff suppressed because one or more lines are too long

8
wms/contract/styles/style.scss

@ -594,6 +594,14 @@ main{
font-weight: 900;
padding: 0;
}
textarea{
width: 100%;
resize: vertical;
min-height: 150px;
border:1px #ccc solid;
outline: none;
border-radius: 6px;
}
.opinion{
width:100%;
min-height: 100px;

BIN
wms/facility-price.xlsx

Binary file not shown.

18
wms/fun_global.php

@ -83,7 +83,7 @@ function manage_class($user_id, &$ret = [])
* @return array
*
*/
function pricereview_class($rate, $user_id, &$ret = [])
function pricereview_class($rate, $user_id, &$ret = [], $special_fee)
{
global $link;
@ -93,18 +93,19 @@ function pricereview_class($rate, $user_id, &$ret = [])
if ($row["manager"] == "M0001") return; // 董事長略過
if ($row["manager"] != "M0060" && $row["manager"] != "M0006" && $row["manager"] != "M0008") {
$ret[1] = $row["manager"] . ",,";
pricereview_class($rate, $row["manager"], $ret);
pricereview_class($rate, $row["manager"], $ret, $special_fee);
} else {
$ret[2] = "M0024,,<##>M0107,,"; // 業務部專員:M0024許伃廷、M0107許紓晴(第2關有多位審核人)
$ret[3] = "M0060,,"; // 業務協理
if ($rate < 75) $ret[4] = "M0006,,"; // 總經理
if ($rate < 80 || $special_fee > 0) {
$ret[4] = "M0006,,"; // 總經理
}
}
}
mysqli_free_result($res);
return $ret;
}
/**
* 汰改(契約)價審簽核順位
* @param string $rate:破價比
@ -128,13 +129,14 @@ function pricereview_renovate_class($rate, $user_id, $renovate_flag)
}
}
mysqli_free_result($res);
$ret[2] = 'M0012';
if ($renovate_flag == "REN") {
if ($rate < 80) $ret[3] = "M0008"; // 詹總
if ($rate < 60) $ret[4] = "M0006"; // 總經理
// $ret[2] = 'M0012';
if ($rate <= 100) $ret[3] = "M0008"; // 詹總
if ($rate < 75) $ret[4] = "M0006"; // 總經理
} else {
// 全汰改
if ($rate < 80) $ret[3] = "M0008"; // 詹總
if ($rate <= 100) $ret[3] = "M0008"; // 詹總
if ($rate < 75) $ret[4] = "M0006"; // 總經理
}

2
wms/header.php

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

101
wms/mkt/assets/js/alpine.js

@ -191,3 +191,104 @@ const priceOptionSelect = ()=>{
}
}
}
const pricereviewOptionSelect = ()=>{
return {
init(){
console.log(options);
this.optionCategory = 0
this.initButtons();
},
options: options,
orioptions: options,
optionalArr: {
1:'標配',
2:'選配',
3:'加價',
},
searchtext:'',
kind:0,
subkind:0,
buttons:[],
initButtons(kind){
if(kind == 'A'){
this.buttons = [
{name: '車廂意匠', type: 'A1'}
]
}else if(kind == 'B'){
this.buttons = [
{name: '天井', type: 'B1'},
{name: '地板', type: 'B2'},
{name: '操縱盤', type: 'B3'},
{name: '扶手', type: 'B4'},
{name: '車廂門與層門(轎門/層門)', type: 'B5'},
{name: '轎壁(車廂側板)', type: 'B6'},
{name: '其他車廂內裝配件', type: 'B7'},
]
}else if(kind == 'C'){
this.buttons = [
{name: '框', type: 'C1'},
{name: '乘場指示器', type: 'C2'},
{name: '燈', type: 'C3'},
{name: '方式與門', type: 'C4'},
]
}else if(kind == 'D'){
this.buttons = [
{name: '功能與配置', type: 'D1'},
{name: 'OH與樓高', type: 'D2'},
]
}else if(kind == 'E'){
this.buttons = [
{name: '平台梯', type: 'E1'},
]
}else if(kind == 'F'){
this.buttons = [
{name: '汰改', type: 'F1'},
]
}else if(kind == 0){
this.buttons = []
}
},
optionSubCategory:1,
changeCategory(category, subcategory=0){
this.kind = (category=='sub') ? this.kind : category;
if(subcategory != 0) {
this.subkind = subcategory
}else{
this.subkind = 0
}
if(category == 0){
this.kind = 0;
this.subkind = 0;
}
this.initButtons(category)
this.reloadOptions();
},
reloadOptions(){
if(this.kind == 0){
this.options = this.orioptions
return;
}
if(this.subkind == 0){
this.options = this.orioptions.filter(option=> option.kind == this.kind)
return;
}
this.options = this.orioptions.filter(option=> option.kind == this.kind && option.subkind == this.subkind)
},
searchOptions(e){
this.reloadOptions();
let val = e.target.value.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)
})
}
}
}

1587
wms/mkt/price_normal-index.php

File diff suppressed because it is too large

24
wms/mkt/pricereview-check.php

@ -105,7 +105,7 @@ foreach ($res as $data) {
} elseif ($status2 == "N") {
$checker_2_result = "不同意";
}
if ($status3 == "Y") {
if ($status3 == "Y" || $status3 == "YY") {
$checker_3_result = "同意";
} elseif ($status3 == "N") {
$checker_3_result = "不同意";
@ -263,6 +263,7 @@ foreach ($res as $data) {
//alert(data.err);
return false;
}
console.log(data.content);
Object.keys(data.content).forEach(function(k) {
//console.log(data.content[k][0]);
// 有值表示先前已寫入MI
@ -283,11 +284,16 @@ foreach ($res as $data) {
mihtml += "以上合計:" + commafy(data.content[k][12]) + "/台";
mihtml += "<hr>";
mihtml += "<h5>OPTION</h5>";
console.log(data.content[k]);
Object.keys(data.content[k][14]).forEach(function(m) {
mihtml += "<li>" + data.content[k][14][m][0] + ":" + commafy(data.content[k][14][m][1]) + "</li>";
if(data.content[k][14][m][0] != '') {
mihtml += "<li>" + data.content[k][14][m][0] + ":" + commafy(data.content[k][14][m][1]) + "</li>";
}
});
Object.keys(data.content[k][16]).forEach(function(m) {
mihtml += "<li>" + data.content[k][16][m][0] + ":" + commafy(data.content[k][16][m][1]) + "</li>";
if(data.content[k][16][m][0] != ''){
mihtml += "<li>" + data.content[k][16][m][0] + ":" + commafy(data.content[k][16][m][1]) + "</li>";
}
});
Object.keys(data.content[k][18]).forEach(function(m) {
mihtml += "<li>" + data.content[k][18][m][0] + ":" + commafy(data.content[k][18][m][1]) + "</li>";
@ -548,7 +554,12 @@ foreach ($res as $data) {
<?php
$idx = 1;
$item_amt_B_all = 0;
$total_qty = 0;
foreach ($option_arr as $item_no => $val) {
if($val['item_qty'] <= 0){
continue;
}
$total_qty = $total_qty + $val['item_qty'];
$item_amt_B_all += $val["item_price_bp"];
?>
<tr>
@ -564,10 +575,12 @@ foreach ($res as $data) {
$idx++;
}
?>
<?php if($total_qty > 0): ?>
<tr>
<td colspan="4">小計</td>
<td colspan="3"><input type="text" name="option_amt" id="option_amt" class="form-control dollar-right" size="8" value="<?= number_format($item_amt_B_all); ?>"></td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
@ -874,7 +887,7 @@ foreach ($res as $data) {
<input type="text" name="qty_total" id="qty_total" value="<?= number_format($data["qty_total"]); ?>">
</div>
<div>
<label for="special_fee">特殊費用</label>
<label for="special_fee">服務費</label>
<input type="text" name="special_fee" id="special_fee" value="<?php echo number_format($data["special_fee"]); ?>">
</div>
<div>
@ -923,6 +936,9 @@ foreach ($res as $data) {
</tr>
</tbody>
</table>
<ul style="display:block">
<li>營業權限85%以上;85-80%呈至區處長審核;80%以下呈至總經理審核。</li>
</ul>
</div>
<div class="table-responsive">

3711
wms/mkt/pricereview-create.php

File diff suppressed because it is too large

9
wms/mkt/pricereview-edit.php

@ -1684,7 +1684,7 @@ $(function(){
<input type="text" name="qty_total" id="qty_total" readonly>
</div>
<div>
<label for="special_fee">特殊費用</label>
<label for="special_fee">服務費</label>
<input type="text" name="special_fee" id="special_fee" value="<?php echo number_format($data["special_fee"]); ?>">
</div>
<div>
@ -1732,11 +1732,10 @@ $(function(){
</tr>
</tbody>
</table>
<ul>
<li>營業權限85%以上;85-80%呈至區處長審核;80%以下呈至總經理審核。。</li>
</ul>
</div>
<ul>
<li>業務員權限>=80%以上;<80-75%呈至業務協理審核<75%以下呈至總經理審核</li>
</ul>
<div class="nextline"></div>
<label for="attatch1">報價單</label>
<?php

50
wms/mkt/pricereview-index.php

@ -10,21 +10,21 @@ $status_arr = ["Y1" => "暫存", "YS" => "簽核中", "YY" => "結案同意", "Y
$data = array();
// sql語法存在變數中
$sql_cmd = sql_myself($user_id, "pricereview_main .creater");
$sql = "select pricereview_main.*, contract_new_apply.status as applystatus from pricereview_main left join contract_new_apply on pricereview_main.id = contract_new_apply.mid where pricereview_main.creater = '$user_id' and pricereview_main.status like 'Y%' and pricereview_main.ekind = '新梯' order by pricereview_main.id";
$sql = "select pricereview_main.*, contract_new_apply.status as applystatus, contract_new_apply.progress as applyprogress from pricereview_main left join contract_new_apply on pricereview_main.id = contract_new_apply.mid where pricereview_main.creater = '$user_id' and pricereview_main.status like 'Y%' and pricereview_main.ekind = '新梯' order by pricereview_main.id";
// M0024許伃廷,M0107許紓晴權限全開
if ($user_id == "M0024" || $user_id == "M0107" || $user_id == "M0174" || $user_id == "M0189" || $user_id == "TEST01" || $user_id == "TEST02" || $user_id == "TEST03" || $user_id == "TEST04") {
if ($user_id == "M0024" || $user_id == 'M0026' || $user_id == "M0107" || $user_id == "M0174" || $user_id == "M0189" || $user_id == "TEST01" || $user_id == "TEST02" || $user_id == "TEST03" || $user_id == "TEST04") {
$sql_cmd = "where create_at >= '2023-01-01 00:00:00'";
$sql = "select pricereview_main.*, contract_new_apply.status as applystatus from pricereview_main left join contract_new_apply on pricereview_main.id = contract_new_apply.mid where create_at >= '2023-01-01 00:00:00' and pricereview_main.status like 'Y%' and pricereview_main.ekind = '新梯' order by pricereview_main.id";
$sql = "select pricereview_main.*, contract_new_apply.status as applystatus, contract_new_apply.progress as applyprogress from pricereview_main left join contract_new_apply on pricereview_main.id = contract_new_apply.mid where create_at >= '2023-01-01 00:00:00' and pricereview_main.status like 'Y%' and pricereview_main.ekind = '新梯' order by pricereview_main.id";
}
if ($user_id == "M0060") {
$sql_cmd = "where creater in (select accountid from account where (department_id like '3%' or department_id like '5%'))";
$sql = "select pricereview_main.*,contract_new_apply.status as applystatus from pricereview_main left join contract_new_apply on pricereview_main.id = contract_new_apply.mid where creater in (select accountid from account where (department_id like '3%' or department_id like '5%')) and pricereview_main.status like 'Y%' and pricereview_main.ekind = '新梯' order by pricereview_main.id";
}
if (empty($sql_cmd)) $sql = "select pricereview_main.*, contract_new_apply.status as applystatus from pricereview_main left join contract_new_apply on pricereview_main.id = contract_new_apply.mid where pricereview_main.status like 'Y%' and pricereview_main.ekind = '新梯' order by pricereview_main.id";
else $sql = "select pricereview_main.*, contract_new_apply.status as applystatus from pricereview_main left join contract_new_apply on contract_new_apply.mid = pricereview_main.id $sql_cmd and pricereview_main.status like 'Y%' and pricereview_main.ekind = '新梯' order by pricereview_main.id";
if (empty($sql_cmd)) $sql = "select pricereview_main.*, contract_new_apply.status as applystatus, contract_new_apply.progress as applyprogress from pricereview_main left join contract_new_apply on pricereview_main.id = contract_new_apply.mid where pricereview_main.status like 'Y%' and pricereview_main.ekind = '新梯' order by pricereview_main.id";
else $sql = "select pricereview_main.*, contract_new_apply.status as applystatus, contract_new_apply.progress as applyprogress from pricereview_main left join contract_new_apply on contract_new_apply.mid = pricereview_main.id $sql_cmd and pricereview_main.status like 'Y%' and pricereview_main.ekind = '新梯' order by pricereview_main.id";
$data = mysqli_query($link, $sql);
// echo $sql;
$para = "function_name=pricereview&" . $token_link;
?>
<style>
@ -238,6 +238,14 @@ if ($data) :
<?php
//if ($oneself && !($data["status"] == "YY" || $data["status"] == "YN")) { // 自己可以進行規調
if ($oneself) {
// 重填價審只能有最新一筆,填規調只有最新一筆可以填。
$contractno = $data['contractno'];
$sql = "SELECT MAX(id),COUNT(*) FROM pricereview_main WHERE contractno = '$contractno' ORDER BY id DESC";
$result = mysqli_query($link, $sql);
$row = mysqli_fetch_row($result);
$maxContractID = $row[0];
$countContract = $row[1];
if ($data["status"] == "Y1") {
?>
<a href="pricereview-edit.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" class="btn btn-primary btn-sm">修改</a>
@ -246,6 +254,10 @@ if ($data) :
} elseif ($data["status"] == "YS") {
?>
<a href="specsurvey-create.php?mid=<?= $data['id']; ?>&function_name=specsurvey&token=<?= $token; ?>" class="btn btn-danger btn-sm">填規調</a>
<?php
} elseif ($data['status'] == 'YN' && $data['id'] == $maxContractID) {
?>
<a href="pricereview-create.php?vol_no=<?= $data['contractno'] ?>&id=<?= $data['id']; ?>&function_name=specsurvey&token=<?= $token; ?>" class="btn btn-danger btn-sm">重填價審</a>
<?php
}
}
@ -269,7 +281,7 @@ if ($data) :
elseif ($ustatus == "N") $str = "<span class=\"glyphicon glyphicon-ban-circle\" title=\"不同意\"></span>";
$str .= "<br>" . $accountname_arr[$uperson] . "<br>" . $udtte;
} else {
if ($ss_arr["sign_st"] == 1 && in_array($user_id, $ss_arr["sign_nt"]) && $data["status"] == "YS" || $user_id = 'TEST04') {
if ($ss_arr["sign_st"] == 1 && in_array($user_id, $ss_arr["sign_nt"]) && $data["status"] == "YS" || $user_id == 'TEST04') {
$str = "<span class=\"glyphicon glyphicon-user\"></span>";
$str = "待簽核";
$str = "<a href=\"pricereview-check.php?st=1&id=" . $data["id"] . "&" . $para . "\" class=\"btn btn-primary btn-sm\">" . $str . "</a>";
@ -457,17 +469,23 @@ if ($data) :
}
</style>
<td>
<?php if (($data['status'] == 'YY' && $oneself) || $user_id == "M0174" || $user_id == 'M0225') : ?>
<a class="applybtn" href="../contract/contract-new-apply.php?id=<?php echo $data['id'] . '&' . $para; ?>">
<?php if ($data['applystatus'] < 1) {
echo "申請";
} else {
echo "檢視";
} ?>
</a><br>
<?php if (($data['status'] == 'YY' && $oneself) || ($data['status'] == 'YY' && ($user_id == "M0174" || $user_id == 'M0225' || $user_id === "M0107" || $user_id === "M0060"))) : ?>
<?php if (($user_id === "M0107" || $user_id === "M0060") && $data['applystatus'] < 3) : ?>
<span style="font-size:13px;font-weight:600">待申請</span>
<?php elseif ($data['applystatus'] < 3) : ?>
<a class="applybtn" href="../contract/contract-new-apply.php?id=<?php echo $data['id'] . '&' . $para; ?>">
<?php if ($data['applystatus'] < 1) {
echo "申請";
} else {
echo "檢視";
} ?>
</a><br>
<?php endif; ?>
<?php else : ?>
<?php endif; ?>
<?php if ($data['status'] == 'YY' && ($user_id == "M0060" || $user_id == "M0107" || $user_id == "M0174" || $user_id == 'M0225') && $data['applystatus'] == 1) : ?>
<?php if ($data['status'] == 'YY' && (($user_id == "M0060" && $data['applyprogress'] == 2) || ($user_id == "M0107" && $data['applyprogress'] <= 1) || $user_id == "M0174" || $user_id == 'M0225') && $data['applystatus'] == 1) : ?>
<a class="applybtn" href="../contract/contract-new-apply.php?id=<?php echo $data['id'] . '&' . $para; ?>">待簽核</a><br>
<?php endif; ?>
<?php if ($data['status'] != 'YY') : ?>

51
wms/mkt/pricereview-record-submit.php

@ -1,6 +1,7 @@
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
//print_r($_POST);exit;
print_r($_POST);
exit;
foreach ($_POST as $k => $v) {
$$k = htmlspecialchars(stripslashes(trim($v)));
}
@ -67,9 +68,9 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$temp_file_name = $_FILES["attatch1"]["tmp_name"];
$file_size = $_FILES["attatch1"]["size"];
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION);
$target_file1 = $target_dir.$vol_no."-price-".$tds.".".$img_file_type;
$target_file1 = $target_dir . $vol_no . "-price-" . $tds . "." . $img_file_type;
$upload_ok = 1;
foreach (glob($target_dir.$vol_no."-price-*") as $todelfile) {
foreach (glob($target_dir . $vol_no . "-price-*") as $todelfile) {
unlink($todelfile);
}
$upload_res_1 = move_uploaded_file($temp_file_name, $target_file1);
@ -81,9 +82,9 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$temp_file_name = $_FILES["attatch2"]["tmp_name"];
$file_size = $_FILES["attatch2"]["size"];
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION);
$target_file2 = $target_dir.$vol_no."-appendix-".$tds.".".$img_file_type;
$target_file2 = $target_dir . $vol_no . "-appendix-" . $tds . "." . $img_file_type;
$upload_ok = 1;
foreach (glob($target_dir.$vol_no."-appendix-*") as $todelfile) {
foreach (glob($target_dir . $vol_no . "-appendix-*") as $todelfile) {
unlink($todelfile);
}
$upload_res_2 = move_uploaded_file($temp_file_name, $target_file2);
@ -156,7 +157,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
*/
$item_no = 1;
for ($i=0; $i<count($item_spec_arr); $i++) {
for ($i = 0; $i < count($item_spec_arr); $i++) {
$spec = trim($item_spec_arr[$i]);
if (empty($spec)) continue;
if (!$fp_id_arr[$i]) $fp_id_arr[$i] = 0;
@ -168,8 +169,8 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($item_price_arr[$i])) $item_price_arr[$i] = 0;
//$gross_profit_arr[$i] = str_replace(",", "", $gross_profit_arr[$i]);
if (empty($gross_profit_arr[$i])) $gross_profit_arr[$i] = 0;
$gross_profit_rate = number_format(($gross_profit_arr[$i]/$item_price_bp_arr[$i])*100, 1);
$note = $fp_kind_arr[$i].",".$fp_seat_arr[$i].",".$fp_numberofstop_arr[$i].",".$fp_speed_arr[$i];
$gross_profit_rate = number_format(($gross_profit_arr[$i] / $item_price_bp_arr[$i]) * 100, 1);
$note = $fp_kind_arr[$i] . "," . $fp_seat_arr[$i] . "," . $fp_numberofstop_arr[$i] . "," . $fp_speed_arr[$i];
$db_query = "insert into pricereview_item (mid, price_id, item_no, item_spec, item_weight, item_op, item_group, item_unit_price, item_qty, item_price_bp, item_price_ct, item_price, gross_profit, gross_profit_rate, note) values (";
$db_query .= "'$mid', '$fp_id_arr[$i]', '$item_no', '$item_spec_arr[$i]', '$item_weight_arr[$i]', '$item_op_arr[$i]', 'A', '$item_unit_price_arr[$i]', '$item_qty_arr[$i]', '$item_price_bp_arr[$i]', '$item_price_ct_arr[$i]', '$item_price_arr[$i]', '$gross_profit_arr[$i]', '$gross_profit_rate', '$note')";
$result = mysqli_query($link, $db_query);
@ -188,7 +189,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$option_memo_arr = explode("@@,", rtrim($option_memo_all, "@@"));
$option_relate_facil_arr = explode(",", htmlspecialchars_decode($option_relate_facil_all));
$item_no = 1;
for ($i=0; $i<count($option_seat_arr); $i++) {
for ($i = 0; $i < count($option_seat_arr); $i++) {
$spec = trim($option_seat_arr[$i]);
if (empty($spec)) continue;
$option_unit_price_arr[$i] = str_replace(",", "", $option_unit_price_arr[$i]);
@ -197,7 +198,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$option_relate_spec = "";
$tmp_arr = explode("<br>", $option_relate_facil_arr[$i]);
foreach ($tmp_arr as $val) {
$option_relate_spec .= substr($val, 0, strpos($val, ".")).",";
$option_relate_spec .= substr($val, 0, strpos($val, ".")) . ",";
}
$option_relate_spec = rtrim($option_relate_spec, ",");
/*
@ -226,16 +227,16 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$mn_memo_arr = explode("@@,", rtrim($mn_memo_all, "@@"));
$mn_relate_facil_arr = explode(",", htmlspecialchars_decode($mn_relate_facil_all));
$item_no = 1;
for ($i=0; $i<count($mn_seat_arr); $i++) {
for ($i = 0; $i < count($mn_seat_arr); $i++) {
if (empty($mn_kind_arr[$i])) continue;
$mn_unit_price_arr[$i] = str_replace(",", "", $mn_unit_price_arr[$i]);
$mn_qty_arr[$i] = str_replace(",", "", $mn_qty_arr[$i]);
$mn_price_bp_arr[$i] = str_replace(",", "", $mn_price_bp_arr[$i]);
$note = $mn_seat_arr[$i].",".$mn_numberofstop_arr[$i].",".$mn_speed_arr[$i];
$note = $mn_seat_arr[$i] . "," . $mn_numberofstop_arr[$i] . "," . $mn_speed_arr[$i];
$option_relate_spec = "";
$tmp_arr = explode("<br>", $mn_relate_facil_arr[$i]);
foreach ($tmp_arr as $val) {
$option_relate_spec .= substr($val, 0, strpos($val, ".")).",";
$option_relate_spec .= substr($val, 0, strpos($val, ".")) . ",";
}
$option_relate_spec = rtrim($option_relate_spec, ",");
$db_query = "insert into pricereview_item (mid, price_id, item_no, item_group, item_spec, option_relate_spec, item_unit_price, item_qty, item_price_bp, note, memo) values (";
@ -253,7 +254,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$except_qty_arr = explode(",", $except_qty_all);
$except_price_bp_arr = explode(",", $except_price_bp_all);
$item_no = 1;
for ($i=0; $i<count($except_spec_arr); $i++) {
for ($i = 0; $i < count($except_spec_arr); $i++) {
$spec = trim($except_spec_arr[$i]);
if (empty($spec)) continue;
$except_unit_price_arr[$i] = str_replace(",", "", $except_unit_price_arr[$i]);
@ -270,7 +271,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$pay_scale_arr = explode(",", $pay_scale_all);
$pay_amount_arr = explode(",", $pay_amount_all);
$pay_period_arr = explode(",", $pay_period_all);
for ($i=0; $i<7; $i++) {
for ($i = 0; $i < 7; $i++) {
$pay_scale_arr[$i] = (empty($pay_scale_arr[$i])) ? 0 : $pay_scale_arr[$i];
$pay_amount_arr[$i] = (empty($pay_amount_arr[$i])) ? 0 : $pay_amount_arr[$i];
$sql = "insert into pricereview_pay (mid, pay_kind, pay_scale, pay_amount, pay_period, pay_note) values ";
@ -279,10 +280,11 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
}
// 價審簽核流程
// <75%以下呈至總經理審核. ($price_rate)
// 小於80%呈至總經理審核. ($price_rate)
// 上級主管 > 伃廷 > MAX > 總經理
if ($status == "YS") {
$manager_arr = pricereview_class($price_rate, $user_id);
$ret = [];
$manager_arr = pricereview_class($price_rate, $user_id, $ret, $special_fee);
if ($manager_arr) {
$sign1 = $sign2 = $sign3 = $sign4 = "";
foreach ($manager_arr as $k => $v) {
@ -291,7 +293,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
elseif ($k == 3) $sign3 = $v;
else $sign4 = $v;
}
$sql = "insert into pricereview_sign (mid, sign1, sign2, sign3, sign4, sign_total) values ('$mid', '$sign1', '$sign2', '$sign3', '$sign4', '".count($manager_arr)."')";
$sql = "insert into pricereview_sign (mid, sign1, sign2, sign3, sign4, sign_total) values ('$mid', '$sign1', '$sign2', '$sign3', '$sign4', '" . count($manager_arr) . "')";
mysqli_query($link, $sql);
// 寫入待簽表
if (strlen($sign1) == 7) $next_signer = str_replace(",", "", $sign1);
@ -310,9 +312,9 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
foreach ($ret as $uid => $uemail) {
$mail_list[] = [$uid, $uemail];
}
include dirname(__DIR__)."/class/Cmail.php";
include dirname(__DIR__) . "/class/Cmail.php";
$sendmail = new Cmail;
$title = "【新梯價審通知】卷號:".$contractno;
$title = "【新梯價審通知】卷號:" . $contractno;
$content = "<p>您有待簽核案件,請至<a href=\"http://oa.masada.com.tw\">客戶管理 > 價格審查_新梯</a>,點擊「待簽核」進行作業,謝謝!</p>";
$sendmail->sendx($title, $content, $mail_list);
}
@ -323,14 +325,13 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
mysqli_close($link);
if ($affected > 0) {
echo "<script type = 'text/JavaScript'>";
echo "alert('".$st_str."成功');";
echo "location.href='pricereview-index.php?function_name=pricereview&".$token_link."';";
echo "alert('" . $st_str . "成功');";
echo "location.href='pricereview-index.php?function_name=pricereview&" . $token_link . "';";
echo "</script>";
} else {
echo "<script type = 'text/JavaScript'>";
echo "alert('".$st_str."失敗,請重新操作');";
echo "location.href='pricereview-index.php?function_name=pricereview&".$token_link."';";
echo "alert('" . $st_str . "失敗,請重新操作');";
echo "location.href='pricereview-index.php?function_name=pricereview&" . $token_link . "';";
echo "</script>";
}
}
?>

2
wms/mkt/pricereview-record-update.php

@ -384,7 +384,7 @@ if(isset($_POST['pmstatus'])) {
}
// 價審簽核流程
// <75%以下呈至總經理審核. ($price_rate)
// 小於80%呈至總經理審核. ($price_rate)
// 上級主管 > 伃廷 > MAX > 總經理
if ($status == "YS") {
$manager_arr = pricereview_class($price_rate, $user_id);

4
wms/mkt/pricereview_mi-api.php

@ -83,7 +83,7 @@ try {
$row = mysqli_fetch_row($res);
$special_fee = $row[0];
mysqli_free_result($res);
$specarr[0] = "特殊費用";
$specarr[0] = "服務費";
$specarr[1] = round($special_fee/$elev_qty_all, 0);
// 電梯所屬OPTION
@ -265,6 +265,7 @@ try {
$sql4 .= "and ($v[item_weight] between o.min_weight and o.max_weight) and o.open_kind = '".$v["item_op"]."'";
$res_om = mysqli_query($link, $sql4);
if ($row_om = mysqli_fetch_assoc($res_om)) {
$row_om['price'] = (int)ceil($row_om['price']);
$plus = ($v["floors"] > $row_om["base_floor"]) ? ($v["floors"] - $row_om["base_floor"])*$row_om["base_floor_plus"] : 0;
// 特例
if ($opt_elev_arr[$val]["price_id"] == "256" && ($v["floors"] < $row_om["base_floor"])) $row_om["price"] = 9815;
@ -287,7 +288,6 @@ try {
$j++;
}
}
// 保固延長
$mnarr = [];
$mn_fee = $j = 0;

1657
wms/mkt/pricereview_renovate-check.php

File diff suppressed because it is too large

4003
wms/mkt/pricereview_renovate-create.php

File diff suppressed because it is too large

6
wms/mkt/pricereview_renovate-edit.php

@ -1,5 +1,4 @@
<?php
phpinfo();
include "../header.php";
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: Record ID not found.');
@ -2054,7 +2053,7 @@ foreach ($res as $data) {
<input type="text" name="qty_total" id="qty_total" readonly>
</div>
<div>
<label for="special_fee">特殊費用</label>
<label for="special_fee">服務費</label>
<input type="text" name="special_fee" id="special_fee" value="<?php echo number_format($data["special_fee"]); ?>">
</div>
<div>
@ -2103,9 +2102,8 @@ foreach ($res as $data) {
</tbody>
</table>
</div>
<ul>
<li>業務員權限>=80%以上;<80-75%呈至業務協理審核<75%以下呈至總經理審核< /li>
<li>營業員權限85%以上;85-80%呈至業務協理審核;80%以下呈至總經理審核。</li>
</ul>
<div class="nextline"></div>
<label for="attatch1">報價單</label>

40
wms/mkt/pricereview_renovate-index.php

@ -137,7 +137,7 @@ if ($data) :
?>
<link rel="stylesheet" href="common.css">
<div style="overflow-x:auto; white-space:nowrap;">
<table id="table_index2" class="table table-striped table-bordered" style="width:100%">
<table id="table_index" class="table table-striped table-bordered" style="width:100%">
<thead>
<tr>
<th>項次</th>
@ -154,7 +154,8 @@ if ($data) :
<th>建檔時間</th>
<th>功能</th>
<th>區經理</th>
<th>工務副總</th>
<th>服務助理</th>
<th>服務副總</th>
<th>總經理</th>
<th>狀態</th>
<th>合約書下載</th>
@ -208,15 +209,30 @@ if ($data) :
<?php
//if ($oneself && !($data["status"] == "YY" || $data["status"] == "YN")) { // 自己可以進行規調
if ($oneself) {
// 重填價審只能有最新一筆,填規調只有最新一筆可以填。
$contractno = $data['contractno'];
$sql = "SELECT MAX(id),COUNT(*) FROM pricereview_main WHERE contractno = '$contractno' ORDER BY id DESC";
$result = mysqli_query($link, $sql);
$row = mysqli_fetch_row($result);
$maxContractID = $row[0];
$countContract = $row[1];
// echo '<pre>';
// print_r($maxContractID);
// echo '</pre>';
if ($data["status"] == "Y1") {
?>
<a href="pricereview_renovate-edit.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" class="btn btn-primary btn-sm">修改</a>
<a href="pricereview_renovate-delete.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" class="btn btn-secondary btn-sm" onClick="return confirm('Are you sure you want to delete?')">刪除</a>
<?php
} elseif ($data["status"] == "YS") {
} elseif ($data["status"] == "YS" && $countContract == 0) {
?>
<a href="specsurvey_renovate-create.php?mid=<?= $data['id']; ?>&function_name=specsurvey_renovate&token=<?= $token; ?>" class="btn btn-danger btn-sm">填規調</a>
<?php
} elseif ($data['status'] == "YN" && $data['id'] == $maxContractID) {
?>
<a href="pricereview_renovate-create.php?vol_no=<?= $data['contractno']; ?>&id=<?= $data['id'] ?>&function_name=pricereview_renovate&token=<?= $token; ?>" class="btn btn-danger btn-sm">重填價審</a>
<?php
}
}
?>
@ -271,6 +287,24 @@ if ($data) :
//echo $str;
?>
</td>
<td>
<?php
$str = $uperson = $ustatus = $udtte = "";
if (!empty($sign2)) list($uperson, $ustatus, $udtte) = explode(",", $sign2);
if ($ustatus) {
if ($ustatus == "Y") $str = "<span class=\"glyphicon glyphicon-ok\" title=\"同意\"></span>";
elseif ($ustatus == "N") $str = "<span class=\"glyphicon glyphicon-ban-circle\" title=\"不同意\"></span>";
$str .= "<br>" . $accountname_arr[$uperson] . "<br>" . $udtte;
} else {
if ($sign_st == 2 && $sign_nt == $user_id && $data["status"] == "YS") {
$str = "<span class=\"glyphicon glyphicon-user\"></span>";
$str = "待簽核";
$str = "<a href=\"pricereview_renovate-check.php?st=2&id=" . $data["id"] . "&" . $para . "\" class=\"btn btn-primary btn-sm\">" . $str . "</a>";
} else $str = "--";
}
echo $str;
?>
</td>
<td>
<?php
$str = $uperson = $ustatus = $udtte = "";

60
wms/mkt/pricereview_renovate-record-submit.php

@ -1,4 +1,5 @@
<?php
/**
* 沒有選擇M1/M4的-->全汰改
*/
@ -70,9 +71,9 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$temp_file_name = $_FILES["attatch1"]["tmp_name"];
$file_size = $_FILES["attatch1"]["size"];
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION);
$target_file1 = $target_dir.$vol_no."-price-".$tds.".".$img_file_type;
$target_file1 = $target_dir . $vol_no . "-price-" . $tds . "." . $img_file_type;
$upload_ok = 1;
foreach (glob($target_dir.$vol_no."-price-*") as $todelfile) {
foreach (glob($target_dir . $vol_no . "-price-*") as $todelfile) {
unlink($todelfile);
}
$upload_res_1 = move_uploaded_file($temp_file_name, $target_file1);
@ -84,9 +85,9 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$temp_file_name = $_FILES["attatch2"]["tmp_name"];
$file_size = $_FILES["attatch2"]["size"];
$img_file_type = pathinfo($file_name, PATHINFO_EXTENSION);
$target_file2 = $target_dir.$vol_no."-appendix-".$tds.".".$img_file_type;
$target_file2 = $target_dir . $vol_no . "-appendix-" . $tds . "." . $img_file_type;
$upload_ok = 1;
foreach (glob($target_dir.$vol_no."-appendix-*") as $todelfile) {
foreach (glob($target_dir . $vol_no . "-appendix-*") as $todelfile) {
unlink($todelfile);
}
$upload_res_2 = move_uploaded_file($temp_file_name, $target_file2);
@ -151,16 +152,16 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$item_price_ct2_arr = [];
$price_total_item = 0;
foreach ($item_qty_arr as $k => $v) {
$price = floor(($price_total/array_sum($item_qty_arr))*$v);
$price = floor(($price_total / array_sum($item_qty_arr)) * $v);
$item_price_ct2_arr[] = $price;
if ($k < count($item_qty_arr)-1) $price_total_item += $price;
if ($k < count($item_qty_arr) - 1) $price_total_item += $price;
}
$item_price_ct2_arr[count($item_qty_arr)-1] = $price_total - $price_total_item;
$item_price_ct2_arr[count($item_qty_arr) - 1] = $price_total - $price_total_item;
$item_price_ct_arr = $item_price_ct2_arr;
}
$item_no = 1;
for ($i=0; $i<count($item_spec_arr); $i++) {
for ($i = 0; $i < count($item_spec_arr); $i++) {
$spec = trim($item_spec_arr[$i]);
if (empty($spec)) continue;
if (!$fp_id_arr[$i]) $fp_id_arr[$i] = 0;
@ -172,8 +173,8 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($item_price_arr[$i])) $item_price_arr[$i] = 0;
//$gross_profit_arr[$i] = str_replace(",", "", $gross_profit_arr[$i]);
if (empty($gross_profit_arr[$i])) $gross_profit_arr[$i] = 0;
$gross_profit_rate = number_format(($gross_profit_arr[$i]/$item_price_bp_arr[$i])*100, 1);
$note = $fp_kind_arr[$i].",".$fp_seat_arr[$i].",".$fp_numberofstop_arr[$i].",".$fp_speed_arr[$i];
$gross_profit_rate = number_format(($gross_profit_arr[$i] / $item_price_bp_arr[$i]) * 100, 1);
$note = $fp_kind_arr[$i] . "," . $fp_seat_arr[$i] . "," . $fp_numberofstop_arr[$i] . "," . $fp_speed_arr[$i];
$db_query = "insert into pricereview_item (mid, price_id, item_no, item_spec, item_weight, item_op, item_group, item_unit_price, item_qty, item_price_bp, item_price_ct, item_price, gross_profit, gross_profit_rate, note) values (";
$db_query .= "'$mid', '$fp_id_arr[$i]', '$item_no', '$item_spec_arr[$i]', '$item_weight_arr[$i]', '$item_op_arr[$i]', 'A', '$item_unit_price_arr[$i]', '$item_qty_arr[$i]', '$item_price_bp_arr[$i]', '$item_price_ct_arr[$i]', '$item_price_arr[$i]', '$gross_profit_arr[$i]', '$gross_profit_rate', '$note')";
$result = mysqli_query($link, $db_query);
@ -192,7 +193,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$option_memo_arr = explode("@@,", rtrim($option_memo_all, "@@"));
$option_relate_facil_arr = explode(",", htmlspecialchars_decode($option_relate_facil_all));
$item_no = 1;
for ($i=0; $i<count($option_seat_arr); $i++) {
for ($i = 0; $i < count($option_seat_arr); $i++) {
$spec = trim($option_seat_arr[$i]);
if (empty($spec)) continue;
$option_unit_price_arr[$i] = str_replace(",", "", $option_unit_price_arr[$i]);
@ -201,7 +202,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$option_relate_spec = "";
$tmp_arr = explode("<br>", $option_relate_facil_arr[$i]);
foreach ($tmp_arr as $val) {
$option_relate_spec .= substr($val, 0, strpos($val, ".")).",";
$option_relate_spec .= substr($val, 0, strpos($val, ".")) . ",";
}
$option_relate_spec = rtrim($option_relate_spec, ",");
$db_query = "insert into pricereview_item (mid, price_id, item_no, item_group, item_spec, option_relate_spec, item_unit_price, item_qty, item_price_bp, memo) values (";
@ -220,7 +221,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$demolition_qty_arr = explode(",", $demolition_qty_all);
$demolition_price_bp_arr = explode(",", $demolition_price_bp_all);
$item_no = 1;
for ($i=0; $i<count($seat_arr); $i++) {
for ($i = 0; $i < count($seat_arr); $i++) {
$spec = trim($seat_arr[$i]);
if (!$spec) continue;
$demolition_unit_price_arr[$i] = str_replace(",", "", $demolition_unit_price_arr[$i]);
@ -246,16 +247,16 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$mn_memo_arr = explode("@@,", rtrim($mn_memo_all, "@@"));
$mn_relate_facil_arr = explode(",", htmlspecialchars_decode($mn_relate_facil_all));
$item_no = 1;
for ($i=0; $i<count($mn_seat_arr); $i++) {
for ($i = 0; $i < count($mn_seat_arr); $i++) {
if (empty($mn_kind_arr[$i])) continue;
$mn_unit_price_arr[$i] = str_replace(",", "", $mn_unit_price_arr[$i]);
$mn_qty_arr[$i] = str_replace(",", "", $mn_qty_arr[$i]);
$mn_price_bp_arr[$i] = str_replace(",", "", $mn_price_bp_arr[$i]);
$note = $mn_seat_arr[$i].",".$mn_numberofstop_arr[$i].",".$mn_speed_arr[$i];
$note = $mn_seat_arr[$i] . "," . $mn_numberofstop_arr[$i] . "," . $mn_speed_arr[$i];
$option_relate_spec = "";
$tmp_arr = explode("<br>", $mn_relate_facil_arr[$i]);
foreach ($tmp_arr as $val) {
$option_relate_spec .= substr($val, 0, strpos($val, ".")).",";
$option_relate_spec .= substr($val, 0, strpos($val, ".")) . ",";
}
$option_relate_spec = rtrim($option_relate_spec, ",");
$db_query = "insert into pricereview_item (mid, price_id, item_no, item_group, item_spec, option_relate_spec, item_unit_price, item_qty, item_price_bp, note, memo) values (";
@ -273,7 +274,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$except_qty_arr = explode(",", $except_qty_all);
$except_price_bp_arr = explode(",", $except_price_bp_all);
$item_no = 1;
for ($i=0; $i<count($except_spec_arr); $i++) {
for ($i = 0; $i < count($except_spec_arr); $i++) {
$spec = trim($except_spec_arr[$i]);
if (empty($spec)) continue;
$except_unit_price_arr[$i] = str_replace(",", "", $except_unit_price_arr[$i]);
@ -290,7 +291,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$pay_scale_arr = explode(",", $pay_scale_all);
$pay_amount_arr = explode(",", $pay_amount_all);
$pay_period_arr = explode(",", $pay_period_all);
for ($i=0; $i<7; $i++) {
for ($i = 0; $i < 7; $i++) {
$pay_scale_arr[$i] = (empty($pay_scale_arr[$i])) ? 0 : $pay_scale_arr[$i];
$pay_amount_arr[$i] = (empty($pay_amount_arr[$i])) ? 0 : $pay_amount_arr[$i];
$sql = "insert into pricereview_pay (mid, pay_kind, pay_scale, pay_amount, pay_period, pay_note) values ";
@ -306,12 +307,12 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
if ($manager_arr) {
$sign1 = $sign2 = $sign3 = $sign4 = "";
foreach ($manager_arr as $k => $v) {
if ($k == 1) $sign1 = $v.",,";
elseif ($k == 2) $sign2 = $v.",,";
elseif ($k == 3) $sign3 = $v.",,";
else $sign4 = $v.",,";
if ($k == 1) $sign1 = $v . ",,";
elseif ($k == 2) $sign2 = $v . ",,";
elseif ($k == 3) $sign3 = $v . ",,";
else $sign4 = $v . ",,";
}
$sql = "insert into pricereview_sign (mid, sign1, sign2, sign3, sign4, sign_total) values ('$mid', '$sign1', '$sign2', '$sign3', '$sign4', '".count($manager_arr)."')";
$sql = "insert into pricereview_sign (mid, sign1, sign2, sign3, sign4, sign_total) values ('$mid', '$sign1', '$sign2', '$sign3', '$sign4', '" . count($manager_arr) . "')";
mysqli_query($link, $sql);
// 寫入待簽表
if (strlen($sign1) == 7) $next_signer = str_replace(",", "", $sign1);
@ -323,9 +324,9 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$ret = accountid2email($next_signer);
if (!empty($ret)) {
$mail_list[0] = [$next_signer, $ret[$next_signer]];
include dirname(__DIR__)."/class/Cmail.php";
include dirname(__DIR__) . "/class/Cmail.php";
$sendmail = new Cmail;
$title = "【汰改價審通知】卷號:".$contractno;
$title = "【汰改價審通知】卷號:" . $contractno;
$content = "<p>您有待簽核案件,請至<a href=\"http://oa.masada.com.tw\">客戶管理 > 價格審查_汰改</a>,點擊「待簽核」進行作業,謝謝!</p>";
$sendmail->sendx($title, $content, $mail_list);
}
@ -336,14 +337,13 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
mysqli_close($link);
if ($affected > 0) {
echo "<script type = 'text/JavaScript'>";
echo "alert('".$st_str."成功');";
echo "location.href='pricereview_renovate-index.php?function_name=pricereview_renovate&".$token_link."';";
echo "alert('" . $st_str . "成功');";
echo "location.href='pricereview_renovate-index.php?function_name=pricereview_renovate&" . $token_link . "';";
echo "</script>";
} else {
echo "<script type = 'text/JavaScript'>";
echo "alert('".$st_str."失敗,請重新操作');";
echo "location.href='pricereview_renovate-index.php?function_name=pricereview_renovate&".$token_link."';";
echo "alert('" . $st_str . "失敗,請重新操作');";
echo "location.href='pricereview_renovate-index.php?function_name=pricereview_renovate&" . $token_link . "';";
echo "</script>";
}
}
?>

60
wms/rib-invoice-check.php

@ -0,0 +1,60 @@
<?php
include "header.php";
$sql = "SELECT
B.rib_id,B.BillNo,B.DeptId, B.CreatorId, C.name, A.InvoiceNo,B.CurrentState
FROM `rib_sub` AS A
LEFT JOIN `rib` AS B
ON A.rib_id=B.rib_id
LEFT JOIN `account` AS C ON A.CreatorId=C.accountid
WHERE B.CurrentState
IN (1,2,4) AND A.InvoiceNo IS NOT NULL AND trim(A.InvoiceNo)!='' AND B.BillNo NOT IN ('M0056231003','M0056231002')
ORDER BY A.InvoiceNo";
$query = mysqli_query($link, $sql);
$array = array();
$repeat_array = array();
foreach ($query as $value) {
$InvoiceNo = preg_replace('/\s(?=)/', '', $value['InvoiceNo']);
$InvoiceNo = str_replace('-', '', $InvoiceNo);
// echo $InvoiceNo." //".$value['BillNo'];
// echo "<br>";
if (isset($array[$InvoiceNo])) {
if (in_array($value['BillNo'], $array[$InvoiceNo]['BillNo'])) {
} else {
array_push($array[$InvoiceNo]['BillNo'], $value['BillNo']);
array_push($array[$InvoiceNo]['InvoiceNo'], $value['InvoiceNo']);
$repeat_array[$InvoiceNo]['BillNo']= $array[$InvoiceNo]['BillNo'];
$repeat_array[$InvoiceNo]['InvoiceNo']= $array[$InvoiceNo]['InvoiceNo'];
}
} else {
// $array[$InvoiceNo] = array($value['BillNo']);
$array[$InvoiceNo]['BillNo']= array($value['BillNo']);
$array[$InvoiceNo]['InvoiceNo']=array($value['InvoiceNo']);
}
}
$duplicate = "(";
foreach($repeat_array as $repeat){
$tmp = "'";
$tmp .= implode("','",$repeat['InvoiceNo']);
$tmp .="'";
$duplicate .= $tmp.",";
}
$duplicate = substr($duplicate,0,-1);
$duplicate.=")";
// // echo $repeat."<br>";
$sql_repeat = "SELECT
A.rib_id,A.BillNo, A.CurrentState, A.CreatorId,C.name,B.InvoiceNo, A.GatheringPersonId,A.WriteOffAmount,A.CreateTime
FROM `rib_sub` AS B
LEFT JOIN `rib` AS A ON A.rib_id=B.rib_id
LEFT JOIN `account` AS C ON A.CreatorId=C.accountid
WHERE A.CurrentState IN (1,2,4)
AND B.InvoiceNo IN $duplicate ORDER BY B.InvoiceNo";
$repeat_query = mysqli_query($link, $sql_repeat);
foreach($repeat_query as $value){
echo $value['rib_id'].";".$value['BillNo'].";".$value['CurrentState'].";".$value['CreatorId'].";".$value['name'].";".$value['InvoiceNo'].";".$value['GatheringPersonId'].";".$value['WriteOffAmount'].";".$value['CreateTime'];
echo "<br>";
}
?>

20
wms/rib02-create.php

@ -7,8 +7,10 @@ $CurrId = isset($_GET['CurrId']) ? $_GET['CurrId'] : null;
$sql_rib = "";
if (empty($rib_id)) {
$sql_rib = "SELECT * FROM rib WHERE BillNo = '$BillNo' && CurrentState=0";
$sql_invoiceNo = "SELECT DISTINCT InvoiceNo FROM rib_sub WHERE BillNo!==$BillNo";
} else {
$sql_rib = "SELECT * FROM rib WHERE rib_id = $rib_id";
$sql_invoiceNo = "SELECT DISTINCT InvoiceNo FROM rib_sub WHERE rib_id!==$rib_id";
}
$rib_query = mysqli_query($link, $sql_rib);
if (mysqli_num_rows($rib_query) > 0) {
@ -114,7 +116,17 @@ foreach ($BizPartner as $biz) {
array_push($BusinessPartner, $bizKey);
$bizcount += 1;
}
// 取得所有報銷過的發票號碼
$invoiceNo = mysqli_query($link, $sql_invoiceNo);
$invoiceNo_array = array();
foreach ($invoiceNo as $invoice) {
array_push($invoiceNo_array, $invoice['InvoiceNo']);
}
$BizJSON = json_encode($BusinessPartner);
$InvoiceJSON = json_encode($invoiceNo_array);
$sql_Project = "SELECT * FROM comProject";
$projects = $conn->query($sql_Project);
$sql_Material = "SELECT * FROM comMaterialGroup";
@ -389,7 +401,7 @@ $materials = $conn->query($sql_Material);
</div>
<div class="col-md-3" id="NotInvoice2">
<label for="InvoiceNo">發票號碼</label>
<input class="form-control" type="text" name="InvoiceNo" id="InvoiceNo">
<input class="form-control" type="text" name="InvoiceNo" id="InvoiceNo" onblur="checkInvoice()">
</div>
</div>
@ -665,6 +677,12 @@ $materials = $conn->query($sql_Material);
window.open('rib02-invoice.php', '發票範例', config = 'height=600, width=600');
}
function checkInvoice(){
var invoiceArray = <?= $InvoiceJSON ?>;
if($.inArray($("#InvoiceNo").val(),invoiceArray) !== -1) {
alert("此發票已報銷過");
$("#InvoiceNo").val('');}
}
function changeWriteOffId(SelectedDept) {
var SelectDeptId = 'WriteOff' + SelectedDept + '-';

19
wms/rib02-edit.php

@ -55,7 +55,18 @@ foreach ($BizPartner as $biz) {
array_push($BusinessPartner, $bizKey);
$bizcount += 1;
}
// 取得所有報銷過的發票號碼
$rib_id = $ribsub['rib_id'];
$sql_invoiceNo = "SELECT DISTINCT InvoiceNo FROM rib_sub WHERE rib_id !== $rib_id";
$invoiceNo = mysqli_query($link, $sql_invoiceNo);
$invoiceNo_array = array();
foreach ($invoiceNo as $invoice) {
array_push($invoiceNo_array, $invoice['InvoiceNo']);
}
$BizJSON = json_encode($BusinessPartner);
$InvoiceJSON = json_encode($invoiceNo_array);
$sql_Project = "SELECT * FROM comProject";
$projects = $conn->query($sql_Project);
$sql_Material = "SELECT * FROM comMaterialGroup";
@ -410,7 +421,7 @@ $materials = $conn->query($sql_Material);
</div>
<div class="col-md-3" id="NotInvoice2">
<label for="InvoiceNo">發票號碼</label>
<input class="form-control" type="text" name="InvoiceNo" id="InvoiceNo" value="<?= $ribsub['InvoiceNo'] ?>">
<input class="form-control" type="text" name="InvoiceNo" id="InvoiceNo" value="<?= $ribsub['InvoiceNo'] ?>" onblur="checkInvoice()">
</div>
</div>
<div>
@ -683,6 +694,12 @@ $materials = $conn->query($sql_Material);
window.open('rib02-invoice.php', '新視窗的名稱', config = 'height=600, width=600');
}
function checkInvoice(){
var invoiceArray = <?= $InvoiceJSON ?>;
if($.inArray($("#InvoiceNo").val().replace("-", ""),invoiceArray) !== -1) {
alert("此發票已報銷過");
$("#InvoiceNo").val('');}
}
function changeWriteOffId(SelectedDept) {
var SelectDeptId = 'WriteOff' + SelectedDept + '-';

11
wms/rib02-submit.php

@ -15,6 +15,13 @@ foreach ($BizPartner as $biz) {
$bizValue = $biz['BizPartnerName'];
$BusinessPartner[$bizKey] = $bizValue;
}
// 取得所有報銷過的發票號碼
$sql_invoiceNo = "SELECT DISTINCT InvoiceNo FROM rib_sub WHERE rib_id !== $rib_id";
$invoiceNo = mysqli_query($link, $sql_invoiceNo);
$invoiceNo_array = array();
foreach ($invoiceNo as $invoice) {
array_push($invoiceNo_array, $invoice['InvoiceNo']);
}
$RowCode = $_POST['RowCode'];
$FeeDate = $_POST['FeeDate'];
@ -35,7 +42,7 @@ $IsCounteract = $_POST['IsCounteract'];
$InvoiceId = $_POST['InvoiceId'];
$VoucherCount = empty($_POST['VoucherCount']) ? 1 : $_POST['VoucherCount'];
$VoucherType = isset($_POST['VoucherType']) ? $_POST['VoucherType'] : 0;
$InvoiceNo = empty($_POST['InvoiceNo']) ? NULL : $_POST['InvoiceNo'];
$InvoiceNo = empty($_POST['InvoiceNo']) ? " ": (in_array(str_replace("-", "",$_POST['InvoiceNo']), $invoiceNo_array) ? " ": str_replace("-", "",$_POST['InvoiceNo']));
$CurrLAmount = empty($_POST['CurrLAmount']) ? null : $_POST['CurrLAmount'];
// $comSupplierName = empty($_POST['comSupplierName']) ? null : $_POST['comSupplierName'];
@ -161,7 +168,7 @@ if ($submit == "add") {
$SQL1 .= empty($CU_MaterialId) ? "" : ",CU_MaterialId='$CU_MaterialId'";
$SQL1 .= empty($VoucherCount) ? "" : ",VoucherCount=$VoucherCount";
$SQL1 .= isset($VoucherType) ? ",VoucherType=$VoucherType" : "";
$SQL1 .= empty($InvoiceNo) ? "" : ",InvoiceNo='$InvoiceNo'";
$SQL1 .= empty($InvoiceNo) ? " " : ",InvoiceNo='$InvoiceNo'";
$SQL1 .= empty($comSupplierName) ? ",comSupplierName=' '" : ",comSupplierName='$comSupplierName'";
$SQL1 .= empty($comSupplierId) ? ",comSupplierId=' '" : ",comSupplierId='$comSupplierId'";
$SQL1 .= isset($OTax) ? ",OTax=$OTax" : "";

2
wms/schedule-index.php

@ -38,7 +38,7 @@ if (!empty($sql_cmd2)) {
}
//$sql = "SELECT * FROM schedule $sql_cmd ORDER BY id";
$sql = "SELECT * FROM schedule $sql_cmd ORDER BY id asc";
$sql = "SELECT * FROM schedule $sql_cmd ORDER BY id desc";
if (!$page_close) $sql .= " limit $page_from, $page_each";
//echo $sql;

8
wms/sign/list.php

@ -38,10 +38,10 @@ if ($result == false) {
die(mysqli_error($link));
}
$res_get = mysqli_fetch_all(mysqli_query($link, $sql_get), MYSQLI_ASSOC);
echo '<pre>';
print_r($sql_get);
echo '</pre>';
exit;
// echo '<pre>';
// print_r($sql_get);
// echo '</pre>';
// exit;
$system_name_opt = array_map(function ($item) {
return array('system_id' => $item['system_id'], 'system_name' => $item['system_name']);

Loading…
Cancel
Save