This commit is contained in:
2024-10-29 14:04:59 +08:00
commit 48bf3e6f33
2839 changed files with 762707 additions and 0 deletions

138
app/admin/controller/Inquiry.php Executable file
View File

@@ -0,0 +1,138 @@
<?php
/**
* Created by PhpStorm.
* User: ORICO
* Date: 2019-01-15
* Time: 11:01
*/
namespace app\admin\controller;
use think\Lang;
use think\Loader;
use think\Config;
class Inquiry extends BaseController
{
private function init_search(&$search){
$search['name'] = '';
$search['timebegin'] = '';
$search['timeend'] = '';
}
public function lists(){
$inquiry = Db('inquiry');
$data = $this->request->param();
$arg_where = ['siteid' => $this->siteid,'stat' => ['in','0,1'], 'country_code' => $this->country_code];
$search = [];
$this->init_search($search);
if (isset($data['name']) && $data['name'] != ''){
$arg_where['first_name|last_name|inquiry|phone'] = ['like', "%$data[name]%"];
$search['name'] = $data['name'];
}
if ((isset($data['timebegin']) && $data['timebegin'] != '') || (isset($data['timeend']) && $data['timeend'] != '')){
// 时间有一个不为空就初始化
$arg_where['createtime'] = [];
if (isset($data['timebegin']) && $data['timebegin'] != '')
{
$time = $data['timebegin'];
array_push($arg_where['createtime'], ['>=', $time]);
$search['timebegin'] = $data['timebegin'];
}
else{
array_push($arg_where['createtime'], ['>=', "0000-00-00"]);
}
if (isset($data['timeend']) && $data['timeend'] != '')
{
$time = $data['timeend'];
array_push($arg_where['createtime'], ['<=', $time]);
$search['timeend'] = $data['timeend'];
}
else{
$time = date('Y-m-d H:i:s',strtotime('+1 month'));
array_push($arg_where['createtime'], ['<=', $time]);
}
}
//
//$where = ['stat'=>0];
$list = $inquiry->where($arg_where)->select();
$count = count($list);
$list = $inquiry->where($arg_where)->paginate(20,$count);
$page = $list->render();
//dump($page);die;
$this->assign('search',$search);
$this->assign('page',$page);
$this->assign('list',$list);
return $this->fetch();
}
public function edit(){
$where = ['id '=>$_GET['id'],'stat'=>0];
$inquiry = Db('inquiry');
$data = $inquiry->where($where)->find();
$this->assign('data',$data);
return $this->fetch();
}
public function save(){
$data = $_POST;
$inquiry = Db('inquiry');
$inster = $inquiry->insert($data);
if($inster){
return $this->success('修改成功');
}else{
return $this->error('修改失败');
}
}
public function view($id = 0){
$id = intval($id);
$where = ['id '=>$id];
$inquiry = Db('Inquiry');
$data = $inquiry->where($where)->find();
$this->assign('data',$data);
return $this->fetch();
}
//2021-05-29 申邵 控制删除
public function delete($id = 0) {
//echo "<pre>====="; print_r($id);die;
$id = intval($id);
if ($id > 0) {
$result = model('Inquiry')->deleteRow($id);
if ($result) {
//echo $id."<pre>=+++++++++"; print_r($result);die;
return $this->success(Lang::get('operation successed'), url('/admin/Inquiry/lists'));
} else {
//echo "<pre>====="; print_r($result);die;
return $this->error(Lang::get('operation failed'));
}
}
return $this->error(Lang::get('incorrect operation'));
}
public function deletes() {
$ids = $this->request->post('ids');
if ($this->request->isPost() && $ids) {
$result = model('Inquiry')->deleteRows($ids);
if ($result) {
return $this->success(Lang::get('operation successed'), url('/admin/Inquiry/lists'));
} else {
return $this->error(Lang::get('operation failed'));
}
}
return $this->error(Lang::get('incorrect operation'));
}
}