:::

4-5-1 完成錄取功能

您沒有觀看影片的權限

您沒有觀看影片的權限

請先登入,登入後,確認您的權限後,即可觀看影片。

  1. 修改 templates\op_tad_signup_actions_show.tpl 加入錄取、未錄取按鈕
    <table class="table" data-toggle="table" data-pagination="true" data-search="true" data-mobile-responsive="true">
        <thead>
            <tr>
                <!--略-->
                <{if $smarty.session.tad_signup_adm}>
                    <th data-sortable="true">錄取</th>
                <{/if}>
                <th data-sortable="true">報名日期</th>
            </tr>
        </thead>
        <tbody>
            <{foreach from=$signup item=signup_data}>
                <tr>
                    <{foreach from=$signup_data.tdc key=col_name item=user_data}>
                        <!--略-->
                    <{/foreach}>
                    <{if $smarty.session.tad_signup_adm}>
                        <td>
                            <{if $signup_data.accept==='1'}>
                                <div class="text-primary">錄取</div>
                                <a href="index.php?op=tad_signup_data_accept&id=<{$signup_data.id}>&action_id=<{$id}>&accept=0" class="btn btn-sm btn-warning">改成未錄取</a>
                            <{elseif $signup_data.accept==='0'}>
                                <div class="text-danger">未錄取</div>
                                <a href="index.php?op=tad_signup_data_accept&id=<{$signup_data.id}>&action_id=<{$id}>&accept=1" class="btn btn-sm btn-success">改成錄取</a>
                            <{else}>
                                <div class="text-muted">尚未設定</div>
                                <a href="index.php?op=tad_signup_data_accept&id=<{$signup_data.id}>&action_id=<{$id}>&accept=0" class="btn btn-sm btn-warning">未錄取</a>
                                <a href="index.php?op=tad_signup_data_accept&id=<{$signup_data.id}>&action_id=<{$id}>&accept=1" class="btn btn-sm btn-success">錄取</a>
                            <{/if}>
                        </td>
                    <{/if}>
                    <td><{$signup_data.signup_date}></td>
                </tr>
            <{/foreach}>
        </tbody>
    </table>

     

  2. 修改 index.php 中的 switch,加入對應流程:
    //更改錄取狀態
    case 'tad_signup_data_accept':
        Tad_signup_data::accept($id, $accept);
        redirect_header($_SERVER['PHP_SELF'] . "?id=$action_id", 3, "成功設定錄取狀態!");
        exit;

    前面記得過濾變數

    $accept = Request::getInt('accept');

     

  3. 最後根據流程在 class\Tad_signup_data.php 中加入新的方法: 影片中資料庫大小寫不正確,一律改為小寫 prefix("tad_signup_data")
    // 更改錄取狀態
    public static function accept($id, $accept)
    {
        global $xoopsDB;
    
        if (!$_SESSION['tad_signup_adm']) {
            redirect_header($_SERVER['PHP_SELF'], 3, "您沒有權限使用此功能");
        }
    
        $id = (int) $id;
        $accept = (int) $accept;
    
        $sql = "update `" . $xoopsDB->prefix("tad_signup_data") . "` set
        `accept` = '$accept'
        where `id` = '$id'";
        $xoopsDB->queryF($sql) or Utility::web_error($sql, __FILE__, __LINE__);
    }

     

 

link to https://github.com/tadlearn/tad_signup/commit/7da6304ef5e82319944558e7745b4fe754fa9146 \


:::

搜尋

QR Code 區塊

https%3A%2F%2Fwww.tad0616.net%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbsn%3D48%26tbdsn%3D1688

書籍目錄

展開 | 闔起

線上使用者

39人線上 (6人在瀏覽線上書籍)

會員: 0

訪客: 39

更多…