將全年報名移至獨立頁籤,並新增未報名品項名單列印功能

This commit is contained in:
2026-05-11 09:11:22 +08:00
parent 9a7c30bd21
commit 46494547db
12 changed files with 1508 additions and 646 deletions
+1
View File
@@ -94,6 +94,7 @@ namespace Model
public virtual DbSet<AncestralTabletRegistrant> AncestralTabletRegistrant { get; set; }
public virtual DbSet<AncestralTabletStatus> AncestralTabletStatus { get; set; }
public virtual DbSet<GuaDanOrderGuest> GuaDanOrderGuest { get; set; }
public virtual DbSet<auto_enroll> auto_enroll { get; set; }
public virtual int pager_eztrust(Nullable<int> startRowIndex, Nullable<int> pageSize, string tableName, string columnName, string sqlWhere, string orderBy, ObjectParameter rowCount)
{
+31 -5
View File
@@ -681,6 +681,31 @@ namespace Model
using System;
using System.Collections.Generic;
public partial class auto_enroll
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public auto_enroll()
{
this.pro_order = new HashSet<pro_order>();
}
public int num { get; set; }
public int f_num { get; set; }
public System.DateTime start_date { get; set; }
public System.DateTime end_date { get; set; }
public string receipt_title { get; set; }
public string receipt_address { get; set; }
public virtual follower followers { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<pro_order> pro_order { get; set; }
}
}
namespace Model
{
using System;
using System.Collections.Generic;
public partial class bed_kind
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
@@ -807,6 +832,7 @@ namespace Model
public string smtp_def { get; set; }
public string use_sender { get; set; }
public string bed_order_no { get; set; }
public string last_auto_order_no { get; set; }
}
}
namespace Model
@@ -908,6 +934,7 @@ namespace Model
this.transfer_register1 = new HashSet<transfer_register>();
this.GuaDanOrder = new HashSet<GuaDanOrder>();
this.GuaDanOrderGuest = new HashSet<GuaDanOrderGuest>();
this.auto_enroll = new HashSet<auto_enroll>();
}
public int num { get; set; }
@@ -942,11 +969,6 @@ namespace Model
public Nullable<int> appellation_id { get; set; }
public string follower_hash { get; set; }
public string search_keywords { get; set; }
public Nullable<bool> is_auto_enroll { get; set; }
public Nullable<System.DateTime> auto_enroll_start_date { get; set; }
public string auto_enroll_receipt_title { get; set; }
public string auto_enroll_receipt_address { get; set; }
public Nullable<bool> auto_enroll_is_receipt { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<activity_check> activity_check { get; set; }
@@ -977,6 +999,8 @@ namespace Model
public virtual ICollection<GuaDanOrder> GuaDanOrder { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<GuaDanOrderGuest> GuaDanOrderGuest { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<auto_enroll> auto_enroll { get; set; }
}
}
namespace Model
@@ -1350,6 +1374,7 @@ namespace Model
public Nullable<int> introducer { get; set; }
public Nullable<bool> send_receipt { get; set; }
public string receipt_title { get; set; }
public Nullable<int> au_num { get; set; }
public virtual activity activity { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
@@ -1358,6 +1383,7 @@ namespace Model
public virtual follower follower1 { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<pro_order_detail> pro_order_detail { get; set; }
public virtual auto_enroll auto_enroll { get; set; }
}
}
namespace Model
+112 -15
View File
@@ -334,6 +334,17 @@
<Property Name="num" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
<Property Name="title" Type="nvarchar" MaxLength="10" />
</EntityType>
<EntityType Name="auto_enroll">
<Key>
<PropertyRef Name="num" />
</Key>
<Property Name="num" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
<Property Name="f_num" Type="int" Nullable="false" />
<Property Name="start_date" Type="date" Nullable="false" />
<Property Name="end_date" Type="date" Nullable="false" />
<Property Name="receipt_title" Type="nvarchar(max)" />
<Property Name="receipt_address" Type="nchar" MaxLength="200" />
</EntityType>
<EntityType Name="bed_kind">
<Key>
<PropertyRef Name="num" />
@@ -405,6 +416,7 @@
<Property Name="smtp_def" Type="nvarchar" MaxLength="1" />
<Property Name="use_sender" Type="nvarchar" MaxLength="1" />
<Property Name="bed_order_no" Type="nvarchar" MaxLength="20" />
<Property Name="last_auto_order_no" Type="nvarchar" MaxLength="20" />
</EntityType>
<EntityType Name="country">
<Key>
@@ -486,11 +498,6 @@
<Property Name="appellation_id" Type="int" />
<Property Name="follower_hash" Type="nvarchar" MaxLength="100" />
<Property Name="search_keywords" Type="varchar(max)" />
<Property Name="is_auto_enroll" Type="bit" />
<Property Name="auto_enroll_start_date" Type="datetime" />
<Property Name="auto_enroll_receipt_title" Type="nvarchar" MaxLength="50" />
<Property Name="auto_enroll_receipt_address" Type="nchar" MaxLength="200" />
<Property Name="auto_enroll_is_receipt" Type="bit" />
</EntityType>
<EntityType Name="followers_tablet">
<Key>
@@ -706,6 +713,7 @@
<Property Name="introducer" Type="int" />
<Property Name="send_receipt" Type="bit" />
<Property Name="receipt_title" Type="nvarchar(max)" />
<Property Name="au_num" Type="int" />
</EntityType>
<EntityType Name="pro_order_detail">
<Key>
@@ -1274,6 +1282,18 @@
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_auto_enroll_followers">
<End Role="followers" Type="Self.followers" Multiplicity="1" />
<End Role="auto_enroll" Type="Self.auto_enroll" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="followers">
<PropertyRef Name="num" />
</Principal>
<Dependent Role="auto_enroll">
<PropertyRef Name="f_num" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_bed_kind_detail_bed_kind">
<End Role="bed_kind" Type="Self.bed_kind" Multiplicity="0..1" />
<End Role="bed_kind_detail" Type="Self.bed_kind_detail" Multiplicity="*" />
@@ -1652,6 +1672,18 @@
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_pro_order_auto_enroll">
<End Role="auto_enroll" Type="Self.auto_enroll" Multiplicity="0..1" />
<End Role="pro_order" Type="Self.pro_order" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="auto_enroll">
<PropertyRef Name="num" />
</Principal>
<Dependent Role="pro_order">
<PropertyRef Name="au_num" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_pro_order_detail_actItem">
<End Role="actItem" Type="Self.actItem" Multiplicity="0..1">
<OnDelete Action="Cascade" />
@@ -2122,6 +2154,7 @@
<EntitySet Name="AncestralTabletRegistrant" EntityType="Self.AncestralTabletRegistrant" Schema="dbo" store:Type="Tables" />
<EntitySet Name="AncestralTabletStatus" EntityType="Self.AncestralTabletStatus" Schema="dbo" store:Type="Tables" />
<EntitySet Name="appellation" EntityType="Self.appellation" Schema="dbo" store:Type="Tables" />
<EntitySet Name="auto_enroll" EntityType="Self.auto_enroll" Schema="dbo" store:Type="Tables" />
<EntitySet Name="bed_kind" EntityType="Self.bed_kind" Schema="dbo" store:Type="Tables" />
<EntitySet Name="bed_kind_detail" EntityType="Self.bed_kind_detail" Schema="dbo" store:Type="Tables" />
<EntitySet Name="bed_order" EntityType="Self.bed_order" Schema="dbo" store:Type="Tables" />
@@ -2253,6 +2286,10 @@
<End Role="AncestralTabletArea" EntitySet="AncestralTabletArea" />
<End Role="AncestralTabletArea1" EntitySet="AncestralTabletArea" />
</AssociationSet>
<AssociationSet Name="FK_auto_enroll_followers" Association="Self.FK_auto_enroll_followers">
<End Role="followers" EntitySet="followers" />
<End Role="auto_enroll" EntitySet="auto_enroll" />
</AssociationSet>
<AssociationSet Name="FK_bed_kind_detail_bed_kind" Association="Self.FK_bed_kind_detail_bed_kind">
<End Role="bed_kind" EntitySet="bed_kind" />
<End Role="bed_kind_detail" EntitySet="bed_kind_detail" />
@@ -2377,6 +2414,10 @@
<End Role="activity" EntitySet="activity" />
<End Role="pro_order" EntitySet="pro_order" />
</AssociationSet>
<AssociationSet Name="FK_pro_order_auto_enroll" Association="Self.FK_pro_order_auto_enroll">
<End Role="auto_enroll" EntitySet="auto_enroll" />
<End Role="pro_order" EntitySet="pro_order" />
</AssociationSet>
<AssociationSet Name="FK_pro_order_detail_actItem" Association="Self.FK_pro_order_detail_actItem">
<End Role="actItem" EntitySet="actItem" />
<End Role="pro_order_detail" EntitySet="pro_order_detail" />
@@ -2905,6 +2946,7 @@
<Property Name="smtp_def" Type="String" MaxLength="1" FixedLength="false" Unicode="true" />
<Property Name="use_sender" Type="String" MaxLength="1" FixedLength="false" Unicode="true" />
<Property Name="bed_order_no" Type="String" MaxLength="20" FixedLength="false" Unicode="true" />
<Property Name="last_auto_order_no" Type="String" MaxLength="20" FixedLength="false" Unicode="true" />
</EntityType>
<EntityType Name="country">
<Key>
@@ -2983,11 +3025,7 @@
<NavigationProperty Name="GuaDanOrder" Relationship="Model.FK_GuaDanOrder_Followers" FromRole="follower" ToRole="GuaDanOrder" />
<Property Name="search_keywords" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
<NavigationProperty Name="GuaDanOrderGuest" Relationship="Model.FK_GuaDanOrderGuest_FOLLOWERS" FromRole="follower" ToRole="GuaDanOrderGuest" />
<Property Name="is_auto_enroll" Type="Boolean" />
<Property Name="auto_enroll_start_date" Type="DateTime" Precision="3" />
<Property Name="auto_enroll_receipt_title" Type="String" MaxLength="50" FixedLength="false" Unicode="true" />
<Property Name="auto_enroll_receipt_address" Type="String" MaxLength="200" FixedLength="true" Unicode="true" />
<Property Name="auto_enroll_is_receipt" Type="Boolean" />
<NavigationProperty Name="auto_enroll" Relationship="Model.FK_auto_enroll_followers" FromRole="follower" ToRole="auto_enroll" />
</EntityType>
<EntityType Name="followers_tablet">
<Key>
@@ -3166,6 +3204,8 @@
<NavigationProperty Name="pro_order_detail" Relationship="Self.FK_pro_order_detail_pro_order" FromRole="pro_order" ToRole="pro_order_detail" />
<Property Name="send_receipt" Type="Boolean" />
<Property Name="receipt_title" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" />
<Property Name="au_num" Type="Int32" />
<NavigationProperty Name="auto_enroll" Relationship="Model.FK_pro_order_auto_enroll" FromRole="pro_order" ToRole="auto_enroll" />
</EntityType>
<EntityType Name="pro_order_detail">
<Key>
@@ -4563,6 +4603,15 @@
<End Role="GuaDanOrderGuest" EntitySet="GuaDanOrderGuest" />
<End Role="RegionAndRoomAndBedSchedule" EntitySet="RegionAndRoomAndBedSchedule" />
</AssociationSet>
<EntitySet Name="auto_enroll" EntityType="Model.auto_enroll" />
<AssociationSet Name="FK_auto_enroll_followers" Association="Model.FK_auto_enroll_followers">
<End Role="follower" EntitySet="followers" />
<End Role="auto_enroll" EntitySet="auto_enroll" />
</AssociationSet>
<AssociationSet Name="FK_pro_order_auto_enroll" Association="Model.FK_pro_order_auto_enroll">
<End Role="auto_enroll" EntitySet="auto_enroll" />
<End Role="pro_order" EntitySet="pro_order" />
</AssociationSet>
</EntityContainer>
<ComplexType Name="sp_helpdiagramdefinition_Result">
<Property Type="Int32" Name="version" Nullable="true" />
@@ -5280,6 +5329,45 @@
</Dependent>
</ReferentialConstraint>
</Association>
<EntityType Name="auto_enroll">
<Key>
<PropertyRef Name="num" />
</Key>
<Property Name="num" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Name="f_num" Type="Int32" Nullable="false" />
<Property Name="start_date" Type="DateTime" Precision="0" Nullable="false" />
<Property Name="end_date" Type="DateTime" Precision="0" Nullable="false" />
<Property Name="receipt_title" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" />
<Property Name="receipt_address" Type="String" MaxLength="200" FixedLength="true" Unicode="true" />
<NavigationProperty Name="followers" Relationship="Model.FK_auto_enroll_followers" FromRole="auto_enroll" ToRole="follower" />
<NavigationProperty Name="pro_order" Relationship="Model.FK_pro_order_auto_enroll" FromRole="auto_enroll" ToRole="pro_order" />
</EntityType>
<Association Name="FK_auto_enroll_followers">
<End Type="Model.follower" Role="follower" Multiplicity="1">
<OnDelete Action="Cascade" />
</End>
<End Type="Model.auto_enroll" Role="auto_enroll" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="follower">
<PropertyRef Name="num" />
</Principal>
<Dependent Role="auto_enroll">
<PropertyRef Name="f_num" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_pro_order_auto_enroll">
<End Type="Model.auto_enroll" Role="auto_enroll" Multiplicity="0..1" />
<End Type="Model.pro_order" Role="pro_order" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="auto_enroll">
<PropertyRef Name="num" />
</Principal>
<Dependent Role="pro_order">
<PropertyRef Name="au_num" />
</Dependent>
</ReferentialConstraint>
</Association>
</Schema>
</edmx:ConceptualModels>
<!-- C-S mapping content -->
@@ -5606,6 +5694,7 @@
<EntitySetMapping Name="companies">
<EntityTypeMapping TypeName="Model.company">
<MappingFragment StoreEntitySet="company">
<ScalarProperty Name="last_auto_order_no" ColumnName="last_auto_order_no" />
<ScalarProperty Name="num" ColumnName="num" />
<ScalarProperty Name="com_name" ColumnName="com_name" />
<ScalarProperty Name="com_mail" ColumnName="com_mail" />
@@ -5657,11 +5746,6 @@
<EntitySetMapping Name="followers">
<EntityTypeMapping TypeName="Model.follower">
<MappingFragment StoreEntitySet="followers">
<ScalarProperty Name="auto_enroll_is_receipt" ColumnName="auto_enroll_is_receipt" />
<ScalarProperty Name="auto_enroll_receipt_address" ColumnName="auto_enroll_receipt_address" />
<ScalarProperty Name="auto_enroll_receipt_title" ColumnName="auto_enroll_receipt_title" />
<ScalarProperty Name="auto_enroll_start_date" ColumnName="auto_enroll_start_date" />
<ScalarProperty Name="is_auto_enroll" ColumnName="is_auto_enroll" />
<ScalarProperty Name="search_keywords" ColumnName="search_keywords" />
<ScalarProperty Name="follower_hash" ColumnName="follower_hash" />
<ScalarProperty Name="num" ColumnName="num" />
@@ -5845,6 +5929,7 @@
<EntitySetMapping Name="pro_order">
<EntityTypeMapping TypeName="Model.pro_order">
<MappingFragment StoreEntitySet="pro_order">
<ScalarProperty Name="au_num" ColumnName="au_num" />
<ScalarProperty Name="receipt_title" ColumnName="receipt_title" />
<ScalarProperty Name="send_receipt" ColumnName="send_receipt" />
<ScalarProperty Name="order_no" ColumnName="order_no" />
@@ -6338,6 +6423,18 @@
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="auto_enroll">
<EntityTypeMapping TypeName="Model.auto_enroll">
<MappingFragment StoreEntitySet="auto_enroll">
<ScalarProperty Name="receipt_address" ColumnName="receipt_address" />
<ScalarProperty Name="receipt_title" ColumnName="receipt_title" />
<ScalarProperty Name="end_date" ColumnName="end_date" />
<ScalarProperty Name="start_date" ColumnName="start_date" />
<ScalarProperty Name="f_num" ColumnName="f_num" />
<ScalarProperty Name="num" ColumnName="num" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
</EntityContainerMapping>
</Mapping>
</edmx:Mappings>
+3
View File
@@ -162,6 +162,9 @@
<AssociationConnector Association="Model.FK_GuaDanOrderGuest_RoomUuid" />
<AssociationConnector Association="Model.FK_GuaDanOrderGuest_StatusCode" />
<AssociationConnector Association="Model.FK_Schedule_GuaDanOrderGuest" />
<EntityTypeShape EntityType="Model.auto_enroll" Width="1.5" PointX="5.25" PointY="37.875" />
<AssociationConnector Association="Model.FK_auto_enroll_followers" />
<AssociationConnector Association="Model.FK_pro_order_auto_enroll" />
</Diagram>
</edmx:Diagrams>
</edmx:Designer>
+336 -8
View File
@@ -1,16 +1,20 @@
using System;
using DocumentFormat.OpenXml.Drawing.Charts;
using DocumentFormat.OpenXml.Office2010.Excel;
using Model;
using MyWeb;
using Newtonsoft.Json;
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
using PagedList;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data.Entity;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using PagedList;
using Newtonsoft.Json;
using System.Collections;
using DocumentFormat.OpenXml.Office2010.Excel;
using MyWeb;
using System.Data.Entity;
using System.Diagnostics;
using System.Web.Razor.Tokenizer;
// api/Follower
//[ezAuthorize(Roles = "admin")]//群組:*
@@ -532,6 +536,203 @@ public class FollowerController : ApiController
}
[HttpGet]
[Route("api/follower/GetAutoEnrollList/{id}")]
public IHttpActionResult GetAutoEnrollList(int id)
{
var prod = _db.auto_enroll.Where(q => q.f_num == id).ToList();
var ret = new
{
list = prod.Select(x => new
{
num = x.num,
auto_enroll_start_date = x.start_date.ToString("yyyy-MM-dd"),
auto_enroll_end_date = x.end_date.ToString("yyyy-MM-dd"),
auto_enroll_receipt_title = x.receipt_title?? "",
auto_enroll_receipt_address = x.receipt_address?? "",
}),
};
return Ok(ret);
}
[HttpPost]
[Route("api/follower/SaveAutoEnrollList")]
public IHttpActionResult SaveAutoEnrollList([FromBody] Model.auto_enroll item)
{
Model.auto_enroll autoEnroll;
if (item.num == 0)
{
// ===== 新增 =====
autoEnroll = new Model.auto_enroll()
{
f_num = item.f_num,
start_date = item.start_date,
end_date = item.end_date,
receipt_title = string.IsNullOrEmpty(item.receipt_title) ? null : item.receipt_title.Trim(),
receipt_address = string.IsNullOrEmpty(item.receipt_address) ? null : item.receipt_address.Trim(),
}
;
_db.auto_enroll.Add(autoEnroll);
_db.SaveChanges();
CreateOrdersForActivities(item.f_num, autoEnroll.num, item.start_date, item.end_date, item.receipt_title, item.receipt_address);
}
else
{
// ===== 更新 =====
autoEnroll = _db.auto_enroll.Where(q => q.num == item.num).FirstOrDefault();
if (autoEnroll == null) return NotFound();
autoEnroll.start_date = item.start_date;
autoEnroll.end_date = item.end_date;
autoEnroll.receipt_title = item.receipt_title?.Trim() ?? null;
autoEnroll.receipt_address = item.receipt_address?.Trim() ?? null;
_db.SaveChanges();
CreateOrdersForActivities(item.f_num, autoEnroll.num, item.start_date, item.end_date, item.receipt_title, item.receipt_address);
}
try
{
var ret = new
{
num = autoEnroll.num,
start_date = autoEnroll.start_date.ToString("yyyy-MM-dd"),
end_date = autoEnroll.end_date.ToString("yyyy-MM-dd"),
receipt_title = autoEnroll.receipt_title,
receipt_address = autoEnroll.receipt_address,
};
return Ok(ret);
}
catch(Exception ex)
{
return InternalServerError(ex);
}
}
[HttpPost]
[Route("api/follower/GetAffectedOrders")]
public IHttpActionResult GetAffectedOrders([FromBody] Model.auto_enroll item, bool is_delete = false)
{
if (item == null) return BadRequest();
try
{
IQueryable<pro_order> query = _db.pro_order
.Where(o => o.f_num == item.f_num
&& o.order_no.StartsWith("AU")
&& o.au_num == item.num);
if (is_delete)
{
// 刪除:查期間內所有自動報名訂單
query = query.Where(o =>
o.activity.startDate_solar >= item.start_date &&
o.activity.startDate_solar <= item.end_date
);
}
else
{
// 修改:查不在新範圍內的訂單
query = query.Where(o =>
o.activity.startDate_solar < item.start_date ||
o.activity.startDate_solar > item.end_date
);
}
var rawOrders = query.Select(o => new
{
o.order_no,
o.activity.subject,
o.activity.startDate_solar
}).ToList();
var affectedOrders = rawOrders.Select(o => new
{
order_no = o.order_no,
activityname = o.subject,
activitydate = o.startDate_solar?.ToString("yyyy/MM/dd") ?? ""
}).ToList();
return Ok(new
{
count = affectedOrders.Count,
list = affectedOrders
});
}
catch (Exception ex)
{
return InternalServerError(ex.GetBaseException());
}
}
[HttpDelete]
[Route("api/follower/DeleteAutoEnroll/{id}")]
public IHttpActionResult DeleteAutoEnroll(int id)
{
try
{
var prod = _db.auto_enroll.Where(q => q.num == id).FirstOrDefault();
if (prod != null)
{
_db.auto_enroll.Remove(prod);
_db.SaveChanges();
return Ok();
}
else return NotFound();
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpGet]
[Route("api/follower/GetUnfilledActivityOrders/{id}")]
public IHttpActionResult GetUnfilledActivityOrders(int id, int page, int pageSize = 10, string sortBy = "", bool sortDesc = false)
{
try
{
var config = _db.auto_enroll.FirstOrDefault(x => x.num == id);
if (config == null) return NotFound();
var query = from o in _db.pro_order
join a in _db.activities on o.activity_num equals a.num
where o.f_num == config.f_num
&& a.startDate_solar >= config.start_date
&& a.startDate_solar <= config.end_date
&& !_db.pro_order_detail.Any(d => d.order_no == o.order_no)
select new { o, a };
int totalCount = query.Count();
var pagedData = query
.OrderByDescending(x => x.o.order_no)
.Skip((page - 1) * pageSize)
.Take(pageSize)
.ToList()
.Select(x => new {
order_no = x.o.order_no,
startdate = x.a.startDate_solar?.ToString("yyyy/MM/dd") ?? "",
enddate = x.a.endDate_solar?.ToString("yyyy/MM/dd") ?? "",
activityname = x.a.subject,
category = x.a.activity_category_kind?.kind ?? ""
});
return Ok(new
{
list = pagedData,
count = totalCount,
page = page,
pageSize = pageSize
});
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpPost]
[Route("api/follower/GetTabletList")]
@@ -733,5 +934,132 @@ public class FollowerController : ApiController
};
return Ok(data);
}
private void CreateOrdersForActivities(int f_num, int au_num, DateTime start_date, DateTime end_date, string receipt_title, string receipt_address)
{
var follower = _db.followers.Where(x => x.num == f_num).FirstOrDefault();
var activities = _db.activities
.Where(x =>
x.startDate_solar >= start_date &&
x.startDate_solar <= end_date
)
.ToList();
foreach (var activity in activities)
{
var existOrder = _db.pro_order
.Where(o => o.activity_num == activity.num && o.f_num == f_num)
.FirstOrDefault();
if (existOrder != null) {
existOrder.au_num = au_num;
_db.SaveChanges();
continue;
}
string newOrderNo = AutoOrderService.CreateAutoOrderNumber(_db);
string finalPhone = follower?.cellphone ?? follower?.phone ?? "";
var newOrder = new pro_order
{
order_no = newOrderNo,
up_time = DateTime.Now,
reg_time = DateTime.Now,
keyin1 = "A01",
f_num = f_num,
au_num = au_num,
phone = finalPhone,
address = string.IsNullOrEmpty(receipt_address) ? "" : receipt_address,
activity_num = activity.num,
receipt_title = receipt_title ?? "",
demo = "",
customize_data = "",
};
_db.pro_order.Add(newOrder);
// 抓取同活動分類的上一筆訂單,複製品項
var latestOrder = _db.pro_order
.Where(o =>
o.f_num == f_num &&
o.activity.kind == activity.kind &&
o.order_no != newOrderNo &&
_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)
{
var newDetail = new 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,
bed_type = detail.bed_type,
qty = detail.qty,
price = detail.price,
start_date = DateTime.Today,
pay = detail.pay,
keyin1 = detail.keyin1,
demo = detail.demo,
customize_data = detail.customize_data,
printed_files = detail.printed_files,
UpdateTime = DateTime.Now,
};
_db.pro_order_detail.Add(newDetail);
}
}
}
_db.SaveChanges();
}
}
public static class AutoOrderService
{
private static readonly object _lock = new object();
public static string CreateAutoOrderNumber(Model.ezEntities _db)
{
lock (_lock)
{
string prefix = "AU" + DateTime.Now.ToString("yyMMdd");
var company = _db.companies.FirstOrDefault(q => q.num == 1);
if (company == null) return "";
string order_no;
if (!string.IsNullOrEmpty(company.last_auto_order_no) && company.last_auto_order_no.StartsWith(prefix))
{
string serialStr = company.last_auto_order_no.Replace(prefix, "");
int nextSerial = int.Parse(serialStr) + 1;
order_no = prefix + nextSerial.ToString("0000");
}
else
{
order_no = prefix + "0001";
}
company.last_auto_order_no = order_no;
_db.SaveChanges();
return order_no;
}
}
}
+138 -6
View File
@@ -803,7 +803,7 @@ public class activityController : ApiController
//已有值
var count = qry.Count(); //pageSize = count;//一次取回??
var qryList = (pageSize > 0) ? qry.OrderBy(a=>a.num).ToPagedList(page, pageSize).ToList() : qry.ToList();
var qryList = (pageSize > 0) ? qry.OrderBy(a => a.num).ToPagedList(page, pageSize).ToList() : qry.ToList();
var ret = new
{
list = qryList.Select(x => new
@@ -959,10 +959,10 @@ public class activityController : ApiController
},
price = x.price ?? 0,
qty = x.qty ?? 0,
has_yang_limit = x.has_yang_limit?? false,
has_chao_limit = x.has_yang_limit?? false,
yang_limit_count = x.yang_limit_count?? 0,
chao_limit_count = x.chao_limit_count?? 0,
has_yang_limit = x.has_yang_limit ?? false,
has_chao_limit = x.has_yang_limit ?? false,
yang_limit_count = x.yang_limit_count ?? 0,
chao_limit_count = x.chao_limit_count ?? 0,
files = x.actItem?.actItem_files.Select(f => new
{
num = f.file.num,
@@ -1180,7 +1180,7 @@ public class activityController : ApiController
if (item.qty.HasValue) { _data.qty = item.qty.Value; }
else { _data.qty = null; }
_data.reg_time = DateTime.Now;
if (item.has_yang_limit.HasValue) { _data.has_yang_limit = item.has_yang_limit; }
if (item.has_yang_limit.HasValue) { _data.has_yang_limit = item.has_yang_limit; }
if (item.yang_limit_count >= 0) { _data.yang_limit_count = item.yang_limit_count.Value; }
if (item.has_chao_limit.HasValue) { _data.has_chao_limit = item.has_chao_limit; }
if (item.chao_limit_count >= 0) { _data.chao_limit_count = item.chao_limit_count.Value; }
@@ -1620,4 +1620,136 @@ public class activityController : ApiController
return Ok(ret);
}
[HttpGet]
[Route("api/activity/GetUnfilledOrdersByActivity/{num}")]
public IHttpActionResult GetUnfilledOrdersByActivity(int num)
{
try
{
var activityExists = _db.activities.Any(a => a.num == num);
if (!activityExists) return NotFound();
var query = from o in _db.pro_order
join f in _db.followers on o.f_num equals f.num into fg
from f in fg.DefaultIfEmpty()
where o.activity_num == num
&& !_db.pro_order_detail.Any(d => d.order_no == o.order_no)
select new { o, f };
MyWeb.encrypt encrypt = new MyWeb.encrypt();
var unfilledOrders = query.ToList().Select(x => new
{
order_no = x.o.order_no,
f_number = x.f.f_number,
u_name = x.f != null ? x.f.u_name : "未知",
phone = !string.IsNullOrEmpty(x.f.cellphone) ? encrypt.DecryptAutoKey(x.f.cellphone) : (encrypt.DecryptAutoKey(x.f.phone) ?? ""),
order_date = x.o.reg_time.HasValue ? x.o.reg_time.Value.ToString("yyyy/MM/dd") : "",
}).ToList();
return Ok(new
{
list = unfilledOrders,
count = unfilledOrders.Count
});
}
catch (Exception ex)
{
return InternalServerError(ex.GetBaseException());
}
}
[HttpPost]
[Route("api/activity/TriggerAutoEnroll/{activity_num}")]
public IHttpActionResult TriggerAutoEnroll(int activity_num)
{
try
{
var activity = _db.activities.FirstOrDefault(a => a.num == activity_num);
if (activity == null) return NotFound();
if (!activity.startDate_solar.HasValue) return BadRequest("該活動沒有設定開始日期,無法執行自動報名。");
DateTime actDate = activity.startDate_solar.Value;
var validConfigs = _db.auto_enroll
.Where(ae => actDate >= ae.start_date && actDate <= ae.end_date)
.ToList();
int successCount = 0;
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);
string newOrderNo = AutoOrderService.CreateAutoOrderNumber(_db);
var newOrder = new pro_order
{
order_no = newOrderNo,
up_time = DateTime.Now,
reg_time = DateTime.Now,
keyin1 = "A01",
f_num = config.f_num,
au_num = config.num,
phone = follower?.cellphone ?? follower?.phone ?? "",
address = config.receipt_address ?? "",
activity_num = activity_num,
receipt_title = config.receipt_title ?? "",
demo = "系統於新增活動時自動報名",
};
_db.pro_order.Add(newOrder);
CopyLatestOrderDetails(newOrderNo, config.f_num, (int)activity.kind);
successCount++;
}
_db.SaveChanges();
return Ok(new
{
message = $"自動報名執行完畢,共為 {successCount} 位信眾完成報名。",
count = successCount
});
}
catch (Exception ex)
{
return InternalServerError(ex.GetBaseException());
}
}
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)
{
_db.pro_order_detail.Add(new 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
});
}
}
}
}
+1 -1
View File
@@ -383,7 +383,7 @@ public class orderController : ApiController
}
var tdesc = publicFun.enum_desc<Model.pro_order.detailKeyin1>();;
var tdesc = publicFun.enum_desc<Model.pro_order.detailKeyin1>();
int i = 1;
//已有值
+160
View File
@@ -277,10 +277,25 @@
order_dialog: {
show: false,
},
unfilled_list: {
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: {
@@ -821,6 +836,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 => `
<tr>
<td>${item.order_no}</td>
<td>${item.f_number || ''}</td>
<td>${item.u_name}</td>
<td>${item.phone}</td>
<td>${item.order_date}</td>
</tr>
`).join('');
const win = window.open('', '_blank');
win.document.write(`
<html>
<head>
<title>未填寫品項名單 - ${activityTitle}</title>
<style>
body { font-family: "Microsoft JhengHei", Arial, sans-serif; padding: 20px; color: #000; }
.header-container { text-align: center; margin-bottom: 30px; }
h2 { margin-bottom: 5px; font-size: 24px; }
h4 { margin-top: 0; color: #333; font-weight: normal; }
table { width: 100%; border-collapse: collapse; }
th, td { border: 1px solid #000; padding: 10px 8px; text-align: left; font-size: 14px; }
th { background-color: #eee; font-weight: bold; }
.text-center { text-align: center; }
@media print {
@page { margin: 1.5cm; }
button { display: none; }
}
</style>
</head>
<body>
<div class="header-container">
<h2>尚未報名品項之信眾清單</h2>
<h4>活動名稱:${activityTitle}</h4>
</div>
<table>
<thead>
<tr>
<th width="18%">訂單編號</th>
<th width="15%">信眾編號</th>
<th width="20%">信眾姓名</th>
<th width="20%">聯絡電話</th>
<th width="27%">建單日期</th>
</tr>
</thead>
<tbody>${rows}</tbody>
</table>
<div style="margin-top: 20px; text-align: right; font-size: 12px;">
列印時間:${new Date().toLocaleString()}
</div>
</body>
</html>
`);
win.document.close();
// 確保內容載入完成後再呼叫列印
setTimeout(() => {
win.print();
win.close();
}, 300);
} catch (error) {
console.error("列印出錯:", error);
this.snackbar.text = "讀取列印資料失敗:" + error;
this.snackbar.show = true;
}
}
},
computed: {
},
@@ -860,6 +982,10 @@
<button v-if="this_id!=''" class="nav-link" id="sec2-tab3" data-bs-toggle="tab" data-bs-target="#sec2-page3"
type="button" role="tab" aria-controls="profile" aria-selected="false">
備品項目</button>
<button v-if="this_id!=''" class="nav-link" id="sec2-tab4" data-bs-toggle="tab" data-bs-target="#sec2-page4"
type="button" role="tab" aria-controls="profile" aria-selected="false" @click="loadUnfilledList">
未填寫名單
</button>
</div>
</nav>
</div>
@@ -1189,6 +1315,40 @@
</div>
<div class="tab-pane fade" id="sec2-page4" role="tabpanel" aria-labelledby="sec2-tab4" v-if="this_id!=''">
<v-card class="mx-auto" outlined id="print-unfilled-area">
<v-data-table
:headers="unfilled_list.headers"
:items="unfilled_list.items"
:loading="unfilled_list.loading"
:search="unfilled_list.search"
class="elevation-1"
fixed-header
height="350px">
<template v-slot:top>
<v-toolbar flat color="white" class="d-print-none">
<div class="d-flex w-100">
<v-text-field
v-model="unfilled_list.search"
append-icon="mdi-magnify"
label="搜尋姓名或訂單號"
dense outlined single-line hide-details>
</v-text-field>
<v-btn color="primary" class="ml-2 white--text" @click="printUnfilledList">
<v-icon left>mdi-printer</v-icon>列印所有名單
</v-btn>
</div>
</v-toolbar>
</template>
<template v-slot:item.status="{ item }">
<v-chip small color="error">未選品項</v-chip>
</template>
</v-data-table>
</v-card>
</div>
</div>
</asp:Panel>
</div>
+83 -57
View File
@@ -320,63 +320,10 @@ public partial class admin_activity_reg : MyWeb.config
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);
// 自動報名的信眾報名
var qry = _db.followers.Where(f => f.is_auto_enroll == true).AsQueryable();
var followers = qry.ToList();
if (followers != null)
{
try
{
foreach (var follower in followers)
{
Model.pro_order pro_order = new Model.pro_order(); //新增
pro_order.order_no = createOrderNumber();
pro_order.up_time = DateTime.Now;
pro_order.reg_time = DateTime.Now;
pro_order.keyin1 = "A01";
pro_order.f_num = follower.num;
if (!isStrNull(follower.phone)) { pro_order.phone = follower.phone; }
if (!isStrNull(follower.cellphone)) { pro_order.phone = follower.cellphone; }
if (IsNumeric(activity.num)) { pro_order.activity_num = activity.num; }
pro_order.address = isStrNull(follower.auto_enroll_receipt_address) ? "" : follower.auto_enroll_receipt_address;
pro_order.receipt_title = isStrNull(follower.auto_enroll_receipt_title) ? "" : follower.auto_enroll_receipt_title;
pro_order.send_receipt = isStrNull(follower.auto_enroll_is_receipt) ? false : follower.auto_enroll_is_receipt;
pro_order.demo = "";
pro_order.customize_data = "";
try
{
if (!isStrNull(pro_order.order_no))
{
bool isRegistered = _db.pro_order.Any(x => x.f_num == pro_order.f_num && x.activity_num == pro_order.activity_num);
if (isRegistered) // 重複報名
{
continue;
}
else
{
_db.pro_order.Add(pro_order);
_db.SaveChanges();
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Order, (int)Model.admin_log.Status.Insert, pro_order.order_no);
}
}
}
catch (Exception ex)
{
}
}
}
catch (Exception ex)
{
}
}
Response.Redirect("index.aspx");
}
else
@@ -451,6 +398,8 @@ public partial class admin_activity_reg : MyWeb.config
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);
}
@@ -470,8 +419,85 @@ 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
}
+538 -153
View File
@@ -116,14 +116,6 @@
vuetify: new Vuetify(vuetify_options),
data() {
return {
init_is_auto_enroll: false,
is_auto_enroll: false,
auto_enroll_date: '',
auto_enroll_config: {
is_receipt: true, // 是否寄送收據
receipt_title: '', // 收據抬頭
receipt_address: '', // 收據地址
},
last_confirmed_date: '',
tabArray: tabtmp,
tabArray2: "",
@@ -142,6 +134,8 @@
title: '',
desc: '',
orders: [],
pendingData: null,
pendingDeleteItem: null,
btn_cancel_text: '', // 「取消報名」按鈕文字
btn_keep_text: '' // 「保留活動」按鈕文字
},
@@ -475,6 +469,56 @@
{ text: '', value: 'actions', sortable: false, width: "100px" },
],
},
// 全年報名表格
auto_enroll: {
headers: [
{ text: '開始日期(西元)', value: 'auto_enroll_start_date', sortable: false },
{ text: '結束日期(西元)', value: 'auto_enroll_end_date', sortable: false },
{ text: '收據抬頭', value: 'auto_enroll_receipt_title', sortable: false },
{ text: '收據地址', value: 'auto_enroll_receipt_address', sortable: false },
{ text: '狀態', value: 'auto_enroll_status', sortable: false },
{ text: '', value: 'actions', sortable: false, width: "150px" },
],
items: [],
editedIndex: -1,
editedItem: {
num: 0,
auto_enroll_start_date: '',
auto_enroll_end_date: '',
auto_enroll_receipt_title: '',
auto_enroll_receipt_address: '',
},
defaultItem: {
num: 0,
auto_enroll_start_date: '',
auto_enroll_end_date: '',
auto_enroll_receipt_title: '',
auto_enroll_receipt_address: '',
},
search:""
},
unfilled_dialog: {
show: false,
headers: [
{ text: '報名單號', value: 'order_no', sortable: false },
{ text: '活動分類', value: 'category', sortable: false },
{ text: '活動名稱', value: 'activityname', sortable: false },
{ text: '開始日期', value: 'startdate', sortable: false },
{ text: '結束日期', value: 'enddate', sortable: false },
],
items: [],
footer: {
showFirstLastPage: true,
disableItemsPerPage: true,
itemsPerPageAllText: '',
itemsPerPageText: '',
current_item: null,
},
count: 0,
page: 1,
pageSize: 10,
loading: false,
},
cityOptions: [], // 城市選項
areaOptions: {}, // 區域選項
//天干地支:甲子, 乙丑...
@@ -507,15 +551,6 @@
}
},
mounted() {
//一開始就載入
this.$nextTick(() => {
this.auto_enroll_date = document.getElementById('<%= hid_auto_enroll_start_date.ClientID %>').value;
this.is_auto_enroll = (document.getElementById('<%= hid_is_auto_enroll.ClientID %>').value.toLowerCase() === "true");
this.init_is_auto_enroll = this.is_auto_enroll;
this.auto_enroll_config.is_receipt = (document.getElementById('<%= hid_auto_enroll_is_receipt.ClientID %>').value.toLowerCase() === "true");
this.auto_enroll_config.receipt_title = document.getElementById('<%= hid_auto_enroll_receipt_title.ClientID %>').value;
this.auto_enroll_config.receipt_address = document.getElementById('<%= hid_auto_enroll_receipt_address.ClientID %>').value;
})
this.search_dialog.current = this.search_dialog.controls.search1 ///default
//console.log("mounted");
//this.initialize();
@@ -524,32 +559,9 @@
this.getFamilyMembers();
this.getCityOptions();
this.onCityChange();
this.initAutoEnroll();
},
watch: {
auto_enroll_config: {
handler(newVal) {
document.getElementById('<%= hid_auto_enroll_is_receipt.ClientID %>').value = newVal.is_receipt;
document.getElementById('<%= hid_auto_enroll_receipt_title.ClientID %>').value = newVal.receipt_title;
document.getElementById('<%= hid_auto_enroll_receipt_address.ClientID %>').value = newVal.receipt_address;
},
deep: true,
},
is_auto_enroll(newVal, oldVal) {
if (newVal === true) {
if (!this.auto_enroll_date) {
this.auto_enroll_date = new Date().toISOString().substr(0, 10);
this.last_confirmed_date = this.auto_enroll_date;
}
} else {
if (this.init_is_auto_enroll === true) {
this.open_confirm_dialog('CANCEL_AUTO_ENROLL');
}
}
document.getElementById('<%=hid_is_auto_enroll.ClientID%>').value = newVal;
},
auto_enroll_date(newVal) {
document.getElementById('<%=hid_auto_enroll_start_date.ClientID%>').value = newVal;
},
options: {
handler() {
//console.log("watch1", this.search_dialog, this.search_dialog.page);
@@ -591,57 +603,322 @@
}
},
methods: {
initAutoEnroll() {
if (this.follower_id != '') {
axios.get(HTTP_HOST + `api/follower/GetAutoEnrollList/${this.follower_id}`)
.then(response => {
this.auto_enroll.items = response.data.list.map(item => ({
...item,
id: item.num
}));
})
}
},
// 取得報名狀態
getEnrollStatus(item) {
const today = new Date();
today.setHours(0, 0, 0, 0);
const start = new Date(item.auto_enroll_start_date);
const end = new Date(item.auto_enroll_end_date);
if (today < start) return { label: '未開始', color: 'blue lighten-4', textColor: 'blue darken-3' };
if (today > end) return { label: '已結束', color: 'grey lighten-2', textColor: 'grey darken-2' };
return { label: '報名中', color: 'green lighten-4', textColor: 'green darken-3' };
},
// 新增
auto_enroll_add() {
if (this.auto_enroll.editedIndex !== -1) return;
const newItem = {
...this.auto_enroll.defaultItem,
id: -Date.now()
};
this.auto_enroll.items.unshift(newItem);
this.auto_enroll.editedItem = { ...newItem };
this.auto_enroll.editedIndex = 0;
},
// 編輯
auto_enroll_edit(item) {
this.auto_enroll.editedIndex = this.auto_enroll.items.indexOf(item);
this.auto_enroll.editedItem = { ...item };
},
// 取消
auto_enroll_cancel() {
// 若是新增的空白列,取消時移除
const item = this.auto_enroll.items[this.auto_enroll.editedIndex];
if (item && !item.auto_enroll_start_date && !item.auto_enroll_end_date) {
this.auto_enroll.items.splice(this.auto_enroll.editedIndex, 1);
}
this.auto_enroll.editedItem = { ...this.auto_enroll.defaultItem };
this.auto_enroll.editedIndex = -1;
},
// 儲存
auto_enroll_save() {
const { id, num, auto_enroll_start_date, auto_enroll_end_date, auto_enroll_receipt_title, auto_enroll_receipt_address } = this.auto_enroll.editedItem;
if (!auto_enroll_start_date || !auto_enroll_end_date) {
alert('請填寫開始與結束日期');
return;
}
if (auto_enroll_start_date > auto_enroll_end_date) {
alert('開始日期不可晚於結束日期');
return;
}
// 檢查是否與其他列日期重疊
const isOverlap = this.auto_enroll.items.some(item => {
if (item.id === id) return false; // 跳過自己
const existStart = item.auto_enroll_start_date;
const existEnd = item.auto_enroll_end_date;
return auto_enroll_start_date <= existEnd && auto_enroll_end_date >= existStart;
});
if (isOverlap) {
alert('此報名期間與現有資料重疊,請重新確認日期');
return;
}
var auto_enroll =
{
num: num,
f_num: Number('<%= Request["num"] %>'),
start_date: auto_enroll_start_date,
end_date: auto_enroll_end_date,
receipt_title: auto_enroll_receipt_title,
receipt_address: auto_enroll_receipt_address,
}
this.open_confirm_dialog(auto_enroll);
//axios.post(HTTP_HOST + 'api/follower/SaveAutoEnrollList', auto_enroll)
// .then(response => {
// const savedData = response.data;
// const updatedItem = {
// ...this.auto_enroll.editedItem,
// num: Number(savedData.num),
// id: Number(savedData.num),
// auto_enroll_start_date: savedData.start_date,
// auto_enroll_end_date: savedData.end_date,
// auto_enroll_receipt_title: savedData.receipt_title,
// auto_enroll_receipt_address: savedData.receipt_address,
// };
// this.$set(this.auto_enroll.items, this.auto_enroll.editedIndex, updatedItem);
// this.auto_enroll.editedItem = { ...this.auto_enroll.defaultItem };
// this.auto_enroll.editedIndex = -1;
// })
},
// 刪除
auto_enroll_delete(item) {
// 先查受影響訂單
axios.post(HTTP_HOST + 'api/follower/GetAffectedOrders', {
num: item.num,
f_num: Number('<%= Request["num"] %>'),
start_date: item.auto_enroll_start_date,
end_date: item.auto_enroll_end_date,
}, {
params: { is_delete: true }
})
.then(response => {
this.confirm_dialog.pendingData = null;
this.confirm_dialog.pendingDeleteItem = item;
if (response.data.list.length > 0) {
this.confirm_dialog.orders = response.data.list;
this.confirm_dialog.title = "刪除全年報名";
this.confirm_dialog.desc = "刪除後,以下已報名的活動是否一併取消?";
this.confirm_dialog.btn_keep_text = "保留現有活動";
this.confirm_dialog.btn_cancel_text = "取消全部活動";
this.confirm_dialog.show = true;
} else {
this.doDelete(item);
}
})
},
doDelete(item) {
axios.delete(HTTP_HOST + `api/follower/DeleteAutoEnroll/${item.num}`)
.then(() => {
const index = this.auto_enroll.items.indexOf(item);
this.auto_enroll.items.splice(index, 1);
this.confirm_dialog.pendingDeleteItem = null; // 清空暫存
})
.catch(error => {
console.log("刪除失敗", error);
this.snackbar.text = "刪除失敗:" + error;
this.snackbar.show = true;
})
},
// 顯示尚未填寫項目的活動
unfilled_dialog_show(item) {
this.unfilled_dialog.current_item = item;
this.unfilled_dialog.page = 1;
this.unfilled_dialog.show = true;
this.unfilled_dialog_load();
},
unfilled_dialog_load() {
const item = this.unfilled_dialog.current_item;
const { page, pageSize, sortBy, sortDesc } = this.unfilled_dialog;
this.unfilled_dialog.loading = true;
axios
.get(HTTP_HOST + `api/follower/GetUnfilledActivityOrders/${item.num}`, {
params: {
page,
pageSize,
sortBy: Array.isArray(sortBy) ? sortBy[0] : sortBy,
sortDesc: Array.isArray(sortDesc) ? sortDesc[0] : sortDesc
}
})
.then(response => {
this.unfilled_dialog.items = response.data.list;
this.unfilled_dialog.count = response.data.count;
})
.finally(() => {
this.unfilled_dialog.loading = false;
});
},
// 列印
async exportUnfilledOrders() {
const item = this.unfilled_dialog.current_item;
// 取得全部資料
const response = await axios.get(
HTTP_HOST + `api/follower/GetUnfilledActivityOrders/${item.num}`,
{ params: { page: 1, pageSize: 99999 } }
);
const allItems = response.data.list;
const fullTitle = this.titleword();
const infoParts = fullTitle.split(' ');
const followerNum = infoParts[0] || "未知編號";
const followerName = infoParts[1] ? infoParts[1].split('')[0] : "未知姓名";
const rows = allItems.map(item => `
<tr>
<td>${item.order_no}</td>
<td>${item.category}</td>
<td>${item.activityname}</td>
<td>${item.startdate?.substring(0, 10)}</td>
<td>${item.enddate?.substring(0, 10)}</td>
</tr>
`).join('');
const win = window.open('', '_blank');
win.document.write(`
<html>
<head>
<title>未填寫品項活動 - ${followerName}</title>
<style>
body { font-family: "Microsoft JhengHei", Arial, sans-serif; padding: 20px; }
h2 { text-align: center; margin-bottom: 10px; }
.info-header { text-align: center; margin-bottom: 20px; font-size: 16px; border-bottom: 1px solid #eee; padding-bottom: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { border: 1px solid #666; padding: 8px; text-align: left; }
th { background-color: #f2f2f2; }
</style>
</head>
<body>
<h2>未填寫品項之活動清單</h2>
<div class="info-header">
信眾編號:<strong>${followerNum}</strong> &nbsp;&nbsp;
信眾姓名:<strong>${followerName}</strong>
</div>
<table>
<thead>
<tr>
<th>報名單號</th>
<th>活動分類</th>
<th>活動名稱</th>
<th>開始日期</th>
<th>結束日期</th>
</tr>
</thead>
<tbody>${rows}</tbody>
</table>
</body>
</html>
`);
win.document.close();
win.print();
win.close();
},
syncAddress() {
const sourceAddr = document.getElementById('<%=address.ClientID%>').value;
this.auto_enroll_config.receipt_address = sourceAddr;
},
open_confirm_dialog(type) {
const targetDate = (type === 'CANCEL_AUTO_ENROLL') ? '2099-12-31' : this.auto_enroll_date;
api_url = 'api/follower/pending_orders?id=' + '<%= Request["num"] %>' + '&targetDate=' + targetDate;
if (type === "CANCEL_AUTO_ENROLL") {
axios
.post(HTTP_HOST + api_url)
.then(response => {
open_confirm_dialog(auto_enroll) {
if (auto_enroll.num == 0) {
this.doSave(auto_enroll);
return;
}
// 受影響訂單
axios.post(HTTP_HOST + 'api/follower/GetAffectedOrders', auto_enroll)
.then(response => {
this.confirm_dialog.pendingData = auto_enroll;
if (response.data.list.length > 0) {
this.confirm_dialog.orders = response.data.list;
this.confirm_dialog.title = "取消自動報名";
this.confirm_dialog.desc = "以下活動已報名,是否一併取消?";
this.confirm_dialog.title = "受影響的已報名活動";
this.confirm_dialog.desc = "修改報名期間後,以下活動將不在新範圍內,是否一併取消?";
this.confirm_dialog.btn_keep_text = "保留現有活動";
this.confirm_dialog.btn_cancel_text = "取消全部活動";
this.confirm_dialog.btn_keep_text = "保留現有活動";
const orderNos = this.confirm_dialog.orders.map(o => o.orderno).join(',');
document.getElementById('<%= hid_delete_order_list.ClientID %>').value = orderNos;
if (this.confirm_dialog.orders.length > 0) this.confirm_dialog.show = true;
})
}
else if (type === "UPDATE_START_DATE") {
axios
.post(HTTP_HOST + api_url)
.then(response => {
this.confirm_dialog.orders = response.data.list;
this.confirm_dialog.title = "生效日期延後確認";
this.confirm_dialog.desc = "以下活動已報名,是否一併取消?";
this.confirm_dialog.btn_cancel_text = "取消活動";
this.confirm_dialog.btn_keep_text = "保留現有活動";
const orderNos = this.confirm_dialog.orders.map(o => o.orderno).join(',');
document.getElementById('<%= hid_delete_order_list.ClientID %>').value = orderNos;
if (this.confirm_dialog.orders.length > 0) this.confirm_dialog.show = true;
})
}
this.confirm_dialog.show = true;
} else {
this.doSave(auto_enroll);
}
})
},
doSave(auto_enroll) {
axios.post(HTTP_HOST + 'api/follower/SaveAutoEnrollList', auto_enroll)
.then(response => {
const savedData = response.data;
const updatedItem = {
...this.auto_enroll.editedItem,
num: Number(savedData.num),
id: Number(savedData.num),
auto_enroll_start_date: savedData.start_date,
auto_enroll_end_date: savedData.end_date,
auto_enroll_receipt_title: savedData.receipt_title,
auto_enroll_receipt_address: savedData.receipt_address,
};
this.$set(this.auto_enroll.items, this.auto_enroll.editedIndex, updatedItem);
this.auto_enroll.editedItem = { ...this.auto_enroll.defaultItem };
this.auto_enroll.editedIndex = -1;
this.confirm_dialog.pendingData = null;
})
},
close_confirm_dialog() {
this.auto_enroll_date = this.last_confirmed_date;
if (!this.is_auto_enroll)this.is_auto_enroll = true;
this.confirm_dialog.show = false;
},
keep_auto_enroll_order() {
document.getElementById('<%= hid_is_delete_all_order.ClientID %>').value = "false";
this.last_confirmed_date = this.auto_enroll_date;
this.confirm_dialog.show = false;
if (this.confirm_dialog.pendingData) {
this.doSave(this.confirm_dialog.pendingData);
} else if (this.confirm_dialog.pendingDeleteItem) {
this.doDelete(this.confirm_dialog.pendingDeleteItem);
}
},
delete_auto_enroll_order() {
document.getElementById('<%= hid_is_delete_all_order.ClientID %>').value = "true";
console.log("TRUE");
this.last_confirmed_date = this.auto_enroll_date;
this.confirm_dialog.show = false;
const orderNos = this.confirm_dialog.orders.map(o => o.order_no);
if (orderNos.length === 0) return;
const numsString = orderNos.join(',')
axios.delete(HTTP_HOST + `api/order/DeleteAll/${numsString}`)
.then(() => {
if (this.confirm_dialog.pendingData) {
this.doSave(this.confirm_dialog.pendingData);
} else if (this.confirm_dialog.pendingDeleteItem) {
this.doDelete(this.confirm_dialog.pendingDeleteItem);
}
})
.catch(error => {
console.log("刪除訂單失敗", error);
this.snackbar.text = "刪除訂單失敗:" + error;
this.snackbar.show = true;
})
},
search_show(curr) {
console.log("btn_click:", curr, curr.api_url);
@@ -1446,7 +1723,6 @@
</script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="page_nav" runat="Server">
<asp:HiddenField ID="hid_delete_order_list" runat="server" />
<div class="scroll-nav nav nav-tabs mb-2 mb-sm-0 d-none d-sm-flex">
<template v-if="follower_id !='' "> {{titleword()}} </template>
</div>
@@ -1487,6 +1763,9 @@
<button class="nav-link" id="sec2-tab4" data-bs-toggle="tab" data-bs-target="#sec2-page4"
type="button" role="tab" aria-controls="profile" aria-selected="false">
牌位標題 </button>
<button class="nav-link" id="sec2-tab5" data-bs-toggle="tab" data-bs-target="#sec2-page5"
type="button" role="tab" aria-controls="profile" aria-selected="false">
全年報名 </button>
</div>
</nav>
</div>
@@ -1671,93 +1950,32 @@
<asp:RegularExpressionValidator ControlToValidate="contactor_phone" ErrorMessage="格式有誤" ID="RegularExpressionValidator3" runat="server" ValidationExpression="^[+-]?\d+([+-]?\d*)*$" Display="Dynamic" SetFocusOnError="true" />
</div>
</div>
<div class="row mb-1 label-sm-right">
<div class="col-sm-2 col-lg-1 d-flex align-center justify-content-end pr-2">
<input type="checkbox"
v-model="is_auto_enroll"
style="width: 18px; height: 18px; cursor: pointer;"
class="mr-2">
<label class="col-form-label">全年報名</label>
<asp:HiddenField ID="hid_is_auto_enroll" runat="server" Value="false" />
<asp:HiddenField ID="hid_is_delete_all_order" runat="server" Value="false" />
</div>
<label class="col-sm-2 col-lg-1 col-form-label">自訂標籤</label>
<div class="col-sm-10 col-lg-3">
<input ID="auto_enroll_start_date" type="date"
class="form-control"
v-model="auto_enroll_date"
:disabled="!is_auto_enroll"
@change="open_confirm_dialog('UPDATE_START_DATE')">
<asp:HiddenField ID="hid_auto_enroll_start_date" runat="server" Value="" />
<small class="text-muted" v-if="is_auto_enroll">請設定生效日期</small>
</div>
<label class="col-sm-2 col-lg-1 col-form-label text-right">自訂標籤</label>
<div class="col-sm-4 col-lg-3">
<div class="input-group">
<div class="input-group">
<input type="text" class="form-control" v-model="tabArray2" v-on:keyup.enter="addTab" title="可自由輸入標籤名稱,輸入完成請按「+」,或「Enter」" placeholder="自訂標籤名稱">
<asp:HiddenField ID="tab" runat="server" />
<div class="input-group-append">
<button type="button" class="btn btn-default" @click="addTab"><i class="mdi mdi-plus"></i></button>
</div>
</div>
<a class="btn btn-default" @click="addTab" ><i class="mdi mdi-plus"></i></a>
</div>
</div>
<div class="col-sm-12 col-lg-4">
<template>
<div class="">
<div class="col-sm-12 col-lg-7">
<template>
<div class="">
<v-chip v-for="item,index in tabArray"
v-if="item != ''"
class="ma-2"
close
@click:close="tabArray.splice(index, 1);remove(item)"
class="ma-2"
close
@click:close="tabArray.splice(index, 1);remove(item)"
>
{{item}}
{{item}}
</v-chip>
</div>
</template>
</div>
</template>
</div>
</div>
<v-expand-transition>
<div v-show="is_auto_enroll" class="row rounded grey lighten-4 border py-4">
<div class="row mb-1 label-sm-right">
<div class="col-sm-2 col-lg-1 d-flex align-center justify-content-end pr-2">
<input type="checkbox" v-model="auto_enroll_config.is_receipt" style="width:18px; height:18px; cursor: pointer;" class="mr-2">
<label class="col-form-label">寄送收據</label>
<asp:HiddenField ID="hid_auto_enroll_is_receipt" runat="server" />
</div>
<div class="col-sm-12 col-lg-3">
<input type="text" class="form-control"
placeholder="收據抬頭" v-model="auto_enroll_config.receipt_title" :disabled="!auto_enroll_config.is_receipt">
<asp:HiddenField ID="hid_auto_enroll_receipt_title" runat="server" />
</div>
<div class="col-sm-12 col-lg-6">
<div class="input-group mb-3">
<input type="text" class="form-control"
placeholder="收據地址" v-model="auto_enroll_config.receipt_address" :disabled="!auto_enroll_config.is_receipt">
<asp:HiddenField ID="hid_auto_enroll_receipt_address" runat="server" />
<button class="btn btn-outline-secondary" type="button" @click="syncAddress" :disabled="!auto_enroll_config.is_receipt">同收件地址</button>
</div>
</div>
</div>
<div class="py-1 px-8 mb-2 text-muted" style="font-size: 0.85rem; line-height: 1.5;">
<div class="font-weight-bold mb-1">
<v-icon small color="info" class="mr-1">mdi-information</v-icon> 自動報名須知:
</div>
<ul class="pl-4 mb-0">
<li><strong>生效範疇:</strong>此處修改僅影響<strong>往後</strong>產生的訂單;既有訂單請至「報名管理」手動調整。</li>
<li><strong>品項帶入:</strong>系統將自動沿用該信眾<strong>距今最近一次</strong>的報名品項(若無歷史紀錄則不自動帶入)。</li>
</ul>
</div>
</div>
</v-expand-transition>
<div class="row mb-1">
<label class="col-form-label">備註</label>
<div class="">
@@ -2145,9 +2363,176 @@
</v-data-table>
</v-card>
</div>
<div class="tab-pane fade" id="sec2-page5" role="tabpanel" aria-labelledby="sec2-tab5" >
<v-card class="mx-auto" outlined v-if="follower_id!=''">
<v-data-table class="elevation-1" fixed-header
:headers="auto_enroll.headers"
:items="auto_enroll.items"
:search="auto_enroll.search">
<v-divider inset></v-divider>
<template v-slot:top>
<v-toolbar flat color="transparent" class="row ms-0">
<div class="col-12 col-md-10 d-flex">
<v-text-field
v-model="auto_enroll.search"
append-icon="mdi-magnify"
label="查詢"
dense
outlined
single-line
hide-details>
</v-text-field>
<v-btn
color="primary"
class="ml-2 white--text "
title="新增全年報名"
@click="auto_enroll_add">
<v-icon dark>mdi-plus</v-icon>新增
</v-btn>
</div>
</v-toolbar>
</template>
<!-- 編輯中 -->
<template v-slot:item.auto_enroll_start_date="{ item }">
<template v-if="item.id === auto_enroll.editedItem.id">
<v-text-field
v-model="auto_enroll.editedItem.auto_enroll_start_date"
type="date"
dense
hide-details
outlined>
</v-text-field>
</template>
<template v-else>
{{ item.auto_enroll_start_date }}
</template>
</template>
<template v-slot:item.auto_enroll_end_date="{ item }">
<template v-if="item.id === auto_enroll.editedItem.id">
<v-text-field
v-model="auto_enroll.editedItem.auto_enroll_end_date"
type="date"
dense
hide-details
outlined>
</v-text-field>
</template>
<template v-else>
{{ item.auto_enroll_end_date }}
</template>
</template>
<template v-slot:item.auto_enroll_receipt_title="{ item }">
<template v-if="item.id === auto_enroll.editedItem.id">
<v-text-field
v-model="auto_enroll.editedItem.auto_enroll_receipt_title"
dense
hide-details
outlined
placeholder="請輸入收據抬頭">
</v-text-field>
</template>
<template v-else>
{{ item.auto_enroll_receipt_title }}
</template>
</template>
<template v-slot:item.auto_enroll_receipt_address="{ item }">
<template v-if="item.id === auto_enroll.editedItem.id">
<v-text-field
v-model="auto_enroll.editedItem.auto_enroll_receipt_address"
dense
hide-details
outlined
placeholder="請輸入收據地址">
</v-text-field>
</template>
<template v-else>
{{ item.auto_enroll_receipt_address }}
</template>
</template>
<!-- 狀態欄位 -->
<template v-slot:item.auto_enroll_status="{ item }">
<v-chip
small
:color="getEnrollStatus(item).color"
:text-color="getEnrollStatus(item).textColor"
class="font-weight-medium">
{{ getEnrollStatus(item).label }}
</v-chip>
</template>
<!-- 操作欄位 -->
<template v-slot:item.actions="{ item }">
<template v-if="item.id === auto_enroll.editedItem.id">
<v-icon color="red" class="mr-2" @click="auto_enroll_cancel">
mdi-window-close
</v-icon>
<v-icon color="green" class="mr-2" @click="auto_enroll_save">
mdi-content-save
</v-icon>
</template>
<template v-else>
<v-icon color="green" class="mr-2" @click="auto_enroll_edit(item)">
mdi-pencil
</v-icon>
<v-icon color="red" class="mr-2" @click="auto_enroll_delete(item)">
mdi-delete
</v-icon>
<v-icon color="blue" class="mr-2" @click="unfilled_dialog_show(item)" title="查看未填寫品項活動">
mdi-file-find
</v-icon>
</template>
</template>
</v-data-table>
</v-card>
</div>
</div>
</asp:Panel>
</div>
<!-- 顯示沒有品項的活動 -->
<v-dialog v-model="unfilled_dialog.show" max-width="900px">
<v-card>
<v-card-title class="headline grey lighten-2">
未填寫品項的活動
<v-spacer></v-spacer>
<v-btn icon @click="unfilled_dialog.show = false"><v-icon>mdi-close</v-icon></v-btn>
</v-card-title>
<v-card-text>
<v-data-table
:headers="unfilled_dialog.headers"
:items="unfilled_dialog.items"
:footer-props="unfilled_dialog.footer"
:items-per-page="unfilled_dialog.pageSize"
:server-items-length="unfilled_dialog.count"
:page.sync="unfilled_dialog.page"
:loading="unfilled_dialog.loading"
@update:page="unfilled_dialog_load"
>
</v-data-table>
</v-card-text>
<v-card-actions class="justify-center pb-6">
<v-btn
color="primary"
:disabled="unfilled_dialog.items.length == 0"
class="px-4"
@click="exportUnfilledOrders">
<v-icon left>mdi-printer</v-icon>
列印
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<!-- Family Member Dialog -->
<v-dialog v-model="family.dialog" max-width="600px">
<v-card>
@@ -2354,7 +2739,7 @@
<v-data-table
:headers="confirm_dialog.headers"
:items="confirm_dialog.orders"
:items-per-page="5"
:items-per-page="10"
class="elevation-1 grey lighten-5"
:footer-props="{
'items-per-page-text': '每頁顯示',
+10 -392
View File
@@ -155,31 +155,6 @@ public partial class admin_follower_reg : MyWeb.config
modify_time.Text = prod.admin_log;
}
if (!isStrNull(prod.is_auto_enroll))
{
hid_is_auto_enroll.Value = prod.is_auto_enroll.ToString();
}
if (prod.auto_enroll_start_date.HasValue)
{
hid_auto_enroll_start_date.Value = prod.auto_enroll_start_date.Value.ToString("yyyy-MM-dd");
}
if (prod.auto_enroll_is_receipt.HasValue)
{
hid_auto_enroll_is_receipt.Value = prod.auto_enroll_is_receipt.ToString();
}
if (!isStrNull(prod.auto_enroll_receipt_title))
{
hid_auto_enroll_receipt_title.Value = prod.auto_enroll_receipt_title.ToString();
}
if (!isStrNull(prod.auto_enroll_receipt_address))
{
hid_auto_enroll_receipt_address.Value = prod.auto_enroll_receipt_address.ToString();
}
edit.Visible = true;
goback.Visible = true;
add.Visible = false;
@@ -292,77 +267,12 @@ public partial class admin_follower_reg : MyWeb.config
//tab
followers.tab = tab.Value.Trim(',');
if (!isStrNull(hid_is_auto_enroll.Value)) followers.is_auto_enroll = hid_is_auto_enroll.Value == "true";
if (!isStrNull(hid_auto_enroll_start_date.Value)) followers.auto_enroll_start_date = Convert.ToDateTime(hid_auto_enroll_start_date.Value);
if (!isStrNull(hid_auto_enroll_is_receipt.Value)) followers.auto_enroll_is_receipt = hid_auto_enroll_is_receipt.Value == "true";
if (!isStrNull(hid_auto_enroll_receipt_title.Value)) followers.auto_enroll_receipt_title = hid_auto_enroll_receipt_title.Value;
if (!isStrNull(hid_auto_enroll_receipt_address.Value)) followers.auto_enroll_receipt_address = hid_auto_enroll_receipt_address.Value;
string ChkNewMsg = Model.follower.ChkNewFollower(followers);
if(string.IsNullOrEmpty(ChkNewMsg))
{
_db.followers.Add(followers);
_db.SaveChanges();
if (hid_is_auto_enroll.Value == "true")
{
// 信眾自動報名
var qry = _db.activities.Where(a => a.startDate_solar >= followers.auto_enroll_start_date).AsQueryable();
var activities = qry.ToList();
if (activities != null)
{
try
{
foreach (var activity in activities)
{
Model.pro_order pro_order = new Model.pro_order(); //新增
bool isRegistered = _db.pro_order.Any(x => x.f_num == followers.num && x.activity_num == activity.num);
if (isRegistered) continue; // 重複報名
pro_order.order_no = createOrderNumber();
pro_order.up_time = DateTime.Now;
pro_order.reg_time = DateTime.Now;
pro_order.keyin1 = "A01";
pro_order.f_num = followers.num;
if (!isStrNull(followers.phone)) { pro_order.phone = followers.phone; }
if (!isStrNull(followers.cellphone)) { pro_order.phone = followers.cellphone; }
if (IsNumeric(activity.num)) { pro_order.activity_num = activity.num; }
pro_order.address = isStrNull(followers.auto_enroll_receipt_address) ? "" : followers.auto_enroll_receipt_address;
pro_order.receipt_title = isStrNull(followers.auto_enroll_receipt_title) ? "" : followers.auto_enroll_receipt_title;
pro_order.send_receipt = isStrNull(followers.auto_enroll_is_receipt) ? false : followers.auto_enroll_is_receipt;
pro_order.demo = "";
pro_order.customize_data = "";
try
{
if (!isStrNull(pro_order.order_no))
{
_db.pro_order.Add(pro_order);
_db.SaveChanges();
Model.admin_log admin_log = new Model.admin_log();
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Order, (int)Model.admin_log.Status.Insert, pro_order.order_no);
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
}
//if (prod.Count > 0)
//{
// var orderNumbers = prod.Select(x => x.order_no).ToList();
// var qry = _db.pro_order_detail
// .Where(o => orderNumbers.Contains(o.order_no))
// }
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
}
}
int _id = followers.num;
@@ -421,10 +331,6 @@ public partial class admin_follower_reg : MyWeb.config
{
try
{
// 記錄修改前的舊值,供後續流程判斷
bool old_is_auto_enroll = followers.is_auto_enroll ?? false;
DateTime? old_auto_enroll_start_date = followers.auto_enroll_start_date;
foreach (Control obj in cardBodyPanel.Controls)
{
if (obj is TextBox)
@@ -454,294 +360,6 @@ public partial class admin_follower_reg : MyWeb.config
//followers.admin_log = admin.info.u_id + " " + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
followers.follower_hash = encrypt.followerHash(followers.phone, followers.id_code);
if (!isStrNull(hid_is_auto_enroll.Value)) followers.is_auto_enroll = hid_is_auto_enroll.Value == "true";
if (!isStrNull(hid_auto_enroll_start_date.Value)) followers.auto_enroll_start_date = Convert.ToDateTime(hid_auto_enroll_start_date.Value);
if (!isStrNull(hid_auto_enroll_is_receipt.Value)) followers.auto_enroll_is_receipt = hid_auto_enroll_is_receipt.Value == "true";
if (!isStrNull(hid_auto_enroll_receipt_title.Value)) followers.auto_enroll_receipt_title = hid_auto_enroll_receipt_title.Value;
if (!isStrNull(hid_auto_enroll_receipt_address.Value)) followers.auto_enroll_receipt_address = hid_auto_enroll_receipt_address.Value;
// is_auto_enroll 從關 → 開,執行自動報名
bool new_is_auto_enroll = followers.is_auto_enroll ?? false;
bool isAutoEnrollTurnedOn = !old_is_auto_enroll && new_is_auto_enroll;
bool isAutoEnrollTurnedOff = old_is_auto_enroll && !new_is_auto_enroll;
// auto_enroll_start_date 有變更,確認是否刪除已有訂單
bool isStartDateChanged = followers.auto_enroll_start_date != old_auto_enroll_start_date;
// 關 → 開,執行自動報名
if (isAutoEnrollTurnedOn)
{
var qry = _db.activities.Where(a => a.startDate_solar >= followers.auto_enroll_start_date).AsQueryable();
var latestOrder = _db.pro_order.Where(o => o.f_num == followers.num).OrderByDescending(o => o.order_no).FirstOrDefault(); // 最近一次訂單
var activities = qry.ToList();
if (activities != null)
{
try
{
foreach (var activity in activities)
{
Model.pro_order pro_order = new Model.pro_order(); //新增
bool isRegistered = _db.pro_order.Any(x => x.f_num == followers.num && x.activity_num == activity.num);
if (isRegistered) continue; // 重複報名
pro_order.order_no = createOrderNumber();
pro_order.up_time = DateTime.Now;
pro_order.reg_time = DateTime.Now;
pro_order.keyin1 = "A01";
pro_order.f_num = followers.num;
if (!isStrNull(followers.phone)) { pro_order.phone = followers.phone; }
if (!isStrNull(followers.cellphone)) { pro_order.phone = followers.cellphone; }
if (IsNumeric(activity.num)) { pro_order.activity_num = activity.num; }
pro_order.address = isStrNull(followers.auto_enroll_receipt_address) ? "" : followers.auto_enroll_receipt_address;
pro_order.receipt_title = isStrNull(followers.auto_enroll_receipt_title) ? "" : followers.auto_enroll_receipt_title;
pro_order.send_receipt = isStrNull(followers.auto_enroll_is_receipt) ? false : followers.auto_enroll_is_receipt;
pro_order.demo = "";
pro_order.customize_data = "";
try
{
if (!isStrNull(pro_order.order_no))
{
_db.pro_order.Add(pro_order);
_db.SaveChanges();
// 報名品項(最近一次訂單內容)
if (latestOrder != null)
{
var last_order_details = _db.pro_order_detail.Where(o => o.order_no == latestOrder.order_no).ToList();
foreach (var last_order_detail in last_order_details)
{
Model.pro_order_detail order_detail = new Model.pro_order_detail();
order_detail.order_no = pro_order.order_no;
order_detail.actItem = last_order_detail.actItem;
order_detail.parent_num = last_order_detail.parent_num;
order_detail.print_id = last_order_detail.print_id;
order_detail.f_num = last_order_detail.f_num;
order_detail.f_num_tablet = last_order_detail.f_num_tablet;
order_detail.address = last_order_detail.address;
order_detail.from_id = last_order_detail.from_id;
order_detail.from_id_tablet = last_order_detail.from_id_tablet;
order_detail.bed_type = last_order_detail.bed_type;
order_detail.qty = last_order_detail.qty;
order_detail.price = last_order_detail.price;
order_detail.start_date = DateTime.Today;
order_detail.pay = last_order_detail.pay;
order_detail.bed_type = last_order_detail.bed_type;
order_detail.keyin1 = last_order_detail.keyin1;
order_detail.demo = last_order_detail.demo;
order_detail.customize_data = last_order_detail.customize_data;
order_detail.printed_files = last_order_detail.printed_files;
order_detail.UpdateTime = DateTime.Now;
_db.pro_order_detail.Add(order_detail);
}
}
_db.SaveChanges();
Model.admin_log admin_log = new Model.admin_log();
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Order, (int)Model.admin_log.Status.Insert, pro_order.order_no);
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
}
// 開 → 關,刪除自動報名訂單
if (isAutoEnrollTurnedOff && hid_is_delete_all_order.Value == "true")
{
if (!string.IsNullOrEmpty(hid_delete_order_list.Value))
{
var ids = hid_delete_order_list.Value.TrimEnd(',').Split(',');
var prod = _db.pro_order.Where(q => ids.Contains(q.order_no)).ToList();
if (prod.Count() > 0)
{
var prod2 = _db.pro_order_detail.Where(q => ids.Contains(q.order_no)).ToList();
if (prod2.Count > 0)
{
foreach (var item2 in prod2)
{
var prod3 = _db.bed_order.Where(q => q.order_no == item2.order_no && q.o_detail_id == item2.num).ToList();
if (prod3.Count > 0)
{
foreach (var item3 in prod3)
{
var prod4 = _db.bed_order_detail.Where(q => q.bed_order_no == item3.bed_order_no).ToList();
if (prod4.Count > 0)
{
_db.bed_order_detail.RemoveRange(prod4);
}
}
_db.bed_order.RemoveRange(prod3);
}
}
_db.pro_order_detail.RemoveRange(prod2);
_db.SaveChanges();
}
_db.pro_order.RemoveRange(prod);
_db.SaveChanges();
Model.admin_log admin_log = new Model.admin_log();
if (admin.isLoign())
{
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Order, (int)Model.admin_log.Status.Delete, admin_log.LogViewBtn(prod.Select(x => x.order_no).ToList()));
}
}
}
}
if (isStartDateChanged && old_auto_enroll_start_date.HasValue && !isAutoEnrollTurnedOff)
{
bool isDateMovedLater = followers.auto_enroll_start_date > old_auto_enroll_start_date; // 變晚
bool isDateMovedEarlier = followers.auto_enroll_start_date < old_auto_enroll_start_date; // 變早
// 日期變晚,刪除指定訂單
if (isDateMovedLater && hid_is_delete_all_order.Value == "true")
{
if (!string.IsNullOrEmpty(hid_delete_order_list.Value))
{
var ids = hid_delete_order_list.Value.TrimEnd(',').Split(',');
var prod = _db.pro_order.Where(q => ids.Contains(q.order_no)).ToList();
if (prod.Count() > 0)
{
//var prod2 = _db.pro_order_detail.ToList().Where(q => ids.Contains(Convert.ToString(q.order_no))).ToList();
var prod2 = _db.pro_order_detail.Where(q => ids.Contains(q.order_no)).ToList();
if (prod2.Count > 0)
{
foreach (var item2 in prod2)
{
var prod3 = _db.bed_order.Where(q => q.order_no == item2.order_no && q.o_detail_id == item2.num).ToList();
if (prod3.Count > 0)
{
foreach (var item3 in prod3)
{
var prod4 = _db.bed_order_detail.Where(q => q.bed_order_no == item3.bed_order_no).ToList();
if (prod4.Count > 0)
{
_db.bed_order_detail.RemoveRange(prod4);
}
}
_db.bed_order.RemoveRange(prod3);
}
}
_db.pro_order_detail.RemoveRange(prod2);
_db.SaveChanges();
}
_db.pro_order.RemoveRange(prod);
_db.SaveChanges();
Model.admin_log admin_log = new Model.admin_log();
if (admin.isLoign())
{
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Order, (int)Model.admin_log.Status.Delete, admin_log.LogViewBtn(prod.Select(x => x.order_no).ToList()));
}
}
}
}
// 日期變早,補報名
else if (isDateMovedEarlier && !isAutoEnrollTurnedOn)
{
var qry = _db.activities.Where(a =>
a.startDate_solar >= followers.auto_enroll_start_date &&
a.startDate_solar < old_auto_enroll_start_date);
var latestOrder = _db.pro_order.Where(o => o.f_num == followers.num).OrderByDescending(o => o.order_no).FirstOrDefault(); // 最近一次訂單
var activities = qry.ToList();
if (activities != null)
{
try
{
foreach (var activity in activities)
{
Model.pro_order pro_order = new Model.pro_order(); //新增
bool isRegistered = _db.pro_order.Any(x => x.f_num == followers.num && x.activity_num == activity.num);
if (isRegistered) continue; // 重複報名
pro_order.order_no = createOrderNumber();
pro_order.up_time = DateTime.Now;
pro_order.reg_time = DateTime.Now;
pro_order.keyin1 = "A01";
pro_order.f_num = followers.num;
if (!isStrNull(followers.phone)) { pro_order.phone = followers.phone; }
if (!isStrNull(followers.cellphone)) { pro_order.phone = followers.cellphone; }
if (IsNumeric(activity.num)) { pro_order.activity_num = activity.num; }
pro_order.address = isStrNull(followers.auto_enroll_receipt_address) ? "" : followers.auto_enroll_receipt_address;
pro_order.receipt_title = isStrNull(followers.auto_enroll_receipt_title) ? "" : followers.auto_enroll_receipt_title;
pro_order.send_receipt = isStrNull(followers.auto_enroll_is_receipt) ? false : followers.auto_enroll_is_receipt;
pro_order.demo = "";
pro_order.customize_data = "";
try
{
if (!isStrNull(pro_order.order_no))
{
_db.pro_order.Add(pro_order);
_db.SaveChanges();
// 報名品項(最近一次訂單內容)
if (latestOrder != null)
{
var last_order_details = _db.pro_order_detail.Where(o => o.order_no == latestOrder.order_no).ToList();
foreach (var last_order_detail in last_order_details)
{
Model.pro_order_detail order_detail = new Model.pro_order_detail();
order_detail.order_no = pro_order.order_no;
order_detail.actItem = last_order_detail.actItem;
order_detail.parent_num = last_order_detail.parent_num;
order_detail.print_id = last_order_detail.print_id;
order_detail.f_num = last_order_detail.f_num;
order_detail.f_num_tablet = last_order_detail.f_num_tablet;
order_detail.address = last_order_detail.address;
order_detail.from_id = last_order_detail.from_id;
order_detail.from_id_tablet = last_order_detail.from_id_tablet;
order_detail.bed_type = last_order_detail.bed_type;
order_detail.qty = last_order_detail.qty;
order_detail.price = last_order_detail.price;
order_detail.start_date = DateTime.Today;
order_detail.pay = last_order_detail.pay;
order_detail.bed_type = last_order_detail.bed_type;
order_detail.keyin1 = last_order_detail.keyin1;
order_detail.demo = last_order_detail.demo;
order_detail.customize_data = last_order_detail.customize_data;
order_detail.printed_files = last_order_detail.printed_files;
order_detail.UpdateTime = DateTime.Now;
_db.pro_order_detail.Add(order_detail);
}
}
_db.SaveChanges();
Model.admin_log admin_log = new Model.admin_log();
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Order, (int)Model.admin_log.Status.Insert, pro_order.order_no);
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
}
}
// 如果啟用 search_keywords 功能,生成並更新 search_keywords
if (GlobalVariables.UseSearchKeywords)
{
@@ -806,16 +424,16 @@ public partial class admin_follower_reg : MyWeb.config
L_msg.Type = alert_type.danger;
L_msg.Text = "查無資料";
}
/*
if (chk_pro_num(f_number.Text, Val(Request["num"])))
{
}
else
{
L_msg.Type = alert_type.danger;
L_msg.Text = "信眾編號重複";
}
*/
/*
if (chk_pro_num(f_number.Text, Val(Request["num"])))
{
}
else
{
L_msg.Type = alert_type.danger;
L_msg.Text = "信眾編號重複";
}
*/
}
}
+86
View File
@@ -0,0 +1,86 @@
###### **FK 規則更新**
FK\_act\_bom\_actItem1 刪除規則設為 cascade
FK\_pro\_order\_followers 刪除規則設為 cascade
FK\_pro\_order\_activity 刪除規則設為 cascade
FK\_pro\_order\_detail\_pro\_order 刪除規則設為 cascade
FK\_pro\_order\_detail\_followers 刪除規則設為 沒有動作
FK\_activity\_relating\_activity 刪除規則設為 cascade
FK\_pro\_order\_auto\_enroll 刪除規則設為 NULL
###### **資料表欄位更新**
actitem 加上 sort\_order(int) 欄位
activity\_relating 加上 has\_yang\_limit(bit) 欄位
activity\_relating 加上 has\_chao\_limit(bit) 欄位
activity\_relating 加上 yang\_limit\_count(int) 欄位
activity\_relating 加上 chao\_limit\_count(int) 欄位
\## follower 加上 is\_auto\_enroll(bit) 欄位
\## follower 加上 auto\_enroll\_start\_date(datetime) 欄位
\## follower 加上 auto\_enroll\_receipt\_title(nvarchar(50)) 欄位
\## follower 加上 auto\_enroll\_receipt\_address(nvarchar(200)) 欄位
\## follower 加上 auto\_enroll\_is\_receipt(bit) 欄位
company 加上 last\_auto\_order\_no(nvarchar(20)) 欄位
pro\_order 加上 au\_num(int) 欄位 並加上 constraint
&#x09;ALTER TABLE pro\_order
&#x09;ADD CONSTRAINT FK\_pro\_order\_auto\_enroll
&#x09;FOREIGN KEY (au\_num) REFERENCES auto\_enroll(num);
###### **新增資料表 auto\_enroll**
num int 不允許 Null
f\_num int 不允許 Null
start\_date date 允許 Null
end\_date date 允許 Null
receipt\_title nvarchar(MAX) 允許 Null
receipt\_address nchar(200) 不允許 Null
ALTER TABLE auto\_enroll
ADD CONSTRAINT FK\_auto\_enroll\_followers
FOREIGN KEY (f\_num) REFERENCES followers(num);
ALTER TABLE \[dbo].\[auto\_enroll]
ADD CONSTRAINT PK\_auto\_enroll PRIMARY KEY (num);
num 識別規格設為 是
Model.edmx auto\_enroll.num 屬性 StoreGeneratedPattern 設為 Identity