fe1c4e2d by Prashant Gupta

New repo of HDFC

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

Too many changes to show.

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

../custom/.env
\ No newline at end of file
* text=auto
*.css linguist-vendored
*.less linguist-vendored
#!/bin/bash
export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
echo asterisk -rx "sip show channels";
No preview for this file type
No preview for this file type
No preview for this file type
<?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 CreportEight extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'CreportEight';
/**
* The console command description.
*
* @var string
*/
protected $description = 'App Main Daily Task for CreportEight';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$nowts=time();
echo "\n".date('Y-m-d H:i:s')."\n";
$logdate=strtotime('0 day');
$tcol=0;$fieldsarr=array();$extrahdrarr=array();
$server_id="08";
$calllog_report = "calllog_report_".date("d_m_Y");
$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);
DB::connection("conn")->getDatabaseName();
$maxid=DB::connection("conn")->select(DB::raw("SELECT max(crmcall_id) as maxid from $calllog_report where server='$server_id'"));
$maxids=$maxid[0]->maxid;
$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))."'"));
$userarr=array();
foreach($alist as $aline)
{
$setstrarr=array();
$clientcode="";$currentstatus="";$legalstatus="";$record_id="";
if($aline->crm_id>0)
{
$user=DB::select(DB::raw("select id,clientcode,currentstatus,legalstatus from records where id='".$aline->crm_id."' limit 1;"));
if(isset($user[0]))
{
$record_id=$user[0]->id;
$clientcode=$user[0]->clientcode;
$currentstatus=$user[0]->currentstatus;
$legalstatus=$user[0]->legalstatus;
}
}
$tpostdata=json_decode($aline->data,true);
$fulldate=date("Y-m-d H:i:s",strtotime($aline->created_at)+330*60);
$talktime=$aline->talkSec+$aline->recstartSec+$aline->recendSec;
$length=round(($aline->waitSec+$aline->callSec+$talktime+$aline->dispoSec)/1000,2);
if(!isset($userarr[$aline->user_id])&&$aline->user_id>0)$userarr[$aline->user_id]=User::find($aline->user_id);
$dispname="";if(isset($userarr[$aline->user_id]))$dispname=$userarr[$aline->user_id]->dispname();
$username="";if(isset($userarr[$aline->user_id]))$username=$userarr[$aline->user_id]->username;
$globalid=$server_id.$record_id;
$setstrarr[]="server='$server_id'";
$setstrarr[]="record_id='$record_id'";
$setstrarr[]="crmcall_id='$aline->id'";
$setstrarr[]="globalid='$globalid'";
$setstrarr[]="start='$fulldate'";
$setstrarr[]="length='$length'";
$setstrarr[]="user='$username'";
$setstrarr[]="name='$dispname'";
$setstrarr[]="dispo='$aline->userstatus'";
$setstrarr[]="subdispo='$aline->usersubstatus'";
$setstrarr[]="callback='$aline->usercallback'";
$setstrarr[]="number='$aline->number'";
$setstrarr[]="clientcode='$clientcode'";
$setstrarr[]="currentstatus='$currentstatus'";
$setstrarr[]="legalstatus='$legalstatus'";
$setstrarr[]="client='$aline->client'";
$setstrarr[]="department='$aline->department'";
$setstrarr[]="state='$aline->state'";
$setstrarr[]="hsource='$aline->hsource'";
$setstrarr[]="type='$aline->type'";
$setstrarr[]="status='$aline->status'";
$setstrarr[]="statuscode='$aline->statuscode'";
$setstrarr[]="statusstr='$aline->substatus'";
$setstrarr[]="dialline='$aline->dialline_id'";
$setstrarr[]="did='$aline->did'";
$setstrarr[]="waitsec='".round($aline->waitSec/1000,2)."'";
$setstrarr[]="callsec='".round($aline->callSec/1000,2)."'";
$setstrarr[]="talksec='".round($talktime/1000,2)."'";
$setstrarr[]="disposec='".round($aline->dispoSec/1000,2)."'";
$setstrarr[]="remarks='".str_replace("'","",$aline->userremarks)."'";
$setstrarr[]="userdata='$aline->userdata'";
$setstr=implode(",",$setstrarr);
DB::connection("conn")->insert(DB::raw("insert into ".$calllog_report." set $setstr"));
}
}
}
<?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 App\Models\Notification;
use App\Jobs\KHRMSLib;
use Input;
use App\Models\Sipid;
use App\Models\Kqueue;
use App\Models\Dialline;
use App\Models\Session;
use Illuminate\Database\Schema\Blueprint;
class DailyLogout extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'DailyLogout';
/**
* The console command description.
*
* @var string
*/
protected $description = 'DailyLogout';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$sipids=Sipid::where("status","=","1")->get();
foreach($sipids as $tsip)
{
$newqueue=new Kqueue();
$newqueue->sipNotify($tsip,"adminCommand","user","logout","");
}
Dialline::where('status','!=','Free')->update(['status'=>'Free','conf'=>'','channel'=>'','server'=>'','updated_at'=>'0000-00-00 00:00:00']);
Sipid::where('status','!=','0')->update(['status'=>0,'user'=>0,'ready'=>0,'confup'=>0,'clients'=>'','server'=>'','updated_at'=>'0000-00-00 00:00:00']);
$serverarray=explode(",",Config::get("app.asterisk_slaves"));
foreach($serverarray as $server)
{
$sparts=explode(":",$server);
Sipid::where("id",">=",$sparts[1])->where("id","<=",$sparts[2])->update(['server' => $sparts[0],'updated_at'=>'0000-00-00 00:00:00']);
Dialline::where("id",">=",$sparts[3])->where("id","<=",$sparts[4])->update(['server' => $sparts[0],'updated_at'=>'0000-00-00 00:00:00']);
$newqueue=new Kqueue();
$newqueue->astCommand($sparts[0],"channel request hangup all");
}
User::where('presence','>','0')->update(['presence'=>0]);
Session::truncate();
return "";
}
}
<?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 App\Models\Notification;
use App\Jobs\KHRMSLib;
use Input;
use App\Models\Sipid;
use App\Models\Kqueue;
use App\Models\Dialline;
use App\Models\Session;
use Illuminate\Database\Schema\Blueprint;
class DeleteCrmcalls extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'DeleteCrmcalls';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Delete data from CRMCalls before 7 days';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$logdate=strtotime('-7 day');
CRMCall::where('created_at','<',date("Y-m-d",$logdate))->delete();
}
}
<?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 App\Models\Notification;
use App\Jobs\KHRMSLib;
use Input;
use App\Models\Sipid;
use App\Models\Kqueue;
use App\Models\Dialline;
use App\Models\Session;
use Illuminate\Database\Schema\Blueprint;
class InsertCrmArchive extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'InsertCrmArchive';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Insert updated data into crmcalls_archive from crmcalls';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
echo 'Start';
DB::insert(DB::raw("insert into crmcalls_archive select * from crmcalls where id>(select max(id) from crmcalls_archive)"));
echo 'End';
}
}
<?php namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Jobs\KPAMIListen;
class KstychARP extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'KstychARP';
/**
* The console command description.
*
* @var string
*/
protected $description = 'ARP Broadcast';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
}
}
<?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 KstychDaily extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'KstychDaily';
/**
* The console command description.
*
* @var string
*/
protected $description = 'App Main Daily Task';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$nowts=time();
Accesslog::where('endtime','<',date("Y-m-d H:i:s",$nowts-2*24*60*60))->update(array('postdata'=>'','queries'=>''));
Accesslog::where('endtime','<',date("Y-m-d H:i:s",$nowts-2*24*60*60))->delete();
if(env('app_ip')=="10.3.177.14")
{
if(!Schema::hasTable('calllog_report'))
{
Schema::create('calllog_report', function(Blueprint $table)
{
$table->string('server', 100);
$table->dateTime('start');
$table->integer('length');
$table->string('user',100);
$table->string('name',100);
$table->string('dispo', 200);
$table->string('subdispo', 200);
$table->dateTime('callback');
$table->string('number', 100);
$table->string('clientcode', 100);
$table->string('currentstatus', 100);
$table->string('legalstatus', 100);
$table->string('client', 200);
$table->string('department', 200);
$table->string('state', 50);
$table->string('hsource', 100);
$table->string('type', 50);
$table->string('statuscode', 20);
$table->string('status', 100);
$table->string('statusstr', 100);
$table->integer('dialline');
$table->string('did', 50);
$table->bigInteger('waitsec');
$table->bigInteger('callsec');
$table->bigInteger('talksec');
$table->bigInteger('disposec');
$table->string('remarks', 500);
$table->string('userdata',1000);
});
}
$offline=array();
$arr=Config::get("app.hdfcnodes");
$logdate=strtotime('-1 day');
$tcol=0;$fieldsarr=array();$extrahdrarr=array();
$ii=1;$ci=0;
foreach($arr as $server=>$serverline)
{
$ci++;
$conn = array(
'driver' => 'mysql',
'host' => $server,
'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$ci", $conn);
try
{
DB::connection("conn$ci")->getDatabaseName();
$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();
$userarr=array();
foreach($alist as $aline)
{
$setstrarr=array();
$clientcode="";$currentstatus="";$legalstatus="";
if($aline->crm_id>0)
{
$user=DB::connection("conn$ci")->select(DB::raw("select id,clientcode,currentstatus,legalstatus from records where id='".$aline->crm_id."' limit 1;"));
if(isset($user[0]))
{
$clientcode=$user[0]->clientcode;
$currentstatus=$user[0]->currentstatus;
$legalstatus=$user[0]->legalstatus;
}
}
$tpostdata=json_decode($aline->data,true);
$fulldate=date("Y-m-d H:i:s",strtotime($aline->created_at)+330*60);
$talktime=$aline->talkSec+$aline->recstartSec+$aline->recendSec;
$length=round(($aline->waitSec+$aline->callSec+$talktime+$aline->dispoSec)/1000,2);
if(!isset($userarr[$aline->user_id])&&$aline->user_id>0)$userarr[$aline->user_id]=User::on("conn$ci")->find($aline->user_id);
$dispname="";if(isset($userarr[$aline->user_id]))$dispname=$userarr[$aline->user_id]->dispname();
$username="";if(isset($userarr[$aline->user_id]))$username=$userarr[$aline->user_id]->username;
$setstrarr[]="server='$server'";
$setstrarr[]="start='$fulldate'";
$setstrarr[]="length='$length'";
$setstrarr[]="user='$username'";
$setstrarr[]="name='$dispname'";
$setstrarr[]="dispo='$aline->userstatus'";
$setstrarr[]="subdispo='$aline->usersubstatus'";
$setstrarr[]="callback='$aline->usercallback'";
$setstrarr[]="number='$aline->number'";
$setstrarr[]="clientcode='$clientcode'";
$setstrarr[]="currentstatus='$currentstatus'";
$setstrarr[]="legalstatus='$legalstatus'";
$setstrarr[]="client='$aline->client'";
$setstrarr[]="department='$aline->department'";
$setstrarr[]="state='$aline->state'";
$setstrarr[]="hsource='$aline->hsource'";
$setstrarr[]="type='$aline->type'";
$setstrarr[]="status='$aline->status'";
$setstrarr[]="statuscode='$aline->statuscode'";
$setstrarr[]="statusstr='$aline->substatus'";
$setstrarr[]="dialline='$aline->dialline_id'";
$setstrarr[]="did='$aline->did'";
$setstrarr[]="waitsec='".round($aline->waitSec/1000,2)."'";
$setstrarr[]="callsec='".round($aline->callSec/1000,2)."'";
$setstrarr[]="talksec='".round($talktime/1000,2)."'";
$setstrarr[]="disposec='".round($aline->dispoSec/1000,2)."'";
$setstrarr[]="remarks='$aline->userremarks'";
$setstrarr[]="userdata='$aline->userdata'";
$setstr=implode(",",$setstrarr);
DB::insert(DB::raw("insert into calllog_report set $setstr"));
}
}
catch(Exception $e)
{
$offline[]=$server;
}
}
}
}
}
<?php namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Jobs\KPAGIListen;
class KstychPAGI extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'KstychPAGI';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Daemon to Listen to Asterisk';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$agi = \PAGI\Client\Impl\ClientImpl::getInstance();
$kpagi = new KPAGIListen(array('pagiClient' => $agi));
$kpagi->init();
$kpagi->run();
}
}
<?php namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Jobs\KPAMIListen;
class KstychPAMI extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'KstychPAMI {serverip=127.0.0.1}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Daemon to Listen to Asterisk';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$listener = new KPAMIListen($this->argument('serverip'));$listener->run();
}
}
<?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 App\Models\Notification;
use App\Jobs\KHRMSLib;
use Input;
use Illuminate\Database\Schema\Blueprint;
class bulkServerUpload extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'bulkServerUpload';
/**
* The console command description.
*
* @var string
*/
protected $description = 'bulkServerUpload';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
echo "\n".date('Y-m-d')."\n";
$wakka = new KHRMSLib();
$kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
$kformlib->gthis=$wakka;
$themehome=$wakka->GetThemePath('/');
$updatetime=time();
$clientlst=$wakka->GetBBBUserData("clientslist");
$isadmin=$wakka->IsAdmin();
$username=$wakka->GetUserName();
$triggers=Input::get("triggers");
$tmpstr=explode(",",$kformlib->HRFiledsStr);
$success="";$message="";$successcnt=0;$duplicatecount=0;
$conn = array(
'driver' => 'mysql',
'host' => '10.3.177.14',
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'yb9738z'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'options' => array(
PDO::ATTR_TIMEOUT => 5,
),
);
Config::set("database.connections.conn", $conn);
DB::connection("conn")->getDatabaseName();
// $excelarray = DB::table('bz_record_upload_uat')->select('*')->get();
$excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat limit 1"));
$excelarray = (array)$excelarray;
$highestColumn = DB::connection("conn")->select(DB::raw("select count(*) from information_schema.columns where table_name='bz_record_upload_uat'"));
$highestrow = count($excelarray);
echo $highestColumn;
$flag = 0;
$editflag=0;
for($i=0;$i<=$highestrow;$i++)
{
if($excelarray[$i]["id"]!="")
{
if($excelarray[$i]["id"]=="CREATE")
{
$excelarray[$i]["id"]=$wakka->Query("insert into","","records_demo",array('created'=>date('Y-m-d H:i:s')));
}
else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
if($wakka->getCount("records_demo","id='".$excelarray[$i]["id"]."'")==1)
{
$empdata=$wakka->getPersonServer($excelarray[$i]["id"]);
$ppldata=$empdata["peopledata"];
$createdlog=$empdata['modifylog'];
$fdirty=$empdata['dirty'];
$createdlog[$updatetime]=$username."::";
$createdlog["updated"]=$updatetime;
$newdata=$ppldata;
foreach($excelarray[$i] as $key => $value)
{
if($value!="")
{
if("A".$ppldata[$key]!="A".$value)//forcing string comparrision //MAGIC
{
$value=str_replace("'"," ",$value);
if(strstr($createdlog[$updatetime],$key)==FALSE)$createdlog[$updatetime].="$key|".str_replace(array("|",",")," ",$ppldata[$key])."|".str_replace(array("|",",")," ",$value).",";
$fdirty[$key]=1;
$newdata[$key]=$value;
}
}
}
$empdata["peopledata"]=$newdata;
$empdata['modifylog']=$createdlog;
$empdata['dirty']=$fdirty;
$wakka->setPersonServer($excelarray[$i]["id"],$empdata);
$excelarray[$i]['modified']=date('Y-m-d H:i:s');
}
}
}
mysqli_close($conn);
}
}
<?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 App\Models\Notification;
use App\Jobs\KHRMSLib;
use Input;
use Illuminate\Database\Schema\Blueprint;
class bulkServerUpload extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'bulkServerUpload';
/**
* The console command description.
*
* @var string
*/
protected $description = 'bulkServerUpload';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
echo "\n".date('Y-m-d')."\n";
$wakka = new KHRMSLib();
$kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
$kformlib->gthis=$wakka;
$themehome=$wakka->GetThemePath('/');
$updatetime=time();
$clientlst=$wakka->GetBBBUserData("clientslist");
$isadmin=$wakka->IsAdmin();
$username=$wakka->GetUserName();
$triggers=Input::get("triggers");
$tmpstr=explode(",",$kformlib->HRFiledsStr);
$success="";$message="";$successcnt=0;$duplicatecount=0;
$conn = array(
'driver' => 'mysql',
'host' => '10.3.177.14',
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'yb9738z'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'options' => array(
PDO::ATTR_TIMEOUT => 5,
),
);
Config::set("database.connections.conn", $conn);
DB::connection("conn")->getDatabaseName();
$excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat where SERVER_IP='10.3.179.121' order by auto_id asc limit 0,20000"));
$server_ip='10.3.179.121';
$location='Mumbai';
$conn='';
$tcol=0;$fieldsarr=array();$extrahdrarr=array();
foreach($excelarray as $key => $array){
$excelarray[$key] = (array)$array;
}
$highestColumn = DB::connection("conn")->select(DB::raw("select count(*) as cnt from information_schema.columns where table_name='bz_record_upload_uat'"));
$highestColumn = $highestColumn[0]->cnt;
$highestrow = count($excelarray);
$flag = 0;
$editflag=0;
for($i=0;$i<=$highestrow;$i++)
{
if($excelarray[$i]["id"]!="")
{
if($excelarray[$i]["id"]=="CREATE")
{
$excelarray[$i]["id"]=$wakka->Query("insert into","","records",array('created'=>date('Y-m-d H:i:s')));
}
else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
if($wakka->getCount("records","id='".$excelarray[$i]["id"]."'")==1)
{
$empdata=$wakka->getPerson($excelarray[$i]["id"]);
$ppldata=$empdata["peopledata"];
$createdlog=$empdata['modifylog'];
$fdirty=$empdata['dirty'];
$createdlog[$updatetime]=$username."::";
$createdlog["updated"]=$updatetime;
$newdata=$ppldata;
foreach($excelarray[$i] as $key => $value)
{
if($value!="")
{
if("A".$ppldata[$key]!="A".$value)//forcing string comparrision //MAGIC
{
$value=str_replace("'"," ",$value);
if(strstr($createdlog[$updatetime],$key)==FALSE)$createdlog[$updatetime].="$key|".str_replace(array("|",",")," ",$ppldata[$key])."|".str_replace(array("|",",")," ",$value).",";
$fdirty[$key]=1;
$newdata[$key]=$value;
}
}
}
/*Start - Changes need to be done*/
if($excelarray[$i]["status"]==null)
{
$empdata['status'] = "rom";
}
if($excelarray[$i]["dialer_status"]==null)
{
$empdata['dialer_status'] = "rom";
}
if($excelarray[$i]["dialer_substatus"]==null)
{
$empdata['dialer_substatus'] = "rom";
}
/*End - Changes need to be done*/
$empdata["peopledata"]=$newdata;
$empdata['modifylog']=$createdlog;
$empdata['dirty']=$fdirty;
$wakka->setPerson($excelarray[$i]["id"],$empdata);
$excelarray[$i]['modified']=date('Y-m-d H:i:s');
$successArr[] = $excelarray[$i];
}
}
else
{
$reason = "";
if($excelarray[$i]["id"]=="")
$reason .= "Column ID is blank,";
$excelarray[$i]['server_ip'] =$server_ip;
$excelarray[$i]['location'] =$location;
if($excelarray[$i]["clientcode"]!="")
$excelarray[$i]['cust_id'] =$excelarray[$i]["clientcode"];
$excelarray[$i]['Reason'] = $reason;
$failureArr[] = $excelarray[$i];
}
}
if(!empty($successArr)){
foreach($successArr as $succes)
{
$setSuccess=array();
$setSuccess[] = "server_ip='$server_ip'";
$setSuccess[] = "location='$location'";
$setSuccess[] = "record_id='".$succes['id']."'";
$setSuccess[] = "cust_id='".$succes['clientcode']."'";
$setSuccess[] = "modified='".$succes['modified']."'";
$setSuccess = implode(",",$setSuccess);
DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_success set $setSuccess"));
}
}
if(!empty($failureArr)){
foreach($failureArr as $failur)
{
$setFailure=array();
$setFailure[] = "server_ip='$server_ip'";
$setFailure[] = "location='$location'";
$setFailure[] = "cust_id='".$failur['clientcode']."'";
$setFailure[] = "reason='".$failur['Reason']."'";
$setFailure = implode(",",$setFailure);
DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_failure set $setFailure"));
}
}
//DB::connection("conn")->delete(DB::raw("DELETE FROM `bz_record_upload_uat` where SERVER_IP='10.3.179.121'"));
DB::connection("conn")->disconnect();
}
}
<?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 App\Models\Notification;
use App\Jobs\KHRMSLib;
use Input;
use Illuminate\Database\Schema\Blueprint;
class bulkServerUpload_1 extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'bulkServerUpload_1';
/**
* The console command description.
*
* @var string
*/
protected $description = 'bulkServerUpload_1';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
echo "\n".date('Y-m-d')."\n";
$wakka = new KHRMSLib();
$kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
$kformlib->gthis=$wakka;
$themehome=$wakka->GetThemePath('/');
$updatetime=time();
$clientlst=$wakka->GetBBBUserData("clientslist");
$isadmin=$wakka->IsAdmin();
$username=$wakka->GetUserName();
$triggers=Input::get("triggers");
$tmpstr=explode(",",$kformlib->HRFiledsStr);
$success="";$message="";$successcnt=0;$duplicatecount=0;
$conn = array(
'driver' => 'mysql',
'host' => '10.3.177.14',
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'yb9738z'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'options' => array(
PDO::ATTR_TIMEOUT => 5,
),
);
Config::set("database.connections.conn", $conn);
DB::connection("conn")->getDatabaseName();
$excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat where SERVER_IP='10.3.179.121' order by auto_id asc limit 20001,40000"));
$server_ip='10.3.179.121';
$location='Mumbai';
$conn='';
$tcol=0;$fieldsarr=array();$extrahdrarr=array();
foreach($excelarray as $key => $array){
$excelarray[$key] = (array)$array;
}
$highestColumn = DB::connection("conn")->select(DB::raw("select count(*) as cnt from information_schema.columns where table_name='bz_record_upload_uat'"));
$highestColumn = $highestColumn[0]->cnt;
$highestrow = count($excelarray);
$flag = 0;
$editflag=0;
for($i=0;$i<$highestrow;$i++)
{
if($excelarray[$i]["id"]!="")
{
if($excelarray[$i]["id"]=="CREATE")
{
$excelarray[$i]["id"]=$wakka->Query("insert into","","records",array('created'=>date('Y-m-d H:i:s')));
}
else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
if($wakka->getCount("records","id='".$excelarray[$i]["id"]."'")==1)
{
$empdata=$wakka->getPerson($excelarray[$i]["id"]);
$ppldata=$empdata["peopledata"];
$createdlog=$empdata['modifylog'];
$fdirty=$empdata['dirty'];
$createdlog[$updatetime]=$username."::";
$createdlog["updated"]=$updatetime;
$newdata=$ppldata;
foreach($excelarray[$i] as $key => $value)
{
if($value!="")
{
if("A".$ppldata[$key]!="A".$value)//forcing string comparrision //MAGIC
{
$value=str_replace("'"," ",$value);
if(strstr($createdlog[$updatetime],$key)==FALSE)$createdlog[$updatetime].="$key|".str_replace(array("|",",")," ",$ppldata[$key])."|".str_replace(array("|",",")," ",$value).",";
$fdirty[$key]=1;
$newdata[$key]=$value;
}
}
}
/*Start - Changes need to be done*/
if($excelarray[$i]["status"]==null)
{
$empdata['status'] = "rom";
}
if($excelarray[$i]["dialer_status"]==null)
{
$empdata['dialer_status'] = "rom";
}
if($excelarray[$i]["dialer_substatus"]==null)
{
$empdata['dialer_substatus'] = "rom";
}
/*End - Changes need to be done*/
$empdata["peopledata"]=$newdata;
$empdata['modifylog']=$createdlog;
$empdata['dirty']=$fdirty;
$wakka->setPerson($excelarray[$i]["id"],$empdata);
$excelarray[$i]['modified']=date('Y-m-d H:i:s');
$successArr[] = $excelarray[$i];
}
else
{
$reason = "";
$reason .= "Record ID is not on local server,";
$excelarray[$i]['server_ip'] =$server_ip;
$excelarray[$i]['location'] =$location;
if($excelarray[$i]["clientcode"]!="")
$excelarray[$i]['cust_id'] =$excelarray[$i]["clientcode"];
$excelarray[$i]['record_id'] = $excelarray[$i]["id"];
$excelarray[$i]['Reason'] = $reason;
$failureArr[] = $excelarray[$i];
}
}
else
{
$reason = "";
if($excelarray[$i]["id"]=="")
$reason .= "Column ID is blank,";
$excelarray[$i]['server_ip'] =$server_ip;
$excelarray[$i]['location'] =$location;
if($excelarray[$i]["clientcode"]!="")
$excelarray[$i]['cust_id'] =$excelarray[$i]["clientcode"];
$excelarray[$i]['Reason'] = $reason;
$failureArr[] = $excelarray[$i];
}
}
if(!empty($successArr)){
foreach($successArr as $succes)
{
$setSuccess=array();
$setSuccess[] = "server_ip='$server_ip'";
$setSuccess[] = "location='$location'";
$setSuccess[] = "record_id='".$succes['id']."'";
$setSuccess[] = "cust_id='".$succes['clientcode']."'";
$setSuccess[] = "modified='".$succes['modified']."'";
$setSuccess = implode(",",$setSuccess);
DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_success set $setSuccess"));
}
}
if(!empty($failureArr)){
foreach($failureArr as $failur)
{
$setFailure=array();
$setFailure[] = "server_ip='$server_ip'";
$setFailure[] = "location='$location'";
$setFailure[] = "cust_id='".$failur['clientcode']."'";
$setFailure[] = "record_id='".$failur['record_id']."'";
$setFailure[] = "reason='".$failur['Reason']."'";
$setFailure = implode(",",$setFailure);
DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_failure set $setFailure"));
}
}
DB::connection("conn")->disconnect();
}
}
<?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 App\Models\Notification;
use App\Jobs\KHRMSLib;
use Input;
use Illuminate\Database\Schema\Blueprint;
class bulkServerUpload_2 extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'bulkServerUpload_2';
/**
* The console command description.
*
* @var string
*/
protected $description = 'bulkServerUpload_2';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
echo "\n".date('Y-m-d')."\n";
$wakka = new KHRMSLib();
$kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
$kformlib->gthis=$wakka;
$themehome=$wakka->GetThemePath('/');
$updatetime=time();
$clientlst=$wakka->GetBBBUserData("clientslist");
$isadmin=$wakka->IsAdmin();
$username=$wakka->GetUserName();
$triggers=Input::get("triggers");
$tmpstr=explode(",",$kformlib->HRFiledsStr);
$success="";$message="";$successcnt=0;$duplicatecount=0;
$conn = array(
'driver' => 'mysql',
'host' => '10.3.177.14',
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'yb9738z'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'options' => array(
PDO::ATTR_TIMEOUT => 5,
),
);
Config::set("database.connections.conn", $conn);
DB::connection("conn")->getDatabaseName();
$excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat where SERVER_IP='10.3.179.121' order by auto_id asc limit 40001,60000"));
$server_ip='10.3.179.121';
$location='Mumbai';
$conn='';
$tcol=0;$fieldsarr=array();$extrahdrarr=array();
foreach($excelarray as $key => $array){
$excelarray[$key] = (array)$array;
}
$highestColumn = DB::connection("conn")->select(DB::raw("select count(*) as cnt from information_schema.columns where table_name='bz_record_upload_uat'"));
$highestColumn = $highestColumn[0]->cnt;
$highestrow = count($excelarray);
$flag = 0;
$editflag=0;
for($i=0;$i<=$highestrow;$i++)
{
if($excelarray[$i]["id"]!="")
{
if($excelarray[$i]["id"]=="CREATE")
{
$excelarray[$i]["id"]=$wakka->Query("insert into","","records",array('created'=>date('Y-m-d H:i:s')));
}
else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
if($wakka->getCount("records","id='".$excelarray[$i]["id"]."'")==1)
{
$empdata=$wakka->getPerson($excelarray[$i]["id"]);
$ppldata=$empdata["peopledata"];
$createdlog=$empdata['modifylog'];
$fdirty=$empdata['dirty'];
$createdlog[$updatetime]=$username."::";
$createdlog["updated"]=$updatetime;
$newdata=$ppldata;
foreach($excelarray[$i] as $key => $value)
{
if($value!="")
{
if("A".$ppldata[$key]!="A".$value)//forcing string comparrision //MAGIC
{
$value=str_replace("'"," ",$value);
if(strstr($createdlog[$updatetime],$key)==FALSE)$createdlog[$updatetime].="$key|".str_replace(array("|",",")," ",$ppldata[$key])."|".str_replace(array("|",",")," ",$value).",";
$fdirty[$key]=1;
$newdata[$key]=$value;
}
}
}
/*Start - Changes need to be done*/
if($excelarray[$i]["status"]==null)
{
$empdata['status'] = "rom";
}
if($excelarray[$i]["dialer_status"]==null)
{
$empdata['dialer_status'] = "rom";
}
if($excelarray[$i]["dialer_substatus"]==null)
{
$empdata['dialer_substatus'] = "rom";
}
/*End - Changes need to be done*/
$empdata["peopledata"]=$newdata;
$empdata['modifylog']=$createdlog;
$empdata['dirty']=$fdirty;
$wakka->setPerson($excelarray[$i]["id"],$empdata);
$excelarray[$i]['modified']=date('Y-m-d H:i:s');
$successArr[] = $excelarray[$i];
}
}
else
{
$reason = "";
if($excelarray[$i]["id"]=="")
$reason .= "Column ID is blank,";
$excelarray[$i]['server_ip'] =$server_ip;
$excelarray[$i]['location'] =$location;
if($excelarray[$i]["clientcode"]!="")
$excelarray[$i]['cust_id'] =$excelarray[$i]["clientcode"];
$excelarray[$i]['Reason'] = $reason;
$failureArr[] = $excelarray[$i];
}
}
if(!empty($successArr)){
foreach($successArr as $succes)
{
$setSuccess=array();
$setSuccess[] = "server_ip='$server_ip'";
$setSuccess[] = "location='$location'";
$setSuccess[] = "record_id='".$succes['id']."'";
$setSuccess[] = "cust_id='".$succes['clientcode']."'";
$setSuccess[] = "modified='".$succes['modified']."'";
$setSuccess = implode(",",$setSuccess);
DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_success set $setSuccess"));
}
}
if(!empty($failureArr)){
foreach($failureArr as $failur)
{
$setFailure=array();
$setFailure[] = "server_ip='$server_ip'";
$setFailure[] = "location='$location'";
$setFailure[] = "cust_id='".$failur['clientcode']."'";
$setFailure[] = "reason='".$failur['Reason']."'";
$setFailure = implode(",",$setFailure);
DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_failure set $setFailure"));
}
}
DB::connection("conn")->disconnect();
}
}
<?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 App\Models\Notification;
use App\Jobs\KHRMSLib;
use Input;
use Illuminate\Database\Schema\Blueprint;
class bulkServerUpload_3 extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'bulkServerUpload_3';
/**
* The console command description.
*
* @var string
*/
protected $description = 'bulkServerUpload_3';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
echo "\n".date('Y-m-d')."\n";
$wakka = new KHRMSLib();
$kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
$kformlib->gthis=$wakka;
$themehome=$wakka->GetThemePath('/');
$updatetime=time();
$clientlst=$wakka->GetBBBUserData("clientslist");
$isadmin=$wakka->IsAdmin();
$username=$wakka->GetUserName();
$triggers=Input::get("triggers");
$tmpstr=explode(",",$kformlib->HRFiledsStr);
$success="";$message="";$successcnt=0;$duplicatecount=0;
$conn = array(
'driver' => 'mysql',
'host' => '10.3.177.14',
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'yb9738z'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'options' => array(
PDO::ATTR_TIMEOUT => 5,
),
);
Config::set("database.connections.conn", $conn);
DB::connection("conn")->getDatabaseName();
$excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat where SERVER_IP='10.3.179.121' order by auto_id asc limit 60001,80000"));
$server_ip='10.3.179.121';
$location='Mumbai';
$conn='';
$tcol=0;$fieldsarr=array();$extrahdrarr=array();
foreach($excelarray as $key => $array){
$excelarray[$key] = (array)$array;
}
$highestColumn = DB::connection("conn")->select(DB::raw("select count(*) as cnt from information_schema.columns where table_name='bz_record_upload_uat'"));
$highestColumn = $highestColumn[0]->cnt;
$highestrow = count($excelarray);
$flag = 0;
$editflag=0;
for($i=0;$i<=$highestrow;$i++)
{
if($excelarray[$i]["id"]!="")
{
if($excelarray[$i]["id"]=="CREATE")
{
$excelarray[$i]["id"]=$wakka->Query("insert into","","records",array('created'=>date('Y-m-d H:i:s')));
}
else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
if($wakka->getCount("records","id='".$excelarray[$i]["id"]."'")==1)
{
$empdata=$wakka->getPerson($excelarray[$i]["id"]);
$ppldata=$empdata["peopledata"];
$createdlog=$empdata['modifylog'];
$fdirty=$empdata['dirty'];
$createdlog[$updatetime]=$username."::";
$createdlog["updated"]=$updatetime;
$newdata=$ppldata;
foreach($excelarray[$i] as $key => $value)
{
if($value!="")
{
if("A".$ppldata[$key]!="A".$value)//forcing string comparrision //MAGIC
{
$value=str_replace("'"," ",$value);
if(strstr($createdlog[$updatetime],$key)==FALSE)$createdlog[$updatetime].="$key|".str_replace(array("|",",")," ",$ppldata[$key])."|".str_replace(array("|",",")," ",$value).",";
$fdirty[$key]=1;
$newdata[$key]=$value;
}
}
}
/*Start - Changes need to be done*/
if($excelarray[$i]["status"]==null)
{
$empdata['status'] = "rom";
}
if($excelarray[$i]["dialer_status"]==null)
{
$empdata['dialer_status'] = "rom";
}
if($excelarray[$i]["dialer_substatus"]==null)
{
$empdata['dialer_substatus'] = "rom";
}
/*End - Changes need to be done*/
$empdata["peopledata"]=$newdata;
$empdata['modifylog']=$createdlog;
$empdata['dirty']=$fdirty;
$wakka->setPerson($excelarray[$i]["id"],$empdata);
$excelarray[$i]['modified']=date('Y-m-d H:i:s');
$successArr[] = $excelarray[$i];
}
}
else
{
$reason = "";
if($excelarray[$i]["id"]=="")
$reason .= "Column ID is blank,";
$excelarray[$i]['server_ip'] =$server_ip;
$excelarray[$i]['location'] =$location;
if($excelarray[$i]["clientcode"]!="")
$excelarray[$i]['cust_id'] =$excelarray[$i]["clientcode"];
$excelarray[$i]['Reason'] = $reason;
$failureArr[] = $excelarray[$i];
}
}
if(!empty($successArr)){
foreach($successArr as $succes)
{
$setSuccess=array();
$setSuccess[] = "server_ip='$server_ip'";
$setSuccess[] = "location='$location'";
$setSuccess[] = "record_id='".$succes['id']."'";
$setSuccess[] = "cust_id='".$succes['clientcode']."'";
$setSuccess[] = "modified='".$succes['modified']."'";
$setSuccess = implode(",",$setSuccess);
DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_success set $setSuccess"));
}
}
if(!empty($failureArr)){
foreach($failureArr as $failur)
{
$setFailure=array();
$setFailure[] = "server_ip='$server_ip'";
$setFailure[] = "location='$location'";
$setFailure[] = "cust_id='".$failur['clientcode']."'";
$setFailure[] = "reason='".$failur['Reason']."'";
$setFailure = implode(",",$setFailure);
DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_failure set $setFailure"));
}
}
DB::connection("conn")->disconnect();
}
}
<?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 App\Models\Notification;
use App\Jobs\KHRMSLib;
use Input;
use Illuminate\Database\Schema\Blueprint;
class bulkServerUpload_4 extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'bulkServerUpload_4';
/**
* The console command description.
*
* @var string
*/
protected $description = 'bulkServerUpload_4';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
echo "\n".date('Y-m-d')."\n";
$wakka = new KHRMSLib();
$kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
$kformlib->gthis=$wakka;
$themehome=$wakka->GetThemePath('/');
$updatetime=time();
$clientlst=$wakka->GetBBBUserData("clientslist");
$isadmin=$wakka->IsAdmin();
$username=$wakka->GetUserName();
$triggers=Input::get("triggers");
$tmpstr=explode(",",$kformlib->HRFiledsStr);
$success="";$message="";$successcnt=0;$duplicatecount=0;
$conn = array(
'driver' => 'mysql',
'host' => '10.3.177.14',
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'yb9738z'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'options' => array(
PDO::ATTR_TIMEOUT => 5,
),
);
Config::set("database.connections.conn", $conn);
DB::connection("conn")->getDatabaseName();
$excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat where SERVER_IP='10.3.179.121' order by auto_id asc limit 80001,100000"));
$server_ip='10.3.179.121';
$location='Mumbai';
$conn='';
$tcol=0;$fieldsarr=array();$extrahdrarr=array();
foreach($excelarray as $key => $array){
$excelarray[$key] = (array)$array;
}
$highestColumn = DB::connection("conn")->select(DB::raw("select count(*) as cnt from information_schema.columns where table_name='bz_record_upload_uat'"));
$highestColumn = $highestColumn[0]->cnt;
$highestrow = count($excelarray);
$flag = 0;
$editflag=0;
for($i=0;$i<=$highestrow;$i++)
{
if($excelarray[$i]["id"]!="")
{
if($excelarray[$i]["id"]=="CREATE")
{
$excelarray[$i]["id"]=$wakka->Query("insert into","","records",array('created'=>date('Y-m-d H:i:s')));
}
else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
if($wakka->getCount("records","id='".$excelarray[$i]["id"]."'")==1)
{
$empdata=$wakka->getPerson($excelarray[$i]["id"]);
$ppldata=$empdata["peopledata"];
$createdlog=$empdata['modifylog'];
$fdirty=$empdata['dirty'];
$createdlog[$updatetime]=$username."::";
$createdlog["updated"]=$updatetime;
$newdata=$ppldata;
foreach($excelarray[$i] as $key => $value)
{
if($value!="")
{
if("A".$ppldata[$key]!="A".$value)//forcing string comparrision //MAGIC
{
$value=str_replace("'"," ",$value);
if(strstr($createdlog[$updatetime],$key)==FALSE)$createdlog[$updatetime].="$key|".str_replace(array("|",",")," ",$ppldata[$key])."|".str_replace(array("|",",")," ",$value).",";
$fdirty[$key]=1;
$newdata[$key]=$value;
}
}
}
/*Start - Changes need to be done*/
if($excelarray[$i]["status"]==null)
{
$empdata['status'] = "rom";
}
if($excelarray[$i]["dialer_status"]==null)
{
$empdata['dialer_status'] = "rom";
}
if($excelarray[$i]["dialer_substatus"]==null)
{
$empdata['dialer_substatus'] = "rom";
}
/*End - Changes need to be done*/
$empdata["peopledata"]=$newdata;
$empdata['modifylog']=$createdlog;
$empdata['dirty']=$fdirty;
$wakka->setPerson($excelarray[$i]["id"],$empdata);
$excelarray[$i]['modified']=date('Y-m-d H:i:s');
$successArr[] = $excelarray[$i];
}
}
else
{
$reason = "";
if($excelarray[$i]["id"]=="")
$reason .= "Column ID is blank,";
$excelarray[$i]['server_ip'] =$server_ip;
$excelarray[$i]['location'] =$location;
if($excelarray[$i]["clientcode"]!="")
$excelarray[$i]['cust_id'] =$excelarray[$i]["clientcode"];
$excelarray[$i]['Reason'] = $reason;
$failureArr[] = $excelarray[$i];
}
}
if(!empty($successArr)){
foreach($successArr as $succes)
{
$setSuccess=array();
$setSuccess[] = "server_ip='$server_ip'";
$setSuccess[] = "location='$location'";
$setSuccess[] = "record_id='".$succes['id']."'";
$setSuccess[] = "cust_id='".$succes['clientcode']."'";
$setSuccess[] = "modified='".$succes['modified']."'";
$setSuccess = implode(",",$setSuccess);
DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_success set $setSuccess"));
}
}
if(!empty($failureArr)){
foreach($failureArr as $failur)
{
$setFailure=array();
$setFailure[] = "server_ip='$server_ip'";
$setFailure[] = "location='$location'";
$setFailure[] = "cust_id='".$failur['clientcode']."'";
$setFailure[] = "reason='".$failur['Reason']."'";
$setFailure = implode(",",$setFailure);
DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_failure set $setFailure"));
}
}
DB::connection("conn")->disconnect();
}
}
<?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 App\Models\Notification;
use App\Jobs\KHRMSLib;
use Input;
use Illuminate\Database\Schema\Blueprint;
class bulkServerUpload_5 extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'bulkServerUpload_5';
/**
* The console command description.
*
* @var string
*/
protected $description = 'bulkServerUpload_5';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
echo "\n".date('Y-m-d')."\n";
$wakka = new KHRMSLib();
$kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
$kformlib->gthis=$wakka;
$themehome=$wakka->GetThemePath('/');
$updatetime=time();
$clientlst=$wakka->GetBBBUserData("clientslist");
$isadmin=$wakka->IsAdmin();
$username=$wakka->GetUserName();
$triggers=Input::get("triggers");
$tmpstr=explode(",",$kformlib->HRFiledsStr);
$success="";$message="";$successcnt=0;$duplicatecount=0;
$conn = array(
'driver' => 'mysql',
'host' => '10.3.177.14',
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'yb9738z'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'options' => array(
PDO::ATTR_TIMEOUT => 5,
),
);
Config::set("database.connections.conn", $conn);
DB::connection("conn")->getDatabaseName();
$excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat where SERVER_IP='10.3.179.121' order by auto_id asc limit 100001,120000"));
$server_ip='10.3.179.121';
$location='Mumbai';
$conn='';
$tcol=0;$fieldsarr=array();$extrahdrarr=array();
foreach($excelarray as $key => $array){
$excelarray[$key] = (array)$array;
}
$highestColumn = DB::connection("conn")->select(DB::raw("select count(*) as cnt from information_schema.columns where table_name='bz_record_upload_uat'"));
$highestColumn = $highestColumn[0]->cnt;
$highestrow = count($excelarray);
$flag = 0;
$editflag=0;
for($i=0;$i<=$highestrow;$i++)
{
if($excelarray[$i]["id"]!="")
{
if($excelarray[$i]["id"]=="CREATE")
{
$excelarray[$i]["id"]=$wakka->Query("insert into","","records",array('created'=>date('Y-m-d H:i:s')));
}
else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
if($wakka->getCount("records","id='".$excelarray[$i]["id"]."'")==1)
{
$empdata=$wakka->getPerson($excelarray[$i]["id"]);
$ppldata=$empdata["peopledata"];
$createdlog=$empdata['modifylog'];
$fdirty=$empdata['dirty'];
$createdlog[$updatetime]=$username."::";
$createdlog["updated"]=$updatetime;
$newdata=$ppldata;
foreach($excelarray[$i] as $key => $value)
{
if($value!="")
{
if("A".$ppldata[$key]!="A".$value)//forcing string comparrision //MAGIC
{
$value=str_replace("'"," ",$value);
if(strstr($createdlog[$updatetime],$key)==FALSE)$createdlog[$updatetime].="$key|".str_replace(array("|",",")," ",$ppldata[$key])."|".str_replace(array("|",",")," ",$value).",";
$fdirty[$key]=1;
$newdata[$key]=$value;
}
}
}
/*Start - Changes need to be done*/
if($excelarray[$i]["status"]==null)
{
$empdata['status'] = "rom";
}
if($excelarray[$i]["dialer_status"]==null)
{
$empdata['dialer_status'] = "rom";
}
if($excelarray[$i]["dialer_substatus"]==null)
{
$empdata['dialer_substatus'] = "rom";
}
/*End - Changes need to be done*/
$empdata["peopledata"]=$newdata;
$empdata['modifylog']=$createdlog;
$empdata['dirty']=$fdirty;
$wakka->setPerson($excelarray[$i]["id"],$empdata);
$excelarray[$i]['modified']=date('Y-m-d H:i:s');
$successArr[] = $excelarray[$i];
}
}
else
{
$reason = "";
if($excelarray[$i]["id"]=="")
$reason .= "Column ID is blank,";
$excelarray[$i]['server_ip'] =$server_ip;
$excelarray[$i]['location'] =$location;
if($excelarray[$i]["clientcode"]!="")
$excelarray[$i]['cust_id'] =$excelarray[$i]["clientcode"];
$excelarray[$i]['Reason'] = $reason;
$failureArr[] = $excelarray[$i];
}
}
if(!empty($successArr)){
foreach($successArr as $succes)
{
$setSuccess=array();
$setSuccess[] = "server_ip='$server_ip'";
$setSuccess[] = "location='$location'";
$setSuccess[] = "record_id='".$succes['id']."'";
$setSuccess[] = "cust_id='".$succes['clientcode']."'";
$setSuccess[] = "modified='".$succes['modified']."'";
$setSuccess = implode(",",$setSuccess);
DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_success set $setSuccess"));
}
}
if(!empty($failureArr)){
foreach($failureArr as $failur)
{
$setFailure=array();
$setFailure[] = "server_ip='$server_ip'";
$setFailure[] = "location='$location'";
$setFailure[] = "cust_id='".$failur['clientcode']."'";
$setFailure[] = "reason='".$failur['Reason']."'";
$setFailure = implode(",",$setFailure);
DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_failure set $setFailure"));
}
}
// DB::connection("conn")->delete(DB::raw("DELETE FROM `bz_record_upload_uat` where SERVER_IP='10.3.179.121'"));
DB::connection("conn")->disconnect();
}
}
<?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 App\Models\Notification;
use App\Jobs\KHRMSLib;
use Input;
use Illuminate\Database\Schema\Blueprint;
class bulkServerUpload_daily extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'bulkServerUpload_daily';
/**
* The console command description.
*
* @var string
*/
protected $description = 'bulkServerUpload_daily';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
echo "\n".date('Y-m-d')."\n";
$wakka = new KHRMSLib();
$kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
$kformlib->gthis=$wakka;
$themehome=$wakka->GetThemePath('/');
$updatetime=time();
$clientlst=$wakka->GetBBBUserData("clientslist");
$isadmin=$wakka->IsAdmin();
$username=$wakka->GetUserName();
$triggers=Input::get("triggers");
$tmpstr=explode(",",$kformlib->HRFiledsStr);
$success="";$message="";$successcnt=0;$duplicatecount=0;
$conn = array(
'driver' => 'mysql',
'host' => '10.3.177.14',
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'yb9738z'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'options' => array(
PDO::ATTR_TIMEOUT => 5,
),
);
Config::set("database.connections.conn", $conn);
DB::connection("conn")->getDatabaseName();
$excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat_daily where SERVER_IP='10.3.179.121' order by auto_id asc limit 0,200"));
$server_ip='10.3.179.121';
$location='Mumbai';
$conn='';
$tcol=0;$fieldsarr=array();$extrahdrarr=array();
foreach($excelarray as $key => $array){
$excelarray[$key] = (array)$array;
}
$highestColumn = DB::connection("conn")->select(DB::raw("select count(*) as cnt from information_schema.columns where table_name='bz_record_upload_uat_daily'"));
$highestColumn = $highestColumn[0]->cnt;
$highestrow = count($excelarray);
$flag = 0;
$editflag=0;
for($i=0;$i<=$highestrow;$i++)
{
if($excelarray[$i]["id"]!="")
{
if($excelarray[$i]["id"]=="CREATE")
{
$excelarray[$i]["id"]=$wakka->Query("insert into","","records",array('created'=>date('Y-m-d H:i:s')));
}
else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
if($wakka->getCount("records","id='".$excelarray[$i]["id"]."'")==1)
{
$empdata=$wakka->getPerson($excelarray[$i]["id"]);
$ppldata=$empdata["peopledata"];
$createdlog=$empdata['modifylog'];
$fdirty=$empdata['dirty'];
$createdlog[$updatetime]=$username."::";
$createdlog["updated"]=$updatetime;
$newdata=$ppldata;
foreach($excelarray[$i] as $key => $value)
{
if($value!="")
{
if("A".$ppldata[$key]!="A".$value)//forcing string comparrision //MAGIC
{
$value=str_replace("'"," ",$value);
if(strstr($createdlog[$updatetime],$key)==FALSE)$createdlog[$updatetime].="$key|".str_replace(array("|",",")," ",$ppldata[$key])."|".str_replace(array("|",",")," ",$value).",";
$fdirty[$key]=1;
$newdata[$key]=$value;
}
}
}
/*Start - Changes need to be done*/
if($excelarray[$i]["status"]==null)
{
$empdata['status'] = "rom";
}
if($excelarray[$i]["dialer_status"]==null)
{
$empdata['dialer_status'] = "rom";
}
if($excelarray[$i]["dialer_substatus"]==null)
{
$empdata['dialer_substatus'] = "rom";
}
/*End - Changes need to be done*/
$empdata["peopledata"]=$newdata;
$empdata['modifylog']=$createdlog;
$empdata['dirty']=$fdirty;
$wakka->setPerson($excelarray[$i]["id"],$empdata);
$excelarray[$i]['modified']=date('Y-m-d H:i:s');
$successArr[] = $excelarray[$i];
}
}
else
{
$reason = "";
if($excelarray[$i]["id"]=="")
$reason .= "Column ID is blank,";
$excelarray[$i]['server_ip'] =$server_ip;
$excelarray[$i]['location'] =$location;
if($excelarray[$i]["clientcode"]!="")
$excelarray[$i]['cust_id'] =$excelarray[$i]["clientcode"];
$excelarray[$i]['Reason'] = $reason;
$failureArr[] = $excelarray[$i];
}
}
if(!empty($successArr)){
foreach($successArr as $succes)
{
$setSuccess=array();
$setSuccess[] = "server_ip='$server_ip'";
$setSuccess[] = "location='$location'";
$setSuccess[] = "record_id='".$succes['id']."'";
$setSuccess[] = "cust_id='".$succes['clientcode']."'";
$setSuccess[] = "modified='".$succes['modified']."'";
$setSuccess = implode(",",$setSuccess);
DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_success_daily set $setSuccess"));
}
}
if(!empty($failureArr)){
foreach($failureArr as $failur)
{
$setFailure=array();
$setFailure[] = "server_ip='$server_ip'";
$setFailure[] = "location='$location'";
$setFailure[] = "cust_id='".$failur['clientcode']."'";
$setFailure[] = "reason='".$failur['Reason']."'";
$setFailure = implode(",",$setFailure);
DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_failure_daily set $setFailure"));
}
}
DB::connection("conn")->delete(DB::raw("DELETE FROM `bz_record_upload_uat_daily` where SERVER_IP='10.3.179.121'"));
DB::connection("conn")->disconnect();
}
}
<?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 App\Models\Notification;
use App\Jobs\KHRMSLib;
use Input;
use Illuminate\Database\Schema\Blueprint;
class bulkServerUpload extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'bulkServerUpload';
/**
* The console command description.
*
* @var string
*/
protected $description = 'bulkServerUpload';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
echo "\n".date('Y-m-d')."\n";
$wakka = new KHRMSLib();
$kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
$kformlib->gthis=$wakka;
$themehome=$wakka->GetThemePath('/');
$updatetime=time();
$clientlst=$wakka->GetBBBUserData("clientslist");
$isadmin=$wakka->IsAdmin();
$username=$wakka->GetUserName();
$triggers=Input::get("triggers");
$tmpstr=explode(",",$kformlib->HRFiledsStr);
$success="";$message="";$successcnt=0;$duplicatecount=0;
$conn = array(
'driver' => 'mysql',
'host' => '10.3.177.14',
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'yb9738z'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'options' => array(
PDO::ATTR_TIMEOUT => 5,
),
);
Config::set("database.connections.conn", $conn);
DB::connection("conn")->getDatabaseName();
$excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat where SERVER_IP='10.3.179.121' order by auto_id asc limit 0,20000"));
foreach($excelarray as $key => $array){
$excelarray[$key] = (array)$array;
}
$highestColumn = DB::connection("conn")->select(DB::raw("select count(*) as cnt from information_schema.columns where table_name='bz_record_upload_uat'"));
$highestColumn = $highestColumn[0]->cnt;
$highestrow = count($excelarray);
$flag = 0;
$editflag=0;
for($i=0;$i<=$highestrow;$i++)
{
if($excelarray[$i]["id"]!="")
{
if($excelarray[$i]["id"]=="CREATE")
{
$excelarray[$i]["id"]=$wakka->Query("insert into","","records",array('created'=>date('Y-m-d H:i:s')));
}
else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
if($wakka->getCount("records","id='".$excelarray[$i]["id"]."'")==1)
{
$empdata=$wakka->getPerson($excelarray[$i]["id"]);
$ppldata=$empdata["peopledata"];
$createdlog=$empdata['modifylog'];
$fdirty=$empdata['dirty'];
$createdlog[$updatetime]=$username."::";
$createdlog["updated"]=$updatetime;
$newdata=$ppldata;
foreach($excelarray[$i] as $key => $value)
{
if($value!="")
{
if("A".$ppldata[$key]!="A".$value)//forcing string comparrision //MAGIC
{
$value=str_replace("'"," ",$value);
if(strstr($createdlog[$updatetime],$key)==FALSE)$createdlog[$updatetime].="$key|".str_replace(array("|",",")," ",$ppldata[$key])."|".str_replace(array("|",",")," ",$value).",";
$fdirty[$key]=1;
$newdata[$key]=$value;
}
}
}
/*Start - Changes need to be done*/
if($excelarray[$i]["status"]==null)
{
$empdata['status'] = "rom";
}
if($excelarray[$i]["dialer_status"]==null)
{
$empdata['dialer_status'] = "rom";
}
if($excelarray[$i]["dialer_substatus"]==null)
{
$empdata['dialer_substatus'] = "rom";
}
/*End - Changes need to be done*/
$empdata["peopledata"]=$newdata;
$empdata['modifylog']=$createdlog;
$empdata['dirty']=$fdirty;
$wakka->setPerson($excelarray[$i]["id"],$empdata);
$excelarray[$i]['modified']=date('Y-m-d H:i:s');
$successArr[] = $excelarray[$i];
}
}
else
{
$reason = "";
if($excelarray[$i]["id"]=="")
$reason .= "Column ID is blank,";
$excelarray[$i]['server_ip'] =$server_ip;
$excelarray[$i]['location'] =$location;
if($excelarray[$i]["clientcode"]!="")
$excelarray[$i]['cust_id'] =$excelarray[$i]["clientcode"];
$excelarray[$i]['Reason'] = $reason;
$failureArr[] = $excelarray[$i];
}
}
if(!empty($successArr)){
foreach($successArr as $succes)
{
$setSuccess=array();
$setSuccess[] = "server_ip='$server_ip'";
$setSuccess[] = "location='$location'";
$setSuccess[] = "record_id='".$succes['id']."'";
$setSuccess[] = "cust_id='".$succes['clientcode']."'";
$setSuccess[] = "modified='".$succes['modified']."'";
$setSuccess = implode(",",$setSuccess);
DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_success set $setSuccess"));
}
}
if(!empty($failureArr)){
foreach($failureArr as $failur)
{
$setFailure=array();
$setFailure[] = "server_ip='$server_ip'";
$setFailure[] = "location='$location'";
$setFailure[] = "cust_id='".$failur['clientcode']."'";
$setFailure[] = "reason='".$failur['Reason']."'";
$setFailure = implode(",",$setFailure);
DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_failure set $setFailure"));
}
}
DB::connection("conn")->disconnect();
}
}
<?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 App\Models\Notification;
use App\Jobs\KHRMSLib;
use Input;
use Illuminate\Database\Schema\Blueprint;
class bulkServerUpload extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'bulkServerUpload';
/**
* The console command description.
*
* @var string
*/
protected $description = 'bulkServerUpload';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
echo "\n".date('Y-m-d')."\n";
$wakka = new KHRMSLib();
$kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
$kformlib->gthis=$wakka;
$themehome=$wakka->GetThemePath('/');
$updatetime=time();
$clientlst=$wakka->GetBBBUserData("clientslist");
$isadmin=$wakka->IsAdmin();
$username=$wakka->GetUserName();
$triggers=Input::get("triggers");
$tmpstr=explode(",",$kformlib->HRFiledsStr);
$success="";$message="";$successcnt=0;$duplicatecount=0;
$conn = array(
'driver' => 'mysql',
'host' => '10.3.177.14',
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'yb9738z'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'options' => array(
PDO::ATTR_TIMEOUT => 5,
),
);
Config::set("database.connections.conn", $conn);
DB::connection("conn")->getDatabaseName();
$excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat_080117 where SERVER_IP='10.3.179.121' and ins_date>'2016-11-29' order by auto_id asc limit 0,20000"));
foreach($excelarray as $key => $array){
$excelarray[$key] = (array)$array;
}
$highestColumn = DB::connection("conn")->select(DB::raw("select count(*) as cnt from information_schema.columns where table_name='bz_record_upload_uat_080117'"));
$highestColumn = $highestColumn[0]->cnt;
$highestrow = count($excelarray);
$flag = 0;
$editflag=0;
for($i=0;$i<=$highestrow;$i++)
{
if($excelarray[$i]["id"]!="")
{
if($excelarray[$i]["id"]=="CREATE")
{
$excelarray[$i]["id"]=$wakka->Query("insert into","","records_demo",array('created'=>date('Y-m-d H:i:s')));
}
else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
if($wakka->getCount("records_demo","id='".$excelarray[$i]["id"]."'")==1)
{
$empdata=$wakka->getPersonServer($excelarray[$i]["id"]);
$ppldata=$empdata["peopledata"];
$createdlog=$empdata['modifylog'];
$fdirty=$empdata['dirty'];
$createdlog[$updatetime]=$username."::";
$createdlog["updated"]=$updatetime;
$newdata=$ppldata;
foreach($excelarray[$i] as $key => $value)
{
if($value!="")
{
if("A".$ppldata[$key]!="A".$value)//forcing string comparrision //MAGIC
{
$value=str_replace("'"," ",$value);
if(strstr($createdlog[$updatetime],$key)==FALSE)$createdlog[$updatetime].="$key|".str_replace(array("|",",")," ",$ppldata[$key])."|".str_replace(array("|",",")," ",$value).",";
$fdirty[$key]=1;
$newdata[$key]=$value;
}
}
}
/*Start - Changes need to be done*/
if($excelarray[$i]["status"]==null)
{
$newdata['status'] = "";
}
if($excelarray[$i]["dialer_status"]==null)
{
$newdata['dialer_status'] = "";
}
if($excelarray[$i]["dialer_substatus"]==null)
{
$newdata['dialer_substatus'] = "";
}
/*End - Changes need to be done*/
$empdata["peopledata"]=$newdata;
$empdata['modifylog']=$createdlog;
$empdata['dirty']=$fdirty;
$wakka->setPersonServer($excelarray[$i]["id"],$empdata);
$excelarray[$i]['modified']=date('Y-m-d H:i:s');
$successArr[] = $excelarray[$i];
}
}
else
{
$reason = "";
if($excelarray[$i]["id"]=="")
$reason .= "Column ID is blank,";
$excelarray[$i]['server_ip'] = $server_ip;
$excelarray[$i]['location'] = $location;
if($excelarray[$i]["clientcode"]!="")
$excelarray[$i]['cust_id'] = $excelarray[$i]["clientcode"];
$excelarray[$i]['Reason'] = $reason;
$failureArr[] = $excelarray[$i];
}
}
if(!empty($successArr)){
foreach($successArr as $succes)
{
$setSuccess=array();
$setSuccess[] = "server_ip='$server_ip'";
$setSuccess[] = "location='$location'";
$setSuccess[] = "record_id='".$succes['id']."'";
$setSuccess[] = "cust_id='".$succes['clientcode']."'";
$setSuccess[] = "modified='".$succes['modified']."'";
$setSuccess = implode(",",$setSuccess);
DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_success set $setSuccess"));
}
}
if(!empty($failureArr)){
foreach($failureArr as $failur)
{
$setFailure=array();
$setFailure[] = "server_ip='$server_ip'";
$setFailure[] = "location='$location'";
$setFailure[] = "cust_id='".$failur['clientcode']."'";
$setFailure[] = "reason='".$failur['Reason']."'";
$setFailure = implode(",",$setFailure);
DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_failure set $setFailure"));
}
}
DB::connection("conn")->disconnect();
}
}
\ No newline at end of file
<?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 questionnaire_details extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'questionnaire_details';
/**
* The console command description.
*
* @var string
*/
protected $description = 'questionnaire_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_id="08";
$questionaire = "questionaire_details_".date("d_m_Y");
//$questionaire = "questionaire_details_23_06_2017";
$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())
{
echo ",".$server_id;
$maxid=DB::connection("conn")->select(DB::raw("SELECT max(question_id) as maxid from $questionaire where server='$server_id'"));
$maxids=$maxid[0]->maxid;
$qlist=DB::select(DB::raw("SELECT * from questionaire_details 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();
$crtdate=date("Y-m-d H:i:s",strtotime($qline->created_at)+330*60);
$update=date("Y-m-d H:i:s",strtotime($qline->updated_at)+330*60);
$qtime=date("Y-m-d H:i:s",strtotime($qline->question_time)+330*60);
$setstrarr[]="server='$server_id'";
$setstrarr[]="question_id='$qline->id'";
$setstrarr[]="created_at='$crtdate'";
$setstrarr[]="updated_at='$update'";
$setstrarr[]="user_id='$qline->user_id'";
$setstrarr[]="cust_id='$qline->cust_id'";
$setstrarr[]="call_id='$qline->call_id'";
$setstrarr[]="name='$qline->name'";
$setstrarr[]="number='$qline->number'";
$setstrarr[]="question_time='$qtime'";
$setstrarr[]="question='$qline->question'";
$setstrarr[]="primary_question='$qline->primary_question'";
$setstrarr[]="primary_response='$qline->primary_response'";
$setstrarr[]="primary_text='$qline->primary_text'";
$setstrarr[]="followup1_question='$qline->followup1_question'";
$setstrarr[]="followup1_response='$qline->followup1_response'";
$setstrarr[]="followup1_text='$qline->followup1_text'";
$setstrarr[]="followup2_question='$qline->followup2_question'";
$setstrarr[]="followup2_response='$qline->followup2_response'";
$setstrarr[]="followup2_text='$qline->followup2_text'";
$setstrarr[]="followup3_question='$qline->followup3_question'";
$setstrarr[]="followup3_response='$qline->followup3_response'";
$setstrarr[]="followup3_text='$qline->followup3_text'";
$setstrarr[]="followup4_question='$qline->followup4_question'";
$setstrarr[]="followup4_response='$qline->followup4_response'";
$setstrarr[]="followup4_text='$qline->followup4_text'";
$setstrarr[]="followup5_question='$qline->followup5_question'";
$setstrarr[]="followup5_response='$qline->followup5_response'";
$setstrarr[]="followup5_text='$qline->followup5_text'";
$setstrarr[]="followup6_question='$qline->followup6_question'";
$setstrarr[]="followup6_response='$qline->followup6_response'";
$setstrarr[]="followup6_text='$qline->followup6_text'";
$setstrarr[]="followup7_question='$qline->followup7_question'";
$setstrarr[]="followup7_response='$qline->followup7_response'";
$setstrarr[]="followup7_text='$qline->followup7_text'";
$setstr=implode(",",$setstrarr);
DB::connection("conn")->insert(DB::raw("insert into ".$questionaire." set $setstr"));
}
DB::connection("conn")->disconnect();
}
}
}
<?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 records_details extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'records_details';
/**
* The console command description.
*
* @var string
*/
protected $description = 'records_details';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$nowts=time();
echo "\n".date('Y-m-d')."\n";
//$slist=DB::connection("conn")->select(DB::raw("select * from server_details where type='COP' and id='1'"));
//$slist=DB::select(DB::raw("select * from server_details where type='COP' and id>'27' and id!='54'"));
$server_ip='10.3.179.121';
$location='mumbai';
$conn='';
$tcol=0;$fieldsarr=array();$extrahdrarr=array();
$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())
{
echo ",".$server_ip;
$qlist=DB::select(DB::raw("SELECT id,clientcode,client,status,clientinternalid,mobile,priority,modified,question,firstname FROM `records`"));
$datainser='';
foreach($qlist as $qline)
{
$record_id=$qline->id;
$clientcode=$qline->clientcode;
$client=$qline->client;
$status=$qline->status;
$clientinternalid=$qline->clientinternalid;
$mobile=$qline->mobile;
$priority=$qline->priority;
$modified=$qline->modified;
$question=$qline->question;
$firstname=$qline->firstname;
DB::connection("conn")->insert(DB::raw("insert into records_details_server_1 set client='$client', server_ip='$server_ip', record_id='$record_id', cust_id='$clientcode', records_status='$status', group_id='$clientinternalid', location='$location',mobile='$mobile',question='$question',firstname='$firstname',priority='$priority',modified='$modified'"));
}
DB::connection("conn")->disconnect();
}
}
}
<?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 App\Models\Notification;
use App\Jobs\KHRMSLib;
use Input;
use Illuminate\Database\Schema\Blueprint;
class bulkServerUpload extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'bulkServerUpload';
/**
* The console command description.
*
* @var string
*/
protected $description = 'bulkServerUpload';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$wakka = new KHRMSLib();
$kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
$kformlib->gthis=$wakka;
$themehome=$wakka->GetThemePath('/');
$updatetime=time();
$clientlst=$wakka->GetBBBUserData("clientslist");
$isadmin=$wakka->IsAdmin();
$username=$wakka->GetUserName();
$triggers=Input::get("triggers");
$tmpstr=explode(",",$kformlib->HRFiledsStr);
$success="";$message="";$successcnt=0;$duplicatecount=0;
$conn = array(
'driver' => 'mysql',
'host' => '10.3.177.14',
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'yb9738z'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'options' => array(
PDO::ATTR_TIMEOUT => 5,
),
);
Config::set("database.connections.conn", $conn);
DB::connection("conn")->getDatabaseName();
$excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat where SERVER_IP='10.3.179.121' and client='G4015' order by auto_id asc limit 0,20000"));
foreach($excelarray as $key => $array){
$excelarray[$key] = (array)$array;
}
$highestColumn = DB::connection("conn")->select(DB::raw("select count(*) as cnt from information_schema.columns where table_name='bz_record_upload_uat'"));
$highestColumn = $highestColumn[0]->cnt;
$highestrow = count($excelarray);
$flag = 0;
$editflag=0;
for($i=0;$i<=$highestrow;$i++)
{
if($excelarray[$i]["id"]!="")
{
if($excelarray[$i]["id"]=="CREATE")
{
$excelarray[$i]["id"]=$wakka->Query("insert into","","records",array('created'=>date('Y-m-d H:i:s')));
}
else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
if($wakka->getCount("records","id='".$excelarray[$i]["id"]."'")==1)
{
$empdata=$wakka->getPerson($excelarray[$i]["id"]);
$ppldata=$empdata["peopledata"];
$createdlog=$empdata['modifylog'];
$fdirty=$empdata['dirty'];
$createdlog[$updatetime]=$username."::";
$createdlog["updated"]=$updatetime;
$newdata=$ppldata;
foreach($excelarray[$i] as $key => $value)
{
if($value!="")
{
if("A".$ppldata[$key]!="A".$value)//forcing string comparrision //MAGIC
{
$value=str_replace("'"," ",$value);
if(strstr($createdlog[$updatetime],$key)==FALSE)$createdlog[$updatetime].="$key|".str_replace(array("|",",")," ",$ppldata[$key])."|".str_replace(array("|",",")," ",$value).",";
$fdirty[$key]=1;
$newdata[$key]=$value;
}
}
}
$empdata["peopledata"]=$newdata;
$empdata['modifylog']=$createdlog;
$empdata['dirty']=$fdirty;
$wakka->setPerson($excelarray[$i]["id"],$empdata);
$excelarray[$i]['modified']=date('Y-m-d H:i:s');
}
}
}
mysqli_close($conn);
}
}
<?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 CreportEight extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'CreportEight';
/**
* The console command description.
*
* @var string
*/
protected $description = 'App Main Daily Task for CreportEight';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$nowts=time();
echo "\n".date('Y-m-d H:i:s')."\n";
$logdate=strtotime('0 day');
$tcol=0;$fieldsarr=array();$extrahdrarr=array();
$central_ip=env('central_ip');
$server_ip=env('app_ip');
$calllog_report = "calllog_report_".date("d_m_Y");
$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;
}
$maxid=DB::connection("conn")->select(DB::raw("SELECT max(crmcall_id) as maxid from $calllog_report where server='$server_id'"));
$maxids=$maxid[0]->maxid;
$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))."'"));
$userarr=array();
foreach($alist as $aline)
{
$setstrarr=array();
$clientcode="";$currentstatus="";$legalstatus="";$record_id="";
if($aline->crm_id>0)
{
$user=DB::select(DB::raw("select id,clientcode,currentstatus,legalstatus from records where id='".$aline->crm_id."' limit 1;"));
if(isset($user[0]))
{
$record_id=$user[0]->id;
$clientcode=$user[0]->clientcode;
$currentstatus=$user[0]->currentstatus;
$legalstatus=$user[0]->legalstatus;
}
}
$tpostdata=json_decode($aline->data,true);
$fulldate=date("Y-m-d H:i:s",strtotime($aline->created_at)+330*60);
$talktime=$aline->talkSec+$aline->recstartSec+$aline->recendSec;
$length=round(($aline->waitSec+$aline->callSec+$talktime+$aline->dispoSec)/1000,2);
if(!isset($userarr[$aline->user_id])&&$aline->user_id>0)$userarr[$aline->user_id]=User::find($aline->user_id);
$dispname="";if(isset($userarr[$aline->user_id]))$dispname=$userarr[$aline->user_id]->dispname();
$username="";if(isset($userarr[$aline->user_id]))$username=$userarr[$aline->user_id]->username;
$globalid=$server_id.$record_id;
$setstrarr[]="server='$server_id'";
$setstrarr[]="record_id='$record_id'";
$setstrarr[]="crmcall_id='$aline->id'";
$setstrarr[]="globalid='$globalid'";
$setstrarr[]="start='$fulldate'";
$setstrarr[]="length='$length'";
$setstrarr[]="user='$username'";
$setstrarr[]="name='$dispname'";
$setstrarr[]="dispo='$aline->userstatus'";
$setstrarr[]="subdispo='$aline->usersubstatus'";
$setstrarr[]="callback='$aline->usercallback'";
$setstrarr[]="number='$aline->number'";
$setstrarr[]="clientcode='$clientcode'";
$setstrarr[]="currentstatus='$currentstatus'";
$setstrarr[]="legalstatus='$legalstatus'";
$setstrarr[]="client='$aline->client'";
$setstrarr[]="department='$aline->department'";
$setstrarr[]="state='$aline->state'";
$setstrarr[]="hsource='$aline->hsource'";
$setstrarr[]="type='$aline->type'";
$setstrarr[]="status='$aline->status'";
$setstrarr[]="statuscode='$aline->statuscode'";
$setstrarr[]="statusstr='$aline->substatus'";
$setstrarr[]="dialline='$aline->dialline_id'";
$setstrarr[]="did='$aline->did'";
$setstrarr[]="waitsec='".round($aline->waitSec/1000,2)."'";
$setstrarr[]="callsec='".round($aline->callSec/1000,2)."'";
$setstrarr[]="talksec='".round($talktime/1000,2)."'";
$setstrarr[]="disposec='".round($aline->dispoSec/1000,2)."'";
$setstrarr[]="remarks='".str_replace("'","",$aline->userremarks)."'";
$setstrarr[]="userdata='$aline->userdata'";
$setstr=implode(",",$setstrarr);
DB::connection("conn")->insert(DB::raw("insert into ".$calllog_report." set $setstr"));
}
}
}
<?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 App\Models\Notification;
use App\Jobs\KHRMSLib;
use Input;
use App\Models\Sipid;
use App\Models\Kqueue;
use App\Models\Dialline;
use App\Models\Session;
use Illuminate\Database\Schema\Blueprint;
class DailyLogout extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'DailyLogout';
/**
* The console command description.
*
* @var string
*/
protected $description = 'DailyLogout';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$sipids=Sipid::where("status","=","1")->get();
foreach($sipids as $tsip)
{
$newqueue=new Kqueue();
$newqueue->sipNotify($tsip,"adminCommand","user","logout","");
}
Dialline::where('status','!=','Free')->update(['status'=>'Free','conf'=>'','channel'=>'','server'=>'','updated_at'=>'0000-00-00 00:00:00']);
Sipid::where('status','!=','0')->update(['status'=>0,'user'=>0,'ready'=>0,'confup'=>0,'clients'=>'','server'=>'','updated_at'=>'0000-00-00 00:00:00']);
$serverarray=explode(",",Config::get("app.asterisk_slaves"));
foreach($serverarray as $server)
{
$sparts=explode(":",$server);
Sipid::where("id",">=",$sparts[1])->where("id","<=",$sparts[2])->update(['server' => $sparts[0],'updated_at'=>'0000-00-00 00:00:00']);
Dialline::where("id",">=",$sparts[3])->where("id","<=",$sparts[4])->update(['server' => $sparts[0],'updated_at'=>'0000-00-00 00:00:00']);
$newqueue=new Kqueue();
$newqueue->astCommand($sparts[0],"channel request hangup all");
}
User::where('presence','>','0')->update(['presence'=>0]);
Session::truncate();
return "";
}
}
<?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 App\Models\Notification;
use App\Jobs\KHRMSLib;
use Input;
use App\Models\Sipid;
use App\Models\Kqueue;
use App\Models\Dialline;
use App\Models\Session;
use Illuminate\Database\Schema\Blueprint;
class DeleteCrmcalls extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'DeleteCrmcalls';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Delete data from CRMCalls before 7 days';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$logdate=strtotime('-7 day');
CRMCall::where('created_at','<',date("Y-m-d",$logdate))->delete();
}
}
<?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 App\Models\Notification;
use App\Jobs\KHRMSLib;
use Input;
use App\Models\Sipid;
use App\Models\Kqueue;
use App\Models\Dialline;
use App\Models\Session;
use Illuminate\Database\Schema\Blueprint;
class InsertCrmArchive extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'InsertCrmArchive';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Insert updated data into crmcalls_archive from crmcalls';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
echo 'Start';
DB::insert(DB::raw("insert into crmcalls_archive select * from crmcalls where id>(select max(id) from crmcalls_archive)"));
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"));
echo 'End';
}
}
<?php namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Jobs\KPAMIListen;
class KstychARP extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'KstychARP';
/**
* The console command description.
*
* @var string
*/
protected $description = 'ARP Broadcast';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
}
}
<?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 KstychDaily extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'KstychDaily';
/**
* The console command description.
*
* @var string
*/
protected $description = 'App Main Daily Task';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$nowts=time();
Accesslog::where('endtime','<',date("Y-m-d H:i:s",$nowts-2*24*60*60))->update(array('postdata'=>'','queries'=>''));
Accesslog::where('endtime','<',date("Y-m-d H:i:s",$nowts-2*24*60*60))->delete();
if(env('app_ip')=="10.3.177.14")
{
if(!Schema::hasTable('calllog_report'))
{
Schema::create('calllog_report', function(Blueprint $table)
{
$table->string('server', 100);
$table->dateTime('start');
$table->integer('length');
$table->string('user',100);
$table->string('name',100);
$table->string('dispo', 200);
$table->string('subdispo', 200);
$table->dateTime('callback');
$table->string('number', 100);
$table->string('clientcode', 100);
$table->string('currentstatus', 100);
$table->string('legalstatus', 100);
$table->string('client', 200);
$table->string('department', 200);
$table->string('state', 50);
$table->string('hsource', 100);
$table->string('type', 50);
$table->string('statuscode', 20);
$table->string('status', 100);
$table->string('statusstr', 100);
$table->integer('dialline');
$table->string('did', 50);
$table->bigInteger('waitsec');
$table->bigInteger('callsec');
$table->bigInteger('talksec');
$table->bigInteger('disposec');
$table->string('remarks', 500);
$table->string('userdata',1000);
});
}
$offline=array();
$arr=Config::get("app.hdfcnodes");
$logdate=strtotime('-1 day');
$tcol=0;$fieldsarr=array();$extrahdrarr=array();
$ii=1;$ci=0;
foreach($arr as $server=>$serverline)
{
$ci++;
$conn = array(
'driver' => 'mysql',
'host' => $server,
'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$ci", $conn);
try
{
DB::connection("conn$ci")->getDatabaseName();
$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();
$userarr=array();
foreach($alist as $aline)
{
$setstrarr=array();
$clientcode="";$currentstatus="";$legalstatus="";
if($aline->crm_id>0)
{
$user=DB::connection("conn$ci")->select(DB::raw("select id,clientcode,currentstatus,legalstatus from records where id='".$aline->crm_id."' limit 1;"));
if(isset($user[0]))
{
$clientcode=$user[0]->clientcode;
$currentstatus=$user[0]->currentstatus;
$legalstatus=$user[0]->legalstatus;
}
}
$tpostdata=json_decode($aline->data,true);
$fulldate=date("Y-m-d H:i:s",strtotime($aline->created_at)+330*60);
$talktime=$aline->talkSec+$aline->recstartSec+$aline->recendSec;
$length=round(($aline->waitSec+$aline->callSec+$talktime+$aline->dispoSec)/1000,2);
if(!isset($userarr[$aline->user_id])&&$aline->user_id>0)$userarr[$aline->user_id]=User::on("conn$ci")->find($aline->user_id);
$dispname="";if(isset($userarr[$aline->user_id]))$dispname=$userarr[$aline->user_id]->dispname();
$username="";if(isset($userarr[$aline->user_id]))$username=$userarr[$aline->user_id]->username;
$setstrarr[]="server='$server'";
$setstrarr[]="start='$fulldate'";
$setstrarr[]="length='$length'";
$setstrarr[]="user='$username'";
$setstrarr[]="name='$dispname'";
$setstrarr[]="dispo='$aline->userstatus'";
$setstrarr[]="subdispo='$aline->usersubstatus'";
$setstrarr[]="callback='$aline->usercallback'";
$setstrarr[]="number='$aline->number'";
$setstrarr[]="clientcode='$clientcode'";
$setstrarr[]="currentstatus='$currentstatus'";
$setstrarr[]="legalstatus='$legalstatus'";
$setstrarr[]="client='$aline->client'";
$setstrarr[]="department='$aline->department'";
$setstrarr[]="state='$aline->state'";
$setstrarr[]="hsource='$aline->hsource'";
$setstrarr[]="type='$aline->type'";
$setstrarr[]="status='$aline->status'";
$setstrarr[]="statuscode='$aline->statuscode'";
$setstrarr[]="statusstr='$aline->substatus'";
$setstrarr[]="dialline='$aline->dialline_id'";
$setstrarr[]="did='$aline->did'";
$setstrarr[]="waitsec='".round($aline->waitSec/1000,2)."'";
$setstrarr[]="callsec='".round($aline->callSec/1000,2)."'";
$setstrarr[]="talksec='".round($talktime/1000,2)."'";
$setstrarr[]="disposec='".round($aline->dispoSec/1000,2)."'";
$setstrarr[]="remarks='$aline->userremarks'";
$setstrarr[]="userdata='$aline->userdata'";
$setstr=implode(",",$setstrarr);
DB::insert(DB::raw("insert into calllog_report set $setstr"));
}
}
catch(Exception $e)
{
$offline[]=$server;
}
}
}
}
}
<?php namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Jobs\KPAGIListen;
class KstychPAGI extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'KstychPAGI';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Daemon to Listen to Asterisk';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$agi = \PAGI\Client\Impl\ClientImpl::getInstance();
$kpagi = new KPAGIListen(array('pagiClient' => $agi));
$kpagi->init();
$kpagi->run();
}
}
<?php namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Jobs\KPAMIListen;
class KstychPAMI extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'KstychPAMI {serverip=127.0.0.1}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Daemon to Listen to Asterisk';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$listener = new KPAMIListen($this->argument('serverip'));$listener->run();
}
}
<?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 Userlog_data extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'Userlog_data';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Userlog_data';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$nowts=time();
echo "\n".date('Y-m-d')."\n";
$logdate=strtotime('-1 day');
$tcol=0;$fieldsarr=array();$extrahdrarr=array();
$server_ip=env('app_ip');
$central_ip=env('central_ip');
$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);
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;
}
$i=0;
$ulist=DB::select(DB::raw("select * from users WHERE 1"));
foreach($ulist as $uline) {
$users[$uline->id] = $uline->username;
}
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)."'"))){
foreach($alist as $aline) {
$i++;
$global_id = $server_id . $i;
if($aline->enddate=='0000-00-00'|| $aline->endtime=='00:00:00' || $aline->durationsec=='0')
{
$enddatetime=date("Y-m-d H:i:s",strtotime($aline->updated_at));
$enddate=explode(" ",$enddatetime)[0];
$endtime=explode(" ",$enddatetime)[1];
$durationsec=date("Y-m-d H:i:s",strtotime($endtime-$aline->starttime));
}
else
{
$enddate=$aline->enddate;
$endtime=$aline->endtime;
$durationsec=$aline->durationsec;
}
$rowdata = array('server'=>$server_id,'server_ip'=>$server_ip,'global_id'=>$global_id,'id'=>$aline->id,
'created_at'=>$aline->created_at,'updated_at'=>$aline->updated_at,'user_id'=>$aline->user_id,'user'=>$users[$aline->user_id],
'startdate'=>$aline->startdate,'starttime'=>$aline->starttime,'enddate'=>$enddate,'endtime'=>$endtime,
'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'=>''
);
$data=json_decode($aline->data,true);
foreach($data as $sipid=>$sdata)
{
$prets= isset($sdata[1]) ? $sdata[1] : (strtotime($aline->startdate . " " . $aline->starttime)+19600)*1000;
if(isset($sdata['states']))
{
$previous="login";
foreach($sdata['states'] as $fts=>$states)
{
if($states[0] != 1)
{
$rowdata[$previous] +=round(($fts-$prets)/1000,2);
$previous = (trim($states[1]) != '') ? strtolower($states[0]."-".$states[1]) : strtolower($states[0]);
$prets=$fts;
}
}
$rowdata[$previous] += round(($sdata['ts']-$prets)/1000,2);
}
}
$rowdata["login"] = $aline->durationsec;
$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'];
$key_value = '';
foreach($rowdata AS $key=>$value) {
if($key != 1)
$key_value .= "`$key` = '$value', ";
}
$startTime=$aline->startdate." ".$aline->starttime;
$endTime=$aline->enddate." ".$aline->endtime;
$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."'"));
$ts_Wait=0;$ts_Call=0;$ts_Talk=0;$ts_Dispo=0;
$progTs_Wait=0;$progTs_Call=0;$progTs_Talk=0;$progTs_Dispo=0;
$manTs_Wait=0;$manTs_Call=0;$manTs_Talk=0;$manTs_Dispo=0;
$inbTs_Wait=0;$inbTs_Call=0;$inbTs_Talk=0;$inbTs_Dispo=0;
$tt_prog=0;$tt_man=0;$tt_inb=0;
if($crmCalls!=null){
foreach($crmCalls as $crmCall){
$ts_Wait += round(($crmCall->ts_Call - $crmCall->ts_Wait)/1000,2);
$ts_Call += round(($crmCall->ts_Talk - $crmCall->ts_Call)/1000,2);
$ts_Talk += round(($crmCall->ts_Dispo - $crmCall->ts_Talk)/1000,2);
$ts_Dispo += round(($crmCall->ts_Close - $crmCall->ts_Dispo)/1000,2);
if($crmCall->type == 'Progressive')
{
$progTs_Wait += round(($crmCall->ts_Call - $crmCall->ts_Wait)/1000,2);
$progTs_Call += round(($crmCall->ts_Talk - $crmCall->ts_Call)/1000,2);
$progTs_Talk += round(($crmCall->ts_Dispo - $crmCall->ts_Talk)/1000,2);
$progTs_Dispo += round(($crmCall->ts_Close - $crmCall->ts_Dispo)/1000,2);
}
if($crmCall->type == 'Manual')
{
$manTs_Wait += round(($crmCall->ts_Call - $crmCall->ts_Wait)/1000,2);
$manTs_Call += round(($crmCall->ts_Talk - $crmCall->ts_Call)/1000,2);
$manTs_Talk += round(($crmCall->ts_Dispo - $crmCall->ts_Talk)/1000,2);
$manTs_Dispo += round(($crmCall->ts_Close - $crmCall->ts_Dispo)/1000,2);
}
if($crmCall->type == 'Inbound')
{
$inbTs_Wait += round(($crmCall->ts_Call - $crmCall->ts_Wait)/1000,2);
$inbTs_Call += round(($crmCall->ts_Talk - $crmCall->ts_Call)/1000,2);
$inbTs_Talk += round(($crmCall->ts_Dispo - $crmCall->ts_Talk)/1000,2);
$inbTs_Dispo += round(($crmCall->ts_Close - $crmCall->ts_Dispo)/1000,2);
}
}
}
$tt_prog = $progTs_Wait + $progTs_Call + $progTs_Talk + $progTs_Dispo;
$tt_man = $manTs_Wait + $manTs_Call + $manTs_Talk + $manTs_Dispo;
$tt_inb = $inbTs_Wait + $inbTs_Call + $inbTs_Talk + $inbTs_Dispo;
$prod_TOS = $ts_Wait + $ts_Call + $ts_Talk + $ts_Dispo;
$key_value .= "`tt_prog` = '$tt_prog', ";
$key_value .= "`tt_man` = '$tt_man', ";
$key_value .= "`tt_inb` = '$tt_inb', ";
$key_value .= "`ts_Wait` = '$ts_Wait', ";
$key_value .= "`ts_Call` = '$ts_Call', ";
$key_value .= "`ts_Talk` = '$ts_Talk', ";
$key_value .= "`ts_Dispo` = '$ts_Dispo', ";
$key_value .= "`progts_Wait` = '$progTs_Wait', ";
$key_value .= "`progts_Call` = '$progTs_Call', ";
$key_value .= "`progts_Talk` = '$progTs_Talk', ";
$key_value .= "`progts_Dispo` = '$progTs_Dispo', ";
$key_value .= "`mants_Wait` = '$manTs_Wait', ";
$key_value .= "`mants_Call` = '$manTs_Call', ";
$key_value .= "`mants_Talk` = '$manTs_Talk', ";
$key_value .= "`mants_Dispo` = '$manTs_Dispo', ";
$key_value .= "`incts_Wait` = '$inbTs_Wait', ";
$key_value .= "`incts_Call` = '$inbTs_Call', ";
$key_value .= "`incts_Talk` = '$inbTs_Talk', ";
$key_value .= "`incts_Dispo` = '$inbTs_Dispo', ";
$key_value .= "`prod_tos` = '$prod_TOS', ";
$key_value = substr($key_value, 0, -2);
$userlogsTable = "userlogs_".date("d_m_Y",$logdate);
DB::connection("conn")->insert(DB::raw("INSERT INTO ".$userlogsTable." SET $key_value"));
}
}
}
}
}
<?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 Userlog_data extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'Userlog_data';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Userlog_data';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$nowts=time();
echo "\n".date('Y-m-d')."\n";
$logdate=strtotime('-1 day');
$tcol=0;$fieldsarr=array();$extrahdrarr=array();
$server_ip='10.3.179.121';
$server_id='08';
$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);
$i=0;
$ulist=DB::select(DB::raw("select * from users WHERE 1"));
foreach($ulist as $uline) {
$users[$uline->id] = $uline->username;
}
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)."'"))){
foreach($alist as $aline) {
$i++;
$global_id = $server_id . $i;
$rowdata = array('server'=>$server_id,'server_ip'=>$server_ip,'global_id'=>$global_id,'id'=>$aline->id,
'created_at'=>$aline->created_at,'updated_at'=>$aline->updated_at,'user_id'=>$aline->user_id,'user'=>$users[$aline->user_id],
'startdate'=>$aline->startdate,'starttime'=>$aline->starttime,'enddate'=>$aline->enddate,'endtime'=>$aline->endtime,
'durationsec'=>$aline->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'=>''
);
$data=json_decode($aline->data,true);
foreach($data as $sipid=>$sdata)
{
$prets= isset($sdata[1]) ? $sdata[1] : (strtotime($aline->startdate . " " . $aline->starttime)+19600)*1000;
if(isset($sdata['states']))
{
$previous="login";
foreach($sdata['states'] as $fts=>$states)
{
if($states[0] != 1)
{
$rowdata[$previous] +=round(($fts-$prets)/1000,2);
$previous = (trim($states[1]) != '') ? strtolower($states[0]."-".$states[1]) : strtolower($states[0]);
$prets=$fts;
}
}
$rowdata[$previous] += round(($sdata['ts']-$prets)/1000,2);
}
}
$rowdata["login"] = $aline->durationsec;
$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'];
$key_value = '';
foreach($rowdata AS $key=>$value) {
if($key != 1)
$key_value .= "`$key` = '$value', ";
}
$startTime=$aline->startdate." ".$aline->starttime;
$endTime=$aline->enddate." ".$aline->endtime;
$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."'"));
$ts_Wait=0;$ts_Call=0;$ts_Talk=0;$ts_Dispo=0;
$progTs_Wait=0;$progTs_Call=0;$progTs_Talk=0;$progTs_Dispo=0;
$manTs_Wait=0;$manTs_Call=0;$manTs_Talk=0;$manTs_Dispo=0;
$inbTs_Wait=0;$inbTs_Call=0;$inbTs_Talk=0;$inbTs_Dispo=0;
$tt_prog=0;$tt_man=0;$tt_inb=0;
if($crmCalls!=null){
foreach($crmCalls as $crmCall){
$ts_Wait += round(($crmCall->ts_Call - $crmCall->ts_Wait)/1000,2);
$ts_Call += round(($crmCall->ts_Talk - $crmCall->ts_Call)/1000,2);
$ts_Talk += round(($crmCall->ts_Dispo - $crmCall->ts_Talk)/1000,2);
$ts_Dispo += round(($crmCall->ts_Close - $crmCall->ts_Dispo)/1000,2);
if($crmCall->type == 'Progressive')
{
$progTs_Wait += round(($crmCall->ts_Call - $crmCall->ts_Wait)/1000,2);
$progTs_Call += round(($crmCall->ts_Talk - $crmCall->ts_Call)/1000,2);
$progTs_Talk += round(($crmCall->ts_Dispo - $crmCall->ts_Talk)/1000,2);
$progTs_Dispo += round(($crmCall->ts_Close - $crmCall->ts_Dispo)/1000,2);
}
if($crmCall->type == 'Manual')
{
$manTs_Wait += round(($crmCall->ts_Call - $crmCall->ts_Wait)/1000,2);
$manTs_Call += round(($crmCall->ts_Talk - $crmCall->ts_Call)/1000,2);
$manTs_Talk += round(($crmCall->ts_Dispo - $crmCall->ts_Talk)/1000,2);
$manTs_Dispo += round(($crmCall->ts_Close - $crmCall->ts_Dispo)/1000,2);
}
if($crmCall->type == 'Inbound')
{
$inbTs_Wait += round(($crmCall->ts_Call - $crmCall->ts_Wait)/1000,2);
$inbTs_Call += round(($crmCall->ts_Talk - $crmCall->ts_Call)/1000,2);
$inbTs_Talk += round(($crmCall->ts_Dispo - $crmCall->ts_Talk)/1000,2);
$inbTs_Dispo += round(($crmCall->ts_Close - $crmCall->ts_Dispo)/1000,2);
}
}
}
$tt_prog = $progTs_Wait + $progTs_Call + $progTs_Talk + $progTs_Dispo;
$tt_man = $manTs_Wait + $manTs_Call + $manTs_Talk + $manTs_Dispo;
$tt_inb = $inbTs_Wait + $inbTs_Call + $inbTs_Talk + $inbTs_Dispo;
$prod_TOS = $ts_Wait + $ts_Call + $ts_Talk + $ts_Dispo;
$key_value .= "`tt_prog` = '$tt_prog', ";
$key_value .= "`tt_man` = '$tt_man', ";
$key_value .= "`tt_inb` = '$tt_inb', ";
$key_value .= "`ts_Wait` = '$ts_Wait', ";
$key_value .= "`ts_Call` = '$ts_Call', ";
$key_value .= "`ts_Talk` = '$ts_Talk', ";
$key_value .= "`ts_Dispo` = '$ts_Dispo', ";
$key_value .= "`progts_Wait` = '$progTs_Wait', ";
$key_value .= "`progts_Call` = '$progTs_Call', ";
$key_value .= "`progts_Talk` = '$progTs_Talk', ";
$key_value .= "`progts_Dispo` = '$progTs_Dispo', ";
$key_value .= "`mants_Wait` = '$manTs_Wait', ";
$key_value .= "`mants_Call` = '$manTs_Call', ";
$key_value .= "`mants_Talk` = '$manTs_Talk', ";
$key_value .= "`mants_Dispo` = '$manTs_Dispo', ";
$key_value .= "`incts_Wait` = '$inbTs_Wait', ";
$key_value .= "`incts_Call` = '$inbTs_Call', ";
$key_value .= "`incts_Talk` = '$inbTs_Talk', ";
$key_value .= "`incts_Dispo` = '$inbTs_Dispo', ";
$key_value .= "`prod_tos` = '$prod_TOS', ";
$key_value = substr($key_value, 0, -2);
$userlogsTable = "userlogs_".date("d_m_Y",$logdate);
DB::connection("conn")->insert(DB::raw("INSERT INTO ".$userlogsTable." SET $key_value"));
}
}
}
}
<?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 App\Models\Notification;
use App\Jobs\KHRMSLib;
use Input;
use Illuminate\Database\Schema\Blueprint;
class bulkServerUpload extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'bulkServerUpload';
/**
* The console command description.
*
* @var string
*/
protected $description = 'bulkServerUpload';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
//echo "\n".date('Y-m-d')."\n";
echo "1";
echo "\n".date('Y-m-d H:i:s')."\n";
$server_ip=env('app_ip');
$central_ip=env('central_ip');
$wakka = new KHRMSLib();
$kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
$kformlib->gthis=$wakka;
$themehome=$wakka->GetThemePath('/');
$updatetime=time();
$clientlst=$wakka->GetBBBUserData("clientslist");
$isadmin=$wakka->IsAdmin();
$username=$wakka->GetUserName();
$triggers=Input::get("triggers");
$tmpstr=explode(",",$kformlib->HRFiledsStr);
$success="";$message="";$successcnt=0;$duplicatecount=0;
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'yb9738z'),
'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 location from server_details where server_ip='$server_ip'"));
$location=$serverclist[0]->location;
echo $central_ip;
echo $location;
$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"));
$conn='';
$tcol=0;$fieldsarr=array();$extrahdrarr=array();
foreach($excelarray as $key => $array){
$excelarray[$key] = (array)$array;
}
$highestColumn = DB::connection("conn")->select(DB::raw("select count(*) as cnt from information_schema.columns where table_name='bz_record_upload_uat'"));
$highestColumn = $highestColumn[0]->cnt;
$highestrow = count($excelarray);
$flag = 0;
$editflag=0;
for($i=0;$i<$highestrow;$i++)
{
if($excelarray[$i]["id"]!="")
{
if($excelarray[$i]["id"]=="CREATE")
{
$excelarray[$i]["id"]=$wakka->Query("insert into","","records",array('created'=>date('Y-m-d H:i:s')));
}
else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
if($wakka->getCount("records","id='".$excelarray[$i]["id"]."'")==1)
{
$empdata=$wakka->getPerson($excelarray[$i]["id"]);
$ppldata=$empdata["peopledata"];
$createdlog=$empdata['modifylog'];
$fdirty=$empdata['dirty'];
$createdlog[$updatetime]=$username."::";
$createdlog["updated"]=$updatetime;
$newdata=$ppldata;
foreach($excelarray[$i] as $key => $value)
{
if($value!="")
{
if("A".$ppldata[$key]!="A".$value)//forcing string comparrision //MAGIC
{
$value=str_replace("'"," ",$value);
if(strstr($createdlog[$updatetime],$key)==FALSE)$createdlog[$updatetime].="$key|".str_replace(array("|",",")," ",$ppldata[$key])."|".str_replace(array("|",",")," ",$value).",";
$fdirty[$key]=1;
$newdata[$key]=$value;
}
}
}
/*Start - Changes need to be done*/
if($excelarray[$i]["status"]==null)
{
$empdata['status'] = "rom";
}
if($excelarray[$i]["dialer_status"]==null)
{
$empdata['dialer_status'] = "rom";
}
if($excelarray[$i]["dialer_substatus"]==null)
{
$empdata['dialer_substatus'] = "rom";
}
/*End - Changes need to be done*/
$empdata["peopledata"]=$newdata;
$empdata['modifylog']=$createdlog;
$empdata['dirty']=$fdirty;
$wakka->setPerson($excelarray[$i]["id"],$empdata);
$excelarray[$i]['modified']=date('Y-m-d H:i:s');
$successArr[] = $excelarray[$i];
}
else
{
$reason = "";
$reason .= "Record ID is not on local server,";
$excelarray[$i]['server_ip'] =$server_ip;
$excelarray[$i]['location'] =$location;
if($excelarray[$i]["clientcode"]!="")
$excelarray[$i]['cust_id'] =$excelarray[$i]["clientcode"];
$excelarray[$i]['record_id'] = $excelarray[$i]["id"];
$excelarray[$i]['Reason'] = $reason;
$failureArr[] = $excelarray[$i];
}
}
else
{
$reason = "";
if($excelarray[$i]["id"]=="")
$reason .= "Column ID is blank,";
$excelarray[$i]['server_ip'] =$server_ip;
$excelarray[$i]['location'] =$location;
if($excelarray[$i]["clientcode"]!="")
$excelarray[$i]['cust_id'] =$excelarray[$i]["clientcode"];
$excelarray[$i]['Reason'] = $reason;
$failureArr[] = $excelarray[$i];
}
}
if(!empty($successArr)){
foreach($successArr as $succes)
{
$setSuccess=array();
$setSuccess[] = "server_ip='$server_ip'";
$setSuccess[] = "location='$location'";
$setSuccess[] = "record_id='".$succes['id']."'";
$setSuccess[] = "cust_id='".$succes['clientcode']."'";
$setSuccess[] = "modified='".$succes['modified']."'";
$setSuccess = implode(",",$setSuccess);
DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_success set $setSuccess"));
}
}
if(!empty($failureArr)){
foreach($failureArr as $failur)
{
$setFailure=array();
$setFailure[] = "server_ip='$server_ip'";
$setFailure[] = "location='$location'";
$setFailure[] = "cust_id='".$failur['clientcode']."'";
$setFailure[] = "record_id='".$failur['record_id']."'";
$setFailure[] = "reason='".$failur['Reason']."'";
$setFailure = implode(",",$setFailure);
DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_failure set $setFailure"));
}
}
DB::connection("conn")->disconnect();
}
}
<?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 App\Models\Notification;
use App\Jobs\KHRMSLib;
use Input;
use Illuminate\Database\Schema\Blueprint;
class bulkServerUpload_1 extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'bulkServerUpload_1';
/**
* The console command description.
*
* @var string
*/
protected $description = 'bulkServerUpload_1';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
//echo "\n".date('Y-m-d')."\n";
echo "2";
echo "\n".date('Y-m-d H:i:s')."\n";
$server_ip=env('app_ip');
$central_ip=env('central_ip');
$wakka = new KHRMSLib();
$kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
$kformlib->gthis=$wakka;
$themehome=$wakka->GetThemePath('/');
$updatetime=time();
$clientlst=$wakka->GetBBBUserData("clientslist");
$isadmin=$wakka->IsAdmin();
$username=$wakka->GetUserName();
$triggers=Input::get("triggers");
$tmpstr=explode(",",$kformlib->HRFiledsStr);
$success="";$message="";$successcnt=0;$duplicatecount=0;
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'yb9738z'),
'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 location from server_details where server_ip='$server_ip'"));
$location=$serverclist[0]->location;
$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"));
$conn='';
$tcol=0;$fieldsarr=array();$extrahdrarr=array();
foreach($excelarray as $key => $array){
$excelarray[$key] = (array)$array;
}
$highestColumn = DB::connection("conn")->select(DB::raw("select count(*) as cnt from information_schema.columns where table_name='bz_record_upload_uat'"));
$highestColumn = $highestColumn[0]->cnt;
$highestrow = count($excelarray);
$flag = 0;
$editflag=0;
for($i=0;$i<$highestrow;$i++)
{
if($excelarray[$i]["id"]!="")
{
if($excelarray[$i]["id"]=="CREATE")
{
$excelarray[$i]["id"]=$wakka->Query("insert into","","records",array('created'=>date('Y-m-d H:i:s')));
}
else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
if($wakka->getCount("records","id='".$excelarray[$i]["id"]."'")==1)
{
$empdata=$wakka->getPerson($excelarray[$i]["id"]);
$ppldata=$empdata["peopledata"];
$createdlog=$empdata['modifylog'];
$fdirty=$empdata['dirty'];
$createdlog[$updatetime]=$username."::";
$createdlog["updated"]=$updatetime;
$newdata=$ppldata;
foreach($excelarray[$i] as $key => $value)
{
if($value!="")
{
if("A".$ppldata[$key]!="A".$value)//forcing string comparrision //MAGIC
{
$value=str_replace("'"," ",$value);
if(strstr($createdlog[$updatetime],$key)==FALSE)$createdlog[$updatetime].="$key|".str_replace(array("|",",")," ",$ppldata[$key])."|".str_replace(array("|",",")," ",$value).",";
$fdirty[$key]=1;
$newdata[$key]=$value;
}
}
}
/*Start - Changes need to be done*/
if($excelarray[$i]["status"]==null)
{
$empdata['status'] = "rom";
}
if($excelarray[$i]["dialer_status"]==null)
{
$empdata['dialer_status'] = "rom";
}
if($excelarray[$i]["dialer_substatus"]==null)
{
$empdata['dialer_substatus'] = "rom";
}
/*End - Changes need to be done*/
$empdata["peopledata"]=$newdata;
$empdata['modifylog']=$createdlog;
$empdata['dirty']=$fdirty;
$wakka->setPerson($excelarray[$i]["id"],$empdata);
$excelarray[$i]['modified']=date('Y-m-d H:i:s');
$successArr[] = $excelarray[$i];
}
else
{
$reason = "";
$reason .= "Record ID is not on local server,";
$excelarray[$i]['server_ip'] =$server_ip;
$excelarray[$i]['location'] =$location;
if($excelarray[$i]["clientcode"]!="")
$excelarray[$i]['cust_id'] =$excelarray[$i]["clientcode"];
$excelarray[$i]['record_id'] = $excelarray[$i]["id"];
$excelarray[$i]['Reason'] = $reason;
$failureArr[] = $excelarray[$i];
}
}
else
{
$reason = "";
if($excelarray[$i]["id"]=="")
$reason .= "Column ID is blank,";
$excelarray[$i]['server_ip'] =$server_ip;
$excelarray[$i]['location'] =$location;
if($excelarray[$i]["clientcode"]!="")
$excelarray[$i]['cust_id'] =$excelarray[$i]["clientcode"];
$excelarray[$i]['Reason'] = $reason;
$failureArr[] = $excelarray[$i];
}
}
if(!empty($successArr)){
foreach($successArr as $succes)
{
$setSuccess=array();
$setSuccess[] = "server_ip='$server_ip'";
$setSuccess[] = "location='$location'";
$setSuccess[] = "record_id='".$succes['id']."'";
$setSuccess[] = "cust_id='".$succes['clientcode']."'";
$setSuccess[] = "modified='".$succes['modified']."'";
$setSuccess = implode(",",$setSuccess);
DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_success set $setSuccess"));
}
}
if(!empty($failureArr)){
foreach($failureArr as $failur)
{
$setFailure=array();
$setFailure[] = "server_ip='$server_ip'";
$setFailure[] = "location='$location'";
$setFailure[] = "cust_id='".$failur['clientcode']."'";
$setFailure[] = "record_id='".$failur['record_id']."'";
$setFailure[] = "reason='".$failur['Reason']."'";
$setFailure = implode(",",$setFailure);
DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_failure set $setFailure"));
}
}
DB::connection("conn")->disconnect();
}
}
<?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 App\Models\Notification;
use App\Jobs\KHRMSLib;
use Input;
use Illuminate\Database\Schema\Blueprint;
class bulkServerUpload_2 extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'bulkServerUpload_2';
/**
* The console command description.
*
* @var string
*/
protected $description = 'bulkServerUpload_2';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
//echo "\n".date('Y-m-d')."\n";
echo "3";
echo "\n".date('Y-m-d H:i:s')."\n";
$server_ip=env('app_ip');
$central_ip=env('central_ip');
$wakka = new KHRMSLib();
$kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
$kformlib->gthis=$wakka;
$themehome=$wakka->GetThemePath('/');
$updatetime=time();
$clientlst=$wakka->GetBBBUserData("clientslist");
$isadmin=$wakka->IsAdmin();
$username=$wakka->GetUserName();
$triggers=Input::get("triggers");
$tmpstr=explode(",",$kformlib->HRFiledsStr);
$success="";$message="";$successcnt=0;$duplicatecount=0;
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'yb9738z'),
'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 location from server_details where server_ip='$server_ip'"));
$location=$serverclist[0]->location;
$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"));
$conn='';
$tcol=0;$fieldsarr=array();$extrahdrarr=array();
foreach($excelarray as $key => $array){
$excelarray[$key] = (array)$array;
}
$highestColumn = DB::connection("conn")->select(DB::raw("select count(*) as cnt from information_schema.columns where table_name='bz_record_upload_uat'"));
$highestColumn = $highestColumn[0]->cnt;
$highestrow = count($excelarray);
$flag = 0;
$editflag=0;
for($i=0;$i<$highestrow;$i++)
{
if($excelarray[$i]["id"]!="")
{
if($excelarray[$i]["id"]=="CREATE")
{
$excelarray[$i]["id"]=$wakka->Query("insert into","","records",array('created'=>date('Y-m-d H:i:s')));
}
else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
if($wakka->getCount("records","id='".$excelarray[$i]["id"]."'")==1)
{
$empdata=$wakka->getPerson($excelarray[$i]["id"]);
$ppldata=$empdata["peopledata"];
$createdlog=$empdata['modifylog'];
$fdirty=$empdata['dirty'];
$createdlog[$updatetime]=$username."::";
$createdlog["updated"]=$updatetime;
$newdata=$ppldata;
foreach($excelarray[$i] as $key => $value)
{
if($value!="")
{
if("A".$ppldata[$key]!="A".$value)//forcing string comparrision //MAGIC
{
$value=str_replace("'"," ",$value);
if(strstr($createdlog[$updatetime],$key)==FALSE)$createdlog[$updatetime].="$key|".str_replace(array("|",",")," ",$ppldata[$key])."|".str_replace(array("|",",")," ",$value).",";
$fdirty[$key]=1;
$newdata[$key]=$value;
}
}
}
/*Start - Changes need to be done*/
if($excelarray[$i]["status"]==null)
{
$empdata['status'] = "rom";
}
if($excelarray[$i]["dialer_status"]==null)
{
$empdata['dialer_status'] = "rom";
}
if($excelarray[$i]["dialer_substatus"]==null)
{
$empdata['dialer_substatus'] = "rom";
}
/*End - Changes need to be done*/
$empdata["peopledata"]=$newdata;
$empdata['modifylog']=$createdlog;
$empdata['dirty']=$fdirty;
$wakka->setPerson($excelarray[$i]["id"],$empdata);
$excelarray[$i]['modified']=date('Y-m-d H:i:s');
$successArr[] = $excelarray[$i];
}
else
{
$reason = "";
$reason .= "Record ID is not on local server,";
$excelarray[$i]['server_ip'] =$server_ip;
$excelarray[$i]['location'] =$location;
if($excelarray[$i]["clientcode"]!="")
$excelarray[$i]['cust_id'] =$excelarray[$i]["clientcode"];
$excelarray[$i]['record_id'] = $excelarray[$i]["id"];
$excelarray[$i]['Reason'] = $reason;
$failureArr[] = $excelarray[$i];
}
}
else
{
$reason = "";
if($excelarray[$i]["id"]=="")
$reason .= "Column ID is blank,";
$excelarray[$i]['server_ip'] =$server_ip;
$excelarray[$i]['location'] =$location;
if($excelarray[$i]["clientcode"]!="")
$excelarray[$i]['cust_id'] =$excelarray[$i]["clientcode"];
$excelarray[$i]['Reason'] = $reason;
$failureArr[] = $excelarray[$i];
}
}
if(!empty($successArr)){
foreach($successArr as $succes)
{
$setSuccess=array();
$setSuccess[] = "server_ip='$server_ip'";
$setSuccess[] = "location='$location'";
$setSuccess[] = "record_id='".$succes['id']."'";
$setSuccess[] = "cust_id='".$succes['clientcode']."'";
$setSuccess[] = "modified='".$succes['modified']."'";
$setSuccess = implode(",",$setSuccess);
DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_success set $setSuccess"));
}
}
if(!empty($failureArr)){
foreach($failureArr as $failur)
{
$setFailure=array();
$setFailure[] = "server_ip='$server_ip'";
$setFailure[] = "location='$location'";
$setFailure[] = "cust_id='".$failur['clientcode']."'";
$setFailure[] = "record_id='".$failur['record_id']."'";
$setFailure[] = "reason='".$failur['Reason']."'";
$setFailure = implode(",",$setFailure);
DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_failure set $setFailure"));
}
}
DB::connection("conn")->disconnect();
}
}
No preview for this file type
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.
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!