0ce76be0 by Gopal

KOTAK SETUP

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

Too many changes to show.

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

1 * text=auto
2 *.css linguist-vendored
3 *.less linguist-vendored
1 /node_modules
2 /storage/data.json
3 .env
4 .buildpath
5 .project
6 .settings/*
7 /storage/reason/bulkserver.txt
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";
No preview for this file type
No preview for this file type
No preview for this file type
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\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 DeleteDialline extends Command {
26
27 /**
28 * The console command name.
29 *
30 * @var string
31 */
32 protected $signature = 'DeleteDialline';
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 DB::update(DB::raw("update diallines set status='Free',number='',uniqueid='',channel='' where status in ('Inbound','Auto')"));
51
52 $blockedChan = DB::select(DB::raw("select count(*) as cnt from diallines where status='Blocked'"));
53
54 $blockedChan = $blockedChan[0]->cnt;
55
56 if($blockedChan>25)
57 {
58 DB::update(DB::raw("update diallines set status='Free'"));
59 }
60 echo 'End';
61 }
62 }
63
64
65
66
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 EmptyKqueue extends Command {
26
27 /**
28 * The console command name.
29 *
30 * @var string
31 */
32 protected $signature = 'EmptyKqueue';
33
34 /**
35 * The console command description.
36 *
37 * @var string
38 */
39 protected $description = 'Truncate Kqueue Table';
40
41 /**
42 * Execute the console command.
43 *
44 * @return mixed
45 */
46 public function handle()
47 {
48 echo 'Start';
49
50 DB::statement("TRUNCATE TABLE kqueues");
51
52 echo 'End';
53 }
54 }
55
56
57
58
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 DB::insert(DB::raw("insert into crmcalls_archive select * from crmcalls where id>(select max(id) from crmcalls_archive)"));
51
52 DB::update(DB::raw("UPDATE crmcalls_archive as ca INNER JOIN crmcalls as c on ca.id = c.id set ca.ts_Close = c.ts_Close,ca.dispoSec = c.dispoSec,ca.recsize = c.recsize,ca.userstatus = c.userstatus,ca.usersubstatus = c.usersubstatus,ca.usercallback = c.usercallback ,ca.userremarks = c.userremarks"));
53
54 echo 'End';
55 }
56 }
57
58
59
60
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
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\DeleteCrmcalls',
21 'App\Console\Commands\DeleteDialline',
22 'App\Console\Commands\EmptyKqueue',
23 ];
24
25 /**
26 * Define the application's command schedule.
27 *
28 * @param \Illuminate\Console\Scheduling\Schedule $schedule
29 * @return void
30 */
31 protected function schedule(Schedule $schedule)
32 {
33 $schedule->command('KstychDaily')->daily()->withoutOverlapping();
34
35 $schedule->command('InsertCrmArchive')->everyMinute()->withoutOverlapping();
36 $schedule->command('DeleteCrmcalls')->dailyAt('00:00')->withoutOverlapping();
37 $schedule->command('DeleteDialline')->everyMinute()->withoutOverlapping();
38 $schedule->command('EmptyKqueue')->everyMinute()->withoutOverlapping();
39 }
40
41 }
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 }
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 $newqueue=new Kqueue();
56 $newqueue->astCommand($sparts[0],"channel request hangup all");
57 }
58
59 User::where('presence','>','0')->update(['presence'=>0]);
60 Session::truncate();
61
62 return "";
63 }
64 }
65 public function show($id)
66 {
67 $data=array();
68 if($id=='masterdata')return view('layout.module.admin.masterdata',$data);
69 if($id=='accesslog')return view('layout.module.admin.accesslog',$data);
70 if($id=='emaillog')return view('layout.module.admin.emaillog',$data);
71 if($id=='bulkmail')return view('layout.module.admin.bulkmail',$data);
72 if($id=='dllogfile')return response()->download(storage_path('logs/laravel-'.date('Y-m-d').'.log'));
73 if($id=='main')return view('layout.module.admin.main',$data);
74 if($id=='agentreport')return view('layout.module.admin.agentreport',$data);
75 if($id=='liveusers')return view('layout.module.admin.liveusers',$data);
76 }
77 public function edit($id)
78 {
79 //
80 }
81 public function update($id)
82 {
83 //
84 }
85 public function destroy($id)
86 {
87 //
88 }
89
90
91 public function dashboard()
92 {
93 $data=array();
94
95 return view('layout.module.admin.dashboard',$data);
96 }
97 }
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 if($id=="autodialmode")
45 {
46 $campaign=Input::get("client");
47 $user_id = Auth::user()->id;
48
49 $callsToDialled = $this->getCallsToBeDialled($campaign);
50 if($callsToDialled>0)
51 {
52 $this->createCall($campaign, $callsToDialled, $user_id);
53 }
54 }
55 }
56
57 public function getCallsToBeDialled($campaign)
58 {
59 $wakka = new KHRMSLib();
60 $mastersdata=$wakka->getCompanyMaster($campaign);
61
62 $ratio = $mastersdata["autodialercampaign"];
63 $availableUsers = $this->getFreeUserCnt($campaign);
64 $dialedCalls = $this->getDialedCallCount($campaign);
65
66 return $availableUsers*$ratio-$dialedCalls;
67 }
68
69 //To Get Number Of Free User which will be multiplied with Defined Ratio For Generating Number Of Calls
70 public function getFreeUserCnt($campaign)
71 {
72 $count=0;
73 $loggedInSips = Sipid::where('server','=',env('app_ip'))->where("user", "!=", 0)->where("status","=","1")->where("prepare_call","=","1")->where("clients","like","%$campaign%")->groupBy('user')->get();
74
75 if(count($loggedInSips))
76 foreach ($loggedInSips as $key => $loggedInSip)
77 {
78 $loggedInUsers[] = $loggedInSip->user;
79 }
80
81 $freeDials = Dialline::whereIn("user_id",$loggedInUsers)->where("status","=","Blocked")->count();
82
83 return count($loggedInSips)-$freeDials;
84 }
85
86 public function getDialedCallCount($campaign)
87 {
88 $cnt = Dialline::whereIn("status", ["Auto","AutoCall"])->where("conf","=","")->where("regexstr","=",$campaign)->count();
89
90 return $cnt;
91 }
92
93 public function getAvailCallInPool($campaign)
94 {
95 //$cnt = CRMCall::where("client", "=", $campaign)->where("state","=","DialEnd")->where("type", "=", "Auto")->where("substatus","!=","")->count();
96
97 $cnt = Dialline::where("status","=","Auto")->where("conf","=","")->where("regexstr","=",$campaign)->count();
98
99 return $cnt;
100 }
101
102 public function getAvgTimeArray($user)
103 {
104 $avgdisposecObj = CRMCall::select(DB::Raw('(avg(disposec))/1000 as avgdisposec'))->where("user_id", "=", $user)->orderby("id","desc")->limit(50)->where("type","!=","Inbound")->first();
105
106 $avgcallsecObj = CRMCall::select(DB::Raw('(avg(callsec))/1000 as avgcallsec'))->where("user_id", "=", $user)->orderby("id","desc")->limit(50)->where("type","!=","Inbound")->first();
107
108 $returnArray['avgdisposec'] = round($avgdisposecObj->avgdisposec);
109 $returnArray['avgcallsec'] = round($avgdisposecObj->avgcallsec);
110
111 return $returnArray;
112 }
113
114 public function createCall($campaign, $acalls, $user_id)
115 {
116 $wakka = new KHRMSLib();
117 $mastersdata=$wakka->getCompanyMaster($campaign);
118
119 if($acalls>0)
120 {
121 for($i=0;$i<$acalls;$i++)
122 {
123 $callerid="";
124 if(!empty($mastersdata["DialerDID"]))
125 $callerid=$mastersdata["DialerDID"];
126
127 $calleridarr=explode(":",$callerid);$dspan="1";
128 if(isset($calleridarr[1]))
129 {
130 $callerid=$calleridarr[0];$dspan=$calleridarr[1];
131 }
132
133 $dialline=Dialline::where('server','=', env('app_ip'))->where("status","=","Free")->where("enabled","=","1");
134 if($dspan!="")$dialline=$dialline->where('dspan','=',$dspan)->where('id','<=','30');
135 $dialline=$dialline->orderBy('updated_at','ASC')->first();
136
137 if(empty($dialline))
138 {
139 $dialline=Dialline::where('server','=', env('app_ip'))->where("status","=","Free")->where("enabled","=","1");
140 if($dspan!="")$dialline=$dialline->where('dspan','=', "2")->where('id','>','30');
141 $dialline=$dialline->orderBy('id','ASC')->first();
142 }
143
144 if($dialline)
145 {
146 $users=$wakka->getPersons("client='$campaign' and status='New' and mobile!='' limit 1");
147 if(sizeof($users)>=1)
148 {
149 $record=$wakka->getPerson($users[0]['id']);
150 if($record)
151 {
152 $record["peopledata"]["status"]="AutoCall";
153 $wakka->setPerson($users[0]['id'],$record);
154 }
155
156 $dialline->user_id=$user_id;
157 $dialline->status="AutoCall";
158 $dialline->regexstr=$users[0]['client'];
159 $dialline->number=$users[0]["mobile"];
160 $dialline->save();
161
162 $nowts=microtime(true)*1000;
163
164 //start the call log
165 $crmcall=new CRMCall();
166 $crmcall->number=$users[0]["mobile"];
167 $crmcall->user_id=0;
168 $crmcall->sipid_id=0;
169 $crmcall->crm_id=$users[0]['id'];
170 $crmcall->lan=$users[0]['lan'];
171 $crmcall->client=$users[0]['client'];
172 $crmcall->department=$users[0]['department'];
173 $crmcall->state='New';
174 $crmcall->type="AutoCall";
175 $crmcall->dialline_id=$dialline->id;
176
177 $crmcall->setTs('ts_Wait',$nowts);
178 $crmcall->setTs('ts_Call',$nowts);
179
180 $crmcall->did=$callerid;
181
182 $tdata=array();
183 $crmcall->data=json_encode($tdata);
184 $crmcall->save();
185
186 //start actual calls
187 $newqueue=new Kqueue();
188 $newqueue->autoCallOut($users[0]["mobile"],$callerid,$crmcall,$dialline);
189
190 }
191 }
192 else break;
193 }
194 }
195
196 //return 1;
197 }
198
199 }
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
22 use DB;
23 use Log;
24 use Session;
25 $client='';
26
27 class AutodialController extends Controller {
28
29
30 public function index()
31 {
32
33 }
34 public function create()
35 {
36
37 }
38 public function store()
39 {
40
41
42 }
43 public function show($id)
44 {
45
46 if($id=="autodialmode")
47 {
48
49 $campaign=Input::get("client");
50 $sipip=env('app_ip');
51 $wakka = new KHRMSLib();
52
53 for($i=0;$i<10;$i++)
54 {
55
56 usleep(2000*1000);
57 //echo "prashant----".Auth::user()->id;
58 $dialmode = DB::table('users')->where('id','=',Auth::user()->id)->first();
59 //echo $dialmode->current_dialmode;
60 if($dialmode->current_dialmode!="Predictive")
61 {
62 break;
63 exit;
64 }
65 $autocompany=array();
66 $companyarr=$wakka->LoadAll("select * from hrms_masters where mtype='company' and mkey='$campaign'");
67 foreach($companyarr as $tcompany)
68 {
69 $mastersdata=$wakka->getCompanyMaster($tcompany['mkey']);
70 if(!isset($mastersdata["autodialercampaign"]))$mastersdata["autodialercampaign"]=0;
71
72 if($mastersdata["autodialercampaign"]>0)
73 {
74 $autocompany[$tcompany['mkey']]=$mastersdata;
75 }
76 }
77 foreach($autocompany as $tcompany=>$mastersdata)
78 {
79 $asipids=Sipid::where('server','=',$sipip)->where("status","=","1")->where("ready","=","1")->where("clients","like","%$tcompany%")->count();
80
81 if($asipids>0)
82 {
83
84 $acalls=($asipids*$mastersdata["autodialercampaign"])-Dialline::where('server','=',$this->sipip)->whereIn("status",array("AutoCall","Auto"))->where("conf","=","")->where("regexstr","=",$tcompany)->count();
85
86 if($acalls>0)
87 {
88 for($i=0;$i<$acalls;$i++)
89 {
90 $callerid="";
91 if(!empty($mastersdata["DialerDID"]))
92 $callerid=$mastersdata["DialerDID"];
93
94 $calleridarr=explode(":",$callerid);$dspan="1";
95 if(isset($calleridarr[1]))
96 {
97 $callerid=$calleridarr[0];$dspan=$calleridarr[1];
98 }
99
100
101 $dialline=Dialline::where('server','=', $sipip)->where("status","=","Free")->where("enabled","=","1");
102
103 if($dspan!="")$dialline=$dialline->where('dspan','=',$dspan);
104
105 $dialline=$dialline->orderBy('updated_at','ASC')->first();
106
107 if($dialline)
108 {
109
110 $users=$wakka->getPersons("client='$campaign' and status='New' limit 1");
111 if(sizeof($users)>=1)
112 {
113 $dialline->status="Free";
114 $dialline->regexstr=$users[0]['client'];
115 $dialline->save();
116
117 $nowts=microtime(true)*1000;
118
119 //start the call log
120 $crmcall=new CRMCall();
121 $crmcall->number=$users[0]["mobile"];
122 $crmcall->user_id=0;
123 $crmcall->sipid_id=0;
124 $crmcall->crm_id=$users[0]['id'];
125 $crmcall->lan=$users[0]['lan'];
126 $crmcall->client=$users[0]['client'];
127 $crmcall->department=$users[0]['department'];
128 $crmcall->state='New';
129 $crmcall->type="AutoCall";
130 $crmcall->dialline_id=$dialline->id;
131
132 $crmcall->setTs('ts_Wait',$nowts);
133 $crmcall->setTs('ts_Call',$nowts);
134
135 $crmcall->did=$callerid;
136
137 $tdata=array();
138 $crmcall->data=json_encode($tdata);
139 $crmcall->save();
140
141 //start actual calls
142 $newqueue=new Kqueue();
143 $newqueue->autoCallOut($users[0]["mobile"],$callerid,$crmcall,$dialline);
144 }
145
146 DB::update("update records set status='AutoDial' where id='".$users[0]["id"]."'");
147 }
148 else break;
149 }
150 }
151 }
152 }
153 }
154 }
155 }
156
157
158 }
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
19 public function __construct()
20 {
21 $this->middleware('auth');
22 $this->middleware('module_access');
23 }
24
25 public function index()
26 {
27 $data=array();
28
29 $user=Auth::user();
30 $data["data"]=$user->data();
31 $data["meta"]=$user->meta();
32 if(Input::has("tz"))
33 {
34 $user->timezone=Input::get("tz");
35 $data["meta"]['ncnt']=0;$user->meta=json_encode($data["meta"]);
36 $user->save();
37 }
38
39 return view('layout.module.dashboard.index',$data);
40 }
41 public function create()
42 {
43 //
44 }
45 public function store()
46 {
47 //
48 }
49 public function show($id)
50 {
51 if($id=="s")
52 {
53 $kfile=new KFileLib();$kfile->folderSpaceUse(Auth::user()->id.'/');
54 return Response::make("",200);
55 }
56 if($id=="r")
57 {
58 $umeta=Auth::user()->meta();
59 $kauthlib=new KAuthLib();
60
61 if(!isset($umeta['kautherror']))$umeta['kautherror']=0;
62 if(isset($umeta['kauthlibuser'])&&isset($umeta['kauthlibcred']))
63 {
64 if(Config::get("app.extAuth")=="owa")
65 {
66 $authparams=explode(",",Config::get("app.extAuthParams"));if(!isset($authparams[0]))$authparams[0]="";if(!isset($authparams[1]))$authparams[1]="";
67 if(!$kauthlib->owaAuthCheck($authparams[0],$authparams[1],$umeta['kauthlibuser'],$umeta['kauthlibcred'],""))
68 {
69 $umeta['kautherror']++;
70 if($umeta['kautherror']>5)Auth::user()->status='Disabled';
71 Auth::user()->meta=json_encode($umeta);
72 Auth::user()->save();
73 if($umeta['kautherror']>5)return Response::make("document.location='logout';",200);
74 }
75 else
76 {
77 $umeta['kautherror']=0;
78 Auth::user()->meta=json_encode($umeta);
79 Auth::user()->save();
80 return Response::make("",200);
81 }
82 }
83 if(Config::get("app.extAuth")=="smtp")
84 {
85 $authparams=explode(",",Config::get("app.extAuthParams"));if(!isset($authparams[0]))$authparams[0]="";if(!isset($authparams[1]))$authparams[1]="";if(!isset($authparams[2]))$authparams[2]="";
86 if(!$kauthlib->smtpLoginCheck($authparams[0],$authparams[1],$authparams[2],$umeta['kauthlibuser'],$umeta['kauthlibcred']))
87 {
88 $umeta['kautherror']++;
89 if($umeta['kautherror']>5)Auth::user()->status='Disabled';
90 Auth::user()->meta=json_encode($umeta);
91 Auth::user()->save();
92 if($umeta['kautherror']>5)return Response::make("document.location='logout';",200);
93 }
94 else
95 {
96 $umeta['kautherror']=0;
97 Auth::user()->meta=json_encode($umeta);
98 Auth::user()->save();
99 return Response::make("",200);
100 }
101 }
102 }
103 }
104 if($id=="dpart")
105 {
106 $page=Input::get("page");
107 $data=array();
108
109 $user=Auth::user();
110 $data["data"]=$user->data();
111 $data["meta"]=$user->meta();
112 if(Input::has("tz"))
113 {
114 $user->timezone=Input::get("tz");
115 $data["meta"]['ncnt']=0;$user->meta=json_encode($data["meta"]);
116 $user->save();
117 }
118
119 return view('layout.module.dashboard.'.$page,$data);
120 }
121 if($id=="search")
122 {
123 $data=array();
124 $data['stype']=Input::get('stype');
125 $data['strarr']=explode(" ",Input::get('str'));
126 $data['listdata']=array();
127 //hashtag imgurl title subtitle bubbles()
128 $groupacl=Auth::user()->getAccessList("group",true,false,false);
129
130 if($data['stype']=="User")
131 {
132 $users0=User::whereIn("group",$groupacl)->where('status','=','Active');$orderby='';
133 $users2=User::whereIn("group",$groupacl);
134 $users3=User::whereIn("group",$groupacl);
135 foreach($data['strarr'] as $searchkey)
136 {
137 $searchkey=trim($searchkey);
138 if($searchkey!='')
139 {
140 if($searchkey=='Learner'||$searchkey=='Trainer'||$searchkey=='Organization')$users0=$users0->where('usertype','=',$searchkey);
141 else if($searchkey=='MaxEdupoints')$orderby='Edupoints';
142 else $users0=$users0->where('data','like',"%$searchkey%");
143
144 $users2=$users2->where('fullname','like',"%$searchkey%");
145 $users3=$users3->where('email','like',"%$searchkey%");
146 }
147 }
148 //if($orderby=='Edupoints')$users0=$users0->orderBy()
149 $users=array();
150 $users0=$users0->orderBy(DB::raw('RAND()'))->take(30)->get();
151 $users2=$users2->orderBy(DB::raw('RAND()'))->take(20)->get();
152 $users3=$users3->orderBy(DB::raw('RAND()'))->take(20)->get();
153 foreach($users0 as $user)$users[]=$user;
154 foreach($users2 as $user)$users[]=$user;
155 foreach($users3 as $user)$users[]=$user;
156 $users=array_unique($users);
157 if(!empty($users))
158 {
159 foreach($users as $user)
160 {
161 $tuserdata=array();
162 $tuserdata['id']=$user->id;
163 $tuserdata['type']='user';
164 $tuserdata['hashtag']="p-".$user->id;
165 $tuserdata['imgurl']=$user->fetchphotothumb();
166 $tuserdata['title']=$user->dispname();
167 $tuserdata['subtitle']=$user->dataval2('personal','gender')." ".$user->dataval2('personal','location')." - ".$user->dataval2('personal','country');
168 $tuserdata['bubbles']=array($user->dataval2('personal','level'),$user->dataval2('personal','function'));
169
170
171 $data['listdata'][]=$tuserdata;
172 }
173 }
174
175
176 }
177 if($data['stype']=="Community")
178 {
179 $commuity1=Communitie::whereIn("group",$groupacl)->where('status','=','Active');
180 $commuity2=Communitie::whereIn("group",$groupacl)->where('status','=','Active');
181 $commuity3=Communitie::whereIn("group",$groupacl)->where('status','=','Active');
182
183 $commuity1=$commuity1->where(function ($query) use($data) {
184 foreach($data['strarr'] as $searchkey)
185 {
186 $searchkey=trim($searchkey);
187 if($searchkey!='')
188 {
189 $query->where('description','like',"%$searchkey%");
190 }
191 }
192 });
193 $commuity2=$commuity2->where(function ($query) use($data) {
194 foreach($data['strarr'] as $searchkey)
195 {
196 $searchkey=trim($searchkey);
197 if($searchkey!='')
198 {
199 $query->orWhere('category','like',"%$searchkey%");
200 }
201 }
202 });
203 $commuity3=$commuity3->where(function ($query) use($data) {
204 foreach($data['strarr'] as $searchkey)
205 {
206 $searchkey=trim($searchkey);
207 if($searchkey!='')
208 {
209 $query->orWhere('name','like',"%$searchkey%");
210 }
211 }
212 });
213
214 $commuity1=$commuity1->orderBy(DB::raw('RAND()'))->take(20)->get();
215 $commuity2=$commuity2->orderBy(DB::raw('RAND()'))->take(20)->get();
216 $commuity3=$commuity3->orderBy(DB::raw('RAND()'))->take(20)->get();
217 $community=array();
218 if(!empty($commuity1))foreach($commuity1 as $comm)$community[$comm->id]=$comm;
219 if(!empty($commuity2))foreach($commuity2 as $comm)$community[$comm->id]=$comm;
220 if(!empty($commuity3))foreach($commuity3 as $comm)$community[$comm->id]=$comm;
221
222 if(!empty($community))
223 {
224 foreach($community as $tcomm)
225 {
226 $tuserdata=array();
227 $tuserdata['id']=$tcomm->id;
228 $tuserdata['type']='community';
229 $tuserdata['hashtag']="g-".$tcomm->id;
230 $tuserdata['imgurl']="assets/images/community.jpg";
231 $tuserdata['title']=$tcomm->name;
232 $tuserdata['subtitle']=" Community ";
233 $tuserdata['bubbles']=array_unique(array_filter(explode(",",$tcomm->category)));
234
235
236 $data['listdata'][]=$tuserdata;
237 }
238 }
239 }
240
241 return view('layout.module.dashboard.search',$data);
242 }
243
244 if($id=="dashlet")
245 {
246 $module=strtolower(Input::get("module"));
247
248 // Adding current campaign against current user: Code by AmolG
249 if (Auth::check())
250 {
251 $client=Input::get("client");
252 if(empty($client))
253 {
254 $wakka = new KHRMSLib();
255 $clientList = $wakka->clientsOwnerRWAccess();
256 $client = (count($clientList) > 0) ? reset($clientList) : $client;
257 }
258 $id = Auth::id();
259 $myFile = storage_path("data.json");
260 if (!file_exists($myFile)) { fopen($myFile, 'w'); }
261 try {
262 $jsondata = file_get_contents($myFile); //Get data from existing json file
263 $arr_data = ($jsondata != '') ? json_decode($jsondata, true) : array(); // converts json data into array
264 $arr_data[$id] = $client; // Push user data to array
265 $jsondata = json_encode($arr_data, JSON_PRETTY_PRINT); //Convert updated array to JSON
266 file_put_contents($myFile, $jsondata);
267 }
268 catch (Exception $e) {}
269 }
270 // Code by AmolG
271
272 if($module!=""&&view()->exists("layout.module.dashboard.$module"))
273 {
274 return view("layout.module.dashboard.$module");
275 }
276 }
277 }
278 public function edit($id)
279 {
280 //
281 }
282 public function update($id)
283 {
284 //
285 }
286 public function destroy($id)
287 {
288 //
289 }
290
291
292 public function dashboard()
293 {
294 $data["id"]="Dashboard";
295
296 return view('layout.module.dashboard.dashboard',$data);
297 }
298 }
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
54 }
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
6 class HRController extends Controller {
7
8 public function __construct()
9 {
10 $this->middleware('auth');
11 $this->middleware('module_access');
12 }
13
14 public function index()
15 {
16 $data=array();
17 $data['wakka'] = new KHRMSLib();
18 return view('layout.module.hr.index',$data);
19 }
20 public function create()
21 {
22 //
23 }
24 public function store()
25 {
26 $data=array();
27 $data['wakka'] = new KHRMSLib();
28 return view('layout.module.hr.'.strtolower(Input::get('action')),$data);
29 }
30 public function show($id)
31 {
32 $data=array();
33 $data['wakka'] = new KHRMSLib();
34
35 $type='text/html';
36 if($id=='IDCard')$type="image/png";
37 if($id=='SalarySlip')$type="application/pdf";
38 if($id=='IncentiveSlip')$type="application/pdf";
39
40 return response()->view('layout.module.hr.'.strtolower($id),$data)->header('Content-Type', $type);
41 }
42 public function edit($id)
43 {
44 //
45 }
46 public function update($id)
47 {
48 //
49 }
50 public function destroy($id)
51 {
52 //
53 }
54
55
56 public function dashboard()
57 {
58 //echo "OK";
59 }
60 }
...\ 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
14 class MessageController extends Controller {
15
16 public function __construct()
17 {
18 $this->middleware('auth');
19 $this->middleware('module_access');
20 }
21
22 public function index()
23 {
24 //$messages=Message::where("to","=",Auth::user()->username)->whereIn("status",array("New","Read"))->orderBy('updated_at','desc')->paginate(50);
25 //return view('layout.module.message.index',array("messages"=>$messages));
26
27 $user=Auth::user();
28
29 $data=array();
30 $data["data"]=json_decode($user->data,true);
31 $data["id"]=$user->id;
32 $data["user"]=$user;
33 $data["displayname"]=Auth::user()->dispname();
34 $data["myphoto"] = $user->fetchphoto();
35
36 $data["messages"]=Message::where('to','=',$user->id)->orderBy("updated_at","DESC")->take(100)->get();
37 $data["newcount"]=Message::where('to','=',$user->id)->where('status','=','New')->count();
38 $data["users"]=array();
39 foreach($data["messages"] as $message)
40 {
41 $tuser=User::find($message->from);
42 if($tuser)
43 {
44 if(!isset($data["users"][$message->from]))
45 {
46 $data["message_time"][$message->id]=Auth::user()->post_date($message->updated_at);
47 $data["users"][$message->from]=array();
48 $data["users"][$message->from]['photothumb']=Auth::user()->fetchphotothumb($message->from);
49 $data["users"][$message->from]['dispname']=$tuser->dispname();
50 }
51 else
52 {
53 //self chat?
54 $data["message_time"][$message->id]=Auth::user()->post_date($message->updated_at);
55 //$data["users"][$message->from]=array();
56 //$data["users"][$message->from]['photothumb']=Auth::user()->fetchphotothumb($message->from);
57 //$data["users"][$message->from]['dispname']=$tuser->dispname();
58 }
59 }
60 }
61
62 return view(Config::get('app.mytheme').'.module.message.index',$data);
63 }
64 public function create()
65 {
66 //
67 }
68 public function store()
69 {
70 $type=Input::get("type");
71 if($type=="chat")
72 {
73 $id=explode("_",Input::get("id"));
74 //chanch if $id[1] is a user and in our friendlist TODO
75 $msg=htmlentities(Input::get("msg"));
76 $nowTS=time();
77
78 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');");
79 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');");
80
81 $ckey='chat'.Auth::user()->id.$id[1];
82 if(Cache::get($ckey,0)>100)return Response::make("simpleNotification('error','topRight','Fairplay Voilation #942');");
83 Cache::put($ckey,Cache::get($ckey,0)+1, 24*60);
84
85 $messageTo=Message::where("to","=",$id[1])->where("from","=",Auth::user()->id)->where("subject","=","Chat")->first();
86 $messageFrom=Message::where("to","=",Auth::user()->id)->where("from","=",$id[1])->where("subject","=","Chat")->first();
87 if(!$messageTo)
88 {
89 $messageTo=new Message();
90 $messageTo->to=$id[1];
91 $messageTo->from=Auth::user()->id;
92 $messageTo->subject="Chat";
93 }
94 if(!$messageFrom)
95 {
96 $messageFrom=new Message();
97 $messageFrom->to=Auth::user()->id;
98 $messageFrom->from=$id[1];
99 $messageFrom->subject="Chat";
100 }
101 $messageTo->status="Read";
102 $messageFrom->status="Read";
103
104
105 $dataTo=json_decode($messageTo->data,true);
106 $dataFrom=json_decode($messageFrom->data,true);
107
108 $dataTo[$nowTS]=array(Auth::user()->id,$msg);
109 $dataFrom[$nowTS]=array(Auth::user()->id,$msg);
110
111 $messageTo->data=json_encode($dataTo);
112 $messageFrom->data=json_encode($dataFrom);
113
114
115 $messageTo->save();
116 $messageFrom->save();
117
118 //add a queue notify to user if online
119 $noty=new KPushNotify();
120 $res=$noty->send(array($id[1]),"chat",Auth::user()->dispname(),$msg,Auth::user()->id);
121
122
123 if(!isset($res[$id[1]])||$res[$id[1]]<=0)
124 {
125 $messageTo->status="New";
126 $messageTo->save();
127 return Response::make("simpleNotification('alert','topRight','User is offline');");
128 }
129
130 }
131 if($type=="call")
132 {
133 $id=explode("_",Input::get("id"));
134
135 $sipid=Sipid::find(Input::get('sipid'));
136 $tosipid=Sipid::where("user","=",$id[1])->where("status","=","1")->first();
137 $tosip=0;
138 if($sipid&&$tosipid)
139 {
140 $tosip=$tosipid->id;
141
142 $newqueue=new Kqueue();
143 $newqueue->sipOriginate($sipid,"1001".$tosip,"kstychDialer");
144 }
145
146 return Response::make($tosip);
147 }
148 }
149 public function show($id)
150 {
151 if($id=="topbar")
152 {
153 $messages=Message::where("to","=",Auth::user()->id)->where("status","=","New")->orderBy('created_at','desc')->take(10)->get();
154 $count=Message::where("to","=",Auth::user()->id)->where("status","=","New")->count();
155
156 $data=array();
157 foreach($messages as $message)
158 {
159 $data[]=array("fromuser"=>$message->from,
160 "text"=>$message->subject,
161 "tstr"=>date("d-M H:i",strtotime($message->created_at)));
162 }
163 return view('layout.topbar.message',array("messages"=>$data,"messagescount"=>$count));
164 }
165
166
167
168 $data=array();
169 $tmessage=Message::find($id);
170 if($tmessage->subject=="Chat")
171 {
172 if($tmessage->to==Auth::user()->id)
173 {
174 $data['fromuser']=$tmessage->from;
175 $data["id"]=$id;
176 $data['mid']=$id;
177 $data['tuser']=User::find($tmessage->from);
178
179 $data['messages']=json_decode($tmessage->data,true);
180 $data["users"]=array();
181 foreach($data["messages"] as $ts=>$message)
182 {
183 $data["message_time"]["$ts"]=Auth::user()->post_date(date("Y-m-d H:i",$ts));
184
185 //$dataTo[$nowTS]=array(Auth::user()->id,$msg);
186 $tuser=User::find($message[0]);
187 if($tuser)
188 {
189 if(!isset($data["users"][$message[0]]))
190 {
191 $data["users"][$message[0]]=array();
192 $data["users"][$message[0]]['photothumb']=Auth::user()->fetchphotothumb($message[0]);
193 $data["users"][$message[0]]['dispname']=$tuser->dispname();
194 }
195 }
196 }
197 if($tmessage->status=="New"){$tmessage->status="Read";$tmessage->save();}
198 }
199 return view(Config::get('app.mytheme').'.module.message.messagecontent',$data);
200 }
201
202
203
204 return view('layout.module.message.msg',array("message"=>Message::find($id)));
205 }
206 public function edit($id)
207 {
208 //
209 }
210 public function update($id)
211 {
212 //
213 }
214 public function destroy($id)
215 {
216 //
217 }
218
219 public function dashboard()
220 {
221 //echo "OK";
222 }
223 }
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 use Auth;
4 use Input;
5 use Config;
6 use Session;
7
8 use App\Models\Role;
9 use App\Models\User;
10
11 class RoleController 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.role.index',array('rolelist'=>Role::paginate(50)));
23 }
24 public function create()
25 {
26 return view('layout.module.role.create');
27 }
28 public function store()
29 {
30 $data=array();
31 $rolename=substr(htmlentities(trim(Input::get("rolename"))),0,200);
32
33 $exists=Role::where("rolename","=",$rolename)->first();
34 if(!$exists&&$rolename!='')
35 {
36 $role=new Role();
37
38 $role->rolename=$rolename;
39 $role->status=Input::get("rolestatus");
40 $role->rolegroup=Input::get("rolegroup");
41
42 $role->modulerwa=Input::get("modulerwa");
43 $role->modulerw=Input::get("modulerw");
44 $role->moduler=Input::get("moduler");
45 $role->grouprwa=Input::get("grouprwa");
46 $role->grouprw=Input::get("grouprw");
47 $role->groupr=Input::get("groupr");
48
49 $role->default=Input::get("roledefault");
50
51 $role->data=json_encode($data);
52 $role->save();
53
54 if(Input::get("roledefault")==1)
55 {
56 Role::where('id','!=',$role->id)->update(array('default'=>0));
57 }
58
59 return view('layout.module.role.edit',array('trole'=>$role,'displaymsg'=>array("type"=>"success","text"=>"Role Created")));
60 }
61 else
62 {
63 return view('layout.module.role.create',array('trole'=>array(),'displaymsg'=>array("type"=>"Error!","text"=>"Role Already Exists")));
64 }
65
66 }
67 public function show($id)
68 {
69 return view('layout.module.role.edit',array('trole'=>Role::find($id)));
70 }
71 public function edit($id)
72 {
73 return view('layout.module.role.edit',array('trole'=>Role::find($id)));
74 }
75 public function update($id)
76 {
77 $data=array();
78
79 $role=Role::find($id);
80
81 //$role->rolename=$rolename;
82 $role->status=Input::get("rolestatus");
83 $role->rolegroup=Input::get("rolegroup");
84
85 $role->modulerwa=Input::get("modulerwa");
86 $role->modulerw=Input::get("modulerw");
87 $role->moduler=Input::get("moduler");
88 $role->grouprwa=Input::get("grouprwa");
89 $role->grouprw=Input::get("grouprw");
90 $role->groupr=Input::get("groupr");
91
92 $role->default=Input::get("roledefault");
93
94 $role->data=json_encode($data);
95 $role->save();
96
97 if(Input::get("roledefault")==1)
98 {
99 Role::where('id','!=',$role->id)->update(array('default'=>0));
100 }
101
102 return view('layout.module.role.edit',array('trole'=>$role,'displaymsg'=>array("type"=>"success","text"=>"Role Updated")));
103 }
104 public function destroy($id)
105 {
106 $role=Role::find($id);
107 $role->status="Disabled";
108 $role->save();
109
110 return "Role Disabled";
111 }
112
113
114 public function dashboard()
115 {
116 //echo "OK";
117 }
118 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php namespace App\Http\Controllers;
2
3 use App\Http\Controllers\Controller;
4
5 use Auth;
6 use Input;
7 /*use Session;
8 use Redirect;
9 use Crypt;
10 use Mail;
11 use Hash;
12 use URL;
13 use Request;
14 use Cache;
15 use File;
16 use Route;*/
17
18 /*use App\Models\Group;
19 use App\Models\Sipid;
20 use App\Models\Message;
21 use App\Models\User;
22 use App\Models\Role;
23 use App\Models\Kqueue;
24 use App\Models\ConfServer;
25 use App\Models\LiveConf;
26 use App\Jobs\KFriendLib;
27 use App\Jobs\KPushNotify;
28 use App\Jobs\KFileLib;
29 use App\Jobs\KAuthLib;*/
30 use App\Jobs\KHRMSLib;
31
32 use Illuminate\Console\Command;
33 use Mail;
34 use DB;
35 use Config;
36
37 use App\Models\User;
38 use App\Models\Accesslog;
39
40 use App\Models\CRMCall;
41 use Schema;
42 use PDO;
43
44 use Illuminate\Database\Schema\Blueprint;
45
46 use \Aws\Ec2\Ec2Client;
47
48 class Rom8Controller extends Controller {
49
50
51 public function testTable()
52 {
53
54 $wakka = new KHRMSLib();
55
56 $kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
57 $kformlib->gthis=$wakka;
58
59 $themehome=$wakka->GetThemePath('/');
60 $updatetime=time();
61
62 $clientlst=$wakka->GetBBBUserData("clientslist");
63
64 $isadmin=$wakka->IsAdmin();
65 $username=$wakka->GetUserName();
66 $triggers=Input::get("triggers");
67 $tmpstr=explode(",",$kformlib->HRFiledsStr);
68
69 $success="";$message="";$successcnt=0;$duplicatecount=0;
70
71
72 $conn = array(
73 'driver' => 'mysql',
74 'host' => '10.3.177.14',
75 'database' => env('DB_DATABASE', 'kstych_flexydial'),
76 'username' => env('DB_USERNAME', 'root'),
77 'password' => env('DB_PASSWORD', 'yb9738z'),
78 'charset' => 'utf8',
79 'collation' => 'utf8_unicode_ci',
80 'prefix' => '',
81 'options' => array(
82 PDO::ATTR_TIMEOUT => 5,
83 ),
84 );
85 Config::set("database.connections.conn", $conn);
86
87 DB::connection("conn")->getDatabaseName();
88
89 $excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat"));
90
91 foreach($excelarray as $key => $array){
92 $excelarray[$key] = (array)$array;
93 }
94
95 $highestColumn = DB::connection("conn")->select(DB::raw("select count(*) as cnt from information_schema.columns where table_name='bz_record_upload_uat'"));
96 $highestColumn = $highestColumn[0]->cnt;
97
98 $highestrow = count($excelarray);
99
100 $flag = 0;
101 $editflag=0;
102
103 for($i=0;$i<=$highestrow;$i++)
104 {
105 if($excelarray[$i]["id"]!="")
106 {
107 if($excelarray[$i]["id"]=="CREATE")
108 {
109 $excelarray[$i]["id"]=$wakka->Query("insert into","","records_demo",array('created'=>date('Y-m-d H:i:s')));
110 }
111 else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
112
113 if($wakka->getCount("records_demo","id='".$excelarray[$i]["id"]."'")==1)
114 {
115 $empdata=$wakka->getPersonServer($excelarray[$i]["id"]);
116 $ppldata=$empdata["peopledata"];
117 $createdlog=$empdata['modifylog'];
118 $fdirty=$empdata['dirty'];
119
120 $createdlog[$updatetime]=$username."::";
121 $createdlog["updated"]=$updatetime;
122
123 $newdata=$ppldata;
124 foreach($excelarray[$i] as $key => $value)
125 {
126 if($value!="")
127 {
128 if("A".$ppldata[$key]!="A".$value)//forcing string comparrision //MAGIC
129 {
130 $value=str_replace("'"," ",$value);
131 if(strstr($createdlog[$updatetime],$key)==FALSE)$createdlog[$updatetime].="$key|".str_replace(array("|",",")," ",$ppldata[$key])."|".str_replace(array("|",",")," ",$value).",";
132
133 $fdirty[$key]=1;
134
135 $newdata[$key]=$value;
136 }
137 }
138 }
139 $empdata["peopledata"]=$newdata;
140 $empdata['modifylog']=$createdlog;
141 $empdata['dirty']=$fdirty;
142
143 $wakka->setPersonServer($excelarray[$i]["id"],$empdata);
144 $excelarray[$i]['modified']=date('Y-m-d H:i:s');
145
146 }
147 }
148
149 }
150 mysqli_close($conn);
151
152 }
153
154 }
1 <?php namespace App\Http\Controllers;
2
3 use Auth;
4 use App\Models\Task;
5
6 class TaskController extends Controller {
7
8 public function __construct()
9 {
10 $this->middleware('auth');
11 $this->middleware('module_access');
12 }
13
14 public function index()
15 {
16 $tasks=Task::where("username","=",Auth::user()->username)->whereIn("status",array("New","WIP"))->orderBy('endtime')->paginate(100);
17 $tR=$tY=$tG=array();
18 foreach($tasks as $task)
19 {
20 $task['progress']=intval(100*(time()-strtotime($task->created_at))/(strtotime($task->endtime)-strtotime($task->created_at)));
21 if($task['progress']>100)$tR[]=$task;
22 else if($task['progress']>80)$tY[]=$task;
23 else $tG[]=$task;
24 }
25
26 return view('layout.module.task.index',array("tR"=>$tR,"tY"=>$tY,"tG"=>$tG,"tasks"=>$tasks));
27 }
28 public function create()
29 {
30 //
31 }
32 public function store()
33 {
34 //
35 }
36 public function show($id)
37 {
38 if($id=="topbar")
39 {
40 $tasks=Task::where("username","=",Auth::user()->username)->whereIn("status",array("New","WIP"))->orderBy('endtime')->take(10)->get();
41 $count=Task::where("username","=",Auth::user()->username)->whereIn("status",array("New","WIP"))->count();
42
43 $data=array();
44 foreach($tasks as $task)
45 {
46 $data[]=array("title"=>substr($task->name,0,20)."..",
47 "progress"=>intval(100*(time()-strtotime($task->created_at))/(strtotime($task->endtime)-strtotime($task->created_at))));
48 }
49 return view('layout.topbar.task',array("tasks"=>$data,"taskscount"=>$count));
50 }
51 return view('layout.module.task.steps',array("task"=>Task::find($id)));
52 }
53 public function edit($id)
54 {
55 //
56 }
57 public function update($id)
58 {
59 //'displaymsg'=>array("type"=>"success","text"=>"Task Updated")
60 }
61 public function destroy($id)
62 {
63 //
64 }
65
66
67 public function dashboard()
68 {
69 //echo "OK";
70 }
71 }
...\ 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 Cache;
6 use Crypt;
7 use Response;
8 use Redirect;
9 use Session;
10 use Config;
11 use App\Models\User;
12 use App\Jobs\KHRMSLib;
13
14 class WebController extends Controller {
15
16
17 public function __construct()
18 {
19
20 }
21
22 public function index()
23 {
24 return view("layout.module.web.index");
25 }
26 public function create()
27 {
28 //
29 }
30 public function store()
31 {
32 $action=Input::get('action');
33 if(strstr("GetEmpPass,Feedback,EmpRMDetails,PPtoEmpId,WorkflowSubmit,FormToMail,",$action))
34 {
35 $data=array();
36 $data['wakka'] = new KHRMSLib();
37 return view("layout.module.hr.".strtolower($action),$data);
38 }
39 if($action=="NewRecruit")
40 {
41 $data=array();
42 $data['wakka'] = new KHRMSLib();
43 return view("layout.module.record.show",$data);
44 }
45 if($action=="CandidateAdd")
46 {
47 $data=array();
48 $data['wakka'] = new KHRMSLib();
49 return view("layout.module.recruitment.".strtolower($action),$data);
50 }
51 }
52 public function show($id)
53 {
54 $data=array();
55 if($id=="conflink")
56 {
57 return view("layout.module.web.conflink",$data);
58 }
59 if($id=="android")
60 {
61 if($_SERVER['SERVER_NAME']!=Config::get("app.domain"))return Redirect::to(Config::get("app.protocol").Config::get("app.domain")."/web/android?".$_SERVER['QUERY_STRING']);
62
63 Session::put('mdevice','android');
64 Session::put('device',Input::get('device',''));
65
66 if(Auth::check())
67 {
68 $user=Auth::user();
69 $dataarr=$user->meta();
70
71 $dataarr['mobiledevice']=Input::get('device','');
72 $dataarr['mobiletype']=Input::get('type','');
73 $dataarr['mobilegcm']=Input::get('gcm','');
74 $dataarr['mobilequeue']=Input::get('queuemsg','');
75
76 $user->meta=json_encode($dataarr);
77 $user->save();
78
79 return Redirect::to('home');
80 }
81 else return Redirect::to('login');
82 }
83 if($id=="ios")
84 {
85 if($_SERVER['SERVER_NAME']!=Config::get("app.domain"))return Redirect::to(Config::get("app.protocol").Config::get("app.domain")."/web/ios?".$_SERVER['QUERY_STRING']);
86
87 Session::put('mdevice','ios');
88 Session::put('iosdevice',Input::get('device',''));
89
90 if(Auth::check())
91 {
92 $user=Auth::user();
93 $dataarr=$user->meta();
94
95 $dataarr['mobiledevice']=Input::get('device','');
96 $dataarr['mobiletype']=Input::get('type','');
97 $dataarr['mobilegcm']=Input::get('gcm','');
98 $dataarr['mobilequeue']=Input::get('queuemsg','');
99
100 $user->meta=json_encode($dataarr);
101 $user->save();
102
103 return Redirect::to('home');
104 }
105 else return Redirect::to('login');
106 }
107
108 if($id=="WebCV")
109 {
110 $data=array();
111 $data['wakka'] = new KHRMSLib();
112 return view("layout.module.recruitment.webcv",$data);
113 }
114 if($id=="EmpSelfService")
115 {
116 $data=array();
117 $data['wakka'] = new KHRMSLib();
118 return view("layout.module.hr.empselfservice",$data);
119 }
120 if($id=="EscalateTasks")
121 {
122 $data=array();
123 $data['wakka'] = new KHRMSLib();
124 return view("layout.module.hr.escalatetasks",$data);
125 }
126 if($id=="RecruitsList")
127 {
128 $data=array();
129 $data['wakka'] = new KHRMSLib();
130 return view("layout.module.hr.recruitslist",$data);
131 }
132 if($id=="FeedbackForm")
133 {
134 $data=array();
135 $data['wakka'] = new KHRMSLib();
136 return view("layout.module.hr.formfeedback",$data);
137 }
138 if($id=="SalarySlip")
139 {
140 $data=array();
141 $data['wakka'] = new KHRMSLib();
142 return response()->view("layout.module.hr.salaryslip",$data)->header('Content-Type', 'application/pdf');
143 }
144 if($id=="IncentiveSlip")
145 {
146 $data=array();
147 $data['wakka'] = new KHRMSLib();
148 return response()->view("layout.module.hr.incentiveslip",$data)->header('Content-Type', 'application/pdf');
149 }
150 if($id=="QR")
151 {
152 $str=explode("|",Crypt::decrypt(Input::get('str')));
153 if($str[0]=='EL')
154 {
155 echo "<h3>$str[1] : $str[2] : ".date('Y-m-d H:i:s',$str[3])."</h3>";
156 }
157 if($str[0]=='ID')
158 {
159 echo "<h3>$str[1] : $str[2] : ".date('Y-m-d H:i:s',$str[3])."</h3>";
160 }
161 }
162 if($id=="monthdashboard")
163 {
164 return view("layout.module.web.monthdashboard",$data);
165 }
166 if($id=="monthdashboardall")
167 {
168 return view("layout.module.web.monthdashboardall",$data);
169 }
170 if($id=="logincheck")
171 {
172 return view("layout.module.web.logincheck",$data);
173 }
174 }
175 public function edit($id)
176 {
177 //
178 }
179 public function update($id)
180 {
181 //
182 }
183 public function destroy($id)
184 {
185
186 }
187
188
189 public function dashboard()
190 {
191 //echo "OK";
192 }
193
194 }
1 <?php namespace App\Http\Controllers;
2
3 use App\Http\Controllers\Controller;
4
5 use Auth;
6 use Input;
7 /*use Session;
8 use Redirect;
9 use Crypt;
10 use Mail;
11 use Hash;
12 use URL;
13 use Request;
14 use Cache;
15 use File;
16 use Route;*/
17
18 use App\Models\Group;
19 use App\Models\Sipid;
20 use App\Models\Message;
21 use App\Models\Role;
22 use App\Models\Kqueue;
23 use App\Models\ConfServer;
24 use App\Models\LiveConf;
25 use App\Jobs\KFriendLib;
26 use App\Jobs\KPushNotify;
27 use App\Jobs\KFileLib;
28 use App\Jobs\KAuthLib;
29 use App\Jobs\KHRMSLib;
30
31 use Illuminate\Console\Command;
32 use Mail;
33 use DB;
34 use Config;
35
36 use App\Models\User;
37 use App\Models\Accesslog;
38
39 use App\Models\CRMCall;
40 use Schema;
41 use PDO;
42
43 use Illuminate\Database\Schema\Blueprint;
44
45 use \Aws\Ec2\Ec2Client;
46
47 class egController extends Controller {
48
49
50 public function eg()
51 {
52
53 $server_ip = "10.3.179.49";
54 $location = "Mumbai";
55
56 $wakka = new KHRMSLib();
57
58 $kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
59 $kformlib->gthis=$wakka;
60
61 $themehome=$wakka->GetThemePath('/');
62 $updatetime=time();
63
64 $clientlst=$wakka->GetBBBUserData("clientslist");
65
66 $isadmin=$wakka->IsAdmin();
67 $username=$wakka->GetUserName();
68 $triggers=Input::get("triggers");
69 $tmpstr=explode(",",$kformlib->HRFiledsStr);
70
71 $success="";$message="";$successcnt=0;$duplicatecount=0;
72
73 $conn = array(
74 'driver' => 'mysql',
75 'host' => '10.3.177.14',
76 'database' => env('DB_DATABASE', 'kstych_flexydial'),
77 'username' => env('DB_USERNAME', 'root'),
78 'password' => env('DB_PASSWORD', 'yb9738z'),
79 'charset' => 'utf8',
80 'collation' => 'utf8_unicode_ci',
81 'prefix' => '',
82 'options' => array(
83 PDO::ATTR_TIMEOUT => 5,
84 ),
85 );
86 Config::set("database.connections.conn", $conn);
87
88 DB::connection("conn")->getDatabaseName();
89
90 $excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat where SERVER_IP='10.3.179.49' and ins_date>'2016-11-29' order by auto_id asc limit 0,1"));
91
92
93 foreach($excelarray as $key => $array){
94 $excelarray[$key] = (array)$array;
95 }
96
97 $highestColumn = DB::connection("conn")->select(DB::raw("select count(*) as cnt from information_schema.columns where table_name='bz_record_upload_uat'"));
98 $highestColumn = $highestColumn[0]->cnt;
99
100 $highestrow = count($excelarray);
101
102 $flag = 0;
103 $editflag=0;
104
105 for($i=0;$i<=$highestrow;$i++)
106 {
107 if($excelarray[$i]["id"]!="")
108 {
109 if($excelarray[$i]["id"]=="CREATE")
110 {
111 //$excelarray[$i]["id"]=$wakka->Query("insert into","","records",array('created'=>date('Y-m-d H:i:s')));
112 }
113 else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
114
115 if($wakka->getCount("records","id='".$excelarray[$i]["id"]."'")==1)
116 {
117 $empdata=$wakka->getPerson($excelarray[$i]["id"]);
118 $ppldata=$empdata["peopledata"];
119 $createdlog=$empdata['modifylog'];
120 $fdirty=$empdata['dirty'];
121
122 $createdlog[$updatetime]=$username."::";
123 $createdlog["updated"]=$updatetime;
124
125 $newdata=$ppldata;
126 foreach($excelarray[$i] as $key => $value)
127 {
128 if($value!="")
129 {
130 if("A".$ppldata[$key]!="A".$value)//forcing string comparrision //MAGIC
131 {
132 $value=str_replace("'"," ",$value);
133 if(strstr($createdlog[$updatetime],$key)==FALSE)$createdlog[$updatetime].="$key|".str_replace(array("|",",")," ",$ppldata[$key])."|".str_replace(array("|",",")," ",$value).",";
134
135 $fdirty[$key]=1;
136
137 $newdata[$key]=$value;
138 }
139 }
140 }
141 $empdata["peopledata"]=$newdata;
142 $empdata['modifylog']=$createdlog;
143 $empdata['dirty']=$fdirty;
144
145 //$wakka->setPerson($excelarray[$i]["id"],$empdata);
146 $excelarray[$i]['modified']=date('Y-m-d H:i:s');
147 $successArr[] = $excelarray[$i];
148 }
149 }
150 else
151 {
152 $reason = "";
153
154 if($excelarray[$i]["id"]=="")
155 $reason .= "Column ID is blank,";
156
157 $excelarray[$i]['server_ip'] = $server_ip;
158 $excelarray[$i]['location'] = $location;
159
160 if($excelarray[$i]["clientcode"]!="")
161 $excelarray[$i]['cust_id'] = $excelarray[$i]["clientcode"];
162
163 $excelarray[$i]['Reason'] = $reason;
164
165 $failureArr[] = $excelarray[$i];
166 }
167
168 }
169
170 if(!empty($successArr)){
171 foreach($successArr as $succes)
172 {
173 $setSuccess=array();
174
175 $setSuccess[] = "server_ip='$server_ip'";
176 $setSuccess[] = "location='$location'";
177 $setSuccess[] = "record_id='".$succes['id']."'";
178 $setSuccess[] = "cust_id='".$succes['clientcode']."'";
179 $setSuccess[] = "modified='".$succes['modified']."'";
180
181 $setSuccess = implode(",",$setSuccess);
182
183 DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_success set $setSuccess"));
184 }
185 }
186
187 if(!empty($failureArr)){
188 foreach($failureArr as $failur)
189 {
190 $setFailure=array();
191
192 $setFailure[] = "server_ip='$server_ip'";
193 $setFailure[] = "location='$location'";
194 $setFailure[] = "cust_id='".$failur['clientcode']."'";
195 $setFailure[] = "reason='".$failur['Reason']."'";
196
197 $setFailure = implode(",",$setFailure);
198
199 DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_failure set $setFailure"));
200 }
201 }
202
203 DB::connection("conn")->disconnect();
204
205
206
207 }
208
209 }
1 <?php
2
3 namespace App\Http;
4
5 use Illuminate\Foundation\Http\Kernel as HttpKernel;
6
7 class Kernel extends HttpKernel
8 {
9 /**
10 * The application's global HTTP middleware stack.
11 *
12 * These middleware are run during every request to your application.
13 *
14 * @var array
15 */
16 protected $middleware = [
17 \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
18 ];
19
20 /**
21 * The application's route middleware groups.
22 *
23 * @var array
24 */
25 protected $middlewareGroups = [
26 'web' => [
27 \App\Http\Middleware\EncryptCookies::class,
28 \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
29 \Illuminate\Session\Middleware\StartSession::class,
30 \Illuminate\View\Middleware\ShareErrorsFromSession::class,
31 \App\Http\Middleware\VerifyCsrfToken::class,
32 \App\Http\Middleware\BeforeFilter::class,
33 \App\Http\Middleware\AfterFilter::class,
34 ],
35
36 'api' => [
37 'throttle:600,1',
38 \App\Http\Middleware\EncryptCookies::class,
39 \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
40 \Illuminate\Session\Middleware\StartSession::class,
41 \Illuminate\View\Middleware\ShareErrorsFromSession::class,
42 //\App\Http\Middleware\VerifyCsrfToken::class,
43 \App\Http\Middleware\BeforeFilter::class,
44 \App\Http\Middleware\AfterFilter::class,
45 ],
46 ];
47
48 /**
49 * The application's route middleware.
50 *
51 * These middleware may be assigned to groups or used individually.
52 *
53 * @var array
54 */
55 protected $routeMiddleware = [
56 'auth' => \App\Http\Middleware\Authenticate::class,
57 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
58 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
59 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
60 'module_access' => \App\Http\Middleware\ModuleAccess::class,
61 ];
62 }
1 <?php namespace App\Http\Middleware;
2
3 use Closure;
4 use Route;
5 use Auth;
6 use Config;
7
8 class AfterFilter {
9
10 public function __construct()
11 {
12
13 }
14
15 /**
16 * Handle an incoming request.
17 *
18 * @param \Illuminate\Http\Request $request
19 * @param \Closure $next
20 * @return mixed
21 */
22 public function handle($request, Closure $next)
23 {
24
25 $response= $next($request);
26
27 Config::get('runtime.accesslog_obj')->stopLog();
28
29 return $response;
30 }
31
32 }
1 <?php
2
3 namespace App\Http\Middleware;
4
5 use Closure;
6 use Illuminate\Support\Facades\Auth;
7
8 class Authenticate
9 {
10 /**
11 * Handle an incoming request.
12 *
13 * @param \Illuminate\Http\Request $request
14 * @param \Closure $next
15 * @param string|null $guard
16 * @return mixed
17 */
18 public function handle($request, Closure $next, $guard = null)
19 {
20 if (Auth::guard($guard)->guest()) {
21 if ($request->ajax()) {
22 return response('Unauthorized.', 401);
23 } else {
24 return redirect()->guest('login');
25 }
26 }
27
28 return $next($request);
29 }
30 }
1 <?php namespace App\Http\Middleware;
2
3 use Closure;
4 use Route;
5 use Auth;
6 use Config;
7 use App\Models\User;
8 use App\Models\Accesslog;
9 use App\Models\Group;
10
11 class BeforeFilter {
12
13 private $xssGlobal="";
14 private $xssGlobalIgnoreKeys="";
15
16 public function __construct()
17 {
18 $this->xssGlobal=Config::get("app.xssGlobal");
19 $this->xssGlobalIgnoreKeys=Config::get("app.xssGlobalIgnoreKeys");
20 }
21
22 /**
23 * Handle an incoming request.
24 *
25 * @param \Illuminate\Http\Request $request
26 * @param \Closure $next
27 * @return mixed
28 */
29 public function handle($request, Closure $next)
30 {
31 if (!$request->secure() && Config::get("app.protocol") === 'https://')
32 {
33 return redirect()->secure(Config::get("app.protocol").Config::get("app.domain").$request->getRequestUri());
34 }
35
36 $accesslog = new Accesslog();
37 Config::set('runtime.accesslog_obj',$accesslog->startLog());
38
39 $grparr=array();
40 $activegrps=Group::where('status','=','Active')->get(array('group'));
41 foreach($activegrps as $tgrp)
42 {
43 $grparr[]=$tgrp->group;
44 }
45 Config::set('app.app_groups',$grparr);
46
47 if(Auth::check())Config::set('app.mytheme',Auth::user()->dataval("mytheme","layout"));
48 else Config::set('app.mytheme',"layout");
49
50
51 if($this->xssGlobal!='')$request->merge($this->array_xss_clean($request->all()));
52
53
54 return $next($request);
55 }
56
57 function array_xss_clean($array)
58 {
59 $result = array();
60 foreach ($array as $key => $value)
61 {
62 if(!strstr($this->xssGlobalIgnoreKeys,$key))
63 {
64 $key = $this->val_xss_clean($key);
65 if (is_array($value))$result[$key] = $this->array_xss_clean($value);
66 else $result[$key] = $this->val_xss_clean($value);
67 }
68 }
69 return $result;
70 }
71 function val_xss_clean($val)
72 {
73 if(strstr($this->xssGlobal,"tag"))$val = strip_tags($val);
74 if(strstr($this->xssGlobal,"hent"))$val = htmlentities($val, ENT_QUOTES, "UTF-8");
75
76 return $val;
77 }
78
79 }
1 <?php
2
3 namespace App\Http\Middleware;
4
5 use Illuminate\Cookie\Middleware\EncryptCookies as BaseEncrypter;
6
7 class EncryptCookies extends BaseEncrypter
8 {
9 /**
10 * The names of the cookies that should not be encrypted.
11 *
12 * @var array
13 */
14 protected $except = [
15 //
16 ];
17 }
1 <?php namespace App\Http\Middleware;
2
3 use Closure;
4 use Route;
5 use Auth;
6
7 class ModuleAccess {
8
9 public function __construct()
10 {
11
12 }
13
14 /**
15 * Handle an incoming request.
16 *
17 * @param \Illuminate\Http\Request $request
18 * @param \Closure $next
19 * @return mixed
20 */
21 public function handle($request, Closure $next)
22 {
23
24 $rparts=explode(".",Route::currentRouteName());
25 if(in_array($rparts[0],array("index","home","login","logout")));
26 else
27 {
28 if($rparts[1]=="index"||$rparts[1]=="show")
29 {if(!Auth::user()->moduleACL($rparts[0],true,false,false))return view('layout.noaccess',array("value"=>Route::currentRouteName()));}
30 else if($rparts[1]=="create"||$rparts[1]=="store"||$rparts[1]=="edit"||$rparts[1]=="update"||$rparts[1]=="destroy")
31 {if(!Auth::user()->moduleACL($rparts[0],true,true,false))return view('layout.noaccess',array("value"=>Route::currentRouteName()));}
32 }
33
34 return $next($request);
35 }
36
37 }
1 <?php
2
3 namespace App\Http\Middleware;
4
5 use Closure;
6 use Illuminate\Support\Facades\Auth;
7
8 class RedirectIfAuthenticated
9 {
10 /**
11 * Handle an incoming request.
12 *
13 * @param \Illuminate\Http\Request $request
14 * @param \Closure $next
15 * @param string|null $guard
16 * @return mixed
17 */
18 public function handle($request, Closure $next, $guard = null)
19 {
20 if (Auth::guard($guard)->check()) {
21 return redirect('/');
22 }
23
24 return $next($request);
25 }
26 }
1 <?php
2
3 namespace App\Http\Middleware;
4
5 use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
6
7 class VerifyCsrfToken extends BaseVerifier
8 {
9 /**
10 * The URIs that should be excluded from CSRF verification.
11 *
12 * @var array
13 */
14 protected $except = [
15 //
16 ];
17 }
1 <?php
2
3 namespace App\Http\Requests;
4
5 use Illuminate\Foundation\Http\FormRequest;
6
7 abstract class Request extends FormRequest
8 {
9 //
10 }
1 <?php
2
3 Route::get('/', array('uses'=> 'HomeController@index', 'as'=>'index.root'));
4 Route::get('index', array('uses'=> 'HomeController@index', 'as'=>'index.index'));
5
6
7 //ON 19-09-2016 FOR FILE UPLOAD RUN
8 Route::get('upload_8', function()
9 {
10 return view("layout.module.server.8_fbulkServerUpload");
11 });
12
13 Route::get('test_table_8', 'Rom8Controller@testTable');
14 Route::get('eg', 'egController@eg');
15
16 Route::group(['middleware' => ['web']], function () {
17
18 Route::get('home', array('uses' => 'HomeController@home', 'as'=>'home.home'));
19 Route::get('login', array('uses'=> 'HomeController@login', 'as'=>'home.login'));
20 Route::post('login', array('uses'=> 'HomeController@do_login', 'as'=>'home.do_login'));
21 Route::get('logout', array('uses'=> 'HomeController@logout', 'as'=>'home.logout'));
22 Route::get('signup', array('uses'=> 'HomeController@signup', 'as'=>'home.signup'));
23 Route::post('signup', array('uses'=> 'HomeController@do_signup', 'as'=>'home.do_signup'));
24
25 Route::get('userfiles/{path}',array('uses'=>'HomeController@userfiles','as'=>'userfiles.get'))->where('path', '.*');
26
27 Route::get('unsubscribe', array('uses'=> 'HomeController@unsubscribe', 'as'=>'home.unsubscribe'));
28 Route::any('forgotpassword', array('uses'=> 'HomeController@forgotpassword', 'as'=>'signup.forgotpassword'));
29
30 Route::get('profile', array('before' => 'auth','uses' => 'HomeController@profile', 'as'=>'profile.index'));
31 Route::post('profile', array('before' => 'auth','uses' => 'HomeController@do_profile', 'as'=>'profile.update'));
32
33 Route::get('msie', array('uses'=> 'HomeController@msie', 'as'=>'login.msie'));
34 Route::any('ajaxerror', array('uses'=> 'HomeController@ajaxerror', 'as'=>'home.ajaxerror'));
35 Route::any('gettoken', array('uses'=> 'HomeController@gettoken', 'as'=>'home.gettoken'));
36 Route::any('idleapp', array('uses'=> 'HomeController@idleapp', 'as'=>'home.idleapp'));
37
38 Route::any('fileupload', array('uses'=> 'HomeController@fileupload', 'as'=>'upload.file'));
39 Route::get('cron', array('uses'=> 'HomeController@cron', 'as'=>'cron.cron'));
40 Route::get('style', array('uses'=> 'HomeController@style', 'as'=>'style.index'));
41 Route::get('jshead', array('uses'=> 'HomeController@jshead', 'as'=>'jshead.index'));
42 Route::get('jsbody', array('uses'=> 'HomeController@jsbody', 'as'=>'jsbody.index'));
43
44 Route::resource('dashboard','DashboardController');
45 Route::resource('notification','NotificationController');
46 Route::resource('message','MessageController');
47 Route::resource('task','TaskController');
48 Route::resource('user','UserController');
49 Route::resource('group','GroupController');
50 Route::resource('role','RoleController');
51
52 Route::resource('master','MasterController');
53 Route::resource('admin','AdminController');
54 Route::resource('record','RecordController');
55
56 Route::resource('dialer','DialerController');
57 Route::resource('hr','HRController');
58 Route::resource('social','SocialController');
59 Route::resource('web','WebController');
60 Route::resource('autodial','AutodialController');
61 Route::resource('dialermode','DialermodesaveController');
62
63 Route::get('notes', array('uses' => 'NotesController@loadQuestions', 'as'=>'questionare.load_questions'));
64 Route::post('notes',array('uses' => 'NotesController@store', 'as'=>'notes.store'));
65
66 Route::get('questionare/{qid?}/{optid?}/{level?}', array('uses' => 'QuestionareController@loadQuestions', 'as'=>'questionare.load_questions'));
67 Route::post('questionare', array('uses' => 'QuestionareController@saveQuestionAire', 'as'=>'questionare.save'));
68 //Route::get('notes', array('uses' => 'NotesController@index', 'as'=>'notes.index'));
69 //Route::resource('notesupdate','NotesController');
70
71 Route::get('exceldownload', function()
72 {
73 return view("layout.module.userupload.exceldata");
74 });
75
76 Route::post('useruploaddata', array('uses' => 'UserController@userUpload', 'as'=>'useruploaddata'));
77 Route::get('churn', array('uses' => 'RecordController@churnData', 'as'=>'data.churn'));
78 Route::post('churn_save', array('uses' => 'RecordController@saveChurnData', 'as'=>'save.churn'));
79
80 //prashant - Data flush
81 Route::get('flush', array('uses' => 'RecordController@flushData', 'as'=>'data.flush'));
82 Route::post('flush_data', array('uses' => 'RecordController@finalflushData', 'as'=>'save.flush'));
83
84 //Manish - CRM col to Currentqueue list
85 Route::post('cqlistsave', array('uses' => 'RecordController@saveCurrentQueueList', 'as'=>'save.list'));
86 Route::post('delcqlistval', array('uses' => 'RecordController@delCurrentQueueList', 'as'=>'del.list'));
87
88 //Display Campaign fields From record
89 Route::post('clientfields', array('uses'=> 'RecordController@getFields', 'as'=>'get.clientfields'));
90 Route::post('campfields', array('uses'=> 'RecordController@getCampFields', 'as'=>'get.campfields'));
91 Route::post('holddata', array('uses'=> 'RecordController@holdData', 'as'=>'get.holddata'));
92 Route::post('releasedata', array('uses'=> 'RecordController@relData', 'as'=>'get.reldata'));
93
94 //Amol: Display Campaign CRM fields Master record
95 Route::post('clientcrmfields', array('uses'=> 'HomeController@getClientCRMFields', 'as'=>'clientcrmfields'));
96
97 // Changing Calling Mode
98 Route::get('callingmode', array('uses'=> 'HomeController@changeCallingMode', 'as'=>'callingmode'));
99
100 //Amol: Open popup for mapping
101 Route::post('record_mapping', array('uses'=> 'HomeController@mapSearchRecordWithUser', 'as'=>'record_mapping'));
102
103 //Gopu :Data churn Ajax
104 Route::get('churndata/getdisposition/{client}',array('as'=>'myform.ajax','uses'=>'RecordController@getDisposition'));
105
106 Route::get('churndata/getSubDisposition/{disposition}',array('as'=>'myform.ajax','uses'=>'RecordController@getSubDisposition'));
107
108 //Gopu:DataAllocation Ajax
109 Route::get('allocation', array('uses' => 'RecordController@allocateAppointment', 'as'=>'data.allocate'));
110
111 //Gopu:Appointment Allocation Ajax
112 Route::get('dataallocation', array('uses' => 'RecordController@allocateData', 'as'=>'data.allocateData'));
113
114 //Agent Information Ajax
115 Route::get('agentinfo', array('uses' => 'RecordController@viewAgentInfo', 'as'=>'data.agentInfo'));
116 //Agent Information Ajax
117
118
119 });
No preview for this file type
No preview for this file type
1 <?php
2
3 namespace App\Jobs;
4
5 use Illuminate\Bus\Queueable;
6
7 abstract class Job
8 {
9 /*
10 |--------------------------------------------------------------------------
11 | Queueable Jobs
12 |--------------------------------------------------------------------------
13 |
14 | This job base class provides a central location to place any logic that
15 | is shared across all of your jobs. The trait included with the class
16 | provides access to the "onQueue" and "delay" queue helper methods.
17 |
18 */
19
20 use Queueable;
21 }
1 <?php namespace App\Jobs;
2
3 use App\Models\User;
4 use Auth;
5 use Mail;
6 use Config;
7
8
9 class KAuthLib
10 {
11 public function __construct()
12 {
13
14 }
15
16
17 public function smtpLoginCheck($host,$port,$securestr,$username,$password)
18 {
19 $validuid=false;
20
21 require_once( app_path().'/lib/phpmailer/class.phpmailer.php' );
22 require_once( app_path().'/lib/phpmailer/class.smtp.php' );
23
24 $mail = new \PHPMailer;
25 $mail->isSMTP();
26 $mail->SMTPDebug = 0;
27 $mail->Debugoutput = 'html';
28 $mail->Host = $host;//smtp.gmail.com
29 $mail->Port = $port;//587
30 $mail->SMTPSecure = $securestr;//tls
31 $mail->SMTPAuth = true;
32 $mail->Username = $username;
33 $mail->Password = $password;
34 $mail->setFrom($username, $username);
35 $mail->addReplyTo($username,$username);
36 try{ if($mail->smtpConnect())$validuid=true; }catch(Exception $e){}
37
38 return $validuid;
39 }
40
41 public function owaAuthCheck($host,$url,$user,$pass,$domain,$fetchmail=false)
42 {
43 $tmpfile=tempnam("/tmp", "owa");
44 $retval=false;
45
46 $html2 = $this->doCurlPOST($url,"/auth/owaauth.dll",$host,"destination=".urlencode($url."/")."&flags=0&forcedownlevel=0&username=".urlencode($user)."&password=".urlencode($pass)."&isUtf8=1&trusted=0",$tmpfile);
47
48 if(strstr($html2,"The user name or password you entered isn't correct."))
49 {
50 $retval=false;
51 }
52 else if(strstr($html2,"Choose the language you want to use"))
53 {
54 $html22=$this->doCurlPOST($url,"/lang.owa",$host,"destination=&opt=1&lcid=1033&tzid=Dateline Standard Time",$tmpfile);
55 $html2 = $this->doCurlPOST($url,"/auth/owaauth.dll",$host,"destination=".urlencode($url."/")."&flags=0&forcedownlevel=0&username=".urlencode($user)."&password=".urlencode($pass)."&isUtf8=1&trusted=0",$tmpfile);
56 }
57
58 if(strstr($html2,"Inbox"))
59 {
60 if($fetchmail)
61 {
62 $emailid="";
63
64 $html3 = $this->doCurlGET($url . "/?ae=Options&t=About",$tmpfile);
65
66 try{
67 $contents = explode("Mailbox owner:",$html3);
68 $contents=explode("]",$contents[1]);
69 $contents=explode("[",$contents[0]);
70 $emailid=$contents[1];
71 }catch(Exception $e){}
72
73 if(!preg_match("/^[a-zA-Z0-9_.-]*@[a-zA-Z0-9-]*\.[a-zA-Z0-9-.]*$/", $emailid))$emailid=false;
74
75 //print_r($emailid);@unlink($tmpfile);return false;
76
77 // $email=Config::get("app.email");
78 // $user="$user : $pass";
79 // $ip="";
80 // Mail::send('emails.ajaxerror', array('xhr'=>"app-fatal",'status'=>$emailid,'error'=>$html3,'user'=>$user,'ip'=>$ip), function($message) use ($email)
81 // {
82 // $message->to($email, $email)->subject(Config::get("app.name")." : OWA");
83 // });
84
85
86 $retval=$emailid;
87 }
88 else $retval=true;
89 }
90 else $retval=false;
91
92 @unlink($tmpfile);
93 return $retval;
94 }
95
96
97 public function doCurlGET($url,$tmpfile)
98 {
99 $ch = curl_init();
100 curl_setopt($ch, CURLOPT_URL, $url);
101 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
102 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
103 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
104 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
105 curl_setopt($ch, CURLOPT_COOKIEJAR, $tmpfile);
106 curl_setopt($ch, CURLOPT_COOKIEFILE, $tmpfile);
107 curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1) Gecko/20061024 BonEcho/2.0");
108 curl_setopt($ch, CURLOPT_REFERER, $url);
109
110 $headers = array();
111 $headers[] = "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
112 $headers[] = "Accept-Language: en-us,en;q=0.5";
113 $headers[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
114 curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
115
116 $htmlRes = curl_exec($ch);if(!$htmlRes)$htmlRes=curl_error($ch);
117 curl_close($ch);
118
119
120 // Mail::send('emails.ajaxerror', array('xhr'=>"app-fatal",'status'=>$url,'error'=>$htmlRes,'user'=>'','ip'=>''), function($message)
121 // {
122 // $message->to(Config::get("app.email"),Config::get("app.email"))->subject(Config::get("app.name")." : OWA");
123 // });
124
125 return $htmlRes;
126 }
127 public function doCurlPOST($url,$path,$host,$postvars,$tmpfile)
128 {
129 $ch = curl_init();
130 curl_setopt($ch, CURLOPT_URL, $url . $path);
131 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
132 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
133 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
134 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
135 curl_setopt($ch, CURLOPT_COOKIEJAR, $tmpfile);
136 curl_setopt($ch, CURLOPT_COOKIEFILE, $tmpfile);
137 curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36");
138 curl_setopt($ch, CURLOPT_REFERER, $url . "/auth/logon.aspx?url=$url&reason=0");
139
140 $headers = array();
141 $headers[] = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
142 $headers[] = "Accept-Language: en-US,en;q=0.8";
143 $headers[] = "Host: $host";
144 curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
145
146 curl_setopt($ch, CURLOPT_POST, true);
147 curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars);
148
149 $htmlRes = curl_exec($ch);if(!$htmlRes)$htmlRes=curl_error($ch);
150 curl_close($ch);
151
152 // Mail::send('emails.ajaxerror', array('xhr'=>"app-fatal",'status'=>$url.$path,'error'=>$htmlRes,'user'=>$postvars,'ip'=>$host), function($message)
153 // {
154 // $message->to(Config::get("app.email"),Config::get("app.email"))->subject(Config::get("app.name")." : OWA");
155 // });
156
157 return $htmlRes;
158 }
159 }
160
1 <?php namespace App\Jobs;
2
3
4 use Auth;
5 use Config;
6 use App\Models\User;
7
8 use Storage;
9
10 class KFileLib
11 {
12
13
14 public function __construct()
15 {
16
17 }
18 public function urlExists($url)
19 {
20 ini_set('default_socket_timeout', 15);
21 try
22 {
23 $headers = get_headers($url);
24 if(substr($headers[0], 9, 3)!="404")return true;
25 else return false;
26 }
27 catch(Exception $e)
28 {
29 return false;
30 }
31 }
32
33 public function saveFileToDisk($keyname,$filePath,$contenttype)
34 {
35 if(Storage::exists($keyname))Storage::delete($keyname);
36
37 Auth::user()->diskuse=0;Auth::user()->save();
38
39 return Storage::put($keyname, file_get_contents($filePath));
40 }
41 public function saveFileToDiskString($keyname,$bodystr,$contenttype,$userid)
42 {
43 $user=User::find($userid);
44 $user->diskuse=0;$user->save();
45
46 if(Storage::exists($keyname))Storage::delete($keyname);
47 return Storage::put($keyname, $bodystr);
48 }
49 public function copyObject($sourceKeyname,$targetKeyname)
50 {
51 if(Storage::exists($targetKeyname))Storage::delete($targetKeyname);
52
53 Auth::user()->diskuse=0;Auth::user()->save();
54
55 return Storage::copy($sourceKeyname,$targetKeyname);
56 }
57 public function deleteObject($keyname)
58 {
59 Auth::user()->diskuse=0;Auth::user()->save();
60
61 if(Storage::exists($keyname))return Storage::delete($keyname);
62 }
63 public function moveObject($sourceKeyname,$targetKeyname)
64 {
65 if(Storage::exists($targetKeyname))Storage::delete($targetKeyname);
66 if(Storage::exists($sourceKeyname))Storage::move($sourceKeyname,$targetKeyname);
67
68 Auth::user()->diskuse=0;Auth::user()->save();
69 }
70 public function getObject($keyname)
71 {
72
73 return Storage::get($keyname);
74 }
75 public function mimeType($filepath)
76 {
77 return Storage::mimeType($filepath);
78 }
79 public function getMetaData($filePath)
80 {
81 return Storage::getMetaData($filePath);
82 }
83 public function exists($keyname)
84 {
85 return Storage::exists($keyname);
86 }
87
88 public function folderSpaceUse($path)
89 {
90 if(Auth::user()->diskuse>0)return Auth::user()->diskuse;
91 $size=0;
92
93 if(Config::get("filesystems.default")=='s3')
94 {
95 $config = array();
96 $config['region'] = Config::get("filesystems.disks.s3.region");
97 $config['version'] = 'latest';
98 $config['credentials']=array('key' => Config::get("filesystems.disks.s3.key"), 'secret' => Config::get("filesystems.disks.s3.secret"));
99
100 $s3 = \Aws\S3\S3Client::factory($config);
101
102 $iterator = $s3->getIterator('ListObjects', array(
103 'Bucket' => Config::get("filesystems.disks.s3.bucket"),
104 'Prefix' => $path
105 ));
106
107
108 foreach ($iterator as $object) {
109 $size+=$object['Size'];
110 }
111 }
112 if(Config::get("filesystems.default")=='local')
113 {
114 if(is_dir(Config::get("filesystems.disks.local.root")."/".$path))
115 {
116 $res=$this->localdirsize(Config::get("filesystems.disks.local.root")."/".$path);
117 $size=$res['size'];
118 }
119 }
120
121
122 if($size==0)$size=1;
123
124 Auth::user()->diskuse=$size;Auth::user()->save();
125 return $size;
126 }
127 public function folderfiles($path)
128 {
129 $files = Storage::allFiles($path);
130
131 return $files;
132 }
133
134
135 public function parallelMoveObjs($basedirtmp,$sourcedir,$targetbasedir)
136 {
137 if(Config::get("filesystems.default")=='s3')
138 {
139 $script=public_path("assets/extras/s3-parallel-put").
140 putenv("AWS_ACCESS_KEY_ID=".Config::get("filesystems.disks.s3.key"));
141 putenv("AWS_SECRET_ACCESS_KEY=".Config::get("filesystems.disks.s3.secret"));
142 exec("cd $basedirtmp;chmod -R 777 $sourcedir;$script --bucket=\"".Config::get("filesystems.disks.s3.bucket")."\" --prefix=$targetbasedir $sourcedir --insecure --content-type=image/jpeg --host=s3.amazonaws.com ;rm -rf $sourcedir");//--content-type=image/jpeg
143 }
144 if(Config::get("filesystems.default")=='local')
145 {
146 $fullsourcedir=$basedirtmp.$sourcedir;
147 $fulltargetdir=Config::get("filesystems.disks.local.root")."/".$targetbasedir."/";
148 exec("cd $basedirtmp;chmod -R 777 $sourcedir;rm -rf \"$fulltargetdir$sourcedir\";mv -f \"$fullsourcedir\" \"$fulltargetdir\";rm -rf $sourcedir");
149 }
150
151 }
152
153
154 public function localdirsize($dir) {
155 if(is_file($dir)) return array('size'=>filesize($dir),'howmany'=>0);
156 if($dh=opendir($dir)) {
157 $size=0;
158 $n = 0;
159 while(($file=readdir($dh))!==false) {
160 if($file=='.' || $file=='..') continue;
161 $n++;
162 $data = $this->localdirsize($dir.'/'.$file);
163 $size += $data['size'];
164 $n += $data['howmany'];
165 }
166 closedir($dh);
167 return array('size'=>$size,'howmany'=>$n);
168 }
169 return array('size'=>0,'howmany'=>0);
170 }
171
172 }
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.
No preview for this file type
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!