:::

8-2-2 手刻簽到表

您沒有觀看影片的權限

您沒有觀看影片的權限

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

  1. 修改 class\Tad_signup_data.phpget_all(),使之可以選擇是否只抓取已錄取者,並可自行設定需之要欄位。   影片中資料庫大小寫不正確,一律改為小寫 prefix("tad_signup_data")
    //取得所有資料陣列
    public static function get_all($action_id = '', $uid = '', $auto_key = false, $only_accept = false)
    {
        global $xoopsDB, $xoopsUser;
        $and_accept = $only_accept ? "and `accept`='1'" : '';
        if ($action_id) {
            $sql = "select * from `" . $xoopsDB->prefix("tad_signup_data") . "` where `action_id`='$action_id' $and_accept order by `signup_date`";
        } else {
            if (!$_SESSION['can_add'] or !$uid) {
                $uid = $xoopsUser ? $xoopsUser->uid() : 0;
            }
            $sql = "select * from `" . $xoopsDB->prefix("tad_signup_data") . "` where `uid`='$uid' $and_accept order by `signup_date`";
        }
    
        /*--略--*/
        return $data_arr;
    }

     

  2. 建立 pdf_signup.php
    <?php
    use Xmf\Request;
    use XoopsModules\Tad_signup\Tad_signup_actions;
    use XoopsModules\Tad_signup\Tad_signup_data;
    /*-----------引入檔案區--------------*/
    require_once __DIR__ . '/header.php';
    
    if (!$_SESSION['can_add']) {
        redirect_header($_SERVER['PHP_SELF'], 3, "您沒有權限使用此功能");
    }
    
    $id = Request::getInt('id');
    
    $action = Tad_signup_actions::get($id);
    
    require_once XOOPS_ROOT_PATH . '/modules/tadtools/tcpdf/tcpdf.php';
    $pdf = new TCPDF("P", "mm", "A4", true, 'UTF-8', false);
    $pdf->setPrintHeader(false); //不要頁首
    $pdf->setPrintFooter(false); //不要頁尾
    $pdf->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM); //設定自動分頁
    $pdf->setFontSubsetting(true); //產生字型子集(有用到的字才放到文件中)
    $pdf->SetFont('droidsansfallback', '', 11, '', true); //設定字型
    $pdf->SetMargins(15, 15); //設定頁面邊界,
    $pdf->AddPage(); //新增頁面,一定要有,否則內容出不來
    
    $title = "{$action['title']}簽到表";
    $pdf->SetFont('droidsansfallback', 'B', 24, '', true); //設定字型
    $pdf->MultiCell(190, 0, $title, 0, "C");
    $pdf->SetFont('droidsansfallback', '', 16, '', true); //設定字型
    $pdf->Cell(40, 20, '活動日期:', 0, 0);
    $pdf->Cell(150, 20, $action['action_date'], 0, 1);
    
    // $pdf->MultiCell( $w, $h, $txt, $border = 0, $align = 'J', $fill = false, $ln = 1, $x = '', $y = '', $reseth = true, $stretch = 0, $ishtml = false, $autopadding = true, $maxh = 0, $valign = 'T', $fitcell = false );
    // $pdf->Cell($w, $h = 0, $txt = '', $border = 0, $ln = 0, $align = '', $fill = 0, $link = nil, $stretch = 0, $ignore_min_height = false, $calign = 'T', $valign = 'M')
    
    $h = 15;
    $maxh = 15;
    $pdf->Cell(15, $h, '編號', 1, 0, 'C');
    $pdf->Cell(40, $h, '姓名', 1, 0, 'C');
    $pdf->Cell(35, $h, '飲食', 1, 0, 'C');
    $pdf->Cell(100, $h, '簽名', 1, 1, 'C');
    
    $signup = Tad_signup_data::get_all($action['id'], null, true, true);
    // Utility::dd($signup);
    $i = 1;
    foreach ($signup as $signup_data) {
        $pdf->MultiCell(15, $h, $i, 1, 'C', false, 0, '', '', true, 0, false, true, $maxh, 'M');
        $pdf->MultiCell(40, $h, implode('、', $signup_data['tdc']['姓名']), 1, 'C', false, 0, '', '', true, 0, false, true, $maxh, 'M');
        $pdf->MultiCell(35, $h, implode('、', $signup_data['tdc']['飲食']), 1, 'C', false, 0, '', '', true, 0, false, true, $maxh, 'M');
        $pdf->MultiCell(100, $h, '', 1, 'C', false, 1, '', '', true, 0, false, true, $maxh, 'M');
        $i++;
    }
    
    $pdf->Output("{$title}.pdf", 'I');
    

     

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


:::

搜尋

QR Code 區塊

https%3A%2F%2Ftad0616.net%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbsn%3D48%26tbdsn%3D1775

書籍目錄

展開 | 闔起

線上使用者

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

會員: 0

訪客: 122

更多…