WIP Voicenumber Billing 2024-07-05
This commit is contained in:
@@ -108,15 +108,23 @@ class VoiceCallHistoryController extends mfBaseController {
|
||||
}
|
||||
|
||||
public function addContractIds() {
|
||||
$ignore_numbers = [
|
||||
"4331641220846",
|
||||
"43623237705",
|
||||
"4367761737195"
|
||||
];
|
||||
$unknown_numbers = [];
|
||||
// get calls without contract id
|
||||
foreach(VoiceCallHistoryModel::getVoiceCallHistoryAsEntity(["contract_id" => null, "billable" => "1", "duration" => ["from" => 1], "end" => "2024-06-01"]) as $call) {
|
||||
foreach(VoiceCallHistoryModel::getVoiceCallHistoryAsEntity(["contract_id" => null, "billable" => "1", "duration" => ["from" => 1]]) as $call) {
|
||||
//var_dump($call);exit;
|
||||
//echo "\n";
|
||||
|
||||
$number = $call->voice_account;
|
||||
if(!$number) continue;
|
||||
|
||||
// server side failed/disconnected calls
|
||||
if($call->duration == 1 && $call->state == 38) continue;
|
||||
|
||||
if(in_array($number, $unknown_numbers)) continue;
|
||||
$voicenumber = VoicenumberModel::getFirst(["number" => $number]);
|
||||
|
||||
@@ -132,12 +140,24 @@ class VoiceCallHistoryController extends mfBaseController {
|
||||
continue;
|
||||
}
|
||||
|
||||
$contract = new Contract($voicenumber->contract_id);
|
||||
if(!$contract) {
|
||||
$this->log->debug(__METHOD__.": No Contract with Contract_ID ".$voicenumber->contract_id." in Voicenumber ".$voicenumber->number);
|
||||
continue;
|
||||
}
|
||||
|
||||
if($contract->isCancelled()) {
|
||||
// mail an office
|
||||
$this->log->warning(__METHOD__.": Contract ".$voicenumber->contract_id." for Voicenumber ".$voicenumber->number." is cancelled!");
|
||||
}
|
||||
|
||||
|
||||
$calldate = new DateTime($call->start);
|
||||
$calldate->setTimezone(new DateTimeZone("Europe/Vienna"));
|
||||
|
||||
|
||||
|
||||
$contract = $voicenumber->contract;
|
||||
|
||||
|
||||
|
||||
// calls from before first IVT Import must be right, we don't have historic contract data
|
||||
|
||||
@@ -110,7 +110,7 @@ class VoiceCallHistoryModel {
|
||||
$sql .= isset($filters['destination']) ? Helper::generateFilterCondition($filters['destination'], "destination") : "";
|
||||
$sql .= isset($filters['billable']) ? Helper::generateFilterCondition($filters['billable'], "billable") : "";
|
||||
$sql .= isset($filters['duration']) ? Helper::generateFilterCondition($filters['duration'], "duration") : "";
|
||||
$sql .= array_key_exists("contract_id", $filters) ? Helper::generateFilterCondition($filters['contract_id'], "contract_id") : "";
|
||||
$sql .= array_key_exists("contract_id", $filters) ? Helper::generateFilterCondition($filters['contract_id'], "contract_id", true) : "";
|
||||
|
||||
return $sql;
|
||||
}
|
||||
@@ -138,7 +138,7 @@ class VoiceCallHistoryModel {
|
||||
$sql .= $order === null || $order['key'] === null ? " ORDER BY `start` DESC" : " ORDER BY `" . $order['key'] . "` " . $order['order'];
|
||||
$sql .= $limit === null ? "" : " LIMIT " . $limit . " OFFSET " . $offset;
|
||||
|
||||
//mfLoghandler::singleton()->debug($sql);exit;
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
// die($sql);
|
||||
$result = $db->query($sql);
|
||||
$rows = [];
|
||||
|
||||
Reference in New Issue
Block a user