Wentihuizong.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. namespace app\company\controller;
  3. use app\common\controller\Apic;
  4. use think\Db;
  5. /**
  6. * 问题汇总
  7. */
  8. class Wentihuizong extends Apic
  9. {
  10. protected $noNeedLogin = [];
  11. protected $noNeedRight = [];
  12. protected $table = 'wentihuizong';
  13. public function index(){
  14. $map = [];
  15. $uc_id = input('uc_id',0);
  16. if($uc_id){
  17. $map['uc_id'] = $uc_id;
  18. }
  19. $list = Db::name($this->table)->alias('hz')
  20. ->join('user_company uc','hz.uc_id = uc.id','LEFT')
  21. ->field('hz.*,uc.projectname')
  22. ->where('hz.company_id',$this->auth->company_id)
  23. ->where($map)
  24. ->paginate();
  25. $total = $list->total();
  26. $list = $list->items();
  27. $rs = [
  28. 'list' => $list,
  29. 'total'=> $total,
  30. ];
  31. $this->success(1,$rs);
  32. }
  33. public function add(){
  34. $uc_id = input('uc_id','');
  35. $uc_info = Db::name('user_company')->where('id',$uc_id)->where('company_id',$this->auth->company_id)->find();
  36. if(empty($uc_info)){
  37. $this->error('不存在的客户');
  38. }
  39. $data = [
  40. 'company_id' => $this->auth->company_id,
  41. 'uc_id' => $uc_id,
  42. 'createtime' => time(),
  43. 'title' => input('title',''),
  44. 'finishtime' => input('finishtime','','strtotime'),
  45. 'remark' => input('remark',''),
  46. 'status' => input('status',1),
  47. ];
  48. Db::name($this->table)->insertGetId($data);
  49. $this->success();
  50. }
  51. public function info(){
  52. $id = input('id',0);
  53. $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->find();
  54. $this->success(1,$info);
  55. }
  56. public function edit(){
  57. $id = input('id',0);
  58. $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->find();
  59. if(empty($info)){
  60. $this->error('没找到该信息,请刷新重试');
  61. }
  62. $data = [
  63. 'title' => input('title',''),
  64. 'finishtime' => input('finishtime','','strtotime'),
  65. 'remark' => input('remark',''),
  66. 'status' => input('status',1),
  67. ];
  68. Db::name($this->table)->where('id',$id)->update($data);
  69. $this->success();
  70. }
  71. public function del(){
  72. $ids = input('ids','');
  73. $ids = explode(',',$ids);
  74. if (empty($ids)) {
  75. $this->error();
  76. }
  77. Db::name($this->table)->where('id','IN',$ids)->where('company_id',$this->auth->company_id)->delete();
  78. $this->success();
  79. }
  80. }