Compare commits
2 Commits
0b95afb125
...
67a788d622
| Author | SHA1 | Date |
|---|---|---|
|
|
67a788d622 | |
|
|
b13121360f |
|
|
@ -10,6 +10,9 @@ using Org.BouncyCastle.Bcpg.OpenPgp;
|
||||||
using NPOI.OpenXmlFormats.Shared;
|
using NPOI.OpenXmlFormats.Shared;
|
||||||
using NPOI.SS.Formula.PTG;
|
using NPOI.SS.Formula.PTG;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
using System;
|
||||||
|
using AutoMapper;
|
||||||
|
using Org.BouncyCastle.Asn1.X509;
|
||||||
|
|
||||||
namespace QuotationMaker.Controllers
|
namespace QuotationMaker.Controllers
|
||||||
{
|
{
|
||||||
|
|
@ -29,6 +32,486 @@ namespace QuotationMaker.Controllers
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Route("saveas")]
|
||||||
|
public ActionResult SaveAs(IFormCollection obj) {
|
||||||
|
saveasResult ret = new saveasResult();
|
||||||
|
|
||||||
|
authToken token = new authToken(this._httpContextAccessor);
|
||||||
|
if (token.user_isLogin == false)
|
||||||
|
{
|
||||||
|
HttpContext.Response.Cookies.Delete("token_key");
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "99999";
|
||||||
|
ret.message = "非登入狀態!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
string quotation_uid = obj["quotation_uid"].ToString();
|
||||||
|
string quotation_name = obj["quotation_name"].ToString();
|
||||||
|
string quotation_version = obj["quotation_version"].ToString();
|
||||||
|
string project_uid = obj["project_uid"].ToString();
|
||||||
|
string project_name = obj["project_name"].ToString();
|
||||||
|
string company_uid = obj["company_uid"].ToString();
|
||||||
|
string contactPerson_uid = obj["contactPerson_uid"].ToString();
|
||||||
|
string method = obj["method"].ToString();
|
||||||
|
|
||||||
|
if (method == "save_to_other") {
|
||||||
|
quotation oldQuotation = conn.QueryFirstOrDefault<quotation>("select * from quotation where quotation_isdel = 'N' and quotation_uid = @quotation_uid and quotation_version = @quotation_version ", new { quotation_uid = quotation_uid, quotation_version = quotation_version });
|
||||||
|
|
||||||
|
if (oldQuotation == null)
|
||||||
|
{
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "0005";
|
||||||
|
ret.message = "無此版本號的 quotation_uid 資料!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
string new_quotation_uid = "q_" + GlobalClass.CreateRandomCode(24);
|
||||||
|
|
||||||
|
var config = new MapperConfiguration(cfg =>
|
||||||
|
{
|
||||||
|
cfg.CreateMap<quotation, quotation>();
|
||||||
|
});
|
||||||
|
var mapper = config.CreateMapper();
|
||||||
|
quotation quotation = new quotation();
|
||||||
|
|
||||||
|
mapper.Map(oldQuotation, quotation);
|
||||||
|
|
||||||
|
quotation.quotation_uid = new_quotation_uid;
|
||||||
|
quotation.quotation_name = quotation_name;
|
||||||
|
quotation.quotation_log = "由 [" + oldQuotation.quotation_name + "] 此報價單另存產生!";
|
||||||
|
quotation.quotation_version = 1;
|
||||||
|
quotation.quotation_createdate = DateTime.Now;
|
||||||
|
quotation.quotation_modifydate = DateTime.Now;
|
||||||
|
quotation.quotation_create_uid = token.user_uid;
|
||||||
|
quotation.quotation_modify_uid = token.user_uid;
|
||||||
|
quotation.quotation_revoke = "N";
|
||||||
|
quotation.company_uid = company_uid;
|
||||||
|
quotation.contactPerson_uid = contactPerson_uid;
|
||||||
|
quotation.project_uid = project_uid;
|
||||||
|
|
||||||
|
|
||||||
|
List<quotationMainItem> quotationMainItems = new List<quotationMainItem>();
|
||||||
|
List<quotationSubItem> quotationSubItems = new List<quotationSubItem>();
|
||||||
|
List<payment> payments = new List<payment>();
|
||||||
|
List<invoice> invoices = new List<invoice>();
|
||||||
|
|
||||||
|
List<quotationMainItem> old_quotationMainItems = conn.Query<quotationMainItem>("select * from quotationMainItem where quotation_uid = @quotation_uid and quotationMainItem_version = @quotation_version", new { quotation_uid = quotation_uid, quotation_version = quotation_version }).ToList();
|
||||||
|
|
||||||
|
List<payment> old_payments = conn.Query<payment>("select * from payment where quotation_uid = @quotation_uid and payment_version = @quotation_version", new { quotation_uid = quotation_uid, quotation_version = quotation_version }).ToList();
|
||||||
|
List<invoice> old_invoices = conn.Query<invoice>("select * from invoice where quotation_uid = @quotation_uid and invoice_version = @quotation_version", new { quotation_uid = quotation_uid, quotation_version = quotation_version }).ToList();
|
||||||
|
|
||||||
|
//主項目複製
|
||||||
|
foreach (quotationMainItem item in old_quotationMainItems)
|
||||||
|
{
|
||||||
|
var configItem = new MapperConfiguration(cfg =>
|
||||||
|
{
|
||||||
|
cfg.CreateMap<quotationMainItem, quotationMainItem>();
|
||||||
|
});
|
||||||
|
var mapperItem = configItem.CreateMapper();
|
||||||
|
|
||||||
|
quotationMainItem quotationMainItem = new quotationMainItem();
|
||||||
|
|
||||||
|
mapperItem.Map(item, quotationMainItem);
|
||||||
|
|
||||||
|
quotationMainItem.quotation_uid = new_quotation_uid;
|
||||||
|
quotationMainItem.quotationMainItem_version = 1;
|
||||||
|
quotationMainItem.quotationMainItem_revoke = "N";
|
||||||
|
quotationMainItem.quotationMainItem_uid = "qm_" + GlobalClass.CreateRandomCode(24);
|
||||||
|
quotationMainItem.quotationMainItem_createdate = DateTime.Now;
|
||||||
|
quotationMainItem.quotationMainItem_modifydate = DateTime.Now;
|
||||||
|
|
||||||
|
|
||||||
|
quotationMainItems.Add(quotationMainItem);
|
||||||
|
|
||||||
|
List<quotationSubItem> old_quotationSubItems = conn.Query<quotationSubItem>("select * from quotationSubItem where quotation_uid = @quotation_uid and quotationSubItem_version = @quotation_version and quotationMainItem_uid = @quotationMainItem_uid ", new { quotation_uid = quotation_uid, quotation_version = quotation_version, quotationMainItem_uid = item.quotationMainItem_uid }).ToList();
|
||||||
|
|
||||||
|
foreach (quotationSubItem subItem in old_quotationSubItems)
|
||||||
|
{
|
||||||
|
var configSubItem = new MapperConfiguration(cfg =>
|
||||||
|
{
|
||||||
|
cfg.CreateMap<quotationSubItem, quotationSubItem>();
|
||||||
|
});
|
||||||
|
var mapperSubItem = configSubItem.CreateMapper();
|
||||||
|
|
||||||
|
quotationSubItem quotationSubItem = new quotationSubItem();
|
||||||
|
|
||||||
|
mapperSubItem.Map(subItem, quotationSubItem);
|
||||||
|
|
||||||
|
quotationSubItem.quotationMainItem_uid = quotationMainItem.quotationMainItem_uid;
|
||||||
|
quotationSubItem.quotation_uid = new_quotation_uid;
|
||||||
|
quotationSubItem.quotationSubItem_version = 1;
|
||||||
|
quotationSubItem.quotationSubItem_uid = "qs_" + GlobalClass.CreateRandomCode(24);
|
||||||
|
quotationSubItem.quotationSubItem_createdate = DateTime.Now;
|
||||||
|
quotationSubItem.quotationSubItem_modifydate = DateTime.Now;
|
||||||
|
|
||||||
|
quotationSubItems.Add(quotationSubItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (payment item in old_payments)
|
||||||
|
{
|
||||||
|
var configItem = new MapperConfiguration(cfg =>
|
||||||
|
{
|
||||||
|
cfg.CreateMap<payment, payment>();
|
||||||
|
});
|
||||||
|
var mapperItem = configItem.CreateMapper();
|
||||||
|
|
||||||
|
payment paymentItem = new payment();
|
||||||
|
|
||||||
|
mapperItem.Map(item, paymentItem);
|
||||||
|
|
||||||
|
paymentItem.payment_uid = "pay_" + GlobalClass.CreateRandomCode(24);
|
||||||
|
paymentItem.quotation_uid = new_quotation_uid;
|
||||||
|
paymentItem.payment_version = 1;
|
||||||
|
paymentItem.payment_createdate = DateTime.Now;
|
||||||
|
paymentItem.payment_modifydate = DateTime.Now;
|
||||||
|
|
||||||
|
payments.Add(paymentItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (invoice item in old_invoices)
|
||||||
|
{
|
||||||
|
var configItem = new MapperConfiguration(cfg =>
|
||||||
|
{
|
||||||
|
cfg.CreateMap<invoice, invoice>();
|
||||||
|
});
|
||||||
|
var mapperItem = configItem.CreateMapper();
|
||||||
|
|
||||||
|
invoice invoiceItem = new invoice();
|
||||||
|
|
||||||
|
mapperItem.Map(item, invoiceItem);
|
||||||
|
|
||||||
|
invoiceItem.invoice_uid = "inv_" + GlobalClass.CreateRandomCode(24);
|
||||||
|
invoiceItem.invoice_version = 1;
|
||||||
|
invoiceItem.invoice_revoke = "N";
|
||||||
|
invoiceItem.quotation_uid = new_quotation_uid;
|
||||||
|
|
||||||
|
invoices.Add(invoiceItem);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
conn.Insert(invoices);
|
||||||
|
conn.Insert(payments);
|
||||||
|
conn.Insert(quotationSubItems);
|
||||||
|
conn.Insert(quotationMainItems);
|
||||||
|
conn.Insert(quotation);
|
||||||
|
|
||||||
|
ret.ret = "yes";
|
||||||
|
ret.quotationView = conn.QueryFirstOrDefault<quotationView>("select * from quotationView where quotation_isdel = 'N' and quotation_revoke = 'N' and quotation_uid = @quotation_uid", new { quotation_uid = new_quotation_uid });
|
||||||
|
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method == "save_to_same") {
|
||||||
|
quotation oldQuotation = conn.QueryFirstOrDefault<quotation>("select * from quotation where quotation_isdel = 'N' and quotation_uid = @quotation_uid and quotation_version = @quotation_version ", new { quotation_uid = quotation_uid, quotation_version = quotation_version });
|
||||||
|
|
||||||
|
if (oldQuotation == null) {
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "0005";
|
||||||
|
ret.message = "無此版本號的 quotation_uid 資料!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
string new_quotation_uid = "q_" + GlobalClass.CreateRandomCode(24);
|
||||||
|
|
||||||
|
var config = new MapperConfiguration(cfg =>
|
||||||
|
{
|
||||||
|
cfg.CreateMap<quotation, quotation>();
|
||||||
|
});
|
||||||
|
var mapper = config.CreateMapper();
|
||||||
|
quotation quotation = new quotation();
|
||||||
|
|
||||||
|
mapper.Map(oldQuotation, quotation);
|
||||||
|
|
||||||
|
quotation.quotation_uid = new_quotation_uid;
|
||||||
|
quotation.quotation_name = quotation_name;
|
||||||
|
quotation.quotation_log = "由 [" + oldQuotation.quotation_name + "] 此報價單另存產生!";
|
||||||
|
quotation.quotation_version = 1;
|
||||||
|
quotation.quotation_createdate = DateTime.Now;
|
||||||
|
quotation.quotation_modifydate = DateTime.Now;
|
||||||
|
quotation.quotation_create_uid = token.user_uid;
|
||||||
|
quotation.quotation_modify_uid = token.user_uid;
|
||||||
|
quotation.quotation_revoke = "N";
|
||||||
|
|
||||||
|
List<quotationMainItem> quotationMainItems = new List<quotationMainItem>();
|
||||||
|
List<quotationSubItem> quotationSubItems = new List<quotationSubItem>();
|
||||||
|
List<payment> payments = new List<payment>();
|
||||||
|
List<invoice> invoices = new List<invoice>();
|
||||||
|
|
||||||
|
List<quotationMainItem> old_quotationMainItems = conn.Query<quotationMainItem>("select * from quotationMainItem where quotation_uid = @quotation_uid and quotationMainItem_version = @quotation_version", new { quotation_uid = quotation_uid, quotation_version = quotation_version }).ToList();
|
||||||
|
|
||||||
|
List<payment> old_payments = conn.Query<payment>("select * from payment where quotation_uid = @quotation_uid and payment_version = @quotation_version", new { quotation_uid = quotation_uid, quotation_version = quotation_version }).ToList();
|
||||||
|
List<invoice> old_invoices = conn.Query<invoice>("select * from invoice where quotation_uid = @quotation_uid and invoice_version = @quotation_version", new { quotation_uid = quotation_uid, quotation_version = quotation_version }).ToList();
|
||||||
|
|
||||||
|
//主項目複製
|
||||||
|
foreach (quotationMainItem item in old_quotationMainItems) {
|
||||||
|
var configItem = new MapperConfiguration(cfg =>
|
||||||
|
{
|
||||||
|
cfg.CreateMap<quotationMainItem, quotationMainItem>();
|
||||||
|
});
|
||||||
|
var mapperItem = configItem.CreateMapper();
|
||||||
|
|
||||||
|
quotationMainItem quotationMainItem = new quotationMainItem();
|
||||||
|
|
||||||
|
mapperItem.Map(item, quotationMainItem);
|
||||||
|
|
||||||
|
quotationMainItem.quotation_uid = new_quotation_uid;
|
||||||
|
quotationMainItem.quotationMainItem_version = 1;
|
||||||
|
quotationMainItem.quotationMainItem_revoke = "N";
|
||||||
|
quotationMainItem.quotationMainItem_uid = "qm_" + GlobalClass.CreateRandomCode(24);
|
||||||
|
quotationMainItem.quotationMainItem_createdate = DateTime.Now;
|
||||||
|
quotationMainItem.quotationMainItem_modifydate = DateTime.Now;
|
||||||
|
|
||||||
|
quotationMainItems.Add(quotationMainItem);
|
||||||
|
|
||||||
|
List<quotationSubItem> old_quotationSubItems = conn.Query<quotationSubItem>("select * from quotationSubItem where quotation_uid = @quotation_uid and quotationSubItem_version = @quotation_version and quotationMainItem_uid = @quotationMainItem_uid ", new { quotation_uid = quotation_uid, quotation_version = quotation_version, quotationMainItem_uid = item.quotationMainItem_uid }).ToList();
|
||||||
|
|
||||||
|
foreach (quotationSubItem subItem in old_quotationSubItems)
|
||||||
|
{
|
||||||
|
var configSubItem = new MapperConfiguration(cfg =>
|
||||||
|
{
|
||||||
|
cfg.CreateMap<quotationSubItem, quotationSubItem>();
|
||||||
|
});
|
||||||
|
var mapperSubItem = configSubItem.CreateMapper();
|
||||||
|
|
||||||
|
quotationSubItem quotationSubItem = new quotationSubItem();
|
||||||
|
|
||||||
|
mapperSubItem.Map(subItem, quotationSubItem);
|
||||||
|
|
||||||
|
quotationSubItem.quotationMainItem_uid = quotationMainItem.quotationMainItem_uid;
|
||||||
|
quotationSubItem.quotation_uid = new_quotation_uid;
|
||||||
|
quotationSubItem.quotationSubItem_version = 1;
|
||||||
|
quotationSubItem.quotationSubItem_uid = "qs_" + GlobalClass.CreateRandomCode(24);
|
||||||
|
quotationSubItem.quotationSubItem_createdate = DateTime.Now;
|
||||||
|
quotationSubItem.quotationSubItem_modifydate = DateTime.Now;
|
||||||
|
|
||||||
|
quotationSubItems.Add(quotationSubItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (payment item in old_payments) {
|
||||||
|
var configItem = new MapperConfiguration(cfg =>
|
||||||
|
{
|
||||||
|
cfg.CreateMap<payment, payment>();
|
||||||
|
});
|
||||||
|
var mapperItem = configItem.CreateMapper();
|
||||||
|
|
||||||
|
payment paymentItem = new payment();
|
||||||
|
|
||||||
|
mapperItem.Map(item, paymentItem);
|
||||||
|
|
||||||
|
paymentItem.payment_uid = "pay_" + GlobalClass.CreateRandomCode(24);
|
||||||
|
paymentItem.quotation_uid = new_quotation_uid;
|
||||||
|
paymentItem.payment_version = 1;
|
||||||
|
paymentItem.payment_createdate = DateTime.Now;
|
||||||
|
paymentItem.payment_modifydate = DateTime.Now;
|
||||||
|
|
||||||
|
payments.Add(paymentItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (invoice item in old_invoices) {
|
||||||
|
var configItem = new MapperConfiguration(cfg =>
|
||||||
|
{
|
||||||
|
cfg.CreateMap<invoice, invoice>();
|
||||||
|
});
|
||||||
|
var mapperItem = configItem.CreateMapper();
|
||||||
|
|
||||||
|
invoice invoiceItem = new invoice();
|
||||||
|
|
||||||
|
mapperItem.Map(item, invoiceItem);
|
||||||
|
|
||||||
|
invoiceItem.invoice_uid = "inv_" + GlobalClass.CreateRandomCode(24);
|
||||||
|
invoiceItem.invoice_version = 1;
|
||||||
|
invoiceItem.invoice_revoke = "N";
|
||||||
|
invoiceItem.quotation_uid = new_quotation_uid;
|
||||||
|
|
||||||
|
invoices.Add(invoiceItem);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
conn.Insert(invoices);
|
||||||
|
conn.Insert(payments);
|
||||||
|
conn.Insert(quotationSubItems);
|
||||||
|
conn.Insert(quotationMainItems);
|
||||||
|
conn.Insert(quotation);
|
||||||
|
|
||||||
|
ret.ret = "yes";
|
||||||
|
ret.quotationView = conn.QueryFirstOrDefault<quotationView>("select * from quotationView where quotation_isdel = 'N' and quotation_revoke = 'N' and quotation_uid = @quotation_uid", new { quotation_uid = new_quotation_uid });
|
||||||
|
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method == "save_to_new") {
|
||||||
|
quotation oldQuotation = conn.QueryFirstOrDefault<quotation>("select * from quotation where quotation_isdel = 'N' and quotation_uid = @quotation_uid and quotation_version = @quotation_version ", new { quotation_uid = quotation_uid, quotation_version = quotation_version });
|
||||||
|
|
||||||
|
if (oldQuotation == null)
|
||||||
|
{
|
||||||
|
ret.ret = "no";
|
||||||
|
ret.err_code = "0005";
|
||||||
|
ret.message = "無此版本號的 quotation_uid 資料!";
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
project_uid = "p_" + GlobalClass.CreateRandomCode(24);
|
||||||
|
project new_project = new project();
|
||||||
|
new_project.project_uid = project_uid;
|
||||||
|
new_project.dept_uid = oldQuotation.dept_uid;
|
||||||
|
new_project.company_uid = company_uid;
|
||||||
|
new_project.project_datetime = DateTime.Now.ToString("yyyy/MM/dd");
|
||||||
|
new_project.project_creative_uid = token.user_uid;
|
||||||
|
new_project.project_lastmodify_uid = token.user_uid;
|
||||||
|
new_project.project_isdel = "N";
|
||||||
|
new_project.project_modifydate = DateTime.Now;
|
||||||
|
new_project.project_createdate = DateTime.Now;
|
||||||
|
new_project.project_name = project_name;
|
||||||
|
|
||||||
|
string new_quotation_uid = "q_" + GlobalClass.CreateRandomCode(24);
|
||||||
|
|
||||||
|
var config = new MapperConfiguration(cfg =>
|
||||||
|
{
|
||||||
|
cfg.CreateMap<quotation, quotation>();
|
||||||
|
});
|
||||||
|
var mapper = config.CreateMapper();
|
||||||
|
quotation quotation = new quotation();
|
||||||
|
|
||||||
|
mapper.Map(oldQuotation, quotation);
|
||||||
|
|
||||||
|
quotation.quotation_uid = new_quotation_uid;
|
||||||
|
quotation.quotation_name = quotation_name;
|
||||||
|
quotation.quotation_log = "由 [" + oldQuotation.quotation_name + "] 此報價單另存產生!";
|
||||||
|
quotation.quotation_version = 1;
|
||||||
|
quotation.quotation_createdate = DateTime.Now;
|
||||||
|
quotation.quotation_modifydate = DateTime.Now;
|
||||||
|
quotation.quotation_create_uid = token.user_uid;
|
||||||
|
quotation.quotation_modify_uid = token.user_uid;
|
||||||
|
quotation.quotation_revoke = "N";
|
||||||
|
quotation.company_uid = company_uid;
|
||||||
|
quotation.contactPerson_uid = contactPerson_uid;
|
||||||
|
quotation.project_uid = project_uid;
|
||||||
|
|
||||||
|
|
||||||
|
List<quotationMainItem> quotationMainItems = new List<quotationMainItem>();
|
||||||
|
List<quotationSubItem> quotationSubItems = new List<quotationSubItem>();
|
||||||
|
List<payment> payments = new List<payment>();
|
||||||
|
List<invoice> invoices = new List<invoice>();
|
||||||
|
|
||||||
|
List<quotationMainItem> old_quotationMainItems = conn.Query<quotationMainItem>("select * from quotationMainItem where quotation_uid = @quotation_uid and quotationMainItem_version = @quotation_version", new { quotation_uid = quotation_uid, quotation_version = quotation_version }).ToList();
|
||||||
|
|
||||||
|
List<payment> old_payments = conn.Query<payment>("select * from payment where quotation_uid = @quotation_uid and payment_version = @quotation_version", new { quotation_uid = quotation_uid, quotation_version = quotation_version }).ToList();
|
||||||
|
List<invoice> old_invoices = conn.Query<invoice>("select * from invoice where quotation_uid = @quotation_uid and invoice_version = @quotation_version", new { quotation_uid = quotation_uid, quotation_version = quotation_version }).ToList();
|
||||||
|
|
||||||
|
//主項目複製
|
||||||
|
foreach (quotationMainItem item in old_quotationMainItems)
|
||||||
|
{
|
||||||
|
var configItem = new MapperConfiguration(cfg =>
|
||||||
|
{
|
||||||
|
cfg.CreateMap<quotationMainItem, quotationMainItem>();
|
||||||
|
});
|
||||||
|
var mapperItem = configItem.CreateMapper();
|
||||||
|
|
||||||
|
quotationMainItem quotationMainItem = new quotationMainItem();
|
||||||
|
|
||||||
|
mapperItem.Map(item, quotationMainItem);
|
||||||
|
|
||||||
|
quotationMainItem.quotation_uid = new_quotation_uid;
|
||||||
|
quotationMainItem.quotationMainItem_version = 1;
|
||||||
|
quotationMainItem.quotationMainItem_revoke = "N";
|
||||||
|
quotationMainItem.quotationMainItem_uid = "qm_" + GlobalClass.CreateRandomCode(24);
|
||||||
|
quotationMainItem.quotationMainItem_createdate = DateTime.Now;
|
||||||
|
quotationMainItem.quotationMainItem_modifydate = DateTime.Now;
|
||||||
|
|
||||||
|
|
||||||
|
quotationMainItems.Add(quotationMainItem);
|
||||||
|
|
||||||
|
List<quotationSubItem> old_quotationSubItems = conn.Query<quotationSubItem>("select * from quotationSubItem where quotation_uid = @quotation_uid and quotationSubItem_version = @quotation_version and quotationMainItem_uid = @quotationMainItem_uid ", new { quotation_uid = quotation_uid, quotation_version = quotation_version, quotationMainItem_uid = item.quotationMainItem_uid }).ToList();
|
||||||
|
|
||||||
|
foreach (quotationSubItem subItem in old_quotationSubItems)
|
||||||
|
{
|
||||||
|
var configSubItem = new MapperConfiguration(cfg =>
|
||||||
|
{
|
||||||
|
cfg.CreateMap<quotationSubItem, quotationSubItem>();
|
||||||
|
});
|
||||||
|
var mapperSubItem = configSubItem.CreateMapper();
|
||||||
|
|
||||||
|
quotationSubItem quotationSubItem = new quotationSubItem();
|
||||||
|
|
||||||
|
mapperSubItem.Map(subItem, quotationSubItem);
|
||||||
|
|
||||||
|
quotationSubItem.quotationMainItem_uid = quotationMainItem.quotationMainItem_uid;
|
||||||
|
quotationSubItem.quotation_uid = new_quotation_uid;
|
||||||
|
quotationSubItem.quotationSubItem_version = 1;
|
||||||
|
quotationSubItem.quotationSubItem_uid = "qs_" + GlobalClass.CreateRandomCode(24);
|
||||||
|
quotationSubItem.quotationSubItem_createdate = DateTime.Now;
|
||||||
|
quotationSubItem.quotationSubItem_modifydate = DateTime.Now;
|
||||||
|
|
||||||
|
quotationSubItems.Add(quotationSubItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (payment item in old_payments)
|
||||||
|
{
|
||||||
|
var configItem = new MapperConfiguration(cfg =>
|
||||||
|
{
|
||||||
|
cfg.CreateMap<payment, payment>();
|
||||||
|
});
|
||||||
|
var mapperItem = configItem.CreateMapper();
|
||||||
|
|
||||||
|
payment paymentItem = new payment();
|
||||||
|
|
||||||
|
mapperItem.Map(item, paymentItem);
|
||||||
|
|
||||||
|
paymentItem.payment_uid = "pay_" + GlobalClass.CreateRandomCode(24);
|
||||||
|
paymentItem.quotation_uid = new_quotation_uid;
|
||||||
|
paymentItem.payment_version = 1;
|
||||||
|
paymentItem.payment_createdate = DateTime.Now;
|
||||||
|
paymentItem.payment_modifydate = DateTime.Now;
|
||||||
|
|
||||||
|
payments.Add(paymentItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (invoice item in old_invoices)
|
||||||
|
{
|
||||||
|
var configItem = new MapperConfiguration(cfg =>
|
||||||
|
{
|
||||||
|
cfg.CreateMap<invoice, invoice>();
|
||||||
|
});
|
||||||
|
var mapperItem = configItem.CreateMapper();
|
||||||
|
|
||||||
|
invoice invoiceItem = new invoice();
|
||||||
|
|
||||||
|
mapperItem.Map(item, invoiceItem);
|
||||||
|
|
||||||
|
invoiceItem.invoice_uid = "inv_" + GlobalClass.CreateRandomCode(24);
|
||||||
|
invoiceItem.invoice_version = 1;
|
||||||
|
invoiceItem.invoice_revoke = "N";
|
||||||
|
invoiceItem.quotation_uid = new_quotation_uid;
|
||||||
|
|
||||||
|
invoices.Add(invoiceItem);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
conn.Insert(invoices);
|
||||||
|
conn.Insert(payments);
|
||||||
|
conn.Insert(quotationSubItems);
|
||||||
|
conn.Insert(quotationMainItems);
|
||||||
|
conn.Insert(quotation);
|
||||||
|
conn.Insert(new_project);
|
||||||
|
|
||||||
|
ret.ret = "yes";
|
||||||
|
ret.quotationView = conn.QueryFirstOrDefault<quotationView>("select * from quotationView where quotation_isdel = 'N' and quotation_revoke = 'N' and quotation_uid = @quotation_uid", new { quotation_uid = new_quotation_uid });
|
||||||
|
ret.projectView = conn.QueryFirstOrDefault<projectView>("select * from projectView where project_isdel = 'N' and project_uid = @project_uid ", new { project_uid = project_uid });
|
||||||
|
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
[Route("getHistoryList")]
|
[Route("getHistoryList")]
|
||||||
public ActionResult GetHistoryList(IFormCollection obj) {
|
public ActionResult GetHistoryList(IFormCollection obj) {
|
||||||
quotationViewListResult ret = new quotationViewListResult();
|
quotationViewListResult ret = new quotationViewListResult();
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,15 @@ using Dapper;
|
||||||
using static DbTableClass;
|
using static DbTableClass;
|
||||||
public class resultClass
|
public class resultClass
|
||||||
{
|
{
|
||||||
|
public class saveasResult
|
||||||
|
{
|
||||||
|
public string ret = "no";
|
||||||
|
public string err_code = "0000";
|
||||||
|
public string message = "";
|
||||||
|
public quotationView quotationView = new quotationView();
|
||||||
|
public projectView projectView = new projectView();
|
||||||
|
}
|
||||||
|
|
||||||
public class quotationDetailResult
|
public class quotationDetailResult
|
||||||
{
|
{
|
||||||
public string ret = "no";
|
public string ret = "no";
|
||||||
|
|
|
||||||
|
|
@ -43,10 +43,11 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="AutoMapper" Version="13.0.1" />
|
||||||
<PackageReference Include="Dapper" Version="2.1.35" />
|
<PackageReference Include="Dapper" Version="2.1.35" />
|
||||||
<PackageReference Include="Dapper.Contrib" Version="2.0.78" />
|
<PackageReference Include="Dapper.Contrib" Version="2.0.78" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="NPOI" Version="2.7.0" />
|
<PackageReference Include="NPOI" Version="2.7.1" />
|
||||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
|
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -724,6 +724,7 @@
|
||||||
<!-- .modal-body -->
|
<!-- .modal-body -->
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<input type="hidden" id="save_to_same_quotation_uid" />
|
<input type="hidden" id="save_to_same_quotation_uid" />
|
||||||
|
<input type="hidden" id="save_to_same_quotation_version" />
|
||||||
<div class="form-label-group">
|
<div class="form-label-group">
|
||||||
<input type="text" id="save_to_same_quotation_name" class="form-control" value="" placeholder="新報價單名稱" maxlength="45" required=""> <label for="save_to_same_quotation_name">新報價單名稱</label>
|
<input type="text" id="save_to_same_quotation_name" class="form-control" value="" placeholder="新報價單名稱" maxlength="45" required=""> <label for="save_to_same_quotation_name">新報價單名稱</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -737,3 +738,101 @@
|
||||||
</div><!-- /.modal-dialog -->
|
</div><!-- /.modal-dialog -->
|
||||||
</div>
|
</div>
|
||||||
</form><!-- /.modal -->
|
</form><!-- /.modal -->
|
||||||
|
|
||||||
|
<!--另存到別專案-->
|
||||||
|
<!-- .modal -->
|
||||||
|
<form id="clientSavetootherForm" name="clientSavetootherForm">
|
||||||
|
<div class="modal fade" id="clientSaveToOtherModal" tabindex="-1" role="dialog" aria-labelledby="clientSaveToOtherModalLabel" data-backdrop="static"
|
||||||
|
data-keyboard="false" aria-hidden="true">
|
||||||
|
<!-- .modal-dialog -->
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<!-- .modal-content -->
|
||||||
|
<div class="modal-content">
|
||||||
|
<!-- .modal-header -->
|
||||||
|
<div class="modal-header">
|
||||||
|
<h6 id="clientProjectModalLabel" class="modal-title inline-editable">
|
||||||
|
<span class="sr-only"></span> <input id="modelSaveToOtherTitle" type="text" class="form-control form-control-lg" placeholder="另存為新報價單至其他專案" required="">
|
||||||
|
</h6>
|
||||||
|
<button type="button" class="close" data-dismiss="modal">
|
||||||
|
<span aria-hidden="true">×</span><span class="sr-only">Close</span>
|
||||||
|
</button>
|
||||||
|
</div><!-- /.modal-header -->
|
||||||
|
<!-- .modal-body -->
|
||||||
|
<div class="modal-body">
|
||||||
|
<input type="hidden" id="save_to_other_quotation_uid" />
|
||||||
|
<input type="hidden" id="save_to_other_quotation_version" />
|
||||||
|
<div class="form-label-group">
|
||||||
|
<input type="text" id="save_to_other_quotation_name" class="form-control" value="" placeholder="新報價單名稱" maxlength="45" required=""> <label for="save_to_other_quotation_name">新報價單名稱</label>
|
||||||
|
</div>
|
||||||
|
<br />
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="project_select">專案名稱</label>
|
||||||
|
<select class="custom-select custom-select-sm" id="project_select" name="project_select" required="">
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="contactPerson_select">窗口</label>
|
||||||
|
<select class="custom-select custom-select-sm" id="contactPerson_select" name="contactPerson_select" required="">
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div><!-- /.modal-body -->
|
||||||
|
<!-- .modal-footer -->
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" id="save_to_other_SaveBtn" class="btn btn-primary">儲存</button> <button id="closeBtn" type="button" class="btn btn-light" data-dismiss="modal">關閉</button>
|
||||||
|
</div><!-- /.modal-footer -->
|
||||||
|
</div><!-- /.modal-content -->
|
||||||
|
</div><!-- /.modal-dialog -->
|
||||||
|
</div>
|
||||||
|
</form><!-- /.modal -->
|
||||||
|
|
||||||
|
<!--另存到新專案-->
|
||||||
|
<!-- .modal -->
|
||||||
|
<form id="clientSavetonewForm" name="clientSavetonewForm">
|
||||||
|
<div class="modal fade" id="clientSaveToNewModal" tabindex="-1" role="dialog" aria-labelledby="clientSaveToNewModalLabel" data-backdrop="static"
|
||||||
|
data-keyboard="false" aria-hidden="true">
|
||||||
|
<!-- .modal-dialog -->
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<!-- .modal-content -->
|
||||||
|
<div class="modal-content">
|
||||||
|
<!-- .modal-header -->
|
||||||
|
<div class="modal-header">
|
||||||
|
<h6 id="clientProjectModalLabel" class="modal-title inline-editable">
|
||||||
|
<span class="sr-only"></span> <input id="modelSaveToNewTitle" type="text" class="form-control form-control-lg" placeholder="另存為新報價單至新專案" required="">
|
||||||
|
</h6>
|
||||||
|
<button type="button" class="close" data-dismiss="modal">
|
||||||
|
<span aria-hidden="true">×</span><span class="sr-only">Close</span>
|
||||||
|
</button>
|
||||||
|
</div><!-- /.modal-header -->
|
||||||
|
<!-- .modal-body -->
|
||||||
|
<div class="modal-body">
|
||||||
|
<input type="hidden" id="save_to_new_quotation_uid" />
|
||||||
|
<input type="hidden" id="save_to_new_quotation_version" />
|
||||||
|
<div class="form-label-group">
|
||||||
|
<input type="text" id="save_to_new_quotation_name" class="form-control" value="" placeholder="新報價單名稱" maxlength="45" required=""> <label for="save_to_other_quotation_name">新報價單名稱</label>
|
||||||
|
</div>
|
||||||
|
<br/>
|
||||||
|
<div class="form-label-group">
|
||||||
|
<input type="text" id="save_to_new_project_name" class="form-control" value="" placeholder="新專案名稱" maxlength="45" required=""> <label for="save_to_other_quotation_name">新專案名稱</label>
|
||||||
|
</div>
|
||||||
|
<br />
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="project_select">客戶公司</label>
|
||||||
|
<select class="custom-select custom-select-sm" id="company_new_select" name="company_new_select" required="">
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="contactPerson_select">窗口</label>
|
||||||
|
<select class="custom-select custom-select-sm" id="contactPerson_new_select" name="contactPerson_new_select" required="">
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div><!-- /.modal-body -->
|
||||||
|
<!-- .modal-footer -->
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" id="save_to_new_SaveBtn" class="btn btn-primary">儲存</button> <button id="closeBtn" type="button" class="btn btn-light" data-dismiss="modal">關閉</button>
|
||||||
|
</div><!-- /.modal-footer -->
|
||||||
|
</div><!-- /.modal-content -->
|
||||||
|
</div><!-- /.modal-dialog -->
|
||||||
|
</div>
|
||||||
|
</form><!-- /.modal -->
|
||||||
|
|
@ -1028,8 +1028,320 @@ $(document).ready(function () {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//另存報價單儲存鈕
|
||||||
|
$('#save_to_same_SaveBtn').on('click', function () {
|
||||||
|
var quotation_uid = $('#save_to_same_quotation_uid').val();
|
||||||
|
var quotation_version = $('#save_to_same_quotation_version').val();
|
||||||
|
var quotation_name = $('#save_to_same_quotation_name').val();
|
||||||
|
|
||||||
|
|
||||||
|
if (quotation_name == '') {
|
||||||
|
alert('請輸入新的報價單名稱!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var formData = {
|
||||||
|
quotation_uid: quotation_uid,
|
||||||
|
quotation_version: quotation_version,
|
||||||
|
quotation_name: quotation_name,
|
||||||
|
method: 'save_to_same'
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "/Api/saveas",
|
||||||
|
type: "post",
|
||||||
|
data: formData,
|
||||||
|
success: function (data, textStatus, jqXHR) {
|
||||||
|
if (data.ret == "yes") {
|
||||||
|
obj = data.quotationView;
|
||||||
|
|
||||||
|
quotationTable.fnAddData(obj);
|
||||||
|
|
||||||
|
alert('另存至本專案為新報價單完成!');
|
||||||
|
|
||||||
|
$('#clientSaveToSameModal').modal('toggle');
|
||||||
|
$('#clientHistoryListModal').modal('toggle');
|
||||||
|
} else {
|
||||||
|
alert(data.message);
|
||||||
|
|
||||||
|
if (data.err_code == "99999") {
|
||||||
|
location.href = "/Root/Login";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
|
alert('網路或伺服器發生錯誤,請稍後重試!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
//另存至其他專案
|
||||||
|
$('#save_to_other_SaveBtn').on('click', function () {
|
||||||
|
var quotation_uid = $('#save_to_other_quotation_uid').val();
|
||||||
|
var quotation_version = $('#save_to_other_quotation_version').val();
|
||||||
|
var quotation_name = $('#save_to_other_quotation_name').val();
|
||||||
|
var project_value = $('#project_select').val();
|
||||||
|
|
||||||
|
if (project_value == '') {
|
||||||
|
alert('請選擇要加入的專案');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var arr = project_value.split('/');
|
||||||
|
var project_uid = arr[0];
|
||||||
|
var company_uid = arr[1];
|
||||||
|
var contactPerson_uid = $('#contactPerson_select').val();
|
||||||
|
|
||||||
|
if (quotation_name == '') {
|
||||||
|
alert('請輸入新的報價單名稱!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (contactPerson_uid == '') {
|
||||||
|
alert('請選擇窗口!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var formData = {
|
||||||
|
quotation_uid: quotation_uid,
|
||||||
|
quotation_version: quotation_version,
|
||||||
|
quotation_name: quotation_name,
|
||||||
|
project_uid: project_uid,
|
||||||
|
company_uid: company_uid,
|
||||||
|
contactPerson_uid: contactPerson_uid,
|
||||||
|
method: 'save_to_other'
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "/Api/saveas",
|
||||||
|
type: "post",
|
||||||
|
data: formData,
|
||||||
|
success: function (data, textStatus, jqXHR) {
|
||||||
|
if (data.ret == "yes") {
|
||||||
|
obj = data.quotationView;
|
||||||
|
|
||||||
|
if (obj.project_uid == $('#quotation_project_uid').val()) {
|
||||||
|
quotationTable.fnAddData(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
alert('另存至其他專案完成!');
|
||||||
|
|
||||||
|
$('#clientSaveToOtherModal').modal('toggle');
|
||||||
|
$('#clientHistoryListModal').modal('toggle');
|
||||||
|
} else {
|
||||||
|
alert(data.message);
|
||||||
|
|
||||||
|
if (data.err_code == "99999") {
|
||||||
|
location.href = "/Root/Login";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
|
alert('網路或伺服器發生錯誤,請稍後重試!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
//另存至新專案
|
||||||
|
$('#save_to_new_SaveBtn').on('click', function () {
|
||||||
|
var quotation_uid = $('#save_to_new_quotation_uid').val();
|
||||||
|
var quotation_version = $('#save_to_new_quotation_version').val();
|
||||||
|
var quotation_name = $('#save_to_new_quotation_name').val();
|
||||||
|
var project_name = $('#save_to_new_project_name').val();
|
||||||
|
var company_uid = $('#company_new_select').val();
|
||||||
|
var contactPerson_uid = $('#contactPerson_new_select').val();
|
||||||
|
|
||||||
|
if (project_name == '') {
|
||||||
|
alert('請輸入新專案名稱!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (quotation_name == '') {
|
||||||
|
alert('請輸入新報價單名稱!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (company_uid == '') {
|
||||||
|
aler('請選擇客戶公司!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (contactPerson_uid == '') {
|
||||||
|
alert('請選擇窗口!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var formData = {
|
||||||
|
quotation_uid: quotation_uid,
|
||||||
|
quotation_version: quotation_version,
|
||||||
|
quotation_name: quotation_name,
|
||||||
|
project_name: project_name,
|
||||||
|
company_uid: company_uid,
|
||||||
|
contactPerson_uid: contactPerson_uid,
|
||||||
|
method: 'save_to_new'
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "/Api/saveas",
|
||||||
|
type: "post",
|
||||||
|
data: formData,
|
||||||
|
success: function (data, textStatus, jqXHR) {
|
||||||
|
if (data.ret == "yes") {
|
||||||
|
obj = data.projectView;
|
||||||
|
|
||||||
|
projectTable.fnAddData(obj);
|
||||||
|
|
||||||
|
alert('另存至新專案完成!');
|
||||||
|
|
||||||
|
$('#clientSaveToNewModal').modal('toggle');
|
||||||
|
$('#clientHistoryListModal').modal('toggle');
|
||||||
|
} else {
|
||||||
|
alert(data.message);
|
||||||
|
|
||||||
|
if (data.err_code == "99999") {
|
||||||
|
location.href = "/Root/Login";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
|
alert('網路或伺服器發生錯誤,請稍後重試!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
//下拉專案列表選擇
|
||||||
|
$('#project_select').on('change', function () {
|
||||||
|
var project_value = $('#project_select').val();
|
||||||
|
|
||||||
|
if (project_value == '') {
|
||||||
|
$('#contactPerson_select').empty();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var arr = project_value.split('/');
|
||||||
|
var project_uid = arr[0];
|
||||||
|
var company_uid = arr[1];
|
||||||
|
|
||||||
|
var formData = {
|
||||||
|
company_uid: company_uid
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "/Api/contactPersonList",
|
||||||
|
type: "post",
|
||||||
|
data: formData,
|
||||||
|
success: function (data, textStatus, jqXHR) {
|
||||||
|
if (data.ret == "yes") {
|
||||||
|
var obj = data.contactPersons;
|
||||||
|
|
||||||
|
$("#contactPerson_select").empty();
|
||||||
|
|
||||||
|
$.each(obj, function (i, item) {
|
||||||
|
$("#contactPerson_select").append($("<option>", {
|
||||||
|
value: item.contactPerson_uid,
|
||||||
|
text: item.contactPerson_name + ' (Tel:' + item.contactPerson_tel + ', Email:' + item.contactPerson_email + ')'
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
alert(data.message);
|
||||||
|
|
||||||
|
if (data.err_code == "99999") {
|
||||||
|
location.href = "/Root/Login";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
|
alert('網路或伺服器發生錯誤,請稍後重試!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
//下拉客戶公司列表
|
||||||
|
$("#company_new_select").on('change', function () {
|
||||||
|
var company_uid = $("#company_new_select").val();
|
||||||
|
|
||||||
|
var formData = {
|
||||||
|
company_uid: company_uid
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "/Api/contactPersonList",
|
||||||
|
type: "post",
|
||||||
|
data: formData,
|
||||||
|
success: function (data, textStatus, jqXHR) {
|
||||||
|
if (data.ret == "yes") {
|
||||||
|
var obj = data.contactPersons;
|
||||||
|
|
||||||
|
$("#contactPerson_new_select").empty();
|
||||||
|
|
||||||
|
$.each(obj, function (i, item) {
|
||||||
|
$("#contactPerson_new_select").append($("<option>", {
|
||||||
|
value: item.contactPerson_uid,
|
||||||
|
text: item.contactPerson_name + ' (Tel:' + item.contactPerson_tel + ', Email:' + item.contactPerson_email + ')'
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
alert(data.message);
|
||||||
|
|
||||||
|
if (data.err_code == "99999") {
|
||||||
|
location.href = "/Root/Login";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
|
alert('網路或伺服器發生錯誤,請稍後重試!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function companyNewList() {
|
||||||
|
$.ajax({
|
||||||
|
url: "/Api/companyList",
|
||||||
|
type: "post",
|
||||||
|
data: null,
|
||||||
|
success: function (data, textStatus, jqXHR) {
|
||||||
|
if (data.ret == "yes") {
|
||||||
|
var obj = data.companys;
|
||||||
|
var items = "";
|
||||||
|
|
||||||
|
$("#company_new_select").empty();
|
||||||
|
|
||||||
|
$("#company_new_select").append($("<option>", {
|
||||||
|
value: '',
|
||||||
|
text: '請選擇客戶公司'
|
||||||
|
}));
|
||||||
|
$.each(obj, function (i, item) {
|
||||||
|
|
||||||
|
|
||||||
|
$("#company_new_select").append($("<option>", {
|
||||||
|
value: item.company_uid,
|
||||||
|
text: item.company_name
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
alert(data.message);
|
||||||
|
|
||||||
|
if (data.err_code == "99999") {
|
||||||
|
location.href = "/Root/Login";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
|
alert('網路或伺服器發生錯誤,請稍後重試!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
function loadContactPersion() {
|
function loadContactPersion() {
|
||||||
var data = $('#dt-responsive').DataTable().row(projectRowPos).data();
|
var data = $('#dt-responsive').DataTable().row(projectRowPos).data();
|
||||||
var uid = $('#quotation_company_uid').val();
|
var uid = $('#quotation_company_uid').val();
|
||||||
|
|
@ -1110,18 +1422,37 @@ function buttonHistoryClick(obj) {
|
||||||
var quotation_uid = obj.getAttribute('data-uid');
|
var quotation_uid = obj.getAttribute('data-uid');
|
||||||
var quotation_version = obj.getAttribute('data-version');
|
var quotation_version = obj.getAttribute('data-version');
|
||||||
|
|
||||||
historyRowID = $('#history_' + quotation_uid);
|
historyRowID = $('#history_' + quotation_version + '_' + quotation_uid);
|
||||||
|
|
||||||
historyRowPos = historyTable.fnGetPosition($('#history_' + quotation_uid)[0]);
|
historyRowPos = historyTable.fnGetPosition($('#history_' + quotation_version + '_' + quotation_uid)[0]);
|
||||||
|
|
||||||
var quotation_row = historyDataTable.row(historyRowPos).data();
|
var quotation_row = historyDataTable.row(historyRowPos).data();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (type == 'save_in_same') {
|
if (type == 'save_in_same') {
|
||||||
$('#save_to_same_quotation_uid').val(quotation_uid);
|
$('#save_to_same_quotation_uid').val(quotation_uid);
|
||||||
|
$('#save_to_same_quotation_version').val(quotation_version);
|
||||||
$('#save_to_same_quotation_name').val(quotation_row.quotation_name + ' - Copy').trigger('change');
|
$('#save_to_same_quotation_name').val(quotation_row.quotation_name + ' - Copy').trigger('change');
|
||||||
$('#clientSaveToSameModal').modal('toggle');
|
$('#clientSaveToSameModal').modal('toggle');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type == 'saveas_to_other') {
|
||||||
|
projectList();
|
||||||
|
$('#save_to_other_quotation_uid').val(quotation_uid);
|
||||||
|
$('#save_to_other_quotation_version').val(quotation_version);
|
||||||
|
$('#save_to_other_quotation_name').val(quotation_row.quotation_name + ' - Copy').trigger('change');
|
||||||
|
$('#clientSaveToOtherModal').modal('toggle');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type == 'saveas_to_new') {
|
||||||
|
companyNewList();
|
||||||
|
$('#save_to_new_quotation_uid').val(quotation_uid);
|
||||||
|
$('#save_to_new_quotation_version').val(quotation_version);
|
||||||
|
$('#save_to_new_quotation_name').val(quotation_row.quotation_name + ' - Copy').trigger('change');
|
||||||
|
$('#clientSaveToNewModal').modal('toggle');
|
||||||
|
}
|
||||||
|
|
||||||
if (type == 'view') {
|
if (type == 'view') {
|
||||||
var formData = {
|
var formData = {
|
||||||
method: 'history',
|
method: 'history',
|
||||||
|
|
@ -1747,7 +2078,7 @@ function loadHistoryTable() {
|
||||||
},
|
},
|
||||||
autoWidth: false,
|
autoWidth: false,
|
||||||
rowId: function (row) {
|
rowId: function (row) {
|
||||||
return 'history_' + row.quotation_uid;
|
return 'history_' + row.quotation_version + '_' + row.quotation_uid;
|
||||||
},
|
},
|
||||||
deferRender: true,
|
deferRender: true,
|
||||||
initComplete: function () {
|
initComplete: function () {
|
||||||
|
|
@ -1789,7 +2120,7 @@ function loadHistoryTable() {
|
||||||
drowdownHtml += ' <div class="dropdown-arrow"></div>';
|
drowdownHtml += ' <div class="dropdown-arrow"></div>';
|
||||||
drowdownHtml += ' <button data-uid="' + row.quotation_uid + '" data-version="' + row.quotation_version + '" data-method="save_in_same" type="button" class="dropdown-item">另存到此專案</button>';
|
drowdownHtml += ' <button data-uid="' + row.quotation_uid + '" data-version="' + row.quotation_version + '" data-method="save_in_same" type="button" class="dropdown-item">另存到此專案</button>';
|
||||||
drowdownHtml += ' <button data-uid="' + row.quotation_uid + '" data-version="' + row.quotation_version + '" data-method="saveas_to_other" type="button" class="dropdown-item">另存到其他專案</button>';
|
drowdownHtml += ' <button data-uid="' + row.quotation_uid + '" data-version="' + row.quotation_version + '" data-method="saveas_to_other" type="button" class="dropdown-item">另存到其他專案</button>';
|
||||||
drowdownHtml += ' <button data-uid="' + row.quotation_uid + '" data-version="' + row.quotation_version + '" data-method="saveas_new_proj" type="button" class="dropdown-item">另存為新專案</button>';
|
drowdownHtml += ' <button data-uid="' + row.quotation_uid + '" data-version="' + row.quotation_version + '" data-method="saveas_to_new" type="button" class="dropdown-item">另存為新專案</button>';
|
||||||
drowdownHtml += ' </div>';
|
drowdownHtml += ' </div>';
|
||||||
drowdownHtml += '</div> ';
|
drowdownHtml += '</div> ';
|
||||||
ret += drowdownHtml;
|
ret += drowdownHtml;
|
||||||
|
|
@ -1914,7 +2245,7 @@ function loadQuotationTable() {
|
||||||
searching: true,
|
searching: true,
|
||||||
columns: [
|
columns: [
|
||||||
{ data: 'quotation_name', className: 'align-top text-left', orderable: true, searchable: true },
|
{ data: 'quotation_name', className: 'align-top text-left', orderable: true, searchable: true },
|
||||||
{ data: 'quotation_date', className: 'align-top text-left', orderable: true, searchable: true },
|
{ data: 'quotation_createdate', className: 'align-top text-left', orderable: true, searchable: true },
|
||||||
{ data: 'contactPerson_name', className: 'align-top text-left', orderable: true, searchable: true },
|
{ data: 'contactPerson_name', className: 'align-top text-left', orderable: true, searchable: true },
|
||||||
{ data: 'quotation_uid', className: 'align-top text-center', orderable: false, searchable: false }
|
{ data: 'quotation_uid', className: 'align-top text-center', orderable: false, searchable: false }
|
||||||
],
|
],
|
||||||
|
|
@ -1931,15 +2262,28 @@ function loadQuotationTable() {
|
||||||
return row.quotation_name;
|
return row.quotation_name;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
targets: 1,
|
||||||
|
className: 'align-middle text-left',
|
||||||
|
orderable: false,
|
||||||
|
searchable: true,
|
||||||
|
render: function render(data, type, row, meta) {
|
||||||
|
|
||||||
|
return (new Date(row.quotation_createdate)).format("yyyy/MM/dd hh:mm:ss");
|
||||||
|
//return '<a href="javascript: void(0);" data-uid="' + row.quotation_uid + '" data-version="' + row.quotation_version + '" data-method="preview" >' + row.quotation_name + '</a>';
|
||||||
|
//return row.quotation_name;
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
targets: 3,
|
targets: 3,
|
||||||
orderable: false,
|
orderable: false,
|
||||||
searchable: false,
|
searchable: false,
|
||||||
render: function render(data, type, row, meta) {
|
render: function render(data, type, row, meta) {
|
||||||
var ret = '';
|
var ret = '';
|
||||||
ret += '<button type="button" data-uid="' + row.quotation_uid + '" data-version="' + row.quotation_version + '" data-method="history" class="btn btn-sm btn-icon btn-secondary" ><i class="oi oi-list"></i> <span class="sr-only">History</span></button>';
|
|
||||||
ret += '<button type="button" data-uid="' + row.quotation_uid + '" data-version="' + row.quotation_version + '" data-method="edit" class="btn btn-sm btn-icon btn-secondary" ><i class="fa fa-pencil-alt"></i> <span class="sr-only">Edit</span></button>';
|
ret += '<button type="button" data-uid="' + row.quotation_uid + '" data-version="' + row.quotation_version + '" data-method="edit" class="btn btn-sm btn-icon btn-secondary" ><i class="fa fa-pencil-alt"></i> <span class="sr-only">Edit</span></button>';
|
||||||
ret += '<button type="button" data-uid="' + row.quotation_uid + '" data-version="' + row.quotation_version + '" data-method="del" class="btn btn-sm btn-icon btn-secondary"><i class="far fa-trash-alt"></i> <span class="sr-only">Remove</span></button>';
|
ret += '<button type="button" data-uid="' + row.quotation_uid + '" data-version="' + row.quotation_version + '" data-method="del" class="btn btn-sm btn-icon btn-secondary"><i class="far fa-trash-alt"></i> <span class="sr-only">Remove</span></button>';
|
||||||
|
ret += '<button type="button" data-uid="' + row.quotation_uid + '" data-version="' + row.quotation_version + '" data-method="history" class="btn btn-sm btn-icon btn-secondary" ><i class="oi oi-list"></i> <span class="sr-only">History</span></button>';
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2188,6 +2532,48 @@ function deptList() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function projectList() {
|
||||||
|
var formData = {
|
||||||
|
dept_uid: $('#dept_select').val(),
|
||||||
|
start_txt: '2023/09',
|
||||||
|
end_txt: $('#dateEnd').val()
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "/Api/projectViewList",
|
||||||
|
type: "post",
|
||||||
|
data: formData,
|
||||||
|
success: function (data, textStatus, jqXHR) {
|
||||||
|
if (data.ret == "yes") {
|
||||||
|
var obj = data.projectViews;
|
||||||
|
var items = "";
|
||||||
|
|
||||||
|
$('#project_select')
|
||||||
|
.empty()
|
||||||
|
.append('<option selected="selected" value="">請選擇要加入的專案</option>');
|
||||||
|
|
||||||
|
$.each(obj, function (i, item) {
|
||||||
|
|
||||||
|
$("#project_select").append($("<option>", {
|
||||||
|
value: item.project_uid + '/' + item.company_uid,
|
||||||
|
text: item.project_name + ' (' + item.company_name + ')'
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
alert(data.message);
|
||||||
|
|
||||||
|
if (data.err_code == "99999") {
|
||||||
|
location.href = "/Root/Login";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
|
alert('網路或伺服器發生錯誤,請稍後重試!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function mainItemHtml(obj) {
|
function mainItemHtml(obj) {
|
||||||
var ac_string = '';
|
var ac_string = '';
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue