4b30b756 by Gopal

Initial setup of Custom CRM

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

Too many changes to show.

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

1 custom/db/kstych_flexydial.sql.gz
2 application/storage/logs/
1 ../custom/.env
...\ No newline at end of file ...\ No newline at end of file
1 * text=auto
2 *.css linguist-vendored
3 *.less linguist-vendored
1 #!/bin/bash
2
3 export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
4
5
6 echo asterisk -rx "sip show channels";
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4 use DB;
5 use Config;
6
7 use App\Models\User;
8 use App\Models\Accesslog;
9
10 use App\Models\CRMCall;
11 use Schema;
12 use PDO;
13
14 use Illuminate\Database\Schema\Blueprint;
15
16 class relationship_tag extends Command {
17
18 /**
19 * The console command name.
20 *
21 * @var string
22 */
23 protected $signature = 'relationship_tag';
24
25 /**
26 * The console command description.
27 *
28 * @var string
29 */
30 protected $description = 'relationship_tag';
31
32 /**
33 * Execute the console command.
34 *
35 * @return mixed
36 */
37 public function handle()
38 {
39 $nowts=time();
40 echo "\n".date('Y-m-d H:i:s')."\n";
41
42 $tcol=0;$fieldsarr=array();$extrahdrarr=array();
43 $server_ip=env('app_ip');
44 $central_ip=env('central_ip');
45
46 $conn = array(
47 'driver' => 'mysql',
48 'host' => $central_ip,
49 'database' => env('DB_DATABASE', 'kstych_flexydial'),
50 'username' => env('DB_USERNAME', 'root'),
51 'password' => env('DB_PASSWORD', ''),
52 'charset' => 'utf8',
53 'collation' => 'utf8_unicode_ci',
54 'prefix' => '',
55 'options' => array(
56 PDO::ATTR_TIMEOUT => 5,
57 ),
58 );
59 Config::set("database.connections.conn", $conn);
60
61
62 if(DB::connection("conn")->getDatabaseName())
63 {
64
65 $relationshipList = DB::connection("conn")->select(DB::raw("SELECT * FROM relationship_tagging"));
66
67 $relationshipData = 0; $newService = 0; $newCategory = 0; $newSubCategory = 0;
68
69 foreach ($relationshipList as $list) {
70 $serviceId = 0;
71
72 $service = DB::select(DB::raw("SELECT * FROM relationship_service WHERE title = '$list->service'"));
73
74 if(count($service)){
75 $serviceId = $service[0]->id;
76 }else{
77 $addService = DB::table('relationship_service')->insert(['title'=>$list->service]);
78 $serviceId = $addService;
79 $newService++;
80 }
81
82 $category = DB::select(DB::raw("SELECT * FROM relationship_category WHERE service_id = $serviceId AND title = '$list->category'"));
83
84 if(count($category)){
85 $categoryId = $category[0]->id;
86 }else{
87 $addCategory = DB::table('relationship_category')->insert(['service_id'=>$serviceId,'title'=>$list->category]);
88 $categoryId = $addCategory;
89 $newCategory++;
90 }
91
92 $subCategory = DB::select(DB::raw("SELECT * FROM relationship_sub_category WHERE category_id = $categoryId AND title = '$list->sub_category'"));
93
94 if(count($subCategory)){
95 $subCategoryId = $subCategory[0]->id;
96 }else{
97 $addSubCategory = DB::table('relationship_sub_category')->insert(['category_id'=>$categoryId,'title'=>$list->sub_category]);
98 $subCategoryId = $addSubCategory;
99 $newSubCategory++;
100 }
101 //DB::table('relationship_tagging')->where('id', $list->id)->update(['status'=>'InActive']);
102 $relationshipData++;
103 }
104 echo "Total ".$relationshipData." data process and ". $newService." service, ".$newCategory." category, ".$newSubCategory." sub category added";
105
106 DB::connection("conn")->disconnect();
107
108 }
109
110 }
111
112
113 }
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 CreportEight extends Command {
18
19 /**
20 * The console command name.
21 *
22 * @var string
23 */
24 protected $signature = 'CreportEight';
25
26 /**
27 * The console command description.
28 *
29 * @var string
30 */
31 protected $description = 'App Main Daily Task for CreportEight';
32
33 /**
34 * Execute the console command.
35 *
36 * @return mixed
37 */
38 public function handle()
39 {
40 $nowts=time();
41 echo "\n".date('Y-m-d H:i:s')."\n";
42
43 $logdate=strtotime('0 day');
44
45 $tcol=0;$fieldsarr=array();$extrahdrarr=array();
46 $central_ip=env('central_ip');
47 $server_ip=env('app_ip');
48 $calllog_report = "calllog_report_".date("d_m_Y");
49
50 $conn = array(
51 'driver' => 'mysql',
52 'host' => $central_ip,
53 'database' => env('DB_DATABASE', 'kstych_flexydial'),
54 'username' => env('DB_USERNAME', 'root'),
55 'password' => env('DB_PASSWORD', ''),
56 'charset' => 'utf8',
57 'collation' => 'utf8_unicode_ci',
58 'prefix' => '',
59 'options' => array(
60 PDO::ATTR_TIMEOUT => 5,
61 ),
62 );
63 Config::set("database.connections.conn", $conn);
64
65 DB::connection("conn")->getDatabaseName();
66
67 $serverclist=DB::connection("conn")->select(DB::raw("select id from server_details where server_ip='$server_ip'"));
68 $server_id=$serverclist[0]->id;
69 if($server_id<10){
70 $server_id="0".$server_id;
71 }
72
73
74 $maxid=DB::connection("conn")->select(DB::raw("SELECT max(crmcall_id) as maxid from $calllog_report where server='$server_id'"));
75
76 $maxids=$maxid[0]->maxid;
77
78 $alist=DB::select(DB::raw("SELECT * from crmcalls where id>'$maxids' and created_at>'".date("Y-m-d")."' and created_at<'".date("Y-m-d H:i:s",$logdate-(60*60))."'"));
79
80 //$alist=DB::select(DB::raw("SELECT * from crmcalls where id>'$maxids' and created_at<'".date("Y-m-d H:i:s",$logdate-(60*60))."'"));
81
82 $userarr=array();
83 foreach($alist as $aline)
84 {
85 $setstrarr=array();
86
87
88 $clientcode="";$currentstatus="";$legalstatus="";$record_id="";
89 if($aline->crm_id>0)
90 {
91 $user=DB::select(DB::raw("select id,clientcode,currentstatus,legalstatus from records where id='".$aline->crm_id."' limit 1;"));
92 if(isset($user[0]))
93 {
94 $record_id=$user[0]->id;
95 $clientcode=$user[0]->clientcode;
96 $currentstatus=$user[0]->currentstatus;
97 $legalstatus=$user[0]->legalstatus;
98 }
99 }
100 $tpostdata=json_decode($aline->data,true);
101 $fulldate=date("Y-m-d H:i:s",strtotime($aline->created_at)+330*60);
102 $talktime=$aline->talkSec+$aline->recstartSec+$aline->recendSec;
103 $length=round(($aline->waitSec+$aline->callSec+$talktime+$aline->dispoSec)/1000,2);
104
105 if(!isset($userarr[$aline->user_id])&&$aline->user_id>0)$userarr[$aline->user_id]=User::find($aline->user_id);
106 $dispname="";if(isset($userarr[$aline->user_id]))$dispname=$userarr[$aline->user_id]->dispname();
107 $username="";if(isset($userarr[$aline->user_id]))$username=$userarr[$aline->user_id]->username;
108 $globalid=$server_id.$record_id;
109 $setstrarr[]="server='$server_id'";
110 $setstrarr[]="record_id='$record_id'";
111 $setstrarr[]="crmcall_id='$aline->id'";
112 $countid=DB::connection("conn")->select(DB::raw("SELECT count(crmcall_id) as countid from $calllog_report where server='$server_id' and crmcall_id='$aline->id'"));
113 $countids=$countid[0]->countid;
114 if($countids>0){continue;}
115 $setstrarr[]="globalid='$globalid'";
116 $setstrarr[]="start='$fulldate'";
117 $setstrarr[]="length='$length'";
118 $setstrarr[]="user='$username'";
119 $setstrarr[]="name='$dispname'";
120 $setstrarr[]="dispo='$aline->userstatus'";
121 $setstrarr[]="subdispo='$aline->usersubstatus'";
122 $setstrarr[]="callback='$aline->usercallback'";
123
124 $setstrarr[]="number='$aline->number'";
125 $setstrarr[]="clientcode='$clientcode'";
126 $setstrarr[]="currentstatus='$currentstatus'";
127 $setstrarr[]="legalstatus='$legalstatus'";
128 $setstrarr[]="client='$aline->client'";
129 $setstrarr[]="department='$aline->department'";
130 $setstrarr[]="state='$aline->state'";
131 $setstrarr[]="hsource='$aline->hsource'";
132
133 $setstrarr[]="type='$aline->type'";
134 $setstrarr[]="status='$aline->status'";
135 $setstrarr[]="statuscode='$aline->statuscode'";
136 $setstrarr[]="statusstr='$aline->substatus'";
137 $setstrarr[]="dialline='$aline->dialline_id'";
138 $setstrarr[]="did='$aline->did'";
139 $setstrarr[]="waitsec='".round($aline->waitSec/1000,2)."'";
140 $setstrarr[]="callsec='".round($aline->callSec/1000,2)."'";
141 $setstrarr[]="talksec='".round($talktime/1000,2)."'";
142 $setstrarr[]="disposec='".round($aline->dispoSec/1000,2)."'";
143 $setstrarr[]="remarks='".str_replace("'","",$aline->userremarks)."'";
144 $setstrarr[]="userdata='$aline->userdata'";
145 $setstrarr[]="attempt='$aline->attempt'";
146
147 $setstr=implode(",",$setstrarr);
148 DB::connection("conn")->insert(DB::raw("insert into ".$calllog_report." set $setstr"));
149 }
150
151 }
152 }
153
154
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4
5 use DB;
6 use App\Models\RelationshipService;
7 use App\Models\RelationshipCategory;
8 use App\Models\RelationshipSubCategory;
9
10 use Config;
11 use Schema;
12 use PDO;
13
14 use Illuminate\Database\Schema\Blueprint;
15
16 class relationship_tag extends Command {
17
18 /**
19 * The console command name.
20 *
21 * @var string
22 */
23 protected $signature = 'relationship_tag';
24
25 /**
26 * The console command description.
27 *
28 * @var string
29 */
30 protected $description = 'relationship_tag';
31
32 /**
33 * Execute the console command.
34 *
35 * @return mixed
36 */
37 public function handle()
38 {
39 $nowts=time();
40
41 echo date('Y-m-d H:i:s')."\n";
42
43 $tcol=0;$fieldsarr=array();$extrahdrarr=array();
44 $server_ip=env('app_ip');
45 $central_ip=env('central_ip');
46
47 $conn = array(
48 'driver' => 'mysql',
49 'host' => $central_ip,
50 'database' => env('DB_DATABASE', 'kstych_flexydial'),
51 'username' => env('DB_USERNAME', 'root'),
52 'password' => env('DB_PASSWORD', ''),
53 'charset' => 'utf8',
54 'collation' => 'utf8_unicode_ci',
55 'prefix' => '',
56 'options' => array(
57 PDO::ATTR_TIMEOUT => 5,
58 ),
59 );
60
61 Config::set("database.connections.conn", $conn);
62
63 if(DB::connection("conn")->getDatabaseName())
64 {
65 $relationshipList = DB::connection("conn")->select(DB::raw("SELECT * FROM relationship_tagging"));
66
67 $relationshipData = 0; $newService = 0; $newCategory = 0; $newSubCategory = 0;
68
69 foreach ($relationshipList as $list) {
70 $service = RelationshipService::where('title','=',$list->service)->first();
71
72 if(count($service)){
73 $serviceId = $service->id;
74
75 }else{
76 $addService = RelationshipService::create(['title'=>$list->service]);
77 $serviceId = $addService->id;
78 $newService++;
79 }
80 //echo $list->service." : ".$serviceId." - ";
81
82 $category = RelationshipCategory::where('service_id','=',$serviceId)->where('title','=',$list->category)->first();
83
84 if(count($category)){
85 $categoryId = $category->id;
86
87 }else{
88 $addCategory = RelationshipCategory::create(['service_id'=>$serviceId,'title'=>$list->category]);
89 $categoryId = $addCategory->id;
90 $newCategory++;
91 }
92 //echo $list->category." : ".$categoryId." - ";
93
94 $subCategory = RelationshipSubCategory::where('category_id','=',$categoryId)->where('title','=',$list->sub_category)->first();
95
96 if(count($subCategory)){
97 $subCategoryId = $subCategory->id;
98 $updateSubCategory = DB::table('relationship_sub_category')->where('category_id','=',$categoryId)->where('title','=',$list->sub_category)->update(['status'=>$list->status]);
99 }else{
100 $addSubCategory = RelationshipSubCategory::create(['category_id'=>$categoryId,'title'=>$list->sub_category,'status'=>$list->status]);
101 $subCategoryId = $addSubCategory->id;
102 $newSubCategory++;
103 }
104 echo $list->sub_category." : ".$subCategoryId."\n";
105
106 //DB::table('relationship_tagging')->where('id', $list->id)->update(['status'=>'InActive']);
107 $relationshipData++;
108 }
109 echo "Total ".$relationshipData." data process and ". $newService." service, ".$newCategory." category, ".$newSubCategory." sub category added\n";
110
111 DB::connection("conn")->disconnect();
112
113 }
114
115 }
116
117 }
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4
5 use DB;
6 use App\Models\RelationshipService;
7 use App\Models\RelationshipCategory;
8 use App\Models\RelationshipSubCategory;
9
10 use Config;
11 use Schema;
12 use PDO;
13
14 use Illuminate\Database\Schema\Blueprint;
15
16 class relationship_tag extends Command {
17
18 /**
19 * The console command name.
20 *
21 * @var string
22 */
23 protected $signature = 'relationship_tag';
24
25 /**
26 * The console command description.
27 *
28 * @var string
29 */
30 protected $description = 'relationship_tag';
31
32 /**
33 * Execute the console command.
34 *
35 * @return mixed
36 */
37 public function handle()
38 {
39 $nowts=time();
40
41 echo date('Y-m-d H:i:s')."\n";
42
43 $tcol=0;$fieldsarr=array();$extrahdrarr=array();
44 $server_ip=env('app_ip');
45 $central_ip=env('central_ip');
46
47 $conn = array(
48 'driver' => 'mysql',
49 'host' => $central_ip,
50 'database' => env('DB_DATABASE', 'kstych_flexydial'),
51 'username' => env('DB_USERNAME', 'root'),
52 'password' => env('DB_PASSWORD', ''),
53 'charset' => 'utf8',
54 'collation' => 'utf8_unicode_ci',
55 'prefix' => '',
56 'options' => array(
57 PDO::ATTR_TIMEOUT => 5,
58 ),
59 );
60
61 Config::set("database.connections.conn", $conn);
62
63 if(DB::connection("conn")->getDatabaseName())
64 {
65
66 DB::table('relationship_service')->truncate();
67 DB::table('relationship_category')->truncate();
68 DB::table('relationship_sub_category')->truncate();
69
70 $relationshipList = DB::connection("conn")->select(DB::raw("SELECT * FROM relationship_tagging"));
71
72 $relationshipData = 0; $newService = 0; $newCategory = 0; $newSubCategory = 0;
73
74 foreach ($relationshipList as $list) {
75 $service = RelationshipService::where('title','=',$list->service)->first();
76
77 if(count($service)){
78 $serviceId = $service->id;
79
80 }else{
81 $addService = RelationshipService::create(['title'=>$list->service]);
82 $serviceId = $addService->id;
83 $newService++;
84 }
85 //echo $list->service." : ".$serviceId." - ";
86
87 $category = RelationshipCategory::where('service_id','=',$serviceId)->where('title','=',$list->category)->first();
88
89 if(count($category)){
90 $categoryId = $category->id;
91
92 }else{
93 $addCategory = RelationshipCategory::create(['service_id'=>$serviceId,'title'=>$list->category]);
94 $categoryId = $addCategory->id;
95 $newCategory++;
96 }
97 //echo $list->category." : ".$categoryId." - ";
98
99 $subCategory = RelationshipSubCategory::where('category_id','=',$categoryId)->where('title','=',$list->sub_category)->first();
100
101 if(count($subCategory)){
102 $subCategoryId = $subCategory->id;
103 //$updateSubCategory = DB::table('relationship_sub_category')->where('category_id','=',$categoryId)->where('title','=',$list->sub_category)->update(['status'=>$list->status]);
104 }else{
105 $addSubCategory = RelationshipSubCategory::create(['category_id'=>$categoryId,'title'=>$list->sub_category,'status'=>$list->status]);
106 $subCategoryId = $addSubCategory->id;
107 $newSubCategory++;
108 }
109 echo $list->sub_category." : ".$subCategoryId."\n";
110
111 //DB::table('relationship_tagging')->where('id', $list->id)->update(['status'=>'InActive']);
112 $relationshipData++;
113 }
114 echo "Total ".$relationshipData." data process and ". $newService." service, ".$newCategory." category, ".$newSubCategory." sub category added\n";
115
116 DB::connection("conn")->disconnect();
117
118 }
119
120 }
121
122 }
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 CreportEight extends Command {
18
19 /**
20 * The console command name.
21 *
22 * @var string
23 */
24 protected $signature = 'CreportEight';
25
26 /**
27 * The console command description.
28 *
29 * @var string
30 */
31 protected $description = 'App Main Daily Task for CreportEight';
32
33 /**
34 * Execute the console command.
35 *
36 * @return mixed
37 */
38 public function handle()
39 {
40 $nowts=time();
41 $date=date('F_Y');
42 echo "\n".date('Y-m-d H:i:s')."\n";
43
44 $logdate=strtotime('0 day');
45
46 $tcol=0;$fieldsarr=array();$extrahdrarr=array();
47 $central_ip=env('central_ip');
48 $server_ip=env('app_ip');
49 //$calllog_report = "calllog_report_".date("d_m_Y");
50 $calllog_report = "calllog_report_".$date;
51 $conn = array(
52 'driver' => 'mysql',
53 'host' => $central_ip,
54 'database' => env('DB_DATABASE', 'kstych_flexydial'),
55 'username' => env('DB_USERNAME', 'root'),
56 'password' => env('DB_PASSWORD', ''),
57 'charset' => 'utf8',
58 'collation' => 'utf8_unicode_ci',
59 'prefix' => '',
60 'options' => array(
61 PDO::ATTR_TIMEOUT => 5,
62 ),
63 );
64 Config::set("database.connections.conn", $conn);
65
66 DB::connection("conn")->getDatabaseName();
67
68 $serverclist=DB::connection("conn")->select(DB::raw("select id from server_details where server_ip='$server_ip'"));
69 $server_id=$serverclist[0]->id;
70 if($server_id<10){
71 $server_id="0".$server_id;
72 }
73
74
75 $maxid=DB::connection("conn")->select(DB::raw("SELECT max(crmcall_id) as maxid from $calllog_report where server='$server_id'"));
76
77 $maxids=$maxid[0]->maxid;
78
79 $alist=DB::select(DB::raw("SELECT * from crmcalls where id>'$maxids' and created_at<'".date("Y-m-d H:i:s",$logdate-(60*60))."'"));
80 //$alist=DB::select(DB::raw("SELECT * from crmcalls where id>'$maxids' and created_at>'".date("Y-m-d")."' and created_at<'".date("Y-m-d H:i:s",$logdate-(60*60))."'"));
81
82 //$alist=DB::select(DB::raw("SELECT * from crmcalls where id>'$maxids' and created_at<'".date("Y-m-d H:i:s",$logdate-(60*60))."'"));
83
84 $userarr=array();
85 foreach($alist as $aline)
86 {
87 $setstrarr=array();
88
89
90 $clientcode="";$currentstatus="";$legalstatus="";$record_id="";
91 if($aline->crm_id>0)
92 {
93 $user=DB::select(DB::raw("select id,clientcode,currentstatus,legalstatus from records where id='".$aline->crm_id."' limit 1;"));
94 if(isset($user[0]))
95 {
96 $record_id=$user[0]->id;
97 $clientcode=$user[0]->clientcode;
98 $currentstatus=$user[0]->currentstatus;
99 $legalstatus=$user[0]->legalstatus;
100 }
101 }
102 $tpostdata=json_decode($aline->data,true);
103 $fulldate=date("Y-m-d H:i:s",strtotime($aline->created_at)+330*60);
104 $talktime=$aline->talkSec+$aline->recstartSec+$aline->recendSec;
105 $length=round(($aline->waitSec+$aline->callSec+$talktime+$aline->dispoSec)/1000,2);
106
107 if(!isset($userarr[$aline->user_id])&&$aline->user_id>0)$userarr[$aline->user_id]=User::find($aline->user_id);
108 $dispname="";if(isset($userarr[$aline->user_id]))$dispname=$userarr[$aline->user_id]->dispname();
109 $username="";if(isset($userarr[$aline->user_id]))$username=$userarr[$aline->user_id]->username;
110 $globalid=$server_id.$record_id;
111 $setstrarr[]="server='$server_id'";
112 $setstrarr[]="record_id='$record_id'";
113 $setstrarr[]="crmcall_id='$aline->id'";
114 $setstrarr[]="globalid='$globalid'";
115 $setstrarr[]="created_at='$aline->created_at'";
116 $setstrarr[]="start='$fulldate'";
117 $setstrarr[]="length='$length'";
118 $setstrarr[]="user='$username'";
119 $setstrarr[]="name='$dispname'";
120 $setstrarr[]="dispo='$aline->userstatus'";
121 $setstrarr[]="subdispo='$aline->usersubstatus'";
122 $setstrarr[]="callback='$aline->usercallback'";
123
124 $setstrarr[]="number='$aline->number'";
125 $setstrarr[]="clientcode='$clientcode'";
126 $setstrarr[]="currentstatus='$currentstatus'";
127 $setstrarr[]="legalstatus='$legalstatus'";
128 $setstrarr[]="client='$aline->client'";
129 $setstrarr[]="department='$aline->department'";
130 $setstrarr[]="state='$aline->state'";
131 $setstrarr[]="hsource='$aline->hsource'";
132
133 $setstrarr[]="type='$aline->type'";
134 $setstrarr[]="status='$aline->status'";
135 $setstrarr[]="statuscode='$aline->statuscode'";
136 $setstrarr[]="statusstr='$aline->substatus'";
137 $setstrarr[]="dialline='$aline->dialline_id'";
138 $setstrarr[]="did='$aline->did'";
139 $setstrarr[]="waitsec='".round($aline->waitSec/1000,2)."'";
140 $setstrarr[]="callsec='".round($aline->callSec/1000,2)."'";
141 $setstrarr[]="talksec='".round($talktime/1000,2)."'";
142 $setstrarr[]="disposec='".round($aline->dispoSec/1000,2)."'";
143 $setstrarr[]="remarks='".str_replace("'","",$aline->userremarks)."'";
144 $setstrarr[]="userdata='$aline->userdata'";
145 $setstrarr[]="attempt='$aline->attempt'";
146 $setstrarr[]="priority='$aline->priority'";
147 $setstrarr[]="question='$aline->question'";
148
149 $setstr=implode(",",$setstrarr);
150 DB::connection("conn")->insert(DB::raw("insert into ".$calllog_report." set $setstr"));
151 }
152
153 }
154 }
155
156
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 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.state = c.state,ca.statuscode = c.statuscode,ca.status = c.status,ca.substatus = c.substatus,ca.callSec = c.callSec,ca.ts_Talk = c.ts_Talk,ca.ts_Recstart = c.ts_Recstart,ca.ts_Recend = c.ts_Recend,ca.ts_Dispo = c.ts_Dispo,ca.ts_Close = c.ts_Close,ca.dispoSec = c.dispoSec,ca.recstartSec=c.recstartSec,ca.data = c.data,ca.recsize = c.recsize,ca.userstatus = c.userstatus,ca.usersubstatus = c.usersubstatus,ca.usercallback = c.usercallback ,ca.userremarks = c.userremarks,ca.attempt = c.attempt,ca.priority = c.priority,ca.question = c.question"));
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-2*24*60*60))->update(array('postdata'=>'','queries'=>''));
42 Accesslog::where('endtime','<',date("Y-m-d H:i:s",$nowts-2*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 DB;
5 use Config;
6
7 use App\Models\User;
8 use App\Models\Accesslog;
9
10 use App\Models\CRMCall;
11 use Schema;
12 use PDO;
13
14 use Illuminate\Database\Schema\Blueprint;
15
16 class Userlog_data extends Command {
17
18 /**
19 * The console command name.
20 *
21 * @var string
22 */
23 protected $signature = 'Userlog_data';
24
25 /**
26 * The console command description.
27 *
28 * @var string
29 */
30 protected $description = 'Userlog_data';
31
32 /**
33 * Execute the console command.
34 *
35 * @return mixed
36 */
37 public function handle()
38 {
39 $nowts=time();
40 echo "\n".date('Y-m-d')."\n";
41
42 $logdate=strtotime('-1 day');
43 $tcol=0;$fieldsarr=array();$extrahdrarr=array();
44 $server_ip=env('app_ip');
45 $central_ip=env('central_ip');
46
47 $conn = array(
48 'driver' => 'mysql',
49 'host' => $central_ip,
50 'database' => env('DB_DATABASE', 'kstych_flexydial'),
51 'username' => env('DB_USERNAME', 'root'),
52 'password' => env('DB_PASSWORD', ''),
53 'charset' => 'utf8',
54 'collation' => 'utf8_unicode_ci',
55 'prefix' => '',
56 'options' => array(
57 PDO::ATTR_TIMEOUT => 5,
58 ),
59 );
60 Config::set("database.connections.conn", $conn);
61 if(DB::connection("conn")->getDatabaseName())
62 {
63 $serverclist=DB::connection("conn")->select(DB::raw("select id from server_details where server_ip='$server_ip'"));
64 $server_id=$serverclist[0]->id;
65 if($server_id<10){
66 $server_id="0".$server_id;
67 }
68
69
70 $i=0;
71
72
73 $ulist=DB::select(DB::raw("select * from users WHERE 1"));
74 foreach($ulist as $uline) {
75 $users[$uline->id] = $uline->username;
76 }
77 if($alist=DB::select(DB::raw("select * from userlogs WHERE created_at>'".date("Y-m-d",$logdate)."' and created_at<'".date("Y-m-d",$logdate+24*60*60)."'"))){
78
79
80 foreach($alist as $aline) {
81 $i++;
82 $global_id = $server_id . $i;
83 if($aline->enddate=='0000-00-00'|| $aline->endtime=='00:00:00' || $aline->durationsec=='0')
84 {
85 $enddatetime=date("Y-m-d H:i:s",strtotime($aline->updated_at));
86 $enddate=explode(" ",$enddatetime)[0];
87 $endtime=explode(" ",$enddatetime)[1];
88 $durationsec=date("Y-m-d H:i:s",strtotime($endtime-$aline->starttime));
89 }
90 else
91 {
92 $enddate=$aline->enddate;
93 $endtime=$aline->endtime;
94 $durationsec=$aline->durationsec;
95 }
96
97 $rowdata = array('server'=>$server_id,'server_ip'=>$server_ip,'global_id'=>$global_id,'id'=>$aline->id,
98 'created_at'=>$aline->created_at,'updated_at'=>$aline->updated_at,'user_id'=>$aline->user_id,'user'=>$users[$aline->user_id],
99 'startdate'=>$aline->startdate,'starttime'=>$aline->starttime,'enddate'=>$enddate,'endtime'=>$endtime,
100 'durationsec'=>$durationsec,'data'=>$aline->data,'group'=>$aline->group,'login'=>'','dialnext'=>'','dialnext-agentbriefing'=>'','dialnext-downtime'=>'','dialnext-floorannouncements'=>'','dialnext-incoming'=>'','dialnext-lunchbreak'=>'','dialnext-manual'=>'','dialnext-notready'=>'','dialnext-qualityfeedback'=>'','dialnext-teabreak'=>'','dialnext-teammeeting'=>'','dialnext-utilitybreak'=>'','manual'=>'','manual-agentbriefing'=>'','manual-agentbriefing'=>'','manual-downtime'=>'','manual-floorannouncements'=>'','manual-incoming'=>'','manual-lunchbreak'=>'','manual-manual'=>'','manual-notready'=>'','manual-qualityfeedback'=>'','manual-teabreak'=>'','manual-teammeeting'=>'','manual-utilitybreak'=>'','paused'=>'','paused-agentbriefing'=>'','paused-downtime'=>'','paused-floorannouncements'=>'','paused-incoming'=>'','paused-lunchbreak'=>'','paused-manual'=>'','paused-notready'=>'','paused-qualityfeedback'=>'','paused-teabreak'=>'','paused-teammeeting'=>'','paused-utilitybreak'=>'','paused-autowrapup'=>'','paused-wrapup'=>'','progressive'=>'','progressive-agentbriefing'=>'','progressive-agentbriefing'=>'','progressive-downtime'=>'','progressive-floorannouncements'=>'','progressive-incoming'=>'','progressive-lunchbreak'=>'','progressive-manual'=>'','progressive-notready'=>'','progressive-qualityfeedback'=>'','progressive-teabreak'=>'','progressive-teammeeting'=>'','progressive-utilitybreak'=>'','ready-incoming'=>''
101 );
102
103 $data=json_decode($aline->data,true);
104 foreach($data as $sipid=>$sdata)
105 {
106 $prets= isset($sdata[1]) ? $sdata[1] : (strtotime($aline->startdate . " " . $aline->starttime)+19600)*1000;
107 if(isset($sdata['states']))
108 {
109 $previous="login";
110 foreach($sdata['states'] as $fts=>$states)
111 {
112 if($states[0] != 1)
113 {
114 $rowdata[$previous] +=round(($fts-$prets)/1000,2);
115
116 $previous = (trim($states[1]) != '') ? strtolower($states[0]."-".$states[1]) : strtolower($states[0]);
117 $prets=$fts;
118 }
119
120 }
121 $rowdata[$previous] += round(($sdata['ts']-$prets)/1000,2);
122 }
123 }
124 $rowdata["login"] = $aline->durationsec;
125
126 $rowdata['not-ready']=$rowdata['paused-agentbriefing']+$rowdata['paused-autowrapup']+$rowdata['paused-downtime']+$rowdata['paused-floorannouncements']+$rowdata['paused-lunchbreak']+$rowdata['paused-notready']+$rowdata['paused-qualityfeedback']+$rowdata['paused-teammeeting']+$rowdata['paused-teabreak']+$rowdata['paused-utilitybreak'];
127
128
129 $key_value = '';
130 foreach($rowdata AS $key=>$value) {
131 if($key != 1)
132 $key_value .= "`$key` = '$value', ";
133 }
134
135 $startTime=$aline->startdate." ".$aline->starttime;
136 $endTime=$aline->enddate." ".$aline->endtime;
137
138 $crmCalls=DB::select(DB::raw("select user_id,type,ts_Wait,ts_Call,ts_Talk,ts_Recstart,ts_Recend,ts_Dispo,ts_Close from crmcalls WHERE updated_at>='".$startTime."' and updated_at<'".$endTime."' and user_id='".$aline->user_id."'"));
139
140 $ts_Wait=0;$ts_Call=0;$ts_Talk=0;$ts_Dispo=0;
141 $progTs_Wait=0;$progTs_Call=0;$progTs_Talk=0;$progTs_Dispo=0;
142 $manTs_Wait=0;$manTs_Call=0;$manTs_Talk=0;$manTs_Dispo=0;
143 $inbTs_Wait=0;$inbTs_Call=0;$inbTs_Talk=0;$inbTs_Dispo=0;
144 $tt_prog=0;$tt_man=0;$tt_inb=0;
145
146 if($crmCalls!=null){
147 foreach($crmCalls as $crmCall){
148 $ts_Wait += round(($crmCall->ts_Call - $crmCall->ts_Wait)/1000,2);
149 $ts_Call += round(($crmCall->ts_Talk - $crmCall->ts_Call)/1000,2);
150 $ts_Talk += round(($crmCall->ts_Dispo - $crmCall->ts_Talk)/1000,2);
151 $ts_Dispo += round(($crmCall->ts_Close - $crmCall->ts_Dispo)/1000,2);
152
153 if($crmCall->type == 'Progressive')
154 {
155 $progTs_Wait += round(($crmCall->ts_Call - $crmCall->ts_Wait)/1000,2);
156 $progTs_Call += round(($crmCall->ts_Talk - $crmCall->ts_Call)/1000,2);
157 $progTs_Talk += round(($crmCall->ts_Dispo - $crmCall->ts_Talk)/1000,2);
158 $progTs_Dispo += round(($crmCall->ts_Close - $crmCall->ts_Dispo)/1000,2);
159 }
160
161 if($crmCall->type == 'Manual')
162 {
163 $manTs_Wait += round(($crmCall->ts_Call - $crmCall->ts_Wait)/1000,2);
164 $manTs_Call += round(($crmCall->ts_Talk - $crmCall->ts_Call)/1000,2);
165 $manTs_Talk += round(($crmCall->ts_Dispo - $crmCall->ts_Talk)/1000,2);
166 $manTs_Dispo += round(($crmCall->ts_Close - $crmCall->ts_Dispo)/1000,2);
167 }
168
169 if($crmCall->type == 'Inbound')
170 {
171 $inbTs_Wait += round(($crmCall->ts_Call - $crmCall->ts_Wait)/1000,2);
172 $inbTs_Call += round(($crmCall->ts_Talk - $crmCall->ts_Call)/1000,2);
173 $inbTs_Talk += round(($crmCall->ts_Dispo - $crmCall->ts_Talk)/1000,2);
174 $inbTs_Dispo += round(($crmCall->ts_Close - $crmCall->ts_Dispo)/1000,2);
175 }
176 }
177 }
178
179 $tt_prog = $progTs_Wait + $progTs_Call + $progTs_Talk + $progTs_Dispo;
180 $tt_man = $manTs_Wait + $manTs_Call + $manTs_Talk + $manTs_Dispo;
181 $tt_inb = $inbTs_Wait + $inbTs_Call + $inbTs_Talk + $inbTs_Dispo;
182
183 $prod_TOS = $ts_Wait + $ts_Call + $ts_Talk + $ts_Dispo;
184
185 $key_value .= "`tt_prog` = '$tt_prog', ";
186 $key_value .= "`tt_man` = '$tt_man', ";
187 $key_value .= "`tt_inb` = '$tt_inb', ";
188
189 $key_value .= "`ts_Wait` = '$ts_Wait', ";
190 $key_value .= "`ts_Call` = '$ts_Call', ";
191 $key_value .= "`ts_Talk` = '$ts_Talk', ";
192 $key_value .= "`ts_Dispo` = '$ts_Dispo', ";
193 $key_value .= "`progts_Wait` = '$progTs_Wait', ";
194 $key_value .= "`progts_Call` = '$progTs_Call', ";
195 $key_value .= "`progts_Talk` = '$progTs_Talk', ";
196 $key_value .= "`progts_Dispo` = '$progTs_Dispo', ";
197 $key_value .= "`mants_Wait` = '$manTs_Wait', ";
198 $key_value .= "`mants_Call` = '$manTs_Call', ";
199 $key_value .= "`mants_Talk` = '$manTs_Talk', ";
200 $key_value .= "`mants_Dispo` = '$manTs_Dispo', ";
201 $key_value .= "`incts_Wait` = '$inbTs_Wait', ";
202 $key_value .= "`incts_Call` = '$inbTs_Call', ";
203 $key_value .= "`incts_Talk` = '$inbTs_Talk', ";
204 $key_value .= "`incts_Dispo` = '$inbTs_Dispo', ";
205 $key_value .= "`prod_tos` = '$prod_TOS', ";
206
207
208
209 $key_value = substr($key_value, 0, -2);
210
211 $userlogsTable = "userlogs_".date("d_m_Y",$logdate);
212 DB::connection("conn")->insert(DB::raw("INSERT INTO ".$userlogsTable." SET $key_value"));
213
214 }
215
216 }
217 }
218 }
219 }
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 echo "1";
48 echo "\n".date('Y-m-d H:i:s')."\n";
49 $server_ip=env('app_ip');
50 $central_ip=env('central_ip');
51
52 $wakka = new KHRMSLib();
53
54 $kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
55 $kformlib->gthis=$wakka;
56
57 $themehome=$wakka->GetThemePath('/');
58 $updatetime=time();
59
60 $clientlst=$wakka->GetBBBUserData("clientslist");
61
62 $isadmin=$wakka->IsAdmin();
63 $username=$wakka->GetUserName();
64 $triggers=Input::get("triggers");
65 $tmpstr=explode(",",$kformlib->HRFiledsStr);
66
67 $success="";$message="";$successcnt=0;$duplicatecount=0;
68
69
70 $conn = array(
71 'driver' => 'mysql',
72 'host' => $central_ip,
73 'database' => env('DB_DATABASE', 'kstych_flexydial'),
74 'username' => env('DB_USERNAME', 'root'),
75 'password' => env('DB_PASSWORD', 'yb9738z'),
76 'charset' => 'utf8',
77 'collation' => 'utf8_unicode_ci',
78 'prefix' => '',
79 'options' => array(
80 PDO::ATTR_TIMEOUT => 5,
81 ),
82 );
83 Config::set("database.connections.conn", $conn);
84
85 DB::connection("conn")->getDatabaseName();
86
87 $serverclist=DB::connection("conn")->select(DB::raw("select location from server_details where server_ip='$server_ip'"));
88 $location=$serverclist[0]->location;
89 echo $central_ip;
90 echo $location;
91 $excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat where SERVER_IP='$server_ip' order by auto_id asc limit 0,20000"));
92 $conn='';
93
94 $tcol=0;$fieldsarr=array();$extrahdrarr=array();
95
96 foreach($excelarray as $key => $array){
97 $excelarray[$key] = (array)$array;
98 }
99
100 $highestColumn = DB::connection("conn")->select(DB::raw("select count(*) as cnt from information_schema.columns where table_name='bz_record_upload_uat'"));
101 $highestColumn = $highestColumn[0]->cnt;
102
103 $highestrow = count($excelarray);
104
105 $flag = 0;
106 $editflag=0;
107
108 for($i=0;$i<$highestrow;$i++)
109 {
110 if($excelarray[$i]["id"]!="")
111 {
112 if($excelarray[$i]["id"]=="CREATE")
113 {
114 $excelarray[$i]["id"]=$wakka->Query("insert into","","records",array('created'=>date('Y-m-d H:i:s')));
115 }
116 else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
117 if($wakka->getCount("records","id='".$excelarray[$i]["id"]."'")==1)
118 {
119 $empdata=$wakka->getPerson($excelarray[$i]["id"]);
120 $ppldata=$empdata["peopledata"];
121 $createdlog=$empdata['modifylog'];
122 $fdirty=$empdata['dirty'];
123
124 $createdlog[$updatetime]=$username."::";
125 $createdlog["updated"]=$updatetime;
126
127 $newdata=$ppldata;
128 foreach($excelarray[$i] as $key => $value)
129 {
130 if($value!="")
131 {
132 if("A".$ppldata[$key]!="A".$value)//forcing string comparrision //MAGIC
133 {
134 $value=str_replace("'"," ",$value);
135 if(strstr($createdlog[$updatetime],$key)==FALSE)$createdlog[$updatetime].="$key|".str_replace(array("|",",")," ",$ppldata[$key])."|".str_replace(array("|",",")," ",$value).",";
136
137 $fdirty[$key]=1;
138
139 $newdata[$key]=$value;
140 }
141 }
142 }
143
144 /*Start - Changes need to be done*/
145
146 if($excelarray[$i]["status"]==null)
147 {
148 $empdata['status'] = "rom";
149 }
150
151 if($excelarray[$i]["dialer_status"]==null)
152 {
153 $empdata['dialer_status'] = "rom";
154 }
155
156 if($excelarray[$i]["dialer_substatus"]==null)
157 {
158 $empdata['dialer_substatus'] = "rom";
159 }
160
161 /*End - Changes need to be done*/
162
163 $empdata["peopledata"]=$newdata;
164 $empdata['modifylog']=$createdlog;
165 $empdata['dirty']=$fdirty;
166
167 $wakka->setPerson($excelarray[$i]["id"],$empdata);
168 $excelarray[$i]['modified']=date('Y-m-d H:i:s');
169 $successArr[] = $excelarray[$i];
170
171 }
172 else
173 {
174 $reason = "";
175
176 $reason .= "Record ID is not on local server,";
177
178 $excelarray[$i]['server_ip'] =$server_ip;
179 $excelarray[$i]['location'] =$location;
180
181 if($excelarray[$i]["clientcode"]!="")
182 $excelarray[$i]['cust_id'] =$excelarray[$i]["clientcode"];
183 $excelarray[$i]['record_id'] = $excelarray[$i]["id"];
184
185 $excelarray[$i]['Reason'] = $reason;
186
187 $failureArr[] = $excelarray[$i];
188
189 }
190 }
191 else
192 {
193
194 $reason = "";
195
196 if($excelarray[$i]["id"]=="")
197 $reason .= "Column ID is blank,";
198
199 $excelarray[$i]['server_ip'] =$server_ip;
200 $excelarray[$i]['location'] =$location;
201
202 if($excelarray[$i]["clientcode"]!="")
203 $excelarray[$i]['cust_id'] =$excelarray[$i]["clientcode"];
204
205 $excelarray[$i]['Reason'] = $reason;
206
207 $failureArr[] = $excelarray[$i];
208
209 }
210
211 }
212 if(!empty($successArr)){
213 foreach($successArr as $succes)
214 {
215 $setSuccess=array();
216
217 $setSuccess[] = "server_ip='$server_ip'";
218 $setSuccess[] = "location='$location'";
219 $setSuccess[] = "record_id='".$succes['id']."'";
220 $setSuccess[] = "cust_id='".$succes['clientcode']."'";
221 $setSuccess[] = "modified='".$succes['modified']."'";
222
223 $setSuccess = implode(",",$setSuccess);
224
225 DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_success set $setSuccess"));
226 }
227 }
228 if(!empty($failureArr)){
229 foreach($failureArr as $failur)
230 {
231 $setFailure=array();
232
233 $setFailure[] = "server_ip='$server_ip'";
234 $setFailure[] = "location='$location'";
235 $setFailure[] = "cust_id='".$failur['clientcode']."'";
236 $setFailure[] = "record_id='".$failur['record_id']."'";
237 $setFailure[] = "reason='".$failur['Reason']."'";
238
239 $setFailure = implode(",",$setFailure);
240
241 DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_failure set $setFailure"));
242 }
243 }
244
245 DB::connection("conn")->disconnect();
246 }
247 }
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_1';
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 echo "2";
48 echo "\n".date('Y-m-d H:i:s')."\n";
49 $server_ip=env('app_ip');
50 $central_ip=env('central_ip');
51
52
53 $wakka = new KHRMSLib();
54
55 $kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
56 $kformlib->gthis=$wakka;
57
58 $themehome=$wakka->GetThemePath('/');
59 $updatetime=time();
60
61 $clientlst=$wakka->GetBBBUserData("clientslist");
62
63 $isadmin=$wakka->IsAdmin();
64 $username=$wakka->GetUserName();
65 $triggers=Input::get("triggers");
66 $tmpstr=explode(",",$kformlib->HRFiledsStr);
67
68 $success="";$message="";$successcnt=0;$duplicatecount=0;
69
70
71 $conn = array(
72 'driver' => 'mysql',
73 'host' => $central_ip,
74 'database' => env('DB_DATABASE', 'kstych_flexydial'),
75 'username' => env('DB_USERNAME', 'root'),
76 'password' => env('DB_PASSWORD', 'yb9738z'),
77 'charset' => 'utf8',
78 'collation' => 'utf8_unicode_ci',
79 'prefix' => '',
80 'options' => array(
81 PDO::ATTR_TIMEOUT => 5,
82 ),
83 );
84 Config::set("database.connections.conn", $conn);
85
86 DB::connection("conn")->getDatabaseName();
87
88 $serverclist=DB::connection("conn")->select(DB::raw("select location from server_details where server_ip='$server_ip'"));
89 $location=$serverclist[0]->location;
90
91
92 $excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat where SERVER_IP='$server_ip' order by auto_id asc limit 20001,40000"));
93
94 $conn='';
95
96 $tcol=0;$fieldsarr=array();$extrahdrarr=array();
97
98 foreach($excelarray as $key => $array){
99 $excelarray[$key] = (array)$array;
100 }
101
102 $highestColumn = DB::connection("conn")->select(DB::raw("select count(*) as cnt from information_schema.columns where table_name='bz_record_upload_uat'"));
103 $highestColumn = $highestColumn[0]->cnt;
104
105 $highestrow = count($excelarray);
106
107 $flag = 0;
108 $editflag=0;
109
110 for($i=0;$i<$highestrow;$i++)
111 {
112 if($excelarray[$i]["id"]!="")
113 {
114 if($excelarray[$i]["id"]=="CREATE")
115 {
116 $excelarray[$i]["id"]=$wakka->Query("insert into","","records",array('created'=>date('Y-m-d H:i:s')));
117 }
118 else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
119 if($wakka->getCount("records","id='".$excelarray[$i]["id"]."'")==1)
120 {
121 $empdata=$wakka->getPerson($excelarray[$i]["id"]);
122 $ppldata=$empdata["peopledata"];
123 $createdlog=$empdata['modifylog'];
124 $fdirty=$empdata['dirty'];
125
126 $createdlog[$updatetime]=$username."::";
127 $createdlog["updated"]=$updatetime;
128
129 $newdata=$ppldata;
130 foreach($excelarray[$i] as $key => $value)
131 {
132 if($value!="")
133 {
134 if("A".$ppldata[$key]!="A".$value)//forcing string comparrision //MAGIC
135 {
136 $value=str_replace("'"," ",$value);
137 if(strstr($createdlog[$updatetime],$key)==FALSE)$createdlog[$updatetime].="$key|".str_replace(array("|",",")," ",$ppldata[$key])."|".str_replace(array("|",",")," ",$value).",";
138
139 $fdirty[$key]=1;
140
141 $newdata[$key]=$value;
142 }
143 }
144 }
145
146 /*Start - Changes need to be done*/
147
148 if($excelarray[$i]["status"]==null)
149 {
150 $empdata['status'] = "rom";
151 }
152
153 if($excelarray[$i]["dialer_status"]==null)
154 {
155 $empdata['dialer_status'] = "rom";
156 }
157
158 if($excelarray[$i]["dialer_substatus"]==null)
159 {
160 $empdata['dialer_substatus'] = "rom";
161 }
162
163 /*End - Changes need to be done*/
164
165 $empdata["peopledata"]=$newdata;
166 $empdata['modifylog']=$createdlog;
167 $empdata['dirty']=$fdirty;
168
169 $wakka->setPerson($excelarray[$i]["id"],$empdata);
170 $excelarray[$i]['modified']=date('Y-m-d H:i:s');
171 $successArr[] = $excelarray[$i];
172
173 }
174 else
175 {
176 $reason = "";
177
178 $reason .= "Record ID is not on local server,";
179
180 $excelarray[$i]['server_ip'] =$server_ip;
181 $excelarray[$i]['location'] =$location;
182
183 if($excelarray[$i]["clientcode"]!="")
184 $excelarray[$i]['cust_id'] =$excelarray[$i]["clientcode"];
185 $excelarray[$i]['record_id'] = $excelarray[$i]["id"];
186
187 $excelarray[$i]['Reason'] = $reason;
188
189 $failureArr[] = $excelarray[$i];
190
191 }
192 }
193 else
194 {
195
196 $reason = "";
197
198 if($excelarray[$i]["id"]=="")
199 $reason .= "Column ID is blank,";
200
201 $excelarray[$i]['server_ip'] =$server_ip;
202 $excelarray[$i]['location'] =$location;
203
204 if($excelarray[$i]["clientcode"]!="")
205 $excelarray[$i]['cust_id'] =$excelarray[$i]["clientcode"];
206
207 $excelarray[$i]['Reason'] = $reason;
208
209 $failureArr[] = $excelarray[$i];
210
211 }
212
213 }
214 if(!empty($successArr)){
215 foreach($successArr as $succes)
216 {
217 $setSuccess=array();
218
219 $setSuccess[] = "server_ip='$server_ip'";
220 $setSuccess[] = "location='$location'";
221 $setSuccess[] = "record_id='".$succes['id']."'";
222 $setSuccess[] = "cust_id='".$succes['clientcode']."'";
223 $setSuccess[] = "modified='".$succes['modified']."'";
224
225 $setSuccess = implode(",",$setSuccess);
226
227 DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_success set $setSuccess"));
228 }
229 }
230 if(!empty($failureArr)){
231 foreach($failureArr as $failur)
232 {
233 $setFailure=array();
234
235 $setFailure[] = "server_ip='$server_ip'";
236 $setFailure[] = "location='$location'";
237 $setFailure[] = "cust_id='".$failur['clientcode']."'";
238 $setFailure[] = "record_id='".$failur['record_id']."'";
239 $setFailure[] = "reason='".$failur['Reason']."'";
240
241 $setFailure = implode(",",$setFailure);
242
243 DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_failure set $setFailure"));
244 }
245 }
246
247 DB::connection("conn")->disconnect();
248 }
249 }
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_2';
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 echo "3";
48 echo "\n".date('Y-m-d H:i:s')."\n";
49 $server_ip=env('app_ip');
50 $central_ip=env('central_ip');
51
52
53 $wakka = new KHRMSLib();
54
55 $kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
56 $kformlib->gthis=$wakka;
57
58 $themehome=$wakka->GetThemePath('/');
59 $updatetime=time();
60
61 $clientlst=$wakka->GetBBBUserData("clientslist");
62
63 $isadmin=$wakka->IsAdmin();
64 $username=$wakka->GetUserName();
65 $triggers=Input::get("triggers");
66 $tmpstr=explode(",",$kformlib->HRFiledsStr);
67
68 $success="";$message="";$successcnt=0;$duplicatecount=0;
69
70
71 $conn = array(
72 'driver' => 'mysql',
73 'host' => $central_ip,
74 'database' => env('DB_DATABASE', 'kstych_flexydial'),
75 'username' => env('DB_USERNAME', 'root'),
76 'password' => env('DB_PASSWORD', 'yb9738z'),
77 'charset' => 'utf8',
78 'collation' => 'utf8_unicode_ci',
79 'prefix' => '',
80 'options' => array(
81 PDO::ATTR_TIMEOUT => 5,
82 ),
83 );
84 Config::set("database.connections.conn", $conn);
85
86 DB::connection("conn")->getDatabaseName();
87
88 $serverclist=DB::connection("conn")->select(DB::raw("select location from server_details where server_ip='$server_ip'"));
89 $location=$serverclist[0]->location;
90
91
92 $excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat where SERVER_IP='$server_ip' order by auto_id asc limit 40001,60000"));
93
94 $conn='';
95
96 $tcol=0;$fieldsarr=array();$extrahdrarr=array();
97
98 foreach($excelarray as $key => $array){
99 $excelarray[$key] = (array)$array;
100 }
101
102 $highestColumn = DB::connection("conn")->select(DB::raw("select count(*) as cnt from information_schema.columns where table_name='bz_record_upload_uat'"));
103 $highestColumn = $highestColumn[0]->cnt;
104
105 $highestrow = count($excelarray);
106
107 $flag = 0;
108 $editflag=0;
109
110 for($i=0;$i<$highestrow;$i++)
111 {
112 if($excelarray[$i]["id"]!="")
113 {
114 if($excelarray[$i]["id"]=="CREATE")
115 {
116 $excelarray[$i]["id"]=$wakka->Query("insert into","","records",array('created'=>date('Y-m-d H:i:s')));
117 }
118 else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
119 if($wakka->getCount("records","id='".$excelarray[$i]["id"]."'")==1)
120 {
121 $empdata=$wakka->getPerson($excelarray[$i]["id"]);
122 $ppldata=$empdata["peopledata"];
123 $createdlog=$empdata['modifylog'];
124 $fdirty=$empdata['dirty'];
125
126 $createdlog[$updatetime]=$username."::";
127 $createdlog["updated"]=$updatetime;
128
129 $newdata=$ppldata;
130 foreach($excelarray[$i] as $key => $value)
131 {
132 if($value!="")
133 {
134 if("A".$ppldata[$key]!="A".$value)//forcing string comparrision //MAGIC
135 {
136 $value=str_replace("'"," ",$value);
137 if(strstr($createdlog[$updatetime],$key)==FALSE)$createdlog[$updatetime].="$key|".str_replace(array("|",",")," ",$ppldata[$key])."|".str_replace(array("|",",")," ",$value).",";
138
139 $fdirty[$key]=1;
140
141 $newdata[$key]=$value;
142 }
143 }
144 }
145
146 /*Start - Changes need to be done*/
147
148 if($excelarray[$i]["status"]==null)
149 {
150 $empdata['status'] = "rom";
151 }
152
153 if($excelarray[$i]["dialer_status"]==null)
154 {
155 $empdata['dialer_status'] = "rom";
156 }
157
158 if($excelarray[$i]["dialer_substatus"]==null)
159 {
160 $empdata['dialer_substatus'] = "rom";
161 }
162
163 /*End - Changes need to be done*/
164
165 $empdata["peopledata"]=$newdata;
166 $empdata['modifylog']=$createdlog;
167 $empdata['dirty']=$fdirty;
168
169 $wakka->setPerson($excelarray[$i]["id"],$empdata);
170 $excelarray[$i]['modified']=date('Y-m-d H:i:s');
171 $successArr[] = $excelarray[$i];
172
173 }
174 else
175 {
176 $reason = "";
177
178 $reason .= "Record ID is not on local server,";
179
180 $excelarray[$i]['server_ip'] =$server_ip;
181 $excelarray[$i]['location'] =$location;
182
183 if($excelarray[$i]["clientcode"]!="")
184 $excelarray[$i]['cust_id'] =$excelarray[$i]["clientcode"];
185 $excelarray[$i]['record_id'] = $excelarray[$i]["id"];
186
187 $excelarray[$i]['Reason'] = $reason;
188
189 $failureArr[] = $excelarray[$i];
190
191 }
192 }
193 else
194 {
195
196 $reason = "";
197
198 if($excelarray[$i]["id"]=="")
199 $reason .= "Column ID is blank,";
200
201 $excelarray[$i]['server_ip'] =$server_ip;
202 $excelarray[$i]['location'] =$location;
203
204 if($excelarray[$i]["clientcode"]!="")
205 $excelarray[$i]['cust_id'] =$excelarray[$i]["clientcode"];
206
207 $excelarray[$i]['Reason'] = $reason;
208
209 $failureArr[] = $excelarray[$i];
210
211 }
212
213 }
214 if(!empty($successArr)){
215 foreach($successArr as $succes)
216 {
217 $setSuccess=array();
218
219 $setSuccess[] = "server_ip='$server_ip'";
220 $setSuccess[] = "location='$location'";
221 $setSuccess[] = "record_id='".$succes['id']."'";
222 $setSuccess[] = "cust_id='".$succes['clientcode']."'";
223 $setSuccess[] = "modified='".$succes['modified']."'";
224
225 $setSuccess = implode(",",$setSuccess);
226
227 DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_success set $setSuccess"));
228 }
229 }
230 if(!empty($failureArr)){
231 foreach($failureArr as $failur)
232 {
233 $setFailure=array();
234
235 $setFailure[] = "server_ip='$server_ip'";
236 $setFailure[] = "location='$location'";
237 $setFailure[] = "cust_id='".$failur['clientcode']."'";
238 $setFailure[] = "record_id='".$failur['record_id']."'";
239 $setFailure[] = "reason='".$failur['Reason']."'";
240
241 $setFailure = implode(",",$setFailure);
242
243 DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_failure set $setFailure"));
244 }
245 }
246
247 DB::connection("conn")->disconnect();
248 }
249 }
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_3';
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 echo "4";
48 echo "\n".date('Y-m-d H:i:s')."\n";
49 $server_ip=env('app_ip');
50 $central_ip=env('central_ip');
51
52
53 $wakka = new KHRMSLib();
54
55 $kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
56 $kformlib->gthis=$wakka;
57
58 $themehome=$wakka->GetThemePath('/');
59 $updatetime=time();
60
61 $clientlst=$wakka->GetBBBUserData("clientslist");
62
63 $isadmin=$wakka->IsAdmin();
64 $username=$wakka->GetUserName();
65 $triggers=Input::get("triggers");
66 $tmpstr=explode(",",$kformlib->HRFiledsStr);
67
68 $success="";$message="";$successcnt=0;$duplicatecount=0;
69
70
71 $conn = array(
72 'driver' => 'mysql',
73 'host' => $central_ip,
74 'database' => env('DB_DATABASE', 'kstych_flexydial'),
75 'username' => env('DB_USERNAME', 'root'),
76 'password' => env('DB_PASSWORD', 'yb9738z'),
77 'charset' => 'utf8',
78 'collation' => 'utf8_unicode_ci',
79 'prefix' => '',
80 'options' => array(
81 PDO::ATTR_TIMEOUT => 5,
82 ),
83 );
84 Config::set("database.connections.conn", $conn);
85
86 DB::connection("conn")->getDatabaseName();
87
88 $serverclist=DB::connection("conn")->select(DB::raw("select location from server_details where server_ip='$server_ip'"));
89 $location=$serverclist[0]->location;
90
91
92 $excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat where SERVER_IP='$server_ip' order by auto_id asc limit 60001,80000"));
93
94 $conn='';
95
96 $tcol=0;$fieldsarr=array();$extrahdrarr=array();
97
98 foreach($excelarray as $key => $array){
99 $excelarray[$key] = (array)$array;
100 }
101
102 $highestColumn = DB::connection("conn")->select(DB::raw("select count(*) as cnt from information_schema.columns where table_name='bz_record_upload_uat'"));
103 $highestColumn = $highestColumn[0]->cnt;
104
105 $highestrow = count($excelarray);
106
107 $flag = 0;
108 $editflag=0;
109
110 for($i=0;$i<$highestrow;$i++)
111 {
112 if($excelarray[$i]["id"]!="")
113 {
114 if($excelarray[$i]["id"]=="CREATE")
115 {
116 $excelarray[$i]["id"]=$wakka->Query("insert into","","records",array('created'=>date('Y-m-d H:i:s')));
117 }
118 else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
119 if($wakka->getCount("records","id='".$excelarray[$i]["id"]."'")==1)
120 {
121 $empdata=$wakka->getPerson($excelarray[$i]["id"]);
122 $ppldata=$empdata["peopledata"];
123 $createdlog=$empdata['modifylog'];
124 $fdirty=$empdata['dirty'];
125
126 $createdlog[$updatetime]=$username."::";
127 $createdlog["updated"]=$updatetime;
128
129 $newdata=$ppldata;
130 foreach($excelarray[$i] as $key => $value)
131 {
132 if($value!="")
133 {
134 if("A".$ppldata[$key]!="A".$value)//forcing string comparrision //MAGIC
135 {
136 $value=str_replace("'"," ",$value);
137 if(strstr($createdlog[$updatetime],$key)==FALSE)$createdlog[$updatetime].="$key|".str_replace(array("|",",")," ",$ppldata[$key])."|".str_replace(array("|",",")," ",$value).",";
138
139 $fdirty[$key]=1;
140
141 $newdata[$key]=$value;
142 }
143 }
144 }
145
146 /*Start - Changes need to be done*/
147
148 if($excelarray[$i]["status"]==null)
149 {
150 $empdata['status'] = "rom";
151 }
152
153 if($excelarray[$i]["dialer_status"]==null)
154 {
155 $empdata['dialer_status'] = "rom";
156 }
157
158 if($excelarray[$i]["dialer_substatus"]==null)
159 {
160 $empdata['dialer_substatus'] = "rom";
161 }
162
163 /*End - Changes need to be done*/
164
165 $empdata["peopledata"]=$newdata;
166 $empdata['modifylog']=$createdlog;
167 $empdata['dirty']=$fdirty;
168
169 $wakka->setPerson($excelarray[$i]["id"],$empdata);
170 $excelarray[$i]['modified']=date('Y-m-d H:i:s');
171 $successArr[] = $excelarray[$i];
172
173 }
174 else
175 {
176 $reason = "";
177
178 $reason .= "Record ID is not on local server,";
179
180 $excelarray[$i]['server_ip'] =$server_ip;
181 $excelarray[$i]['location'] =$location;
182
183 if($excelarray[$i]["clientcode"]!="")
184 $excelarray[$i]['cust_id'] =$excelarray[$i]["clientcode"];
185 $excelarray[$i]['record_id'] = $excelarray[$i]["id"];
186
187 $excelarray[$i]['Reason'] = $reason;
188
189 $failureArr[] = $excelarray[$i];
190
191 }
192 }
193 else
194 {
195
196 $reason = "";
197
198 if($excelarray[$i]["id"]=="")
199 $reason .= "Column ID is blank,";
200
201 $excelarray[$i]['server_ip'] =$server_ip;
202 $excelarray[$i]['location'] =$location;
203
204 if($excelarray[$i]["clientcode"]!="")
205 $excelarray[$i]['cust_id'] =$excelarray[$i]["clientcode"];
206
207 $excelarray[$i]['Reason'] = $reason;
208
209 $failureArr[] = $excelarray[$i];
210
211 }
212
213 }
214 if(!empty($successArr)){
215 foreach($successArr as $succes)
216 {
217 $setSuccess=array();
218
219 $setSuccess[] = "server_ip='$server_ip'";
220 $setSuccess[] = "location='$location'";
221 $setSuccess[] = "record_id='".$succes['id']."'";
222 $setSuccess[] = "cust_id='".$succes['clientcode']."'";
223 $setSuccess[] = "modified='".$succes['modified']."'";
224
225 $setSuccess = implode(",",$setSuccess);
226
227 DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_success set $setSuccess"));
228 }
229 }
230 if(!empty($failureArr)){
231 foreach($failureArr as $failur)
232 {
233 $setFailure=array();
234
235 $setFailure[] = "server_ip='$server_ip'";
236 $setFailure[] = "location='$location'";
237 $setFailure[] = "cust_id='".$failur['clientcode']."'";
238 $setFailure[] = "record_id='".$failur['record_id']."'";
239 $setFailure[] = "reason='".$failur['Reason']."'";
240
241 $setFailure = implode(",",$setFailure);
242
243 DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_failure set $setFailure"));
244 }
245 }
246
247 DB::connection("conn")->disconnect();
248 }
249 }
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_4';
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 echo "5";
48 echo "\n".date('Y-m-d H:i:s')."\n";
49 $server_ip=env('app_ip');
50 $central_ip=env('central_ip');
51
52
53 $wakka = new KHRMSLib();
54
55 $kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
56 $kformlib->gthis=$wakka;
57
58 $themehome=$wakka->GetThemePath('/');
59 $updatetime=time();
60
61 $clientlst=$wakka->GetBBBUserData("clientslist");
62
63 $isadmin=$wakka->IsAdmin();
64 $username=$wakka->GetUserName();
65 $triggers=Input::get("triggers");
66 $tmpstr=explode(",",$kformlib->HRFiledsStr);
67
68 $success="";$message="";$successcnt=0;$duplicatecount=0;
69
70
71 $conn = array(
72 'driver' => 'mysql',
73 'host' => $central_ip,
74 'database' => env('DB_DATABASE', 'kstych_flexydial'),
75 'username' => env('DB_USERNAME', 'root'),
76 'password' => env('DB_PASSWORD', 'yb9738z'),
77 'charset' => 'utf8',
78 'collation' => 'utf8_unicode_ci',
79 'prefix' => '',
80 'options' => array(
81 PDO::ATTR_TIMEOUT => 5,
82 ),
83 );
84 Config::set("database.connections.conn", $conn);
85
86 DB::connection("conn")->getDatabaseName();
87 $serverclist=DB::connection("conn")->select(DB::raw("select location from server_details where server_ip='$server_ip'"));
88 $location=$serverclist[0]->location;
89
90
91 $excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat where SERVER_IP='$server_ip' order by auto_id asc limit 80001,100000"));
92
93 $conn='';
94
95 $tcol=0;$fieldsarr=array();$extrahdrarr=array();
96
97 foreach($excelarray as $key => $array){
98 $excelarray[$key] = (array)$array;
99 }
100
101 $highestColumn = DB::connection("conn")->select(DB::raw("select count(*) as cnt from information_schema.columns where table_name='bz_record_upload_uat'"));
102 $highestColumn = $highestColumn[0]->cnt;
103
104 $highestrow = count($excelarray);
105
106 $flag = 0;
107 $editflag=0;
108
109 for($i=0;$i<$highestrow;$i++)
110 {
111 if($excelarray[$i]["id"]!="")
112 {
113 if($excelarray[$i]["id"]=="CREATE")
114 {
115 $excelarray[$i]["id"]=$wakka->Query("insert into","","records",array('created'=>date('Y-m-d H:i:s')));
116 }
117 else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
118 if($wakka->getCount("records","id='".$excelarray[$i]["id"]."'")==1)
119 {
120 $empdata=$wakka->getPerson($excelarray[$i]["id"]);
121 $ppldata=$empdata["peopledata"];
122 $createdlog=$empdata['modifylog'];
123 $fdirty=$empdata['dirty'];
124
125 $createdlog[$updatetime]=$username."::";
126 $createdlog["updated"]=$updatetime;
127
128 $newdata=$ppldata;
129 foreach($excelarray[$i] as $key => $value)
130 {
131 if($value!="")
132 {
133 if("A".$ppldata[$key]!="A".$value)//forcing string comparrision //MAGIC
134 {
135 $value=str_replace("'"," ",$value);
136 if(strstr($createdlog[$updatetime],$key)==FALSE)$createdlog[$updatetime].="$key|".str_replace(array("|",",")," ",$ppldata[$key])."|".str_replace(array("|",",")," ",$value).",";
137
138 $fdirty[$key]=1;
139
140 $newdata[$key]=$value;
141 }
142 }
143 }
144
145 /*Start - Changes need to be done*/
146
147 if($excelarray[$i]["status"]==null)
148 {
149 $empdata['status'] = "rom";
150 }
151
152 if($excelarray[$i]["dialer_status"]==null)
153 {
154 $empdata['dialer_status'] = "rom";
155 }
156
157 if($excelarray[$i]["dialer_substatus"]==null)
158 {
159 $empdata['dialer_substatus'] = "rom";
160 }
161
162 /*End - Changes need to be done*/
163
164 $empdata["peopledata"]=$newdata;
165 $empdata['modifylog']=$createdlog;
166 $empdata['dirty']=$fdirty;
167
168 $wakka->setPerson($excelarray[$i]["id"],$empdata);
169 $excelarray[$i]['modified']=date('Y-m-d H:i:s');
170 $successArr[] = $excelarray[$i];
171
172 }
173 else
174 {
175 $reason = "";
176
177 $reason .= "Record ID is not on local server,";
178
179 $excelarray[$i]['server_ip'] =$server_ip;
180 $excelarray[$i]['location'] =$location;
181
182 if($excelarray[$i]["clientcode"]!="")
183 $excelarray[$i]['cust_id'] =$excelarray[$i]["clientcode"];
184 $excelarray[$i]['record_id'] = $excelarray[$i]["id"];
185
186 $excelarray[$i]['Reason'] = $reason;
187
188 $failureArr[] = $excelarray[$i];
189
190 }
191 }
192 else
193 {
194
195 $reason = "";
196
197 if($excelarray[$i]["id"]=="")
198 $reason .= "Column ID is blank,";
199
200 $excelarray[$i]['server_ip'] =$server_ip;
201 $excelarray[$i]['location'] =$location;
202
203 if($excelarray[$i]["clientcode"]!="")
204 $excelarray[$i]['cust_id'] =$excelarray[$i]["clientcode"];
205
206 $excelarray[$i]['Reason'] = $reason;
207
208 $failureArr[] = $excelarray[$i];
209
210 }
211
212 }
213 if(!empty($successArr)){
214 foreach($successArr as $succes)
215 {
216 $setSuccess=array();
217
218 $setSuccess[] = "server_ip='$server_ip'";
219 $setSuccess[] = "location='$location'";
220 $setSuccess[] = "record_id='".$succes['id']."'";
221 $setSuccess[] = "cust_id='".$succes['clientcode']."'";
222 $setSuccess[] = "modified='".$succes['modified']."'";
223
224 $setSuccess = implode(",",$setSuccess);
225
226 DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_success set $setSuccess"));
227 }
228 }
229 if(!empty($failureArr)){
230 foreach($failureArr as $failur)
231 {
232 $setFailure=array();
233
234 $setFailure[] = "server_ip='$server_ip'";
235 $setFailure[] = "location='$location'";
236 $setFailure[] = "cust_id='".$failur['clientcode']."'";
237 $setFailure[] = "record_id='".$failur['record_id']."'";
238 $setFailure[] = "reason='".$failur['Reason']."'";
239
240 $setFailure = implode(",",$setFailure);
241
242 DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_failure set $setFailure"));
243 }
244 }
245
246 DB::connection("conn")->disconnect();
247 }
248 }
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_5 extends Command {
22
23 /**
24 * The console command name.
25 *
26 * @var string
27 */
28 protected $signature = 'bulkServerUpload_5';
29
30 /**
31 * The console command description.
32 *
33 * @var string
34 */
35 protected $description = 'bulkServerUpload_5';
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 echo "6";
48 echo "\n".date('Y-m-d H:i:s')."\n";
49 $server_ip=env('app_ip');
50 $central_ip=env('central_ip');
51
52
53 $wakka = new KHRMSLib();
54
55 $kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
56 $kformlib->gthis=$wakka;
57
58 $themehome=$wakka->GetThemePath('/');
59 $updatetime=time();
60
61 $clientlst=$wakka->GetBBBUserData("clientslist");
62
63 $isadmin=$wakka->IsAdmin();
64 $username=$wakka->GetUserName();
65 $triggers=Input::get("triggers");
66 $tmpstr=explode(",",$kformlib->HRFiledsStr);
67
68 $success="";$message="";$successcnt=0;$duplicatecount=0;
69
70
71 $conn = array(
72 'driver' => 'mysql',
73 'host' => $central_ip,
74 'database' => env('DB_DATABASE', 'kstych_flexydial'),
75 'username' => env('DB_USERNAME', 'root'),
76 'password' => env('DB_PASSWORD', 'yb9738z'),
77 'charset' => 'utf8',
78 'collation' => 'utf8_unicode_ci',
79 'prefix' => '',
80 'options' => array(
81 PDO::ATTR_TIMEOUT => 5,
82 ),
83 );
84 Config::set("database.connections.conn", $conn);
85
86 DB::connection("conn")->getDatabaseName();
87
88 $serverclist=DB::connection("conn")->select(DB::raw("select location from server_details where server_ip='$server_ip'"));
89 $location=$serverclist[0]->location;
90
91
92 $excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat where SERVER_IP='$server_ip' order by auto_id asc limit 100001,120000"));
93
94 $conn='';
95
96 $tcol=0;$fieldsarr=array();$extrahdrarr=array();
97
98 foreach($excelarray as $key => $array){
99 $excelarray[$key] = (array)$array;
100 }
101
102 $highestColumn = DB::connection("conn")->select(DB::raw("select count(*) as cnt from information_schema.columns where table_name='bz_record_upload_uat'"));
103 $highestColumn = $highestColumn[0]->cnt;
104
105 $highestrow = count($excelarray);
106
107 $flag = 0;
108 $editflag=0;
109
110 for($i=0;$i<$highestrow;$i++)
111 {
112 if($excelarray[$i]["id"]!="")
113 {
114 if($excelarray[$i]["id"]=="CREATE")
115 {
116 $excelarray[$i]["id"]=$wakka->Query("insert into","","records",array('created'=>date('Y-m-d H:i:s')));
117 }
118 else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
119 if($wakka->getCount("records","id='".$excelarray[$i]["id"]."'")==1)
120 {
121 $empdata=$wakka->getPerson($excelarray[$i]["id"]);
122 $ppldata=$empdata["peopledata"];
123 $createdlog=$empdata['modifylog'];
124 $fdirty=$empdata['dirty'];
125
126 $createdlog[$updatetime]=$username."::";
127 $createdlog["updated"]=$updatetime;
128
129 $newdata=$ppldata;
130 foreach($excelarray[$i] as $key => $value)
131 {
132 if($value!="")
133 {
134 if("A".$ppldata[$key]!="A".$value)//forcing string comparrision //MAGIC
135 {
136 $value=str_replace("'"," ",$value);
137 if(strstr($createdlog[$updatetime],$key)==FALSE)$createdlog[$updatetime].="$key|".str_replace(array("|",",")," ",$ppldata[$key])."|".str_replace(array("|",",")," ",$value).",";
138
139 $fdirty[$key]=1;
140
141 $newdata[$key]=$value;
142 }
143 }
144 }
145
146 /*Start - Changes need to be done*/
147
148 if($excelarray[$i]["status"]==null)
149 {
150 $empdata['status'] = "rom";
151 }
152
153 if($excelarray[$i]["dialer_status"]==null)
154 {
155 $empdata['dialer_status'] = "rom";
156 }
157
158 if($excelarray[$i]["dialer_substatus"]==null)
159 {
160 $empdata['dialer_substatus'] = "rom";
161 }
162
163 /*End - Changes need to be done*/
164
165 $empdata["peopledata"]=$newdata;
166 $empdata['modifylog']=$createdlog;
167 $empdata['dirty']=$fdirty;
168
169 $wakka->setPerson($excelarray[$i]["id"],$empdata);
170 $excelarray[$i]['modified']=date('Y-m-d H:i:s');
171 $successArr[] = $excelarray[$i];
172
173 }
174 else
175 {
176 $reason = "";
177
178 $reason .= "Record ID is not on local server,";
179
180 $excelarray[$i]['server_ip'] =$server_ip;
181 $excelarray[$i]['location'] =$location;
182
183 if($excelarray[$i]["clientcode"]!="")
184 $excelarray[$i]['cust_id'] =$excelarray[$i]["clientcode"];
185 $excelarray[$i]['record_id'] = $excelarray[$i]["id"];
186
187 $excelarray[$i]['Reason'] = $reason;
188
189 $failureArr[] = $excelarray[$i];
190
191 }
192 }
193 else
194 {
195
196 $reason = "";
197
198 if($excelarray[$i]["id"]=="")
199 $reason .= "Column ID is blank,";
200
201 $excelarray[$i]['server_ip'] =$server_ip;
202 $excelarray[$i]['location'] =$location;
203
204 if($excelarray[$i]["clientcode"]!="")
205 $excelarray[$i]['cust_id'] =$excelarray[$i]["clientcode"];
206
207 $excelarray[$i]['Reason'] = $reason;
208
209 $failureArr[] = $excelarray[$i];
210
211 }
212
213 }
214 if(!empty($successArr)){
215 foreach($successArr as $succes)
216 {
217 $setSuccess=array();
218
219 $setSuccess[] = "server_ip='$server_ip'";
220 $setSuccess[] = "location='$location'";
221 $setSuccess[] = "record_id='".$succes['id']."'";
222 $setSuccess[] = "cust_id='".$succes['clientcode']."'";
223 $setSuccess[] = "modified='".$succes['modified']."'";
224
225 $setSuccess = implode(",",$setSuccess);
226
227 DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_success set $setSuccess"));
228 }
229 }
230 if(!empty($failureArr)){
231 foreach($failureArr as $failur)
232 {
233 $setFailure=array();
234
235 $setFailure[] = "server_ip='$server_ip'";
236 $setFailure[] = "location='$location'";
237 $setFailure[] = "cust_id='".$failur['clientcode']."'";
238 $setFailure[] = "record_id='".$failur['record_id']."'";
239 $setFailure[] = "reason='".$failur['Reason']."'";
240
241 $setFailure = implode(",",$setFailure);
242
243 DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_failure set $setFailure"));
244 }
245 }
246
247 DB::connection("conn")->disconnect();
248 }
249 }
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_6 extends Command {
22
23 /**
24 * The console command name.
25 *
26 * @var string
27 */
28 protected $signature = 'bulkServerUpload_6';
29
30 /**
31 * The console command description.
32 *
33 * @var string
34 */
35 protected $description = 'bulkServerUpload_6';
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 echo "6";
48 echo "\n".date('Y-m-d H:i:s')."\n";
49 $server_ip=env('app_ip');
50 $central_ip=env('central_ip');
51
52
53 $wakka = new KHRMSLib();
54
55 $kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
56 $kformlib->gthis=$wakka;
57
58 $themehome=$wakka->GetThemePath('/');
59 $updatetime=time();
60
61 $clientlst=$wakka->GetBBBUserData("clientslist");
62
63 $isadmin=$wakka->IsAdmin();
64 $username=$wakka->GetUserName();
65 $triggers=Input::get("triggers");
66 $tmpstr=explode(",",$kformlib->HRFiledsStr);
67
68 $success="";$message="";$successcnt=0;$duplicatecount=0;
69
70
71 $conn = array(
72 'driver' => 'mysql',
73 'host' => $central_ip,
74 'database' => env('DB_DATABASE', 'kstych_flexydial'),
75 'username' => env('DB_USERNAME', 'root'),
76 'password' => env('DB_PASSWORD', 'yb9738z'),
77 'charset' => 'utf8',
78 'collation' => 'utf8_unicode_ci',
79 'prefix' => '',
80 'options' => array(
81 PDO::ATTR_TIMEOUT => 5,
82 ),
83 );
84 Config::set("database.connections.conn", $conn);
85
86 DB::connection("conn")->getDatabaseName();
87
88 $serverclist=DB::connection("conn")->select(DB::raw("select location from server_details where server_ip='$server_ip'"));
89 $location=$serverclist[0]->location;
90
91
92 $excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat where SERVER_IP='$server_ip' order by auto_id asc limit 120001,140000"));
93
94 $conn='';
95
96 $tcol=0;$fieldsarr=array();$extrahdrarr=array();
97
98 foreach($excelarray as $key => $array){
99 $excelarray[$key] = (array)$array;
100 }
101
102 $highestColumn = DB::connection("conn")->select(DB::raw("select count(*) as cnt from information_schema.columns where table_name='bz_record_upload_uat'"));
103 $highestColumn = $highestColumn[0]->cnt;
104
105 $highestrow = count($excelarray);
106
107 $flag = 0;
108 $editflag=0;
109
110 for($i=0;$i<$highestrow;$i++)
111 {
112 if($excelarray[$i]["id"]!="")
113 {
114 if($excelarray[$i]["id"]=="CREATE")
115 {
116 $excelarray[$i]["id"]=$wakka->Query("insert into","","records",array('created'=>date('Y-m-d H:i:s')));
117 }
118 else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
119 if($wakka->getCount("records","id='".$excelarray[$i]["id"]."'")==1)
120 {
121 $empdata=$wakka->getPerson($excelarray[$i]["id"]);
122 $ppldata=$empdata["peopledata"];
123 $createdlog=$empdata['modifylog'];
124 $fdirty=$empdata['dirty'];
125
126 $createdlog[$updatetime]=$username."::";
127 $createdlog["updated"]=$updatetime;
128
129 $newdata=$ppldata;
130 foreach($excelarray[$i] as $key => $value)
131 {
132 if($value!="")
133 {
134 if("A".$ppldata[$key]!="A".$value)//forcing string comparrision //MAGIC
135 {
136 $value=str_replace("'"," ",$value);
137 if(strstr($createdlog[$updatetime],$key)==FALSE)$createdlog[$updatetime].="$key|".str_replace(array("|",",")," ",$ppldata[$key])."|".str_replace(array("|",",")," ",$value).",";
138
139 $fdirty[$key]=1;
140
141 $newdata[$key]=$value;
142 }
143 }
144 }
145
146 /*Start - Changes need to be done*/
147
148 if($excelarray[$i]["status"]==null)
149 {
150 $empdata['status'] = "rom";
151 }
152
153 if($excelarray[$i]["dialer_status"]==null)
154 {
155 $empdata['dialer_status'] = "rom";
156 }
157
158 if($excelarray[$i]["dialer_substatus"]==null)
159 {
160 $empdata['dialer_substatus'] = "rom";
161 }
162
163 /*End - Changes need to be done*/
164
165 $empdata["peopledata"]=$newdata;
166 $empdata['modifylog']=$createdlog;
167 $empdata['dirty']=$fdirty;
168
169 $wakka->setPerson($excelarray[$i]["id"],$empdata);
170 $excelarray[$i]['modified']=date('Y-m-d H:i:s');
171 $successArr[] = $excelarray[$i];
172
173 }
174 else
175 {
176 $reason = "";
177
178 $reason .= "Record ID is not on local server,";
179
180 $excelarray[$i]['server_ip'] =$server_ip;
181 $excelarray[$i]['location'] =$location;
182
183 if($excelarray[$i]["clientcode"]!="")
184 $excelarray[$i]['cust_id'] =$excelarray[$i]["clientcode"];
185 $excelarray[$i]['record_id'] = $excelarray[$i]["id"];
186
187 $excelarray[$i]['Reason'] = $reason;
188
189 $failureArr[] = $excelarray[$i];
190
191 }
192 }
193 else
194 {
195
196 $reason = "";
197
198 if($excelarray[$i]["id"]=="")
199 $reason .= "Column ID is blank,";
200
201 $excelarray[$i]['server_ip'] =$server_ip;
202 $excelarray[$i]['location'] =$location;
203
204 if($excelarray[$i]["clientcode"]!="")
205 $excelarray[$i]['cust_id'] =$excelarray[$i]["clientcode"];
206
207 $excelarray[$i]['Reason'] = $reason;
208
209 $failureArr[] = $excelarray[$i];
210
211 }
212
213 }
214 if(!empty($successArr)){
215 foreach($successArr as $succes)
216 {
217 $setSuccess=array();
218
219 $setSuccess[] = "server_ip='$server_ip'";
220 $setSuccess[] = "location='$location'";
221 $setSuccess[] = "record_id='".$succes['id']."'";
222 $setSuccess[] = "cust_id='".$succes['clientcode']."'";
223 $setSuccess[] = "modified='".$succes['modified']."'";
224
225 $setSuccess = implode(",",$setSuccess);
226
227 DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_success set $setSuccess"));
228 }
229 }
230 if(!empty($failureArr)){
231 foreach($failureArr as $failur)
232 {
233 $setFailure=array();
234
235 $setFailure[] = "server_ip='$server_ip'";
236 $setFailure[] = "location='$location'";
237 $setFailure[] = "cust_id='".$failur['clientcode']."'";
238 $setFailure[] = "record_id='".$failur['record_id']."'";
239 $setFailure[] = "reason='".$failur['Reason']."'";
240
241 $setFailure = implode(",",$setFailure);
242
243 DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_failure set $setFailure"));
244 }
245 }
246
247 DB::connection("conn")->disconnect();
248 }
249 }
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_daily extends Command {
22
23 /**
24 * The console command name.
25 *
26 * @var string
27 */
28 protected $signature = 'bulkServerUpload_daily';
29
30 /**
31 * The console command description.
32 *
33 * @var string
34 */
35 protected $description = 'bulkServerUpload_daily';
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 echo "1";
48 echo "\n".date('Y-m-d H:i:s')."\n";
49
50 $server_ip=env('app_ip');
51 $central_ip=env('central_ip');
52
53 $wakka = new KHRMSLib();
54
55 $kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
56 $kformlib->gthis=$wakka;
57
58 $themehome=$wakka->GetThemePath('/');
59 $updatetime=time();
60
61 $clientlst=$wakka->GetBBBUserData("clientslist");
62
63 $isadmin=$wakka->IsAdmin();
64 $username=$wakka->GetUserName();
65 $triggers=Input::get("triggers");
66 $tmpstr=explode(",",$kformlib->HRFiledsStr);
67
68 $success="";$message="";$successcnt=0;$duplicatecount=0;
69
70
71 $conn = array(
72 'driver' => 'mysql',
73 'host' => $central_ip,
74 'database' => env('DB_DATABASE', 'kstych_flexydial'),
75 'username' => env('DB_USERNAME', 'root'),
76 'password' => env('DB_PASSWORD', 'yb9738z'),
77 'charset' => 'utf8',
78 'collation' => 'utf8_unicode_ci',
79 'prefix' => '',
80 'options' => array(
81 PDO::ATTR_TIMEOUT => 5,
82 ),
83 );
84 Config::set("database.connections.conn", $conn);
85
86 DB::connection("conn")->getDatabaseName();
87
88 $serverclist=DB::connection("conn")->select(DB::raw("select location from server_details where server_ip='$server_ip'"));
89 $location=$serverclist[0]->location;
90 echo $central_ip;
91 echo $location;
92
93
94 $excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat_daily where SERVER_IP='$server_ip' order by auto_id asc limit 0,200"));
95
96 $conn='';
97
98 $tcol=0;$fieldsarr=array();$extrahdrarr=array();
99
100 foreach($excelarray as $key => $array){
101 $excelarray[$key] = (array)$array;
102 }
103
104 $highestColumn = DB::connection("conn")->select(DB::raw("select count(*) as cnt from information_schema.columns where table_name='bz_record_upload_uat'"));
105 $highestColumn = $highestColumn[0]->cnt;
106
107 $highestrow = count($excelarray);
108
109 $flag = 0;
110 $editflag=0;
111
112 for($i=0;$i<$highestrow;$i++)
113 {
114 if($excelarray[$i]["id"]!="")
115 {
116 if($excelarray[$i]["id"]=="CREATE")
117 {
118 $excelarray[$i]["id"]=$wakka->Query("insert into","","records",array('created'=>date('Y-m-d H:i:s')));
119 }
120 else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
121 if($wakka->getCount("records","id='".$excelarray[$i]["id"]."'")==1)
122 {
123 $empdata=$wakka->getPerson($excelarray[$i]["id"]);
124 $ppldata=$empdata["peopledata"];
125 $createdlog=$empdata['modifylog'];
126 $fdirty=$empdata['dirty'];
127
128 $createdlog[$updatetime]=$username."::";
129 $createdlog["updated"]=$updatetime;
130
131 $newdata=$ppldata;
132 foreach($excelarray[$i] as $key => $value)
133 {
134 if($value!="")
135 {
136 if("A".$ppldata[$key]!="A".$value)//forcing string comparrision //MAGIC
137 {
138 $value=str_replace("'"," ",$value);
139 if(strstr($createdlog[$updatetime],$key)==FALSE)$createdlog[$updatetime].="$key|".str_replace(array("|",",")," ",$ppldata[$key])."|".str_replace(array("|",",")," ",$value).",";
140
141 $fdirty[$key]=1;
142
143 $newdata[$key]=$value;
144 }
145 }
146 }
147
148 /*Start - Changes need to be done*/
149
150 if($excelarray[$i]["status"]==null)
151 {
152 $empdata['status'] = "rom";
153 }
154
155 if($excelarray[$i]["dialer_status"]==null)
156 {
157 $empdata['dialer_status'] = "rom";
158 }
159
160 if($excelarray[$i]["dialer_substatus"]==null)
161 {
162 $empdata['dialer_substatus'] = "rom";
163 }
164
165 /*End - Changes need to be done*/
166
167 $empdata["peopledata"]=$newdata;
168 $empdata['modifylog']=$createdlog;
169 $empdata['dirty']=$fdirty;
170
171 $wakka->setPerson($excelarray[$i]["id"],$empdata);
172 $excelarray[$i]['modified']=date('Y-m-d H:i:s');
173 $successArr[] = $excelarray[$i];
174
175 }
176 else
177 {
178 $reason = "";
179
180 $reason .= "Record ID is not on local server,";
181
182 $excelarray[$i]['server_ip'] =$server_ip;
183 $excelarray[$i]['location'] =$location;
184
185 if($excelarray[$i]["clientcode"]!="")
186 $excelarray[$i]['cust_id'] =$excelarray[$i]["clientcode"];
187 $excelarray[$i]['record_id'] = $excelarray[$i]["id"];
188
189 $excelarray[$i]['Reason'] = $reason;
190
191 $failureArr[] = $excelarray[$i];
192
193 }
194 }
195 else
196 {
197
198 $reason = "";
199
200 if($excelarray[$i]["id"]=="")
201 $reason .= "Column ID is blank,";
202
203 $excelarray[$i]['server_ip'] =$server_ip;
204 $excelarray[$i]['location'] =$location;
205
206 if($excelarray[$i]["clientcode"]!="")
207 $excelarray[$i]['cust_id'] =$excelarray[$i]["clientcode"];
208
209 $excelarray[$i]['Reason'] = $reason;
210
211 $failureArr[] = $excelarray[$i];
212
213 }
214
215 }
216 if(!empty($successArr)){
217 foreach($successArr as $succes)
218 {
219 $setSuccess=array();
220
221 $setSuccess[] = "server_ip='$server_ip'";
222 $setSuccess[] = "location='$location'";
223 $setSuccess[] = "record_id='".$succes['id']."'";
224 $setSuccess[] = "cust_id='".$succes['clientcode']."'";
225 $setSuccess[] = "modified='".$succes['modified']."'";
226
227 $setSuccess = implode(",",$setSuccess);
228
229 DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_success_daily set $setSuccess"));
230
231 DB::connection("conn")->delete(DB::raw("DELETE FROM `bz_record_upload_uat_daily` where SERVER_IP='$server_ip' and id='".$succes['id']."'"));
232 }
233 }
234 if(!empty($failureArr)){
235 foreach($failureArr as $failur)
236 {
237 $setFailure=array();
238
239 $setFailure[] = "server_ip='$server_ip'";
240 $setFailure[] = "location='$location'";
241 $setFailure[] = "cust_id='".$failur['clientcode']."'";
242 $setFailure[] = "record_id='".$failur['record_id']."'";
243 $setFailure[] = "reason='".$failur['Reason']."'";
244
245 $setFailure = implode(",",$setFailure);
246
247 DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_failure_daily set $setFailure"));
248 }
249 }
250
251 //DB::connection("conn")->delete(DB::raw("DELETE FROM `bz_record_upload_uat_daily` where SERVER_IP='10.3.179.121'"));
252
253 DB::connection("conn")->disconnect();
254
255
256 }
257 }
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 calllog extends Command {
18
19 /**
20 * The console command name.
21 *
22 * @var string
23 */
24 protected $signature = 'calllog';
25
26 /**
27 * The console command description.
28 *
29 * @var string
30 */
31 protected $description = 'App Main Daily Task for calllog';
32
33 /**
34 * Execute the console command.
35 *
36 * @return mixed
37 */
38 public function handle()
39 {
40 $nowts=time();
41 $date=date('F_Y');
42 echo "\n".date('Y-m-d H:i:s')."\n";
43
44 $logdate=strtotime('0 day');
45
46 $tcol=0;$fieldsarr=array();$extrahdrarr=array();
47 $central_ip=env('central_ip');
48 $server_ip=env('app_ip');
49 $calllog_report = "calllog_report_".$date;
50
51 $conn = array(
52 'driver' => 'mysql',
53 'host' => $central_ip,
54 'database' => env('DB_DATABASE', 'kstych_flexydial'),
55 'username' => env('DB_USERNAME', 'root'),
56 'password' => env('DB_PASSWORD', ''),
57 'charset' => 'utf8',
58 'collation' => 'utf8_unicode_ci',
59 'prefix' => '',
60 'options' => array(
61 PDO::ATTR_TIMEOUT => 5,
62 ),
63 );
64 Config::set("database.connections.conn", $conn);
65
66 DB::connection("conn")->getDatabaseName();
67
68 $serverclist=DB::connection("conn")->select(DB::raw("select id from server_details where server_ip='$server_ip'"));
69 $server_id=$serverclist[0]->id;
70 if($server_id<10){
71 $server_id="0".$server_id;
72 }
73
74
75 $maxid=DB::connection("conn")->select(DB::raw("SELECT max(crmcall_id) as maxid from $calllog_report where server='$server_id'"));
76
77 $maxids=$maxid[0]->maxid;
78
79 $alist=DB::select(DB::raw("SELECT * from crmcalls where id>'$maxids' and created_at<'".date("Y-m-d H:i:s",$logdate-(60*60))."'"));
80
81 //$alist=DB::select(DB::raw("SELECT * from crmcalls where id>'$maxids' and created_at>'".date("Y-m-d")."' and created_at<'".date("Y-m-d H:i:s",$logdate-(60*60))."'"));
82
83 //$alist=DB::select(DB::raw("SELECT * from crmcalls where id>'$maxids' and created_at<'".date("Y-m-d H:i:s",$logdate-(60*60))."'"));
84
85 $userarr=array();
86 foreach($alist as $aline)
87 {
88 $setstrarr=array();
89
90
91 $clientcode="";$currentstatus="";$legalstatus="";$record_id="";
92 if($aline->crm_id>0)
93 {
94 $user=DB::select(DB::raw("select id,clientcode,currentstatus,legalstatus from records where id='".$aline->crm_id."' limit 1;"));
95 if(isset($user[0]))
96 {
97 $record_id=$user[0]->id;
98 $clientcode=$user[0]->clientcode;
99 $currentstatus=$user[0]->currentstatus;
100 $legalstatus=$user[0]->legalstatus;
101 }
102 }
103 $tpostdata=json_decode($aline->data,true);
104 $fulldate=date("Y-m-d H:i:s",strtotime($aline->created_at)+330*60);
105 $talktime=$aline->talkSec+$aline->recstartSec+$aline->recendSec;
106 $length=round(($aline->waitSec+$aline->callSec+$talktime+$aline->dispoSec)/1000,2);
107
108 if(!isset($userarr[$aline->user_id])&&$aline->user_id>0)$userarr[$aline->user_id]=User::find($aline->user_id);
109 $dispname="";if(isset($userarr[$aline->user_id]))$dispname=$userarr[$aline->user_id]->dispname();
110 $username="";if(isset($userarr[$aline->user_id]))$username=$userarr[$aline->user_id]->username;
111 $globalid=$server_id.$record_id;
112 $setstrarr[]="server='$server_id'";
113 $setstrarr[]="record_id='$record_id'";
114 $setstrarr[]="crmcall_id='$aline->id'";
115 $countid=DB::connection("conn")->select(DB::raw("SELECT count(crmcall_id) as countid from $calllog_report where server='$server_id' and crmcall_id='$aline->id'"));
116 $countids=$countid[0]->countid;
117 if($countids>0){continue;}
118 $setstrarr[]="globalid='$globalid'";
119 $setstrarr[]="start='$fulldate'";
120 $setstrarr[]="length='$length'";
121 $setstrarr[]="user='$username'";
122 $setstrarr[]="name='$dispname'";
123 $setstrarr[]="dispo='$aline->userstatus'";
124 $setstrarr[]="subdispo='$aline->usersubstatus'";
125 $setstrarr[]="callback='$aline->usercallback'";
126
127 $setstrarr[]="number='$aline->number'";
128 $setstrarr[]="clientcode='$clientcode'";
129 $setstrarr[]="currentstatus='$currentstatus'";
130 $setstrarr[]="legalstatus='$legalstatus'";
131 $setstrarr[]="client='$aline->client'";
132 $setstrarr[]="department='$aline->department'";
133 $setstrarr[]="state='$aline->state'";
134 $setstrarr[]="hsource='$aline->hsource'";
135
136 $setstrarr[]="type='$aline->type'";
137 $setstrarr[]="status='$aline->status'";
138 $setstrarr[]="statuscode='$aline->statuscode'";
139 $setstrarr[]="statusstr='$aline->substatus'";
140 $setstrarr[]="dialline='$aline->dialline_id'";
141 $setstrarr[]="did='$aline->did'";
142 $setstrarr[]="waitsec='".round($aline->waitSec/1000,2)."'";
143 $setstrarr[]="callsec='".round($aline->callSec/1000,2)."'";
144 $setstrarr[]="talksec='".round($talktime/1000,2)."'";
145 $setstrarr[]="disposec='".round($aline->dispoSec/1000,2)."'";
146 $setstrarr[]="remarks='".str_replace("'","",$aline->userremarks)."'";
147 $setstrarr[]="userdata='$aline->userdata'";
148 $setstrarr[]="attempt='$aline->attempt'";
149
150 $setstr=implode(",",$setstrarr);
151 DB::connection("conn")->insert(DB::raw("insert into ".$calllog_report." set $setstr"));
152 }
153
154 }
155 }
156
157
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4
5 use DB;
6 use App\Models\ComplaintCategory;
7 use App\Models\ComplaintResolclassUnit;
8 use App\Models\ComplaintSubCategory;
9
10 use Config;
11 use Schema;
12 use PDO;
13
14 use Illuminate\Database\Schema\Blueprint;
15
16 class complaint_data extends Command {
17
18 /**
19 * The console command name.
20 *
21 * @var string
22 */
23 protected $signature = 'complaint_data';
24
25 /**
26 * The console command description.
27 *
28 * @var string
29 */
30 protected $description = 'complaint_data';
31
32 /**
33 * Execute the console command.
34 *
35 * @return mixed
36 */
37 public function handle()
38 {
39 $nowts=time();
40
41 echo date('Y-m-d H:i:s')."\n";
42
43 $tcol=0;$fieldsarr=array();$extrahdrarr=array();
44 $server_ip=env('app_ip');
45 $central_ip=env('central_ip');
46
47 $conn = array(
48 'driver' => 'mysql',
49 'host' => $central_ip,
50 'database' => env('DB_DATABASE', 'kstych_flexydial'),
51 'username' => env('DB_USERNAME', 'root'),
52 'password' => env('DB_PASSWORD', ''),
53 'charset' => 'utf8',
54 'collation' => 'utf8_unicode_ci',
55 'prefix' => '',
56 'options' => array(
57 PDO::ATTR_TIMEOUT => 5,
58 ),
59 );
60
61 Config::set("database.connections.conn", $conn);
62
63 if(DB::connection("conn")->getDatabaseName())
64 {
65
66 DB::table('complaint_category')->truncate();
67 DB::table('complaint_resol_class_unit')->truncate();
68 DB::table('complaint_sub_category')->truncate();
69
70 $complaintdataList = DB::connection("conn")->select(DB::raw("SELECT * FROM complaint_category"));
71
72 $complaintData = 0; $newCategory = 0; $newSubCategory = 0; $newComplaintResolClassUnit = 0;
73
74 foreach ($complaintdataList as $list) {
75 $category = ComplaintCategory::where('category','=',$list->category)->first();
76
77 if(count($category)){
78 $categoryId = $category->id;
79
80 }else{
81 $addCategory = ComplaintCategory::create(['category'=>$list->category]);
82 $categoryId = $addCategory->id;
83 $newCategory++;
84 }
85
86
87 $complaintResolClassUnit = ComplaintResolclassUnit::where('resolve_class_unit','=',$list->resolve_class_unit)->first();
88
89 if(count($complaintResolClassUnit)){
90 $complaintResolClassUnitId = $complaintResolClassUnit->id;
91 }else{
92 $addComplaintResolClassUnit = ComplaintResolclassUnit::create(['resolve_class_unit'=>$list->resolve_class_unit]);
93 $complaintResolClassUnitId = $addComplaintResolClassUnit->id;
94 $newComplaintResolClassUnit++;
95 }
96
97 $subCategory = ComplaintSubCategory::where('resolve_class_unit_id','=',$complaintResolClassUnitId)->where('category_id','=',$categoryId)->where('sub_category','=',$list->sub_category)->first();
98
99 if(count($subCategory)){
100 $subCategoryId = $subCategory->id;
101
102 }else{
103 $addSubCategory = ComplaintSubCategory::create(['sub_category'=>$list->sub_category,'resolve_class_unit_id'=>$complaintResolClassUnitId,'category_id'=>$categoryId]);
104 $subCategoryId = $addSubCategory->id;
105 $newSubCategory++;
106 }
107
108 $complaintData++;
109 }
110 DB::connection("conn")->disconnect();
111
112 }
113
114 }
115
116 }
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4 use DB;
5 use Config;
6
7 use App\Models\User;
8 use App\Models\Accesslog;
9
10 use App\Models\CRMCall;
11 use Schema;
12 use PDO;
13
14 use Illuminate\Database\Schema\Blueprint;
15
16 class complaint_details extends Command {
17
18 /**
19 * The console command name.
20 *
21 * @var string
22 */
23 protected $signature = 'complaint_details';
24
25 /**
26 * The console command description.
27 *
28 * @var string
29 */
30 protected $description = 'complaint_details';
31
32 /**
33 * Execute the console command.
34 *
35 * @return mixed
36 */
37 public function handle()
38 {
39 $nowts=time();
40 echo "\n".date('Y-m-d H:i:s')."\n";
41
42
43 $logdate=strtotime('0 day');
44
45 $tcol=0;$fieldsarr=array();$extrahdrarr=array();
46 $server_ip=env('app_ip');
47 $lead_form = "lead_form_details";
48 $central_ip=env('central_ip');
49
50 $conn = array(
51 'driver' => 'mysql',
52 'host' => $central_ip,
53 'database' => env('DB_DATABASE', 'kstych_flexydial'),
54 'username' => env('DB_USERNAME', 'root'),
55 'password' => env('DB_PASSWORD', ''),
56 'charset' => 'utf8',
57 'collation' => 'utf8_unicode_ci',
58 'prefix' => '',
59 'options' => array(
60 PDO::ATTR_TIMEOUT => 5,
61 ),
62 );
63 Config::set("database.connections.conn", $conn);
64
65
66 if(DB::connection("conn")->getDatabaseName())
67 {
68 $serverclist=DB::connection("conn")->select(DB::raw("select id from server_details where server_ip='$server_ip'"));
69 $server_id=$serverclist[0]->id;
70 if($server_id<10){
71 $server_id="0".$server_id;
72 }
73
74 $maxid=DB::connection("conn")->select(DB::raw("SELECT max(complaint_id) as maxid from complaint_details where server='$server_id'"));
75
76 $maxids=$maxid[0]->maxid;
77
78 $qlist=DB::select(DB::raw("SELECT * from complaint_details where id>$maxids"));
79 $userarr=array();
80 foreach($qlist as $qline)
81 {
82
83 $setstrarr=array();
84
85 $setstrarr[]="complaint_id='$qline->id'";
86 $setstrarr[]="upload_date='$qline->upload_date'";
87 $setstrarr[]="call_id='$qline->call_id'";
88 $setstrarr[]="cust_band='$qline->cust_band'";
89 $setstrarr[]="cust_type='$qline->cust_type'";
90 $setstrarr[]="source_of_info='$qline->source_of_info'";
91 $setstrarr[]="service_type='$qline->service_type'";
92 $setstrarr[]="priority='$qline->priority'";
93 $setstrarr[]="category='$qline->category'";
94 $setstrarr[]="sub_category='$qline->sub_category'";
95 $setstrarr[]="resolving_branch='$qline->resolving_branch'";
96 $setstrarr[]="cust_city='$qline->cust_city'";
97 $setstrarr[]="acknowledge='$qline->acknowledge'";
98 $setstrarr[]="resolve_class_unit='$qline->resolve_class_unit'";
99 $setstrarr[]="rbb='$qline->rbb'";
100 $setstrarr[]="non_rrb='$qline->non_rrb'";
101 $setstrarr[]="complainant_name='$qline->complainant_name'";
102 $setstrarr[]="existing_customer='$qline->existing_customer'";
103 $setstrarr[]="cust_id='$qline->cust_id'";
104 $setstrarr[]="shadow_cust_id='$qline->shadow_cust_id'";
105 $setstrarr[]="casa_number='$qline->casa_number'";
106 $setstrarr[]="docket_number='$qline->docket_number'";
107 $setstrarr[]="cust_mobile='$qline->cust_mobile'";
108 $setstrarr[]="contact_number='$qline->contact_number'";
109 $setstrarr[]="email='$qline->email'";
110 $setstrarr[]="case_reference='$qline->case_reference'";
111 $setstrarr[]="logging_branch_name='$qline->logging_branch_name'";
112 $setstrarr[]="logging_class_unit='$qline->logging_class_unit'";
113 $setstrarr[]="nature_of_complaint='$qline->nature_of_complaint'";
114 $setstrarr[]="detailed_suggestion='$qline->detailed_suggestion'";
115 $setstrarr[]="additional_info='$qline->additional_info'";
116 $setstrarr[]="cust_name_on_card='$qline->cust_name_on_card'";
117 if($qline->card_number==''){
118 $setstrarr[]="card_number='' ";
119 }else{
120 $setstrarr[]="card_number='".substr($qline->card_number,0,6).'******'.substr($qline->card_number,-4,4)."'";
121 }
122 $setstrarr[]="aan='$qline->aan'";
123 $setstrarr[]="logging_branch_code='$qline->logging_branch_code'";
124 $setstrarr[]="resolving_branch_code='$qline->resolving_branch_code'";
125 $setstrarr[]="status='$qline->status'";
126 $setstrarr[]="server='$server_id'";
127
128 $setstr=implode(",",$setstrarr);
129 DB::connection("conn")->insert(DB::raw("insert into complaint_details set $setstr"));
130
131 }
132 DB::connection("conn")->disconnect();
133
134 }
135
136 }
137
138
139 }
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4 use DB;
5 use Config;
6
7 use App\Models\User;
8 use App\Models\Accesslog;
9
10 use App\Models\CRMCall;
11 use Schema;
12 use PDO;
13
14 use Illuminate\Database\Schema\Blueprint;
15
16 class complaint_fields extends Command {
17
18 /**
19 * The console command name.
20 *
21 * @var string
22 */
23 protected $signature = 'complaint_fields';
24
25 /**
26 * The console command description.
27 *
28 * @var string
29 */
30 protected $description = 'complaint_fields';
31
32 /**
33 * Execute the console command.
34 *
35 * @return mixed
36 */
37 public function handle()
38 {
39 $nowts=time();
40 echo "\n".date('Y-m-d H:i:s')."\n";
41
42
43 $logdate=strtotime('0 day');
44
45 $tcol=0;$fieldsarr=array();$extrahdrarr=array();
46 $server_ip=env('app_ip');
47 $lead_form = "lead_form_details";
48 $central_ip=env('central_ip');
49
50 $conn = array(
51 'driver' => 'mysql',
52 'host' => $central_ip,
53 'database' => env('DB_DATABASE', 'kstych_flexydial'),
54 'username' => env('DB_USERNAME', 'root'),
55 'password' => env('DB_PASSWORD', ''),
56 'charset' => 'utf8',
57 'collation' => 'utf8_unicode_ci',
58 'prefix' => '',
59 'options' => array(
60 PDO::ATTR_TIMEOUT => 5,
61 ),
62 );
63 Config::set("database.connections.conn", $conn);
64
65
66 if(DB::connection("conn")->getDatabaseName())
67 {
68 DB::table('complaint_fields')->truncate();
69
70 $qlist=DB::connection("conn")->select(DB::raw("SELECT * from complaint_fields"));
71 $userarr=array();
72 foreach($qlist as $qline)
73 {
74
75 $setstrarr=array();
76
77 $setstrarr[]="cust_band='$qline->cust_band'";
78 $setstrarr[]="cust_type='$qline->cust_type'";
79 $setstrarr[]="source_of_info='$qline->source_of_info'";
80 $setstrarr[]="service_type='$qline->service_type'";
81 $setstrarr[]="priority='$qline->priority'";
82 $setstrarr[]="category='$qline->category'";
83 $setstrarr[]="sub_category='$qline->sub_category'";
84 $setstrarr[]="resolving_branch='$qline->resolving_branch'";
85 $setstrarr[]="cust_city='$qline->cust_city'";
86 $setstrarr[]="acknowledge='$qline->acknowledge'";
87 $setstrarr[]="resolve_class_unit='$qline->resolve_class_unit'";
88 $setstrarr[]="rbb='$qline->rbb'";
89 $setstrarr[]="non_rbb='$qline->non_rbb'";
90 $setstrarr[]="logging_branch_name='$qline->logging_branch_name'";
91 $setstrarr[]="logging_branch_code='$qline->logging_branch_code'";
92 $setstrarr[]="resolving_branch_code='$qline->resolving_branch_code'";
93 $setstrarr[]="resolving_branch_w_code='$qline->resolving_branch_w_code'";
94 $setstrarr[]="logging_branch_w_code='$qline->logging_branch_w_code'";
95
96 $setstr=implode(",",$setstrarr);
97 DB::insert(DB::raw("insert into complaint_fields set $setstr"));
98
99 }
100 DB::connection("conn")->disconnect();
101
102 }
103
104 }
105
106
107 }
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4 use DB;
5 use Config;
6
7 use App\Models\User;
8 use App\Models\Accesslog;
9
10 use App\Models\CRMCall;
11 use Schema;
12 use PDO;
13
14 use Illuminate\Database\Schema\Blueprint;
15
16 class dailyupload_calllog extends Command {
17
18 /**
19 * The console command name.
20 *
21 * @var string
22 */
23 protected $signature = 'dailyupload_calllog';
24
25 /**
26 * The console command description.
27 *
28 * @var string
29 */
30 protected $description = 'dailyupload_calllog';
31
32 /**
33 * Execute the console command.
34 *
35 * @return mixed
36 */
37 public function handle()
38 {
39 $nowts=time();
40 echo "\n".date('Y-m-d H:i:s')."\n";
41 $logdate=strtotime('0 day');
42
43 $tcol=0;$fieldsarr=array();$extrahdrarr=array();
44 $server_ip=env('app_ip');
45 $central_ip=env('central_ip');
46 $calllog_report = "calllog_report_".date("d_m_Y",$logdate);
47 $created_at=date("Y-m-d H:i:s");
48
49 $conn = array(
50 'driver' => 'mysql',
51 'host' => $central_ip,
52 'database' => env('DB_DATABASE', 'kstych_flexydial'),
53 'username' => env('DB_USERNAME', 'root'),
54 'password' => env('DB_PASSWORD', ''),
55 'charset' => 'utf8',
56 'collation' => 'utf8_unicode_ci',
57 'prefix' => '',
58 'options' => array(
59 PDO::ATTR_TIMEOUT => 5,
60 ),
61 );
62 Config::set("database.connections.conn", $conn);
63 if(DB::connection("conn")->getDatabaseName())
64 {
65
66 $serverclist=DB::connection("conn")->select(DB::raw("select id from server_details where server_ip='$server_ip'"));
67 $server_id=$serverclist[0]->id;
68 if($server_id<10){
69 $server_id="0".$server_id;
70 }
71
72 $clist=DB::connection("conn")->select(DB::raw("select count(*) as cnt,server from $calllog_report group by server"));
73 $caar=[];
74 foreach($clist as $cline)
75 {
76 $caar[$cline->server]= $cline->cnt;
77
78
79 }
80 $mlist=DB::select(DB::raw("select count(*) as countrecord from crmcalls where created_at>'".date("Y-m-d",$logdate)."' and created_at<'".date("Y-m-d",$logdate+24*60*60)."'"));
81
82 $location_cont='0';
83 $central_cont='0';
84
85 $location_cont=$mlist[0]->countrecord;
86 if(array_key_exists($server_id,$caar)){
87 $central_cont=$caar[$server_id];
88 }else{
89 $central_cont=0;
90
91 }
92 $dif=($central_cont)-($mlist[0]->countrecord);
93
94 if($dif==0){
95
96 $result="Y";
97
98 DB::connection("conn")->insert(DB::raw("insert into dailyupload_calllog_records set created_at='$created_at',server_id='$server_id',server_ip='$server_ip',central_count='$central_cont',location_count='$location_cont',difference='$dif',result='$result'"));
99
100 }else{
101
102 $result="N";
103 DB::connection("conn")->insert(DB::raw("insert into dailyupload_calllog_records set created_at='$created_at',server_id='$server_id',server_ip='$server_ip',central_count='$central_cont',location_count='$location_cont',difference='$dif',result='$result'"));
104
105 }
106
107 DB::connection("conn")->disconnect();
108
109 }
110
111 }
112
113
114 }
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4 use DB;
5 use Config;
6
7 use App\Models\User;
8 use App\Models\Accesslog;
9
10 use App\Models\CRMCall;
11 use Schema;
12 use PDO;
13
14 use Illuminate\Database\Schema\Blueprint;
15
16 class dailyupload_questionaire extends Command {
17
18 /**
19 * The console command name.
20 *
21 * @var string
22 */
23 protected $signature = 'dailyupload_questionaire';
24
25 /**
26 * The console command description.
27 *
28 * @var string
29 */
30 protected $description = 'dailyupload_questionaire';
31
32 /**
33 * Execute the console command.
34 *
35 * @return mixed
36 */
37 public function handle()
38 {
39 $nowts=time();
40 echo "\n".date('Y-m-d H:i:s')."\n";
41
42
43 $logdate=strtotime('0 day');
44
45 $tcol=0;$fieldsarr=array();$extrahdrarr=array();
46 $server_ip=env('app_ip');
47 $central_ip=env('central_ip');
48 $questionaire_details = "questionaire_details_".date("d_m_Y",$logdate);
49 $created_at=date("Y-m-d H:i:s");
50
51 $conn = array(
52 'driver' => 'mysql',
53 'host' => $central_ip,
54 'database' => env('DB_DATABASE', 'kstych_flexydial'),
55 'username' => env('DB_USERNAME', 'root'),
56 'password' => env('DB_PASSWORD', ''),
57 'charset' => 'utf8',
58 'collation' => 'utf8_unicode_ci',
59 'prefix' => '',
60 'options' => array(
61 PDO::ATTR_TIMEOUT => 5,
62 ),
63 );
64 Config::set("database.connections.conn", $conn);
65
66
67 if(DB::connection("conn")->getDatabaseName())
68 {
69
70 $serverclist=DB::connection("conn")->select(DB::raw("select id from server_details where server_ip='$server_ip'"));
71 $server_id=$serverclist[0]->id;
72 if($server_id<10){
73 $server_id="0".$server_id;
74 }
75
76
77 $clist=DB::connection("conn")->select(DB::raw("select count(*) as cnt,server from $questionaire_details group by server"));
78
79 $caar=[];
80 foreach($clist as $cline)
81 {
82 $caar[$cline->server]= $cline->cnt;
83 }
84
85 $mlist=DB::select(DB::raw("select count(*) as countrecord from questionaire_details where created_at>'".date("Y-m-d",$logdate)."' and created_at<'".date("Y-m-d",$logdate+24*60*60)."'"));
86
87 $location_cont='0';
88 $central_cont='0';
89
90 $location_cont=$mlist[0]->countrecord;
91 if(array_key_exists($server_id,$caar)){
92 $central_cont=$caar[$server_id];
93 }else{
94 $central_cont=0;
95
96 }
97 $dif=($central_cont)-($mlist[0]->countrecord);
98
99 if($dif==0){
100
101 $result="Y";
102
103 DB::connection("conn")->insert(DB::raw("insert into dailyupload_questionaire set created_at='$created_at',server_id='$server_id',server_ip='$server_ip',central_count='$central_cont',location_count='$location_cont',difference='$dif',result='$result'"));
104
105 }else{
106
107 $result="N";
108 DB::connection("conn")->insert(DB::raw("insert into dailyupload_questionaire set created_at='$created_at',server_id='$server_id',server_ip='$server_ip',central_count='$central_cont',location_count='$location_cont',difference='$dif',result='$result'"));
109
110 }
111
112 DB::connection("conn")->disconnect();
113
114 }
115
116 }
117
118
119 }
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4 use DB;
5 use Config;
6
7 use App\Models\User;
8 use App\Models\Accesslog;
9
10 use App\Models\CRMCall;
11 use Schema;
12 use PDO;
13
14 use Illuminate\Database\Schema\Blueprint;
15
16 class full_remark_details extends Command {
17
18 /**
19 * The console command name.
20 *
21 * @var string
22 */
23 protected $signature = 'full_remark_details';
24
25 /**
26 * The console command description.
27 *
28 * @var string
29 */
30 protected $description = 'full_remark_details';
31
32 /**
33 * Execute the console command.
34 *
35 * @return mixed
36 */
37 public function handle()
38 {
39 $nowts=time();
40 echo "\n".date('Y-m-d H:i:s')."\n";
41
42
43 $logdate=strtotime('0 day');
44
45 $tcol=0;$fieldsarr=array();$extrahdrarr=array();
46 $server_ip=env('app_ip');
47 $full_remark = "full_remark_details";
48 $central_ip=env('central_ip');
49
50 $conn = array(
51 'driver' => 'mysql',
52 'host' => $central_ip,
53 'database' => env('DB_DATABASE', 'kstych_flexydial'),
54 'username' => env('DB_USERNAME', 'root'),
55 'password' => env('DB_PASSWORD', ''),
56 'charset' => 'utf8',
57 'collation' => 'utf8_unicode_ci',
58 'prefix' => '',
59 'options' => array(
60 PDO::ATTR_TIMEOUT => 5,
61 ),
62 );
63 Config::set("database.connections.conn", $conn);
64
65
66 if(DB::connection("conn")->getDatabaseName())
67 {
68 $serverclist=DB::connection("conn")->select(DB::raw("select id from server_details where server_ip='$server_ip'"));
69 $server_id=$serverclist[0]->id;
70 if($server_id<10){
71 $server_id="0".$server_id;
72 }
73
74 $maxid=DB::connection("conn")->select(DB::raw("SELECT max(full_remark_id) as maxid from $full_remark where server_id='$server_id'"));
75
76 $maxids=$maxid[0]->maxid;
77
78 //$qlist=DB::select(DB::raw("SELECT * from full_remark"));
79 $qlist=DB::select(DB::raw("SELECT * from full_remark where id>'$maxids' and created_at>'".date("Y-m-d")."' and created_at<'".date("Y-m-d H:i:s",$logdate-(60*60))."'"));
80
81 $userarr=array();
82 foreach($qlist as $qline)
83 {
84
85 $setstrarr=array();
86
87 $setstrarr[]="server_id='$server_id'";
88 $setstrarr[]="full_remark_id='$qline->id'";
89 $setstrarr[]="call_id='$qline->call_id'";
90 $setstrarr[]="fullremark='$qline->fullremark'";
91 $setstrarr[]="created_at='$qline->created_at'";
92
93 $setstr=implode(",",$setstrarr);
94 DB::connection("conn")->insert(DB::raw("insert into ".$full_remark." set $setstr"));
95
96 }
97 DB::connection("conn")->disconnect();
98
99 }
100
101 }
102
103
104 }
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4 use DB;
5 use Config;
6
7 use App\Models\User;
8 use App\Models\Accesslog;
9
10 use App\Models\CRMCall;
11 use Schema;
12 use PDO;
13
14 use Illuminate\Database\Schema\Blueprint;
15
16 class lead_form_details extends Command {
17
18 /**
19 * The console command name.
20 *
21 * @var string
22 */
23 protected $signature = 'lead_form_details';
24
25 /**
26 * The console command description.
27 *
28 * @var string
29 */
30 protected $description = 'lead_form_details';
31
32 /**
33 * Execute the console command.
34 *
35 * @return mixed
36 */
37 public function handle()
38 {
39 $nowts=time();
40 echo "\n".date('Y-m-d H:i:s')."\n";
41
42
43 $logdate=strtotime('0 day');
44
45 $tcol=0;$fieldsarr=array();$extrahdrarr=array();
46 $server_ip=env('app_ip');
47 $lead_form = "lead_form_details";
48 $central_ip=env('central_ip');
49
50 $conn = array(
51 'driver' => 'mysql',
52 'host' => $central_ip,
53 'database' => env('DB_DATABASE', 'kstych_flexydial'),
54 'username' => env('DB_USERNAME', 'root'),
55 'password' => env('DB_PASSWORD', ''),
56 'charset' => 'utf8',
57 'collation' => 'utf8_unicode_ci',
58 'prefix' => '',
59 'options' => array(
60 PDO::ATTR_TIMEOUT => 5,
61 ),
62 );
63 Config::set("database.connections.conn", $conn);
64
65
66 if(DB::connection("conn")->getDatabaseName())
67 {
68 $serverclist=DB::connection("conn")->select(DB::raw("select id,location from server_details where server_ip='$server_ip'"));
69 $server_id=$serverclist[0]->id;
70 if($server_id<10){
71 $server_id="0".$server_id;
72 }
73 $location=$serverclist[0]->location;
74 $maxid=DB::connection("conn")->select(DB::raw("SELECT max(lead_form_id) as maxid from lead_form_details where server_ip='$server_ip'"));
75
76 $maxids=$maxid[0]->maxid;
77
78 $qlist=DB::select(DB::raw("SELECT * from lead_form where id>'$maxids'"));
79 $userarr=array();
80 foreach($qlist as $qline)
81 {
82
83 $setstrarr=array();
84
85 $crtdate=date("Y-m-d H:i:s",strtotime($qline->created_at)+330*60);
86 $update=date("Y-m-d H:i:s",strtotime($qline->updated_at)+330*60);
87
88
89 $setstrarr[]="lead_form_id='$qline->id'";
90 $setstrarr[]="created_at='$crtdate'";
91 $setstrarr[]="updated_at='$update'";
92 $setstrarr[]="br_code='$qline->br_code'";
93 $setstrarr[]="br_name='$qline->br_name'";
94 $setstrarr[]="lg_code='$qline->lg_code'";
95 $setstrarr[]="processing_entity='$qline->processing_entity'";
96 $setstrarr[]="lead_owner='$qline->lead_owner'";
97 $setstrarr[]="lead_priority='$qline->lead_priority'";
98 $setstrarr[]="product='$qline->product'";
99 $setstrarr[]="customer_profile='$qline->customer_profile'";
100 $setstrarr[]="customer_name='$qline->customer_name'";
101 $setstrarr[]="connected_number='$qline->connected_number'";
102 $setstrarr[]="remarks='$qline->remarks'";
103 $setstrarr[]="mobile='$qline->mobile'";
104 $setstrarr[]="client='$qline->client'";
105 $setstrarr[]="user_id='$qline->user_id'";
106 $setstrarr[]="firstname='$qline->firstname'";
107 $setstrarr[]="clientcode='$qline->clientcode'";
108 $setstrarr[]="call_id='$qline->call_id'";
109 $setstrarr[]="record_id='$qline->record_id'";
110 $setstrarr[]="server_id='$server_id'";
111 $setstrarr[]="server_ip='$server_ip'";
112
113 $setstr=implode(",",$setstrarr);
114 DB::connection("conn")->insert(DB::raw("insert into lead_form_details set $setstr"));
115
116 }
117 DB::connection("conn")->disconnect();
118
119 }
120
121 }
122
123
124 }
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4 use DB;
5 use Config;
6
7 use App\Models\User;
8 use App\Models\Accesslog;
9
10 use App\Models\CRMCall;
11 use Schema;
12 use PDO;
13
14 use Illuminate\Database\Schema\Blueprint;
15
16 class leadform_products extends Command {
17
18 /**
19 * The console command name.
20 *
21 * @var string
22 */
23 protected $signature = 'leadform_products';
24
25 /**
26 * The console command description.
27 *
28 * @var string
29 */
30 protected $description = 'leadform_products';
31
32 /**
33 * Execute the console command.
34 *
35 * @return mixed
36 */
37 public function handle()
38 {
39 $nowts=time();
40 echo "\n".date('Y-m-d H:i:s')."\n";
41
42
43 $logdate=strtotime('0 day');
44
45 $tcol=0;$fieldsarr=array();$extrahdrarr=array();
46 $server_ip=env('app_ip');
47 $lead_form = "lead_form_details";
48 $central_ip=env('central_ip');
49
50 $conn = array(
51 'driver' => 'mysql',
52 'host' => $central_ip,
53 'database' => env('DB_DATABASE', 'kstych_flexydial'),
54 'username' => env('DB_USERNAME', 'root'),
55 'password' => env('DB_PASSWORD', ''),
56 'charset' => 'utf8',
57 'collation' => 'utf8_unicode_ci',
58 'prefix' => '',
59 'options' => array(
60 PDO::ATTR_TIMEOUT => 5,
61 ),
62 );
63 Config::set("database.connections.conn", $conn);
64
65
66 if(DB::connection("conn")->getDatabaseName())
67 {
68 DB::table('leadform_products')->truncate();
69
70 $qlist=DB::connection("conn")->select(DB::raw("SELECT * from UD_PRODUCT_MASTER"));
71 $userarr=array();
72 foreach($qlist as $qline)
73 {
74
75 $setstrarr=array();
76
77 $setstrarr[]="products='$qline->PRODUCT_NAME'";
78
79 $setstr=implode(",",$setstrarr);
80 DB::insert(DB::raw("insert into leadform_products set $setstr"));
81
82 }
83 DB::table('UD_CRM_BR_MASTER')->truncate();
84
85 $qlist=DB::connection("conn")->select(DB::raw("SELECT * from UD_CRM_BR_MASTER"));
86 $userarr=array();
87 foreach($qlist as $qline)
88 {
89
90 $setstrarr=array();
91
92 $setstrarr[]="BR_CODE='$qline->BR_CODE'";
93 $setstrarr[]="BR_NAME='$qline->BR_NAME'";
94 $setstrarr[]="STATUS='$qline->STATUS'";
95 $setstrarr[]="INS_DATE='$qline->INS_DATE'";
96 $setstrarr[]="REMARKS='$qline->REMARKS'";
97 $setstrarr[]="FIELD1='$qline->FIELD1'";
98 $setstrarr[]="FIELD2='$qline->FIELD2'";
99
100 $setstr=implode(",",$setstrarr);
101 DB::insert(DB::raw("insert into UD_CRM_BR_MASTER set $setstr"));
102
103 }
104 DB::table('UD_LEAD_ENTRY_CUSTOMER_PROFILE')->truncate();
105
106 $qlist=DB::connection("conn")->select(DB::raw("SELECT * from UD_LEAD_ENTRY_CUSTOMER_PROFILE"));
107 $userarr=array();
108 foreach($qlist as $qline)
109 {
110
111 $setstrarr=array();
112
113 $setstrarr[]="CUST_PROFILE='$qline->CUST_PROFILE'";
114 $setstrarr[]="INS_DATE='$qline->INS_DATE'";
115 $setstrarr[]="STATUS='$qline->STATUS'";
116
117 $setstr=implode(",",$setstrarr);
118 DB::insert(DB::raw("insert into UD_LEAD_ENTRY_CUSTOMER_PROFILE set $setstr"));
119
120 }
121 DB::table('UD_SM_MAPPING')->truncate();
122
123 $qlist=DB::connection("conn")->select(DB::raw("SELECT * from UD_SM_MAPPING"));
124 $userarr=array();
125 foreach($qlist as $qline)
126 {
127
128 $setstrarr=array();
129 //$qlist_BR_NAME=preg_replace("/[^ \w]+/","", $qline->BR_NAME);
130 $setstrarr[]="USER_NAME='$qline->USER_NAME'";
131 $setstrarr[]="EMPLOYEE_CODE='$qline->EMPLOYEE_CODE'";
132
133 $setstr=implode(",",$setstrarr);
134 DB::insert(DB::raw("insert into UD_SM_MAPPING set $setstr"));
135
136 }
137 DB::connection("conn")->disconnect();
138
139 }
140
141 }
142
143 }
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4 use DB;
5 use Config;
6
7 use App\Models\User;
8 use App\Models\Accesslog;
9
10 use App\Models\CRMCall;
11 use Schema;
12 use PDO;
13
14 use Illuminate\Database\Schema\Blueprint;
15
16 class oa_leadform_details extends Command {
17
18 /**
19 * The console command name.
20 *
21 * @var string
22 */
23 protected $signature = 'oa_leadform_details';
24
25 /**
26 * The console command description.
27 *
28 * @var string
29 */
30 protected $description = 'oa_leadform_details';
31
32 /**
33 * Execute the console command.
34 *
35 * @return mixed
36 */
37 public function handle()
38 {
39 $nowts=time();
40 echo "\n".date('Y-m-d H:i:s')."\n";
41
42
43 $logdate=strtotime('0 day');
44
45 $tcol=0;$fieldsarr=array();$extrahdrarr=array();
46 $server_ip=env('app_ip');
47 $oa_leadform_details = "oa_leadform_details";
48 $central_ip=env('central_ip');
49
50 $conn = array(
51 'driver' => 'mysql',
52 'host' => $central_ip,
53 'database' => env('DB_DATABASE', 'kstych_flexydial'),
54 'username' => env('DB_USERNAME', 'root'),
55 'password' => env('DB_PASSWORD', ''),
56 'charset' => 'utf8',
57 'collation' => 'utf8_unicode_ci',
58 'prefix' => '',
59 'options' => array(
60 PDO::ATTR_TIMEOUT => 5,
61 ),
62 );
63 Config::set("database.connections.conn", $conn);
64
65
66 if(DB::connection("conn")->getDatabaseName())
67 {
68 $serverclist=DB::connection("conn")->select(DB::raw("select id,location from server_details where server_ip='$server_ip'"));
69 $server_id=$serverclist[0]->id;
70 if($server_id<10){
71 $server_id="0".$server_id;
72 }
73 $location=$serverclist[0]->location;
74 $maxid=DB::connection("conn")->select(DB::raw("SELECT max(oa_lead_id) as maxid from oa_leadform_details where server_ip='$server_ip'"));
75 $maxids=$maxid[0]->maxid;
76
77 $qlist=DB::select(DB::raw("SELECT * from oa_leadform where id>'$maxids'"));
78 $userarr=array();
79 foreach($qlist as $qline)
80 {
81
82 $setstrarr=array();
83
84 $setstrarr[]="server_id='$server_id'";
85 $setstrarr[]="server_ip='$server_ip'";
86 $setstrarr[]="oa_lead_id='$qline->id'";
87 $setstrarr[]="created_at='$qline->created_at'";
88 $setstrarr[]="updated_at='$qline->updated_at'";
89 $setstrarr[]="call_created_at='$qline->call_created_at'";
90 $setstrarr[]="call_id='$qline->call_id'";
91 $setstrarr[]="record_id='$qline->record_id'";
92 $setstrarr[]="customer_name='$qline->customer_name'";
93 $setstrarr[]="mobile='$qline->mobile'";
94 $setstrarr[]="call_number='$qline->call_number'";
95 $setstrarr[]="pbcode='$qline->pbcode'";
96 $setstrarr[]="emailid='$qline->emailid'";
97 $setstrarr[]="cod_cust='$qline->cod_cust'";
98 $setstrarr[]="ucic_id='$qline->ucic_id'";
99 $setstrarr[]="unit='$qline->unit'";
100 $setstrarr[]="cust_remarks='$qline->cust_remarks'";
101 $setstrarr[]="agent_remarks='$qline->agent_remarks'";
102 $setstrarr[]="user_id='$qline->user_id'";
103
104 $setstr=implode(",",$setstrarr);
105
106 DB::connection("conn")->insert(DB::raw("insert into ".$oa_leadform_details." set $setstr"));
107
108 }
109
110 DB::connection("conn")->disconnect();
111 }
112 }
113 }
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4
5 use DB;
6 use App\Models\RelationshipService;
7 use App\Models\RelationshipCategory;
8 use App\Models\RelationshipSubCategory;
9
10 use Config;
11 use Schema;
12 use PDO;
13
14 use Illuminate\Database\Schema\Blueprint;
15
16 class relationship_tag extends Command {
17
18 /**
19 * The console command name.
20 *
21 * @var string
22 */
23 protected $signature = 'relationship_tag';
24
25 /**
26 * The console command description.
27 *
28 * @var string
29 */
30 protected $description = 'relationship_tag';
31
32 /**
33 * Execute the console command.
34 *
35 * @return mixed
36 */
37 public function handle()
38 {
39 $nowts=time();
40
41 echo date('Y-m-d H:i:s')."\n";
42
43 $tcol=0;$fieldsarr=array();$extrahdrarr=array();
44 $server_ip=env('app_ip');
45 $central_ip=env('central_ip');
46
47 $conn = array(
48 'driver' => 'mysql',
49 'host' => $central_ip,
50 'database' => env('DB_DATABASE', 'kstych_flexydial'),
51 'username' => env('DB_USERNAME', 'root'),
52 'password' => env('DB_PASSWORD', ''),
53 'charset' => 'utf8',
54 'collation' => 'utf8_unicode_ci',
55 'prefix' => '',
56 'options' => array(
57 PDO::ATTR_TIMEOUT => 5,
58 ),
59 );
60
61 Config::set("database.connections.conn", $conn);
62
63 if(DB::connection("conn")->getDatabaseName())
64 {
65 $relationshipList = DB::connection("conn")->select(DB::raw("SELECT * FROM relationship_tagging"));
66
67 $relationshipData = 0; $newService = 0; $newCategory = 0; $newSubCategory = 0;
68
69 foreach ($relationshipList as $list) {
70 $service = RelationshipService::where('title','=',$list->service)->first();
71
72 if(count($service)){
73 $serviceId = $service->id;
74 }else{
75 $addService = RelationshipService::create(['title'=>$list->service]);
76 $serviceId = $addService->id;
77 $newService++;
78 }
79 echo $list->service." : ".$serviceId." - ";
80
81 $category = RelationshipCategory::where('service_id','=',$serviceId)->where('title','=',$list->category)->first();
82
83 if(count($category)){
84 $categoryId = $category->id;
85 }else{
86 $addCategory = RelationshipCategory::create(['service_id'=>$serviceId,'title'=>$list->category]);
87 $categoryId = $addCategory->id;
88 $newCategory++;
89 }
90 echo $list->category." : ".$categoryId." - ";
91
92 $subCategory = RelationshipSubCategory::where('category_id','=',$categoryId)->where('title','=',$list->sub_category)->first();
93
94 if(count($subCategory)){
95 $subCategoryId = $subCategory->id;
96 }else{
97 $addSubCategory = RelationshipSubCategory::create(['category_id'=>$categoryId,'title'=>$list->sub_category,'status'=>$list->status]);
98 $subCategoryId = $addSubCategory->id;
99 $newSubCategory++;
100 }
101 echo $list->sub_category." : ".$subCategoryId."\n";
102
103 //DB::table('relationship_tagging')->where('id', $list->id)->update(['status'=>'InActive']);
104 $relationshipData++;
105 }
106 echo "Total ".$relationshipData." data process and ". $newService." service, ".$newCategory." category, ".$newSubCategory." sub category added\n";
107
108 DB::connection("conn")->disconnect();
109
110 }
111
112 }
113
114 }
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4 use DB;
5 use Config;
6
7 use App\Models\User;
8 use App\Models\Accesslog;
9
10 use App\Models\CRMCall;
11 use Schema;
12 use PDO;
13
14 use Illuminate\Database\Schema\Blueprint;
15
16 class question_tree extends Command {
17
18 /**
19 * The console command name.
20 *
21 * @var string
22 */
23 protected $signature = 'question_tree';
24
25 /**
26 * The console command description.
27 *
28 * @var string
29 */
30 protected $description = 'question_tree';
31
32 /**
33 * Execute the console command.
34 *
35 * @return mixed
36 */
37 public function handle()
38 {
39 $nowts=time();
40 echo "\n".date('Y-m-d H:i:s')."\n";
41
42 $tcol=0;$fieldsarr=array();$extrahdrarr=array();
43 $server_ip=env('app_ip');
44 $lead_form = "lead_form_details";
45 $central_ip=env('central_ip');
46
47 $conn = array(
48 'driver' => 'mysql',
49 'host' => $central_ip,
50 'database' => env('DB_DATABASE', 'kstych_flexydial'),
51 'username' => env('DB_USERNAME', 'root'),
52 'password' => env('DB_PASSWORD', ''),
53 'charset' => 'utf8',
54 'collation' => 'utf8_unicode_ci',
55 'prefix' => '',
56 'options' => array(
57 PDO::ATTR_TIMEOUT => 5,
58 ),
59 );
60 Config::set("database.connections.conn", $conn);
61
62
63 if(DB::connection("conn")->getDatabaseName())
64 {
65 DB::table('question_tree')->truncate();
66 DB::table('question')->truncate();
67
68
69 $qlist=DB::connection("conn")->select(DB::raw("SELECT * from question_tree"));
70
71 foreach($qlist as $qline)
72 {
73
74 $setstrarr=array();
75
76 $setstrarr[]="parent_id='$qline->parent_id'";
77 $setstrarr[]="parent_opt='$qline->parent_opt'";
78 $setstrarr[]="question_id='$qline->question_id'";
79 $setstrarr[]="priority='$qline->priority'";
80
81 $setstr=implode(",",$setstrarr);
82 DB::insert(DB::raw("insert into question_tree set $setstr"));
83
84 }
85
86 $slist=DB::connection("conn")->select(DB::raw("SELECT * from question_bank"));
87 foreach($slist as $sline)
88 {
89
90 $setstrarr=array();
91
92 $setstrarr[]="question_no='$sline->question_no'";
93 $setstrarr[]="questions='$sline->questions'";
94 $setstrarr[]="opt_1='$sline->opt_1'";
95 $setstrarr[]="opt_2='$sline->opt_2'";
96 $setstrarr[]="opt_3='$sline->opt_3'";
97 $setstrarr[]="opt_4='$sline->opt_4'";
98 $setstrarr[]="opt_5='$sline->opt_5'";
99 $setstrarr[]="opt_6='$sline->opt_6'";
100 $setstrarr[]="opt_7='$sline->opt_7'";
101 $setstrarr[]="opt_8='$sline->opt_8'";
102 $setstrarr[]="opt_9='$sline->opt_9'";
103 $setstrarr[]="opt_10='$sline->opt_10'";
104 $setstrarr[]="type='$sline->type'";
105 $setstrarr[]="compulsory_qes='$sline->compulsory_qes'";
106
107 $setstr=implode(",",$setstrarr);
108 DB::insert(DB::raw("insert into question set $setstr"));
109
110 }
111 DB::connection("conn")->disconnect();
112
113 }
114
115 }
116
117
118 }
1 <?php namespace App\Console\Commands;
2
3 use Illuminate\Console\Command;
4 use DB;
5 use Config;
6
7 use App\Models\User;
8 use App\Models\Accesslog;
9
10 use App\Models\CRMCall;
11 use Schema;
12 use PDO;
13
14 use Illuminate\Database\Schema\Blueprint;
15
16 class questionnaire_details extends Command {
17
18 /**
19 * The console command name.
20 *
21 * @var string
22 */
23 protected $signature = 'questionnaire_details';
24
25 /**
26 * The console command description.
27 *
28 * @var string
29 */
30 protected $description = 'questionnaire_details';
31
32 /**
33 * Execute the console command.
34 *
35 * @return mixed
36 */
37 public function handle()
38 {
39 $nowts=time();
40 echo "\n".date('Y-m-d')."\n";
41
42
43 //$logdate=strtotime('0 day');
44
45 $logdate=strtotime('0 day'. '00:00:00');
46
47 $logtodate=strtotime('0 day'. '23:59:59');
48
49 $tcol=0;$fieldsarr=array();$extrahdrarr=array();
50 $questionaire = "questionaire_details_".date("d_m_Y");
51 $server_ip=env('app_ip');
52 $central_ip=env('central_ip');
53
54 $conn = array(
55 'driver' => 'mysql',
56 'host' => $central_ip,
57 'database' => env('DB_DATABASE', 'kstych_flexydial'),
58 'username' => env('DB_USERNAME', 'root'),
59 'password' => env('DB_PASSWORD', ''),
60 'charset' => 'utf8',
61 'collation' => 'utf8_unicode_ci',
62 'prefix' => '',
63 'options' => array(
64 PDO::ATTR_TIMEOUT => 5,
65 ),
66 );
67 Config::set("database.connections.conn", $conn);
68
69
70 if(DB::connection("conn")->getDatabaseName())
71 {
72 $serverclist=DB::connection("conn")->select(DB::raw("select id from server_details where server_ip='$server_ip'"));
73 $server_id=$serverclist[0]->id;
74 if($server_id<10){
75 $server_id="0".$server_id;
76 }
77
78 echo ",".$server_id;
79
80 $maxid=DB::connection("conn")->select(DB::raw("SELECT max(question_id) as maxid from $questionaire where server='$server_id'"));
81
82 $maxids=$maxid[0]->maxid;
83
84 //$qlist=DB::select(DB::raw("SELECT * from questionaire_details where id>'$maxids' and created_at>'".date("Y-m-d 00:00:00")."' and created_at<'".date("Y-m-d ")."'"));
85
86 //$qlist=DB::select(DB::raw("SELECT * from questionaire_details where id>'$maxids' and created_at>'".date("Y-m-d H:i:s",$logdate)."' and created_at<'".date("Y-m-d H:i:s",$logtodate)."'"));
87
88 $qlist=DB::select(DB::raw("SELECT * from questionaire_details where id>'$maxids' and created_at>'".date("Y-m-d H:i:s",$logdate)."'"));
89
90
91 $userarr=array();
92 foreach($qlist as $qline)
93 {
94
95 $setstrarr=array();
96
97 $crtdate=date("Y-m-d H:i:s",strtotime($qline->created_at)+330*60);
98 $update=date("Y-m-d H:i:s",strtotime($qline->updated_at)+330*60);
99
100 $qtime=date("Y-m-d H:i:s",strtotime($qline->question_time)+330*60);
101
102 $setstrarr[]="server='$server_id'";
103 $setstrarr[]="question_id='$qline->id'";
104 $countid=DB::connection("conn")->select(DB::raw("SELECT count(question_id) as countid from $questionaire where server='$server_id' and question_id='$qline->id'"));
105 $countids=$countid[0]->countid;
106 if($countids>0){continue;}
107 $setstrarr[]="created_at='$crtdate'";
108 $setstrarr[]="updated_at='$update'";
109 $setstrarr[]="user_id='$qline->user_id'";
110 $setstrarr[]="cust_id='$qline->cust_id'";
111 $setstrarr[]="call_id='$qline->call_id'";
112 $setstrarr[]="name='$qline->name'";
113 $setstrarr[]="number='$qline->number'";
114 $setstrarr[]="question_time='$qtime'";
115
116 $setstrarr[]="question='$qline->question'";
117 $setstrarr[]="primary_question='$qline->primary_question'";
118 $setstrarr[]="primary_response='$qline->primary_response'";
119 $setstrarr[]="primary_text='$qline->primary_text'";
120 $setstrarr[]="followup1_question='$qline->followup1_question'";
121 $setstrarr[]="followup1_response='$qline->followup1_response'";
122 $setstrarr[]="followup1_text='$qline->followup1_text'";
123 $setstrarr[]="followup2_question='$qline->followup2_question'";
124 $setstrarr[]="followup2_response='$qline->followup2_response'";
125 $setstrarr[]="followup2_text='$qline->followup2_text'";
126 $setstrarr[]="followup3_question='$qline->followup3_question'";
127 $setstrarr[]="followup3_response='$qline->followup3_response'";
128 $setstrarr[]="followup3_text='$qline->followup3_text'";
129 $setstrarr[]="followup4_question='$qline->followup4_question'";
130 $setstrarr[]="followup4_response='$qline->followup4_response'";
131 $setstrarr[]="followup4_text='$qline->followup4_text'";
132 $setstrarr[]="followup5_question='$qline->followup5_question'";
133 $setstrarr[]="followup5_response='$qline->followup5_response'";
134 $setstrarr[]="followup5_text='$qline->followup5_text'";
135 $setstrarr[]="followup6_question='$qline->followup6_question'";
136 $setstrarr[]="followup6_response='$qline->followup6_response'";
137 $setstrarr[]="followup6_text='$qline->followup6_text'";
138 $setstrarr[]="followup7_question='$qline->followup7_question'";
139 $setstrarr[]="followup7_response='$qline->followup7_response'";
140 $setstrarr[]="followup7_text='$qline->followup7_text'";
141
142 $setstr=implode(",",$setstrarr);
143 DB::connection("conn")->insert(DB::raw("insert into ".$questionaire." set $setstr"));
144 //DB::connection("conn")->insert(DB::raw("insert into questionaire_details_daily set $setstr"));
145 }
146 DB::connection("conn")->disconnect();
147
148 }
149
150 }
151
152
153 }
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
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.
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!