Merge branch 'fronkdev' into 'master'
Added email notifications to VoicecallHistory::addContractIds() See merge request fronk/thetool!441
This commit is contained in:
@@ -94,7 +94,7 @@
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr><tr>
|
||||
<td colspan="2"><h4>Verrechnungsdaten<?=(array_key_exists("billing", $address->links) && is_array($address->links["billing"]) && count($address->links["billing"])) ? "(<span class='text-danger'>Achtung: Seperate Rechnungsadresse vorhanden</span>)" : ""?> </h4></td>
|
||||
<td colspan="2"><h4>Verrechnungsdaten<?=(array_key_exists("billing", $address->links) && is_array($address->links["billing"]) && count($address->links["billing"])) ? " (<span class='text-danger'>Achtung: Seperate Rechnungsadresse vorhanden</span>)" : ""?> </h4></td>
|
||||
</tr><tr>
|
||||
<th>UID</th>
|
||||
<td><?=$address->uid?></td>
|
||||
@@ -103,7 +103,7 @@
|
||||
<td><?=($address->billing_type == "sepa") ? "SEPA Bankeinzug" : "Rechnung"?></td>
|
||||
</tr><tr>
|
||||
<th>Rechnungsversand</th>
|
||||
<td><?=($address->billing_delivery == "paper" || !$address->billing_delivery) ? "POST" : "Email"?></td>
|
||||
<td><?=($address->billing_delivery == "paper" || !$address->billing_delivery) ? "Post" : "Email"?></td>
|
||||
</tr><tr>
|
||||
<th>Kreditinstitut</th>
|
||||
<td><?=$address->bank_account_bank?></td>
|
||||
|
||||
@@ -114,6 +114,16 @@ class VoiceCallHistoryController extends mfBaseController {
|
||||
"4367761737195"
|
||||
];
|
||||
$unknown_numbers = [];
|
||||
$missing_contracts = [];
|
||||
$update_job_error = false;
|
||||
|
||||
$last_calls = VoiceCallHistoryModel::getVoiceCallHistoryAsEntity([[], 1, 0, ["key" => "create", "order" => "DESC"]]);
|
||||
$last_call = $last_calls[0];
|
||||
if($last_call->create < date("U") - 86400) {
|
||||
$update_job_error = $last_call->create;
|
||||
return false;
|
||||
}
|
||||
|
||||
// get calls without contract id
|
||||
foreach(VoiceCallHistoryModel::getVoiceCallHistoryAsEntity(["contract_id" => null, "billable" => "1", "duration" => ["from" => 1]]) as $call) {
|
||||
//var_dump($call);exit;
|
||||
@@ -130,12 +140,13 @@ class VoiceCallHistoryController extends mfBaseController {
|
||||
|
||||
// TODO: Mail an office
|
||||
if(!$voicenumber) {
|
||||
$this->log->debug(__METHOD__.": Voicenumber $number not found.");
|
||||
$unknown_numbers[] = $number;
|
||||
$this->log->debug(__METHOD__.": Voicenumber $number not found.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!$voicenumber->contract_id) {
|
||||
$missing_contracts[] = $number;
|
||||
$this->log->debug(__METHOD__.": Missing Contract_ID in Voicenumber ".$voicenumber->number);
|
||||
continue;
|
||||
}
|
||||
@@ -156,10 +167,6 @@ class VoiceCallHistoryController extends mfBaseController {
|
||||
$calldate->setTimezone(new DateTimeZone("Europe/Vienna"));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// calls from before first IVT Import must be right, we don't have historic contract data
|
||||
if($calldate->format("Y-m") < "2024-08") {
|
||||
$call->contract_id = $contract->id;
|
||||
@@ -174,10 +181,13 @@ class VoiceCallHistoryController extends mfBaseController {
|
||||
if($calldate->getTimestamp() <= $contract->finish_date && (!$contract->cancel_date || $calldate->getTimestamp() <= $contract->cancel_date)) {
|
||||
// 2023-08 is the oldest we can know because of contract import in July 2024
|
||||
$call->contract_id = $contract->id;
|
||||
echo "save 2\n";
|
||||
//echo "save 2\n";
|
||||
$call->save();
|
||||
} else {
|
||||
//echo "Kann Zeit nicht zu contract zuordnern: ".$call->start." contract id ".$contract->id."\n";
|
||||
}
|
||||
|
||||
// TODO
|
||||
// ... else look for contract with this number active at that time ...
|
||||
|
||||
// ... else use current active contract
|
||||
@@ -190,5 +200,43 @@ class VoiceCallHistoryController extends mfBaseController {
|
||||
echo "save 3\n";
|
||||
$call->save();
|
||||
}
|
||||
|
||||
// set System value voicecallhistory.contact-job.ts
|
||||
$ts = new mfConfig("voicecallhistory.contact-job.ts");
|
||||
$ts->type("int");
|
||||
$ts->value(date("U"));
|
||||
$ts->save();
|
||||
|
||||
if(count($missing_contracts) || count($unknown_numbers) || $update_job_error) {
|
||||
$to = "backoffice@xinon.at";
|
||||
$from = "noreply@xinon.at";
|
||||
$subject = "Rufnummern nicht zuweisbar";
|
||||
|
||||
if($update_job_error) {
|
||||
$body = "VoicecallHistory Update Job ist zuletze am ".date("Y-m-d H:i"). " gelaufen\n";
|
||||
} else {
|
||||
$body = "Für folgende Nummern konnte kein Contract gefunden werden:";
|
||||
|
||||
if (count($unknown_numbers)) {
|
||||
$body .= "\n\nUnbekannte Nummern:\n";
|
||||
foreach ($unknown_numbers as $number) {
|
||||
$body .= $number . "\n";
|
||||
}
|
||||
}
|
||||
if (count($missing_contracts)) {
|
||||
$body .= "\n\nNummer in keinem Contract:\n";
|
||||
foreach ($missing_contracts as $number) {
|
||||
$body .= $number . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
$email = new Emailnotification();
|
||||
$email->setFrom($from);
|
||||
$email->setTo($to);
|
||||
$email->setSubject($subject);
|
||||
$email->setBody($body);
|
||||
$email->send();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user