diff --git a/web/App_Code/api/orderController.cs b/web/App_Code/api/orderController.cs
index 66a8872..6b55626 100644
--- a/web/App_Code/api/orderController.cs
+++ b/web/App_Code/api/orderController.cs
@@ -597,7 +597,7 @@ public class orderController : ApiController
//var qry1 = _db.pro_order_detail.AsEnumerable();
//qry1 = qry1.Where(o => o.order_no == order_no);
//var qry1 = prod.pro_order_detail.AsEnumerable();
- var qry1 = prod.pro_order_detail.AsQueryable();
+ var qry1 = prod.pro_order_detail.AsQueryable().include(o=>o.pro_order.activity.activity_relating);
//if (!string.IsNullOrEmpty(q.subject))
// qry = qry.Where(o => o.subject.Contains(q.subject));
@@ -638,13 +638,19 @@ public class orderController : ApiController
var ret = new
{
- list = qry1_list.Select(x => new
+ list = qry1_list.Select(x => {
+ var tmpActivityRelating = x.pro_order?.activity?.activity_relating?.Where(a => a.actItem_num == x.actItem_num).FirstOrDefault();
+ return new
{
+ has_yang_limit = tmpActivityRelating?.has_yang_limit ?? false,
+ has_chao_limit = tmpActivityRelating?.has_chao_limit ?? false,
+ yang_limit_count = tmpActivityRelating?.yang_limit_count ?? 0,
+ chao_limit_count = tmpActivityRelating?.chao_limit_count ?? 0,
id = i++,
num = x.num,
order_no = x.order_no,
actitem_num_selected = new
- {
+ {
text = x.actItem_num.HasValue ? x.actItem.subject : "",
val = x.actItem_num.HasValue ? x.actItem_num.Value : 0,
},
@@ -758,6 +764,10 @@ public class orderController : ApiController
text = ar.actItem.subject,
val = ar.actItem_num,
},
+ has_yang_limit = ar.has_yang_limit ?? false,
+ has_chao_limit = ar.has_chao_limit ?? false,
+ yang_limit_count = ar.yang_limit_count ?? 0,
+ chao_limit_count = ar.chao_limit_count ?? 0,
parent_num = q.num,
f_num_selected = new
{
@@ -838,6 +848,10 @@ public class orderController : ApiController
text = x.actItem.subject,
val = x.actItem.num,
},
+ has_yang_limit = x.has_yang_limit,
+ has_chao_limit = x.has_chao_limit,
+ yang_limit_count = x.yang_limit_count,
+ chao_limit_count = x.chao_limit_count,
f_num_selected = new
{
text = "",
@@ -922,8 +936,6 @@ public class orderController : ApiController
{
return NotFound();
}
-
-
}
[HttpPost]
diff --git a/web/admin/activity/reg.aspx b/web/admin/activity/reg.aspx
index 056f57c..130269f 100644
--- a/web/admin/activity/reg.aspx
+++ b/web/admin/activity/reg.aspx
@@ -165,6 +165,8 @@
{ text: '* 品項名稱', value: 'act_item_selected.text', sortable: false },
{ text: '預設金額', value: 'price', sortable: false },
{ text: '數量', value: 'qty', sortable: false },
+ { text: '陽上/祈福人數限制', value: 'limit_yang', sortable: false },
+ { text: '超渡人數限制', value: 'limit_chao', sortable: false },
{ text: '', value: 'actions', sortable: false, width: "200px" },
],
footersDetail: {
@@ -191,6 +193,10 @@
price: 0,
qty: 0,
files: [],
+ has_yang_limit: false,
+ has_chao_limit: false,
+ yang_limit_count: 0,
+ chao_limit_count: 0,
},
defaultItem: {
id: 0,
@@ -203,6 +209,10 @@
price: 0,
qty: 0,
files: [],
+ has_yang_limit: false,
+ has_chao_limit: false,
+ yang_limit_count: 0,
+ chao_limit_count: 0,
},
//列印
data_table: {
@@ -267,10 +277,23 @@
order_dialog: {
show: false,
},
+ loading: false,
+ search: '',
+ headers: [
+ { text: '訂單編號', value: 'order_no' },
+ { text: '信眾編號', value: 'f_number' },
+ { text: '信眾姓名', value: 'u_name' },
+ { text: '聯絡電話', value: 'phone' },
+ { text: '建立日期', value: 'order_date' },
+ ],
+ items: [
+ { order_no: "D", member_name: "S", order_date:"2025-12-07"}
+ ],
}
},
mounted() {
this.search_dialog.current = this.search_dialog.controls.search1
+ this.loadUnfilledList();
//console.log("mounted");
},
watch: {
@@ -482,6 +505,10 @@
actItem_num: this.editedItem.act_item_selected.val,
price: this.editedItem.price,
qty: this.editedItem.qty,
+ has_yang_limit: this.editedItem.has_yang_limit,
+ has_chao_limit: this.editedItem.has_chao_limit,
+ yang_limit_count: this.editedItem.yang_limit_count,
+ chao_limit_count: this.editedItem.chao_limit_count,
}
axios
.post(HTTP_HOST + 'api/activity/SaveRelatingData', pro_order_detail)
@@ -886,6 +913,113 @@
const _date = $('#<%= startDate_solar.ClientID%>').val();
return _subject + " " + _date;
},
+loadUnfilledList() {
+ if (!this.this_id) return;
+
+ this.unfilled_list.loading = true;
+
+ axios.get(HTTP_HOST + 'api/activity/GetUnfilledOrdersByActivity/' + this.this_id)
+ .then(response => {
+ this.unfilled_list.items = response.data.list || [];
+ })
+ .catch(error => {
+ console.log(error);
+ this.snackbar.text = "名單載入失敗:" + error;
+ this.snackbar.show = true;
+ })
+ .finally(() => {
+ this.unfilled_list.loading = false;
+ });
+ },
+ async printUnfilledList() {
+ if (!this.this_id) return;
+
+ try {
+ const response = await axios.get(
+ HTTP_HOST + `api/activity/GetUnfilledOrdersByActivity/${this.this_id}`,
+ { params: { page: 1, pageSize: 99999 } }
+ );
+
+ const allItems = response.data.list || [];
+
+ if (allItems.length === 0) {
+ this.snackbar.text = "目前沒有未填寫品項的資料可供列印!";
+ this.snackbar.show = true;
+ return;
+ }
+
+ const activityTitle = this.titleword();
+
+ const rows = allItems.map(item => `
+
+ | ${item.order_no} |
+ ${item.f_number || ''} |
+ ${item.u_name} |
+ ${item.phone} |
+ ${item.order_date} |
+
+ `).join('');
+
+ const win = window.open('', '_blank');
+ win.document.write(`
+
+
+ 未填寫品項名單 - ${activityTitle}
+
+
+
+
+
+
+
+
+ | 訂單編號 |
+ 信眾編號 |
+ 信眾姓名 |
+ 聯絡電話 |
+ 建單日期 |
+
+
+ ${rows}
+
+
+
+ 列印時間:${new Date().toLocaleString()}
+
+
+
+ `);
+
+ win.document.close();
+
+ // 確保內容載入完成後再呼叫列印
+ setTimeout(() => {
+ win.print();
+ win.close();
+ }, 300);
+
+ } catch (error) {
+ console.error("列印出錯:", error);
+ this.snackbar.text = "讀取列印資料失敗:" + error;
+ this.snackbar.show = true;
+ }
+ }
},
computed: {
},
@@ -925,6 +1059,10 @@
<%-- --%>
+
@@ -1098,6 +1236,53 @@
{{item.qty}}
+
+
+
+
+
+
+
+ 不限
+ {{item.yang_limit_count}} 人
+
+
+
+
+
+
+
+
+ 不限
+ {{item.chao_limit_count}} 人
+
+
@@ -1207,6 +1392,41 @@
+
+
+
+
+
+
+
+
+
+
+
+ mdi-printer列印所有名單
+
+
+
+
+
+
+ 未選品項
+
+
+
+
+
diff --git a/web/admin/activity/reg.aspx.cs b/web/admin/activity/reg.aspx.cs
index 7d37de7..c4a7c9a 100644
--- a/web/admin/activity/reg.aspx.cs
+++ b/web/admin/activity/reg.aspx.cs
@@ -235,7 +235,36 @@ public partial class admin_activity_reg : MyWeb.config
#endregion
#region 資料新增
+ protected string createOrderNumber()
+ {
+ Application.Lock();
+ string order_no = "AA" + DateTime.Now.ToString("yyMMdd");
+ var qry = _db.companies.AsQueryable();
+ //var prod = qry.Where(q => q.last_order_no.Contains(order_no)).FirstOrDefault();
+ var prod = qry.Where(q => q.num == 1).FirstOrDefault();
+ if (prod != null)
+ {
+ if (!isStrNull(prod.last_order_no) && prod.last_order_no.Contains(order_no))
+ {
+ int tmp = Convert.ToInt32(prod.last_order_no.Replace(order_no, "")) + 1;
+ order_no = order_no + tmp.ToString("0000");
+ }
+ else
+ {
+ order_no = order_no + "0001";
+ }
+
+ prod.last_order_no = order_no;
+ _db.SaveChanges();
+ }
+ else
+ order_no = "";
+
+ Application.UnLock();
+
+ return order_no;
+ }
protected void add_Click(object sender, EventArgs e)
{
if (Page.IsValid) {
@@ -281,7 +310,21 @@ public partial class admin_activity_reg : MyWeb.config
// printInit 欄位
//var printInitValue = printInit.Text.Trim();
//activity.print_init = !string.IsNullOrEmpty(printInitValue) ? printInitValue : null;
- if (activity.startDate_solar == null || activity.endDate_solar == null)
+ activity.kind = Val(kind.Value);
+ activity.category_kind = Val(category_kind.Value);
+ activity.reg_time = DateTime.Now;
+ _db.activities.Add(activity);
+ _db.SaveChanges();
+ int _id = activity.num;
+ if (_id > 0)
+ {
+ RunAutoEnroll(_id);
+
+ Model.admin_log admin_log = new Model.admin_log();
+ admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Activity, (int)Model.admin_log.Status.Insert, subject.Text);
+ Response.Redirect("index.aspx");
+ }
+ else if (activity.startDate_solar == null || activity.endDate_solar == null)
{
L_msg.Type = alert_type.danger;
L_msg.Text = "開始、結束日期必須填寫";
@@ -378,8 +421,11 @@ public partial class admin_activity_reg : MyWeb.config
else
{
//activity.category_kind = Val(category_kind.Value);
+ activity.category_kind = Val(category_kind.Value);
_db.SaveChanges();
+ RunAutoEnroll(activity.num);
+
Model.admin_log admin_log = new Model.admin_log();
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Activity, (int)Model.admin_log.Status.Update, subject.Text);
}
@@ -399,6 +445,84 @@ public partial class admin_activity_reg : MyWeb.config
}
}
}
+private void RunAutoEnroll(int activityNum)
+ {
+ var activity = _db.activities.FirstOrDefault(a => a.num == activityNum);
+ if (activity == null || !activity.startDate_solar.HasValue) return;
+
+ DateTime actDate = activity.startDate_solar.Value;
+
+ var validConfigs = _db.auto_enroll
+ .Where(ae => actDate >= ae.start_date && actDate <= ae.end_date)
+ .ToList();
+
+ foreach (var config in validConfigs)
+ {
+ if (_db.pro_order.Any(o => o.activity_num == activity.num && o.f_num == config.f_num))
+ continue;
+
+ var follower = _db.followers.FirstOrDefault(f => f.num == config.f_num);
+ if (follower == null) continue;
+
+ string newOrderNo = AutoOrderService.CreateAutoOrderNumber(_db);
+
+ Model.pro_order proOrder = new Model.pro_order
+ {
+ order_no = newOrderNo,
+ up_time = DateTime.Now,
+ reg_time = DateTime.Now,
+ keyin1 = "A01",
+ f_num = follower.num,
+ au_num = config.num,
+ phone = !string.IsNullOrEmpty(follower.cellphone) ? follower.cellphone : (follower.phone ?? ""),
+ activity_num = activity.num,
+ address = config.receipt_address ?? "",
+ receipt_title = config.receipt_title ?? "",
+ demo = "",
+ customize_data = ""
+ };
+
+ _db.pro_order.Add(proOrder);
+
+ CopyLatestOrderDetails(newOrderNo, config.f_num, (int)activity.kind);
+ }
+
+ _db.SaveChanges();
+ }
+
+ private void CopyLatestOrderDetails(string newOrderNo, int f_num, int activityKind)
+ {
+ var latestOrder = _db.pro_order
+ .Where(o => o.f_num == f_num && o.activity.kind == activityKind && _db.pro_order_detail.Any(d => d.order_no == o.order_no))
+ .OrderByDescending(o => o.order_no)
+ .FirstOrDefault();
+
+ if (latestOrder != null)
+ {
+ var prevDetails = _db.pro_order_detail.Where(d => d.order_no == latestOrder.order_no).ToList();
+ foreach (var detail in prevDetails)
+ {
+ Model.pro_order_detail newDetail = new Model.pro_order_detail
+ {
+ order_no = newOrderNo,
+ actItem_num = detail.actItem_num,
+ parent_num = detail.parent_num,
+ print_id = detail.print_id,
+ f_num = detail.f_num,
+ f_num_tablet = detail.f_num_tablet,
+ address = detail.address,
+ from_id = detail.from_id,
+ from_id_tablet = detail.from_id_tablet,
+ qty = detail.qty,
+ price = detail.price,
+ start_date = DateTime.Today,
+ pay = 0,
+ UpdateTime = DateTime.Now
+ };
+ _db.pro_order_detail.Add(newDetail);
+ }
+ }
+ }
#endregion