1. 新增法會活動品項:牌位陽上與超度人數限制功能
2. 信眾資料新增全年性選項以及開始參加活動日期,自動報名並代入前一次的報名資料(品項)
This commit is contained in:
+227
-19
@@ -116,6 +116,15 @@
|
||||
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: "",
|
||||
follower_id: '<%= Request["num"] %>',
|
||||
@@ -124,6 +133,18 @@
|
||||
multiSort: false,
|
||||
//itemsPerPage: -1,
|
||||
},
|
||||
confirm_dialog: {
|
||||
show: false,
|
||||
headers: [
|
||||
{ text: '活動日期', value: 'activitydate' },
|
||||
{ text: '活動名稱', value: 'activityname'},
|
||||
],
|
||||
title: '',
|
||||
desc: '',
|
||||
orders: [],
|
||||
btn_cancel_text: '', // 「取消報名」按鈕文字
|
||||
btn_keep_text: '' // 「保留活動」按鈕文字
|
||||
},
|
||||
search_dialog: {
|
||||
controls: {
|
||||
search1: {
|
||||
@@ -485,7 +506,16 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
mounted() {//一開始就載入
|
||||
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();
|
||||
@@ -496,6 +526,30 @@
|
||||
this.onCityChange();
|
||||
},
|
||||
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);
|
||||
@@ -537,6 +591,58 @@
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
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 => {
|
||||
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;
|
||||
})
|
||||
}
|
||||
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;
|
||||
})
|
||||
}
|
||||
},
|
||||
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;
|
||||
},
|
||||
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;
|
||||
},
|
||||
search_show(curr) {
|
||||
console.log("btn_click:", curr, curr.api_url);
|
||||
this.search_dialog.current = curr;
|
||||
@@ -1335,11 +1441,12 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
</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>
|
||||
@@ -1564,32 +1671,92 @@
|
||||
<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">
|
||||
<label class="col-sm-2 col-lg-1 col-form-label">自訂標籤</label>
|
||||
<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>
|
||||
|
||||
<div class="col-sm-10 col-lg-3">
|
||||
<div class="input-group">
|
||||
<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">
|
||||
<input type="text" class="form-control" v-model="tabArray2" v-on:keyup.enter="addTab" title="可自由輸入標籤名稱,輸入完成請按「+」,或「Enter」" placeholder="自訂標籤名稱">
|
||||
<asp:HiddenField ID="tab" runat="server" />
|
||||
<a class="btn btn-default" @click="addTab" ><i class="mdi mdi-plus"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-12 col-lg-7">
|
||||
<template>
|
||||
<div class="">
|
||||
<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>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12 col-lg-4">
|
||||
<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>
|
||||
@@ -2123,7 +2290,7 @@
|
||||
<v-card>
|
||||
<v-card-title class="justify-space-between grey lighten-2">
|
||||
查詢:{{search_dialog.current.title}}
|
||||
<v-btn icon @click="search_dialog.show=false"><v-icon>mdi-close</v-icon></v-btn>
|
||||
<v-btn icon @click="search_dialog.show=false;"><v-icon>mdi-close</v-icon></v-btn>
|
||||
</v-card-title>
|
||||
<v-card-text >
|
||||
<v-row>
|
||||
@@ -2173,6 +2340,47 @@
|
||||
</v-btn>
|
||||
</template>
|
||||
</v-snackbar>
|
||||
|
||||
<v-dialog v-model="confirm_dialog.show" max-width="500px" persistent>
|
||||
<v-card>
|
||||
<v-card-title class="justify-space-between grey lighten-2">
|
||||
<span>{{ confirm_dialog.title }}</span>
|
||||
<v-btn icon @click="close_confirm_dialog"><v-icon>mdi-close</v-icon></v-btn>
|
||||
</v-card-title>
|
||||
|
||||
<v-card-text class="pt-4">
|
||||
<p class="body-1">{{ confirm_dialog.desc }}</p>
|
||||
|
||||
<v-data-table
|
||||
:headers="confirm_dialog.headers"
|
||||
:items="confirm_dialog.orders"
|
||||
:items-per-page="5"
|
||||
class="elevation-1 grey lighten-5"
|
||||
:footer-props="{
|
||||
'items-per-page-text': '每頁顯示',
|
||||
'items-per-page-options': [5, 10]
|
||||
}"
|
||||
>
|
||||
<template v-slot:item.activitydate="{ item }">
|
||||
<span>{{ item.activitydate }}</span>
|
||||
</template>
|
||||
|
||||
|
||||
</v-data-table>
|
||||
</v-card-text>
|
||||
<v-divider class="pa-0 ma-0"></v-divider>
|
||||
<v-card-actions class="pa-4 justify-end">
|
||||
<v-btn color="primary" @click="keep_auto_enroll_order">
|
||||
{{ confirm_dialog.btn_keep_text }}
|
||||
</v-btn>
|
||||
|
||||
<v-btn color="red" dark @click="delete_auto_enroll_order">
|
||||
{{ confirm_dialog.btn_cancel_text }}
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
|
||||
</div>
|
||||
|
||||
</asp:Content>
|
||||
@@ -11,9 +11,11 @@ using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using static Model.activity_check;
|
||||
|
||||
public partial class admin_follower_reg : MyWeb.config
|
||||
{
|
||||
@@ -142,7 +144,7 @@ public partial class admin_follower_reg : MyWeb.config
|
||||
country.Value = prod.country.ToString();
|
||||
}
|
||||
if (prod.reg_time.HasValue)
|
||||
{
|
||||
{
|
||||
timePanel1.Visible = true;
|
||||
reg_time.Text= prod.reg_time.Value.ToString("yyyy/MM/dd HH:mm:ss");
|
||||
}
|
||||
@@ -153,6 +155,30 @@ 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;
|
||||
@@ -178,10 +204,39 @@ public partial class admin_follower_reg : MyWeb.config
|
||||
Response.Redirect("index.aspx?page=" + Convert.ToString(Request["page"]));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#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) {
|
||||
@@ -237,12 +292,77 @@ 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;
|
||||
|
||||
@@ -301,6 +421,10 @@ 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)
|
||||
@@ -318,10 +442,7 @@ public partial class admin_follower_reg : MyWeb.config
|
||||
}
|
||||
else
|
||||
ObjValue.SetValue(followers, null);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
followers.identity_type = Val(identity_type.SelectedValue);
|
||||
@@ -333,6 +454,302 @@ 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))
|
||||
{
|
||||
Debug.WriteLine(pro_order.order_no);
|
||||
|
||||
_db.pro_order.Add(pro_order);
|
||||
_db.SaveChanges();
|
||||
|
||||
// 報名品項(最近一次訂單內容)
|
||||
if (latestOrder != null)
|
||||
{
|
||||
Debug.WriteLine("上次的單號 ", latestOrder.order_no);
|
||||
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(',');
|
||||
Debug.WriteLine(ids);
|
||||
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(',');
|
||||
Debug.WriteLine(ids);
|
||||
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))
|
||||
{
|
||||
Debug.WriteLine(pro_order.order_no);
|
||||
|
||||
_db.pro_order.Add(pro_order);
|
||||
_db.SaveChanges();
|
||||
|
||||
// 報名品項(最近一次訂單內容)
|
||||
if (latestOrder != null)
|
||||
{
|
||||
Debug.WriteLine("上次的單號 ", latestOrder.order_no);
|
||||
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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user