default:
# ---- 目前網址 ----
$_SESSION['return_url'] = getCurrentUrl();
$op = "opList";
opList();
break;
####################################################
# 列表
####################################################
function opList() {
global $xoopsDB, $xoopsTpl, $module_name, $kind, $ugmKind;
#---- 過濾讀出的變數值 ----
$myts = MyTextSanitizer::getInstance();
# ----得到ForeignKeyMainOption選項 ----------------------------
$ForeignKeyMainOption = $ugmKind->get_kindOption($kind);
$ForeignKeyForm = "
<div class='row' style='margin-bottom:5px;'>
<div class='col-sm-3'>
<select name='kind' id='kind' onchange=\"location.href='?kind='+this.value\" class='form-control'>
<option value=''>" . _MD_UGMMODULE_ALL . "</option>\n
$ForeignKeyMainOption
</select>
</div>
</div>
";
$xoopsTpl->assign('ForeignKeyForm', $ForeignKeyForm);
$xoopsTpl->assign('kind', $kind);
#身體array
$and_key = $kind ? " where a.kind='{$kind}'" : "";
//sn kind kind_gallery title summary content price amount enable date sort
$sql = "select a.*,b.title as kind_title
from " . $xoopsDB->prefix("cnu_show_prod") . " as a
left join " . $xoopsDB->prefix("cnu_show_kind") . " as b on a.kind=b.sn
{$and_key}
order by a.sort desc,a.date desc"; //die($sql);
//getPageBar($原sql語法, 每頁顯示幾筆資料, 最多顯示幾個頁數選項);
$p_count = 20;
$PageBar = getPageBar($sql, $p_count, 10);
$bar = $PageBar['bar'];
$sql = $PageBar['sql'];
$total = $PageBar['total'];
$bar = $total > $p_count ? $bar : "";
$xoopsTpl->assign("bar", $bar);
$result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'], 3, web_error());
$rows = array();
#----單檔圖片上傳
$subdir = "prod"; //子目錄(前後不要有 / )
$ugmUpFiles = new ugmUpFiles($module_name, $subdir); //實體化
$col_name = "prod";
$thumb = false ; //顯示縮圖 //資料表關鍵字
while ($row = $xoopsDB->fetchArray($result)) {
$row['sn'] = intval($row['sn']);
#一般文字
$row['title'] = $myts->htmlSpecialChars($row['title']);
$row['enable'] = intval($row['enable']);
$row['choice'] = intval($row['choice']);
$row['price'] = intval($row['price']);
$row['date'] = intval($row['date']);
$row['kind_title'] = $myts->htmlSpecialChars($row['kind_title']);
#日期
$row['date'] = date("Y-m-d", xoops_getUserTimestamp($row['date'])); //從資料庫撈出
$col_sn = $row['sn']; //關鍵字流水號
$row['prod'] = $ugmUpFiles->get_rowPicSingleUrl($col_name,$col_sn,$thumb);
#-----------------------------------
if($row['prod']){
$row['prod'] = "<a href='{$row['prod']}' class='showImg'><img src='{$row['prod']}' style='width:50px;' class='img-responsive center-block'></a>";
}
$rows[] = $row;
}
# ---- fancybox_code ----
if (!file_exists(XOOPS_ROOT_PATH . "/modules/tadtools/fancybox.php")) {
redirect_header("index.php", 3, _MA_NEED_TADTOOLS);
}
include_once XOOPS_ROOT_PATH . "/modules/tadtools/fancybox.php";
$fancybox = new fancybox('.showImg', '90%', '90%');
$reload = false;
$fancybox->render($reload);
#刪除-------------------------------------------------------
if (!file_exists(XOOPS_ROOT_PATH . "/modules/tadtools/sweet_alert.php")) {
redirect_header("index.php", 3, _MA_NEED_TADTOOLS);
}
include_once XOOPS_ROOT_PATH . "/modules/tadtools/sweet_alert.php";
$sweet_alert_obj = new sweet_alert();
$sweet_alert_obj->render('op_delete_js', "?op=opDelete&sn=", "sn");
# ------------------------------------------------------------
$xoopsTpl->assign("rows", $rows);
}
<{if $op=="opList"}>
<div class='container-fluid'>
<{$ForeignKeyForm}>
<div class='row'>
<div id="save_msg"></div>
<table id="form_table" class="table table-bordered table-condensed table-hover">
<thead>
<tr>
<th class="col-sm-1 text-center"><{$smarty.const._MD_UGMMODULE_THUMB}></th>
<th class="col-sm-1 text-center"><{$smarty.const._MD_UGMMODULE_DATE}></th>
<th class="col-sm-4 text-center"><{$smarty.const._MD_UGMMODULE_TITLE}></th>
<th class="col-sm-1 text-center"><{$smarty.const._MD_UGMMODULE_SORT}></th>
<th class="col-sm-1 text-center"><{$smarty.const._MD_UGMMODULE_CHOICE}></th>
<th class="col-sm-1 text-center"><{$smarty.const._MD_UGMMODULE_ENABLE}></th>
<th class="col-sm-2 text-center"><a href='?op=opForm' class='btn btn-primary btn-xs' ait='' ><{$smarty.const._ADD}></a></th>
</tr>
</thead>
<{foreach from=$rows item=row key=id name=t}>
<{if $smarty.foreach.t.first}>
<tbody id='sort'>
<{/if}>
<tr id='tr_<{$row.sn}>'>
<td class="text-center"><{$row.prod}></td>
<td class="text-center"><{$row.date}></td>
<td class="text-center"><{$row.title}></td>
<td class="text-center"><{$row.sort}></td>
<td class="text-center">
<{if $row.choice}>
<a href='?op=opUpdate_choice&sn=<{$row.sn}>&choice=0' atl='<{$smarty.const._MD_UGMMODULE_ENABLE_0}>' title='<{$smarty.const._MD_UGMMODULE_ENABLE_0}>'><img src='<{$xoops_url}>/modules/ugm_tools2/images/on.png' /></a>
<{else}>
<a href='?op=opUpdate_choice&sn=<{$row.sn}>&choice=1' atl='<{$smarty.const._MD_UGMMODULE_ENABLE_1}>' title='<{$smarty.const._MD_UGMMODULE_ENABLE_1}>'><img src='<{$xoops_url}>/modules/ugm_tools2/images/off.png' /></a>
<{/if}>
</td>
<td class="text-center">
<{if $row.enable}>
<a href='?op=opUpdate_enable&sn=<{$row.sn}>&enable=0' atl='<{$smarty.const._MD_UGMMODULE_ENABLE_0}>' title='<{$smarty.const._MD_UGMMODULE_ENABLE_0}>'><img src='<{$xoops_url}>/modules/ugm_tools2/images/on.png' /></a>
<{else}>
<a href='?op=opUpdate_enable&sn=<{$row.sn}>&enable=1' atl='<{$smarty.const._MD_UGMMODULE_ENABLE_1}>' title='<{$smarty.const._MD_UGMMODULE_ENABLE_1}>'><img src='<{$xoops_url}>/modules/ugm_tools2/images/off.png' /></a>
<{/if}>
</td>
<td class="text-center">
<a href="<{xoAppUrl modules/cnu_show/index.php?op=opShow&sn=}><{$row.sn}>" class="btn btn-primary btn-xs" target="_blank">前台</a>
<a href="?op=opForm&sn=<{$row.sn}>" class="btn btn-success btn-xs"><{$smarty.const._EDIT}></a>
<a href="?op=opCopy&sn=<{$row.sn}>" class="btn btn-default btn-xs" target="_blank">複製</a>
<a href="javascript:op_delete_js(<{$row.sn}>);" class="btn btn-danger btn-xs"><{$smarty.const._DELETE}></a>
</td>
</tr>
<{if $smarty.foreach.t.last}>
</tbody>
<{/if}>
<{/foreach}>
</table>
<{$bar}>
</div>
</div>
<{/if}>