forked from dk96/QuotationMaker
updates
parent
b0fd635c98
commit
fd756369f7
|
|
@ -65,6 +65,28 @@ namespace QuotationMaker.Controllers
|
|||
string mainItems_jsonstr = obj["mainItems"].ToString();
|
||||
string payments_jsonstr = obj["payments"].ToString();
|
||||
string invoices_jsonstr = obj["invoices"].ToString();
|
||||
string quotation_revoke = "N";
|
||||
string quotation_isdel = "N";
|
||||
|
||||
if (quotation_specTotal == "") {
|
||||
quotation_specTotal = "0";
|
||||
};
|
||||
|
||||
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 });
|
||||
|
||||
if (objQuotation == null) {
|
||||
ret.ret = "no";
|
||||
ret.err_code = "0009";
|
||||
ret.message = "此筆資料不存在或已被刪除!";
|
||||
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||
}
|
||||
|
||||
ret.quotationDetail = new quotationDetail(objQuotation);
|
||||
ret.quotationView = conn.QueryFirstOrDefault<quotationView>("select * from quotationView where quotation_isdel = 'N' and quotation_revoke = 'N' and quotation_uid = @quotation_uid ", new { quotation_uid = quotation_uid });
|
||||
ret.ret = "yes";
|
||||
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||
}
|
||||
|
||||
if (method == "add") {
|
||||
quotation objQuotation = new quotation();
|
||||
|
|
@ -91,6 +113,8 @@ namespace QuotationMaker.Controllers
|
|||
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;
|
||||
|
||||
|
|
@ -124,10 +148,10 @@ namespace QuotationMaker.Controllers
|
|||
newItem.mainItem_uid = item.mainItem_uid;
|
||||
newItem.quotationMainItem_uid = quotationMainItem_uid;
|
||||
newItem.quotationMainItem_name = item.quotationMainItem_name;
|
||||
newItem.quotationMainItem_ac = double.Parse(item.quotationMainItem_ac);
|
||||
newItem.quotationMainItem_subTotal = double.Parse(item.quotationMainItem_subTotal);
|
||||
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(quotation_version);
|
||||
newItem.quotationMainItem_version = int.Parse((string)quotation_version);
|
||||
|
||||
quotationMainItems.Add(newItem);
|
||||
|
||||
|
|
@ -137,20 +161,68 @@ namespace QuotationMaker.Controllers
|
|||
newSubItem.quotationMainItem_uid = quotationMainItem_uid;
|
||||
newSubItem.quotation_uid = quotation_uid;
|
||||
newSubItem.subItem_uid = subItem.subItem_uid;
|
||||
newSubItem.quotationSubItem_name = subItem.subItem_name;
|
||||
newSubItem.quotationSubItem_descript = subItem.subItem_descript;
|
||||
newSubItem.quotationSubItem_price = double.Parse(subItem.subItem_price);
|
||||
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(subItem.quotationSubItem_number);
|
||||
newSubItem.quotationSubItem_subTotal = double.Parse(subItem.quotationSubItem_subTotal);
|
||||
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(quotation_version);
|
||||
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);
|
||||
}
|
||||
|
||||
conn.Insert(invoices);
|
||||
conn.Insert(payments);
|
||||
conn.Insert(quotationSubItems);
|
||||
conn.Insert(quotationMainItems);
|
||||
conn.Insert<quotation>(objQuotation);
|
||||
|
||||
ret.quotationView = conn.QueryFirstOrDefault<quotationView>("select * from quotationView where quotation_uid = @quotation_uid and quotation_version = 1", new {quotation_uid = quotation_uid});
|
||||
ret.ret = "yes";
|
||||
|
||||
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||
}
|
||||
|
||||
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ public class resultClass
|
|||
this.GetType().GetProperty(propName).SetValue(this, propValue);
|
||||
}
|
||||
|
||||
List<quotationMainItem> quotationMainItems = conn.Query<quotationMainItem>("select * from quotationMainItem where quotationSubItem_version = @quotationSubItem_version and quotation_uid = @quotation_uid ", new { quotationSubItem_version = this.quotation_version, quotation_uid = this.quotation_uid }).ToList();
|
||||
List<quotationMainItem> quotationMainItems = conn.Query<quotationMainItem>("select * from quotationMainItem where quotationMainItem_version = @quotation_version and quotation_uid = @quotation_uid ", new { quotation_version = this.quotation_version, quotation_uid = this.quotation_uid }).ToList();
|
||||
|
||||
foreach (quotationMainItem qItem in quotationMainItems) {
|
||||
quotationMainItemDetails.Add(new quotationMainItemDetail(qItem));
|
||||
|
|
|
|||
|
|
@ -299,7 +299,7 @@
|
|||
<input type="hidden" id="quotation_uid" />
|
||||
<input type="hidden" id="quotation_version" />
|
||||
<!-- .form-group -->
|
||||
<div class="form-group">
|
||||
<div class="form-group" id="quotation_editType_div">
|
||||
<label>報價單編輯方式 (儲存後無法變更)</label>
|
||||
<div class="custom-control custom-radio mb-1">
|
||||
<input type="radio" class="custom-control-input" name="rdGroup3" id="quotation_custom" checked> <label class="custom-control-label" for="quotation_custom">自訂</label>
|
||||
|
|
|
|||
|
|
@ -159,6 +159,7 @@ $(document).ready(function () {
|
|||
|
||||
quotation_total = 0;
|
||||
|
||||
$('#quotation_editType_div').show();
|
||||
$('#quotation_sa').val(service_text());
|
||||
$('#quotation_method').val('add');
|
||||
$('#clientModelQuotationModal').modal("toggle");
|
||||
|
|
@ -703,9 +704,9 @@ $(document).ready(function () {
|
|||
var quotation_specTotal_old = $('#quotation_specTotal_old').val();
|
||||
var quotation_tax = $('#quotation_tax').val();
|
||||
var quotation_tax_old = $('#quotation_tax_old').val();
|
||||
var quotation_grandTotal = $('quotation_grandTotal').val();
|
||||
var quotation_grandTotal = $('#quotation_grandTotal').val();
|
||||
var quotation_grandTotal_old = $('#quotation_grandTotal_old').val();
|
||||
var quotation_sa = $('quotation_sa').val();
|
||||
var quotation_sa = $('#quotation_sa').val();
|
||||
var quotation_sa_old = $('#quotation_sa_old').val();
|
||||
|
||||
var err_msg = '';
|
||||
|
|
@ -972,19 +973,19 @@ $(document).ready(function () {
|
|||
data: formData,
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
if (data.ret == "yes") {
|
||||
//var obj = data.projectViews[0];
|
||||
var obj = data.quotationView;
|
||||
|
||||
if (method == "add") {
|
||||
//projectTable.fnAddData(obj);
|
||||
if (quotation_method == "add") {
|
||||
quotationTable.fnAddData(obj);
|
||||
}
|
||||
|
||||
if (method == "edit") {
|
||||
//projectTable.fnUpdate(obj, projectRowPos);
|
||||
if (quotation_method == "edit") {
|
||||
quotationTable.fnUpdate(obj, quotationPos);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//$('#clientProjectModal').modal('toggle');
|
||||
$('#clientModelQuotationModal').modal('toggle');
|
||||
} else {
|
||||
alert(data.message);
|
||||
|
||||
|
|
@ -1214,6 +1215,129 @@ function buttonClick(obj) {
|
|||
}
|
||||
}
|
||||
|
||||
function quotationEditModelFillData(obj, objView) {
|
||||
$('#quotation_editType_div').hide();
|
||||
$('#quotation_uid').val(obj.quotation_uid);
|
||||
$('#quotation_version').val(obj.quotation_version);
|
||||
$('#quotation_date').val(obj.quotation_date).trigger('change');
|
||||
$('#quotation_date_old').val(obj.quotation_date);
|
||||
$('#quotation_expStart').val(obj.quotation_expStart);
|
||||
$('#quotation_expEnd').val(obj.quotation_expEnd);
|
||||
$('#quotation_expStart_old').val(obj.quotation_expStart);
|
||||
$('#quotation_expEnd_old').val(obj.quotation_expEnd);
|
||||
$('#quotation_name').val(obj.quotation_name).trigger('change');
|
||||
$('#quotation_name_old').val(obj.quotation_name);
|
||||
$('#quotation_name').val(obj.quotation_name).trigger('change');
|
||||
$('#quotation_name_old').val(obj.quotation_name);
|
||||
|
||||
//$('#quotation_noTaxTotal').val('').trigger('change');
|
||||
//$('#quotation_specTotal').val('').trigger('change');
|
||||
|
||||
//$('#quotation_noTaxTotal').val(obj.quotation_noTaxTotal);
|
||||
//$('#quotation_noTaxTotal_old').val(obj.quotation_noTaxTotal);
|
||||
|
||||
if (obj.quotation_specTotal != 0) {
|
||||
$('#quotation_specTotal').val(obj.quotation_specTotal).trigger('change');
|
||||
$('#quotation_specTotal_old').val(obj.quotation_specTotal);
|
||||
} else {
|
||||
$('#quotation_specTotal').val('').trigger('change');
|
||||
$('#quotation_specTotal_old').val('');
|
||||
}
|
||||
$('#quotation_noTaxTotal').val(obj.quotation_noTaxTotal);
|
||||
$('#quotation_noTaxTotal_old').val(obj.quotation_noTaxTotal);
|
||||
$('#quotation_tax').val(obj.quotation_tax).trigger('change');
|
||||
$('#quotation_tax_old').val(obj.quotation_tax);
|
||||
$('#quotation_grandTotal').val(obj.quotation_grandTotal).trigger('change');
|
||||
$('#quotation_grandTotal_old').val(obj.quotation_grandTotal);
|
||||
$('#quotation_sa').val(obj.quotation_sa).trigger('change');
|
||||
$('#quotation_sa_old').val(obj.quotation_sa);
|
||||
|
||||
|
||||
var no_found = 1;
|
||||
$("#contactPerson_uid option").each(function () {
|
||||
if ($(this).val() == obj.contactPerson_uid) {
|
||||
no_found = 0;
|
||||
}
|
||||
});
|
||||
|
||||
if (no_found == 1) {
|
||||
$("#contactPerson_uid").append($("<option>", {
|
||||
value: obj.contactPerson_uid,
|
||||
text: objView.contactPerson_name
|
||||
}));
|
||||
}
|
||||
|
||||
$('#contactPerson_uid').val(obj.contactPerson_uid);
|
||||
$('#contactPerson_uid_old').val(obj.contactPerson_uid);
|
||||
|
||||
|
||||
$("#quotation_range").flatpickr({
|
||||
mode: 'range',
|
||||
onChange: function (selectedDates, dateStr, instance) {
|
||||
if (selectedDates.length == 2) {
|
||||
var dateStart = instance.formatDate(selectedDates[0], "Y/m/d");
|
||||
var dateEnd = instance.formatDate(selectedDates[1], "Y/m/d");
|
||||
|
||||
$('#quotation_expStart').val(dateStart);
|
||||
$('#quotation_expEnd').val(dateEnd);
|
||||
|
||||
// interact with selected dates here
|
||||
}
|
||||
},
|
||||
defaultDate: [obj.quotation_expStart, obj.quotation_expEnd]
|
||||
});
|
||||
|
||||
$("#quotation_range").trigger('change');
|
||||
}
|
||||
function buttonQuotationClick(obj, view) {
|
||||
var type = obj.getAttribute('data-method');
|
||||
var version = obj.getAttribute('data-version');
|
||||
var uid = obj.getAttribute('data-uid');
|
||||
var dept_uid = $('#dept_select').val();
|
||||
|
||||
quotationRowID = $('#' + uid);
|
||||
|
||||
quotationRowPos = quotationTable.fnGetPosition($('#' + uid)[0]);
|
||||
|
||||
if (type == "edit") {
|
||||
var formData = {
|
||||
method: 'get',
|
||||
quotation_uid: uid,
|
||||
dept_uid: dept_uid
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: "/Api/addEditDelQuotation",
|
||||
type: "post",
|
||||
data: formData,
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
if (data.ret == "yes") {
|
||||
var obj = data.quotationDetail;
|
||||
var objView = data.quotationView;
|
||||
|
||||
$("#quotation_method").val('edit');
|
||||
|
||||
quotationEditModelFillData(obj, objView);
|
||||
//$("#project_uid").val(obj.project_uid);
|
||||
//$("#project_name").val(obj.project_name).trigger('change');
|
||||
//$("#company_select").val(obj.company_uid);
|
||||
//$("#project_ps").val(obj.project_ps).trigger('change');
|
||||
|
||||
$('#clientModelQuotationModal').modal('toggle');
|
||||
} else {
|
||||
alert(data.message);
|
||||
|
||||
if (data.err_code == "99999") {
|
||||
location.href = "/Root/Login";
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('網路或伺服器發生錯誤,請稍後重試!');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
function loadQuotationTable() {
|
||||
var dataTables = {
|
||||
init: function init() {
|
||||
|
|
@ -1270,14 +1394,14 @@ function loadQuotationTable() {
|
|||
|
||||
|
||||
},
|
||||
order: [[0, 'desc']],
|
||||
order: [[1, 'desc']],
|
||||
info: true,
|
||||
search: "搜尋:",
|
||||
searching: true,
|
||||
columns: [
|
||||
{ data: 'quotation_name', className: 'align-top text-left', orderable: true, searchable: true },
|
||||
{ data: 'quotation_date', className: 'align-top text-left', orderable: false, searchable: true },
|
||||
{ data: 'contactPerson_name', className: 'align-top text-left', orderable: false, searchable: true },
|
||||
{ data: 'quotation_date', 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 }
|
||||
],
|
||||
columnDefs: [
|
||||
|
|
@ -1289,8 +1413,8 @@ function loadQuotationTable() {
|
|||
render: function render(data, type, row, meta) {
|
||||
|
||||
|
||||
return '<a href="javascript: void(0);" data-uid="' + row.quotation_uid + '" data-version="' + row.quotation_version + '" data-method="preview" >' + row.quotation_name + '</a>';
|
||||
|
||||
//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;
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue