EduDealDeleteAction.class.php 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Fanwe 方维直播系统
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: 云淡风轻(1956838968@qq.com)
  8. // +----------------------------------------------------------------------
  9. class EduDealDeleteAction extends CommonAction{
  10. public function index(){
  11. if (trim($_REQUEST['name']) != '') {
  12. $map['name'] = array('like', '%' . trim($_REQUEST['name']) . '%');
  13. }
  14. $user_id = intval($_REQUEST['user_id']);
  15. if ($user_id) {
  16. $map['user_id'] = array('eq', $user_id);
  17. }
  18. $create_time_2=empty($_REQUEST['create_time_2'])?to_date(get_gmtime(),'Y-m-d'):strim($_REQUEST['create_time_2']);
  19. $create_time_2=to_timespan($create_time_2)+24*3600;
  20. if(trim($_REQUEST['create_time_1'])!='')
  21. {
  22. $map["create_time"] = array('between',array(to_timespan($_REQUEST['create_time_1']),$create_time_2));
  23. }
  24. $map['is_delete']=1;
  25. if (method_exists($this, '_filter')) {
  26. $this->_filter($map);
  27. }
  28. $name = 'EduDeal';
  29. $model = M($name);
  30. if (!empty ($model)) {
  31. $this->_list($model, $map);
  32. }
  33. $this->display();
  34. }
  35. public function restore() {
  36. //彻底删除指定记录
  37. $ajax = intval($_REQUEST['ajax']);
  38. $id = $_REQUEST ['id'];
  39. if (isset ( $id )) {
  40. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  41. $rel_data = M('EduDeal')->where($condition)->findAll();
  42. foreach($rel_data as $data)
  43. {
  44. $info[] = $data['name'];
  45. }
  46. if($info) $info = implode(",",$info);
  47. $list = M('EduDeal')->where ( $condition )->setField("is_delete",0);
  48. if ($list!==false) {
  49. save_log($info."恢复成功",1);
  50. $this->success ("恢复成功",$ajax);
  51. } else {
  52. save_log($info."恢复出错",0);
  53. $this->error ("恢复出错",$ajax);
  54. }
  55. } else {
  56. $this->error (l("INVALID_OPERATION"),$ajax);
  57. }
  58. }
  59. public function foreverdelete() {
  60. //彻底删除指定记录
  61. $ajax = intval($_REQUEST['ajax']);
  62. $id = $_REQUEST ['id'];
  63. if (isset ( $id )) {
  64. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  65. $link_condition = array ('deal_id' => array ('in', explode ( ',', $id ) ) );
  66. $rel_data = M('EduDeal')->where($condition)->findAll();
  67. foreach($rel_data as $data)
  68. {
  69. $info[] = $data['name'];
  70. }
  71. if($info) $info = implode(",",$info);
  72. $list = M('EduDeal')->where ( $condition )->delete();
  73. if ($list!==false) {
  74. M("EduDealOrder")->where($link_condition)->delete();
  75. M("EduDealPayLog")->where($link_condition)->delete();
  76. save_log($info.l("FOREVER_DELETE_SUCCESS"),1);
  77. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  78. } else {
  79. save_log($info.l("FOREVER_DELETE_FAILED"),0);
  80. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  81. }
  82. } else {
  83. $this->error (l("INVALID_OPERATION"),$ajax);
  84. }
  85. }
  86. }
  87. ?>