<?php
namespace admin\controller;

/**
 * 控制器
 * 
 */
class Goodsattr extends Admin {
	

	public function lists(){
		$type_id=I('type_id',0);
		//分组
		$group=M('goods_type')->where(array('id'=>$type_id))->getField('group');
		$group=preg_split("/[\r\n,]+/s", $group,-1,PREG_SPLIT_NO_EMPTY);
		
		$m=M('goods_attr');
		$where=array(
			'type_id'=>$type_id
		);
		$list=$m->where($where)->order("`group`,`sort`")->select();
		foreach ($list as $k => &$v) {
			$v['attr_values']=preg_split("/[,\r\n]+/s", $v['attr_values'],-1,PREG_SPLIT_NO_EMPTY);
		}
		$redata=array(
			'group'=>$group,
			'list'=>$list
		);
		$this->ajaxReturn($redata);
		
    }

}