批量删除
modelpublic function delete($order_id){
$condtion['order_id']=$order_id;
$this->db->where($condtion)->delete($this->tablename);
}
controller
public function order_delete(){
$order_id=$this->input->post('order_id',true);
$this->order_model->delete($order_id);
$result['status'] = "ok";
echo json_encode($result);
}
视图
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title></title>
<link href="<?php echo base_url('assets/cishop/admin/styles/general.css');?>" rel="stylesheet" type="text/css" />
<link href="<?php echo base_url('assets/cishop/admin/styles/main.css');?>" rel="stylesheet" type="text/css" />
<script src="http://cdn.staticfile.org/jquery/1.8.0/jquery.min.js"></script>
</head>
<body>
<?php
$array_address=$this->common->showaddress();
$array_order_state=$this->common->show_order_state();
$array_marry = $this->common->showmarry(); //获取婚姻情况
?>
<h1>
<span class="action-span1"><a href="">SHOP 管理中心</a> </span><span id="search_id" class="action-span1"> - 用户列表 </span>
<div style="clear:both"></div>
</h1>
<div class="form-div">
<form action="<?php echo base_url('admin/order_search');?>" method="get">
<img src="<?php echo base_url('assets/cishop/admin');?>/images/icon_search.gif" width="26" height="22" border="0" alt="SEARCH">
<!-- 分类 -->
<select name="order_status" id="order_status">
<option value="">所有状态</option>
<?php for($i=0;$i<count($array_order_state);$i++){?>
<optionvalue="<?php echo $i;?>"><?php echo $array_order_state[$i];?></option>
<?php }?>
</select>
<input type="submit" value=" 搜索 " class="button">
</form>
</div>
<form method="post" action="" name="listForm">
<!-- start goods list -->
<div class="list-div" id="listDiv">
<?php $per_page = isset($_GET['per_page']) ? $_GET['per_page'] : 0; ?>
<table cellpadding="3" cellspacing="1">
<tbody>
<tr>
<th></th><!--goods_id-->
<th>订单号</th><!--goods_id-->
<th>用户id</th><!--goods_name -->
<th>收货地址</th><!--goods_sn-->
<th>订单状态</th><!--shop_price -->
<th>送货方式</th><!--promote_price -->
<th>商品金额</th><!-- market_price-->
<th>下单时间</th>
<th>其他操作</th>
</tr>
<?php foreach($list as $row):?>
<tr>
<td><input type="checkbox"name="checktag[]" value="<?php echo $row['order_id'];?>"></td>
<td class="first-cell"><span><?php echo $row['order_sn']; ?></span></td>
<td align="right"><span><?php echo $row['user_id']; ?></span></td>
<td align="right"><span><?php echo $array_address[$row['address_id']]; ?></span></td>
<td align="right"><span><?php echo $array_order_state[$row['order_status']]; ?></span></td>
<td align="right"><span><?php echo $row['shipping_id']; ?></span></td>
<td align="right"><span><?php echo $row['goods_amount']; ?>元</span></td>
<td align="right"><span><?php echo date("Y-m-d,H:i:s",$row['order_time']); ?></span></td>
</span></td>
<td align="center">
<a href="<?php echo base_url('admin/order_delete');?>?order_id=<?php echo $row['order_id'];?>"onclick="return window.confirm('确定要删除吗?')"><img src="<?php echo base_url('assets/cishop/admin');?>/images/icon_trash.gif" width="16" height="16" border="0"></a>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<!-- end goods list -->
<ul class="pagination">
<?php echo $this->mypage->show(3); ?>
</ul>
<div class="form-div">
<form action="<?php echo base_url('');?>" method="post">
<tr>
<td colspan="11">
全选<input id="allbtn" type="checkbox">
反选:<input id="inversebtn" type="checkbox">
<button id="selectbtn" type="button" >开启</button>
<button id="delbtn" type="button" >批量删除</button>
</td>
</tr>
<select name="order_status">
<option value="">所有状态</option>
<?php for($i=0;$i<count($array_order_state);$i++){?>
<optionvalue="<?php echo $i;?>"><?php echo $array_order_state[$i];?></option>
<?php }?>
</select>
</form>
</div>
<script type="text/javascript">
/*设置 单选 反选 全选*/
$("document").ready(function(){
$("#allbtn").click(function(){
$("']").attr("checked",'true'); //全选
});
$("#cancelbtn").click(function(){
$("']").removeAttr("checked"); //取消全选
});
$("#inversebtn").click(function(){ //反选
$("']").each(function(){
if($(this).attr("checked")){
$(this).removeAttr("checked");
}
else{
$(this).attr("checked",'true');
}
});
});
});
</script>
<!-- jbox提示框 -->
<script type="text/javascript" src="<?php echo base_url('assets/jBox/');?>/jquery.jBox-2.3.min.js"></script>
<script type="text/javascript" src="<?php echo base_url('assets/jBox/');?>/i18n/jquery.jBox-zh-CN.js"></script>
<link type="text/css" rel="stylesheet" href="<?php echo base_url('assets/jBox/');?>/Skins/GrayCool/jbox.css"/>
<!--批量删除-->
<script type="text/javascript">
$(document).ready(function(){
$("#delbtn").click(function(){
var obj = document.getElementsByName('checktag[]');//选择所有name='tags'的对象,返回数组
//取到对象那数组后,循环检测它是不是被选中
var s='';
var order_id='';
for(var i=0;i<obj.length;i++){
if(obj.checked){
s+=obj.value+',';
}
}
if(s == ''){
alert("您还没有选择任何内容");
}else{
var submit = function (v, h, f) {
if (v == 'ok') {
$.jBox.tip("正在删除数据...", 'loading');
for(var i=0;i<obj.length;i++){
if(obj.checked){
order_id = obj.value;
$.ajax({
url: "<?php echo base_url('admin/order_delete');?>",
type: 'post',
data: "order_id="+order_id,
dataType: 'json',
success: function(d){
}
});
}
}
window.setTimeout(function () { $.jBox.tip('删除成功。', 'success'); window.location.reload(true);}, 2000);
}
return true; //close
};
$.jBox.confirm("确定要删除选中吗?", "温馨提示", submit);
}
});
});
</script>
<div id="footer">
版权所有 -
</div>
</body>
</html>
学习下 谢谢
页:
[1]