Browse Source

merge conflict

main
10994015 1 year ago
parent
commit
f02ec6134d
  1. 534
      mkt/pricereview-create.php
  2. 72804
      wms/account-receivable-bill.txt
  3. 108
      wms/account-receivable-excel.php
  4. BIN
      wms/account-receivable-facility.xlsx
  5. 137
      wms/account-receivable-index-ing.php
  6. 357
      wms/account-receivable-index.php
  7. BIN
      wms/account-receivable-test.xlsx
  8. 6
      wms/cont/sign_list.php
  9. 55
      wms/contract-repair/contract-download.php
  10. 35
      wms/contract-repair/js/alpine.js
  11. 195
      wms/contract/api/postContractData.php
  12. 38
      wms/contract/api/testT8API.php
  13. 29
      wms/contract/conn.php
  14. 15
      wms/contract/connt8.php
  15. BIN
      wms/facility-price.xlsx
  16. 2
      wms/header.php
  17. 1587
      wms/mkt/price_normal-index.php
  18. 3546
      wms/mkt/pricereview-create.php
  19. 3962
      wms/mkt/pricereview_renovate-create.php
  20. 60
      wms/rib-invoice-check.php
  21. 20
      wms/rib02-create.php
  22. 19
      wms/rib02-edit.php
  23. 11
      wms/rib02-submit.php
  24. 8
      wms/sign/list.php

534
mkt/pricereview-create.php

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

72804
wms/account-receivable-bill.txt

File diff suppressed because it is too large

108
wms/account-receivable-excel.php

@ -5,56 +5,84 @@ require_once dirname(__DIR__) . '/common/composer/vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx; use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
header('Content-Type: application/json'); header('Content-Type: application/json');
$type = $_GET['type'];
$array_data = array(); $array_data = array();
$Bill = json_decode(file_get_contents("php://input"), true); $Bill = json_decode(file_get_contents("php://input"), true);
$spreadsheet = new Spreadsheet(); $spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet(); $sheet = $spreadsheet->getActiveSheet();
$colomnHeader = [
'合約號','作番號', '部門', '經理', '營業員', '客戶名稱', '統一編號', '聯絡地址', '抬頭', if ($type == 'facility') {
'訂金', '訂金目前應收', '訂金已收','訂金催收','訂金符合收款條件日期','訂金催收次數', $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','AT'
]; ];
foreach ($column as $col) { $sheet->fromArray($colomnHeader, NULL, 'A1');
if ($col == 'AT') { $rowIndex = 2;
$sheet->getStyle('AT' . $rowIndex)->getAlignment()->setWrapText(true); foreach ($Bill as $key => $value) {
} else {
$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); $sheet->getColumnDimension($col)->setAutoSize(true);
} }
$rowIndex++;
} }
$writer = new Xlsx($spreadsheet);
$excelFileName = 'account-receivable-facility.xlsx';
$writer->save($excelFileName);
} else {
$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', 'AT'
];
foreach ($column as $col) {
if ($col == 'AT') {
$sheet->getStyle('AT' . $rowIndex)->getAlignment()->setWrapText(true);
} else {
$sheet->getColumnDimension($col)->setAutoSize(true);
}
}
$rowIndex++; $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; echo $excelFileName;
?> ?>
<!-- <script>
window.location.href = "account-receivable-index.php?<?= $token_link ?>";
</script> -->

BIN
wms/account-receivable-facility.xlsx

Binary file not shown.

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

