13d4c618 by Manish Mihsra

Updated Latest changes

1 parent ca191993
Showing 144 changed files with 7902 additions and 3988 deletions
......@@ -2,3 +2,4 @@ application/storage/reason
custom/.env
application/storage/framework
custom/db/
application/vendor
......
Version No. 1.19v
Changes:made changes by Jadhav in getPersonshome function,KHRMSLib.php
Date: 12/09/2018
Version No. 1.18v
Changes: Missed calls to changed will reflect after 11th sept.,Changes DialerController.php and dialer.blade.php
Date: 10/09/2018
Version No. 1.17v
Changes: DAP implementation, Changes KFormLib has been Changed,
Date: 10/09/2018
Version No. 1.16v
Changes: missed call bucket in order Changes KHRMSLib.php added one function for asc
Date: 10/09/2018
Version No. 1.15v
Changes: progressive new logic like COP, Changes dialerController.php
Date: 08/09/2018
Version No. 1.14v
Changes: agent time report updated, commented if condition.
Date: 03/09/2018
Version No. 1.13v
Changes: hangup beep, footer.blade.php, dialer.js changed and hangup beep added to assets/sounds/
Date: 11/08/2018 Only on Mumbai servers
Version No. 1.12v
Changes: followup for new disposition, DialerController.php and dialer.js is changed.
Date: 11/08/2018
Version No. 1.11v
Changes: Master report download, Changes main.blade.php, Added two libraries lib, php, KHRMS.php, XLSX library.
Date: 08/08/2018
Version No. 1.10v
Changes: Username for inbounddrop and Userbusy for SIP/GATEWAY , Changes KPAMIListen.php
Date: 02/08/2018
Version No. 1.9v
Changes: Call log report supervisor, and Date range in call report.
Date: 30/07/2018
Version No. 1.8v
Changes: HDFC Mogo, Changes 1.extension.conf, 2.DialerController.php, 3.mogo tune in moh location.
Date 20/07/2018
Version No. 1.7V
Changes: Live report reload button issue, commented one line of code in Livereport.blade.php
Date: 19/07/2018
Versio No. 1.6V
Changes: call forward, KPAMIListen, .env and extension.conf file updated
Date: 14/07/2018
Version No. 1.5V
Changes: Birthday calls for progressive mode, DialerController.php is updated
Date: 13/07/2018
Version No. 1.4V
Changes: To Blank diallines, DailyLogout.php is updated.
Date: 6/07/2018
Version No. 1.3v
Changes: Bulkupload
Date: 5/07/2018
Version NO. 1.2v
Changes: To remove multiple circles in dialer, dialer.js is updated.
Date: 4/07/2018
Version No. 1.1v
Changes: To remove Inbound Portfolio issue, KPAMIListen updated.
Date: 18/06/2018
Version No. 1.14v
Changes: agent time report updated, commented if condition.
Date: 03/09/2018
Version No. 1.13v
Changes: hangup beep, footer.blade.php, dialer.js changed and hangup beep added to assets/sounds/
Date: 11/08/2018 Only on Mumbai servers
Version No. 1.12v
Changes: followup for new disposition, DialerController.php and dialer.js is changed.
Date: 11/08/2018
Version No. 1.11v
Changes: Master report download, Changes main.blade.php, Added two libraries lib, php, KHRMS.php, XLSX library.
Date: 08/08/2018
Version No. 1.10v
Changes: Username for inbounddrop and Userbusy for SIP/GATEWAY , Changes KPAMIListen.php
Date: 02/08/2018
Version No. 1.9v
Changes: Call log report supervisor, and Date range in call report.
Date: 30/07/2018
Version No. 1.8v
Changes: HDFC Mogo, Changes 1.extension.conf, 2.DialerController.php, 3.mogo tune in moh location.
Date 20/07/2018
Version No. 1.7V
Changes: Live report reload button issue, commented one line of code in Livereport.blade.php
Date: 19/07/2018
Versio No. 1.6V
Changes: call forward, KPAMIListen, .env and extension.conf file updated
Date: 14/07/2018
Version No. 1.5V
Changes: Birthday calls for progressive mode, DialerController.php is updated
Date: 13/07/2018
Version No. 1.4V
Changes: To Blank diallines, DailyLogout.php is updated.
Date: 6/07/2018
Version No. 1.3v
Changes: Bulkupload
Date: 5/07/2018
Version NO. 1.2v
Changes: To remove multiple circles in dialer, dialer.js is updated.
Date: 4/07/2018
Version No. 1.1v
Changes: To remove Inbound Portfolio issue, KPAMIListen updated.
Date: 18/06/2018
Version No. 1.20v
Changes:Dialer Controller for Diallines blocked, KPAMIListen for Log comment, show.blade.php casesensitivity campaign error: No Access
Date: 02/11/2018
Version No. 1.19v
Changes:made changes by Jadhav in getPersonshome function,KHRMSLib.php
Date: 12/09/2018
Version No. 1.18v
Changes: Missed calls to changed will reflect after 11th sept.,Changes DialerController.php and dialer.blade.php
Date: 10/09/2018
Version No. 1.17v
Changes: DAP implementation, Changes KFormLib has been Changed,
Date: 10/09/2018
Version No. 1.16v
Changes: missed call bucket in order Changes KHRMSLib.php added one function for asc
Date: 10/09/2018
Version No. 1.15v
Changes: progressive new logic like COP, Changes dialerController.php
Date: 08/09/2018
Version No. 1.14v
Changes: agent time report updated, commented if condition.
Date: 03/09/2018
Version No. 1.13v
Changes: hangup beep, footer.blade.php, dialer.js changed and hangup beep added to assets/sounds/
Date: 11/08/2018 Only on Mumbai servers
Version No. 1.12v
Changes: followup for new disposition, DialerController.php and dialer.js is changed.
Date: 11/08/2018
Version No. 1.11v
Changes: Master report download, Changes main.blade.php, Added two libraries lib, php, KHRMS.php, XLSX library.
Date: 08/08/2018
Version No. 1.10v
Changes: Username for inbounddrop and Userbusy for SIP/GATEWAY , Changes KPAMIListen.php
Date: 02/08/2018
Version No. 1.9v
Changes: Call log report supervisor, and Date range in call report.
Date: 30/07/2018
Version No. 1.8v
Changes: HDFC Mogo, Changes 1.extension.conf, 2.DialerController.php, 3.mogo tune in moh location.
Date 20/07/2018
Version No. 1.7V
Changes: Live report reload button issue, commented one line of code in Livereport.blade.php
Date: 19/07/2018
Versio No. 1.6V
Changes: call forward, KPAMIListen, .env and extension.conf file updated
Date: 14/07/2018
Version No. 1.5V
Changes: Birthday calls for progressive mode, DialerController.php is updated
Date: 13/07/2018
Version No. 1.4V
Changes: To Blank diallines, DailyLogout.php is updated.
Date: 6/07/2018
Version No. 1.3v
Changes: Bulkupload
Date: 5/07/2018
Version NO. 1.2v
Changes: To remove multiple circles in dialer, dialer.js is updated.
Date: 4/07/2018
Version No. 1.1v
Changes: To remove Inbound Portfolio issue, KPAMIListen updated.
Date: 18/06/2018
The difference between this server and other servers is KPAMIListen.php Please make sure updating this file.
Version No.1.21v
Changes: DialerController for the after New calls based on Subdispo Not contacted call will come in the queue.
Date: 12/11/2018
Version No. 1.20v
Changes:Dialer Controller for Diallines blocked, KPAMIListen for Log comment, show.blade.php casesensitivity campaign error: No Access
Date: 02/11/2018
Version No. 1.19v
Changes:made changes by Jadhav in getPersonshome function,KHRMSLib.php
Date: 12/09/2018
Version No. 1.18v
Changes: Missed calls to changed will reflect after 11th sept.,Changes DialerController.php and dialer.blade.php
Date: 10/09/2018
Version No. 1.17v
Changes: DAP implementation, Changes KFormLib has been Changed,
Date: 10/09/2018
Version No. 1.16v
Changes: missed call bucket in order Changes KHRMSLib.php added one function for asc
Date: 10/09/2018
Version No. 1.15v
Changes: progressive new logic like COP, Changes dialerController.php
Date: 08/09/2018
Version No. 1.14v
Changes: agent time report updated, commented if condition.
......
<?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_data extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'bulkserverupload_data';
/**
* The console command description.
*
* @var string
*/
protected $description = 'bulkserverupload_data';
/**
* 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_150918 where SERVER_IP='$server_ip'"));
$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_150918'"));
$highestColumn = $highestColumn[0]->cnt;
$highestrow = count($excelarray);
$flag = 0;
$editflag=0;
for($i=0;$i<$highestrow;$i++)
{
if($excelarray[$i]["clientcode"]!="")
{
/*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]["clientcode"]=intval($excelarray[$i]["clientcode"]);
//$excelarray[$i]["client"]=$excelarray[$i]["rm_code"];
if($wakka->getCount("records","clientcode='".$excelarray[$i]["clientcode"]."'")==1)
{
//$empdata=$wakka->getPerson($excelarray[$i]["id"]);
$empdata=$wakka->getPersonServer($excelarray[$i]["clientcode"]);
$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);
$wakka->setPersonServer($excelarray[$i]["clientcode"],$empdata);
$excelarray[$i]['modified']=date('Y-m-d H:i:s');
$successArr[] = $excelarray[$i];
}
else
{
$excelarray[$i]["id"]=$wakka->Query("insert into","","records",array('created'=>date('Y-m-d H:i:s')));
$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);
$wakka->setPerson($excelarray[$i]["id"],$empdata);
$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 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 "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_09102018_1 where SERVER_IP='$server_ip'"));
$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_09102018_1'"));
$highestColumn = $highestColumn[0]->cnt;
$highestrow = count($excelarray);
$flag = 0;
$editflag=0;
for($i=0;$i<$highestrow;$i++)
{
if($excelarray[$i]["clientcode"]!="")
{
/*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]["clientcode"]=intval($excelarray[$i]["clientcode"]);
//$excelarray[$i]["client"]=$excelarray[$i]["rm_code"];
if($wakka->getCount("records","clientcode='".$excelarray[$i]["clientcode"]."'")==1)
{
//$empdata=$wakka->getPerson($excelarray[$i]["id"]);
$empdata=$wakka->getPersonServer($excelarray[$i]["clientcode"]);
$excelarray[$i]["other_information"]='2018-10-09_1';
$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);
$wakka->setPersonServer($excelarray[$i]["clientcode"],$empdata);
$excelarray[$i]['modified']=date('Y-m-d H:i:s');
$successArr[] = $excelarray[$i];
}
else
{
$excelarray[$i]["id"]=$wakka->Query("insert into","","records",array('created'=>date('Y-m-d H:i:s')));
$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);
$wakka->setPerson($excelarray[$i]["id"],$empdata);
$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];
}
}
echo "\n"."Updated data partial upload end"."\n";
/*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_09102018_1_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();
}
}
......@@ -50,9 +50,9 @@ class Calllogupdate extends Command {
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......
<?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 App\Http\Controllers\DialerController;
use Input;
use Log;
use App\Models\Sipid;
use App\Models\Kqueue;
use App\Models\Dialline;
use App\Models\Session;
use App\Models\Cutoff;
use Illuminate\Database\Schema\Blueprint;
class CreateCall extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'CreateCall';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create Pedictive Call If any User is Free';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
while(true)
{
usleep(2000000);
$this->runPredictive();
}
}
public function runPredictive()
{
try {
$this->updatePrepareColumn();
$usrArrs = $this->getActiveUsersCampaignWise("with");
$cntAndStrArr = $this->getActualAvailChannelCount();
$availChannel = $cntAndStrArr['cnt'];
$availDialStr = $cntAndStrArr['dialstr'];
if(count($usrArrs)){
//Log::useFiles(storage_path()."/logs/predictive_".date("Y_m_d").".log");
//Log::info($usrArrs);
//Log::useFiles(storage_path()."/logs/predictive_".date("Y_m_d").".log");
//Log::info("Channel=".$availChannel);
foreach ($usrArrs as $client => $usrArr) {
//Log::useFiles(storage_path()."/logs/predictive_".date("Y_m_d").".log");
//Log::info("campaign=".$client);
$acalls = $this->getCreateCallCount($client, count($usrArr));
$acalls = min($acalls, $availChannel);
//Log::useFiles(storage_path()."/logs/predictive_".date("Y_m_d").".log");
//Log::info("CallCount=".$acalls);
$this->CreateCall($client, $acalls, $availDialStr);
}
}
} catch (Exception $e) {
Log::useFiles(storage_path()."/logs/predictive_".date("Y_m_d").".log");
Log::error($e);
}
}
public function updatePrepareColumn()
{
$allClientUsrIdArr = array();
$updatedUserIdArr = array();
$currentTime = strtotime(date("Y-m-d H:i:s"));
$clientWiseUserIdArr = $this->getActiveUsersCampaignWise("without");
if(count($clientWiseUserIdArr)) {
//Log::useFiles(storage_path()."/logs/predictive_".date("Y_m_d").".log");
//Log::info("updatePrepareColumn");Log::info($clientWiseUserIdArr);
foreach ($clientWiseUserIdArr as $client => $usrIdArr) {
$allClientUsrIdArr = array_merge($allClientUsrIdArr, $usrIdArr);
}
$usersTimeArr = Cutoff::whereIn('user_id', $allClientUsrIdArr)->get();
foreach ($usersTimeArr as $userTimeArr) {
$cutOffTime = strtotime($userTimeArr->hangup_time) + ($userTimeArr->avg_dispo - $userTimeArr->avg_ring);
if($cutOffTime < $currentTime)
{
$updatedUserIdArr[] = $userTimeArr->user_id;
}
}
if(count($updatedUserIdArr)) {
//Log::useFiles(storage_path()."/logs/predictive_".date("Y_m_d").".log");
//Log::info("updatedUserIdArr");Log::info($updatedUserIdArr);
}
DB::table('sipids')->whereIn('user', $updatedUserIdArr)->update(['prepare_call'=>1]);
}
}
public function getActiveUsersCampaignWise($checkPrepareCol)
{
$campaignWiseUsrs = array();
$prepareUsrIds = array();
$loggedInSips = Sipid::where('server','=',env('app_ip'))->where("user", "!=", 0)->where("status","=","1");
if($checkPrepareCol=="with"){
$loggedInSips = $loggedInSips->where("prepare_call","=","1");
}
elseif($checkPrepareCol=="without"){
$loggedInSips = $loggedInSips->where("patched","=","0");
}
$loggedInSips = $loggedInSips->groupBy('user')->get();
if(count($loggedInSips)){
foreach ($loggedInSips as $loggedInSip) {
$prepareUsrIds[] = $loggedInSip->user;
}
//TODO: Change Dialmode Value in the column Of User Table (Ready to Predictive)
$usersLoggedIn = User::whereIn('id', $prepareUsrIds);
if($checkPrepareCol=="without")$usersLoggedIn = $usersLoggedIn->where('current_dialmode', '=', 'Predictive');
$usersLoggedIn = $usersLoggedIn->select('id','sel_campaign')->get();
foreach ($usersLoggedIn as $userLoggedIn) {
$campaignWiseUsrs[$userLoggedIn->sel_campaign][] = $userLoggedIn->id;
}
}
return $campaignWiseUsrs;
}
public function getActualAvailChannelCount()
{
$data = array();
$cnt = 0;
$allChanlCnt = $this->getSpanCount();
$dialstr = "";
$diallineVal = Dialline::where('server','=', env('app_ip'))->where("status","=","Free")->where("dialstr","!=","")->where("enabled","=","1")->select('dialstr')->first();
//TODO: When SIP and Dahdi both are active
if(count($diallineVal)){
if(stristr($diallineVal->dialstr,"Dahdi")){
$dialedCnt = $this->getActualDahdiDialedCallCount();
$cnt = $allChanlCnt - $dialedCnt;
}
elseif(stristr($diallineVal->dialstr,"GATEWAY")){
$dialedCnt = $this->getActualSipDialedCallCount();
$cnt = $allChanlCnt - $dialedCnt;
}
$dialstr = $diallineVal->dialstr;
}
$data['cnt'] = $cnt;
$data['dialstr'] = $dialstr;
return $data;
}
public function getActualSipDialedCallCount()
{
$allChnnlArr = array();
$dialstr = "Dial(SIP/GATEWAY/";
$chnlCnt = 0;
exec("/usr/sbin/asterisk -rx 'core show channels'",$allChnnls);
foreach($allChnnls as $allChnnl){
//$allChnnlArr[] = explode(" ", preg_replace('!\s+!', ' ', $allChnnl) );
if(stristr($allChnnl, $dialstr)){
$chnlCnt++;
}
}
return $chnlCnt;
}
public function getActualDahdiDialedCallCount()
{
$allChnnlArr = array();
$dialstr = "- ACTIVE";
$status = "RED";
$chnlCnt = 0;
//exec("/usr/sbin/asterisk -rx 'service dahdi status'",$allChnnls);
exec("service dahdi status",$allChnnls);
foreach($allChnnls as $allChnnl){
//$allChnnlArr[] = explode(" ", preg_replace('!\s+!', ' ', $allChnnl) );
if(stristr($allChnnl, $status)){
Break;
}
if(stristr($allChnnl, $dialstr)){
$chnlCnt++;
}
}
return $chnlCnt;
}
//TODO: Generate Client File To Take All Parameteres Of Campaigns
public function getCreateCallCount($client, $usrCnt)
{
$wakka = new KHRMSLib();
$mastersdata=$wakka->getCompanyMaster($client);
$ratio = $mastersdata["autodialercampaign"];
$dialedCallCnt = $this->getDialedCallCount($client);
return ($usrCnt*$ratio) - $dialedCallCnt;
}
public function getDialedCallCount($client)
{
$cnt = Dialline::whereIn("status", ["Auto","AutoCall"])->where("conf","=","")->where("regexstr","=",$client)->count();
return $cnt;
}
public function CreateCall($client, $acalls, $availDialStr)
{
if($acalls>0)
{
for($i=0;$i<$acalls;$i++)
{
$this->useChannelToDial($client, $availDialStr);
}
}
}
public function useChannelToDial($client, $availDialStr)
{
$dialline=Dialline::where('server','=', env('app_ip'))->where("status","=","Free")->where("enabled","=","1")->where("dialstr", "=", $availDialStr)->orderBy('updated_at','ASC')->first();
//TODO::Need To Code Dspan Logic as per discussion
//if($dspan!="")$dialline=$dialline->where('dspan','=',$dspan)->where('id','<=','30');
//$dialline=$dialline->orderBy('id','ASC')->first();
if(!empty($dialline))
{
$this->createCrmCall($client, $dialline);
}
return;
}
public function createCrmCall($client, $dialline)
{
//TODO: Need to check whether callerid is required or not (in case of GSM Gateway)
$callerid="";
$wakka = new KHRMSLib();
$gz = new DialerController();
$users= $gz->getCallSequencing(1,$client);
if(sizeof($users)>=1)
{
$record=$wakka->getPerson($users[0]['id'],$client);
if($record)
{
$record["peopledata"]["status"]="AutoCall";
$wakka->setPerson($users[0]['id'],$record,$client);
DB::table('records_'.$client)->where('id',$users[0]['id'])->update(['filter_condition'=>'2','modified'=>date("Y-m-d H:i:s")]);
}
$dialline->user_id=$user_id;
$dialline->status="AutoCall";
$dialline->regexstr=$users[0]['client'];
$dialline->number=$users[0]["mobile"];
$dialline->save();
$nowts=microtime(true)*1000;
//start the call log
$crmcall=new CRMCall();
$crmcall->number=$users[0]["mobile"];
$crmcall->user_id=0;
$crmcall->sipid_id=0;
$crmcall->crm_id=$users[0]['id'];
//$crmcall->lan=$users[0]['lan'];
$crmcall->client=$users[0]['client'];
$crmcall->department=$users[0]['department'];
$crmcall->state='New';
$crmcall->type="AutoCall";
$crmcall->dialline_id=$dialline->id;
$crmcall->setTs('ts_Wait',$nowts);
$crmcall->setTs('ts_Call',$nowts);
$crmcall->did=$callerid;
$tdata=array();
$crmcall->data=json_encode($tdata);
$crmcall->save();
//start actual calls
$newqueue=new Kqueue();
$newqueue->autoCallOut($users[0]["mobile"],$callerid,$crmcall,$dialline);
}
return;
}
public function getSpanCount()
{
$spanArr = array("span1" => 30, "span2" => 30, "span3" => 30, "span4" => 30);
$cnt = array_sum($spanArr);
return $cnt;
}
}
......@@ -45,14 +45,14 @@ class CreportEight extends Command {
$tcol=0;$fieldsarr=array();$extrahdrarr=array();
$central_ip=env('central_ip');
$server_ip=env('app_ip');
$server_ip=env('DB_HOST');
$calllog_report = "calllog_report_".$date;
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......
......@@ -53,9 +53,9 @@ class CreportNine extends Command {
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......
<?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 CreportTen extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'CreportTen';
/**
* The console command description.
*
* @var string
*/
protected $description = 'App Main Daily Task for CreportTen';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$nowts=time();
$date=date('F_Y');
echo "\n".date('Y-m-d H:i:s')."\n";
$logdate=strtotime('0 day');
$tcol=0;$fieldsarr=array();$extrahdrarr=array();
$central_ip=env('central_ip');
$server_ip=env('app_ip');
//$calllog_report = "calllog_report_".date("d_m_Y");
$calllog_report = "calllog_report_test";
$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;
echo "Maxid".$maxids;
//$alist=DB::select(DB::raw("SELECT * from crmcalls_archive where created_at>'2018-06-01' and created_at<'2018-07-01'"));
//$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))."'"));
$alist=DB::select(DB::raw("SELECT * from crmcalls where id>'$maxids' 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[]="created_at='$aline->created_at'";
$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'";
$setstrarr[]="attempt='$aline->attempt'";
$setstrarr[]="priority='$aline->priority'";
$setstrarr[]="question='$aline->question'";
$setstr=implode(",",$setstrarr);
DB::connection("conn")->insert(DB::raw("insert into ".$calllog_report." set $setstr"));
//DB::connection("conn")->update(DB::raw("UPDATE ".$calllog_report." as ca INNER JOIN crmcalls as c on ca.crmcall_id = c.id set ca.state = c.state,ca.statuscode = c.statuscode,ca.status = c.status,ca.substatus = c.substatus,ca.callSec = c.callSec,ca.ts_Talk = c.ts_Talk,ca.ts_Recstart = c.ts_Recstart,ca.ts_Recend = c.ts_Recend,ca.ts_Dispo = c.ts_Dispo,ca.ts_Close = c.ts_Close,ca.dispoSec = c.dispoSec,ca.recstartSec=c.recstartSec,ca.data = c.data,ca.recsize = c.recsize,ca.userstatus = c.userstatus,ca.usersubstatus = c.usersubstatus,ca.usercallback = c.usercallback ,ca.userremarks = c.userremarks,ca.attempt = c.attempt,ca.priority = c.priority,ca.question = c.question"));
}
echo "AfterUploadingData=".date('Y-m-d H:i:s');
}
}
......@@ -98,9 +98,9 @@ class KstychDaily extends Command {
$conn = array(
'driver' => 'mysql',
'host' => $server,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......
<?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 App\Models\Cutoff;
use Log;
use Illuminate\Database\Schema\Blueprint;
class PredictiveCallHangUp extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'PredictiveCallHangUp';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Hang Up Extra Calls If Agents Are Not Free';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
while(true)
{
usleep(1000000);
$this->runHangUp();
}
}
public function runHangUp()
{
try {
$breathingTime = 30;
$avgringsec = 30;
$avgringsec = Cutoff::select(DB::Raw('avg(avg_ring) as avgringsec'))->first();
if($avgringsec)$avgringsec= intval($avgringsec->avgringsec);
$diallines = Dialline::whereIn("status", ["Auto","AutoCall"])->where("conf","=","")->select('src_channel','status','updated_at','channel','server')->get();
foreach ($diallines as $dialline) {
$newqueue=new Kqueue();
$lastUpdatedTime = strtotime(date("Y-m-d H:i:s")) - strtotime($dialline->updated_at);
if ($dialline->status == 'Auto' && $lastUpdatedTime > $breathingTime) {
$newqueue->hangupChannelS($dialline->channel,$dialline->server);
}
elseif($dialline->status == 'AutoCall' && $lastUpdatedTime > ($avgringsec+$breathingTime)) {
$newqueue->hangupChannelS($dialline->src_channel,$dialline->server);
}
}
} catch (Exception $e) {
Log::useFiles(storage_path()."/logs/predictive_".date("Y_m_d").".log");
Log::error($e);
}
}
}
<?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 Smsreport extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'Smsreport';
/**
* The console command description.
*
* @var string
*/
protected $description = 'App Main Daily Task for Smsreport';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$nowts=time();
$date=date('F_Y');
echo "\n".date('Y-m-d H:i:s')."\n";
$logdate=strtotime('0 day');
$tcol=0;$fieldsarr=array();$extrahdrarr=array();
$central_ip=env('central_ip');
$server_ip=env('app_ip');
$calllog_report = "calllog_report_".$date;
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'options' => array(
PDO::ATTR_TIMEOUT => 5,
),
);
Config::set("database.connections.conn", $conn);
DB::connection("conn")->getDatabaseName();
$serverclist=DB::connection("conn")->select(DB::raw("select id from server_details where server_ip='$server_ip'"));
$server_id=str_pad($serverclist[0]->id, 2, '0', STR_PAD_LEFT);
$maxid=DB::connection("conn")->select(DB::raw("SELECT max(sms_id) as maxid from sms_report where server='$server_id'"));
$maxids=$maxid[0]->maxid;
$alist=DB::select(DB::raw("SELECT * from sms_log where id>'$maxids'"));
$iii=0;
$shortinsert="";
foreach($alist as $aline)
{
$iii++;
$server = $server_id;
$sms_id = $aline->id;
$created_at = $aline->created_at;
$message_time = date("Y-m-d H:i:s",strtotime($aline->created_at)+330*60);
$server_ip = $aline->server_ip;
$call_id = $aline->call_id;
$agent_name = $aline->agent_name;
$subdispo = $aline->subdispo;
$number = $aline->number;
$message = $aline->message;
$response = $aline->response;
$shortinsert.="('$server', '$sms_id','$created_at', '$message_time', '$server_ip', '$call_id', '$agent_name', '$subdispo', '$number', '$message', '$response'),";
if($iii%50==0 || $iii == count($alist)){
$shortinsert=substr($shortinsert,0,-1);
DB::connection("conn")->insert(DB::raw("INSERT INTO sms_report (`server`, `sms_id`, `created_at`, `message_time`, `server_ip`, `call_id`, `agent_name`, `subdispo`, `number`, `message`, `response`) VALUES $shortinsert"));
$shortinsert="";
}
}
echo "\n".date('Y-m-d H:i:s')."\n";
DB::connection("conn")->disconnect();
}
}
\ No newline at end of file
<?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 App\Models\Cutoff;
use Log;
use Illuminate\Database\Schema\Blueprint;
class UpdateAvgRingSec extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'UpdateAvgRingSec';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Update Avg Call Ring Sec Of Last 50 Calls';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$avgcallsecObj = CRMCall::select(DB::Raw('ROUND((avg(callsec))/1000) as avgcallsec'))->limit(50)->where("type","!=","Inbound")->first();
if(count($avgcallsecObj))
{
Cutoff::where('user_id', '!=', "")->update(
['avg_ring' => $avgcallsecObj->avgcallsec
]);
}
}
}
\ No newline at end of file
......@@ -40,16 +40,18 @@ class Userlog_data extends Command {
echo "\n".date('Y-m-d')."\n";
$logdate=strtotime('-1 day');
//$date=date('F_Y');
echo date("Y-m-d",$logdate);
$tcol=0;$fieldsarr=array();$extrahdrarr=array();
$server_ip=env('app_ip');
$server_ip=env('DB_HOST');
$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', ''),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......@@ -85,7 +87,11 @@ class Userlog_data extends Command {
$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));
//echo "endtime".$endtime;
//$durationsec=date("Y-m-d H:i:s",strtotime($endtime-$aline->starttime));
$durationsec=strtotime(date("Y-m-d H:i:s",strtotime($endtime)-strtotime($aline->starttime)));
//echo "durationsec".$durationsec;
if($aline->created_at==$aline->updated_at){ $durationsec=0; }
}
else
{
......@@ -93,11 +99,11 @@ class Userlog_data extends Command {
$endtime=$aline->endtime;
$durationsec=$aline->durationsec;
}
//echo $endtime."^".$enddate."^".$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'=>''
'durationsec'=>$durationsec,'group'=>$aline->group,'login'=>'','dialnext'=>'','manual'=>'','paused'=>'','paused-agentbriefing'=>'','paused-downtime'=>'','paused-floorannouncements'=>'','paused-incoming'=>'','paused-lunchbreak'=>'','paused-manual'=>'','paused-notready'=>'','paused-qualityfeedback'=>'','paused-wrapup'=>'','paused-teabreak'=>'','paused-teammeeting'=>'','paused-utilitybreak'=>'','paused-autowrapup'=>'','progressive'=>'','ready-incoming'=>''
);
$data=json_decode($aline->data,true);
......@@ -111,45 +117,69 @@ class Userlog_data extends Command {
{
if($states[0] != 1)
{
//if($previous!='paused-wrapup'){
$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["login"] = $aline->durationsec;
$rowdata["login"] = $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'];
/*$rowdata["not-ready"] = $durationsec-($rowdata['dialnext']+$rowdata['manual']+$rowdata['paused']+$rowdata['paused-agentbriefing']+$rowdata['paused-downtime']+$rowdata['paused-floorannouncements']+$rowdata['paused-incoming']+$rowdata['paused-lunchbreak']+$rowdata['paused-manual']+$rowdata['paused-notready']+$rowdata['paused-qualityfeedback']+$rowdata['paused-teabreak']+$rowdata['paused-teammeeting']+$rowdata['paused-utilitybreak']+$rowdata['paused-autowrapup']+$rowdata['progressive']+$rowdata['ready-incoming']);*/
$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'];
//$rowdata["not-ready"] = $aline->durationsec-($rowdata['dialnext']+$rowdata['dialnext-agentbriefing']+$rowdata['dialnext-downtime']+$rowdata['dialnext-floorannouncements']+$rowdata['dialnext-incoming']+$rowdata['dialnext-lunchbreak']+$rowdata['dialnext-manual']+$rowdata['dialnext-notready']+$rowdata['dialnext-qualityfeedback']+$rowdata['dialnext-teabreak']+$rowdata['dialnext-teammeeting']+$rowdata['dialnext-utilitybreak']+$rowdata['manual']+$rowdata['manual-agentbriefing']+$rowdata['manual-downtime']+$rowdata['manual-floorannouncements']+$rowdata['manual-incoming']+$rowdata['manual-lunchbreak']+$rowdata['manual-manual']+$rowdata['manual-notready']+$rowdata['manual-qualityfeedback']+$rowdata['manual-teabreak']+$rowdata['manual-teammeeting']+$rowdata['manual-utilitybreak']+$rowdata['paused']+$rowdata['paused-agentbriefing']+$rowdata['paused-autowrapup']+$rowdata['paused-downtime']+$rowdata['paused-floorannouncements']+$rowdata['paused-incoming']+$rowdata['paused-lunchbreak']+$rowdata['paused-manual']+$rowdata['paused-notready']+$rowdata['paused-qualityfeedback']+$rowdata['paused-teabreak']+$rowdata['paused-teammeeting']+$rowdata['paused-utilitybreak']+$rowdata['paused-autowrapup']+$rowdata['paused-wrapup']+$rowdata['progressive']+$rowdata['progressive-agentbriefing']+$rowdata['progressive-agentbriefing']+$rowdata['progressive-downtime']+$rowdata['progressive-floorannouncements']+$rowdata['progressive-incoming']+$rowdata['progressive-lunchbreak']+$rowdata['progressive-manual']+$rowdata['progressive-notready']+$rowdata['progressive-qualityfeedback']+$rowdata['progressive-teabreak']+$rowdata['progressive-teammeeting']+$rowdata['progressive-utilitybreak']+$rowdata['ready-incoming']);
$key_value = '';
foreach($rowdata AS $key=>$value) {
if($key != 1)
/*foreach($rowdata AS $key=>$value) {
//if($key == 1){ $key }
if($key != 1 && $key != 'paused-wrapup'){
$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."'"));
//$endTime=$aline->enddate." ".$aline->endtime;
if($aline->enddate=='0000-00-00'|| $aline->endtime=='00:00:00' || $aline->durationsec=='0')
{
$endTime=date("Y-m-d H:i:s",strtotime($aline->updated_at));
}else{
$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,waitSec,callSec,talkSec,recstartSec,recendSec,dispoSec from crmcalls WHERE created_at>='".$startTime."' and updated_at<'".$endTime."' and user_id='".$aline->user_id."'"));
$crmCalls=DB::select(DB::raw("select updated_at,user_id,type,userstatus,ts_Wait,ts_Call,ts_Talk,ts_Recstart,ts_Recend,ts_Dispo,ts_Close from crmcalls WHERE created_at>='".$startTime."' and created_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;
$force_Close=0;$force_Wait=0;$force_Call=0;$force_Talk=0;$force_Dispo=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->userstatus =='FORCEDCLOSE' || $crmCall->updated_at > $endTime)
{
$force_Wait += round(($crmCall->ts_Call - $crmCall->ts_Wait)/1000,2);
$force_Call += round(($crmCall->ts_Talk - $crmCall->ts_Call)/1000,2);
$force_Talk += round(($crmCall->ts_Dispo - $crmCall->ts_Talk)/1000,2);
// $force_Dispo += round(($crmCall->ts_Close - $crmCall->ts_Dispo)/1000,2);
}else{
$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);
......@@ -160,10 +190,15 @@ class Userlog_data extends Command {
if($crmCall->type == 'Manual')
{
/*$manTs_Wait += round($crmCall->waitSec/1000,2);
$manTs_Call += round($crmCall->callSec/1000,2);
$manTs_Talk += round(($crmCall->talkSec+$crmCall->recstartSec+$crmCall->recendSec)/1000,2);
$manTs_Dispo += round($crmCall->dispoSec/1000,2);*/
$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);
//echo round($crmCall->dispoSec/1000,2).":";
}
if($crmCall->type == 'Inbound')
......@@ -175,17 +210,23 @@ class Userlog_data extends Command {
}
}
}
}
$inbTs_Call =0;
//print_r($manTs_Dispo);
$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;
//$rowdata['not-ready']=$aline->durationsec-($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']+$tt_prog+$tt_man+$tt_inb);
$prod_TOS = $ts_Wait + $ts_Call + $ts_Talk + $ts_Dispo;
//$rowdata['not-ready']=$aline->durationsec-$prod_TOS;
$tt_act_inb=$tt_inb-$inbTs_Call;
// $prod_TOS = $ts_Wait + $ts_Call + $ts_Talk + $ts_Dispo;
$force_Close = $force_Wait + $force_Call + $force_Talk + $force_Dispo;
$prod_TOS = $tt_prog+$tt_man+$tt_inb+$force_Close;
$key_value .= "`tt_prog` = '$tt_prog', ";
$key_value .= "`tt_man` = '$tt_man', ";
$key_value .= "`tt_inb` = '$tt_inb', ";
$key_value .= "`force_Close` = '$force_Close',";
$key_value .= "`ts_Wait` = '$ts_Wait', ";
$key_value .= "`ts_Call` = '$ts_Call', ";
$key_value .= "`ts_Talk` = '$ts_Talk', ";
......@@ -204,12 +245,25 @@ class Userlog_data extends Command {
$key_value .= "`incts_Dispo` = '$inbTs_Dispo', ";
$key_value .= "`prod_tos` = '$prod_TOS', ";
$key_value .= "`manual` = '$tt_man',";
$key_value .= "`progressive` = '$tt_prog',";
$key_value .= "`ready-incoming` = '$tt_act_inb',";
$rowdata["not-ready"] = $durationsec-($rowdata['dialnext']+$rowdata['paused']+$rowdata['paused-agentbriefing']+$rowdata['paused-downtime']+$rowdata['paused-floorannouncements']+$rowdata['paused-incoming']+$rowdata['paused-lunchbreak']+$rowdata['paused-manual']+$rowdata['paused-notready']+$rowdata['paused-qualityfeedback']+$rowdata['paused-teabreak']+$rowdata['paused-teammeeting']+$rowdata['paused-utilitybreak']+$rowdata['paused-autowrapup']+$tt_man+$tt_prog+$tt_act_inb+$force_Close);
//$key_value = '';
foreach($rowdata AS $key=>$value) {
//if($key == 1){ $key }
if($key != 1 && $key != 'paused-wrapup' && $key != 'progressive' && $key != 'manual' && $key != 'ready-incoming'){
//if($key != 1 && $key != 'paused-wrapup' && $key != 'progressive' && $key != 'manual'){
$key_value .= "`$key` = '$value', ";
}
}
$key_value = substr($key_value, 0, -2);
$userlogsTable = "userlogs_".date("d_m_Y",$logdate);
//print_r($key_value);
$userlogsTable = "userlogs_".date("d_m_Y",$logdate);;
//echo $userlogsTable;
DB::connection("conn")->insert(DB::raw("INSERT INTO ".$userlogsTable." SET $key_value"));
//DB::connection("conn")->insert(DB::raw("INSERT INTO userlogs_13_11_2018_bk 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_datavalidation extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'Userlog_datavalidation';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Userlog_datavalidation';
/**
* 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 = '';
$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;
$total_idealtime=$rowdata["login"]-($rowdata['not-ready']+$tt_prog+$tt_man+$tt_inb);
echo "notready time-----idle----".$total_idealtime;
foreach($rowdata AS $key=>$value) {
if($key != 1)
$key_value .= "`$key` = '$value', ";
}
$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 .= "`totalidealtime` = '$total_idealtime', ";
$key_value = substr($key_value, 0, -2);
//$userlogsTable = "userlogs_".date("d_m_Y",$logdate);
$userlogsTable = "userlogs_datavalid";
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 dailyupload_calllog extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'dailyupload_calllog';
/**
* The console command description.
*
* @var string
*/
protected $description = 'dailyupload_calllog';
/**
* 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_ip=env('app_ip');
$central_ip=env('central_ip');
$calllog_report = "calllog_report_".date("d_m_Y",$logdate);
$created_at=date("Y-m-d H:i:s");
$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;
}
$clist=DB::connection("conn")->select(DB::raw("select count(*) as cnt,server from $calllog_report group by server"));
$caar=[];
foreach($clist as $cline)
{
$caar[$cline->server]= $cline->cnt;
}
$mlist=DB::select(DB::raw("select count(*) as countrecord from crmcalls where created_at>'".date("Y-m-d",$logdate)."' and created_at<'".date("Y-m-d",$logdate+24*60*60)."'"));
$location_cont='0';
$central_cont='0';
$location_cont=$mlist[0]->countrecord;
if(array_key_exists($server_id,$caar)){
$central_cont=$caar[$server_id];
}else{
$central_cont=0;
}
$dif=($central_cont)-($mlist[0]->countrecord);
if($dif==0){
$result="Y";
DB::connection("conn")->insert(DB::raw("insert into dailyupload_calllog_records set created_at='$created_at',server_id='$server_id',server_ip='$server_ip',central_count='$central_cont',location_count='$location_cont',difference='$dif',result='$result'"));
}else{
$result="N";
DB::connection("conn")->insert(DB::raw("insert into dailyupload_calllog_records set created_at='$created_at',server_id='$server_id',server_ip='$server_ip',central_count='$central_cont',location_count='$location_cont',difference='$dif',result='$result'"));
}
DB::connection("conn")->disconnect();
}
}
}
......@@ -71,9 +71,9 @@ class bulkServerUpload extends Command {
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'yb9738z'),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......@@ -88,8 +88,7 @@ class bulkServerUpload extends Command {
$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 0,20000"));
$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,50000"));
$conn='';
......@@ -211,7 +210,7 @@ class bulkServerUpload extends Command {
}
}
if(!empty($successArr)){
/*if(!empty($successArr)){
foreach($successArr as $succes)
{
$setSuccess=array();
......@@ -242,7 +241,7 @@ class bulkServerUpload extends Command {
DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_failure set $setFailure"));
}
}
}*/
DB::connection("conn")->disconnect();
}
......
......@@ -71,9 +71,9 @@ class bulkServerUpload_1 extends Command {
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'yb9738z'),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......@@ -89,7 +89,7 @@ class bulkServerUpload_1 extends Command {
$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"));
$excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat where SERVER_IP='$server_ip' order by auto_id asc limit 50000,50000"));
$conn='';
......@@ -211,6 +211,7 @@ class bulkServerUpload_1 extends Command {
}
}
/*
if(!empty($successArr)){
foreach($successArr as $succes)
{
......@@ -243,6 +244,7 @@ class bulkServerUpload_1 extends Command {
DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_failure set $setFailure"));
}
}
*/
DB::connection("conn")->disconnect();
}
......
......@@ -71,9 +71,9 @@ class bulkServerUpload_2 extends Command {
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'yb9738z'),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......@@ -89,7 +89,7 @@ class bulkServerUpload_2 extends Command {
$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"));
$excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat where SERVER_IP='$server_ip' order by auto_id asc limit 100000,50000"));
$conn='';
......@@ -211,6 +211,7 @@ class bulkServerUpload_2 extends Command {
}
}
/*
if(!empty($successArr)){
foreach($successArr as $succes)
{
......@@ -243,7 +244,7 @@ class bulkServerUpload_2 extends Command {
DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_failure set $setFailure"));
}
}
*/
DB::connection("conn")->disconnect();
}
}
......
......@@ -71,9 +71,9 @@ class bulkServerUpload_3 extends Command {
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'yb9738z'),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......@@ -89,7 +89,7 @@ class bulkServerUpload_3 extends Command {
$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 60001,80000"));
$excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat where SERVER_IP='$server_ip' order by auto_id asc limit 150000,50000"));
$conn='';
......@@ -211,6 +211,7 @@ class bulkServerUpload_3 extends Command {
}
}
/*
if(!empty($successArr)){
foreach($successArr as $succes)
{
......@@ -243,7 +244,7 @@ class bulkServerUpload_3 extends Command {
DB::connection("conn")->insert(DB::raw("insert into bz_record_upload_uat_failure set $setFailure"));
}
}
*/
DB::connection("conn")->disconnect();
}
}
......
......@@ -71,9 +71,9 @@ class bulkServerUpload_4 extends Command {
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'yb9738z'),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......
......@@ -71,9 +71,9 @@ class bulkServerUpload_5 extends Command {
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'yb9738z'),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......
......@@ -71,9 +71,9 @@ class bulkServerUpload_6 extends Command {
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'yb9738z'),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......
......@@ -71,9 +71,9 @@ class bulkServerUpload_daily extends Command {
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'yb9738z'),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......@@ -91,7 +91,7 @@ echo $central_ip;
echo $location;
$excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat_daily where SERVER_IP='$server_ip'"));
$excelarray = DB::connection("conn")->select(DB::raw("select * from bz_record_upload_uat_daily where SERVER_IP='$server_ip' order by auto_id asc limit 0,200"));
$conn='';
......
......@@ -71,9 +71,9 @@ class bulkServerUpload_data3 extends Command {
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'yb9738z'),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......
......@@ -71,9 +71,9 @@ class bulkserverupload_data extends Command {
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'yb9738z'),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......
......@@ -51,9 +51,9 @@ class calllog extends Command {
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......
......@@ -47,9 +47,9 @@ class complaint_data extends Command {
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......
......@@ -50,9 +50,9 @@ public function handle()
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......
......@@ -50,9 +50,9 @@ public function handle()
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......
......@@ -50,9 +50,9 @@ class dailyupload_calllog extends Command {
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......
......@@ -51,9 +51,9 @@ class dailyupload_questionaire extends Command {
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......
......@@ -44,15 +44,15 @@ class full_remark_details extends Command {
$tcol=0;$fieldsarr=array();$extrahdrarr=array();
$server_ip=env('app_ip');
$full_remark = "full_remark_details";
$central_ip=env('central_ip');
$full_remark = "full_remark_details";
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......@@ -76,8 +76,8 @@ class full_remark_details extends Command {
$maxids=$maxid[0]->maxid;
//$qlist=DB::select(DB::raw("SELECT * from full_remark"));
$qlist=DB::select(DB::raw("SELECT * from full_remark where id>'$maxids' and created_at>'".date("Y-m-d")."' and created_at<'".date("Y-m-d H:i:s",$logdate-(60*60))."'"));
$qlist=DB::select(DB::raw("SELECT * from full_remark where id>'$maxids' and fullremark!=''"));
echo count($qlist);
$userarr=array();
foreach($qlist as $qline)
{
......@@ -94,6 +94,7 @@ class full_remark_details extends Command {
DB::connection("conn")->insert(DB::raw("insert into ".$full_remark." set $setstr"));
}
echo "\n".date('Y-m-d H:i:s')."\n";
DB::connection("conn")->disconnect();
}
......
......@@ -50,9 +50,9 @@ public function handle()
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......
......@@ -50,9 +50,9 @@ public function handle()
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......
......@@ -50,9 +50,9 @@ public function handle()
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......
......@@ -47,9 +47,9 @@ class relationship_tag extends Command {
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......
......@@ -47,9 +47,9 @@ public function handle()
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......
......@@ -54,9 +54,9 @@ public function handle()
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......
......@@ -60,9 +60,9 @@ use Illuminate\Database\Schema\Blueprint;
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......
......@@ -51,9 +51,9 @@ class recording_reconcilation_metadata extends Command
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......
......@@ -46,9 +46,9 @@ class records_details extends Command {
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......@@ -73,7 +73,7 @@ echo ",".$server_ip;
$maxids=$maxid[0]->maxid;
$qlist=DB::select(DB::raw("SELECT id,clientcode,client,status,clientinternalid,mobile,priority,modified,question,firstname FROM `records` where id>'$maxids'"));
$qlist=DB::select(DB::raw("SELECT id,created,clientcode,client,status,clientinternalid,mobile,priority,modified,question,firstname FROM `records` where id>'$maxids' and client != 'Inactive'"));
$countnumber=count($qlist);
$finalnumber=$countnumber/50;
......@@ -86,6 +86,7 @@ echo ",".$server_ip;
foreach($qlist as $qline)
{
$record_id=$qline->id;
$created=$qline->created;
$clientcode=$qline->clientcode;
$client=$qline->client;
$status=$qline->status;
......@@ -96,19 +97,19 @@ echo ",".$server_ip;
$question=$qline->question;
$firstname=$qline->firstname;
$shortinsert.="('$client', '$server_ip', '$record_id', '$clientcode', '$status', '$clientinternalid', '$location', '$mobile', '$question', '$firstname', '$priority', '$modified'),";
$shortinsert.="('$client', '$server_ip', '$record_id', '$clientcode', '$status', '$clientinternalid', '$location', '$mobile', '$question', '$firstname', '$priority', '$modified', '$created'),";
if($kkk<=$finalnumber){
if($iii%50==0){
$shortinsert=substr($shortinsert,0,-1);
DB::connection("conn")->insert(DB::raw("INSERT INTO `records_details` (`client`, `server_ip`, `record_id`, `cust_id`, `records_status`, `group_id`, `location`, `mobile`, `question`,`firstname`, `priority`, `modified`) VALUES $shortinsert"));
DB::connection("conn")->insert(DB::raw("INSERT INTO `records_details` (`client`, `server_ip`, `record_id`, `cust_id`, `records_status`, `group_id`, `location`, `mobile`, `question`,`firstname`, `priority`, `modified`, `created`) VALUES $shortinsert"));
$kkk++;
}
}else{
DB::connection("conn")->insert(DB::raw("insert into records_details 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")->insert(DB::raw("insert into records_details 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',created='$created'"));
}
if($iii%50==0){
$shortinsert="";
......
......@@ -47,9 +47,9 @@ class relationship_tag extends Command {
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......
......@@ -46,9 +46,9 @@ public function handle()
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......
......@@ -46,9 +46,9 @@ public function handle()
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......
......@@ -50,9 +50,9 @@ public function handle()
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......
......@@ -50,9 +50,9 @@ public function handle()
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......
......@@ -50,9 +50,9 @@ public function handle()
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......
......@@ -50,9 +50,9 @@ public function handle()
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......
......@@ -47,8 +47,10 @@ protected $commands = [
'App\Console\Commands\BirthdayDate',
'App\Console\Commands\bulkserverupload_data',
'App\Console\Commands\bulkServerUpload_data3',
'App\Console\Commands\Userlog_datavalidation',
'App\Console\Commands\Calllogupdate',
'App\Console\Commands\CreateCall',
'App\Console\Commands\PredictiveCallHangUp',
'App\Console\Commands\UpdateAvgRingSec',
];
/**
......@@ -59,12 +61,13 @@ protected $commands = [
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('KstychDaily')->daily()->withoutOverlapping();
//$schedule->command('KstychDaily')->daily()->withoutOverlapping();
$schedule->command('UpdateAvgRingSec')->daily()->withoutOverlapping();
//$schedule->command('bulkServerUpload')->everyFiveMinutes()->appendOutputTo(storage_path()."/reason/bulkserver.txt")->withoutOverlapping();
//$schedule->command('bulkserverupload_data')->everyMinute()->appendOutputTo(storage_path()."/reason/bulkserverupload_data.txt")->withoutOverlapping();
$schedule->command('bulkserverupload_data')->dailyAt('14:17')->appendOutputTo(storage_path()."/reason/bulkserverupload_data.txt")->withoutOverlapping();
$schedule->command('bulkServerUpload')->dailyAt('14:15')->appendOutputTo(storage_path()."/reason/bulkserver.txt")->withoutOverlapping();
$schedule->command('bulkServerUpload_data3')->dailyAt('14:20')->appendOutputTo(storage_path()."/reason/bulkServerUpload_data3.txt")->withoutOverlapping();
//$schedule->command('bulkserverupload_data')->dailyAt('14:17')->appendOutputTo(storage_path()."/reason/bulkserverupload_data.txt")->withoutOverlapping();
//$schedule->command('bulkServerUpload')->dailyAt('14:15')->appendOutputTo(storage_path()."/reason/bulkserver.txt")->withoutOverlapping();
//$schedule->command('bulkServerUpload_data3')->dailyAt('14:20')->appendOutputTo(storage_path()."/reason/bulkServerUpload_data3.txt")->withoutOverlapping();
//$schedule->command('relationship_tag')->everyMinute()->appendOutputTo(storage_path()."/reason/relationship_tag.txt")->withoutOverlapping();
//$schedule->command('calllog')->everyMinute()->appendOutputTo(storage_path()."/reason/calllog.txt")->withoutOverlapping();
......@@ -73,19 +76,18 @@ protected function schedule(Schedule $schedule)
//$schedule->command('supervisor_agent_rec')->everyMinute()->appendOutputTo(storage_path()."/reason/supervisor_agent_rec.txt")->withoutOverlapping();
//$schedule->command('supervisor_recommendation')->everyMinute()->appendOutputTo(storage_path()."/reason/supervisor_recommendation.txt")->withoutOverlapping();
//$schedule->command('question_tree')->everyMinute()->appendOutputTo(storage_path()."/reason/question_tree.txt")->withoutOverlapping();
//$schedule->command('bulkServerUpload')->dailyAt('10:08')->appendOutputTo(storage_path()."/reason/bulkserver.txt")->withoutOverlapping();
$schedule->command('Userlog_data')->dailyAt('01:10')->appendOutputTo(storage_path()."/reason/Userlog_data.txt")->withoutOverlapping();
//$schedule->command('Userlog_data')->everyMinute()->appendOutputTo(storage_path()."/reason/Userlog_data.txt")->withoutOverlapping();
//$schedule->command('Userlog_data')->dailyAt('01:10')->appendOutputTo(storage_path()."/reason/Userlog_data.txt")->withoutOverlapping();
$schedule->command('bulkServerUpload')->dailyAt('14:45')->appendOutputTo(storage_path()."/reason/bulkserver.txt")->withoutOverlapping();
$schedule->command('bulkServerUpload_1')->dailyAt('16:18')->appendOutputTo(storage_path()."/reason/bulkserver.txt")->withoutOverlapping();
$schedule->command('bulkServerUpload_2')->dailyAt('17:45')->appendOutputTo(storage_path()."/reason/bulkserver.txt")->withoutOverlapping();
$schedule->command('bulkServerUpload_3')->dailyAt('19:15')->appendOutputTo(storage_path()."/reason/bulkserver.txt")->withoutOverlapping();
$schedule->command('bulkServerUpload_4')->dailyAt('20:45')->appendOutputTo(storage_path()."/reason/bulkserver.txt")->withoutOverlapping();
$schedule->command('bulkServerUpload_1')->dailyAt('16:12')->appendOutputTo(storage_path()."/reason/bulkserver.txt")->withoutOverlapping();
$schedule->command('bulkServerUpload_2')->dailyAt('16:45')->appendOutputTo(storage_path()."/reason/bulkserver.txt")->withoutOverlapping();
$schedule->command('bulkServerUpload_3')->dailyAt('21:15')->appendOutputTo(storage_path()."/reason/bulkserver.txt")->withoutOverlapping();
$schedule->command('bulkServerUpload_4')->dailyAt('23:45')->appendOutputTo(storage_path()."/reason/bulkserver.txt")->withoutOverlapping();
//$schedule->command('bulkServerUpload_daily')->everyMinute()->appendOutputTo(storage_path()."/reason/bulkServerUpload_daily.txt")->withoutOverlapping();
//$schedule->command('bulkServerUpload_daily')->everyMinute()->appendOutputTo(storage_path()."/reason/bulkserver_daily.txt")->withoutOverlapping();
$schedule->command('BirthdayDate')->dailyAt('01:45')->appendOutputTo(storage_path()."/reason/BirthdayDate.txt")->withoutOverlapping();
/*$schedule->command('BirthdayDate')->dailyAt('01:45')->appendOutputTo(storage_path()."/reason/BirthdayDate.txt")->withoutOverlapping();
$schedule->command('bulkServerUpload_daily')->dailyAt('05:05')->appendOutputTo(storage_path()."/reason/bulkserver_daily.txt")->withoutOverlapping();
$schedule->command('bulkServerUpload_daily')->dailyAt('07:05')->appendOutputTo(storage_path()."/reason/bulkserver_daily.txt")->withoutOverlapping();
$schedule->command('bulkServerUpload_daily')->dailyAt('09:05')->appendOutputTo(storage_path()."/reason/bulkserver_daily.txt")->withoutOverlapping();
......@@ -98,7 +100,7 @@ protected function schedule(Schedule $schedule)
$schedule->command('CreportNine')->dailyAt('14:44')->appendOutputTo(storage_path()."/reason/CreportNine.txt")->withoutOverlapping();
$schedule->command('CreportNine')->dailyAt('01:14')->appendOutputTo(storage_path()."/reason/CreportNine.txt")->withoutOverlapping();
$schedule->command('Calllogupdate')->dailyAt('09:55')->appendOutputTo(storage_path()."/reason/calllog_update.txt")->withoutOverlapping();
//$schedule->command('CreportNine')->everyMinute()->appendOutputTo(storage_path()."/reason/CreportNine.txt")->withoutOverlapping();
//$schedule->command('CreportEight')->everyMinute()->appendOutputTo(storage_path()."/reason/CreportEight.txt")->withoutOverlapping();
$schedule->command('questionnaire_details')->hourly()->appendOutputTo(storage_path()."/reason/questionnaire_details.txt")->withoutOverlapping();
......@@ -126,8 +128,7 @@ protected function schedule(Schedule $schedule)
//$schedule->command('relationship_data')->everyMinute()->appendOutputTo(storage_path()."/reason/relationship_data.txt")->withoutOverlapping();
//$schedule->command('table_create')->everyMinute()->appendOutputTo(storage_path()."/reason/table_create.txt")->withoutOverlapping();
//$schedule->command('Userlog_datavalidation')->everyMinute()->appendOutputTo(storage_path()."/reason/Userlog_datavalid.txt")->withoutOverlapping();
*/
}
}
......
<?php namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
'App\Console\Commands\KstychDaily',
'App\Console\Commands\KstychPAMI',
'App\Console\Commands\KstychPAGI',
'App\Console\Commands\DailyLogout',
'App\Console\Commands\bulkServerUpload',
'App\Console\Commands\bulkServerUpload_1',
'App\Console\Commands\bulkServerUpload_2',
'App\Console\Commands\bulkServerUpload_3',
'App\Console\Commands\bulkServerUpload_4',
//'App\Console\Commands\bulkServerUpload_5',
'App\Console\Commands\bulkServerUpload_daily',
'App\Console\Commands\InsertCrmArchive',
'App\Console\Commands\DeleteCrmcalls',
'App\Console\Commands\records_details',
'App\Console\Commands\CreportEight',
'App\Console\Commands\questionnaire_details',
'App\Console\Commands\Userlog_data',
'App\Console\Commands\lead_form_details',
'App\Console\Commands\full_remark_details',
'App\Console\Commands\recording_reconcilation',
'App\Console\Commands\recording_reconcilation_metadata',
'App\Console\Commands\dailyupload_calllog',
'App\Console\Commands\dailyupload_questionaire',
'App\Console\Commands\relationship_data',
'App\Console\Commands\relationship_tag',
'App\Console\Commands\supervisor_agent_rec',
'App\Console\Commands\supervisor_recommendation',
'App\Console\Commands\rlppb_details',
'App\Console\Commands\question_tree',
//'App\Console\Commands\table_create',
//'App\Console\Commands\calllog',
//'App\Console\Commands\CreportNine',
//'App\Console\Commands\CreportTen',
'App\Console\Commands\BirthdayDate',
'App\Console\Commands\bulkserverupload_data',
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('KstychDaily')->daily()->withoutOverlapping();
//$schedule->command('bulkServerUpload')->everyFiveMinutes()->appendOutputTo(storage_path()."/reason/bulkserver.txt")->withoutOverlapping();
$schedule->command('bulkserverupload_data')->dailyAt('01:45')->appendOutputTo(storage_path()."/reason/bulkserverupload_data.txt")->withoutOverlapping();
//$schedule->command('relationship_tag')->everyMinute()->appendOutputTo(storage_path()."/reason/relationship_tag.txt")->withoutOverlapping();
//$schedule->command('calllog')->everyMinute()->appendOutputTo(storage_path()."/reason/calllog.txt")->withoutOverlapping();
//$schedule->command('rlppb_details')->everyMinute()->appendOutputTo(storage_path()."/reason/rlppb_details.txt")->withoutOverlapping();
$schedule->command('BirthdayDate')->dailyAt('01:45')->appendOutputTo(storage_path()."/reason/BirthdayDate.txt")->withoutOverlapping();
//$schedule->command('supervisor_agent_rec')->everyMinute()->appendOutputTo(storage_path()."/reason/supervisor_agent_rec.txt")->withoutOverlapping();
//$schedule->command('supervisor_recommendation')->everyMinute()->appendOutputTo(storage_path()."/reason/supervisor_recommendation.txt")->withoutOverlapping();
//$schedule->command('question_tree')->everyMinute()->appendOutputTo(storage_path()."/reason/question_tree.txt")->withoutOverlapping();
$schedule->command('Userlog_data')->dailyAt('01:10')->appendOutputTo(storage_path()."/reason/Userlog_data.txt")->withoutOverlapping();
$schedule->command('bulkServerUpload')->dailyAt('14:45')->appendOutputTo(storage_path()."/reason/bulkserver.txt")->withoutOverlapping();
$schedule->command('bulkServerUpload_1')->dailyAt('16:18')->appendOutputTo(storage_path()."/reason/bulkserver.txt")->withoutOverlapping();
$schedule->command('bulkServerUpload_2')->dailyAt('17:45')->appendOutputTo(storage_path()."/reason/bulkserver.txt")->withoutOverlapping();
$schedule->command('bulkServerUpload_3')->dailyAt('19:15')->appendOutputTo(storage_path()."/reason/bulkserver.txt")->withoutOverlapping();
$schedule->command('bulkServerUpload_4')->dailyAt('20:45')->appendOutputTo(storage_path()."/reason/bulkserver.txt")->withoutOverlapping();
//$schedule->command('bulkServerUpload_daily')->everyMinute()->appendOutputTo(storage_path()."/reason/bulkServerUpload_daily.txt")->withoutOverlapping();
//$schedule->command('bulkServerUpload_daily')->everyMinute()->appendOutputTo(storage_path()."/reason/bulkserver_daily.txt")->withoutOverlapping();
$schedule->command('bulkServerUpload_daily')->dailyAt('05:05')->appendOutputTo(storage_path()."/reason/bulkserver_daily.txt")->withoutOverlapping();
$schedule->command('bulkServerUpload_daily')->dailyAt('07:05')->appendOutputTo(storage_path()."/reason/bulkserver_daily.txt")->withoutOverlapping();
$schedule->command('bulkServerUpload_daily')->dailyAt('09:05')->appendOutputTo(storage_path()."/reason/bulkserver_daily.txt")->withoutOverlapping();
$schedule->command('bulkServerUpload_daily')->dailyAt('11:05')->appendOutputTo(storage_path()."/reason/bulkserver_daily.txt")->withoutOverlapping();
$schedule->command('bulkServerUpload_daily')->dailyAt('13:05')->appendOutputTo(storage_path()."/reason/bulkserver_daily.txt")->withoutOverlapping();
$schedule->command('dailyupload_questionaire')->dailyAt('19:30')->appendOutputTo(storage_path()."/reason/dailyupload_questionaire.txt")->withoutOverlapping();
//$schedule->command('CreportEight')->everyFiveMinutes()->appendOutputTo(storage_path()."/reason/CreportEight.txt")->withoutOverlapping();
$schedule->command('CreportEight')->everyTenMinutes()->appendOutputTo(storage_path()."/reason/CreportEight.txt")->withoutOverlapping();
//$schedule->command('CreportNine')->everyMinute()->appendOutputTo(storage_path()."/reason/CreportNine.txt")->withoutOverlapping();
//$schedule->command('CreportTen')->everyMinute()->appendOutputTo(storage_path()."/reason/CreportTen.txt")->withoutOverlapping();
//$schedule->command('CreportEight')->everyMinute()->appendOutputTo(storage_path()."/reason/CreportEight.txt")->withoutOverlapping();
$schedule->command('questionnaire_details')->hourly()->appendOutputTo(storage_path()."/reason/questionnaire_details.txt")->withoutOverlapping();
$schedule->command('InsertCrmArchive')->hourly()->appendOutputTo(storage_path()."/reason/InsertCrmArchive.txt")->withoutOverlapping();
//$schedule->command('InsertCrmArchive')->everyMinute()->appendOutputTo(storage_path()."/reason/InsertCrmArchive.txt")->withoutOverlapping();
$schedule->command('DeleteCrmcalls')->hourly()->withoutOverlapping();
$schedule->command('DailyLogout')->dailyAt('14:30')->withoutOverlapping();
$schedule->command('lead_form_details')->everyTenMinutes()->appendOutputTo(storage_path()."/reason/lead_form_details.txt")->withoutOverlapping();
$schedule->command('records_details')->dailyAt('17:45')->appendOutputTo(storage_path()."/reason/records_details.txt")->withoutOverlapping();
//$schedule->command('recording_reconcilation')->everyMinute()->appendOutputTo(storage_path()."/reason/recording_reconcilation.txt")->withoutOverlapping();
//$schedule->command('recording_reconcilation_metadata')->everyMinute()->appendOutputTo(storage_path()."/reason/recording_reconcilation_metadata.txt")->withoutOverlapping();
//$schedule->command('lead_form_details')->everyMinute()->appendOutputTo(storage_path()."/reason/lead_form_details.txt")->withoutOverlapping();
$schedule->command('dailyupload_calllog')->dailyAt('19:30')->appendOutputTo(storage_path()."/reason/dailycalllog_records.txt")->withoutOverlapping();
//$schedule->command('records_details')->everyMinute()->appendOutputTo(storage_path()."/reason/records_details.txt")->withoutOverlapping();
$schedule->command('full_remark_details')->hourly()->appendOutputTo(storage_path()."/reason/full_remark_details.txt")->withoutOverlapping();
//$schedule->command('questionnaire_details')->everyMinute()->appendOutputTo(storage_path()."/reason/questionnaire_details.txt")->withoutOverlapping();
//$schedule->command('relationship_data')->everyMinute()->appendOutputTo(storage_path()."/reason/relationship_data.txt")->withoutOverlapping();
//$schedule->command('table_create')->everyMinute()->appendOutputTo(storage_path()."/reason/table_create.txt")->withoutOverlapping();
}
}
<?php
define('SMS_NOTCONTACTED',1);
define('SMS_THANKYOU',2);
$smsContactedSubdispositionsArr = array ('Contacted','Feedback');
$smsNotContactedSubdispositionsArr = array (
'NC - Customer Traveling / Abroad',
'NC - Customer in Meeting',
'NC - Ringing / No response',
'NC - Not Reachable',
'NC - Switched off',
'NC - Third Party'
);
$smsTemplatesArr = array(
//SMS_NOTCONTACTED => "Dear Customer,Your Virtual Relationship Manager #name# from HDFC Bank tried reaching you. Kindly call #number# for all your banking and financial needs",
//SMS_NOTCONTACTED =>"Dear Customer, Your Virtual RM #name# from HDFC Bank tried reaching you. Kindly call #number# for all your banking and financial needs.",
SMS_NOTCONTACTED =>"Your RM is unable to contact you!
Call #name# @ #number# for any banking need.
Check & invest in our FD/RD @best rate.
Click here: bit.ly/2TqCdKA",
//SMS_THANKYOU =>"Thank you for speaking to your VirtualRM on #date# . Now also access your account 24/7 via NetBanking/MobileBanking. Download MobileBanking App: bit.ly/2ajTksK"
//SMS_THANKYOU =>"Thank you for speaking to your Virtual RM on #date#. Now also access your account 24/7 via Net / Mobile Banking. Download Mobile App: bit.ly/2ajTksK"
SMS_THANKYOU =>"Your opinion matters!
Thanks for talking & sharing your feedback on #number# with RM #name#
Check & invest in our FD/RD @best rate
Click: bit.ly/2TqCdKA"
);
?>
<?php
$gatewaydispoArry=Array('19'=>'NC-BUSY','17'=>'NC-BUSY','0'=>'NC-BUSY','16'=>'NC-Ringing');
?>
<?php
$DisableNumbersArray = Array('2250910057','2653321205','2656702205','2657145889','2268231057');
$BlockedNumbersArray = Array('8074030875');
?>
<?php namespace App\Http\Controllers;
use DB;
use Auth;
use Input;
use App\Models\Campaign;
use App\Services\FormBuilder;
use Illuminate\Http\Request;
use Response;
use App\Models\User;
use SimpleXLSX;
use App\Jobs\KHRMSLib;
class CampaignController extends Controller {
public function __construct()
{
$this->middleware('auth');
$this->middleware('module_access');
}
public function index()
{
$data['campaignList'] = Campaign::where('mtype',"=","company")->where('status','=','active')->orderBy('mkey')->get();
$dashboarduser=Auth::user();
if($dashboarduser->usertype != 'Admin'){
$allusers=User::where(function ($query) use($dashboarduser) {
$query->where('supervisor','=',$dashboarduser->username)
->orWhere('lteam2','=',$dashboarduser->username)
->orWhere('lteam','=',$dashboarduser->username);
})->get();
}
else
{
$allusers=DB::table('users')->select('*')->where('status','=','Active')->get();
}
foreach($allusers as $alluser)
{
$username[] = $alluser->username;
}
//$data['client'] = $client;
if(isset($username))$data['username'] = $username;
return view("layout.module.campaign.index",$data);
}
public function create()
{
}
public function store(Request $request)
{
$action = Input::get("action");
if($action == 'upload'){
if($request->hasFile('file')){
include_once(app_path().'/lib/phpexcel/PHPExcel.php');
include(app_path().'/lib/simplexlsx-master/simplexlsx.class.php');
$path = $request->file->getRealPath();
$objSimpleXLSX = SimpleXLSX::parse($path);
$objWorksheet = $objSimpleXLSX->rows();
$highestColumn = count($objWorksheet[0]);
$highestrow=count($objWorksheet);
//echo "<pre>";print_r($objWorksheet);
//echo "\n";
//print_r($highestColumn);
//echo "\n";
//echo $highestrow;
for($i=0;$i<$highestrow;$i++)
{//echo $i;
$excelarray[$i]=array();
for ($head = 0; $head < $highestColumn; $head++)
{
if($i==0)
{
$keys[$head]=trim($objWorksheet[$i][$head]);
}
else
{
$excelarray[$i][$keys[$head]]=trim($objWorksheet[$i][$head]);
}
}
}
//echo "<pre>";print_r($excelarray);
for($i=1;$i<$highestrow;$i++)
{
if($excelarray[$i]["name"]!="" || $excelarray[$i]["name"]!="0" || $excelarray[$i]["name"]!=0 )
{
//echo $excelarray[$i]["name"];
if(!empty($excelarray[$i]["name"])){
$campaign = Input::get("selectCampaignField");
if($campaign=="all"){
$campaign="";
$allcampaign=Campaign::where('mtype',"=","company")->orderBy('mkey')->get();
foreach ($allcampaign as $mkeycampaign)
{
$campaign .= $mkeycampaign->mkey.",";
}
$campaign=substr($campaign, 0, -1);
}
$usercampaign=User::where('username','=',trim($excelarray[$i]["name"]));
if($usercampaign->count() > 0){
$usercampaign = $usercampaign->first();
$campaignList =$usercampaign->clients.",".$campaign;
$data=json_decode($usercampaign->data,true);
if(isset($data['hrmsdata']))
{
$hrmsdata=unserialize($data['hrmsdata']);
$hrmsdata['clientsownerlist'] = $campaignList;
$data['hrmsdata']=serialize($hrmsdata);
}else
{
$hrmsdata['clientsownerlist'] = $campaignList;
$data['hrmsdata']=serialize($hrmsdata);
}
$data=json_encode($data);
$usercampaign->updated_at=date("Y-m-d H:i:s");
$usercampaign->clients=$campaignList;
$usercampaign->data=$data;
$usercampaign->save();
}
}
}
}
}
}
if($action == 'bulkupload'){
if($request->hasFile('file')){
include_once(app_path().'/lib/phpexcel/PHPExcel.php');
include(app_path().'/lib/simplexlsx-master/simplexlsx.class.php');
$path = $request->file->getRealPath();
$objSimpleXLSX = SimpleXLSX::parse($path);
$objWorksheet = $objSimpleXLSX->rows();
$highestColumn = count($objWorksheet[0]);
$highestrow=count($objWorksheet);
$dbUsers=DB::table('users')->select('username', 'data')->where('status','=','Active')->get();
$dbCampaigns=DB::table('hrms_masters')->select('mkey')->where('status','=','Active')->get();
$activeUser = array();
$activeCampaign = array();
$activeUserData = array();
foreach ($dbUsers as $key => $dbUser){
$activeUser[] = $dbUser->username;
$activeUserData[$dbUser->username] = $dbUser->data;
}
foreach ($dbCampaigns as $key => $dbCampaign)$activeCampaign[] = $dbCampaign->mkey;
$campaigns = array();
$users = array();
for($row=0;$row<$highestrow;$row++)
{
if($row!=0 && !empty(trim($objWorksheet[$row][0]))){
if(in_array(trim($objWorksheet[$row][0]), $activeCampaign) && in_array(trim($objWorksheet[$row][1]), $activeUser)){
$users[trim($objWorksheet[$row][1])][] = $objWorksheet[$row][0];
}
}
}
foreach ($users as $userName => $campaigns) {
$campaignList = implode(',', $campaigns);
$data=json_decode($activeUserData[$userName],true);
if(isset($data['hrmsdata']))
{
$hrmsdata=unserialize($data['hrmsdata']);
$hrmsdata['clientsownerlist'] = $campaignList;
$data['hrmsdata']=serialize($hrmsdata);
}else
{
$hrmsdata['clientsownerlist'] = $campaignList;
$data['hrmsdata']=serialize($hrmsdata);
}
$data=json_encode($data);
DB::table('users')->where('username', $userName)->update(['clients'=>$campaignList, 'data' => $data]);
}
}
}
// if($action=="createCampaign")
// {
// $this->validate($request,[
// 'campaignName' => 'required|alpha_dash',
// ]);
// $campaignName = Input::get("campaignName");
// if($campaignName != ""){
// Campaign::insert(["mkey"=>$campaignName,"mtype"=>"company"]);
// $data['campaignDetails'] = Campaign::where("mtype","=","company")->where("mkey","=",$campaignName)->first();
// return view("layout.module.campaign.campaign",$data);
// }else{
// return "<script>simpleNotification('error','topRight','Campaign name should not be blank.');</script><br/><p class='text-danger text-center'>Campaign name should not be blank.</p>";
// }
// }
// if($action=="buildForm")
// {
// $rawData = Input::get("rawData");
// $fb = new FormBuilder();
// $output = $fb->buildForm($rawData);
// return $output;
// }
// if($action=="dataUpload")
// {
// return view("layout.module.campaign.campaignTabData");
// }
}
public function show($id)
{
if($id=="show")
{
$gthis = new KHRMSLib();
$campaign = Input::get("campaign");
$mastersdata=$gthis->getCompanyMaster($campaign);
$disposition = array();
if(empty($mastersdata['dialerDispoList']))$mastersdata['dialerDispoList']=$gthis->HRCoreVars['dialerDispoList'];
$dispoarr=explode("~",$mastersdata['dialerDispoList']);
foreach($dispoarr as $dispo)
{
if(!empty($dispo))
{
$dispoprts=explode("|",$dispo);
if(sizeof($dispoprts)>=3)
{
$disposition[$dispoprts[1]] = $dispoprts[2];
$dispositionCode[$dispoprts[1]] = $dispoprts[0];
/*$data.="dialerdispoarray['$dispoprts[1]']='$dispoprts[2]';
dispoClassArray['$dispoprts[0]']='$dispoprts[1]';";*/
}
}
}
$data['disposition'] = $disposition;
$data['dispositionCode'] = $dispositionCode;
$dispositionList=DB::table('hrms_masters')->select('*')->where('status','=','Active')->where("mkey","=",$campaign)->where("mtype","=",'coreconfig')->first();
$dispolist=explode("~",$dispositionList->mvalue);
$dispositionList = array();
foreach ($dispolist as $key => $dispo) {
if(!empty($dispo))
{
$dispoprts=explode("|",$dispo);
$dispositionList[$dispoprts[1]]= $dispoprts[2];
}
}
$data['dispositionList'] = $dispositionList;
//$campaign = Input::get("campaign");
if($campaign != ""){
//this condition for getting all campaign data
if($campaign == "all")
{
$data['campaignDetails']['mkey'] ="All";
$data['dataCountByStatus'] = DB::table("records")->select(DB::Raw('status, count(*) as recordCount'))->groupBy('status')->get();
$data['dataCountByDisposition'] = DB::table("records")->select(DB::Raw('dialer_status, count(*) as recordCount'))->groupBy('dialer_status')->get();
$data['queryLogs'] = DB::table("campaign_query")->get();
// $data['dataList'] = DB::table("records")->select(DB::Raw('list_id, count(*) as recordCount'))->where("client","=",$campaign)->groupBy('list_id')->get();
$userassignedcampign=DB::table('users')->select('username','clients')->whereRaw(' FIND_IN_SET(?,clients)', [$campaign])->get();
return view("layout.module.campaign.campaign",$data,compact('userassignedcampign'));
}else{
$data['campaignDetails'] = Campaign::where("mtype","=","company")->where("mkey","=",$campaign)->first();
$data['dataCountByStatus'] = DB::table("records")->select(DB::Raw('status, count(*) as recordCount'))->where("client","=",$campaign)->groupBy('status')->get();
$data['dataCountByDisposition'] = DB::table("records")->select(DB::Raw('dialer_status, count(*) as recordCount'))->where("client","=",$campaign)->groupBy('dialer_status')->get();
$data['queryLogs'] = DB::table("campaign_query")->where('campaign', '=', $campaign)->get();
// $data['dataList'] = DB::table("records")->select(DB::Raw('list_id, count(*) as recordCount'))->where("client","=",$campaign)->groupBy('list_id')->get();
$userassignedcampign=DB::table('users')->select('username','clients')->whereRaw(' FIND_IN_SET(?,clients)', [$campaign])->get();
//$scheduledCampaign = Campaign::where("mtype","=","company")->where("mkey","=",$campaign)->first();
return view("layout.module.campaign.campaign",$data,compact('userassignedcampign'));
}
}else{
return "<script>simpleNotification('error','topRight','Campaign name should not be blank.');</script><br/><p class='text-danger text-center'>Campaign name should not be blank.</p>";
}
}
if($id=="runquery")
{
$campaign = Input::get("campaign");
$querySelect = Input::get("allvalues");
$queryConditions = Input::get("queryConditions");
if($queryConditions){
$queryConditions = str_replace('&quot;', "'", $queryConditions);
$queryConditions = str_replace('&#039;', "'", $queryConditions);
}else{
$queryConditions = '1';
}
$fields = explode(",", $querySelect);
$i = 1; $output = '';
try {
if($campaign=="All")
{
// $selQuery = "SELECT $querySelect FROM records WHERE $queryConditions LIMIT $queryLimit OFFSET $queryOffset";
$selQuery = "SELECT $querySelect FROM records WHERE $queryConditions";
$sqlQuery = DB::select($selQuery);
}else
{
//$selQuery = "SELECT $querySelect FROM records WHERE client = '$campaign' AND $queryConditions LIMIT $queryLimit OFFSET $queryOffset";
$selQuery = "SELECT $querySelect FROM records WHERE client = '$campaign' AND $queryConditions";
$sqlQuery = DB::select($selQuery);
}
} catch(\Illuminate\Database\QueryException $ex){
$output .= "<p class='text-danger'>".$ex->getMessage()."</p>";
return $output;
}
if(count($sqlQuery)){
$output .='<div><label>'.count($sqlQuery).'</label></div>';
}
return $output;
}
if($id=="savequery")
{
$campaign = Input::get("campaign");
$querySelect = Input::get("allvalues");
$queryConditions = Input::get("queryConditions");
if($queryConditions){
$queryConditions = str_replace('&quot;', "'", $queryConditions);
$queryConditions = str_replace('&#039;', "'", $queryConditions);
}else{
$queryConditions = '1';
}
// $queryInCondition = Input::get("queryInCondition");
// if($queryInCondition != 'null'){
// $queryInCondition = str_replace('&quot;', "'", $queryInCondition);
// $queryInCondition = str_replace('&#039;', "'", $queryInCondition);
// $queryInCondition = "or elegible IN ($queryInCondition)";
// $querySelect .= ',elegible';
// }else{
// $queryInCondition = '';
// }
//$queryLimit = Input::get("queryLimit");
//$queryOffset = Input::get("queryOffset");
//$checkedValue = Input::get("checkedValue");
// print_r($checkedValue);
$fields = explode(",", $querySelect);
$i = 1; $output = '';
try {
if($campaign=="All")
{
// $selQuery = "SELECT $querySelect FROM records WHERE $queryConditions LIMIT $queryLimit OFFSET $queryOffset";
$selQuery = "SELECT $querySelect FROM records WHERE $queryConditions";
$sqlQuery = DB::select($selQuery);
}else
{
//$selQuery = "SELECT $querySelect FROM records WHERE client = '$campaign' AND $queryConditions LIMIT $queryLimit OFFSET $queryOffset";
$selQuery = "SELECT $querySelect FROM records WHERE client = '$campaign' AND $queryConditions";
$sqlQuery = DB::select($selQuery);
}
if($sqlQuery){
$queryExist = DB::table('campaign_query')->where('query','=',$selQuery)->where('campaign', '=', $campaign)->select('id')->first();
if(empty($queryExist))
{
DB::table('campaign_query')->insert(['campaign'=>$campaign, 'query'=>$selQuery, 'select_col'=>$querySelect,'where_cond'=>"client = '$campaign' AND $queryConditions"]);
}else{
$output .="<p class='text-danger'>".'QueryAlreadyExist'."</p></br>";
}
}
} catch(\Illuminate\Database\QueryException $ex){
$output .= "<p class='text-danger'>".$ex->getMessage()."</p>";
return $output;
}
if(count($sqlQuery)){
$output .='<div><label>'.count($sqlQuery).'</label></div>';
}
/*$output .= '<div style="overflow-x:auto;"><table class="table table-bordered"><thead><tr><th class="text-center">#</th>';
foreach ($fields as $key) {
$output .= '<th class="text-center">'.trim($key).'</th>';
}
$output .= "</tr></thed><tbody>";
foreach($sqlQuery as $row){
$output .= '<tr><th class="text-center">'.$i.'</th>';
foreach ($fields as $key) {
$output .= '<td>'.trim($row->$key).'</td>';
}
$output .= "</tr>";
$i++;
}
}else{
$output .= '<h5 class="text-danger"><i class="fa fa-exclamation-circle"></i> No Result!</h5>';
}
$output .= '</tbody></table></div>';*/
return $output;
}
/*if($id="runcount"){
$output = '';
$i = 1;
$campaign = Input::get("campaign");
$id = Input::get("id");
$queryTxt = DB::table('campaign_query')->where('id','=', $id)->select('query','select_col')->first();
$fields = explode(",", $queryTxt->select_col);
$sqlQuery = DB::select($queryTxt->query);
if(count($sqlQuery)){
$output .= '<div style="overflow-x:auto;"><h5>'.count($sqlQuery).'</h5>';
}else{
$output .= '<h5 class="text-danger"><i class="fa fa-exclamation-circle"></i> No Result!</h5>';
}
return $output;
}*/
if($id=="fquery")
{
$output = '';$i = 1;
$campaign = Input::get("campaign");
$id = Input::get("id");
$queryTxt = DB::table('campaign_query')->where('id','=', $id)->select('query','select_col')->first();
$fields = explode(",", $queryTxt->select_col);
$sqlQuery = DB::select($queryTxt->query);
if(count($sqlQuery)){
$output .= '<div style="overflow-x:auto;"><h5>'.count($sqlQuery).'</h5>';
/*foreach ($fields as $key) {
$output .= '<th class="text-center">'.trim($key).'</th>';
}
$output .= "</tr></thed><tbody>";
foreach($sqlQuery as $row){
$output .= '<tr><th class="text-center">'.$i.'</th>';
foreach ($fields as $key) {
$output .= '<td>'.trim($row->$key).'</td>';
}
$output .= "</tr>";
$i++;
}*/
}else{
$output .= '<h5 class="text-danger"><i class="fa fa-exclamation-circle"></i> No Result!</h5>';
}
return $output;
}
if($id=="delete")
{
$id = Input::get("id");
DB::table('campaign_query')->where('id','=', $id)->delete();
return;
}
if($id=="download")
{
$campaign = Input::get("campaign");
$querySelect = Input::get("querySelect");
$queryConditions = Input::get("queryConditions");
if($queryConditions){
$queryConditions = str_replace('&quot;', "'", $queryConditions);
$queryConditions = str_replace('&#039;', "'", $queryConditions);
}else{
$queryConditions = '1';
}
$queryInCondition = Input::get("queryInCondition");
if($queryInCondition != 'null'){
$queryInCondition = str_replace('&quot;', "'", $queryInCondition);
$queryInCondition = str_replace('&#039;', "'", $queryInCondition);
$queryInCondition = "or elegible IN ($queryInCondition)";
$querySelect .= ',elegible';
}else{
$queryInCondition = '';
}
$queryLimit = Input::get("queryLimit");
$queryOffset = Input::get("queryOffset");
try {
if($campaign=="All"){
//$selQuery = "SELECT $querySelect FROM records WHERE $queryConditions LIMIT $queryLimit OFFSET $queryOffset";
$selQuery = "SELECT $querySelect FROM records WHERE $queryConditions $queryInCondition LIMIT $queryLimit OFFSET $queryOffset";
$sqlQuery = DB::select($selQuery);
}else{
$selQuery = "SELECT $querySelect FROM records WHERE client = '$campaign' AND $queryConditions $queryInCondition LIMIT $queryLimit OFFSET $queryOffset";
//$selQuery = "SELECT $querySelect FROM records WHERE client = '$campaign' AND $queryConditions LIMIT $queryLimit OFFSET $queryOffset";
$sqlQuery = DB::select($selQuery);
}
} catch(\Illuminate\Database\QueryException $ex){
$output .= "<p class='text-danger'>".$ex->getMessage()."</p>";
return $output;
}
$data['fieldsarr'] = explode(",", $querySelect);
$data['alist'] = $sqlQuery;
return view("layout.module.campaign.download",$data);
}
if($id=="getDataFormat")
{
return view("layout.module.campaign.campaignTabData");
}
if($id=="addCurrQueue")
{
$campQryId = Input::get("radioValue");
$campaign = Input::get("campaign");
DB::table('campaign_query')->where('id','!=', $campQryId)->where('campaign','=',$campaign)->update(['current_queue'=>'']);
DB::table('campaign_query')->where('id','=', $campQryId)->where('campaign','=',$campaign)->update(['current_queue'=>'selected']);
$queryCond=DB::table('campaign_query')->where('id','=',$campQryId)->where('campaign','=',$campaign)->select('where_cond');
if($queryCond->count() > 0){
$queryCond = $queryCond->first();
DB::update(DB::raw("UPDATE records set filter_condition='1' where $queryCond->where_cond"));
}
return;
//return "<script>simpleNotification('success','topRight','Query Logic Successfully Applied');</script>";
}
if($id=="assigncampaign")
{
$agentsNewArr = array();
$agents = Input::get('agents');
$campaign = Input::get("selectCampaignField");
$agentsArr = explode(",", $agents);
$hrmsdata['clientsownerlist'] = array();
$campaignList="";
if($campaign=="all")
{
$campaign="";
$allcampaign=Campaign::where('mtype',"=","company")->orderBy('mkey')->get();
foreach ($allcampaign as $mkeycampaign)
{
$campaign .= $mkeycampaign->mkey.",";
}
$campaign=substr($campaign, 0, -1);
foreach ($agentsArr as $key => $agent)
{
$usercampaign=DB::table('users')->where('username','=',$agent)->select('clients','data')->first();
$data=json_decode($usercampaign->data,true);
if(isset($data['hrmsdata'])){
$hrmsdata=unserialize($data['hrmsdata']);
$hrmsdata['clientsownerlist'].=",".$campaign;
$data['hrmsdata']=serialize($hrmsdata);
}else{
$hrmsdata['clientsownerlist'] =$campaign;
$data['hrmsdata']=serialize($hrmsdata);
}
$data=json_encode($data);
DB::statement("update users set updated_at='".date("Y-m-d H:i:s")."',clients='$campaign',data='$data' where username='$agent'");
}
}
else
{
foreach ($agentsArr as $key => $agent)
{
$usercampaign=User::where('username','=',$agent)->first();
//$campaignList =$usercampaign->clients.",".$campaign;
$data=json_decode($usercampaign->data,true);
if(isset($data['hrmsdata']))
{
$hrmsdata=unserialize($data['hrmsdata']);
if($usercampaign->clients==$hrmsdata['clientsownerlist']){
$campaignList =$usercampaign->clients.",".$campaign;
// print_r($hrmsdata['clientsownerlist']);
// $hrmsdata['clientsownerlist'] = $campaignList;
}else{
//print_r($hrmsdata['clientsownerlist']);
$campaignList = $hrmsdata['clientsownerlist'].",".$campaign;
//$hrmsdata['clientsownerlist'] = $hrmsdata['clientsownerlist'].",".$campaign;
}
$hrmsdata['clientsownerlist'] = $campaignList;
//print_r($hrmsdata['clientsownerlist']);
$data['hrmsdata']=serialize($hrmsdata);
//print_r($data['hrmsdata']);
//exit();
}else
{
//exit();
$campaignList =$usercampaign->clients.",".$campaign;
$hrmsdata['clientsownerlist'] = $campaignList;
$data['hrmsdata']=serialize($hrmsdata);
//print_r($data['hrmsdata']);
}
$data=json_encode($data);
//print_r($data);
$usercampaign->updated_at=date("Y-m-d H:i:s");
$usercampaign->clients=$campaignList;
$usercampaign->data=$data;
$usercampaign->save();
//DB::statement("update users set updated_at='".date("Y-m-d H:i:s")."',clients='$campaign1',data='$data' where username='$agent'");
}
}
return;
}
if($id=="removecampaign")
{
$agentsNewArr = array();
$agents = Input::get('agents');
$campaign = Input::get("selectCampaignField");
$agentsArr = explode(",", $agents);
$hrmsdata['clientsownerlist'] = array();
$campaignList="";
if($campaign)
{
$usercampaignall=User::where('clients','like','%'.$campaign.'%')->pluck('username')->toArray();
$removeagentsArr=array();
if ($usercampaignall)
{
$removeagentsArr=array_diff($usercampaignall,$agentsArr);
}
foreach ($removeagentsArr as $key => $agent)
{
$usercampaign=DB::table('users')->where('username','=',$agent)->select('clients','data')->first();
$data=json_decode($usercampaign->data,true);
$clients=$usercampaign->clients;
if($clients)
{
$clients_arr=explode(",",$clients);
$update_campaign[]=$campaign;
$update_clients=array_diff($clients_arr, $update_campaign);
$finalcampaign= implode(",",$update_clients);
}
if(isset($data['hrmsdata']))
{
$hrmsdata=unserialize($data['hrmsdata']);
//print_r($hrmsdata);
$hrms_arr=explode(",", $hrmsdata['clientsownerlist']);
$update_campaign[]=$campaign;
$update_hrms=array_diff($hrms_arr, $update_campaign);
$hrmsdata['clientsownerlist']= implode(",",$update_hrms);
$final = implode(",",$update_hrms);
// print_r($hrmsdata['clientsownerlist']);
$data['hrmsdata']=serialize($hrmsdata);
$data=json_encode($data);
}
$usercampaign1=User::where('username','=',$agent)->first();
$usercampaign1->updated_at=date("Y-m-d H:i:s");
$usercampaign1->clients=$finalcampaign;
$usercampaign1->data=$data;
$usercampaign1->save();
//DB::statement("update users set updated_at='".date("Y-m-d H:i:s")."',clients='$finalcampaign',data='$data' where username='$agent'");
}
}
return;
}
if($id=="schedulecampaign"){
$campaign = Input::get("selectCampaignField");
$starttime = Input::get("starttime");
$endtime = Input::get("endtime");
//return view("layout.module.outputreport.supervisorreport", $data);
/*$updateschedule = Campaign::where("mtype","=","company")->where("mkey","=",$campaign)->first();
$updateschedule->campaignstartdate=$starttime;
$updateschedule->campaignenddate=$endtime;
$updateschedule->save();*/
/* $scheduledCampaign = Campaign::where("mtype","=","company")->where("mkey","=",$campaign)->get();
$data['scheduledCampaign']=$scheduledCampaign;
return view("layout/module/campaign/campaignScheduler",$data);*/
DB::statement("update hrms_masters set campaignstartdate='$starttime:00',campaignenddate='$endtime:00' where mkey='$campaign' and mtype='company'");
}
if($id=="bulkupload"){
return view("layout.module.campaign.bulkupload");
}
if($id=='deleteAssignDisposition'){
$wakka = new KHRMSLib();
$campaign = Input::get("selectCampaignField");
$disposition = Input::get("disposition");
echo $disposition;
$hrmsdata = DB::table('hrms_masters')->where('mkey','=', $campaign)->where('mtype','=', 'coreconfig')->select('*');
if($hrmsdata->count() > 0){
$hrmsdata = $hrmsdata->first();
$dispolist=explode("~",$hrmsdata->mvalue);
$dispositionList = array();
$mvalue = '';
foreach ($dispolist as $key => $dispo) {
if(!empty($dispo))
{
$dispoprts=explode("|",$dispo);
if($dispoprts[1] != $disposition){
if(empty($mvalue)){
$mvalue .= "$dispo";
}else{
$mvalue .= "~$dispo";
}
}
}
}
//echo $mvalue;
$wakka->Query("update hrms_masters set mvalue='$mvalue' where mkey='$campaign' and mtype='coreconfig';");
}
}
if($id=="assigndisposition"){
$wakka = new KHRMSLib();
$code = Input::get('code');
$disposition = Input::get('disposition');
$subDisposition = Input::get('subDisposition');
$campaign = Input::get("selectCampaignField");
$hrmsdata = DB::table('hrms_masters')->where('mkey','=', $campaign)->where('mtype','=', 'coreconfig')->select('*');
if($hrmsdata->count() == 0){
$mvalue = "$code|$disposition|$subDisposition";
DB::table('hrms_masters')->insert(['mkey'=>$campaign, 'mtype'=>'coreconfig', 'mvalue'=>$mvalue,'status'=>'active']);
}else{
$hrmsdata = $hrmsdata->first();
if(!empty($hrmsdata->mvalue)){
$dispolist=explode("~",$hrmsdata->mvalue);
$dispositionList = array();
$mvalue = '';
foreach ($dispolist as $key => $dispo) {
if(!empty($dispo))
{
$dispoprts=explode("|",$dispo);
if($dispoprts[1] == $disposition){
$mvalue = $hrmsdata->mvalue;
$mvalue = str_replace($dispoprts[2], $subDisposition, $mvalue);
}
}
}
if(empty($mvalue)){
$mvalue .= $hrmsdata->mvalue."~$code|$disposition|$subDisposition";
}
}else{
$mvalue = "$code|$disposition|$subDisposition";
}
$wakka->Query("update hrms_masters set mvalue='$mvalue' where mkey='$campaign' and mtype='coreconfig';");
}
}
if($id == "sampleDataExcel"){
/*$objPHPExcel = new \PHPExcel();
$objPHPExcel->getProperties()
->setCreator("Temporaris")
->setLastModifiedBy("Temporaris")
->setTitle("Template Relevé des heures intérimaires")
->setSubject("Template excel")
->setDescription("Template excel permettant la création d'un ou plusieurs relevés d'heures")
->setKeywords("Template excel");
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->SetCellValue('A1', "12");
$writer = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="excel.xls"');
header('Cache-Control: max-age=0');
$writer->save('php://output');
return ;*/
return view("layout.module.campaign.sampleDataExcel");
}
return;
}
public function edit($id)
{
}
public function update($id)
{
}
public function destroy($id)
{
}
}
......@@ -10,6 +10,9 @@ use Response;
use App\Models\User;
use SimpleXLSX;
use App\Jobs\KHRMSLib;
use App\Models\Disposition;
use App\Models\SubDisposition;
use App\Models\DispositionPlan;
class CampaignController extends Controller {
......@@ -64,13 +67,6 @@ class CampaignController extends Controller {
$highestColumn = count($objWorksheet[0]);
$highestrow=count($objWorksheet);
//echo "<pre>";print_r($objWorksheet);
//echo "\n";
//print_r($highestColumn);
//echo "\n";
//echo $highestrow;
for($i=0;$i<$highestrow;$i++)
{//echo $i;
$excelarray[$i]=array();
......@@ -88,8 +84,6 @@ class CampaignController extends Controller {
}
}
//echo "<pre>";print_r($excelarray);
for($i=1;$i<$highestrow;$i++)
{
if($excelarray[$i]["name"]!="" || $excelarray[$i]["name"]!="0" || $excelarray[$i]["name"]!=0 )
......@@ -129,13 +123,21 @@ class CampaignController extends Controller {
$usercampaign->clients=$campaignList;
$usercampaign->data=$data;
$usercampaign->save();
}
}else{
$discardedData[] = $excelarray[$i]["name"];
}
}
}
}
// download discarded data
}
}
......@@ -237,41 +239,26 @@ class CampaignController extends Controller {
$gthis = new KHRMSLib();
$campaign = Input::get("campaign");
$mastersdata=$gthis->getCompanyMaster($campaign);
$disposition = array();
if(empty($mastersdata['dialerDispoList']))$mastersdata['dialerDispoList']=$gthis->HRCoreVars['dialerDispoList'];
$dispoarr=explode("~",$mastersdata['dialerDispoList']);
foreach($dispoarr as $dispo)
{
if(!empty($dispo))
{
$dispoprts=explode("|",$dispo);
if(sizeof($dispoprts)>=3)
{
$disposition[$dispoprts[1]] = $dispoprts[2];
$dispositionCode[$dispoprts[1]] = $dispoprts[0];
/*$data.="dialerdispoarray['$dispoprts[1]']='$dispoprts[2]';
dispoClassArray['$dispoprts[0]']='$dispoprts[1]';";*/
}
}
}
$data['disposition'] = $disposition;
$data['dispositionCode'] = $dispositionCode;
$dispositionPlans=DispositionPlan::where("status","=","active")->get();
$data['dispositionPlans'] = $dispositionPlans;
$dispositionList=DB::table('hrms_masters')->select('*')->where('status','=','Active')->where("mkey","=",$campaign)->where("mtype","=",'coreconfig')->first();
$data['selectedDispositionPlan'] = DB::table('campaign_disposition_plan')
->join('disposition_plan', 'campaign_disposition_plan.dispo_plan_id', '=', 'disposition_plan.id')
//->select('disposition_plan.name as name ', 'disposition_plan.id as planid')->where("campaign","=",$campaign)->first();
->select('disposition_plan.name as name ', 'disposition_plan.id as planid')
->where("campaign","=",$campaign)
->where("disposition_plan.status","active")
->first();
$dispolist=explode("~",$dispositionList->mvalue);
$dispositionList = array();
foreach ($dispolist as $key => $dispo) {
if(!empty($dispo))
{
$dispoprts=explode("|",$dispo);
$dispositionList[$dispoprts[1]]= $dispoprts[2];
}
}
$data['dispositionList'] = DB::table('campaign_disposition_plan')
->join('disposition_plan_config', 'campaign_disposition_plan.dispo_plan_id', '=', 'disposition_plan_config.dispo_plan_id')
->join('disposition_plan', 'disposition_plan.id', '=', 'disposition_plan_config.dispo_plan_id')
->select('disposition_plan_config.disposition as disposition ', 'disposition_plan_config.sub_disposition as subDisposition')
->where("campaign","=",$campaign)
->where("disposition_plan.status","active")
->get();
$data['dispositionList'] = $dispositionList;
//$campaign = Input::get("campaign");
if($campaign != ""){
//this condition for getting all campaign data
......@@ -294,6 +281,7 @@ class CampaignController extends Controller {
// $data['dataList'] = DB::table("records")->select(DB::Raw('list_id, count(*) as recordCount'))->where("client","=",$campaign)->groupBy('list_id')->get();
$userassignedcampign=DB::table('users')->select('username','clients')->whereRaw(' FIND_IN_SET(?,clients)', [$campaign])->get();
//$scheduledCampaign = Campaign::where("mtype","=","company")->where("mkey","=",$campaign)->first();
// $data['pri_details'] = DB::table("pri_details")->where("server_ip","=",env('app_ip'))->get();
return view("layout.module.campaign.campaign",$data,compact('userassignedcampign'));
}
......@@ -320,12 +308,10 @@ class CampaignController extends Controller {
if($campaign=="All")
{
// $selQuery = "SELECT $querySelect FROM records WHERE $queryConditions LIMIT $queryLimit OFFSET $queryOffset";
$selQuery = "SELECT $querySelect FROM records WHERE $queryConditions";
$sqlQuery = DB::select($selQuery);
}else
{
//$selQuery = "SELECT $querySelect FROM records WHERE client = '$campaign' AND $queryConditions LIMIT $queryLimit OFFSET $queryOffset";
$selQuery = "SELECT $querySelect FROM records WHERE client = '$campaign' AND $queryConditions";
$sqlQuery = DB::select($selQuery);
}
......@@ -336,6 +322,8 @@ class CampaignController extends Controller {
if(count($sqlQuery)){
$output .='<div><label>'.count($sqlQuery).'</label></div>';
}else{
$output .="<p class='text-danger'>No result Found.</p>";
}
return $output;
}
......@@ -381,7 +369,7 @@ class CampaignController extends Controller {
$sqlQuery = DB::select($selQuery);
}
if($sqlQuery){
if($selQuery!=''){
$queryExist = DB::table('campaign_query')->where('query','=',$selQuery)->where('campaign', '=', $campaign)->select('id')->first();
......@@ -402,6 +390,8 @@ class CampaignController extends Controller {
if(count($sqlQuery)){
$output .='<div><label>'.count($sqlQuery).'</label></div>';
}else{
$output .="<p class='text-danger'>No result found.</p>";
}
/*$output .= '<div style="overflow-x:auto;"><table class="table table-bordered"><thead><tr><th class="text-center">#</th>';
foreach ($fields as $key) {
......@@ -542,7 +532,7 @@ class CampaignController extends Controller {
$queryCond=DB::table('campaign_query')->where('id','=',$campQryId)->where('campaign','=',$campaign)->select('where_cond');
if($queryCond->count() > 0){
$queryCond = $queryCond->first();
DB::update(DB::raw("UPDATE records set filter_condition='1' where $queryCond->where_cond"));
DB::update(DB::raw("UPDATE records_$campaign set filter_condition='1' where $queryCond->where_cond"));
}
return;
//return "<script>simpleNotification('success','topRight','Query Logic Successfully Applied');</script>";
......@@ -734,9 +724,88 @@ class CampaignController extends Controller {
$wakka->Query("update hrms_masters set mvalue='$mvalue' where mkey='$campaign' and mtype='coreconfig';");
}
}
if($id=="campaignpri"){
$selected = Input::get("select");
$client = Input::get("campaignField");
//echo "selected".$selected;
DB::statement("update hrms_masters set pri_line='$selected' where mkey='$client' and mtype='company'");
}
if($id=="assigndisposition"){
$wakka = new KHRMSLib();
$planId = Input::get('plan');
$campaign = Input::get("selectCampaignField");
$campaignDispositionPlan = DB::table('campaign_disposition_plan')->where('campaign','=', $campaign)->select('*');
if($campaignDispositionPlan->count() > 0){
DB::table('campaign_disposition_plan')->where('campaign','=', $campaign)->update(['dispo_plan_id' => $planId,'updated_at'=>date("Y-m-d H:i:s")]);
}else{
DB::table('campaign_disposition_plan')->insert(['campaign'=>$campaign,'dispo_plan_id'=>$planId, 'created_at'=>date("Y-m-d H:i:s"),'updated_at'=>date("Y-m-d H:i:s")]);
}
$dispositionEntities = DispositionPlan::join('disposition_plan_config', 'disposition_plan.id', '=', 'disposition_plan_config.dispo_plan_id')
->join('disposition', 'disposition.name', '=', 'disposition_plan_config.disposition')
->select('disposition_plan.id as dispositionPlanId', 'disposition_plan.name as name','disposition_plan.status AS status','disposition.code AS code','disposition_plan_config.disposition as disposition','disposition_plan_config.sub_disposition as sub_disposition')
->where('disposition_plan.id','=',$planId)
->where('disposition.status','active')
->get();
if($dispositionEntities->count() > 0){
$mvalue = '';
foreach ($dispositionEntities as $key => $dispositionEntity) {
$code = $dispositionEntity->code;
$disposition = $dispositionEntity->disposition;
$subDisposition = $dispositionEntity->sub_disposition;
if(!empty($mvalue)){
$mvalue = $mvalue."~$code|$disposition|$subDisposition";
}else{
$mvalue = "$code|$disposition|$subDisposition";
}
}
$hrmsdata = DB::table('hrms_masters')->where('mkey','=', $campaign)->where('mtype','=', 'coreconfig')->select('*');
if($hrmsdata->count() == 0){
DB::table('hrms_masters')->insert(['mkey'=>$campaign, 'mtype'=>'coreconfig', 'mvalue'=>$mvalue,'status'=>'active']);
}else{
$wakka->Query("update hrms_masters set mvalue='$mvalue' where mkey='$campaign' and mtype='coreconfig';");
}
}
/*foreach ($plans as $key => $plan) {
$dispositionPlan = Disposition::join('sub_disposition', 'disposition.id', '=', 'sub_disposition.dispo_id')
->select('disposition.id as dispoId', 'disposition.plan AS plan', 'disposition.name as disposition','disposition.code as code','disposition.status AS status',
DB::raw('count(*) as totalSubDispo, sub_disposition.id'),
DB::raw('GROUP_CONCAT(sub_disposition.name) as sunDispoName, sub_disposition.name'))
->where("plan","=",$plan)
->groupBy('sub_disposition.dispo_id')
->get();
if($dispositionPlan->count() > 0){
$dispositionPlan = $dispositionPlan->first();
$code = $dispositionPlan->code;
$disposition = $dispositionPlan->disposition;
$subDisposition = $dispositionPlan->sunDispoName;
$hrmsdata = DB::table('hrms_masters')->where('mkey','=', $campaign)->where('mtype','=', 'coreconfig')->select('*');
if($hrmsdata->count() == 0){
$mvalue = "$code|$disposition|$subDisposition";
DB::table('hrms_masters')->insert(['mkey'=>$campaign, 'mtype'=>'coreconfig', 'mvalue'=>$mvalue,'status'=>'active']);
}else{
$hrmsdata = $hrmsdata->first();
if(!empty($hrmsdata->mvalue)){
$mvalue .= $hrmsdata->mvalue."~$code|$disposition|$subDisposition";
}else{
$mvalue = "$code|$disposition|$subDisposition";
}
$wakka->Query("update hrms_masters set mvalue='$mvalue' where mkey='$campaign' and mtype='coreconfig';");
}
}
}*/
/*$wakka = new KHRMSLib();
$code = Input::get('code');
$disposition = Input::get('disposition');
$subDisposition = Input::get('subDisposition');
......@@ -771,32 +840,40 @@ class CampaignController extends Controller {
$mvalue = "$code|$disposition|$subDisposition";
}
$wakka->Query("update hrms_masters set mvalue='$mvalue' where mkey='$campaign' and mtype='coreconfig';");
}
}*/
}
if($id == "sampleDataExcel"){
/*$objPHPExcel = new \PHPExcel();
$objPHPExcel->getProperties()
->setCreator("Temporaris")
->setLastModifiedBy("Temporaris")
->setTitle("Template Relevé des heures intérimaires")
->setSubject("Template excel")
->setDescription("Template excel permettant la création d'un ou plusieurs relevés d'heures")
->setKeywords("Template excel");
/*include_once(app_path().'/lib/phpexcel/PHPExcel.php');
$objPHPExcel = new \PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->SetCellValue('A1', "12");
$objPHPExcel->getActiveSheet()->SetCellValue('A1', "campaign");
$objPHPExcel->getActiveSheet()->SetCellValue('A2', "C1");
$objPHPExcel->getActiveSheet()->SetCellValue('A3', "C1");
$objPHPExcel->getActiveSheet()->SetCellValue('A4', "C2");
$objPHPExcel->getActiveSheet()->SetCellValue('A5', "C2");
$objPHPExcel->getActiveSheet()->SetCellValue('B1', "name");
$objPHPExcel->getActiveSheet()->SetCellValue('B2', "U1");
$objPHPExcel->getActiveSheet()->SetCellValue('B3', "U2");
$objPHPExcel->getActiveSheet()->SetCellValue('B4', "U1");
$objPHPExcel->getActiveSheet()->SetCellValue('B5', "U3");
$writer = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="excel.xls"');
header('Content-Disposition: attachment;filename="campaignUserMappingExcelFormat.xls"');
header('Cache-Control: max-age=0');
$writer->save('php://output');
$writer->save('php://output');*/
return ;*/
//$filepath = "assets/extras/campaignUserMappingFormat.xlsx";
$action = Input::get('action');
return view("layout.module.campaign.sampleDataExcel");
if($action == 'upload'){
$filepath = "assets/extras/MultipleUserCampaignUploadFormat.xlsx";
}else if($action == 'bulkupload'){
$filepath = "assets/extras/MultipleUserMultipleCampaignUploadFormat.xlsx";
}
return Response::download($filepath);
}
return;
......
......@@ -77,7 +77,7 @@ class DialModeController extends Controller {
$data['client'] = $client;
$data['username'] = $username;
$data['callingmodeArr'] = array("Progressive", "Manual", "Incoming", "Predictive");
return view('layout.module.dialmode.index',$data);
}
......
......@@ -12,6 +12,7 @@ use App\Models\CRMCallArchive;
use App\Models\CRM;
use App\Models\CRMCampaign;
use App\Models\CRMList;
use App\Models\Cutoff;
use App\Jobs\KHRMSLib;
use App\Models\Sipid;
use App\Models\Dialline;
......@@ -149,23 +150,30 @@ class DialerController extends Controller {
$oclientlst=$wakka->clientsReadAccess();
//print_r($oclientlst);
if(!empty($oclientlst))foreach($oclientlst as $tclnt)if($tclnt!=""){$roclientstr[]="'$tclnt'";}
if(!empty($roclientstr))$roclientstr="and client in (".implode(",",$roclientstr).")";else $roclientstr="";
$users=array();$searchresult="";
if(!empty($kstychCall["previewcrmid"]))$users=$wakka->getPersons("id='".$kstychCall["previewcrmid"]."' $roclientstr limit 1");
else $users=$this->getCallSequencing(1);
$client=Input::get("client");
if($client==''||$client==undefined){
$client="";
}
//$client=$this->campaignlist($client);
if(!empty($kstychCall["previewcrmid"])){
$users=$wakka->getPersons("id='".$kstychCall["previewcrmid"]."' limit 1",$client);}
else{
$users=$this->getCallSequencing(1);
}
//$wakka->setPersonKey($users[0]['id'],"status","Incall");
if($users[0]['id']>0){
Log::info("1----".$users[0]['id']);
DB::table('records')->where('id',$users[0]['id'])->update(['filter_condition'=>'2','modified'=>date("Y-m-d H:i:s")]);
if($client!=''){
DB::table('records_'.$client)->where('id',$users[0]['id'])->update(['filter_condition'=>'2','modified'=>date("Y-m-d H:i:s")]);
}
}
if(!empty($users))
{
$searchresult.="<div id=divworking></div><div style='clear:both'></div><script>kSetDData('C','previewcrmid','".$users[0]['id']."');showRecruit(\"".$users[0]['id']."\");</script>";
$searchresult.="<div id=internalid_matchlist></div><script>
doAjax('record?action=quicksearch','maintextsearch_1_txt=".$users[0]['clientinternalid']."&maintextsearch_1_span=InternalID','internalid_matchlist','searchMutex', 'searchxhr','POST',function(retstr){
doAjax('record?action=quicksearch','maintextsearch_1_txt=".$users[0]['clientinternalid']."&maintextsearch_1_span=InternalID&client=$client','internalid_matchlist','searchMutex', 'searchxhr','POST',function(retstr){
if(retstr.responseText.indexOf('No Records Found!')>-1)$('#internalid_matchlist').html('');
});
</script>";
......@@ -187,7 +195,13 @@ class DialerController extends Controller {
$oclientlst=$wakka->clientsReadAccess();
if(!empty($oclientlst))foreach($oclientlst as $tclnt)if($tclnt!=""){$roclientstr[]="'$tclnt'";}
if(!empty($roclientstr))$roclientstr="and client in (".implode(",",$roclientstr).")";else $roclientstr="";
//Log::info("newcall-->> ".$roclientstr);
$client=Input::get("client");
if($client==''||$client==undefined){
$client='';
}
//$client=$this->campaignlist($client);
$users=array();$callnumber=$kstychCall['callnumber'];
if($kstychCall['crmid'])
{
......@@ -213,7 +227,7 @@ class DialerController extends Controller {
altphone7 like '%".substr($callnumber,-10)."' OR
altphone8 like '%".substr($callnumber,-10)."' OR
altphone9 like '%".substr($callnumber,-10)."' OR
altphone10 like '%".substr($callnumber,-10)."') and id=$crmid $roclientstr ");
altphone10 like '%".substr($callnumber,-10)."') and id=$crmid ",$client);
}
......@@ -229,7 +243,7 @@ class DialerController extends Controller {
altphone7 like '%".substr($callnumber,-10)."' OR
altphone8 like '%".substr($callnumber,-10)."' OR
altphone9 like '%".substr($callnumber,-10)."' OR
altphone10 like '%".substr($callnumber,-10)."' $roclientstr");
altphone10 like '%".substr($callnumber,-10)."'",$client);
}
......@@ -246,7 +260,7 @@ class DialerController extends Controller {
altphone7 like '%$callnumber' OR
altphone8 like '%$callnumber' OR
altphone9 like '%$callnumber' OR
altphone10 like '%$callnumber' ) and id in ($idstr) $roclientstr");
altphone10 like '%$callnumber' ) and id in ($idstr)",$client);
if(!$users)
{
......@@ -256,8 +270,8 @@ class DialerController extends Controller {
if($kstychDialer['mDialerState']=="DialNext"||$kstychDialer['mDialerState']=="Progressive")
{
if($kstychCall['crmid']!="")$users=$wakka->getPersons("id='".$kstychCall['crmid']."' $roclientstr limit 1");
else if($kstychCall['callnumber']!="")$users=$wakka->getPersons("mobile='".$kstychCall['callnumber']."' $roclientstr limit 1");
if($kstychCall['crmid']!="")$users=$wakka->getPersons("id='".$kstychCall['crmid']."' limit 1",$client);
else if($kstychCall['callnumber']!="")$users=$wakka->getPersons("mobile='".$kstychCall['callnumber']."' $roclientstr limit 1",$client);
else $users=$this->getCallSequencing(1);
}
......@@ -275,7 +289,7 @@ class DialerController extends Controller {
if($kstychDialer['mDialerState']=="Manual"){
if(!is_numeric($callnumber) || strlen($callnumber)<6){
return Response::make("<script>simpleNotification('error','topRight','Please enter a valid phone number');</script>");
return Response::make("<simpleNotification('error','topRight','Please enter a valid phone number');</script>");
}
}
......@@ -296,14 +310,57 @@ class DialerController extends Controller {
$calleridarr=explode(":",$callerid);$dspan="1";
if(isset($calleridarr[1])){$callerid=$calleridarr[0];$dspan=$calleridarr[1];}
/*$calleridarr=explode(":",env("non_open"));
$callerid=$calleridarr[0];
$dspan =$calleridarr[1];
}*/
//see if user is online on this sipid
$sipid=Sipid::find($kstychDialer['phone']);
if($sipid&&$sipid->user==Auth::user()->id&&$sipid->status==1)
{
//echo $client."--".$ppldata['client'];
if($client=='')$client=$ppldata['client'];
$dialline=Dialline::where("status","=","Free")->where("enabled","=","1")->where("server","=",env("app_ip"));
if($dspan!="")$dialline=$dialline->where('dspan','=',$dspan);
$master=DB::table('hrms_masters')->select('pri_line')->where('mkey','=',$client)->where('mtype','=','company')->first();
//echo $ppldata['client'];
$diallineenabled=DB::table('diallines')->distinct('dspan')->where('enabled','=','1')->where("server","=",env("app_ip"))->groupBy('dspan')->get();
$count=0;
foreach($diallineenabled as $diallines){
$count++;
}
$callerid="";
if($master->pri_line!=''){
if($count>2){
if($master->pri_line=='open'){
$dialline->where('dspan','>=','3');
}else if($master->pri_line=='non-open'){
$dialline->where('dspan','<=','2');
}
}else if($count<3){
//echo $count;
//echo $master->pri_line;
if($master->pri_line=='open'){
$dialline->where('dspan','=','2');
$callerid=env("openline");
}else if($master->pri_line=='non-open'){
$dialline->where('dspan','=','1');
$callerid=env("140line");
}
}
}else{
return Response::make("<script>simpleNotification('error','topRight','No PRI Lines Selected Please Contact to Your Admin!');</script>");
/*$callerid="";if(!empty($mastersdata["DialerDID"]))$callerid=$mastersdata["DialerDID"];
if($callerid=="")$callerid=Auth::user()->exten;
$dspan="1";
$calleridarr=explode(":",$callerid);
if(isset($calleridarr[1])){$callerid=$calleridarr[0];$dspan=$calleridarr[1];
}
if($dspan!="")$dialline->where('dspan','=',$dspan);*/
}
//if($dspan!="")$dialline=$dialline->where('dspan','=',$dspan);
$dialline=$dialline->orderBy('updated_at','ASC')->first();
if($dialline)
......@@ -339,12 +396,15 @@ class DialerController extends Controller {
$crmcall->data=json_encode($tdata);
$crmcall->save();
if($users[0]['id']>0){
DB::table('records')->where('id',$users[0]['id'])->update(['filter_condition'=>'3','usr_id'=>Auth::user()->id]);
if($client!='')$records='records_'.$client;else $records='records';
DB::table($records)->where('id',$users[0]['id'])->update(['filter_condition'=>'3','usr_id'=>Auth::user()->id]);
DB::table('records')->where('id',$users[0]['id'])->update(['usr_id'=>Auth::user()->id]);
}
//start actual calls
$ppldata['dialer_lastcall']=date("Y-m-d H:i:s");
$preppldata['peopledata'] = serialize($ppldata);
$wakka->setPerson($ppldata['peopledata']['id'],$preppldata);
$wakka->setPerson($ppldata['peopledata']['id'],$preppldata,$client); $wakka->setPerson($ppldata['peopledata']['id'],$preppldata,"");
$newqueue=new Kqueue();
$newqueue->userToConf($sipid);
......@@ -357,7 +417,7 @@ class DialerController extends Controller {
$searchresult.="<div id=internalid_matchlist></div><script>
doAjax('record?action=quicksearch','maintextsearch_1_txt=".$users[0]['clientinternalid']."&maintextsearch_1_span=InternalID','internalid_matchlist','searchMutex', 'searchxhr','POST',function(retstr){
doAjax('record?action=quicksearch','maintextsearch_1_txt=".$users[0]['clientinternalid']."&maintextsearch_1_span=InternalID&client=$client','internalid_matchlist','searchMutex', 'searchxhr','POST',function(retstr){
if(retstr.responseText.indexOf('No Records Found!')>-1)$('#internalid_matchlist').html('');
});
</script>";
......@@ -377,7 +437,8 @@ class DialerController extends Controller {
}
else
{
$wakka->setPersonKey($users[0]['id'],"status","NoNumber");
$wakka->setPersonKey($users[0]['id'],"status","NoNumber","",$client);
$wakka->setPersonKey($users[0]['id'],"status","NoNumber","","");
return Response::make($searchresult."<script>kstychCall['crmid']=0;kSetDData('C','previewcrmid','');simpleNotification('error','topRight','No Number in Record!');</script>");
}
......@@ -470,9 +531,118 @@ if($action=="addconfcall")
return Response::make($retstr);
}
if($action=="transfercall")
{
$retstr="";
$callnumber=Input::get("confnumber");
$callerid="";
//see if user is online on this sipid
$sipid=Sipid::find($kstychDialer['phone']);
if($sipid&&$sipid->user==Auth::user()->id&&$sipid->status==1)
{
$oldcrmcall=CRMCall::find($kstychCall['callid']);
if($oldcrmcall)
{
$olddialline=Dialline::find($oldcrmcall->dialline_id);
$dspan="1";if($olddialline)$dspan=$olddialline->dspan;
// $dialline=Dialline::where("status","=","Free")->where("enabled","=","1");
// if($dspan!="")$dialline=$dialline->where('dspan','=',$dspan);
// $dialline=$dialline->orderBy('updated_at','ASC')->first();
if($olddialline)
{
$callerid=$oldcrmcall->did;
// $dialline->status="transfer";
// $dialline->channel=$olddialline->channel;
// $dialline->save();
$nowts=microtime(true)*1000;
//start the call log
$crmcall=new CRMCall();
$crmcall->number=$callnumber;
$crmcall->user_id=Auth::user()->id;
$crmcall->sipid_id=$sipid->id;
$crmcall->crm_id=$oldcrmcall->crm_id;
$crmcall->client=$oldcrmcall->client;
$crmcall->department=$oldcrmcall->department;
$crmcall->state='New';
$crmcall->userstatus='Transfer';
$crmcall->usersubstatus='Transfer';
$crmcall->type='Transfer';
//$crmcall->dialline_id=$dialline->id;
$crmcall->setTs('ts_Wait',$nowts);
$crmcall->setTs('ts_Call',$nowts);
$crmcall->did=$callerid;
$tdata=array();
$crmcall->data=json_encode($tdata);
$crmcall->save();
$newqueue=new Kqueue();
$newqueue->transferCall($sipid,$callnumber,$callerid,$crmcall,$olddialline);
//start actual calls
// $newqueue=new Kqueue();
// $newqueue->userToConf($sipid);
// $newqueue=new Kqueue();
// $newqueue->custToConf($sipid,$callnumber,$callerid,$crmcall,$dialline);
$retstr=$crmcall->id;
}
else
{
$retstr="Error : No Lines Free to Dial!";
}
}
else
{
$retstr="Error : No calls to conference found!";
}
}
else
{
$retstr="Error : You Are Not Connected!";
}
return Response::make($retstr);
}
if($action=="hangupall")
{
$res=0;
$aUser = Auth::user();
If($aUser->current_dialmode == "Predictive"){
$avgTimeArr = array();
$user_id = $aUser->id;
$campaign = $aUser->sel_campaign;
$avgTimeArr = $this->getAvgTimeArray($campaign, $user_id);
$cutOffUsrArr = Cutoff::where('user_id', '=', $user_id)->where('c_name', '=', $campaign)->get();
if(count($cutOffUsrArr)){
Cutoff::where('user_id', '=', $user_id)->where('c_name', '=', $campaign)->update(
['hangup_time' => date('Y-m-d H:i:s'),
'avg_dispo' => $avgTimeArr['avgdisposec']
]);
}
else
{
$cutoff = new Cutoff();
$cutoff->user_id = $user_id;
$cutoff->c_name = $campaign;
$cutoff->hangup_time = date('Y-m-d H:i:s');
$cutoff->avg_dispo = $avgTimeArr['avgdisposec'];
$cutoff->avg_ring = 0;
$cutoff->save();
}
}
$callid=intval($kstychCall['callid'])+0;
$crmcall=CRMCall::find($callid);
if($crmcall&&$crmcall->user_id==Auth::user()->id)
......@@ -545,12 +715,18 @@ if($action=="closecall")
{
$kstychCall["usercallback"]=date("Y-m-d H:i:s",strtotime($kstychCall["usercallback"].":00")+((Auth::user()->timezone)*60));
}
if($kstychCall["userappointment"]!="")
{
$kstychCall["userappointment"]=date("Y-m-d H:i:s",strtotime($kstychCall["userappointment"].":00")+((Auth::user()->timezone)*60));
}
$crmcall->setTs('ts_Close',$nowts);
$crmcall->userstatus =$kstychCall["userstatus"];
$crmcall->usersubstatus =$kstychCall["usersubstatus"];
$crmcall->usercallback =$kstychCall["usercallback"];
$crmcall->userappointmentdate =$kstychCall["userappointment"];
//$user['peopledata']["dialer_appointment"]=$kstychCall["userappointment"];
//$kstychCall["attempt"]='';
$crmcall->attempt = isset($kstychCall["attempt"]) ? $kstychCall["attempt"] : ' ';
$crmcall->call_flag="Z";
......@@ -568,7 +744,8 @@ if($action=="closecall")
{
$crmcall->crm_id=$kstychCall["crmid"];
$temparr=$wakka->getPerson($crmcall->crm_id);
$temparr=$wakka->getPerson($crmcall->crm_id,$crmcall->client);
if(isset($temparr)&&isset($temparr['peopledata'])&&isset($temparr['peopledata']['client']))$crmcall->client=$temparr['peopledata']['client'];
}
}
......@@ -618,12 +795,14 @@ if($action=="closecall")
$tcrmcall->save();
DB::table('records')->where('id',$crmcall->crm_id)->update(['filter_condition'=>'4']);
DB::table('records_'.$crmcall->client)->where('id',$crmcall->crm_id)->update(['filter_condition'=>'4']);
$tuser=$wakka->getPerson($tcrmid,$crmcall->client);
$tuser=$wakka->getPerson($tcrmid);
$tuser['peopledata']["dialer_status"]=$kstychCall["userstatus"];
$tuser['peopledata']["dialer_substatus"]=$kstychCall["usersubstatus"];
$tuser['peopledata']["dialer_callback"]=$kstychCall["usercallback"];
$tuser['peopledata']["dialer_appointment"]=$kstychCall["userappointment"];
$tuser['peopledata']["dialer_remarks"]=str_replace("'","",$kstychCall["userremarks"]);
$tuser['peopledata']["dialer_flag"]=$kstychCall["userflag"];
......@@ -643,22 +822,25 @@ if($action=="closecall")
$tuser['supcomntid']=$kstychCall["supcomntid"];
$tuser['peopledata']["dialer_lastcall"]=date("Y-m-d H:i:s");
$wakka->setPerson($tcrmid,$tuser);
$wakka->setPerson($tcrmid,$tuser,$crmcall->client);
$wakka->setPerson($tcrmid,$tuser,"");
}
}
}
}
$user=$wakka->getPerson($crmcall->crm_id);
$user=$wakka->getPerson($crmcall->crm_id,$crmcall->client);
if($user['peopledata']['id']==$crmcall->crm_id)
{
if($crmcall->crm_id>0){
DB::table('records')->where('id',$crmcall->crm_id)->update(['filter_condition'=>'4']);
DB::table('records_'.$crmcall->client)->where('id',$crmcall->crm_id)->update(['filter_condition'=>'4']);
}
$user['peopledata']["dialer_status"]=$kstychCall["userstatus"];
$user['peopledata']["dialer_substatus"]=$kstychCall["usersubstatus"];
$user['peopledata']["dialer_callback"]=$kstychCall["usercallback"];
$user['peopledata']["dialer_appointment"]=$kstychCall["userappointment"];
$user['peopledata']["dialer_remarks"]=str_replace("'","",$kstychCall["userremarks"]);
$user['peopledata']["dialer_flag"]=$kstychCall["userflag"];
......@@ -688,25 +870,29 @@ if($action=="closecall")
$user['agentcomments']=$kstychCall["agentcomments"];
$user['supcomntid']=$kstychCall["supcomntid"];
$wakka->setPerson($crmcall->crm_id,$user);
$wakka->setPerson($crmcall->crm_id,$user,$crmcall->client);
$wakka->setPerson($crmcall->crm_id,$user,"");
//update groupid if this is not groupid TODO move to config
if($user['peopledata']['clientcode']!=$user['peopledata']['clientinternalid'])
{
$tusers=$wakka->getPersons(" clientinternalid='".$user['peopledata']['clientinternalid']."' limit 1");
$tusers=$wakka->getPersons(" clientinternalid='".$user['peopledata']['clientinternalid']."' limit 1",$crmcall->client);
if(!empty($tusers))
{
$tppldata=unserialize($tusers[0]['peopledata']);
if($tppldata['status']=='New' || $tppldata['status']=='Incall')$wakka->setPersonKey($tusers[0]['id'],'status','Called');
if($tppldata['status']=='New' || $tppldata['status']=='Incall'){
$wakka->setPersonKey($tusers[0]['id'],'status','Called',"",$crmcall->client);
$wakka->setPersonKey($tusers[0]['id'],'status','Called',"","");
}
//print_r($tppldata['status']);
//Log::info($tppldata['status']);
//if($tppldata['dialer_status']=='') //TODO Config
{
$wakka->setPersonKey($tusers[0]['id'],'dialer_status',$user['peopledata']["dialer_status"]);
$wakka->setPersonKey($tusers[0]['id'],'dialer_substatus',$user['peopledata']["dialer_substatus"]);
$wakka->setPersonKey($tusers[0]['id'],'dialer_status',$user['peopledata']["dialer_status"],"",$crmcall->client);
$wakka->setPersonKey($tusers[0]['id'],'dialer_status',$user['peopledata']["dialer_status"],"","");
$wakka->setPersonKey($tusers[0]['id'],'dialer_substatus',$user['peopledata']["dialer_substatus"],"",$crmcall->client);
$wakka->setPersonKey($tusers[0]['id'],'dialer_substatus',$user['peopledata']["dialer_substatus"],"","");
}
}
}
......@@ -830,13 +1016,24 @@ if($action=="kCallAction")
if($action=="dialerstate")
{
$ready=0;if($kstychDialer['mDialerState']=="Ready"&&$kstychCall['mCallState']=="Wait")$ready=1;
//$ready=0;if($kstychDialer['mDialerState']=="Ready"&&$kstychCall['mCallState']=="Wait")$ready=1;
$ready=0;$perpareCall=0;
if($kstychDialer['mDialerState']=="Ready"&&$kstychCall['mCallState']=="Wait")
{
$ready=1;
}
if($kstychDialer['mDialerSubState']=="Predictive"&&$kstychCall['mCallState']=="Wait")
{
$perpareCall=1;
}
$nowts=microtime(true)*1000;
$sipid=Sipid::find($kstychDialer['phone']);
if($sipid&&$sipid->user==Auth::user()->id&&$sipid->status==1)
{
$sipid->ready=$ready;
$sipid->prepare_call=$perpareCall;
$sipid->save();
$userlog=UserLog::where('user_id','=',Auth::user()->id)->orderBy("id","DESC")->first();
......@@ -845,6 +1042,71 @@ if($action=="dialerstate")
}
return Response::make("");
}
if($action=="usersel")
{
$user = Auth::user();
$currDialerState = $kstychDialer['mDialerState'];
//$client=Input::get("client");
if($kstychDialer['mDialerSubState'] != "")
$currDialerState = $kstychDialer['mDialerSubState'];
if($client!=""){
DB::table('users')->where('id', Auth::user()->id)->update([
'sel_campaign'=>$client,
'current_dialmode'=>$currDialerState
]);
}else{
DB::table('users')->where('id', Auth::user()->id)->update([
'current_dialmode'=>$currDialerState
]);
}
$campaigndata = Sipid::select("clients")->where("user", $user->id)->where("status", "=", 1)->first();
if($campaigndata)
{
$campdata= json_decode($campaigndata->clients);
if(Auth::user()->id!='1'){
$campdata->sel_campaign=$client;
Sipid::where("user",$user->id)->update(["clients"=>json_encode($campdata)]);
}
}
return Response::make("");
}
if($action=="sipcleanup")
{
$user = Auth::user();
$sipid = Sipid::where("user", $user->id)->select('id')->first();
Sipid::where("user", $user->id)->update([
"user" => 0,
"status" => 0,
"ready" => 0,
"patched" => 0,
"prepare_call" => 0,
"confup" => 0,
"clients" => ""
]);
$diallines = Dialline::where('status', '!=', 'Free')->where('conf', '=', "1000".$sipid->id);
if($diallines){
$diallines=$diallines->get();
foreach ($diallines as $dialline) {
$newqueue=new Kqueue();
$newqueue->hangupChannelS($dialline->channel,$dialline->server);
}
}
if(count($sipid)){
exec('/usr/sbin/asterisk -rx "channel request hangup '.$sipid->id.'"');
exec('/usr/sbin/asterisk -rx "confbridge kick 1000'.$sipid->id.' all"');
}
}
if($action=="spychannel")
{
......@@ -875,11 +1137,14 @@ if($action=="recarchive")
}
public function show($id)
{
//echo "show--->".$id;
//exit();
if($id=="bucketdata")
{
//Log::info("ABCDDD----".Input::get("client"));
$client=Input::get("client","");
$bucket=Input::get("bucket");
$currentstatus=Input::get("currentstatus");
//$currentstatus=Input::get("currentstatus");
$legalstatus=Input::get("legalstatus");
$page=intval(Input::get('page'));if($page<1)$page=1;
$skey=Input::get('skey');
......@@ -931,9 +1196,9 @@ public function show($id)
$birthdate=date('m-d');
$dbres=array();
if($bucket=="CurrentQueue")$dbres=$this->getCallSequencing(20);
else if($bucket=="Priority")$dbres=$wakka->getPersons("priority in (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) $owclientstr ORDER BY FIELD(priority,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1) limit $bs,$bl");
else if($bucket=="TotalData")$dbres=$wakka->getPersons("1=1 and currentstatus='$currentstatus' and legalstatus='$legalstatus' and status!='Noqueue' $owclientstr limit $bs,$bl");
if($bucket=="CurrentQueue")$dbres=$this->getCallSequencing(1);
/*else if($bucket=="Priority")$dbres=$wakka->getPersons("priority in (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) $owclientstr ORDER BY FIELD(priority,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1) limit $bs,$bl");
else if($bucket=="TotalData")//$dbres=$wakka->getPersons("1=1 and currentstatus='$currentstatus' and legalstatus='$legalstatus' and status!='Noqueue' $owclientstr limit $bs,$bl");
else if($bucket=="SearchData")$dbres=$wakka->getPersons("1=1 $roclientstrAll $skey limit $bs,$bl");
else if($bucket=="NotCalled")$dbres=$wakka->getPersons("status='New' and currentstatus='$currentstatus' and legalstatus='$legalstatus' $owclientstr limit $bs,$bl");
else if($bucket=="Called")$dbres=$wakka->getPersons("status='Called' $owclientstr limit $bs,$bl");
......@@ -941,9 +1206,9 @@ public function show($id)
else if($bucket=="Flagged-Called")$dbres=$wakka->getPersons("dialer_flag='VIP' and currentstatus='$currentstatus' and legalstatus='$legalstatus' $owclientstr limit $bs,$bl");
else if($bucket=="Flagged-Notcalled")$dbres=$wakka->getPersons("mf_isa='VIP' and currentstatus='$currentstatus' and legalstatus='$legalstatus' $owclientstr limit $bs,$bl");
else if($bucket=="today-birthday")$dbres=$wakka->getPersons("DATE_FORMAT(DOB,'%m-%d')='$birthdate' and priority='11' $owclientstr limit $bs,$bl");
*/
else if($bucket=="MissedCalls")
{
{/*
$udidlinesstr = array();
foreach($didlinesstr as $didlinestr){
$didlinestrArr=explode(":",$didlinestr);
......@@ -972,8 +1237,6 @@ public function show($id)
if(count($number_list) > 0) {
$lcalls=DB::select("SELECT * FROM crmcalls where id in (SELECT max(id) FROM crmcalls WHERE number IN ('" . implode("','", $number_list). "') GROUP BY number) ORDER BY id DESC");
//$lcalls=DB::select("SELECT * FROM crmcalls where id in (SELECT max(id) FROM crmcalls WHERE number IN ('" . implode("','", $number_list). "') GROUP BY number)");
//$lcalls=$lcalls->orderBy("id","DESC");
foreach($lcalls as $lcall)
{
if($lcall->userstatus=="InboundDROP")
......@@ -1005,7 +1268,7 @@ public function show($id)
}
}
*/ }
else if($bucket=="CallsToday")$dbres=$wakka->getPersons("dialer_lastcall>='".date("Y-m-d 00:00:00",time()+((Auth::user()->timezone)*60))."' $owclientstr limit $bs,$bl");
else if($bucket=="CallsMonth")$dbres=$wakka->getPersons("dialer_lastcall>='".date("Y-m-01 00:00:00",time()+((Auth::user()->timezone)*60))."' $owclientstr limit $bs,$bl");
......@@ -1182,26 +1445,33 @@ public function show($id)
$calllog = DB::table('records')
//->join('crmcalls', 'records.dialer_callback', '=', 'crmcalls.usercallback')
->select('records.customer_name', 'records.cust_id', 'records.mobile', 'records.dialer_callback', 'records.status','records.dialer_lastcall','records.id','records.dialer_status','records.client')
->where("records.dialer_callback", "!=","0000-00-00 00:00:00");
->select('customer_name', 'cust_id', 'mobile', 'dialer_callback', 'status','dialer_lastcall','id','dialer_status','client')
->where("dialer_callback", "!=","0000-00-00 00:00:00");
if($role == 'Supervisor'){
$userName = Auth::user()->username;
$supervisorUsers=$wakka->LoadAll("select id from users where supervisor='$userName';");
$supervisorUsers = implode(",",$supervisorUsers);
$userIds= [];
foreach ($supervisorUsers as $key => $value) $userIds[] = "'".$value['id']."'";
$supervisorUsers = implode(",",$userIds);
//print_r($supervisorUsers);
//$supervisorUsers = implode(",",$supervisorUsers);
print_r($supervisorUsers);
if(!empty($supervisorUsers)){
if($selection == 'all'){
$setClient ='';
$calllog = $calllog = DB::select("select records.customer_name, records.cust_id, records.mobile, records.dialer_callback, records.status,records.dialer_lastcall,records.id,records.dialer_status,records.client from records where usr_id in (".$supervisorUsers.") and records.dialer_callback !='0000-00-00 00:00:00'");
}else{
$setClient = $client;
$calllog = $calllog->where('records.client', '=', $client);
$calllog = $calllog = DB::select("select records.customer_name, records.cust_id, records.mobile, records.dialer_callback, records.status,records.dialer_lastcall,records.id,records.dialer_status,records.client from records where usr_id in (".$supervisorUsers.") and records.dialer_callback !='0000-00-00 00:00:00' and client = '$client'");
//$calllog = $calllog->where('client', '=', $client);
}
//print_r($supervisorUsers);
//$calllog = $calllog = DB::select("select records.customer_name, records.cust_id, records.mobile, records.dialer_callback, records.status,records.dialer_lastcall,records.id,records.dialer_status,records.client from records where usr_id in (".$supervisorUsers.") and records.dialer_callback !='0000-00-00 00:00:00'");
//$calllog = $calllog->whereIn("usr_id",[$supervisorUsers]) ->get();
$calllog = $calllog->whereIn("records.usr_id",[$supervisorUsers])
->get();
$count = count($calllog);
echo $count = count($calllog);
}
}else if($role == 'User'){
......@@ -1209,9 +1479,9 @@ public function show($id)
$setClient ='';
}else{
$setClient = $client;
$calllog = $calllog->where('records.client', '=', $client);
$calllog = $calllog->where('client', '=', $client);
}
$calllog = $calllog->where("records.usr_id",$user)->get();
$calllog = $calllog->where("usr_id",$user)->get();
$count = count($calllog);
}
......@@ -1221,6 +1491,62 @@ public function show($id)
$data['count'] = $count;
return view("layout.module.dialer.followUp",$data);
}
if($id=="loadAppointmentData")
{
$wakka = new KHRMSLib();
$user=Auth::user()->id;
$role = Auth::user()->usertype;
$client = Input::get("client");
$selection = Input::get("selection");
$setClient = '';
$count = 0;
$totalAppointmentCount = DB::table('records')
->select('customer_name', 'cust_id', 'mobile', 'dialer_appointment', 'status','dialer_lastcall','id','dialer_status','client')
->where("dialer_appointment", "!=","0000-00-00 00:00:00")
->where('dialer_appointment','>',date('Y-m-d H:i:s',time()-(7*24*60*60)));
//print_r($totalAppointmentCount);
if($role == 'Supervisor'){
$userName = Auth::user()->username;
$supervisorUsers=$wakka->LoadAll("select id from users where supervisor='$userName';");
$userIds = [];
//print_r($supervisorUsers);
foreach ($supervisorUsers as $key => $value) $userIds[] = "'".$value['id']."'";
$supervisorUsers = implode(",",$userIds);
//echo $supervisorUsers;
if(!empty($supervisorUsers)){
if($selection == 'all'){
$setClient ='';
}else{
$setClient = $client;
$totalAppointmentCount = $totalAppointmentCount->where('client', '=', $client);
}
$totalAppointmentCount = $totalAppointmentCount->whereIn("usr_id",[$supervisorUsers])
->get();
$count = count($totalAppointmentCount);
}
}else if($role == 'User'){
if($selection == 'all'){
$setClient ='';
}else{
$setClient = $client;
$totalAppointmentCount = $totalAppointmentCount->where('client', '=', $client);
}
$totalAppointmentCount = $totalAppointmentCount->where("usr_id",$user)->get();
$count = count($totalAppointmentCount);
}
$data['appointment'] = $totalAppointmentCount;
$data['client'] = $setClient;
$data['count'] = $count;
return view("layout.module.dialer.appointment",$data);
}
if($id=="reports")
{
return view("layout.module.dialer.reports",array());
......@@ -1467,11 +1793,13 @@ public function show($id)
//echo "OK";
}
private function getCallSequencing($limit)
public function getCallSequencing($limit,$client=null)
{
//Log::info("Inside getCall");
$wakka = new KHRMSLib();
$roclientstr=array();$didlinesstr=array();
if($client==null){
if(Auth::user()->exten!="")$didlinesstr[]=Auth::user()->exten;
$oclientlst=$wakka->clientsOwnerRWAccess();
if(!empty($oclientlst))foreach($oclientlst as $tclnt)if($tclnt!="")
......@@ -1485,21 +1813,20 @@ public function show($id)
$mroclientstr = $roclientstr;
$client=Input::get("client");
//print_r($client);
if(!empty($roclientstr))$roclientstr="client='$client'";else $roclientstr="";
// echo $roclientstr."Abc";
$users=array();
if(Auth::user()->usertype!="User"){$tusers=array();return $tusers;}
}else{
$roclientstr="client='$client'";
}
//$client=$this->campaignlist($client);
if($client!='')$records='records_'.$client;else $records='records';
DB::table($records)->where('filter_condition','=','2')->where('modified','<',date('Y-m-d H:i:s',time()-(2*60)))->update(['filter_condition'=>'1']);
DB::table('records')->where('filter_condition','=','2')->where('modified','<',date('Y-m-d H:i:s',time()-(2*60)))->update(['filter_condition'=>'1']);
// $clientDetails=$wakka->getPersonshome("$roclientstr order by dialer_lastcall asc");
//$campaign=DB::table("campaign_query")->where('campaign', '=', $client)->where('current_queue','=','selected')->first();
$tusers=$wakka->getPersonshome("filter_condition IN('0','1','4') and $roclientstr and dialer_callback <'".date('Y-m-d H:i:s',time()+(15*60))."' and usr_id='".Auth::user()->id."' and dialer_substatus='Follow Up' limit 1;");
//if($client!=''){
$tusers=$wakka->getPersonshome("filter_condition IN('0','1','4') and $roclientstr and dialer_callback <'".date('Y-m-d H:i:s',time()+(15*60))."' and usr_id='".Auth::user()->id."' and dialer_substatus='Follow Up' limit 1;",$client);
if(count($tusers)>0){
if($limit>0){
$l=1;
......@@ -1516,7 +1843,9 @@ public function show($id)
$limit=$limit-sizeof($tusers);
}
}
//Log::info("clients-->".$roclientstr);
$campaign=DB::table("campaign_query")->where('campaign', '=', $client)->where('current_queue','=','selected')->first();
//Log::info($campaign);
if($campaign)
{
if(stripos($campaign->where_cond,"order by")===false){
......@@ -1524,9 +1853,7 @@ public function show($id)
}else{
$orderby ="";
}
// echo "campaign1";
//print_r($campaign);
$tusers=$wakka->getPersonshome("filter_condition = '1' and $campaign->where_cond $orderby limit 1;");
$tusers=$wakka->getPersonshome("filter_condition IN ('1','0') and dialer_callback ='0000-00-00 00:00:00' and $campaign->where_cond $orderby limit 1;",$client);
//print_r($tusers);
if(count($tusers)>0){
if($limit>0){
......@@ -1546,14 +1873,11 @@ public function show($id)
$limit=$limit-sizeof($tusers);
}
}else{
// echo "campaign 2";
$condition=$campaign->where_cond;
if(stripos($condition,"order by")!==false){
// $orderby="order by dialer_lastcall asc";
$condition = substr($condition,0,stripos($condition, 'order by'));
}
//$condition = substr($campaign->where_cond,0,stripos($campaign->where_cond, 'order by'));
$tusers=$wakka->getPersonshome("filter_condition=4 and $condition order by dialer_lastcall asc limit 1;");
$tusers=$wakka->getPersonshome("filter_condition=4 and $condition order by dialer_lastcall asc limit 1;",$client);
if($limit>0){
$l=1;
foreach($tusers as $tuser){
......@@ -1570,7 +1894,22 @@ public function show($id)
}
}
}else{
$clientDetails=$wakka->getPersonshome("$roclientstr and filter_condition NOT IN ('2','3') order by dialer_lastcall asc limit 1;");
$tusers=$wakka->getPersonshome("filter_condition NOT IN ('2','3') and status='New' order by dialer_lastcall asc limit 1;",$client);
if($limit>0){
$l=1;
foreach($tusers as $tuser){
if(!isset($users[$tuser['id']])){
$users[$tuser['id']]=$tuser;
$l++;
if($l>$limit)
break;
}
}
$limit=$limit-sizeof($tusers);
}
//print_r($clientDetails);
//print_r($clientDetails);
......@@ -1664,7 +2003,7 @@ public function show($id)
}*/
if($limit>0)
/*if($limit>0)
{
$tusers = array_filter($clientDetails, function($var){
return ($var['dialer_callback']>'2018-09-11 00:00:00'&&strtotime($var['dialer_callback'])<strtotime(date('Y-m-d H:i:s',time()+(15*60)))&&($var['dialer_status']=='Contacted - FollowUp - Specific' || $var['dialer_substatus']=='Followup Call' || $var['dialer_status']=='Service Call - Inbound Follow up' || $var['dialer_status'])=='Productive Call - Sales Follow Up');
......@@ -1682,8 +2021,8 @@ public function show($id)
}
$limit=$limit-sizeof($tusers);
}
for($p=15;$p>0;$p--)
}*/
/*for($p=15;$p>0;$p--)
{
// echo "2";
if($limit>0)
......@@ -1708,8 +2047,8 @@ public function show($id)
$limit=$limit-sizeof($tusers);
}
}
}
if($limit>0)
}*/
/*if($limit>0)
{
$tusers = array_filter($clientDetails, function($var){
return ($var['status']=='New'&&$var['mobile']!='');
......@@ -1727,9 +2066,9 @@ public function show($id)
}
$limit=$limit-sizeof($tusers);
}
}*/
if($limit>0)
/*if($limit>0)
{
$tusers = array_filter($clientDetails, function($var){
//return ($var['status']=='Called'&&($var['dialer_substatus']=='NC - Customer in Meeting' || $var['dialer_substatus']=='NC - Ringing / No response' || $var['dialer_substatus']=='NC - Not Reachable' || $var['dialer_substatus']=='NC - Switched off' || $var['dialer_substatus']=='NC - Third Party' || $var['dialer_status'=='Not Contacted']));
......@@ -1748,7 +2087,7 @@ public function show($id)
}
$limit=$limit-sizeof($tusers);
}
}*/
/*if($limit>0)
{
......@@ -1769,7 +2108,7 @@ public function show($id)
$limit=$limit-sizeof($tusers);
}*/
if($limit>0)
/*if($limit>0)
{
// echo "5";
$tusers = array_filter($clientDetails, function($var){
......@@ -1787,9 +2126,24 @@ public function show($id)
}
$limit=$limit-sizeof($tusers);
}
}*/
}
$tusers=array();foreach($users as $tuser)$tusers[]=$tuser;
// }
return $tusers;
}
public function getAvgTimeArray($campaign, $user)
{
$avgdisposecObj = CRMCall::select(DB::Raw('(avg(disposec))/1000 as avgdisposec'))->where("client", "=", $campaign)->where("user_id", "=", $user)->orderby("id","desc")->limit(50)->where("type","!=","Inbound")->first();
$avgcallsecObj = CRMCall::select(DB::Raw('(avg(callsec))/1000 as avgcallsec'))->where("client", "=", $campaign)->where("user_id", "=", $user)->orderby("id","desc")->limit(50)->where("type","!=","Inbound")->first();
$returnArray['avgdisposec'] = round($avgdisposecObj->avgdisposec);
$returnArray['avgcallsec'] = round($avgdisposecObj->avgcallsec);
return $returnArray;
}
}
......
<?php namespace App\Http\Controllers;
use Auth;
use Input;
use Config;
use Session;
use DB;
use App\Services\FormBuilder;
use Illuminate\Http\Request;
use Response;
use App\Models\Disposition;
use App\Models\SubDisposition;
class DispositionController extends Controller {
public function __construct()
{
$this->middleware('auth');
$this->middleware('module_access');
}
public function index()
{
$data['dispositions']= Disposition::join('sub_disposition', 'disposition.id', '=', 'sub_disposition.dispo_id')
->select('disposition.id as dispoId', 'disposition.name as disposition','disposition.code as code','disposition.status AS status',
DB::raw('count(*) as totalSubDispo, sub_disposition.id'),
DB::raw('GROUP_CONCAT(sub_disposition.name) as sunDispoName, sub_disposition.name'))
->groupBy('sub_disposition.dispo_id')
->get();
return view("layout.module.disposition.index", $data);
}
public function create()
{
return view('layout.module.disposition.create');
}
public function store(Request $request)
{
$action = Input::get("action");
if($action == 'isExists'){
$disposition = Input::get("disposition");
$code = Input::get("code");
$exists=Disposition::where("name","=",$disposition)->orwhere("code","=",$code)->first();
if($exists){
$dispositionId = Input::get("dispoId");
if($dispositionId == $exists->id){
return "false";
}
return "true";
}else{
return "false";
}
}
if($action == 'createDisposition'){
$code = Input::get("code");
$disposition = Input::get("disposition");
$subDisposition = Input::get("subDisposition");
$status = Input::get("status");
$disposition = Disposition::create([
'code' => $code,
'name' => $disposition,
'status' => $status,
'created_at' => date("Y-m-d H:i:s"),
'updated_at' => date("Y-m-d H:i:s")
]);
$dispoId = $disposition->id;
foreach ($subDisposition as $key => $value) {
$subDisposition = SubDisposition::create([
'dispo_id' => $dispoId,
'name' => $value,
'created_at' => date("Y-m-d H:i:s"),
'updated_at' => date("Y-m-d H:i:s")
]);
}
return;
}
if($action == 'updateDisposition'){
$dispoId = Input::get("dispoId");
$code = Input::get("code");
$disposition = Input::get("disposition");
$subDisposition = Input::get("subDisposition");
$status = Input::get("status");
Disposition::where('id', $dispoId)
->update([
'code' => $code,
'name' => $disposition,
'status' => $status]);
SubDisposition::where('dispo_id', $dispoId)->delete();
foreach ($subDisposition as $key => $value) {
$subDisposition = SubDisposition::create([
'dispo_id' => $dispoId,
'name' => $value,
'created_at' => date("Y-m-d H:i:s"),
'updated_at' => date("Y-m-d H:i:s")
]);
}
return;
}
}
public function show($id)
{
}
public function edit($id)
{
$data['disposition']= Disposition::join('sub_disposition', 'disposition.id', '=', 'sub_disposition.dispo_id')
->select('disposition.id AS dispoId', 'disposition.name as disposition','disposition.code as code','disposition.status AS status',
DB::raw('count(*) as totalSubDispo, sub_disposition.id'),
DB::raw('GROUP_CONCAT(sub_disposition.name) as sunDispoName, sub_disposition.name'))
->groupBy('sub_disposition.dispo_id')
->where('disposition.id','=',$id)
->get()->first();
return view('layout.module.disposition.edit',$data);
}
public function update($id)
{
}
public function destroy($id)
{
}
public function dashboard()
{
}
}
<?php namespace App\Http\Controllers;
use Auth;
use Input;
use Config;
use Session;
use DB;
use App\Services\FormBuilder;
use Illuminate\Http\Request;
use Response;
use App\Models\Disposition;
use App\Models\SubDisposition;
use App\Models\DispositionPlan;
use App\Models\DispositionPlanConfig;
class DispositionPlanController extends Controller {
public function __construct()
{
$this->middleware('auth');
$this->middleware('module_access');
}
public function index()
{
$data['dispositionPlan']= DispositionPlan::leftjoin('disposition_plan_config', 'disposition_plan.id', '=', 'disposition_plan_config.dispo_plan_id')
->select('disposition_plan.id as dispositionPlanId', 'disposition_plan.name as name','disposition_plan.status AS status',
DB::raw('count(*) as totalDisposition, disposition_plan_config.id'),
DB::raw('GROUP_CONCAT(disposition_plan_config.disposition) as disposition, disposition_plan_config.disposition'))
->groupBy('disposition_plan_config.dispo_plan_id')
//->where('status','active')
->get();
return view("layout.module.dispositionplan.index", $data);
}
public function create()
{
$data['dispositionEntities'] = Disposition::join('sub_disposition', 'disposition.id', '=', 'sub_disposition.dispo_id')
->select('disposition.id as dispoId', 'disposition.name as disposition','disposition.code as code','disposition.status AS status',
DB::raw('count(*) as totalSubDispo, sub_disposition.id'),
DB::raw('GROUP_CONCAT(sub_disposition.name) as sunDispoName, sub_disposition.name'))
->groupBy('sub_disposition.dispo_id')
->where('status','active')
->get();
return view('layout.module.dispositionplan.create', $data);
}
public function store(Request $request)
{
$action = Input::get("action");
if($action == 'isExists'){
$plan = Input::get("plan");
$exists=DispositionPlan::where("name","=",$plan)->first();
if($exists){
$planId = Input::get("dispositionPlanId");
if($planId == $exists->id){
return "false";
}
return "true";
}else{
return "false";
}
}
if($action == 'createDispositionPlan'){
$plan = Input::get("plan");
$dispositionList = Input::get("disposition");
$subDisposition = Input::get("subDisposition");
$status = Input::get("status");
$dispositionPlan = DispositionPlan::create([
'name' => $plan,
'status' => $status,
'created_at' => date("Y-m-d H:i:s"),
'updated_at' => date("Y-m-d H:i:s")
]);
foreach ($dispositionList as $key => $disposition) {
$dispositionPlanConfig = DispositionPlanConfig::create([
'dispo_plan_id' => $dispositionPlan->id,
'disposition' => $disposition,
'sub_disposition' => implode(",", $subDisposition[$key]),
'created_at' => date("Y-m-d H:i:s"),
'updated_at' => date("Y-m-d H:i:s")
]);
}
return;
}
if($action == 'updateDispositionPlan'){
$dispositionPlanId = Input::get("dispositionPlanId");
$plan = Input::get("plan");
$dispositionList = Input::get("disposition");
$subDisposition = Input::get("subDisposition");
$status = Input::get("status");
DispositionPlan::where('id', $dispositionPlanId)
->update(['name' => $plan,
'status' => $status,
'updated_at' => date("Y-m-d H:i:s")
]);
DispositionPlanConfig::where('dispo_plan_id', $dispositionPlanId)->delete();
foreach ($dispositionList as $key => $disposition) {
$dispositionPlanConfig = DispositionPlanConfig::create([
'dispo_plan_id' => $dispositionPlanId,
'disposition' => $disposition,
'sub_disposition' => implode(",", $subDisposition[$key]),
'created_at' => date("Y-m-d H:i:s"),
'updated_at' => date("Y-m-d H:i:s")
]);
}
return;
}
}
public function show($id)
{
}
public function edit($id)
{
$data['dispositionEntities'] = Disposition::join('sub_disposition', 'disposition.id', '=', 'sub_disposition.dispo_id')
->select('disposition.id as dispoId', 'disposition.name as disposition','disposition.code as code','disposition.status AS status',
DB::raw('count(*) as totalSubDispo, sub_disposition.id'),
DB::raw('GROUP_CONCAT(sub_disposition.name) as sunDispoName, sub_disposition.name'))
->groupBy('sub_disposition.dispo_id')
->where('status','active')
->get();
$data['dispositionPlan']= DispositionPlan::join('disposition_plan_config', 'disposition_plan.id', '=', 'disposition_plan_config.dispo_plan_id')
->select('disposition_plan.id as dispositionPlanId', 'disposition_plan.name as name','disposition_plan.status AS status','disposition_plan_config.disposition as disposition','disposition_plan_config.sub_disposition as sub_disposition')
->where('disposition_plan.id','=',$id)
->get();
return view('layout.module.dispositionplan.edit',$data);
}
public function update($id)
{
}
public function destroy($id)
{
}
public function dashboard()
{
}
}
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Models\Pri;
use Validator;
class PriController extends Controller
{
public function pri(Request $request)
{
// $ab =escapeshellarg(`ls -al`);
// echo "<pre>$ab</pre>";
$output = `ls -al`;
echo "<pre>$output</pre>";
}
}
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use Auth;
use Log;
use DB;
class SmsController extends Controller
{
public $smsUrl = 'https://10.2.55.165:443/servlet/com.aclwireless.pushconnectivity.listeners.TextListener?';
//public $userarray = array("A21568","admin");
public function sendSmsBasedOnSubDisposition($kstychCall)
{
//public $userarray = array("A21568","admin");
//$users = $this->userarray;
//Log::info(Auth::user()->username." ^ ".$users[0]);
//Log::info(in_array(Auth::user()->username , $users));
//if(in_array(Auth::user()->username , $users)){
$msgText = $this->getSmsTemplate($kstychCall);
if( !empty($msgText) ) {
$msgText = $this->fillValuesInTemplate($msgText);
//Log::info($msgText);
$this->sendSmsRequest($kstychCall, $msgText);
}
//}
return;
}
public function sendSmsRequest($kstychCall, $msgText)
{
$url = $this->smsUrl;
//Log::info($kstychCall['callnumber']);
$inputArray = [
'userId'=>'hdfcbalrt',
"pass"=>'hdfcbalrt25',
"appid"=>"hdfcbalrt",
"subappid"=>"hdfcbalrt",
"contenttype"=>"1",
"to"=>$kstychCall['callnumber'],
"from"=>"HDFCBK",
"text"=>$msgText,
"selfid"=>"true",
"alert"=>"1",
"dlrreq"=>"true",
"intflag"=>"false"
];
$query = http_build_query($inputArray);
$url .= $query;
try{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$number=$kstychCall['callnumber'];
$callid=intval($kstychCall['callid'])+0;
$serverip=env(app_ip);
$rmname=Auth::user()->fullname;
$subdispo=$kstychCall["usersubstatus"];
DB::insert(DB::raw("insert into sms_log set server_ip='$serverip',call_id='$callid',rm_name='$rmname',subdispo='$subdispo',number='$number',message='$msgText',response='$response'"));
Log::useFiles(storage_path().'/logs/SMS_Messages_'.date("Y-m-d").'.log');
Log::info('|'.env(app_ip).'|'.date('Y-m-d H:i:s', strtotime('+5 hours 30 minutes')).'|'.Auth::user()->fullname.'|'.$kstychCall['callnumber'].'|"'.$msgText.'"|'.$response.'|');
//Log::info($response);
curl_close($ch);
} catch(Exception $e) {
Log::info($e->getMessage());
}
}
public function getSmsTemplate($kstychCall)
{
$msgText = "";
include( app_path() . '/Constants/SmsTemplate.php');
if( in_array( $kstychCall["usersubstatus"] , $smsContactedSubdispositionsArr) ) {
$msgText = $smsTemplatesArr[SMS_THANKYOU];
} else if( in_array( $kstychCall["usersubstatus"] , $smsNotContactedSubdispositionsArr) ) {
$msgText = $smsTemplatesArr[SMS_NOTCONTACTED];
}
return $msgText;
}
public function fillValuesInTemplate($msgText)
{
if( !empty($msgText) )
{
$msgText = str_replace("#name#", Auth::user()->fullname, $msgText);
//$msgText = str_replace("#number#", explode(":", Auth::user()->exten)[0], $msgText);
$exten = '';
$extension = Auth::user()->exten;
if(!empty($extension))
{
$extenArr = explode(":", $extension);
$exten = $extenArr[0];
}
//Log::info($exten);
$msgText = str_replace("#number#", $exten, $msgText);
$msgText = str_replace("#date#", date('d-m-Y'), $msgText);
}
return $msgText;
}
}
......@@ -252,7 +252,7 @@ class UserController extends Controller {
if(isset($userdata["usergroup"]))$user->group=$userdata["usergroup"];
$user->presence=0;
if(isset($userdata["clientsownerlist"]))$user->clients=$userdata["clientsownerlist"];
if(isset($userdata["lteam"]))$user->lteam=$userdata["lteam"];
if(isset($userdata["lteam2"]))$user->lteam2=$userdata["lteam2"];
if(isset($userdata["supervisor"]))$user->supervisor=$userdata["supervisor"];
......@@ -290,7 +290,7 @@ class UserController extends Controller {
if(isset($userdata["recclientsownerlist"]))$bbb['recclientsownerlist']=$userdata["recclientsownerlist"];
if(isset($userdata["bdmclientsownerlist"]))$bbb['bdmclientsownerlist']=$userdata["bdmclientsownerlist"];
$data['hrmsdata']=serialize($bbb);
//$user->clients=$userdata["clientsownerlist"];
$user->data=json_encode($data);
$meta=$user->meta();
......
......@@ -12,6 +12,7 @@ use App\Models\CRMCallArchive;
use App\Models\CRM;
use App\Models\CRMCampaign;
use App\Models\CRMList;
use App\Models\Cutoff;
use App\Jobs\KHRMSLib;
use App\Models\Sipid;
use App\Models\Dialline;
......@@ -147,20 +148,33 @@ class DialerController extends Controller {
$roclientstr=array();
$oclientlst=$wakka->clientsReadAccess();
//print_r($oclientlst);
if(!empty($oclientlst))foreach($oclientlst as $tclnt)if($tclnt!=""){$roclientstr[]="'$tclnt'";}
if(!empty($roclientstr))$roclientstr="and client in (".implode(",",$roclientstr).")";else $roclientstr="";
$users=array();$searchresult="";
if(!empty($kstychCall["previewcrmid"]))$users=$wakka->getPersons("id='".$kstychCall["previewcrmid"]."' $roclientstr limit 1");
else $users=$this->getCallSequencing(1);
$client=Input::get("client");
if($client==''||$client==undefined){
$client="";
}
//$client=$this->campaignlist($client);
if(!empty($kstychCall["previewcrmid"])){
$users=$wakka->getPersons("id='".$kstychCall["previewcrmid"]."' limit 1",$client);}
else{
$users=$this->getCallSequencing(1);
}
//$wakka->setPersonKey($users[0]['id'],"status","Incall");
if($users[0]['id']>0){
Log::info("1----".$users[0]['id']);
if($client!=''){
DB::table('records_'.$client)->where('id',$users[0]['id'])->update(['filter_condition'=>'2','modified'=>date("Y-m-d H:i:s")]);
}
}
if(!empty($users))
{
$searchresult.="<div id=divworking></div><div style='clear:both'></div><script>kSetDData('C','previewcrmid','".$users[0]['id']."');showRecruit(\"".$users[0]['id']."\");</script>";
$searchresult.="<div id=internalid_matchlist></div><script>
doAjax('record?action=quicksearch','maintextsearch_1_txt=".$users[0]['clientinternalid']."&maintextsearch_1_span=InternalID','internalid_matchlist','searchMutex', 'searchxhr','POST',function(retstr){
doAjax('record?action=quicksearch','maintextsearch_1_txt=".$users[0]['clientinternalid']."&maintextsearch_1_span=InternalID&client=$client','internalid_matchlist','searchMutex', 'searchxhr','POST',function(retstr){
if(retstr.responseText.indexOf('No Records Found!')>-1)$('#internalid_matchlist').html('');
});
</script>";
......@@ -182,17 +196,14 @@ class DialerController extends Controller {
$oclientlst=$wakka->clientsReadAccess();
if(!empty($oclientlst))foreach($oclientlst as $tclnt)if($tclnt!=""){$roclientstr[]="'$tclnt'";}
if(!empty($roclientstr))$roclientstr="and client in (".implode(",",$roclientstr).")";else $roclientstr="";
$users=array();$callnumber=$kstychCall['callnumber'];
$callnumber = trim($callnumber);
if($kstychDialer['mDialerState']=="Manual"){
if((!preg_match('/^[0-9]*$/',$callnumber)) || strlen($callnumber)<6){
return Response::make("<script>simpleNotification('error','topRight','Please enter a valid phone number');</script>");
}
//Log::info("newcall-->> ".$roclientstr);
$client=Input::get("client");
Log::info($client);
if($client==''||$client==undefined){
$client='';
}
//$client=$this->campaignlist($client);
$users=array();$callnumber=$kstychCall['callnumber'];
if($kstychCall['crmid'])
{
$crmid=$kstychCall['crmid'];
......@@ -204,13 +215,7 @@ class DialerController extends Controller {
}
if($kstychDialer['mDialerState']=="Manual")
{
$callnumber=trim($callnumber);
if(!preg_match('/^[1-9][0-9]*$/',$callnumber)){
return Response::make("<script>simpleNotification('error','topRight','Only Digits are allowed');</script>");
}
if(strlen($callnumber)<6){
return Response::make("<script>simpleNotification('error','topRight','Enter a valid Number');</script>");
}
if($crmid!="")
{
$tusers=$wakka->getPersonIDs("(mobile like '%".substr($callnumber,-10)."' OR
......@@ -223,7 +228,7 @@ class DialerController extends Controller {
altphone7 like '%".substr($callnumber,-10)."' OR
altphone8 like '%".substr($callnumber,-10)."' OR
altphone9 like '%".substr($callnumber,-10)."' OR
altphone10 like '%".substr($callnumber,-10)."') and id=$crmid $roclientstr ");
altphone10 like '%".substr($callnumber,-10)."') and id=$crmid ",$client);
}
......@@ -239,7 +244,7 @@ class DialerController extends Controller {
altphone7 like '%".substr($callnumber,-10)."' OR
altphone8 like '%".substr($callnumber,-10)."' OR
altphone9 like '%".substr($callnumber,-10)."' OR
altphone10 like '%".substr($callnumber,-10)."' $roclientstr");
altphone10 like '%".substr($callnumber,-10)."'",$client);
}
......@@ -256,7 +261,7 @@ class DialerController extends Controller {
altphone7 like '%$callnumber' OR
altphone8 like '%$callnumber' OR
altphone9 like '%$callnumber' OR
altphone10 like '%$callnumber' ) and id in ($idstr) $roclientstr");
altphone10 like '%$callnumber' ) and id in ($idstr)",$client);
if(!$users)
{
......@@ -266,8 +271,9 @@ class DialerController extends Controller {
if($kstychDialer['mDialerState']=="DialNext"||$kstychDialer['mDialerState']=="Progressive")
{
if($kstychCall['crmid']!="")$users=$wakka->getPersons("id='".$kstychCall['crmid']."' $roclientstr limit 1");
else if($kstychCall['callnumber']!="")$users=$wakka->getPersons("mobile='".$kstychCall['callnumber']."' $roclientstr limit 1");
Log::info("crmid-->".$kstychCall['crmid']."--callnumber-->".$kstychCall['callnumber']);
if($kstychCall['crmid']!="")$users=$wakka->getPersons("id='".$kstychCall['crmid']."' limit 1",$client);
else if($kstychCall['callnumber']!="")$users=$wakka->getPersons("mobile='".$kstychCall['callnumber']."' $roclientstr limit 1",$client);
else $users=$this->getCallSequencing(1);
}
......@@ -281,6 +287,23 @@ class DialerController extends Controller {
if(!isset($ppldata['department']))$ppldata['department']="";
if($callnumber==""||intval($callnumber)<=0)$callnumber=$ppldata['mobile'];
$callnumber = trim($callnumber);
if($kstychDialer['mDialerState']=="Manual"){
if(!is_numeric($callnumber) || strlen($callnumber)<6){
return Response::make("<script>simpleNotification('error','topRight','Please enter a valid phone number');</script>");
}
}
if($kstychDialer['mDialerState']=="Progressive"){
if(!is_numeric($callnumber) || strlen($callnumber)<6){
Log::useFiles(storage_path().'/logs/Dialline_block_progressive.log');
Log::info('Number='.$callnumber.' Campaign='.$ppldata['client']);
Log::info('PregMatch='.(!is_numeric($callnumber)).' StringLength='.strlen($callnumber));
}
}
if($callnumber!=""&&intval($callnumber)>0)
{
$mastersdata=$wakka->getCompanyMaster($ppldata['client']);
......@@ -289,22 +312,24 @@ class DialerController extends Controller {
$calleridarr=explode(":",$callerid);$dspan="1";
if(isset($calleridarr[1])){$callerid=$calleridarr[0];$dspan=$calleridarr[1];}
/*$calleridarr=explode(":",env("non_open"));
$callerid=$calleridarr[0];
$dspan =$calleridarr[1];
}*/
//see if user is online on this sipid
$sipid=Sipid::find($kstychDialer['phone']);
if($sipid&&$sipid->user==Auth::user()->id&&$sipid->status==1)
{
$dialline=Dialline::where("status","=","Free")->where("enabled","=","1");
$dialline=Dialline::where("status","=","Free")->where("enabled","=","1")->where("server","=",env("app_ip"));
if($dspan!="")$dialline=$dialline->where('dspan','=',$dspan);
$dialline=$dialline->orderBy('updated_at','ASC')->first();
if($dialline)
{
//Log::info("before callconnected".$dialline->status." ^ ".$dialline->dchannel." ^ ".$dialline->dspan." ^ ".$callnumber." ^ ".$dialline->channel);
$dialline->status="Blocked";
$dialline->save();
//Log::info("After diallineset".$dialline->status);
$nowts=microtime(true)*1000;
//get ts_Wait
......@@ -333,11 +358,16 @@ class DialerController extends Controller {
$tdata=array();
$crmcall->data=json_encode($tdata);
$crmcall->save();
if($users[0]['id']>0){
if($client!='')$records='records_'.$client;else $records='records';
DB::table($records)->where('id',$users[0]['id'])->update(['filter_condition'=>'3','usr_id'=>Auth::user()->id]);
DB::table('records')->where('id',$users[0]['id'])->update(['usr_id'=>Auth::user()->id]);
}
//start actual calls
$ppldata['dialer_lastcall']=date("Y-m-d H:i:s");
$preppldata['peopledata'] = serialize($ppldata);
$wakka->setPerson($ppldata['peopledata']['id'],$preppldata);
$wakka->setPerson($ppldata['peopledata']['id'],$preppldata,$client); $wakka->setPerson($ppldata['peopledata']['id'],$preppldata,"");
$newqueue=new Kqueue();
$newqueue->userToConf($sipid);
......@@ -350,7 +380,7 @@ class DialerController extends Controller {
$searchresult.="<div id=internalid_matchlist></div><script>
doAjax('record?action=quicksearch','maintextsearch_1_txt=".$users[0]['clientinternalid']."&maintextsearch_1_span=InternalID','internalid_matchlist','searchMutex', 'searchxhr','POST',function(retstr){
doAjax('record?action=quicksearch','maintextsearch_1_txt=".$users[0]['clientinternalid']."&maintextsearch_1_span=InternalID&client=$client','internalid_matchlist','searchMutex', 'searchxhr','POST',function(retstr){
if(retstr.responseText.indexOf('No Records Found!')>-1)$('#internalid_matchlist').html('');
});
</script>";
......@@ -370,7 +400,8 @@ class DialerController extends Controller {
}
else
{
$wakka->setPersonKey($users[0]['id'],"status","NoNumber");
$wakka->setPersonKey($users[0]['id'],"status","NoNumber","",$client);
$wakka->setPersonKey($users[0]['id'],"status","NoNumber","","");
return Response::make($searchresult."<script>kstychCall['crmid']=0;kSetDData('C','previewcrmid','');simpleNotification('error','topRight','No Number in Record!');</script>");
}
......@@ -398,7 +429,7 @@ if($action=="addconfcall")
$olddialline=Dialline::find($oldcrmcall->dialline_id);
$dspan="1";if($olddialline)$dspan=$olddialline->dspan;
$dialline=Dialline::where("status","=","Free")->where("enabled","=","1");
$dialline=Dialline::where("status","=","Free")->where("enabled","=","1")->where("server","=",env("app_ip"));
if($dspan!="")$dialline=$dialline->where('dspan','=',$dspan);
$dialline=$dialline->orderBy('updated_at','ASC')->first();
......@@ -463,9 +494,118 @@ if($action=="addconfcall")
return Response::make($retstr);
}
if($action=="transfercall")
{
$retstr="";
$callnumber=Input::get("confnumber");
$callerid="";
//see if user is online on this sipid
$sipid=Sipid::find($kstychDialer['phone']);
if($sipid&&$sipid->user==Auth::user()->id&&$sipid->status==1)
{
$oldcrmcall=CRMCall::find($kstychCall['callid']);
if($oldcrmcall)
{
$olddialline=Dialline::find($oldcrmcall->dialline_id);
$dspan="1";if($olddialline)$dspan=$olddialline->dspan;
// $dialline=Dialline::where("status","=","Free")->where("enabled","=","1");
// if($dspan!="")$dialline=$dialline->where('dspan','=',$dspan);
// $dialline=$dialline->orderBy('updated_at','ASC')->first();
if($olddialline)
{
$callerid=$oldcrmcall->did;
// $dialline->status="transfer";
// $dialline->channel=$olddialline->channel;
// $dialline->save();
$nowts=microtime(true)*1000;
//start the call log
$crmcall=new CRMCall();
$crmcall->number=$callnumber;
$crmcall->user_id=Auth::user()->id;
$crmcall->sipid_id=$sipid->id;
$crmcall->crm_id=$oldcrmcall->crm_id;
$crmcall->client=$oldcrmcall->client;
$crmcall->department=$oldcrmcall->department;
$crmcall->state='New';
$crmcall->userstatus='Transfer';
$crmcall->usersubstatus='Transfer';
$crmcall->type='Transfer';
//$crmcall->dialline_id=$dialline->id;
$crmcall->setTs('ts_Wait',$nowts);
$crmcall->setTs('ts_Call',$nowts);
$crmcall->did=$callerid;
$tdata=array();
$crmcall->data=json_encode($tdata);
$crmcall->save();
$newqueue=new Kqueue();
$newqueue->transferCall($sipid,$callnumber,$callerid,$crmcall,$olddialline);
//start actual calls
// $newqueue=new Kqueue();
// $newqueue->userToConf($sipid);
// $newqueue=new Kqueue();
// $newqueue->custToConf($sipid,$callnumber,$callerid,$crmcall,$dialline);
$retstr=$crmcall->id;
}
else
{
$retstr="Error : No Lines Free to Dial!";
}
}
else
{
$retstr="Error : No calls to conference found!";
}
}
else
{
$retstr="Error : You Are Not Connected!";
}
return Response::make($retstr);
}
if($action=="hangupall")
{
$res=0;
$aUser = Auth::user();
If($aUser->current_dialmode == "Predictive"){
$avgTimeArr = array();
$user_id = $aUser->id;
$campaign = $aUser->sel_campaign;
$avgTimeArr = $this->getAvgTimeArray($campaign, $user_id);
$cutOffUsrArr = Cutoff::where('user_id', '=', $user_id)->where('c_name', '=', $campaign)->get();
if(count($cutOffUsrArr)){
Cutoff::where('user_id', '=', $user_id)->where('c_name', '=', $campaign)->update(
['hangup_time' => date('Y-m-d H:i:s'),
'avg_dispo' => $avgTimeArr['avgdisposec']
]);
}
else
{
$cutoff = new Cutoff();
$cutoff->user_id = $user_id;
$cutoff->c_name = $campaign;
$cutoff->hangup_time = date('Y-m-d H:i:s');
$cutoff->avg_dispo = $avgTimeArr['avgdisposec'];
$cutoff->avg_ring = 0;
$cutoff->save();
}
}
$callid=intval($kstychCall['callid'])+0;
$crmcall=CRMCall::find($callid);
if($crmcall&&$crmcall->user_id==Auth::user()->id)
......@@ -527,6 +667,7 @@ if($action=="hangupall")
if($action=="closecall")
{
//echo "Manoj";
$callid=intval($kstychCall['callid'])+0;
$crmcall=CRMCall::find($callid);
if($crmcall&&$crmcall->user_id==Auth::user()->id)
......@@ -537,12 +678,18 @@ if($action=="closecall")
{
$kstychCall["usercallback"]=date("Y-m-d H:i:s",strtotime($kstychCall["usercallback"].":00")+((Auth::user()->timezone)*60));
}
if($kstychCall["userappointment"]!="")
{
$kstychCall["userappointment"]=date("Y-m-d H:i:s",strtotime($kstychCall["userappointment"].":00")+((Auth::user()->timezone)*60));
}
$crmcall->setTs('ts_Close',$nowts);
$crmcall->userstatus =$kstychCall["userstatus"];
$crmcall->usersubstatus =$kstychCall["usersubstatus"];
$crmcall->usercallback =$kstychCall["usercallback"];
$crmcall->userappointmentdate =$kstychCall["userappointment"];
//$user['peopledata']["dialer_appointment"]=$kstychCall["userappointment"];
//$kstychCall["attempt"]='';
$crmcall->attempt = isset($kstychCall["attempt"]) ? $kstychCall["attempt"] : ' ';
$crmcall->call_flag="Z";
......@@ -560,13 +707,15 @@ if($action=="closecall")
{
$crmcall->crm_id=$kstychCall["crmid"];
$temparr=$wakka->getPerson($crmcall->crm_id);
$temparr=$wakka->getPerson($crmcall->crm_id,$crmcall->client);
Log::info("client---->in close1 --".$crmcall->client);
if(isset($temparr)&&isset($temparr['peopledata'])&&isset($temparr['peopledata']['client']))$crmcall->client=$temparr['peopledata']['client'];
}
}
if($crmcall->crm_id>0)
{
//print_r("manoj1");
if(is_array($kstychCall["userdata"]))
{
foreach($kstychCall["userdata"] as $tcrmid=>$tuserdata)
......@@ -609,11 +758,14 @@ if($action=="closecall")
$tcrmcall->save();
DB::table('records_'.$crmcall->client)->where('id',$crmcall->crm_id)->update(['filter_condition'=>'4']);
$tuser=$wakka->getPerson($tcrmid);
$tuser=$wakka->getPerson($tcrmid,$crmcall->client);
Log::info("client in 2-->".$crmcall->client);
$tuser['peopledata']["dialer_status"]=$kstychCall["userstatus"];
$tuser['peopledata']["dialer_substatus"]=$kstychCall["usersubstatus"];
$tuser['peopledata']["dialer_callback"]=$kstychCall["usercallback"];
$tuser['peopledata']["dialer_appointment"]=$kstychCall["userappointment"];
$tuser['peopledata']["dialer_remarks"]=str_replace("'","",$kstychCall["userremarks"]);
$tuser['peopledata']["dialer_flag"]=$kstychCall["userflag"];
......@@ -622,28 +774,36 @@ if($action=="closecall")
$tuser["resolution"]=$kstychCall["resolution"];
$tuser["satisfy"]=$kstychCall["satisfy"];
$tuser["final_call_assess"]=$kstychCall["final_call_assess"];
//print_r($tuser['peopledata']["status"]);
$tuser['peopledata']["dialer_userdata"]=$kstychCall["userdata"][$tcrmid];
if($tuser['peopledata']["status"]=='New' || $tuser['peopledata']["status"]=='NEW')$tuser['peopledata']["status"]="Called";
if($tuser['peopledata']["status"]=='New' || $tuser['peopledata']["status"]=='NEW' || $tuser['peopledata']["status"]=='Incall')$tuser['peopledata']["status"]="Called";
//Log::info("Manoj ".$tuser['peopledata']["status"]);
//print_r($tuser['peopledata']["status"]);
//for Supervisor Comments - By Manish
$tuser['agentcomments']=$kstychCall["agentcomments"];
$tuser['supcomntid']=$kstychCall["supcomntid"];
$tuser['peopledata']["dialer_lastcall"]=date("Y-m-d H:i:s");
$wakka->setPerson($tcrmid,$tuser);
$wakka->setPerson($tcrmid,$tuser,$crmcall->client);
$wakka->setPerson($tcrmid,$tuser,"");
}
}
}
}
$user=$wakka->getPerson($crmcall->crm_id);
$user=$wakka->getPerson($crmcall->crm_id,$crmcall->client);
Log::info("client in 3 --".$crmcall->client);
if($user['peopledata']['id']==$crmcall->crm_id)
{
if($crmcall->crm_id>0){
DB::table('records_'.$crmcall->client)->where('id',$crmcall->crm_id)->update(['filter_condition'=>'4']);
}
$user['peopledata']["dialer_status"]=$kstychCall["userstatus"];
$user['peopledata']["dialer_substatus"]=$kstychCall["usersubstatus"];
$user['peopledata']["dialer_callback"]=$kstychCall["usercallback"];
$user['peopledata']["dialer_appointment"]=$kstychCall["userappointment"];
$user['peopledata']["dialer_remarks"]=str_replace("'","",$kstychCall["userremarks"]);
$user['peopledata']["dialer_flag"]=$kstychCall["userflag"];
......@@ -668,26 +828,35 @@ if($action=="closecall")
$user['peopledata']["dialer_userdata"]=$kstychCall["userdata"][$crmcall->crm_id];
$user['peopledata']["dialer_lastcall"]=date("Y-m-d H:i:s");
if($user['peopledata']["status"]=='New' || $user['peopledata']["status"]=='NEW')$user['peopledata']["status"]="Called";
if($user['peopledata']["status"]=='New' || $user['peopledata']["status"]=='NEW' || $user['peopledata']["status"]=='Incall')$user['peopledata']["status"]="Called";
//for Supervisor Comments - By Manish
$user['agentcomments']=$kstychCall["agentcomments"];
$user['supcomntid']=$kstychCall["supcomntid"];
$wakka->setPerson($crmcall->crm_id,$user);
$wakka->setPerson($crmcall->crm_id,$user,$crmcall->client);
$wakka->setPerson($crmcall->crm_id,$user,"");
//update groupid if this is not groupid TODO move to config
if($user['peopledata']['clientcode']!=$user['peopledata']['clientinternalid'])
{
$tusers=$wakka->getPersons(" clientinternalid='".$user['peopledata']['clientinternalid']."' limit 1");
Log::info("client in 4 -->".$crmcall->client);
$tusers=$wakka->getPersons(" clientinternalid='".$user['peopledata']['clientinternalid']."' limit 1",$crmcall->client);
if(!empty($tusers))
{
$tppldata=unserialize($tusers[0]['peopledata']);
if($tppldata['status']=='New')$wakka->setPersonKey($tusers[0]['id'],'status','Called');
if($tppldata['status']=='New' || $tppldata['status']=='Incall'){
$wakka->setPersonKey($tusers[0]['id'],'status','Called',"",$crmcall->client);
$wakka->setPersonKey($tusers[0]['id'],'status','Called',"","");
}
//print_r($tppldata['status']);
//Log::info($tppldata['status']);
//if($tppldata['dialer_status']=='') //TODO Config
{
$wakka->setPersonKey($tusers[0]['id'],'dialer_status',$user['peopledata']["dialer_status"]);
$wakka->setPersonKey($tusers[0]['id'],'dialer_substatus',$user['peopledata']["dialer_substatus"]);
$wakka->setPersonKey($tusers[0]['id'],'dialer_status',$user['peopledata']["dialer_status"],"",$crmcall->client);
$wakka->setPersonKey($tusers[0]['id'],'dialer_status',$user['peopledata']["dialer_status"],"","");
$wakka->setPersonKey($tusers[0]['id'],'dialer_substatus',$user['peopledata']["dialer_substatus"],"",$crmcall->client);
$wakka->setPersonKey($tusers[0]['id'],'dialer_substatus',$user['peopledata']["dialer_substatus"],"","");
}
}
}
......@@ -811,13 +980,24 @@ if($action=="kCallAction")
if($action=="dialerstate")
{
$ready=0;if($kstychDialer['mDialerState']=="Ready"&&$kstychCall['mCallState']=="Wait")$ready=1;
//$ready=0;if($kstychDialer['mDialerState']=="Ready"&&$kstychCall['mCallState']=="Wait")$ready=1;
$ready=0;$perpareCall=0;
if($kstychDialer['mDialerState']=="Ready"&&$kstychCall['mCallState']=="Wait")
{
$ready=1;
}
if($kstychDialer['mDialerSubState']=="Predictive"&&$kstychCall['mCallState']=="Wait")
{
$perpareCall=1;
}
$nowts=microtime(true)*1000;
$sipid=Sipid::find($kstychDialer['phone']);
if($sipid&&$sipid->user==Auth::user()->id&&$sipid->status==1)
{
$sipid->ready=$ready;
$sipid->prepare_call=$perpareCall;
$sipid->save();
$userlog=UserLog::where('user_id','=',Auth::user()->id)->orderBy("id","DESC")->first();
......@@ -826,6 +1006,71 @@ if($action=="dialerstate")
}
return Response::make("");
}
if($action=="usersel")
{
$user = Auth::user();
$currDialerState = $kstychDialer['mDialerState'];
//$client=Input::get("client");
if($kstychDialer['mDialerSubState'] != "")
$currDialerState = $kstychDialer['mDialerSubState'];
if($client!=""){
DB::table('users')->where('id', Auth::user()->id)->update([
'sel_campaign'=>$client,
'current_dialmode'=>$currDialerState
]);
}else{
DB::table('users')->where('id', Auth::user()->id)->update([
'current_dialmode'=>$currDialerState
]);
}
$campaigndata = Sipid::select("clients")->where("user", $user->id)->where("status", "=", 1)->first();
if($campaigndata)
{
$campdata= json_decode($campaigndata->clients);
if(Auth::user()->id!='1'){
$campdata->sel_campaign=$client;
Sipid::where("user",$user->id)->update(["clients"=>json_encode($campdata)]);
}
}
return Response::make("");
}
if($action=="sipcleanup")
{
$user = Auth::user();
$sipid = Sipid::where("user", $user->id)->select('id')->first();
Sipid::where("user", $user->id)->update([
"user" => 0,
"status" => 0,
"ready" => 0,
"patched" => 0,
"prepare_call" => 0,
"confup" => 0,
"clients" => ""
]);
$diallines = Dialline::where('status', '!=', 'Free')->where('conf', '=', "1000".$sipid->id);
if($diallines){
$diallines=$diallines->get();
foreach ($diallines as $dialline) {
$newqueue=new Kqueue();
$newqueue->hangupChannelS($dialline->channel,$dialline->server);
}
}
if(count($sipid)){
exec('/usr/sbin/asterisk -rx "channel request hangup '.$sipid->id.'"');
exec('/usr/sbin/asterisk -rx "confbridge kick 1000'.$sipid->id.' all"');
}
}
if($action=="spychannel")
{
......@@ -856,11 +1101,14 @@ if($action=="recarchive")
}
public function show($id)
{
//echo "show--->".$id;
//exit();
if($id=="bucketdata")
{
//Log::info("ABCDDD----".Input::get("client"));
$client=Input::get("client","");
$bucket=Input::get("bucket");
$currentstatus=Input::get("currentstatus");
//$currentstatus=Input::get("currentstatus");
$legalstatus=Input::get("legalstatus");
$page=intval(Input::get('page'));if($page<1)$page=1;
$skey=Input::get('skey');
......@@ -912,9 +1160,9 @@ public function show($id)
$birthdate=date('m-d');
$dbres=array();
if($bucket=="CurrentQueue")$dbres=$this->getCallSequencing(20);
else if($bucket=="Priority")$dbres=$wakka->getPersons("priority in (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) $owclientstr ORDER BY FIELD(priority,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1) limit $bs,$bl");
else if($bucket=="TotalData")$dbres=$wakka->getPersons("1=1 and currentstatus='$currentstatus' and legalstatus='$legalstatus' and status!='Noqueue' $owclientstr limit $bs,$bl");
if($bucket=="CurrentQueue")$dbres=$this->getCallSequencing(1);
/*else if($bucket=="Priority")$dbres=$wakka->getPersons("priority in (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) $owclientstr ORDER BY FIELD(priority,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1) limit $bs,$bl");
else if($bucket=="TotalData")//$dbres=$wakka->getPersons("1=1 and currentstatus='$currentstatus' and legalstatus='$legalstatus' and status!='Noqueue' $owclientstr limit $bs,$bl");
else if($bucket=="SearchData")$dbres=$wakka->getPersons("1=1 $roclientstrAll $skey limit $bs,$bl");
else if($bucket=="NotCalled")$dbres=$wakka->getPersons("status='New' and currentstatus='$currentstatus' and legalstatus='$legalstatus' $owclientstr limit $bs,$bl");
else if($bucket=="Called")$dbres=$wakka->getPersons("status='Called' $owclientstr limit $bs,$bl");
......@@ -922,9 +1170,9 @@ public function show($id)
else if($bucket=="Flagged-Called")$dbres=$wakka->getPersons("dialer_flag='VIP' and currentstatus='$currentstatus' and legalstatus='$legalstatus' $owclientstr limit $bs,$bl");
else if($bucket=="Flagged-Notcalled")$dbres=$wakka->getPersons("mf_isa='VIP' and currentstatus='$currentstatus' and legalstatus='$legalstatus' $owclientstr limit $bs,$bl");
else if($bucket=="today-birthday")$dbres=$wakka->getPersons("DATE_FORMAT(DOB,'%m-%d')='$birthdate' and priority='11' $owclientstr limit $bs,$bl");
*/
else if($bucket=="MissedCalls")
{
{/*
$udidlinesstr = array();
foreach($didlinesstr as $didlinestr){
$didlinestrArr=explode(":",$didlinestr);
......@@ -940,7 +1188,6 @@ public function show($id)
$number_list=array();
foreach($mc as $key=>$tcall){
//Log::info($tcall);
$tccal=substr($tcall->number,-10);
$mc_number=CRMCall::where('userstatus','!=','InboundDROP')->where ('created_at','>',$tcall->created_at)->where('number','like',"%".$tccal."%")->orderBy("id","DESC")->first();
......@@ -954,12 +1201,8 @@ public function show($id)
if(count($number_list) > 0) {
$lcalls=DB::select("SELECT * FROM crmcalls where id in (SELECT max(id) FROM crmcalls WHERE number IN ('" . implode("','", $number_list). "') GROUP BY number) ORDER BY id DESC");
//$lcalls=DB::select("SELECT * FROM crmcalls where id in (SELECT max(id) FROM crmcalls WHERE number IN ('" . implode("','", $number_list). "') GROUP BY number)");
//$lcalls=$lcalls->orderBy("id","DESC");
// Log::info($lcalls->id);
foreach($lcalls as $lcall)
{
//Log::info($lcall);
if($lcall->userstatus=="InboundDROP")
{
if($lcall->crm_id>0)
......@@ -981,18 +1224,15 @@ public function show($id)
if(!empty($reccrm_ids))
{
//Log::info($dbres);
$recids_str = implode(",", $reccrm_ids);
$rec=$wakka->getPersonsMissedcall("id in ($recids_str)");
//Log::info($dbres);
$dbres = array_merge($dbres,$rec);
//Log::info($dbres);
}
}
}
*/ }
else if($bucket=="CallsToday")$dbres=$wakka->getPersons("dialer_lastcall>='".date("Y-m-d 00:00:00",time()+((Auth::user()->timezone)*60))."' $owclientstr limit $bs,$bl");
else if($bucket=="CallsMonth")$dbres=$wakka->getPersons("dialer_lastcall>='".date("Y-m-01 00:00:00",time()+((Auth::user()->timezone)*60))."' $owclientstr limit $bs,$bl");
......@@ -1004,12 +1244,11 @@ public function show($id)
$dbres=$wakka->getPersons("dialer_status='$bucket' $currentstatus2 $legalstatus2 $owclientstr limit $bs,$bl");
}
$ccountsummary=array();$k=1;//Log::info(count($dbres));
$ccountsummary=array();$k=1;
foreach($dbres as $dbrow)
{
if(isset($dbrow['callid']))
{
//Log::info($dbrow['callid']);
$lastcall=CRMCall::find($dbrow['callid']);
$callcntmonth=CRMCall::where("number","=",$dbrow['mobile'])->where("created_at",">=",date("Y-m-01 H:i:s",time()+((Auth::user()->timezone)*60)))->count();
}
......@@ -1030,12 +1269,11 @@ public function show($id)
$lasttime=$lastcall->created_at;if($lasttime=="0000-00-00 00:00:00")$lasttime="";else $lasttime=date("d-M-y H:i:s",strtotime($lasttime)-((Auth::user()->timezone)*60));
$dispo=$lastcall->userstatus;
$subdispo=$lastcall->usersubstatus;
$followup=$dbrow[dialer_callback];if($followup=="0000-00-00 00:00:00")$followup="";else $followup=date("d-M-y H:i:s",strtotime($followup)-(Auth::user()->timezone*60));
$followup=$dbrow['dialer_callback'];if($followup=="0000-00-00 00:00:00")$followup="";else $followup=date("d-M-y H:i:s",strtotime($followup)-(Auth::user()->timezone*60));
$remarks=$lastcall->userremarks;
$did=$lastcall->did;
}
//Log::info($dbrow[firstname]);
if(stristr($dbrow[firstname], "_ETHNIC_CODE14") != "")
if(stristr($dbrow['firstname'], "_ETHNIC_CODE14") != "")
{
$rows.="<tr style='background-color: #59ee7c;color:#ffffff;font-weight: bolder;font-size:115%'>";
}
......@@ -1122,7 +1360,7 @@ public function show($id)
$data.="
<div style='clear:both'></div>
<table class='table '>
<table class='table' style='display:none'>
<thead>
<tr>
<th></th>
......@@ -1147,6 +1385,125 @@ public function show($id)
</table>";
return Response::make($data);
}
if($id=="loadFollowupData")
{
$wakka = new KHRMSLib();
$user=Auth::user()->id;
$role = Auth::user()->usertype;
$client = Input::get("client");
$selection = Input::get("selection");
$setClient = '';
$count = 0;
/*$calllog = DB::table('records')
->join('crmcalls', 'records.dialer_callback', '=', 'crmcalls.usercallback')
->select('records.firstname', 'records.cust_id', 'records.mobile', 'records.dialer_callback', 'records.status','records.dialer_lastcall','records.id','records.dialer_status','records.client')
->where("crmcalls.user_id",$user)
//->where("records.dialer_substatus","Follow Up")
->where("records.dialer_callback", "!=","0000-00-00 00:00:00")
//->where("crmcalls.usercallback", "!=","0000-00-00 00:00:00")
//->where("crmcalls.created_at", ">",date("Y-m-d 08:00:00"))
//->where("crmcalls_archive.usercallback", "=","records.dialer_callback")
//->where("records.dialer_lastcall", "<=","crmcalls_archive.usercallback")
->get();*/
$calllog = DB::table('records')
//->join('crmcalls', 'records.dialer_callback', '=', 'crmcalls.usercallback')
->select('customer_name', 'cust_id', 'mobile', 'dialer_callback', 'status','dialer_lastcall','id','dialer_status','client')
->where("dialer_callback", "!=","0000-00-00 00:00:00");
if($role == 'Supervisor'){
$userName = Auth::user()->username;
$supervisorUsers=$wakka->LoadAll("select id from users where supervisor='$userName';");
$supervisorUsers = implode(",",$supervisorUsers);
if(!empty($supervisorUsers)){
if($selection == 'all'){
$setClient ='';
}else{
$setClient = $client;
$calllog = $calllog->where('client', '=', $client);
}
$calllog = $calllog->whereIn("usr_id",[$supervisorUsers])
->get();
$count = count($calllog);
}
}else if($role == 'User'){
if($selection == 'all'){
$setClient ='';
}else{
$setClient = $client;
$calllog = $calllog->where('client', '=', $client);
}
$calllog = $calllog->where("usr_id",$user)->get();
$count = count($calllog);
}
$data['calllog'] = $calllog;
$data['client'] = $setClient;
$data['count'] = $count;
return view("layout.module.dialer.followUp",$data);
}
if($id=="loadAppointmentData")
{
$wakka = new KHRMSLib();
$user=Auth::user()->id;
$role = Auth::user()->usertype;
$client = Input::get("client");
$selection = Input::get("selection");
$setClient = '';
$count = 0;
$totalAppointmentCount = DB::table('records')
->select('customer_name', 'cust_id', 'mobile', 'dialer_appointment', 'status','dialer_lastcall','id','dialer_status','client')
->where("dialer_appointment", "!=","0000-00-00 00:00:00")
->where('dialer_appointment','>',date('Y-m-d H:i:s',time()-(7*24*60*60)));
//print_r($totalAppointmentCount);
if($role == 'Supervisor'){
$userName = Auth::user()->username;
$supervisorUsers=$wakka->LoadAll("select id from users where supervisor='$userName';");
$userIds = [];
//print_r($supervisorUsers);
foreach ($supervisorUsers as $key => $value) $userIds[] = "'".$value['id']."'";
$supervisorUsers = implode(",",$userIds);
//echo $supervisorUsers;
if(!empty($supervisorUsers)){
if($selection == 'all'){
$setClient ='';
}else{
$setClient = $client;
$totalAppointmentCount = $totalAppointmentCount->where('client', '=', $client);
}
$totalAppointmentCount = $totalAppointmentCount->whereIn("usr_id",[$supervisorUsers])
->get();
$count = count($totalAppointmentCount);
}
}else if($role == 'User'){
if($selection == 'all'){
$setClient ='';
}else{
$setClient = $client;
$totalAppointmentCount = $totalAppointmentCount->where('client', '=', $client);
}
$totalAppointmentCount = $totalAppointmentCount->where("usr_id",$user)->get();
$count = count($totalAppointmentCount);
}
$data['appointment'] = $totalAppointmentCount;
$data['client'] = $setClient;
$data['count'] = $count;
return view("layout.module.dialer.appointment",$data);
}
if($id=="reports")
{
return view("layout.module.dialer.reports",array());
......@@ -1393,11 +1750,13 @@ public function show($id)
//echo "OK";
}
private function getCallSequencing($limit)
public function getCallSequencing($limit,$client=null)
{
//Log::info("Inside getCall");
$wakka = new KHRMSLib();
$roclientstr=array();$didlinesstr=array();
if($client==null){
if(Auth::user()->exten!="")$didlinesstr[]=Auth::user()->exten;
$oclientlst=$wakka->clientsOwnerRWAccess();
if(!empty($oclientlst))foreach($oclientlst as $tclnt)if($tclnt!="")
......@@ -1413,14 +1772,106 @@ public function show($id)
$client=Input::get("client");
if(!empty($roclientstr))$roclientstr="client='$client'";else $roclientstr="";
$users=array();
if(Auth::user()->usertype!="User"){$tusers=array();return $tusers;}
$clientDetails=$wakka->getPersonshome("$roclientstr order by dialer_lastcall asc");
}else{
$roclientstr="client='$client'";
Log::info($roclientstr);
}
//$client=$this->campaignlist($client);
if($client!='')$records='records_'.$client;else $records='records';
DB::table($records)->where('filter_condition','=','2')->where('modified','<',date('Y-m-d H:i:s',time()-(2*60)))->update(['filter_condition'=>'1']);
//if($client!=''){
$tusers=$wakka->getPersonshome("filter_condition IN('0','1','4') and $roclientstr and dialer_callback <'".date('Y-m-d H:i:s',time()+(15*60))."' and usr_id='".Auth::user()->id."' and dialer_substatus='Follow Up' limit 1;",$client);
if(count($tusers)>0){
if($limit>0){
$l=1;
foreach($tusers as $tuser){
if(!isset($users[$tuser['id']])){
$users[$tuser['id']]=$tuser;
$l++;
if($l>$limit)
break;
}
}
if($limit>0)
$limit=$limit-sizeof($tusers);
}
}
//Log::info("clients-->".$roclientstr);
$campaign=DB::table("campaign_query")->where('campaign', '=', $client)->where('current_queue','=','selected')->first();
//Log::info($campaign);
if($campaign)
{
if(stripos($campaign->where_cond,"order by")===false){
$orderby="order by dialer_lastcall asc";
}else{
$orderby ="";
}
$tusers=$wakka->getPersonshome("filter_condition IN ('1','0') and dialer_callback ='0000-00-00 00:00:00' and $campaign->where_cond $orderby limit 1;",$client);
//print_r($tusers);
if(count($tusers)>0){
if($limit>0){
$l=1;
foreach($tusers as $tuser){
//Log::info($tuser);
if(!isset($users[$tuser['id']])){
//Log::info("2-".$users[$tuser['id']]);
$users[$tuser['id']]=$tuser;
$l++;
if($l>$limit)
break;
}
}
$limit=$limit-sizeof($tusers);
}
}else{
$condition=$campaign->where_cond;
if(stripos($condition,"order by")!==false){
$condition = substr($condition,0,stripos($condition, 'order by'));
}
$tusers=$wakka->getPersonshome("filter_condition=4 and $condition order by dialer_lastcall asc limit 1;",$client);
if($limit>0){
$l=1;
foreach($tusers as $tuser){
if(!isset($users[$tuser['id']])){
$users[$tuser['id']]=$tuser;
$l++;
if($l>$limit)
break;
}
}
$limit=$limit-sizeof($tusers);
}
}
}else{
$tusers=$wakka->getPersonshome("filter_condition NOT IN ('2','3') and status='New' order by dialer_lastcall asc limit 1;",$client);
if($limit>0){
$l=1;
foreach($tusers as $tuser){
if(!isset($users[$tuser['id']])){
$users[$tuser['id']]=$tuser;
$l++;
if($l>$limit)
break;
}
}
$limit=$limit-sizeof($tusers);
}
//print_r($clientDetails);
//print_r($clientDetails);
/*if($limit>0)
{
$tusers = array_filter($clientDetails, function($var){
return ($var['dialer_status']=='InboundDROP' && $var['dialer_lastcall']>'2018-09-11 00:00:00' && $var['dialer_lastcall']>date('Y-m-d H:i:s',time()-(7*24*60*60)));
......@@ -1438,9 +1889,9 @@ public function show($id)
}
$limit=$limit-sizeof($tusers);
}
}*/
if($limit>0)
/*if($limit>0)
{
if(!empty($didlinesstr))
{
......@@ -1480,7 +1931,7 @@ public function show($id)
/* Changes For Missed Call - 14/02/17 */
foreach($othermissedcalls as $othermissedcall)
/*foreach($othermissedcalls as $othermissedcall)
{
$crmnumber = substr($othermissedcall->number, -10);
......@@ -1503,19 +1954,19 @@ public function show($id)
/* Changes For Missed Call - 14/02/17 */
foreach($tusers as $tuser)if(!isset($users[$tuser['id']]))$users[$tuser['id']]=$tuser;
/*foreach($tusers as $tuser)if(!isset($users[$tuser['id']]))$users[$tuser['id']]=$tuser;
$limit=$limit-sizeof($tusers);
}
}
}*/
if($limit>0)
/*if($limit>0)
{
$tusers = array_filter($clientDetails, function($var){
return ($var['dialer_callback']>'2018-09-11 00:00:00'&&strtotime($var['dialer_callback'])<strtotime(date('Y-m-d H:i:s',time()+(15*60)))&&($var['dialer_status']=='Contacted - FollowUp - Specific' || $var['dialer_substatus']=='Followup Call' || $var['dialer_status']=='Service Call - Inbound Follow up' || $var['dialer_status'])=='Productive Call - Sales Follow Up');
});
// echo "1";
$l=1;
foreach($tusers as $tuser){
if(!isset($users[$tuser['id']])){
......@@ -1528,9 +1979,10 @@ public function show($id)
}
$limit=$limit-sizeof($tusers);
}
for($p=15;$p>0;$p--)
}*/
/*for($p=15;$p>0;$p--)
{
// echo "2";
if($limit>0)
{
$tusers = array_filter($clientDetails, function($var) use ($p){
......@@ -1553,13 +2005,13 @@ public function show($id)
$limit=$limit-sizeof($tusers);
}
}
}
if($limit>0)
}*/
/*if($limit>0)
{
$tusers = array_filter($clientDetails, function($var){
return ($var['status']=='New'&&$var['mobile']!='');
});
// echo "3";
$l=1;
foreach($tusers as $tuser){
if(!isset($users[$tuser['id']])){
......@@ -1572,15 +2024,15 @@ public function show($id)
}
$limit=$limit-sizeof($tusers);
}
}*/
if($limit>0)
/*if($limit>0)
{
$tusers = array_filter($clientDetails, function($var){
//return ($var['status']=='Called'&&($var['dialer_substatus']=='NC - Customer in Meeting' || $var['dialer_substatus']=='NC - Ringing / No response' || $var['dialer_substatus']=='NC - Not Reachable' || $var['dialer_substatus']=='NC - Switched off' || $var['dialer_substatus']=='NC - Third Party' || $var['dialer_status'=='Not Contacted']));
return ($var['status']=='Called'&&$var['dialer_status']=='Not Contacted');
//return ($var['status']=='Called'&&$var['dialer_status']=='Not Contacted');
});
// echo "4";
$l=1;
foreach($tusers as $tuser){
if(!isset($users[$tuser['id']])){
......@@ -1593,9 +2045,9 @@ public function show($id)
}
$limit=$limit-sizeof($tusers);
}
}*/
if($limit>0)
/*if($limit>0)
{
$tusers = array_filter($clientDetails, function($var){
return ($var['status']=='Called'&&$var['dialer_status']=='Contacted - Follow-Up - Generic');
......@@ -1612,10 +2064,11 @@ public function show($id)
}
$limit=$limit-sizeof($tusers);
}
}*/
if($limit>0)
/*if($limit>0)
{
// echo "5";
$tusers = array_filter($clientDetails, function($var){
return ($var['status']=='Called'&&$var['dialer_status']=='AUTOWRAPUP');
});
......@@ -1631,9 +2084,24 @@ public function show($id)
}
$limit=$limit-sizeof($tusers);
}*/
}
$tusers=array();foreach($users as $tuser)$tusers[]=$tuser;
// }
return $tusers;
}
public function getAvgTimeArray($campaign, $user)
{
$avgdisposecObj = CRMCall::select(DB::Raw('(avg(disposec))/1000 as avgdisposec'))->where("client", "=", $campaign)->where("user_id", "=", $user)->orderby("id","desc")->limit(50)->where("type","!=","Inbound")->first();
$avgcallsecObj = CRMCall::select(DB::Raw('(avg(callsec))/1000 as avgcallsec'))->where("client", "=", $campaign)->where("user_id", "=", $user)->orderby("id","desc")->limit(50)->where("type","!=","Inbound")->first();
$returnArray['avgdisposec'] = round($avgdisposecObj->avgdisposec);
$returnArray['avgcallsec'] = round($avgdisposecObj->avgcallsec);
return $returnArray;
}
}
......
......@@ -41,6 +41,8 @@ Route::group(['middleware' => ['web']], function () {
Route::resource('user','UserController');
Route::resource('group','GroupController');
Route::resource('role','RoleController');
Route::resource('dispositionPlan','DispositionPlanController');
Route::resource('disposition','DispositionController');
Route::resource('master','MasterController');
Route::resource('admin','AdminController');
......
This diff could not be displayed because it is too large.
......@@ -575,6 +575,13 @@ $data.="</div><div style='width:49%;float:left'>
<label class=label-small_new style='width:25%;' title=''>Callback: </label>
<input class='form_new form_new_amend datetimepicker_dthr' id='dialer_usercallback' name='dialer_usercallback'>
</p>";
//if(Auth::user()->id==266){
$data.="<p style='clear:both'>
<label class=label-small_new style='width:25%;' title=''>Appointmet Date: </label>
<input class='form_new form_new_amend datetimepicker_dthr' id='dialer_appointment' name='dialer_appointment'>
</p>";
//}
/*$data.="<p style='clear:both'>
<label class=label-small_new style='width:25%;' title=''>Call Remarks: </label>
<textarea id='dialer_userremarks' name='dialer_userremarks' style='width:70%' maxlength=250></textarea>
......@@ -818,20 +825,69 @@ $data.="</fieldset></div>
var dialerdispoarray={};var dispoClassArray={};
dialerdispoarray['']='';\n";
$mastersdata=$gthis->getDispocampaignData($dataarr[client]);
//$dispoarr=explode("~",$mastersdata['mvalue']);
// to get client corconfig
/*$mastersdata= $gthis->getDispocampaignData($dataarr['client']);
$dispoarr = [];
if(empty($mastersdata))
{
// if client company is empty get data from campaign company
$mastersdata=$gthis->getCompanyMaster($client);
if(empty($mastersdata['dialerDispoList']))$mastersdata['dialerDispoList']=$gthis->HRCoreVars['dialerDispoList'];
/* commented above code : now get data from dispostion table
if(empty($mastersdata['dialerDispoList'])){
$mastersdata['dialerDispoList']=$gthis->HRCoreVars['dialerDispoList'];
}*
if(!empty($mastersdata['dialerDispoList'])){
$dispoarr=explode("~",$mastersdata['dialerDispoList']);
}
}else{
$dispoarr=explode("~",$mastersdata['mvalue']);
}
if(count($dispoarr) > 0){
foreach($dispoarr as $dispo)
{
if(!empty($dispo))
{
$dispoprts=explode("|",$dispo);
if(sizeof($dispoprts)>=3)
{
$data.="dialerdispoarray['$dispoprts[1]']='$dispoprts[2]';dispoClassArray['$dispoprts[0]']='$dispoprts[1]';";
}
}
}
}else{
// get disposition from disposition table
$dispositionPlan = $gthis->getDispositionList();
foreach ($dispositionPlan as $key => $value) {
$disposition = $value->disposition;
$subDisposition = $value->sunDispoName;
$data.="dialerdispoarray['$disposition']='$subDisposition';";
}
}*/
$mastersdata = DB::table('campaign_disposition_plan')
->join('disposition_plan_config', 'campaign_disposition_plan.dispo_plan_id', '=', 'disposition_plan_config.dispo_plan_id')
->join('disposition_plan', 'disposition_plan.id', '=', 'disposition_plan_config.dispo_plan_id')
->select('disposition_plan_config.disposition as disposition ', 'disposition_plan_config.sub_disposition as subDisposition')
->where("disposition_plan.status","active")
->where("campaign","=",$dataarr['client'])
->get();
if(count($mastersdata) > 0){
foreach ($mastersdata as $key => $value) {
$disposition = $value->disposition;
$subDisposition = $value->subDisposition;
$data.="dialerdispoarray['$disposition']='$subDisposition';";
}
}else{
// if client company is empty get data from campaign company
$mastersdata=$gthis->getCompanyMaster($client);
if(!empty($mastersdata['dialerDispoList'])){
$dispoarr=explode("~",$mastersdata['dialerDispoList']);
foreach($dispoarr as $dispo)
{
if(!empty($dispo))
......@@ -843,6 +899,16 @@ $data.="</fieldset></div>
}
}
}
}else{
// get disposition from disposition table
$dispositionPlan = $gthis->getDispositionList();
foreach ($dispositionPlan as $key => $value) {
$disposition = $value->disposition;
$subDisposition = $value->sunDispoName;
$data.="dialerdispoarray['$disposition']='$subDisposition';";
}
}
}
$data.="
......@@ -4033,8 +4099,8 @@ function validatePostData()
}
//client cannot be changed unless Admin
if(!$wakka->IsAdmin())if(trim($ppldata["client"])!=""&&$ppldata["client"]!=Input::get("client"))$message=" Client Cannot be changed, use Renew-Record";
//if(!$wakka->IsAdmin())if(trim($ppldata["client"])!=""&&$ppldata["client"]!=Input::get("client"))$message=" Client Cannot be changed, use Renew-Record";
if(!$wakka->IsAdmin())if(trim($ppldata["client"])=="")$message=" Client Cannot be changed, use Renew-Record";
if(Input::get('currentstatus')==$wakka->HRCoreVars['hrTriggerHoldStatus'])
{
$message="";//bypass checks for candidates
......@@ -4187,7 +4253,7 @@ function validatePostData()
$recruitdata["dirty"][$taskline['completecheck']]=1;
}
$this->recruitdata=$recruitdata;
$res=$wakka->setPerson($varid,$this->recruitdata);
$res=$wakka->setPerson($varid,$this->recruitdata,'');
}
}
......
......@@ -13,7 +13,7 @@ class KHRMSLib
public $dblink;
public $user=NULL;
public $EMPCacheCols="currentstatus,legalstatus,firstname,lastname,mobile,emailid,altphone1,altphone2,altphone3,altphone4,altphone5,altphone6,altphone7,altphone8,altphone9,altphone10,candidatecategory,nextfollowupdate,passportno,joiningdate,client,designation,supervisor,contracttype,saltotal,ibannumber,servicestoppeddate,employeeexitstatus,exittype,dateofexit,abscondtype,abscondeddate,workflowstatus,status,clientinternalid,department,passportstatus,clientcode,laborcardpersonalid,dialer_status,dialer_substatus,dialer_callback,dialer_remarks,dialer_flag,dialer_lastcall,priority,crmlist_id,group,bttc,service_vs_product,resolution,satisfaction,final_call_assessment,question,mf_isa,DOB,other_information,agreementid,applied_amount,city,comp_code,company,completeddate,cust_id,cust_name,customer_name,disb_date,emi_hl,eqty_amt,foir,ins_amt,int_rate,irr,loan_amount,location,mf_amt,nth,offer_amt,outstanding,pf,ph_mob,ph_off,ph_res,pl_offer,proc_fee,product_flag,profile_new,rank,segment,tenure,tu_application_id,ucic_id,filler1,filler2,filler3,filler4,filler5,filler6,filler7,filler8,filler9,filler10,filler11,filler12,filler13,filler14,filler15";
public $EMPCacheCols="mobile,emailid,altphone1,altphone2,altphone3,altphone4,altphone5,altphone6,altphone7,altphone8,altphone9,altphone10,client,status,clientinternalid,dialer_status,dialer_substatus,dialer_callback,dialer_remarks,dialer_flag,dialer_lastcall,priority,crmlist_id,group,bttc,service_vs_product,resolution,satisfaction,final_call_assessment,question,mf_isa,DOB,other_information,agreementid,applied_amount,city,comp_code,company,completeddate,cust_id,cust_name,customer_name,disb_date,emi_hl,eqty_amt,foir,ins_amt,int_rate,irr,loan_amount,location,mf_amt,nth,offer_amt,outstanding,pf,ph_mob,ph_off,ph_res,pl_offer,proc_fee,product_flag,profile_new,rank,segment,tenure,tu_application_id,ucic_id,filler1,filler2,filler3,filler4,filler5,filler6,filler7,filler8,filler9,filler10,filler11,filler12,filler13,filler14,filler15,dialer_appointment";
public $USRCacheCols="id,username,password,fullname,email,status,organization,group,data,presence,timezone,invisible,usertype,diskuse,source,meta,lteam,lteam2,supervisor,created_at,updated_at,remember_token,passwordreset,number1,number2,exten,extencontext,manager";
......@@ -839,6 +839,11 @@ function popMail($userid)
if($tuser)if($tuser->moduleACL("admin",false,false,true))$res=true;
return $res;
}
function getSelClient()
{
return Auth::user()->sel_campaign;
}
function getPersonOld($empid)
{
......@@ -853,11 +858,29 @@ function popMail($userid)
}
else return FALSE;
}
function getPerson($empid)
function getPersonIDsWithLike($key,$value,$client=""){
if($client == ""){
$records = "records";
}else{
$records = "records_$client";
}
return $this->LoadAll("select id from $records where $key like '%$value%'");
}
function getPerson($empid,$client)
{
/*if($this->getCount("records","id='$empid'")==1)
{*/
if($empdata=$this->LoadSingle("select peopledata,modifylog,dirty from records where id='$empid';"))
if($client == ""){
$records = "records";
}else{
$records = "records_$client";
}
if($empdata=$this->LoadSingle("select peopledata,modifylog,dirty from $records where id='$empid';"))
{
//$empdata=$this->LoadSingle("select * from records where id='$empid';");
$personarr['peopledata']=unserialize($empdata['peopledata']);
......@@ -936,11 +959,11 @@ function popMail($userid)
else return FALSE;
}
function setPersonKey($empid,$key,$val,$username="")
function setPersonKey($empid,$key,$val,$username="",$client)
{
$cachestr='';if(in_array($key,$this->cachearray))$cachestr=" ,`$key`='$val' ";
$personarr=$this->getPerson($empid);
$personarr=$this->getPerson($empid,$client);
if(is_array($personarr['peopledata']))
{
if($personarr['peopledata'][$key]!=$val)
......@@ -957,14 +980,14 @@ function popMail($userid)
}
$personarr['peopledata'][$key]=$val;
$res=$this->setPerson($empid,$personarr);
$res=$this->setPerson($empid,$personarr,$client);
return $res;
}
return true;
}
else return false;
}
function setPerson($empid,&$personarr)
function setPerson($empid,&$personarr,$client)
{
//if($this->getCount("records","id='$empid'")==1&&is_array($personarr['peopledata']))
if($empid!=""&&is_array($personarr['peopledata']))
......@@ -1018,14 +1041,18 @@ function popMail($userid)
{
$setComntArr = array();
$setComntArr['clientcode']=$personarr['peopledata']['clientcode'];
$setComntArr['clientcode']=$personarr['peopledata']['cust_id'];
$setComntArr['agent']=Auth::user()->username;
$setComntArr['agent_comments']=$personarr['agentcomments'];
$this->setComment($setComntArr['clientcode'],$setComntArr);
}
return $this->Query("update records set modified=now(),peopledata='$quoteP',modifylog='0',dirty='$quoteD' $cachestr where id='$empid' limit 1");
if($client!=''){
$recordsTable = 'records_'.$client;
}else{
$recordsTable = 'records';
}
return $this->Query("update $recordsTable set modified=now(),peopledata='$quoteP',modifylog='0',dirty='$quoteD' $cachestr where id='$empid' limit 1");
}
}
else return -1;
......@@ -1144,11 +1171,16 @@ function popMail($userid)
}
}
function getPersonIDs($wheresql)
function getPersonIDs($wheresql,$client)
{
return $this->LoadAll("select id from records where $wheresql");
if($client==""){
$recordsTable = "records";
}else{
$recordsTable = "records_".$client;
}
return $this->LoadAll("select id from $recordsTable where $wheresql");
}
function getPersonshome($wheresql)
function getPersonshome($wheresql,$client)
{
$sqlarr="";
foreach($this->cachearray as $cachekey)
......@@ -1158,10 +1190,14 @@ function popMail($userid)
$sqlarr.=" ,`$cachekey`";
}
}
return $this->LoadAll("select id".$sqlarr." from records where $wheresql;");
if($client==""){
$recordsTable = "records";
}else{
$recordsTable = "records_".$client;
}
return $this->LoadAll("select id".$sqlarr." from $recordsTable where $wheresql;");
}
function getPersons($wheresql)
function getPersons($wheresql,$client)
{
$sqlarr="";
foreach($this->cachearray as $cachekey)
......@@ -1171,8 +1207,12 @@ function popMail($userid)
$sqlarr.=" ,`$cachekey`";
}
}
return $this->LoadAll("select id,created,modified,peopledata,modifylog,dirty".$sqlarr." from records where $wheresql;");
if($client==""){
$recordsTable = "records";
}else{
$recordsTable = "records_".$client;
}
return $this->LoadAll("select id,created,modified,peopledata,modifylog,dirty".$sqlarr." from $recordsTable where $wheresql;");
}
function isWorkingEmployee(&$ppldata,$year,$month,$date=0)
......@@ -1398,6 +1438,21 @@ function popMail($userid)
//print_r($company);
return $companyar;
}
function getDispositionList(){
$dispositionPlan = DB::table('disposition')->join('sub_disposition', 'disposition.id', '=', 'sub_disposition.dispo_id')
->select('disposition.id as dispoId', 'disposition.name as disposition','disposition.code as code','disposition.status AS status',
DB::raw('count(*) as totalSubDispo, sub_disposition.id'),
DB::raw('GROUP_CONCAT(sub_disposition.name) as sunDispoName, sub_disposition.name'))
->groupBy('sub_disposition.dispo_id')
->where('status','active')
->get();
return $dispositionPlan;
}
function getEmailListforClient($tclient)
{
$unameslist=array();
......@@ -1593,26 +1648,6 @@ function popMail($userid)
}
function clientsReadAccess()
{
/* $companyarr=$this->LoadAll("select * from hrms_masters where mtype='company' and status='active'");
$campaigns=array();
$now = new \DateTime();
foreach($companyarr as $tcompany){
$campaigns[]=$tcompany['mkey'];
}
foreach($companyarr as $tcompany){
$campaignstartdate = new \DateTime($tcompany['campaignstartdate']);
$campaignenddate = new \DateTime($tcompany['campaignenddate']);
if(empty($tcompany['campaignstartdate']) || empty($tcompany['campaignenddate'])){
print_r($tcompany['mkey']);
$campaigns[]=$tcompany['mkey'];
}else{
if($campaignstartdate < $now and $campaignenddate > $now){
print_r($tcompany['mkey']);
$campaigns[]=$tcompany['mkey'];
}
}
}*/
$clientlst=array();
if($this->GetBBBUserData("readotherdata")=="No")
{
......@@ -1645,16 +1680,17 @@ function popMail($userid)
}
$activeClientCampaign = array();
$companyarr=$this->LoadAll("select * from hrms_masters where mtype='company' and status='active'");
//$recordsArry=$this->LoadAll("select client from records group by client");
//$records=array();
$campaigns=array();
$dashboarduser=Auth::user();
$timeoffset = $dashboarduser->timezone; //-330; //$dashboarduser->timezone;
$timeoffset = $timeoffset*60;
$now = strtotime(date("Y-m-d H:i:s"))-$timeoffset;
$now = strtotime(date("H:i:s"))-$timeoffset;
foreach($companyarr as $tcompany){
$campaignstartdate = strtotime($tcompany['campaignstartdate']);
$campaignenddate = strtotime($tcompany['campaignenddate']);
if($tcompany['campaignstartdate'] == '0000-00-00 00:00:00' || $tcompany['campaignenddate'] == '0000-00-00 00:00:00'){
if($tcompany['campaignstartdate'] == '00:00:00' and $tcompany['campaignenddate'] == '00:00:00'){
$campaigns[]=$tcompany['mkey'];
}else{
if($campaignstartdate < $now and $campaignenddate > $now){
......@@ -1667,12 +1703,55 @@ function popMail($userid)
$activeClientCampaign[]=$value;
}
}
/*$activeClientCampaign1=array();
foreach($recordsArry as $records){
if(in_array($records['client'],$activeClientCampaign)){
$activeClientCampaign1[]=$records['client'];
}else{
continue;
}
}*/
//Log::info($activeClientCampaign1);
return $activeClientCampaign;
}
function clientsOwnerRWAccess()
{
$clientlst=array_unique(array_merge(explode(",",$this->GetBBBUserData("clientsownerlist")),explode(",",$this->GetBBBUserData("clientslist"))));
return $clientlst;
$activeClientCampaign = array();
$companyarr=$this->LoadAll("select * from hrms_masters where mtype='company' and status='active'");
//$recordsArry=$this->LoadAll("select client from records group by client");
//$records=array();
$campaigns=array();
$dashboarduser=Auth::user();
$timeoffset = $dashboarduser->timezone; //-330; //$dashboarduser->timezone;
$timeoffset = $timeoffset*60;
$now = strtotime(date("H:i:s"))-$timeoffset;
foreach($companyarr as $tcompany){
$campaignstartdate = strtotime($tcompany['campaignstartdate']);
$campaignenddate = strtotime($tcompany['campaignenddate']);
if($tcompany['campaignstartdate'] == '00:00:00' and $tcompany['campaignenddate'] == '00:00:00'){
$campaigns[]=$tcompany['mkey'];
}else{
if($campaignstartdate < $now and $campaignenddate > $now){
$campaigns[]=$tcompany['mkey'];
}
}
}
foreach ($clientlst as $key => $value) {
if(in_array($value, $campaigns)){
$activeClientCampaign[]=$value;
}
}
/*$activeClientCampaign1=array();
foreach($recordsArry as $records){
if(in_array($records['client'],$activeClientCampaign)){
$activeClientCampaign1[]=$records['client'];
}else{
continue;
}
}*/
return $activeClientCampaign;
//return $clientlst;
}
function generateRandomString($length = 10)
{
......
......@@ -17,6 +17,8 @@ use PAMI\Message\Event\NewstateEvent;
use PAMI\Message\Event\OriginateResponseEvent;
use PAMI\Message\Event\HangupEvent;
use PAMI\Message\Event\UnknownEvent;
use PAMI\Message\Event\DialBeginEvent;
use PAMI\Message\Event\DialEndEvent;
use PAMI\Message\Action\AGIAction;
use PAMI\Message\Action\SIPNotifyAction;
......@@ -30,6 +32,8 @@ use PAMI\Message\Action\RedirectAction;
use PAMI\Message\Action\ConfbridgeMuteAction;
use PAMI\Message\Action\ConfbridgeUnmuteAction;
use PAMI\Message\Action\ActionMessage;
use PAMI\Message\Action\AttendedTransferAction;
use PAMI\Message\Action\BlindTransferAction;
use App\Models\Sipid;
use App\Models\User;
......@@ -103,6 +107,8 @@ class KPAMIListen implements IEventListener
else if ($event instanceof OriginateResponseEvent){$this->OriginateResponseEvent($event);}
else if ($event instanceof HangupEvent) {$this->HangupEvent($event);}
else if ($event instanceof UnknownEvent) {$this->UnknownEvent($event);}
else if ($event instanceof DialBeginEvent) {$this->DialBeginEvent($event);}
else if ($event instanceof DialEndEvent) {$this->DialEndEvent($event);}
//else var_dump($event);
}
......@@ -196,14 +202,16 @@ class KPAMIListen implements IEventListener
if($crmcall->crm_id>0)
{
$wakka = new KHRMSLib();
$record=$wakka->getPerson($crmcall->crm_id);
$record=$wakka->getPerson($crmcall->crm_id,$crmcall->client);
if($record)
{
DB::table('records_'.$crmcall->client)->where($crmcall->crm_id)->update(['filter_condition'=>'4']);
$record["peopledata"]["dialer_status"]="FORCEDCLOSE";
$record["peopledata"]["dialer_substatus"]="FORCEDCLOSE";
$record["peopledata"]["dialer_callback"]="";
$record["peopledata"]["dialer_remarks"]="";
$wakka->setPerson($crmcall->crm_id,$record);
$wakka->setPerson($crmcall->crm_id,$record,$crmcall->client);
$wakka->setPerson($crmcall->crm_id,$record,"");
}
}
......@@ -464,6 +472,7 @@ class KPAMIListen implements IEventListener
$dialline->number="";
$dialline->uniqueid="";
$dialline->channel="";
$dialline->did="";
$dialline->save();
}
......@@ -480,6 +489,102 @@ class KPAMIListen implements IEventListener
$crmcall->save();
}
}
else if($accountcodearr[1]=="a") // Code Added by AmolG: AutoDial
{
$crmcall=CRMCall::find($accountcodearr[2]);
if($crmcall)
{
$nowts=microtime(true)*1000;
$crmcall->setTs('ts_Recend',$nowts);
$crmcall->state=$eventname;
$crmcall->statuscode=$cause;
$crmcall->substatus=$causetxt;
if($crmcall->type=="Auto"&&$crmcall->user_id==0)
{
include( app_path() . '/Constants/gatewaydispo.php');
foreach($gatewaydispoArry as $key=>$value){
$gatewaydispo[]=$key;
}
if(in_array($cause, $gatewaydispo)){
$gatewayStatus=$gatewaydispoArry[$cause];
}else{
$gatewayStatus="AutoDROP";
}
$crmcall->userstatus=$gatewayStatus;
$crmcall->usersubstatus="AutoDROP";
$crmcall->setTs('ts_Talk',$nowts);
$crmcall->setTs('ts_Recstart',$nowts);
if($crmcall->crm_id>0)
{
$wakka = new KHRMSLib();
$record=$wakka->getPerson($crmcall->crm_id,$crmcall->client);
if($record)
{
$record["peopledata"]["status"]="Called";
$record["peopledata"]["dialer_status"]=$gatewayStatus;
$record["peopledata"]["dialer_substatus"]="AutoDROP";
//$record["peopledata"]["dialer_lastcall"]=date("Y-m-d H:i:s");
$wakka->setPerson($crmcall->crm_id,$record,$crmcall->client);
$wakka->setPerson($crmcall->crm_id,$record,"");
DB::table('records_'.$crmcall->client)->where('id',$crmcall->crm_id)->update(['filter_condition'=>'4']);
}
}
}
if($crmcall->type=="AutoCall")
{
$crmcall->userstatus="AutoCall";
$crmcall->usersubstatus="AutoCall";
$crmcall->setTs('ts_Talk',$nowts);
$crmcall->setTs('ts_Recstart',$nowts);
if($crmcall->crm_id>0)
{
$wakka = new KHRMSLib();
$record=$wakka->getPerson($crmcall->crm_id,$crmcall->client);
if($record)
{
$record["peopledata"]["status"]="Called";
$record["peopledata"]["dialer_status"]="AutoCall";
$record["peopledata"]["dialer_substatus"]="AutoCall";
$wakka->setPerson($crmcall->crm_id,$record,$crmcall->client);
$wakka->setPerson($crmcall->crm_id,$record,"");
}
}
}
$dialline=Dialline::find($crmcall->dialline_id);
if($dialline && ($dialline->channel==$channel || $dialline->status== "AutoCall"))
{
$dialline->status="Free";
$dialline->conf="";
$dialline->number="";
$dialline->uniqueid="";
$dialline->channel="";
$dialline->regexstr="";
$dialline->did="";
$dialline->save();
$tsip=Sipid::find($crmcall->sipid_id);
if(!empty($tsip))
{
$tsip->patched=0;
$tsip->save();
}
$newqueue=new Kqueue();
$newqueue->sipNotify($tsip,"dialerUI","hangup","c",$crmcall->id."~".$crmcall->number."~".base64_encode($channel));
}
$crmcall->addEventLog($nowts,"$accountcode:HangupEvent : $eventname $channelstate:$channelstatedesc $uniqueid $exten:$priority $channel $cause:$causetxt");
$crmcall->save();
}
}
}
}
else
......@@ -569,6 +674,196 @@ class KPAMIListen implements IEventListener
}
}
}
private function DialBeginEvent(EventMessage $event)
{
$eventname = "DialBegin";
$channel=$event->getKey("Channel");
$channelstate=$event->getKey("ChannelState");
$channelstatedesc=$event->getKey("ChannelStateDesc");
$accountcode=$event->getKey("AccountCode");
$exten=$event->getKey("Exten");
$priority=$event->getKey("Priority");
$uniqueid=$event->getKey("Uniqueid");
$dchannel=$event->getKey("DestChannel");
$dchannelstate=$event->getKey("DestChannelState");
$dchannelstatedesc=$event->getKey("DestChannelStateDesc");
$daccountcode=$event->getKey("DestAccountCode");
$dexten=$event->getKey("DestExten");
$dpriority=$event->getKey("DestPriority");
$duniqueid=$event->getKey("DestUniqueid");
$dialstring=$event->getKey("DialString");
if($accountcode!="")
{
//echo "$accountcode:Unknown : $eventname $channelstate:$channelstatedesc $uniqueid $exten:$priority $channel\n";
//echo "$accountcode:Unknown : $eventname $dchannelstate:$dchannelstatedesc $duniqueid $dexten:$dpriority $dchannel $dialstring\n";
echo "$accountcode:$eventname $dexten:$dpriority $dchannel $dialstring\n";
$accountcodearr=explode("|",$accountcode);
if($accountcodearr[0]=="m")
{
if($accountcodearr[1]=="u")
{
$sipid=Sipid::find($accountcodearr[2]);
if($sipid)
{
$data=json_decode($sipid->clients,true);
$data['channel']=$dchannel;
$sipid->clients=json_encode($data);
$sipid->save();
$newqueue=new Kqueue();
$newqueue->sipNotify($sipid,"dialerUI","dialstart","u","~~".base64_encode($dchannel));
}
}
if($accountcodearr[1]=="c")
{
$crmcall=CRMCall::find($accountcodearr[2]);
if($crmcall)
{
$nowts=microtime(true)*1000;
$crmcall->setTs('ts_Call',$nowts);
$crmcall->state=$eventname;
$dialline=Dialline::find($crmcall->dialline_id);
if($dialline)
{
$dialline->channel=$dchannel;
$dialline->save();
}
$tsip=Sipid::find($crmcall->sipid_id);
$newqueue=new Kqueue();
$newqueue->sipNotify($tsip,"dialerUI","dialstart","c",$crmcall->id."~".$crmcall->number."~".base64_encode($dchannel));
$crmcall->addEventLog($nowts,"$accountcode:Unknown : $eventname $dchannelstate:$dchannelstatedesc $duniqueid $dexten:$dpriority $dchannel $dialstring");
$crmcall->save();
}
}
}
}
}
private function DialEndEvent(EventMessage $event)
{
$eventname = "DialEnd";
$channel=$event->getKey("Channel");
$channelstate=$event->getKey("ChannelState");
$channelstatedesc=$event->getKey("ChannelStateDesc");
$accountcode=$event->getKey("AccountCode");
$exten=$event->getKey("Exten");
$priority=$event->getKey("Priority");
$uniqueid=$event->getKey("Uniqueid");
$dchannel=$event->getKey("DestChannel");
$dchannelstate=$event->getKey("DestChannelState");
$dchannelstatedesc=$event->getKey("DestChannelStateDesc");
$daccountcode=$event->getKey("DestAccountCode");
$dexten=$event->getKey("DestExten");
$dpriority=$event->getKey("DestPriority");
$duniqueid=$event->getKey("DestUniqueid");
$dialstatus=$event->getKey("DialStatus");
if($accountcode!="")
{
//echo "$accountcode:Unknown : $eventname $channelstate:$channelstatedesc $uniqueid $exten:$priority $channel\n";
//echo "$accountcode:Unknown : $eventname $dchannelstate:$dchannelstatedesc $duniqueid $dexten:$dpriority $dchannel $dialstatus\n";
echo "$accountcode:$eventname $dexten:$dpriority $dchannel $dialstatus\n";
$accountcodearr=explode("|",$accountcode);
if($accountcodearr[0]=="m")
{
if($accountcodearr[1]=="u")
{
if($dialstatus=="ANSWER")
{
$sipid=Sipid::find($accountcodearr[2]);
if($sipid)
{
$sipid->confup=1;
$sipid->save();
}
}
}
else if($accountcodearr[1]=="c")
{
$crmcall=CRMCall::find($accountcodearr[2]);
if($crmcall)
{
$nowts=microtime(true)*1000;
$crmcall->setTs('ts_Talk',$nowts);
$crmcall->state=$eventname;
$crmcall->status=$dialstatus;
$dialline=Dialline::find($crmcall->dialline_id);
if($dialline)
{
$dialline->channel=$channel;
$dialline->save();
}
$recfile=$crmcall->newRecFilePath();
$tsip=Sipid::find($crmcall->sipid_id);
//start recording
$newqueue=new Kqueue();
$newqueue->recordChannel($tsip->server,$dchannel,$recfile);
$crmcall->setTs('ts_Recstart',$nowts);
//notify UI (only the sip id)
$newqueue=new Kqueue();
$newqueue->sipNotify($tsip,"dialerUI","dialend","c",$crmcall->id."~".$crmcall->number."~".base64_encode($channel));
$crmcall->addEventLog($nowts,"$accountcode:Unknown : $eventname $dchannelstate:$dchannelstatedesc $duniqueid $dexten:$dpriority $dchannel $dialstatus");
$crmcall->save();
}
}
else if($accountcodearr[1]=="a") // Code Added by AmolG: AutoDial
{
$crmcall=CRMCall::find($accountcodearr[2]);
if($crmcall)
{
$nowts=microtime(true)*1000;
$crmcall->setTs('ts_Talk',$nowts);
$crmcall->state=$eventname;
$crmcall->status=$dialstatus;
$crmcall->uniqueid=$uniqueid;
$dialline=Dialline::find($crmcall->dialline_id);
if($dialline && $dialstatus=="ANSWER")
{
$dialline->channel=$dchannel;
$dialline->uniqueid=$uniqueid;
$dialline->status="Auto";
$dialline->save();
}
$crmcall->addEventLog($nowts,"$accountcode:Unknown : $eventname $dchannelstate:$dchannelstatedesc $duniqueid $dexten:$dpriority $dchannel $dialstatus");
$crmcall->type="Auto";
$crmcall->save();
}
}
}
}
}
private function UnknownEvent(EventMessage $event)
{
$eventname=$event->getKey("Event");
......@@ -742,7 +1037,7 @@ class KPAMIListen implements IEventListener
$dialline=Dialline::find($crmcall->dialline_id);
if($dialline)
{
$dialline->channel=$dchannel;
$dialline->channel=$channel;
$dialline->save();
}
......@@ -758,12 +1053,41 @@ class KPAMIListen implements IEventListener
//notify UI (only the sip id)
$newqueue=new Kqueue();
$newqueue->sipNotify($tsip,"dialerUI","dialend","c",$crmcall->id."~".$crmcall->number."~".base64_encode($dchannel));
$newqueue->sipNotify($tsip,"dialerUI","dialend","c",$crmcall->id."~".$crmcall->number."~".base64_encode($channel));
$crmcall->addEventLog($nowts,"$accountcode:Unknown : $eventname $dchannelstate:$dchannelstatedesc $duniqueid $dexten:$dpriority $dchannel $dialstatus");
$crmcall->save();
}
}
else if($accountcodearr[1]=="a") // Code Added by AmolG: AutoDial
{
$crmcall=CRMCall::find($accountcodearr[2]);
if($crmcall)
{
$nowts=microtime(true)*1000;
$crmcall->setTs('ts_Talk',$nowts);
$crmcall->state=$eventname;
$crmcall->status=$dialstatus;
$crmcall->uniqueid=$uniqueid;
$dialline=Dialline::find($crmcall->dialline_id);
if($dialline && $dialstatus=="ANSWER")
{
$dialline->channel=$dchannel;
$dialline->uniqueid=$uniqueid;
$dialline->status="Auto";
$dialline->save();
}
$crmcall->addEventLog($nowts,"$accountcode:Unknown : $eventname $dchannelstate:$dchannelstatedesc $duniqueid $dexten:$dpriority $dchannel $dialstatus");
$crmcall->type="Auto";
$crmcall->save();
}
}
}
}
......@@ -1027,12 +1351,38 @@ class KPAMIListen implements IEventListener
private function redirectIncoming()
{
$diallines=Dialline::where('server','=',$this->sipip)->where("status","=","Inbound")->where("conf","=","")->get();
$diallines=Dialline::where('server','=',$this->sipip)->whereIn("status",["Inbound","Auto"])->where("conf","=","")->get();
if($diallines)
{
foreach($diallines as $dialline)
{
exec("/usr/sbin/asterisk -rx 'core show channels'",$allChnnlsArr);
$cnt = 0;
foreach($allChnnlsArr as $allChnnls)
{
if(stristr($allChnnls, substr(stripslashes($dialline->channel),0, 20)))
{
$cnt++;
}
}
if($cnt == 0)
{
Log::useFiles(storage_path()."/logs/Predictive/predictive_".date("Y_m_d").".log");
Log::info($dialline);
$dialline->status="Free";
$dialline->conf="";
$dialline->number="";
$dialline->uniqueid="";
$dialline->src_channel="";
$dialline->channel="";
$dialline->regexstr="";
$dialline->save();
continue;
}
echo $dialline->number." waiting\n";
$crmcall=CRMCall::where("uniqueid","like","%".$dialline->uniqueid."%")->first();
......@@ -1080,15 +1430,15 @@ class KPAMIListen implements IEventListener
$sipids=array();
if($crmcall->client!="")
{
$sipids=Sipid::where('server','=',$this->sipip)->where("status","=","1")->where("clients","like","%".$crmcall->client."%")->where("clients","like","%".$crmcall->did."%")->get();
$sipids=Sipid::where('server','=',$this->sipip)->where("status","=","1")->where("clients","like","%".$crmcall->client."%")->where("clients","like","%".$crmcall->did."%")->orderBy("updated_at","desc")->get();
}
else if($crmcall->did!="")
{
$sipids=Sipid::where('server','=',$this->sipip)->where("status","=","1")->where("clients","like","%".$crmcall->did."%")->get();
$sipids=Sipid::where('server','=',$this->sipip)->where("status","=","1")->where("clients","like","%".$crmcall->did."%")->orderBy("updated_at","desc")->get();
}
else
{
$sipids=Sipid::where('server','=',$this->sipip)->where("status","=","1")->get();//send to all?
$sipids=Sipid::where('server','=',$this->sipip)->where("status","=","1")->orderBy("updated_at","desc")->get();//send to all?
}
if(!empty($sipids))
......@@ -1099,7 +1449,30 @@ class KPAMIListen implements IEventListener
$first_r=0;$first_w=0;$first_a=0;$allsipids=array();
foreach($sipids as $sipid)
{
if($sipid->ready==1)
//if($sipid->ready==1)
if($sipid->ready==1&&$sipid->prepare_call==0&&$dialline->status=="Inbound")
{
$clientsarr=json_decode($sipid->clients,true);
if($crmcall->client=="")$first_a=$sipid;
else
{
if($clientsarr['a']!="")$clientaarr = explode(",", $clientsarr['a']);
if(isset($clientsarr['a'])&&in_array($crmcall->client, $clientaarr))$first_a=$sipid;
if($clientsarr['w']!="")$clientwarr = explode(",", $clientsarr['w']);
if(isset($clientsarr['w'])&&in_array($crmcall->client, $clientwarr))$first_w=$sipid;
if($clientsarr['r']!="")$clientrarr = explode(",", $clientsarr['r']);
if(isset($clientsarr['r'])&&in_array($crmcall->client, $clientrarr))$first_r=$sipid;
}
}
else
{
$allsipids[]=$sipid;
}
}
foreach($sipids as $sipid)
{
if($sipid->ready==1&&$sipid->prepare_call==1&&$dialline->status=="Auto")
{
$clientsarr=json_decode($sipid->clients,true);
if($crmcall->client=="")$first_a=$sipid;
......@@ -1163,8 +1536,13 @@ class KPAMIListen implements IEventListener
$dialline->conf="1000".$found->id;
$dialline->save();
if($crmcall->crm_id>0){
DB::table('records')->where('id',$crmcall->crm_id)->update(['filter_condition'=>'3','usr_id'=>$found->user]);
}
$found->ready=0;
$found->prepare_call=0;
$found->patched=1;
$found->save();
$recfile=$crmcall->newRecFilePath();
......@@ -1195,10 +1573,15 @@ class KPAMIListen implements IEventListener
{
foreach($allsipids as $tsip)
{
//$newqueue=new Kqueue();
//$newqueue->sipNotify($tsip,"popupalert"," Incoming Calls",$crmcall->number."|".$crmcall->client,"");
if($dialline->status!="Auto")
{
$newqueue=new Kqueue();
$newqueue->sipNotify($tsip,"popupalert"," Incoming Calls",$crmcall->number."|".$crmcall->client,"");
}
}
}
else
{
//play no users available
......@@ -1319,7 +1702,11 @@ class KPAMIListen implements IEventListener
$redirect=new RedirectAction($data['fromext'], $data['toext'], $data['context'], 1);
$res=$this->_client->send($redirect);
}
else if($tqueue->key=="transfer")
{
$attendedtransferaction=new AttendedTransferAction($data['channel'],$data['exten'],$data['context'],"1");
$res=$this->_client->send($attendedtransferaction);
}
$tqueue->delete();
}
}
......
<?php namespace App\Jobs;
use PAMI\Client\Impl\ClientImpl;
use PAMI\Listener\IEventListener;
use PAGI\Application\PAGIApplication;
use PAGI\Client\AbstractClient;
use PAMI\Message\Event\NewextenEvent;
use PAMI\Message\Event\AsyncAGIEvent;
use PAMI\Message\Event\EventMessage;
use PAMI\Message\Event\PeerStatusEvent;
use PAMI\Message\Event\ExtensionStatusEvent;
use PAMI\Message\Event\NewchannelEvent;
use PAMI\Message\Event\VarSetEvent;
use PAMI\Message\Event\NewCalleridEvent;
use PAMI\Message\Event\NewstateEvent;
use PAMI\Message\Event\OriginateResponseEvent;
use PAMI\Message\Event\HangupEvent;
use PAMI\Message\Event\UnknownEvent;
use PAMI\Message\Event\DialBeginEvent;
use PAMI\Message\Event\DialEndEvent;
use PAMI\Message\Action\AGIAction;
use PAMI\Message\Action\SIPNotifyAction;
use PAMI\Message\Action\OriginateAction;
use PAMI\Message\Action\CommandAction;
use PAMI\Message\Action\GetVarAction;
use PAMI\Message\Action\SetVarAction;
use PAMI\Message\Action\HangupAction;
use PAMI\Message\Action\MixMonitorAction;
use PAMI\Message\Action\RedirectAction;
use PAMI\Message\Action\ConfbridgeMuteAction;
use PAMI\Message\Action\ConfbridgeUnmuteAction;
use PAMI\Message\Action\ActionMessage;
use PAMI\Message\Action\AttendedTransferAction;
use PAMI\Message\Action\BlindTransferAction;
use App\Models\Sipid;
use App\Models\User;
use App\Models\UserLog;
use App\Models\CRMCall;
use App\Models\Kqueue;
use App\Models\Dialline;
use App\Jobs\KHRMSLib;
use DB;
use Config;
use Log;
class KPAMIListen implements IEventListener
{
private $_client;
private $_id;
private $_pamiOptions;
private $sipip="";
public function __construct($sipip)
{
$this->sipip=$sipip;
$options = array('host' => $sipip,'port' => '5038','username' => 'kstychAMIAdmin','secret' => 'yb9738z_kstych','connect_timeout' => 10000,'read_timeout' => 10000,'scheme' => 'tcp://');
$this->_pamiOptions = $options;
$this->_client = new ClientImpl($options);
$this->_id = $this->_client->registerEventListener($this);
Config::set('runtime.echosqllogs',Config::get("app.echosqllogs"));
}
public function run()
{
$pid1 = pcntl_fork();
if(!$pid1)
{
DB::reconnect();
while(true)
{
usleep(2000*1000);
$this->redirectIncoming();
}
return;
}
$i=1;
DB::reconnect();
$this->_client->open();
while(true)
{
usleep(1000);
$this->_client->process();
if($i++%100==0)$this->sendAMICommands();if($i>1000)$i=1;
}
$this->_client->close();
}
public function handle(EventMessage $event)
{
//Log::info($event);
if ($event instanceof AsyncAGIEvent) {}
else if ($event instanceof PeerStatusEvent) {$this->PeerStatusEvent($event);}
else if ($event instanceof ExtensionStatusEvent) {$this->ExtensionStatusEvent($event);}
else if ($event instanceof NewchannelEvent) {$this->NewchannelEvent($event);}
else if ($event instanceof NewextenEvent) {$this->NewextenEvent($event);}
else if ($event instanceof VarSetEvent) {$this->VarSetEvent($event);}
else if ($event instanceof NewCalleridEvent) {$this->NewCalleridEvent($event);}
else if ($event instanceof NewstateEvent) {$this->NewstateEvent($event);}
else if ($event instanceof OriginateResponseEvent){$this->OriginateResponseEvent($event);}
else if ($event instanceof HangupEvent) {$this->HangupEvent($event);}
else if ($event instanceof UnknownEvent) {$this->UnknownEvent($event);}
else if ($event instanceof DialBeginEvent) {$this->DialBeginEvent($event);}
else if ($event instanceof DialEndEvent) {$this->DialEndEvent($event);}
//else var_dump($event);
}
private function PeerStatusEvent(EventMessage $event)
{
$status=0;$userstatus=0;
if($event->getPeerStatus()=="Registered"||$event->getPeerStatus()=="Reachable")$status=1;
$nowts=microtime(true)*1000;
$peerdata=explode("/",$event->getPeer());
if(strtolower($peerdata[0])=="sip")
{
$id=intval($peerdata[1]);
if($id>0)
{
$sipid=Sipid::where('server','=',$this->sipip)->where('id','=',$id)->first();
if($sipid&&$sipid->status!=$status)
{
$sipid->status=$status;
$data=json_decode($sipid->clients,true);
if($status==0)
{
if($sipid->confup==1)
{
if(isset($data['channel']))
{
$newqueue=new Kqueue();
$newqueue->hangupChannelS($data['channel'],$sipid->server);
}
}
$sipid->ready=0;$sipid->confup=0;$sipid->clients="";
}
else
{
if(isset($data['keepconf'])&&$data['keepconf']==1)
{
$newqueue=new Kqueue();
$newqueue->userToConf($sipid);
}
}
$sipid->save();
$user=User::find($sipid->user);
if($user)
{
$userstatus=0+intval(Sipid::where("user","=",$sipid->user)->max('status'));
if($user->presence!=$userstatus)
{
if($userstatus==1)
{
$userlog=new UserLog();
$userlog->startLog($user);
$userlog->getLastTs($sipid->id,$nowts);
$userlog->save();
}
else if($userstatus==0)
{
$userlog=UserLog::where('user_id','=',$user->id)->orderBy("id","DESC")->first();
if($userlog)
{
$userlog->stopLog();
$userlog->getLastTs($sipid->id,$nowts);
$userlog->save();
}
}
$user->presence=$userstatus;
$user->save();
$frndlib=new KFriendLib();
$noty=new KPushNotify();
$noty->send($frndlib->myFrndList($user->id),"presence",$user->dispname(),$user->presence,$user->id);
}
//close any calls
if($status==0)
{
$crmcalls=CRMCall::where("sipid_id","=",$sipid->id)->where("user_id","=",$sipid->user)->whereRaw('ts_Dispo = ts_Close')->where('userstatus','=','')->where('created_at','>=',date('Y-m-d 00:00:00'))->get();
foreach($crmcalls as $crmcall)
{
$crmcall->setTs('ts_Close',$nowts);
$crmcall->userstatus="FORCEDCLOSE";
$crmcall->usersubstatus="FORCEDCLOSE";
$crmcall->call_flag="Z";
if($crmcall->crm_id>0)
{
$wakka = new KHRMSLib();
$record=$wakka->getPerson($crmcall->crm_id,$crmcall->client);
if($record)
{
DB::table('records_'.$crmcall->client)->where($crmcall->crm_id)->update(['filter_condition'=>'4']);
$record["peopledata"]["dialer_status"]="FORCEDCLOSE";
$record["peopledata"]["dialer_substatus"]="FORCEDCLOSE";
$record["peopledata"]["dialer_callback"]="";
$record["peopledata"]["dialer_remarks"]="";
$wakka->setPerson($crmcall->crm_id,$record,$crmcall->client);
$wakka->setPerson($crmcall->crm_id,$record,"");
}
}
$crmcall->saveRecFileSize();
$crmcall->save();
}
}
}
echo "Updated Sip: $sipid->id - $status Uid: $sipid->user - $userstatus\n";
}
}
}
}
private function ExtensionStatusEvent(EventMessage $event)
{
//echo "ExtensionStatusEvent : ".$event->getKey("Event")." -- ".$event->getKey("AccountCode")."\n";
}
private function NewchannelEvent(EventMessage $event)
{
$eventname=$event->getKey("Event");
$channel=$event->getKey("Channel");
$channelstate=$event->getKey("ChannelState");
$channelstatedesc=$event->getKey("ChannelStateDesc");
$accountcode=$event->getKey("AccountCode");
$context=$event->getKey("Context");
$exten=$event->getKey("Exten");
$priority=$event->getKey("Priority");
$uniqueid=$event->getKey("Uniqueid");
$phonenumber=$event->getKey("CallerIDNum");
$callerid=$event->getKey("CallerIDName");
echo "$accountcode:NewchannelEvent : $context:$eventname $channelstate:$channelstatedesc $uniqueid $phonenumber $exten:$priority $channel\n";
}
private function NewextenEvent(EventMessage $event)
{
$eventname=$event->getKey("Event");
$channel=$event->getKey("Channel");
$channelstate=$event->getKey("ChannelState");
$channelstatedesc=$event->getKey("ChannelStateDesc");
$accountcode=$event->getKey("AccountCode");
$context=$event->getKey("Context");
$exten=$event->getKey("Exten");
$priority=$event->getKey("Priority");
$uniqueid=$event->getKey("Uniqueid");
$phonenumber=$event->getKey("CallerIDNum");
$callerid=$event->getKey("CallerIDName");
//echo "$accountcode:NewextenEvent : $context:$eventname $channelstate:$channelstatedesc $uniqueid $phonenumber $exten:$priority $channel\n";
if($context=="kstychDialerINB"&&$exten!="s"&&$priority=="1")
{
if(strtolower(substr($channel,0,4))=="sip/")
{
$dahdispan='';
$dahdichannel='';
echo "$context:$eventname $phonenumber $exten:$priority $dahdispan:$dahdichannel $uniqueid\n";
$dialline=Dialline::where('server','=',$this->sipip)->where("dialstr","=",env("sip_dialstr"))->where("status","=","Free")->first();
if($dialline)
{
$dialline->status='Inbound';
$dialline->uniqueid=$uniqueid;
$dialline->number=$phonenumber;
$dialline->channel=$channel;
$dialline->save();
$nowts=microtime(true)*1000;
//start the call log
$crmcall=new CRMCall();
$crmcall->number=$phonenumber;
$crmcall->user_id=0;//////
$crmcall->sipid_id=0;//////
$crmcall->did=$exten;
$crmcall->crm_id=0;
$crmcall->client=".";
$crmcall->department="";
$crmcall->state='Inbound';
$crmcall->type="Inbound";
$crmcall->status="ANSWER";
$crmcall->uniqueid=$uniqueid;
$crmcall->dialline_id=$dialline->id;
$crmcall->setTs('ts_Wait',$nowts);
$crmcall->group=$dialline->group;
$tdata=array();
$tdata['uniqueid']=$uniqueid;
$tdata['inboundchannel']=$channel;
$crmcall->data=json_encode($tdata);
$crmcall->save();
$userStatus=User::where("updated_at",">",date("Y-m-d"))->where("exten","like","%".substr($exten,-4)."%")->where("usertype","!=","Admin")->where('presence', '=', '1')->select('*')->get();
if($userStatus=="[]")
{
$newqueue=new Kqueue();
$newqueue->playbusyfile($dialline->channel,$dialline->server);
}
$callStat=CRMCall::where("did","like","%".substr($exten,-4)."%")->where("updated_at",">",date("Y-m-d"))->whereIn('state',['DialBegin', 'DialEnd'])->get();
if($callStat!="[]")
{
$newqueue=new Kqueue();
$newqueue->playbusyfile($dialline->channel,$dialline->server);
}
}
}
}
}
private function VarSetEvent(EventMessage $event)
{
$eventname=$event->getKey("Event");
$channel=$event->getKey("Channel");
$channelstate=$event->getKey("ChannelState");
$channelstatedesc=$event->getKey("ChannelStateDesc");
$accountcode=$event->getKey("AccountCode");
$exten=$event->getKey("Exten");
$priority=$event->getKey("Priority");
$uniqueid=$event->getKey("Uniqueid");
$variable=$event->getKey("Variable");
$value=$event->getKey("Value");
if($accountcode!="")
{
//echo "$accountcode:VarSetEvent : $eventname $channelstate:$channelstatedesc $uniqueid $exten:$priority $channel $variable=$value\n";
echo "$accountcode:$eventname $exten:$priority $variable=$value\n";
if($variable=="DIALSTATUS")
{
$accountcodearr=explode("|",$accountcode);
if($accountcodearr[0]=="m")
{
if($accountcodearr[1]=="c")
{
$crmcall=CRMCall::find($accountcodearr[2]);
if($crmcall)
{
$nowts=microtime(true)*1000;
$crmcall->status=$value;
$crmcall->addEventLog($nowts,"$accountcode:VarSetEvent : $eventname $channelstate:$channelstatedesc $uniqueid $exten:$priority $channel $variable=$value");
$crmcall->save();
}
}
}
}
}
}
private function NewCalleridEvent(EventMessage $event)
{
$eventname=$event->getKey("Event");
$channel=$event->getKey("Channel");
$channelstate=$event->getKey("ChannelState");
$channelstatedesc=$event->getKey("ChannelStateDesc");
$accountcode=$event->getKey("AccountCode");
$exten=$event->getKey("Exten");
$priority=$event->getKey("Priority");
$uniqueid=$event->getKey("Uniqueid");
//echo "$accountcode:NewCalleridEvent : $eventname $channelstate:$channelstatedesc $uniqueid $exten:$priority $channel\n";
}
private function NewstateEvent(EventMessage $event)
{
$eventname=$event->getKey("Event");
$channel=$event->getKey("Channel");
$channelstate=$event->getKey("ChannelState");
$channelstatedesc=$event->getKey("ChannelStateDesc");
$accountcode=$event->getKey("AccountCode");
$exten=$event->getKey("Exten");
$priority=$event->getKey("Priority");
$uniqueid=$event->getKey("Uniqueid");
//echo "$accountcode:NewstateEvent : $eventname $channelstate:$channelstatedesc $uniqueid $exten:$priority $channel\n";
}
private function OriginateResponseEvent(EventMessage $event)
{
$eventname=$event->getKey("Event");
$channel=$event->getKey("Channel");
$actionid=$event->getKey("ActionID");
$response=$event->getKey("Response");
$accountcode=$event->getKey("AccountCode");
$exten=$event->getKey("Exten");
$reason=$event->getKey("Reason");
$uniqueid=$event->getKey("Uniqueid");
//echo "$accountcode:OriginateResponseEvent : $eventname $actionid:$response $uniqueid $exten:$reason $channel\n";
}
private function HangupEvent(EventMessage $event)
{
$eventname=$event->getKey("Event");
$channel=$event->getKey("Channel");
$channelstate=$event->getKey("ChannelState");
$channelstatedesc=$event->getKey("ChannelStateDesc");
$accountcode=$event->getKey("AccountCode");
$exten=$event->getKey("Exten");
$priority=$event->getKey("Priority");
$uniqueid=$event->getKey("Uniqueid");
$context=$event->getKey("Context");
$cause=$event->getKey("Cause");
$causetxt=$event->getKey("Cause-txt");
if($accountcode!="")
{
//echo "$accountcode:HangupEvent : $eventname $channelstate:$channelstatedesc $uniqueid $exten:$priority $channel $cause:$causetxt\n";
echo "$accountcode:$eventname $exten:$priority $cause:$causetxt\n";
$accountcodearr=explode("|",$accountcode);
if($accountcodearr[0]=="m")
{
if($accountcodearr[1]=="u")
{
$sipid=Sipid::find($accountcodearr[2]);
if($sipid)
{
$sipid->confup=0;
$sipid->save();
}
}
else if($accountcodearr[1]=="c")
{
$crmcall=CRMCall::find($accountcodearr[2]);
if($crmcall)
{
$nowts=microtime(true)*1000;
$crmcall->setTs('ts_Recend',$nowts);
$crmcall->state=$eventname;
$crmcall->statuscode=$cause;
$crmcall->substatus=$causetxt;
$dialline=Dialline::find($crmcall->dialline_id);
if($dialline)
{
$dialline->status="Free";
$dialline->conf="";
$dialline->number="";
$dialline->uniqueid="";
$dialline->channel="";
$dialline->save();
}
$tsip=Sipid::find($crmcall->sipid_id);
//$newqueue=new Kqueue();
//$newqueue->playhangupfile($dialline->channel,$dialline->server);
$newqueue=new Kqueue();
$newqueue->sipNotify($tsip,"dialerUI","hangup","c",$crmcall->id."~".$crmcall->number."~".base64_encode($channel));
$crmcall->addEventLog($nowts,"$accountcode:HangupEvent : $eventname $channelstate:$channelstatedesc $uniqueid $exten:$priority $channel $cause:$causetxt");
$crmcall->save();
}
}
else if($accountcodearr[1]=="a") // Code Added by AmolG: AutoDial
{
$crmcall=CRMCall::find($accountcodearr[2]);
if($crmcall)
{
$nowts=microtime(true)*1000;
$crmcall->setTs('ts_Recend',$nowts);
$crmcall->state=$eventname;
$crmcall->statuscode=$cause;
$crmcall->substatus=$causetxt;
if($crmcall->type=="Auto"&&$crmcall->user_id==0)
{
$crmcall->userstatus="AutoDROP";
$crmcall->usersubstatus="AutoDROP";
$crmcall->setTs('ts_Talk',$nowts);
$crmcall->setTs('ts_Recstart',$nowts);
if($crmcall->crm_id>0)
{
$wakka = new KHRMSLib();
$record=$wakka->getPerson($crmcall->crm_id);
if($record)
{
$record["peopledata"]["status"]="Called";
$record["peopledata"]["dialer_status"]="AutoDROP";
$record["peopledata"]["dialer_substatus"]="AutoDROP";
//$record["peopledata"]["dialer_lastcall"]=date("Y-m-d H:i:s");
$wakka->setPerson($crmcall->crm_id,$record);
DB::table('records')->where('id',$crmcall->crm_id)->update(['filter_condition'=>'4']);
}
}
}
if($crmcall->type=="Auto" && $crmcall->user_id>0)
{
$crmcall->userstatus="AutoCall";
$crmcall->usersubstatus="AutoCall";
$crmcall->setTs('ts_Talk',$nowts);
$crmcall->setTs('ts_Recstart',$nowts);
if($crmcall->crm_id>0)
{
$wakka = new KHRMSLib();
$record=$wakka->getPerson($crmcall->crm_id);
if($record)
{
$record["peopledata"]["status"]="Called";
$record["peopledata"]["dialer_status"]="AutoCall";
$record["peopledata"]["dialer_substatus"]="AutoCall";
$wakka->setPerson($crmcall->crm_id,$record);
}
}
}
$dialline=Dialline::find($crmcall->dialline_id);
if($dialline && ($dialline->channel==$channel || $dialline->status== "AutoCall"))
{
$dialline->status="Free";
$dialline->conf="";
$dialline->number="";
$dialline->uniqueid="";
$dialline->channel="";
$dialline->regexstr="";
$dialline->save();
$tsip=Sipid::find($crmcall->sipid_id);
if(!empty($tsip))
{
$tsip->patched=0;
$tsip->save();
}
$newqueue=new Kqueue();
$newqueue->sipNotify($tsip,"dialerUI","hangup","c",$crmcall->id."~".$crmcall->number."~".base64_encode($channel));
}
$crmcall->addEventLog($nowts,"$accountcode:HangupEvent : $eventname $channelstate:$channelstatedesc $uniqueid $exten:$priority $channel $cause:$causetxt");
$crmcall->save();
}
}
}
}
else
{
echo "$context:$eventname $exten:$priority $cause:$causetxt $uniqueid\n";
$crmcall=CRMCall::where("uniqueid","=",$uniqueid)->first();
if($crmcall)
{
$nowts=microtime(true)*1000;
$crmcall->state=$eventname;
$crmcall->statuscode=$cause;
$crmcall->substatus=$causetxt;
if($crmcall->type=="Inbound"&&$crmcall->user_id==0)//InboundDROP
{
$userslist=User::where('exten','like' ,'%'.$crmcall->did.'%')->get();
foreach ($userslist as $ulist) {
$crmcall->user_id=$ulist->id;
}
if($crmcall->client==".")
{
$wakka = new KHRMSLib();
$users=$wakka->searchPhone("mobile",$crmcall->number);
if(!empty($users))
{
$ppldata=unserialize($users[0]['peopledata']);
$crmcall->crm_id=$users[0]['id'];
$crmcall->number=$users[0]['mobile'];
$crmcall->client=($ppldata['client']?$ppldata['client']:"");
$crmcall->department=($ppldata['department']?$ppldata['department']:"");
$wakka->setPersonKey($crmcall->crm_id,"dialer_lastcall",date("Y-m-d H:i:s"));
echo $users[0]['id']." -- ID Found\n";
}
else
{
$crmcall->crm_id=0;
$crmcall->client="";
$crmcall->department="";
echo "User Not Found!!\n";
}
$crmcall->save();
}
$crmcall->userstatus="InboundDROP";
$crmcall->usersubstatus="InboundDROP";
$crmcall->call_flag="Z";
$crmcall->setTs('ts_Talk',$nowts);
$crmcall->setTs('ts_Recstart',$nowts);
if($crmcall->crm_id>0)
{
$wakka = new KHRMSLib();
$record=$wakka->getPerson($crmcall->crm_id);
if($record)
{
$record["peopledata"]["dialer_status"]="InboundDROP";
$record["peopledata"]["dialer_substatus"]="InboundDROP";
$wakka->setPerson($crmcall->crm_id,$record);
}
}
}
$dialline=Dialline::find($crmcall->dialline_id);
if($dialline)
{
$dialline->status="Free";
$dialline->conf="";
$dialline->number="";
$dialline->uniqueid="";
$dialline->channel="";
$dialline->save();
}
$crmcall->setTs('ts_Recend',$nowts);
$crmcall->save();
$tsip=Sipid::find($crmcall->sipid_id);
if($tsip)
{
$newqueue=new Kqueue();
$newqueue->sipNotify($tsip,"dialerUI","hangup","c",$crmcall->id."~".$crmcall->number."~".base64_encode($channel));
}
}
}
}
private function DialBeginEvent(EventMessage $event)
{
$eventname = "DialBegin";
$channel=$event->getKey("Channel");
$channelstate=$event->getKey("ChannelState");
$channelstatedesc=$event->getKey("ChannelStateDesc");
$accountcode=$event->getKey("AccountCode");
$exten=$event->getKey("Exten");
$priority=$event->getKey("Priority");
$uniqueid=$event->getKey("Uniqueid");
$dchannel=$event->getKey("DestChannel");
$dchannelstate=$event->getKey("DestChannelState");
$dchannelstatedesc=$event->getKey("DestChannelStateDesc");
$daccountcode=$event->getKey("DestAccountCode");
$dexten=$event->getKey("DestExten");
$dpriority=$event->getKey("DestPriority");
$duniqueid=$event->getKey("DestUniqueid");
$dialstring=$event->getKey("DialString");
if($accountcode!="")
{
//echo "$accountcode:Unknown : $eventname $channelstate:$channelstatedesc $uniqueid $exten:$priority $channel\n";
//echo "$accountcode:Unknown : $eventname $dchannelstate:$dchannelstatedesc $duniqueid $dexten:$dpriority $dchannel $dialstring\n";
echo "$accountcode:$eventname $dexten:$dpriority $dchannel $dialstring\n";
$accountcodearr=explode("|",$accountcode);
if($accountcodearr[0]=="m")
{
if($accountcodearr[1]=="u")
{
$sipid=Sipid::find($accountcodearr[2]);
if($sipid)
{
$data=json_decode($sipid->clients,true);
$data['channel']=$dchannel;
$sipid->clients=json_encode($data);
$sipid->save();
$newqueue=new Kqueue();
$newqueue->sipNotify($sipid,"dialerUI","dialstart","u","~~".base64_encode($dchannel));
}
}
if($accountcodearr[1]=="c")
{
$crmcall=CRMCall::find($accountcodearr[2]);
if($crmcall)
{
$nowts=microtime(true)*1000;
$crmcall->setTs('ts_Call',$nowts);
$crmcall->state=$eventname;
$dialline=Dialline::find($crmcall->dialline_id);
if($dialline)
{
$dialline->channel=$dchannel;
$dialline->save();
}
$tsip=Sipid::find($crmcall->sipid_id);
$newqueue=new Kqueue();
$newqueue->sipNotify($tsip,"dialerUI","dialstart","c",$crmcall->id."~".$crmcall->number."~".base64_encode($dchannel));
$crmcall->addEventLog($nowts,"$accountcode:Unknown : $eventname $dchannelstate:$dchannelstatedesc $duniqueid $dexten:$dpriority $dchannel $dialstring");
$crmcall->save();
}
}
}
}
}
private function DialEndEvent(EventMessage $event)
{
$eventname = "DialEnd";
$channel=$event->getKey("Channel");
$channelstate=$event->getKey("ChannelState");
$channelstatedesc=$event->getKey("ChannelStateDesc");
$accountcode=$event->getKey("AccountCode");
$exten=$event->getKey("Exten");
$priority=$event->getKey("Priority");
$uniqueid=$event->getKey("Uniqueid");
$dchannel=$event->getKey("DestChannel");
$dchannelstate=$event->getKey("DestChannelState");
$dchannelstatedesc=$event->getKey("DestChannelStateDesc");
$daccountcode=$event->getKey("DestAccountCode");
$dexten=$event->getKey("DestExten");
$dpriority=$event->getKey("DestPriority");
$duniqueid=$event->getKey("DestUniqueid");
$dialstatus=$event->getKey("DialStatus");
Log::info($accountcode);
if($accountcode!="")
{
//echo "$accountcode:Unknown : $eventname $channelstate:$channelstatedesc $uniqueid $exten:$priority $channel\n";
//echo "$accountcode:Unknown : $eventname $dchannelstate:$dchannelstatedesc $duniqueid $dexten:$dpriority $dchannel $dialstatus\n";
echo "$accountcode:$eventname $dexten:$dpriority $dchannel $dialstatus\n";
$accountcodearr=explode("|",$accountcode);
if($accountcodearr[0]=="m")
{
if($accountcodearr[1]=="u")
{
if($dialstatus=="ANSWER")
{
$sipid=Sipid::find($accountcodearr[2]);
if($sipid)
{
$sipid->confup=1;
$sipid->save();
}
}
}
else if($accountcodearr[1]=="c")
{
$crmcall=CRMCall::find($accountcodearr[2]);
if($crmcall)
{
$nowts=microtime(true)*1000;
$crmcall->setTs('ts_Talk',$nowts);
$crmcall->state=$eventname;
$crmcall->status=$dialstatus;
$dialline=Dialline::find($crmcall->dialline_id);
if($dialline)
{
$dialline->channel=$channel;
$dialline->save();
}
$recfile=$crmcall->newRecFilePath();
$tsip=Sipid::find($crmcall->sipid_id);
//start recording
$newqueue=new Kqueue();
$newqueue->recordChannel($tsip->server,$dchannel,$recfile);
$crmcall->setTs('ts_Recstart',$nowts);
//notify UI (only the sip id)
$newqueue=new Kqueue();
$newqueue->sipNotify($tsip,"dialerUI","dialend","c",$crmcall->id."~".$crmcall->number."~".base64_encode($channel));
$crmcall->addEventLog($nowts,"$accountcode:Unknown : $eventname $dchannelstate:$dchannelstatedesc $duniqueid $dexten:$dpriority $dchannel $dialstatus");
$crmcall->save();
}
}
else if($accountcodearr[1]=="a") // Code Added by AmolG: AutoDial
{
$crmcall=CRMCall::find($accountcodearr[2]);
if($crmcall)
{
$nowts=microtime(true)*1000;
$crmcall->setTs('ts_Talk',$nowts);
$crmcall->state=$eventname;
$crmcall->status=$dialstatus;
$crmcall->uniqueid=$uniqueid;
$dialline=Dialline::find($crmcall->dialline_id);
if($dialline && $dialstatus=="ANSWER")
{
$dialline->channel=$dchannel;
$dialline->uniqueid=$uniqueid;
$dialline->status="Auto";
$dialline->save();
}
$crmcall->addEventLog($nowts,"$accountcode:Unknown : $eventname $dchannelstate:$dchannelstatedesc $duniqueid $dexten:$dpriority $dchannel $dialstatus");
$crmcall->type="Auto";
$crmcall->save();
}
}
}
}
}
private function UnknownEvent(EventMessage $event)
{
$eventname=$event->getKey("Event");
if($eventname=="NewConnectedLine")
{
$channel=$event->getKey("Channel");
$channelstate=$event->getKey("ChannelState");
$channelstatedesc=$event->getKey("ChannelStateDesc");
$accountcode=$event->getKey("AccountCode");
$exten=$event->getKey("Exten");
$priority=$event->getKey("Priority");
$uniqueid=$event->getKey("Uniqueid");
//echo "$accountcode:Unknown : $eventname $channelstate:$channelstatedesc $uniqueid $exten:$priority $channel\n";
}
if($eventname=="LocalBridge")
{
$l1channel=$event->getKey("LocalOneChannel");
$l1channelstate=$event->getKey("LocalOneChannelState");
$l1channelstatedesc=$event->getKey("LocalOneChannelStateDesc");
$l1accountcode=$event->getKey("LocalOneAccountCode");
$l1exten=$event->getKey("LocalOneExten");
$l1priority=$event->getKey("LocalOnePriority");
$l1uniqueid=$event->getKey("LocalOneUniqueid");
$l2channel=$event->getKey("LocalTwoChannel");
$l2channelstate=$event->getKey("LocalTwoChannelState");
$l2channelstatedesc=$event->getKey("LocalTwoChannelStateDesc");
$l2accountcode=$event->getKey("LocalTwoAccountCode");
$l2exten=$event->getKey("LocalTwoExten");
$l2priority=$event->getKey("LocalTwoPriority");
$l2uniqueid=$event->getKey("LocalTwoUniqueid");
//echo "$l1accountcode:Unknown : $eventname $l1channelstate:$l1channelstatedesc $l1uniqueid $l1exten:$l1priority $l1channel\n";
//echo "$l2accountcode:Unknown : $eventname $l2channelstate:$l2channelstatedesc $l2uniqueid $l2exten:$l2priority $l2channel\n";
}
if($eventname=="DialBegin")
{
$channel=$event->getKey("Channel");
$channelstate=$event->getKey("ChannelState");
$channelstatedesc=$event->getKey("ChannelStateDesc");
$accountcode=$event->getKey("AccountCode");
$exten=$event->getKey("Exten");
$priority=$event->getKey("Priority");
$uniqueid=$event->getKey("Uniqueid");
$dchannel=$event->getKey("DestChannel");
$dchannelstate=$event->getKey("DestChannelState");
$dchannelstatedesc=$event->getKey("DestChannelStateDesc");
$daccountcode=$event->getKey("DestAccountCode");
$dexten=$event->getKey("DestExten");
$dpriority=$event->getKey("DestPriority");
$duniqueid=$event->getKey("DestUniqueid");
$dialstring=$event->getKey("DialString");
if($accountcode!="")
{
//echo "$accountcode:Unknown : $eventname $channelstate:$channelstatedesc $uniqueid $exten:$priority $channel\n";
//echo "$accountcode:Unknown : $eventname $dchannelstate:$dchannelstatedesc $duniqueid $dexten:$dpriority $dchannel $dialstring\n";
echo "$accountcode:$eventname $dexten:$dpriority $dchannel $dialstring\n";
$accountcodearr=explode("|",$accountcode);
if($accountcodearr[0]=="m")
{
if($accountcodearr[1]=="u")
{
$sipid=Sipid::find($accountcodearr[2]);
if($sipid)
{
$data=json_decode($sipid->clients,true);
$data['channel']=$dchannel;
$sipid->clients=json_encode($data);
$sipid->save();
$newqueue=new Kqueue();
$newqueue->sipNotify($sipid,"dialerUI","dialstart","u","~~".base64_encode($dchannel));
}
}
if($accountcodearr[1]=="c")
{
$crmcall=CRMCall::find($accountcodearr[2]);
if($crmcall)
{
$nowts=microtime(true)*1000;
$crmcall->setTs('ts_Call',$nowts);
$crmcall->state=$eventname;
$dialline=Dialline::find($crmcall->dialline_id);
if($dialline)
{
$dialline->channel=$dchannel;
$dialline->save();
}
$tsip=Sipid::find($crmcall->sipid_id);
$newqueue=new Kqueue();
$newqueue->sipNotify($tsip,"dialerUI","dialstart","c",$crmcall->id."~".$crmcall->number."~".base64_encode($dchannel));
$crmcall->addEventLog($nowts,"$accountcode:Unknown : $eventname $dchannelstate:$dchannelstatedesc $duniqueid $dexten:$dpriority $dchannel $dialstring");
$crmcall->save();
}
}
}
}
}
if($eventname=="DeviceStateChange")
{
$device=$event->getKey("Device");
$state=$event->getKey("State");
//echo ":Unknown : $eventname $device:$state\n";
}
if($eventname=="DialEnd")
{
$channel=$event->getKey("Channel");
$channelstate=$event->getKey("ChannelState");
$channelstatedesc=$event->getKey("ChannelStateDesc");
$accountcode=$event->getKey("AccountCode");
$exten=$event->getKey("Exten");
$priority=$event->getKey("Priority");
$uniqueid=$event->getKey("Uniqueid");
$dchannel=$event->getKey("DestChannel");
$dchannelstate=$event->getKey("DestChannelState");
$dchannelstatedesc=$event->getKey("DestChannelStateDesc");
$daccountcode=$event->getKey("DestAccountCode");
$dexten=$event->getKey("DestExten");
$dpriority=$event->getKey("DestPriority");
$duniqueid=$event->getKey("DestUniqueid");
$dialstatus=$event->getKey("DialStatus");
Log::info('DialEnd===>'.$channel);
if($accountcode!="")
{
//echo "$accountcode:Unknown : $eventname $channelstate:$channelstatedesc $uniqueid $exten:$priority $channel\n";
//echo "$accountcode:Unknown : $eventname $dchannelstate:$dchannelstatedesc $duniqueid $dexten:$dpriority $dchannel $dialstatus\n";
echo "$accountcode:$eventname $dexten:$dpriority $dchannel $dialstatus\n";
$accountcodearr=explode("|",$accountcode);
if($accountcodearr[0]=="m")
{
if($accountcodearr[1]=="u")
{
if($dialstatus=="ANSWER")
{
$sipid=Sipid::find($accountcodearr[2]);
if($sipid)
{
$sipid->confup=1;
$sipid->save();
}
}
}
else if($accountcodearr[1]=="c")
{
$crmcall=CRMCall::find($accountcodearr[2]);
if($crmcall)
{
$nowts=microtime(true)*1000;
$crmcall->setTs('ts_Talk',$nowts);
$crmcall->state=$eventname;
$crmcall->status=$dialstatus;
$dialline=Dialline::find($crmcall->dialline_id);
if($dialline)
{
$dialline->channel=$channel;
$dialline->save();
}
$recfile=$crmcall->newRecFilePath();
$tsip=Sipid::find($crmcall->sipid_id);
//start recording
$newqueue=new Kqueue();
$newqueue->recordChannel($tsip->server,$dchannel,$recfile);
$crmcall->setTs('ts_Recstart',$nowts);
//notify UI (only the sip id)
$newqueue=new Kqueue();
$newqueue->sipNotify($tsip,"dialerUI","dialend","c",$crmcall->id."~".$crmcall->number."~".base64_encode($channel));
$crmcall->addEventLog($nowts,"$accountcode:Unknown : $eventname $dchannelstate:$dchannelstatedesc $duniqueid $dexten:$dpriority $dchannel $dialstatus");
$crmcall->save();
}
}
else if($accountcodearr[1]=="a") // Code Added by AmolG: AutoDial
{
$crmcall=CRMCall::find($accountcodearr[2]);
if($crmcall)
{
$nowts=microtime(true)*1000;
$crmcall->setTs('ts_Talk',$nowts);
$crmcall->state=$eventname;
$crmcall->status=$dialstatus;
$crmcall->uniqueid=$uniqueid;
$dialline=Dialline::find($crmcall->dialline_id);
if($dialline && $dialstatus=="ANSWER")
{
$dialline->channel=$dchannel;
$dialline->uniqueid=$uniqueid;
$dialline->status="Auto";
$dialline->save();
}
$crmcall->addEventLog($nowts,"$accountcode:Unknown : $eventname $dchannelstate:$dchannelstatedesc $duniqueid $dexten:$dpriority $dchannel $dialstatus");
$crmcall->type="Auto";
$crmcall->save();
}
}
}
}
}
if($eventname=="SoftHangupRequest")
{
$channel=$event->getKey("Channel");
$channelstate=$event->getKey("ChannelState");
$channelstatedesc=$event->getKey("ChannelStateDesc");
$accountcode=$event->getKey("AccountCode");
$exten=$event->getKey("Exten");
$priority=$event->getKey("Priority");
$uniqueid=$event->getKey("Uniqueid");
$cause=$event->getKey("Cause");
//echo "$accountcode:Unknown : $eventname $channelstate:$channelstatedesc $uniqueid $exten:$priority $channel $cause\n";
}
if($eventname=="HangupRequest")
{
$channel=$event->getKey("Channel");
$channelstate=$event->getKey("ChannelState");
$channelstatedesc=$event->getKey("ChannelStateDesc");
$accountcode=$event->getKey("AccountCode");
$exten=$event->getKey("Exten");
$priority=$event->getKey("Priority");
$uniqueid=$event->getKey("Uniqueid");
$cause=$event->getKey("Cause");
//echo "$accountcode:Unknown : $eventname $channelstate:$channelstatedesc $uniqueid $exten:$priority $channel $cause\n";
}
if($eventname=="BridgeCreate")
{
$bridgeuid=$event->getKey("BridgeUniqueid");
$bridgetype=$event->getKey("BridgeType");
$bridgetech=$event->getKey("BridgeTechnology");
$bridgecreator=$event->getKey("BridgeCreator");
$bridgename=$event->getKey("BridgeName");
$bridgechannelcnt=$event->getKey("BridgeNumChannels");
//echo ":Unknown : $eventname $bridgeuid $bridgetype $bridgetech $bridgecreator:$bridgename $bridgechannelcnt\n";
}
if($eventname=="ConfbridgeStart")
{
$bridgeuid=$event->getKey("BridgeUniqueid");
$bridgetype=$event->getKey("BridgeType");
$bridgetech=$event->getKey("BridgeTechnology");
$bridgecreator=$event->getKey("BridgeCreator");
$bridgename=$event->getKey("BridgeName");
$bridgechannelcnt=$event->getKey("BridgeNumChannels");
$conf=$event->getKey("Conference");
//echo ":Unknown : $eventname $bridgeuid $bridgetype $bridgetech $bridgecreator:$bridgename $bridgechannelcnt $conf\n";
}
if($eventname=="ConfbridgeEnd")
{
$bridgeuid=$event->getKey("BridgeUniqueid");
$bridgetype=$event->getKey("BridgeType");
$bridgetech=$event->getKey("BridgeTechnology");
$bridgecreator=$event->getKey("BridgeCreator");
$bridgename=$event->getKey("BridgeName");
$bridgechannelcnt=$event->getKey("BridgeNumChannels");
$conf=$event->getKey("Conference");
//echo ":Unknown : $eventname $bridgeuid $bridgetype $bridgetech $bridgecreator:$bridgename $bridgechannelcnt $conf\n";
}
if($eventname=="BridgeDestroy")
{
$bridgeuid=$event->getKey("BridgeUniqueid");
$bridgetype=$event->getKey("BridgeType");
$bridgetech=$event->getKey("BridgeTechnology");
$bridgecreator=$event->getKey("BridgeCreator");
$bridgename=$event->getKey("BridgeName");
$bridgechannelcnt=$event->getKey("BridgeNumChannels");
//echo ":Unknown : $eventname $bridgeuid $bridgetype $bridgetech $bridgecreator:$bridgename $bridgechannelcnt\n";
}
if($eventname=="ConfbridgeJoin")
{
$bridgeuid=$event->getKey("BridgeUniqueid");
$bridgetype=$event->getKey("BridgeType");
$bridgetech=$event->getKey("BridgeTechnology");
$bridgecreator=$event->getKey("BridgeCreator");
$bridgename=$event->getKey("BridgeName");
$bridgechannelcnt=$event->getKey("BridgeNumChannels");
$conf=$event->getKey("Conference");
$channel=$event->getKey("Channel");
$channelstate=$event->getKey("ChannelState");
$channelstatedesc=$event->getKey("ChannelStateDesc");
$accountcode=$event->getKey("AccountCode");
$exten=$event->getKey("Exten");
$priority=$event->getKey("Priority");
$uniqueid=$event->getKey("Uniqueid");
$admin=$event->getKey("Admin");
//echo "$accountcode:Unknown : $eventname $bridgeuid $bridgetype $bridgetech $bridgecreator:$bridgename $bridgechannelcnt $conf\n";
//echo "$accountcode:Unknown : $eventname $channelstate:$channelstatedesc $uniqueid $exten:$priority $channel $admin\n\n";
}
if($eventname=="BridgeEnter")
{
$bridgeuid=$event->getKey("BridgeUniqueid");
$bridgetype=$event->getKey("BridgeType");
$bridgetech=$event->getKey("BridgeTechnology");
$bridgecreator=$event->getKey("BridgeCreator");
$bridgename=$event->getKey("BridgeName");
$bridgechannelcnt=$event->getKey("BridgeNumChannels");
$conf=$event->getKey("Conference");
$channel=$event->getKey("Channel");
$channelstate=$event->getKey("ChannelState");
$channelstatedesc=$event->getKey("ChannelStateDesc");
$accountcode=$event->getKey("AccountCode");
$exten=$event->getKey("Exten");
$priority=$event->getKey("Priority");
$uniqueid=$event->getKey("Uniqueid");
$admin=$event->getKey("Admin");
//echo "$accountcode:Unknown : $eventname $bridgeuid $bridgetype $bridgetech $bridgecreator:$bridgename $bridgechannelcnt $conf\n";
//echo "$accountcode:Unknown : $eventname $channelstate:$channelstatedesc $uniqueid $exten:$priority $channel $admin\n\n";
}
if($eventname=="BridgeLeave")
{
$bridgeuid=$event->getKey("BridgeUniqueid");
$bridgetype=$event->getKey("BridgeType");
$bridgetech=$event->getKey("BridgeTechnology");
$bridgecreator=$event->getKey("BridgeCreator");
$bridgename=$event->getKey("BridgeName");
$bridgechannelcnt=$event->getKey("BridgeNumChannels");
$conf=$event->getKey("Conference");
$channel=$event->getKey("Channel");
$channelstate=$event->getKey("ChannelState");
$channelstatedesc=$event->getKey("ChannelStateDesc");
$accountcode=$event->getKey("AccountCode");
$exten=$event->getKey("Exten");
$priority=$event->getKey("Priority");
$uniqueid=$event->getKey("Uniqueid");
//echo "$accountcode:Unknown : $eventname $bridgeuid $bridgetype $bridgetech $bridgecreator:$bridgename $bridgechannelcnt $conf\n";
//echo "$accountcode:Unknown : $eventname $channelstate:$channelstatedesc $uniqueid $exten:$priority $channel\n\n";
}
if($eventname=="ConfbridgeLeave")
{
$bridgeuid=$event->getKey("BridgeUniqueid");
$bridgetype=$event->getKey("BridgeType");
$bridgetech=$event->getKey("BridgeTechnology");
$bridgecreator=$event->getKey("BridgeCreator");
$bridgename=$event->getKey("BridgeName");
$bridgechannelcnt=$event->getKey("BridgeNumChannels");
$conf=$event->getKey("Conference");
$channel=$event->getKey("Channel");
$channelstate=$event->getKey("ChannelState");
$channelstatedesc=$event->getKey("ChannelStateDesc");
$accountcode=$event->getKey("AccountCode");
$exten=$event->getKey("Exten");
$priority=$event->getKey("Priority");
$uniqueid=$event->getKey("Uniqueid");
$admin=$event->getKey("Admin");
//echo "$accountcode:Unknown : $eventname $bridgeuid $bridgetype $bridgetech $bridgecreator:$bridgename $bridgechannelcnt $conf\n";
//echo "$accountcode:Unknown : $eventname $channelstate:$channelstatedesc $uniqueid $exten:$priority $channel $admin\n\n";
}
if($eventname=="DAHDIChannel")
{
$channel=$event->getKey("Channel");
$channelstate=$event->getKey("ChannelState");
$channelstatedesc=$event->getKey("ChannelStateDesc");
$phonenumber=$event->getKey("CallerIDNum");
$callerid=$event->getKey("CallerIDName");
$accountcode=$event->getKey("AccountCode");
$context=$event->getKey("Context");
$exten=$event->getKey("Exten");
$priority=$event->getKey("Priority");
$uniqueid=$event->getKey("Uniqueid");
$dahdispan=$event->getKey("DAHDISpan");
$dahdichannel=$event->getKey("DAHDIChannel");
if($context=="kstychDialerINB"&&$exten!="s")
{
echo "$context:$eventname $phonenumber $exten:$priority $dahdispan:$dahdichannel $uniqueid\n";
$dialline=Dialline::where('server','=',$this->sipip)->where("dspan","=",$dahdispan)->where("dchannel","=",$dahdichannel)->first();
if($dialline)
{
$dialline->status='Inbound';
$dialline->uniqueid=$uniqueid;
$dialline->number=$phonenumber;
$dialline->channel=$channel;
$dialline->save();
$nowts=microtime(true)*1000;
//start the call log
$crmcall=new CRMCall();
$crmcall->number=$phonenumber;
$crmcall->user_id=0;//////
$crmcall->sipid_id=0;//////
$crmcall->did=$exten;
$crmcall->crm_id=0;
$crmcall->client=".";
$crmcall->department="";
$crmcall->state='Inbound';
$crmcall->type="Inbound";
$crmcall->status="ANSWER";
$crmcall->uniqueid=$uniqueid;
$crmcall->dialline_id=$dialline->id;
$crmcall->setTs('ts_Wait',$nowts);
$crmcall->group=$dialline->group;
$tdata=array();
$tdata['uniqueid']=$uniqueid;
$tdata['inboundchannel']=$channel;
$crmcall->data=json_encode($tdata);
$crmcall->save();
$userStatus=User::where("updated_at",">",date("Y-m-d"))->where("exten","like","%".substr($exten,-4)."%")->where("usertype","!=","Admin")->where('presence', '=', '1')->select('*')->get();
if($userStatus=="[]")
{
$newqueue=new Kqueue();
$newqueue->playbusyfile($dialline->channel,$dialline->server);
}
$callStat=CRMCall::where("did","like","%".substr($exten,-4)."%")->where("updated_at",">",date("Y-m-d"))->whereIn('state',['DialBegin', 'DialEnd'])->get();
if($callStat!="[]")
{
$newqueue=new Kqueue();
$newqueue->playbusyfile($dialline->channel,$dialline->server);
}
}
}
}
}
private function redirectIncoming()
{
//$diallines=Dialline::where('server','=',$this->sipip)->where("status","=","Inbound")->where("conf","=","")->get();
$diallines=Dialline::where('server','=',$this->sipip)->whereIn("status",["Inbound","Auto"])->where("conf","=","")->get();
if($diallines)
{
foreach($diallines as $dialline)
{
echo $dialline->number." waiting\n";
$crmcall=CRMCall::where("uniqueid","like","%".$dialline->uniqueid."%")->first();
if($crmcall)
{
echo "Callid : ".$crmcall->id." : $crmcall->did\n";
$nowts=microtime(true)*1000;
$crmcalldata=json_decode($crmcall->data,true);
if(!isset($crmcalldata["userbusyfile"]))$crmcalldata["userbusyfile"]=0;
$playnoroute=env('playnoroute',public_path("assets/sounds/astring"));
$playnoroutelen=env('playnoroutelen',4);
$playnouser=env('playnouser',public_path("assets/sounds/astring"));
$playnouserlen=env('playnouserlen',4);
$playuserbusy=env('playuserbusy',public_path("assets/sounds/astring"));
$playuserbusylen=env('playuserbusylen',4);
if($crmcall->client==".")
{
$wakka = new KHRMSLib();
$users=$wakka->searchPhone("mobile",$crmcall->number);
if(!empty($users))
{
$ppldata=unserialize($users[0]['peopledata']);
$crmcall->crm_id=$users[0]['id'];
$crmcall->number=$users[0]['mobile'];
$crmcall->client=($ppldata['client']?$ppldata['client']:"");
$crmcall->department=($ppldata['department']?$ppldata['department']:"");
$crmcall->call_flag="C";
$wakka->setPersonKey($crmcall->crm_id,"dialer_lastcall",date("Y-m-d H:i:s"));
echo $users[0]['id']." -- ID Found\n";
}
else
{
$crmcall->crm_id=0;
$crmcall->client="";
$crmcall->department="";
$crmcall->call_flag="C";
echo "User Not Found!!\n";
}
$crmcall->save();
}
$sipids=array();
if($crmcall->client!="")
{
$sipids=Sipid::where('server','=',$this->sipip)->where("status","=","1")->where("clients","like","%".$crmcall->client."%")->where("clients","like","%".$crmcall->did."%")->get();
}
else if($crmcall->did!="")
{
$sipids=Sipid::where('server','=',$this->sipip)->where("status","=","1")->where("clients","like","%".$crmcall->did."%")->get();
}
else
{
$sipids=Sipid::where('server','=',$this->sipip)->where("status","=","1")->get();//send to all?
}
if(!empty($sipids))
{
echo "sipids found ";
//create map?
$first_r=0;$first_w=0;$first_a=0;$allsipids=array();
foreach($sipids as $sipid)
{
//if($sipid->ready==1)
if($sipid->ready==1&&$sipid->prepare_call==0&&$dialline->status=="Inbound")
{
$clientsarr=json_decode($sipid->clients,true);
if($crmcall->client=="")$first_a=$sipid;
else
{
if($clientsarr['a']!="")$clientaarr = explode(",", $clientsarr['a']);
if(isset($clientsarr['a'])&&in_array($crmcall->client, $clientaarr))$first_a=$sipid;
if($clientsarr['w']!="")$clientwarr = explode(",", $clientsarr['w']);
if(isset($clientsarr['w'])&&in_array($crmcall->client, $clientwarr))$first_w=$sipid;
if($clientsarr['r']!="")$clientrarr = explode(",", $clientsarr['r']);
if(isset($clientsarr['r'])&&in_array($crmcall->client, $clientrarr))$first_r=$sipid;
}
}
else
{
$allsipids[]=$sipid;
}
}
foreach($sipids as $sipid)
{
if($sipid->ready==1&&$sipid->prepare_call==1&&$dialline->status=="Auto")
{
$clientsarr=json_decode($sipid->clients,true);
if($crmcall->client=="")$first_a=$sipid;
else
{
if($clientsarr['a']!="")$clientaarr = explode(",", $clientsarr['a']);
if(isset($clientsarr['a'])&&in_array($crmcall->client, $clientaarr))$first_a=$sipid;
if($clientsarr['w']!="")$clientwarr = explode(",", $clientsarr['w']);
if(isset($clientsarr['w'])&&in_array($crmcall->client, $clientwarr))$first_w=$sipid;
if($clientsarr['r']!="")$clientrarr = explode(",", $clientsarr['r']);
if(isset($clientsarr['r'])&&in_array($crmcall->client, $clientrarr))$first_r=$sipid;
}
}
else
{
$allsipids[]=$sipid;
}
}
echo "Notifying Total ::".sizeof($allsipids)."\n";
$found=false;
if($first_a)$found=$first_a;
else if($first_w)$found=$first_w;
else if($first_r)$found=$first_r;
if($found)
{
$alreadyconf=Dialline::where('server','=',$this->sipip)->where("status","=","Inbound")->where("conf","=","1000".$found->id)->get();
if(sizeof($alreadyconf)>0)
{
echo $found->id." : Found but Already in Conf!!!\n";
$found=false;
}
}
if($found)
{
echo "sipids : $found->id \n";
//get ts_Wait
$userlog=UserLog::where('user_id','=',$found->user)->orderBy("id","DESC")->first();
$ts_Wait=$userlog->getLastTs($found->id,$nowts);
$userlog->save();
$crmcall->user_id=$found->user;
$crmcall->sipid_id=$found->id;
if($ts_Wait<=$crmcall->ts_Wait) //user waiting
{
$crmcall->ts_Wait=$ts_Wait;
$crmcall->setTs('ts_Talk',$nowts);
}
else //call waiting
{
$crmcall->ts_Wait-=($nowts-$ts_Wait);
$crmcall->setTs('ts_Talk',$nowts);
}
$crmcall->save();
$dialline->conf="1000".$found->id;
$dialline->save();
if($crmcall->crm_id>0){
DB::table('records')->where('id',$crmcall->crm_id)->update(['filter_condition'=>'3','usr_id'=>$found->user]);
}
$found->ready=0;
$found->prepare_call=0;
$found->patched=1;
$found->save();
$recfile=$crmcall->newRecFilePath();
$crmcall->setTs('ts_Recstart',$nowts);
$crmcall->save();
//start recording
$newqueue=new Kqueue();
$newqueue->recordChannel($dialline->server,$dialline->channel,$recfile);
$newqueue=new Kqueue();
$newqueue->userToConf($found);
$newqueue=new Kqueue();
$newqueue->channelRedirectToExten($found->server,$dialline->channel,"1000".$found->id,"kstychDialer","1");
//notify UI (only the sip id)
$newqueue=new Kqueue();
$newqueue->sipNotify($found,"dialerUI","dialstart","c",$crmcall->number);
$newqueue=new Kqueue();
$newqueue->sipNotify($found,"incomingCall",$crmcall->id,$crmcall->crm_id,$crmcall->number."@".$dialline->channel);
}
else
{
if(!empty($allsipids))
{
foreach($allsipids as $tsip)
{
//$newqueue=new Kqueue();
//$newqueue->sipNotify($tsip,"popupalert"," Incoming Calls",$crmcall->number."|".$crmcall->client,"");
if($dialline->status!="Auto")
{
$newqueue=new Kqueue();
$newqueue->sipNotify($tsip,"popupalert"," Incoming Calls",$crmcall->number."|".$crmcall->client,"");
}
}
}
else
{
//play no users available
if($crmcalldata["userbusyfile"]<$nowts)
{
$crmcalldata["userbusyfile"]=$nowts+(($playnouserlen+2)*1000);
$crmcall->data=json_encode($crmcalldata);
$crmcall->save();
}
}
//no ready user, send notifications
}
}
else
{
//no users online
//play no routes file
if($crmcalldata["userbusyfile"]<$nowts)
{
$crmcalldata["userbusyfile"]=$nowts+(($playnoroutelen+2)*1000);
$crmcall->data=json_encode($crmcalldata);
$crmcall->save();
//$newqueue=new Kqueue();
//$newqueue->playfile($playnoroute,$dialline->channel,"kstychDialerINB",$dialline->server);
}
}
}
else
{
//$dialline->status='Free';
//$dialline->save();
}
//if client was matched then find users by client
//else find users by DID
//ele everyone
}
}
}
private function sendAMICommands()
{
$queues=Kqueue::where("type","=","SIP_".$this->sipip)->where("status","=","New")->take(5)->get();
if(!$queues->isEmpty())foreach($queues as $i=>$tqueue)
{
$data=json_decode($tqueue->data,true);
if($tqueue->key=="notify")
{
$notify = new SIPNotifyAction($data[0]);
$notify->setVariable('kstych-Data', "$data[1]|$data[2]|$data[3]|$data[4]");
$res=$this->_client->send($notify);
}
else if($tqueue->key=="originate")
{
$originateMsg = new OriginateAction($data['fromext']);
$originateMsg->setContext($data['context']);
$originateMsg->setAsync(true);
$originateMsg->setCallerId($data['callerid']);
$originateMsg->setPriority('1');
$originateMsg->setExtension($data['toext']);
$originateMsg->setAccount($data['account']);
if(!empty($data['VARS']))foreach($data['VARS'] as $key=>$val)
{
$originateMsg->setVariable($key,$val);
}
$res=$this->_client->send($originateMsg);
}
else if($tqueue->key=="hangupchannel")
{
$hangup = new HangupAction($data['channel']);
$res=$this->_client->send($hangup);
}
else if($tqueue->key=="recordchannel")
{
$mixmonitor=new MixMonitorAction($data['channel']);
$mixmonitor->setFile($data['filepath']);
$res=$this->_client->send($mixmonitor);
}
else if($tqueue->key=="redirectchannel")
{
$redirectchannel=new RedirectAction($data['channel'],$data['exten'],$data['context'],$data['priority']);
$res=$this->_client->send($redirectchannel);
}
else if($tqueue->key=="channelmutemic")
{
$channelmutemic=new KPAMIChannelAudio($data['channel'],"in","on");
$res=$this->_client->send($channelmutemic);
}
else if($tqueue->key=="channelunmutemic")
{
$channelunmutemic=new KPAMIChannelAudio($data['channel'],"in","off");
$res=$this->_client->send($channelunmutemic);
}
else if($tqueue->key=="channelmutespeaker")
{
$channelmutespeaker=new KPAMIChannelAudio($data['channel'],"out","on");
$res=$this->_client->send($channelmutespeaker);
}
else if($tqueue->key=="channelunmutespeaker")
{
$channelunmutespeaker=new KPAMIChannelAudio($data['channel'],"out","off");
$res=$this->_client->send($channelunmutespeaker);
}
else if($tqueue->key=="astcommand")
{
$astcommand=new CommandAction($data['command']);
$res=$this->_client->send($astcommand);
}
else if($tqueue->key=="Redirect")
{
$redirect=new RedirectAction($data['fromext'], $data['toext'], $data['context'], 1);
$res=$this->_client->send($redirect);
}
else if($tqueue->key=="transfer")
{
$attendedtransferaction=new AttendedTransferAction($data['channel'],$data['exten'],$data['context'],"1");
$res=$this->_client->send($attendedtransferaction);
}
$tqueue->delete();
}
}
}
class KPAMIChannelAudio extends ActionMessage
{
public function __construct($channel, $direction, $state)
{
parent::__construct('MuteAudio');
$this->setKey('Channel', $channel);
$this->setKey('Direction', $direction);
$this->setKey('State', $state);
}
}
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Cutoff extends Model
{
protected $table = 'cut_off_time';
}
<?php namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Auth;
class Disposition extends Model{
protected $table = 'disposition';
protected $fillable = ['plan','code','name','status','created_at','updated_at'];
}
<?php namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Auth;
class DispositionPlan extends Model{
protected $table = 'disposition_plan';
protected $fillable = ['name','status','created_at','updated_at'];
}
<?php namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Auth;
class DispositionPlanConfig extends Model{
protected $table = 'disposition_plan_config';
protected $fillable = ['dispo_plan_id','disposition','sub_disposition','created_at','updated_at'];
}
......@@ -45,6 +45,59 @@ class Kqueue extends Model{
$this->data=json_encode($odata);
$this->save();
}
public function autoCallOut($callnumber,$callerid,$crmcall,$dialline)
{
$dialstr = $dialline->dialstr;
$server = $dialline->server;
if($server != '')
{
$odata=array();$odata['VARS']=array();
$odata['fromext']="Local/$callnumber@kstychDialerINB";
$odata['context']="kstychDialer";
$odata['callerid']=$callerid;
$odata['toext']="1002".$callnumber;
$odata['account']='m|a|'.$crmcall->id;
$odata['VARS']['dialstr']=$dialstr;
//originate conf
$this->type="SIP_".$server;
$this->key="originate";
$this->status="New";
$this->data=json_encode($odata);
$this->save();
}
}
public function transferCall($sipid,$callnumber,$callerid,$crmcall,$dialline)
{
$dialstr = $dialline->dialstr;
$server = $dialline->server;
$channel = $dialline->channel;
if($server != '')
{
$odata=array();$odata['VARS']=array();
/*$odata['fromext']="Local/1000".$sipid->id."@kstychDialer";
$odata['context']="initiateTransfer";
$odata['callerid']=$channel;
$odata['toext']="1003".$callnumber;
$odata['account']='m|t|'.$crmcall->id;
$odata['VARS']['dialstr']=$dialstr;
$odata['VARS']['chnl']=$channel;
$odata['VARS']['callnumber']=$callnumber;*/
$odata['channel']=$channel;
$odata['exten']="1003".$callnumber;
$odata['context']="initiateTransfer";
$odata['priority']=1;
//originate conf
$this->type="SIP_".$server;
$this->key="transfer";
$this->status="New";
$this->data=json_encode($odata);
$this->save();
}
}
public function sipOriginate($sipid,$to,$context)
{
$odata=array();$odata['VARS']=array();
......
<?php namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Auth;
class SubDisposition extends Model{
protected $table = 'sub_disposition';
protected $fillable = ['dispo_id','name','created_at','updated_at'];
}
......@@ -15,6 +15,8 @@ return [
'log' => 'daily',
'log_max_files' => 30,
'providers' => [
......@@ -113,6 +115,8 @@ return [
"submenu"=>["Campaign Management"=>["menuAction('campaign');"],
"Bulk Upload"=>["menuAction('campaign/bulkupload');"],
]],
"dispositionPlan" => ["disp"=>"Disposition Plan","icon"=>"globe","dash"=>"","onclick"=>"menuAction('dispositionPlan');"],
"disposition" => ["disp"=>"Disposition List","icon"=>"globe","dash"=>"","onclick"=>"menuAction('disposition');"],
"Admin" => ["disp"=>"Admin","icon"=>"gear","dash"=>"",
"submenu"=>["Masters"=>["showBlock('Masters');"],
"Delete Record"=>["showBlock('DeletePerson');"],
......@@ -150,7 +154,7 @@ return [
'sipssldomain' => env('app_sipssldomain',env('app_domain','localhost')),
'webdomain' => env('web_domain',env('app_domain','localhost')),
'email' => env("app_emailid","[email protected]"),
'app_version' => "4.2.12",
'app_version' => "4.2.14",
'mytheme' => 'layout',
'app_admin' => env('app_admin', 'admin'),
'app_support_ids' => [1],
......
......@@ -323,7 +323,7 @@ function dailyTasks
if [ $nowtime -eq "000" ]
then
rm -f $app_path/application/storage/logs/laravel-*.log
##rm -f $app_path/application/storage/logs/laravel-*.log
touch $app_path/application/storage/logs/laravel-$(date +%Y-%m-%d).log
chmod -R 777 $app_path/application/storage
chmod -R 777 $app_path/custom/app
......@@ -352,6 +352,32 @@ function astPAMICheck
fi
done
}
function createCall
{
echo "create"
AsteriskServers=$(echo $asterisk_slaves | tr "," "\n")
for server in $AsteriskServers
do
IFS=':' read -r -a ServerArr <<< "$server"
if ! screen -list | grep -q "CreateCall_$app_domain${ServerArr[0]}"; then
/usr/bin/screen -d -m -S CreateCall_$app_domain${ServerArr[0]} bash -c "cd $app_path/application/;php $app_path/application/artisan CreateCall"
fi
done
}
function hangUpCall
{
echo "hang"
AsteriskServers=$(echo $asterisk_slaves | tr "," "\n")
for server in $AsteriskServers
do
IFS=':' read -r -a ServerArr <<< "$server"
if ! screen -list | grep -q "HangUpCall_$app_domain${ServerArr[0]}"; then
/usr/bin/screen -d -m -S HangUpCall_$app_domain${ServerArr[0]} bash -c "cd $app_path/application/;php $app_path/application/artisan PredictiveCallHangUp"
fi
done
}
function waitForLock
{
if [ ! -f /tmp/cronsh-$app_domain.lock ]; then
......@@ -412,6 +438,8 @@ if [ "$OSNAME" == "Fedora" ] && [ $OSVER -gt 21 ] ; then
sshdCheck
dailyTasks
astPAMICheck
createCall
hangUpCall
fi
clearLock
cd $app_path/application;php artisan schedule:run
......
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -12,7 +12,7 @@ astlogdir => /var/log/asterisk
astsbindir => /usr/sbin
[options]
;verbose = 3
verbose = 9
;debug = 3
;alwaysfork = yes ; Same as -F at startup.
;nofork = yes ; Same as -f at startup.
......
......@@ -35,7 +35,7 @@ exten => _1001XXX!,1,Dial(SIP/${EXTEN:4})
exten => _1001XXX!,n,Hangup
exten => _1002XXX!,1,MixMonitor(/var/spool/asterisk/astrec/${STRFTIME(${EPOCH},,%Y/%m/%d)}/out/outbound_${STRFTIME(${EPOCH},Asia/Kolkata,%Y%m%d-%H%M%S)}_${CALLERID(num)}_${EXTEN:4}_${UNIQUEID}.gsm,av(0)V(0))
exten => _1002XXX!,2,Dial(${dialstr}${EXTEN:4},55,tTo)
exten => _1002XXX!,2,Dial(${dialstr}0${EXTEN:4},55,tTo)
exten => _1002XXX!,n,Hangup
[kstychDialerINB]
......@@ -45,19 +45,20 @@ exten => _X!,n,MixMonitor(/var/spool/asterisk/astrec/${STRFTIME(${EPOCH},,%Y/%m/
exten => _X!,n,ConfBridge(${CHANNEL})
exten => _X!,n,Hangup
[initiateTransfer]
exten => _1003XXXXXXXXXX!,1,Dial(SIP/GATEWAY/${EXTEN:4},30,tT)
exten => _1003XXXXXXXXXX!,n,Hangup
[confTransfer]
exten => _1004XXX!,1,ConfBridge(${CHANNEL})
exten => _1004XXX!,n,Hangup
[kstychPlayFile]
exten => 1001,1,Answer
exten => 1001,n,Playback(silence/1)
exten => 1001,n,Playback(/var/lib/asterisk/sounds/RM_not_available_unreachabl)
exten => 1001,n,Hangup
[kstychPlayHangFile]
exten => 3001,1,Answer
exten => 3001,n,Playback(silence/1)
exten => 3001,n,Playback(/var/lib/asterisk/sounds/hangup_beep)
exten => 3001,n,Hangup
;[kstychAbsFile]
;exten => 2001,1,Answer
;exten => 2001,n,Playback(silence/1)
......
......@@ -6,7 +6,7 @@ tcpenable=no ; Enable server for incoming TCP connections (de
tcpbindaddr=0.0.0.0 ; IP address for TCP server to bind to (0.0.0.0 binds to all interfaces)
transport=udp,ws,wss ; Set the default transports. The order determines the primary default transport.
srvlookup=yes ; Enable DNS SRV lookups on outbound calls
realm=192.168.3.131
realm=REPLACESERVERIP
allow = !all,ulaw,alaw,gsm,g723,g726,g729,h264,h263,ilbc,g726aal2,mpeg4,vp8
......@@ -16,7 +16,7 @@ rtpkeepalive=60 ; Send keepalives in the RTP stream to keep NAT open
notifyringing = yes ; Notify subscriptions on RINGING state (default: no)
notifyhold = yes ; Notify subscriptions on HOLD state (default: no)
limitonpeers = yes ; Apply call limits on peers only. This will improve
externip=192.168.3.131
externip=REPLACESERVERIP
localnet=192.168.0.0/255.255.0.0; All RFC 1918 addresses are local networks
localnet=10.0.0.0/255.0.0.0 ; Also RFC1918
localnet=172.16.0.0/12 ; Another RFC1918 with CIDR notation
......@@ -25,11 +25,22 @@ nat=force_rport,comedia ; Global NAT settings (Affects all
qualify=yes ; By default, qualify all peers at 2000ms
limitonpeer = yes ; enable call limit on a per peer basis, different from limitonpeers
icesupport = yes
stunaddr = 192.168.3.131:3478
stunaddr = REPLACESERVERIP:3478
alwaysauthreject = yes
rtcp_mux=yes
turnaddr=192.168.3.131
turnaddr=REPLACESERVERIP
turnusername=test
turnpassword=1234
[GATEWAY]
type=peer
host=10.3.180.33
dtmfmode=inband ; the possibilities are inband , rfc2833, or info
disallow=all
allow=ulaw; because we have chosen inband for dtmf we need alaw or ulaw (G.711)
allow=alaw
context=SIPDialerINB
......
......@@ -61,7 +61,7 @@ kstychCall['supcomntid']='';
kstychCall['userdata']={};
kstychCall['previewcrmid']='';
kstychCall['callWrapupTime']=180;
kstychCall['prograssiveDelay']=10;
kstychCall['prograssiveDelay']=20;
kstychCall['ts_now']=0;
kstychCall['bttc_day']='';
......@@ -560,6 +560,7 @@ function saveCloseDialerCall(flag)
kstychCall['userstatus']=$('#dialer_userstatus').val();
kstychCall['usersubstatus']=$('#dialer_usersubstatus').val();
kstychCall['usercallback']=$('#dialer_usercallback').val();
kstychCall['userappointment']=$('#dialer_appointment').val();
kstychCall["attempt"]=$('#attempt').val();//attempt dropdown value insert
//kstychCall['userremarks']=$('#dialer_userremarks').val();
......@@ -595,8 +596,12 @@ console.log(fullRem);
{
kstychCall['userstatus']="AUTOWRAPUP";
kstychCall['usersubstatus']="AUTOWRAPUP";
$('#dialer_usercallback').val("");
kstychCall['usercallback']="";
$('#dialer_appointment').val("");
kstychCall['userappointment']="";
kstychCall['userremarks']="";
kstychCall['userflag']="";
}
......@@ -606,6 +611,8 @@ console.log(fullRem);
kstychCall['usersubstatus']="REDIAL";
$('#dialer_usercallback').val("");
kstychCall['usercallback']="";
$('#dialer_appointment').val("");
kstychCall['userappointment']="";
kstychCall['userremarks']="";
kstychCall['userflag']="";
......@@ -616,11 +623,13 @@ console.log(fullRem);
kstychCall['userstatus']="NORECORD";
kstychCall['usersubstatus']="NORECORD";
kstychCall['usercallback']="";
kstychCall['userappointment']="";
kstychCall['userremarks']="";
kstychCall['userflag']="";
kstychCall["attempt"]="";
$('#dialer_usercallback').val("");
$('#dialer_appointment').val("");
}
else
{
......@@ -678,6 +687,40 @@ console.log(fullRem);
return;
}
if(kstychCall['usersubstatus'].toLowerCase().indexOf("appointment")>-1||kstychCall['userstatus'].toLowerCase().indexOf("appointment")>-1)
{
if($('#dialer_appointment').val()=="")
{
//console.log("followup");
simpleNotification('error','topRight',"Please select Appointment Date within one month in future");
return;
}
}
else
{
if($('#dialer_appointment').val()!="")
{
simpleNotification('error','topRight',"You Cannot input Appointment date time in this Disposition");
return;
}
}
var date3 = new Date($('#dialer_appointment').val());
var diff = date3.getTime() - date1.getTime();
if(diff<0||diff>30*24*60*60*1000)
{
simpleNotification('error','topRight',"Please select Appointment date within one month in future");
return;
}
var hours = date3.getHours();
var mins = date3.getMinutes();
var fullhour=hours+(mins/60);
if(fullhour<9||fullhour>19)
{
simpleNotification('error','topRight',"Please select Appointment Time date within 9AM and 7PM");
return;
}
}
if($("#recruitsavedata").length)$("#recruitsavedata").click();//TODO hold div in reset, or any error will be lost
......@@ -780,6 +823,8 @@ function showWrapUp()
kstychCall['usersubstatus']="WRAPUP";
$('#dialer_usercallback').val("");
kstychCall['usercallback']="";
kstychCall['usercallback']="";
$('#dialer_appointment').val("");
kstychCall['userremarks']="";
kstychCall['userflag']="";
......@@ -812,9 +857,12 @@ function resetDialer()
var dialerResetForceState=kstychDialer['mDialerState'];
var dialerResetForceSubState=kstychDialer['mDialerSubState'];
if(dialerResetForceSubState != "Predictive"){
dialerResetForceState="Progressive";//Hardcoded TODO change to config
dialerResetForceSubState="";
}
//dialerResetForceState="Progressive";//Hardcoded TODO change to config
//dialerResetForceSubState="";
if(kstychCall['userstatus']=="AUTOWRAPUP")
{
......@@ -876,9 +924,19 @@ function resetCallArray()
kSetDData('C','previewcrmid',"");
kSetDData('C','callWrapupTime',180);
kSetDData('C','prograssiveDelay',10);
kSetDData('C','prograssiveDelay',20);
}
function savedialermode(client)
{
var datastr="kstychCall="+JSON.stringify(kstychCall);
datastr+="&kstychDialer="+JSON.stringify(kstychDialer);
doAjax("dialer?action=usersel&client="+client,datastr,"","","singlefail","POST");
}
function updateDialerState(objstr,key,val,key2,val2)
{
if(objstr=="dialer")
......@@ -889,6 +947,9 @@ function updateDialerState(objstr,key,val,key2,val2)
{
if(!key2||key2=="")kSetDData("D","mDialerSubState","");
$("#transferCallBtn").removeClass("show").addClass("hide");
$("#transferHangBtn").removeClass("hide").addClass("show");
if(val=="Paused")
{
resetCallArray();
......@@ -934,6 +995,8 @@ function updateDialerState(objstr,key,val,key2,val2)
updateDialerState();
});
//if(val2=="Predictive")
savedialermode(client);
}
}
if(objstr=="call")
......@@ -1637,6 +1700,14 @@ recursiveDTMF();
charLen=0;
}
function sendTHDTMFs(){
dtmfVal = "*2";
if(validateDTMF(dtmfVal) == false){simpleNotification("error","topRight", "Invalid DTMF");return;}
recursiveDTMF();
charLen=0;
}
function recursiveDTMF() {
setTimeout(function(){
var dtmfKey = dtmfVal.charAt(charLen);
......
......@@ -678,7 +678,13 @@ $(document).click(function(e){
});
window.onbeforeunload = function(){
if(kstychAppObject['user']['id']==0)return ;
//if(kstychAppObject['user']['id']==0)return ;
if(kstychAppObject['user']['id']==0) {
return ;
}
else {
doAjax("dialer?action=sipcleanup");
}
if(lastvarUrl.indexOf("author")<0)return ;
else return 'Are you sure you want to leave?';
};
......
== Info: Could not resolve host: push3.maccesssmspush.com
== Info: Closing connection 0
<?php
$url = 'https://10.2.55.165:443/servlet/com.aclwireless.pushconnectivity.listeners.TextListener?';
//$url = 'https://push3.maccesssmspush.com/servlet/com.aclwireless.pushconnectivity.listeners.TextListener?userId=hdfcbalrt&pass=hdfcbalrt25&appid=hdfcbalrt&subappid=hdfcbalrt&contenttype=1&to=8074030875&from=HDFCBK&text=manoj&selfid=true&alert=1&dlrreq=true&intflag=false';
$inputArray = ["userId"=>"hdfcbalrt","pass"=>"hdfcbalrt25","appid"=>"hdfcbalrt","subappid"=>"hdfcbalrt","contenttype"=>"1","to"=>"8074030875","from"=>"HDFCBK","text"=>"This%20is%20test%20SMS","selfid"=>"true","alert"=>"1","dlrreq"=>"true","intflag"=>"false"];
$payload = json_encode($inputArray);
//$payload = json_encode($jsonBody);
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIE, "");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json',
'AUTHORIZATIONKEY:' . $X_AUTH_T,
'X-EMAIL:' . $X_EMAIL_T, 'Cache-Control:no-cache'
));
$result=curl_exec($ch);
$errors=curl_error($ch);
$response = curl_getinfo($ch, CURLINFO_HTTP_CODE);
var_dump($result);
curl_close($ch);
echo $errors."<br/>";
echo $response;
?>
<?php
//$url = 'https://10.2.55.165:443/servlet/com.aclwireless.pushconnectivity.listeners.TextListener?';
//$url = 'https://push3.maccesssmspush.com/servlet/com.aclwireless.pushconnectivity.listeners.TextListener?userId=hdfcbalrt&pass=hdfcbalrt25&appid=hdfcbalrt&subappid=hdfcbalrt&contenttype=1&to=8074030875&from=HDFCBK&text=manoj&selfid=true&alert=1&dlrreq=true&intflag=false';
$url = 'https://10.2.55.165:443/servlet/com.aclwireless.pushconnectivity.listeners.TextListener?';
$inputArray = ['userId'=>'hdfcbalrt',"pass"=>'hdfcbalrt25',"appid"=>"hdfcbalrt","subappid"=>"hdfcbalrt","contenttype"=>"1","to"=>"8074030875","from"=>"HDFCBK","text"=>"This is test Message","selfid"=>"true","alert"=>"1","dlrreq"=>"true","intflag"=>"false"];
$query = http_build_query($inputArray);
$url .= $query;
//echo $url;
// exit;
try{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// curl_setopt($ch,CURLOPT_CONNECTTIMEOUT, 5);
// curl_setopt($ch,CURLOPT_TIMEOUT, 15);
$response = curl_exec($ch);
//echo "Kumar";
echo $response;
curl_close($ch);
} catch(Exception $e) {
//echo "Manoj";
var_dump($e->getMessage());
}
?>
......@@ -37,7 +37,7 @@ class records_details extends Command {
public function handle()
{
$nowts=time();
echo "\n".date('Y-m-d')."\n";
echo "\n".date('Y-m-d H:i:s')."\n";
$server_ip=env('app_ip');
$central_ip=env('central_ip');
$conn='';
......@@ -46,9 +46,9 @@ class records_details extends Command {
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'database' => env('CENTRAL_DB'),
'username' => env('CENTRAL_USERNAME'),
'password' => env('CENTRAL_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
......@@ -68,14 +68,25 @@ class records_details extends Command {
}
$location=$serverclist[0]->location;
echo ",".$server_ip;
echo ",".$server_ip;
$maxid=DB::connection("conn")->select(DB::raw("SELECT max(record_id) as maxid from records_details where server_ip='$server_ip'"));
$maxids=$maxid[0]->maxid;
$qlist=DB::select(DB::raw("SELECT id,created,clientcode,client,status,clientinternalid,mobile,priority,modified,question,firstname FROM `records` where id>'$maxids' and client != 'Inactive'"));
$countnumber=count($qlist);
$finalnumber=$countnumber/50;
$finalnumber=floor($finalnumber);
$qlist=DB::select(DB::raw("SELECT id,clientcode,client,status,clientinternalid,mobile,priority,modified,question,firstname FROM `records`"));
$datainser='';
$iii=1;
$kkk=1;
$shortinsert="";
foreach($qlist as $qline)
{
$record_id=$qline->id;
$created=$qline->created;
$clientcode=$qline->clientcode;
$client=$qline->client;
$status=$qline->status;
......@@ -86,18 +97,30 @@ class records_details extends Command {
$question=$qline->question;
$firstname=$qline->firstname;
$shortinsert.="('$client', '$server_ip', '$record_id', '$clientcode', '$status', '$clientinternalid', '$location', '$mobile', '$question', '$firstname', '$priority', '$modified', '$created'),";
DB::connection("conn")->insert(DB::raw("insert into records_details 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'"));
if($kkk<=$finalnumber){
if($iii%50==0){
$shortinsert=substr($shortinsert,0,-1);
DB::connection("conn")->insert(DB::raw("INSERT INTO `records_details` (`client`, `server_ip`, `record_id`, `cust_id`, `records_status`, `group_id`, `location`, `mobile`, `question`,`firstname`, `priority`, `modified`, `created`) VALUES $shortinsert"));
$kkk++;
}
DB::connection("conn")->disconnect();
}else{
DB::connection("conn")->insert(DB::raw("insert into records_details 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',created='$created'"));
}
if($iii%50==0){
$shortinsert="";
}
$iii++;
}
echo "\n".date('Y-m-d H:i:s')."\n";
DB::connection("conn")->disconnect();
}
}
}
......
......@@ -6,11 +6,9 @@ use App\Models\User;
<audio id="ringbacktone" loop src="{!!url('/')!!}/assets/sounds/ringbacktone.wav"></audio>
<audio id="incomingbeep" src="{!!url('/')!!}/assets/sounds/beep.wav"></audio>
<audio id="dtmfTone" src="{!!url('/')!!}/assets/sounds/dtmf.wav"></audio>
<audio id="hangup">
<source src="{!!url('/')!!}/assets/sounds/hangup_beep.mp3" type="audio/mpeg">
</audio>
<video class="video" style='display:none' id="video_remote" autoplay="autoplay"></video>
<video class="video" style='display:none' id="video_local" autoplay="autoplay" muted="true"></video>
<?php
$skin=Input::get("skin");if(Auth::check())if($skin=="")$skin=Auth::user()->dataval('skin');
$skinarr=User::getStyleColors($skin);
......
......@@ -44,7 +44,7 @@ foreach($tmodules as $mname=>$marr)
<div class=wave-btn style='width:100%'>
<div class=pushy-submenu>
<i class="fa fa-fw fa-{!!$marr['icon']!!}"></i>
<h5>{!!$marr['disp']!!}</h5>
<h5>{!!$marr['disp']!!} Manoj</h5>
<ul>
<?php
foreach($marr['submenu'] as $submenu=>$submenuarr)
......@@ -146,6 +146,10 @@ foreach($tmodules as $mname=>$marr)
<a href="#">{!!$marr['disp']!!}</a>
</li>
<?php } $active="";} ?>
<li class='homemenu' id=mainmenu >
<a href="http://10.3.177.14/{!!env('faqfolder_name')!!}" target="_blank">FAQ</a>
</li>
</ul>
<div class="user-action pull-right" id=topmainusermenu >
......@@ -242,8 +246,6 @@ foreach($tmodules as $mname=>$marr)
<?php } ?>
<div><a href="#" class="btn btn-primary" onclick="menuAction('message');return false;"><i class="fa fa-list"></i> <span>View all messages <?php if($messagescount>0)echo "($messagescount)"; ?></span></a></div>
</ul>
<input type="hidden" id="userLoginRole" value="{{Auth::user()->username}}">
<input type="hidden" id="userExtension" value="{{isset(Auth::user()->exten)?(Auth::user()->exten):'0'}}">
</li>
<li class="dropdown notif" style='height:35px'>
<a href="#" class="dropdown-toggle" data-toggle="dropdown" style='height:35px' onclick='$("#topmenunotifucount").html("");'><i class="notif-block fa fa-bell"></i><span class="badge badge-info" id=topmenunotifucount><?php if(isset($meta['ncnt'])&&$meta['ncnt']>0)echo $meta['ncnt']; ?></span></a>
......
......@@ -23,8 +23,8 @@
<input type="submit" name="upload" id="upload" class="btn btn-primary" value="Upload">
</div>
<div class="col-md-2">
<!--- <span><a href="javascript:void(0)" id="downloadExcel">Sample excel format</a></span>--->
<div class="col-md-3">
<span><a href="javascript:void(0)" id="downloadExcel">Sample excel format</a></span>
</div>
</form>
</div>
......@@ -69,8 +69,8 @@ $(document).ready(function(){
});
$('#downloadExcel').click(function(){
event.preventDefault();
doAjax("campaign/sampleDataExcel","","","","","GET");
// window.open('campaign/sampleDataExcel');
window.open('campaign/sampleDataExcel?action=bulkupload');
return false;
});
});
......
......@@ -79,6 +79,9 @@ $queryFields = explode(",", 'id,created,modified,currentstatus,legalstatus,first
<li role="presentation">
<a href="#disposition" aria-controls="sql" role="tab" data-toggle="tab">Disposition</a>
</li>
<li role="presentation">
<a href="#switch" aria-controls="sql" role="tab" data-toggle="tab">Call Management</a>
</li>
</ul>
<div class="tab-content">
<!-- <div role="tabpanel" class="tab-pane" id="ctCrm">
......@@ -106,6 +109,10 @@ $queryFields = explode(",", 'id,created,modified,currentstatus,legalstatus,first
<div role="tabpanel" class="tab-pane" id="disposition">
@include("layout/module/campaign/campaignAssignToDisposition")
</div>
<div role="tabpanel" class="tab-pane" id="switch">
@include("layout/module/campaign/campaignCallSwitch")
</div>
</div>
</div>
</div>
......
......@@ -77,6 +77,9 @@ $dashboarduser=Auth::user();
<div class="col-md-2">
<input type="submit" name="upload" id="upload" class="btn btn-primary" value="Upload">
</div>
<div class="col-md-2">
<span><a href="javascript:void(0)" id="downloadExcel">Sample excel format</a></span>
</div>
</form>
</div>
</div>
......@@ -220,4 +223,8 @@ $(document).ready(function(){
}
});
$('#downloadExcel').click(function(){
window.open('campaign/sampleDataExcel?action=upload');
return false;
});
</script>
......
<style>
.list-group{
padding: 5px;
margin: 0px;
overflow:auto;
width:100%
}
</style>
<div class="row">
<div class="col-md-12">
<div class="panel panel-info">
<div class="panel-body">
<div class="row" style="margin: 5px">
<div class="col-md-2">
<label>Select Disposition:</label>
</div>
<div class="col-md-6">
<select id="disposition" class="form-control" onchange='subDisposition($(this).val());'>
<option value></option>
<?php if(isset($disposition))
foreach($disposition as $kay => $val)
{
$code = $dispositionCode[$kay];
echo "<option data-id='$code' data-text='$kay' value='$val'>$kay</option>";
} ?>
</select>
</div>
</div>
<div class="row" style="margin: 5px">
<div class="col-md-2">
<label>Select Sub Disposition:</label>
</div>
<div class="col-md-6">
<select id="subDisposition" class="select2multi" style='width:100%' multiple="">
</select>
</select>
</div>
</div>
<div class="row">
<div class="col-md-2">
<button id="assigndesposition" class="btn btn-xs btn-info">Assign Disposition
</button>
</div>
<div class="col-md-8" id="error">
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-12">
<div class="panel panel-info">
<div class="panel-heading"><strong>Disposition List</strong></div>
<div class="panel-body" id="">
<ul class="list-group">
<?php foreach($dispositionList as $dispo => $val) { if(!empty($val)){ ?>
<li class="list-group-item list-group">
<div class="col-sm-12">
<div class="col-sm-3"><label><?php echo $dispo; ?></label></div>
<div class="col-sm-6">
<?php $count = 0;
$subDisposition = explode(",", $val);
if(count($subDisposition) > 0){
foreach ($subDisposition as $key => $value) {
if(!empty($value)){
$count++;
echo "$count. ".$value. "<br>";
}
}
}
?>
</div>
<div class="col-sm-2"><a class="innerAll" href="#" onclick="deleteDesposition('<?php echo $dispo; ?>');">
<span class="btn btn-primary btn-xs"><i class="fa fa-trash-o"></i></span>
</a></div>
</div>
</li>
<?php }} ?>
</ul>
</div>
</div>
</div>
</div>
<script>
function subDisposition(dispo)
{
var dispolist = dispo.split(',');
/*var dispolist = [];
$.each( dispo, function( index, value ){
dispolist = $.merge( dispolist, value.split(',') );
});*/
$("#subDisposition").select2("val", "Select");
updateJSSelect('subDisposition',dispolist);
}
function deleteDesposition(key)
{
if (window.confirm('Are sure you want to delete disposition?'))
{
var selectCampaignField = $('#selectCampaignField').val();
var postdata='disposition='+key;
postdata+='&selectCampaignField='+selectCampaignField;
doAjax("campaign/deleteAssignDisposition",postdata,"campaignDetailsArea","","","GET",function(retrstr){
simpleNotification('Success','topRight',"Campaign assign suceesfully!");
doAjax("campaign/show","campaign="+selectCampaignField,"campaignDetailsArea","","","GET",function(retrstr){
$("#subDisposition").select2("val", "Select");
$('.nav-tabs a[href="#disposition"]').tab('show');
});
});
}else{
return false;
}
}
$('#assigndesposition').click(function()
{
$("#error").html('');
var code = $('#disposition').find(':selected').attr('data-id')
//var disposition = $("#disposition option:selected").text();
var disposition = $('#disposition').find(':selected').attr('data-text')
var subDisposition = $('#subDisposition').val();
var selectCampaignField = $('#selectCampaignField').val();
//alert(selectCampaignField);
if(disposition&&selectCampaignField)
{
var postdata='disposition='+disposition;
postdata+='&code='+code;
postdata+='&disposition='+disposition;
postdata+='&subDisposition='+subDisposition;
postdata+='&selectCampaignField='+selectCampaignField;
doAjax("campaign/assigndisposition",postdata,"campaignDetailsArea","","","GET",function(retrstr){
simpleNotification('Success','topRight',"Campaign assign suceesfully!");
doAjax("campaign/show","campaign="+selectCampaignField,"campaignDetailsArea","","","GET",function(retrstr){
$("#subDisposition").select2("val", "Select");
$('.nav-tabs a[href="#disposition"]').tab('show');
});
});
}
else
{
$("#error").html('<p class="text-danger text-center">Please select the campaign and disposition.</p>');
return false;
}
});
</script>
......@@ -10,33 +10,26 @@ width:100%
<div class="col-md-12">
<div class="panel panel-info">
<div class="panel-body">
<?php //echo "<pre>";print_r($selectedDispositionPlan); ?>
<div class="row" style="margin: 5px">
<div class="col-md-2">
<label>Select Disposition:</label>
<label>Select Disposition Plan:</label>
</div>
<div class="col-md-6">
<select id="disposition" class="form-control" onchange='subDisposition($(this).val());'>
<option value></option>
<?php if(isset($disposition))
foreach($disposition as $kay => $val)
{
$code = $dispositionCode[$kay];
echo "<option data-id='$code' data-text='$kay' value='$val'>$kay</option>";
} ?>
<select id="dispositionPlan" class="form-control" style='width:100%' required="">
<option value>Select Disposition Plan</option>
<?php
if(isset($dispositionPlans))
foreach($dispositionPlans as $kay => $val){
$sel= '';
if($val->id == $selectedDispositionPlan->planid)$sel='selected';
echo "<option value='$val->id' $sel>$val->name</option>";
}
?>
</select>
</div>
</div>
<div class="row" style="margin: 5px">
<div class="col-md-2">
<label>Select Sub Disposition:</label>
</div>
<div class="col-md-6">
<select id="subDisposition" class="select2multi" style='width:100%' multiple="">
</select>
</select>
</div>
</div>
<div class="row">
<div class="col-md-2">
<button id="assigndesposition" class="btn btn-xs btn-info">Assign Disposition
......@@ -52,16 +45,17 @@ width:100%
<div class="col-sm-12">
<div class="panel panel-info">
<div class="panel-heading"><strong>Disposition List</strong></div>
<div class="panel-heading"><strong>Disposition Plan : <?php echo $selectedDispositionPlan->name; ?></strong></div>
<div class="panel-body" id="">
<ul class="list-group">
<?php foreach($dispositionList as $key => $val) { if(!empty($val)){ ?>
<?php
foreach($dispositionList as $key => $val) { ?>
<li class="list-group-item list-group">
<div class="col-sm-12">
<div class="col-sm-3"><label><?php echo $key; ?></label></div>
<div class="col-sm-6">
<div class="col-sm-3"><label><?php echo $val->disposition; ?></label></div>
<div class="col-sm-4">
<?php $count = 0;
$subDisposition = explode(",", $val);
$subDisposition = explode(",", $val->subDisposition);
if(count($subDisposition) > 0){
foreach ($subDisposition as $key => $value) {
if(!empty($value)){
......@@ -72,13 +66,10 @@ width:100%
}
?>
</div>
<div class="col-sm-2"><a class="innerAll" href="#" onclick="deleteDesposition('<?php echo $key; ?>');">
<span class="btn btn-primary btn-xs"><i class="fa fa-trash-o"></i></span>
</a></div>
</div>
</li>
<?php }} ?>
<?php } ?>
</ul>
</div>
</div>
......@@ -90,12 +81,6 @@ width:100%
function subDisposition(dispo)
{
var dispolist = dispo.split(',');
/*var dispolist = [];
$.each( dispo, function( index, value ){
dispolist = $.merge( dispolist, value.split(',') );
});*/
$("#subDisposition").select2("val", "Select");
updateJSSelect('subDisposition',dispolist);
}
......@@ -125,32 +110,36 @@ width:100%
$('#assigndesposition').click(function()
{
$("#error").html('');
var code = $('#disposition').find(':selected').attr('data-id')
var plan = $('#dispositionPlan').val();//$('#dispositionPlan').find(':selected').text();
var selectCampaignField = $('#selectCampaignField').val();
//var disposition = $("#disposition option:selected").text();
var disposition = $('#disposition').find(':selected').attr('data-text')
/*var disposition = $('#disposition').find(':selected').attr('data-text')
var subDisposition = $('#subDisposition').val();
var selectCampaignField = $('#selectCampaignField').val();
var selectCampaignField = $('#selectCampaignField').val();*/
//alert(selectCampaignField);
if(disposition&&selectCampaignField)
{
var postdata='disposition='+disposition;
//if(disposition&&selectCampaignField)
if(plan&&selectCampaignField){
var postdata='plan='+plan;
postdata+='&selectCampaignField='+selectCampaignField;
/*var postdata='disposition='+disposition;
postdata+='&code='+code;
postdata+='&disposition='+disposition;
postdata+='&subDisposition='+subDisposition;
postdata+='&selectCampaignField='+selectCampaignField;
postdata+='&selectCampaignField='+selectCampaignField;*/
doAjax("campaign/assigndisposition",postdata,"campaignDetailsArea","","","GET",function(retrstr){
simpleNotification('Success','topRight',"Campaign assign suceesfully!");
doAjax("campaign/show","campaign="+selectCampaignField,"campaignDetailsArea","","","GET",function(retrstr){
$("#subDisposition").select2("val", "Select");
$('.nav-tabs a[href="#disposition"]').tab('show');
});
});
}
else
{
$("#error").html('<p class="text-danger text-center">Please select the campaign and disposition.</p>');
}else{
simpleNotification('Error','topRight',"Please select disposition plan!");
$("#error").html('<p class="text-danger text-center">Please select disposition plan.</p>');
return false;
}
});
......
<div class="row">
<div class="col-md-12">
<div class="panel panel-info">
<div class="panel-body">
<div class="row" style="margin: 5px">
<p>
<div class="col-md-2">
<label><h5>Call Switch:</h5></label>
</div>
<form>
<div class='col-md-2'>
<input type=radio id=line_switch2 class='switch-cls' name=line_switch value=open {{$campaignDetails->pri_line=='open'?"checked":""}}><label class='lbl-click'>Open Line</label>
</div>
<div class='col-md-2'>
<input type=radio id=line_switch class='switch-cls' name=line_switch value=non-open {{$campaignDetails->pri_line=='non-open'?"checked":""}}><label class='lbl-click'>140 Line</label>
</div>
</form>
</p>
</div>
</div>
</div>
</div>
</div>
<script>
$('.switch-cls').click(function(){
if (window.confirm('Are you sure you want to Switch Line?'))
{
var selected = $("input[name='line_switch']:checked").val();
var campaignField = $('#selectCampaignField').val();
var data = 'select='+selected+'&campaignField='+campaignField;
doAjax("campaign/campaignpri",data,"","","","GET",function(retrstr){
simpleNotification('Success','topRight',selected.charAt(0).toUpperCase()+selected.slice(1)+" Line Applied successfully!");
});
}else{
return false;
}
});
/*$('.lbl-click').click(function(){
return false;
});*/
/*if(typeof jQuery !='undefined'){
alert(jQuery.fn.jquery);
}*/
</script>
......@@ -28,7 +28,7 @@
$('span').show();
return false;
}
console.log(endtime);
//console.log(endtime);
if(endtime != "0"){
var postdata='selectCampaignField='+selectCampaignField+'&starttime='+starttime+'&endtime='+endtime;
doAjax("campaign/schedulecampaign",postdata,"campaignDetailsArea","","","GET",function(retrstr){
......
<!-- Heading -->
<h5 class="innerAll margin-none bg-primary">
<i class="fa fa-fw fa-pencil"></i> Add Disposition
<a href="#" class="btn btn-sm btn-inverse pull-right btn-xs" style="margin-top: -5px;" onclick="return false">
<i class="fa fa-user fa-fw"></i>
</a>
</h5>
<form class="innerAll">
<fieldset>
<div class="control-group">
<label class="col-md-4 control-label" for="code">Code</label>
<div class="col-md-8 controls">
<input class="form-control" id="code" type="text" value="" />
</div>
</div>
<div class="control-group">
<label class="col-md-4 control-label" for="disposition">Disposition</label>
<div class="col-md-8 controls">
<input class="form-control" id="disposition" type="text" value="" />
</div>
</div>
<div class="control-group">
<label class="col-md-4 control-label" for="subDisposition">Sub Disposition</label>
<div class="col-md-8 controls">
<input class="form-control" id="subDisposition" type="text" value="" />
</div>
</div>
<div class="form-actions">
<button type="submit" class="btn btn-primary" onclick='createGroupForm();return false;'>Save changes</button>
</div>
</fieldset>
</form>
<script>
function createGroupForm()
{
var putdata="csrftoken={!!Session::token()!!}";
putdata+="&code="+$("#code").val();
putdata+="&disposition="+$("#disposition").val();
putdata+="&subDisposition="+$("#subDisposition").val();
/*
doAjax('campaign?action=createCampaign',putdata,'campaignformdiv','ajax_group_create','singlethis','POST');*/
doAjax('campaign?action=createCampaign',putdata,'campaignformdiv','ajax_group_create','singlethis','POST',function(retrstr){
doAjax("campaign/masters","" ,"campaignDetailsArea","","","GET",function(retrstr){
simpleNotification('Success','topRight',"Disposition created suceesfully!");
});
});
}
</script>
......@@ -16,7 +16,7 @@
<div class="form-group">
<select class="form-control" id="selectCampaignField" onchange="campaignDetailsShow(this.value);return false;">
<option value="">Select Campaign</option>
<option value="all">All</option>
<!--<option value="all">All</option>--->
@foreach($campaignList as $campaign)
<option value="{{ $campaign->mkey }}">{{ $campaign->mkey }}</option>
@endforeach
......
<?php
include_once(app_path().'/lib/phpexcel/PHPExcel.php');
$inputFileType = "Excel5";
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load("assets/extras/blank.xls");
$baseRow = 2;
$objPHPExcel->getActiveSheet()->setCellValue('A1', "12");
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="Output.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType);
$objWriter->save('php://output');
return ;
?>
\ No newline at end of file
......@@ -28,19 +28,19 @@
</div>
<div class="col-sm-4 bot">
<a href="javascript:;" onclick="menuAction(&quot;group&quot;);return false;" style="color:white;">
<a href="javascript:;" onclick="menuAction('disposition');return false;" style="color:white;">
<div class="new1">
<div class="icon"> <i class="fa fa-users"></i></div>
Groups
Disposition List
</div>
</a>
</div>
<div class="col-sm-4 bot">
<a href="javascript:;" onclick="menuAction(&quot;role&quot;);return false;" style="color:white;">
<a href="javascript:;" onclick="menuAction('dispositionPlan');return false;" style="color:white;">
<div class="new1">
<div class="icon"> <i class="fa fa-star"></i></div>
Role
Dispositon Plan
</div>
</a>
</div>
......
......@@ -3,14 +3,14 @@ use App\Jobs\KHRMSLib;
use App\Models\CRMCall;
$client=Input::get("client");
/*$prevData=Input::get("prev");
$prevData=Input::get("prev");
$currentStatus = Input::get("currentStatus");
$legalStatus = Input::get("legalStatus");
if($currentStatus==""||$legalStatus==""|| $prevData==""){
$currentStatus="ACTIVE";
$legalStatus="PRIMARY";
$prevData="MTD";
}*/
}
$wakka=new KHRMSLib();
$dispoclassarr=array('NC'=>array(0,array()),'CC'=>array(0,array()),'CB'=>array(0,array()),'NA'=>array(0,array()));
......@@ -31,7 +31,7 @@ use App\Models\CRMCall;
$roclientstr=array();$didlinesstr=array();if(Auth::user()->exten!="")$didlinesstr[]=Auth::user()->exten;
$roclientlst=$wakka->clientsReadAccess();
//print_r($roclientlst);
if(!empty($roclientlst))foreach($roclientlst as $tclnt)if($tclnt!="")
{
$roclientstr[]="'$tclnt'";
......@@ -72,7 +72,7 @@ use App\Models\CRMCall;
//$currentstatuses=$wakka->LoadAll("select distinct currentstatus from records where currentstatus!='' $owclientstr");
//$legalstatuses=$wakka->LoadAll("select distinct legalstatus from records where legalstatus!='' $owclientstr");
/*$dispoarr=$wakka->LoadAll("select count(*) as cnt,currentstatus,legalstatus,dialer_status from records where 1=1 $owclientstr group by currentstatus,legalstatus,dialer_status");
$dispoarr=$wakka->LoadAll("select count(*) as cnt,currentstatus,legalstatus,dialer_status from records where 1=1 $owclientstr group by currentstatus,legalstatus,dialer_status");
$countStatuses = array('New', 'Called');
foreach ($countStatuses as $status) {
......@@ -111,7 +111,7 @@ use App\Models\CRMCall;
$Priority=$wakka->getCount("records","priority in (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
$Flagged=$wakka->getCount("records","dialer_flag='VIP' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
/*$NotCalledFlagged=$wakka->getCount("records"," priority='VIP' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");*/
/*$NotCalledFlagged=$wakka->getCount("records"," mf_isa='VIP' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
$NotCalledFlagged=$wakka->getCount("records"," mf_isa='VIP' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
}
if($prevData=='YTD'&&$legalStatus!='SECONDARY')
......@@ -122,12 +122,12 @@ use App\Models\CRMCall;
$NotCalled=$wakka->getCount("records","old_status='New' and currentstatus='$currentStatus' and legalstatus='$legalStatus' $owclientstr");
$TotalCalled=$wakka->getCount("records","old_status='Called' and currentstatus='$currentStatus' and legalstatus='$legalStatus' $owclientstr");
$Priority=$wakka->getCount("records","priority in (1,2,3,4,5,6,7,8,9,10) and currentstatus='$currentStatus' and legalstatus='$legalStatus' $owclientstr");
$Flagged=$wakka->getCount("records","dialer_flag='VIP' and currentstatus='$currentStatus' and legalstatus='$legalStatus' $owclientstr");*/
$Flagged=$wakka->getCount("records","dialer_flag='VIP' and currentstatus='$currentStatus' and legalstatus='$legalStatus' $owclientstr");
/*$NotCalledFlagged=$wakka->getCount("records"," priority='VIP' and currentstatus='$currentStatus' and legalstatus='$legalStatus' $owclientstr");*/
/*$NotCalledFlagged=$wakka->getCount("records"," mf_isa='VIP' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
}*/
$NotCalledFlagged=$wakka->getCount("records"," mf_isa='VIP' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
}
/*if($prevData=='MTD'&&$legalStatus=='SECONDARY')
if($prevData=='MTD'&&$legalStatus=='SECONDARY')
{
$dispoarr=$wakka->LoadAll("select count(*) as cnt,currentstatus,legalstatus,dialer_status from records where 1=1 $owclientstr group by currentstatus,legalstatus,dialer_status having legalstatus='$legalStatus' and currentstatus='$currentStatus'");
......@@ -137,10 +137,10 @@ use App\Models\CRMCall;
$Priority=$wakka->getCount("records","priority in (1,2,3,4,5,6,7,8,9,10) and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
$Flagged=$wakka->getCount("records","dialer_flag='VIP' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
/*$NotCalledFlagged=$wakka->getCount("records"," priority='VIP' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");*/
/*$NotCalledFlagged=$wakka->getCount("records"," mf_isa='VIP' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
}*/
$NotCalledFlagged=$wakka->getCount("records"," mf_isa='VIP' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
}
/*if($prevData=='YTD'&&$legalStatus=='SECONDARY')
if($prevData=='YTD'&&$legalStatus=='SECONDARY')
{
$ydispoarr=$wakka->LoadAll("select count(*) as cnt,currentstatus,legalstatus,old_dialer_status from records where 1=1 $owclientstr group by currentstatus,legalstatus,old_dialer_status having legalstatus='$legalStatus' and currentstatus='$currentStatus'");
......@@ -150,7 +150,7 @@ use App\Models\CRMCall;
$Priority=$wakka->getCount("records","priority in (1,2,3,4,5,6,7,8,9,10) and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
$Flagged=$wakka->getCount("records","dialer_flag='VIP' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
/*$NotCalledFlagged=$wakka->getCount("records"," priority='VIP' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");*/
/*$NotCalledFlagged=$wakka->getCount("records"," mf_isa='VIP' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
$NotCalledFlagged=$wakka->getCount("records"," mf_isa='VIP' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
}
$MissedCalls=0;
......@@ -202,30 +202,278 @@ use App\Models\CRMCall;
$recstoday=$wakka->getCount("records","dialer_lastcall>='".date("Y-m-d 00:00:00")."' $owclientstr");
$recsmonth=$wakka->getCount("records","dialer_lastcall>='".date("Y-m-01 00:00:00")."' $owclientstr");*/
$recsmonth=$wakka->getCount("records","dialer_lastcall>='".date("Y-m-01 00:00:00")."' $owclientstr");
$user=Auth::user()->id;
$role = Auth::user()->usertype;
$userId = Auth::user()->id;
// role== user
// all
if($role == 'User'){
$TotalCalled=$wakka->getCount("crmcalls","user_id = $userId and created_at > '".date("Y-m-d 03:00:00")."'");
$contactedTotalCalled=$wakka->getCount("crmcalls","userstatus='Contacted' and user_id = $userId and created_at > '".date("Y-m-d 03:00:00")."'");
$calllog = DB::table('records')
//->join('crmcalls', 'records.dialer_callback', '=', 'crmcalls.usercallback')
->select('records.customer_name', 'records.cust_id', 'records.mobile', 'records.dialer_callback', 'records.status','records.dialer_lastcall','records.id','records.dialer_status','records.client')
->where("records.usr_id",$userId)
//->where("records.dialer_substatus","Follow Up")
->where("records.dialer_callback", "!=","0000-00-00 00:00:00")
//->where("crmcalls.usercallback", "!=","0000-00-00 00:00:00")
//->where("crmcalls.created_at", ">",date("Y-m-d 08:00:00"))
//->where("crmcalls_archive.usercallback", "=","records.dialer_callback")
//->where("records.dialer_lastcall", "<=","crmcalls_archive.usercallback")
->get();
// campaign
$campaignTotalCalled=$wakka->getCount("crmcalls","user_id = $userId and client = '$client' and created_at > '".date("Y-m-d 03:00:00")."'");
$campaignContactedTotalCalled=$wakka->getCount("crmcalls","userstatus='Contacted' and user_id = $userId and client = '$client' and created_at > '".date("Y-m-d 03:00:00")."'");
$campaignFollowupCount = DB::table('records')
//->join('crmcalls', 'records.dialer_callback', '=', 'crmcalls.usercallback')
->select('records.customer_name', 'records.cust_id', 'records.mobile', 'records.dialer_callback', 'records.status','records.dialer_lastcall','records.id','records.dialer_status','records.client')
->where("records.usr_id",$userId)
//->where("records.dialer_substatus","Follow Up")
->where("records.dialer_callback", "!=","0000-00-00 00:00:00")
//->where("crmcalls.usercallback", "!=","0000-00-00 00:00:00")
//->where("crmcalls.created_at", ">",date("Y-m-d 08:00:00"))
//->where("crmcalls_archive.usercallback", "=","records.dialer_callback")
//->where("records.dialer_lastcall", "<=","crmcalls_archive.usercallback")
->where('records.client', '=', $client)
->get();
}else if($role == 'Supervisor'){
//supervisor
$userName = Auth::user()->username;
$supervisorUsers=$wakka->LoadAll("select id from users where supervisor='$userName';");
$userIds = [];
foreach ($supervisorUsers as $key => $value) $userIds[] = "'".$value['id']."'";
$supervisorUsers = implode(",",$userIds);
$supervisorTotalCalled = 0;
$supervisorContacted = 0;
$supervisorCallLog = 0;
$supervisorCampaignTotalCalled = 0;
$supervisorCampaignContacted = 0;
$supervisorCampaignCallLog = 0;
if(!empty($supervisorUsers)){
// all
$supervisorTotalCalled=$wakka->getCount("crmcalls","user_id IN ($supervisorUsers) and created_at > '".date("Y-m-d 03:00:00")."'");
$supervisorContacted=$wakka->getCount("crmcalls","userstatus='Contacted' and user_id IN ($supervisorUsers) and created_at > '".date("Y-m-d 03:00:00")."'");
$supervisorCallLog = $calllog = DB::table('records')
//->join('crmcalls', 'records.dialer_callback', '=', 'crmcalls.usercallback')
->select('records.customer_name', 'records.cust_id', 'records.mobile', 'records.dialer_callback', 'records.status','records.dialer_lastcall','records.id','records.dialer_status','records.client')
->whereIn("records.usr_id",[$supervisorUsers])
//->where("records.dialer_substatus","Follow Up")
->where("records.dialer_callback", "!=","0000-00-00 00:00:00")
//->where("crmcalls.usercallback", "!=","0000-00-00 00:00:00")
//->where("crmcalls.created_at", ">",date("Y-m-d 08:00:00"))
//->where("crmcalls_archive.usercallback", "=","records.dialer_callback")
//->where("records.dialer_lastcall", "<=","crmcalls_archive.usercallback")
->get();
$supervisorCallLog = count($supervisorCallLog);
// campaign
$supervisorCampaignTotalCalled=$wakka->getCount("crmcalls","user_id IN ($supervisorUsers) and client = '$client' and created_at > '".date("Y-m-d 03:00:00")."'");
$supervisorCampaignContacted=$wakka->getCount("crmcalls","userstatus='Contacted' and user_id IN ($supervisorUsers) and client = '$client' and created_at > '".date("Y-m-d 03:00:00")."'");
$supervisorCampaignCallLog = $calllog = DB::table('records')
//->join('crmcalls', 'records.dialer_callback', '=', 'crmcalls.usercallback')
->select('records.customer_name', 'records.cust_id', 'records.mobile', 'records.dialer_callback', 'records.status','records.dialer_lastcall','records.id','records.dialer_status','records.client')
->whereIn("records.usr_id",[$supervisorUsers])
//->where("records.dialer_substatus","Follow Up")
->where("records.dialer_callback", "!=","0000-00-00 00:00:00")
//->where("crmcalls.usercallback", "!=","0000-00-00 00:00:00")
//->where("crmcalls.created_at", ">",date("Y-m-d 08:00:00"))
//->where("crmcalls_archive.usercallback", "=","records.dialer_callback")
//->where("records.dialer_lastcall", "<=","crmcalls_archive.usercallback")
->where('records.client', '=', $client)
->get();
$supervisorCampaignCallLog = count($supervisorCampaignCallLog);
}
}
?>
<?php if($role == 'User'){ ?>
<div class="container">
<div class=col-md-3>
<div class=col-md-11>
<div class="row">
<?php if(sizeof($roclientlst)>0){ ?>
<h5>
Campaign
<select class='form-control pull-right' id=tcampaign_select onchange='campaignSelect();' style='width:50%'>
<?php foreach($roclientlst as $c){$s="";if($c==$client)$s='selected';echo "<option value='$c' $s>$c</option>";} ?>
<div class="col-md-1" style="padding: 0px;margin: 6px;">
<h4>Campaign</h4>
</div>
<div class=col-md-5>
<select class='form-control selcls' id=tcampaign_select onchange='campaignSelect();'>
<?php $s=""; $i = 0;
foreach($roclientlst as $c){
$c=trim($c);
if(!empty($c)){
//if($c==$client)$s='selected';
if($i == 0)$s='selected';
echo "<option value='$c' $s>$c</option>";
}
} ?>
</select>
</h5>
<br>
<!---<div class=col-md-6>
<select class=form-control id=data_select onchange='dataSelect();'>
<?php //foreach($dataSelect as $d){$s="";if($d==$prevData)$s='selected';echo "<option value='$d' $s>$d</option>";} ?>
</div>
<div class=col-md-5>
<select class=form-control id=data_select onchange='dataSelect();' style='display:none'>
<?php foreach($dataSelect as $d){$s="";if($d==$prevData)$s='selected';echo "<option value='$d' $s>$d</option>";} ?>
</select>
</div>
<div style='clear:both'></div>
<br>
<?php } ?>
</div>
<div class="row"><div class="col-sm-4"><h4>Total</h4></div></div>
<div class="row">
<div class="col-sm-4 bot">
<div class="new1" style="color:white;">
<div class="text">
<var><?php echo $TotalCalled; ?></var>
</div>
Called
</div>
</div>
<div class="col-sm-4 bot">
<div class="new1" style="color:white;">
<div class="text">
<var><?php echo $contactedTotalCalled; ?></var>
</div>
Contacted
</div>
</div>
<div class="col-sm-4 bot">
<a href="javascript:;" onclick="loadFollowupData('all');" style="color:white;">
<div class="new1" style="color:white;">
<div class="text">
<var><?php echo count($calllog); ?></var>
</div>
Follow Up
</div>
</a>
</div>
</div>
<div class="row"><div class="col-sm-4"><h4>Campaign Wise</h4></div></div>
<div class="row">
<div class="col-sm-4 bot">
<div class="new1" style="color:white;">
<div class="text">
<var><?php echo $campaignTotalCalled; ?></var>
</div>
Called
</div>
</div>
<div class="col-sm-4 bot">
<div class="new1" style="color:white;">
<div class="text">
<var><?php echo $campaignContactedTotalCalled; ?></var>
</div>
Contacted
</div>
</div>
<div class="col-sm-4 bot">
<a href="javascript:;" onclick="loadFollowupData('campaign');" style="color:white;">
<div class="new1" style="color:white;">
<div class="text">
<var><?php echo count($campaignFollowupCount); ?></var>
</div>
Follow Up
</div>
</a>
</div>
</div>
<!-- <div class="row"><div class="col-sm-4"><h4>Total</h4></div></div>
<div class="row">
<div class="col-sm-4">
<div class="hero-widget well well-sm">
<div class="text">
<var><?php echo $TotalCalled; ?></var>
<label class="text-muted">Called</label>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="hero-widget well well-sm">
<div class="text">
<var ><?php echo $contactedTotalCalled; ?></var>
<label class="text-muted">Contacted</label>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="hero-widget well well-sm">
<div class="text">
<var><?php echo count($calllog); ?></var>
<label class="text-muted">
<!-- <a href="#" onclick="menuAction('dialer/loadFollowupData');return false;">Follow Up</a>Follow Up
</label>
</div>
</div>
</div>
<h5>
</div>
<div class="row"><div class="col-sm-4"><h4>Campaign Wise</h4></div></div>
<div class="row">
<div class="col-sm-4">
<div class="hero-widget well well-sm">
<div class="text">
<var><?php echo $campaignTotalCalled; ?></var>
<label class="text-muted">Called</label>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="hero-widget well well-sm">
<div class="text">
<var ><?php echo $campaignContactedTotalCalled; ?></var>
<label class="text-muted">Contacted</label>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="hero-widget well well-sm">
<div class="text">
<var><?php echo count($campaignFollowupCount); ?></var>
<label class="text-muted"><!-- <a href="#" onclick="menuAction('dialer/loadFollowupData');return false;">Follow Up</a>Follow Up</label>
</div>
</div>
</div>
</div> -->
</div>
<div class=col-md-3 style="display: none" >
<div class=col-md-11>
<!-- <h5>
Buckets
<span class='label label-small label-default pull-right'>
<a href=# onclick="dialerLoadData('CallsMonth','','',1,'','');return false;" style='color:#fff;font-size:12px'>
......@@ -240,13 +488,13 @@ use App\Models\CRMCall;
</h5>
<div style='clear:both'></div>
<hr><br>
<hr><br>-->
<?php
//print_r($legalstatuses);
//print_r($currentstatuses);
?>
<div class=col-md-6>
<!-- <div class=col-md-6>
<select class=form-control id=legalstatus_select onchange='bucketSelect();'>
<option value='PRIMARY'>PRIMARY</option>
<option value='SECONDARY'>SECONDARY</option>
......@@ -257,75 +505,83 @@ use App\Models\CRMCall;
<option value='ACTIVE'>ACTIVE</option>
<option value='PASSIVE'>PASSIVE</option>
</select>
</div>
</div> -->
<div style='clear:both'></div>
<ul style="list-style:none">
<li class="notify_alert">
<span><a href=# onclick="dialerLoadData('CurrentQueue','','',1,'','');return false;">CurrentQueue</a></span>--->
<!--<span class="label label-small pull-right" >
<!-- <li class="notify_alert">
<span><a href=# onclick="dialerLoadData('CurrentQueue','','',1,'','');return false;">CurrentQueue</a></span>
<span class="label label-small pull-right" >
0
</span>-->
<!---</li>
<li class="notify_alert">
</span>
</li> -->
<!-- <li class="notify_alert">
<span><a href=# onclick="dialerLoadData('MissedCalls','','',1,'','');return false;">MissedCalls</a></span>
<span class="label label-small label-primary pull-right" >
{!!$MissedCalls!!}
</span>
</li>
<li class="notify_alert">
</li> -->
<!-- <li class="notify_alert">
<span><a href=# onclick="dialerLoadData('Priority','','',1,'','');return false;">Priority</a></span>
<span class="label label-small label-info pull-right" >
{!!$Priority!!}
</span>
</li> -->
<li class="notify_alert">
<span><a href=# onclick="dialerLoadData('FollowUp,','','',1,'','');return false;">FollowUp</a></span>
<span class="label label-small label-default pull-right" >
{!!$FollowUp!!}
</span>
</li>
<li class="notify_alert">
<span><a href=# onclick="dialerLoadData('TotalData','{!!$currentStatus!!}','{!!$legalStatus!!}',1,'','');return false;">TotalData</a></span>
<!-- <span><a href=# onclick="dialerLoadData('TotalData','{!!$currentStatus!!}','{!!$legalStatus!!}',1,'','');return false;">TotalData</a></span> -->
<span>TotalData</span>
<span class="label label-small label-default pull-right" >
{!!$TotalData!!}
</span>
</li>
<li class="notify_alert">
<!-- <li class="notify_alert">
<span><a href=# onclick="dialerLoadData('NotCalled','{!!$currentStatus!!}','{!!$legalStatus!!}',1,'','');return false;">NotCalled</a></span>
<span class="label label-small label-default pull-right" >
{!!$NotCalled!!}
</span>
</li>
</li> -->
<li class="notify_alert">
<span><a href=# onclick="dialerLoadData('Called','','',1,'','');return false;">Called</a></span>
<!-- <span><a href=# onclick="dialerLoadData('Called','','',1,'','');return false;">Called</a></span> -->
<span>Called</span>
<span class="label label-small label-success pull-right" >
{!!$TotalCalled!!}
</span>
</li>
<li class="notify_alert">
<span><a href=# onclick="return false;">Contacted</a></span>
<!-- <span><a href=# onclick="return false;">Contacted</a></span> -->
<span>Contacted</span>
<span class="label label-small label-success pull-right" id=contactedcnt_span>
0
</span>
</li>
<li class="notify_alert">
<!-- <li class="notify_alert">
<span><a href=# onclick="dialerLoadData('Flagged-Called','{!!$currentStatus!!}','{!!$legalStatus!!}',1,'','');return false;">Flagged-Called</a></span>
<span class="label label-small label-success pull-right" >
{!!$Flagged!!}
</span>
</li>
<li class="notify_alert">
</li> -->
<!-- <li class="notify_alert">
<span><a href=# onclick="dialerLoadData('Flagged-Notcalled','{!!$currentStatus!!}','{!!$legalStatus!!}',1,'','');return false;">Flagged-NotCalled</a></span>
<span class="label label-small label-warning pull-right" >
{!!$NotCalledFlagged!!}
</span>
</li>
<li class="notify_alert">
</li> -->
<!-- <li class="notify_alert">
<span><a href=# onclick="dialerLoadData('today-birthday','{!!$currentStatus!!}','{!!$legalStatus!!}',1,'','');return false;">Today Birthday</a></span>
<span class="label label-small label-warning pull-right" >
{!!$todaybirthday!!}
</span>
</li>
</li> -->
<hr><br>--->
<hr><br>
<?php
/*if($prevData=='' ||$prevData=='MTD')
if($prevData=='' ||$prevData=='MTD')
{
foreach($dispoarr as $disp) {
......@@ -342,7 +598,7 @@ use App\Models\CRMCall;
if($disp['dialer_status'])
{
?>
<li class="notify_alert bucketliitem {!!$class!!}">
<li class="notify_alert bucketliitem sdfsdf {!!$class!!}">
<span><a href=# onclick="dialerLoadData('{!!$disp['dialer_status']!!}','{!!$disp['currentstatus']!!}','{!!$disp['legalstatus']!!}',1,'','');return false;">{!!$disp['dialer_status']!!}</a></span>
<span class="label label-small label-success pull-right" >
{!!$disp['cnt']!!}
......@@ -369,7 +625,7 @@ use App\Models\CRMCall;
if($disp['old_dialer_status'])
{
?>
<li class="notify_alert bucketliitem {!!$class!!}">
<li class="notify_alert bucketliitem test {!!$class!!}">
<span><a href=# onclick="dialerLoadData('{!!$disp['old_dialer_status']!!}','{!!$disp['currentstatus']!!}','{!!$disp['legalstatus']!!}',1,'','');return false;">{!!$disp['old_dialer_status']!!}</a></span>
<span class="label label-small label-success pull-right" >
{!!$disp['cnt']!!}
......@@ -382,16 +638,22 @@ use App\Models\CRMCall;
}
$contacted=$dispoclassarr['CC'][0]+$dispoclassarr['CB'][0]+$dispoclassarr['NC'][0];
echo "<script>$('#contactedcnt_span').html('$contacted');</script>";*/
echo "<script>$('#contactedcnt_span').html('$contacted');</script>";
?>
<!-- </ul>
</div>
</div>
<div class=col-md-9 id=bucketlistdiv>--- -->
</ul>
</div>
<div style='clear:both'></div>
</div>
<!-- <div class=col-md-9 id=bucketlistdiv></div>
--><div style='clear:both'></div>
<?php }else if($role == 'Admin'){ ?>
@include("layout/module/dashboard/adminHomePage")
<?php }else if($role == 'Supervisor'){ ?>
@include("layout/module/dashboard/supervisorHomePage")
<?php } ?>
<script>
......@@ -399,25 +661,32 @@ use App\Models\CRMCall;
$("#tcampaign_select").val('<?=$client?>');
<?php }?>
<?php //if($prevData){ ?>
//$("#data_select").val('<?=$prevData?>');
<?php //}?>
<?php if($prevData){ ?>
$("#data_select").val('<?=$prevData?>');
<?php }?>
<?php //if($legalStatus){ ?>
//$("#legalstatus_select").val('<?=$legalStatus?>');
<?php //}?>
<?php if($legalStatus){ ?>
$("#legalstatus_select").val('<?=$legalStatus?>');
<?php }?>
<?php if($currentStatus){ ?>
$("#currentstatus_select").val('<?=$currentStatus?>');
<?php }?>
function loadFollowupData(val)
{
var menu = "dialer/loadFollowupData";
doAjax(menu+"?client="+$("#tcampaign_select").val()+"&selection="+val,'','content','ajax_'+menu,'singlethis','GET');
}
function campaignSelect()
{
var dashlet="Dialer";
doAjax("dashboard/dashlet?module="+dashlet+"&client="+$("#tcampaign_select").val(),"","DashletT-"+dashlet,"ajax_dashlet_"+dashlet,"singlefail","GET");
}
/*function dataSelect()
function dataSelect()
{
var currentStatus = $('#currentstatus_select').val();
var legalStatus = $('#legalstatus_select').val();
......@@ -427,13 +696,13 @@ function campaignSelect()
var dashlet="Dialer";
doAjax("dashboard/dashlet?module="+dashlet+"&client="+client+"&prev="+prev+"&currentStatus="+currentStatus+"&legalStatus="+legalStatus,"","DashletT-"+dashlet,"ajax_dashlet_"+dashlet,"singlefail","GET");
}
*/
function bucketSelect()
{
/*var activeclass='CLS_'+$('#currentstatus_select').val()+$('#legalstatus_select').val();
$('.bucketliitem').hide();
$('.'+activeclass).show();*/
/*var currentStatus = $('#currentstatus_select').val();
var currentStatus = $('#currentstatus_select').val();
var legalStatus = $('#legalstatus_select').val();
var prev = $("#data_select").val();
var client = $("#tcampaign_select").val();
......@@ -441,14 +710,58 @@ function bucketSelect()
var dashlet="Dialer";
doAjax("dashboard/status?module="+dashlet+"&client="+client+"&prev="+prev+"&currentStatus="+currentStatus+"&legalStatus="+legalStatus,"","DashletT-"+dashlet,"ajax_dashlet_"+dashlet,"singlefail","GET");
}*/
}
//bucketSelect();
function dialerLoadData(listname,currentstatus,legalstatus,page,skey,stxt)
{
//doAjax("dialer/bucketdata","client={!!$client!!}&bucket="+listname+"&currentstatus="+currentstatus+"&legalstatus="+legalstatus+'&page='+page+'&skey='+skey+'&stxt='+stxt,"bucketlistdiv","ajax_dialer_list","singlefail","GET");
doAjax("dialer/bucketdata","client={!!$client!!}&bucket="+listname+"&currentstatus="+currentstatus+"&legalstatus="+legalstatus+'&page='+page+'&skey='+skey+'&stxt='+stxt,"bucketlistdiv","ajax_dialer_list","singlefail","GET");
}
dialerLoadData('CurrentQueue','','',1,'','');
</script>
<style>
.hero-widget { text-align: center; padding-top: 20px; padding-bottom: 20px; text-shadow: 1px 1px 2px blue, 0 0 25px blue, 0 0 5px darkblue; }
.hero-widget .icon { display: block; font-size: 96px; line-height: 96px; margin-bottom: 10px; text-align: center; }
.hero-widget var { display: block; height: 64px; font-size: 64px; line-height: 64px; font-style: normal; }
.hero-widget label { font-size: 17px; }
.hero-widget .options { margin-top: 10px; }
.well { background-color : #040404 }
.acolor { color: #000000;}
.new1 .icon { display: block; font-size: 96px; line-height: 96px; margin-bottom: 10px; text-align: center; }
.bot { padding-bottom: 20px !important; }
.new1 var { display: block; height: 96px; font-size: 96px; line-height: 96px; font-style: normal; }
</style>
<style>
.new1 {
/*width: 200px;
height: auto;*/
padding: 15px;
background-color: #f6f7fb;
box-shadow: 10px 10px 5px grey;
font-size:30px;
border: 2px solid red;
border-radius: 50px 20px;
text-align: center;
/* text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;*/
text-shadow: 1px 1px 2px blue, 0 0 25px blue, 0 0 5px darkblue;
}
.selcls {
/* padding: 9px; */
border: solid 1px #517B97;
outline: 0;
background: -webkit-gradient(linear, left top, left 25, from(#FFFFFF), color-stop(4%, #CAD9E3), to(#FFFFFF));
background: -moz-linear-gradient(top, #FFFFFF, #CAD9E3 1px, #FFFFFF 25px);
box-shadow: rgba(0,0,0, 0.1) 0px 0px 8px;
-moz-box-shadow: rgba(0,0,0, 0.1) 0px 0px 8px;
-webkit-box-shadow: rgba(0,0,0, 0.1) 0px 0px 8px;
}
</style>
\ No newline at end of file
......
......@@ -40,12 +40,14 @@ use App\Models\CRMCall;
$mastersdata=$wakka->getCompanyMaster($tclnt);
if(!empty($mastersdata["DialerDID"]))$didlinesstr[]=$mastersdata["DialerDID"];
if(empty($mastersdata['dialerDispoList']))$mastersdata['dialerDispoList']=$wakka->HRCoreVars['dialerDispoList'];
$dispoarr = [];
if(!empty($mastersdata['dialerDispoList'])){
// $mastersdata['dialerDispoList']=$wakka->HRCoreVars['dialerDispoList'];
$dispoarr=explode("~",$mastersdata['dialerDispoList']);
foreach($dispoarr as $dispo)
{
}
if(count($dispoarr) > 0){
foreach($dispoarr as $dispo){
if(!empty($dispo))
{
$dispoprts=explode("|",$dispo);
......@@ -58,6 +60,15 @@ use App\Models\CRMCall;
}
}
}
}else{
$dispositionPlan = $wakka->getDispositionList();
foreach ($dispositionPlan as $key => $value) {
$disposition = $value->disposition;
$subDisposition = $value->sunDispoName;
$data.="dialerdispoarray['$disposition']='$subDisposition';";
}
}
}
foreach($didlinesstr as $k=>$dids)
{
......@@ -72,7 +83,7 @@ use App\Models\CRMCall;
//$currentstatuses=$wakka->LoadAll("select distinct currentstatus from records where currentstatus!='' $owclientstr");
//$legalstatuses=$wakka->LoadAll("select distinct legalstatus from records where legalstatus!='' $owclientstr");
$dispoarr=$wakka->LoadAll("select count(*) as cnt,currentstatus,legalstatus,dialer_status from records where 1=1 $owclientstr group by currentstatus,legalstatus,dialer_status");
//$dispoarr=$wakka->LoadAll("select count(*) as cnt,currentstatus,legalstatus,dialer_status from records where 1=1 $owclientstr group by currentstatus,legalstatus,dialer_status");
$countStatuses = array('New', 'Called');
foreach ($countStatuses as $status) {
......@@ -103,59 +114,59 @@ use App\Models\CRMCall;
if($prevData=='MTD'&&$legalStatus!='SECONDARY')
{
$dispoarr=$wakka->LoadAll("select count(*) as cnt,currentstatus,legalstatus,dialer_status from records where 1=1 $owclientstr group by currentstatus,legalstatus,dialer_status having legalstatus='$legalStatus' and currentstatus='$currentStatus'");
//$dispoarr=$wakka->LoadAll("select count(*) as cnt,currentstatus,legalstatus,dialer_status from records where 1=1 $owclientstr group by currentstatus,legalstatus,dialer_status having legalstatus='$legalStatus' and currentstatus='$currentStatus'");
$TotalData=$wakka->getCount("records","status IN ('New', 'Called','Noqueue') and currentstatus='$currentStatus' and legalstatus='$legalStatus' $owclientstr");
$NotCalled=$wakka->getCount("records","status='New' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
$TotalCalled=$wakka->getCount("records","status='Called' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
$Priority=$wakka->getCount("records","priority in (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
$Flagged=$wakka->getCount("records","dialer_flag='VIP' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
//$TotalData=$wakka->getCount("records","status IN ('New', 'Called','Noqueue') and currentstatus='$currentStatus' and legalstatus='$legalStatus' $owclientstr");
//$NotCalled=$wakka->getCount("records","status='New' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
//$TotalCalled=$wakka->getCount("records","status='Called' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
//$Priority=$wakka->getCount("records","priority in (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
//$Flagged=$wakka->getCount("records","dialer_flag='VIP' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
/*$NotCalledFlagged=$wakka->getCount("records"," priority='VIP' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");*/
$NotCalledFlagged=$wakka->getCount("records"," mf_isa='VIP' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
//$NotCalledFlagged=$wakka->getCount("records"," mf_isa='VIP' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
}
if($prevData=='YTD'&&$legalStatus!='SECONDARY')
{
$ydispoarr=$wakka->LoadAll("select count(*) as cnt,currentstatus,legalstatus,old_dialer_status from records where 1=1 $owclientstr group by currentstatus,legalstatus,old_dialer_status");
/*$ydispoarr=$wakka->LoadAll("select count(*) as cnt,currentstatus,legalstatus,old_dialer_status from records where 1=1 $owclientstr group by currentstatus,legalstatus,old_dialer_status");
$TotalData=$wakka->getCount("records","old_status IN ('New', 'Called','Noqueue') and currentstatus='$currentStatus' and legalstatus='$legalStatus' $owclientstr");
$NotCalled=$wakka->getCount("records","old_status='New' and currentstatus='$currentStatus' and legalstatus='$legalStatus' $owclientstr");
$TotalCalled=$wakka->getCount("records","old_status='Called' and currentstatus='$currentStatus' and legalstatus='$legalStatus' $owclientstr");
$Priority=$wakka->getCount("records","priority in (1,2,3,4,5,6,7,8,9,10) and currentstatus='$currentStatus' and legalstatus='$legalStatus' $owclientstr");
$Flagged=$wakka->getCount("records","dialer_flag='VIP' and currentstatus='$currentStatus' and legalstatus='$legalStatus' $owclientstr");
$Flagged=$wakka->getCount("records","dialer_flag='VIP' and currentstatus='$currentStatus' and legalstatus='$legalStatus' $owclientstr");*/
/*$NotCalledFlagged=$wakka->getCount("records"," priority='VIP' and currentstatus='$currentStatus' and legalstatus='$legalStatus' $owclientstr");*/
$NotCalledFlagged=$wakka->getCount("records"," mf_isa='VIP' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
//$NotCalledFlagged=$wakka->getCount("records"," mf_isa='VIP' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
}
if($prevData=='MTD'&&$legalStatus=='SECONDARY')
{
$dispoarr=$wakka->LoadAll("select count(*) as cnt,currentstatus,legalstatus,dialer_status from records where 1=1 $owclientstr group by currentstatus,legalstatus,dialer_status having legalstatus='$legalStatus' and currentstatus='$currentStatus'");
/*$dispoarr=$wakka->LoadAll("select count(*) as cnt,currentstatus,legalstatus,dialer_status from records where 1=1 $owclientstr group by currentstatus,legalstatus,dialer_status having legalstatus='$legalStatus' and currentstatus='$currentStatus'");
$TotalData=$wakka->getCount("records","status IN ('New', 'Called','Noqueue') and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
$NotCalled=$wakka->getCount("records","status='New' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
$TotalCalled=$wakka->getCount("records","status='Called' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
$Priority=$wakka->getCount("records","priority in (1,2,3,4,5,6,7,8,9,10) and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
$Flagged=$wakka->getCount("records","dialer_flag='VIP' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
$Flagged=$wakka->getCount("records","dialer_flag='VIP' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");*/
/*$NotCalledFlagged=$wakka->getCount("records"," priority='VIP' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");*/
$NotCalledFlagged=$wakka->getCount("records"," mf_isa='VIP' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
// $NotCalledFlagged=$wakka->getCount("records"," mf_isa='VIP' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
}
if($prevData=='YTD'&&$legalStatus=='SECONDARY')
{
$ydispoarr=$wakka->LoadAll("select count(*) as cnt,currentstatus,legalstatus,old_dialer_status from records where 1=1 $owclientstr group by currentstatus,legalstatus,old_dialer_status having legalstatus='$legalStatus' and currentstatus='$currentStatus'");
/* $ydispoarr=$wakka->LoadAll("select count(*) as cnt,currentstatus,legalstatus,old_dialer_status from records where 1=1 $owclientstr group by currentstatus,legalstatus,old_dialer_status having legalstatus='$legalStatus' and currentstatus='$currentStatus'");
$TotalData=$wakka->getCount("records","old_status IN ('New', 'Called','Noqueue') and currentstatus='$currentStatus' and legalstatus='$legalStatus' $owclientstr");
$NotCalled=$wakka->getCount("records","old_status='New' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
$TotalCalled=$wakka->getCount("records","old_status='Called' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
$Priority=$wakka->getCount("records","priority in (1,2,3,4,5,6,7,8,9,10) and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
$Flagged=$wakka->getCount("records","dialer_flag='VIP' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
/*$NotCalledFlagged=$wakka->getCount("records"," priority='VIP' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");*/
$NotCalledFlagged=$wakka->getCount("records"," mf_isa='VIP' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");
*/ /*$NotCalledFlagged=$wakka->getCount("records"," priority='VIP' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");*/
/* $NotCalledFlagged=$wakka->getCount("records"," mf_isa='VIP' and (currentstatus='$currentStatus' and legalstatus='$legalStatus') $owclientstr");*/
}
$MissedCalls=0;
$udidlinesstr = array();
/*$udidlinesstr = array();
foreach($didlinesstr as $didlinestr){
$didlinestrArr=explode(":",$didlinestr);
$udidlinesstr[] = substr($didlinestrArr[0], env('didnumber'));
......@@ -164,8 +175,8 @@ use App\Models\CRMCall;
$mc=CRMCall::where('userstatus','=','InboundDROP')->where('created_at','>','2018-09-11 00:00:00')->where('created_at','>',date('Y-m-d H:i:s',time()-(7*24*60*60)));
$mc=$mc->where(function ($query) use($roclientlst,$udidlinesstr){
$query->orWhereIn('client',$roclientlst)->orWhereIn('did',$udidlinesstr);
});
$mc=$mc->get();
});*/
/* $mc=$mc->get();
$number_list=array();
foreach($mc as $key=>$tcall)
......@@ -195,7 +206,7 @@ use App\Models\CRMCall;
$MissedCalls++;
}
}
}
}*/
$callstoday=CRMCall::where("created_at",">=",date("Y-m-d 00:00:00"))->where("user_id","=",Auth::user()->id)->count();
$callsmonth=CRMCall::where("created_at",">=",date("Y-m-01 00:00:00"))->where("user_id","=",Auth::user()->id)->count();
......@@ -210,38 +221,50 @@ use App\Models\CRMCall;
// role== user
// all
if($role == 'User'){
$TotalCalled= 0;
$contactedTotalCalled=0;
$calllog = [];
$campaignTotalCalled=0;
$campaignContactedTotalCalled=0;
$campaignFollowupCount = [];
$totalAppointmentCount = [];
$campaignAppointmentCount = [];
$TotalCalled=$wakka->getCount("crmcalls","user_id = $userId and created_at > '".date("Y-m-d 03:00:00")."'");
//$TotalCalled=$wakka->getCount("crmcalls","user_id = $userId and created_at > '".date("Y-m-d 03:00:00")."'");
$contactedTotalCalled=$wakka->getCount("crmcalls","userstatus='Contacted' and user_id = $userId and created_at > '".date("Y-m-d 03:00:00")."'");
$calllog = DB::table('records')
//->join('crmcalls', 'records.dialer_callback', '=', 'crmcalls.usercallback')
->select('records.customer_name', 'records.cust_id', 'records.mobile', 'records.dialer_callback', 'records.status','records.dialer_lastcall','records.id','records.dialer_status','records.client')
->where("records.usr_id",$userId)
//->where("records.dialer_substatus","Follow Up")
->where("records.dialer_callback", "!=","0000-00-00 00:00:00")
//->where("crmcalls.usercallback", "!=","0000-00-00 00:00:00")
//->where("crmcalls.created_at", ">",date("Y-m-d 08:00:00"))
//->where("crmcalls_archive.usercallback", "=","records.dialer_callback")
//->where("records.dialer_lastcall", "<=","crmcalls_archive.usercallback")
->select('customer_name', 'cust_id', 'mobile', 'dialer_callback', 'status','dialer_lastcall','id','dialer_status','client')
->where("usr_id",$userId)
->where("dialer_callback", "!=","0000-00-00 00:00:00")
->get();
$totalAppointmentCount = DB::table('records')
->select('customer_name', 'cust_id', 'mobile', 'dialer_appointment', 'status','dialer_lastcall','id','dialer_status','client')
->where("usr_id",$userId)
->where("dialer_appointment", "!=","0000-00-00 00:00:00")
->where('dialer_appointment','>',date('Y-m-d H:i:s',time()-(7*24*60*60)))
->get();
// campaign
$campaignTotalCalled=$wakka->getCount("crmcalls","user_id = $userId and client = '$client' and created_at > '".date("Y-m-d 03:00:00")."'");
//$campaignTotalCalled=$wakka->getCount("crmcalls","user_id = $userId and client = '$client' and created_at > '".date("Y-m-d 03:00:00")."'");
$campaignContactedTotalCalled=$wakka->getCount("crmcalls","userstatus='Contacted' and user_id = $userId and client = '$client' and created_at > '".date("Y-m-d 03:00:00")."'");
$campaignFollowupCount = DB::table('records')
//->join('crmcalls', 'records.dialer_callback', '=', 'crmcalls.usercallback')
->select('records.customer_name', 'records.cust_id', 'records.mobile', 'records.dialer_callback', 'records.status','records.dialer_lastcall','records.id','records.dialer_status','records.client')
->where("records.usr_id",$userId)
//->where("records.dialer_substatus","Follow Up")
->where("records.dialer_callback", "!=","0000-00-00 00:00:00")
//->where("crmcalls.usercallback", "!=","0000-00-00 00:00:00")
//->where("crmcalls.created_at", ">",date("Y-m-d 08:00:00"))
//->where("crmcalls_archive.usercallback", "=","records.dialer_callback")
//->where("records.dialer_lastcall", "<=","crmcalls_archive.usercallback")
->where('records.client', '=', $client)
->select('customer_name', 'cust_id', 'mobile', 'dialer_callback', 'status','dialer_lastcall','id','dialer_status','client')
->where("usr_id",$userId)
->where("dialer_callback", "!=","0000-00-00 00:00:00")
->where('client', '=', $client)
->get();
$campaignAppointmentCount = DB::table('records')
->select('customer_name', 'cust_id', 'mobile', 'dialer_appointment', 'status','dialer_lastcall','id','dialer_status','client')
->where("usr_id",$userId)
->where("dialer_appointment", "!=","0000-00-00 00:00:00")
->where('client', '=', $client)
->where('dialer_appointment','>',date('Y-m-d H:i:s',time()-(7*24*60*60)))
->get();
}else if($role == 'Supervisor'){
......@@ -250,16 +273,20 @@ use App\Models\CRMCall;
$userName = Auth::user()->username;
$supervisorUsers=$wakka->LoadAll("select id from users where supervisor='$userName';");
$userIds = [];
//print_r($supervisorUsers);
foreach ($supervisorUsers as $key => $value) $userIds[] = "'".$value['id']."'";
$supervisorUsers = implode(",",$userIds);
$supervisorTotalCalled = 0;
$supervisorContacted = 0;
$supervisorCallLog = 0;
$supervisorAppointmentCount = 0;
$supervisorCampaignTotalCalled = 0;
$supervisorCampaignContacted = 0;
$supervisorCampaignCallLog = 0;
$supervisorcampaignAppointCount = 0;
if(!empty($supervisorUsers)){
......@@ -269,39 +296,55 @@ use App\Models\CRMCall;
$supervisorContacted=$wakka->getCount("crmcalls","userstatus='Contacted' and user_id IN ($supervisorUsers) and created_at > '".date("Y-m-d 03:00:00")."'");
/* $supervisorUsers = explode(',',$supervisorUsers);
$supervisorUsers = implode(',',$supervisorUsers);
$supervisorCallLog = $calllog = DB::table('records')
//->join('crmcalls', 'records.dialer_callback', '=', 'crmcalls.usercallback')
->select('records.customer_name', 'records.cust_id', 'records.mobile', 'records.dialer_callback', 'records.status','records.dialer_lastcall','records.id','records.dialer_status','records.client')
->whereIn("records.usr_id",[$supervisorUsers])
//->where("records.dialer_substatus","Follow Up")
->where("records.dialer_callback", "!=","0000-00-00 00:00:00")
//->where("crmcalls.usercallback", "!=","0000-00-00 00:00:00")
//->where("crmcalls.created_at", ">",date("Y-m-d 08:00:00"))
//->where("crmcalls_archive.usercallback", "=","records.dialer_callback")
//->where("records.dialer_lastcall", "<=","crmcalls_archive.usercallback")
->get();
->whereIn('recordss.usr_id',[$supervisorUsers])
->where('records.dialer_callback', '!=','0000-00-00 00:00:00')
->get();*/
$supervisorCallLog = $calllog = DB::select("select records.customer_name, records.cust_id, records.mobile, records.dialer_callback, records.status,records.dialer_lastcall,records.id,records.dialer_status,records.client from records where usr_id in (".$supervisorUsers.") and records.dialer_callback !='0000-00-00 00:00:00'");
$supervisorCallLog = count($supervisorCallLog);
/*$supervisorAppointmentCount = DB::table('records')
->select('records.customer_name', 'records.cust_id', 'records.mobile', 'records.dialer_appointment', 'records.status','records.dialer_lastcall','records.id','records.dialer_status','records.client')
->whereIn("records.usr_id",[$supervisorUsers])
//->where("records.dialer_appointment", "!=","0000-00-00 00:00:00")
->where('records.dialer_appointment','>',date('Y-m-d H:i:s',time()-(7*24*60*60)))
->get();*/
$supervisorAppointmentCount = DB::select('select customer_name,cust_id,mobile,dialer_appointment,status,dialer_lastcall,client from records where usr_id in ('.$supervisorUsers.') and dialer_appointment>"'.date("Y-m-d H:i:s",time()-(7*24*60*60)).'"');
//print_r($supervisorAppointmentCount);
$supervisorAppointmentCount = count($supervisorAppointmentCount);
// campaign
$supervisorCampaignTotalCalled=$wakka->getCount("crmcalls","user_id IN ($supervisorUsers) and client = '$client' and created_at > '".date("Y-m-d 03:00:00")."'");
//print_r($supervisorCampaignTotalCalled);
$supervisorCampaignContacted=$wakka->getCount("crmcalls","userstatus='Contacted' and user_id IN ($supervisorUsers) and client = '$client' and created_at > '".date("Y-m-d 03:00:00")."'");
$supervisorCampaignCallLog = $calllog = DB::table('records')
//->join('crmcalls', 'records.dialer_callback', '=', 'crmcalls.usercallback')
/* $supervisorCampaignCallLog = $calllog = DB::table('records')
->select('records.customer_name', 'records.cust_id', 'records.mobile', 'records.dialer_callback', 'records.status','records.dialer_lastcall','records.id','records.dialer_status','records.client')
->whereIn("records.usr_id",[$supervisorUsers])
//->where("records.dialer_substatus","Follow Up")
->where("records.dialer_callback", "!=","0000-00-00 00:00:00")
//->where("crmcalls.usercallback", "!=","0000-00-00 00:00:00")
//->where("crmcalls.created_at", ">",date("Y-m-d 08:00:00"))
//->where("crmcalls_archive.usercallback", "=","records.dialer_callback")
//->where("records.dialer_lastcall", "<=","crmcalls_archive.usercallback")
->where('records.client', '=', $client)
->get();
->get();*/
$supervisorCampaignCallLog = $calllog = DB::select("select records.customer_name, records.cust_id, records.mobile, records.dialer_callback, records.status,records.dialer_lastcall,records.id,records.dialer_status,records.client from records where usr_id in (".$supervisorUsers.") and records.dialer_callback !='0000-00-00 00:00:00' and records.client ='$client'");
//print_r( $supervisorCampaignCallLog);
$supervisorCampaignCallLog = count($supervisorCampaignCallLog);
//print_r( $supervisorCampaignCallLog);
/*$supervisorcampaignAppointCount = DB::table('records')
->select('records.customer_name', 'records.cust_id', 'records.mobile', 'records.dialer_appointment', 'records.status','records.dialer_lastcall','records.id','records.dialer_status','records.client')
->whereIn("records.usr_id",[$supervisorUsers])
->where("records.dialer_appointment", "!=","0000-00-00 00:00:00")
->where('records.client', '=', $client)
->where('records.dialer_appointment','>',date("Y-m-d H:i:s",time()-(7*24*60*60)))
->get();*/
$supervisorcampaignAppointCount = DB::select('select customer_name,cust_id,mobile,dialer_appointment,status,dialer_lastcall,client from records where usr_id in ('.$supervisorUsers.') and client = "'.$client.'" and dialer_appointment>"'.date("Y-m-d H:i:s",time()-(7*24*60*60)).'"');
$supervisorcampaignAppointCount = count($supervisorcampaignAppointCount);
}
}
......@@ -322,8 +365,9 @@ use App\Models\CRMCall;
foreach($roclientlst as $c){
$c=trim($c);
if(!empty($c)){
//if($c==$client)$s='selected';
if($i == 0)$s='selected';
if($c == $client)$s='selected';
echo "<option value='$c' $s>$c</option>";
}
} ?>
......@@ -343,14 +387,14 @@ use App\Models\CRMCall;
<div class="row"><div class="col-sm-4"><h4>Total</h4></div></div>
<div class="row">
<div class="col-sm-4 bot">
<!--<div class="col-sm-4 bot">
<div class="new1" style="color:white;">
<div class="text">
<var><?php echo $TotalCalled; ?></var>
<var><?php //echo $TotalCalled; ?></var>
</div>
Called
</div>
</div>
</div>-->
<div class="col-sm-4 bot">
<div class="new1" style="color:white;">
......@@ -371,19 +415,29 @@ use App\Models\CRMCall;
</div>
</a>
</div>
<div class="col-sm-4 bot">
<a href="javascript:;" onclick="loadAppointmentData('all');" style="color:white;">
<div class="new1" style="color:white;">
<div class="text">
<var><?php echo count($totalAppointmentCount); ?></var>
</div>
Appointment Fixed
</div>
</a>
</div>
</div>
<div class="row"><div class="col-sm-4"><h4>Campaign Wise</h4></div></div>
<div class="row">
<div class="col-sm-4 bot">
<!---<div class="col-sm-4 bot">
<div class="new1" style="color:white;">
<div class="text">
<var><?php echo $campaignTotalCalled; ?></var>
<var><?php //echo $campaignTotalCalled; ?></var>
</div>
Called
</div>
</div>
</div>-->
<div class="col-sm-4 bot">
<div class="new1" style="color:white;">
......@@ -404,6 +458,16 @@ use App\Models\CRMCall;
</div>
</a>
</div>
<div class="col-sm-4 bot">
<a href="javascript:;" onclick="loadAppointmentData('campaign');" style="color:white;">
<div class="new1" style="color:white;">
<div class="text">
<var><?php echo count($campaignAppointmentCount); ?></var>
</div>
Appointment Fixed
</div>
</a>
</div>
</div>
<!-- <div class="row"><div class="col-sm-4"><h4>Total</h4></div></div>
......@@ -656,7 +720,7 @@ use App\Models\CRMCall;
<?php } ?>
<script>
client = $('#tcampaign_select').val();
<?php if($client){?>
$("#tcampaign_select").val('<?=$client?>');
<?php }?>
......@@ -679,11 +743,20 @@ function loadFollowupData(val)
doAjax(menu+"?client="+$("#tcampaign_select").val()+"&selection="+val,'','content','ajax_'+menu,'singlethis','GET');
}
function loadAppointmentData(val)
{
var menu = "dialer/loadAppointmentData";
doAjax(menu+"?client="+$("#tcampaign_select").val()+"&selection="+val,'','content','ajax_'+menu,'singlethis','GET');
}
function campaignSelect()
{
var dashlet="Dialer";
var client = $('#tcampaign_select').val();
console.log();
doAjax("dashboard/dashlet?module="+dashlet+"&client="+$("#tcampaign_select").val(),"","DashletT-"+dashlet,"ajax_dashlet_"+dashlet,"singlefail","GET");
savedialermode(client);
}
function dataSelect()
......@@ -695,6 +768,7 @@ function dataSelect()
var dashlet="Dialer";
doAjax("dashboard/dashlet?module="+dashlet+"&client="+client+"&prev="+prev+"&currentStatus="+currentStatus+"&legalStatus="+legalStatus,"","DashletT-"+dashlet,"ajax_dashlet_"+dashlet,"singlefail","GET");
savedialermode(client);
}
function bucketSelect()
......@@ -708,15 +782,16 @@ function bucketSelect()
var client = $("#tcampaign_select").val();
var dashlet="Dialer";
doAjax("dashboard/status?module="+dashlet+"&client="+client+"&prev="+prev+"&currentStatus="+currentStatus+"&legalStatus="+legalStatus,"","DashletT-"+dashlet,"ajax_dashlet_"+dashlet,"singlefail","GET");
}
//bucketSelect();
function dialerLoadData(listname,currentstatus,legalstatus,page,skey,stxt)
{
//var client=$("#tcampaign_select").val();
doAjax("dialer/bucketdata","client={!!$client!!}&bucket="+listname+"&currentstatus="+currentstatus+"&legalstatus="+legalstatus+'&page='+page+'&skey='+skey+'&stxt='+stxt,"bucketlistdiv","ajax_dialer_list","singlefail","GET");
savedialermode("{!!$client!!}");
}
dialerLoadData('CurrentQueue','','',1,'','');
</script>
......
......@@ -59,6 +59,17 @@
</div>
</a>
</div>
<div class="col-sm-4 bot">
<a href="javascript:;" onclick="loadAppointmentData('all');" style="color:white;">
<div class="new1" style="color:white;">
<div class="text">
<var><?php echo $supervisorAppointmentCount; ?></var>
</div>
Appointment Fixed
</div>
</a>
</div>
</div>
<div class="row"><div class="col-sm-4"><h4>Campaign Wise</h4></div></div>
......@@ -93,5 +104,16 @@
</a>
</div>
<div class="col-sm-4 bot">
<a href="javascript:;" onclick="loadAppointmentData('campaign');" style="color:white;">
<div class="new1" style="color:white;">
<div class="text">
<var><?php echo $supervisorcampaignAppointCount; ?></var>
</div>
Appointment Fixed
</div>
</a>
</div>
</div>
</div>
......
<?php
use App\Models\CRMCall;
use App\Models\CRMCallArchive;
use App\Models\User;
use App\Models\UserLog;
use App\Jobs\KHRMSLib;
$wakka = new KHRMSLib();
$dashboarduser=Auth::user();
$timeoffset = $dashboarduser->timezone; //-330; //$dashboarduser->timezone;
$timeoffset = $timeoffset*60;
$logtime =(isset($_GET['logtime'])) ? $_GET['logtime'] :9;
$logtimeto =(isset($_GET['logtimeto']))? $_GET['logtimeto']:20;
$logdate =(isset($_GET['logdate'])) ? strtotime($_GET['logdate']." ".$logtime.":00:00")
: strtotime(date("Y-m-d")." 09:00:00");
$logdateto =(isset($_GET['logdateto']))? strtotime($_GET['logdateto']." ".$logtimeto.":00:00")
: strtotime(date("Y-m-d")." 20:00:00");
$campaign =(isset($_GET['campaign'])) ? $_GET['campaign'] : "All";
// testing input
//$logtime = 9;$logtimeto = 20;$logdate = strtotime("2017-10-26 ".$logtime.":00:00");$logdateto = strtotime("2017-10-26 ".$logtimeto.":00:00");$campaign = 'All';
// testing input
$alist=CRMCallArchive::where('user_id','!=',0)->where('created_at','>=',date("Y-m-d H:i:s",$logdate+$timeoffset))->where('created_at','<=',date("Y-m-d H:i:s",$logdateto+$timeoffset));
$alist->orderBy('user_id', 'ASC')->orderBy('ts_Close', 'ASC');
$userlog=UserLog::where('created_at','>=',date("Y-m-d H:i:s",$logdate+$timeoffset))->where('created_at','<=',date("Y-m-d H:i:s",$logdateto+$timeoffset));
if($campaign != 'All') $alist->where('client','=',$campaign);
$userarr=array();
$allusers = DB::table('users as u1')->leftjoin('users AS u2', 'u2.username', '=', 'u1.supervisor')
->select('u1.id','u1.username','u1.fullname AS telecaller', 'u2.fullname AS sepervisor')
->where('u1.status','=','Active');
$roclientstr=array();$didlinesstr=array();
if($dashboarduser->exten!="")$didlinesstr[]=$dashboarduser->exten;
$oclientlst=$wakka->clientsReadAccess(); sort($oclientlst); $oclientlst[0] = 'All';
if(!empty($oclientlst))foreach($oclientlst as $tclnt)if($tclnt!="")
{
$roclientstr[]="$tclnt";
$mastersdata=$wakka->getCompanyMaster($tclnt);
if(!empty($mastersdata["DialerDID"]))$didlinesstr[]=$mastersdata["DialerDID"];
}
$breaks=array("Paused","AgentBriefing","TeamMeeting","QualityFeedback","LunchBreak","TeaBreak","UtilityBreak","FloorAnnouncements","DownTime");
$reporthead=array_merge(array("#","RM","RM Code","Team Manager","Sessions","CallCount","TOS","Net Total","Wait","Call","Talk","Dispo","ProgressiveTotal","P-Call","P-Talk","P-Dispo","ManualTotal","M-Call","M-Talk","M-Dispo","IncomingTotal","I-Call","I-Talk","I-Dispo","PausedTotal"),$breaks);
$reportarray=array();
$i=1;
if($dashboarduser->usertype != 'Admin')
{
$uidlist=array($dashboarduser->id);
$allusers=$allusers->where(function ($query) use($dashboarduser) {
$query->where('u1.supervisor','=',$dashboarduser->username)
->orWhere('u1.lteam2','=',$dashboarduser->username)
->orWhere('u1.lteam','=',$dashboarduser->username);
})->get();
foreach($allusers as $tuser)
{
$uidlist[]=$tuser->id;
$reportarray[$tuser->id]=array("#"=>$i++,"RM"=>$tuser->telecaller,"RM Code"=>$tuser->username,"Team Manager"=>$tuser->sepervisor);
}
$reportarray[$dashboarduser->id]=array("#"=>$i++,"RM"=>$dashboarduser->fullname,"RM Code"=>$dashboarduser->username,"Team Manager"=>$dashboarduser->supervisor);
$alist=$alist->whereIn('user_id',$uidlist);
/*$alist=$alist->where(function ($query) use($roclientstr,$uidlist,$didlinesstr){
$query->orWhereIn('client',$roclientstr)
->orWhereIn('did',$didlinesstr);
});*/
$userlog=$userlog->whereIn('user_id',$uidlist);
}else{
$allusers=$allusers->get();
foreach($allusers as $tuser)
{
$reportarray[$tuser->id]=array("#"=>$i++,"RM"=>$tuser->telecaller,"RM Code"=>$tuser->username,"Team Manager"=>$tuser->sepervisor);
}
}
// echo "<pre>"; print_r($allusers);exit;
$alist=$alist->get();
$userlog=$userlog->get();
$prev_close = 0;
// echo count($userlog);exit;
foreach($alist as $aline)
{
if($prev_user != $aline->user_id || $prev_close <= $aline->ts_Wait)
{
$userid=$aline->user_id;
$talktime=$aline->talkSec+$aline->recstartSec+$aline->recendSec;
$totaltime=$aline->callSec+$talktime+$aline->dispoSec;
$reportarray[$userid]["oncall"]+=$totaltime/1000;
// $reportarray[$userid]["Wait"]+=$aline->waitSec/1000;
$reportarray[$userid]["Call"]+=$aline->callSec/1000;
$reportarray[$userid]["Talk"]+=$talktime/1000;
$reportarray[$userid]["Dispo"]+=$aline->dispoSec/1000;
if($aline->type == 'Progressive')
{
$reportarray[$userid]["P-Call"]+=$aline->callSec/1000;
$reportarray[$userid]["P-Talk"]+=$talktime/1000;
$reportarray[$userid]["P-Dispo"]+=$aline->dispoSec/1000;
$reportarray[$userid]["ProgressiveTotal"]+=($aline->callSec/1000)+($talktime/1000)+($aline->dispoSec/1000);
}
if($aline->type == 'Manual')
{
$reportarray[$userid]["M-Call"]+=$aline->callSec/1000;
$reportarray[$userid]["M-Talk"]+=$talktime/1000;
$reportarray[$userid]["M-Dispo"]+=$aline->dispoSec/1000;
$reportarray[$userid]["ManualTotal"]+=($aline->callSec/1000)+($talktime/1000)+($aline->dispoSec/1000);
}
if($aline->type == 'Inbound')
{
$reportarray[$userid]["I-Call"]+=$aline->callSec/1000;
$reportarray[$userid]["I-Talk"]+=$talktime/1000;
$reportarray[$userid]["I-Dispo"]+=$aline->dispoSec/1000;
$reportarray[$userid]["IncomingTotal"]+=($aline->callSec/1000)+($talktime/1000)+($aline->dispoSec/1000);
}
}
$reportarray[$userid]["CallCount"]++;
$prev_close = $aline->ts_Close;//-ts_Wait
$prev_user = $aline->user_id;//-ts_Wait
}
function cmp($a, $b) {
return $a["ts"] - $b["ts"];
}
$userLogin=array();
foreach($userlog as $ulog)
{
$data=json_decode($ulog->data,true);
usort($data, "cmp");
$lastSip = end($data);
$starttime = strtotime($ulog->startdate.' '.$ulog->starttime);
//echo "starttime:".$starttime;
$endtime = round($lastSip['ts']/1000);
//console.log($endtime);
//echo "End time:".$endtime;
$userLogin[$ulog->user_id]['duration'] += ($endtime-$starttime);
//echo "Userlog:".$userLogin[$ulog->user_id]['duration'];
$userLogin[$ulog->user_id]['start'][] = $starttime;
$userLogin[$ulog->user_id]['end'][] = $endtime;
$prets=strtotime($ulog->startdate." ".$ulog->starttime)*1000;
$previous="Paused-Paused";
foreach($data as $sdata)
{
$pts=$sdata['ts'];
if(isset($sdata['states']))
{
foreach($sdata['states'] as $ts=>$states)
{
if($previous != "Paused-WRAPUP")$previous = str_replace('Paused-', '', $previous);
if(!in_array($previous,$reporthead) && !in_array($previous,array('Progressive-','Manual-','Ready-Incoming','Ready-Predictive','DialNext-','Paused-WRAPUP'))) {
$previous = 'Paused';
}
$reportarray[$ulog->user_id][$previous]+=round($ts-$prets,2)/1000;
$prets=$ts;
$previous=$states[0].'-'.$states[1];
}
if($previous != "Paused-WRAPUP")$previous = str_replace('Paused-', '', $previous);
$reportarray[$ulog->user_id][$previous]+=round($pts-$prets,2)/1000;
$prets=$pts;
}
}
}
if(count($userLogin)) foreach ($userLogin as $userid => $value)
{
$break_time=0;
foreach ($breaks as $break) {
$break_time+=$reportarray[$userid][$break];
$reportarray[$userid]["PausedTotal"]+=$reportarray[$userid][$break];
}
$sessionsStr = "";
for($i = 0; $i < count($value['start']); $i++){
if($sessionsStr == ""){
$sessionsStr .= date("Y-m-d H:i:s", $value['start'][$i]-$timeoffset)." - ".date("Y-m-d H:i:s", $value['end'][$i]-$timeoffset);
}else{
$sessionsStr .= ",\n".date("Y-m-d H:i:s", $value['start'][$i]-$timeoffset)." - ".date("Y-m-d H:i:s", $value['end'][$i]-$timeoffset);
}
}
$reportarray[$userid]["Sessions"]=$sessionsStr;
// $reportarray[$userid]["Signin"]=date("Y-m-d H:i:s", min($value['start'])-$timeoffset);
// $reportarray[$userid]["Signout"]=date("Y-m-d H:i:s", max($value['end'])-$timeoffset);
$reportarray[$userid]["TOS"]=$value['duration'];
$reportarray[$userid]["Net Total"]=$value['duration']-$break_time;
$reportarray[$userid]["Wait"]=$reportarray[$userid]["Net Total"]-$reportarray[$userid]['oncall'];
if($reportarray[$userid]["Wait"] < 0){
$reportarray[$userid]["Net Total"] += abs($reportarray[$userid]["Wait"]);
$reportarray[$userid]["TOS"] += abs($reportarray[$userid]["Wait"]);
$reportarray[$userid]["Wait"] = 0;
}
}
$highestColumn = sizeof($reporthead);
if(count($reportarray)) {
$outhead="<tr>";$outstr="";
for ($head = 0; $head < $highestColumn; $head++){
if($reporthead[$head] == "Sessions"){
$outhead.="<td style='width:270px;display:block;'>".$reporthead[$head]."</td>";
}elseif($reporthead[$head] == "PausedTotal" || $reporthead[$head] == "ProgressiveTotal" || $reporthead[$head] == "ManualTotal" || $reporthead[$head] == "IncomingTotal"){
$outhead.="<td class='warning'>".$reporthead[$head]."</td>";
}elseif($reporthead[$head] == "Paused"){
$outhead.="<td>ManualPaused</td>";
}else{
$outhead.="<td>".$reporthead[$head]."</td>";
}
}
$outhead.="</tr>";
$utotalarr = array("RM"=>'Net Total');
$reportRowNo = 1;
foreach($reportarray as $uid=>$uarr)
{
if(array_key_exists('TOS',$uarr) && array_key_exists('RM Code',$uarr))
{
$outstr.="<tr>";
for ($head = 0; $head < $highestColumn; $head++){
if($head < 1){
$data_str = $reportRowNo; $reportRowNo++;
}elseif($head < 5) {
// if($head < 6) {
$data_str = $uarr[$reporthead[$head]];
}
elseif($head < 6) {
$data_str = $uarr[$reporthead[$head]];
$utotalarr[$reporthead[$head]] += $uarr[$reporthead[$head]];
}
else {
$data_str = secToDuration(round($uarr[$reporthead[$head]]));
$utotalarr[$reporthead[$head]] += $uarr[$reporthead[$head]];
}
if($head == 12 || $head == 16 || $head == 20 || $head == 24){
$outstr.="<td class='warning'>".$data_str."</td>";
}else{
$outstr.="<td>".$data_str."</td>";
}
}
$outstr.="</tr>";
}
}
$outstr.="<tr>";
for ($head = 0; $head < $highestColumn; $head++)
{
if($head < 6) {
$data_str = $utotalarr[$reporthead[$head]];
}
else {
$data_str = secToDuration($utotalarr[$reporthead[$head]]);
}
if($head == 12 || $head == 16 || $head == 20 || $head == 24){
$outstr.="<td class='warning'>".$data_str."</td>";
}else{
$outstr.="<td>".$data_str."</td>";
}
}
$outstr.="</tr>";
} else {
$outhead.="<tr><td>No Records Found.</td></tr>";
}
if(Input::has("dllogxls"))
{
include_once(app_path().'/lib/phpexcel/PHPExcel.php');
$inputFileType = "Excel5";
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load("assets/extras/blank.xls");
$baseRow = 2;
$highestColumn = sizeof($reporthead);
for ($head = 0; $head < $highestColumn; $head++){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr."1", $reporthead[$head]);
}
foreach($reportarray as $uid=>$uarr)
{
if(array_key_exists('TOS',$uarr) && array_key_exists('RM Code',$uarr))
{
$row = $baseRow++;
$col = 0;
for ($head = 0; $head < $highestColumn; $head++){
$excelval = ($head < 6) ? $uarr[$reporthead[$head]] : secToDuration(round($uarr[$reporthead[$head]]));
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $excelval);
}
$row++;
}
}
//$row++;
for ($head = 0; $head < $highestColumn; $head++){
$excelval = ($head < 6) ? $utotalarr[$reporthead[$head]] : secToDuration(round($utotalarr[$reporthead[$head]]));
$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $excelval);
}
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="AgentTime.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType);
$objWriter->save('php://output');
return ;
}
function secToDuration($sec) {
return sprintf("%02d%s%02d%s%02d", floor($sec/3600), ':', ($sec/60)%60, ':', $sec%60);
}
?>
<style>#logtable.td{vertical-align:top;padding:20px;}#logtable.tr{height:28px;overflow-y:hidden;}
/*#logtable.table thead tr{
display:block;
}
#logtable.table tbody{
display:block;
height:500px;
overflow:auto;//set tbody to auto
}*/
</style>
<div class=innerAll>
<h4 style="float:left;width:50%;margin:10px 0;">Login Report <small>(Agent Time Report)</small></h4>
<div style="float:right;width:50%">
<button class="pull-right btn btn-sm btn-default" onclick='dlAgentlogXls();return false;' title='Download'><i class='fa fa-download'></i> Download</button>
</div>
<div style="clear:both"></div>
<hr style="margin-bottom: 5px;">
<div>
Search <input id=filter name="filter" type="text" style="border:1px solid #efefef; padding: 2px 10px;">&nbsp;&nbsp;
Date: From <input size=10 id='modfrom' name='modfrom' type='text' value='<?php echo date("Y-m-d",$logdate); ?>' onchange='statusLogReloadFun("");' />
<select id="modtime" style="border:1px solid #efefef;" onchange='statusLogReloadFun("");'>
<?php
foreach (range(0,23) as $hour) {
$selected = ($hour == $logtime) ? "selected" : "";
echo "<option value='$hour' $selected>".str_pad($hour, 2, "0", STR_PAD_LEFT) . ":00</option>";
}
?>
</select>
To <input size=10 id='modto' name='modto' type='text' value='<?php echo date("Y-m-d",$logdateto); ?>' onchange='statusLogReloadFun("");' />
<select id="modtimeto" style="border:1px solid #efefef;" onchange='statusLogReloadFun("");'>
<?php
foreach (range(0,23) as $hour) {
$selected = ($hour == $logtimeto) ? "selected" : "";
echo "<option value='$hour' $selected>".str_pad($hour, 2, "0", STR_PAD_LEFT) . ":00</option>";
}
?></select>&nbsp;&nbsp;
Campaign
<select id="campaign" style="border:1px solid #efefef;" onchange='statusLogReloadFun("");'>
<?php foreach($oclientlst as $c){$s="";if($c==$campaign)$s='selected';echo "<option value='$c' $s>$c</option>";} ?>
</select>
</div>
<div style="clear:both"></div>
<hr style="margin:5px;">
<div style="overflow: auto; margin-top: 10px;">
<table id=logtable class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px; margin:0; border:1px solid #BBB;'>
<thead><?php echo $outhead; ?></thead>
<tbody id="logTableData"><?php echo $outstr; ?></tbody>
</table>
</div>
<div id=dialoglog></div>
</div>
<script>
$(document).ready(function() {
if(!$('#dialoglog').hasClass('ui-dialog-content'))
{
$('#dialoglog').dialog({
autoOpen: false,
width: '70%',
buttons: {
"Ok": function() {
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
}
waitKeyUpRun("filter",function() { filter2(document.getElementById('filter'), 'logTableData') },"2000");
$('#modfrom').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
$('#modto').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
});
function dataString()
{
return 'logdate='+$("#modfrom").val()+'&logtime='+$("#modtime").val()+'&logdateto='+$("#modto").val()+'&logtimeto='+$("#modtimeto").val()+'&campaign='+$("#campaign").val();
}
function statusLogReloadFun(sortby)
{
var sortstr='';if(sortby!="")sortstr="&sort="+sortby
var searchStr = dataString();
doAjax('dialer/agenttime?'+searchStr+sortstr,'','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');
}
function dlAgentlogXls()
{
var searchStr = dataString();
window.open('dialer/agenttime?dllogxls=1&'+searchStr);
return false;
}
</script>
<?php
$dashboarduser=Auth::user();
$timeoffset=$dashboarduser->timezone*60;
?>
<div class="container-fluid">
<div class="layout-app">
<div class="row">
<div class="col-md-12">
<div class="col-separator col-separator-first col-unscrollable box">
<div class="innerAll">
<div>
<h4 id='tcampaign_select' value=<?php if(!empty($client)) echo $client; ?>>Appointment <?php if(!empty($client)) echo ": ".$client; ?></h4></div>
<hr style="margin-bottom: 10px;" />
<table class='table'
<thead>
<tr>
<th></th>
<th></th>
<?php if(empty($client)) echo "<th>Campaign</th>" ?>
<th>Cust_ID</th>
<th>Name</th>
<th>Number</th>
<!-- <th>Type</th>-->
<th>LastCall</th>
<!-- <th>Disposition</th> --->
<th>Appointment Date</th>
<!--- <th>Status</th> --->
<!-- <th>Count</th> -->
<!--<th></th>-->
<!-- <th>DID</th> -->
</tr>
</thead>
<tbody>
<?php
if($count > 0){
foreach ($appointment as $key => $value) { //echo "<pre>";print_r($value);exit;?>
<tr>
<td></td>
<td></td>
<?php if(empty($client)) echo "<td>$value->client</td>" ?>
<td><?php echo $value->cust_id; ?></td>
<td><?php echo $value->customer_name; ?></td>
<td><a href=# class='' onclick='dialerQuickOpen("<?php echo $value->id; ?>","<?php echo $value->mobile; ?>","Manual","",0);return false;'><?php echo $value->mobile; ?></a></td>
<td><?php echo date("Y-m-d H:i:s",strtotime($value->dialer_lastcall)-$timeoffset); ?></td>
<!--<td><?php //echo $value->dialer_status; ?></td>-->
<td><?php echo date("Y-m-d H:i:s",strtotime($value->dialer_appointment)-$timeoffset); ?></td>
<!--<td><?php //echo $value->status; ?></td>-->
</tr>
<?php }
}else{ ?>
<td colspan="9" align="center">No Record Available</td>
<?php } ?>
</table>
<div id="campaignDetailsArea"></div>
</div>
</div>
</div>
</div>
</div>
</div>
......@@ -176,12 +176,12 @@ foreach($alist_remark as $aline)
$remarkval[$aline->call_id]=$aline->fullremark;
}
$clientcodearr=DB::table('records')->select('clientcode','id','currentstatus','legalstatus')->whereIn('id',$crm_id)->get();
$clientcodearr=DB::table('records')->select('cust_id','id')->whereIn('id',$crm_id)->get();
foreach ($clientcodearr as $clientid)
{
$clientcodeval[$clientid->id]=$clientid->clientcode;
$currentstatusval[$clientid->id]=$clientid->currentstatus;
$legalstatusval[$clientid->id]=$clientid->legalstatus;
$clientcodeval[$clientid->id]=$clientid->cust_id;
//$currentstatusval[$clientid->id]=$clientid->currentstatus;
//$legalstatusval[$clientid->id]=$clientid->legalstatus;
}
if(Input::has("dllogxls"))
......@@ -247,8 +247,8 @@ if(Input::has("dllogxls"))
$legalstatus=$user["peopledata"]["legalstatus"];*/
$clientcode=$clientcodeval[$aline->crm_id];
$currentstatus=$currentstatusval[$aline->crm_id];
$legalstatus=$legalstatusval[$aline->crm_id];
// $currentstatus=$currentstatusval[$aline->crm_id];
// $legalstatus=$legalstatusval[$aline->crm_id];
}
$tpostdata=json_decode($aline->data,true);
$fulldate=date("Y-m-d H:i:s",strtotime($aline->created_at)-$timeoffset);
......
......@@ -44,7 +44,7 @@ $reportarray=array();
foreach($newcalls as $newcall)
{
$tcall=CRMCall::where('dialline_id','=',$newcall->id)->orderBy('id','DESC')->first();
$cust_id=DB::table('records')->select('clientcode','id','currentstatus','legalstatus')->where('id','=',$tcall->crm_id)->first();
$cust_id=DB::table('records')->select('cust_id','id')->where('id','=',$tcall->crm_id)->first();
$un="";$uid="";$us="";
if($tcall->user_id>0)
{
......@@ -132,7 +132,7 @@ foreach($sipids as $sipid)
$clidata=json_decode($sipid->clients,true);
$tcall=CRMCall::where('user_id','=',$sipid->user)->orderBy('id','DESC')->first();
$cust_id=DB::table('records')->select('clientcode','id','currentstatus','legalstatus')->where('id','=',$tcall->crm_id)->first();
$cust_id=DB::table('records')->select('cust_id','id')->where('id','=',$tcall->crm_id)->first();
$tuser=User::find($sipid->user);
$userlog=UserLog::where('user_id','=',$tuser->id)->orderBy("id","DESC")->first();
......
......@@ -42,9 +42,10 @@ foreach($allusers as $user){
<div class='container'>
<select id='dialmodeassign' class=select2multi multiple="" style="width: 30%;">
<option value="Progressive">Ready</option>
<!--<option value="Progressive">Ready</option>
<option value="Manual">Manual</option>
<option value="Incoming">Incoming</option>
<option value="Incoming">Incoming</option>-->
<?php foreach($callingmodeArr as $callingmode){;echo "<option value='$callingmode'>$callingmode</option>";} ?>
</select>
<select id='username' class=select2multi multiple="" style="width: 30%;">
......
<!-- Heading -->
<h5 class="innerAll margin-none bg-primary">
<i class="fa fa-fw fa-pencil"></i>Add Disposition
<a href="#" class="btn btn-sm btn-inverse pull-right btn-xs" style="margin-top: -5px;" onclick="return false">
<i class="fa fa-user fa-fw"></i>
</a>
</h5>
<form method="post" id="dispositionForm" class="innerAll">
<fieldset>
<div class="control-group">
<label class="col-md-4 control-label" for="disposition">Disposition Name</label>
<div class="col-md-8 controls tmar">
<input class="form-control" id="disposition" name="disposition" type="text" value="" required />
</div>
</div>
<div class="control-group ">
<label class="col-md-4 control-label" for="code">Code</label>
<div class="col-md-8 controls tmar">
<input class="form-control" id="code" name="code" type="text" value="" required />
</div>
</div>
<!-- <div class="control-group">
<label class="col-md-4 control-label" for="subDisposition">Sub Disposition</label>
<div class="col-md-8 controls tmar">
<input class="form-control" id="subDisposition" name="subDisposition" type="text" required />
</div>
</div> -->
<div class="control-group">
<label class="col-md-4 control-label" for="status">Status</label>
<div class="col-md-8 controls tmar">
<select class="form-control" id="" name="status" >
<option value="active">Active</option>
<option value="inactive">Inactive</option>
</select>
</div>
</div>
<div class="field_wrapper">
<div class="row">
<label class="col-md-4 control-label" for="subDisposition">Sub Disposition</label>
<div class="col-md-7 controls tmar">
<input type="text" class="form-control" name="subDisposition[]" required/>
</div>
<div class="col-md-1 controls tmar">
<a href="javascript:void(0);" class="add_button" title="Add field"><i class="fa fa-plus fa-3 iconsize" aria-hidden="true"></i></a>
</div>
</div>
</div>
<div class="form-actions">
<!-- <button type="submit" class="btn btn-primary" onclick='createDisposition();return false;'>Save changes</button> -->
<input type="submit" name="save" id="save" class="btn btn-primary" value="Save changes">
</div>
</fieldset>
</form>
<script>
$(document).ready(function(){
//var maxField = 10; //Input fields increment limitation
var addButton = $('.add_button'); //Add button selector
var wrapper = $('.field_wrapper'); //Input field wrapper
var fieldHTML = '<div class="row"><label class="col-md-4 control-label" for="subDisposition"></label><div class="col-md-7 controls tmar"><input type="text" class="form-control" name="subDisposition[]" required /></div><div class="col-md-1 controls tmar"><a href="javascript:void(0);" class="remove_button"><i class="fa fa-minus fa-3 iconsize" aria-hidden="true"></i></a></div></div>'; //New input field html
//var x = 1; //Initial field counter is 1
//Once add button is clicked
$(addButton).click(function(){
//Check maximum number of input fields
//if(x < maxField){
//x++; //Increment field counter
$(wrapper).append(fieldHTML); //Add field html
//}
});
//Once remove button is clicked
$(wrapper).on('click', '.remove_button', function(e){
e.preventDefault();
$(this).parent('div').parent('div').remove(); //Remove field html
//x--; //Decrement field counter
});
$('#dispositionForm').on('submit', function(event){
event.preventDefault();
var putdata = $('#dispositionForm').serialize();
doAjax('disposition?action=isExists',putdata,'','','','POST',function(retrstr){
if(retrstr.responseText == "true"){
simpleNotification('Error','topRight',"Disposition Already Exists!");
return false;
}else{
doAjax('disposition?action=createDisposition',putdata,'dispositionFormDiv','ajax_group_create','singlethis','POST',function(retrstr){
doAjax('disposition','','content','ajax_disposition','singlethis','GET',function(retrstr){
simpleNotification('Success','topRight',"Disposition created suceesfully!");
});
});
}
});
});
});
</script>
\ No newline at end of file
<!-- Heading -->
<h5 class="innerAll margin-none bg-primary">
<i class="fa fa-fw fa-pencil"></i> Edit Disposition
<a href="#" class="btn btn-sm btn-inverse pull-right btn-xs" style="margin-top: -5px;" onclick="return false">
<i class="fa fa-user fa-fw"></i>
</a>
</h5>
<?php //echo "<prE>";print_r($dispositionPlan); ?>
<form method="post" id="dispositionForm" class="innerAll">
<input class="form-control" name="dispoId" type="hidden" value="{!!$disposition->dispoId!!}" />
<fieldset>
<div class="control-group">
<label class="col-md-4 control-label" for="disposition">Disposition Name</label>
<div class="col-md-8 controls tmar">
<input class="form-control" id="disposition" name="disposition" type="text" value="{!!$disposition->disposition!!}" required />
</div>
</div>
<div class="control-group ">
<label class="col-md-4 control-label" for="code">Code</label>
<div class="col-md-8 controls tmar">
<input class="form-control" id="code" name="code" type="text" value="{!!$disposition->code!!}" required />
</div>
</div>
<!-- <div class="control-group">
<label class="col-md-4 control-label" for="subDisposition">Sub Disposition</label>
<div class="col-md-8 controls tmar">
<input class="form-control" id="subDisposition" name="subDisposition" type="text" required />
</div>
</div> -->
<div class="control-group">
<label class="col-md-4 control-label" for="status">Status</label>
<div class="col-md-8 controls tmar">
<select class="form-control" id="" name="status" >
<option value="{!!$disposition->status!!}">{!!$disposition->status!!}</option>
<option value="active">Active</option>
<option value="inactive">Inactive</option>
</select>
</div>
</div>
<?php $subDispo = explode(",", $disposition->sunDispoName); ?>
<div class="field_wrapper">
<?php for ($i=0; $i < count($subDispo); $i++) {
if($i == 0){ ?>
<div class="row">
<label class="col-md-4 control-label" for="subDisposition">Sub Disposition</label>
<div class="col-md-7 controls tmar">
<input type="text" class="form-control" name="subDisposition[]" value="{!!$subDispo[$i]!!}" required/>
</div>
<div class="col-md-1 controls tmar">
<a href="javascript:void(0);" class="add_button" title="Add field"><i class="fa fa-plus fa-3" aria-hidden="true"></i></a>
</div>
</div>
<?php }else{
?>
<div class="row">
<label class="col-md-4 control-label" for="subDisposition"></label>
<div class="col-md-7 controls tmar">
<input type="text" class="form-control" name="subDisposition[]" value="{!!$subDispo[$i]!!}" required /></div><div class="col-md-1 controls tmar"><a href="javascript:void(0);" class="remove_button"><i class="fa fa-minus fa-3 iconsize" aria-hidden="true"></i></a>
</div>
</div>
<?php }
} ?>
</div>
<div class="form-actions">
<!-- <button type="submit" class="btn btn-primary" onclick='createDisposition();return false;'>Save changes</button> -->
<input type="submit" name="save" id="save" class="btn btn-primary" value="Save changes">
</div>
</fieldset>
</form>
<script>
$(document).ready(function(){
//var maxField = 10; //Input fields increment limitation
var addButton = $('.add_button'); //Add button selector
var wrapper = $('.field_wrapper'); //Input field wrapper
var fieldHTML = '<div class="row"><label class="col-md-4 control-label" for="subDisposition"></label><div class="col-md-7 controls tmar"><input type="text" class="form-control" name="subDisposition[]" required /></div><div class="col-md-1 controls tmar"><a href="javascript:void(0);" class="remove_button"><i class="fa fa-minus fa-3 iconsize" aria-hidden="true"></i></a></div></div>'; //New input field html
//var x = 1; //Initial field counter is 1
//Once add button is clicked
$(addButton).click(function(){
//Check maximum number of input fields
//if(x < maxField){
//x++; //Increment field counter
$(wrapper).append(fieldHTML); //Add field html
//}
});
//Once remove button is clicked
$(wrapper).on('click', '.remove_button', function(e){
e.preventDefault();
$(this).parent('div').parent('div').remove(); //Remove field html
//x--; //Decrement field counter
});
$('#dispositionForm').on('submit', function(event){
event.preventDefault();
var putdata = $('#dispositionForm').serialize();
doAjax('disposition?action=isExists',putdata,'','','','POST',function(retrstr){
if(retrstr.responseText == "true"){
simpleNotification('Error','topRight',"Disposition Already Exists!");
return false;
}else{
doAjax('disposition?action=updateDisposition',putdata,'dispositionFormDiv','ajax_group_create','singlethis','POST',function(retrstr){
doAjax('disposition','','content','ajax_disposition','singlethis','GET',function(retrstr){
simpleNotification('Success','topRight',"Disposition updated suceesfully!");
});
});
}
});
});
});
</script>
\ No newline at end of file
......@@ -38,48 +38,71 @@
<!-- Category Heading -->
<div class="heading-buttons bg-gray border-bottom innerR half">
<a href="#" class="btn btn-sm btn-inverse pull-right" onclick="doAjax('campaign/create','','campaignformdiv','ajax_group_create','singlethis','GET');return false"><i class="fa fa-plus fa-fw"></i>New Disposition</a>
<h4 class="innerTB margin-bottom-none">Dispositions</h4>
<a href="#" class="btn btn-sm btn-inverse pull-right" onclick="doAjax('disposition/create','','dispositionFormDiv','ajax_group_create','singlethis','GET');return false"><i class="fa fa-plus fa-fw"></i>New Disposition</a>
<h4 class="innerTB margin-bottom-none">Disposition List</h4>
<div class="clearfix"></div>
</div>
<!-- End Category Heading -->
<?php //echo $grouplist->render(); ?>
<?php foreach ($dispositionList as $dispo)
{ //print_r($dispo);exit();
<?php if(count($dispositions) > 0){
foreach ($dispositions as $dispo){ //echo "<pre>";print_r($dispo);exit();
$tphoto="assets/images/people/avatar.jpg";
?>
<!-- Category Listing -->
<div class="row innerAll half border-bottom bg-gray- hover">
<div class="col-sm-8 col-xs-10">
<!-- dispolist Listing -->
<div class="row innerAll half border-bottom bg-gray-hover">
<div class="col-sm-2 col-xs-4">
<ul class="media-list margin-none">
<li class="media">
<a class="pull-left innerAll" href="#" onclick="editCampaign(' <?php echo $dispo['code']; ?>' , '<?php echo $dispo['disposition']; ?>', '<?php echo $dispo['disposition']; ?>');">
<a class="pull-left innerAll" href="#" onclick="doAjax('disposition/{!!$dispo->dispoId!!}/edit','','dispositionFormDiv','ajax_group_create','singlethis','GET');return false;">
<span class="btn btn-primary btn-xs"><i class="fa fa-pencil"></i></span>
</a>
<a class="pull-left innerAll" href="#" onclick="doAjax('group/{!!$tgroup->id!!}','','campaignformdiv','ajax_group_delete','singlethis','DELETE');return false;">
<span class="btn btn-primary btn-xs"><i class="fa fa-trash-o"></i></span>
</a>
<div class="media-body">
<!-- <div class="media-body">
<div class="innerAll">
<h5 class=""><a href="#" class="media-heading text-primary">{!!$dispo['code']!!} : {{$dispo['disposition']}}</a></h5>
<h5 class=""><a href="#" class="media-heading text-primary" onclick="doAjax('disposition/{!!$dispo->dispoId!!}/edit','','dispositionFormDiv','ajax_group_create','singlethis','GET');return false;"> {!!$dispo->plan!!}</a></h5>
<div class="clearfix"></div>
</div>
</div>
</div> -->
</li>
</ul>
</div>
<div class="col-sm-3 col-xs-2">
<div class="col-sm-4 col-xs-hidden">
<div class="innerAll">
<div class="media">
<!-- <a href="#" class="pull-left">
<img src="{!!$tphoto!!}" class="media-object" width=35px />
</a> -->
<div class="media-body">
<a href="#" class="text-small" title='{!!$dispo->created_at!!}' onclick="doAjax('disposition/{!!$dispo->dispoId!!}/edit','','dispositionFormDiv','ajax_group_create','singlethis','GET');return false;">{!!$dispo->code!!} : {!!$dispo->disposition!!}</a>
<div class="clearfix"></div>
<small>
@if($dispo->status=="active")
<span class="label label-success">{!!$dispo->status!!}</span>
@elseif($dispo->status=="inactive")
<span class="label label-warning">{!!$dispo->status!!}</span>
@endif
</small>
</div>
</div>
</div>
</div>
<div class="col-sm-3 col-xs-4">
<div class="text-center">
<p class="strong">Sub Disposition</p>
<span class="badge badge-primary badge-stroke" data-toggle="tooltip" data-title="Subscribed" data-placement ="right" data-container="body">{{$dispo['totalSubdisposition']}}</span>
<!-- <span class="badge badge-primary" data-toggle="tooltip" data-title="Published" data-placement="left" data-container="body">0</span> -->
<span class="badge badge-primary badge-stroke" data-toggle="tooltip" data-title="Subscribed" data-placement="right" data-container="body">{!!$dispo->totalSubDispo!!}</span>
</div>
</div>
</div>
<!-- // END Category Listing -->
<!-- // END Dispolist Listing -->
<?php } }else{?>
<div class="row innerAll half border-bottom bg-gray-hover">
<div class="col-sm-6 col-xs-8" style="text-align: center;">
<b>No data available</b>
</div>
</div>
<?php } ?>
<?php //echo $grouplist->render(); ?>
......@@ -92,7 +115,7 @@
<div class="col-md-6">
<!-- col-separator -->
<div class="col-separator col-separator-last" id=campaignformdiv>
<div class="col-separator col-separator-last" id=dispositionFormDiv>
</div>
<!-- // END col-separator -->
......@@ -118,7 +141,16 @@ menuAction("group?page="+res[1]);
return false;
});
function editCampaign(){
doAjax('campaign/edit','','campaignformdiv','ajax_group_create','singlethis','GET');return false;
}
$(document).ready(function(){
});
</script>
<style type="text/css">
.tmar {
margin-top : 10px;
}
.iconsize {
font-size: 2em;
margin-top: 5px;
}
</style>
\ No newline at end of file
......
<!-- Heading -->
<h5 class="innerAll margin-none bg-primary">
<i class="fa fa-fw fa-pencil"></i> Edit Disposition Plan
<a href="#" class="btn btn-sm btn-inverse pull-right btn-xs" style="margin-top: -5px;" onclick="return false">
<i class="fa fa-user fa-fw"></i>
</a>
</h5>
<?php //echo "<prE>";print_r($dispositionPlan[0]->dispositionPlanId);exit(); ?>
<form method="post" id="dispositionForm" class="innerAll">
<input class="form-control" name="dispositionPlanId" type="hidden" value="{!!$dispositionPlan[0]->dispositionPlanId!!}" />
<fieldset>
<div class="control-group">
<label class="col-md-4 control-label" for="plan">Disposition Plan Name</label>
<div class="col-md-8 controls tmar">
<input class="form-control" id="plan" name="plan" type="text" value="{!!$dispositionPlan[0]->name!!}" required />
</div>
</div>
<div class="control-group">
<label class="col-md-4 control-label" for="status">Status</label>
<div class="col-md-8 controls tmar">
<select class="form-control" id="" name="status" required>
<option value="{!!$dispositionPlan[0]->status!!}">{!!$dispositionPlan[0]->status!!}</option>
<option value="active">Active</option>
<option value="inactive">Inactive</option>
</select>
</div>
</div>
<div class="control-group">
<label class="col-md-12 control-label tmar" for="status">Disposition</label>
</div>
<div class="control-group field_wrapper">
<?php foreach ($dispositionPlan as $key => $dispoList) { ?>
<?php //$dispositions = explode(",", $dispositionPlan[0]->dispositions); ?>
<?php //for ($i=0; $i < count($dispositions); $i++) {
if($key == 0){ ?>
<div class="row">
<div class="col-md-11">
<div class="panel panel-info">
<div class="panel-body">
<div class="row" style="margin: 5px">
<div class="col-md-4">
<label>Select Disposition:</label>
</div>
<?php $newFieldOption = ''; $data = ''; $subDispoList = '';
if(isset($dispositionEntities))
foreach($dispositionEntities as $dispositionEntity)
{
$s='';
if($dispoList->disposition == $dispositionEntity->disposition){
$s='selected';
$subDispoList = $dispositionEntity->sunDispoName;
}
$data .= "<option data-id='$dispositionEntity->code' data-text='$dispositionEntity->sunDispoName' value='$dispositionEntity->disposition' $s>$dispositionEntity->disposition</option>";
$newFieldOption .= "<option data-id='$dispositionEntity->code' data-text='$dispositionEntity->sunDispoName' value='$dispositionEntity->disposition'>$dispositionEntity->disposition</option>";
}
?>
<div class="col-md-8 controls tmar">
<select class="form-control disposition" name="disposition[]" data-subDospoId="subDisposition1" required>
<option value></option>
<?php echo $data; ?>
</select>
</div>
</div>
<div class="row" style="margin: 5px">
<div class="col-md-4">
<label>Select Sub Disposition:</label>
</div>
<div class="col-md-8 controls tmar">
<select name="subDisposition[0][]" id="subDisposition1" class="select2multi" style='width:100%' multiple="" required>
<?php
$selectedSubDisposition = explode(",", $dispoList->sub_disposition);
$subDisposition = explode(",", $subDispoList);
foreach ($subDisposition as $key => $subDispo) {
$seltext = '';
foreach ($selectedSubDisposition as $key => $selSubDispo) {
if($selSubDispo == $subDispo){
$seltext = 'selected';
}
}
echo "<option value='$subDispo' $seltext>$subDispo</option>";
}
?>
</select>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-1">
<a href="javascript:void(0);" class="add_button" title="Add field"><i class="fa fa-plus fa-3 iconsize" aria-hidden="true"></i></a>
</div>
</div>
<?php }else{ ?>
<div class="row">
<div class="col-md-11">
<div class="panel panel-info">
<div class="panel-body">
<div class="row" style="margin: 5px">
<div class="col-md-4">
<label>Select Disposition:</label>
</div>
<?php $data = ''; $subDispoList = '';
if(isset($dispositionEntities))
foreach($dispositionEntities as $dispositionEntity)
{
$s='';
if($dispoList->disposition == $dispositionEntity->disposition){
$s='selected';
$subDispoList = $dispositionEntity->sunDispoName;
}
$data .= "<option data-id='$dispositionEntity->code' data-text='$dispositionEntity->sunDispoName' value='$dispositionEntity->disposition' $s>$dispositionEntity->disposition</option>";
}
?>
<div class="col-md-8 controls tmar">
<select class="form-control disposition" name="disposition[$key]" data-subDospoId="subDisposition<?php echo $key; ?>" required>
<option value></option>
<?php echo $data; ?>
</select>
</div>
</div>
<div class="row" style="margin: 5px">
<div class="col-md-4">
<label>Select Sub Disposition:</label>
</div>
<div class="col-md-8 controls tmar">
<select name="subDisposition[$key][]" id="subDisposition<?php echo $key; ?>" class="select2multi" style='width:100%' multiple="" required>
<?php
$selectedSubDisposition = explode(",", $dispoList->sub_disposition);
$subDisposition = explode(",", $subDispoList);
foreach ($subDisposition as $key => $subDispo) {
$seltext = '';
foreach ($selectedSubDisposition as $key => $selSubDispo) {
if($selSubDispo == $subDispo){
$seltext = 'selected';
}
}
echo "<option value='$subDispo' $seltext>$subDispo</option>";
}
?>
</select>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-1">
<a href="javascript:void(0);" class="remove_button"><i class="fa fa-minus fa-3 iconsize" aria-hidden="true"></i></a>
</div>
</div>
<?php }
//}
} ?>
</div>
<div class="form-actions">
<!-- <button type="submit" class="btn btn-primary" onclick='createDisposition();return false;'>Save changes</button> -->
<input type="submit" name="save" id="save" class="btn btn-primary" value="Save changes">
</div>
</fieldset>
</form>
<script>
$(document).ready(function(){
var i = 1;
var wrapper = $('.field_wrapper'); //Input field wrapper
$('.add_button').click(function(){
i++;
var dispoOption = "<?php echo $newFieldOption; ?>";
var fieldHTML = '<div class="row"><div class="col-md-11"><div class="panel panel-info"><div class="panel-body"><div class="row" style="margin: 5px"><div class="col-md-4"><label>Select Disposition:</label></div><div class="col-md-8 controls tmar"><select name="disposition[]" class="form-control disposition" data-subDospoId="subDisposition'+i+'" required><option value></option>';
fieldHTML = fieldHTML + dispoOption;
fieldHTML = fieldHTML +'</select></div></div><div class="row" style="margin: 5px"><div class="col-md-4"> <label>Select Sub Disposition:</label></div><div class="col-md-8 controls tmar"><select name="subDisposition['+(i-1)+'][]" id="subDisposition'+i+'" class="select2multi" style="width:100%"" multiple="" required></select></div></div></div></div></div><div class="col-md-1"><a href="javascript:void(0);" class="remove_button"><i class="fa fa-minus fa-3 iconsize" aria-hidden="true"></i></a></div></div>'; //New input field html
$(wrapper).append(fieldHTML);
$(".select2multi").not('.kstych_init').addClass('kstych_init').select2({placeholder: "Select...",allowClear: true });
});
$(wrapper).on('click', '.remove_button', function(e){
e.preventDefault();
$(this).parent('div').parent('div').remove();
});
//$(".disposition").change(function(){
$('body').on('click', '.disposition', function() {
var subDispositionId = $(this).attr('data-subDospoId');
var subDispo = $(this).find(':selected').attr('data-text') //this.find(':selected').attr('data-text');
var subdispolist = subDispo.split(',');
$("#"+subDispositionId).select2("val", "Select");
updateJSSelect(subDispositionId,subdispolist);
});
$('#dispositionForm').on('submit', function(event){
event.preventDefault();
var putdata = $('#dispositionForm').serialize();
doAjax('dispositionPlan?action=isExists',putdata,'','','','POST',function(retrstr){
if(retrstr.responseText == "true"){
simpleNotification('Error','topRight',"Disposition plan Already Exists!");
return false;
}else{
doAjax('dispositionPlan?action=updateDispositionPlan',putdata,'dispositionPlanFormDiv','ajax_group_create','singlethis','POST',function(retrstr){
doAjax('dispositionPlan','','content','ajax_dispositionPlan','singlethis','GET',function(retrstr){
simpleNotification('Success','topRight',"Disposition plan updated suceesfully!");
});
});
}
});
});
});
</script>
<!-- Heading -->
<h5 class="innerAll margin-none bg-primary">
<i class="fa fa-fw fa-pencil"></i>Add Disposition Plan
<a href="#" class="btn btn-sm btn-inverse pull-right btn-xs" style="margin-top: -5px;" onclick="return false">
<i class="fa fa-user fa-fw"></i>
</a>
</h5>
<form method="post" id="dispositionPlanForm" class="innerAll">
<fieldset>
<div class="control-group">
<label class="col-md-4 control-label" for="plan">Disposition Plan Name</label>
<div class="col-md-8 controls tmar">
<input class="form-control" id="plan" name="plan" type="text" value="" required />
</div>
</div>
<div class="control-group">
<label class="col-md-4 control-label" for="status">Status</label>
<div class="col-md-8 controls tmar">
<select class="form-control" id="" name="status" required>
<option value="active">Active</option>
<option value="inactive">Inactive</option>
</select>
</div>
</div>
<div class="control-group">
<label class="col-md-12 control-label tmar" for="status">Disposition</label>
</div>
<div class="control-group field_wrapper">
<div class="row">
<div class="col-md-11">
<div class="panel panel-info">
<div class="panel-body">
<div class="row" style="margin: 5px">
<div class="col-md-4">
<label>Select Disposition:</label>
</div>
<?php $data = '';
if(isset($dispositionEntities))
foreach($dispositionEntities as $dispositionEntity)
{
$data .= "<option data-id='$dispositionEntity->code' data-text='$dispositionEntity->sunDispoName' value='$dispositionEntity->disposition'>$dispositionEntity->disposition</option>";
}
?>
<div class="col-md-8 controls tmar">
<select class="form-control disposition" name="disposition[]" data-subDospoId="subDisposition1" required>
<option value>Select ..</option>
<?php echo $data; ?>
</select>
</div>
</div>
<div class="row" style="margin: 5px">
<div class="col-md-4">
<label>Select Sub Disposition:</label>
</div>
<div class="col-md-8 controls tmar">
<select name="subDisposition[0][]" id="subDisposition1" class="select2multi" style='width:100%' multiple="">
</select>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-1">
<a href="javascript:void(0);" class="add_button" title="Add field"><i class="fa fa-plus fa-3 iconsize" aria-hidden="true"></i></a>
</div>
</div>
</div>
<div class="form-actions">
<input type="submit" name="save" id="save" class="btn btn-primary" value="Save changes">
</div>
</fieldset>
</form>
<script>
$(document).ready(function(){
var i = 1;
var wrapper = $('.field_wrapper'); //Input field wrapper
$('body').on('click', '.add_button', function() {
i++;
var dispoOption = "<?php echo $data; ?>";
var fieldHTML = '<div class="row"><div class="col-md-11"><div class="panel panel-info"><div class="panel-body"><div class="row" style="margin: 5px"><div class="col-md-4"><label>Select Disposition:</label></div><div class="col-md-8 controls tmar"><select name="disposition[]" class="form-control disposition" data-subDospoId="subDisposition'+i+'" required><option value>Select...</option>';
fieldHTML = fieldHTML + dispoOption;
fieldHTML = fieldHTML +'</select></div></div><div class="row" style="margin: 5px"><div class="col-md-4"> <label>Select Sub Disposition:</label></div><div class="col-md-8 controls tmar"><select name="subDisposition['+(i-1)+'][]" id="subDisposition'+i+'" class="select2multi" style="width:100%"" multiple=""></select></div></div></div></div></div><div class="col-md-1"><a href="javascript:void(0);" class="remove_button"><i class="fa fa-minus fa-3 iconsize" aria-hidden="true"></i></a></div></div>'; //New input field html
$(wrapper).append(fieldHTML);
$(".select2multi").not('.kstych_init').addClass('kstych_init').select2({placeholder: "Select...",allowClear: true });
});
$(wrapper).on('click', '.remove_button', function(e){
e.preventDefault();
$(this).parent('div').parent('div').remove();
});
//$(".disposition").change(function(){
$('body').on('click', '.disposition', function() {
var subDispositionId = $(this).attr('data-subDospoId');
var subDispo = $(this).find(':selected').attr('data-text') //this.find(':selected').attr('data-text');
var subdispolist = subDispo.split(',');
$("#"+subDispositionId).select2("val", "Select");
updateJSSelect(subDispositionId,subdispolist);
});
$('#dispositionPlanForm').on('submit', function(event){
event.preventDefault();
var putdata = $('#dispositionPlanForm').serialize();
doAjax('dispositionPlan?action=isExists',putdata,'','','','POST',function(retrstr){
if(retrstr.responseText == "true"){
simpleNotification('Error','topRight',"Disposition plan Already Exists!");
return false;
}else{
doAjax('dispositionPlan?action=createDispositionPlan',putdata,'dispositionPlanFormDiv','ajax_group_create','singlethis','POST',function(retrstr){
doAjax('dispositionPlan','','content','ajax_dispositionPlan','singlethis','GET',function(retrstr){
simpleNotification('Success','topRight',"Disposition plan created suceesfully!");
});
});
}
});
});
});
</script>
\ No newline at end of file
<!-- Heading -->
<h5 class="innerAll margin-none bg-primary">
<i class="fa fa-fw fa-pencil"></i> Edit Disposition Plan
<a href="#" class="btn btn-sm btn-inverse pull-right btn-xs" style="margin-top: -5px;" onclick="return false">
<i class="fa fa-user fa-fw"></i>
</a>
</h5>
<?php //echo "<prE>";print_r($dispositionPlan[0]->dispositionPlanId);exit(); ?>
<form method="post" id="dispositionForm" class="innerAll">
<input class="form-control" name="dispositionPlanId" type="hidden" value="{!!$dispositionPlan[0]->dispositionPlanId!!}" />
<fieldset>
<div class="control-group">
<label class="col-md-4 control-label" for="plan">Disposition Plan Name</label>
<div class="col-md-8 controls tmar">
<input class="form-control" id="plan" name="plan" type="text" value="{!!$dispositionPlan[0]->name!!}" required />
</div>
</div>
<div class="control-group">
<label class="col-md-4 control-label" for="status">Status</label>
<div class="col-md-8 controls tmar">
<select class="form-control" id="" name="status" required>
<option value="{!!$dispositionPlan[0]->status!!}">{!!$dispositionPlan[0]->status!!}</option>
<option value="active">Active</option>
<option value="inactive">Inactive</option>
</select>
</div>
</div>
<div class="control-group">
<label class="col-md-12 control-label tmar" for="status">Disposition</label>
</div>
<div class="control-group field_wrapper">
<?php foreach ($dispositionPlan as $key => $dispoList) { ?>
<?php
if($key == 0){ ?>
<div class="row">
<div class="col-md-11">
<div class="panel panel-info">
<div class="panel-body">
<div class="row" style="margin: 5px">
<div class="col-md-4">
<label>Select Disposition:</label>
</div>
<?php $newFieldOption = ''; $data = ''; $subDispoList = '';
if(isset($dispositionEntities))
foreach($dispositionEntities as $dispositionEntity)
{
$s='';
if($dispoList->disposition == $dispositionEntity->disposition){
$s='selected';
$subDispoList = $dispositionEntity->sunDispoName;
}
$data .= "<option data-id='$dispositionEntity->code' data-text='$dispositionEntity->sunDispoName' value='$dispositionEntity->disposition' $s>$dispositionEntity->disposition</option>";
$newFieldOption .= "<option data-id='$dispositionEntity->code' data-text='$dispositionEntity->sunDispoName' value='$dispositionEntity->disposition'>$dispositionEntity->disposition</option>";
}
?>
<div class="col-md-8 controls tmar">
<select class="form-control disposition" name="disposition[]" data-subDospoId="subDisposition0" required>
<option value></option>
<?php echo $data; ?>
</select>
</div>
</div>
<div class="row" style="margin: 5px">
<div class="col-md-4">
<label>Select Sub Disposition:</label>
</div>
<div class="col-md-8 controls tmar">
<select name="subDisposition[0][]" id="subDisposition0" class="select2multi" style='width:100%' multiple="" required>
<?php
$selectedSubDisposition = explode(",", $dispoList->sub_disposition);
$subDisposition = explode(",", $subDispoList);
foreach ($subDisposition as $key => $subDispo) {
$seltext = '';
foreach ($selectedSubDisposition as $key => $selSubDispo) {
if($selSubDispo == $subDispo){
$seltext = 'selected';
}
}
echo "<option value='$subDispo' $seltext>$subDispo</option>";
}
?>
</select>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-1">
<a href="javascript:void(0);" class="add_button" title="Add field"><i class="fa fa-plus fa-3 iconsize" aria-hidden="true"></i></a>
</div>
</div>
<?php }else{ ?>
<div class="row">
<div class="col-md-11">
<div class="panel panel-info">
<div class="panel-body">
<div class="row" style="margin: 5px">
<div class="col-md-4">
<label>Select Disposition:</label>
</div>
<?php $data = ''; $subDispoList = '';
if(isset($dispositionEntities))
foreach($dispositionEntities as $dispositionEntity)
{
$s='';
if($dispoList->disposition == $dispositionEntity->disposition){
$s='selected';
$subDispoList = $dispositionEntity->sunDispoName;
}
$data .= "<option data-id='$dispositionEntity->code' data-text='$dispositionEntity->sunDispoName' value='$dispositionEntity->disposition' $s>$dispositionEntity->disposition</option>";
}
?>
<div class="col-md-8 controls tmar">
<select class="form-control disposition" name="disposition[<?php echo $key; ?>]" data-subDospoId="subDisposition<?php echo $key; ?>" required>
<option value></option>
<?php echo $data; ?>
</select>
</div>
</div>
<div class="row" style="margin: 5px">
<div class="col-md-4">
<label>Select Sub Disposition:</label>
</div>
<div class="col-md-8 controls tmar">
<select name="subDisposition[<?php echo $key; ?>][]" id="subDisposition<?php echo $key; ?>" class="select2multi" style='width:100%' multiple="" required>
<?php
$selectedSubDisposition = explode(",", $dispoList->sub_disposition);
$subDisposition = explode(",", $subDispoList);
foreach ($subDisposition as $key => $subDispo) {
$seltext = '';
foreach ($selectedSubDisposition as $key => $selSubDispo) {
if($selSubDispo == $subDispo){
$seltext = 'selected';
}
}
echo "<option value='$subDispo' $seltext>$subDispo</option>";
}
?>
</select>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-1">
<a href="javascript:void(0);" class="remove_button"><i class="fa fa-minus fa-3 iconsize" aria-hidden="true"></i></a>
</div>
</div>
<?php }
//}
} ?>
</div>
<div class="form-actions">
<!-- <button type="submit" class="btn btn-primary" onclick='createDisposition();return false;'>Save changes</button> -->
<input type="submit" name="save" id="save" class="btn btn-primary" value="Save changes">
</div>
</fieldset>
</form>
<script>
$(document).ready(function(){
var i = $('.disposition').length;
var wrapper = $('.field_wrapper'); //Input field wrapper
$('.add_button').click(function(){
i++;
var dispoOption = "<?php echo $newFieldOption; ?>";
var fieldHTML = '<div class="row"><div class="col-md-11"><div class="panel panel-info"><div class="panel-body"><div class="row" style="margin: 5px"><div class="col-md-4"><label>Select Disposition:</label></div><div class="col-md-8 controls tmar"><select name="disposition[]" class="form-control disposition" data-subDospoId="subDisposition'+i+'" required><option value></option>';
fieldHTML = fieldHTML + dispoOption;
fieldHTML = fieldHTML +'</select></div></div><div class="row" style="margin: 5px"><div class="col-md-4"> <label>Select Sub Disposition:</label></div><div class="col-md-8 controls tmar"><select name="subDisposition['+(i-1)+'][]" id="subDisposition'+i+'" class="select2multi" style="width:100%"" multiple="" required></select></div></div></div></div></div><div class="col-md-1"><a href="javascript:void(0);" class="remove_button"><i class="fa fa-minus fa-3 iconsize" aria-hidden="true"></i></a></div></div>'; //New input field html
$(wrapper).append(fieldHTML);
$(".select2multi").not('.kstych_init').addClass('kstych_init').select2({placeholder: "Select...",allowClear: true });
});
$(wrapper).on('click', '.remove_button', function(e){
e.preventDefault();
$(this).parent('div').parent('div').remove();
});
//$(".disposition").change(function(){
$('body').on('change', '.disposition', function() {
var subDispositionId = $(this).attr('data-subDospoId');
var subDispo = $(this).find(':selected').attr('data-text') //this.find(':selected').attr('data-text');
var subdispolist = subDispo.split(',');
$("#"+subDispositionId).select2("val", "Select");
updateJSSelect(subDispositionId,subdispolist);
});
$('#dispositionForm').on('submit', function(event){
event.preventDefault();
var putdata = $('#dispositionForm').serialize();
doAjax('dispositionPlan?action=isExists',putdata,'','','','POST',function(retrstr){
if(retrstr.responseText == "true"){
simpleNotification('Error','topRight',"Disposition plan Already Exists!");
return false;
}else{
doAjax('dispositionPlan?action=updateDispositionPlan',putdata,'dispositionPlanFormDiv','ajax_group_create','singlethis','POST',function(retrstr){
doAjax('dispositionPlan','','content','ajax_dispositionPlan','singlethis','GET',function(retrstr){
simpleNotification('Success','topRight',"Disposition plan updated suceesfully!");
});
});
}
});
});
});
</script>
\ No newline at end of file
<style>
.heading-buttons h4{
line-height:20px;
}
</style>
<div class="layout-app"><!-- row-app -->
<div class="row row-app">
<!-- col -->
<div class="col-md-12">
<!-- col-separator.box -->
<div class="col-separator col-separator-first col-unscrollable box">
<!-- col-table -->
<div class="col-table" id=authorworkspacediv>
<!-- Search Bar -->
<div class="input-group">
<input type="text" class="form-control" placeholder="Search for Disposition...">
<span class="input-group-btn">
<button class="btn btn-primary rounded-none" type="button"><i class="fa fa-search"></i></button>
</span>
</div>
<div class="col-separator-h"></div>
<!-- End Search Bar -->
<div class="col-table-row">
<div class="col-app col-unscrollable">
<div class="col-app">
<div class="row-app">
<div class="col-md-6">
<div class="col-separator">
<!-- Category Heading -->
<div class="heading-buttons bg-gray border-bottom innerR half">
<a href="#" class="btn btn-sm btn-inverse pull-right" onclick="doAjax('dispositionPlan/create','','dispositionPlanFormDiv','ajax_group_create','singlethis','GET');return false"><i class="fa fa-plus fa-fw"></i>New Disposition Plan</a>
<h4 class="innerTB margin-bottom-none">Disposition Plan</h4>
<div class="clearfix"></div>
</div>
<!-- End Category Heading -->
<?php //echo $grouplist->render(); ?>
<?php if(count($dispositionPlan) > 0){
foreach ($dispositionPlan as $dispo){ //echo "<pre>";print_r($dispo);exit();
$tphoto="assets/images/people/avatar.jpg";
?>
<!-- dispolist Listing -->
<div class="row innerAll half border-bottom bg-gray-hover">
<div class="col-sm-6 col-xs-8">
<ul class="media-list margin-none">
<li class="media">
<a class="pull-left innerAll" href="#" onclick="doAjax('dispositionPlan/{!!$dispo->dispositionPlanId!!}/edit','','dispositionPlanFormDiv','ajax_group_create','singlethis','GET');return false;">
<span class="btn btn-primary btn-xs"><i class="fa fa-pencil"></i></span>
</a>
<!-- <a class="pull-left innerAll" href="#" onclick="doAjax('campaign/{!!$dispo->id!!}','','groupformdiv','ajax_group_delete','singlethis','DELETE');return false;">
<span class="btn btn-primary btn-xs"><i class="fa fa-trash-o"></i></span>
</a> -->
<div class="media-body">
<div class="innerAll">
<h5 class=""><a href="#" class="media-heading text-primary" onclick="doAjax('dispositionPlan/{!!$dispo->dispositionPlanId!!}/edit','','dispositionPlanFormDiv','ajax_group_create','singlethis','GET');return false;"> {!!$dispo->name!!}</a></h5>
<div class="clearfix"></div>
<small>
@if($dispo->status=="active")
<span class="label label-success">{!!$dispo->status!!}</span>
@elseif($dispo->status=="inactive")
<span class="label label-warning">{!!$dispo->status!!}</span>
@endif
</small>
<!-- <small class="margin-none label label-inverse">Social</small>
<small class="margin-none label label-inverse">Learn</small>
<small class="margin-none label label-inverse">Author</small>
<small class="margin-none label label-inverse">Library</small> -->
</div>
</div>
</li>
</ul>
</div>
<!-- <div class="col-sm-3 col-xs-hidden">
<div class="innerAll">
<div class="media">
<div class="media-body">
<a href="#" class="text-small" title='{!!$dispo->created_at!!}' onclick="doAjax('dispositionPlan/{!!$dispo->dispoId!!}/edit','','dispositionPlanFormDiv','ajax_group_create','singlethis','GET');return false;">{!!$dispo->disposition!!}</a>
<div class="clearfix"></div>
<small>
@if($dispo->status=="active")
<span class="label label-success">{!!$dispo->status!!}</span>
@elseif($dispo->status=="inactive")
<span class="label label-warning">{!!$dispo->status!!}</span>
@endif
</small>
</div>
</div>
</div>
</div> -->
<div class="col-sm-3 col-xs-4">
<div class="text-center">
<p class="strong">Disposition</p>
<!-- <span class="badge badge-primary" data-toggle="tooltip" data-title="Published" data-placement="left" data-container="body">0</span> -->
<span class="badge badge-primary badge-stroke" data-toggle="tooltip" data-title="Subscribed" data-placement="right" data-container="body">{!!$dispo->totalDisposition!!}</span>
</div>
</div>
</div>
<!-- // END Dispolist Listing -->
<?php } }else{?>
<div class="row innerAll half border-bottom bg-gray-hover">
<div class="col-sm-6 col-xs-8" style="text-align: center;">
<b>No data available</b>
</div>
</div>
<?php } ?>
<?php //echo $grouplist->render(); ?>
</div>
<!-- // END col-separator -->
</div>
<!-- // END col -->
<!-- col -->
<div class="col-md-6">
<!-- col-separator -->
<div class="col-separator col-separator-last" id=dispositionPlanFormDiv>
</div>
<!-- // END col-separator -->
</div>
<!-- // END col-table -->
</div>
<!-- // END col-separator.box -->
</div>
<!-- // END col -->
</div>
<!-- // END row-app -->
</div>
<script>
$(".pagination a").click(function(e){
e.preventDefault();
var url=$(this).attr("href");
var res = url.split("page=");
menuAction("group?page="+res[1]);
return false;
});
$(document).ready(function(){
});
</script>
<style type="text/css">
.tmar {
margin-top : 10px;
}
.iconsize {
font-size: 2em;
margin-top: 5px;
}
</style>
\ No newline at end of file
<?php
$kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
//error_reporting(E_ALL);
ini_set("memory_limit", -1);
include_once(app_path().'/lib/phpexcel/PHPExcel.php');
$wakka->setUserTimezone();
$themehome=$wakka->GetThemePath('/');
$sindex[0]='salbasic';
$sindex[1]='salhouserent';
$sindex[2]='saltransport';
$sindex[3]='salfood';
$sindex[4]='saltelephone';
$sindex[5]='salmedical';
$sindex[6]='salelectricity';
$sindex[7]='salother';
$sindex[8]='saltotal';
$sindex[9]='nettotal';$kformlib->HRFieldNames['nettotal']="Net Salary";
if(Input::has("reportsubmit"))
{
if(Input::has("savedreportget"))
{
$filterstr="";$fieldsarr="";
$rpt=Input::get("savedreportget");
$userreports=$wakka->GetBBBUserData("UserSavedReports");
if(isset($userreports[$rpt]))
{
$tarr=json_decode(base64_decode($userreports[$rpt]),true);
unset($tarr["_token"]);
Input::merge($tarr);
}
}
$empid=Input::get("empid");
$client=Input::get("client");
$currentstatus=Input::get("currentstatus");
$modfrom=explode(".",Input::get("modfrom"));
$modto=explode(".",Input::get("modto"));
$crefrom=explode(".",Input::get("crefrom"));
$creto=explode(".",Input::get("creto"));
$reporttmpl=Input::get("reporttmpl");
$visacompany=Input::get("visacompany");
$asalmonth=Input::get("asalmonth");
$asalyear=Input::get("asalyear");
$frcrefrom=explode(".",Input::get("frcrefrom"));
$frcreto=explode(".",Input::get("frcreto"));
$fieldbyrange=trim(Input::get("fieldbyrange"));
$filterbyfielddates=0;
if($fieldbyrange!=""&&sizeof($frcrefrom)==3&&sizeof($frcreto)==3)
{
$filterbyfielddates=1;
$frcrefrom=mktime(0, 0, 0, $frcrefrom[1], $frcrefrom[0], $frcrefrom[2]);
$frcreto=mktime(23, 59, 59, $frcreto[1], $frcreto[0], $frcreto[2]);
}
$ddprts=array();
$datesdiffstr=Input::get("datesdiffstr");
if(!empty($datesdiffstr))
{
$ddprts=explode(",",$datesdiffstr);//datesdiffstr=servicestoppeddate,joiningdate,LT,180 ==> if(servicestopdate-joiningdate < 180) then ok,else not ok
}
//$finputarr=Input::get("fieldsarr");
$finputarr=$_REQUEST['fieldsarr'];
if(is_array($finputarr))foreach($finputarr as $eachfield)$fieldsarr[]=$eachfield;
else {echo "Please Select List of fields In report.";return;}
$reporttype=Input::get("reporttype");
$outputtype=Input::get("outputtype","XLS");
if(sizeof($fieldsarr)==0){echo "Please Select List of fields In report.";return;}
if($reporttype==""){echo "Please Select a Report Type.";return;}
if($client==""&&$currentstatus==""&&$visacompany==''&&$modfrom[0]==''&&$crefrom[0]==''&&$empid==''&&$fieldbyrange==''){echo $client."Please Select atleast one of Client or Status or ModifyFrom or CreatedFrom.";return;}
if($reporttype=='Binary')$reporttype='|b';
if($reporttype=='History')$reporttype='|h';
if($reporttype=='Values')$reporttype='';
$filterstr=array();
if($empid!="")
{
$idarr=explode(',',$empid);
foreach($idarr as $tid)if(trim($tid)!='')$tarr[]="'$tid'";
$empid=implode(",",$tarr);
$filterstr[]=" id in ($empid) ";
}
else
{
if($client!=""){$filterstr[]=getQueryFromList('client',$client);}
if($currentstatus!=""){$filterstr[]=getQueryFromList('currentstatus',$currentstatus);}
// if($visacompany!=""){$filterstr[]=getQueryFromList('visacompany',$visacompany);}
if($modfrom[0]!="")$filterstr[]=" modified>='$modfrom[2]-$modfrom[1]-$modfrom[0] 00:00:00' ";
if($modto[0]!="") $filterstr[]=" modified<='$modto[2]-$modto[1]-$modto[0] 23:59:59' ";
if($crefrom[0]!="")$filterstr[]=" created>='$crefrom[2]-$crefrom[1]-$crefrom[0] 00:00:00' ";
if($creto[0]!="") $filterstr[]=" created<='$creto[2]-$creto[1]-$creto[0] 23:59:59' ";
if($filterbyfielddates==1)
{
$filterstr[]=" modified>='".date('Y-m-d 00:00:00',$frcrefrom)."' ";
}
}
$type = PHPExcel_Cell_DataType::TYPE_STRING;
if(!empty($filterstr))$filterstr=implode(" and ",$filterstr);else $filterstr="";
if($filterstr=="")$filterstr="1";
$savereportname=Input::get("savereportname");
if($savereportname!="")
{
$userreports=$wakka->GetBBBUserData("UserSavedReports");
$userreports[$savereportname]=base64_encode(json_encode(Input::all()));
$wakka->SetBBBUserData("UserSavedReports",$userreports);
}
$usersarr=$wakka->getPersons($filterstr);
$inputFileType = "Excel5";
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load("$themehome/uploads/sreports/blank.xls");
$baseRow = 3;
$highestColumn = sizeof($fieldsarr);
$baserowArr=$fieldsarr;
$objPHPExcel->getActiveSheet()->setCellValue("A1", "id");
for ($head = 0; $head < $highestColumn; $head++){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head+1);
$objPHPExcel->getActiveSheet()->setCellValue($colstr."1", $baserowArr[$head]);
}
$objPHPExcel->getActiveSheet()->setCellValue("A2", "EMPID");
for ($head = 0; $head < $highestColumn; $head++){
$colstr=PHPExcel_Cell::stringFromColumnIndex($head+1);
$objPHPExcel->getActiveSheet()->setCellValue($colstr."2", $kformlib->HRFieldNames[$baserowArr[$head]]);
}
$skippedrows=0;
foreach($usersarr as $r => $userdata)
{
$ppldata=unserialize($userdata['peopledata']);
$logarr=unserialize($userdata['modifylog']);
$hrexclusiveflag=0;if(empty($ppldata['client']))$ppldata['client']='__';
if(strstr($wakka->HRCoreVars['HRExclusiveClients'],$ppldata['client']))
{
if(!$wakka->IsAdmin())
{
if(!strstr($wakka->getManagerUsers($wakka->getUserListforClient($ppldata['client'])),$wakka->GetUserName()))
{
if(!strstr($wakka->GetBBBUserData("clientsownerlist"),$ppldata['client']))$hrexclusiveflag=1;
}
}
}
if(($wakka->GetBBBUserData("readotherdata")=="No"&&!$wakka->recordReadAccess($ppldata))||$hrexclusiveflag==1)$pass=0;
else
{
if($filterbyfielddates==1)
{
if(!isset($ppldata[$fieldbyrange])||trim($ppldata[$fieldbyrange])==""){$skippedrows++;continue;}
else
{
//$fieldbyrange $frcrefrom $frcreto
$tdt=explode(".",$ppldata[$fieldbyrange]);
if(sizeof($tdt)==3)
{
$tdt=mktime(0, 0, 0, intval($tdt[1]), intval($tdt[0]), intval($tdt[2]));
if(!($tdt>=$frcrefrom&&$tdt<=$frcreto)){$skippedrows++;continue;}
}
else {$skippedrows++;continue;}
}
}
if(sizeof($ddprts)>3)
{
$dddt1=explode(".",$ppldata[$ddprts[0]]);
$dddt2=explode(".",$ppldata[$ddprts[1]]);
$dddt1=mktime(0, 0, 0, intval($dddt1[1]), intval($dddt1[0]), intval($dddt1[2]));
$dddt2=mktime(0, 0, 0, intval($dddt2[1]), intval($dddt2[0]), intval($dddt2[2]));
if($ddprts[2]=="LT")
{
if($dddt1-$dddt2 < $ddprts[3]);else {$skippedrows++;continue;}
}
if($ddprts[2]=="GT")
{
if($dddt1-$dddt2 > $ddprts[3]);else {$skippedrows++;continue;}
}
}
$row = $baseRow + $r - $skippedrows;$rkey=0;
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow(0,$row)->setValueExplicit($userdata['id'], $type);
foreach($baserowArr as $key => $val)
{
$cellval=$wakka->getXlsVal($baserowArr[$key].$reporttype,$ppldata,$logarr);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($key+1,$row)->setValueExplicit($cellval, $type);
$rkey=$key+1;
}
//month data in report
if($asalyear>2000&&$asalmonth>0)
{
$saldata=$ppldata["salaryentries"][$asalyear][$asalmonth];
$leavedata=$ppldata["leavesentries"][$asalyear][1][$asalmonth];
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow(++$rkey,$row)->setValueExplicit($leavedata[0][2], $type);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($rkey,1)->setValueExplicit("Annual Leaves", $type);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow(++$rkey,$row)->setValueExplicit($leavedata[1][2], $type);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($rkey,1)->setValueExplicit("Sick Leaves", $type);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow(++$rkey,$row)->setValueExplicit($leavedata[2][2], $type);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($rkey,1)->setValueExplicit("Meternity Leaves", $type);
for($i=0;$i<=9;$i++)
{
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($rkey+1,"1")->setValueExplicit($kformlib->HRFieldNames[$sindex[$i]], $type);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($rkey+1,$row)->setValueExplicit($saldata[1][$i][1], $type);
$rkey=$rkey+1;
}
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow(++$rkey,$row)->setValueExplicit($wakka->getLOPAmt($ppldata,$asalyear,$asalmonth), $type);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($rkey,1)->setValueExplicit("LOP Amount", $type);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow(++$rkey,$row)->setValueExplicit($wakka->getNWDAmt($ppldata,$asalyear,$asalmonth), $type);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($rkey,1)->setValueExplicit("NWD Amount", $type);
foreach($saldata[0] as $tadded)
{
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($rkey+1,1)->setValueExplicit("Add/Ded Type", $type);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($rkey+2,1)->setValueExplicit("Value", $type);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($rkey+3,1)->setValueExplicit("Remarks", $type);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($rkey+1,$row)->setValueExplicit($tadded[0], $type);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($rkey+2,$row)->setValueExplicit($tadded[1], $type);
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($rkey+3,$row)->setValueExplicit($tadded[2], $type);
$rkey+=3;
}
}
}
}
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="MainReport.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType);
$objWriter->save('php://output');
return;
}
function getQueryFromList($key,$list)
{
$rstatusstr=array();$rstatuses=explode(",",$list);
foreach($rstatuses as $rstatus)
{
if($rstatus!='')$rstatusstr[]="'$rstatus'";
}
return " ($key in (".implode(",",$rstatusstr).")) ";
}
?>
<style>
.tab_bar_purple{
border: 1px solid #EFEFEF;
height: 39px;
margin: 0 0 10px;
overflow: hidden;
position: relative;
}
.tab_bar_purple ul{
list-style: none outside none;
margin: 0;
padding: 0;
background: none repeat scroll 0 0 #ac92ed;
}
.tab_bar_purple ul li{
border: medium none;
height: 39px;
padding: 0;
display: block;
float: left;
}
.tab_bar_purple ul li a{
background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
height: 39px;
line-height: 39px;
display: block;
padding: 0 15px;
text-decoration: none;
color:#fff;
}
.tab_bar_purple .tabsbar-2{
/*height: 39px;*/
}
.tab_bar_purple ul li.active{
background: none repeat scroll 0 0 #fff;
}
.tab_bar_purple ul li.active a{
color:#967bdc;
}
.form_new{
margin:0px;
}
.table_hrm_heading_purple{
padding: 7px 9px;
text-align: center;
background-color: #D5C5FF;
border: 5px solid #fff;
font-weight: 600;
}
.table_hrm_heading_purple:first-child{
border-left: 0px;
}
.table_hrm_cells{
padding: 5px 7px;
color:#434a54;
}
.table_hrm_cells a{
color:#434a54;
}
.table_hrm_celltext{
border: 1px solid #ccd0d9;
border-color: #ccd0d9 !important;
border-radius: 3px !important;
padding: 3px 7px;
text-align: center;
}
.hasDatepicker{
border: 1px solid #e2e2e4;
border-radius: 3px !important;
padding: 3px 10px;
margin: 0 10px;
width: 10%;
margin-left: 0px;
}
#saved_reprts{
margin-right: 3px;
border: 1px solid #ccd0d9;
padding: 1% 0 1% 3%;
margin-bottom: 30px;
border-radius: 10px;
}
#saved_reprts legend{
width:10%
}
.new-recruit_legend{
font-size: 14px;
height: auto;
margin: 0 0 1%;
padding: 10px;
line-height: 25px;
}
</style>
<div class="layout-app"><!-- row-app -->
<div class="row row-app">
<div class="col-md-12">
<div class="col-separator col-separator-first col-unscrollable box" style='overflow:hidden'>
<div class=innerAll>
<div class="relativeWrap" >
<div class="tab_generic">
<!-- Tabs Heading -->
<div class="tab_bar_purple tabsbar-2">
<ul class="row row-merge">
<li class=active><a href="#tabs-1" data-toggle="tab">Select Filters and Report format</a></li>
</ul>
</div>
<!-- // Tabs Heading END -->
<div class="tab-content">
<div id=tabs-1 class="tab-pane active">
<fieldset>
<legend class='task_legend'>Select Filters</legend>
<form method=post action='hr?action=MainReport' target=_BLANK name=reportform>
<input type=hidden name=_token value='<?php echo csrf_token(); ?>'>
<input type=hidden name=client id=client value=''>
<input type=hidden name=visacompany id=visacompany value=''>
<input type=hidden name=currentstatus id=currentstatus value=''>
<div id=reportformarrs></div>
<p>
<label class='label-small_new' style='width:15%'>Record Ids:</label>
<input class='form_new form_new_amend' id='empid' name='empid' type='text' value='' style='width:25%' />
<span class=field_desc id='fd'></span><span class=validate_success></span><span class=validate_error></span>
</p>
<p>
<label class='label-small_new' style='width:15%'></label>
<b>-- OR --</b>
</p>
<p>
<label class='label-small_new' style='width:15%'>Company: </label>
<select name=client2 id=client2 multiple='' data-rel=chosen class=select2multi style='width:40%'>
<?php
$clients=$wakka->clientsReadAccess();
sort($clients);
foreach($clients as $clientval){echo "<option value='$clientval'>$clientval</option>";}
?>
</select>
</p>
<div class='clear:both'></div>
<!-- <p>
<label class='label-small_new' style='width:15%'>Visa Company: </label>
<select name=visacompany2 id=visacompany2 multiple='' data-rel=chosen class=select2multi style='width:40%'>
<?php
$clients=explode("~",$kformlib->FormSelectVals['visacompany']);
foreach($clients as $clientval){echo "<option value='$clientval'>$clientval</option>";}
?>
</select>
</p>-->
<p>
<label class='label-small_new' style='width:15%'>Record Status: </label>
<select name=currentstatus2 id=currentstatus2 multiple='' data-rel=chosen class=select2multi style='width:40%'>
<?php
$clients=explode("~",$kformlib->FormSelectVals['currentstatus']);
foreach($clients as $clientval){echo "<option value='$clientval'>$clientval</option>";}
?>
<?php if($wakka->IsAdmin()){ ?><option value='<?php echo $wakka->HRCoreVars["systemExitStatus"]; ?>'><?php echo $wakka->HRCoreVars["systemExitStatus"]; ?></option><?php } ?>
</select>
</p>
<p>
<label class='label-small_new' style='width:15%'>Record Modified From: </label>
<input size=7 id='modfrom' name='modfrom' type='text' value='' /> To: <input size=7 id='modto' name='modto' type='text' value='' />
</p>
<p>
<label class='label-small_new' style='width:15%'>Record Created From: </label>
<input size=7 id='crefrom' name='crefrom' type='text' value='' /> To: <input size=7 id='creto' name='creto' type='text' value='' />
</p>
<p>
<label class='label-small_new' style='width:15%'>For:</label><select class='form_hrm_select' id=fieldbyrange name=fieldbyrange><option></option>
<?php
$dtfields=explode(",",$kformlib->HRDateFilds);
foreach($dtfields as $tdtf)if(trim($tdtf)!="")echo "<option value='$tdtf'>".$kformlib->HRFieldNames[$tdtf]."</option>";
?>
</select>
</p>
<p>
<label class='label-small_new' style='width:15%'>Between:</label>
<input size=7 id='frcrefrom' name='frcrefrom' type='text' value='' /> To: <input size=7 id='frcreto' name='frcreto' type='text' value='' />
</p>
<?php
$toarr=array();
$optionsstr="";
$fileids=explode(",",$kformlib->HRFiledsStr);
foreach($fileids as $fileid)
{
if(trim($fileid)!='')
{
if(strstr($kformlib->HRFileFieldsStr,$fileid))$ftype='File';
else if(strstr($kformlib->HRDateFilds,$fileid))$ftype='Date';
else if(strstr($kformlib->HRDropFilds,$fileid))$ftype='Dropdown';
else $ftype='Text';
$toarr[$fileid]=$kformlib->HRFieldNames[$fileid]." ($ftype)";
}
}
//asort($toarr);
foreach($toarr as $key=>$opts)$optionsstr.="<option value='$key'>$opts</option>";
?>
<p><label class='label-small_new' style='width:15%;'>Fields: </label>
<select size=9 id=fieldsarr2 multiple='multiple' style='width:40%' class=select2multi><?php echo $optionsstr; ?></select><span style='margin-left: 20px;line-height: 30px;'>(Hold ctrl to select multiple)</span></p>
<p><label class='label-small_new' style='width:15%'>Report Type</label><select class='form_hrm_select' id=reporttype name=reporttype><option value='Values'>Values</option><option value='Binary'>Binary</option><option value='History'>History</option></select>
<select class='form_hrm_select' id=outputtype name=outputtype><option value='XLS'>XLS</option><option value='CSV'>CSV</option></select>
<select class='form_hrm_select' id='asalmonth' name='asalmonth'>
<option value=''></option>
<option value=1>Jan</option>
<option value=2>Feb</option>
<option value=3>Mar</option>
<option value=4>Apr</option>
<option value=5>May</option>
<option value=6>Jun</option>
<option value=7>Jul</option>
<option value=8>Aug</option>
<option value=9>Sep</option>
<option value=10>Oct</option>
<option value=11>Nov</option>
<option value=12>Dec</option>
</select>
<select class='form_hrm_select' id='asalyear' name='asalyear'>
<option value=''></option>
<?php for($i=date('Y')+1;$i>=1990;$i--)echo "<option value=$i>$i</option>"; ?>
</select>
</p>
<p>
<label class='label-small_new' style='width:15%'></label>
<input type=hidden name=reportsubmit value=reportsubmit>
<input class='form_new form_new_amend' style='width:355px' type=text name=savereportname id=savereportname placeholder='Name of the report to save'>
<input type=button class='btn btn-purple_outline' name=reportsubmit value="Generate Report" onclick="setRptSelection();return false;">
<span class=field_desc id='fd'></span><span class=validate_success></span><span class=validate_error></span>
</p>
</form>
</fieldset>
<fieldset id='saved_reprts'><legend class='new-recruit_legend'>Saved Reports</legend>
<?php
$savedreports=$wakka->GetBBBUserData("UserSavedReports");
if(is_array($savedreports))foreach($savedreports as $rname=>$rpts)
{
echo "<p><label class='label-small_new' style='width:15%'>$rname</label><a href='".url("/hr/MainReport?reportsubmit=1&savedreportget=$rname")."' class='btn btn-purple' target=_BLANK>Download</a> <a href=# title='Delete this entry' onclick='deletesavedreport(\"$rname\");return false;' style='margin-left: 50px;'><i class='fa fa-times-circle' style='color:#967bdc'>Delete</i></a></p>";
}
?>
</fieldset>
</div>
</div>
</div>
</div>
</div>
<!-- // Tabs END -->
</div>
</div>
</div>
</div>
</div><!-- // END row-app -->
<script>
$('#modfrom').datepicker({dateFormat: 'dd.mm.yy',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
$('#modto').datepicker({dateFormat: 'dd.mm.yy',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
$('#crefrom').datepicker({dateFormat: 'dd.mm.yy',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
$('#creto').datepicker({dateFormat: 'dd.mm.yy',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
$('#frcrefrom').datepicker({dateFormat: 'dd.mm.yy',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
$('#frcreto').datepicker({dateFormat: 'dd.mm.yy',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
function setRptSelection()
{
$("#client").val($("#client2").val());
// $("#visacompany").val($("#visacompany2").val());
$("#currentstatus").val($("#currentstatus2").val());
$("#reportformarrs").html("");
$("#fieldsarr2").select2("data").forEach(function(elem){$("#reportformarrs").append("<input type=hidden name=fieldsarr[] value='"+elem.id+"'>");});
document.reportform.submit();
}
// $("#client2").dropdownchecklist({icon:{}, width:300, maxDropHeight:300, emptyText:"Select.." });
// $("#visacompany2").dropdownchecklist({icon:{}, width:300, maxDropHeight:300, emptyText:"Select.." });
// $("#currentstatus2").dropdownchecklist({icon:{}, width:300, maxDropHeight:300, emptyText:"Select.." });
function deletesavedreport(rname)
{
doAjax('hr?action=DeleteSavedReport&rname='+rname,'','searchresults');
}
</script>
......@@ -39,6 +39,9 @@ $yemaxcarryleaves=base64_encode(Input::get("yemaxcarryleaves"));
$trackerfields=base64_encode(Input::get("trackerfields"));
if(Input::get("autodial_pacing")){
$autodial=base64_encode(Input::get("autodial_pacing"));
}
$developerparam=base64_encode(str_replace('\n',"\n",Input::get("developerparam")));
......@@ -74,7 +77,7 @@ $mvalue.="yrsickleaves~$yrsickleaves|";
$mvalue.="yrannualleaves~$yrannualleaves|";
$mvalue.="yemaxcarryleaves~$yemaxcarryleaves|";
$mvalue.="developerparam~$developerparam|";
$mvalue.="autodialercampaign~$autodial|";
$mvalue.="trackerfields~$trackerfields|";
//if($wakka->getCount("hrms_masters","mkey='$client' and mtype='company'")==0)$companyarr=$wakka->Query("insert into hrms_masters set mvalue='',mkey='$client',mtype='company';");
......
......@@ -11,7 +11,14 @@ if(Input::has('addcompany'))
//$wakka->Query("insert into hrms_masters set mvalue='',mkey='$company',mtype='company';");
//$wakka->Query("insert into hrms_masters set mvalue='',mkey='$company',mtype='company',status='active';");
$wakka->Query("insert into hrms_masters set mvalue='',mkey='$company',mtype='company',status='active', campaignstartdate='$campaignstartdate', campaignenddate='$campaignenddate';");
/*if(!(Schema::hasTable('records_'.$company)))
{
DB::statement("CREATE TABLE records_$company LIKE records;");
DB::insert(DB::raw("Insert into records_$company SELECT * from records where client='$company'"));
//exit();
}*/
}
}
return;
......@@ -109,6 +116,7 @@ if($client!="")
echo "<p><label class='label-small_new' style='width:15%'>AnnualMaxCarryLeaves :</label><input type=text class='form_new form_new_amend' name=yemaxcarryleaves id=yemaxcarryleaves value='".($mastersdata["yemaxcarryleaves"])."'></p>";
echo "<p><label class='label-small_new' style='width:15%'>Parameters</label><textarea rows=8 id='developerparam' style='font-size:12px;width:85%'>".($mastersdata["developerparam"])."</textarea></p>";
echo "<p><label class='label-small_new' style='width:15%'>Autodial Ratio</label><input type=text class='form_new form_new_amend' name='autodial_pacing' id='autodial_pacing' style='font-size:12px;width:15%' value='".($mastersdata["autodialercampaign"])."'></p>";
......
......@@ -458,7 +458,7 @@ function saveCompanies()
vardata+="&developerparam="+encodeURIComponent($("#developerparam").val());
vardata+="&autodial_pacing="+encodeURIComponent($("#autodial_pacing").val());
doAjax("hr?action=CompanyMaster", vardata, "searchresults");
}
function loadCompanyMasters(companyname)
......
<?php
$url = 'https://push3.maccesssmspush.com/servlet/com.aclwireless.pushconnectivity.listeners.TextListener?';
//$url = 'https://push3.maccesssmspush.com/servlet/com.aclwireless.pushconnectivity.listeners.TextListener?userId=hdfcbalrt&pass=hdfcbalrt25&appid=hdfcbalrt&subappid=hdfcbalrt&contenttype=1&to=8074030875&from=HDFCBK&text=manoj&selfid=true&alert=1&dlrreq=true&intflag=false';
$inputArray = ['userId'=>'hdfcbalrt',"pass"=>'hdfcbalrt25',"appid"=>"hdfcbalrt","subappid"=>"hdfcbalrt","contenttype"=>"1","to"=>"8074030875","from"=>"HDFCBK","text"=>"Hi","selfid"=>"true","alert"=>"1","dlrreq"=>"true","intflag"=>"false"];
$payload = json_encode($inputArray);
$payload = json_encode($jsonBody);
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIE, "");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json',
'AUTHORIZATIONKEY:' . $X_AUTH_T,
'X-EMAIL:' . $X_EMAIL_T, 'Cache-Control:no-cache'
));
curl_exec($ch);
curl_close($ch);
?>
<style>
.tab_bar_green{
border: 1px solid #EFEFEF;
height: 39px;
margin: 0 0 10px;
overflow: hidden;
position: relative;
}
.tab_bar_green ul{
list-style: none outside none;
margin: 0;
padding: 0;
background: none repeat scroll 0 0 #48cfae;
}
.tab_bar_green ul li{
border: medium none;
height: 39px;
padding: 0;
display: block;
float: left;
}
.tab_bar_green ul li a{
background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
height: 39px;
line-height: 39px;
display: block;
padding: 0 15px;
text-decoration: none;
color:#fff;
font-weight:600;
}
.tab_bar_green .tabsbar-2{
/*height: 39px;*/
}
.tab_bar_green ul li.active{
background: none repeat scroll 0 0 #fff;
}
.tab_bar_green ul li.active a{
color:#36bc9b;
}
</style>
<?php
$kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
$kformlib->gthis=$wakka;
include_once(app_path().'/lib/phpexcel/PHPExcel.php');
$themehome=$wakka->GetThemePath('/');
$updatetime=time();
function mkdir_r ($dir)
{
if (strlen($dir) == 0)return 0;
if (is_dir($dir))return 1;
elseif (dirname($dir) == $dir)return 1;
return (mkdir_r(dirname($dir)) and mkdir($dir,0777));
}
print_r($_POST['ebulkuploadform']);
if(isset($_POST['ebulkuploadform'])&&$wakka->GetUser())
{
$clientlst=$wakka->GetBBBUserData("clientslist");
$isadmin=$wakka->IsAdmin();
$username=$wakka->GetUserName();
$triggers=Input::get("triggers");
$tmpstr=explode(",",$kformlib->HRFiledsStr);
$success="";$message="";$successcnt=0;$duplicatecount=0;
$inputFileType = "Excel5";
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($_FILES['empbulkfile']['tmp_name']);
$objWorksheet = $objPHPExcel->getActiveSheet();
$highestColumn = PHPExcel_Cell::columnIndexFromString($objPHPExcel->getActiveSheet()->getHighestColumn());
$highestrow=$objPHPExcel->getActiveSheet()->getHighestRow();
$excelarray=array();$keys=array();
for($i=1;$i<=$highestrow;$i++)
{
$excelarray[$i]=array();
for ($head = 0; $head < $highestColumn; $head++)
{
if($i==1)
{
$keys[$head]=trim($objWorksheet->getCellByColumnAndRow($head,$i)->getValue());
}
else
{
$excelarray[$i][$keys[$head]]=trim($objWorksheet->getCellByColumnAndRow($head, $i)->getValue());
}
}
}
for($i=2;$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;
$excelarray[$i]["DOB"]= date('Y-m-d', PHPExcel_Shared_Date::ExcelToPHP($excelarray[$i]["DOB"]));
$newdata=$ppldata;
if($isadmin||strstr($clientlst,$ppldata['client']))
{
$editflag=0;
foreach($excelarray[$i] as $key => $value)
{
if(isset($kformlib->HRFieldNames[$key]))
{
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;$editflag=1;
if($triggers=='Yes')
{
$kformlib->empAnalytics($excelarray[$i]["id"],$ppldata,$key,$value,$ppldata[$key]);
$kformlib->empWorkflowTrigger($excelarray[$i]["id"],$ppldata['client'],$key,$value,$ppldata[$key],$ppldata,$newdata);
}
$newdata[$key]=$value;
}
//else $message.="same $excelarray[$i][id]:$key:$value, ";
}
//else $message.="empty $excelarray[$i][id]:$key, ";
}
else
{
// $message.="Invalid key :$key, ";
}
}
if($editflag)
{
$empdata["peopledata"]=$newdata;$empdata['modifylog']=$createdlog;$empdata['dirty']=$fdirty;$wakka->setPerson($excelarray[$i]["id"],$empdata);
$success.=$excelarray[$i]["id"].",";$successcnt++;
}
}
else
{
// $message.="No access to $excelarray[$i][id], ";
}
}
else
{
// $message.="ID not found $excelarray[$i][id], ";
}
}
else
{
$message.="Incorrect ID '$excelarray[$i][id]', ";
}
}
@unlink($_FILES['empbulkfile']);
$success="Data Uploaded ($successcnt): ".$success.". Duplicate : $duplicatecount";
print_r(Config::get('app.sqllog'));
?>
<script>
var data='';
data+="<?php if($success!="")echo "<div class='message success close'><h2>Success!</h2><p>$success</p></div>"; ?>";
data+="<?php if($message!="")echo "<div class='message error close'><h2>Error!</h2><p>$message</p></div>"; ?>";
parent.document.getElementById("ebulkuploadresult").innerHTML = data;
parent.messageCloseFun();
</script>
<?php
return;
}
else if(isset($_POST['ebulkuploadformf'])&&$wakka->GetUser())
{
if(false)$message="Other Bulk Uploads are Running, Please Wait for them to finish..";
else
{
$clientlst=$wakka->GetBBBUserData("clientslist");
$fileElementName=$_POST['filefieldname'];
if($fileElementName!=""&&strstr($kformlib->HRFileFieldsStr,$fileElementName))
{
for($i=0;$i<20;$i++)
{
$fileElementNameI = "empbulkfilef$i";
$varid=$_POST["empid$i"];
if($varid!=""&&isset($_FILES[$fileElementNameI]))
{
if($wakka->getCount("records","id='$varid'")==1&&empty($_FILES[$fileElementNameI]['error'])&&$_FILES[$fileElementNameI]["size"]<=2*1024*1024)
{
$empdata=$wakka->getPerson($varid);
$createdlog=$empdata['modifylog'];
$ppldata=$empdata["peopledata"];
if($wakka->IsAdmin()||strstr($clientlst,$ppldata['client']))
{
$filename=explode(".",$_FILES[$fileElementNameI]['name']);
$filenameNew=$varid."_".$fileElementName.".".$filename[(sizeof($filename)-1)];
$filenamePdf=$varid."_".$fileElementName.".pdf";
if($fileElementName=="genericfileselect")
{
$filenameNew=$varid."_G_".str_replace(" ","_",$_POST['gr']).".".$filename[(sizeof($filename)-1)];
$filenamePdf=$varid."_G_".str_replace(" ","_",$_POST['gr']).".pdf";
}
$destfile = "$themehome/recruits/$varid/$filenameNew";
$destfilepdf ="$themehome/recruits/$varid/$filenamePdf";
if (!is_dir("$themehome/recruits/$varid"))mkdir_r("$themehome/recruits/$varid");
if (!is_dir("$themehome/thumbs/$varid"))mkdir_r("$themehome/thumbs/$varid");
//rename if exists
if(file_exists($destfilepdf))rename($destfilepdf, "$themehome/recruits/$varid/OLD__$filenamePdf");
if(!move_uploaded_file($_FILES[$fileElementNameI]['tmp_name'], $destfile))$error="File cannot be uploaded to folder: $varid, ";
if($error=="")
{
if(strtolower($filename[(sizeof($filename)-1)])=="pdf")rename("$destfile","$destfile.pdf");
else if(strtolower($filename[(sizeof($filename)-1)])=="txt")exec("convert -quality 200% -compress zip \"$destfile\" \"$destfile.pdf\"");
else exec("convert -quality 100% -units PixelsPerInch -density 200 -resize 200% -compress zip \"$destfile\" \"$destfile.pdf\"");
exec("convert -adjoin -quality 100% -units PixelsPerInch -density 100 -resize 100% -compress zip \"$themehome/recruits/$varid/OLD__$filenamePdf\" \"$destfile.pdf\" \"$destfilepdf\"");
exec("convert -quality 100% -delay 100 -thumbnail x400 \"$destfilepdf\" \"$themehome/thumbs/$varid/$filenamePdf.gif\"");
}
@unlink($_FILES[$fileElementNameI]);
if($filename[(sizeof($filename)-1)]!="pdf")@unlink("$destfile.pdf");
else rename("$destfile.pdf","$destfile");
if($filename[(sizeof($filename)-1)]!="pdf")if(file_exists($destfilepdf))@unlink($destfile);
$kformlib->empWorkflowTrigger($varid,$ppldata['client'],$fileElementName,$filenamePdf,$filename,$ppldata,$ppldata);
$wakka->setPersonKey($ppldata["id"],$fileElementName,$filenamePdf,$wakka->GetUserName());
if($error=="")$success.="Done : $varid, ";
else $message.=$error;
}
else
{
$message.="No Access to $varid, ";
}
}
else $message.="Error Uploading for ID : $varid, ";
}
//else $message.="nothing $i ($varid,$fileElementNameI), ";
}
}
}
?>
<script>
var data='';
data+="<?php if($success!="")echo "<div class='message success close'><h2>Success!</h2><p>$success</p></div>"; ?>";
data+="<?php if($message!="")echo "<div class='message error close'><h2>Error!</h2><p>$message</p></div>"; ?>";
parent.document.getElementById("ebulkuploadresultf").innerHTML = data;
parent.messageCloseFun();
</script>
<?php
return;
}
else if(isset($_POST['useruploadform'])&&$wakka->GetUser())
{
$clientlst=$wakka->GetBBBUserData("clientslist");
$isadmin=$wakka->IsAdmin();
$username=$wakka->GetUserName();
$triggers=Input::get("triggers");
$tmpstr=explode(",",$kformlib->HRFiledsStr);
$success="";$message="";$successcnt=0;$duplicatecount=0;
$inputFileType = "Excel5";
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($_FILES['useruploadfile']['tmp_name']);
$objWorksheet = $objPHPExcel->getActiveSheet();
$highestColumn = PHPExcel_Cell::columnIndexFromString($objPHPExcel->getActiveSheet()->getHighestColumn());
$highestrow=$objPHPExcel->getActiveSheet()->getHighestRow();
$excelarray=array();$keys=array();
for($i=1;$i<=$highestrow;$i++)
{
$excelarray[$i]=array();
for ($head = 0; $head < $highestColumn; $head++)
{
if($i==1)
{
$keys[$head]=trim($objWorksheet->getCellByColumnAndRow($head,$i)->getValue());
}
else
{
$excelarray[$i][$keys[$head]]=trim($objWorksheet->getCellByColumnAndRow($head, $i)->getValue());
}
}
}
for($i=2;$i<=$highestrow;$i++)
{
if($excelarray[$i]["id"]!="")
{
if($excelarray[$i]["id"]=="CREATE")
{
$excelarray[$i]["id"]=$wakka->Query("insert into","","users",array('created_at'=>date('Y-m-d H:i:s')));
}
else $excelarray[$i]["id"]=intval($excelarray[$i]["id"]);
if($wakka->getCount("users","id='".$excelarray[$i]["id"]."'")==1)
{
$empdata=$wakka->getPersonUser($excelarray[$i]["id"]);
$ppldata=$empdata["peopledata"];
$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).",";
$newdata[$key]=$value;
}
}
}
$empdata["peopledata"]=$newdata;
$successcnt++;
$wakka->setPersonUser($excelarray[$i]["id"],$empdata);
$excelarray[$i]['modified']=date('Y-m-d H:i:s');
}
else
{
// $message.="ID not found $excelarray[$i][id], ";
}
}
else
{
$message.="Incorrect ID '$excelarray[$i][id]', ";
}
}
@unlink($_FILES['empbulkfile']);
$success="Data Uploaded ($successcnt): ".$success.". Duplicate : $duplicatecount";
print_r(Config::get('app.sqllog'));
?>
<script>
var data='';
data+="<?php if($success!="")echo "<div class='message success close'><h2>Success!</h2><p>$success</p></div>"; ?>";
data+="<?php if($message!="")echo "<div class='message error close'><h2>Error!</h2><p>$message</p></div>"; ?>";
parent.document.getElementById("userupload").innerHTML = data;
parent.messageCloseFun();
</script>
<?php
return;
}
?>
<?php if($wakka->GetUser()){ ?>
<div class="layout-app"><!-- row-app -->
<div class="row row-app">
<div class="col-md-12">
<div class="col-separator col-separator-first col-unscrollable box">
<div class=innerAll>
<div class="relativeWrap" >
<div class="tab_generic">
<!-- Tabs Heading -->
<div class="tab_bar_green tabsbar-2">
<ul class="row row-merge">
<li class=active><a href="#tabs-1" data-toggle="tab">Bulk Upload</a></li>
<li><a href="#tabs-2" data-toggle="tab">Files Upload</a></li>
<li><a href="#tabs-3" data-toggle="tab">User Upload</a></li>
</ul>
</div>
<div class="tab-content">
<div id=tabs-1 class="tab-pane active">
<form method=post enctype='multipart/form-data' target=ebresultsf action="record?action=bulkupload">
<input type=hidden name=_token value='<?php echo csrf_token(); ?>'>
<input type=hidden name=ebulkuploadform value='1'>
<fieldset>
<legend class='task_legend'>Bulk Upload Record Data</legend>
<p><b style="color: #fb6e52;">Instruction</b>(Works only if you have 'Write access" to the records)<br>
Please create an Excel-2003 format file with header as field-keys and rows containing record data.
<br>
<span style="color: #fb6e52;">Extream Care is should be taken during bulk upload as previous values will be overwritten and lost</span>
</p>
<p>Upload File</p>
<p>Triggers : <select name=triggers class='form-control' style='width:150px;display:inline'><option value='Yes'>Yes</option><option value='No'>No</option></select></p>
<div style='clear:both'></div>
<p><input type=file name=empbulkfile style='float:left'><input type=submit class='btn btn-green_outline' value="Bulk Update" style='float:left'></p>
<p>
<iframe name=ebresultsf id="ebresultsf" style='width:0px;height:0px;display:none'></iframe>
</p>
</fieldset>
</form>
<div id=ebulkuploadresult></div>
</div>
<div id=tabs-2 class="tab-pane">
<form method=post enctype='multipart/form-data' target=ebresultsff action="record?action=bulkupload">
<input type=hidden name=_token value='<?php echo csrf_token(); ?>'>
<input type=hidden name=ebulkuploadformf value='1'>
<fieldset>
<legend class='task_legend'>Bulk Upload Employee Files</legend>
<p><b style="color: #fb6e52;">Instruction</b>(Works only if you have 'Write access" to the records)<br>
You can upload 20 files at a time for each upload type, after that process can be repeated
<br>
</p>
<p><label class='label_new'>Select Field Name</label>
<select name=filefieldname class=form_hrm_select style='margin: 0 6px;width: 24%;'><option></option>
<?php
$dtfields=explode(",",$kformlib->HRFileFieldsStr);
foreach($dtfields as $tdtf)if(trim($tdtf)!="")echo "<option value='$tdtf'>".$kformlib->HRFieldNames[$tdtf]."</option>";
?></select>
</p>
<?php for($i=0;$i<20;$i++){ ?>
<p><label class='label_new' style='float: left'>Upload File For</label>
<input type=text name='empid<?php echo $i; ?>' placeholder=Employee-ID class='form_new mrgn' size=40 style='float: left'> <input type=file name='empbulkfilef<?php echo $i; ?>' style=' padding-top: 10px;'>
</p><div style='clear:both'></div>
<?php } ?>
<p style='float: right;margin-right: 40%;margin-top: 2%;'><label></label>
<input type=submit class='btn btn-green' value="Bulk Upload">
</p>
<p><label></label>
<iframe name=ebresultsff id="ebresultsff" style='width:0px;height:0px;display:none'></iframe>
</p>
</fieldset>
</form>
<div id=ebulkuploadresultf></div>
</div>
<div id=tabs-3 class="tab-pane">
<div style='clear:both'></div>
<br><br>
<a href='/exceldownload'><button class='btn btn-info' style='float:right'><i class="fa fa-download"></i> Extract</button></a>
<br><br>
<form method=post enctype='multipart/form-data' action="record?action=bulkupload" target=uploadresult>
<input type=hidden name=_token value='<?php echo csrf_token(); ?>'>
<input type=hidden name=useruploadform value='1'>
<p><input type=file name=useruploadfile style='float:left'>
<input type=submit class='btn btn-green_outline' value="User Upload" style='float:left'> <br></p>
<iframe name=uploadresult id="uploadresult" style='width:0px;height:0px;display:none'></iframe>
</form>
<div id=userupload></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div><!-- // END row-app -->
<?php } ?>
......@@ -40,141 +40,43 @@ $searchkey3=trim(Input::get('maintextsearch_3_span'));
$searchstr4=trim(Input::get('maintextsearch_4_txt'));
$searchkey4=trim(Input::get('maintextsearch_4_span'));
$client=trim(Input::get('client'));
$uids=array();
function getUidsByKey($wakka, $key, $value, $client) {
if($searchstr1!="")
{
$key='';$tusers=array();
if($searchkey1=="ID")$key='id';
if($searchkey1=="FirstName")$key='firstname';
if($searchkey1=="LastName")$key='lastname';
if($searchkey1=="Client")$key='client';
if($searchkey1=="Mobile")$key='mobile';
if($searchkey1=="Email")$key='emailid';
if($searchkey1=="Passport")$key='passportno';
if($searchkey1=="IBAN")$key='ibannumber';
if($searchkey1=="Status")$key='currentstatus';
if($searchkey1=="PersonalID")$key='laborcardpersonalid';
if($searchkey1=="InternalID")$key='clientinternalid';
if($searchkey1=="ClientCode")$key='clientcode';
$searchKeyArray = array(
"ID" =>'id', "FirstName" =>'firstname', "LastName" =>'lastname',
"Client" =>'client', "Mobile" =>'mobile', "Email" =>'emailid',
"Passport" =>'passportno', "IBAN" =>'ibannumber', "Status" =>'currentstatus',
"InternalID"=>'clientinternalid', "ClientCode"=>'clientcode', "PersonalID"=>'laborcardpersonalid');
if($key!='')
{
if($key=='id')$uids=array(intval($searchstr1));
else
{
$matchkeys=array();
$prematchstr="";if(!empty($uids))$prematchstr="where id in (".implode(",",$uids).")";
$res=$wakka->LoadAll("select distinct $key from records $prematchstr");
foreach($res as $tres)if($tres[$key]!=''&&stristr($tres[$key],$searchstr1))$matchkeys[]="'".$tres[$key]."'";
$prematchstr2="";if(!empty($uids))$prematchstr2="and id in (".implode(",",$uids).")";
if(!empty($matchkeys))$tusers=$wakka->getPersonIDs("$key in (".implode(",",$matchkeys).") $prematchstr2");
$uids=array();foreach($tusers as $tuser)if(isset($tuser['id']))$uids[]=$tuser['id']+0;
}
}
}
if($searchstr2!="")
{
$key='';$tusers=array();
if($searchkey2=="ID")$key='id';
if($searchkey2=="FirstName")$key='firstname';
if($searchkey2=="LastName")$key='lastname';
if($searchkey2=="Client")$key='client';
if($searchkey2=="Mobile")$key='mobile';
if($searchkey2=="Email")$key='emailid';
if($searchkey2=="Passport")$key='passportno';
if($searchkey2=="IBAN")$key='ibannumber';
if($searchkey2=="Status")$key='currentstatus';
if($searchkey2=="PersonalID")$key='laborcardpersonalid';
if($searchkey2=="InternalID")$key='clientinternalid';
if($searchkey2=="ClientCode")$key='clientcode';
$key=$searchKeyArray[$key];
$uids=array();
if($key!='')
{
if($key=='id')$uids=array(intval($searchstr2));
else
{
$matchkeys=array();
$prematchstr="";if(!empty($uids))$prematchstr="where id in (".implode(",",$uids).")";
$res=$wakka->LoadAll("select distinct $key from records $prematchstr");
foreach($res as $tres)if($tres[$key]!=''&&stristr($tres[$key],$searchstr2))$matchkeys[]="'".$tres[$key]."'";
$prematchstr2="";if(!empty($uids))$prematchstr2="and id in (".implode(",",$uids).")";
if(!empty($matchkeys))$tusers=$wakka->getPersonIDs("$key in (".implode(",",$matchkeys).") $prematchstr2");
$uids=array();foreach($tusers as $tuser)if(isset($tuser['id']))$uids[]=$tuser['id']+0;
}
if($key=='id'){
$uids=array(intval($value));
}
}
if($searchstr3!="")
{
$key='';$tusers=array();
if($searchkey3=="ID")$key='id';
if($searchkey3=="FirstName")$key='firstname';
if($searchkey3=="LastName")$key='lastname';
if($searchkey3=="Client")$key='client';
if($searchkey3=="Mobile")$key='mobile';
if($searchkey3=="Email")$key='emailid';
if($searchkey3=="Passport")$key='passportno';
if($searchkey3=="IBAN")$key='ibannumber';
if($searchkey3=="Status")$key='currentstatus';
if($searchkey3=="PersonalID")$key='laborcardpersonalid';
if($searchkey3=="InternalID")$key='clientinternalid';
if($searchkey3=="ClientCode")$key='clientcode';
if($key!='')
{
if($key=='id')$uids=array(intval($searchstr3));
else
{
$matchkeys=array();
$prematchstr="";if(!empty($uids))$prematchstr="where id in (".implode(",",$uids).")";
$res=$wakka->LoadAll("select distinct $key from records $prematchstr");
foreach($res as $tres)if($tres[$key]!=''&&stristr($tres[$key],$searchstr3))$matchkeys[]="'".$tres[$key]."'";
if(!empty($value)){
$tusers=$wakka->getPersonIDsWithLike($key, $value, $client);
$prematchstr2="";if(!empty($uids))$prematchstr2="and id in (".implode(",",$uids).")";
if(!empty($matchkeys))$tusers=$wakka->getPersonIDs("$key in (".implode(",",$matchkeys).") $prematchstr2");
$uids=array();foreach($tusers as $tuser)if(isset($tuser['id']))$uids[]=$tuser['id']+0;
if(count($tusers))foreach($tusers as $tuser) $uids[]=$tuser['id']+0;
}
}
}
return $uids;
}
if($searchstr4!="")
{
$key='';$tusers=array();
if($searchkey4=="ID")$key='id';
if($searchkey4=="FirstName")$key='firstname';
if($searchkey4=="LastName")$key='lastname';
if($searchkey4=="Client")$key='client';
if($searchkey4=="Mobile")$key='mobile';
if($searchkey4=="Email")$key='emailid';
if($searchkey4=="Passport")$key='passportno';
if($searchkey4=="IBAN")$key='ibannumber';
if($searchkey4=="Status")$key='currentstatus';
if($searchkey4=="PersonalID")$key='laborcardpersonalid';
if($searchkey4=="InternalID")$key='clientinternalid';
if($searchkey4=="ClientCode")$key='clientcode';
if($key!='')
{
if($key=='id')$uids=array(intval($searchstr4));
else
{
$matchkeys=array();
$prematchstr="";if(!empty($uids))$prematchstr="where id in (".implode(",",$uids).")";
$uids=array();
if($searchstr1!="") $uids = getUidsByKey($wakka, $searchkey1, $searchstr1, $client);
if($searchstr2!="") $uids = getUidsByKey($wakka, $searchkey2, $searchstr2, $client);
if($searchstr3!="") $uids = getUidsByKey($wakka, $searchkey3, $searchstr3, $client);
if($searchstr4!="") $uids = getUidsByKey($wakka, $searchkey4, $searchstr4, $client);
$res=$wakka->LoadAll("select distinct $key from records $prematchstr");
foreach($res as $tres)if($tres[$key]!=''&&stristr($tres[$key],$searchstr4))$matchkeys[]="'".$tres[$key]."'";
$prematchstr2="";if(!empty($uids))$prematchstr2="and id in (".implode(",",$uids).")";
if(!empty($matchkeys))$tusers=$wakka->getPersonIDs("$key in (".implode(",",$matchkeys).") $prematchstr2");
$uids=array();foreach($tusers as $tuser)if(isset($tuser['id']))$uids[]=$tuser['id']+0;
}
}
}
$roclientstr=array();
if($wakka->GetBBBUserData("readotherdata")=="No")
{
......@@ -183,7 +85,7 @@ if($searchstr4!="")
}
if(!empty($roclientstr))$roclientstr="and client in (".implode(",",$roclientstr).")";else $roclientstr="";
if(!empty($uids))$users=$wakka->getPersons("id in (".implode(",",$uids).") $roclientstr limit 200");
if(!empty($uids))$users=$wakka->getPersons("id in (".implode(",",$uids).") $roclientstr limit 10;",$client);
if(!empty($users))
{
......
......@@ -4,7 +4,7 @@ $kformlib=new \App\Jobs\KFormLib($wakka->HRCoreVars["HRFiledsStr"]);
if($wakka->GetUser())
{
$varid=Input::get('varid');
$recruitdata=$wakka->getPerson($varid);
$recruitdata=$wakka->getPerson($varid,"");
$config=array();
$config['varid']=$varid;
......
......@@ -5,11 +5,9 @@ $wakka->setUserTimezone();
$themehome=$wakka->GetThemePath('/');
$varid=Input::get('varid');
$bkvarid=Input::get('bkvarid');
$edituser=0;$noreaduser=0;$oldbkrec=0;
$isuser=$wakka->GetUser()?1:0;
$recruitdata=array();
if($varid=="0")
{
return;
......@@ -74,7 +72,7 @@ if($varid!=""||$isuser)
{
$varid=intval($varid);
$recruitdata=$wakka->getPerson($varid);
$recruitdata=$wakka->getPerson($varid,"");
}
......
......@@ -85,6 +85,7 @@ $(document).ready(function(){
{
//doAjax('social/{!!Auth::user()->id!!}','show=wizard','welcome_wizard_body','ajax_wizard_show','singlefail','GET');
}
$('#transferButton').popover({title: "<b>Transfer Current Call</b>", content: '<div class="input-group"><input type="text" class="form-control" placeholder="Number" id=transfercalltxt><span class="input-group-btn"><button class="btn btn-default" type="button" onclick="transfercallconf();return false;" id="transferCallBtn"><i class="glyphicon glyphicon-transfer"></i></button><button class="btn btn-danger hide" type="button" onclick="sendTHDTMFs();return false;" id="transferHangBtn">&times;</button></span></div>', html: true, placement: "bottom"});
});
function hrmsSearch()
......@@ -198,35 +199,39 @@ function createSearchRecordDiv(divid)
<?php
$userdialmode=Auth::user()->dialmode_assign;
$client=Auth::user()->sel_campaign;
$userdialmode=explode(",",$userdialmode);
//print_r($userdialmode);
if(in_array('Progressive',$userdialmode))
{ ?>
<li><a href="#" onclick='updateDialerState("dialer","mDialerState","Progressive");return false;'><b>Progressive</b></a></li>
<li><a href="#" onclick='updateDialerState("dialer","mDialerState","Progressive");savedialermode(<?php echo $client; ?>);return false;'><b>Progressive</b></a></li>
<?php
}
if(in_array('Manual',$userdialmode)){?>
<li id=dialerManualAllowLI><a href="#" onclick='updateDialerState("dialer","mDialerState","Manual");return false;'><b>Manual</b></a></li>
<li id=dialerManualAllowLI><a href="#" onclick='updateDialerState("dialer","mDialerState","Manual");savedialermode();return false;'><b>Manual</b></a></li>
<?php } if(in_array('Incoming',$userdialmode)){ ?>
<li style='background:#36bc9b'><a href="#" onclick='updateDialerState("dialer","mDialerState","Ready","mDialerSubState","Incoming");return false;'><b>Incoming</b></a></li>
<li style='background:#36bc9b'><a href="#" onclick='updateDialerState("dialer","mDialerState","Ready","mDialerSubState","Incoming");savedialermode();return false;'><b>Incoming</b></a></li>
<?php } if(in_array('Predictive',$userdialmode)){?>
<li style='background:#68cc9e'><a href="#" onclick='updateDialerState("dialer","mDialerState","Ready","mDialerSubState","Predictive");savedialermode();return false;'><b>Predictive</b></a></li>
<?php } ?>
<!--<li><a href="#" onclick='updateDialerState("dialer","mDialerState","DialNext");return false;'><b>DialNext</b></a></li>-->
<li><a href="#" onclick='updateDialerState("dialer","mDialerState","Paused","mDialerSubState","Manual");return false;'><b>Paused</b></a></li>
<li><a href="#" onclick='updateDialerState("dialer","mDialerState","Paused","mDialerSubState","Manual");savedialermode();return false;'><b>Paused</b></a></li>
<li style='background:#ccc'><a href="#" onclick='updateDialerState("dialer","mDialerState","Paused","mDialerSubState","AgentBriefing");return false;'><b>AgentBriefing</b></a></li>
<li style='background:#ccc'><a href="#" onclick='updateDialerState("dialer","mDialerState","Paused","mDialerSubState","TeamMeeting");return false;'><b>TeamMeeting</b></a></li>
<li style='background:#ccc'><a href="#" onclick='updateDialerState("dialer","mDialerState","Paused","mDialerSubState","QualityFeedback");return false;'><b>QualityFeedback</b></a></li>
<li style='background:#ccc'><a href="#" onclick='updateDialerState("dialer","mDialerState","Paused","mDialerSubState","LunchBreak");return false;'><b>LunchBreak</b></a></li>
<li style='background:#ccc'><a href="#" onclick='updateDialerState("dialer","mDialerState","Paused","mDialerSubState","TeaBreak");return false;'><b>TeaBreak</b></a></li>
<li style='background:#ccc'><a href="#" onclick='updateDialerState("dialer","mDialerState","Paused","mDialerSubState","UtilityBreak");return false;'><b>UtilityBreak</b></a></li>
<li style='background:#ccc'><a href="#" onclick='updateDialerState("dialer","mDialerState","Paused","mDialerSubState","FloorAnnouncements");return false;'><b>FloorAnnouncements</b></a></li>
<li style='background:#ccc'><a href="#" onclick='updateDialerState("dialer","mDialerState","Paused","mDialerSubState","DownTime");return false;'><b>DownTime</b></a></li>
<li style='background:#ccc'><a href="#" onclick='updateDialerState("dialer","mDialerState","Paused","mDialerSubState","AgentBriefing");savedialermode();return false;'><b>AgentBriefing</b></a></li>
<li style='background:#ccc'><a href="#" onclick='updateDialerState("dialer","mDialerState","Paused","mDialerSubState","TeamMeeting");savedialermode();return false;'><b>TeamMeeting</b></a></li>
<li style='background:#ccc'><a href="#" onclick='updateDialerState("dialer","mDialerState","Paused","mDialerSubState","QualityFeedback");savedialermode();return false;'><b>QualityFeedback</b></a></li>
<li style='background:#ccc'><a href="#" onclick='updateDialerState("dialer","mDialerState","Paused","mDialerSubState","LunchBreak");savedialermode();return false;'><b>LunchBreak</b></a></li>
<li style='background:#ccc'><a href="#" onclick='updateDialerState("dialer","mDialerState","Paused","mDialerSubState","TeaBreak");savedialermode();return false;'><b>TeaBreak</b></a></li>
<li style='background:#ccc'><a href="#" onclick='updateDialerState("dialer","mDialerState","Paused","mDialerSubState","UtilityBreak");savedialermode();return false;'><b>UtilityBreak</b></a></li>
<li style='background:#ccc'><a href="#" onclick='updateDialerState("dialer","mDialerState","Paused","mDialerSubState","FloorAnnouncements");savedialermode();return false;'><b>FloorAnnouncements</b></a></li>
<li style='background:#ccc'><a href="#" onclick='updateDialerState("dialer","mDialerState","Paused","mDialerSubState","DownTime");savedialermode();return false;'><b>DownTime</b></a></li>
</ul>
......@@ -234,9 +239,7 @@ function createSearchRecordDiv(divid)
</div>
<input class="form-control" id="manualdialnumber_txt" style='width:200px' type="text" />
<span class="input-group-addon btn btn-default" id=manualdial_btn dialaction=dialnext onclick='updateDialerState("action",$(this).attr("dialaction"),$("#manualdialnumber_txt").val());'></span>
</div>
......@@ -255,9 +258,10 @@ function createSearchRecordDiv(divid)
<i class='fa fa-fw fa-phone'></i> <span id=spandialer_num onclick='dialerDispNumberClick();return false;'></span>
</a>
</div>
<div id=dialerToggleViewDiv style='float:right;margin-right:20px;'>
<?php if(Auth::user()->id=='1'){ ?>
<button class="btn btn-circle btn-default" id="transferButton"><i class="glyphicon glyphicon-transfer"></i></button>
<?php } ?>
<button class="btn btn-circle btn-default" ><i class="fa fa-phone"></i></button>
<i class="fa fa-long-arrow-left"></i>
......@@ -365,6 +369,45 @@ function createSearchRecordDiv(divid)
$("#topdialerconfcall").hide();
}
function transfercallconf()
{
var confnumber=$("#transfercalltxt").val();
if(confnumber==''||confnumber.length<2)
{
simpleNotification('error','topRight',"Empty Number");
return;
}
if(!kcallHasConnection(kstychCall['callnumber'])||kstychCall['ts_Dispo']>1)
{
simpleNotification('error','topRight',"No call to transfer");
return;
}
$("#transferCallBtn").removeClass("show").addClass("hide");
$("#transferHangBtn").removeClass("hide").addClass("show");
var datastr="kstychCall="+JSON.stringify(kstychCall);
datastr+="&kstychDialer="+JSON.stringify(kstychDialer);
//kcallNewConnection(confnumber);
doAjax('dialer?action=transfercall&confnumber='+confnumber,datastr,'__fake__div__', 'ajax_confdial','singlefail','POST', function(retstr){
if(retstr.responseText.indexOf('Error')<0)
{
// kcallSetConnection(confnumber,'callid',retstr.responseText);
// kcallSetConnection(confnumber,'ts_Call',getNowTS());
updateDialerState();
}
else
{
simpleNotification('error','topRight',retstr.responseText);
}
});
$("#topdialerconfcall").hide();
}
</script>
</div>
</div>
......
#!/usr/bin/php
<?php
$db = mysqli_connect("localhost", "root", "yb9738z", "fullerton");
for ($i=0; $i < 6; $i++) {
$sql = $db->query("SELECT d.conf FROM diallines d JOIN sipids s ON d.conf = concat('1000',s.id) WHERE s.status=0");
$confs = $sql->fetch_all();
foreach($confs as $conf){
print_r($conf);
exec('/usr/sbin/asterisk -rx "confbridge kick '.$conf[0].' all"');
}
$sql = $db->query("SELECT channel FROM diallines WHERE status IN ('Inbound','Auto') AND conf='' AND UNIX_TIMESTAMP(updated_at) <= (".time()." - 60)");
$channels = $sql->fetch_all();
foreach($channels as $channel){
print_r($channel);
exec('/usr/sbin/asterisk -rx "confbridge kick '.$channel[0].' all"');
}
$sipIdStr = "'0'";
exec("/usr/sbin/asterisk -rx 'confbridge list'",$activeConfs);
foreach($activeConfs as $activeConf){
$activeConfArr = explode(" ", preg_replace('!\s+!', ' ', $activeConf) );
$sipConf = $activeConfArr[0];
if(!empty($sipConf) && !(strpos($sipConf, '1000')===false) ){
$sipIdStr .= ",'".substr($sipConf, 4)."'";
}
}
$sql = $db->query("select * from sipids where status=0 and id in ($sipIdStr)");
$sipids = $sql->fetch_all();
foreach($sipids as $sipid){
print_r('1000'. $sipid[0]);
exec('/usr/sbin/asterisk -rx "channel request hangup '.$sipid[0].'"');
exec('/usr/sbin/asterisk -rx "confbridge kick 1000'.$sipid[0].' all"');
}
usleep(1000*1000*9);
}
?>
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!