Function Show-Journal {
param(
[string]$police,
[string]$client,
[string]$userName
)
$journalData = Get-JournalData
# --- CONFIGURATION FENÊTRE (Équilibre Confort/Espace) ---
$jouForm = New-Object System.Windows.Forms.Form
$jouForm.Text = "Terminal Journal de Recouvrement - Star Assurance"
$jouForm.Size = New-Object System.Drawing.Size(720, 780)
$jouForm.BackColor = [System.Drawing.Color]::FromArgb(15, 15, 20)
$jouForm.StartPosition = "CenterParent"
$jouForm.FormBorderStyle = "FixedDialog"
$jouForm.MaximizeBox = $false
$jouForm.AutoScaleMode = [System.Windows.Forms.AutoScaleMode]::Dpi
# --- HEADER HUD ---
$panelHeader = New-Object System.Windows.Forms.Panel
$panelHeader.SetBounds(0, 0, 720, 95)
$panelHeader.BackColor = [System.Drawing.Color]::FromArgb(25, 30, 45)
$jouForm.Controls.Add($panelHeader)
$lblTitle = New-Object System.Windows.Forms.Label
$lblTitle.Text = "AUDIT RECOUVREMENT"
$lblTitle.SetBounds(25, 15, 400, 30)
$lblTitle.ForeColor = [System.Drawing.Color]::LimeGreen
$lblTitle.Font = New-Object System.Drawing.Font("Segoe UI", 16, [System.Drawing.FontStyle]::Bold)
$panelHeader.Controls.Add($lblTitle)
$lblTimer = New-Object System.Windows.Forms.Label
$lblTimer.SetBounds(530, 20, 140, 25)
$lblTimer.ForeColor = [System.Drawing.Color]::Cyan
$lblTimer.Font = New-Object System.Drawing.Font("Consolas", 12, [System.Drawing.FontStyle]::Bold)
$lblTimer.TextAlign = "MiddleRight"
$panelHeader.Controls.Add($lblTimer)
$timer = New-Object System.Windows.Forms.Timer
$timer.Interval = 1000
$timer.add_Tick({ $lblTimer.Text = (Get-Date).ToString("HH:mm:ss") })
$timer.Start()
$lblInfo = New-Object System.Windows.Forms.Label
$lblInfo.Text = "CLIENT : $($client.ToUpper()) | POLICE : $police"
$lblInfo.SetBounds(27, 55, 650, 25)
$lblInfo.ForeColor = [System.Drawing.Color]::FromArgb(200, 200, 200)
$lblInfo.Font = New-Object System.Drawing.Font("Consolas", 10, [System.Drawing.FontStyle]::Bold)
$panelHeader.Controls.Add($lblInfo)
# --- RECHERCHE ---
$txtSearch = New-Object System.Windows.Forms.TextBox
$txtSearch.SetBounds(455, 105, 210, 25)
$txtSearch.BackColor = [System.Drawing.Color]::FromArgb(30, 35, 50)
$txtSearch.ForeColor = [System.Drawing.Color]::Gray
$txtSearch.Text = "🔍 Filtrer l'historique..."
$txtSearch.BorderStyle = [System.Windows.Forms.BorderStyle]::FixedSingle
$jouForm.Controls.Add($txtSearch)
# --- LOGS (Taille de texte agrandie) ---
$logDisplay = New-Object System.Windows.Forms.RichTextBox
$logDisplay.SetBounds(25, 140, 655, 240)
$logDisplay.BackColor = [System.Drawing.Color]::FromArgb(20, 25, 35)
$logDisplay.ForeColor = [System.Drawing.Color]::White
$logDisplay.Font = New-Object System.Drawing.Font("Consolas", 11) # Agrandi
$logDisplay.ReadOnly = $true
$logDisplay.BorderStyle = [System.Windows.Forms.BorderStyle]::None
$jouForm.Controls.Add($logDisplay)
function Update-Display ($filter = "") {
$logDisplay.ReadOnly = $false
$logDisplay.Clear()
$notes = if ($journalData.PSObject.Properties[$police]) { @($journalData."$police") } else { @() }
foreach ($n in $notes) {
if ($filter -eq "" -or $filter -eq "🔍 Filtrer l'historique..." -or $n -like "*$filter*") {
if ($n -match "\[(.*?)\] \[(.*?)\] ⚡ (.*)") {
$logDisplay.SelectionColor = [System.Drawing.Color]::Cyan
$logDisplay.AppendText("[$($matches[1])] ")
$logDisplay.SelectionColor = [System.Drawing.Color]::LimeGreen
$logDisplay.AppendText("($($matches[2])) ")
$logDisplay.SelectionColor = [System.Drawing.Color]::White
$logDisplay.AppendText("» $($matches[3])`n" + ("-" * 50) + "`n")
}
}
}
$logDisplay.ReadOnly = $true
}
$txtSearch.Add_GotFocus({ if($this.Text -eq "🔍 Filtrer l'historique...") { $this.Text = ""; $this.ForeColor = [System.Drawing.Color]::White } })
$txtSearch.Add_TextChanged({ Update-Display $this.Text })
# --- ACTIONS RAPIDES ---
$flowButtons = New-Object System.Windows.Forms.FlowLayoutPanel
$flowButtons.SetBounds(25, 395, 655, 40)
$jouForm.Controls.Add($flowButtons)
$actions = @("📞 APPEL", "📵 ABSENT", "✉️ SMS", "💰 PROMESSE", "⚖️ CONTENTIEUX")
foreach ($act in $actions) {
$btnAct = New-Object System.Windows.Forms.Button
$btnAct.Text = $act
$btnAct.AutoSize = $true
$btnAct.FlatStyle = "Flat"
$btnAct.ForeColor = [System.Drawing.Color]::Cyan
$btnAct.Font = New-Object System.Drawing.Font("Segoe UI", 9, [System.Drawing.FontStyle]::Bold)
$btnAct.Add_Click({ $txtNote.Text = "$($this.Text) : " + $txtNote.Text; $txtNote.Focus() })
$flowButtons.Controls.Add($btnAct)
}
# --- ZONE DE SAISIE (AGRANDIE AVEC PLACEHOLDER) ---
$lblNoteTitle = New-Object System.Windows.Forms.Label
$lblNoteTitle.Text = "SAISIE DE L'ACTION :"
$lblNoteTitle.SetBounds(25, 445, 300, 20)
$lblNoteTitle.ForeColor = [System.Drawing.Color]::LimeGreen
$lblNoteTitle.Font = New-Object System.Drawing.Font("Segoe UI", 10, [System.Drawing.FontStyle]::Bold)
$jouForm.Controls.Add($lblNoteTitle)
$txtNote = New-Object System.Windows.Forms.TextBox
$txtNote.Multiline = $true
$txtNote.SetBounds(25, 470, 655, 110) # Zone agrandie
$txtNote.BackColor = [System.Drawing.Color]::FromArgb(40, 45, 60)
$txtNote.ForeColor = [System.Drawing.Color]::Gray
$placeholderNote = "Décrivez ici l'action menée (ex: Rappel client pour impayé)..."
$txtNote.Text = $placeholderNote
$txtNote.Font = New-Object System.Drawing.Font("Segoe UI", 12) # Caractères agrandis
$jouForm.Controls.Add($txtNote)
$txtNote.Add_GotFocus({ if($this.Text -eq $placeholderNote) { $this.Text = ""; $this.ForeColor = [System.Drawing.Color]::White } })
$txtNote.Add_LostFocus({ if($this.Text -eq "") { $this.Text = $placeholderNote; $this.ForeColor = [System.Drawing.Color]::Gray } })
$txtNote.Add_KeyDown({ if ($_.Control -and $_.KeyCode -eq [System.Windows.Forms.Keys]::Enter) { $btnAddNote.PerformClick() } })
# --- BOUTON VALIDER (PLUS GRAND ET EN BAS) ---
$btnAddNote = New-Object System.Windows.Forms.Button
$btnAddNote.Text = "VALIDER ET ARCHIVER (Ctrl+Enter)"
$btnAddNote.SetBounds(25, 600, 655, 65) # Bouton imposant
$btnAddNote.FlatStyle = "Flat"
$btnAddNote.FlatAppearance.BorderSize = 2
$btnAddNote.FlatAppearance.BorderColor = [System.Drawing.Color]::LimeGreen
$btnAddNote.ForeColor = [System.Drawing.Color]::White
$btnAddNote.BackColor = [System.Drawing.Color]::FromArgb(30, 60, 30)
$btnAddNote.Font = New-Object System.Drawing.Font("Segoe UI", 14, [System.Drawing.FontStyle]::Bold)
$btnAddNote.Cursor = [System.Windows.Forms.Cursors]::Hand
$btnAddNote.Add_MouseEnter({ $this.BackColor = [System.Drawing.Color]::LimeGreen; $this.ForeColor = [System.Drawing.Color]::Black })
$btnAddNote.Add_MouseLeave({ $this.BackColor = [System.Drawing.Color]::FromArgb(30, 60, 30); $this.ForeColor = [System.Drawing.Color]::White })
$jouForm.Controls.Add($btnAddNote)
$btnAddNote.Add_Click({
if ($txtNote.Text.Trim() -ne "" -and $txtNote.Text -ne $placeholderNote) {
$ts = Get-Date -Format "dd/MM HH:mm"
$nouvelleNote = "[$ts] [$userName] ⚡ $($txtNote.Text.Replace('"',"'"))"
$notesExistantes = if ($journalData.PSObject.Properties[$police]) { @($journalData."$police") } else { @() }
$nouveauTableau = @($nouvelleNote) + $notesExistantes
$journalData | Add-Member -MemberType NoteProperty -Name $police -Value $nouveauTableau -Force
Save-JournalData -data $journalData
Update-Display
$txtNote.Text = $placeholderNote
$txtNote.ForeColor = [System.Drawing.Color]::Gray
}
})
Update-Display
$jouForm.ShowDialog()
$timer.Stop()
}