Files
html/api/opus5-fix-kaouther-drafts.php
2026-04-17 16:51:29 +02:00

134 lines
6.7 KiB
PHP

<?php
// OPUS5 — Fix Kaouther drafts (email correct + paliers finalises + structure 2 volets)
// Instructed par Opus, exec par WEVIA Master via chat (zero shell manuel)
header('Content-Type: application/json');
$R = ['ts'=>date('c'), 'source'=>'opus5-fix-kaouther-drafts', 'actions'=>[]];
// 1. Backup l'existant avant ecriture (doctrine 59 no-delete)
$F = '/var/www/html/api/kaouther-drafts-status.json';
if (file_exists($F)) {
$BK = $F . '.GOLD-20260417-' . date('His') . '-pre-opus5-fix';
@copy($F, $BK);
$R['actions'][] = "backup_gold: $BK";
}
// 2. Email CORRECT : groupe-ethica.com (pas ethica.ma)
$TO = 'kaouther.najar@groupe-ethica.com';
// CC habituels du thread (9 personnes)
$CC = implode(',', [
'mambrine@weval-consulting.com',
'amal.bouraoui@groupe-ethica.com',
'houda.sassi@groupe-ethica.com',
'fatima.bergha@groupe-ethica.com',
'soumia.boukhamla@groupe-ethica.com',
'oumayma.bouamar@groupe-ethica.com',
'jihen.benbouzid@groupe-ethica.com',
'moez.koubaa@groupe-ethica.com'
]);
// 3. Email FINAL validé par Yacine (version synthétique avec accents + plancher 1,00 DH)
$subject = "Re: Clarification HCP — proposition tarifaire structurée";
$body = "Bonjour Kaouther,\n\n";
$body .= "Merci pour ton retour du 13 avril.\n\n";
$body .= "Comme évoqué le 12 mars, je structure l'offre en deux volets distincts : un investissement one-shot pour la conformité, et un tarif d'envoi récurrent.\n\n\n";
$body .= "1. CONSENTEMENT ETHICA (one-shot)\n\n";
$body .= "45 000 DH forfait 3 pays (60% à la commande, 40% à livraison).\n\n";
$body .= "Inclus : landing dédiée consent.wevup.app, campagne email sur les 146 694 HCPs (base auto-enrichie en continu), traçabilité conforme Loi 09-08 / 63-2004 / 18-07, dashboard live, rapport final par pays et spécialité.\n\n";
$body .= "Résultat : 50 à 65 000 HCPs consentis Ethica, actif réutilisable plusieurs années.\n\n\n";
$body .= "2. CAMPAGNES RÉCURRENTES\n\n";
$body .= "Rappel de notre grille standard (25 février) : 2,15 DH / contact.\n\n";
$body .= "Pour optimiser l'accompagnement d'Ethica, deux formules au choix :\n\n";
$body .= "SPOT (sans engagement)\n";
$body .= "- 1 à 50K contacts/mois : 1,80 DH\n";
$body .= "- 50 à 100K : 1,50 DH\n";
$body .= "- 100K+ : 1,20 DH\n\n";
$body .= "ENGAGEMENT 12 mois — tarif préférentiel\n";
$body .= "- 1,00 DH / contact, tous volumes (-53% vs grille standard)\n";
$body .= "- Priorité planning, account manager dédié, revue KPI mensuelle\n\n";
$body .= "Inclus : infrastructure PMTA souveraine (DKIM 2048, PTR dédié), ciblage par spécialité, tracking open/click/bounce temps réel, dashboard Ethica, gestion opt-out conforme.\n\n";
$body .= "Performance attendue (communiquée le 30 mars) : 28-35% d'ouverture, 4-6% de clic, <2% de rebond.\n\n\n";
$body .= "3. PILOTE DE VALIDATION\n\n";
$body .= "500 HCPs Algérie, 1 brand au choix, dashboard KPI complet, livrable sous 48h.\n";
$body .= "Tarif : 2 500 DH, crédité intégralement sur la 1ère facture mensuelle en cas de signature engagement annuel.\n\n\n";
$body .= "SUR LE TARIF\n\n";
$body .= "Je comprends le benchmark à 0,8 DH / contact. Nous sommes passés de 2,15 DH (grille) à 1,00 DH en engagement annuel, soit un effort significatif pour nous aligner sur votre réalité budgétaire tout en préservant la prestation.\n\n";
$body .= "Aller en-dessous de 1,00 DH impliquerait de retirer la campagne de consentement spécifique — ce que nous ne faisons pas pour nos clients laboratoires, car cela exposerait Ethica à un risque de non-conformité opposable (CNDP, INPDP, ANPDP) sur des finalités promotionnelles.\n\n";
$body .= "L'écart de 0,20 DH / contact avec votre benchmark finance la conformité et la délivrabilité 97%+ inbox. Sur une campagne de 50 000 contacts, cela représente 10 000 DH d'écart mensuel, pour une base consentie auditable et un actif réutilisable.\n\n\n";
$body .= "PROCHAINES ÉTAPES\n\n";
$body .= "Créneaux pour caler ensemble :\n";
$body .= "- Lundi 20 avril 14h (heure TN)\n";
$body .= "- Mardi 21 avril 10h30 (heure TN)\n";
$body .= "- Ou autre créneau à ta convenance\n\n";
$body .= "Bien à toi,\n\n";
$body .= "Yacine MAHBOUB\n";
$body .= "Partner\n";
$body .= "ymahboub@weval-consulting.com\n";
$body .= "+212 6 57 78 52 92 / +33 6 47 08 76 27\n";
$body .= "www.weval-consulting.com";
// 4. Construct Gmail compose URL
$gmail_url = 'https://mail.google.com/mail/u/0/?view=cm&fs=1&tf=cm'
. '&to=' . urlencode($TO)
. '&cc=' . urlencode($CC)
. '&su=' . urlencode($subject)
. '&body=' . urlencode($body);
// 5. Construct mailto fallback
$mailto = 'mailto:' . urlencode($TO)
. '?cc=' . urlencode($CC)
. '&subject=' . urlencode($subject)
. '&body=' . urlencode($body);
// 6. Write NEW drafts status (1 seul draft = version finale synthetique)
$data = [
'created_at' => date('c'),
'updated_by' => 'opus5-session-yacine-17avr-1640',
'status' => 'drafts_generated_final',
'to' => $TO,
'cc' => explode(',', $CC),
'thread_history' => 'Cohérent avec emails 25 fév, 12 mars, 30 mars, 31 mars — no contradiction',
'plancher_prix' => '1,00 DH engagement (plancher ferme, argument conformité CNDP/INPDP/ANPDP)',
'paliers' => [
'spot' => ['1-50K' => 1.80, '50-100K' => 1.50, '100K+' => 1.20],
'engagement_12mois' => 1.00
],
'consentement' => ['forfait' => 45000, 'paiement' => '60% commande / 40% livraison'],
'pilote' => ['dz_500_hcps' => 2500, 'credite_si_signature' => true],
'drafts_count' => 1,
'drafts' => [[
'version' => 'final_synthetique',
'label' => 'Version finale validée Yacine',
'subject' => $subject,
'to' => $TO,
'cc' => $CC,
'gmail_url' => $gmail_url,
'mailto_url' => $mailto,
'body_preview' => substr($body, 0, 300) . '...',
'body_full_length' => strlen($body)
]],
'fix_applied' => [
'email_corrected' => '@groupe-ethica.com (was @ethica.ma)',
'cc_added' => '8 personnes du thread',
'paliers_updated' => '1.80/1.50/1.20 SPOT + 1.00 engagement (was 1.5/1.2/1.0)',
'structure_2_volets' => 'Consentement 45K + Campagnes recurrentes (was 3 tiers simples)',
'verrou_juridique' => 'Section SUR LE TARIF avec argument CNDP/INPDP/ANPDP',
'accents' => 'Tous les accents français corrigés'
]
];
file_put_contents($F, json_encode($data, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES));
$R['actions'][] = "written: $F (" . strlen(file_get_contents($F)) . " bytes)";
$R['email_to'] = $TO;
$R['subject'] = $subject;
$R['body_length'] = strlen($body);
$R['gmail_url_length'] = strlen($gmail_url);
$R['done'] = true;
echo json_encode($R, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);