后台功能模板

ecshop

16-1-7 8:52:06

admin目录  新建 d.php


define('IN_ECS', true);
require(dirname(__FILE__) . '/includes/init.php');


if ($_REQUEST['act'] == 'list')
{

    admin_priv('d');      /* 检查权限 */


    $user_list = d_list();
    $smarty->assign('user_list',    $user_list['user_list']);
    $smarty->assign('filter',       $user_list['filter']);
    $smarty->assign('record_count', $user_list['record_count']);
    $smarty->assign('page_count',   $user_list['page_count']);
    $smarty->assign('full_page',    1);
    assign_query_info();
    $smarty->display('d_list.htm');
}

/*--------------------------ajax返回用户列表---------------------------- */
elseif ($_REQUEST['act'] == 'query')
{
    $user_list = d_list();
    $smarty->assign('user_list',    $user_list['user_list']);
    $smarty->assign('filter',       $user_list['filter']);
    $smarty->assign('record_count', $user_list['record_count']);
    $smarty->assign('page_count',   $user_list['page_count']);
    make_json_result($smarty->fetch('d_list'), '', array('filter' => $user_list['filter'], 'page_count' => $user_list['page_count']));
}

/*-------------其他 ---------------- */
elseif ($_REQUEST['act'] == 'add')
{
    admin_priv('d');  /* 检查权限 */
    $smarty->display('dm_user_info.htm');
}




function d_list()
{
    $result = get_filter();
    if ($result === false)
    {
        /* 过滤条件 */
        $filter['keywords'] = empty($_REQUEST['keywords']) ? '' : trim($_REQUEST['keywords']);
        $filter['lx'] = empty($_REQUEST['lx']) ? '' : trim($_REQUEST['lx']);

        if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1)
        {
            $filter['keywords'] = json_str_iconv($filter['keywords']);
        }
 

        $filter['sort_by']    = empty($_REQUEST['sort_by'])    ? 'id' : trim($_REQUEST['sort_by']);
        $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC'     : trim($_REQUEST['sort_order']);

        $ex_where = ' WHERE 1 ';
        if ($filter['keywords'])
        {
            
            if($filter['lx']=='1'){$ex_where .= " AND xm LIKE '%" . mysql_like_quote($filter['keywords']) ."%'";}
            if($filter['lx']=='2'){$ex_where .= " AND sj LIKE '%" . mysql_like_quote($filter['keywords']) ."%'";}
            
        }
       

        $filter['record_count'] = $GLOBALS['db']->getOne("SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('dmhy') . $ex_where);

        /* 分页大小 */
        $filter = page_and_size($filter);
        $sql = "SELECT * ".
                " FROM " . $GLOBALS['ecs']->table('dmhy') . $ex_where .
                " ORDER by " . $filter['sort_by'] . ' ' . $filter['sort_order'] .
                " LIMIT " . $filter['start'] . ',' . $filter['page_size'];

        $filter['keywords'] = stripslashes($filter['keywords']);
        set_filter($filter, $sql);
    }
    else
    {
        $sql    = $result['sql'];
        $filter = $result['filter'];
    }

    $user_list = $GLOBALS['db']->getAll($sql);






    $count = count($user_list);
    for ($i=0; $i<$count; $i++)
    {
        $user_list[$i]['name'] =user_name($user_list[$i]['uid']);
        $user_list[$i]['wjf'] =user_jf($user_list[$i]['uid']);
        $user_list[$i]['reg_time'] = local_date($GLOBALS['_CFG']['date_format'], $user_list[$i]['reg_time']);
    }

    $arr = array('user_list' => $user_list, 'filter' => $filter,
        'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);

    return $arr;
}


----------------------------------------------------------------------------------------------------------------------------------------------------------------------

模板制作


{if $full_page}
{include file="pageheader.htm"}
{insert_scripts files="../js/utils.js,listtable.js"}

<div class="form-div">
  <form action="javascript:searchUser()" name="searchForm" style="display:none">
    <img src="images/icon_search.gif" width="26" height="22" border="0" alt="SEARCH" />
    &nbsp;查询<select name="user_rank">
    
    <option value="4">卡号</option>
    <option value="1">姓名</option>
    <option value="2">手机号</option>
    <option value="3">网站帐号</option>
    </select>
    &nbsp;<input type="text" name="keyword" /> <input type="submit" value="提交" />
  </form>&nbsp;&nbsp;&nbsp;&nbsp;<a  href="?act=add">增加会员</a>
</div>

<form method="POST" action="" name="listForm" onsubmit="return confirm_bath()">

<!-- start users list -->
<div class="list-div" id="listDiv">
{/if}
<!--用户列表部分-->
<table cellpadding="3" cellspacing="1">
  <tr>
    <th>ID</th>
    <th>操作</th>
   
  <tr>
  {foreach from=$user_list item=user}
  <tr>
   <td>{$user.id}</td>
   <td><a href="dmhy.php?act=del&id={$user.id}"  onclick="return confirm('确认删除?!!')">删</a></td>
  </tr>
  {foreachelse}
  <tr><td class="no-records" colspan="10">{$lang.no_records}</td></tr>
  {/foreach}
  <tr>
      <td colspan="2">
      <input type="hidden" name="act" value="xxx" />
      <input type="submit" id="btnSubmit" value="{$lang.button_remove}" disabled="true" class="button" /></td>
      <td align="right" nowrap="true" colspan="8">
      {include file="page.htm"}
      </td>
  </tr>
</table>

{if $full_page}
</div>
<!-- end users list -->
</form>
<script type="text/javascript" language="JavaScript">
<!--
listTable.recordCount = {$record_count};
listTable.pageCount = {$page_count};

{foreach from=$filter item=item key=key}
listTable.filter.{$key} = '{$item}';
{/foreach}

{literal}
onload = function()
{
    document.forms['searchForm'].elements['keyword'].focus();
    // 开始检查订单
    startCheckOrder();
}

/**
 * 搜索用户
 */
function searchUser()
{
    listTable.filter['keywords'] = Utils.trim(document.forms['searchForm'].elements['keyword'].value);
    listTable.filter['rank'] = document.forms['searchForm'].elements['user_rank'].value;
    listTable.filter['pay_points_gt'] = Utils.trim(document.forms['searchForm'].elements['pay_points_gt'].value);
    listTable.filter['pay_points_lt'] = Utils.trim(document.forms['searchForm'].elements['pay_points_lt'].value);
    listTable.filter['page'] = 1;
    listTable.loadList();
}

function confirm_bath()
{
  userItems = document.getElementsByName('checkboxes[]');

  cfm = '{$lang.list_remove_confirm}';

  for (i=0; userItems[i]; i++)
  {
    if (userItems[i].checked && userItems[i].notice == 1)
    {
      cfm = '{$lang.list_still_accounts}' + '{$lang.list_remove_confirm}';
      break;
    }
  }

  return confirm(cfm);
}
//-->
</script>
{/literal}
{include file="pagefooter.htm"}
{/if}