updates
parent
fd756369f7
commit
5542acb4cf
|
|
@ -9,6 +9,7 @@ using Newtonsoft.Json;
|
|||
using Org.BouncyCastle.Bcpg.OpenPgp;
|
||||
using NPOI.OpenXmlFormats.Shared;
|
||||
using NPOI.SS.Formula.PTG;
|
||||
using System.Data;
|
||||
|
||||
namespace QuotationMaker.Controllers
|
||||
{
|
||||
|
|
@ -72,6 +73,204 @@ namespace QuotationMaker.Controllers
|
|||
quotation_specTotal = "0";
|
||||
};
|
||||
|
||||
if (method == "del") {
|
||||
quotation objQuotation = conn.QueryFirstOrDefault<quotation>("select * from quotation where quotation_isdel = 'N' and quotation_revoke = 'N' and quotation_uid = @quotation_uid order by quotation_version desc", new { quotation_uid = quotation_uid });
|
||||
|
||||
if (objQuotation == null)
|
||||
{
|
||||
ret.ret = "no";
|
||||
ret.err_code = "0009";
|
||||
ret.message = "此筆資料不存在或已被刪除!";
|
||||
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||
}
|
||||
|
||||
objQuotation.quotation_isdel = "Y";
|
||||
objQuotation.quotation_modifydate = DateTime.Now;
|
||||
objQuotation.quotation_modify_uid = token.user_uid;
|
||||
objQuotation.quotation_log = token.user_name + " 刪除了此張報價單!";
|
||||
|
||||
conn.Update(objQuotation);
|
||||
|
||||
ret.ret = "yes";
|
||||
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||
}
|
||||
|
||||
if (method == "edit")
|
||||
{
|
||||
quotation oldQuotation = conn.QueryFirstOrDefault<quotation>("select * from quotation where quotation_version = @quotation_version and quotation_uid = @quotation_uid ", new { quotation_version = quotation_version, quotation_uid = quotation_uid });
|
||||
|
||||
if (oldQuotation == null)
|
||||
{
|
||||
ret.ret = "no";
|
||||
ret.err_code = "0002";
|
||||
ret.message = "找不到此筆報價單資料!";
|
||||
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||
}
|
||||
|
||||
quotation lastVerQuotation = conn.QueryFirstOrDefault<quotation>("select * from quotation where quotation_isdel = 'N' and quotation_revoke = 'N' and quotation_uid = @quotation_uid order by quotation_version desc ", new { quotation_uid = quotation_uid });
|
||||
|
||||
if (lastVerQuotation == null)
|
||||
{
|
||||
ret.ret = "no";
|
||||
ret.err_code = "0002";
|
||||
ret.message = "找不到此筆報價單資料!";
|
||||
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||
}
|
||||
|
||||
int new_version = lastVerQuotation.quotation_version + 1;
|
||||
|
||||
//--- start update
|
||||
quotation objQuotation = new quotation();
|
||||
|
||||
//quotation_log = quotation_log;
|
||||
//quotation_uid = quotation_uid;
|
||||
quotation_version = new_version.ToString();
|
||||
objQuotation.quotation_uid = quotation_uid;
|
||||
objQuotation.quotation_version = int.Parse(quotation_version);
|
||||
objQuotation.dept_uid = dept_uid;
|
||||
objQuotation.quotation_prodMethod = lastVerQuotation.quotation_prodMethod;
|
||||
objQuotation.quotation_date = quotation_date;
|
||||
objQuotation.quotation_expStart = quotation_expStart;
|
||||
objQuotation.quotation_expEnd = quotation_expEnd;
|
||||
objQuotation.quotation_name = quotation_name;
|
||||
objQuotation.project_uid = project_uid;
|
||||
objQuotation.contactPerson_uid = contactPerson_uid;
|
||||
objQuotation.company_uid = company_uid;
|
||||
objQuotation.quotation_log = quotation_log;
|
||||
objQuotation.quotation_create_uid = oldQuotation.quotation_create_uid;
|
||||
objQuotation.quotation_modify_uid = token.user_uid;
|
||||
objQuotation.quotation_noTaxTotal = double.Parse(quotation_noTaxTotal);
|
||||
objQuotation.quotation_specTotal = double.Parse(quotation_specTotal);
|
||||
objQuotation.quotation_tax = double.Parse(quotation_tax);
|
||||
objQuotation.quotation_grandTotal = double.Parse(quotation_grandTotal);
|
||||
objQuotation.quotation_sa = quotation_sa;
|
||||
objQuotation.quotation_isdel = quotation_isdel;
|
||||
objQuotation.quotation_revoke = quotation_revoke;
|
||||
objQuotation.quotation_createdate = DateTime.Now;
|
||||
objQuotation.quotation_modifydate = DateTime.Now;
|
||||
|
||||
dynamic mainItems_Json;
|
||||
dynamic payments_Json;
|
||||
dynamic invoices_Json;
|
||||
|
||||
try
|
||||
{
|
||||
mainItems_Json = JsonConvert.DeserializeObject(mainItems_jsonstr);
|
||||
payments_Json = JsonConvert.DeserializeObject(payments_jsonstr);
|
||||
invoices_Json = JsonConvert.DeserializeObject(invoices_jsonstr);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ret.ret = "no";
|
||||
ret.err_code = "0003";
|
||||
ret.message = "mainItems or payments or invoices json error," + ex.Message;
|
||||
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||
}
|
||||
|
||||
List<quotationMainItem> quotationMainItems = new List<quotationMainItem>();
|
||||
List<quotationSubItem> quotationSubItems = new List<quotationSubItem>();
|
||||
|
||||
foreach (dynamic item in mainItems_Json)
|
||||
{
|
||||
string quotationMainItem_uid = "qm_" + GlobalClass.CreateRandomCode(24);
|
||||
|
||||
quotationMainItem newItem = new quotationMainItem();
|
||||
newItem.quotation_uid = quotation_uid;
|
||||
newItem.mainItem_uid = item.mainItem_uid;
|
||||
newItem.quotationMainItem_uid = quotationMainItem_uid;
|
||||
newItem.quotationMainItem_name = item.quotationMainItem_name;
|
||||
newItem.quotationMainItem_ac = double.Parse((string)item.quotationMainItem_ac);
|
||||
newItem.quotationMainItem_subTotal = double.Parse((string)item.quotationMainItem_subTotal);
|
||||
newItem.quotationMainItem_revoke = "N";
|
||||
newItem.quotationMainItem_version = int.Parse((string)quotation_version);
|
||||
|
||||
quotationMainItems.Add(newItem);
|
||||
|
||||
foreach (dynamic subItem in item.subitems)
|
||||
{
|
||||
quotationSubItem newSubItem = new quotationSubItem();
|
||||
newSubItem.quotationSubItem_uid = "qs" + GlobalClass.CreateRandomCode(24);
|
||||
newSubItem.quotationMainItem_uid = quotationMainItem_uid;
|
||||
newSubItem.quotation_uid = quotation_uid;
|
||||
newSubItem.subItem_uid = subItem.subItem_uid;
|
||||
newSubItem.quotationSubItem_name = subItem.quotationSubItem_name;
|
||||
newSubItem.quotationSubItem_descript = subItem.quotationSubItem_descript;
|
||||
newSubItem.quotationSubItem_price = double.Parse((string)subItem.quotationSubItem_price);
|
||||
newSubItem.quotationSubItem_unitType = subItem.quotationSubItem_unitType;
|
||||
newSubItem.quotationSubItem_number = double.Parse((string)subItem.quotationSubItem_number);
|
||||
newSubItem.quotationSubItem_subTotal = double.Parse((string)subItem.quotationSubItem_subTotal);
|
||||
newSubItem.quotationSubItem_hasAC = subItem.quotationSubItem_hasAC;
|
||||
newSubItem.quotationSubItem_revoke = "N";
|
||||
newSubItem.quotationSubItem_version = int.Parse((string)quotation_version);
|
||||
|
||||
quotationSubItems.Add(newSubItem);
|
||||
}
|
||||
}
|
||||
|
||||
List<payment> payments = new List<payment>();
|
||||
|
||||
foreach (dynamic item in payments_Json)
|
||||
{
|
||||
payment newItem = new payment();
|
||||
|
||||
newItem.payment_uid = "pay_" + GlobalClass.CreateRandomCode(20);
|
||||
newItem.quotation_uid = quotation_uid;
|
||||
newItem.payment_method = item.payment_method;
|
||||
newItem.payment_methodname = item.payment_methodname;
|
||||
newItem.payment_descript = item.payment_descript;
|
||||
newItem.payment_revoke = "N";
|
||||
newItem.payment_version = int.Parse((string)quotation_version);
|
||||
|
||||
payments.Add(newItem);
|
||||
}
|
||||
|
||||
List<invoice> invoices = new List<invoice>();
|
||||
|
||||
foreach (dynamic item in invoices_Json)
|
||||
{
|
||||
invoice newItem = new invoice();
|
||||
|
||||
newItem.invoice_uid = "inv_" + GlobalClass.CreateRandomCode(20);
|
||||
newItem.quotation_uid = quotation_uid;
|
||||
newItem.invoice_name = item.invoice_name;
|
||||
|
||||
string yearmonth = item.invoice_date;
|
||||
string strYear = yearmonth.Split('/')[0];
|
||||
string strMonth = yearmonth.Split("/")[1];
|
||||
|
||||
newItem.invoice_year = int.Parse(strYear);
|
||||
newItem.invoice_month = int.Parse(strMonth);
|
||||
newItem.invoice_noTaxMoney = int.Parse((string)item.invoice_noTaxMoney);
|
||||
newItem.invoice_revoke = "N";
|
||||
newItem.invoice_version = int.Parse((string)quotation_version);
|
||||
|
||||
invoices.Add(newItem);
|
||||
}
|
||||
|
||||
string old_version = lastVerQuotation.quotation_version.ToString();
|
||||
|
||||
conn.Execute("update invoice set invoice_revoke = 'Y', invoice_modifydate = @invoice_modifydate where quotation_uid = @quotation_uid and invoice_version = @quotation_version ", new { invoice_modifydate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), quotation_uid = quotation_uid, quotation_version = old_version });
|
||||
conn.Execute("update payment set payment_revoke = 'Y', payment_modifydate = @payment_modifydate where quotation_uid = @quotation_uid and payment_version = @quotation_version ", new { payment_modifydate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), quotation_uid = quotation_uid, quotation_version = old_version });
|
||||
conn.Execute("update quotationSubItem set quotationSubItem_revoke = 'Y', quotationSubItem_modifydate = @quotationSubItem_modifydate where quotation_uid = @quotation_uid and quotationSubItem_version = @quotation_version ", new { quotationSubItem_modifydate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), quotation_uid = quotation_uid, quotation_version = old_version });
|
||||
conn.Execute("update quotationMainItem set quotationMainItem_revoke = 'Y', quotationMainItem_modifydate = @quotationMainItem_modifydate where quotation_uid = @quotation_uid and quotationMainItem_version = @quotation_version ", new { quotationMainItem_modifydate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), quotation_uid = quotation_uid, quotation_version = old_version });
|
||||
conn.Execute("update quotation set quotation_modify_uid = @quotation_modify_uid, quotation_revoke = 'Y', quotation_modifydate = @quotation_modifydate where quotation_uid = @quotation_uid and quotation_version = @quotation_version ", new { quotation_modify_uid = token.user_uid, quotation_modifydate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), quotation_uid = quotation_uid, quotation_version = old_version });
|
||||
|
||||
|
||||
|
||||
conn.Insert(invoices);
|
||||
conn.Insert(payments);
|
||||
conn.Insert(quotationSubItems);
|
||||
conn.Insert(quotationMainItems);
|
||||
conn.Insert<quotation>(objQuotation);
|
||||
|
||||
//--- end update
|
||||
ret.quotationView = conn.QueryFirstOrDefault<quotationView>("select * from quotationView where quotation_uid = @quotation_uid and quotation_isdel = 'N' and quotation_revoke = 'N' ", new { quotation_uid = quotation_uid });
|
||||
ret.ret = "yes";
|
||||
|
||||
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||
}
|
||||
|
||||
if (method == "get") {
|
||||
quotation objQuotation = conn.QueryFirstOrDefault<quotation>("select * from quotation where quotation_isdel = 'N' and quotation_revoke = 'N' and quotation_uid = @quotation_uid order by quotation_version desc", new { quotation_uid = quotation_uid });
|
||||
|
||||
|
|
|
|||
|
|
@ -367,13 +367,14 @@
|
|||
</div>
|
||||
<!-- grid row -->
|
||||
<div id="quotatiion_div" class="row">
|
||||
<div id="modelItem_div" class="col-lg-12">
|
||||
</div>
|
||||
<div class="card-body border-top">
|
||||
<button id="addModelMainItemBtn" type="button" class="btn btn-primary btn-lg btn-block">新增工作主項目</button>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="modelItem_div" class="col-lg-12">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- .form-group -->
|
||||
<div class="form-group">
|
||||
|
|
|
|||
|
|
@ -157,6 +157,10 @@ $(document).ready(function () {
|
|||
deledPayments = [];
|
||||
deledInvoices = [];
|
||||
|
||||
$('#modelItem_div').html('');
|
||||
$('#payment_group').find('ol').html('');
|
||||
$('#invoice_group').find('ol').html('');
|
||||
|
||||
quotation_total = 0;
|
||||
|
||||
$('#quotation_editType_div').show();
|
||||
|
|
@ -608,6 +612,7 @@ $(document).ready(function () {
|
|||
var htmlCode = '';
|
||||
|
||||
htmlCode += ' <li class="list-group-item align-items-center drag-handle">\n';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="data_method">add</textarea>';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="payment_method">' + payment_method + '</textarea>';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="payment_methodname">' + payment_methodname + '</textarea>';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="payment_descript">' + payment_descript + '</textarea>';
|
||||
|
|
@ -661,6 +666,7 @@ $(document).ready(function () {
|
|||
var htmlCode = '';
|
||||
|
||||
htmlCode += ' <li class="list-group-item align-items-center drag-handle">\n';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="data_method">add</textarea>';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="invoice_name">' + invoice_name + '</textarea>';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="invoice_date">' + invoice_date + '</textarea>';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="invoice_noTaxMoney">' + invoice_noTaxMoney + '</textarea>';
|
||||
|
|
@ -730,6 +736,8 @@ $(document).ready(function () {
|
|||
|
||||
var quotation_log = '';
|
||||
|
||||
|
||||
|
||||
if ($('#quotation_custom').prop('checked') == true) {
|
||||
quotation_prodMethod = 'custom';
|
||||
}
|
||||
|
|
@ -771,7 +779,7 @@ $(document).ready(function () {
|
|||
quotation_log += '實際總價由 ' + AppendComma(quotation_grandTotal_old) + ' 變更為 ' + AppendComma(quotation_grandTotal) + '\n';
|
||||
}
|
||||
|
||||
if (quotation_sa != cquotation_sa_old) {
|
||||
if (quotation_sa != quotation_sa_old) {
|
||||
quotation_log += '製作及維護服務協議條款內容有所變更\n';
|
||||
}
|
||||
|
||||
|
|
@ -860,6 +868,12 @@ $(document).ready(function () {
|
|||
|
||||
subitems.push(subItemFormData);
|
||||
|
||||
if (data_method == 'add' && quotation_method == 'edit') {
|
||||
if (quotationSubItem_name != quotationSubItem_name_old) {
|
||||
quotation_log += '報價主項目 [' + quotationMainItem_name + '] 中新增子項目 [' + quotationSubItem_name + '] \n';
|
||||
}
|
||||
}
|
||||
|
||||
if (data_method == 'edit') {
|
||||
if (quotationSubItem_name != quotationSubItem_name_old) {
|
||||
quotation_log += '報價主項目 [' + quotationMainItem_name + '] 的子項目名稱由 [' + quotationSubItem_name_old + '] 更改為 [' + quotationSubItem_name + '] \n';
|
||||
|
|
@ -911,6 +925,10 @@ $(document).ready(function () {
|
|||
var payment_methodname = $(item).find('[data-name="payment_methodname"]').val();
|
||||
var payment_descript = $(item).find('[data-name="payment_descript"]').val();
|
||||
|
||||
var data_method = $(item).find('[data-name="data_method"]').val();
|
||||
if (quotation_method == 'edit' && data_method == 'add') {
|
||||
quotation_log += '付款方式增加了 [' + payment_methodname + ' - ' + payment_descript + ']\n';
|
||||
}
|
||||
|
||||
var paymentFormData = {
|
||||
payment_method: payment_method,
|
||||
|
|
@ -927,7 +945,11 @@ $(document).ready(function () {
|
|||
var invoice_name = $(item).find('[data-name="invoice_name"]').val();
|
||||
var invoice_date = $(item).find('[data-name="invoice_date"]').val();
|
||||
var invoice_noTaxMoney = $(item).find('[data-name="invoice_noTaxMoney"]').val();
|
||||
var data_method = $(item).find('[data-name="data_method"]').val();
|
||||
|
||||
if (quotation_method == 'edit' && data_method == 'add') {
|
||||
quotation_log += '發票品項增加了 [' + invoice_name + ' (' + invoice_date + ') ' + AppendComma(invoice_noTaxMoney) + ']\n';
|
||||
}
|
||||
|
||||
var invoiceFormData = {
|
||||
invoice_name: invoice_name,
|
||||
|
|
@ -1288,6 +1310,196 @@ function quotationEditModelFillData(obj, objView) {
|
|||
});
|
||||
|
||||
$("#quotation_range").trigger('change');
|
||||
|
||||
quotation_total = 0;
|
||||
|
||||
var mainItemHtmlCode = '';
|
||||
|
||||
$.each(obj.quotationMainItemDetails, function (i, mainItem) {
|
||||
//產生報價項目
|
||||
mainItemHtmlCode += makeMainItemHtml(mainItem);
|
||||
});
|
||||
|
||||
$('#modelItem_div').html(mainItemHtmlCode);
|
||||
|
||||
//產生付款方式
|
||||
var paymentHtmlCode = '';
|
||||
$.each(obj.payments, function (i, payment) {
|
||||
paymentHtmlCode += makePaymentHtml(payment);
|
||||
});
|
||||
|
||||
$('#payment_group').find('ol').append(paymentHtmlCode);
|
||||
|
||||
//產生發票品項
|
||||
var invoiceHtmlCode = '';
|
||||
|
||||
$.each(obj.invoices, function (i, invoice) {
|
||||
invoiceHtmlCode += makeInvoiceHtml(invoice);
|
||||
});
|
||||
|
||||
$('#invoice_group').find('ol').append(invoiceHtmlCode);
|
||||
}
|
||||
|
||||
function makeMainItemHtml(obj) {
|
||||
var ac_string = '';
|
||||
|
||||
if (obj.quotationMainItem_ac == 0) {
|
||||
ac_string = '無';
|
||||
} else {
|
||||
ac_string = obj.quotationMainItem_ac + '%'
|
||||
}
|
||||
|
||||
var mainItem_total = 0;
|
||||
var mainItem_ac = 0.0;
|
||||
|
||||
$.each(obj.quotationSubItems, function (i, subitem) {
|
||||
var subitem_val = subitem.quotationSubItem_subTotal;
|
||||
mainItem_total += subitem_val;
|
||||
if (subitem.quotationSubItem_hasAC == 'Y') {
|
||||
|
||||
mainItem_ac += (subitem_val * (obj.quotationMainItem_ac / 100));
|
||||
}
|
||||
});
|
||||
|
||||
var mainItem_totalac = Math.round(mainItem_total + mainItem_ac);
|
||||
|
||||
quotation_total += mainItem_totalac;
|
||||
|
||||
var htmlCode = '';
|
||||
htmlCode += '<!-- .card -->';
|
||||
htmlCode += '<div class="card card-fluid" data-uid="' + obj.quotationMainItem_uid + '" data-main-uid="' + obj.mainItem_uid + '" data-type="edit">';
|
||||
htmlCode += ' <div class="card-header border-bottom-0 btn-group">';
|
||||
htmlCode += ' <input type="hidden" data-name="quotationMainItem_name" value="' + obj.quotationMainItem_name + '" />';
|
||||
htmlCode += ' <input type="hidden" data-name="quotationMainItem_ac" value="' + obj.quotationMainItem_ac + '" />';
|
||||
htmlCode += ' <input type="hidden" data-name="quotationMainItem_subTotal" value="' + mainItem_totalac + '" />';
|
||||
htmlCode += ' <input type="hidden" data-name="quotationMainItem_name_old" value="' + obj.quotationMainItem_name +'" />';
|
||||
htmlCode += ' <input type="hidden" data-name="quotationMainItem_ac_old" value="' + obj.quotationMainItem_ac + '" />';
|
||||
htmlCode += ' <input type="hidden" data-name="quotationMainItem_subTotal_old" value="' + mainItem_totalac + '" />';
|
||||
htmlCode += ' <input type="hidden" data-name="mainItem_uid_old" value="" />';
|
||||
htmlCode += ' <span data-span="quotationMainItem_name" style="width: 60%;">' + obj.quotationMainItem_name + ' </span>';
|
||||
htmlCode += ' <span data-span="quotationMainItem_ac" style="width: 10%;">AC: ' + ac_string + ' </span>';
|
||||
htmlCode += ' <span data-span="quotationMainItem_subTotal" style="text-align: right;">項目合計: ' + AppendComma(mainItem_totalac) + '</span>';
|
||||
htmlCode += ' <div class="dd-nodrag btn-group ml-auto">';
|
||||
htmlCode += ' <button type="button" class="btn btn-sm btn-secondary" onclick="editQuotationMainItem(this);">Edit</button> <button type="button" onclick="delQuotationMainItem(this);" class="btn btn-sm btn-secondary"><i class="far fa-trash-alt"></i></button>';
|
||||
htmlCode += ' </div>';
|
||||
htmlCode += ' ';
|
||||
htmlCode += ' </div>';
|
||||
htmlCode += ' <div class="dd" id="nest_' + obj.quotationMainItem_uid + '" data-toggle="sortable" data-max-depth="1" >';
|
||||
htmlCode += ' <!-- .dd-list -->';
|
||||
htmlCode += ' <ol class="dd-list">';
|
||||
|
||||
$.each(obj.quotationSubItems, function (i, subitem) {
|
||||
htmlCode += makeSubItemHtml(subitem);
|
||||
});
|
||||
|
||||
htmlCode += ' ';
|
||||
htmlCode += ' </ol><!-- /.dd-list -->';
|
||||
htmlCode += ' </div>';
|
||||
htmlCode += ' <!-- .card-footer -->';
|
||||
htmlCode += ' <div class="card-footer">';
|
||||
htmlCode += ' <a href="javascript: void(0);" onclick="addQuotationSubItem(this);" class="card-footer-item justify-content-start"><span><i class="fa fa-plus-circle mr-1"></i> 添加子項目</span></a>';
|
||||
htmlCode += ' </div><!-- /.card-footer -->';
|
||||
htmlCode += '</div><!-- /.card -->';
|
||||
|
||||
return htmlCode;
|
||||
}
|
||||
function makeSubItemHtml(obj) {
|
||||
var htmlCode = '';
|
||||
|
||||
htmlCode += ' <li class="dd-item" data-model-subitem-uid="' + obj.quotationSubItem_uid + '" data-method="edit">';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="subItem_uid">' + obj.subItem_uid + '</textarea>';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="quotationSubItem_uid">' + obj.subItem_uid + '</textarea>';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="quotationSubItem_name">' + obj.quotationSubItem_name + '</textarea>';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="quotationSubItem_price">' + obj.quotationSubItem_price + '</textarea>';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="quotationSubItem_unitType">' + obj.quotationSubItem_unitType + '</textarea>';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="quotationSubItem_number">' + obj.quotationSubItem_number + '</textarea>';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="quotationSubItem_hasAC">' + obj.quotationSubItem_hasAC + '</textarea>';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="quotationSubItem_subTotal">' + obj.quotationSubItem_subTotal + '</textarea>';
|
||||
htmlCode += ' <textarea data-name="quotationSubItem_descript" style="display:none;">' + obj.quotationSubItem_descript + '</textarea>';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="subItem_uid_old">' + obj.subItem_uid + '</textarea>';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="quotationSubItem_uid_old">' + obj.quotationSubItem_uid + '</textarea>';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="quotationSubItem_name_old">' + obj.quotationSubItem_name + '</textarea>';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="quotationSubItem_price_old">' + obj.quotationSubItem_price + '</textarea>';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="quotationSubItem_unitType_old">' + obj.quotationSubItem_unitType + '</textarea>';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="quotationSubItem_number_old">' + obj.quotationSubItem_number + '</textarea>';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="quotationSubItem_hasAC_old">' + obj.quotationSubItem_hasAC + '</textarea>';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="quotationSubItem_subTotal_old">' + obj.quotationSubItem_subTotal + '</textarea>';
|
||||
htmlCode += ' <textarea data-name="quotationSubItem_descript_old" style="display:none;">' + obj.quotationSubItem_descript + '</textarea>';
|
||||
htmlCode += ' <div class="dd-handle">';
|
||||
htmlCode += ' <div class="list-group-item">';
|
||||
htmlCode += ' <div class="list-group-item-figure">';
|
||||
htmlCode += ' <span class="drag-indicator"></span>';
|
||||
htmlCode += ' </div>';
|
||||
htmlCode += ' <div class="list-group-item-body">';
|
||||
htmlCode += ' <div class="team">';
|
||||
htmlCode += ' <h4 data-name="subname" class="list-group-item-title">';
|
||||
htmlCode += ' ' + obj.quotationSubItem_name;
|
||||
htmlCode += ' </h4><br/>';
|
||||
htmlCode += ' <p class="list-group-item-text" data-name="subdesc" style="white-space: pre-line;font-size: 13px;">';
|
||||
htmlCode += ' ' + obj.quotationSubItem_descript;
|
||||
htmlCode += ' </p><br/>';
|
||||
htmlCode += ' <p class="list-group-item-text" data-name="subsummy" style="white-space: pre-line;font-size: 11px;">';
|
||||
htmlCode += ' 單價 NT$' + AppendComma(obj.quotationSubItem_price) + ', 數量 ' + obj.quotationSubItem_number + ', 單位 ' + obj.quotationSubItem_unitType + '\r\n';
|
||||
htmlCode += ' 小計 NT$' + AppendComma(obj.quotationSubItem_subTotal) + '\r\n';
|
||||
htmlCode += ' AC(' + obj.quotationSubItem_hasAC + ')';
|
||||
htmlCode += ' </p>';
|
||||
htmlCode += ' </div>';
|
||||
htmlCode += ' </div>';
|
||||
htmlCode += ' </div>';
|
||||
htmlCode += ' <div class="dd-nodrag btn-group ml-auto">';
|
||||
htmlCode += ' <button type="button" onclick="editQuotationSubItemButton(this);" class="btn btn-sm btn-secondary">Edit</button> <button type="button" onclick="delQuotationSubItemButton(this);" class="btn btn-sm btn-secondary"><i class="far fa-trash-alt"></i></button>';
|
||||
htmlCode += ' </div>';
|
||||
htmlCode += ' </div> ';
|
||||
htmlCode += ' </li>';
|
||||
|
||||
return htmlCode;
|
||||
}
|
||||
|
||||
function makePaymentHtml(obj) {
|
||||
var payment_display = obj.payment_methodname;
|
||||
|
||||
if (obj.payment_descript != '') {
|
||||
obj.payment_display = obj.payment_display + ': ' + obj.payment_descript;
|
||||
}
|
||||
|
||||
var htmlCode = '';
|
||||
|
||||
htmlCode += ' <li class="list-group-item align-items-center drag-handle">\n';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="data_method">edit</textarea>';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="payment_method">' + obj.payment_method + '</textarea>';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="payment_methodname">' + obj.payment_methodname + '</textarea>';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="payment_descript">' + obj.payment_descript + '</textarea>';
|
||||
htmlCode += ' <span class="drag-indicator"></span>\n';
|
||||
htmlCode += ' <div> ' + payment_display + ' </div>\n';
|
||||
htmlCode += ' <div class="btn-group ml-auto">\n';
|
||||
htmlCode += ' <button class="btn btn-sm btn-secondary" data-method="add" onclick="delPaymentItem(this);"><i class="far fa-trash-alt"></i></button>\n';
|
||||
htmlCode += ' </div>\n';
|
||||
htmlCode += ' </li>\n';
|
||||
|
||||
return htmlCode;
|
||||
}
|
||||
|
||||
function makeInvoiceHtml(obj) {
|
||||
var invoice_display = "開立品項: " + obj.invoice_name + ", 開立月份: " + obj.invoice_date + ", 金額(未稅): " + AppendComma(obj.invoice_noTaxMoney);
|
||||
var invoice_date = obj.invoice_year + "/" + String(obj.invoice_month).padStart(2, "0");
|
||||
var htmlCode = '';
|
||||
|
||||
htmlCode += ' <li class="list-group-item align-items-center drag-handle">\n';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="data_method">edit</textarea>';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="invoice_name">' + obj.invoice_name + '</textarea>';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="invoice_date">' + invoice_date + '</textarea>';
|
||||
htmlCode += ' <textarea style="display:none;" data-name="invoice_noTaxMoney">' + obj.invoice_noTaxMoney + '</textarea>';
|
||||
htmlCode += ' <span class="drag-indicator"></span>\n';
|
||||
htmlCode += ' <span style="width: 15%;"> ' + "開立品項: " + obj.invoice_name + ' </span>\n';
|
||||
htmlCode += ' <span style="width: 15%;"> ' + "開立月份: " + invoice_date + ' </span\n';
|
||||
htmlCode += ' <span style="width: 20%;">' + "金額(未稅): " + AppendComma(obj.invoice_noTaxMoney) + ' </span>\n';
|
||||
htmlCode += ' <span style="width: 50%;"></span>';
|
||||
htmlCode += ' <div class="btn-group ml-auto">\n';
|
||||
htmlCode += ' <button class="btn btn-sm btn-secondary" data-method="add" onclick="delInvoiceItem(this);"><i class="far fa-trash-alt"></i></button>\n';
|
||||
htmlCode += ' </div>\n';
|
||||
htmlCode += ' </li>\n';
|
||||
|
||||
return htmlCode;
|
||||
}
|
||||
function buttonQuotationClick(obj, view) {
|
||||
var type = obj.getAttribute('data-method');
|
||||
|
|
@ -1299,6 +1511,47 @@ function buttonQuotationClick(obj, view) {
|
|||
|
||||
quotationRowPos = quotationTable.fnGetPosition($('#' + uid)[0]);
|
||||
|
||||
if (type == "del") {
|
||||
if (confirm('確定要刪除此張報價單?')) {
|
||||
var formData = {
|
||||
method: 'del',
|
||||
quotation_uid: uid,
|
||||
dept_uid: dept_uid
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: "/Api/addEditDelQuotation",
|
||||
type: "post",
|
||||
data: formData,
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
if (data.ret == "yes") {
|
||||
if (data.ret == "yes") {
|
||||
var row = quotationTable.api().row(quotationRowID).remove().draw(false);
|
||||
alert('刪除成功');
|
||||
|
||||
} else {
|
||||
alert(data.message);
|
||||
|
||||
if (data.err_code == "99999") {
|
||||
location.href = "/Root/Login";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
alert(data.message);
|
||||
|
||||
if (data.err_code == "99999") {
|
||||
location.href = "/Root/Login";
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('網路或伺服器發生錯誤,請稍後重試!');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (type == "edit") {
|
||||
var formData = {
|
||||
method: 'get',
|
||||
|
|
@ -1315,6 +1568,10 @@ function buttonQuotationClick(obj, view) {
|
|||
var obj = data.quotationDetail;
|
||||
var objView = data.quotationView;
|
||||
|
||||
$('#modelItem_div').html('');
|
||||
$('#payment_group').find('ol').html('');
|
||||
$('#invoice_group').find('ol').html('');
|
||||
|
||||
$("#quotation_method").val('edit');
|
||||
|
||||
quotationEditModelFillData(obj, objView);
|
||||
|
|
@ -2121,8 +2378,11 @@ function editQuotationSubItemButton(obj) {
|
|||
var modelSubItem_number = $(divObj).find("[data-name='quotationSubItem_number']").val();
|
||||
var modelSubItem_hasAC = $(divObj).find("[data-name='quotationSubItem_hasAC']").val();
|
||||
var modelSubItem_descript = $(divObj).find("[data-name='quotationSubItem_descript']").val();
|
||||
var modelMainItem_uid = $(divObj).parent().parent().attr("data-uid");
|
||||
var parent_mainItem_uid = $(divObj).parent().parent().attr("data-main-uid");
|
||||
|
||||
var divTmp = $(divObj).parent().parent().parent();
|
||||
|
||||
var modelMainItem_uid = $(divTmp).attr("data-uid");
|
||||
var parent_mainItem_uid = $(divTmp).attr("data-main-uid");
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue