diff --git a/CRM/Core/BAO/Note.php b/CRM/Core/BAO/Note.php index c93215d23520..d63d8dea2713 100644 --- a/CRM/Core/BAO/Note.php +++ b/CRM/Core/BAO/Note.php @@ -477,6 +477,7 @@ private static function buildNoteTree($parentId, $maxDepth = 0, $snippet = FALSE $contact->fetch(); $tree[$note->id]['createdBy'] = $contact->display_name; $tree[$note->id]['createdById'] = $createdById; + $tree[$note->id]['note_date'] = CRM_Utils_Date::customFormat($tree[$note->id]['note_date']); $tree[$note->id]['modified_date'] = CRM_Utils_Date::customFormat($tree[$note->id]['modified_date']); // paper icon view for attachments part diff --git a/CRM/Core/DAO/Note.php b/CRM/Core/DAO/Note.php index b1cbbac5fc0f..8d933d0e5f6d 100644 --- a/CRM/Core/DAO/Note.php +++ b/CRM/Core/DAO/Note.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Core/Note.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:769d2ecb72a576a60f8a83940ab4c995) + * (GenCodeChecksum:376337f58ebba7da3702cdc9b14f4220) */ /** @@ -72,6 +72,20 @@ class CRM_Core_DAO_Note extends CRM_Core_DAO { */ public $contact_id; + /** + * Date attached to the note. + * + * @var timestamp + */ + public $note_date; + + /** + * When the note was created. + * + * @var timestamp + */ + public $created_date; + /** * When was this note last modified/edited * @@ -220,11 +234,43 @@ public static function &fields() { ], 'add' => '1.1', ], + 'note_date' => [ + 'name' => 'note_date', + 'type' => CRM_Utils_Type::T_TIMESTAMP, + 'title' => ts('Note Date'), + 'description' => ts('Date attached to the note.'), + 'where' => 'civicrm_note.note_date', + 'default' => 'CURRENT_TIMESTAMP', + 'table_name' => 'civicrm_note', + 'entity' => 'Note', + 'bao' => 'CRM_Core_BAO_Note', + 'localizable' => 0, + 'html' => [ + 'type' => 'Select Date', + 'formatType' => 'activityDateTime', + ], + 'add' => '5.36', + ], + 'created_date' => [ + 'name' => 'created_date', + 'type' => CRM_Utils_Type::T_TIMESTAMP, + 'title' => ts('Created Date'), + 'description' => ts('When the note was created.'), + 'required' => TRUE, + 'where' => 'civicrm_note.created_date', + 'default' => 'CURRENT_TIMESTAMP', + 'table_name' => 'civicrm_note', + 'entity' => 'Note', + 'bao' => 'CRM_Core_BAO_Note', + 'localizable' => 0, + 'add' => '5.36', + ], 'modified_date' => [ 'name' => 'modified_date', 'type' => CRM_Utils_Type::T_TIMESTAMP, - 'title' => ts('Note Modified By'), + 'title' => ts('Modified Date'), 'description' => ts('When was this note last modified/edited'), + 'required' => TRUE, 'where' => 'civicrm_note.modified_date', 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', 'table_name' => 'civicrm_note', diff --git a/CRM/Note/Form/Note.php b/CRM/Note/Form/Note.php index 574bb9ecebb3..2104fd32459d 100644 --- a/CRM/Note/Form/Note.php +++ b/CRM/Note/Form/Note.php @@ -130,6 +130,7 @@ public function buildQuickForm() { } $this->addField('subject'); + $this->addField('note_date', [], FALSE, FALSE); $this->addField('note', [], TRUE); $this->addField('privacy'); $this->add('hidden', 'parent_id'); diff --git a/CRM/Upgrade/Incremental/php/FiveThirtySeven.php b/CRM/Upgrade/Incremental/php/FiveThirtySeven.php index bad13a5b51dd..539a8d761306 100644 --- a/CRM/Upgrade/Incremental/php/FiveThirtySeven.php +++ b/CRM/Upgrade/Incremental/php/FiveThirtySeven.php @@ -52,21 +52,29 @@ public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) { * (change the x in the function name): */ - // /** - // * Upgrade function. - // * - // * @param string $rev - // */ - // public function upgrade_5_0_x($rev) { - // $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); - // $this->addTask('Do the foo change', 'taskFoo', ...); - // // Additional tasks here... - // // Note: do not use ts() in the addTask description because it adds unnecessary strings to transifex. - // // The above is an exception because 'Upgrade DB to %1: SQL' is generic & reusable. - // } + /** + * Upgrade function. + * + * @param string $rev + */ + public function upgrade_5_37_alpha1($rev) { + $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); + $this->addTask('core-issue#2243 - Add note_date to civicrm_note', 'addColumn', + 'civicrm_note', 'note_date', "timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Date attached to the note'"); + $this->addTask('core-issue#2243 - Add created_date to civicrm_note', 'addColumn', + 'civicrm_note', 'created_date', "timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'When the note was created'"); + + $this->addTask('core-issue#2243 - Update existing note_date and created_date', 'updateNoteDates'); + } - // public static function taskFoo(CRM_Queue_TaskContext $ctx, ...) { - // return TRUE; - // } + /** + * @param \CRM_Queue_TaskContext $ctx + * + * @return bool + */ + public static function updateNoteDates(CRM_Queue_TaskContext $ctx): bool { + CRM_Core_DAO::executeQuery("UPDATE civicrm_note SET note_date = modified_date, created_date = modified_date, modified_date = modified_date"); + return TRUE; + } } diff --git a/templates/CRM/Contact/Page/View/Note.tpl b/templates/CRM/Contact/Page/View/Note.tpl index 8cdf82cfd7a0..c35f0d2ad38a 100644 --- a/templates/CRM/Contact/Page/View/Note.tpl +++ b/templates/CRM/Contact/Page/View/Note.tpl @@ -13,7 +13,8 @@
{ts}Subject{/ts} | {$note.subject} | ||
{ts}Date:{/ts} | {$note.modified_date|crmDate} | ||
{ts}Date:{/ts} | {$note.note_date|crmDate} | ||
{ts}Modified Date:{/ts} | {$note.modified_date|crmDate} | ||
{ts}Privacy:{/ts} | {$note.privacy} | ||
{ts}Note:{/ts} | {$note.note|nl2br} | ||
{ts}Comment{/ts} | {ts}Created By{/ts} | {ts}Date{/ts} | |
---|---|---|---|
{$comment.note} | {$comment.createdBy} | {$comment.modified_date} | |
{$comment.note} | {$comment.createdBy} | {$comment.note_date} | {$comment.modified_date} |