4-5-2
加入複製活動功能
您沒有觀看影片的權限
請先登入,登入後,確認您的權限後,即可觀看影片。
- 修改
templates\op_tad_signup_actions_index.tpl
加入複製按鈕
<{if $smarty.session.tad_signup_adm}>
<a href="index.php?op=tad_signup_actions_edit&id=<{$action.id}>" class="btn btn-warning btn-sm"><i class="fa fa-plus" aria-hidden="true"></i> 編輯活動</a>
<a href="index.php?op=tad_signup_actions_copy&id=<{$action.id}>" class="btn btn-info btn-sm"><i class="fa fa-copy" aria-hidden="true"></i> 複製活動</a>
<{/if}>
- 修改
index.php
在流程中加入對應動作
// 複製活動
case 'tad_signup_actions_copy':
$new_id = Tad_signup_actions::copy($id);
header("location: {$_SERVER['PHP_SELF']}?op=tad_signup_actions_edit&id=$new_id");
exit;
- 修改
class\Tad_signup_actions.php
加入對應方法
//複製活動
public static function copy($id)
{
global $xoopsDB, $xoopsUser;
if (!$_SESSION['tad_signup_adm']) {
redirect_header($_SERVER['PHP_SELF'], 3, "您沒有權限使用此功能");
}
$action = self::get($id);
$uid = $xoopsUser->uid();
$end_date = date('Y-m-d 17:30:00', strtotime('+2 weeks'));
$action_date = date('Y-m-d 09:00:00', strtotime('+16 days'));
$sql = "insert into `" . $xoopsDB->prefix("tad_signup_actions") . "` (
`title`,
`detail`,
`action_date`,
`end_date`,
`number`,
`setup`,
`uid`,
`enable`
) values(
'{$action['title']}_copy',
'{$action['detail']}',
'{$action_date}',
'{$end_date}',
'{$action['number']}',
'{$action['setup']}',
'{$uid}',
'0'
)";
$xoopsDB->queryF($sql) or Utility::web_error($sql, __FILE__, __LINE__);
//取得最後新增資料的流水編號
$id = $xoopsDB->getInsertId();
return $id;
}
link to https://github.com/tadlearn/tad_signup/commit/8601ed7cdd7dc70834d33e348fe62617efe933d4 \