ContactGroup.php
2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php namespace App\Console\Commands;
use Illuminate\Console\Command;
//use Mail;
use DB;
use Config;
use App\Models\User;
use App\Models\Accesslog;
use App\Models\CRMCall;
use Schema;
use PDO;
use Illuminate\Database\Schema\Blueprint;
class ContactGroup extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'ContactGroup';
/**
* The console command description.
*
* @var string
*/
protected $description = 'App Main Daily Task for ContactGroup';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$nowts=time();
$date=date('F_Y');
echo "\n".date('Y-m-d H:i:s')."\n";
$logdate=strtotime('0 day');
$central_ip=env('central_ip');
$server_ip=env('app_ip');
$calllog_report = "calllog_report_".$date;
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'options' => array(
PDO::ATTR_TIMEOUT => 5,
),
);
Config::set("database.connections.conn", $conn);
DB::connection("conn")->getDatabaseName();
$serverclist=DB::connection("conn")->select(DB::raw("select id from server_details where server_ip='$server_ip'"));
$server_id=$serverclist[0]->id;
if($server_id<10){
$server_id="0".$server_id;
}
$contact=DB::connection("conn")->select(DB::raw("SELECT * from contactserver where server_ip='$server_ip'"));
foreach ($contact as $cline) {
$name=$cline->name;
$slug=$cline->slug;
$priority=$cline->priority;
$contact_limit=$cline->contacted_limit;
$contact_count=$cline->contacted_count;
$status=$cline->status;
$created_at=date('Y-m-d H:i:s');
$updated_at=date('Y-m-d H:i:s');
DB::insert(DB::raw("INSERT INTO contact_group set `name`=$name,`slug`=$slug,`priority`=$priority,`contacted_limit`=$contact_limit,`contacted_count`=$contact_count,`status`=$status,`created_at`=$created_at,`updated_at`=$updated_at"));
}
echo "\n".date('Y-m-d H:i:s')."\n";
DB::connection("conn")->disconnect();
}
}