GoodsCateAction.class.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Fanwe 方维p2p借贷系统
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: 云淡风轻(1956838968@qq.com)
  8. // +----------------------------------------------------------------------
  9. class GoodsCateAction extends CommonAction{
  10. public function index()
  11. {
  12. $name=$this->getActionName();
  13. $model = D ($name);
  14. if (! empty ( $model )) {
  15. $this->_list ( $model);
  16. }
  17. // $list = $this->get('list');
  18. // $this->assign("list",$list);
  19. $this->display ();
  20. }
  21. public function add()
  22. {
  23. $this->assign("new_sort", M(MODULE_NAME)->where("is_delete=0"));
  24. $this->display();
  25. }
  26. public function edit() {
  27. $id = intval($_REQUEST ['id']);
  28. $condition['id'] = $id;
  29. $vo = M(MODULE_NAME)->where($condition)->find();
  30. $this->assign ( 'vo', $vo );
  31. $this->display ();
  32. }
  33. public function insert() {
  34. B('FilterString');
  35. $data = M(MODULE_NAME)->create();
  36. //开始验证有效性
  37. $this->assign("jumpUrl",u(MODULE_NAME."/index"));
  38. if(!check_empty($data['name']))
  39. {
  40. $this->error(L("ARTICLECATE_TITLE_EMPTY_TIP"));
  41. }
  42. // 更新数据
  43. $log_info = $data['name'];
  44. $list=M(MODULE_NAME)->add($data);
  45. if (false !== $list) {
  46. //$this->create_httpd();
  47. //成功提示
  48. save_log($log_info.L("INSERT_SUCCESS"),1);
  49. $this->success(L("INSERT_SUCCESS"));
  50. } else {
  51. //错误提示
  52. save_log($log_info.L("INSERT_FAILED"),0);
  53. $this->error(L("INSERT_FAILED"));
  54. }
  55. }
  56. public function update() {
  57. $data = M(MODULE_NAME)->create ();
  58. $log_info = M(MODULE_NAME)->where("id=".intval($data['id']))->getField("name");
  59. //开始验证有效性
  60. $this->assign("jumpUrl",u(MODULE_NAME."/edit",array("id"=>$data['id'])));
  61. if(!check_empty($data['name']))
  62. {
  63. $this->error(L("ARTICLECATE_TITLE_EMPTY_TIP"));
  64. }
  65. $data['name'] = strim($data['name']);
  66. // 更新数据
  67. $list=M(MODULE_NAME)->save ($data);
  68. if (false !== $list) {
  69. //成功提示
  70. save_log($log_info.L("UPDATE_SUCCESS"),1);
  71. $this->success(L("UPDATE_SUCCESS"));
  72. } else {
  73. //错误提示
  74. save_log($log_info.L("UPDATE_FAILED"),0);
  75. $this->error(L("UPDATE_FAILED"),0,$log_info.L("UPDATE_FAILED"));
  76. }
  77. }
  78. public function delete() {
  79. //删除指定记录
  80. $ajax = intval($_REQUEST['ajax']);
  81. $id = $_REQUEST ['id'];
  82. if (isset ( $id )) {
  83. $condition['id'] = $id;
  84. $list = M(MODULE_NAME)->where($condition)->setField ( 'is_effect', 0 );
  85. if ($list!==false) {
  86. $result['info'] = "删除成功!";
  87. $result['status'] = 1;
  88. admin_ajax_return($result);
  89. } else {
  90. $result['info'] = "删除失败!";
  91. $result['status'] = 0;
  92. admin_ajax_return($result);
  93. }
  94. } else {
  95. $this->error (l("INVALID_OPERATION"),$ajax);
  96. }
  97. }
  98. // public function restore() {
  99. // //删除指定记录
  100. // $ajax = intval($_REQUEST['ajax']);
  101. // $id = $_REQUEST ['id'];
  102. // if (isset ( $id )) {
  103. // $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  104. // $rel_data = M(MODULE_NAME)->where($condition)->findAll();
  105. // foreach($rel_data as $data)
  106. // {
  107. // $info[] = $data['title'];
  108. // }
  109. // if($info) $info = implode(",",$info);
  110. // $list = M(MODULE_NAME)->where ( $condition )->setField ( 'is_delete', 0 );
  111. // if ($list!==false) {
  112. // save_log($info.l("RESTORE_SUCCESS"),1);
  113. // clear_auto_cache("cache_shop_acate_tree");
  114. // clear_auto_cache("deal_shop_acate_belone_ids");
  115. // clear_auto_cache("get_help_cache");
  116. // $this->success (l("RESTORE_SUCCESS"),$ajax);
  117. // } else {
  118. // save_log($info.l("RESTORE_FAILED"),0);
  119. // $this->error (l("RESTORE_FAILED"),$ajax);
  120. // }
  121. // } else {
  122. // $this->error (l("INVALID_OPERATION"),$ajax);
  123. // }
  124. // }
  125. // public function foreverdelete() {
  126. // //彻底删除指定记录
  127. // $ajax = intval($_REQUEST['ajax']);
  128. // $id = $_REQUEST ['id'];
  129. // if (isset ( $id )) {
  130. // $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  131. // if(M("Article")->where(array ('cate_id' => array ('in', explode ( ',', $id ) ) ))->count()>0)
  132. // {
  133. // $this->error (l("SUB_ARTICLE_EXIST"),$ajax);
  134. // }
  135. //
  136. // $rel_data = M(MODULE_NAME)->where($condition)->findAll();
  137. // foreach($rel_data as $data)
  138. // {
  139. // $info[] = $data['title'];
  140. // }
  141. // if($info) $info = implode(",",$info);
  142. // $list = M(MODULE_NAME)->where ( $condition )->delete();
  143. //
  144. // if ($list!==false) {
  145. // save_log($info.l("FOREVER_DELETE_SUCCESS"),1);
  146. // clear_auto_cache("cache_shop_acate_tree");
  147. // clear_auto_cache("deal_shop_acate_belone_ids");
  148. // clear_auto_cache("get_help_cache");
  149. // $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  150. // } else {
  151. // save_log($info.l("FOREVER_DELETE_FAILED"),0);
  152. // $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  153. // }
  154. // } else {
  155. // $this->error (l("INVALID_OPERATION"),$ajax);
  156. // }
  157. // }
  158. }
  159. ?>