updates
parent
34a87cbf40
commit
8c149e555d
|
|
@ -28,6 +28,56 @@ namespace QuotationMaker.Controllers
|
|||
|
||||
}
|
||||
|
||||
[Route("quotationList")]
|
||||
public ActionResult QuotationList(IFormCollection obj)
|
||||
{
|
||||
quotationViewListResult ret = new quotationViewListResult();
|
||||
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 user_uid = token.user_uid;
|
||||
string user_perm = token.user_perm;
|
||||
string project_uid = obj["project_uid"].ToString();
|
||||
string dept_uid = obj["dept_uid"].ToString();
|
||||
|
||||
string user_uid_list = "'" + user_uid + "'";
|
||||
|
||||
if (user_perm == "system" && token.user_id != GlobalClass.appsettings("Admin:id"))
|
||||
{
|
||||
groupUser gpUser = conn.QueryFirstOrDefault<groupUser>("select * from groupUser where dept_uid = @dept_uid and user_uid = @user_uid ", new { dept_uid = dept_uid, user_uid = user_uid });
|
||||
|
||||
if (gpUser != null)
|
||||
{
|
||||
List<groupUser> groupUsers = conn.Query<groupUser>("select * from groupUser where group_uid = @group_uid", new { group_uid = gpUser.group_uid }).ToList();
|
||||
|
||||
foreach (groupUser groupUser in groupUsers)
|
||||
{
|
||||
user_uid_list += ", '" + groupUser.user_uid + "'";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (token.user_id != GlobalClass.appsettings("Admin:id"))
|
||||
{
|
||||
ret.quotationViews = conn.Query<quotationView>("select * from quotationView where quotationView_isdel = 'N' and quotationView_revoke = 'N' and project_uid = @project_uid and quotation_create_uid in (@user_list) order by quotation_modifydate desc", new { project_uid = project_uid, user_list = user_uid_list }).ToList();
|
||||
|
||||
}
|
||||
else {
|
||||
ret.quotationViews = conn.Query<quotationView>("select * from quotationView where quotation_isdel = 'N' and quotation_revoke = 'N' and project_uid = @project_uid order by quotation_modifydate desc", new { project_uid = project_uid }).ToList();
|
||||
}
|
||||
|
||||
ret.ret = "yes";
|
||||
|
||||
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||
}
|
||||
|
||||
[Route("deptList")]
|
||||
public ActionResult DeptList(IFormCollection obj)
|
||||
{
|
||||
|
|
@ -125,6 +175,7 @@ namespace QuotationMaker.Controllers
|
|||
newProject.dept_uid = dept_uid;
|
||||
newProject.company_uid = company_uid;
|
||||
newProject.project_ps = project_ps;
|
||||
newProject.project_creative_uid = token.user_uid;
|
||||
newProject.project_lastmodify_uid = token.user_uid;
|
||||
newProject.project_name = project_name;
|
||||
newProject.project_datetime = DateTime.Now.ToString("yyyy/MM/dd");
|
||||
|
|
@ -271,7 +322,7 @@ namespace QuotationMaker.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
string sqlString = "select * from projectView where project_isdel = 'N' and project_lastmodify_uid in (" + user_uid_list + ") and project_createdate >= '" + startDateTime.ToString("yyyy/MM/dd") + "' and project_createdate <= '" + endDateTime.ToString("yyyy/MM/dd 23:59:59") + "'";
|
||||
string sqlString = "select * from projectView where project_isdel = 'N' and project_creative_uid in (" + user_uid_list + ") and project_createdate >= '" + startDateTime.ToString("yyyy/MM/dd") + "' and project_createdate <= '" + endDateTime.ToString("yyyy/MM/dd 23:59:59") + "'";
|
||||
|
||||
ret.projectViews = conn.Query<projectView>(sqlString).ToList();
|
||||
ret.ret = "yes";
|
||||
|
|
|
|||
|
|
@ -9,6 +9,161 @@ using Org.BouncyCastle.Bcpg.OpenPgp;
|
|||
|
||||
public class DbTableClass
|
||||
{
|
||||
|
||||
[Table("quotationView")]
|
||||
public class quotationView
|
||||
{
|
||||
[JsonIgnore]
|
||||
[Key]
|
||||
public int quotation_sn { get; set; }
|
||||
public string quotation_uid { get; set; } = "";
|
||||
public string quotation_name { get; set; } = "";
|
||||
public string quotation_date { get; set; } = "";
|
||||
public string dept_uid { get; set; } = "";
|
||||
public string quotation_expStart { get; set; } = "";
|
||||
public string quotation_expEnd { get; set; } = "";
|
||||
public string quotation_prodMethod { get; set; } = "";
|
||||
public string project_uid { get; set; } = "";
|
||||
public string modelProj_uid { get; set; } = "";
|
||||
public string modelQuotation_uid { get; set; } = "";
|
||||
public string company_uid { get; set; } = "";
|
||||
public string contactPerson_uid { get; set; } = "";
|
||||
public double quotation_noTaxTotal { get; set; } = 0.0;
|
||||
public double quotation_specTotal { get; set; } = 0.0;
|
||||
public double quotation_tax { get; set; } = 0.0;
|
||||
public double quotation_grandTotal { get; set; } = 0.0;
|
||||
public string quotation_sa { get; set; } = "";
|
||||
public string quotation_isdel { get; set; } = "";
|
||||
public string quotation_revoke { get; set; } = "";
|
||||
public int quotation_version { get; set; } = 0;
|
||||
public DateTime quotation_createdate { get; set; } = DateTime.Now;
|
||||
public DateTime quotation_modifydate { get; set; } = DateTime.Now;
|
||||
public string quotation_create_uid { get; set; } = "";
|
||||
public string quotation_modify_uid { get; set; } = "";
|
||||
public string contactPerson_name { get; set; } = "";
|
||||
public string contactPerson_email { get; set; } = "";
|
||||
public string contactPerson_tel { get; set; } = "";
|
||||
public string contactPerson_fax { get; set; } = "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Table("invoice")]
|
||||
public class invoice
|
||||
{
|
||||
[JsonIgnore]
|
||||
[Key]
|
||||
public int invoice_sn { get; set; }
|
||||
public string invoice_uid { get; set; } = "";
|
||||
public string quotation_uid { get; set; } = "";
|
||||
public string invoice_name { get; set; } = "";
|
||||
public string invoice_month { get; set; } = "";
|
||||
public int invoice_noTaxMoney { get; set; } = 0;
|
||||
public string invoice_revoke { get; set; } = "N";
|
||||
public int invoice_version { get; set; } = 1;
|
||||
public DateTime invoice_createdate { get; set; } = DateTime.Now;
|
||||
public DateTime invoice_modifydate { get; set; } = DateTime.Now;
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Table("payment")]
|
||||
public class payment
|
||||
{
|
||||
[JsonIgnore]
|
||||
[Key]
|
||||
public int payment_sn { get; set; }
|
||||
public string payment_uid { get; set; } = "";
|
||||
public string quotation_uid { get; set; } = "";
|
||||
public string payment_method { get; set; } = "";
|
||||
public string payment_descript { get; set; } = "";
|
||||
public string payment_revoke { get; set; } = "N";
|
||||
public int payment_version { get; set; } = 1;
|
||||
public DateTime payment_createdate { get; set; } = DateTime.Now;
|
||||
public DateTime payment_modifydate { get; set; } = DateTime.Now;
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Table("quotationSubItem")]
|
||||
public class quotationSubItem
|
||||
{
|
||||
[JsonIgnore]
|
||||
[Key]
|
||||
public int quotationSubItem_sn { get; set; }
|
||||
public string quotationSubItem_uid { get; set; } = "";
|
||||
public string quotation_uid { get; set; } = "";
|
||||
public string subItem_uid { get; set; } = "";
|
||||
public string quotationMainItem_uid { get; set; } = "";
|
||||
public string quotationSubItem_name { get; set; } = "";
|
||||
public string quotationSubItem_descript { get; set; } = "";
|
||||
public double quotationSubItem_price { get; set; } = 0.0;
|
||||
public string quotationSubItem_unitType { get; set; } = "";
|
||||
public double quotationSubItem_number { get; set; } = 0.0;
|
||||
public double quotationSubItem_subTotal { get; set; } = 0.0;
|
||||
public string quotationSubItem_hasAC { get; set; } = "Y";
|
||||
public string quotationSubItem_revoke { get; set; } = "N";
|
||||
public int quotationSubItem_version { get; set; } = 1;
|
||||
public DateTime quotationSubItem_createdate { get; set; } = DateTime.Now;
|
||||
public DateTime quotationSubItem_modifydate { get; set; } = DateTime.Now;
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Table("quotationMainItem")]
|
||||
public class quotationMainItem
|
||||
{
|
||||
[JsonIgnore]
|
||||
[Key]
|
||||
public int quotationMainItem_sn { get; set; }
|
||||
public string quotation_uid { get; set; } = "";
|
||||
public string mainItem_uid { get; set; } = "";
|
||||
public string quotationMainItem_uid { get; set; } = "";
|
||||
public string quotationMainItem_name { get; set; } = "";
|
||||
public double quotationMainItem_ac { get; set; } = 0.0;
|
||||
public double quotationMainItem_subTotal { get; set; } = 0.0;
|
||||
public string quotationMainItem_revoke { get; set; } = "N";
|
||||
public int quotationMainItem_version { get; set; } = 1;
|
||||
public DateTime quotationMainItem_createdate { get; set; } = DateTime.Now;
|
||||
public DateTime quotationMainItem_modifydate { get; set; } = DateTime.Now;
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Table("quotation")]
|
||||
public class quotation
|
||||
{
|
||||
[JsonIgnore]
|
||||
[Key]
|
||||
public int quotation_sn { get; set; }
|
||||
public string quotation_uid { get; set; } = "";
|
||||
public string quotation_name { get; set; } = "";
|
||||
public string quotation_date { get; set; } = "";
|
||||
public string dept_uid { get; set; } = "";
|
||||
public string quotation_expStart { get; set; } = "";
|
||||
public string quotation_expEnd { get; set; } = "";
|
||||
public string quotation_prodMethod { get; set; } = "";
|
||||
public string project_uid { get; set; } = "";
|
||||
public string modelProj_uid { get; set; } = "";
|
||||
public string modelQuotation_uid { get; set; } = "";
|
||||
public string company_uid { get; set; } = "";
|
||||
public string contactPerson_uid { get; set; } = "";
|
||||
public double quotation_noTaxTotal { get; set; } = 0.0;
|
||||
public double quotation_specTotal { get; set; } = 0.0;
|
||||
public double quotation_tax { get; set; } = 0.0;
|
||||
public double quotation_grandTotal { get; set; } = 0.0;
|
||||
public string quotation_sa { get; set; } = "";
|
||||
public string quotation_isdel { get; set; } = "";
|
||||
public string quotation_revoke { get; set; } = "";
|
||||
public int quotation_version { get; set; } = 1;
|
||||
public DateTime quotation_createdate { get; set; } = DateTime.Now;
|
||||
public DateTime quotation_modifydate { get; set; } = DateTime.Now;
|
||||
public string quotation_create_uid { get; set; } = "";
|
||||
public string quotation_modify_uid { get; set; } = "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Table("projectView")]
|
||||
public class projectView
|
||||
{
|
||||
|
|
@ -21,6 +176,7 @@ public class DbTableClass
|
|||
public string project_name { get; set; } = "";
|
||||
public string project_datetime { get; set; } = "";
|
||||
public string company_uid { get; set; } = "";
|
||||
public string project_creative_uid { get; set; } = "";
|
||||
public string project_lastmodify_uid { get; set; } = "";
|
||||
public DateTime project_createdate { get; set; } = DateTime.Now;
|
||||
public DateTime project_modifydate { get; set; } = DateTime.Now;
|
||||
|
|
@ -50,6 +206,8 @@ public class DbTableClass
|
|||
public string project_ps { get; set; } = "";
|
||||
|
||||
public string project_isdel { get; set; } = "N";
|
||||
|
||||
public string project_creative_uid { get; set; } = "";
|
||||
public string project_lastmodify_uid { get; set; } = "";
|
||||
public DateTime project_createdate { get; set; } = DateTime.Now;
|
||||
public DateTime project_modifydate { get; set; } = DateTime.Now;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,14 @@ using Dapper;
|
|||
using static DbTableClass;
|
||||
public class resultClass
|
||||
{
|
||||
public class quotationViewListResult
|
||||
{
|
||||
public string ret = "no";
|
||||
public string err_code = "0000";
|
||||
public string message = "";
|
||||
public List<quotationView> quotationViews = new List<quotationView>();
|
||||
}
|
||||
|
||||
public class projectViewResult
|
||||
{
|
||||
public string ret = "no";
|
||||
|
|
|
|||
|
|
@ -213,3 +213,63 @@
|
|||
</div>
|
||||
</form><!-- /.modal -->
|
||||
|
||||
<!-- .modal -->
|
||||
<form id="clientQuotationListForm" name="clientQuotationListForm">
|
||||
<div class="modal fade" id="clientQuotationListModal" tabindex="-1" role="dialog" aria-labelledby="clientQuotationListModalLabel" data-backdrop="static"
|
||||
data-keyboard="false" aria-hidden="true">
|
||||
<!-- .modal-dialog -->
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<!-- .modal-content -->
|
||||
<div class="modal-content">
|
||||
<!-- .modal-header -->
|
||||
<div class="modal-header">
|
||||
<h6 id="clientNewModalLabel" class="modal-title inline-editable">
|
||||
<span class="sr-only">報價單列表</span> <input id="QuotationTitle" 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="quotation_project_uid" />
|
||||
<!-- .page-section -->
|
||||
<div class="page-section">
|
||||
<button type="button" id="QuotationListNewBtn" class="btn btn-primary btn-floated position-absolute" title="Add new client"><i class="fa fa-plus"></i></button>
|
||||
|
||||
<div class="section-block">
|
||||
<div class="col-lg-12">
|
||||
<div id="project_info_div" class="alert alert-info" role="alert">
|
||||
專案名稱:
|
||||
客戶名稱:
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- .card -->
|
||||
<div class="card card-fluid">
|
||||
<!-- .card-body -->
|
||||
<div class="card-body">
|
||||
<!-- .table -->
|
||||
<table id="dt-responsive-quotation" class="table dt-responsive nowrap w-100">
|
||||
<thead>
|
||||
<tr>
|
||||
<th> 報價單名稱 </th>
|
||||
<th> 建立時間 </th>
|
||||
<th> 窗口 </th>
|
||||
<th style="width: 25px;"> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
</table><!-- /.table -->
|
||||
</div><!-- /.card-body -->
|
||||
</div><!-- /.card -->
|
||||
</div><!-- /.page-section -->
|
||||
</div><!-- /.modal-body -->
|
||||
<!-- .modal-footer -->
|
||||
<div class="modal-footer">
|
||||
<button type="button" id="QuotationSaveBtn" style="visibility:hidden;" 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 -->
|
||||
|
|
@ -2,11 +2,15 @@
|
|||
var projectRowID;
|
||||
var projectPos;
|
||||
|
||||
var quotationTable;
|
||||
var quotationRowID;
|
||||
var quotationPos;
|
||||
|
||||
$(document).ready(function () {
|
||||
deptList();
|
||||
companyList();
|
||||
loadyearmonth();
|
||||
|
||||
loadQuotationTable();
|
||||
|
||||
var actualDate = new Date(); // convert to actual date
|
||||
var prevDate = new Date(actualDate.getFullYear(), actualDate.getMonth() - 13, actualDate.getDate());
|
||||
|
|
@ -140,6 +144,55 @@ function buttonClick(obj) {
|
|||
|
||||
projectRowPos = projectTable.fnGetPosition($('#' + uid)[0]);
|
||||
|
||||
if (type == "preview") {
|
||||
var data = $('#dt-responsive').DataTable().row(projectRowPos).data();
|
||||
var project_name = data.project_name;
|
||||
var company_name = data.company_name;
|
||||
|
||||
var project_info_div = '專案名稱: ' + project_name + ", 客戶公司:" + company_name;
|
||||
|
||||
var formData = {
|
||||
project_uid: uid,
|
||||
dept_uid: dept_uid
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: "/Api/quotationList",
|
||||
type: "post",
|
||||
data: formData,
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
if (data.ret == "yes") {
|
||||
|
||||
var obj = data.quotationViews;
|
||||
|
||||
$('#dt-responsive-quotation').dataTable().fnClearTable();
|
||||
if (obj.length > 0) {
|
||||
|
||||
$('#dt-responsive-quotation').dataTable().fnAddData(obj);
|
||||
}
|
||||
|
||||
$('#project_info_div').text(project_info_div);
|
||||
$('#clientQuotationListModal').modal('toggle');
|
||||
|
||||
} 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',
|
||||
|
|
@ -213,6 +266,130 @@ function buttonClick(obj) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
function loadQuotationTable() {
|
||||
var dataTables = {
|
||||
init: function init() {
|
||||
|
||||
this.bindUIActions();
|
||||
},
|
||||
bindUIActions: function bindUIActions() {
|
||||
|
||||
// event handlers
|
||||
this.table = this.handleDataTables();
|
||||
|
||||
// add buttons
|
||||
//this.table.buttons().container().appendTo('#dt-buttons').unwrap();
|
||||
},
|
||||
handleDataTables: function handleDataTables() {
|
||||
//$('#myTable').append("<tfoot><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr></tfoot>");
|
||||
return $('#dt-responsive-quotation').DataTable({
|
||||
dom: '<\'text-muted\'Bif>\n <\'table-responsive\'trl>\n <\'mt-4\'p>',
|
||||
lengthChange: true,
|
||||
lengthMenu: [[25, 50, 100, -1], [25, 50, 100, "All"]],
|
||||
pageLength: 50,
|
||||
buttons: [
|
||||
//{
|
||||
// text: '休假設定',
|
||||
// action: function (e, dt, node, config) {
|
||||
// vacationBtnFun();
|
||||
|
||||
// }
|
||||
//},
|
||||
//'excelHtml5'
|
||||
],
|
||||
language: {
|
||||
paginate: {
|
||||
previous: '<i class="fa fa-lg fa-angle-left"></i>',
|
||||
next: '<i class="fa fa-lg fa-angle-right"></i>'
|
||||
},
|
||||
buttons: {
|
||||
copyTitle: 'Data copied',
|
||||
copyKeys: 'Use your keyboard or menu to select the copy command'
|
||||
}
|
||||
},
|
||||
autoWidth: false,
|
||||
rowId: 'quotation_uid',
|
||||
deferRender: true,
|
||||
initComplete: function () {
|
||||
quotationTable = $('#dt-responsive-quotation').dataTable();
|
||||
$('#dt-responsive-quotation').on('click', 'a', function () {
|
||||
buttonQuotationClick(this);
|
||||
});
|
||||
|
||||
$('#dt-responsive-quotation').on('click', 'button', function () {
|
||||
buttonQuotationClick(this);
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
order: [[0, '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_uid', className: 'align-top text-center', orderable: false, searchable: false }
|
||||
],
|
||||
columnDefs: [
|
||||
{
|
||||
targets: 0,
|
||||
className: 'align-middle text-left',
|
||||
orderable: false,
|
||||
searchable: true,
|
||||
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>';
|
||||
|
||||
}
|
||||
},
|
||||
{
|
||||
targets: 3,
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
render: function render(data, type, row, meta) {
|
||||
var ret = '';
|
||||
|
||||
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>';
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
],
|
||||
responsive: {
|
||||
details: {
|
||||
display: $.fn.dataTable.Responsive.display.childRowImmediate,
|
||||
type: ''
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
handleSearchRecords: function handleSearchRecords() {
|
||||
var self = this;
|
||||
|
||||
$('#table-search, #filterBy').on('keyup change focus', function (e) {
|
||||
var filterBy = $('#filterBy').val();
|
||||
var hasFilter = filterBy !== '';
|
||||
var value = $('#table-search').val();
|
||||
|
||||
self.table.search('').columns().search('').draw();
|
||||
|
||||
if (hasFilter) {
|
||||
self.table.columns(filterBy).search(value).draw();
|
||||
} else {
|
||||
self.table.search(value).draw();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
dataTables.init();
|
||||
}
|
||||
function loadDataTable() {
|
||||
var dataTables = {
|
||||
init: function init() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue