From eae7a01f0d11269256f5051f744b75a1e779c91e Mon Sep 17 00:00:00 2001 From: boffart <> Date: Tue, 12 Nov 2024 15:33:50 +0300 Subject: [PATCH] =?UTF-8?q?#741=20=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=BF=D1=80=D0=BE=D0=B1=D0=BB=D0=B5=D0=BC=D1=8B?= =?UTF-8?q?=20=D0=BB=D0=BE=D0=B3=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=B8=D1=81=D1=82=D0=BE=D1=80=D0=B8=D0=B8=20=D0=B7?= =?UTF-8?q?=D0=B2=D0=BE=D0=BD=D0=BA=D0=BE=D0=B2.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WorkerCallEvents/ActionHangupChan.php | 2 +- .../ActionTransferDialHangup.php | 2 +- .../Libs/WorkerCallEvents/InsertDataToDB.php | 24 +++++++++++-------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/Core/Workers/Libs/WorkerCallEvents/ActionHangupChan.php b/src/Core/Workers/Libs/WorkerCallEvents/ActionHangupChan.php index 145b5b6ce..3f5e3c7d0 100644 --- a/src/Core/Workers/Libs/WorkerCallEvents/ActionHangupChan.php +++ b/src/Core/Workers/Libs/WorkerCallEvents/ActionHangupChan.php @@ -218,7 +218,7 @@ private static function regMissedCall(array $data, int $tmpCdrCount): void $data['start'] = date("Y-m-d H:i:s.v", $time); $data['endtime'] = $data['end']; - InsertDataToDB::execute($data); + InsertDataToDB::execute($data, $data['agi_channel']); } /** diff --git a/src/Core/Workers/Libs/WorkerCallEvents/ActionTransferDialHangup.php b/src/Core/Workers/Libs/WorkerCallEvents/ActionTransferDialHangup.php index 06e2f9ca3..5e8e934ea 100644 --- a/src/Core/Workers/Libs/WorkerCallEvents/ActionTransferDialHangup.php +++ b/src/Core/Workers/Libs/WorkerCallEvents/ActionTransferDialHangup.php @@ -128,7 +128,7 @@ private static function fillNotAnsweredCdr(WorkerCallEvents $worker, array $data 'bind' => [ 'linkedid' => $data['linkedid'], 'src_chan' => $data['TRANSFERERNAME'], - 'dst_chan' => $data['dst_chan'], + 'dst_chan' => empty($data['dst_chan'])?$data['agi_channel']:$data['dst_chan'], ], ]; /** @var CallDetailRecordsTmp $m_data */ diff --git a/src/Core/Workers/Libs/WorkerCallEvents/InsertDataToDB.php b/src/Core/Workers/Libs/WorkerCallEvents/InsertDataToDB.php index 0ec901ff2..afb0d2197 100644 --- a/src/Core/Workers/Libs/WorkerCallEvents/InsertDataToDB.php +++ b/src/Core/Workers/Libs/WorkerCallEvents/InsertDataToDB.php @@ -36,9 +36,10 @@ class InsertDataToDB * Execute the insertion of data into the database. * * @param array $data The data to be inserted. + * @param string $channel Channel data, additional filter. * @return void */ - public static function execute($data): void + public static function execute($data, string $channel = ''): void { if (empty($data['UNIQUEID'])) { SystemMessages::sysLogMsg(__FUNCTION__, 'UNIQUEID is empty ' . json_encode($data), LOG_DEBUG); @@ -46,16 +47,19 @@ public static function execute($data): void } $is_new = false; + $filter = [ + "UNIQUEID=:id: AND linkedid=:linkedid:", + 'bind' => [ + 'id' => $data['UNIQUEID'], + 'linkedid' => $data['linkedid'] + ], + ]; + if($channel !== ''){ + $filter[0].= " AND (src_chan = :chan: OR dst_chan = :chan: )"; + $filter['bind']['chan'] = $channel; + } /** @var CallDetailRecordsTmp $m_data */ - $m_data = CallDetailRecordsTmp::findFirst( - [ - "UNIQUEID=:id: AND linkedid=:linkedid:", - 'bind' => [ - 'id' => $data['UNIQUEID'], - 'linkedid' => $data['linkedid'] - ], - ] - ); + $m_data = CallDetailRecordsTmp::findFirst($filter); if ($m_data === null) { // Create a new call record. $m_data = new CallDetailRecordsTmp();