<?php
if(!defined('APP_PATH')||!defined('I_PATH')){exit('Access Denied');}

class ld_traits extends controllerBase
{
	function __construct(){
		parent::__construct();
		$this->molds=$this->sysParams('molds',1);
		$this->moldname=moldsinfo($this->molds,'moldname');
		$this->Get_c='ld_traits&molds='.$this->molds;
		$this->newrow = array(
			'molds' => $this->molds,
			'name' => $this->sysParams('name',1),
		);
	}
	function index(){
		$this->toptxt=$this->moldname.'-推荐属性管理';
		$this->lists = syDB('traits')->findAll(array('molds'=>$this->molds));
		$this->display("traits.html");
	}
	function add(){
		if ($this->sysParams('run')==1){
			if(syDB('traits')->create($this->newrow)){
				message_a("推荐属性创建成功","?c=".$this->Get_c);
			}else{message_a("推荐属性创建失败，请重新提交");}
		}
		$this->toptxt=$this->moldname.'-添加推荐属性';
		$this->postgo='add';
		$this->display("traits.html");
	}
	function edit(){
		$this->d=syDB('traits')->find(array('id'=>$this->sysParams('id')));
		if ($this->sysParams('run')==1){
			if(syDB('traits')->update(array('id'=>$this->d['id']),$this->newrow)){
				message_a("推荐属性修改成功","?c=".$this->Get_c);
			}else{message_a("推荐属性修改失败,请重新提交");}
		}
		$this->toptxt=$this->moldname.'-修改推荐属性';
		$this->postgo='edit';
		$this->display("traits.html");
	}
	function del(){
		$this->toptxt=$this->moldname.'-删除推荐属性';
		$this->d=syDB('traits')->find(array('id'=>$this->sysParams('id')));
		if ($this->sysParams('run')==1){
			if(syDB('traits')->delete(array('id'=>$this->sysParams('id'))))
			{message_a("推荐属性删除成功","?c=".$this->Get_c);}else{message_a("推荐属性删除失败,请重新提交");}
		}
		$this->msgtitle='确定要删除推荐属性 <strong>['.$this->d['name'].']</strong> 吗？';
		$this->msg='';
		$this->msggo='<a href="?c='.$this->Get_c.'&a=del&run=1&id='.$this->d['id'].'">确定删除</a><a href="?c='.$this->Get_c.'">取消操作</a>';
		$this->display("msg.html");
	}

}	