<?php
/**
 * 店铺分类管理
 * @Copyright (C) 2016 汉潮 All rights reserved.
 * @License http://www.hanchao9999.com
 * @Author xiaogg <xiaogg@sina.cn>
 */
namespace Admin\Controller;
class ShopsCategoryController extends BaseController
{
    public function _initialize()
    {
        parent::_initialize();
    }

    public function index()
    {
        $id = I('shopsid');
        $map['shop_id']=$id;
        $ShopsCategory = M('ShopsCategory')->where($map)->field(true)->select();
        $Tree = new \Common\Vendor\Tree();
        $Tree->icon = array('&nbsp;&nbsp;&nbsp;   ', '&nbsp;&nbsp;&nbsp;├─ ', '&nbsp;&nbsp;&nbsp;└─ ');
        $Tree->nbsp = '&nbsp;&nbsp;&nbsp;';
        if (!empty($ShopsCategory)) {
            foreach ($ShopsCategory as &$values) {
                $values['status'] = '<td onclick="status(' . $values['id'] . ',' . "'status'" . ')" id="status_' . $values['id'] . '" style="text-align:center;"><img src="' . __ROOT__ . '/Public/images/status_' . $values['status'] . '.gif" /></td>';
            }
        }
        $Tree->init($ShopsCategory);
        $str = "<tr>
	    <td style='text-align:center;'>\$id</td>
		<td><input name='sort[\$id]' class='text' tabindex='10' type='text' size='3' value='\$sort' class='input' style='text-align:center;'></td>
		<td style='text-align:left;padding-left:10px;' title='\$name'>\$spacer\$name</td>
                        \$status
		</tr>";
        $cateString = $Tree->get_tree(0, $str);
        $this->assign('cateString', $cateString);
        $this->assign('id', $id);
        $this->display();
    }
}