diff --git a/application/VoiceCallHistory/VoiceCallHistoryModel.php b/application/VoiceCallHistory/VoiceCallHistoryModel.php index f9bbfc146..b86d43cd1 100644 --- a/application/VoiceCallHistory/VoiceCallHistoryModel.php +++ b/application/VoiceCallHistory/VoiceCallHistoryModel.php @@ -8,7 +8,6 @@ class VoiceCallHistoryModel { public $billable; public $duration; - public function __construct($data = []) { foreach ($data as $field => $value) { if (property_exists(get_called_class(), $field)) { @@ -58,7 +57,14 @@ class VoiceCallHistoryModel { public static function importVoiceCallHistory($callHistory): array { $db = FronkDB::singleton(); - $sql = /** @lang text */ "INSERT INTO `VoiceCallHistory` (`uid`, `voice_account`, `start`, `source`, `destination`, `state`, `billable`, `duration`) VALUES "; + $me = mfValuecache::singleton()->get("me"); + if(!$me) { + $me = new User(); + $me->loadMe(); + mfValuecache::singleton()->set("me", $me); + } + + $sql = /** @lang text */ "INSERT INTO `VoiceCallHistory` (`uid`, `voice_account`, `start`, `source`, `destination`, `state`, `billable`, `duration`, `create_by`, `edit_by`, `create`, `edit`) VALUES "; $values = []; foreach ($callHistory as $voiceCall) { $uid = $voiceCall['uid']; @@ -70,7 +76,12 @@ class VoiceCallHistoryModel { ($voiceCall['destination'] === 'Anonymous' ? "NULL" : $voiceCall['destination'] ) . "', " . $voiceCall['state'] . ", " . $voiceCall['billable'] . ", " . - $voiceCall['duration'] . ")"; + $voiceCall['duration'] . ", ". + + $me->id . ", ". + $me->id . ", ". + date("U") . ", ". + date("U") . ")"; $values[] = $valueStr; } diff --git a/db/migrations/20240704184126_voicecallhistory_add_contract_id.php b/db/migrations/20240704184126_voicecallhistory_add_contract_id.php new file mode 100644 index 000000000..b22117fb4 --- /dev/null +++ b/db/migrations/20240704184126_voicecallhistory_add_contract_id.php @@ -0,0 +1,54 @@ +getEnvironment() == "thetool") { + $table = $this->table("VoiceCallHistory"); + $table->addColumn("contract_id", "integer", ["null" => true, "default" => null, "after" => "voice_account"]); + $table->addIndex("contract_id"); + + $table->addColumn("create_by", "integer", ["null" => false, "default" => 1]); + $table->addColumn("edit_by", "integer", ["null" => false, "default" => 1]); + $table->addColumn("create", "integer", ["null" => false, "default" => 0]); + $table->addColumn("edit", "integer", ["null" => false, "default" => 0]); + + $table->update(); + + $table->changeColumn("create_by", "integer", ["null" => false]); + $table->changeColumn("edit_by", "integer", ["null" => false]); + $table->changeColumn("create", "integer", ["null" => false]); + $table->changeColumn("edit", "integer", ["null" => false]); + + $table->update(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } + + public function down(): void + { + if($this->getEnvironment() == "thetool") { + $table = $this->table("VoiceCallHistory"); + + $table->removeColumn("contract_id"); + $table->removeColumn("create_by"); + $table->removeColumn("edit_by"); + $table->removeColumn("create"); + $table->removeColumn("edit"); + + $table->update(); + + } + + if($this->getEnvironment() == "addressdb") { + + } + } +}