JFIF $ d d 7 * Z qn )ZP 0 !1 A "#a$2Qr D8 a Ri [f \m I ykI w0 c u F c Rı?lO7 к _f˓ [C $殷WF< _W ԣ s Kc ëI zyQy /_LK ℂ ;C",p F A : /] =H ~ , l s / 9 ć: [=/#f ; ) x { ٛE Q )~ = 𘙲r*2~ a _V = ' ku m F D } KYYC )( { * g& f `툪 r y ` = ^ c J. I ]( * `wq 1dđ #̩ ͑ 0 ; H ] u 搂 @:~ ו K L N s h } O I R* 8 :2 ! lD JV o ( 3 = M ( z Ȱ+i *N A r6K n S l ) ! J J Ӂ* % ݉?|D } d5: eP0 R; {$X' x F @ .ÊB {,WJ uQ ɲRI ;9 Q E琯 6 2fT .DU J ;*c P A\IL Nj! J ۱+ O\ ͔ ] ޒ S J ȧ c%A N ol ՎprU L Zԛe r E2= X D Xg VQeӓ k y P7 U* o m Q I s ,K `) 6\G3t?pgjr m ۛجw luGt f h 9uyP 0D;Uڽ"OXl i f $ ) &|ML 0 Z rm1 [ H XP l P R0 'G=i 2N +0 e 2 ]] 9 VT P O 7 h(F * 癈 ' = Q VZD F,d ߬ ~ T X G[ `le 69C R(!S2! P < 0 x < !1AQ "Raq 02Br #S CTb ? Ζ "]mH5WR 7 k.ۛ ! } Q~ + yԏ z |@ T20 S~ K e k *zF f^2X *( @ 8 r ? C I uI|֓>^Ex LgNU Y+{.R Ѫ τV YT D I 6 2 '8Y2 7'\T P.6 d &˦ @V q i |8 -O Ε ] ʔ U= T L 8= ;6c | !qfF3 a ů& ~$ l} 'NW U s$U k^S V : U#6w + +s &r+n ڐ { @ 29gL u " T Ù M=6 (^ "7 r}=6Yݾ lC u hquymp Ǧ G jhs ǜNl ɻ} o 7 #S6 a w 4 ! OS r D 5 7 % | ?x> L | / nD 6?/8 w # [ ) L 7 +6〼T A T g ! %5 Mm Z /c -{1_Je "| ^$ 'O & ޱմ < H vNqϡQ$ < 6 &Nݛ ֨tǻN (9 n ru~'όN sMG& ,uH Kw *Ī 5@ u6 BԒ i YN * f 0 _ GhKW u lT <nj- 0{ M L~ | /a v\ E = ?1 \ɟuq Ђ Y O a K ޡP q $ H8o Q˼EV ~ k 0 h' L Pp M -M" m^ !6l nմ 쮝C U T . ! :vMǨb h ډ Vc r @~p # !1QAa q ? AL0L x LU 4 d ; x " 16ad0 7.\ߋ 0 = P l v/ " c A Ay A|2pO8"d MV #1] = \ " ˡ ] k v I9 d ۓ & q ) ǐq E ꞅ v "P )q X &Q З non]я u ג./ ; gZ$ M QР 2M ]h ni 0 P $ێ 3CɏGjώy : m c # S_ l@ '_ \m|C 2`K _ 1 cIvGc $? PCQ S+D ? K aײ k Fr b 8 ύ NEدg ĝ U 3 6 #Ik+ v { v i ( ވ ? a e) X xy/*@Q Ǽ Ծ ) $ IWO l c G; !i k{ gOŀ L ('x T rb $ w) R $ & N1E td U3Uȉ1p M"N* (DNy d96.(jQ) X 5 c QɎMy W ? Q *!R > 6=7)Xj 5`J ] e 8%t ! + ' ! 1Q 5 !1 AQaq ё #2 "0BRb ? G t^ ## .l lQ T $ v , ,m 㵜5u bV =sY+ @d { N ! dn O < .- B; _w J t 6;Q Jd. Q c%p{ 1 ,sND dF H I0 Гo X ш e黅X ۢ F :)[ F G X ƹ / w _c MeD ,ʡc c . W D tA $ j@ : ) - #u c1< @ۗ9F ) KJ- hpP] _ x [ q B lb p ʖ w q " LFGd ƶ * s +ډ_Zc " ? % t[I P 6 J ]# =ɺ V v v CGs Gh1 > )6 |e y ? L ӣ m,4 G W Ui ` ] uJVo VDG< SB 6ϏQ @ TiU l y O U 0 kfV ~ ~}S Z @ *WU Ui ## ; s /[ = ! 7}" W N ] ' (L ! ~ y5 g9T̅J kbM' +s :S +B) v @ M j e C f j E 0 Y\Qn z G 1 д~ W o{T 9?` Rm yhsy3 !HAD ] m c1 ~ 2 L S u7x T ;j$ `} 4-> L# vzŏ I L S ֭ T { r jGK C ; b pU= - ` Bs K. S F w4 M q] Z dH S 0 ) tLg
<div class="crm-main">
<div class="crm-emails-header">
<h1>Boite mail</h1>
<div class="crm-emails-actions">
<button class="button crm-btn-compose-email">Nouveau mail</button>
<a href="index.php?page=boite-mail&action=sync" class="crm-btn">Actualiser</a>
</div>
</div>
<div class="crm-emails-tabs">
<button class="crm-emails-tab active" data-tab="reception" data-label="Réception">Réception</button>
<button class="crm-emails-tab" data-tab="envoi" data-label="Envoi">Envoi</button>
<button class="crm-emails-tab" data-tab="brouillons" data-label="Brouillons">Brouillons</button>
<button class="crm-emails-tab" data-tab="corbeille" data-label="Corbeille">Corbeille</button>
</div>
<?php if (isset($_GET['mail_message'])): ?>
<div style="margin:10px 0 16px 0;padding:8px 12px;border-radius:8px;background:<?= (($_GET['mail_status'] ?? '') === 'success') ? '#e8f7ee' : '#fdecec' ?>;color:<?= (($_GET['mail_status'] ?? '') === 'success') ? '#186a3b' : '#b42318' ?>;font-weight:600;">
<?= htmlspecialchars((string) $_GET['mail_message']) ?>
</div>
<?php endif; ?>
<?php
$formatMailboxDate = static function ($rawDate): string {
$timestamp = strtotime((string) $rawDate);
if ($timestamp === false) {
$timestamp = time();
}
$today = date('Y-m-d');
$targetDay = date('Y-m-d', $timestamp);
if ($targetDay === $today) {
return date('H:i', $timestamp);
}
$yesterday = date('Y-m-d', strtotime('-1 day'));
if ($targetDay === $yesterday) {
return 'Hier';
}
$dayDiff = (int) floor((strtotime($today . ' 00:00:00') - strtotime($targetDay . ' 00:00:00')) / 86400);
if ($dayDiff >= 0 && $dayDiff < 7) {
$dayMap = [
'Mon' => 'Lun',
'Tue' => 'Mar',
'Wed' => 'Mer',
'Thu' => 'Jeu',
'Fri' => 'Ven',
'Sat' => 'Sam',
'Sun' => 'Dim',
];
$dayKey = date('D', $timestamp);
return $dayMap[$dayKey] ?? date('d/m', $timestamp);
}
return date('d/m/Y', $timestamp);
};
?>
<style>
.crm-emails-split {
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
gap: 14px;
align-items: start;
}
.crm-emails-split .crm-emails-lists {
min-width: 0;
background: #fff;
border: 1px solid #e5e7eb;
border-radius: 10px;
padding: 0;
max-height: 78vh;
overflow: auto;
}
.crm-emails-list h2 {
margin: 0;
padding: 12px 14px 10px 14px;
font-size: 1.02em;
border-bottom: 1px solid #edf2f7;
position: sticky;
top: 0;
background: #fff;
z-index: 1;
}
.crm-email-conversation-list {
display: flex;
flex-direction: column;
}
.crm-email-row {
display: block;
border-bottom: 1px solid #f1f5f9;
padding: 9px 12px;
cursor: pointer;
}
.crm-email-row:hover {
background: #f8fbff;
}
.crm-email-row-top {
display: flex;
align-items: center;
gap: 8px;
}
.crm-email-sender {
min-width: 0;
flex: 1;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
color: #111827;
font-weight: 600;
}
.crm-email-row-unread .crm-email-sender {
font-weight: 700;
}
.crm-email-row-date {
white-space: nowrap;
color: #6b7280;
font-size: 0.85em;
margin-left: auto;
}
.crm-email-attachment-dot {
color: #2563eb;
font-size: 0.9em;
}
.crm-email-subject-line {
display: flex;
align-items: center;
gap: 6px;
font-weight: 700;
color: #111827;
margin-top: 2px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.crm-email-row-read .crm-email-subject-line {
font-weight: 400;
}
.crm-email-snippet {
margin-top: 2px;
font-size: 0.85em;
color: #6b7280;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.crm-email-preview-pane {
background: #fff;
border: 1px solid #e5e7eb;
border-radius: 10px;
padding: 14px;
min-height: 520px;
max-height: 78vh;
overflow: auto;
position: sticky;
top: 10px;
}
.crm-email-preview-placeholder {
color: #6b7280;
font-size: 0.95em;
padding: 12px 4px;
}
.crm-email-row-active {
background: #dbeafe;
box-shadow: inset 3px 0 0 #1769aa;
}
@keyframes crm-row-fadein {
from { opacity: 0; transform: translateY(-6px); background: #e8f7ee; }
to { opacity: 1; transform: translateY(0); background: transparent; }
}
.crm-row-new-fadein {
animation: crm-row-fadein 0.5s ease forwards;
}
@media (max-width: 1100px) {
.crm-emails-split {
grid-template-columns: 1fr;
}
.crm-email-preview-pane {
position: static;
max-height: none;
min-height: 260px;
}
}
</style>
<div class="crm-emails-split">
<div class="crm-emails-lists">
<div class="crm-emails-list crm-emails-list-reception">
<h2>Boîte de réception</h2>
<div class="crm-email-conversation-list">
<?php if (!empty($emailsReception)): ?>
<?php foreach ($emailsReception as $mail): ?>
<?php
$isUnread = (int)($mail['lu'] ?? 0) === 0;
$hasAttachments = !empty($mail['has_attachments']);
$snippet = trim(preg_replace('/\s+/', ' ', strip_tags((string)($mail['corps'] ?? ''))));
if (function_exists('mb_substr')) {
$snippet = mb_substr($snippet, 0, 110, 'UTF-8');
} else {
$snippet = substr($snippet, 0, 110);
}
?>
<div class="crm-email-row<?= $isUnread ? ' crm-email-row-unread' : ' crm-email-row-read' ?>" tabindex="0" data-email-id="<?= (int)($mail['id'] ?? 0) ?>" data-box="reception">
<div class="crm-email-row-top">
<div class="crm-email-sender"><?= htmlspecialchars($mail['expediteur'] ?? '') ?></div>
<div class="crm-email-row-date"><?= htmlspecialchars($formatMailboxDate($mail['date_message'] ?? 'now')) ?></div>
<?php if ($hasAttachments): ?><span class="crm-email-attachment-dot">📎</span><?php endif; ?>
</div>
<div class="crm-email-subject-line"><?= htmlspecialchars($mail['sujet'] ?? '') ?><?= $isUnread ? ' <span class="crm-email-badge-unread">●</span>' : '' ?></div>
<div class="crm-email-snippet"><?= htmlspecialchars($snippet) ?></div>
</div>
<?php endforeach; ?>
<?php else: ?>
<div style="color:#888;padding:12px 14px;">Aucun e-mail reçu</div>
<?php endif; ?>
</div>
</div>
<div class="crm-emails-list crm-emails-list-envoi" style="display:none;">
<h2>Boîte d'envoi</h2>
<div class="crm-email-conversation-list">
<?php if (!empty($emailsEnvoi)): ?>
<?php foreach ($emailsEnvoi as $mail): ?>
<?php
$hasAttachments = !empty($mail['has_attachments']);
$snippet = trim(preg_replace('/\s+/', ' ', strip_tags((string)($mail['corps'] ?? ''))));
if (function_exists('mb_substr')) {
$snippet = mb_substr($snippet, 0, 110, 'UTF-8');
} else {
$snippet = substr($snippet, 0, 110);
}
?>
<div class="crm-email-row crm-email-row-read" tabindex="0" data-email-id="<?= (int)($mail['id'] ?? 0) ?>" data-box="envoi">
<div class="crm-email-row-top">
<div class="crm-email-sender"><?= htmlspecialchars($mail['destinataire'] ?? '') ?></div>
<div class="crm-email-row-date"><?= htmlspecialchars($formatMailboxDate($mail['date_message'] ?? 'now')) ?></div>
<?php if ($hasAttachments): ?><span class="crm-email-attachment-dot">📎</span><?php endif; ?>
</div>
<div class="crm-email-subject-line"><?= htmlspecialchars($mail['sujet'] ?? '') ?></div>
<div class="crm-email-snippet"><?= htmlspecialchars($snippet) ?></div>
</div>
<?php endforeach; ?>
<?php else: ?>
<div style="color:#888;padding:12px 14px;">Aucun e-mail envoyé</div>
<?php endif; ?>
</div>
</div>
<div class="crm-emails-list crm-emails-list-brouillons" style="display:none;">
<h2>Brouillons</h2>
<div class="crm-email-conversation-list">
<?php if (!empty($emailsBrouillons)): ?>
<?php foreach ($emailsBrouillons as $mail): ?>
<?php
$hasAttachments = !empty($mail['has_attachments']);
$snippet = trim(preg_replace('/\s+/', ' ', strip_tags((string)($mail['corps'] ?? ''))));
if (function_exists('mb_substr')) {
$snippet = mb_substr($snippet, 0, 110, 'UTF-8');
} else {
$snippet = substr($snippet, 0, 110);
}
?>
<div class="crm-email-row crm-email-row-read" tabindex="0" data-email-id="<?= (int)($mail['id'] ?? 0) ?>" data-box="brouillons">
<div class="crm-email-row-top">
<div class="crm-email-sender"><?= htmlspecialchars($mail['destinataire'] ?? '') ?></div>
<div class="crm-email-row-date"><?= htmlspecialchars($formatMailboxDate($mail['date_message'] ?? 'now')) ?></div>
<?php if ($hasAttachments): ?><span class="crm-email-attachment-dot">📎</span><?php endif; ?>
</div>
<div class="crm-email-subject-line"><?= htmlspecialchars($mail['sujet'] ?? '') ?></div>
<div class="crm-email-snippet"><?= htmlspecialchars($snippet) ?></div>
</div>
<?php endforeach; ?>
<?php else: ?>
<div style="color:#888;padding:12px 14px;">Aucun brouillon</div>
<?php endif; ?>
</div>
</div>
<div class="crm-emails-list crm-emails-list-corbeille" style="display:none;">
<h2>Corbeille</h2>
<div class="crm-email-conversation-list">
<?php if (!empty($emailsCorbeille)): ?>
<?php foreach ($emailsCorbeille as $mail): ?>
<?php
$hasAttachments = !empty($mail['has_attachments']);
$correspondant = (($mail['type'] ?? 'sent') === 'received')
? ($mail['expediteur'] ?? '')
: ($mail['destinataire'] ?? '');
$snippet = trim(preg_replace('/\s+/', ' ', strip_tags((string)($mail['corps'] ?? ''))));
if (function_exists('mb_substr')) {
$snippet = mb_substr($snippet, 0, 110, 'UTF-8');
} else {
$snippet = substr($snippet, 0, 110);
}
?>
<div class="crm-email-row crm-email-row-read" tabindex="0" data-email-id="<?= (int)($mail['id'] ?? 0) ?>" data-box="corbeille">
<div class="crm-email-row-top">
<div class="crm-email-sender"><?= htmlspecialchars($correspondant) ?></div>
<div class="crm-email-row-date"><?= htmlspecialchars($formatMailboxDate($mail['date_message'] ?? 'now')) ?></div>
<?php if ($hasAttachments): ?><span class="crm-email-attachment-dot">📎</span><?php endif; ?>
</div>
<div class="crm-email-subject-line"><?= htmlspecialchars($mail['sujet'] ?? '') ?></div>
<div class="crm-email-snippet"><?= htmlspecialchars($snippet) ?></div>
</div>
<?php endforeach; ?>
<?php else: ?>
<div style="color:#888;padding:12px 14px;">Corbeille vide</div>
<?php endif; ?>
</div>
</div>
</div>
<div id="crm-email-modal" class="crm-email-preview-pane" data-inline-preview="1">
<div>
<div style="display:flex;align-items:center;gap:8px;margin-bottom:8px;">
<h2 id="crm-email-modal-subject" style="margin:0;font-size:1.05em;flex:1;">Aucun e-mail sélectionné</h2>
</div>
<div style="margin-bottom:8px;display:flex;gap:8px;flex-wrap:wrap;">
<a href="#" id="crm-email-modal-reply" class="button">Répondre</a>
<a href="#" id="crm-email-modal-forward" class="button">Transférer</a>
<a href="#" id="crm-email-modal-toggle-read" class="button" style="background:#e0e0e0;color:#232946;display:none;"></a>
<a href="#" id="crm-email-modal-delete" class="button" style="background:#e74c3c;">Supprimer</a>
</div>
<p><strong>De :</strong> <span id="crm-email-modal-from"></span></p>
<p><strong>À :</strong> <span id="crm-email-modal-to"></span></p>
<p><strong>Date :</strong> <span id="crm-email-modal-date"></span></p>
<div id="crm-email-modal-project-box" style="margin:12px 0 0 0;padding-top:10px;border-top:1px dashed #e5e7eb;">
<label style="display:block;font-size:0.92em;color:#4b5563;">Attacher au projet<br>
<input type="text" id="crm-email-modal-project-search" list="crm-email-modal-project-list" placeholder="Optionnel" style="width:100%;padding:8px;border-radius:5px;border:1px solid #d1d5db;margin-top:4px;">
</label>
<input type="hidden" id="crm-email-modal-project-id" value="">
<datalist id="crm-email-modal-project-list">
<?php foreach (($projectList ?? []) as $projectItem): ?>
<option data-project-id="<?= (int) ($projectItem['id'] ?? 0) ?>" value="#<?= (int) ($projectItem['id'] ?? 0) ?> - <?= htmlspecialchars((string) ($projectItem['titre'] ?? 'Projet')) ?>"></option>
<?php endforeach; ?>
</datalist>
<div style="display:flex;align-items:center;gap:8px;margin-top:8px;flex-wrap:wrap;">
<button type="button" id="crm-email-modal-attach-project" class="button" style="background:#eef6ff;color:#1d4ed8;">Attacher</button>
<span id="crm-email-modal-project-status" style="font-size:0.88em;color:#4b5563;"></span>
</div>
</div>
<hr>
<div id="crm-email-preview-placeholder" class="crm-email-preview-placeholder">Sélectionnez un e-mail dans la liste à gauche pour afficher son aperçu.</div>
<pre id="crm-email-modal-body" style="white-space:pre-wrap;font-family:inherit;display:none;"></pre>
<div id="crm-email-modal-attachments" style="margin-top:12px;"></div>
</div>
</div>
</div>
<style>
#crm-compose-modal {
z-index: 10010;
}
#crm-compose-modal .crm-modal-content {
overflow: visible;
}
.tox-tinymce-aux,
.tox-dialog-wrap,
.tox-menu,
.tox-collection--list,
.tox-silver-sink,
.tox-notifications-container {
z-index: 10030 !important;
}
</style>
<!-- Modale de composition d'e-mail -->
<div id="crm-compose-modal" class="crm-modal" style="display:none;">
<div class="crm-modal-content" style="max-width:750px;width:90%;max-height:80vh;overflow:auto;">
<div style="display:flex;align-items:center;gap:8px;margin-bottom:8px;">
<h2 style="margin:0;font-size:1.05em;flex:1;">Composer un e-mail</h2>
<button type="button" id="crm-compose-modal-close" class="button" style="background:#bdc3c7;color:#232946;">Fermer</button>
</div>
<form method="post" action="index.php?page=boite-mail&action=send" id="crm-compose-form" enctype="multipart/form-data">
<div style="display:flex;gap:12px;margin-bottom:8px;">
<label style="flex:1;">Destinataire<br>
<div style="position:relative;">
<input type="text" name="destinataire" id="crm-compose-to" list="crm-compose-to-directory" inputmode="email" autocomplete="off" style="width:100%;padding:6px 8px;border-radius:5px;border:1px solid #ccc;">
<div id="crm-compose-to-suggestions" style="display:none;position:absolute;top:calc(100% + 4px);left:0;right:0;z-index:2100;background:#fff;border:1px solid #d1d5db;border-radius:8px;box-shadow:0 10px 24px rgba(15,23,42,0.12);overflow:hidden;"></div>
</div>
<datalist id="crm-compose-to-directory">
<?php foreach (($composeRecipients ?? []) as $recipient): ?>
<?php
$recipientEmail = trim((string)($recipient['email'] ?? ''));
if ($recipientEmail === '') {
continue;
}
$recipientMeta = array_filter([
trim((string)($recipient['entreprise'] ?? '')),
trim((string)($recipient['nom'] ?? '')),
]);
?>
<option value="<?= htmlspecialchars($recipientEmail) ?>" label="<?= htmlspecialchars(implode(' - ', $recipientMeta)) ?>"></option>
<?php endforeach; ?>
</datalist>
<div id="crm-compose-docs" style="margin-top:4px;font-size:0.85em;color:#555;"></div>
<div id="crm-compose-facture-disabled" style="display:none;margin-top:6px;padding:8px 10px;border-radius:6px;background:#fff7ed;border:1px solid #fdba74;color:#9a3412;font-size:0.85em;">L'envoi des factures par e-mail est désactivé dans Réglages > E-mails.</div>
</label>
<label style="flex:1;">Sujet<br>
<input type="text" name="sujet" id="crm-compose-subject" style="width:100%;padding:6px 8px;border-radius:5px;border:1px solid #ccc;">
</label>
</div>
<div style="margin-bottom:8px;">
<label>Contenu<br>
<div style="margin-bottom:6px;display:flex;align-items:center;gap:8px;flex-wrap:wrap;">
<select id="crm-compose-font" style="min-width:150px;padding:4px 6px;border-radius:6px;border:1px solid #d1d5db;background:#fff;color:#232946;font-size:0.85em;">
<option value="">Police</option>
<option value="Albert Sans">Albert Sans</option>
<option value="Arial">Arial</option>
<option value="Georgia">Georgia</option>
<option value="Times New Roman">Times New Roman</option>
<option value="Courier New">Courier New</option>
</select>
</div>
<div id="crm-compose-auto-attachment" style="display:none;margin:0 0 8px 0;padding:8px 10px;border-radius:6px;background:#eef6ff;border:1px solid #bfdbfe;color:#1d4ed8;font-size:0.88em;"></div>
<textarea name="corps" id="crm-compose-body" style="width:100%;min-height:260px;padding:6px 8px;border-radius:5px;border:1px solid #ccc;background:#fff;font-family:'Albert Sans',Arial,sans-serif;font-size:0.9em;font-weight:400;white-space:pre-wrap;overflow:auto;"></textarea>
</label>
</div>
<div id="crm-signature-box" style="display:none;margin:8px 0 4px 0;padding:8px 10px;border-radius:6px;background:#f9fafb;border:1px solid #e5e7eb;font-size:0.9em;">
<strong>Signature de devis :</strong><br>
<span style="color:#4b5563;">Si vous joignez un devis suggéré par le champ « mail du Client », un lien de signature et le devis en PDF seront ajoutés automatiquement à l'e-mail.</span>
<div style="margin-top:6px;display:flex;flex-direction:column;gap:4px;">
<span style="font-weight:600;">Options de paiement en ligne proposées au client :</span>
<label style="margin:0;font-weight:normal;"><input type="checkbox" name="signature_allow_bank" value="1" checked> Paiement par virement/chèque</label>
<label style="margin:0;font-weight:normal;"><input type="checkbox" name="signature_allow_online" value="1" checked id="signature-allow-online"> Afficher les options de paiement en ligne</label>
<div id="signature-online-options" style="display:flex;flex-direction:column;gap:4px;padding-left:18px;">
<label style="margin:0;font-weight:normal;"><input type="checkbox" name="signature_allow_acompte_manual" value="1" checked id="signature-allow-acompte-manual"> <span id="signature-acompte-manual-label">Proposer le devis tel que créé avec acompte manuel</span></label>
<label style="margin:0;font-weight:normal;"><input type="checkbox" name="signature_allow_acompte_40" value="1"> Acompte 40% du montant HT</label>
<label style="margin:0;font-weight:normal;"><input type="checkbox" name="signature_allow_full_ht" value="1"> Paiement 100% du montant HT</label>
<div style="display:flex;align-items:center;gap:8px;margin-top:2px;flex-wrap:wrap;">
<label style="margin:0;font-weight:normal;"><input type="checkbox" name="signature_allow_abonnement_auto" value="1"> Abonnement mensuel</label>
<span style="font-size:0.85em;color:#4b5563;">Durée (mois) :</span>
<input type="number" name="signature_subscription_months" value="12" min="1" max="120" style="width:70px;padding:3px 4px;border-radius:4px;border:1px solid #d1d5db;font-size:0.85em;">
</div>
</div>
<span style="font-size:0.8em;color:#6b7280;">Le client choisira lui-même l'option lors de la signature.</span>
</div>
</div>
<div style="margin:8px 0 4px 0;font-size:0.9em;">
<strong>Ajouter pièce(s) jointe(s)</strong><br>
<input type="file" name="attachments[]" multiple>
<span style="display:block;margin-top:2px;color:#6b7280;font-size:0.8em;">Vous pouvez ajouter des fichiers supplémentaires à cet e-mail.</span>
<div id="crm-compose-forward-attachments" style="margin-top:8px;font-size:0.9em;color:#111827;"></div>
</div>
<div style="margin:14px 0 8px 0;padding-top:10px;border-top:1px dashed #e5e7eb;">
<label style="display:block;font-size:0.92em;color:#4b5563;">Ajouter au projet<br>
<input type="text" id="crm-compose-project-search" name="linked_project_label" list="crm-compose-project-list" placeholder="Optionnel" style="width:100%;padding:8px;border-radius:5px;border:1px solid #d1d5db;margin-top:4px;">
</label>
<input type="hidden" name="linked_project_id" id="crm-compose-project-id" value="">
<datalist id="crm-compose-project-list">
<?php foreach (($projectList ?? []) as $projectItem): ?>
<option data-project-id="<?= (int) ($projectItem['id'] ?? 0) ?>" value="#<?= (int) ($projectItem['id'] ?? 0) ?> - <?= htmlspecialchars((string) ($projectItem['titre'] ?? 'Projet')) ?>"></option>
<?php endforeach; ?>
</datalist>
</div>
<input type="hidden" name="attach_devis_id" id="crm-attach-devis-id" value="">
<input type="hidden" name="attach_facture_id" id="crm-attach-facture-id" value="">
<input type="hidden" name="draft_id" id="crm-draft-id" value="">
<div style="text-align:right;margin-top:8px;">
<button type="submit" class="button">Envoyer</button>
<button type="submit" name="save_as_draft" value="1" class="button" style="margin-left:6px;background:#f3f4f6;color:#232946;">Enregistrer le brouillon</button>
</div>
</form>
</div>
</div>
<script>
window.crmComposeTemplates = <?= json_encode($composeTemplates ?? ['devis' => '', 'facture' => ''], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?>;
window.crmFactureEmailEnabled = <?= !empty($factureEmailEnabled) ? 'true' : 'false' ?>;
window.crmOpenEmailId = <?= !empty($openEmailId) ? (int) $openEmailId : '0' ?>;
</script>
<script src="assets/vendor/tinymce/tinymce.min.js"></script>
<script src="assets/js/emails.js"></script>
</div>