Commit 808c2245 by 冷斌

add

parent 7d55a9bf
<admintpl file="header" />
<link href="__PUBLIC__/colpick/colpick.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="wrap">
<ul class="nav nav-tabs">
<li ><a href="{:U('Impression/index2')}">列表</a></li>
<li class="active"><a >添加</a></li>
</ul>
<form method="post" class="form-horizontal js-ajax-form" action="{:U('Impression/add_post2')}">
<fieldset>
<div class="control-group">
<label class="control-label">名称</label>
<div class="controls">
<input type="text" name="name">
<span class="form-required">*</span>
</div>
</div>
<div class="control-group">
<label class="control-label">颜色</label>
<div class="controls">
<input type="text" name="colour" id="picker"> <input id="colour_block" style="width:50px;height:20px;background:#000;" disabled/>
<span class="form-required">*</span> 内容为6位颜色16进制色码,点击可选择
</div>
</div>
<input type="hidden" name="addtime" value="{$time}">
</fieldset>
<div class="form-actions">
<button type="submit" class="btn btn-primary js-ajax-submit">{:L('ADD')}</button>
<a class="btn" href="{:U('Impression/index2')}">{:L('BACK')}</a>
</div>
</form>
</div>
<script src="__PUBLIC__/js/common.js"></script>
<script src="__PUBLIC__/colpick/colpick.js"></script>
<script>
(function(){
$('#picker').colpick({
layout:'hex',
submit:0,
colorScheme:'dark',
onChange:function(hsb,hex,rgb,el,bySetColor) {
$("#colour_block").css('background','#'+hex);
// Fill the text box just if the color was set using the picker, and not the colpickSetColor function.
if(!bySetColor) $(el).val(hex);
}
}).keyup(function(){
$(this).colpickSetColor(this.value);
});
})()
</script>
</body>
</html>
<admintpl file="header" />
<link href="__PUBLIC__/colpick/colpick.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="wrap">
<ul class="nav nav-tabs">
<li ><a href="{:U('Impression/index2')}">列表</a></li>
<li class="active"><a >编辑</a></li>
</ul>
<form method="post" class="form-horizontal js-ajax-form" action="{:U('Impression/edit_post2')}">
<input type="hidden" name="id" value="{$data['id']}">
<fieldset>
<div class="control-group">
<label class="control-label">名称</label>
<div class="controls">
<input type="text" name="name" value="{$data['name']}">
<span class="form-required">*</span>
</div>
</div>
<div class="control-group">
<label class="control-label">颜色</label>
<div class="controls">
<input type="text" name="colour" id="picker" value="{$data['colour']}"> <input id="colour_block" style="width:50px;height:20px;background:#{$data['colour']};" disabled/>
<span class="form-required">*</span> 内容为6位颜色16进制色码,点击可选择
</div>
</div>
</fieldset>
<div class="form-actions">
<button type="submit" class="btn btn-primary js-ajax-submit">{:L('EDIT')}</button>
<a class="btn" href="{:U('Impression/index2')}">{:L('BACK')}</a>
</div>
</form>
</div>
<script src="__PUBLIC__/js/common.js"></script>
<script src="__PUBLIC__/colpick/colpick.js"></script>
<script>
(function(){
$('#picker').colpick({
layout:'hex',
submit:0,
colorScheme:'dark',
onChange:function(hsb,hex,rgb,el,bySetColor) {
$("#colour_block").css('background','#'+hex);
// Fill the text box just if the color was set using the picker, and not the colpickSetColor function.
if(!bySetColor) $(el).val(hex);
}
}).keyup(function(){
$(this).colpickSetColor(this.value);
});
})()
</script>
</body>
</html>
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
<th align="center">ID</th> <th align="center">ID</th>
<th>名称</th> <th>名称</th>
<th>颜色</th> <th>颜色</th>
<th>创建时间</th>
<th align="center">{:L('ACTIONS')}</th> <th align="center">{:L('ACTIONS')}</th>
</tr> </tr>
</thead> </thead>
...@@ -22,10 +23,11 @@ ...@@ -22,10 +23,11 @@
<td align="center">{$vo.id}</td> <td align="center">{$vo.id}</td>
<td>{$vo['name']}</td> <td>{$vo['name']}</td>
<td><input style="width:50px;height:20px;background:#{$vo['colour']};" disabled/></td> <td><input style="width:50px;height:20px;background:#{$vo['colour']};" disabled/></td>
<td>{$vo.addtime|date="Y-m-d H:i:s",###}</td>
<td align="center"> <td align="center">
<a href="{:U('Impression/edit',array('id'=>$vo['id']))}" >编辑</a> <a href="{:U('Impression/edit2',array('id'=>$vo['id']))}" >编辑</a>
| |
<a href="{:U('Impression/del',array('id'=>$vo['id']))}" class="js-ajax-dialog-btn" data-msg="您确定要删除吗?">删除</a> <a href="{:U('Impression/del2',array('id'=>$vo['id']))}" class="js-ajax-dialog-btn" data-msg="您确定要删除吗?">删除</a>
</td> </td>
</tr> </tr>
</foreach> </foreach>
......
...@@ -99,7 +99,6 @@ class ImpressionController extends AdminbaseController { ...@@ -99,7 +99,6 @@ class ImpressionController extends AdminbaseController {
} }
$this->display(); $this->display();
} }
function edit_post(){ function edit_post(){
if(IS_POST){ if(IS_POST){
$name=I("name"); $name=I("name");
...@@ -139,12 +138,11 @@ class ImpressionController extends AdminbaseController { ...@@ -139,12 +138,11 @@ class ImpressionController extends AdminbaseController {
function index2(){ function index2(){
$gift_model=M("impression_label"); $gift_model=M("impression_label2");
$count=$gift_model->count(); $count=$gift_model->count();
$page = $this->page($count, 20); $page = $this->page($count, 20);
$lists = $gift_model $lists = $gift_model
//->where() //->where()
->order("orderno asc, id desc")
->limit($page->firstRow . ',' . $page->listRows) ->limit($page->firstRow . ',' . $page->listRows)
->select(); ->select();
$this->assign('lists', $lists); $this->assign('lists', $lists);
...@@ -152,4 +150,98 @@ class ImpressionController extends AdminbaseController { ...@@ -152,4 +150,98 @@ class ImpressionController extends AdminbaseController {
$this->display(); $this->display();
} }
function del2(){
$id=intval($_GET['id']);
if($id){
$result=M("impression_label2")->delete($id);
if($result){
$action="删除标签:{$id}";
setAdminLog($action);
$this->resetCache2();
$this->success('删除成功');
}else{
$this->error('删除失败');
}
}else{
$this->error('数据传入失败!');
}
$this->display();
}
function add2(){
$this->assign('time', time());
$this->display();
}
function add_post2(){
if(IS_POST){
$name=I("name");
if($name==''){
$this->error('请填写名称');
}
$colour=I("colour");
if($colour==''){
$this->error('请选择颜色');
}
$Live_class=M("impression_label2");
$Live_class->create();
$result=$Live_class->add();
if($result){
$action="添加标签:{$result}";
setAdminLog($action);
$this->resetCache2();
$this->success('添加成功');
}else{
$this->error('添加失败');
}
}
}
function edit2(){
$id=intval($_GET['id']);
if($id){
$data=M("impression_label2")->where("id={$id}")->find();
$this->assign('data', $data);
}else{
$this->error('数据传入失败!');
}
$this->display();
}
function edit_post2(){
if(IS_POST){
$name=I("name");
if($name==''){
$this->error('请填写名称');
}
$colour=I("colour");
if($colour==''){
$this->error('请选择颜色');
}
$Live_class=M("impression_label2");
$Live_class->create();
$result=$Live_class->save();
if($result!==false){
$action="修改标签:{$_POST['id']}";
setAdminLog($action);
$this->resetCache2();
$this->success('修改成功');
}else{
$this->error('修改失败');
}
}
}
function resetCache2(){
$key='getImpressionLabel2';
$rules= M("impression_label2")
->select();
foreach($rules as $k=>$v){
$rules[$k]['colour']='#'.$v['colour'];
}
setcaches($key,$rules);
return 1;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment