AdminController.php
2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php namespace App\Http\Controllers;
use Input;
use App\Models\User;
use App\Models\CRMCall;
use App\Models\Sipid;
use App\Models\Kqueue;
use App\Models\Dialline;
use App\Models\Session;
use Config;
class AdminController extends Controller {
public function __construct()
{
$this->middleware('auth');
$this->middleware('module_access');
}
public function index()
{
$data=array();
return view('layout.module.admin.index',$data);
}
public function create()
{
//
}
public function store()
{
$action=Input::get('action');
if($action=="mmtbulkupload")return view('layout.module.admin.index',array());
if($action=="userlogoutall")
{
$sipids=Sipid::where("status","=","1")->get();
foreach($sipids as $tsip)
{
$newqueue=new Kqueue();
$newqueue->sipNotify($tsip,"adminCommand","user","logout","");
}
Dialline::where('status','!=','Free')->update(['status'=>'Free','conf'=>'','channel'=>'','server'=>'','updated_at'=>'0000-00-00 00:00:00']);
Sipid::where('status','!=','0')->update(['status'=>0,'user'=>0,'ready'=>0,'confup'=>0,'clients'=>'','server'=>'','updated_at'=>'0000-00-00 00:00:00']);
$serverarray=explode(",",Config::get("app.asterisk_slaves"));
foreach($serverarray as $server)
{
$sparts=explode(":",$server);
Sipid::where("id",">=",$sparts[1])->where("id","<=",$sparts[2])->update(['server' => $sparts[0],'updated_at'=>'0000-00-00 00:00:00']);
Dialline::where("id",">=",$sparts[3])->where("id","<=",$sparts[4])->update(['server' => $sparts[0],'updated_at'=>'0000-00-00 00:00:00']);
$newqueue=new Kqueue();
$newqueue->astCommand($sparts[0],"channel request hangup all");
}
User::where('presence','>','0')->update(['presence'=>0]);
Session::truncate();
return "";
}
}
public function show($id)
{
$data=array();
if($id=='masterdata')return view('layout.module.admin.masterdata',$data);
if($id=='accesslog')return view('layout.module.admin.accesslog',$data);
if($id=='emaillog')return view('layout.module.admin.emaillog',$data);
if($id=='bulkmail')return view('layout.module.admin.bulkmail',$data);
if($id=='dllogfile')return response()->download(storage_path('logs/laravel-'.date('Y-m-d').'.log'));
if($id=='main')return view('layout.module.admin.main',$data);
if($id=='agentreport')return view('layout.module.admin.agentreport',$data);
if($id=='liveusers')return view('layout.module.admin.liveusers',$data);
}
public function edit($id)
{
//
}
public function update($id)
{
//
}
public function destroy($id)
{
//
}
public function dashboard()
{
$data=array();
return view('layout.module.admin.dashboard',$data);
}
}