full_remark_details.php 2.61 KB
<?php namespace App\Console\Commands;

use Illuminate\Console\Command;
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 full_remark_details extends Command {

	/**
	 * The console command name.
	 *
	 * @var string
	 */
	protected $signature = 'full_remark_details';

	/**
	 * The console command description.
	 *
	 * @var string
	 */
	protected $description = 'full_remark_details';

	/**
	 * Execute the console command.
	 *
	 * @return mixed
	 */
	public function handle()
	{
		$nowts=time();
		echo "\n".date('Y-m-d')."\n";
		

			$logdate=strtotime('0 day');			
	
			$tcol=0;$fieldsarr=array();$extrahdrarr=array();
			$server_ip=env('app_ip');
			$full_remark = "full_remark_details";

			$conn = array(
				'driver'    => 'mysql',
				'host'      => '10.3.177.14',
				'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);

			
			if(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;
                        }
		
			$maxid=DB::connection("conn")->select(DB::raw("SELECT max(full_remark_id) as maxid from $full_remark where server_id='$server_id'"));

			$maxids=$maxid[0]->maxid;

			//$qlist=DB::select(DB::raw("SELECT * from full_remark"));
			$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))."'"));
			
			$userarr=array();
			foreach($qlist as $qline)
			{
			
				$setstrarr=array();

                                $setstrarr[]="server_id='$server_id'";
				$setstrarr[]="full_remark_id='$qline->id'";
                                $setstrarr[]="call_id='$qline->call_id'";
                                $setstrarr[]="fullremark='$qline->fullremark'";
				$setstrarr[]="created_at='$qline->created_at'";

                                $setstr=implode(",",$setstrarr);
                                DB::connection("conn")->insert(DB::raw("insert into ".$full_remark." set $setstr"));
			
			}
 DB::connection("conn")->disconnect();
			
		}
			
	}		
	

}