Skip to content

#601 [EventPro] fix: use dictionary refusal reason as closure event title - #764

Open
evarisk-kilyan wants to merge 1 commit into
Eoxia:developfrom
evarisk-kilyan:fix/601-refusal-reason-from-dico
Open

evarisk-kilyan wants to merge 1 commit into
Eoxia:developfrom
evarisk-kilyan:fix/601-refusal-reason-from-dico

Conversation

@evarisk-kilyan

Copy link
Copy Markdown
Contributor

Contexte

Fixes #601

À la clôture d'une opportunité en Perdu, le widget imposait de choisir une raison dans le dictionnaire ET de la ré-écrire dans un champ texte libre (obligatoire). La raison du dico n'était stockée que dans l'extrafield opprefusal et n'apparaissait jamais dans le libellé de l'event de clôture.

Correctif fonctionnel

  • Commentaire optionnel : sélectionner une raison dans la liste suffit pour enregistrer (actions_reedcrm.class.php — validation + placeholders).
  • Libellé de l'event = raison du dictionnaire : PJ… - Clôturé - <raison du dico>.
  • Le manuscrit (si saisi) va en description de l'event (note_private), plus dans le titre.

Nettoyage $sql → fonctions natives Dolibarr (ajax/close_record.php)

Avant (SQL à la main) Après (natif)
SELECT … c_lead_status WHERE code=… dol_getIdFromCode($db, $statusStr, 'c_lead_status', 'code', 'rowid')
SELECT … c_refusal_reason WHERE rowid=… getDictionaryValue('c_refusal_reason', 'ref'/'label', …)
SELECT id FROM actioncomm … + UPDATE actioncomm SET label … ActionComm::getActions() + $event->update($user)
INSERT … actioncomm_extrafields … $actioncomm->array_options['options_reedcrm_status_object'] (persisté par create())
UPDATE projet_extrafields SET opprefusal … (failsafe redondant) supprimé (insertExtraFields() le fait déjà)

Bénéfices : escaping/entité gérés, triggers déclenchés, cache dico, code plus court.

Notes

  • Le note_private reçoit $comment (lu en GETPOST(..., 'alpha')). Comme il devient une vraie description, on pourrait passer à 'restricthtml' pour préserver ponctuation/accents — laissé tel quel ici (hors périmètre), à voir en suivi.
  • Le flux reopen (L41) garde sa requête JOIN sur actioncomm_extrafields (migration plus risquée, hors périmètre de cette PR).

Test

  1. Ouvrir une opportunité, cliquer 😭 Perdu, choisir une raison dans la liste sans rien taper → le bouton enregistrer s'active.
  2. Enregistrer → l'event s'appelle PJ… - Clôturé - <raison choisie>.
  3. Avec une précision manuscrite → elle apparaît dans la description de l'event (pas le titre).

…ent title

When closing an opportunity as lost, the user had to BOTH pick a refusal
reason from the dictionary AND retype it in a mandatory free-text field. The
dictionary reason was only stored in the opprefusal extrafield, never used for
the closure event label.

- Free comment is now optional: selecting a dictionary reason is enough to save.
- The actioncomm label is built from the dictionary reason (c_refusal_reason);
  the handwritten comment now goes to the event description (note_private).
- Replace hand-written SQL with native Dolibarr helpers: dol_getIdFromCode
  (c_lead_status), getDictionaryValue (c_refusal_reason), ActionComm::getActions
  + ->update($user), and extrafields via array_options/insertExtraFields. Drop
  the redundant raw projet_extrafields UPDATE.

Fixes Eoxia#601

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants