# TODO
* 資料庫SQL:
    * 結構:GIT
    * 含資料: 傳檔
* 確認編號規則**
    * 一般:
        * 活動: 選項
        * 牌位類型
        * 流水號(4碼起)(依類型)
        * 例: 消災0001,消災0002
    * 功德主:
        * 活動: 選項
        * 功德主類型
        * 流水號(4碼起)(依類型)
        * "-"
        * 牌位類型
        * 流水號(不補0)(依功德主+類型)
        * 例:
            * 如意主0001-消災1, 如意主0001-消災2
            * 如意主0001-超1, 如意主0001-超2
            * 如意主0002-消災1, 如意主0002-消災2
            * 如意主0002-超1, 如意主0002-超2
* 少字的字距
* 親友名換行"|"
* 可依上述SQL做綜合查詢/列印
    * 列印參考:~/admin/activity/reg.aspx

# SQL

## 報名牌位綜合查詢
```SQL
SELECT  activity.subject AS 活動_名稱, activity.startDate_solar AS 活動_報名日, activity.print_init AS 活動_編碼開頭, followers.u_name AS 信眾_名稱, pro_order_detail.order_no AS 報名_編號, pro_order.up_time AS 報名_時間, 
           pro_order_detail.num AS 項目_序號, pro_order_detail.parent_num AS 項目_上層, pro_order_detail.actItem_num AS 項目_品項, actItem.subject AS 品項_名稱, actItem.print_init AS 品項_編碼開頭, 
           pro_order_detail.print_id AS 項目_牌位編號, pro_order_detail.f_num_tablet AS 項目_牌位文字, pro_order_detail.price AS 項目_金額, pro_order_detail.qty AS 項目_數量, pro_order_detail.printed_files AS 項目_已列印
FROM    pro_order_detail INNER JOIN
           pro_order ON pro_order_detail.order_no = pro_order.order_no INNER JOIN
           actItem ON pro_order_detail.actItem_num = actItem.num INNER JOIN
           followers ON pro_order.f_num = followers.num INNER JOIN
           activity ON pro_order.activity_num = activity.num
ORDER BY 活動_報名日, 項目_序號, 報名_編號
```

## 功德主(套餐)
https://demo2.eztrust.tw/17168erp_e/admin/activity/item_reg.aspx?num=1264
以下查詢為概念:
actItem : 品項 (基本資料)
act_bom : 主項/細項 (功德項目:上/下)
```
SELECT  actItem.num, actItem.partno, actItem.subject, actItem.print_init, act_bom.num, act_bom.package_num, act_bom_1.num, act_bom_1.package_num, act_bom_1.item_num
FROM    actItem INNER JOIN
           act_bom ON actItem.num = act_bom.item_num INNER JOIN
           act_bom AS act_bom_1 ON actItem.num = act_bom_1.item_num AND act_bom.package_num = act_bom_1.num
```

## 家屬
```
SELECT  followers.num AS 信眾_序號, followers.f_number AS 信眾_編號, followers.u_name AS 信眾_姓名, family_members.num AS 親友_序號, family_members.fam_name AS 親友_姓名, 
           family_members.deceased AS 親友_往生
FROM    followers INNER JOIN
           family_members ON followers.num = family_members.follower_num
```

## 牌位文字格式
```JSON
{"mid_items":[
    {"num":0,"fam_name":"姓名","option_break":true},
    {"num":0,"fam_name":"姓名","option_break":true},
    {"num":0,"fam_name":"姓名","option_break":true}
],
"left_items":[
    {"num":0,"fam_name":"姓名","option_break":true},
    {"num":0,"fam_name":"姓名","option_break":true},
    {"num":0,"fam_name":"姓名","option_break":true}
]}
```

