59030e1f by Unnayan

First Commit

0 parents
Showing 1000 changed files with 5090 additions and 0 deletions

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

1 APP_ENV=local
2 APP_DEBUG=true
3 APP_ADMIN_DEBUG=true
4 APP_LOG_LEVEL=error
5 APP_KEY=LEynnBaQoqsLncOWZwgdtfxxWU2hEyfp
6 APP_PROTOCOL=http://
7 app_name=Flexydial
8 app_title=Flexydial
9 app_domain=localhost:8000
10 web_domain=localhost:8000
11 app_ip=localhost
12 asterisk_slaves=192.168.3.242:1001:2000:1:240
13 asterisk_manager=192.168.3.242
14 asterisk_extensions=31330,_X!
15
16
17 APP_Multiple_Logins=yes
18 kDialer_keeplocalconf=1
19
20 kstych_viewportMeta=responsive:1:1
21
22 DB_HOST=192.168.3.234
23 DB_DATABASE=fullerton
24 DB_USERNAME=root
25 DB_PASSWORD=yb9738z
26
27 CACHE_DRIVER=database
28 SESSION_DRIVER=database
29 SESSION_LIFEMin=43200
30 QUEUE_DRIVER=sync
31
32 #MAIL_DRIVER=smtp
33 #MAIL_HOST=localhost
34 #MAIL_PORT=587
35 #MAIL_USERNAME=mail
36 #MAIL_PASSWORD=mail
37 #[email protected]
38
39 AWS_KEY=
40 AWS_Secret=
41 AWS_Region=us-east-1
42 AWS_Bucket=
43
44 FS_DefaultDriver=local
45 FS_CloudDriver=s3
46
47 facebook_appid=
48 facebook_appkey=
49 gcm_apikey=
50
51
52 extAuth=
53 extAuthParams=
54
55 xssGlobal=tag,hent
56 xssGlobalIgnoreKeys=content,pdata,courseintroductiondiv,coursecoverphoto,data,rlog,rstring
57
58 MobileTitle=Flexydial
59
1 * text=auto
2 *.css linguist-vendored
3 *.less linguist-vendored
1 application/.env
2 application/storage/framework/sessions/
3 application/storage/framework/views/
4 application/storage/framework/cache/
5 custom/.env
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
1 <?php
2
3 namespace App\Jobs;
4
5 use Auth;
6 use Request;
7 use App\Models\User;
8 use App\Models\CRMCall;
9 use App\Models\AgentNumber;
10 use App\Models\Dialline;
11 use App\Models\Kqueue;
12 use Response;
13 use Log;
14 use Hash;
15
16 class DialerLib
17 {
18 /**
19 * To Create New CRM call entry based on calling details
20 */
21 public function createCRMCallEntry($crmdata, $ppldata)
22 {
23 $nowts = microtime(true) * 1000;
24 //start the call log
25 $crmcall = new CRMCall();
26 $crmdata['number'] = $this->arrayKey('number', $crmdata);
27 $crmcall->number = $this->arrayKey('mobile', $ppldata, $crmdata['number']);
28 $crmcall->user_id = $this->arrayKey('user_id', $crmdata, '0');
29 $crmcall->sipid_id = $this->arrayKey('sipid_id', $crmdata, '0');
30 $crmcall->crm_id = $ppldata['crm_id'];
31 $crmcall->client = $ppldata['client'];
32 $crmcall->department = $this->arrayKey('department', $ppldata);
33 $crmcall->state = 'New';
34 $crmcall->type = $crmdata['type']; //"MOutbound";
35 $crmcall->dialline_id = $crmdata['dialline_id'];
36 $crmcall->setTs('ts_Wait', $nowts);
37 $crmcall->setTs('ts_Call', $nowts);
38 $crmcall->did = $this->arrayKey('did', $crmdata);
39
40 $tdata = array();
41 $crmcall->data = json_encode($tdata);
42 $crmcall->save();
43 return $crmcall;
44 }
45 function arrayKey($key, $arraydata, $defaultval = '')
46 {
47 return (array_key_exists($key, $arraydata)) ? $arraydata[$key] : $defaultval;
48 }
49 function createAgentcallEntry($user)
50 {
51 $sipid = $this->mobileAgentlogin($user);
52 if ($sipid) {
53 $dialline = Dialline::where('enabled', '1')->where('status', 'Free')->where('server', env('app_ip'))->first();
54
55 if ($dialline) {
56 $dialline->status = "Agent";
57 $dialline->number = $sipid->number;
58 $dialline->save();
59
60 $crmcall = new CRMCall();
61 $crmcall->number = $sipid->number;
62 $crmcall->sipid_id = $sipid->id;
63 $crmcall->user_id = $user->id;
64 $crmcall->userstatus = "AgentCall";
65 $crmcall->usersubstatus = "AgentCall";
66 $crmcall->save();
67 $sipid->ready = 2;
68 $sipid->save();
69
70 $dialline->call_id = $crmcall->id;
71 $dialline->user_id = $user->id;
72 $dialline->save();
73
74 $newqueue = new Kqueue();
75 $newqueue->userToMobileAgent($sipid, $dialline);
76 } else {
77 return "error";
78 }
79 }
80 return $sipid;
81 }
82 function mobileAgentlogin($user)
83 {
84 $sipid = AgentNumber::where('user_id', $user->id)->first();
85 if ($sipid == null) $sipid = new AgentNumber();
86 if ($sipid) {
87 $sipid->number = $user->phone;
88 $sipid->campaign = $user->campaign;
89 $sipid->server = env('app_ip');
90 $sipid->user_id = $user->id;
91 $sipid->save();
92 }
93 return $sipid;
94 }
95 }
1 function restartServices
2 {
3 systemctl disable httpd.service
4 systemctl disable mariadb.service
5 systemctl disable ntpd.service
6 systemctl disable iptables.service
7 systemctl disable ip6tables.service
8 systemctl disable firewalld.service
9 systemctl disable cockpit.socket
10 systemctl disable asterisk.service
11 systemctl disable resiprocate-turn-server.service
12
13 systemctl stop httpd.service
14 systemctl stop mariadb.service
15 systemctl stop ntpd.service
16 systemctl stop iptables.service
17 systemctl stop ip6tables.service
18 systemctl stop firewalld.service
19 systemctl stop cockpit.socket
20 systemctl stop asterisk.service
21 systemctl stop resiprocate-turn-server.service
22
23 systemctl start httpd.service
24 systemctl start ntpd.service
25 systemctl start mariadb.service
26 systemctl start cockpit.socket
27 systemctl start resiprocate-turn-server.service
28 systemctl start asterisk.service
29 systemctl start iptables.service
30 systemctl start ip6tables.service
31
32 iptables -F
33
34 iptables -A INPUT -p tcp --dport 22 -j ACCEPT
35 iptables -A INPUT -p tcp --dport 25 -j ACCEPT
36 iptables -A INPUT -p tcp --dport 80 -j ACCEPT
37 iptables -A INPUT -p tcp --dport 443 -j ACCEPT
38 iptables -A INPUT -p tcp --dport 1935 -j ACCEPT
39 iptables -A INPUT -p tcp --dport 3478 -j ACCEPT
40 iptables -A INPUT -p tcp --dport 5038 -j ACCEPT
41 iptables -A INPUT -p tcp --dport 3306 -j ACCEPT
42 iptables -A INPUT -p tcp --dport 8088 -j ACCEPT
43 iptables -A INPUT -p tcp --dport 8089 -j ACCEPT
44 iptables -A INPUT -p tcp --dport 9090 -j ACCEPT
45 iptables -A INPUT -p tcp --match multiport --dports 10000:20000 -j ACCEPT
46 iptables -A INPUT -p udp --dport 3478 -j ACCEPT
47 iptables -A INPUT -p udp --match multiport --dports 10000:60000 -j ACCEPT
48 iptables -I OUTPUT -j ACCEPT
49 }
50
51 restartServices
1 #!/bin/bash
2
3 export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
4
5
6 echo asterisk -rx "sip show channels";
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4 //use Mail;
5 use DB;
6 use Config;
7
8 use App\Models\User;
9 use App\Models\Accesslog;
10
11 use App\Models\CRMCall;
12 use Schema;
13 use PDO;
14 use App\Models\Notification;
15 use App\Jobs\KHRMSLib;
16
17 use Input;
18 use Log;
19 use App\Models\Sipid;
20 use App\Models\Kqueue;
21 use App\Models\Dialline;
22 use App\Models\Session;
23 use App\Models\Cutoff;
24
25 use Illuminate\Database\Schema\Blueprint;
26
27 class CreateCall extends Command {
28
29 /**
30 * The console command name.
31 *
32 * @var string
33 */
34 protected $signature = 'CreateCall';
35
36 /**
37 * The console command description.
38 *
39 * @var string
40 */
41 protected $description = 'Create Pedictive Call If any User is Free';
42
43 /**
44 * Execute the console command.
45 *
46 * @return mixed
47 */
48 public function handle()
49 {
50 while(true)
51 {
52 usleep(5000000);
53 $this->runPredictive();
54 }
55 }
56
57 public function runPredictive()
58 {
59
60 try {
61 $this->updatePrepareColumn();
62 $usrArrs = $this->getActiveUsersCampaignWise("with");
63 $cntAndStrArr = $this->getActualAvailChannelCount();
64
65 $availChannel = $cntAndStrArr['cnt'];
66 $availDialStr = $cntAndStrArr['dialstr'];
67
68 if(count($usrArrs)){
69
70 //Log::useFiles(storage_path()."/logs/predictive_".date("Y_m_d").".log");
71 //Log::info($usrArrs);
72
73 //Log::useFiles(storage_path()."/logs/predictive_".date("Y_m_d").".log");
74 //Log::info("Channel=".$availChannel);
75
76 foreach ($usrArrs as $client => $usrArr) {
77 //Log::useFiles(storage_path()."/logs/predictive_".date("Y_m_d").".log");
78 //Log::info("campaign=".$client);
79
80 $acalls = $this->getCreateCallCount($client, count($usrArr));
81
82 $acalls = min($acalls, $availChannel);
83
84 //Log::useFiles(storage_path()."/logs/predictive_".date("Y_m_d").".log");
85 //Log::info("CallCount=".$acalls);
86
87 $this->CreateCall($client, $acalls, $availDialStr);
88 }
89 }
90 } catch (Exception $e) {
91 Log::useFiles(storage_path()."/logs/predictive_".date("Y_m_d").".log");
92 Log::error($e);
93 }
94 }
95
96 public function updatePrepareColumn()
97 {
98 $allClientUsrIdArr = array();
99 $updatedUserIdArr = array();
100 $currentTime = strtotime(date("Y-m-d H:i:s"));
101
102 $clientWiseUserIdArr = $this->getActiveUsersCampaignWise("without");
103
104 if(count($clientWiseUserIdArr)) {
105 //Log::useFiles(storage_path()."/logs/predictive_".date("Y_m_d").".log");
106 //Log::info("updatePrepareColumn");Log::info($clientWiseUserIdArr);
107
108 foreach ($clientWiseUserIdArr as $client => $usrIdArr) {
109 $allClientUsrIdArr = array_merge($allClientUsrIdArr, $usrIdArr);
110 }
111
112 $usersTimeArr = Cutoff::whereIn('user_id', $allClientUsrIdArr)->get();
113
114 foreach ($usersTimeArr as $userTimeArr) {
115 $cutOffTime = strtotime($userTimeArr->hangup_time) + ($userTimeArr->avg_dispo - $userTimeArr->avg_ring);
116
117 if($cutOffTime < $currentTime)
118 {
119 $updatedUserIdArr[] = $userTimeArr->user_id;
120 }
121 }
122
123 //if(count($updatedUserIdArr)) {
124 //Log::useFiles(storage_path()."/logs/predictive_".date("Y_m_d").".log");
125 //Log::info("updatedUserIdArr");Log::info($updatedUserIdArr);
126 //}
127
128 DB::table('sipids')->whereIn('user', $updatedUserIdArr)->update(['prepare_call'=>1]);
129 }
130 }
131
132 public function getActiveUsersCampaignWise($checkPrepareCol)
133 {
134 $campaignWiseUsrs = array();
135 $prepareUsrIds = array();
136
137 $loggedInSips = Sipid::where('server','=',env('app_ip'))->where("user", "!=", 0)->where("status","=","1");
138 if($checkPrepareCol=="with"){
139 $loggedInSips = $loggedInSips->where("prepare_call","=","1");
140 }
141 elseif($checkPrepareCol=="without"){
142 $loggedInSips = $loggedInSips->where("patched","=","0");
143 }
144
145 $loggedInSips = $loggedInSips->groupBy('user')->get();
146
147 if(count($loggedInSips)){
148
149 foreach ($loggedInSips as $loggedInSip) {
150 $prepareUsrIds[] = $loggedInSip->user;
151 }
152
153 //TODO: Change Dialmode Value in the column Of User Table (Ready to Predictive)
154 $usersLoggedIn = User::whereIn('id', $prepareUsrIds);
155 if($checkPrepareCol=="without")$usersLoggedIn = $usersLoggedIn->where('current_dialmode', '=', 'Predictive');
156 $usersLoggedIn = $usersLoggedIn->select('id','sel_campaign')->get();
157
158 foreach ($usersLoggedIn as $userLoggedIn) {
159 $campaignWiseUsrs[$userLoggedIn->sel_campaign][] = $userLoggedIn->id;
160 }
161 }
162 return $campaignWiseUsrs;
163 }
164
165 public function getActualAvailChannelCount()
166 {
167 $data = array();
168 $cnt = 0;
169 $allChanlCnt = $this->getSpanCount();
170 $dialstr = "";
171
172 $diallineVal = Dialline::where('server','=', env('app_ip'))->where("status","=","Free")->where("dialstr","!=","")->where("enabled","=","1")->select('dialstr')->first();
173
174 //TODO: When SIP and Dahdi both are active
175 if(count($diallineVal)){
176 if(stristr($diallineVal->dialstr,"Dahdi")){
177 $dialedCnt = $this->getActualDahdiDialedCallCount();
178
179 $cnt = $allChanlCnt - $dialedCnt;
180 }
181 elseif(stristr($diallineVal->dialstr,"GATEWAY")){
182 $dialedCnt = $this->getActualSipDialedCallCount();
183
184 $cnt = $allChanlCnt - $dialedCnt;
185 }
186
187 $dialstr = $diallineVal->dialstr;
188 }
189
190 $data['cnt'] = $cnt;
191 $data['dialstr'] = $dialstr;
192
193 return $data;
194 }
195
196 public function getActualSipDialedCallCount()
197 {
198 $allChnnlArr = array();
199 $dialstr = "Dial(SIP/GATEWAY/";
200 $chnlCnt = 0;
201
202 exec("/usr/sbin/asterisk -rx 'core show channels'",$allChnnls);
203
204 foreach($allChnnls as $allChnnl){
205 //$allChnnlArr[] = explode(" ", preg_replace('!\s+!', ' ', $allChnnl) );
206 if(stristr($allChnnl, $dialstr)){
207 $chnlCnt++;
208 }
209 }
210
211 return $chnlCnt;
212 }
213
214 public function getActualDahdiDialedCallCount()
215 {
216 $allChnnlArr = array();
217 $dialstr = "- ACTIVE";
218 $status = "RED";
219 $chnlCnt = 0;
220
221 //exec("/usr/sbin/asterisk -rx 'service dahdi status'",$allChnnls);
222 exec("service dahdi status",$allChnnls);
223
224 foreach($allChnnls as $allChnnl){
225 //$allChnnlArr[] = explode(" ", preg_replace('!\s+!', ' ', $allChnnl) );
226 if(stristr($allChnnl, $status)){
227 Break;
228 }
229
230 if(stristr($allChnnl, $dialstr)){
231 $chnlCnt++;
232 }
233 }
234
235 return $chnlCnt;
236 }
237
238 //TODO: Generate Client File To Take All Parameteres Of Campaigns
239 public function getCreateCallCount($client, $usrCnt)
240 {
241 $wakka = new KHRMSLib();
242 $mastersdata=$wakka->getCompanyMaster($client);
243
244 $ratio = $mastersdata["autodialercampaign"];
245 $dialedCallCnt = $this->getDialedCallCount($client);
246
247 return ($usrCnt*$ratio) - $dialedCallCnt;
248 }
249
250 public function getDialedCallCount($client)
251 {
252 $cnt = Dialline::whereIn("status", ["Auto","AutoCall"])->where("conf","=","")->where("regexstr","=",$client)->count();
253
254 return $cnt;
255 }
256
257 public function CreateCall($client, $acalls, $availDialStr)
258 {
259 if($acalls>0)
260 {
261 for($i=1;$i<=$acalls;$i++)
262 {
263 $this->createCrmCall($client, $availDialStr);
264 }
265 }
266 }
267
268 public function useChannelToDial($client, $availDialStr)
269 {
270 $retCrmCall = 0;
271 $dialline=Dialline::where('server','=', env('app_ip'))->where("status","=","Free")->where("enabled","=","1")->where("dialstr", "=", $availDialStr)->orderBy('updated_at','ASC')->first();
272
273 //TODO::Need To Code Dspan Logic as per discussion
274 //if($dspan!="")$dialline=$dialline->where('dspan','=',$dspan)->where('id','<=','30');
275 //$dialline=$dialline->orderBy('id','ASC')->first();
276
277 if(!empty($dialline))
278 {
279 $dialline->status="Incall";
280 $dialline->save();
281
282 $retCrmCall = $this->createCrmCall($client, $dialline);
283 }
284
285 if(!$retCrmCall && !empty($dialline))
286 {
287 $dialline->status="Free";
288 $dialline->save();
289 }
290
291 return;
292 }
293
294 public function createCrmCall($client, $availDialStr)
295 {
296 //TODO: Need to check whether callerid is required or not (in case of GSM Gateway)
297 $callerid="";
298 $wakka = new KHRMSLib();
299
300 //TODO::Need To Add Sequence Logic Here
301 $users=$wakka->getPersons("client='$client' and status='New' and mobile!='' limit 1");
302
303 if(sizeof($users)>=1)
304 {
305 $dialline=Dialline::where('server','=', env('app_ip'))->where("status","=","Free")->where("enabled","=","1")->where("dialstr", "=", $availDialStr)->orderBy('updated_at','ASC')->first();
306
307 if(!empty($dialline))
308 {
309 $dialline->status="AutoCall";
310 $dialline->regexstr=$client;
311 $dialline->number=$users[0]["mobile"];
312 $dialline->save();
313
314 $record=$wakka->getPerson($users[0]['id']);
315 if($record)
316 {
317 $record["peopledata"]["status"]="AutoCall";
318 $wakka->setPerson($users[0]['id'],$record);
319 }
320
321 $nowts=microtime(true)*1000;
322
323 //start the call log
324 $crmcall=new CRMCall();
325 $crmcall->number=$users[0]["mobile"];
326 $crmcall->user_id=0;
327 $crmcall->sipid_id=0;
328 $crmcall->crm_id=$users[0]['id'];
329 $crmcall->lan=$users[0]['lan'];
330 $crmcall->client=$users[0]['client'];
331 $crmcall->department=$users[0]['department'];
332 $crmcall->state='New';
333 $crmcall->type="AutoCall";
334 $crmcall->dialline_id=$dialline->id;
335
336 $crmcall->setTs('ts_Wait',$nowts);
337 $crmcall->setTs('ts_Call',$nowts);
338
339 $crmcall->did=$callerid;
340
341 $tdata=array();
342 $crmcall->data=json_encode($tdata);
343 $crmcall->save();
344
345 $dialline->call_id=$crmcall->id;
346 $dialline->save();
347
348 //start actual calls
349 $newqueue=new Kqueue();
350 $newqueue->autoCallOut($users[0]["mobile"],$callerid,$crmcall,$dialline);
351
352 return 1;
353 }
354 }
355 return 0;
356 }
357
358 public function getSpanCount()
359 {
360 $spanArr = array("span1" => 30, "span2" => 30, "span3" => 0, "span4" => 0);
361
362 $cnt = array_sum($spanArr);
363
364 return $cnt;
365 }
366 }
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4 //use Mail;
5 use DB;
6 // use Config;
7
8 // use App\Models\User;
9 // use App\Models\Accesslog;
10
11 // use App\Models\CRMCall;
12 // use Schema;
13 // use PDO;
14 // use App\Models\Notification;
15 // use App\Jobs\KHRMSLib;
16
17 // use Input;
18 // use App\Models\Sipid;
19 // use App\Models\Kqueue;
20 // use App\Models\Dialline;
21 // use App\Models\Session;
22
23 // use Illuminate\Database\Schema\Blueprint;
24
25 class ClearDiallines extends Command {
26
27 /**
28 * The console command name.
29 *
30 * @var string
31 */
32 protected $signature = 'ClearDiallines';
33
34 /**
35 * The console command description.
36 *
37 * @var string
38 */
39 protected $description = 'Clear diallines if it is not in use';
40
41 /**
42 * Execute the console command.
43 *
44 * @return mixed
45 */
46 public function handle()
47 {
48 DB::update(DB::raw("update diallines set status='Free' where channel='' and status='Blocked'"));
49 }
50 }
51
52
53
54
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4 //use Mail;
5 use DB;
6 use Config;
7
8 use App\Models\User;
9 use App\Models\Accesslog;
10
11 use App\Models\CRMCall;
12 use Schema;
13 use PDO;
14 use App\Models\Notification;
15 use App\Jobs\KHRMSLib;
16
17 use Input;
18 use Log;
19 use App\Models\Sipid;
20 use App\Models\Kqueue;
21 use App\Models\Dialline;
22 use App\Models\Session;
23 use App\Models\Cutoff;
24
25 use Illuminate\Database\Schema\Blueprint;
26
27 class CreateCall extends Command {
28
29 /**
30 * The console command name.
31 *
32 * @var string
33 */
34 protected $signature = 'CreateCall';
35
36 /**
37 * The console command description.
38 *
39 * @var string
40 */
41 protected $description = 'Create Pedictive Call If any User is Free';
42
43 /**
44 * Execute the console command.
45 *
46 * @return mixed
47 */
48 public function handle()
49 {
50 while(true)
51 {
52 usleep(5000000);
53 $this->runPredictive();
54 }
55 }
56
57 public function runPredictive()
58 {
59
60 try {
61 $this->updatePrepareColumn();
62 $usrArrs = $this->getActiveUsersCampaignWise("with");
63 $cntAndStrArr = $this->getActualAvailChannelCount();
64 log::info("count");
65 log::info($cntAndStrArr);
66 $availChannel = $cntAndStrArr['cnt'];
67 $availDialStr = $cntAndStrArr['dialstr'];
68 log::info("users");
69 log::info($usrArrs);
70 if(count($usrArrs)){
71
72 //Log::useFiles(storage_path()."/logs/predictive_".date("Y_m_d").".log");
73 //Log::info($usrArrs);
74
75 //Log::useFiles(storage_path()."/logs/predictive_".date("Y_m_d").".log");
76 //Log::info("Channel=".$availChannel);
77
78 foreach ($usrArrs as $client => $usrArr) {
79 Log::useFiles(storage_path()."/logs/predictive_".date("Y_m_d").".log");
80 Log::info("campaign=".$client);
81
82 $acalls = $this->getCreateCallCount($client, count($usrArr));
83 log::info("callbount".$acalls);
84 $acalls = min($acalls, $availChannel);
85 log::info("min".$acalls);
86 //Log::useFiles(storage_path()."/logs/predictive_".date("Y_m_d").".log");
87 //Log::info("CallCount=".$acalls);
88
89 $this->CreateCall($client, $acalls, $availDialStr);
90 }
91 }
92 } catch (Exception $e) {
93 Log::useFiles(storage_path()."/logs/predictive_".date("Y_m_d").".log");
94 Log::error($e);
95 }
96 }
97
98 public function updatePrepareColumn()
99 {
100 $allClientUsrIdArr = array();
101 $updatedUserIdArr = array();
102 $currentTime = strtotime(date("Y-m-d H:i:s"));
103
104 $clientWiseUserIdArr = $this->getActiveUsersCampaignWise("without");
105
106 if(count($clientWiseUserIdArr)) {
107 //Log::useFiles(storage_path()."/logs/predictive_".date("Y_m_d").".log");
108 //Log::info("updatePrepareColumn");Log::info($clientWiseUserIdArr);
109
110 foreach ($clientWiseUserIdArr as $client => $usrIdArr) {
111 $allClientUsrIdArr = array_merge($allClientUsrIdArr, $usrIdArr);
112 }
113
114 $usersTimeArr = Cutoff::whereIn('user_id', $allClientUsrIdArr)->get();
115
116 foreach ($usersTimeArr as $userTimeArr) {
117 $cutOffTime = strtotime($userTimeArr->hangup_time) + ($userTimeArr->avg_dispo - $userTimeArr->avg_ring);
118
119 if($cutOffTime < $currentTime)
120 {
121 $updatedUserIdArr[] = $userTimeArr->user_id;
122 }
123 }
124
125 //if(count($updatedUserIdArr)) {
126 //Log::useFiles(storage_path()."/logs/predictive_".date("Y_m_d").".log");
127 //Log::info("updatedUserIdArr");Log::info($updatedUserIdArr);
128 //}
129 log::info("came");
130 log::info($updatedUserIdArr);
131 DB::table('sipids')->whereIn('user', $updatedUserIdArr)->update(['prepare_call'=>1]);
132 }
133 }
134
135 public function getActiveUsersCampaignWise($checkPrepareCol)
136 {
137 $campaignWiseUsrs = array();
138 $prepareUsrIds = array();
139 log::info("env".env('app_ip'));
140 $loggedInSips = Sipid::where('server','=',env('app_ip'))->where("user", "!=", 0)->where("status","=","1");
141 if($checkPrepareCol=="with"){
142 $loggedInSips = $loggedInSips->where("prepare_call","=","1");
143 }
144 elseif($checkPrepareCol=="without"){
145 $loggedInSips = $loggedInSips->where("patched","=","0");
146 }
147
148 $loggedInSips = $loggedInSips->groupBy('user')->get();
149
150 if(count($loggedInSips)){
151
152 foreach ($loggedInSips as $loggedInSip) {
153 $prepareUsrIds[] = $loggedInSip->user;
154 }
155
156 //TODO: Change Dialmode Value in the column Of User Table (Ready to Predictive)
157 $usersLoggedIn = User::whereIn('id', $prepareUsrIds);
158 if($checkPrepareCol=="without")$usersLoggedIn = $usersLoggedIn->where('current_dialmode', '=', 'Predictive');
159 $usersLoggedIn = $usersLoggedIn->select('id','sel_campaign')->get();
160
161 foreach ($usersLoggedIn as $userLoggedIn) {
162 $campaignWiseUsrs[$userLoggedIn->sel_campaign][] = $userLoggedIn->id;
163 }
164 }
165 log::info("campaignwine");
166 log::info($campaignWiseUsrs);
167 return $campaignWiseUsrs;
168 }
169
170 public function getActualAvailChannelCount()
171 {
172 $data = array();
173 $cnt = 0;
174 $allChanlCnt = $this->getSpanCount();
175 $dialstr = "";
176 log::info($allChanlCnt);
177 log::info("all channel");
178 $diallineVal = Dialline::where('server','=', '10.4.105.141')->where("status","=","Free")->where("dialstr","!=","")->where("enabled","=","1")->select('dialstr')->first();
179 log::info($diallineVal);
180 //TODO: When SIP and Dahdi both are active
181 if(count($diallineVal)){
182 if(stristr($diallineVal->dialstr,"Dahdi")){
183 $dialedCnt = $this->getActualDahdiDialedCallCount();
184
185 $cnt = $allChanlCnt - $dialedCnt;
186 }
187 elseif(stristr($diallineVal->dialstr,"GATEWAY")){
188 $dialedCnt = $this->getActualSipDialedCallCount();
189
190 $cnt = $allChanlCnt - $dialedCnt;
191 }
192
193 $dialstr = $diallineVal->dialstr;
194 }
195
196 $data['cnt'] = $cnt;
197 $data['dialstr'] = $dialstr;
198
199 return $data;
200 }
201
202 public function getActualSipDialedCallCount()
203 {
204 $allChnnlArr = array();
205 $dialstr = "Dial(SIP/GATEWAY/";
206 $chnlCnt = 0;
207
208 exec("/usr/sbin/asterisk -rx 'core show channels'",$allChnnls);
209
210 foreach($allChnnls as $allChnnl){
211 //$allChnnlArr[] = explode(" ", preg_replace('!\s+!', ' ', $allChnnl) );
212 if(stristr($allChnnl, $dialstr)){
213 $chnlCnt++;
214 }
215 }
216
217 return $chnlCnt;
218 }
219
220 public function getActualDahdiDialedCallCount()
221 {
222 $allChnnlArr = array();
223 $dialstr = "- ACTIVE";
224 $status = "RED";
225 $chnlCnt = 0;
226
227 //exec("/usr/sbin/asterisk -rx 'service dahdi status'",$allChnnls);
228 exec("service dahdi status",$allChnnls);
229
230 foreach($allChnnls as $allChnnl){
231 //$allChnnlArr[] = explode(" ", preg_replace('!\s+!', ' ', $allChnnl) );
232 if(stristr($allChnnl, $status)){
233 Break;
234 }
235
236 if(stristr($allChnnl, $dialstr)){
237 $chnlCnt++;
238 }
239 }
240
241 return $chnlCnt;
242 }
243
244 //TODO: Generate Client File To Take All Parameteres Of Campaigns
245 public function getCreateCallCount($client, $usrCnt)
246 {
247 $wakka = new KHRMSLib();
248 $mastersdata=$wakka->getCompanyMaster($client);
249
250 $ratio = $mastersdata["autodialercampaign"];
251 $dialedCallCnt = $this->getDialedCallCount($client);
252
253 return ($usrCnt*$ratio) - $dialedCallCnt;
254 }
255
256 public function getDialedCallCount($client)
257 {
258 $cnt = Dialline::whereIn("status", ["Auto","AutoCall"])->where("conf","=","")->where("regexstr","=",$client)->count();
259
260 return $cnt;
261 }
262
263 public function CreateCall($client, $acalls, $availDialStr)
264 {
265 if($acalls>0)
266 {
267 for($i=1;$i<=$acalls;$i++)
268 {
269 $this->createCrmCall($client, $availDialStr);
270 }
271 }
272 }
273
274 public function useChannelToDial($client, $availDialStr)
275 {
276 $retCrmCall = 0;
277 $dialline=Dialline::where('server','=', env('app_ip'))->where("status","=","Free")->where("enabled","=","1")->where("dialstr", "=", $availDialStr)->orderBy('updated_at','ASC')->first();
278
279 //TODO::Need To Code Dspan Logic as per discussion
280 //if($dspan!="")$dialline=$dialline->where('dspan','=',$dspan)->where('id','<=','30');
281 //$dialline=$dialline->orderBy('id','ASC')->first();
282
283 if(!empty($dialline))
284 {
285 $dialline->status="Incall";
286 $dialline->save();
287
288 $retCrmCall = $this->createCrmCall($client, $dialline);
289 }
290
291 if(!$retCrmCall && !empty($dialline))
292 {
293 $dialline->status="Free";
294 $dialline->save();
295 }
296
297 return;
298 }
299
300 public function createCrmCall($client, $availDialStr)
301 {
302 //TODO: Need to check whether callerid is required or not (in case of GSM Gateway)
303 $callerid="";
304 $wakka = new KHRMSLib();
305
306 //TODO::Need To Add Sequence Logic Here
307 $users=$wakka->getPersons("client='$client' and status='New' and mobile!='' limit 1");
308 log::info($users);
309 if(sizeof($users)>=1)
310 {
311 $dialline=Dialline::where('server','=', env('app_ip'))->where("status","=","Free")->where("enabled","=","1")->where("dialstr", "=", $availDialStr)->orderBy('updated_at','ASC')->first();
312 log::info($availDialStr);
313 if(!empty($dialline))
314 {
315 $dialline->status="AutoCall";
316 $dialline->regexstr=$client;
317 $dialline->number=$users[0]["mobile"];
318 $dialline->save();
319
320 $record=$wakka->getPerson($users[0]['id']);
321 if($record)
322 {
323 $record["peopledata"]["status"]="AutoCall";
324 $wakka->setPerson($users[0]['id'],$record);
325 }
326
327 $nowts=microtime(true)*1000;
328
329 //start the call log
330 $crmcall=new CRMCall();
331 $crmcall->number=$users[0]["mobile"];
332 $crmcall->user_id=0;
333 $crmcall->sipid_id=0;
334 $crmcall->crm_id=$users[0]['id'];
335 $crmcall->lan=$users[0]['lan'];
336 $crmcall->client=$users[0]['client'];
337 $crmcall->department=$users[0]['department'];
338 $crmcall->state='New';
339 $crmcall->type="AutoCall";
340 $crmcall->dialline_id=$dialline->id;
341
342 $crmcall->setTs('ts_Wait',$nowts);
343 $crmcall->setTs('ts_Call',$nowts);
344
345 $crmcall->did=$callerid;
346
347 $tdata=array();
348 $crmcall->data=json_encode($tdata);
349 $crmcall->save();
350
351 $dialline->call_id=$crmcall->id;
352 $dialline->save();
353
354 //start actual calls
355 $newqueue=new Kqueue();
356 $newqueue->autoCallOut($users[0]["mobile"],$callerid,$crmcall,$dialline);
357
358 return 1;
359 }
360 }
361 return 0;
362 }
363
364 public function getSpanCount()
365 {
366 $spanArr = array("span1" => 30, "span2" => 30, "span3" => 0, "span4" => 0);
367
368 $cnt = array_sum($spanArr);
369
370 return $cnt;
371 }
372 }
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4 //use Mail;
5 use DB;
6 use Config;
7
8 use App\Models\User;
9 use App\Models\Accesslog;
10
11 use App\Models\CRMCall;
12 use Schema;
13 use PDO;
14 use App\Models\Notification;
15 use App\Jobs\KHRMSLib;
16
17 use Input;
18 use App\Models\Sipid;
19 use App\Models\Kqueue;
20 use App\Models\Dialline;
21 use App\Models\Session;
22
23 use Illuminate\Database\Schema\Blueprint;
24
25 class DailyLogout extends Command {
26
27 /**
28 * The console command name.
29 *
30 * @var string
31 */
32 protected $signature = 'DailyLogout';
33
34 /**
35 * The console command description.
36 *
37 * @var string
38 */
39 protected $description = 'DailyLogout';
40
41 /**
42 * Execute the console command.
43 *
44 * @return mixed
45 */
46 public function handle()
47 {
48 $sipids=Sipid::where("status","=","1")->get();
49 foreach($sipids as $tsip)
50 {
51 $newqueue=new Kqueue();
52 $newqueue->sipNotify($tsip,"adminCommand","user","logout","");
53 }
54
55 Dialline::where('status','!=','Free')->update(['status'=>'Free','conf'=>'','channel'=>'','server'=>'','updated_at'=>'0000-00-00 00:00:00']);
56 Sipid::where('status','!=','0')->update(['status'=>0,'user'=>0,'ready'=>0,'confup'=>0,'clients'=>'','server'=>'','updated_at'=>'0000-00-00 00:00:00']);
57
58 $serverarray=explode(",",Config::get("app.asterisk_slaves"));
59 foreach($serverarray as $server)
60 {
61 $sparts=explode(":",$server);
62
63 Sipid::where("id",">=",$sparts[1])->where("id","<=",$sparts[2])->update(['server' => $sparts[0],'updated_at'=>'0000-00-00 00:00:00']);
64 Dialline::where("id",">=",$sparts[3])->where("id","<=",$sparts[4])->update(['server' => $sparts[0],'updated_at'=>'0000-00-00 00:00:00']);
65
66 $newqueue=new Kqueue();
67 $newqueue->astCommand($sparts[0],"channel request hangup all");
68 }
69
70 User::where('presence','>','0')->update(['presence'=>0]);
71 Session::truncate();
72
73 return "";
74 }
75 }
76
77
78
79
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4 //use Mail;
5 use DB;
6 use Config;
7
8 use App\Models\User;
9 use App\Models\Accesslog;
10
11 use App\Models\CRMCallArchive;
12 use Schema;
13 use PDO;
14 use App\Models\Notification;
15 use App\Jobs\KHRMSLib;
16
17 use Input;
18 use App\Models\Sipid;
19 use App\Models\Kqueue;
20 use App\Models\Dialline;
21 use App\Models\Session;
22
23 use Illuminate\Database\Schema\Blueprint;
24
25 class DeleteCRMCallArchive extends Command {
26
27 /**
28 * The console command name.
29 *
30 * @var string
31 */
32 protected $signature = 'DeleteCRMCallArchive';
33
34 /**
35 * The console command description.
36 *
37 * @var string
38 */
39 protected $description = 'Delete data from CRMCallArchive before 6 months';
40
41 /**
42 * Execute the console command.
43 *
44 * @return mixed
45 */
46 public function handle()
47 {
48 $logdate=strtotime('-6 months');
49
50 CRMCallArchive::where('created_at','<',date("Y-m-d",$logdate))->delete();
51 }
52 }
53
54
55
56
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4 //use Mail;
5 use DB;
6 use Config;
7
8 use App\Models\User;
9 use App\Models\Accesslog;
10
11 use App\Models\CRMCall;
12 use Schema;
13 use PDO;
14 use App\Models\Notification;
15 use App\Jobs\KHRMSLib;
16
17 use Input;
18 use App\Models\Sipid;
19 use App\Models\Kqueue;
20 use App\Models\Dialline;
21 use App\Models\Session;
22
23 use Illuminate\Database\Schema\Blueprint;
24
25 class DeleteCrmcalls extends Command {
26
27 /**
28 * The console command name.
29 *
30 * @var string
31 */
32 protected $signature = 'DeleteCrmcalls';
33
34 /**
35 * The console command description.
36 *
37 * @var string
38 */
39 protected $description = 'Delete data from CRMCalls before 7 days';
40
41 /**
42 * Execute the console command.
43 *
44 * @return mixed
45 */
46 public function handle()
47 {
48 $logdate=strtotime('-7 day');
49
50 CRMCall::where('created_at','<',date("Y-m-d",$logdate))->delete();
51 }
52 }
53
54
55
56
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4 use Mail;
5 use DB;
6 use Config;
7
8 use App\Models\User;
9 use App\Models\Accesslog;
10
11 use App\Models\CRMCall;
12 use Schema;
13 use PDO;
14 use App\Models\Notification;
15 use App\Jobs\KHRMSLib;
16
17 use Input;
18 use App\Models\Sipid;
19 use App\Models\Kqueue;
20 use App\Models\Dialline;
21 use App\Models\Session;
22
23 use Illuminate\Database\Schema\Blueprint;
24
25 class HangupCall extends Command {
26
27 /**
28 * The console command name.
29 *
30 * @var string
31 */
32 protected $signature = 'HangupCall';
33
34 /**
35 * The console command description.
36 *
37 * @var string
38 */
39 protected $description = 'Hangup Long Wait Call';
40
41 /**
42 * Execute the console command.
43 *
44 * @return mixed
45 */
46 public function handle()
47 {
48 $Diallines = Dialline::where("status","=","Auto")->where("conf","=","")->where("channel","!=","")->get();
49
50 foreach ($Diallines as $key => $Dialline) {
51
52 $to_time = strtotime(date("Y-m-d H:i:s"));
53 $from_time = strtotime($Dialline->updated_at);
54
55 $diff_time = round(abs($to_time - $from_time)/60,2);
56
57 if($diff_time>2)
58 {
59 $newqueue=new Kqueue();
60 $newqueue->hangupChannel($Dialline);
61 }
62 }
63 }
64 }
65
66
67
68
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4 //use Mail;
5 use DB;
6 use Config;
7
8 use App\Models\User;
9 use App\Models\Accesslog;
10
11 use App\Models\CRMCall;
12 use Schema;
13 use PDO;
14 use App\Models\Notification;
15 use App\Jobs\KHRMSLib;
16
17 use Input;
18 use App\Models\Sipid;
19 use App\Models\Kqueue;
20 use App\Models\Dialline;
21 use App\Models\Session;
22
23 use Illuminate\Database\Schema\Blueprint;
24
25 class InsertCrmArchive extends Command {
26
27 /**
28 * The console command name.
29 *
30 * @var string
31 */
32 protected $signature = 'InsertCrmArchive';
33
34 /**
35 * The console command description.
36 *
37 * @var string
38 */
39 protected $description = 'Insert updated data into crmcalls_archive from crmcalls';
40
41 /**
42 * Execute the console command.
43 *
44 * @return mixed
45 */
46 public function handle()
47 {
48 echo 'Start';
49
50 $minidObj = DB::selectOne(DB::raw("SELECT MIN(id) AS min_id FROM crmcalls_archive WHERE created_at >= DATE_SUB((SELECT MAX(created_at) from crmcalls_archive), INTERVAL 1 HOUR)"));
51
52 $min_id = $minidObj->min_id;
53
54 DB::delete(DB::raw("DELETE FROM crmcalls_archive WHERE id >= '$min_id'"));
55
56 DB::insert(DB::raw("insert into crmcalls_archive select * from crmcalls where id>(select max(id) from crmcalls_archive)"));
57
58 echo 'End';
59 }
60 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4 //use Mail;
5 use DB;
6 use Config;
7
8 use App\Models\User;
9 use App\Models\Accesslog;
10
11 use App\Models\CRMCall;
12 use Schema;
13 use PDO;
14 use App\Models\Notification;
15 use App\Jobs\KHRMSLib;
16
17 use Input;
18 use App\Models\Sipid;
19 use App\Models\Kqueue;
20 use App\Models\Dialline;
21 use App\Models\Session;
22
23 use Illuminate\Database\Schema\Blueprint;
24
25 class InsertCrmArchive2 extends Command {
26
27 /**
28 * The console command name.
29 *
30 * @var string
31 */
32 protected $signature = 'InsertCrmArchive2';
33
34 /**
35 * The console command description.
36 *
37 * @var string
38 */
39 protected $description = 'Insert updated data into crmcalls_archive_2 from crmcalls';
40
41 /**
42 * Execute the console command.
43 *
44 * @return mixed
45 */
46 public function handle()
47 {
48 echo 'Start';
49
50 DB::insert(DB::raw("insert into crmcalls_archive_2 select * from crmcalls_archive where id>(select max(id) from crmcalls_archive_2)"));
51
52 echo 'End';
53 }
54 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4
5 use App\Jobs\KPAMIListen;
6
7 class KstychARP extends Command {
8
9 /**
10 * The console command name.
11 *
12 * @var string
13 */
14 protected $signature = 'KstychARP';
15
16 /**
17 * The console command description.
18 *
19 * @var string
20 */
21 protected $description = 'ARP Broadcast';
22
23 /**
24 * Execute the console command.
25 *
26 * @return mixed
27 */
28 public function handle()
29 {
30
31 }
32
33 }
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4 use Mail;
5 use DB;
6 use Config;
7
8 use App\Models\User;
9 use App\Models\Accesslog;
10
11 use App\Models\CRMCall;
12 use Schema;
13 use PDO;
14
15 use Illuminate\Database\Schema\Blueprint;
16
17 class KstychDaily extends Command {
18
19 /**
20 * The console command name.
21 *
22 * @var string
23 */
24 protected $signature = 'KstychDaily';
25
26 /**
27 * The console command description.
28 *
29 * @var string
30 */
31 protected $description = 'App Main Daily Task';
32
33 /**
34 * Execute the console command.
35 *
36 * @return mixed
37 */
38 public function handle()
39 {
40 $nowts=time();
41 Accesslog::where('endtime','<',date("Y-m-d H:i:s",$nowts-10*24*60*60))->update(array('postdata'=>'','queries'=>''));
42 Accesslog::where('endtime','<',date("Y-m-d H:i:s",$nowts-30*24*60*60))->delete();
43
44
45
46 if(env('app_ip')=="10.3.177.14")
47 {
48
49 if(!Schema::hasTable('calllog_report'))
50 {
51 Schema::create('calllog_report', function(Blueprint $table)
52 {
53 $table->string('server', 100);
54 $table->dateTime('start');
55 $table->integer('length');
56 $table->string('user',100);
57 $table->string('name',100);
58 $table->string('dispo', 200);
59 $table->string('subdispo', 200);
60 $table->dateTime('callback');
61 $table->string('number', 100);
62 $table->string('clientcode', 100);
63 $table->string('currentstatus', 100);
64 $table->string('legalstatus', 100);
65 $table->string('client', 200);
66 $table->string('department', 200);
67 $table->string('state', 50);
68 $table->string('hsource', 100);
69 $table->string('type', 50);
70 $table->string('statuscode', 20);
71 $table->string('status', 100);
72 $table->string('statusstr', 100);
73 $table->integer('dialline');
74 $table->string('did', 50);
75 $table->bigInteger('waitsec');
76 $table->bigInteger('callsec');
77 $table->bigInteger('talksec');
78 $table->bigInteger('disposec');
79 $table->string('remarks', 500);
80 $table->string('userdata',1000);
81 });
82 }
83
84
85 $offline=array();
86 $arr=Config::get("app.hdfcnodes");
87 $logdate=strtotime('-1 day');
88
89
90 $tcol=0;$fieldsarr=array();$extrahdrarr=array();
91
92
93
94 $ii=1;$ci=0;
95 foreach($arr as $server=>$serverline)
96 {
97 $ci++;
98 $conn = array(
99 'driver' => 'mysql',
100 'host' => $server,
101 'database' => env('DB_DATABASE', 'kstych_flexydial'),
102 'username' => env('DB_USERNAME', 'root'),
103 'password' => env('DB_PASSWORD', ''),
104 'charset' => 'utf8',
105 'collation' => 'utf8_unicode_ci',
106 'prefix' => '',
107 'options' => array(
108 PDO::ATTR_TIMEOUT => 5,
109 ),
110 );
111 Config::set("database.connections.conn$ci", $conn);
112
113 try
114 {
115 DB::connection("conn$ci")->getDatabaseName();
116
117
118 $alist=CRMCall::on("conn$ci")->where('created_at','>=',date("Y-m-d H:i:s",$logdate))->where('created_at','<=',date("Y-m-d H:i:s",$logdate+24*60*60))->get();
119 $userarr=array();
120 foreach($alist as $aline)
121 {
122 $setstrarr=array();
123
124
125 $clientcode="";$currentstatus="";$legalstatus="";
126 if($aline->crm_id>0)
127 {
128 $user=DB::connection("conn$ci")->select(DB::raw("select id,clientcode,currentstatus,legalstatus from records where id='".$aline->crm_id."' limit 1;"));
129 if(isset($user[0]))
130 {
131 $clientcode=$user[0]->clientcode;
132 $currentstatus=$user[0]->currentstatus;
133 $legalstatus=$user[0]->legalstatus;
134 }
135 }
136 $tpostdata=json_decode($aline->data,true);
137 $fulldate=date("Y-m-d H:i:s",strtotime($aline->created_at)+330*60);
138 $talktime=$aline->talkSec+$aline->recstartSec+$aline->recendSec;
139 $length=round(($aline->waitSec+$aline->callSec+$talktime+$aline->dispoSec)/1000,2);
140
141 if(!isset($userarr[$aline->user_id])&&$aline->user_id>0)$userarr[$aline->user_id]=User::on("conn$ci")->find($aline->user_id);
142 $dispname="";if(isset($userarr[$aline->user_id]))$dispname=$userarr[$aline->user_id]->dispname();
143 $username="";if(isset($userarr[$aline->user_id]))$username=$userarr[$aline->user_id]->username;
144
145 $setstrarr[]="server='$server'";
146 $setstrarr[]="start='$fulldate'";
147 $setstrarr[]="length='$length'";
148 $setstrarr[]="user='$username'";
149 $setstrarr[]="name='$dispname'";
150 $setstrarr[]="dispo='$aline->userstatus'";
151 $setstrarr[]="subdispo='$aline->usersubstatus'";
152 $setstrarr[]="callback='$aline->usercallback'";
153
154 $setstrarr[]="number='$aline->number'";
155 $setstrarr[]="clientcode='$clientcode'";
156 $setstrarr[]="currentstatus='$currentstatus'";
157 $setstrarr[]="legalstatus='$legalstatus'";
158 $setstrarr[]="client='$aline->client'";
159 $setstrarr[]="department='$aline->department'";
160 $setstrarr[]="state='$aline->state'";
161 $setstrarr[]="hsource='$aline->hsource'";
162
163 $setstrarr[]="type='$aline->type'";
164 $setstrarr[]="status='$aline->status'";
165 $setstrarr[]="statuscode='$aline->statuscode'";
166 $setstrarr[]="statusstr='$aline->substatus'";
167 $setstrarr[]="dialline='$aline->dialline_id'";
168 $setstrarr[]="did='$aline->did'";
169 $setstrarr[]="waitsec='".round($aline->waitSec/1000,2)."'";
170 $setstrarr[]="callsec='".round($aline->callSec/1000,2)."'";
171 $setstrarr[]="talksec='".round($talktime/1000,2)."'";
172 $setstrarr[]="disposec='".round($aline->dispoSec/1000,2)."'";
173 $setstrarr[]="remarks='$aline->userremarks'";
174 $setstrarr[]="userdata='$aline->userdata'";
175
176 $setstr=implode(",",$setstrarr);
177 DB::insert(DB::raw("insert into calllog_report set $setstr"));
178 }
179
180 }
181 catch(Exception $e)
182 {
183 $offline[]=$server;
184 }
185 }
186
187 }
188
189
190
191 }
192
193 }
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4
5 use App\Jobs\KPAGIListen;
6
7 class KstychPAGI extends Command {
8
9 /**
10 * The console command name.
11 *
12 * @var string
13 */
14 protected $signature = 'KstychPAGI';
15
16 /**
17 * The console command description.
18 *
19 * @var string
20 */
21 protected $description = 'Daemon to Listen to Asterisk';
22
23 /**
24 * Execute the console command.
25 *
26 * @return mixed
27 */
28 public function handle()
29 {
30 $agi = \PAGI\Client\Impl\ClientImpl::getInstance();
31 $kpagi = new KPAGIListen(array('pagiClient' => $agi));
32 $kpagi->init();
33 $kpagi->run();
34 }
35
36 }
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4
5 use App\Jobs\KPAMIListen;
6
7 class KstychPAMI extends Command {
8
9 /**
10 * The console command name.
11 *
12 * @var string
13 */
14 protected $signature = 'KstychPAMI {serverip=127.0.0.1}';
15
16 /**
17 * The console command description.
18 *
19 * @var string
20 */
21 protected $description = 'Daemon to Listen to Asterisk';
22
23 /**
24 * Execute the console command.
25 *
26 * @return mixed
27 */
28 public function handle()
29 {
30 $listener = new KPAMIListen($this->argument('serverip'));$listener->run();
31 }
32
33 }
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4 //use Mail;
5 use DB;
6 use Config;
7
8 use App\Models\User;
9 use App\Models\Accesslog;
10
11 use App\Models\CRMCall;
12 use Schema;
13 use PDO;
14 use App\Models\Notification;
15 use App\Jobs\KHRMSLib;
16
17 use Input;
18
19 use Illuminate\Database\Schema\Blueprint;
20
21 class bulkServerUpload extends Command {
22
23 /**
24 * The console command name.
25 *
26 * @var string
27 */
28 protected $signature = 'bulkServerUpload';
29
30 /**
31 * The console command description.
32 *
33 * @var string
34 */
35 protected $description = 'bulkServerUpload';
36
37 /**
38 * Execute the console command.
39 *
40 * @return mixed
41 */
42 public function handle()
43 {
44 echo "\n".date('Y-m-d')."\n";
45
46 $wakka = new KHRMSLib();
47
48 $kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
49 $kformlib->gthis=$wakka;
50
51 $themehome=$wakka->GetThemePath('/');
52 $updatetime=time();
53
54 $clientlst=$wakka->GetBBBUserData("clientslist");
55
56 $isadmin=$wakka->IsAdmin();
57 $username=$wakka->GetUserName();
58 $triggers=Input::get("triggers");
59 $tmpstr=explode(",",$kformlib->HRFiledsStr);
60
61 $success="";$message="";$successcnt=0;$duplicatecount=0;
62
63
64 $conn = array(
65 'driver' => 'mysql',
66 'host' => '10.3.177.14',
67 'database' => env('DB_DATABASE', 'kstych_flexydial'),
68 'username' => env('DB_USERNAME', 'root'),
69 'password' => env('DB_PASSWORD', 'yb9738z'),
70 'charset' => 'utf8',
71 'collation' => 'utf8_unicode_ci',
72 'prefix' => '',
73 'options' => array(
74 PDO::ATTR_TIMEOUT => 5,
75 ),
76 );
77 Config::set("database.connections.conn", $conn);
78
79 DB::connection("conn")->getDatabaseName();
80
81 // $excelarray = DB::table('bz_record_upload_uat')->select('*')->get();
82
83 $excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat limit 1"));
84 $excelarray = (array)$excelarray;
85
86 $highestColumn = DB::connection("conn")->select(DB::raw("select count(*) from information_schema.columns where table_name='bz_record_upload_uat'"));
87 $highestrow = count($excelarray);
88 echo $highestColumn;
89 $flag = 0;
90 $editflag=0;
91
92 for($i=0;$i<=$highestrow;$i++)
93 {
94 if($excelarray[$i]["id"]!="")
95 {
96 if($excelarray[$i]["id"]=="CREATE")
97 {
98 $excelarray[$i]["id"]=$wakka->Query("insert into","","records_demo",array('created'=>date('Y-m-d H:i:s')));
99 }
100 else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
101
102 if($wakka->getCount("records_demo","id='".$excelarray[$i]["id"]."'")==1)
103 {
104 $empdata=$wakka->getPersonServer($excelarray[$i]["id"]);
105 $ppldata=$empdata["peopledata"];
106 $createdlog=$empdata['modifylog'];
107 $fdirty=$empdata['dirty'];
108
109 $createdlog[$updatetime]=$username."::";
110 $createdlog["updated"]=$updatetime;
111
112 $newdata=$ppldata;
113 foreach($excelarray[$i] as $key => $value)
114 {
115 if($value!="")
116 {
117 if("A".$ppldata[$key]!="A".$value)//forcing string comparrision //MAGIC
118 {
119 $value=str_replace("'"," ",$value);
120 if(strstr($createdlog[$updatetime],$key)==FALSE)$createdlog[$updatetime].="$key|".str_replace(array("|",",")," ",$ppldata[$key])."|".str_replace(array("|",",")," ",$value).",";
121
122 $fdirty[$key]=1;
123
124 $newdata[$key]=$value;
125 }
126 }
127 }
128 $empdata["peopledata"]=$newdata;
129 $empdata['modifylog']=$createdlog;
130 $empdata['dirty']=$fdirty;
131
132 $wakka->setPersonServer($excelarray[$i]["id"],$empdata);
133 $excelarray[$i]['modified']=date('Y-m-d H:i:s');
134
135 }
136 }
137
138 }
139 mysqli_close($conn);
140
141 }
142 }
143
144
145
146
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4 //use Mail;
5 use DB;
6 use Config;
7
8 use App\Models\User;
9 use App\Models\Accesslog;
10
11 use App\Models\CRMCall;
12 use Schema;
13 use PDO;
14 use App\Models\Notification;
15 use App\Jobs\KHRMSLib;
16
17 use Input;
18 use App\Models\Sipid;
19 use App\Models\Kqueue;
20 use App\Models\Dialline;
21 use App\Models\Session;
22 use App\Models\Cutoff;
23
24 use Log;
25 use Illuminate\Database\Schema\Blueprint;
26
27 class PredictiveCallHangUp extends Command {
28
29 /**
30 * The console command name.
31 *
32 * @var string
33 */
34 protected $signature = 'PredictiveCallHangUp';
35
36 /**
37 * The console command description.
38 *
39 * @var string
40 */
41 protected $description = 'Hang Up Extra Calls If Agents Are Not Free';
42
43 /**
44 * Execute the console command.
45 *
46 * @return mixed
47 */
48 public function handle()
49 {
50 while(true)
51 {
52 usleep(1000000);
53 $this->runHangUp();
54 }
55 }
56
57 public function runHangUp()
58 {
59 try {
60 $breathingTime = 30;
61 $avgringsec = 30;
62 $dStatus = "InHangUp";
63
64 // $avgringsec = Cutoff::select(DB::Raw('avg(avg_ring) as avgringsec'))->first();
65 // if($avgringsec)$avgringsec= intval($avgringsec->avgringsec);
66
67 $diallines = Dialline::where('server', '=', env('app_ip'))->whereIn("status", ["Auto","AutoCall"])->where("conf","=","")->select('id', 'call_id', 'src_channel', 'status', 'updated_at', 'channel', 'server')->get();
68
69 foreach ($diallines as $dialline) {
70
71 $newqueue=new Kqueue();
72 $lastUpdatedTime = strtotime(date("Y-m-d H:i:s")) - strtotime($dialline->updated_at);
73 $callId = $dialline->call_id;
74
75 if ($dialline->status == 'Auto' && $lastUpdatedTime > $breathingTime) {
76 $dialline->status=$dStatus;
77 $dialline->save();
78
79 $newqueue->hangupChannelS($dialline->channel,$dialline->server);
80
81 $this->updateCrmCallEntry($callId);
82 }
83 }
84 } catch (Exception $e) {
85 Log::useFiles(storage_path()."/logs/predictive_".date("Y_m_d").".log");
86 Log::error($e);
87 }
88 }
89
90 public function updateCrmCallEntry($callId)
91 {
92 $hsource = "DTO";
93
94 CRMCall::where('id', $callId)
95 ->update([
96 'hsource'=> $hsource
97 ]);
98 }
99 }
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4 //use Mail;
5 use DB;
6 use Config;
7
8 use App\Models\User;
9 use App\Models\Accesslog;
10
11 use App\Models\CRMCall;
12 use Schema;
13 use PDO;
14 use App\Models\Notification;
15 use App\Jobs\KHRMSLib;
16
17 use Input;
18 use App\Models\Sipid;
19 use App\Models\Kqueue;
20 use App\Models\Dialline;
21 use App\Models\Session;
22 use App\Models\Cutoff;
23
24 use Log;
25 use Illuminate\Database\Schema\Blueprint;
26
27 class UpdateAvgRingSec extends Command {
28
29 /**
30 * The console command name.
31 *
32 * @var string
33 */
34 protected $signature = 'UpdateAvgRingSec';
35
36 /**
37 * The console command description.
38 *
39 * @var string
40 */
41 protected $description = 'Update Avg Call Ring Sec Of Last 50 Calls';
42
43 /**
44 * Execute the console command.
45 *
46 * @return mixed
47 */
48 public function handle()
49 {
50 $avgcallsecObj = CRMCall::select(DB::Raw('ROUND((avg(callsec))/1000) as avgcallsec'))->limit(50)->where("type","!=","Inbound")->first();
51
52 if(count($avgcallsecObj))
53 {
54 Cutoff::where('user_id', '!=', "")->update(
55 ['avg_ring' => $avgcallsecObj->avgcallsec
56 ]);
57 }
58 }
59 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4 //use Mail;
5 use DB;
6 use Config;
7
8 use App\Models\User;
9 use App\Models\Accesslog;
10
11 use App\Models\CRMCall;
12 use Schema;
13 use PDO;
14 use App\Models\Notification;
15 use App\Jobs\KHRMSLib;
16
17 use Input;
18
19 use Illuminate\Database\Schema\Blueprint;
20
21 class bulkServerUpload extends Command {
22
23 /**
24 * The console command name.
25 *
26 * @var string
27 */
28 protected $signature = 'bulkServerUpload';
29
30 /**
31 * The console command description.
32 *
33 * @var string
34 */
35 protected $description = 'bulkServerUpload';
36
37 /**
38 * Execute the console command.
39 *
40 * @return mixed
41 */
42 public function handle()
43 {
44
45 echo "\n".date('Y-m-d')."\n";
46
47 $wakka = new KHRMSLib();
48
49 $kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
50 $kformlib->gthis=$wakka;
51
52 $themehome=$wakka->GetThemePath('/');
53 $updatetime=time();
54
55 $clientlst=$wakka->GetBBBUserData("clientslist");
56
57 $isadmin=$wakka->IsAdmin();
58 $username=$wakka->GetUserName();
59 $triggers=Input::get("triggers");
60 $tmpstr=explode(",",$kformlib->HRFiledsStr);
61
62 $success="";$message="";$successcnt=0;$duplicatecount=0;
63
64
65 $conn = array(
66 'driver' => 'mysql',
67 'host' => '10.3.177.14',
68 'database' => env('DB_DATABASE', 'kstych_flexydial'),
69 'username' => env('DB_USERNAME', 'root'),
70 'password' => env('DB_PASSWORD', 'yb9738z'),
71 'charset' => 'utf8',
72 'collation' => 'utf8_unicode_ci',
73 'prefix' => '',
74 'options' => array(
75 PDO::ATTR_TIMEOUT => 5,
76 ),
77 );
78 Config::set("database.connections.conn", $conn);
79
80 DB::connection("conn")->getDatabaseName();
81
82 $excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat where SERVER_IP='10.3.179.121' and ins_date>'2016-11-29' order by auto_id asc limit 0,20000"));
83
84 foreach($excelarray as $key => $array){
85 $excelarray[$key] = (array)$array;
86 }
87
88 $highestColumn = DB::connection("conn")->select(DB::raw("select count(*) as cnt from information_schema.columns where table_name='bz_record_upload_uat'"));
89 $highestColumn = $highestColumn[0]->cnt;
90
91 $highestrow = count($excelarray);
92
93 $flag = 0;
94 $editflag=0;
95
96 for($i=0;$i<=$highestrow;$i++)
97 {
98 if($excelarray[$i]["id"]!="")
99 {
100 if($excelarray[$i]["id"]=="CREATE")
101 {
102 $excelarray[$i]["id"]=$wakka->Query("insert into","","records",array('created'=>date('Y-m-d H:i:s')));
103 }
104 else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
105
106 if($wakka->getCount("records","id='".$excelarray[$i]["id"]."'")==1)
107 {
108 $empdata=$wakka->getPerson($excelarray[$i]["id"]);
109 $ppldata=$empdata["peopledata"];
110 $createdlog=$empdata['modifylog'];
111 $fdirty=$empdata['dirty'];
112
113 $createdlog[$updatetime]=$username."::";
114 $createdlog["updated"]=$updatetime;
115
116 $newdata=$ppldata;
117 foreach($excelarray[$i] as $key => $value)
118 {
119 if($value!="")
120 {
121 if("A".$ppldata[$key]!="A".$value)//forcing string comparrision //MAGIC
122 {
123 $value=str_replace("'"," ",$value);
124 if(strstr($createdlog[$updatetime],$key)==FALSE)$createdlog[$updatetime].="$key|".str_replace(array("|",",")," ",$ppldata[$key])."|".str_replace(array("|",",")," ",$value).",";
125
126 $fdirty[$key]=1;
127
128 $newdata[$key]=$value;
129 }
130 }
131 }
132 $empdata["peopledata"]=$newdata;
133 $empdata['modifylog']=$createdlog;
134 $empdata['dirty']=$fdirty;
135
136 $wakka->setPerson($excelarray[$i]["id"],$empdata);
137 $excelarray[$i]['modified']=date('Y-m-d H:i:s');
138
139 }
140 }
141
142 }
143 DB::connection("conn")->disconnect();
144
145
146 }
147 }
148
149
150
151
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4 //use Mail;
5 use DB;
6 use Config;
7
8 use App\Models\User;
9 use App\Models\Accesslog;
10
11 use App\Models\CRMCall;
12 use Schema;
13 use PDO;
14 use App\Models\Notification;
15 use App\Jobs\KHRMSLib;
16
17 use Input;
18
19 use Illuminate\Database\Schema\Blueprint;
20
21 class bulkServerUpload_1 extends Command {
22
23 /**
24 * The console command name.
25 *
26 * @var string
27 */
28 protected $signature = 'bulkServerUpload_1';
29
30 /**
31 * The console command description.
32 *
33 * @var string
34 */
35 protected $description = 'bulkServerUpload';
36
37 /**
38 * Execute the console command.
39 *
40 * @return mixed
41 */
42 public function handle()
43 {
44
45 $wakka = new KHRMSLib();
46
47 $kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
48 $kformlib->gthis=$wakka;
49
50 $themehome=$wakka->GetThemePath('/');
51 $updatetime=time();
52
53 $clientlst=$wakka->GetBBBUserData("clientslist");
54
55 $isadmin=$wakka->IsAdmin();
56 $username=$wakka->GetUserName();
57 $triggers=Input::get("triggers");
58 $tmpstr=explode(",",$kformlib->HRFiledsStr);
59
60 $success="";$message="";$successcnt=0;$duplicatecount=0;
61
62
63 $conn = array(
64 'driver' => 'mysql',
65 'host' => '10.3.177.14',
66 'database' => env('DB_DATABASE', 'kstych_flexydial'),
67 'username' => env('DB_USERNAME', 'root'),
68 'password' => env('DB_PASSWORD', 'yb9738z'),
69 'charset' => 'utf8',
70 'collation' => 'utf8_unicode_ci',
71 'prefix' => '',
72 'options' => array(
73 PDO::ATTR_TIMEOUT => 5,
74 ),
75 );
76 Config::set("database.connections.conn", $conn);
77
78 DB::connection("conn")->getDatabaseName();
79
80 $excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat where SERVER_IP='10.3.179.121' and ins_date>'2016-11-29' order by auto_id asc limit 20001,20000"));
81
82 foreach($excelarray as $key => $array){
83 $excelarray[$key] = (array)$array;
84 }
85
86 $highestColumn = DB::connection("conn")->select(DB::raw("select count(*) as cnt from information_schema.columns where table_name='bz_record_upload_uat'"));
87 $highestColumn = $highestColumn[0]->cnt;
88
89 $highestrow = count($excelarray);
90
91 $flag = 0;
92 $editflag=0;
93
94 for($i=0;$i<=$highestrow;$i++)
95 {
96 if($excelarray[$i]["id"]!="")
97 {
98 if($excelarray[$i]["id"]=="CREATE")
99 {
100 $excelarray[$i]["id"]=$wakka->Query("insert into","","records",array('created'=>date('Y-m-d H:i:s')));
101 }
102 else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
103
104 if($wakka->getCount("records","id='".$excelarray[$i]["id"]."'")==1)
105 {
106 $empdata=$wakka->getPerson($excelarray[$i]["id"]);
107 $ppldata=$empdata["peopledata"];
108 $createdlog=$empdata['modifylog'];
109 $fdirty=$empdata['dirty'];
110
111 $createdlog[$updatetime]=$username."::";
112 $createdlog["updated"]=$updatetime;
113
114 $newdata=$ppldata;
115 foreach($excelarray[$i] as $key => $value)
116 {
117 if($value!="")
118 {
119 if("A".$ppldata[$key]!="A".$value)//forcing string comparrision //MAGIC
120 {
121 $value=str_replace("'"," ",$value);
122 if(strstr($createdlog[$updatetime],$key)==FALSE)$createdlog[$updatetime].="$key|".str_replace(array("|",",")," ",$ppldata[$key])."|".str_replace(array("|",",")," ",$value).",";
123
124 $fdirty[$key]=1;
125
126 $newdata[$key]=$value;
127 }
128 }
129 }
130 $empdata["peopledata"]=$newdata;
131 $empdata['modifylog']=$createdlog;
132 $empdata['dirty']=$fdirty;
133
134 $wakka->setPerson($excelarray[$i]["id"],$empdata);
135 $excelarray[$i]['modified']=date('Y-m-d H:i:s');
136
137 }
138 }
139
140 }
141 DB::connection("conn")->disconnect();
142
143 }
144 }
145
146
147
148
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4 //use Mail;
5 use DB;
6 use Config;
7
8 use App\Models\User;
9 use App\Models\Accesslog;
10
11 use App\Models\CRMCall;
12 use Schema;
13 use PDO;
14 use App\Models\Notification;
15 use App\Jobs\KHRMSLib;
16
17 use Input;
18
19 use Illuminate\Database\Schema\Blueprint;
20
21 class bulkServerUpload_2 extends Command {
22
23 /**
24 * The console command name.
25 *
26 * @var string
27 */
28 protected $signature = 'bulkServerUpload_2';
29
30 /**
31 * The console command description.
32 *
33 * @var string
34 */
35 protected $description = 'bulkServerUpload';
36
37 /**
38 * Execute the console command.
39 *
40 * @return mixed
41 */
42 public function handle()
43 {
44
45 $wakka = new KHRMSLib();
46
47 $kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
48 $kformlib->gthis=$wakka;
49
50 $themehome=$wakka->GetThemePath('/');
51 $updatetime=time();
52
53 $clientlst=$wakka->GetBBBUserData("clientslist");
54
55 $isadmin=$wakka->IsAdmin();
56 $username=$wakka->GetUserName();
57 $triggers=Input::get("triggers");
58 $tmpstr=explode(",",$kformlib->HRFiledsStr);
59
60 $success="";$message="";$successcnt=0;$duplicatecount=0;
61
62
63 $conn = array(
64 'driver' => 'mysql',
65 'host' => '10.3.177.14',
66 'database' => env('DB_DATABASE', 'kstych_flexydial'),
67 'username' => env('DB_USERNAME', 'root'),
68 'password' => env('DB_PASSWORD', 'yb9738z'),
69 'charset' => 'utf8',
70 'collation' => 'utf8_unicode_ci',
71 'prefix' => '',
72 'options' => array(
73 PDO::ATTR_TIMEOUT => 5,
74 ),
75 );
76 Config::set("database.connections.conn", $conn);
77
78 DB::connection("conn")->getDatabaseName();
79
80 $excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat where SERVER_IP='10.3.179.121' and ins_date>'2016-11-29' order by auto_id asc limit 40001,20000"));
81
82 foreach($excelarray as $key => $array){
83 $excelarray[$key] = (array)$array;
84 }
85
86 $highestColumn = DB::connection("conn")->select(DB::raw("select count(*) as cnt from information_schema.columns where table_name='bz_record_upload_uat'"));
87 $highestColumn = $highestColumn[0]->cnt;
88
89 $highestrow = count($excelarray);
90
91 $flag = 0;
92 $editflag=0;
93
94 for($i=0;$i<=$highestrow;$i++)
95 {
96 if($excelarray[$i]["id"]!="")
97 {
98 if($excelarray[$i]["id"]=="CREATE")
99 {
100 $excelarray[$i]["id"]=$wakka->Query("insert into","","records",array('created'=>date('Y-m-d H:i:s')));
101 }
102 else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
103
104 if($wakka->getCount("records","id='".$excelarray[$i]["id"]."'")==1)
105 {
106 $empdata=$wakka->getPerson($excelarray[$i]["id"]);
107 $ppldata=$empdata["peopledata"];
108 $createdlog=$empdata['modifylog'];
109 $fdirty=$empdata['dirty'];
110
111 $createdlog[$updatetime]=$username."::";
112 $createdlog["updated"]=$updatetime;
113
114 $newdata=$ppldata;
115 foreach($excelarray[$i] as $key => $value)
116 {
117 if($value!="")
118 {
119 if("A".$ppldata[$key]!="A".$value)//forcing string comparrision //MAGIC
120 {
121 $value=str_replace("'"," ",$value);
122 if(strstr($createdlog[$updatetime],$key)==FALSE)$createdlog[$updatetime].="$key|".str_replace(array("|",",")," ",$ppldata[$key])."|".str_replace(array("|",",")," ",$value).",";
123
124 $fdirty[$key]=1;
125
126 $newdata[$key]=$value;
127 }
128 }
129 }
130 $empdata["peopledata"]=$newdata;
131 $empdata['modifylog']=$createdlog;
132 $empdata['dirty']=$fdirty;
133
134 $wakka->setPerson($excelarray[$i]["id"],$empdata);
135 $excelarray[$i]['modified']=date('Y-m-d H:i:s');
136
137 }
138 }
139
140 }
141 DB::connection("conn")->disconnect();
142
143 }
144 }
145
146
147
148
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4 //use Mail;
5 use DB;
6 use Config;
7
8 use App\Models\User;
9 use App\Models\Accesslog;
10
11 use App\Models\CRMCall;
12 use Schema;
13 use PDO;
14 use App\Models\Notification;
15 use App\Jobs\KHRMSLib;
16
17 use Input;
18
19 use Illuminate\Database\Schema\Blueprint;
20
21 class bulkServerUpload_3 extends Command {
22
23 /**
24 * The console command name.
25 *
26 * @var string
27 */
28 protected $signature = 'bulkServerUpload_3';
29
30 /**
31 * The console command description.
32 *
33 * @var string
34 */
35 protected $description = 'bulkServerUpload';
36
37 /**
38 * Execute the console command.
39 *
40 * @return mixed
41 */
42 public function handle()
43 {
44
45 $wakka = new KHRMSLib();
46
47 $kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
48 $kformlib->gthis=$wakka;
49
50 $themehome=$wakka->GetThemePath('/');
51 $updatetime=time();
52
53 $clientlst=$wakka->GetBBBUserData("clientslist");
54
55 $isadmin=$wakka->IsAdmin();
56 $username=$wakka->GetUserName();
57 $triggers=Input::get("triggers");
58 $tmpstr=explode(",",$kformlib->HRFiledsStr);
59
60 $success="";$message="";$successcnt=0;$duplicatecount=0;
61
62
63 $conn = array(
64 'driver' => 'mysql',
65 'host' => '10.3.177.14',
66 'database' => env('DB_DATABASE', 'kstych_flexydial'),
67 'username' => env('DB_USERNAME', 'root'),
68 'password' => env('DB_PASSWORD', 'yb9738z'),
69 'charset' => 'utf8',
70 'collation' => 'utf8_unicode_ci',
71 'prefix' => '',
72 'options' => array(
73 PDO::ATTR_TIMEOUT => 5,
74 ),
75 );
76 Config::set("database.connections.conn", $conn);
77
78 DB::connection("conn")->getDatabaseName();
79
80 $excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat where SERVER_IP='10.3.179.121' and ins_date>'2016-11-29' order by auto_id asc limit 60001,20000"));
81
82 foreach($excelarray as $key => $array){
83 $excelarray[$key] = (array)$array;
84 }
85
86 $highestColumn = DB::connection("conn")->select(DB::raw("select count(*) as cnt from information_schema.columns where table_name='bz_record_upload_uat'"));
87 $highestColumn = $highestColumn[0]->cnt;
88
89 $highestrow = count($excelarray);
90
91 $flag = 0;
92 $editflag=0;
93
94 for($i=0;$i<=$highestrow;$i++)
95 {
96 if($excelarray[$i]["id"]!="")
97 {
98 if($excelarray[$i]["id"]=="CREATE")
99 {
100 $excelarray[$i]["id"]=$wakka->Query("insert into","","records",array('created'=>date('Y-m-d H:i:s')));
101 }
102 else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
103
104 if($wakka->getCount("records","id='".$excelarray[$i]["id"]."'")==1)
105 {
106 $empdata=$wakka->getPerson($excelarray[$i]["id"]);
107 $ppldata=$empdata["peopledata"];
108 $createdlog=$empdata['modifylog'];
109 $fdirty=$empdata['dirty'];
110
111 $createdlog[$updatetime]=$username."::";
112 $createdlog["updated"]=$updatetime;
113
114 $newdata=$ppldata;
115 foreach($excelarray[$i] as $key => $value)
116 {
117 if($value!="")
118 {
119 if("A".$ppldata[$key]!="A".$value)//forcing string comparrision //MAGIC
120 {
121 $value=str_replace("'"," ",$value);
122 if(strstr($createdlog[$updatetime],$key)==FALSE)$createdlog[$updatetime].="$key|".str_replace(array("|",",")," ",$ppldata[$key])."|".str_replace(array("|",",")," ",$value).",";
123
124 $fdirty[$key]=1;
125
126 $newdata[$key]=$value;
127 }
128 }
129 }
130 $empdata["peopledata"]=$newdata;
131 $empdata['modifylog']=$createdlog;
132 $empdata['dirty']=$fdirty;
133
134 $wakka->setPerson($excelarray[$i]["id"],$empdata);
135 $excelarray[$i]['modified']=date('Y-m-d H:i:s');
136
137 }
138 }
139
140 }
141 DB::connection("conn")->disconnect();
142
143 }
144 }
145
146
147
148
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4 //use Mail;
5 use DB;
6 use Config;
7
8 use App\Models\User;
9 use App\Models\Accesslog;
10
11 use App\Models\CRMCall;
12 use Schema;
13 use PDO;
14 use App\Models\Notification;
15 use App\Jobs\KHRMSLib;
16
17 use Input;
18
19 use Illuminate\Database\Schema\Blueprint;
20
21 class bulkServerUpload_4 extends Command {
22
23 /**
24 * The console command name.
25 *
26 * @var string
27 */
28 protected $signature = 'bulkServerUpload_4';
29
30 /**
31 * The console command description.
32 *
33 * @var string
34 */
35 protected $description = 'bulkServerUpload';
36
37 /**
38 * Execute the console command.
39 *
40 * @return mixed
41 */
42 public function handle()
43 {
44
45 $wakka = new KHRMSLib();
46
47 $kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
48 $kformlib->gthis=$wakka;
49
50 $themehome=$wakka->GetThemePath('/');
51 $updatetime=time();
52
53 $clientlst=$wakka->GetBBBUserData("clientslist");
54
55 $isadmin=$wakka->IsAdmin();
56 $username=$wakka->GetUserName();
57 $triggers=Input::get("triggers");
58 $tmpstr=explode(",",$kformlib->HRFiledsStr);
59
60 $success="";$message="";$successcnt=0;$duplicatecount=0;
61
62
63 $conn = array(
64 'driver' => 'mysql',
65 'host' => '10.3.177.14',
66 'database' => env('DB_DATABASE', 'kstych_flexydial'),
67 'username' => env('DB_USERNAME', 'root'),
68 'password' => env('DB_PASSWORD', 'yb9738z'),
69 'charset' => 'utf8',
70 'collation' => 'utf8_unicode_ci',
71 'prefix' => '',
72 'options' => array(
73 PDO::ATTR_TIMEOUT => 5,
74 ),
75 );
76 Config::set("database.connections.conn", $conn);
77
78 DB::connection("conn")->getDatabaseName();
79
80 $excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat where SERVER_IP='10.3.179.121' and ins_date>'2016-11-29' order by auto_id asc limit 80001,20000"));
81
82 foreach($excelarray as $key => $array){
83 $excelarray[$key] = (array)$array;
84 }
85
86 $highestColumn = DB::connection("conn")->select(DB::raw("select count(*) as cnt from information_schema.columns where table_name='bz_record_upload_uat'"));
87 $highestColumn = $highestColumn[0]->cnt;
88
89 $highestrow = count($excelarray);
90
91 $flag = 0;
92 $editflag=0;
93
94 for($i=0;$i<=$highestrow;$i++)
95 {
96 if($excelarray[$i]["id"]!="")
97 {
98 if($excelarray[$i]["id"]=="CREATE")
99 {
100 $excelarray[$i]["id"]=$wakka->Query("insert into","","records",array('created'=>date('Y-m-d H:i:s')));
101 }
102 else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
103
104 if($wakka->getCount("records","id='".$excelarray[$i]["id"]."'")==1)
105 {
106 $empdata=$wakka->getPerson($excelarray[$i]["id"]);
107 $ppldata=$empdata["peopledata"];
108 $createdlog=$empdata['modifylog'];
109 $fdirty=$empdata['dirty'];
110
111 $createdlog[$updatetime]=$username."::";
112 $createdlog["updated"]=$updatetime;
113
114 $newdata=$ppldata;
115 foreach($excelarray[$i] as $key => $value)
116 {
117 if($value!="")
118 {
119 if("A".$ppldata[$key]!="A".$value)//forcing string comparrision //MAGIC
120 {
121 $value=str_replace("'"," ",$value);
122 if(strstr($createdlog[$updatetime],$key)==FALSE)$createdlog[$updatetime].="$key|".str_replace(array("|",",")," ",$ppldata[$key])."|".str_replace(array("|",",")," ",$value).",";
123
124 $fdirty[$key]=1;
125
126 $newdata[$key]=$value;
127 }
128 }
129 }
130 $empdata["peopledata"]=$newdata;
131 $empdata['modifylog']=$createdlog;
132 $empdata['dirty']=$fdirty;
133
134 $wakka->setPerson($excelarray[$i]["id"],$empdata);
135 $excelarray[$i]['modified']=date('Y-m-d H:i:s');
136
137 }
138 }
139
140 }
141 DB::connection("conn")->disconnect();
142
143 }
144 }
145
146
147
148
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4 //use Mail;
5 use DB;
6 use Config;
7
8 use App\Models\User;
9 use App\Models\Accesslog;
10
11 use App\Models\CRMCall;
12 use Schema;
13 use PDO;
14 use App\Models\Notification;
15 use App\Jobs\KHRMSLib;
16
17 use Input;
18
19 use Illuminate\Database\Schema\Blueprint;
20
21 class bulkServerUpload extends Command {
22
23 /**
24 * The console command name.
25 *
26 * @var string
27 */
28 protected $signature = 'bulkServerUpload';
29
30 /**
31 * The console command description.
32 *
33 * @var string
34 */
35 protected $description = 'bulkServerUpload';
36
37 /**
38 * Execute the console command.
39 *
40 * @return mixed
41 */
42 public function handle()
43 {
44
45 $wakka = new KHRMSLib();
46
47 $kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
48 $kformlib->gthis=$wakka;
49
50 $themehome=$wakka->GetThemePath('/');
51 $updatetime=time();
52
53 $clientlst=$wakka->GetBBBUserData("clientslist");
54
55 $isadmin=$wakka->IsAdmin();
56 $username=$wakka->GetUserName();
57 $triggers=Input::get("triggers");
58 $tmpstr=explode(",",$kformlib->HRFiledsStr);
59
60 $success="";$message="";$successcnt=0;$duplicatecount=0;
61
62
63 $conn = array(
64 'driver' => 'mysql',
65 'host' => '10.3.177.14',
66 'database' => env('DB_DATABASE', 'kstych_flexydial'),
67 'username' => env('DB_USERNAME', 'root'),
68 'password' => env('DB_PASSWORD', 'yb9738z'),
69 'charset' => 'utf8',
70 'collation' => 'utf8_unicode_ci',
71 'prefix' => '',
72 'options' => array(
73 PDO::ATTR_TIMEOUT => 5,
74 ),
75 );
76 Config::set("database.connections.conn", $conn);
77
78 DB::connection("conn")->getDatabaseName();
79
80 $excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat where SERVER_IP='10.3.179.121' and client='G4015' order by auto_id asc limit 0,20000"));
81
82 foreach($excelarray as $key => $array){
83 $excelarray[$key] = (array)$array;
84 }
85
86 $highestColumn = DB::connection("conn")->select(DB::raw("select count(*) as cnt from information_schema.columns where table_name='bz_record_upload_uat'"));
87 $highestColumn = $highestColumn[0]->cnt;
88
89 $highestrow = count($excelarray);
90
91 $flag = 0;
92 $editflag=0;
93
94 for($i=0;$i<=$highestrow;$i++)
95 {
96 if($excelarray[$i]["id"]!="")
97 {
98 if($excelarray[$i]["id"]=="CREATE")
99 {
100 $excelarray[$i]["id"]=$wakka->Query("insert into","","records",array('created'=>date('Y-m-d H:i:s')));
101 }
102 else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
103
104 if($wakka->getCount("records","id='".$excelarray[$i]["id"]."'")==1)
105 {
106 $empdata=$wakka->getPerson($excelarray[$i]["id"]);
107 $ppldata=$empdata["peopledata"];
108 $createdlog=$empdata['modifylog'];
109 $fdirty=$empdata['dirty'];
110
111 $createdlog[$updatetime]=$username."::";
112 $createdlog["updated"]=$updatetime;
113
114 $newdata=$ppldata;
115 foreach($excelarray[$i] as $key => $value)
116 {
117 if($value!="")
118 {
119 if("A".$ppldata[$key]!="A".$value)//forcing string comparrision //MAGIC
120 {
121 $value=str_replace("'"," ",$value);
122 if(strstr($createdlog[$updatetime],$key)==FALSE)$createdlog[$updatetime].="$key|".str_replace(array("|",",")," ",$ppldata[$key])."|".str_replace(array("|",",")," ",$value).",";
123
124 $fdirty[$key]=1;
125
126 $newdata[$key]=$value;
127 }
128 }
129 }
130 $empdata["peopledata"]=$newdata;
131 $empdata['modifylog']=$createdlog;
132 $empdata['dirty']=$fdirty;
133
134 $wakka->setPerson($excelarray[$i]["id"],$empdata);
135 $excelarray[$i]['modified']=date('Y-m-d H:i:s');
136
137 }
138 }
139
140 }
141 mysqli_close($conn);
142
143
144 }
145 }
146
147
148
149
1 <?php namespace App\Console;
2
3 use Illuminate\Console\Scheduling\Schedule;
4 use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
5
6 class Kernel extends ConsoleKernel
7 {
8
9 /**
10 * The Artisan commands provided by your application.
11 *
12 * @var array
13 */
14 protected $commands = [
15 'App\Console\Commands\KstychDaily',
16 'App\Console\Commands\KstychPAMI',
17 'App\Console\Commands\KstychPAGI',
18 'App\Console\Commands\DailyLogout',
19 'App\Console\Commands\InsertCrmArchive',
20 'App\Console\Commands\InsertCrmArchive2',
21 'App\Console\Commands\DeleteCrmcalls',
22 'App\Console\Commands\DeleteCRMCallArchive',
23 'App\Console\Commands\DeleteCrmcalls',
24 'App\Console\Commands\ClearDiallines',
25 'App\Console\Commands\HangupCall',
26 'App\Console\Commands\CreateCall',
27 'App\Console\Commands\PredictiveCallHangUp',
28 'App\Console\Commands\UpdateAvgRingSec',
29 ];
30
31 /**
32 * Define the application's command schedule.
33 *
34 * @param \Illuminate\Console\Scheduling\Schedule $schedule
35 * @return void
36 */
37 protected function schedule(Schedule $schedule)
38 {
39 $schedule->command('KstychDaily')->daily()->withoutOverlapping()->runInBackground();
40
41 $schedule->command('InsertCrmArchive')->everyFiveMinutes()->appendOutputTo(storage_path() . "/reason/kstych.txt")->withoutOverlapping()->runInBackground();
42 //$schedule->command('InsertCrmArchive2')->monthlyOn(1,'14:30')->withoutOverlapping();
43
44 $schedule->command('DeleteCrmcalls')->dailyAt('02:30')->withoutOverlapping()->runInBackground();
45 //$schedule->command('DeleteCRMCallArchive')->monthlyOn(1,'14:30')->withoutOverlapping();
46
47
48 // added cron for do diallines free by YASHWANT on 29062017
49 $schedule->command('ClearDiallines')->everyMinute()->withoutOverlapping()->runInBackground(); // ->appendOutputTo(storage_path()."/output.txt");
50
51 $schedule->command('HangupCall')->everyTenMinutes()->withoutOverlapping()->runInBackground();
52 }
53 }
1 <?php
2
3 namespace App\Events;
4
5 abstract class Event
6 {
7 //
8 }
1 <?php namespace App\Exceptions;
2
3 use Exception;
4 use Illuminate\Auth\Access\AuthorizationException;
5 use Illuminate\Database\Eloquent\ModelNotFoundException;
6 use Symfony\Component\HttpKernel\Exception\HttpException;
7 use Illuminate\Foundation\Validation\ValidationException;
8 use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
9 use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
10
11 use Config;
12 use Auth;
13 use Request;
14 use Mail;
15 use Cache;
16
17 class Handler extends ExceptionHandler {
18
19 /**
20 * A list of the exception types that should not be reported.
21 *
22 * @var array
23 */
24 protected $dontReport = [
25 AuthorizationException::class,
26 HttpException::class,
27 ModelNotFoundException::class,
28 ValidationException::class,
29 ];
30
31 /**
32 * Report or log an exception.
33 *
34 * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
35 *
36 * @param \Exception $e
37 * @return void
38 */
39 public function report(Exception $e)
40 {
41 if(!empty($e))
42 {
43 $errorStr='';
44 if ($this->isHttpException($e) && $e->getStatusCode() == 404)$errorStr='MISSING';
45 else if(strstr(json_encode($e->getTrace(),true),"VerifyCsrfToken"))$errorStr='IGNORE';
46 else $errorStr='ERROR';
47
48 $accesslog=Config::get('runtime.accesslog_obj');
49 if($accesslog)
50 {
51 $postdata=(array)json_decode($accesslog->postdata);
52 $postdata["ErrorType"]=$errorStr;
53 $postdata["ErrorMsg"]=$e->getMessage();
54 $accesslog->postdata=json_encode($postdata, true);
55 $accesslog->stopLog();
56 }
57
58 if($errorStr=='ERROR')
59 {
60 $email=Config::get("app.email");
61 $user="guest";if(Auth::check())$user=Auth::user()->id." ".Auth::user()->dispname()." ".Auth::user()->username;
62 $ip=Request::getClientIp();
63
64 $key=$user.$ip.'ajaxerror'.Request::path();
65 if(Cache::get($key,'')!=$e->getMessage().json_encode($e->getTrace(),true)&&Cache::get($key.'cnt',0)<10)
66 {
67 Cache::put($key,$e->getMessage().json_encode($e->getTrace(),true), 24*60);//minutes in 1 day
68 Cache::put($key.'cnt',Cache::get($key.'cnt',0)+1, 24*60);
69
70 Mail::send('emails.ajaxerror', array('xhr'=>"app-fatal",'status'=>$e->getMessage(),'error'=>json_encode($e->getTrace(),true),'user'=>$user,'ip'=>$ip), function($message) use ($email)
71 {
72 $message->to($email, $email)->subject(Config::get("app.name")." : Error");
73 });
74
75 }
76 }
77 else if($errorStr=='MISSING'){}
78 else if($errorStr=='IGNORE'){}
79 }
80
81 return parent::report($e);
82 }
83
84 /**
85 * Render an exception into an HTTP response.
86 *
87 * @param \Illuminate\Http\Request $request
88 * @param \Exception $e
89 * @return \Illuminate\Http\Response
90 */
91 public function render($request, Exception $e)
92 {
93 if(!empty($e))
94 {
95 $errorStr='';
96 if ($this->isHttpException($e) && $e->getStatusCode() == 404)$errorStr='MISSING';
97 else $errorStr='ERROR';
98
99 if($errorStr=='ERROR')
100 {
101 if(!Config::get('app.debug')) return response()->view("errors.exception");
102 }
103 else if($errorStr=='MISSING')
104 {
105 return response()->view('errors.missing', array());
106 }
107 }
108
109 return parent::render($request, $e);
110 }
111
112 }
No preview for this file type
1 <?php namespace App\Http\Controllers;
2
3 use Input;
4 use App\Models\User;
5 use App\Models\CRMCall;
6 use App\Models\Sipid;
7 use App\Models\Kqueue;
8 use App\Models\Dialline;
9 use App\Models\Session;
10 use Config;
11
12 class AdminController extends Controller {
13
14
15 public function __construct()
16 {
17 $this->middleware('auth');
18 $this->middleware('module_access');
19 }
20
21 public function index()
22 {
23 $data=array();
24
25 return view('layout.module.admin.index',$data);
26 }
27 public function create()
28 {
29 //
30 }
31 public function store()
32 {
33 $action=Input::get('action');
34 if($action=="mmtbulkupload")return view('layout.module.admin.index',array());
35 if($action=="userlogoutall")
36 {
37 $sipids=Sipid::where("status","=","1")->get();
38 foreach($sipids as $tsip)
39 {
40 $newqueue=new Kqueue();
41 $newqueue->sipNotify($tsip,"adminCommand","user","logout","");
42 }
43
44 Dialline::where('status','!=','Free')->update(['status'=>'Free','conf'=>'','channel'=>'','server'=>'','updated_at'=>'0000-00-00 00:00:00']);
45 Sipid::where('status','!=','0')->update(['status'=>0,'user'=>0,'ready'=>0,'confup'=>0,'clients'=>'','server'=>'','updated_at'=>'0000-00-00 00:00:00']);
46
47 $serverarray=explode(",",Config::get("app.asterisk_slaves"));
48 foreach($serverarray as $server)
49 {
50 $sparts=explode(":",$server);
51
52 Sipid::where("id",">=",$sparts[1])->where("id","<=",$sparts[2])->update(['server' => $sparts[0],'updated_at'=>'0000-00-00 00:00:00']);
53 Dialline::where("id",">=",$sparts[3])->where("id","<=",$sparts[4])->update(['server' => $sparts[0],'updated_at'=>'0000-00-00 00:00:00']);
54 }
55
56 User::where('presence','>','0')->update(['presence'=>0]);
57 Session::truncate();
58
59 return "";
60 }
61 }
62 public function show($id)
63 {
64 $data=array();
65 if($id=='masterdata')return view('layout.module.admin.masterdata',$data);
66 if($id=='accesslog')return view('layout.module.admin.accesslog',$data);
67 if($id=='emaillog')return view('layout.module.admin.emaillog',$data);
68 if($id=='bulkmail')return view('layout.module.admin.bulkmail',$data);
69 if($id=='dllogfile')return response()->download(storage_path('logs/laravel-'.date('Y-m-d').'.log'));
70 if($id=='main')return view('layout.module.admin.main',$data);
71 if($id=='agentreport')return view('layout.module.admin.agentreport',$data);
72 if($id=='liveusers')return view('layout.module.admin.liveusers',$data);
73 }
74 public function edit($id)
75 {
76 //
77 }
78 public function update($id)
79 {
80 //
81 }
82 public function destroy($id)
83 {
84 //
85 }
86
87
88 public function dashboard()
89 {
90 $data=array();
91
92 return view('layout.module.admin.dashboard',$data);
93 }
94 }
1 <?php
2
3 namespace App\Http\Controllers\Auth;
4
5 use App\User;
6 use Validator;
7 use App\Http\Controllers\Controller;
8 use Illuminate\Foundation\Auth\ThrottlesLogins;
9 use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
10 use Session;
11
12 class AuthController extends Controller
13 {
14 /*
15 |--------------------------------------------------------------------------
16 | Registration & Login Controller
17 |--------------------------------------------------------------------------
18 |
19 | This controller handles the registration of new users, as well as the
20 | authentication of existing users. By default, this controller uses
21 | a simple trait to add these behaviors. Why don't you explore it?
22 |
23 */
24
25 use AuthenticatesAndRegistersUsers, ThrottlesLogins;
26
27 /**
28 * Where to redirect users after login / registration.
29 *
30 * @var string
31 */
32 protected $redirectTo = '/home';
33
34 /**
35 * Create a new authentication controller instance.
36 *
37 * @return void
38 */
39 public function __construct()
40 {
41 $this->middleware('guest', ['except' => 'logout']);
42 }
43
44 /**
45 * Get a validator for an incoming registration request.
46 *
47 * @param array $data
48 * @return \Illuminate\Contracts\Validation\Validator
49 */
50 protected function validator(array $data)
51 {
52 return Validator::make($data, [
53 'name' => 'required|max:255',
54 'email' => 'required|email|max:255|unique:users',
55 'password' => 'required|confirmed|min:6',
56 ]);
57 }
58
59 /**
60 * Create a new user instance after a valid registration.
61 *
62 * @param array $data
63 * @return User
64 */
65 protected function create(array $data)
66 {
67 return User::create([
68 'name' => $data['name'],
69 'email' => $data['email'],
70 'password' => bcrypt($data['password']),
71 ]);
72 }
73 }
1 <?php
2
3 namespace App\Http\Controllers\Auth;
4
5 use App\Http\Controllers\Controller;
6 use Illuminate\Foundation\Auth\ResetsPasswords;
7
8 class PasswordController extends Controller
9 {
10 /*
11 |--------------------------------------------------------------------------
12 | Password Reset Controller
13 |--------------------------------------------------------------------------
14 |
15 | This controller is responsible for handling password reset requests
16 | and uses a simple trait to include this behavior. You're free to
17 | explore this trait and override any methods you wish to tweak.
18 |
19 */
20
21 use ResetsPasswords;
22
23 /**
24 * Create a new password controller instance.
25 *
26 * @return void
27 */
28 public function __construct()
29 {
30 $this->middleware('guest');
31 }
32 }
1 <?php namespace App\Http\Controllers;
2
3 use Auth;
4 use Input;
5 use Response;
6 use App\Models\Group;
7 use App\Models\Master;
8 use App\Models\Record;
9 use App\Models\CRMCall;
10 use App\Models\CRMCallArchive;
11 use App\Models\CRM;
12 use App\Models\CRMCampaign;
13 use App\Models\CRMList;
14 use App\Jobs\KHRMSLib;
15 use App\Models\Sipid;
16 use App\Models\Dialline;
17 use App\Models\UserLog;
18 use App\Models\User;
19 use App\Models\Kqueue;
20 use App\Models\QCFeedback;
21 use DB;
22 use Log;
23 use Session;
24 $client='';
25
26 class AutodialController extends Controller {
27
28
29 public function index()
30 {
31
32 }
33 public function create()
34 {
35
36 }
37 public function store()
38 {
39
40
41 }
42 public function show($id)
43 {
44
45 //TODO: Need To Create New Function To Calculate (T : X + Y - Z - R) *** To Run In the Background
46 //TODO: Need To Create New Function To Get R
47 //TODO: Need To Edit Existing Function ( "getAvgTimeArray()" ) To Calculate X
48 //TODO: Need Define Y and Z as per need
49 //TODO: Need To Create New Function To Handle Early Media Cases (F)
50 //TODO: Need To Create Function To Drop ringing calls after RTO
51
52 if($id=="autodialmode")
53 {
54 $campaign=Input::get("client");
55 $user_id = Auth::user()->id;
56
57 $callsToDialled = $this->getCallsToBeDialled($campaign);
58 if($callsToDialled>0)
59 {
60 $this->createCall($campaign, $callsToDialled, $user_id);
61 }
62 }
63 }
64
65 //TODO: To Calculate D - Edit This Function If Required
66 public function getCallsToBeDialled($campaign)
67 {
68 $wakka = new KHRMSLib();
69 $mastersdata=$wakka->getCompanyMaster($campaign);
70
71 $ratio = $mastersdata["autodialercampaign"];
72 $availableUsers = $this->getFreeUserCnt($campaign);
73 $dialedCalls = $this->getDialedCallCount($campaign);
74
75 return $availableUsers*$ratio-$dialedCalls;
76 }
77
78 //TODO: Need To Edit getFreeUserCnt() To Calculate N
79
80 //To Get Number Of Free User which will be multiplied with Defined Ratio For Generating Number Of Calls
81 public function getFreeUserCnt($campaign)
82 {
83 $count=0;
84 $loggedInSips = Sipid::where('server','=',env('app_ip'))->where("user", "!=", 0)->where("status","=","1")->where("prepare_call","=","1")->where("clients","like","%$campaign%")->groupBy('user')->get();
85
86 if(count($loggedInSips))
87 foreach ($loggedInSips as $key => $loggedInSip)
88 {
89 $loggedInUsers[] = $loggedInSip->user;
90 }
91
92 $freeDials = Dialline::whereIn("user_id",$loggedInUsers)->where("status","=","Blocked")->count();
93
94 return count($loggedInSips)-$freeDials;
95 }
96
97 //TODO: To Calculate C - Edit This Function If Required
98 public function getDialedCallCount($campaign)
99 {
100 $cnt = Dialline::whereIn("status", ["Auto","AutoCall"])->where("conf","=","")->where("regexstr","=",$campaign)->count();
101
102 return $cnt;
103 }
104
105 public function getAvailCallInPool($campaign)
106 {
107 //$cnt = CRMCall::where("client", "=", $campaign)->where("state","=","DialEnd")->where("type", "=", "Auto")->where("substatus","!=","")->count();
108
109 $cnt = Dialline::where("status","=","Auto")->where("conf","=","")->where("regexstr","=",$campaign)->count();
110
111 return $cnt;
112 }
113
114 public function getAvgTimeArray($user)
115 {
116 $avgdisposecObj = CRMCall::select(DB::Raw('(avg(disposec))/1000 as avgdisposec'))->where("user_id", "=", $user)->orderby("id","desc")->limit(50)->where("type","!=","Inbound")->first();
117
118 $avgcallsecObj = CRMCall::select(DB::Raw('(avg(callsec))/1000 as avgcallsec'))->where("user_id", "=", $user)->orderby("id","desc")->limit(50)->where("type","!=","Inbound")->first();
119
120 $returnArray['avgdisposec'] = round($avgdisposecObj->avgdisposec);
121 $returnArray['avgcallsec'] = round($avgdisposecObj->avgcallsec);
122
123 return $returnArray;
124 }
125
126 public function createCall($campaign, $acalls, $user_id)
127 {
128 $wakka = new KHRMSLib();
129 $mastersdata=$wakka->getCompanyMaster($campaign);
130
131 if($acalls>0)
132 {
133 for($i=0;$i<$acalls;$i++)
134 {
135 $callerid="";
136 if(!empty($mastersdata["DialerDID"]))
137 $callerid=$mastersdata["DialerDID"];
138
139 $calleridarr=explode(":",$callerid);$dspan="1";
140 if(isset($calleridarr[1]))
141 {
142 $callerid=$calleridarr[0];$dspan=$calleridarr[1];
143 }
144
145 $dialline=Dialline::where('server','=', env('app_ip'))->where("status","=","Free")->where("enabled","=","1");
146 if($dspan!="")$dialline=$dialline->where('dspan','=',$dspan)->where('id','<=','30');
147 $dialline=$dialline->orderBy('updated_at','ASC')->first();
148
149 if(empty($dialline))
150 {
151 $dialline=Dialline::where('server','=', env('app_ip'))->where("status","=","Free")->where("enabled","=","1");
152 if($dspan!="")$dialline=$dialline->where('dspan','=', "2")->where('id','>','30');
153 $dialline=$dialline->orderBy('id','ASC')->first();
154 }
155
156 if($dialline)
157 {
158 $users=$wakka->getPersons("client='$campaign' and status='New' and mobile!='' limit 1");
159 if(sizeof($users)>=1)
160 {
161 $record=$wakka->getPerson($users[0]['id']);
162 if($record)
163 {
164 $record["peopledata"]["status"]="AutoCall";
165 $wakka->setPerson($users[0]['id'],$record);
166 }
167
168 $dialline->user_id=$user_id;
169 $dialline->status="AutoCall";
170 $dialline->regexstr=$users[0]['client'];
171 $dialline->number=$users[0]["mobile"];
172 $dialline->save();
173
174 $nowts=microtime(true)*1000;
175
176 //start the call log
177 $crmcall=new CRMCall();
178 $crmcall->number=$users[0]["mobile"];
179 $crmcall->user_id=0;
180 $crmcall->sipid_id=0;
181 $crmcall->crm_id=$users[0]['id'];
182 $crmcall->lan=$users[0]['lan'];
183 $crmcall->client=$users[0]['client'];
184 $crmcall->department=$users[0]['department'];
185 $crmcall->state='New';
186 $crmcall->type="AutoCall";
187 $crmcall->dialline_id=$dialline->id;
188
189 $crmcall->setTs('ts_Wait',$nowts);
190 $crmcall->setTs('ts_Call',$nowts);
191
192 $crmcall->did=$callerid;
193
194 $tdata=array();
195 $crmcall->data=json_encode($tdata);
196 $crmcall->save();
197
198 //start actual calls
199 $newqueue=new Kqueue();
200 $newqueue->autoCallOut($users[0]["mobile"],$callerid,$crmcall,$dialline);
201
202 }
203 }
204 else break;
205 }
206 }
207
208 //return 1;
209 }
210
211 }
1 <?php
2
3 namespace App\Http\Controllers;
4
5 use Illuminate\Foundation\Bus\DispatchesJobs;
6 use Illuminate\Routing\Controller as BaseController;
7 use Illuminate\Foundation\Validation\ValidatesRequests;
8 use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
9
10 class Controller extends BaseController
11 {
12 use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
13 }
1 <?php namespace App\Http\Controllers;
2
3 use App\Http\Controllers\Controller;
4
5 use DB;
6 use Auth;
7 use Config;
8 use Input;
9 use Response;
10 use App\Models\User;
11 use App\Models\Communitie;
12 use App\Jobs\KFileLib;
13 use App\Jobs\KAuthLib;
14 use App\Jobs\KHRMSLib;
15
16 class DashboardController extends Controller {
17
18 public function __construct()
19 {
20 $this->middleware('auth');
21 $this->middleware('module_access');
22 }
23
24 public function index()
25 {
26 $data=array();
27
28 $user=Auth::user();
29 $data["data"]=$user->data();
30 $data["meta"]=$user->meta();
31 if(Input::has("tz"))
32 {
33 $user->timezone=Input::get("tz");
34 $data["meta"]['ncnt']=0;$user->meta=json_encode($data["meta"]);
35 $user->save();
36 }
37 return view('layout.module.dashboard.index',$data);
38 }
39
40 public function create()
41 {
42 }
43
44 public function store()
45 {
46 }
47
48 public function show($id)
49 {
50 if($id=="s")
51 {
52 $kfile=new KFileLib();$kfile->folderSpaceUse(Auth::user()->id.'/');
53 return Response::make("",200);
54 }
55 if($id=="r")
56 {
57 $umeta=Auth::user()->meta();
58 $kauthlib=new KAuthLib();
59
60 if(!isset($umeta['kautherror']))$umeta['kautherror']=0;
61 if(isset($umeta['kauthlibuser'])&&isset($umeta['kauthlibcred']))
62 {
63 if(Config::get("app.extAuth")=="owa")
64 {
65 $authparams=explode(",",Config::get("app.extAuthParams"));if(!isset($authparams[0]))$authparams[0]="";if(!isset($authparams[1]))$authparams[1]="";
66 if(!$kauthlib->owaAuthCheck($authparams[0],$authparams[1],$umeta['kauthlibuser'],$umeta['kauthlibcred'],""))
67 {
68 $umeta['kautherror']++;
69 if($umeta['kautherror']>5)Auth::user()->status='Disabled';
70 Auth::user()->meta=json_encode($umeta);
71 Auth::user()->save();
72 if($umeta['kautherror']>5)return Response::make("document.location='logout';",200);
73 }
74 else
75 {
76 $umeta['kautherror']=0;
77 Auth::user()->meta=json_encode($umeta);
78 Auth::user()->save();
79 return Response::make("",200);
80 }
81 }
82 if(Config::get("app.extAuth")=="smtp")
83 {
84 $authparams=explode(",",Config::get("app.extAuthParams"));if(!isset($authparams[0]))$authparams[0]="";if(!isset($authparams[1]))$authparams[1]="";if(!isset($authparams[2]))$authparams[2]="";
85 if(!$kauthlib->smtpLoginCheck($authparams[0],$authparams[1],$authparams[2],$umeta['kauthlibuser'],$umeta['kauthlibcred']))
86 {
87 $umeta['kautherror']++;
88 if($umeta['kautherror']>5)Auth::user()->status='Disabled';
89 Auth::user()->meta=json_encode($umeta);
90 Auth::user()->save();
91 if($umeta['kautherror']>5)return Response::make("document.location='logout';",200);
92 }
93 else
94 {
95 $umeta['kautherror']=0;
96 Auth::user()->meta=json_encode($umeta);
97 Auth::user()->save();
98 return Response::make("",200);
99 }
100 }
101 }
102 }
103 if($id=="dpart")
104 {
105 $page=Input::get("page");
106 $data=array();
107
108 $user=Auth::user();
109 $data["data"]=$user->data();
110 $data["meta"]=$user->meta();
111 if(Input::has("tz"))
112 {
113 $user->timezone=Input::get("tz");
114 $data["meta"]['ncnt']=0;$user->meta=json_encode($data["meta"]);
115 $user->save();
116 }
117
118 return view('layout.module.dashboard.'.$page,$data);
119 }
120 if($id=="search")
121 {
122 $data=array();
123 $data['stype']=Input::get('stype');
124 $data['strarr']=explode(" ",Input::get('str'));
125 $data['listdata']=array();
126 //hashtag imgurl title subtitle bubbles()
127 $groupacl=Auth::user()->getAccessList("group",true,false,false);
128
129 if($data['stype']=="User")
130 {
131 $users0=User::whereIn("group",$groupacl)->where('status','=','Active');$orderby='';
132 $users2=User::whereIn("group",$groupacl);
133 $users3=User::whereIn("group",$groupacl);
134 foreach($data['strarr'] as $searchkey)
135 {
136 $searchkey=trim($searchkey);
137 if($searchkey!='')
138 {
139 if($searchkey=='Learner'||$searchkey=='Trainer'||$searchkey=='Organization')$users0=$users0->where('usertype','=',$searchkey);
140 else if($searchkey=='MaxEdupoints')$orderby='Edupoints';
141 else $users0=$users0->where('data','like',"%$searchkey%");
142
143 $users2=$users2->where('fullname','like',"%$searchkey%");
144 $users3=$users3->where('email','like',"%$searchkey%");
145 }
146 }
147 //if($orderby=='Edupoints')$users0=$users0->orderBy()
148 $users=array();
149 $users0=$users0->orderBy(DB::raw('RAND()'))->take(30)->get();
150 $users2=$users2->orderBy(DB::raw('RAND()'))->take(20)->get();
151 $users3=$users3->orderBy(DB::raw('RAND()'))->take(20)->get();
152 foreach($users0 as $user)$users[]=$user;
153 foreach($users2 as $user)$users[]=$user;
154 foreach($users3 as $user)$users[]=$user;
155 $users=array_unique($users);
156 if(!empty($users))
157 {
158 foreach($users as $user)
159 {
160 $tuserdata=array();
161 $tuserdata['id']=$user->id;
162 $tuserdata['type']='user';
163 $tuserdata['hashtag']="p-".$user->id;
164 $tuserdata['imgurl']=$user->fetchphotothumb();
165 $tuserdata['title']=$user->dispname();
166 $tuserdata['subtitle']=$user->dataval2('personal','gender')." ".$user->dataval2('personal','location')." - ".$user->dataval2('personal','country');
167 $tuserdata['bubbles']=array($user->dataval2('personal','level'),$user->dataval2('personal','function'));
168
169
170 $data['listdata'][]=$tuserdata;
171 }
172 }
173
174
175 }
176 if($data['stype']=="Community")
177 {
178 $commuity1=Communitie::whereIn("group",$groupacl)->where('status','=','Active');
179 $commuity2=Communitie::whereIn("group",$groupacl)->where('status','=','Active');
180 $commuity3=Communitie::whereIn("group",$groupacl)->where('status','=','Active');
181
182 $commuity1=$commuity1->where(function ($query) use($data) {
183 foreach($data['strarr'] as $searchkey)
184 {
185 $searchkey=trim($searchkey);
186 if($searchkey!='')
187 {
188 $query->where('description','like',"%$searchkey%");
189 }
190 }
191 });
192 $commuity2=$commuity2->where(function ($query) use($data) {
193 foreach($data['strarr'] as $searchkey)
194 {
195 $searchkey=trim($searchkey);
196 if($searchkey!='')
197 {
198 $query->orWhere('category','like',"%$searchkey%");
199 }
200 }
201 });
202 $commuity3=$commuity3->where(function ($query) use($data) {
203 foreach($data['strarr'] as $searchkey)
204 {
205 $searchkey=trim($searchkey);
206 if($searchkey!='')
207 {
208 $query->orWhere('name','like',"%$searchkey%");
209 }
210 }
211 });
212
213 $commuity1=$commuity1->orderBy(DB::raw('RAND()'))->take(20)->get();
214 $commuity2=$commuity2->orderBy(DB::raw('RAND()'))->take(20)->get();
215 $commuity3=$commuity3->orderBy(DB::raw('RAND()'))->take(20)->get();
216 $community=array();
217 if(!empty($commuity1))foreach($commuity1 as $comm)$community[$comm->id]=$comm;
218 if(!empty($commuity2))foreach($commuity2 as $comm)$community[$comm->id]=$comm;
219 if(!empty($commuity3))foreach($commuity3 as $comm)$community[$comm->id]=$comm;
220
221 if(!empty($community))
222 {
223 foreach($community as $tcomm)
224 {
225 $tuserdata=array();
226 $tuserdata['id']=$tcomm->id;
227 $tuserdata['type']='community';
228 $tuserdata['hashtag']="g-".$tcomm->id;
229 $tuserdata['imgurl']="assets/images/community.jpg";
230 $tuserdata['title']=$tcomm->name;
231 $tuserdata['subtitle']=" Community ";
232 $tuserdata['bubbles']=array_unique(array_filter(explode(",",$tcomm->category)));
233
234
235 $data['listdata'][]=$tuserdata;
236 }
237 }
238 }
239 return view('layout.module.dashboard.search',$data);
240 }
241
242 if($id=="dashlet")
243 {
244 $module=strtolower(Input::get("module"));
245 $client=Input::get("client");
246
247 if($client=="")$client = Auth::user()->sel_campaign;
248
249 $data['client'] = $client;
250
251 if($module!=""&&view()->exists("layout.module.dashboard.$module"))
252 {
253 return view("layout.module.dashboard.$module", $data);
254 }
255 }
256 }
257 public function edit($id)
258 {
259 //
260 }
261 public function update($id)
262 {
263 //
264 }
265 public function destroy($id)
266 {
267 //
268 }
269
270
271 public function dashboard()
272 {
273 $data["id"]="Dashboard";
274
275 return view('layout.module.dashboard.dashboard',$data);
276 }
277 }
1 <?php namespace App\Http\Controllers;
2
3 use Auth;
4 use Input;
5 use Response;
6 use App\Models\Group;
7 use App\Models\Master;
8 use App\Models\Record;
9 use App\Models\CRMCall;
10 use App\Models\CRMCallArchive;
11 use App\Models\CRM;
12 use App\Models\CRMCampaign;
13 use App\Models\CRMList;
14 use App\Jobs\KHRMSLib;
15 use App\Models\Sipid;
16 use App\Models\Dialline;
17 use App\Models\UserLog;
18 use App\Models\User;
19 use App\Models\Kqueue;
20 use DB;
21 use Log;
22 use Session;
23 $client='';
24
25 class DataController extends Controller {
26
27 public function __construct()
28 {
29 $this->middleware('auth');
30 $this->middleware('module_access');
31 }
32
33 public function index()
34 {
35 }
36
37 public function create()
38 {
39 }
40
41 public function store()
42 {
43 $action = Input::get("action");
44
45 if($action=="upload")
46 {
47 $data['wakka'] = new KHRMSLib();
48 return view("layout.module.data.upload",$data);
49 }
50 }
51
52 public function show($id)
53 {
54 if($id=="display")
55 {
56 return view("layout.module.data.display");
57 }
58
59 if($id=="upload")
60 {
61 return view("layout.module.data.upload");
62 }
63
64 if($id=="load")
65 {
66 $page = Input::get('page');
67
68 $listingCount = 20;
69 $offset = ($page-1)*$listingCount;
70 if($offset < 0)$offset=0;
71 $limit = $listingCount;
72
73 $customers = DB::table('records')->offset($offset)->limit($limit)->get();
74
75 $output = "<table class='table table-bordered table-striped'>
76 <tr>
77 <th style='background-color: #999 !important;color: #fff;text-align:center;'>ID</th>
78 <th style='background-color: #999 !important;color: #fff;text-align:center;'>LAN</th>
79 <th style='background-color: #999 !important;color: #fff;text-align:center;'>Name</th>
80 <th style='background-color: #999 !important;color: #fff;text-align:center;'>Number</th>
81 <th style='background-color: #999 !important;color: #fff;text-align:center;'>Campaign</th>
82 <th style='background-color: #999 !important;color: #fff;text-align:center;'>Organization</th>
83 <th style='background-color: #999 !important;color: #fff;text-align:center;'>Designation</th>
84 </tr>";
85
86 foreach($customers as $customer){
87 $output .= "<tr>
88 <td>$customer->id</td>
89 <td>$customer->lan</td>
90 <td>$customer->customerName</td>
91 <td>$customer->mobile</td>
92 <td>$customer->client</td>
93 <td>$customer->organizationName</td>
94 <td>$customer->designation</td>
95 </tr>";
96 }
97
98 $output .= "</table>";
99
100 return $output;
101 }
102
103 if($id=="churn")
104 {
105 // $recordsData = DB::table('records')->select('id','lan','client','status','dialer_status','dialer_substatus')->get();
106 $data['campaign'] = DB::table('records')->select('client',DB::raw('COUNT(client) as count'))->groupBy('client')->get();
107
108 $data['callStatus'] = DB::table('records')->select('status',DB::raw('COUNT(status) as count'))->groupBy('status')->get();
109
110 $data['dispoStatus'] = DB::table('records')->select('dialer_status',DB::raw('COUNT(dialer_status) as count'))->groupBy('dialer_status')->get();
111
112 $data['resultcodeStatus'] = DB::table('records')->select('dialer_substatus',DB::raw('COUNT(dialer_substatus) as count'))->groupBy('dialer_substatus')->get();
113
114 return view("layout.module.data.churn",$data);
115 }
116
117 if($id=="churnQueue")
118 {
119 $churnAction = Input::get("action");
120 $churnCampaign = Input::get("campaign");
121 $churnStatus = Input::get("status");
122 $churnSubStatus = Input::get("substatus");
123 $oldStatusString = 's:0:"";';
124
125 switch ($churnStatus) {
126 case 'Incall': $oldStatusString = 's:6:"Incall";'; break;
127 case 'Called': $oldStatusString = 's:6:"Called";'; break;
128 case 'New': $oldStatusString = 's:3:"New";'; break;
129 case 'NoNumber': $oldStatusString = 's:8:"NoNumber";'; break;
130 case 'Noqueue': $oldStatusString = 's:7:"Noqueue";'; break;
131 }
132
133 $newStatusString = 's:3:"New";';
134
135 if($churnAction == "callStatus" && $churnCampaign != "" && $churnStatus != ""){
136 if($churnCampaign == "AllCampaignData"){
137 DB::table('records')->where('status','=',$churnStatus)
138 ->update(['status'=>'New','peopledata' => DB::raw("REPLACE(peopledata,'$oldStatusString','$newStatusString')")]);
139
140 }else{
141 DB::table('records')->where('status','=',$churnStatus)->where('client','=',$churnCampaign)
142 ->update(['status'=>'New','peopledata' => DB::raw("REPLACE(peopledata,'$oldStatusString','$newStatusString')")]);
143 }
144
145 }elseif($churnAction == "dialerStatus" && $churnCampaign != "" && $churnStatus != ""){
146 if($churnCampaign == "AllCampaignData"){
147 DB::table('records')->where('dialer_status','=',$churnStatus)->update(['status'=>'New','peopledata' => DB::raw("REPLACE(peopledata,'". 's:6:"Called";' . "','$newStatusString')"),'peopledata' => DB::raw("REPLACE(peopledata,'". 's:7:"NoQueue";' . "','$newStatusString')")]);
148 }else{
149 DB::table('records')->where('client','=',$churnCampaign)->where('dialer_status','=',$churnStatus)->update(['status'=>'New','peopledata' => DB::raw("REPLACE(peopledata,'". 's:6:"Called";' . "','$newStatusString')"),'peopledata' => DB::raw("REPLACE(peopledata,'". 's:7:"NoQueue";' . "','$newStatusString')")]);
150 }
151
152 }elseif($churnAction == "clearQueue" && $churnCampaign != "" && $churnStatus != ""){
153 if($churnCampaign == "AllCampaignData"){
154 DB::table('records')->where('status','=','New')->update(['status'=>'Noqueue']);
155 return "All campaign records has removed from queue";
156 }else{
157 DB::table('records')->where('client','=',$churnCampaign)->where('status','=','New')->update(['status'=>'Noqueue']);
158 return "In ".$churnCampaign." campaign records has removed from queue";
159 }
160 }elseif($churnAction == "dialersubStatus" && $churnCampaign != "" && $churnStatus != ""){
161 if($churnCampaign == "AllCampaignData"){
162 DB::table('records')->where('dialer_substatus','=',$churnStatus)->update(['status'=>'New','peopledata' => DB::raw("REPLACE(peopledata,'". 's:6:"Called";' . "','$newStatusString')"),'peopledata' => DB::raw("REPLACE(peopledata,'". 's:7:"NoQueue";' . "','$newStatusString')")]);
163 }else{
164 DB::table('records')->where('client','=',$churnCampaign)->where('dialer_substatus','=',$churnStatus)->update(['status'=>'New','peopledata' => DB::raw("REPLACE(peopledata,'". 's:6:"Called";' . "','$newStatusString')"),'peopledata' => DB::raw("REPLACE(peopledata,'". 's:7:"NoQueue";' . "','$newStatusString')")]);
165 }
166 }else{
167 return "Select the filters";
168 }
169 return "In ".$churnCampaign." campaign ".$churnStatus." records churn successfully";
170 }
171
172 if($id=="churnCampaignChange")
173 {
174 $churnAction = Input::get("action");
175 $churnCampaign = Input::get("campaign");
176
177
178 if($churnAction == "campaignDispo"){
179 if($churnCampaign=="AllCampaignData"){
180 $data = DB::table('records')->select('dialer_status',DB::raw('COUNT(dialer_status) as count'))->groupBy('dialer_status')->get();
181 }else{
182 $data = DB::table('records')->select('dialer_status',DB::raw('COUNT(dialer_status) as count'))->where('client','=',$churnCampaign)->groupBy('dialer_status')->get();
183 }
184 $output = "";
185 foreach ($data as $dispo) {
186 $name = $dispo->dialer_status?$dispo->dialer_status:"--Blank--";
187 $output .= "<label><input type='radio' name='dispoStatus' value='$dispo->dialer_status'/> $name ($dispo->count)</label><br/>";
188 }
189 return $output;
190 }
191 //data churn by result code wise.
192 if($churnAction == "resultcampaigncode"){
193 if($churnCampaign=="AllCampaignData"){
194 $data = DB::table('records')->select('dialer_substatus',DB::raw('COUNT(dialer_substatus) as count'))->groupBy('dialer_substatus')->get();
195 }else{
196 $data = DB::table('records')->select('dialer_substatus',DB::raw('COUNT(dialer_substatus) as count'))->where('client','=',$churnCampaign)->groupBy('dialer_substatus')->get();
197 }
198 $output = "";
199 foreach ($data as $dispo) {
200 $name = $dispo->dialer_substatus?$dispo->dialer_substatus:"--Blank--";
201 $output .= "<label><input type='radio' name='disposubStatus' value='$dispo->dialer_substatus'/> $name ($dispo->count)</label><br/>";
202 }
203 return $output;
204 }
205
206 if($churnAction == "campaignCall"){
207 if($churnCampaign=="AllCampaignData"){
208 $data = DB::table('records')->select('status',DB::raw('COUNT(status) as count'))->groupBy('status')->get();
209 }else{
210 $data = DB::table('records')->select('status',DB::raw('COUNT(status) as count'))->where('client','=',$churnCampaign)->groupBy('status')->get();
211 }
212 $output = "";
213 foreach ($data as $dispo) {
214 $name = $dispo->status?$dispo->status:"--Blank--";
215 $output .= "<label><input type='radio' name='callStatus' value='$dispo->status'/> $name ($dispo->count)</label><br/>";
216 }
217 return $output;
218 }
219 }
220
221 return "";
222 }
223
224 public function edit($id)
225 {
226
227 }
228 public function update($id)
229 {
230
231 }
232 public function destroy($id)
233 {
234 //
235 }
236 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php namespace App\Http\Controllers;
2
3 use Auth;
4 use Input;
5 use Response;
6 use App\Models\Group;
7 use App\Models\Master;
8 use App\Models\Record;
9 use App\Models\CRMCall;
10 use App\Models\CRMCallArchive;
11 use App\Models\CRM;
12 use App\Models\CRMCampaign;
13 use App\Models\CRMList;
14 use App\Jobs\KHRMSLib;
15 use App\Models\Sipid;
16 use App\Models\Dialline;
17 use App\Models\UserLog;
18 use App\Models\User;
19
20 use DB;
21 use Log;
22 use Session;
23 $client='';
24
25 class DialermodesaveController extends Controller {
26
27
28 public function index()
29 {
30
31 }
32 public function create()
33 {
34
35 }
36 public function store()
37 {
38
39
40 }
41 public function show($id)
42 {
43
44 if($id=="savedialerstate")
45 {
46 $dialerstate=Input::get('dialerstate');
47 $client=Input::get("client");
48
49 //echo "Prashant".$dialerstate;
50 DB::table('users')->where('id', Auth::user()->id)->update(['sel_campaign'=>Input::get("client"),'current_dialmode'=>Input::get('dialerstate')]);
51 }
52 }
53 private function redirectIncoming()
54 {
55
56 }
57
58 }
1 <?php namespace App\Http\Controllers;
2
3 use Auth;
4 use Input;
5 use Config;
6 use Session;
7
8 use App\Models\Group;
9 use App\Models\User;
10
11 class GroupController extends Controller {
12
13
14 public function __construct()
15 {
16 $this->middleware('auth');
17 $this->middleware('module_access');
18 }
19
20 public function index()
21 {
22 return view('layout.module.group.index',array('grouplist'=>Group::where('owner','=',Auth::user()->id)->orderBy("created_at","DESC")->paginate(30)));
23 }
24 public function create()
25 {
26 return view('layout.module.group.create');
27 }
28 public function store()
29 {
30 $data=array();
31 $grpname=substr(htmlentities(trim(Input::get("group"))),0,200);
32
33 $exists=Group::where("group","=",$grpname)->first();
34 if(!$exists)
35 {
36 $group=new Group();
37
38 $group->group=$grpname;
39 $group->dispname=$group->group;
40 $group->owner=Auth::user()->id;
41 $group->status=Input::get("groupstatus");
42 $role=Auth::user()->role();
43 foreach(Config::get('app.app_modules') as $tmod=>$tmodarr)
44 if (strstr(",".$role->modulerwa.",",",$tmod,"))
45 $data[$tmod."_settings"]=Input::get($tmod."_settings");
46 $group->data=json_encode($data);
47 $group->save();
48
49 return view('layout.module.group.edit',array('tgroup'=>$group,'displaymsg'=>array("type"=>"success","text"=>"Group Created")));
50 }
51 else
52 {
53 return view('layout.module.group.create',array('tgroup'=>array(),'displaymsg'=>array("type"=>"Error!","text"=>"Group Already Exists")));
54 }
55 }
56 public function show($id)
57 {
58 return view('layout.module.group.edit',array('tgroup'=>Group::find($id)));
59 }
60 public function edit($id)
61 {
62 return view('layout.module.group.edit',array('tgroup'=>Group::find($id)));
63 }
64 public function update($id)
65 {
66 $data=array();
67
68 $group=Group::find($id);
69
70 //$group->group=Input::get("group");
71 $group->status=Input::get("groupstatus");
72 $group->parent=Input::get("groupparent");
73 $group->dispname=Input::get("groupdispname");
74 if(trim($group->dispname)=="")$group->dispname=$group->group;
75
76 $role=Auth::user()->role();
77 foreach(Config::get('app.app_modules') as $tmod=>$tmodarr)
78 if (strstr(",".$role->modulerwa.",",",$tmod,"))
79 $data[$tmod."_settings"]=Input::get($tmod."_settings");
80
81 $group->data=json_encode($data);
82 $group->save();
83
84 return view('layout.module.group.edit',array('tgroup'=>$group,'displaymsg'=>array("type"=>"success","text"=>"Group Updated")));
85 }
86 public function destroy($id)
87 {
88 $group=Group::find($id);
89 $group->status="Disabled";
90 $group->save();
91
92 return "Group Disabled";
93 }
94
95
96 public function dashboard()
97 {
98 //echo "OK";
99 }
100 }
1 <?php namespace App\Http\Controllers;
2
3 use Input;
4 use App\Jobs\KHRMSLib;
5 use App\Models\Cutoff;
6 use Auth;
7 use Response;
8
9 class HRController extends Controller {
10
11 public function __construct()
12 {
13 $this->middleware('auth');
14 $this->middleware('module_access');
15 }
16
17 public function index()
18 {
19 $data=array();
20 $data['wakka'] = new KHRMSLib();
21 return view('layout.module.hr.index',$data);
22 }
23 public function create()
24 {
25 //
26 }
27 public function store()
28 {
29 if(Input::get('action') == "CutOff"){
30 //change start code
31 $cutoff = new Cutoff();
32 $cutoff->starttime=Input::get("cutoffstarttime");
33 $cutoff->endtime=Input::get("cutoffendtime");
34 $cutoff->user_id=Auth::user()->id;
35 $cutoff->save();
36 return Response::make("<script>simpleNotification('success','topRight','Cutoff added successfully!');</script>");
37 //change end code
38 }else{
39 $data=array();
40 $data['wakka'] = new KHRMSLib();
41 return view('layout.module.hr.'.strtolower(Input::get('action')),$data);
42 }
43 }
44 public function show($id)
45 {
46 $data=array();
47 $data['wakka'] = new KHRMSLib();
48
49 $type='text/html';
50 if($id=='IDCard')$type="image/png";
51 if($id=='SalarySlip')$type="application/pdf";
52 if($id=='IncentiveSlip')$type="application/pdf";
53
54 return response()->view('layout.module.hr.'.strtolower($id),$data)->header('Content-Type', $type);
55 }
56 public function edit($id)
57 {
58 //
59 }
60 public function update($id)
61 {
62 //
63 }
64 public function destroy($id)
65 {
66 //
67 }
68
69
70 public function dashboard()
71 {
72 //echo "OK";
73 }
74 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php namespace App\Http\Controllers;
2
3 use Auth;
4 use Config;
5 use Response;
6 use Input;
7 use Cache;
8 use App\Models\Message;
9 use App\Models\Sipid;
10 use App\Jobs\KPushNotify;
11 use App\Models\User;
12 use App\Models\Kqueue;
13 use DB;
14
15 class MessageController extends Controller {
16
17 public function __construct()
18 {
19 $this->middleware('auth');
20 $this->middleware('module_access');
21 }
22
23 public function index()
24 {
25 //$messages=Message::where("to","=",Auth::user()->username)->whereIn("status",array("New","Read"))->orderBy('updated_at','desc')->paginate(50);
26 //return view('layout.module.message.index',array("messages"=>$messages));
27
28 $user=Auth::user();
29
30 $data=array();
31 $data["data"]=json_decode($user->data,true);
32 $data["id"]=$user->id;
33 $data["user"]=$user;
34 $data["displayname"]=Auth::user()->dispname();
35 $data["myphoto"] = $user->fetchphoto();
36
37 $data["messages"]=Message::where('to','=',$user->id)->orderBy("updated_at","DESC")->take(100)->get();
38 $data["newcount"]=Message::where('to','=',$user->id)->where('status','=','New')->count();
39 $data["users"]=array();
40 foreach($data["messages"] as $message)
41 {
42 $tuser=User::find($message->from);
43 if($tuser)
44 {
45 if(!isset($data["users"][$message->from]))
46 {
47 $data["message_time"][$message->id]=Auth::user()->post_date($message->updated_at);
48 $data["users"][$message->from]=array();
49 $data["users"][$message->from]['photothumb']=Auth::user()->fetchphotothumb($message->from);
50 $data["users"][$message->from]['dispname']=$tuser->dispname();
51 }
52 else
53 {
54 //self chat?
55 $data["message_time"][$message->id]=Auth::user()->post_date($message->updated_at);
56 //$data["users"][$message->from]=array();
57 //$data["users"][$message->from]['photothumb']=Auth::user()->fetchphotothumb($message->from);
58 //$data["users"][$message->from]['dispname']=$tuser->dispname();
59 }
60 }
61 }
62
63 return view(Config::get('app.mytheme').'.module.message.index',$data);
64 }
65 public function create()
66 {
67 //
68 }
69 public function store()
70 {
71 $type=Input::get("type");
72 if($type=="chat")
73 {
74 $id=explode("_",Input::get("id"));
75 //chanch if $id[1] is a user and in our friendlist TODO
76 $msg=htmlentities(Input::get("msg"));
77 $nowTS=time();
78
79 if(Message::where("from","=",Auth::user()->id)->where("created_at",'>',date('Y-m-d H:i:s',(time()-(60*60))))->count()>30)return Response::make("simpleNotification('error','topRight','Fairplay Voilation #940');");
80 if(Message::where("from","=",Auth::user()->id)->where("created_at",'>',date('Y-m-d H:i:s',(time()-(24*60*60))))->count()>100)return Response::make("simpleNotification('error','topRight','Fairplay Voilation #941');");
81
82 $ckey='chat'.Auth::user()->id.$id[1];
83 if(Cache::get($ckey,0)>100)return Response::make("simpleNotification('error','topRight','Fairplay Voilation #942');");
84 Cache::put($ckey,Cache::get($ckey,0)+1, 24*60);
85
86 $messageTo=Message::where("to","=",$id[1])->where("from","=",Auth::user()->id)->where("subject","=","Chat")->first();
87 $messageFrom=Message::where("to","=",Auth::user()->id)->where("from","=",$id[1])->where("subject","=","Chat")->first();
88 if(!$messageTo)
89 {
90 $messageTo=new Message();
91 $messageTo->to=$id[1];
92 $messageTo->from=Auth::user()->id;
93 $messageTo->subject="Chat";
94 }
95 if(!$messageFrom)
96 {
97 $messageFrom=new Message();
98 $messageFrom->to=Auth::user()->id;
99 $messageFrom->from=$id[1];
100 $messageFrom->subject="Chat";
101 }
102 $messageTo->status="Read";
103 $messageFrom->status="Read";
104
105
106 $dataTo=json_decode($messageTo->data,true);
107 $dataFrom=json_decode($messageFrom->data,true);
108
109 $dataTo[$nowTS]=array(Auth::user()->id,$msg);
110 $dataFrom[$nowTS]=array(Auth::user()->id,$msg);
111
112 $messageTo->data=json_encode($dataTo);
113 $messageFrom->data=json_encode($dataFrom);
114
115
116 $messageTo->save();
117 $messageFrom->save();
118
119 //add a queue notify to user if online
120 $noty=new KPushNotify();
121 $res=$noty->send(array($id[1]),"chat",Auth::user()->dispname(),$msg,Auth::user()->id);
122
123
124 if(!isset($res[$id[1]])||$res[$id[1]]<=0)
125 {
126 $messageTo->status="New";
127 $messageTo->save();
128 return Response::make("simpleNotification('alert','topRight','User is offline');");
129 }
130
131 }
132 if($type=="call")
133 {
134 $id=explode("_",Input::get("id"));
135
136 $sipid=Sipid::find(Input::get('sipid'));
137 $tosipid=Sipid::where("user","=",$id[1])->where("status","=","1")->first();
138 $tosip=0;
139 if($sipid&&$tosipid)
140 {
141 $tosip=$tosipid->id;
142
143 $newqueue=new Kqueue();
144 $newqueue->sipOriginate($sipid,"1001".$tosip,"kstychDialer");
145 }
146
147 return Response::make($tosip);
148 }
149 }
150 public function show($id)
151 {
152 if($id=="topbar")
153 {
154 $messages=Message::where("to","=",Auth::user()->id)->where("status","=","New")->orderBy('created_at','desc')->take(10)->get();
155 $count=Message::where("to","=",Auth::user()->id)->where("status","=","New")->count();
156
157 $data=array();
158 foreach($messages as $message)
159 {
160 $data[]=array("fromuser"=>$message->from,
161 "text"=>$message->subject,
162 "tstr"=>date("d-M H:i",strtotime($message->created_at)));
163 }
164 return view('layout.topbar.message',array("messages"=>$data,"messagescount"=>$count));
165 }
166
167
168
169 $data=array();
170 $tmessage=Message::find($id);
171 if($tmessage->subject=="Chat")
172 {
173 if($tmessage->to==Auth::user()->id)
174 {
175 $data['fromuser']=$tmessage->from;
176 $data["id"]=$id;
177 $data['mid']=$id;
178 $data['tuser']=User::find($tmessage->from);
179
180 $data['messages']=json_decode($tmessage->data,true);
181 $data["users"]=array();
182 foreach($data["messages"] as $ts=>$message)
183 {
184 $data["message_time"]["$ts"]=Auth::user()->post_date(date("Y-m-d H:i",$ts));
185
186 //$dataTo[$nowTS]=array(Auth::user()->id,$msg);
187 $tuser=User::find($message[0]);
188 if($tuser)
189 {
190 if(!isset($data["users"][$message[0]]))
191 {
192 $data["users"][$message[0]]=array();
193 $data["users"][$message[0]]['photothumb']=Auth::user()->fetchphotothumb($message[0]);
194 $data["users"][$message[0]]['dispname']=$tuser->dispname();
195 }
196 }
197 }
198 if($tmessage->status=="New"){$tmessage->status="Read";$tmessage->save();}
199 }
200 return view(Config::get('app.mytheme').'.module.message.messagecontent',$data);
201 }
202
203
204
205 return view('layout.module.message.msg',array("message"=>Message::find($id)));
206 }
207 public function edit($id)
208 {
209 //
210 }
211 public function update($id)
212 {
213 //
214 }
215 public function destroy($id)
216 {
217 //
218 }
219
220 public function dashboard()
221 {
222 //echo "OK";
223 }
224
225 public function sendSupVisorMessage()
226 {
227 $agentsNewArr = array();
228
229 $agents = Input::get('agents');
230 $message = Input::get('message');
231 $sup_id = Auth::user()->usertype;
232 $status = "New";
233
234 $agentsArr = explode(",", $agents);
235 foreach ($agentsArr as $key => $agent) {
236 $agentsNewArr[$key] = $agent."-Unread";
237 }
238
239 $updatedAgents = implode(",", $agentsNewArr);
240
241 DB::statement("insert into supervisor_message set created_at='".date("Y-m-d H:i:s")."', updated_at='".date("Y-m-d H:i:s")."', sup_id='$sup_id',agents='$agents',message='$message',status='$updatedAgents'");
242
243 return;
244 }
245
246 public function viewSupVisorMessage($msg_id, $username)
247 {
248 $data["newcount"]=DB::table('supervisor_message')->where('agents','like','%'.Auth::user()->username.'%')->where('status','like','%'.Auth::user()->username."-Unread".'%')->count();
249
250 $data["allMesgs"] = DB::table('supervisor_message')->where('agents','like','%'.Auth::user()->username.'%')->get();
251
252 if(Auth::user()->usertype == "Supervisor")
253 {
254 $data["allMesgs"] = DB::table('supervisor_message')->where('sup_id','=',Auth::user()->username)->get();
255 }
256
257 return view('layout.module.message.supmsg', $data);
258 }
259
260 public function viewMessage($msg_id, $username='')
261 {
262 $msgDet = DB::table('supervisor_message')->where('id','=',$msg_id)->get();
263
264 foreach ($msgDet as $key => $val) {
265 $msg = $val->message;
266 $status = $val->status;
267 }
268
269 $statUsrArr = explode(",", $status);
270
271 foreach ($statUsrArr as $key => $statArr) {
272 $stat = explode("-", $statArr);
273
274 if($stat[0] == $username)
275 {
276 $stat[1] = "Read";
277 $mergeStat = implode("-", $stat);
278 $statUsrArr[$key] = $mergeStat;
279 }
280 }
281
282 $updateStatus = implode(",", $statUsrArr);
283
284 DB::statement("update supervisor_message set updated_at='".date("Y-m-d H:i:s")."',status='$updateStatus' where id='$msg_id'");
285
286 if(Auth::user()->usertype == "Supervisor")
287 {
288 return $status;
289 }
290 else
291 {
292 return $msg;
293 }
294 }
295 }
1 <?php namespace App\Http\Controllers;
2
3 use Auth;
4 use Input;
5 use Config;
6 use Session;
7 use App\Http\Controllers;
8 use App\Http\Requests;
9 use Illuminate\Http\Request;
10 use DB;
11 use App\Models\Group;
12 use App\Models\User;
13 use App\Jobs\KHRMSLib;
14 use Log;
15 use DateTime;
16
17 class NotesController extends Controller
18 {
19 public function __construct()
20 {
21 // $this->middleware('auth');
22 // $this->middleware('module_access');
23 }
24
25 public function loadQuestions($userId='')
26 {
27 $fieldDetails=array();
28 $userId = Auth::user()->id;
29
30 $notesDetails = DB::table('agent_notes')
31 ->where('user_id',$userId)
32 ->get();
33
34 if($notesDetails != null){
35 $notesDetails = $notesDetails[0];
36
37 for($i=1;$i<=50;$i++){
38 $field = 'field_'.$i;
39
40 $fieldDetails[$i] = explode(":",$notesDetails->$field);
41 }
42
43 usort($fieldDetails, function($a1, $a2) {
44 $v1 = strtotime($a1[1]);
45 $v2 = strtotime($a2[1]);
46 return $v2 - $v1; // $v2 - $v1 to reverse direction
47 });
48
49 foreach($fieldDetails as $key=> $field){
50 $fieldDetails[$key+1] = $field;
51 }
52 }
53
54 return view('layout.module.notes.index',compact('userId','fieldDetails','notesDetails'));
55 }
56
57 public function store()
58 {
59 $userId=Input::get("user_id");
60 $action=Input::get("action");
61 $fieldVal=Input::get("fieldVal");
62 $dashboarduser=Auth::user();
63
64 $notesDetails = DB::table('agent_notes')
65 ->where('user_id',$userId)
66 ->get();
67
68 /*$fieldDetails=array();
69
70 for($i=1;$i<=50;$i++){
71 $field = 'field_'.$i;
72
73 $fieldDetails[$i] = explode(":",$notesDetails[0]->$field);}
74
75 usort($fieldDetails, function($a1, $a2) {
76 $v1 = strtotime($a1[1]);
77 $v2 = strtotime($a2[1]);
78 return $v2 - $v1; // $v2 - $v1 to reverse direction
79 });
80
81 foreach($fieldDetails as $key=> $field){
82 $fieldDetails[$key+1] = $field;
83 }*/
84
85 if($action=="save")
86 {
87 $fieldArray = array();
88 $fieldVal = explode(",",$fieldVal);
89
90 for($i=0;$i<50;$i++){
91 $fieldArray[]="field_".($i+1)."='".$fieldVal[$i]."'";
92 }
93
94 $setArray = implode(",",$fieldArray);
95
96 if($notesDetails == null)
97 {
98 DB::statement("insert into agent_notes set created_at='".date("Y-m-d H:i:s")."', updated_at='".date("Y-m-d H:i:s")."', user_id='".$userId."', $setArray" );
99 }
100 else{
101 $notesDetails = $notesDetails[0];
102
103 DB::statement("update agent_notes set updated_at='".date("Y-m-d H:i:s")."', $setArray where user_id='".$userId."'");
104 }
105
106 $notesDetails = DB::table('agent_notes')
107 ->where('user_id',$userId)
108 ->get();
109
110 $fieldDetails=array();
111
112 for($i=1;$i<=50;$i++){
113 $field = 'field_'.$i;
114
115 $fieldDetails[$i] = explode(":",$notesDetails[0]->$field);}
116
117 usort($fieldDetails, function($a1, $a2) {
118 $v1 = strtotime($a1[1]);
119 $v2 = strtotime($a2[1]);
120 return $v2 - $v1; // $v2 - $v1 to reverse direction
121 });
122
123 foreach($fieldDetails as $key=> $field){
124 $fieldDetails[$key+1] = $field;
125 }
126
127 unset($fieldDetails[0]);
128
129 return view('layout.module.notes.index',compact('userId','notesDetails','fieldDetails'));
130 }
131
132 }
133
134 }
135
136
1 <?php namespace App\Http\Controllers;
2
3 use Auth;
4 use App\Models\Notification;
5
6 class NotificationController extends Controller {
7
8
9 public function __construct()
10 {
11 $this->middleware('auth');
12 $this->middleware('module_access');
13 }
14
15 public function index()
16 {
17 $notifications=Notification::where("to","=",Auth::user()->username)->where("status","=","New")->orderBy('created_at')->get();
18 return view('layout.module.notification.index',array("notifications"=>$notifications));
19 }
20 public function create()
21 {
22 //
23 }
24 public function store()
25 {
26 //
27 }
28 public function show($id)
29 {
30 if($id=="topbar")
31 {
32 $this->checkLiveRooms();
33
34 $notifications=Notification::where("to","=",Auth::user()->username)->where("status","=","New")->orderBy('created_at','desc')->take(10)->get();
35 $count=Notification::where("to","=",Auth::user()->username)->where("status","=","New")->count();
36
37 $data=array();
38 foreach($notifications as $notification)
39 {
40 $data[]=array("sign"=>"+",
41 "type"=>$notification->type,
42 "text"=>$notification->data,
43 "tstr"=>date("d-M H:i",strtotime($notification->created_at)));
44 }
45 return view('layout.topbar.notification',array("notifications"=>$data,"notificationscount"=>$count));
46 }
47 }
48 public function edit($id)
49 {
50 //
51 }
52 public function update($id)
53 {
54 //
55 }
56 public function destroy($id)
57 {
58 if($id=="clearall")
59 {
60 Notification::where("to","=",Auth::user()->username)->where("status","=","New")->update(array('status' => 'Archive'));
61 return view('layout.module.notification.index',array("notifications"=>array(),'displaymsg'=>array("type"=>"success","text"=>"All Notifications Cleared")));
62 }
63 }
64
65
66 public function dashboard()
67 {
68 //echo "OK";
69 }
70
71 }
1 <?php namespace App\Http\Controllers;
2
3 use Auth;
4 use Input;
5 use Config;
6 use Session;
7 use App\Http\Controllers;
8 use App\Http\Requests;
9 use Illuminate\Http\Request;
10 use DB;
11 use Log;
12 use App\Models\Group;
13 use App\Models\User;
14 use App\Models\CRMCall;
15
16 class QuestionareController extends Controller
17 {
18 public function __construct()
19 {
20 $this->middleware('auth');
21 //$this->middleware('module_access');
22 }
23
24 public function loadQuestions($qid='', $optid='', $level=1)
25 {
26 if($qid == '') {
27 $auth_ques_count = 5;
28 $where = 'id = 1';
29 $auth_questions = DB::select('SELECT * FROM authentication_questions_test ORDER BY RAND() LIMIT '.$auth_ques_count );
30 $query = 'SELECT * FROM question WHERE '.$where;
31 $questions = DB::select($query);
32
33 return view('layout.module.questionare.questions',compact('qid','questions', 'auth_questions', 'auth_ques_count'));
34 }
35 else {
36 $where = 'question_no IN (SELECT question_id FROM question_tree WHERE parent_id = '.$qid.' AND parent_opt = "opt_'.$optid.'")';
37 $query = 'SELECT * FROM question WHERE '.$where;
38 $questions = DB::select($query);
39 return view('layout.module.questionare.childquestions',compact('qid','questions','auth_questions','level'));
40 }
41 }
42
43 public function saveQuestionAire()
44 {
45 $varid=Input::get('varid');
46 $questionDateTime=Input::get('questionDateTime');
47
48 $questionArray = $_POST['questionArray'];
49 $questionArray = json_decode($questionArray);
50 //$questionArray = explode(",",$questionArray);
51 $questionArray=(array)$questionArray;
52
53 $authQuestionArray = $_POST['authQuestionArray'];
54 $authQuestionArray = json_decode($authQuestionArray);
55 $authQuestionArray=(array)$authQuestionArray;
56
57 $recordDetails = DB::table('records')->where('id','=',$varid)->select('*')->first();
58
59 $user_id = Auth::user()->username;
60 $cust_id = $recordDetails->clientcode;
61 $name = $recordDetails->firstname;
62 $mobile = $recordDetails->mobile;
63
64 $crmcallDetails=CRMCall::where('crm_id','=',$varid)->orderBy("created_at","DESC")->first();
65
66 $call_id = $crmcallDetails->id;
67
68 foreach($questionArray as $key=> $quesArray){
69 $explodeQues = explode("-", $key);
70
71 $ques = $explodeQues[1];
72
73 DB::statement("insert into questionaire_details set created_at='".date("Y-m-d H:i:s")."', updated_at='".date("Y-m-d H:i:s")."', user_id='".$user_id."',cust_id='".$cust_id."',call_id='".$call_id."',name='".$name."',number='".$mobile."',question_time='".$questionDateTime."',auth_question_1='".$authQuestionArray['auth_0']->auth_ques."',auth_opt_1='".trim($authQuestionArray['auth_0']->auth_opt)."',auth_question_2='".$authQuestionArray['auth_1']->auth_ques."',auth_opt_2='".trim($authQuestionArray['auth_1']->auth_opt)."',auth_question_3='".$authQuestionArray['auth_2']->auth_ques."',auth_opt_3='".trim($authQuestionArray['auth_2']->auth_opt)."',auth_question_4='".$authQuestionArray['auth_3']->auth_ques."',auth_opt_4='".trim($authQuestionArray['auth_3']->auth_opt)."',auth_question_5='".$authQuestionArray['auth_4']->auth_ques."',auth_opt_5='".trim($authQuestionArray['auth_4']->auth_opt)."',question='".$ques."',primary_question='".$quesArray->prim_ques."',primary_response='".trim($quesArray->prim_response)."',primary_text='".$quesArray->prim_txt."',followup_question='".$quesArray->fol_ques."',followup_response='".trim($quesArray->fol_response)."',followup_text='".$quesArray->fol_txt."',secondary_question='".$quesArray->sec_ques."',secondary_response='".trim($quesArray->sec_response)."',secondary_text='".$quesArray->sec_txt."'");
74 }
75 return "<div class='alert alert-success'><strong>All Questions Saved Successfully!</strong></div>";
76 }
77 }
78
79
1 <?php namespace App\Http\Controllers;
2
3
4 use Auth;
5 use Input;
6 use Response;
7 use App\Models\Notification;
8 use App\Jobs\KHRMSLib;
9 use App\Models\User;
10 use DB;
11 use App\Models\CRMCall;
12 use App\Http\Controllers;
13 use App\Http\Requests;
14 use Illuminate\Http\Request;
15 use Log;
16
17 class RecordController extends Controller {
18
19
20 public function __construct()
21 {
22 $this->middleware('auth');
23 $this->middleware('module_access');
24 }
25
26 public function index()
27 {
28 return view('layout.module.record.index',array());
29 }
30 public function create()
31 {
32 //
33 }
34 public function store()
35 {
36 $data=array();
37 $data['wakka'] = new KHRMSLib();
38 $action=Input::get("action")!=""?Input::get("action"):$_SESSION['fapiRequest'];
39 $client=Input::get("client");
40 $data['wakka']->HRFillNames($client);
41 if($action=="show")
42 {
43 return view('layout.module.record.show',$data);
44 }
45 if($action=="save")
46 {
47 return view('layout.module.record.save',$data);
48 }
49 if($action=="quicksearch")
50 {
51 return view('layout.module.record.quicksearch',$data);
52 }
53 if($action=="textsearch")
54 {
55 return view('layout.module.record.textsearch',$data);
56 }
57 if($action=="addkey")
58 {
59 $wakka = new KHRMSLib();
60
61 $varid=Input::get("varid");
62 $keys=explode(",",Input::get("keys"));
63 $record=$wakka->getPerson($varid);
64 if(!empty($keys))foreach($keys as $key)
65 {
66 $val=Input::get($key);
67 $record["peopledata"][$key]=$val;
68 }
69
70 $wakka->setPerson($varid,$record);
71
72 return Response::make("");
73 }
74 if($action=="delaltphone")
75 {
76 $wakka = new KHRMSLib();
77
78 $varid=Input::get("varid");
79 $i=Input::get("i");
80
81 $record=$wakka->getPerson($varid);
82 for($k=$i+1;$k<=10;$k++,$i++)
83 {
84 $record["peopledata"]["altphone$i"]=$record["peopledata"]["altphone$k"];
85 $record["peopledata"]["altphone_lbl_$i"]=$record["peopledata"]["altphone_lbl_$k"];
86 }
87 $record["peopledata"]["altphone10"]="";
88 $record["peopledata"]["altphone_lbl_10"]="";
89
90 $wakka->setPerson($varid,$record);
91 }
92 if($action=="bulkupload")
93 {
94 return view('layout.module.record.bulkupload',$data);
95 }
96 if($action=="Appointment")
97 {
98 $wakka = new KHRMSLib();
99
100 $CustomerName=Input::get("CustomerName");
101 $AppntLocation=Input::get("AppntLocation");
102 $AppntTime=Input::get("AppntTime");
103 $Address=Input::get("Address");
104 $AppntDate=Input::get("AppntDate");
105 $ContactPerson=Input::get("ContactPerson");
106 $Phone=Input::get("Phone");
107
108 $AppntDate=date("d-M-Y",strtotime($AppntDate));
109 $h = $AppntTime;
110 $hm = $h * 60;
111 $ms = $hm * 60;
112 $AppntTime=gmdate("g A",$ms);
113
114 $smsapi="http://115.114.132.71/servlet/com.aclwireless.pushconnectivity.listeners.TextListener?userId=idcamps&pass=pacamps1&contenttype=1&from=HEROFC&selfid=true&alert=1&dlrreq=true";
115
116 $MsgContent="Dear $CustomerName, Your appointment is fixed at $AppntLocation. Appointment Date - $AppntDate, Time - $AppntTime. Address: $Address Contact Person - $ContactPerson. In case of any assistence Please give a missed call. $Tollfree";
117 $EnMsgContent=urlencode($MsgContent);
118 $smsurl=$smsapi."&to=".$Phone."&text=".$EnMsgContent;
119
120 $MessageID=$wakka->get_response($smsurl);
121
122 if($MessageID)
123 print $MessageID;
124 else
125 print "Failed";
126 //echo $CustomerName . ' = ' . $AppntLocation . ' = ' . $AppntTime . ' = ' . $Address . ' = ' . $AppntDate . ' = ' . $ContactPerson;
127 }
128 if($action=="sendAPI")
129 {
130 $mobile=Input::get("mobile")!=""?Input::get("mobile"):$_SESSION['apiMobile'];
131 $custName=Input::get("custName")!=""?Input::get("custName"):$_SESSION['apiCustName'];
132 $lan=Input::get("lan")!=""?Input::get("lan"):$_SESSION['apiLan'];
133 $emi=Input::get("emi")!=""?Input::get("emi"):$_SESSION['apiEmi'];
134 $X_AUTH_T = 'eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL21vYmlsZXBheW1lbnRzLmJlbm93LmluLyIsInN1YiI6ImhpbWFuc2h1LnNoYXJtYUBmdWxsZXJ0b25pbmRpYS5jb20iLCJkYXRhIjp7Im1lcmNoYW50SWQiOiIxODU1ODMiLCJtY2NDb2RlIjoiNzMyMiIsIm1vYmlsZU51bWJlciI6Ijg0NTIwNzc1NTUiLCJkaXNwbGF5TmFtZSI6IkZVTExFUlRPTiBJTkRJQSBDUkVESVQgQ09NUEFOWSBMSU1JVEVEIiwibWVyY2hhbnRDb2RlIjoiRDRESzgiLCJwcml2YXRlSWQiOiI2OTEifSwiaWF0IjoxNTMxOTExMjU5fQ.pJupG7g5iOHgsJbUucjP_Hu8Zfd-wIVJkijkHMZ9vl0';
135 $X_EMAIL_T = '[email protected]';
136
137 $key = '[B@334418de'; // this is salt/key which would be provided by benow
138 $inputArray = ['merchantCode'=>'D4DK8',"amount"=>$emi,"description"=>"FULLERTON INDIA CREDIT COMPANY LIMITED","customerName"=>$custName,"mobileNumber"=>$mobile,"refNumber"=>$lan]; // payload
139 $input = json_encode($inputArray);
140 $key = openssl_digest($key,'sha256');
141 $key = openssl_digest($key,'md5');
142 $key = substr($key,0,16);
143 $iv = 'xxxxyyyyzzzzwwww'; // this will be provided by benow
144 $encryptedString = openssl_encrypt($input,'aes-128-cbc',$key,0,$iv);
145 $jsonString = $input;
146 $data = ['encryptedString'=>$encryptedString,'jsonString'=> $input];
147 $jsonBody = $data;
148
149 $url = 'https://mobilepayments.benow.in/payments/paymentadapter/portablePaymentRequest';
150 $payload = json_encode($jsonBody);
151 $ch = curl_init();
152 curl_setopt($ch, CURLOPT_COOKIE, "");
153 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
154 curl_setopt($ch, CURLOPT_URL, $url);
155 curl_setopt($ch, CURLOPT_POST, 1);
156 curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
157 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
158 curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json',
159 'AUTHORIZATIONKEY:' . $X_AUTH_T,
160 'X-EMAIL:' . $X_EMAIL_T, 'Cache-Control:no-cache'
161 ));
162 $response = curl_exec($ch);
163 curl_close($ch);
164
165 Log::useFiles(storage_path().'/logs/SMS_'.date("d_m_Y").'.log');
166 Log::info(date("Y-m-d H:i:s")." Mobile=".$mobile." LAN=".$lan." Response=".$response);
167
168 if(isset($_SESSION['fapiRequest']))
169 {
170 $_SESSION['fapiRequest'] = '';
171 $_SESSION['apiMobile'] = '';
172 $_SESSION['apiCustName'] = '';
173 $_SESSION['apiLan'] = '';
174 $_SESSION['apiEmi'] = '';
175 }
176
177 return $response;
178
179 }
180 }
181 public function show($id)
182 {
183 $data=array();
184 $data['wakka'] = new KHRMSLib();
185 if($id=="bulkupload")
186 {
187 return view('layout.module.record.bulkupload',$data);
188 }
189 if($id=="textsearch")
190 {
191 return view('layout.module.record.textsearch',$data);
192 }
193 }
194 public function edit($id)
195 {
196 //
197 }
198 public function update($id)
199 {
200 //
201 }
202 public function destroy($id)
203 {
204
205 }
206
207
208 public function dashboard()
209 {
210 //echo "OK";
211 }
212
213 public function churnData()
214 {
215 $data=array();
216 $wakka = new KHRMSLib();
217
218 $listVal = DB::table('currentqueue_list')->get();
219
220 $rclientlst=$wakka->clientsReadAccess();
221
222 $data['listVal'] = $listVal;
223 $data['cntlistVal'] = count($listVal);
224 $data['rclientlst'] = $rclientlst;
225
226 return view('layout.module.record.churn',$data);
227 }
228
229 public function saveChurnData()
230 {
231 $user_agent=Input::get('agent');
232 $data = $_POST['data'];
233
234 $exitAgent = DB::table('cq_logic')->where('user_agent','=',$user_agent)->first();
235
236 if($exitAgent)
237 {
238 DB::update("update cq_logic set updated_at='".date("Y-m-d H:i:s")."', data='".$data."' where user_agent='".$user_agent."'");
239 }
240 else
241 {
242 DB::statement("insert into cq_logic set created_at='".date("Y-m-d H:i:s")."', updated_at='".date("Y-m-d H:i:s")."', user_agent='".$user_agent."', data='".$data."'");
243 }
244
245 return ;
246 }
247 public function supervisorUpload()
248 {
249 $data = array();
250 $client = array();
251
252 $data['wakka'] = new KHRMSLib();
253 $dashboarduser=Auth::user();
254
255 $allusers=User::where('usertype','=','Telecaller')->get();
256
257 $client="";
258
259 foreach($allusers as $alluser)
260 {
261 $usrData = json_decode($alluser->data);
262 $usrHRMSData = unserialize($usrData->hrmsdata);
263 //echo "----userdta---".print_r($usrHRMSData);
264
265 if($usrHRMSData['clientsownerlist']&&$usrHRMSData['clientsownerlist']!='null')
266 //$client[] = $usrHRMSData['clientsownerlist'];
267
268 $pbcode [] = explode(',', $usrHRMSData['clientsownerlist']);
269
270 $username[] = $alluser->username;
271 $userid[] = $alluser->id;
272 }
273 foreach ($pbcode as $pbarr) {
274 foreach($pbarr as $c){
275 $client[] .= $c;
276 }
277 }
278 // print_r($client);
279 $data['client'] = $client;
280 $data['username'] = array_combine($userid,$username);
281 return view('layout.module.record.commentsUpload',$data);
282 }
283 public function rlpPbwise()
284 {
285 $data = array();
286
287 $pbcode=Input::get('pbcode');
288
289 $data['pbcode']=$pbcode;
290 return view('layout.module.record.rlppbwise',$data);
291 }
292
293 }
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!