36b5f5c0 by Manish Mihsra

Added updated sms report file and created one more module to assign any role

1 parent 207e0cdb
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 Smsreport extends Command {
18
19 /**
20 * The console command name.
21 *
22 * @var string
23 */
24 protected $signature = 'Smsreport';
25
26 /**
27 * The console command description.
28 *
29 * @var string
30 */
31 protected $description = 'App Main Daily Task for Smsreport';
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 $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=str_pad($serverclist[0]->id, 2, '0', STR_PAD_LEFT);
69
70 $maxid=DB::connection("conn")->select(DB::raw("SELECT max(sms_id) as maxid from sms_report where server='$server_id'"));
71
72 $maxids=$maxid[0]->maxid;
73
74 $alist=DB::select(DB::raw("SELECT * from sms_log where id>'$maxids'"));
75 $iii=0;
76 $shortinsert="";
77 foreach($alist as $aline)
78 {
79 $iii++;
80 $server = $server_id;
81 $sms_id = $aline->id;
82 $created_at = $aline->created_at;
83 $message_time = date("Y-m-d H:i:s",strtotime($aline->created_at)+330*60);
84 $server_ip = $aline->server_ip;
85 $call_id = $aline->call_id;
86 $agent_name = $aline->agent_name;
87 $subdispo = $aline->subdispo;
88 $number = $aline->number;
89 $message = $aline->message;
90 $response = $aline->response;
91
92 $shortinsert.="('$server', '$sms_id','$created_at', '$message_time', '$server_ip', '$call_id', '$agent_name', '$subdispo', '$number', '$message', '$response'),";
93
94 if($iii%50==0 || $iii == count($alist)){
95
96 $shortinsert=substr($shortinsert,0,-1);
97 DB::connection("conn")->insert(DB::raw("INSERT INTO sms_report (`server`, `sms_id`, `created_at`, `message_time`, `server_ip`, `call_id`, `agent_name`, `subdispo`, `number`, `message`, `response`) VALUES $shortinsert"));
98 $shortinsert="";
99 }
100 }
101 echo "\n".date('Y-m-d H:i:s')."\n";
102 DB::connection("conn")->disconnect();
103 }
104 }
...\ No newline at end of file ...\ No newline at end of file
...@@ -121,6 +121,7 @@ return [ ...@@ -121,6 +121,7 @@ return [
121 "Record" => ["disp"=>"Record","icon"=>"file","dash"=>"","onclick"=>""], 121 "Record" => ["disp"=>"Record","icon"=>"file","dash"=>"","onclick"=>""],
122 "User" => ["disp"=>"User","icon"=>"home","dash"=>"","onclick"=>""], 122 "User" => ["disp"=>"User","icon"=>"home","dash"=>"","onclick"=>""],
123 "Role" => ["disp"=>"Role","icon"=>"home","dash"=>"","onclick"=>""], 123 "Role" => ["disp"=>"Role","icon"=>"home","dash"=>"","onclick"=>""],
124 "Reports" => ["disp"=>"Report","icon"=>"home","dash"=>"","onclick"=>""],
124 "DialMode" => ["disp"=>"DialMode","icon"=>"home","dash"=>"","onclick"=>""], 125 "DialMode" => ["disp"=>"DialMode","icon"=>"home","dash"=>"","onclick"=>""],
125 "SupervisorModule" => ["disp"=>"SupervisorModule","icon"=>"globe","dash"=>"","onclick"=>"menuAction('SupervisorModule');"], 126 "SupervisorModule" => ["disp"=>"SupervisorModule","icon"=>"globe","dash"=>"","onclick"=>"menuAction('SupervisorModule');"],
126 "Notes" => ["disp"=>"Notes","icon"=>"globe","dash"=>"","onclick"=>"menuAction('notes');"], 127 "Notes" => ["disp"=>"Notes","icon"=>"globe","dash"=>"","onclick"=>"menuAction('notes');"],
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!