7-6-5
產生 Excel 預覽界面並批次匯入資料
您沒有觀看影片的權限
請先登入,登入後,確認您的權限後,即可觀看影片。
- 將
templates\op_tad_signup_data_preview_csv.tpl
複製為 templates\op_tad_signup_data_preview_excel.tpl
,並改一下 op 值即可:
<h2 class="my">匯入「<{$action.title}>」報名資料預覽</h2>
<form action="index.php" method="post" id="myForm">
<table class="table table-bordered table-sm">
<{foreach from=$preview_data key=i item=data name=preview_data}>
<tr>
<{if $smarty.foreach.preview_data.iteration==1}>
<{foreach from=$row item=title}>
<th class="c bg-light text-dark"><{$title}></th>
<{/foreach}>
<{else}>
<{foreach from=$data key=j item=preview}>
<{assign var=title value=$row.$j}>
<{if $type.$title=='checkbox'}>
<td>
<{assign var=preview_arr value='|'|explode:$preview}>
<{foreach from=$preview_arr key=k item=val name=preview}>
<div class="form-check-inline checkbox-inline">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" name="tdc[<{$i}>][<{$title}>][]" value="<{$val}>" checked>
<{$val}>
</label>
</div>
<{/foreach}>
</td>
<{elseif $title}>
<td>
<input type="text" name="tdc[<{$i}>][<{$title}>]" value="<{$preview}>" class="form-control form-control-sm">
</td>
<{/if}>
<{/foreach}>
<{/if}>
</tr>
<{/foreach}>
</table>
<{$token_form}>
<input type="hidden" name="id" value="<{$action.id}>">
<input type="hidden" name="op" value="tad_signup_data_import_excel">
<div class="bar">
<button type="submit" class="btn btn-primary">
<i class="fa fa-save" aria-hidden="true"></i> 匯入資料
</button>
</div>
</form>
- 在
index.php
加入對應流程
// 將 Excel 資料存入資料庫
case 'tad_signup_data_import_excel':
Tad_signup_data::import_excel($id);
header("location: {$_SERVER['PHP_SELF']}?id=$id");
exit;
- 在
class\Tad_signup_data.php
加入對應方法:
// 匯入 Excel
public static function import_excel($action_id)
{
self::import_csv($action_id);
}
link to https://github.com/tadlearn/tad_signup/commit/7bc23558ee2e7cfbf0df74dcd9fc495fe704fed1 \