@ -233,6 +233,10 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['total_facility_num'] += 1; $arrayData[$wip['contractno']]['total_facility_num'] += 1;
// [合約號]['facility'][作番號]['no'] // [合約號]['facility'][作番號]['no']
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['no'] = $wip['facilityno']; $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'] [金額]/[合約預計收款日期] // [合約號][作番號][款別] ['con'] [金額]/[合約預計收款日期]
// [合約號][作番號][款別] ['inv'] [金額]/[發票開立日期] // [合約號][作番號][款別] ['inv'] [金額]/[發票開立日期]
@ -320,7 +324,7 @@ foreach ($wipwhole_array as $wip) {
// real_contract_arrival_date 預計出貨日=預計到貨日=預計貨抵工地 // real_contract_arrival_date 預計出貨日=預計到貨日=預計貨抵工地
// real_arrival_date 實際出貨日=實際到貨日=實際貨抵工地 // real_arrival_date 實際出貨日=實際到貨日=實際貨抵工地
//----------------------------------------寶佳的另外處理--------------------------------------------------- //----------------------------------------寶佳的另外處理---------------------------------------------------
//[合約號]['facility'] [作番號][款別]0 款項名稱 1 合約金額 2 應收日期 3 應收金額 4 已收金額 5 催收金額 6 催收次數
if ($arrayData[$wip['contractno']]['sign'][0] == "寶佳出貨前30天") { if ($arrayData[$wip['contractno']]['sign'][0] == "寶佳出貨前30天") {
$facility_status = ""; $facility_status = "";
// if ($arrayData[$wip['contractno']]['sign'][2]) // if ($arrayData[$wip['contractno']]['sign'][2])
@ -332,6 +336,7 @@ foreach ($wipwhole_array as $wip) {
if ($today > $contractday) { if ($today > $contractday) {
$arrayData[$wip['contractno']]['sign_num'] += 1; $arrayData[$wip['contractno']]['sign_num'] += 1;
$facility_status = $wip['facilityno'] . " (出貨前30天" . $arrayData[$wip['contractno']]['sign'][2] . "已過) <br>"; $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]); $contractday = strtotime($arrayData[$wip['contractno']]['second'][2]);
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['second'][2] = $arrayData[$wip['contractno']]['second'][2]; $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['second'][2] = $arrayData[$wip['contractno']]['second'][2];
@ -340,6 +345,7 @@ foreach ($wipwhole_array as $wip) {
if ($today > $contractday) { if ($today > $contractday) {
$arrayData[$wip['contractno']]['second_num'] += 1; $arrayData[$wip['contractno']]['second_num'] += 1;
$facility_status = $wip['facilityno'] . " (出貨後10天" . $arrayData[$wip['contractno']]['second'][2] . "已過) <br>"; $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) { if ($wip['real_arrival_date'] != NULL) {
$estimate_time = strtotime($wip['real_arrival_date']); $estimate_time = strtotime($wip['real_arrival_date']);
@ -351,6 +357,7 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['arrive_num'] += 1; $arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['arrive'][2] = strval(date('Y-m-d', $contractday)); $arrayData[$wip['contractno']]['arrive'][2] = strval(date('Y-m-d', $contractday));
$facility_status = $wip['facilityno'] . " (貨抵工地後90天" . $arrayData[$wip['contractno']]['arrive'][2] . "已過) <br>"; $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) { if ($wip['tryrun_end_date'] != NULL) {
$estimate_time = strtotime($wip['tryrun_end_date']); $estimate_time = strtotime($wip['tryrun_end_date']);
@ -362,6 +369,7 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['tryrun_num'] += 1; $arrayData[$wip['contractno']]['tryrun_num'] += 1;
$arrayData[$wip['contractno']]['tryrun'][2] = strval(date('Y-m-d', $contractday)); $arrayData[$wip['contractno']]['tryrun'][2] = strval(date('Y-m-d', $contractday));
$facility_status = $wip['facilityno'] . " (試車後90天" . $arrayData[$wip['contractno']]['tryrun'][2] . "已過) <br>"; $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) { if ($wip['delivery_date'] != NULL) {
$estimate_time = strtotime($wip['delivery_date']); $estimate_time = strtotime($wip['delivery_date']);
@ -373,6 +381,7 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['delivery_num'] += 1; $arrayData[$wip['contractno']]['delivery_num'] += 1;
$arrayData[$wip['contractno']]['delivery'][2] = strval(date('Y-m-d', $contractday)); $arrayData[$wip['contractno']]['delivery'][2] = strval(date('Y-m-d', $contractday));
$facility_status = $wip['facilityno'] . " (交車後270天" . $arrayData[$wip['contractno']]['delivery'][2] . "已過) <br>"; $facility_status = $wip['facilityno'] . " (交車後270天" . $arrayData[$wip['contractno']]['delivery'][2] . "已過) <br>";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $facility_status;
} }
} }
} }
@ -382,6 +391,7 @@ foreach ($wipwhole_array as $wip) {
} }
} else { } else {
$facility_status = $wip['facilityno'] . " (出貨前30天" . $arrayData[$wip['contractno']]['sign'][2] . "未到) <br>"; $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; $arrayData[$wip['contractno']]['facilities'] .= $facility_status;
} else { } else {
@ -397,6 +407,7 @@ foreach ($wipwhole_array as $wip) {
} }
if ($wip['delivery_date'] != NULL) { if ($wip['delivery_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['delivery_date'] . "已移交) <br>"; $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']]['tryrun_num'] += 1;
$arrayData[$wip['contractno']]['install_num'] += 1; $arrayData[$wip['contractno']]['install_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1; $arrayData[$wip['contractno']]['arrive_num'] += 1;
@ -487,6 +498,7 @@ foreach ($wipwhole_array as $wip) {
} }
} elseif ($wip['official_check_date'] != NULL) { } elseif ($wip['official_check_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['official_check_date'] . "官檢完畢) <br>"; $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']]['check_num'] += 1;
$arrayData[$wip['contractno']]['tryrun_num'] += 1; $arrayData[$wip['contractno']]['tryrun_num'] += 1;
$arrayData[$wip['contractno']]['install_num'] += 1; $arrayData[$wip['contractno']]['install_num'] += 1;
@ -503,7 +515,7 @@ foreach ($wipwhole_array as $wip) {
} }
if (!empty($wip['tryrun_end_date']) && $wip['tryrun_end_date'] != NULL) { 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']); $estimate_delivery_time = strtotime($wip['tryrun_end_date']);
$tryruntime = $estimate_delivery_time + (90 * 86400); $tryruntime = $estimate_delivery_time + (90 * 86400);
$month = collect_month($tryruntime); $month = collect_month($tryruntime);
@ -532,7 +544,7 @@ foreach ($wipwhole_array as $wip) {
array_push($arrayData[$wip['contractno']]['install']['max'], 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 (!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']); $estimate_delivery_time = strtotime($wip['real_arrival_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400); $arrivetime = $estimate_delivery_time + (90 * 86400);
$month = collect_month($arrivetime); $month = collect_month($arrivetime);
@ -567,6 +579,7 @@ foreach ($wipwhole_array as $wip) {
} }
} elseif ($wip['tryrun_end_date'] != NULL) { } elseif ($wip['tryrun_end_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['tryrun_end_date'] . "試車完畢) <br>"; $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']]['tryrun_num'] += 1;
$arrayData[$wip['contractno']]['install_num'] += 1; $arrayData[$wip['contractno']]['install_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1; $arrayData[$wip['contractno']]['arrive_num'] += 1;
@ -624,6 +637,7 @@ foreach ($wipwhole_array as $wip) {
} }
} elseif ($wip['install_end_date'] != NULL) { } elseif ($wip['install_end_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['install_end_date'] . "安裝完畢) <br>"; $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']]['install_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1; $arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1; $arrayData[$wip['contractno']]['second_num'] += 1;
@ -672,6 +686,7 @@ foreach ($wipwhole_array as $wip) {
} }
} elseif ($wip['real_arrival_date'] != NULL) { } elseif ($wip['real_arrival_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['real_arrival_date'] . "貨抵工地) <br>"; $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']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1; $arrayData[$wip['contractno']]['second_num'] += 1;
$arrayData[$wip['contractno']]['sign_num'] += 1; $arrayData[$wip['contractno']]['sign_num'] += 1;
@ -701,16 +716,20 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['second'][6] = $month; $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['second'][6] = $month;
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['second'][2] = strval(date('Ymd', $secondtime)); $arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['second'][2] = strval(date('Ymd', $secondtime));
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (已達二次款收款條件) <br>"; $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']]['second_num'] += 1;
$arrayData[$wip['contractno']]['sign_num'] += 1; $arrayData[$wip['contractno']]['sign_num'] += 1;
} else { } else {
$arrayData[$wip['contractno']]['sign_num'] += 1; $arrayData[$wip['contractno']]['sign_num'] += 1;
if ($wip['real_contract_arrival_date'] != NULL) { if ($wip['real_contract_arrival_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['real_contract_arrival_date'] . "預計出貨日) <br>"; $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) { } elseif ($wip['estimated_shipping_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['estimated_shipping_date'] . "預計出港日) <br>"; $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 { } else {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (預計出港日待確認) <br>"; $arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (預計出港日待確認) <br>";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (預計出港日待確認) <br>";
} }
} }
} }
@ -719,6 +738,7 @@ foreach ($wipwhole_array as $wip) {
// 計算每個合約的應收款、作番總數 // 計算每個合約的應收款、作番總數
$today_date = new DateTime(date('Y-m-d', strtotime('-1 month', strtotime(date('Y-m-d'))))); $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) { foreach ($arrayData as &$value) {
if ($value['total_facility_num'] > 0) { 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'])) + $value['receivable_budget'] = $value['sign'][1] * ($value['sign_num'] / $value['total_facility_num']) + ($value['second'][1] * ($value['second_num'] / $value['total_facility_num'])) +
@ -734,9 +754,24 @@ foreach ($arrayData as &$value) {
$value['delivery'][3] = $value['delivery'][1] * ($value['delivery_num'] / $value['total_facility_num']); $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']); $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) { foreach ($contractstage as $i) {
if (!empty($value[$i]['min']) && count($value[$i]['min']) > 0) { if (!empty($value[$i]['min']) && count($value[$i]['min']) > 0) {
$latest_timestamp = max($value[$i]['min']); $latest_timestamp = max($value[$i]['min']);
@ -810,6 +845,7 @@ foreach ($received_array as $received) {
$excel_aray = array(); $excel_aray = array();
$boga_array = array(); $boga_array = array();
$exclude_boga_array = array(); $exclude_boga_array = array();
$facility_array = array();
foreach ($arrayData as $key => $value) { foreach ($arrayData as $key => $value) {
$value['sign'][3] = (isset($value['sign'][3])) ? $value['sign'][3] : 0; $value['sign'][3] = (isset($value['sign'][3])) ? $value['sign'][3] : 0;
$value['second'][3] = (isset($value['second'][3])) ? $value['second'][3] : 0; $value['second'][3] = (isset($value['second'][3])) ? $value['second'][3] : 0;
@ -867,11 +903,43 @@ foreach ($arrayData as $key => $value) {
$value['final'][1], $value['final'][3], $value['final']['max'], $value['final']['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'], $value['total_facility_num'], 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] = [
$key, $value[1], $value[2], $value[4], $value[5], $value[7], $value[8], $value[6], $valkey,
$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']
];
}
} }
// foreach($facility_array as $key=>$value){
// echo $key;
// echo '<br>';
// print_r($value);
// echo '<br><br>';
// }
$data = json_encode($excel_aray); $data = json_encode($excel_aray);
$boga_data = json_encode($boga_array); $boga_data = json_encode($boga_array);
$exclude_boga_data = json_encode($exclude_boga_array); $exclude_boga_data = json_encode($exclude_boga_array);
$facility_data = json_encode($facility_array);
?> ?>
<style> <style>
@ -911,16 +979,23 @@ $exclude_boga_data = json_encode($exclude_boga_array);
} }
</style> </style>
<button type="button" onclick="downloadData()" class="btn btn-success btn-lg pull-right">全部<span class="glyphicon glyphicon-download-alt"></span></button> <div class="btn-group btn-group-lg" style="padding:10 px;">
<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="downloadData()" class="btn btn-success">全部<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> <button type="button" onclick="exclude_bogaData()" class="btn btn-info">不含寶佳<span class="glyphicon glyphicon-download-alt"></span></button>
<?php <button type="button" onclick="bogaData()" class="btn btn-warning">寶佳<span class="glyphicon glyphicon-download-alt"></span></button>
if (in_array(accountidToDepartId($user_id), array('220', '210')) || $user_id == 'M0060') { </div>
?> <div style="padding: 10px;">
<a href="facility-price.php?<?= $token_link ?>" class="btn btn-primary btn-lg pull-right">合約作番明細</span></a> <button type="button" onclick="downloadFacilityData()" class="btn btn-primary btn-lg">合約作番明細<span class="glyphicon glyphicon-download-alt"></span></button>
<?php </div>
} <div>
?> <?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>
<div style="width:98%;margin:1% ;overflow-x: auto;"> <div style="width:98%;margin:1% ;overflow-x: auto;">
<table id="table_index" class="table table-striped table-bordered" style="width:100%;"> <table id="table_index" class="table table-striped table-bordered" style="width:100%;">
<thead> <thead>
@ -1034,10 +1109,10 @@ if (in_array(accountidToDepartId($user_id), array('220', '210')) || $user_id ==
} }
function test() { function test() {
var BillData = <?= $data ?>; var BillData = <?= $boga_data ?>;
var form = document.createElement("form"); var form = document.createElement("form");
form.method = 'POST'; 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"); var input = document.createElement("input");
input.type = "hidden"; input.type = "hidden";
input.name = "Bill"; input.name = "Bill";
@ -1050,7 +1125,7 @@ if (in_array(accountidToDepartId($user_id), array('220', '210')) || $user_id ==
function downloadData() { function downloadData() {
var xhr = new XMLHttpRequest(); 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.open('POST', url, true);
xhr.setRequestHeader('Content-Type', 'application/json'); xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onreadystatechange = function() { xhr.onreadystatechange = function() {
@ -1079,7 +1154,7 @@ if (in_array(accountidToDepartId($user_id), array('220', '210')) || $user_id ==
function bogaData() { function bogaData() {
var xhr = new XMLHttpRequest(); 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.open('POST', url, true);
xhr.setRequestHeader('Content-Type', 'application/json'); xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onreadystatechange = function() { xhr.onreadystatechange = function() {
@ -1100,11 +1175,33 @@ if (in_array(accountidToDepartId($user_id), array('220', '210')) || $user_id ==
})); }));
} }
function downloadFacilityData() {
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');
var name = "作番應收帳款" + "<?= date('Y-m-d-Hm') ?>" + ".xlsx";
link.setAttribute('href', window.location.origin + "/wms/account-receivable-facility.xlsx");
link.setAttribute('download', name);
link.style.display = 'none';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
}
xhr.send(JSON.stringify({
Bill: <?= $facility_data ?>
}));
}
function exclude_bogaData() { function exclude_bogaData() {
var xhr = new XMLHttpRequest(); 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.open('POST', url, true);
xhr.setRequestHeader('Content-Type', 'application/json'); xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onreadystatechange = function() { xhr.onreadystatechange = function() {

357
wms/account-receivable-index.php

@ -220,6 +220,8 @@ FROM department
ON d.department_id = tmp2.department_id ORDER BY contractno"; ON d.department_id = tmp2.department_id ORDER BY contractno";
$wipwhole_array = mysqli_query($link, $sql); $wipwhole_array = mysqli_query($link, $sql);
foreach ($wipwhole_array as $wip) { foreach ($wipwhole_array as $wip) {
$today = strtotime(date('Ymd'));
//[合約號]['facility'] [作番號][款別]0 款項名稱 1 合約金額 2 應收日期 3 應收金額 4 已收金額 5 催收金額 6 催收次數
if (isset($arrayData[$wip['contractno']])) { if (isset($arrayData[$wip['contractno']])) {
// 整理合約資料 // 整理合約資料
$arrayData[$wip['contractno']][0] = $wip['department_id'];; $arrayData[$wip['contractno']][0] = $wip['department_id'];;
@ -229,14 +231,19 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']][4] = $wip['name']; $arrayData[$wip['contractno']][4] = $wip['name'];
$arrayData[$wip['contractno']][10] = $wip['contractno']; $arrayData[$wip['contractno']][10] = $wip['contractno'];
$arrayData[$wip['contractno']]['total_facility_num'] += 1; $arrayData[$wip['contractno']]['total_facility_num'] += 1;
// [合約號][作番號]['no'] // [合約號]['facility'][作番號]['no']
$arrayData[$wip['contractno']][$wip['facilityno']]['no'] = $wip['facilityno']; $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'] [金額]/[合約預計收款日期] // [合約號][作番號][款別] ['con'] [金額]/[合約預計收款日期]
// [合約號][作番號][款別] ['inv'] [金額]/[發票開立日期] // [合約號][作番號][款別] ['inv'] [金額]/[發票開立日期]
// [合約號][作番號][款別] ['rec'] [金額]/[實際收款日期] // [合約號][作番號][款別] ['rec'] [金額]/[實際收款日期]
$contractstage = array('sign', 'second', 'arrive', 'install', 'tryrun', 'check', 'delivery', 'final'); $contractstage = array('sign', 'second', 'arrive', 'install', 'tryrun', 'check', 'delivery', 'final');
foreach ($contractstage as $i) { 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']['date'] = "";
$arrayData[$wip['contractno']][$wip['facilityno']][$i]['inv']['budget'] = 0; $arrayData[$wip['contractno']][$wip['facilityno']][$i]['inv']['budget'] = 0;
$arrayData[$wip['contractno']][$wip['facilityno']][$i]['rec']['date'] = ""; $arrayData[$wip['contractno']][$wip['facilityno']][$i]['rec']['date'] = "";
@ -317,40 +324,64 @@ foreach ($wipwhole_array as $wip) {
// real_contract_arrival_date 預計出貨日=預計到貨日=預計貨抵工地 // real_contract_arrival_date 預計出貨日=預計到貨日=預計貨抵工地
// real_arrival_date 實際出貨日=實際到貨日=實際貨抵工地 // real_arrival_date 實際出貨日=實際到貨日=實際貨抵工地
//----------------------------------------寶佳的另外處理--------------------------------------------------- //----------------------------------------寶佳的另外處理---------------------------------------------------
if ($arrayData[$wip['contractno']]['sign'][0] == "寶佳出貨前30天") { if ($arrayData[$wip['contractno']]['sign'][0] == "寶佳出貨前30天") {
$facility_status = ""; $facility_status = "";
// if ($arrayData[$wip['contractno']]['sign'][2]) // if ($arrayData[$wip['contractno']]['sign'][2])
$today = strtotime(date('Ymd')); $today = strtotime(date('Ymd'));
$contractday = strtotime($arrayData[$wip['contractno']]['sign'][2]); $contractday = strtotime($arrayData[$wip['contractno']]['sign'][2]);
$month = collect_month($contractday); $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) { if ($today > $contractday) {
$arrayData[$wip['contractno']]['sign_num'] += 1; $arrayData[$wip['contractno']]['sign_num'] += 1;
$facility_status = $wip['facilityno'] . " (出貨前30天" . $arrayData[$wip['contractno']]['sign'][2] . "已過) <br>"; $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]); $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) { if ($today > $contractday) {
$arrayData[$wip['contractno']]['second_num'] += 1; $arrayData[$wip['contractno']]['second_num'] += 1;
$facility_status = $wip['facilityno'] . " (出貨後10天" . $arrayData[$wip['contractno']]['second'][2] . "已過) <br>"; $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) { if ($wip['real_arrival_date'] != NULL) {
$estimate_time = strtotime($wip['real_arrival_date']); $estimate_time = strtotime($wip['real_arrival_date']);
$contractday = $estimate_time + (90 * 86400); $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) { if ($today > $contractday) {
$arrayData[$wip['contractno']]['arrive_num'] += 1; $arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['arrive'][2] = strval(date('Y-m-d', $contractday)); $arrayData[$wip['contractno']]['arrive'][2] = strval(date('Y-m-d', $contractday));
$facility_status = $wip['facilityno'] . " (貨抵工地後90天" . $arrayData[$wip['contractno']]['arrive'][2] . "已過) <br>"; $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) { if ($wip['tryrun_end_date'] != NULL) {
$estimate_time = strtotime($wip['tryrun_end_date']); $estimate_time = strtotime($wip['tryrun_end_date']);
$contractday = $estimate_time + (90 * 86400); $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) { if ($today > $contractday) {
$arrayData[$wip['contractno']]['tryrun_num'] += 1; $arrayData[$wip['contractno']]['tryrun_num'] += 1;
$arrayData[$wip['contractno']]['tryrun'][2] = strval(date('Y-m-d', $contractday)); $arrayData[$wip['contractno']]['tryrun'][2] = strval(date('Y-m-d', $contractday));
$facility_status = $wip['facilityno'] . " (試車後90天" . $arrayData[$wip['contractno']]['tryrun'][2] . "已過) <br>"; $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) { if ($wip['delivery_date'] != NULL) {
$estimate_time = strtotime($wip['delivery_date']); $estimate_time = strtotime($wip['delivery_date']);
$contractday = $estimate_time + (270 * 86400); $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) { if ($today > $contractday) {
$arrayData[$wip['contractno']]['delivery_num'] += 1; $arrayData[$wip['contractno']]['delivery_num'] += 1;
$arrayData[$wip['contractno']]['delivery'][2] = strval(date('Y-m-d', $contractday)); $arrayData[$wip['contractno']]['delivery'][2] = strval(date('Y-m-d', $contractday));
$facility_status = $wip['facilityno'] . " (交車後270天" . $arrayData[$wip['contractno']]['delivery'][2] . "已過) <br>"; $facility_status = $wip['facilityno'] . " (交車後270天" . $arrayData[$wip['contractno']]['delivery'][2] . "已過) <br>";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $facility_status;
} }
} }
} }
@ -360,11 +391,23 @@ foreach ($wipwhole_array as $wip) {
} }
} else { } else {
$facility_status = $wip['facilityno'] . " (出貨前30天" . $arrayData[$wip['contractno']]['sign'][2] . "未到) <br>"; $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; $arrayData[$wip['contractno']]['facilities'] .= $facility_status;
} else { } 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) { if ($wip['delivery_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['delivery_date'] . "已移交) <br>"; $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']]['tryrun_num'] += 1;
$arrayData[$wip['contractno']]['install_num'] += 1; $arrayData[$wip['contractno']]['install_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1; $arrayData[$wip['contractno']]['arrive_num'] += 1;
@ -374,7 +417,13 @@ foreach ($wipwhole_array as $wip) {
if ($arrayData[$wip['contractno']]['delivery'][0] == "交車後270天") { if ($arrayData[$wip['contractno']]['delivery'][0] == "交車後270天") {
$estimate_delivery_time = strtotime($wip['delivery_date']); $estimate_delivery_time = strtotime($wip['delivery_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400); $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); $arrayData[$wip['contractno']]['delivery'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['delivery']['min'], strtotime(strval($arrivetime))); array_push($arrayData[$wip['contractno']]['delivery']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['delivery']['max'], strtotime(strval($arrivetime))); array_push($arrayData[$wip['contractno']]['delivery']['max'], strtotime(strval($arrivetime)));
@ -382,60 +431,74 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['delivery_num'] += 1; $arrayData[$wip['contractno']]['delivery_num'] += 1;
$arrayData[$wip['contractno']]['check_num'] += 1; $arrayData[$wip['contractno']]['check_num'] += 1;
$arrayData[$wip['contractno']]['delivery'][2] = strval($wip['delivery_date']); $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']['min'], strtotime(strval($wip['delivery_date'])));
array_push($arrayData[$wip['contractno']]['delivery']['max'], 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) { 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']['min'], strtotime(strval($wip['official_check_date'])));
array_push($arrayData[$wip['contractno']]['check']['max'], 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 (!empty($wip['tryrun_end_date']) && $wip['tryrun_end_date'] != NULL) {
if ($arrayData[$wip['contractno']]['tryrun'][0] == "安裝試車後90天") { if ($arrayData[$wip['contractno']]['tryrun'][0] == "安裝試車後90天") {
$estimate_delivery_time = strtotime($wip['tryrun_end_date']); $estimate_delivery_time = strtotime($wip['tryrun_end_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400); $tryruntime = $estimate_delivery_time + (90 * 86400);
$arrivetime = date('Ymd', $secondtime); $tryruntime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['tryrun'][2] = strval($secondtime); $arrayData[$wip['contractno']]['tryrun'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['tryrun']['min'], strtotime(strval($arrivetime))); array_push($arrayData[$wip['contractno']]['tryrun']['min'], strtotime(strval($tryruntime)));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], strtotime(strval($arrivetime))); 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 { } else {
$arrayData[$wip['contractno']]['tryrun'][2] = strval($wip['tryrun_end_date']); $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']['min'], strtotime(strval($wip['tryrun_end_date'])));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], 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) { 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']['min'], strtotime(strval($wip['install_end_date'])));
array_push($arrayData[$wip['contractno']]['install']['max'], 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 (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) {
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") { if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
$estimate_delivery_time = strtotime($wip['real_arrival_date']); $estimate_delivery_time = strtotime($wip['real_arrival_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400); $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); $arrivetime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime); $arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime))); array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime))); array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime)));
} else { } 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']); $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']['min'], strtotime(strval($wip['real_arrival_date'])));
array_push($arrayData[$wip['contractno']]['arrive']['max'], 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) { } elseif ($wip['official_check_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['official_check_date'] . "官檢完畢) <br>"; $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']]['check_num'] += 1;
$arrayData[$wip['contractno']]['tryrun_num'] += 1; $arrayData[$wip['contractno']]['tryrun_num'] += 1;
$arrayData[$wip['contractno']]['install_num'] += 1; $arrayData[$wip['contractno']]['install_num'] += 1;
@ -445,30 +508,48 @@ foreach ($wipwhole_array as $wip) {
if (!empty($wip['official_check_date']) && $wip['official_check_date'] != NULL) { 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']['min'], strtotime(strval($wip['official_check_date'])));
array_push($arrayData[$wip['contractno']]['check']['max'], 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 (!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']); $estimate_delivery_time = strtotime($wip['tryrun_end_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400); $tryruntime = $estimate_delivery_time + (90 * 86400);
$arrivetime = date('Ymd', $secondtime); $month = collect_month($tryruntime);
$tryruntime = date('Ymd', $tryruntime);
$arrayData[$wip['contractno']]['tryrun'][2] = strval($secondtime); $arrayData[$wip['contractno']]['tryrun'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['tryrun']['min'], strtotime(strval($arrivetime))); array_push($arrayData[$wip['contractno']]['tryrun']['min'], strtotime(strval($tryruntime)));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], strtotime(strval($arrivetime))); 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 { } 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']); $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']['min'], strtotime(strval($wip['tryrun_end_date'])));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], 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) { 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']['min'], strtotime(strval($wip['install_end_date'])));
array_push($arrayData[$wip['contractno']]['install']['max'], 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 (!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']); $estimate_delivery_time = strtotime($wip['real_arrival_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400); $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); $arrivetime = date('Ymd', $secondtime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime); $arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime))); array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime)));
@ -477,6 +558,10 @@ foreach ($wipwhole_array as $wip) {
$arrayData[$wip['contractno']]['arrive'][2] = strval($wip['real_arrival_date']); $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']['min'], strtotime(strval($wip['real_arrival_date'])));
array_push($arrayData[$wip['contractno']]['arrive']['max'], 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 { } else {
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") { if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
@ -494,6 +579,7 @@ foreach ($wipwhole_array as $wip) {
} }
} elseif ($wip['tryrun_end_date'] != NULL) { } elseif ($wip['tryrun_end_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['tryrun_end_date'] . "試車完畢) <br>"; $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']]['tryrun_num'] += 1;
$arrayData[$wip['contractno']]['install_num'] += 1; $arrayData[$wip['contractno']]['install_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1; $arrayData[$wip['contractno']]['arrive_num'] += 1;
@ -502,20 +588,35 @@ foreach ($wipwhole_array as $wip) {
if (!empty($wip['tryrun_end_date']) && $wip['tryrun_end_date'] != NULL) { 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']['min'], strtotime(strval($wip['tryrun_end_date'])));
array_push($arrayData[$wip['contractno']]['tryrun']['max'], 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) { 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']['min'], strtotime(strval($wip['install_end_date'])));
array_push($arrayData[$wip['contractno']]['install']['max'], 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 (!empty($wip['real_arrival_date']) && $wip['real_arrival_date'] != NULL) {
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") { if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
$estimate_delivery_time = strtotime($wip['real_arrival_date']); $estimate_delivery_time = strtotime($wip['real_arrival_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400); $arrivetime = $estimate_delivery_time + (90 * 86400);
$arrivetime = date('Ymd', $secondtime); $month = collect_month($arrivetime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime); $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']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime))); array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime)));
} else { } 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']); $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']['min'], strtotime(strval($wip['real_arrival_date'])));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date']))); array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date'])));
@ -524,8 +625,8 @@ foreach ($wipwhole_array as $wip) {
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") { if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
$estimate_delivery_time = strtotime($wip['real_contract_arrival_date']); $estimate_delivery_time = strtotime($wip['real_contract_arrival_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400); $arrivetime = $estimate_delivery_time + (90 * 86400);
$arrivetime = date('Ymd', $secondtime); $arrivetime = date('Ymd', $arrivetime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime); $arrayData[$wip['contractno']]['arrive'][2] = strval($arrivetime);
array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime))); array_push($arrayData[$wip['contractno']]['arrive']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime))); array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime)));
} else { } else {
@ -536,11 +637,16 @@ foreach ($wipwhole_array as $wip) {
} }
} elseif ($wip['install_end_date'] != NULL) { } elseif ($wip['install_end_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['install_end_date'] . "安裝完畢) <br>"; $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']]['install_num'] += 1;
$arrayData[$wip['contractno']]['arrive_num'] += 1; $arrayData[$wip['contractno']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1; $arrayData[$wip['contractno']]['second_num'] += 1;
$arrayData[$wip['contractno']]['sign_num'] += 1; $arrayData[$wip['contractno']]['sign_num'] += 1;
if (!empty($wip['install_end_date']) && $wip['install_end_date'] != NULL) { 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']['min'], strtotime(strval($wip['install_end_date'])));
array_push($arrayData[$wip['contractno']]['install']['max'], strtotime(strtotime(strval($wip['install_end_date'])))); array_push($arrayData[$wip['contractno']]['install']['max'], strtotime(strtotime(strval($wip['install_end_date']))));
} }
@ -548,11 +654,18 @@ foreach ($wipwhole_array as $wip) {
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") { if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
$estimate_delivery_time = strtotime($wip['real_arrival_date']); $estimate_delivery_time = strtotime($wip['real_arrival_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400); $arrivetime = $estimate_delivery_time + (90 * 86400);
$arrivetime = date('Ymd', $secondtime); $month = collect_month($arrivetime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime); $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']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime))); array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime)));
} else { } 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']); $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']['min'], strtotime(strval($wip['real_arrival_date'])));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date']))); array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($wip['real_arrival_date'])));
@ -573,6 +686,7 @@ foreach ($wipwhole_array as $wip) {
} }
} elseif ($wip['real_arrival_date'] != NULL) { } elseif ($wip['real_arrival_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['real_arrival_date'] . "貨抵工地) <br>"; $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']]['arrive_num'] += 1;
$arrayData[$wip['contractno']]['second_num'] += 1; $arrayData[$wip['contractno']]['second_num'] += 1;
$arrayData[$wip['contractno']]['sign_num'] += 1; $arrayData[$wip['contractno']]['sign_num'] += 1;
@ -580,28 +694,42 @@ foreach ($wipwhole_array as $wip) {
if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") { if ($arrayData[$wip['contractno']]['arrive'][0] == "貨抵工地後90天") {
$estimate_delivery_time = strtotime($wip['real_arrival_date']); $estimate_delivery_time = strtotime($wip['real_arrival_date']);
$arrivetime = $estimate_delivery_time + (90 * 86400); $arrivetime = $estimate_delivery_time + (90 * 86400);
$arrivetime = date('Ymd', $secondtime); $month = collect_month($arrivetime);
$arrayData[$wip['contractno']]['arrive'][2] = strval($secondtime); $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']['min'], strtotime(strval($arrivetime)));
array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime))); array_push($arrayData[$wip['contractno']]['arrive']['max'], strtotime(strval($arrivetime)));
} else { } 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']); $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']['min'], strtotime(strval($wip['real_arrival_date'])));
array_push($arrayData[$wip['contractno']]['arrive']['max'], 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'))) { } 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']]['facilities'] .= $wip['facilityno'] . " (已達二次款收款條件) <br>";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (已達二次款收款條件) <br>";
$arrayData[$wip['contractno']]['second_num'] += 1; $arrayData[$wip['contractno']]['second_num'] += 1;
$arrayData[$wip['contractno']]['sign_num'] += 1; $arrayData[$wip['contractno']]['sign_num'] += 1;
} else { } else {
$arrayData[$wip['contractno']]['sign_num'] += 1; $arrayData[$wip['contractno']]['sign_num'] += 1;
if ($wip['real_contract_arrival_date'] != NULL) { if ($wip['real_contract_arrival_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['real_contract_arrival_date'] . "預計出貨日) <br>"; $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) { } elseif ($wip['estimated_shipping_date'] != NULL) {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (" . $wip['estimated_shipping_date'] . "預計出港日) <br>"; $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 { } else {
$arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (預計出港日待確認) <br>"; $arrayData[$wip['contractno']]['facilities'] .= $wip['facilityno'] . " (預計出港日待確認) <br>";
$arrayData[$wip['contractno']]['facility'][$wip['facilityno']]['status'] = $wip['facilityno'] . " (預計出港日待確認) <br>";
} }
} }
} }
@ -610,6 +738,7 @@ foreach ($wipwhole_array as $wip) {
// 計算每個合約的應收款、作番總數 // 計算每個合約的應收款、作番總數
$today_date = new DateTime(date('Y-m-d', strtotime('-1 month', strtotime(date('Y-m-d'))))); $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) { foreach ($arrayData as &$value) {
if ($value['total_facility_num'] > 0) { 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'])) + $value['receivable_budget'] = $value['sign'][1] * ($value['sign_num'] / $value['total_facility_num']) + ($value['second'][1] * ($value['second_num'] / $value['total_facility_num'])) +
@ -625,9 +754,24 @@ foreach ($arrayData as &$value) {
$value['delivery'][3] = $value['delivery'][1] * ($value['delivery_num'] / $value['total_facility_num']); $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']); $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) { foreach ($contractstage as $i) {
if (!empty($value[$i]['min']) && count($value[$i]['min']) > 0) { if (!empty($value[$i]['min']) && count($value[$i]['min']) > 0) {
$latest_timestamp = max($value[$i]['min']); $latest_timestamp = max($value[$i]['min']);
@ -701,6 +845,9 @@ foreach ($received_array as $received) {
$excel_aray = array(); $excel_aray = array();
$boga_array = array(); $boga_array = array();
$exclude_boga_array = array(); $exclude_boga_array = array();
$facility_array = array();
$facility_boga_array = array();
$facility_exclude_boga_array = array();
foreach ($arrayData as $key => $value) { foreach ($arrayData as $key => $value) {
$value['sign'][3] = (isset($value['sign'][3])) ? $value['sign'][3] : 0; $value['sign'][3] = (isset($value['sign'][3])) ? $value['sign'][3] : 0;
$value['second'][3] = (isset($value['second'][3])) ? $value['second'][3] : 0; $value['second'][3] = (isset($value['second'][3])) ? $value['second'][3] : 0;
@ -758,11 +905,67 @@ foreach ($arrayData as $key => $value) {
$value['final'][1], $value['final'][3], $value['final']['max'], $value['final']['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'], $value['total_facility_num'], 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); $data = json_encode($excel_aray);
$boga_data = json_encode($boga_array); $boga_data = json_encode($boga_array);
$exclude_boga_data = json_encode($exclude_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> <style>
@ -802,16 +1005,43 @@ $exclude_boga_data = json_encode($exclude_boga_array);
} }
</style> </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> <!-- <div style="width: 98%;margin: 1%;">
<button type="button" onclick="bogaData()" class="btn btn-warning btn-lg pull-right">寶佳<span class="glyphicon glyphicon-download-alt"></span></button> <div class="btn-group btn-group-lg " style="padding:10 px;">
<?php <button type="button" onclick="downloadData()" class="btn btn-success">全部<span class="glyphicon glyphicon-download-alt"></span></button>
if (in_array(accountidToDepartId($user_id), array('220', '210')) || $user_id == 'M0060') { <button type="button" onclick="exclude_bogaData()" class="btn btn-info">不含寶佳<span class="glyphicon glyphicon-download-alt"></span></button>
?> <button type="button" onclick="bogaData()" class="btn btn-warning">寶佳<span class="glyphicon glyphicon-download-alt"></span></button>
<a href="facility-price.php?<?= $token_link ?>" class="btn btn-primary btn-lg pull-right">合約作番明細</span></a> </div>
<?php </div>
} <div style="width: 98%;margin: 1%;">
?> <div class="btn-group btn-group-lg">
<button type="button" onclick="downloadFacilityData()" class="btn btn-success btn-lg">合約作番明細<span class="glyphicon glyphicon-download-alt"></span></button>
<button type="button" onclick="downloadFacilityBogaData()" class="btn btn-info btn-lg">寶佳合約作番明細<span class="glyphicon glyphicon-download-alt"></span></button>
<button type="button" onclick="downloadFacilityExcludeBogaData()" class="btn btn-warning btn-lg">不含寶佳合約作番明細<span class="glyphicon glyphicon-download-alt"></span></button>
</div>
</div> -->
<div class="btn-group" role="group">
<div class="btn-group" role="group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
合約
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><button type="button" onclick="downloadData()" class="btn btn-success">全部<span class="glyphicon glyphicon-download-alt"></span></button></li>
<li><button type="button" onclick="exclude_bogaData()" class="btn btn-info">不含寶佳<span class="glyphicon glyphicon-download-alt"></span></button></li>
<li><button type="button" onclick="bogaData()" class="btn btn-warning">寶佳<span class="glyphicon glyphicon-download-alt"></span></button></li>
</ul>
</div>
</div>
<div>
<?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>
<div style="width:98%;margin:1% ;overflow-x: auto;"> <div style="width:98%;margin:1% ;overflow-x: auto;">
<table id="table_index" class="table table-striped table-bordered" style="width:100%;"> <table id="table_index" class="table table-striped table-bordered" style="width:100%;">
<thead> <thead>
@ -925,10 +1155,10 @@ if (in_array(accountidToDepartId($user_id), array('220', '210')) || $user_id ==
} }
function test() { function test() {
var BillData = <?= $data ?>; var BillData = <?= $boga_data ?>;
var form = document.createElement("form"); var form = document.createElement("form");
form.method = 'POST'; 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"); var input = document.createElement("input");
input.type = "hidden"; input.type = "hidden";
input.name = "Bill"; input.name = "Bill";
@ -941,7 +1171,7 @@ if (in_array(accountidToDepartId($user_id), array('220', '210')) || $user_id ==
function downloadData() { function downloadData() {
var xhr = new XMLHttpRequest(); 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.open('POST', url, true);
xhr.setRequestHeader('Content-Type', 'application/json'); xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onreadystatechange = function() { xhr.onreadystatechange = function() {
@ -970,7 +1200,7 @@ if (in_array(accountidToDepartId($user_id), array('220', '210')) || $user_id ==
function bogaData() { function bogaData() {
var xhr = new XMLHttpRequest(); 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.open('POST', url, true);
xhr.setRequestHeader('Content-Type', 'application/json'); xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onreadystatechange = function() { xhr.onreadystatechange = function() {
@ -992,10 +1222,33 @@ if (in_array(accountidToDepartId($user_id), array('220', '210')) || $user_id ==
} }
function downloadFacilityData() {
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');
var name = "作番應收帳款" + "<?= date('Y-m-d-Hm') ?>" + ".xlsx";
link.setAttribute('href', window.location.origin + "/wms/account-receivable-facility.xlsx");
link.setAttribute('download', name);
link.style.display = 'none';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
}
xhr.send(JSON.stringify({
Bill: <?= $facility_data ?>
}));
}
function exclude_bogaData() { function exclude_bogaData() {
var xhr = new XMLHttpRequest(); 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.open('POST', url, true);
xhr.setRequestHeader('Content-Type', 'application/json'); xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onreadystatechange = function() { xhr.onreadystatechange = function() {

BIN
wms/account-receivable-test.xlsx

Binary file not shown.

6
wms/cont/sign_list.php

@ -75,8 +75,10 @@ form_key,
status, status,
f_return_content('payment_kind',payment_kind ) payment_kind FROM $table f_return_content('payment_kind',payment_kind ) payment_kind FROM $table
where 1=1 $where ORDER BY vol_no"; where 1=1 $where ORDER BY vol_no";
// echo $sql;
$data = mysqli_query($link, $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; $oneself = ($row['salesman'] == $user_id) ? 1 : 0;
?> ?>
<tr> <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['vol_no'] ?></td>
<td><?php echo $row['address'] ?></td> <td><?php echo $row['address'] ?></td>
<td><?php echo $row['case_name'] ?></td> <td><?php echo $row['case_name'] ?></td>

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

@ -70,32 +70,27 @@ if (!empty($_GET['apply_key'])) {
$noteArr = array(1, 1, 1, 1, 1); $noteArr = array(1, 1, 1, 1, 1);
$qty = $contract_maintance[0]['num']; $qty = $contract_maintance[0]['num'];
// echo $qty; // echo $qty;
// foreach ($contract_maintance as $idx => $amount) { foreach ($contract_maintance as $idx => $amount) {
// $isset = false; $isset = false;
// if ($amount['payment_kind'] == 5 || $amount['payment_kind'] == 6) {
// if ($amount['pay_scale'] >= 0) { if ($amount['pay_kind'] == 1 || $amount['pay_kind'] == 2 || $amount['pay_kind'] == 3) {
// $install_total_price = $install_total_price + $amount['pay_amount']; if ($amount['pay_scale'] > 0) {
// $installArr[] = ['installment' => $amount['pay_kind'], 'scale' => $amount['pay_scale'], 'amount' => $amount['pay_amount'], 'pay_period' => $amount['pay_period']]; $buy_total_price = $buy_total_price + $amount['pay_amount'];
// } foreach ($buyArr as $buy) {
// } if ($buy['installment'] == $amount['pay_kind']) {
// if ($amount['pay_kind'] == 1 || $amount['pay_kind'] == 2 || $amount['pay_kind'] == 3) { $isset = true;
// if ($amount['pay_scale'] > 0) { }
// $buy_total_price = $buy_total_price + $amount['pay_amount']; }
// foreach ($buyArr as $buy) { // if (!$isset) { {
// if ($buy['installment'] == $amount['pay_kind']) { // $buyArr[] = ['installment' => $amount['pay_kind'], 'scale' => $amount['pay_scale'], 'amount' => $amount['pay_amount'], 'pay_period' => $amount['pay_period']];
// $isset = true; // }
// } // if ($amount['pay_kind'] == 2) {
// } // $buyNo2Pay = 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 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"; $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); $stmt = $conn->prepare($sql_str);
@ -119,7 +114,7 @@ if (!empty($_GET['apply_key'])) {
<ul> <ul>
<button :class="isbuyShow ? 'active' : ''" @click="isbuyShow = true">電梯買賣合約書</button> <button :class="isbuyShow ? 'active' : ''" @click="isbuyShow = true">電梯買賣合約書</button>
<button :class="!isbuyShow ?'active' : ''" @click="isbuyShow = false">電梯安裝合約書</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> </ul>
</div> </div>
<div class="inputDiv" x-show="isbuyShow && isBuyInputIng"> <div class="inputDiv" x-show="isbuyShow && isBuyInputIng">
@ -453,11 +448,11 @@ if (!empty($_GET['apply_key'])) {
const totalInstallPrice = <?php echo $install_total_price; ?>; const totalInstallPrice = <?php echo $install_total_price; ?>;
const totalBuyPrice = <?php echo $buy_total_price; ?>; const totalBuyPrice = <?php echo $buy_total_price; ?>;
// const secondPayDeadline = <?php echo $contract['secondPayDeadline']; ?>; // 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 installfill1 = "<?php echo $contract_maintance['test_time']; ?>";
// const installfill2 = "<?php echo $contract_maintance['freedeadline']; ?>"; // const installfill2 = "<?php echo $contract_maintance['freedeadline']; ?>";
// const buyArr = [...<?php echo json_encode($buyArr); ?>]; const buyArr = [...<?php echo json_encode($buyArr); ?>];
// const installArr = [...<?php echo json_encode($installArr); ?>]; const installArr = [...<?php echo json_encode($installArr); ?>];
let install_pay_text = '付款方式:<br> '; let install_pay_text = '付款方式:<br> ';
let buy_pay_text = '' let buy_pay_text = ''
const chineseArr = ['零', '一', '二', '三', '四', '五', '六', '七'] const chineseArr = ['零', '一', '二', '三', '四', '五', '六', '七']

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

@ -6,6 +6,8 @@ const contractDownload = () => {
this.buystandarData = this.deepClone(this.buydata); this.buystandarData = this.deepClone(this.buydata);
this.buyonstandardViewData = 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; }`, 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: { data: {
illustrate: { 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: { buydata: {
}, },
@ -129,7 +147,22 @@ const contractDownload = () => {
return; return;
} }
} },
isBuyShow: true,
sendBuyInputFn() {
if (this.buyfilt1 == '') {
alert('請輸入交貨期限');
return;
}
if (this.buyfilt1 < 1) {
alert('交貨日期不得低於1日');
return;
}
if (buyArr[1].installment == 2) {
}
},
isBuyInputIng: true,
} }
}; };

195
wms/contract/api/postContractData.php

@ -1,8 +1,10 @@
<?php <?php
require_once("../conn.php"); require_once("../conn.php");
// require_once("../connt8.php");
include_once("./getFacilityNo.php"); include_once("./getFacilityNo.php");
include_once("./getComboNo.php"); include_once("./getComboNo.php");
include_once("./upload_chk.php"); include_once("./upload_chk.php");
ini_set('date.timezone', 'Asia/Taipei'); ini_set('date.timezone', 'Asia/Taipei');
//保養簽回 //保養簽回
if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['contracttype']) && $_POST['contracttype'] == 'b') { if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['contracttype']) && $_POST['contracttype'] == 'b') {
@ -137,7 +139,14 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
$facility_arr[] = $dailyNecessities[$elevator['spec']]; $facility_arr[] = $dailyNecessities[$elevator['spec']];
} }
echo json_encode($facility_arr); echo json_encode($facility_arr);
// 電梯做番號
$facilityno = $createFacilityNo->makeBFacilityNo("T", $facility_arr, (int)$num); $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 json_encode($facilityno);
echo '-------'; echo '-------';
$sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid"; $sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid";
@ -304,6 +313,19 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
$stmt->execute(); $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'); header('Content-Type: application/json');
$jsonData = json_encode($files); $jsonData = json_encode($files);
@ -314,4 +336,177 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c
echo $e->getMessage(); echo $e->getMessage();
die('Error!:' . $e->getMessage()); die('Error!:' . $e->getMessage());
} }
};
function T8insert($data, $facilityno)
{
require_once("../connt8.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($_POST['area']) ? $_POST['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 (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
(MaterialId,MaterialCategoryId,CreatorId,CreateTime)
VALUES (:MaterialId,'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,UnitId,CreatorId,CreateTime)
VALUES ('10',:MaterialId,:MaterialName,'E','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
(MaterialId,CurrId,SUnitId,TaxId,CreatorId,CreateTime)
VALUES (: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();
}
$connT8->commit();
} }

38
wms/contract/api/testT8API.php

@ -0,0 +1,38 @@
<?php
require_once("../connt8.php");
try {
$contractno = 'M0225202300';
$user_id = 'M0225';
// $sql = "INSERT INTO comBusinessPartner (BizPartnerId,TaxNo,CreatorId) VALUES('M0225202301','0923373895','$userid')";
// $stmt = $connT8->prepare($sql);
// $stmt->execute();
$sql = "UPDATE comBusinessPartner SET WorkTelNo = '' WHERE BizPartnerId= 'M0225202301'";
$stmt = $connT8->prepare($sql);
$stmt->execute();
echo 'Success';
} catch (PDOException $e) {
echo '<script>alert("更新失敗")</script>';
}
// $sql = "SELECT * FROM comCustomer WHERE BizPartnerId = :BizPartnerId";
// $stmt = $conn->prepare($sql);
// $stmt->bindParam(':BizPartnerId', $contractno);
// $stmt->execute();
// $result = $stmt->fetch(PDO::FETCH_NUM);
// $arr = array();
// if (!empty($result)) {
// foreach ($result as $key => $value) {
// $arr[$key] = $value;
// }
// }
// $count = empty($result) == '' ? 0 : COUNT($result);
// echo '<pre>';
// print_r($result);
// echo '</pre>';
// echo '<br/>';
// $createTime = Date('Y-m-sH-i-s');
// echo str_replace('-', '', $createTime);

29
wms/contract/conn.php

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

BIN
wms/facility-price.xlsx

Binary file not shown.

2
wms/header.php

@ -34,7 +34,7 @@ if (isset($_REQUEST["function_name"])) {
* 連線T8 MSSQL * 連線T8 MSSQL
*/ */
try { 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) { if ($conn) {
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} }

1587
wms/mkt/price_normal-index.php

File diff suppressed because it is too large

3546
wms/mkt/pricereview-create.php

File diff suppressed because it is too large

3962
wms/mkt/pricereview_renovate-create.php

File diff suppressed because it is too large

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 = ""; $sql_rib = "";
if (empty($rib_id)) { if (empty($rib_id)) {
$sql_rib = "SELECT * FROM rib WHERE BillNo = '$BillNo' && CurrentState=0"; $sql_rib = "SELECT * FROM rib WHERE BillNo = '$BillNo' && CurrentState=0";
$sql_invoiceNo = "SELECT DISTINCT InvoiceNo FROM rib_sub WHERE BillNo!==$BillNo";
} else { } else {
$sql_rib = "SELECT * FROM rib WHERE rib_id = $rib_id"; $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); $rib_query = mysqli_query($link, $sql_rib);
if (mysqli_num_rows($rib_query) > 0) { if (mysqli_num_rows($rib_query) > 0) {
@ -114,7 +116,17 @@ foreach ($BizPartner as $biz) {
array_push($BusinessPartner, $bizKey); array_push($BusinessPartner, $bizKey);
$bizcount += 1; $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); $BizJSON = json_encode($BusinessPartner);
$InvoiceJSON = json_encode($invoiceNo_array);
$sql_Project = "SELECT * FROM comProject"; $sql_Project = "SELECT * FROM comProject";
$projects = $conn->query($sql_Project); $projects = $conn->query($sql_Project);
$sql_Material = "SELECT * FROM comMaterialGroup"; $sql_Material = "SELECT * FROM comMaterialGroup";
@ -389,7 +401,7 @@ $materials = $conn->query($sql_Material);
</div> </div>
<div class="col-md-3" id="NotInvoice2"> <div class="col-md-3" id="NotInvoice2">
<label for="InvoiceNo">發票號碼</label> <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>
</div> </div>
@ -665,6 +677,12 @@ $materials = $conn->query($sql_Material);
window.open('rib02-invoice.php', '發票範例', config = 'height=600, width=600'); 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) { function changeWriteOffId(SelectedDept) {
var SelectDeptId = 'WriteOff' + SelectedDept + '-'; var SelectDeptId = 'WriteOff' + SelectedDept + '-';

19
wms/rib02-edit.php

@ -55,7 +55,18 @@ foreach ($BizPartner as $biz) {
array_push($BusinessPartner, $bizKey); array_push($BusinessPartner, $bizKey);
$bizcount += 1; $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); $BizJSON = json_encode($BusinessPartner);
$InvoiceJSON = json_encode($invoiceNo_array);
$sql_Project = "SELECT * FROM comProject"; $sql_Project = "SELECT * FROM comProject";
$projects = $conn->query($sql_Project); $projects = $conn->query($sql_Project);
$sql_Material = "SELECT * FROM comMaterialGroup"; $sql_Material = "SELECT * FROM comMaterialGroup";
@ -410,7 +421,7 @@ $materials = $conn->query($sql_Material);
</div> </div>
<div class="col-md-3" id="NotInvoice2"> <div class="col-md-3" id="NotInvoice2">
<label for="InvoiceNo">發票號碼</label> <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> </div>
<div> <div>
@ -683,6 +694,12 @@ $materials = $conn->query($sql_Material);
window.open('rib02-invoice.php', '新視窗的名稱', config = 'height=600, width=600'); 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) { function changeWriteOffId(SelectedDept) {
var SelectDeptId = 'WriteOff' + SelectedDept + '-'; var SelectDeptId = 'WriteOff' + SelectedDept + '-';

11
wms/rib02-submit.php

@ -15,6 +15,13 @@ foreach ($BizPartner as $biz) {
$bizValue = $biz['BizPartnerName']; $bizValue = $biz['BizPartnerName'];
$BusinessPartner[$bizKey] = $bizValue; $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']; $RowCode = $_POST['RowCode'];
$FeeDate = $_POST['FeeDate']; $FeeDate = $_POST['FeeDate'];
@ -35,7 +42,7 @@ $IsCounteract = $_POST['IsCounteract'];
$InvoiceId = $_POST['InvoiceId']; $InvoiceId = $_POST['InvoiceId'];
$VoucherCount = empty($_POST['VoucherCount']) ? 1 : $_POST['VoucherCount']; $VoucherCount = empty($_POST['VoucherCount']) ? 1 : $_POST['VoucherCount'];
$VoucherType = isset($_POST['VoucherType']) ? $_POST['VoucherType'] : 0; $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']; $CurrLAmount = empty($_POST['CurrLAmount']) ? null : $_POST['CurrLAmount'];
// $comSupplierName = empty($_POST['comSupplierName']) ? null : $_POST['comSupplierName']; // $comSupplierName = empty($_POST['comSupplierName']) ? null : $_POST['comSupplierName'];
@ -161,7 +168,7 @@ if ($submit == "add") {
$SQL1 .= empty($CU_MaterialId) ? "" : ",CU_MaterialId='$CU_MaterialId'"; $SQL1 .= empty($CU_MaterialId) ? "" : ",CU_MaterialId='$CU_MaterialId'";
$SQL1 .= empty($VoucherCount) ? "" : ",VoucherCount=$VoucherCount"; $SQL1 .= empty($VoucherCount) ? "" : ",VoucherCount=$VoucherCount";
$SQL1 .= isset($VoucherType) ? ",VoucherType=$VoucherType" : ""; $SQL1 .= isset($VoucherType) ? ",VoucherType=$VoucherType" : "";
$SQL1 .= empty($InvoiceNo) ? "" : ",InvoiceNo='$InvoiceNo'"; $SQL1 .= empty($InvoiceNo) ? " " : ",InvoiceNo='$InvoiceNo'";
$SQL1 .= empty($comSupplierName) ? ",comSupplierName=' '" : ",comSupplierName='$comSupplierName'"; $SQL1 .= empty($comSupplierName) ? ",comSupplierName=' '" : ",comSupplierName='$comSupplierName'";
$SQL1 .= empty($comSupplierId) ? ",comSupplierId=' '" : ",comSupplierId='$comSupplierId'"; $SQL1 .= empty($comSupplierId) ? ",comSupplierId=' '" : ",comSupplierId='$comSupplierId'";
$SQL1 .= isset($OTax) ? ",OTax=$OTax" : ""; $SQL1 .= isset($OTax) ? ",OTax=$OTax" : "";

8
wms/sign/list.php

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

Loading…
Cancel
Save