Skip to content
Snippets Groups Projects
Commit c1742415 authored by jaapjansma's avatar jaapjansma
Browse files

update after integration with form builder

parent 4c00db76
No related branches found
No related tags found
No related merge requests found
......@@ -24,12 +24,12 @@ class CRM_Documents_BAO_Document extends CRM_Documents_DAO_Document {
if (empty($record['added_by'])) {
$record['added_by'] = CRM_Core_Session::getLoggedInContactID();
}
if (empty($record['date_updated'])) {
$record['date_updated'] = date('Ymd');
}
if (empty($record['updated_by'])) {
$record['updated_by'] = CRM_Core_Session::getLoggedInContactID();
}
}
if (empty($record['date_updated'])) {
$record['date_updated'] = date('Ymd');
}
if (empty($record['updated_by'])) {
$record['updated_by'] = CRM_Core_Session::getLoggedInContactID();
}
$instance = parent::writeRecord($record);
if (!empty($record['case_id'])) {
......@@ -52,9 +52,14 @@ class CRM_Documents_BAO_Document extends CRM_Documents_DAO_Document {
try {
$documentsRepo = CRM_Documents_Entity_DocumentRepository::singleton();
$id = $instance->id;
$contactId = $record['contact_id'];
$document = $documentsRepo->getDocumentById($id);
$document->addContactId($contactId);
if (is_array($record['contact_id'])) {
foreach ($record['contact_id'] as $contactId) {
$document->addContactId($contactId);
}
} else {
$document->addContactId($record['contact_id']);
}
$documentsRepo->persistContacts($document);
$documentsRepo->flush();
} catch (\Throwable $e) {
......
......@@ -23,4 +23,27 @@ class CRM_Documents_BAO_DocumentVersion extends CRM_Documents_DAO_DocumentVersio
return $instance;
} */
/**
* Create or update a record from supplied params.
*
* If 'id' is supplied, an existing record will be updated
* Otherwise a new record will be created.
*
* @param array $record
*
* @return static
* @throws \CRM_Core_Exception
*/
public static function writeRecord(array $record): CRM_Documents_DAO_DocumentVersion
{
if (empty($record['date_updated'])) {
$record['date_updated'] = date('Ymd');
}
if (empty($record['updated_by'])) {
$record['updated_by'] = CRM_Core_Session::getLoggedInContactID();
}
$instance = parent::writeRecord($record);
return $instance;
}
}
......@@ -49,6 +49,8 @@ class DocumentCreateSpecProvider extends AutoService implements SpecProviderInte
->setInputType('EntityRef')
->setType('Extra')
->setFkEntity('Contact')
->setInputAttrs(['multiple' => TRUE])
->setSerialize(\CRM_Core_DAO::SERIALIZE_COMMA)
->setReadonly(FALSE)
;
$spec->addFieldSpec($field);
......
......@@ -14,8 +14,8 @@
<url desc="Support">http://civicoop.org</url>
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2025-03-17</releaseDate>
<version>1.30</version>
<releaseDate>2025-03-18</releaseDate>
<version>1.31</version>
<develStage>stable</develStage>
<compatibility>
<ver>5.69</ver>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment