diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml
index 0f12ebe7c..b8d7aea9e 100644
--- a/.github/workflows/unit-tests.yml
+++ b/.github/workflows/unit-tests.yml
@@ -15,7 +15,7 @@ jobs:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
- operating-system: [ubuntu-latest]
+ operating-system: [ubuntu-20.04]
php-versions: ['7.4', '8.0']
name: Unittest on ${{ matrix.operating-system }} with PHP version ${{ matrix.php-versions }}
steps:
diff --git a/css/admin.css b/css/admin.css
index 609572452..a174431ad 100644
--- a/css/admin.css
+++ b/css/admin.css
@@ -679,6 +679,19 @@ body #post-head-content p.wp-clearfix:nth-child(1) {
margin-left: 5px;
}
+.oo-poststuff .custom-input-field textarea[name=oopluginformactivityconfig-remark] {
+ min-height: 100px;
+}
+
+.oo-poststuff .select2-container--default.select2-container--disabled .select2-selection--multiple {
+ background-color: #f6f7f7;
+ border-color: #dcdcde;
+}
+
+.oo-poststuff .select2-container--default .select2-selection--multiple[aria-disabled="true"] .select2-selection__choice {
+ opacity: 0.5;
+}
+
.oo-search-field {
width: 100%;
float: left;
diff --git a/dist/checkbox.min.js b/dist/checkbox.min.js
index 968c164b2..358afded4 100644
--- a/dist/checkbox.min.js
+++ b/dist/checkbox.min.js
@@ -1 +1 @@
-var onOffice=onOffice||{};onOffice.checkboxAdmin=function(){this._isInitialRun=true;this._configuration={"input[name^=oopluginaddressfieldconfig-filterable]":[{element:"input[name^=oopluginaddressfieldconfig-hidden]",invert:false},{element:"input[name^=oopluginaddressfieldconfig-convertInputTextToSelectForField]",invert:false}],"input[name=oopluginforms-createaddress]":[{element:"input[name=oopluginforms-checkduplicates]",invert:false},{element:"input[name=oopluginforms-newsletter]",invert:false}],"input[name^=oopluginfieldconfig-filterable]":[{element:"input[name^=oopluginfieldconfig-hidden]",invert:false},{element:"input[name^=oopluginfieldconfig-availableOptions]",invert:false},{element:"input[name^=oopluginfieldconfig-convertTextToSelectForCityField]",invert:false}],"input[name=oopluginforms-defaultrecipient]":[{element:"input[name=oopluginforms-recipient]",invert:true}],"input[name^=oopluginformfieldconfig-hiddenfield]":[{element:"input[name^=oopluginformfieldconfig-required]",invert:true}],"input[name^=oopluginformfieldconfig-required]":[{element:"input[name^=oopluginformfieldconfig-hiddenfield]",invert:true}]}};onOffice.checkboxAdmin.prototype.changeCbStatus=function(topElement){var $=jQuery;var instance=this;var toggleChild=function(receivers,mainElement,fromOnChange){for(var i in receivers){var receiver=receivers[i];var receiverElement=mainElement.parent().parent().find(receiver.element);var invert=receiver.invert;if(receiverElement.length){if(mainElement.prop("checked")){if(!invert){receiverElement[0].checked=receiverElement[0].checked||receiver.checkOnActive&&(instance._isInitialRun||fromOnChange);receiverElement.removeAttr("disabled")}else{receiverElement.prop("disabled","disabled");receiverElement.removeAttr("checked")}}else{if(!invert){receiverElement.prop("disabled","disabled");receiverElement.removeAttr("checked")}else{receiverElement.removeAttr("disabled")}}}}instance._isInitialRun=false};for(var sender in this._configuration){var mainElements=$(topElement).find(sender);if(!mainElements.length){continue}mainElements.each((function(i){var mainElement=$(mainElements[i]);var receivers=instance._configuration[sender];var callback=function(){toggleChild(receivers,mainElement,true)};mainElement.ready((function(){toggleChild(receivers,mainElement,false)})).change(callback)}))}};jQuery(document).ready((function(){var cbAdmin=new onOffice.checkboxAdmin;cbAdmin.changeCbStatus(this)}));
\ No newline at end of file
+var onOffice=onOffice||{};onOffice.checkboxAdmin=function(){this._isInitialRun=true;this._configuration={"input[name^=oopluginaddressfieldconfig-filterable]":[{element:"input[name^=oopluginaddressfieldconfig-hidden]",invert:false},{element:"input[name^=oopluginaddressfieldconfig-convertInputTextToSelectForField]",invert:false}],"input[name=oopluginforms-createaddress]":[{element:"input[name=oopluginforms-checkduplicates]",invert:false},{element:"input[name=oopluginforms-newsletter]",invert:false}],"input[name^=oopluginfieldconfig-filterable]":[{element:"input[name^=oopluginfieldconfig-hidden]",invert:false},{element:"input[name^=oopluginfieldconfig-availableOptions]",invert:false},{element:"input[name^=oopluginfieldconfig-convertTextToSelectForCityField]",invert:false}],"input[name=oopluginforms-defaultrecipient]":[{element:"input[name=oopluginforms-recipient]",invert:true}],"input[name^=oopluginformfieldconfig-hiddenfield]":[{element:"input[name^=oopluginformfieldconfig-required]",invert:true}],"input[name^=oopluginformfieldconfig-required]":[{element:"input[name^=oopluginformfieldconfig-hiddenfield]",invert:true}],"input[name=oopluginformactivityconfig-writeactivity]":[{element:"select[name=oopluginformactivityconfig-actionkind]",invert:false},{element:"select[name=oopluginformactivityconfig-actiontype]",invert:false},{element:"select[name^=oopluginformactivityconfig-characteristic]",invert:false},{element:"textarea[name=oopluginformactivityconfig-remark]",invert:false},{element:"select[name^=oopluginformactivityconfig-origincontact]",invert:false},{element:"select[name^=oopluginformactivityconfig-advisorylevel]",invert:false}]}};onOffice.checkboxAdmin.prototype.changeCbStatus=function(topElement){var $=jQuery;var instance=this;var toggleChild=function(receivers,mainElement,fromOnChange){for(var i in receivers){var receiver=receivers[i];var receiverElement=mainElement.parent().parent().find(receiver.element);var invert=receiver.invert;if(receiverElement.length){if(mainElement.prop("checked")){if(!invert){receiverElement[0].checked=receiverElement[0].checked||receiver.checkOnActive&&(instance._isInitialRun||fromOnChange);receiverElement.removeAttr("disabled")}else{receiverElement.prop("disabled","disabled");receiverElement.removeAttr("checked")}}else{if(!invert){receiverElement.prop("disabled","disabled");receiverElement.removeAttr("checked")}else{receiverElement.removeAttr("disabled")}}}}instance._isInitialRun=false};for(var sender in this._configuration){var mainElements=$(topElement).find(sender);if(!mainElements.length){continue}mainElements.each((function(i){var mainElement=$(mainElements[i]);var receivers=instance._configuration[sender];var callback=function(){toggleChild(receivers,mainElement,true)};mainElement.ready((function(){toggleChild(receivers,mainElement,false)})).change(callback)}))}};jQuery(document).ready((function(){var cbAdmin=new onOffice.checkboxAdmin;cbAdmin.changeCbStatus(this)}));
\ No newline at end of file
diff --git a/dist/onoffice-handle-activity-config.min.js b/dist/onoffice-handle-activity-config.min.js
new file mode 100644
index 000000000..d44d03d13
--- /dev/null
+++ b/dist/onoffice-handle-activity-config.min.js
@@ -0,0 +1 @@
+jQuery(document).ready((function($){const actionKindSelect=$('.oo-poststuff select[name="oopluginformactivityconfig-actionkind"]');const actionTypeSelect=$('.oo-poststuff select[name="oopluginformactivityconfig-actiontype"]');if(actionTypeSelect.length&&actionKindSelect.length){const actionTypes=onOffice_loc_settings.action_type;function populateActionTypes(actionKind){if(actionTypeSelect.children("option").length===0){const defaultOption=$("").attr("value","").text(onOffice_loc_settings.default_label_choose);actionTypeSelect.append(defaultOption);const selectedActionTypes=actionTypes[actionKind];if(selectedActionTypes){Object.entries(selectedActionTypes).forEach((([value,label])=>{if(value!==""){const option=$("").attr("value",value).text(label);actionTypeSelect.append(option)}}))}}}actionKindSelect.on("change",(function(){actionTypeSelect.empty();const selectedActionKind=$(this).val();populateActionTypes(selectedActionKind)}));const initialActionKind=actionKindSelect.val();populateActionTypes(initialActionKind)}}));
\ No newline at end of file
diff --git a/js/checkbox.js b/js/checkbox.js
index 9587fed49..6d0cf3f62 100644
--- a/js/checkbox.js
+++ b/js/checkbox.js
@@ -61,6 +61,34 @@ onOffice.checkboxAdmin = function() {
invert: true
},
],
+
+ // view: create activity form
+ "input[name=oopluginformactivityconfig-writeactivity]": [
+ {
+ element: "select[name=oopluginformactivityconfig-actionkind]",
+ invert: false
+ },
+ {
+ element: "select[name=oopluginformactivityconfig-actiontype]",
+ invert: false
+ },
+ {
+ element: "select[name^=oopluginformactivityconfig-characteristic]",
+ invert: false
+ },
+ {
+ element: "textarea[name=oopluginformactivityconfig-remark]",
+ invert: false
+ },
+ {
+ element: "select[name^=oopluginformactivityconfig-origincontact]",
+ invert: false
+ },
+ {
+ element: "select[name^=oopluginformactivityconfig-advisorylevel]",
+ invert: false
+ }
+ ]
};
};
diff --git a/js/onoffice-handle-activity-config.js b/js/onoffice-handle-activity-config.js
new file mode 100644
index 000000000..28fa575fd
--- /dev/null
+++ b/js/onoffice-handle-activity-config.js
@@ -0,0 +1,32 @@
+jQuery(document).ready(function($) {
+ const actionKindSelect = $('.oo-poststuff select[name="oopluginformactivityconfig-actionkind"]');
+ const actionTypeSelect = $('.oo-poststuff select[name="oopluginformactivityconfig-actiontype"]');
+
+ if (actionTypeSelect.length && actionKindSelect.length) {
+ const actionTypes = onOffice_loc_settings.action_type;
+ function populateActionTypes(actionKind) {
+ if (actionTypeSelect.children('option').length === 0) {
+ const defaultOption = $('').attr('value', '').text(onOffice_loc_settings.default_label_choose);
+ actionTypeSelect.append(defaultOption);
+ const selectedActionTypes = actionTypes[actionKind];
+ if (selectedActionTypes) {
+ Object.entries(selectedActionTypes).forEach(([value, label]) => {
+ if (value !== '') {
+ const option = $('').attr('value', value).text(label);
+ actionTypeSelect.append(option);
+ }
+ });
+ }
+ }
+ }
+
+ actionKindSelect.on('change', function() {
+ actionTypeSelect.empty();
+ const selectedActionKind = $(this).val();
+ populateActionTypes(selectedActionKind);
+ });
+
+ const initialActionKind = actionKindSelect.val();
+ populateActionTypes(initialActionKind);
+ }
+});
\ No newline at end of file
diff --git a/plugin/DataFormConfiguration/DataFormConfiguration.php b/plugin/DataFormConfiguration/DataFormConfiguration.php
index 92ee10c10..afefc8cfa 100644
--- a/plugin/DataFormConfiguration/DataFormConfiguration.php
+++ b/plugin/DataFormConfiguration/DataFormConfiguration.php
@@ -81,6 +81,28 @@ class DataFormConfiguration
/** @var array */
private $_hiddenFields = [];
+
+ /** @var bool */
+ private $_writeActivity = false;
+
+ /** @var string */
+ private $_actionKind = '';
+
+ /** @var string */
+ private $_actionType = '';
+
+ /** @var string */
+ private $_characteristic = '';
+
+ /** @var string */
+ private $_remark = '';
+
+ /** @var string */
+ private $_originContact = '';
+
+ /** @var string */
+ private $_advisorylevel = '';
+
/**
*
* Override to set default fields for new, empty forms
@@ -249,4 +271,60 @@ public function getRecipientByUserSelection(): string {
return $this->_recipient;
}
+
+ /** @return bool */
+ public function getWriteActivity(): bool
+ { return $this->_writeActivity; }
+
+ /** @param bool $writeActivity */
+ public function setWriteActivity(bool $writeActivity)
+ { $this->_writeActivity = $writeActivity; }
+
+ /** @return string */
+ public function getActionKind(): string
+ { return $this->_actionKind; }
+
+ /** @param string $actionKind */
+ public function setActionKind(string $actionKind)
+ { $this->_actionKind = $actionKind; }
+
+ /** @return string */
+ public function getActionType(): string
+ { return $this->_actionType; }
+
+ /** @param string $actionType */
+ public function setActionType(string $actionType)
+ { $this->_actionType = $actionType; }
+
+ /** @return string */
+ public function getCharacteristic(): string
+ { return $this->_characteristic; }
+
+ /** @param string $characteristic */
+ public function setCharacteristic(string $characteristic)
+ { $this->_characteristic = $characteristic; }
+
+ /** @return string */
+ public function getRemark(): string
+ { return $this->_remark; }
+
+ /** @param string $remark */
+ public function setRemark(string $remark)
+ { $this->_remark = $remark; }
+
+ /** @return string */
+ public function getOriginContact(): string
+ { return $this->_originContact; }
+
+ /** @param string $originContact */
+ public function setOriginContact(string $originContact)
+ { $this->_originContact = $originContact; }
+
+ /** @return string */
+ public function getAdvisorylevel(): string
+ { return $this->_advisorylevel; }
+
+ /** @param string $advisorylevel */
+ public function setAdvisorylevel(string $advisorylevel)
+ { $this->_advisorylevel = $advisorylevel; }
}
diff --git a/plugin/DataFormConfiguration/DataFormConfigurationFactory.php b/plugin/DataFormConfiguration/DataFormConfigurationFactory.php
index b897f06db..c38b113a2 100644
--- a/plugin/DataFormConfiguration/DataFormConfigurationFactory.php
+++ b/plugin/DataFormConfiguration/DataFormConfigurationFactory.php
@@ -180,6 +180,11 @@ private function createByRow(array $row)
$this->_pGeoPositionFieldHandler->readValues($pConfig);
$rowFields = $this->configureGeoFields($rowFields);
+ if ($this->_type !== Form::TYPE_APPLICANT_SEARCH){
+ $rowActivityConfig = $this->_pRecordManagerRead->readActivityConfigByFormId($formId);
+ $this->configureActivity($pConfig, $rowActivityConfig);
+ }
+
foreach ($rowFields as $fieldRow) {
$this->configureFieldsByRow($fieldRow, $pConfig);
}
@@ -188,6 +193,26 @@ private function createByRow(array $row)
}
+ /**
+ * @param DataFormConfiguration\DataFormConfiguration $pFormConfiguration
+ * @param array|null $row
+ * @return void
+ */
+ private function configureActivity(DataFormConfiguration\DataFormConfiguration $pFormConfiguration, array $row = null)
+ {
+ if (empty($row)) {
+ return;
+ }
+ $pFormConfiguration->setWriteActivity((bool)$row['write_activity'] ?? false);
+ $pFormConfiguration->setActionKind($row['action_kind'] ?? '');
+ $pFormConfiguration->setActionType($row['action_type'] ?? '');
+ $pFormConfiguration->setCharacteristic($row['characteristic'] ?? '');
+ $pFormConfiguration->setRemark($row['remark'] ?? '');
+ $pFormConfiguration->setOriginContact($row['origin_contact'] ?? '');
+ $pFormConfiguration->setAdvisorylevel($row['advisory_level'] ?? '');
+ }
+
+
/**
*
* @param array $row
diff --git a/plugin/Form/FormAddressCreator.php b/plugin/Form/FormAddressCreator.php
index 278affcab..505e313f3 100644
--- a/plugin/Form/FormAddressCreator.php
+++ b/plugin/Form/FormAddressCreator.php
@@ -37,6 +37,7 @@
use onOffice\WPlugin\Types\FieldsCollection;
use onOffice\WPlugin\Types\FieldTypes;
use onOffice\WPlugin\Language;
+use onOffice\WPlugin\DataFormConfiguration\DataFormConfiguration;
/**
*
@@ -403,4 +404,34 @@ private function getAddressDataForReadAddressApiCall(FormData $pFormData): array
return $addressData;
}
+
+ /**
+ * @param DataFormConfiguration $pFormConfig
+ * @param int $addressId
+ * @param int|null $estateId
+ */
+ public function createAgentsLog(DataFormConfiguration $pFormConfig, int $addressId, int $estateId = null)
+ {
+ if (empty($pFormConfig->getActionKind()) && empty($pFormConfig->getActionType()) && empty($pFormConfig->getCharacteristic()) && empty($pFormConfig->getRemark())) {
+ return;
+ }
+ $requestParams = [
+ 'addressids' => [$addressId],
+ 'actionkind' => $pFormConfig->getActionKind() ?: null,
+ 'actiontype' => $pFormConfig->getActionType() ?: null,
+ 'origincontact' => $pFormConfig->getOriginContact() ?: null,
+ 'features' => !empty($pFormConfig->getCharacteristic()) ? explode(',', $pFormConfig->getCharacteristic()) : null,
+ 'note' => $pFormConfig->getRemark(),
+ ];
+
+ if (!empty($estateId)) {
+ $requestParams['estateid'] = $estateId;
+ $requestParams['advisorylevel'] = $pFormConfig->getAdvisorylevel() ?: null;
+ }
+
+ $pApiClientAction = new APIClientActionGeneric
+ ($this->_pSDKWrapper, onOfficeSDK::ACTION_ID_CREATE, 'agentslog');
+ $pApiClientAction->setParameters($requestParams);
+ $pApiClientAction->addRequestToQueue()->sendRequests();
+ }
}
diff --git a/plugin/FormPostContact.php b/plugin/FormPostContact.php
index a5cf0be41..dc157b2e1 100644
--- a/plugin/FormPostContact.php
+++ b/plugin/FormPostContact.php
@@ -145,6 +145,7 @@ private function createAddress(FormData $pFormData)
{
$pFormConfig = $pFormData->getDataFormConfiguration();
$checkDuplicate = $pFormConfig->getCheckDuplicateOnCreateAddress();
+ $writeActivity = $pFormConfig->getWriteActivity();
$contactType = $pFormConfig->getContactType();
$pWPQuery = $this->_pFormPostContactConfiguration->getWPQueryWrapper()->getWPQuery();
$estateId = $pWPQuery->get('estate_id', null);
@@ -156,6 +157,9 @@ private function createAddress(FormData $pFormData)
->createOrCompleteAddress($pFormData, $checkDuplicate, $contactType, $estateId);
$this->_messageDuplicateAddressData = $this->_pFormPostContactConfiguration->getFormAddressCreator()
->getMessageDuplicateAddressData($pFormData, $addressId, $latestAddressIdOnEnterPrise);
+ if ($writeActivity) {
+ $this->_pFormPostContactConfiguration->getFormAddressCreator()->createAgentsLog($pFormConfig, $addressId, $estateId);
+ }
if (!$this->_pFormPostContactConfiguration->getNewsletterAccepted()) {
// No subscription for newsletter, which is ok
diff --git a/plugin/FormPostInterest.php b/plugin/FormPostInterest.php
index 4eed28302..acd8dd326 100644
--- a/plugin/FormPostInterest.php
+++ b/plugin/FormPostInterest.php
@@ -89,6 +89,7 @@ protected function analyseFormContentByPrefix(FormData $pFormData)
$contactType = $pFormConfiguration->getContactType();
$pWPQuery = $this->_pFormPostInterestConfiguration->getWPQueryWrapper()->getWPQuery();
$estateId = $pWPQuery->get('estate_id', null);
+ $writeActivity = $pFormConfiguration->getWriteActivity();
$latestAddressIdOnEnterPrise = null;
if ($checkDuplicate) {
$latestAddressIdOnEnterPrise = $this->_pFormPostInterestConfiguration->getFormAddressCreator()->getLatestAddressIdInOnOfficeEnterprise();
@@ -98,6 +99,9 @@ protected function analyseFormContentByPrefix(FormData $pFormData)
$this->_messageDuplicateAddressData = $this->_pFormPostInterestConfiguration->getFormAddressCreator()
->getMessageDuplicateAddressData($pFormData, $addressId, $latestAddressIdOnEnterPrise);
$this->createSearchcriteria( $pFormData, $addressId );
+ if ($writeActivity) {
+ $this->_pFormPostInterestConfiguration->getFormAddressCreator()->createAgentsLog($pFormConfiguration, $addressId, null);
+ }
$this->setNewsletter( $addressId );
}
} finally {
diff --git a/plugin/FormPostOwner.php b/plugin/FormPostOwner.php
index affd581df..788524494 100644
--- a/plugin/FormPostOwner.php
+++ b/plugin/FormPostOwner.php
@@ -106,6 +106,7 @@ protected function analyseFormContentByPrefix(FormData $pFormData)
$contactType = $pDataFormConfiguration->getContactType();
$pWPQuery = $this->_pFormPostOwnerConfiguration->getWPQueryWrapper()->getWPQuery();
$estateId = $pWPQuery->get('estate_id', null);
+ $writeActivity = $pDataFormConfiguration->getWriteActivity();
$latestAddressIdOnEnterPrise = null;
if ($checkDuplicate) {
$latestAddressIdOnEnterPrise = $this->_pFormPostOwnerConfiguration->getFormAddressCreator()->getLatestAddressIdInOnOfficeEnterprise();
@@ -117,6 +118,9 @@ protected function analyseFormContentByPrefix(FormData $pFormData)
$estateData = $this->getEstateData();
$estateId = $this->createEstate( $estateData );
$this->createOwnerRelation( $estateId, $addressId );
+ if ($writeActivity) {
+ $this->_pFormPostOwnerConfiguration->getFormAddressCreator()->createAgentsLog($pDataFormConfiguration, $addressId, $estateId);
+ }
$this->setNewsletter( $addressId );
}
} finally {
diff --git a/plugin/Gui/AdminPageFormSettingsBase.php b/plugin/Gui/AdminPageFormSettingsBase.php
index 7f3a918fc..c011c4481 100644
--- a/plugin/Gui/AdminPageFormSettingsBase.php
+++ b/plugin/Gui/AdminPageFormSettingsBase.php
@@ -75,6 +75,9 @@ abstract class AdminPageFormSettingsBase
/** */
const FORM_VIEW_FORM_SPECIFIC = 'viewformspecific';
+ /** */
+ const FORM_VIEW_FORM_ACTIVITYCONFIG = 'viewformactivityconfig';
+
/** */
const MODULE_LABELS = 'modulelabels';
@@ -202,6 +205,10 @@ protected function updateValues(array $row, stdClass $pResult, $recordId = null)
$row[RecordManager::TABLENAME_FORMS]['name'] = $this->sanitizeShortcodeName(
$row[RecordManager::TABLENAME_FORMS]['name']);
}
+
+ if (array_key_exists(RecordManager::TABLENAME_ACTIVITY_CONFIG_FORM, $row) && !empty($row[RecordManager::TABLENAME_ACTIVITY_CONFIG_FORM])) {
+ $row[RecordManager::TABLENAME_ACTIVITY_CONFIG_FORM] = $this->convertCharacteristicActivityConfigData($row);
+ }
if ($recordId != 0) {
$action = RecordManagerFactory::ACTION_UPDATE;
@@ -217,6 +224,10 @@ protected function updateValues(array $row, stdClass $pResult, $recordId = null)
if (array_key_exists(RecordManager::TABLENAME_CONTACT_TYPES, $row)) {
$result = $result && $pRecordManagerUpdateForm->updateContactTypeByRow($row[RecordManager::TABLENAME_CONTACT_TYPES]);
}
+ if (array_key_exists(RecordManager::TABLENAME_ACTIVITY_CONFIG_FORM, $row)) {
+ $result = $result && $pRecordManagerUpdateForm->updateActivityConfigByRow
+ ($row[RecordManager::TABLENAME_ACTIVITY_CONFIG_FORM]);
+ }
} else {
$action = RecordManagerFactory::ACTION_INSERT;
// insert
@@ -231,6 +242,8 @@ protected function updateValues(array $row, stdClass $pResult, $recordId = null)
$row[RecordManager::TABLENAME_FIELDCONFIG_FORMS] = $rowFieldConfig;
$row[RecordManager::TABLENAME_CONTACT_TYPES] =
$this->prepareRelationValues(RecordManager::TABLENAME_CONTACT_TYPES, 'form_id', $row, $recordId);
+ $row[RecordManager::TABLENAME_ACTIVITY_CONFIG_FORM]['form_id'] = $recordId;
+ $pRecordManagerInsertForm->insertSingleRow($row, RecordManager::TABLENAME_ACTIVITY_CONFIG_FORM);
$pRecordManagerInsertForm->insertAdditionalValues($row);
$result = true;
} catch (RecordManagerInsertException $pException) {
@@ -248,6 +261,24 @@ protected function updateValues(array $row, stdClass $pResult, $recordId = null)
$pResult->record_id = $recordId;
}
+ /**
+ * @param array $row
+ * @return array
+ */
+ private function convertCharacteristicActivityConfigData(array $row): array
+ {
+ $rowActivityConfig = $row[RecordManager::TABLENAME_ACTIVITY_CONFIG_FORM];
+ $data = [];
+ foreach ($rowActivityConfig as $key => $value) {
+ if (is_array($value)) {
+ $data[] = $value['characteristic'];
+ unset($rowActivityConfig[$key]);
+ }
+ }
+ $rowActivityConfig['characteristic'] = implode(',', $data);
+
+ return $rowActivityConfig;
+ }
/**
*
diff --git a/plugin/Gui/AdminPageFormSettingsContact.php b/plugin/Gui/AdminPageFormSettingsContact.php
index a36a311df..511941804 100644
--- a/plugin/Gui/AdminPageFormSettingsContact.php
+++ b/plugin/Gui/AdminPageFormSettingsContact.php
@@ -36,6 +36,12 @@
use onOffice\WPlugin\Record\RecordManagerReadForm;
use onOffice\WPlugin\Types\FieldsCollection;
use function __;
+use onOffice\WPlugin\SDKWrapper;
+use onOffice\WPlugin\API\APIClientActionGeneric;
+use onOffice\WPlugin\Language;
+use DI\DependencyException;
+use DI\NotFoundException;
+use onOffice\WPlugin\API\ApiClientException;
/**
*
@@ -172,7 +178,29 @@ protected function buildForms()
$pFormModelFormSpecific->addInputModel($pInputModel);
}
+ $pInputModelWriteActivity = $pFormModelBuilder->createInputModelWriteActivity();
+ $pInputModelActionKind = $pFormModelBuilder->createInputModelActionKind();
+ $pInputModelActionType= $pFormModelBuilder->createInputModelActionType();
+ $pInputModelOriginContact= $pFormModelBuilder->createInputModelOriginContact();
+ $pInputModelAdvisoryLevel= $pFormModelBuilder->createInputModelAdvisoryLevel();
+ $pInputModelCharacteristic= $pFormModelBuilder->createInputModelCharacteristic();
+ $pInputModelRemark= $pFormModelBuilder->createInputModelRemark();
+ $pFormModelFormActivitiy = new FormModel();
+ $pFormModelFormActivitiy->setPageSlug($this->getPageSlug());
+ $pFormModelFormActivitiy->setGroupSlug(self::FORM_VIEW_FORM_ACTIVITYCONFIG);
+ $pFormModelFormActivitiy->setLabel(__('Activities', 'onoffice-for-wp-websites'));
+ $pFormModelFormActivitiy->addInputModel($pInputModelWriteActivity);
+ $pFormModelFormActivitiy->addInputModel($pInputModelActionKind);
+ $pFormModelFormActivitiy->addInputModel($pInputModelActionType);
+ $pFormModelFormActivitiy->addInputModel($pInputModelOriginContact);
+ if ($this->getType() !== Form::TYPE_INTEREST) {
+ $pFormModelFormActivitiy->addInputModel($pInputModelAdvisoryLevel);
+ }
+ $pFormModelFormActivitiy->addInputModel($pInputModelCharacteristic);
+ $pFormModelFormActivitiy->addInputModel($pInputModelRemark);
+
$this->addFormModel($pFormModelFormSpecific);
+ $this->addFormModel($pFormModelFormActivitiy);
$this->buildGeoPositionSettings();
$this->addFieldConfigurationForMainModules($pFormModelBuilder);
@@ -183,6 +211,35 @@ protected function buildForms()
}
+ /**
+ * @return array
+ * @throws DependencyException
+ * @throws NotFoundException
+ * @throws ApiClientException
+ */
+ private function getTypesOfAction(): array
+ {
+ $pLanguage = $this->getContainer()->get(Language::class);
+ $pSDKWrapper = $this->getContainer()->get(SDKWrapper::class);
+ $pApiClientAction = new APIClientActionGeneric
+ ($pSDKWrapper, onOfficeSDK::ACTION_ID_GET, 'actionkindtypes');
+ $pApiClientAction->setParameters(['lang'=> $pLanguage->getDefault()]);
+ $pApiClientAction->addRequestToQueue()->sendRequests();
+ $result = $pApiClientAction->getResultRecords();
+
+ if (empty($result)) {
+ return [];
+ }
+
+ $data = [];
+
+ foreach ($result as $record) {
+ $data[$record['elements']['key']] = $record['elements']['types'];
+ }
+
+ return $data;
+ }
+
/**
*
*/
@@ -206,6 +263,30 @@ private function buildGeoPositionSettings()
}
}
+ /**
+ * @return array
+ */
+
+ public function getEnqueueData(): array
+ {
+ $returnArray = parent::getEnqueueData();
+ $returnArray['action_type'] = $this->getTypesOfAction();
+ $returnArray['default_label_choose'] = __('Please choose', 'onoffice-for-wp-websites');
+
+ return $returnArray;
+ }
+
+ /**
+ *
+ */
+
+ public function doExtraEnqueues()
+ {
+ parent::doExtraEnqueues();
+ $pluginPath = ONOFFICE_PLUGIN_DIR.'/index.php';
+ wp_register_script('onoffice-handle-activity-config', plugins_url('/dist/onoffice-handle-activity-config.min.js', $pluginPath));
+ wp_enqueue_script('onoffice-handle-activity-config');
+ }
/**
*
@@ -221,6 +302,9 @@ protected function generateMetaBoxes()
$this->createMetaBoxByForm($pFormGeoPosition, 'side');
}
+ $pFormActivities = $this->getFormModelByGroupSlug(self::FORM_VIEW_FORM_ACTIVITYCONFIG);
+ $this->createMetaBoxByForm($pFormActivities, 'side');
+
parent::generateMetaBoxes();
}
diff --git a/plugin/Installer/DatabaseChanges.php b/plugin/Installer/DatabaseChanges.php
index fa3592cca..f7af83792 100644
--- a/plugin/Installer/DatabaseChanges.php
+++ b/plugin/Installer/DatabaseChanges.php
@@ -41,7 +41,7 @@
class DatabaseChanges implements DatabaseChangesInterface
{
/** @var int */
- const MAX_VERSION = 50;
+ const MAX_VERSION = 51;
/** @var WPOptionWrapperBase */
private $_pWpOption;
@@ -334,13 +334,18 @@ public function install()
dbDelta($this->getCreateQueryAddressFieldConfig());
$dbversion = 49;
}
-
+
if ($dbversion == 49) {
dbDelta($this->getCreateQueryFieldConfigAddressCustomsLabels());
dbDelta($this->getCreateQueryFieldConfigAddressTranslatedLabels());
$dbversion = 50;
}
+ if ($dbversion == 50) {
+ dbDelta($this->getCreateQueryFormActivityConfig());
+ $dbversion = 51;
+ }
+
$this->_pWpOption->updateOption( 'oo_plugin_db_version', $dbversion, true );
}
@@ -975,6 +980,7 @@ public function deinstall()
$prefix."oo_plugin_contacttypes",
$prefix."oo_plugin_fieldconfig_address_customs_labels",
$prefix."oo_plugin_fieldconfig_address_translated_labels",
+ $prefix."oo_plugin_form_activityconfig",
);
foreach ($tables as $table) {
@@ -1265,4 +1271,28 @@ private function getCreateQueryFieldConfigAddressTranslatedLabels(): string
return $sql;
}
+
+ /**
+ * @return string
+ */
+ private function getCreateQueryFormActivityConfig(): string
+ {
+ $prefix = $this->getPrefix();
+ $charsetCollate = $this->getCharsetCollate();
+ $tableName = $prefix."oo_plugin_form_activityconfig";
+ $sql = "CREATE TABLE $tableName (
+ `form_activityconfig_id` bigint(20) NOT NULL AUTO_INCREMENT,
+ `form_id` int(11) NOT NULL,
+ `write_activity` tinyint(1) NOT NULL DEFAULT '0',
+ `action_kind` tinytext NOT NULL,
+ `action_type` tinytext NOT NULL,
+ `origin_contact` tinytext NOT NULL,
+ `advisory_level` tinytext NOT NULL,
+ `characteristic` VARCHAR(255) NOT NULL,
+ `remark` text NOT NULL,
+ PRIMARY KEY (`form_activityconfig_id`)
+ ) $charsetCollate;";
+
+ return $sql;
+ }
}
diff --git a/plugin/Model/FormModelBuilder/FormModelBuilderDBForm.php b/plugin/Model/FormModelBuilder/FormModelBuilderDBForm.php
index 2c2194ab6..2939eb1c3 100644
--- a/plugin/Model/FormModelBuilder/FormModelBuilderDBForm.php
+++ b/plugin/Model/FormModelBuilder/FormModelBuilderDBForm.php
@@ -54,6 +54,10 @@
use function get_option;
use const ONOFFICE_DI_CONFIG_PATH;
use onOffice\WPlugin\Field\Collection\FieldsCollectionConfiguratorForm;
+use onOffice\WPlugin\API\APIClientActionGeneric;
+use onOffice\WPlugin\SDKWrapper;
+use onOffice\WPlugin\Language;
+use onOffice\WPlugin\API\ApiClientException;
/**
*
@@ -71,6 +75,18 @@ class FormModelBuilderDBForm
/** @var Container */
private $_pContainer;
+ /** @var array */
+ private $_actionKind = [];
+
+ /** @var array */
+ private $_actionType = [];
+
+ /** @var array */
+ private $_characteristic = [];
+
+ /** @var array */
+ private $_originContact = [];
+
/**
* @param Container $pContainer
*/
@@ -220,6 +236,13 @@ public function generate(string $pageSlug, $formId = null): FormModel
$values['fieldsAvailableOptions'] = $pDataFormConfiguration->getAvailableOptionsFields();
$values['fieldsMarkdown'] = $pDataFormConfiguration->getMarkdownFields();
$values['fieldsHiddenField'] = $pDataFormConfiguration->getHiddenFields();
+ $values['writeactivity'] = $pDataFormConfiguration->getWriteActivity();
+ $values['actionkind'] = $pDataFormConfiguration->getActionKind();
+ $values['actiontype'] = $pDataFormConfiguration->getActionType();
+ $values['characteristic'] = $pDataFormConfiguration->getCharacteristic();
+ $values['remark'] = $pDataFormConfiguration->getRemark();
+ $values['origincontact'] = $pDataFormConfiguration->getOriginContact();
+ $values['advisorylevel'] = $pDataFormConfiguration->getAdvisorylevel();
$this->setValues($values);
$pFormModel = new FormModel();
@@ -227,6 +250,8 @@ public function generate(string $pageSlug, $formId = null): FormModel
$pFormModel->setGroupSlug('onoffice-form-settings');
$pFormModel->setPageSlug($pageSlug);
+ $this->fetchDataTypesOfActionAndCharacteristics();
+
return $pFormModel;
}
@@ -786,6 +811,197 @@ public function createSearchFieldForFieldLists($module, string $htmlType)
return $pInputModelFieldsConfig;
}
+ /**
+ * @return InputModelDB
+ */
+
+ public function createInputModelWriteActivity(): InputModelDB
+ {
+ $labelWriteActivity = __('Write activity', 'onoffice-for-wp-websites');
+
+ $pInputModelWriteActivity = $this->getInputModelDBFactory()->create
+ (InputModelDBFactoryConfigForm::INPUT_FORM_WRITE_ACTIVITY, $labelWriteActivity);
+ $pInputModelWriteActivity->setHtmlType(InputModelBase::HTML_TYPE_CHECKBOX);
+ $pInputModelWriteActivity->setValue($this->getValue('writeactivity'));
+ $pInputModelWriteActivity->setValuesAvailable(1);
+
+ return $pInputModelWriteActivity;
+ }
+
+ /**
+ * @return InputModelDB
+ */
+
+ public function createInputModelActionKind(): InputModelDB
+ {
+ $labelActionKind = __('Type of action', 'onoffice-for-wp-websites');
+
+ $pInputModelActionKind = $this->getInputModelDBFactory()->create
+ (InputModelDBFactoryConfigForm::INPUT_FORM_ACTION_KIND, $labelActionKind);
+ $pInputModelActionKind->setHtmlType(InputModelBase::HTML_TYPE_SELECT);
+ $pInputModelActionKind->setValue($this->getValue('actionkind') ?? '');
+ $actionKind = ['' => __('Please choose', 'onoffice-for-wp-websites')]
+ + $this->_actionKind;
+ $pInputModelActionKind->setValuesAvailable($actionKind);
+
+ return $pInputModelActionKind;
+ }
+
+ /**
+ * @return InputModelDB
+ */
+
+ public function createInputModelActionType(): InputModelDB
+ {
+ $labelActionType = __('Kind of action', 'onoffice-for-wp-websites');
+
+ $pInputModelActionType = $this->getInputModelDBFactory()->create
+ (InputModelDBFactoryConfigForm::INPUT_FORM_ACTION_TYPE, $labelActionType);
+ $pInputModelActionType->setHtmlType(InputModelBase::HTML_TYPE_SELECT);
+ $pInputModelActionType->setValue($this->getValue('actiontype') ?? '');
+ $ationType = $this->_actionType[$this->getValue('actionkind')] ?? [];
+ $pInputModelActionType->setValuesAvailable($ationType);
+
+ return $pInputModelActionType;
+ }
+
+ /**
+ * @return void
+ * @throws DependencyException
+ * @throws NotFoundException
+ * @throws ApiClientException
+ */
+
+ private function fetchDataTypesOfActionAndCharacteristics()
+ {
+ $language = Language::getDefault();
+ $pSDKWrapper = $this->_pContainer->get(SDKWrapper::class);
+ $pApiClientAction = new APIClientActionGeneric
+ ($pSDKWrapper, onOfficeSDK::ACTION_ID_GET, 'actionkindtypes');
+ $pApiClientAction->setParameters(['lang'=> $language]);
+ $pApiClientAction->addRequestToQueue();
+
+ $parameters = [
+ 'labels' => true,
+ 'language' => $language,
+ 'fieldList' => ['merkmal', 'HerkunftKontakt'],
+ 'modules' => ['agentsLog', 'address']
+ ];
+
+ $pApiClientActionGetCharacteristic = new APIClientActionGeneric
+ ($pSDKWrapper, onOfficeSDK::ACTION_ID_GET, 'fields');
+ $pApiClientActionGetCharacteristic->setParameters($parameters);
+ $pApiClientActionGetCharacteristic->addRequestToQueue()->sendRequests();
+
+ $resultAction = $pApiClientAction->getResultRecords();
+ $resultCharacteristic = $pApiClientActionGetCharacteristic->getResultRecords();
+
+ if (!empty($resultAction)) {
+ foreach ($resultAction as $record) {
+ $this->_actionKind[$record['elements']['key']] = $record['elements']['label'];
+ $this->_actionType[$record['elements']['key']] = $record['elements']['types'];
+ }
+ }
+ if (!empty($resultCharacteristic)) {
+ foreach (array_column($resultCharacteristic, 'elements') as $value) {
+ if (isset($value['merkmal']))
+ $this->_characteristic = $value['merkmal'];
+ if (isset($value['HerkunftKontakt']))
+ $this->_originContact = $value['HerkunftKontakt'];
+ }
+ }
+ }
+
+ /**
+ * @return InputModelDB
+ */
+
+ public function createInputModelCharacteristic(): InputModelDB
+ {
+ $labelCharacteristic = __('Characteristic', 'onoffice-for-wp-websites');
+
+ $pInputModelCharacteristic = $this->getInputModelDBFactory()->create
+ (InputModelDBFactoryConfigForm::INPUT_FORM_CHARACTERISTIC, $labelCharacteristic);
+ $pInputModelCharacteristic->setHtmlType(InputModelBase::HTML_TYPE_SELECT_TWO);
+ $characteristicArray = explode(',', $this->getValue('characteristic')) ?? [];
+ $pInputModelCharacteristic->setIsMulti(true);
+ $pInputModelCharacteristic->setValue($characteristicArray);
+ $pInputModelCharacteristic->setValuesAvailable($this->_characteristic['permittedvalues'] ?? []);
+
+ return $pInputModelCharacteristic;
+ }
+
+ /**
+ * @return InputModelDB
+ */
+
+ public function createInputModelOriginContact(): InputModelDB
+ {
+ $labelOriginContact = __('Origin Contact', 'onoffice-for-wp-websites');
+
+ $pInputModelOriginContact = $this->getInputModelDBFactory()->create
+ (InputModelDBFactoryConfigForm::INPUT_FORM_ORIGIN_CONTACT, $labelOriginContact);
+ $pInputModelOriginContact->setHtmlType(InputModelBase::HTML_TYPE_SELECT);
+ $pInputModelOriginContact->setValue($this->getValue('origincontact') ?? '');
+ $defaultOriginContact = ['' => __('Please choose', 'onoffice-for-wp-websites')]
+ + $this->_originContact['permittedvalues'];
+ $pInputModelOriginContact->setValuesAvailable($defaultOriginContact ?? []);
+
+ return $pInputModelOriginContact;
+ }
+
+
+ /**
+ * @return array
+ */
+
+ private function getDefaultAdvisoryLevel() {
+ return [
+ 'A' => __('A Rental/purchase contract signed', 'onoffice-for-wp-websites'),
+ 'B' => __('B Written rental / purchase commitment', 'onoffice-for-wp-websites'),
+ 'C' => __('C Intense communication', 'onoffice-for-wp-websites'),
+ 'D' => __('D Interested, but still reviewing', 'onoffice-for-wp-websites'),
+ 'E' => __('E Documentation received', 'onoffice-for-wp-websites'),
+ 'F' => __('F Documentation ordered', 'onoffice-for-wp-websites'),
+ 'G' => __('G Cancellation', 'onoffice-for-wp-websites'),
+ ];
+ }
+
+ /**
+ * @return InputModelDB
+ */
+
+ public function createInputModelAdvisoryLevel(): InputModelDB
+ {
+ $labelAdvisoryLevel= __('Advisory Level', 'onoffice-for-wp-websites');
+
+ $pInputModelAdvisoryLevel = $this->getInputModelDBFactory()->create
+ (InputModelDBFactoryConfigForm::INPUT_FORM_ADVISORY_LEVEL, $labelAdvisoryLevel);
+ $pInputModelAdvisoryLevel->setHtmlType(InputModelBase::HTML_TYPE_SELECT);
+ $pInputModelAdvisoryLevel->setValue($this->getValue('advisorylevel') ?? '');
+ $defaultAdvisoryLevel = ['' => __('Please choose', 'onoffice-for-wp-websites')]
+ + $this->getDefaultAdvisoryLevel();
+ $pInputModelAdvisoryLevel->setValuesAvailable($defaultAdvisoryLevel);
+
+ return $pInputModelAdvisoryLevel;
+ }
+
+ /**
+ * @return InputModelDB
+ */
+
+ public function createInputModelRemark(): InputModelDB
+ {
+ $labelRemark = __('Comment', 'onoffice-for-wp-websites');
+
+ $pInputModelRemark = $this->getInputModelDBFactory()->create
+ (InputModelDBFactoryConfigForm::INPUT_FORM_REMARK, $labelRemark);
+ $pInputModelRemark->setHtmlType(InputModelBase::HTML_TYPE_TEXTAREA);
+ $pInputModelRemark->setValue($this->getValue('remark') ?? '');
+
+ return $pInputModelRemark;
+ }
+
/** @return string */
public function getFormType()
{ return $this->_formType; }
diff --git a/plugin/Model/InputModel/InputModelDBFactoryConfigForm.php b/plugin/Model/InputModel/InputModelDBFactoryConfigForm.php
index fb4725e71..f440ddc4d 100644
--- a/plugin/Model/InputModel/InputModelDBFactoryConfigForm.php
+++ b/plugin/Model/InputModel/InputModelDBFactoryConfigForm.php
@@ -101,6 +101,26 @@ class InputModelDBFactoryConfigForm
/** */
const INPUT_FORM_CONTACT_TYPE = 'contactType';
+ /** */
+ const INPUT_FORM_WRITE_ACTIVITY = 'writeActivity';
+
+ /** */
+ const INPUT_FORM_ACTION_KIND = 'actionKind';
+
+ /** */
+ const INPUT_FORM_ACTION_TYPE = 'actionType';
+
+ /** */
+ const INPUT_FORM_CHARACTERISTIC = 'characteristic';
+
+ /** */
+ const INPUT_FORM_REMARK = 'remark';
+
+ /** */
+ const INPUT_FORM_ORIGIN_CONTACT = 'originContact';
+
+ /** */
+ const INPUT_FORM_ADVISORY_LEVEL = 'advisoryLevel';
/** @var array */
private $_inputConfig = [
@@ -205,6 +225,34 @@ class InputModelDBFactoryConfigForm
self::KEY_TABLE => 'oo_plugin_form_fieldconfig',
self::KEY_FIELD => 'hidden_field',
],
+ self::INPUT_FORM_WRITE_ACTIVITY => [
+ self::KEY_TABLE => 'oo_plugin_form_activityconfig',
+ self::KEY_FIELD => 'write_activity',
+ ],
+ self::INPUT_FORM_ACTION_KIND => [
+ self::KEY_TABLE => 'oo_plugin_form_activityconfig',
+ self::KEY_FIELD => 'action_kind',
+ ],
+ self::INPUT_FORM_ACTION_TYPE => [
+ self::KEY_TABLE => 'oo_plugin_form_activityconfig',
+ self::KEY_FIELD => 'action_type',
+ ],
+ self::INPUT_FORM_CHARACTERISTIC => [
+ self::KEY_TABLE => 'oo_plugin_form_activityconfig',
+ self::KEY_FIELD => 'characteristic',
+ ],
+ self::INPUT_FORM_REMARK => [
+ self::KEY_TABLE => 'oo_plugin_form_activityconfig',
+ self::KEY_FIELD => 'remark',
+ ],
+ self::INPUT_FORM_ORIGIN_CONTACT => [
+ self::KEY_TABLE => 'oo_plugin_form_activityconfig',
+ self::KEY_FIELD => 'origin_contact',
+ ],
+ self::INPUT_FORM_ADVISORY_LEVEL => [
+ self::KEY_TABLE => 'oo_plugin_form_activityconfig',
+ self::KEY_FIELD => 'advisory_level',
+ ],
];
diff --git a/plugin/Model/InputModelBase.php b/plugin/Model/InputModelBase.php
index a32d1e632..cf37ef177 100644
--- a/plugin/Model/InputModelBase.php
+++ b/plugin/Model/InputModelBase.php
@@ -90,6 +90,9 @@ abstract class InputModelBase
/** */
const HTML_GOOGLE_RECAPTCHA_ACCOUNT = 'googleRecaptchaAccount';
+ /** */
+ const HTML_TYPE_TEXTAREA = 'textarea';
+
/** @var string */
private $_name = null;
diff --git a/plugin/Model/InputModelDBAdapterRow.php b/plugin/Model/InputModelDBAdapterRow.php
index 890f65497..c6ed3167b 100644
--- a/plugin/Model/InputModelDBAdapterRow.php
+++ b/plugin/Model/InputModelDBAdapterRow.php
@@ -70,11 +70,14 @@ class InputModelDBAdapterRow
'sortbyvalue_id' => null,
'listview_id' => ['oo_plugin_listviews', 'listview_id'],
],
-
'oo_plugin_contacttypes' => [
'contacttype_id' => null,
'form_id' => ['oo_plugin_forms', 'form_id'],
],
+ 'oo_plugin_form_activityconfig' => [
+ 'form_activityconfig_id' => null,
+ 'form_id' => ['oo_plugin_forms', 'form_id'],
+ ],
];
diff --git a/plugin/Record/RecordManager.php b/plugin/Record/RecordManager.php
index d4bfda6b9..6b76358ca 100644
--- a/plugin/Record/RecordManager.php
+++ b/plugin/Record/RecordManager.php
@@ -86,6 +86,9 @@ abstract class RecordManager
/** */
const TABLENAME_FIELDCONFIG_ADDRESS_TRANSLATED_LABELS = 'oo_plugin_fieldconfig_address_translated_labels';
+ /** */
+ const TABLENAME_ACTIVITY_CONFIG_FORM = 'oo_plugin_form_activityconfig';
+
/**
*
* @deprecated get wpdb via DI
diff --git a/plugin/Record/RecordManagerDeleteForm.php b/plugin/Record/RecordManagerDeleteForm.php
index f38475a93..0103bb46d 100644
--- a/plugin/Record/RecordManagerDeleteForm.php
+++ b/plugin/Record/RecordManagerDeleteForm.php
@@ -91,6 +91,7 @@ public function deleteByIds(array $ids)
$pWpdb->delete($prefix.'oo_plugin_fieldconfig_form_defaults', ['form_id' => $id]);
$pWpdb->delete($prefix.'oo_plugin_fieldconfig_form_customs_labels', ['form_id' => $id]);
+ $pWpdb->delete($prefix.'oo_plugin_form_activityconfig', ['form_id' => $id]);
}
}
}
\ No newline at end of file
diff --git a/plugin/Record/RecordManagerDuplicateListViewForm.php b/plugin/Record/RecordManagerDuplicateListViewForm.php
index f6a9ba370..3771e504f 100644
--- a/plugin/Record/RecordManagerDuplicateListViewForm.php
+++ b/plugin/Record/RecordManagerDuplicateListViewForm.php
@@ -172,6 +172,15 @@ public function duplicateByName(string $name)
]
);
}
+
+ //duplicate data related oo_plugin_form_activityconfig table
+ $tableActivityConfig = $prefix . self::TABLENAME_ACTIVITY_CONFIG_FORM;
+ $activityConfigByFormId = "SELECT * FROM {$this->_pWPDB->_escape($tableActivityConfig)} WHERE form_id='{$this->_pWPDB->_escape($listViewRoot['form_id'])}'";
+ $activityConfigRows = $this->_pWPDB->get_results($activityConfigByFormId, 'ARRAY_A');
+ if (!empty($activityConfigRows) && (count($activityConfigRows) !== 0)) {
+ $this->duplicateDataRelated( $duplicateListViewId, $activityConfigRows,
+ $tableActivityConfig, 'form_id', 'form_activityconfig_id' );
+ }
}
}
}
diff --git a/plugin/Record/RecordManagerInsertGeneric.php b/plugin/Record/RecordManagerInsertGeneric.php
index 4aea0d79b..056a0793f 100644
--- a/plugin/Record/RecordManagerInsertGeneric.php
+++ b/plugin/Record/RecordManagerInsertGeneric.php
@@ -110,4 +110,22 @@ public function insertAdditionalValues(array $values)
$this->_pWPDB->suppress_errors($suppressErrors);
}
+
+
+ /**
+ * @param array $values
+ * @param string $table
+ * @throws RecordManagerInsertException
+ */
+
+ public function insertSingleRow(array $values, string $table)
+ {
+ $suppressErrors = $this->_pWPDB->suppress_errors();
+
+ if (false === $this->_pWPDB->insert($this->_pWPDB->prefix.$table, $values[$table])) {
+ $this->_pWPDB->suppress_errors($suppressErrors);
+ throw new RecordManagerInsertException();
+ }
+ $this->_pWPDB->suppress_errors($suppressErrors);
+ }
}
diff --git a/plugin/Record/RecordManagerReadForm.php b/plugin/Record/RecordManagerReadForm.php
index e4ce2d852..55cadc5bc 100644
--- a/plugin/Record/RecordManagerReadForm.php
+++ b/plugin/Record/RecordManagerReadForm.php
@@ -265,4 +265,23 @@ public function getCountByType()
return $returnValues;
}
+
+ /**
+ *
+ * @param int $formId
+ * @return array
+ *
+ */
+
+ public function readActivityConfigByFormId(int $formId): array
+ {
+ $prefix = $this->getTablePrefix();
+ $pWpDb = $this->getWpdb();
+
+ $sqlFields = "SELECT *
+ FROM {$prefix}oo_plugin_form_activityconfig
+ WHERE `".esc_sql($this->getIdColumnMain())."` = ".esc_sql($formId)."";
+
+ return $pWpDb->get_row($sqlFields, ARRAY_A) ?? [];
+ }
}
\ No newline at end of file
diff --git a/plugin/Record/RecordManagerUpdateForm.php b/plugin/Record/RecordManagerUpdateForm.php
index 05d84360f..f365ca21c 100644
--- a/plugin/Record/RecordManagerUpdateForm.php
+++ b/plugin/Record/RecordManagerUpdateForm.php
@@ -93,4 +93,23 @@ public function updateContactTypeByRow(array $contactTypes): bool
return $result;
}
+
+ /**
+ *
+ * @param array $row
+ * @return bool
+ *
+ */
+
+ public function updateActivityConfigByRow(array $row): bool
+ {
+ $prefix = $this->getTablePrefix();
+ $pWpDb = $this->getWpdb();
+ $pWpDb->delete($prefix.self::TABLENAME_ACTIVITY_CONFIG_FORM, ['form_id' => $this->getRecordId()]);
+
+ $result = true;
+ $row['form_id'] = $this->getRecordId();
+
+ return $result && $pWpDb->insert($pWpDb->prefix.self::TABLENAME_ACTIVITY_CONFIG_FORM, $row);
+ }
}
diff --git a/plugin/Record/RecordStructure.php b/plugin/Record/RecordStructure.php
index a3a5db087..d38fc60ea 100644
--- a/plugin/Record/RecordStructure.php
+++ b/plugin/Record/RecordStructure.php
@@ -209,6 +209,28 @@ class RecordStructure
self::EMPTY_VALUE => '',
),
),
+ RecordManager::TABLENAME_ACTIVITY_CONFIG_FORM => array(
+ 'write_activity' => array(
+ self::NULL_ALLOWED => false,
+ self::EMPTY_VALUE => 0,
+ ),
+ 'action_kind' => array(
+ self::NULL_ALLOWED => false,
+ self::EMPTY_VALUE => '',
+ ),
+ 'action_type' => array(
+ self::NULL_ALLOWED => false,
+ self::EMPTY_VALUE => '',
+ ),
+ 'characteristic' => array(
+ self::NULL_ALLOWED => false,
+ self::EMPTY_VALUE => '',
+ ),
+ 'remark' => array(
+ self::NULL_ALLOWED => false,
+ self::EMPTY_VALUE => '',
+ ),
+ ),
);
diff --git a/plugin/Renderer/InputFieldTextAreaRenderer.php b/plugin/Renderer/InputFieldTextAreaRenderer.php
new file mode 100644
index 000000000..c8d438f17
--- /dev/null
+++ b/plugin/Renderer/InputFieldTextAreaRenderer.php
@@ -0,0 +1,60 @@
+.
+ *
+ */
+
+namespace onOffice\WPlugin\Renderer;
+
+use Exception;
+
+/**
+ *
+ * @url http://www.onoffice.de
+ * @copyright 2003-2024, onOffice(R) GmbH
+ *
+ */
+
+class InputFieldTextAreaRenderer
+ extends InputFieldRenderer
+{
+ /**
+ *
+ * @param string $type
+ * @param string $name
+ * @param string $value
+ *
+ * @throws Exception
+ */
+
+ public function __construct($type, $name, $value = null)
+ {
+ parent::__construct($type, $name, $value);
+ }
+
+
+ /**
+ *
+ */
+
+ public function render()
+ {
+ echo '';
+ }
+}
diff --git a/plugin/Renderer/InputModelRenderer.php b/plugin/Renderer/InputModelRenderer.php
index f25235d2d..e446de641 100644
--- a/plugin/Renderer/InputModelRenderer.php
+++ b/plugin/Renderer/InputModelRenderer.php
@@ -299,6 +299,11 @@ private function createInputField(InputModelBase $pInputModel, FormModel $pFormM
$pInstance->setValue($pInputModel->getValue());
$pInstance->setLabel($pInputModel->getLabel());
break;
+
+ case InputModelBase::HTML_TYPE_TEXTAREA:
+ $pInstance = new InputFieldTextAreaRenderer('textarea', $elementName);
+ $pInstance->setValue($pInputModel->getValue());
+ break;
}
if ($pInstance !== null) {
diff --git a/tests/TestClassDataFormConfiguration.php b/tests/TestClassDataFormConfiguration.php
index 242a014f8..638d44bb6 100644
--- a/tests/TestClassDataFormConfiguration.php
+++ b/tests/TestClassDataFormConfiguration.php
@@ -67,6 +67,11 @@ public function prepare()
$pDataFormConfiguration->addMarkdownFields('test3');
$pDataFormConfiguration->setShowEstateContext(true);
$pDataFormConfiguration->addHiddenFields('test-hidden');
+ $pDataFormConfiguration->setWriteActivity(true);
+ $pDataFormConfiguration->setActionKind('test1');
+ $pDataFormConfiguration->setActionType('test2');
+ $pDataFormConfiguration->setCharacteristic('test3');
+ $pDataFormConfiguration->setRemark('comment');
$this->_pDataFormConfiguration = $pDataFormConfiguration;
}
@@ -103,6 +108,11 @@ public function testGetterSetter()
$this->assertEquals('form', $pDataFormConfiguration->getModule());
$this->assertTrue($pDataFormConfiguration->getShowEstateContext());
$this->assertEquals(['test-hidden'], $pDataFormConfiguration->getHiddenFields());
+ $this->assertTrue($pDataFormConfiguration->getWriteActivity());
+ $this->assertEquals('test1', $pDataFormConfiguration->getActionKind());
+ $this->assertEquals('test2', $pDataFormConfiguration->getActionType());
+ $this->assertEquals('test3', $pDataFormConfiguration->getCharacteristic());
+ $this->assertEquals('comment', $pDataFormConfiguration->getRemark());
}
@@ -139,5 +149,10 @@ public function testSetDefaultFields()
$this->assertEquals([], $pDataFormConfiguration->getAvailableOptionsFields());
$this->assertEquals([], $pDataFormConfiguration->getMarkdownFields());
$this->assertFalse($pDataFormConfiguration->getShowEstateContext());
+ $this->assertFalse($pDataFormConfiguration->getWriteActivity());
+ $this->assertEquals('', $pDataFormConfiguration->getActionKind());
+ $this->assertEquals('', $pDataFormConfiguration->getActionType());
+ $this->assertEquals('', $pDataFormConfiguration->getCharacteristic());
+ $this->assertEquals('', $pDataFormConfiguration->getRemark());
}
}
diff --git a/tests/TestClassDataFormConfigurationFactory.php b/tests/TestClassDataFormConfigurationFactory.php
index a521a99b6..211fbe75a 100644
--- a/tests/TestClassDataFormConfigurationFactory.php
+++ b/tests/TestClassDataFormConfigurationFactory.php
@@ -99,6 +99,12 @@ public function prepare()
['testForm3', $this->getBaseRow(3, Form::TYPE_INTEREST)],
['testForm4', $this->getBaseRow(4, Form::TYPE_APPLICANT_SEARCH)],
]));
+ $this->_pRecordManagerReadForm->method('readActivityConfigByFormId')->will($this->returnValueMap([
+ [1, $this->getActivityConfigRow(1)],
+ [2, $this->getActivityConfigRow(2)],
+ [3, $this->getActivityConfigRow(3)],
+ [6, $this->getActivityConfigRow(6)]
+ ]));
$this->_pGeoPositionFieldHandler->method('getActiveFields')->will($this->returnValue([
GeoPosition::ESTATE_LIST_SEARCH_COUNTRY,
@@ -320,6 +326,11 @@ private function assertFactoryOutput(string $class, string $formType,
$this->assertTrue($pDataFormConfiguration->getCheckDuplicateOnCreateAddress());
$this->assertTrue($pDataFormConfiguration->getCreateAddress());
$this->assertEquals(['contactSpecialField1'], $pDataFormConfiguration->getAvailableOptionsFields());
+ $this->assertTrue($pDataFormConfiguration->getWriteActivity());
+ $this->assertEquals('action_kind1', $pDataFormConfiguration->getActionKind());
+ $this->assertEquals('action_type1', $pDataFormConfiguration->getActionType());
+ $this->assertEquals('action_kind1, action_type1', $pDataFormConfiguration->getCharacteristic());
+ $this->assertEquals('comment', $pDataFormConfiguration->getRemark());
break;
case Form::TYPE_OWNER:
/* @var $pDataFormConfiguration DataFormConfigurationOwner */
@@ -328,12 +339,22 @@ private function assertFactoryOutput(string $class, string $formType,
$this->assertEquals('A Subject', $pDataFormConfiguration->getSubject());
$this->assertEquals('test@my-onoffice.com', $pDataFormConfiguration->getRecipient());
$this->assertEquals(['ownerSpecialField1'], $pDataFormConfiguration->getAvailableOptionsFields());
+ $this->assertTrue($pDataFormConfiguration->getWriteActivity());
+ $this->assertEquals('action_kind1', $pDataFormConfiguration->getActionKind());
+ $this->assertEquals('action_type1', $pDataFormConfiguration->getActionType());
+ $this->assertEquals('action_kind1, action_type1', $pDataFormConfiguration->getCharacteristic());
+ $this->assertEquals('comment', $pDataFormConfiguration->getRemark());
break;
case Form::TYPE_INTEREST:
/* @var $pDataFormConfiguration DataFormConfigurationInterest */
$this->assertTrue($pDataFormConfiguration->getCheckDuplicateOnCreateAddress());
$this->assertEquals('A Subject', $pDataFormConfiguration->getSubject());
$this->assertEquals('test@my-onoffice.com', $pDataFormConfiguration->getRecipient());
+ $this->assertTrue($pDataFormConfiguration->getWriteActivity());
+ $this->assertEquals('action_kind1', $pDataFormConfiguration->getActionKind());
+ $this->assertEquals('action_type1', $pDataFormConfiguration->getActionType());
+ $this->assertEquals('action_kind1, action_type1', $pDataFormConfiguration->getCharacteristic());
+ $this->assertEquals('comment', $pDataFormConfiguration->getRemark());
break;
case Form::TYPE_APPLICANT_SEARCH:
/* @var $pDataFormConfiguration DataFormConfigurationApplicantSearch */
@@ -451,4 +472,24 @@ private function getBaseRow(int $formId, string $formType): array
'default_recipient' => 'default@my-onoffice.com'
];
}
+
+ /**
+ *
+ * @param int $formId
+ * @return array
+ *
+ */
+
+ private function getActivityConfigRow(int $formId): array
+ {
+ return [
+ 'form_activityconfig_id' => 1,
+ 'form_id' => $formId,
+ 'write_activity' => '1',
+ 'action_kind' => 'action_kind1',
+ 'action_type' => 'action_type1',
+ 'characteristic' => 'action_kind1, action_type1',
+ 'remark' => 'comment'
+ ];
+ }
}
diff --git a/tests/TestClassDatabaseChanges.php b/tests/TestClassDatabaseChanges.php
index a3f0d04e0..baa1cea49 100644
--- a/tests/TestClassDatabaseChanges.php
+++ b/tests/TestClassDatabaseChanges.php
@@ -118,7 +118,7 @@ public function testInstall(): array
$this->assertGreaterThanOrEqual(self::NUM_NEW_TABLES, count($this->_createQueries));
$dbversion = $this->_pDbChanges->getDbVersion();
- $this->assertEquals(50, $dbversion);
+ $this->assertEquals(51, $dbversion);
return $this->_createQueries;
}
@@ -271,7 +271,7 @@ public function testDeleteMessageFieldApplicantSearchForm()
*/
public function testMaxVersion()
{
- $this->assertEquals(50, DatabaseChanges::MAX_VERSION);
+ $this->assertEquals(51, DatabaseChanges::MAX_VERSION);
}
diff --git a/tests/TestClassFormModelBuilderDBForm.php b/tests/TestClassFormModelBuilderDBForm.php
index 64ab4f0a7..ed78b2f26 100644
--- a/tests/TestClassFormModelBuilderDBForm.php
+++ b/tests/TestClassFormModelBuilderDBForm.php
@@ -38,6 +38,7 @@
use WP_UnitTestCase;
use onOffice\WPlugin\Field\Collection\FieldsCollectionBuilderShort;
use onOffice\WPlugin\Types\FieldTypes;
+use onOffice\WPlugin\SDKWrapper;
class TestClassFormModelBuilderDBForm
extends WP_UnitTestCase
@@ -98,6 +99,24 @@ public function prepare()
return $this->_pFieldsCollectionBuilderShort;
}));
+ $pSDKWrapperMocker = new SDKWrapperMocker();
+ $response = json_decode
+ (file_get_contents(__DIR__ . '/resources/ApiResponseActionKindTypes.json'), true);
+ /* @var $pSDKWrapperMocker SDKWrapperMocker */
+
+ $pSDKWrapperMocker->addResponseByParameters
+ (onOfficeSDK::ACTION_ID_GET, 'actionkindtypes', '', ['lang'=> "ENG"], null, $response);
+
+ $parameters = [
+ 'labels' => true,
+ 'language' => "ENG",
+ 'fieldList' => ['merkmal', 'HerkunftKontakt'],
+ 'modules' => ['agentsLog', 'address']
+ ];
+ $pSDKWrapperMocker->addResponseByParameters
+ (onOfficeSDK::ACTION_ID_GET, 'fields', '', $parameters, null, $this->getResponseFieldCharacteristic());
+
+ $this->_pContainer->set(SDKWrapper::class, $pSDKWrapperMocker);
$this->_pInstance = new FormModelBuilderDBForm($this->_pContainer);
}
@@ -422,4 +441,164 @@ public function testCreateSearchFieldForFieldLists()
$this->assertInstanceOf(InputModelDB::class, $pInputModelDB);
$this->assertEquals($pInputModelDB->getHtmlType(), 'searchFieldForFieldLists');
}
+
+ /**
+ * @covers onOffice\WPlugin\Model\FormModelBuilder\FormModelBuilderDBForm::createInputModelCharacteristic
+ * @covers onOffice\WPlugin\Model\FormModelBuilder\FormModelBuilderDBForm::fetchDataTypesOfActionAndCharacteristics
+ * @covers onOffice\WPlugin\Model\FormModelBuilder\FormModelBuilderDBForm::generate
+ */
+ public function testCreateInputModelCharacteristic()
+ {
+ $this->_pInstance->setFormType('contact');
+
+ $this->_pInstance->generate('test');
+ $pInputModelDB = $this->_pInstance->createInputModelCharacteristic();
+
+ $this->assertInstanceOf(InputModelDB::class, $pInputModelDB);
+ $this->assertEquals(['invoiceOpen', 'invoiceOpen2'], $pInputModelDB->getValuesAvailable());
+ $this->assertTrue($pInputModelDB->getIsMulti());
+ $this->assertEquals($pInputModelDB->getHtmlType(), 'select2');
+ }
+
+ /**
+ * @covers onOffice\WPlugin\Model\FormModelBuilder\FormModelBuilderDBForm::createInputModelActionKind
+ * @covers onOffice\WPlugin\Model\FormModelBuilder\FormModelBuilderDBForm::fetchDataTypesOfActionAndCharacteristics
+ * @covers onOffice\WPlugin\Model\FormModelBuilder\FormModelBuilderDBForm::generate
+ */
+ public function testCreateInputModelActionKind()
+ {
+ $data = [
+ '' => "Please choose",
+ 'Immofeedback / Terminnachbereitung' => "Immofeedback / Terminnachbereitung",
+ 'Termin' => "Termin",
+ 'AGB bestätigt' => "AGB bestätigt",
+ 'Kaufpreisangebot' => "Kaufpreisangebot",
+ 'Widerruf bestätigt' => "Widerruf bestätigt"
+ ];
+ $this->_pInstance->setFormType('contact');
+
+ $this->_pInstance->generate('test');
+ $pInputModelDB = $this->_pInstance->createInputModelActionKind();
+
+ $this->assertInstanceOf(InputModelDB::class, $pInputModelDB);
+ $this->assertEquals($data, $pInputModelDB->getValuesAvailable());
+ $this->assertEquals($pInputModelDB->getHtmlType(), 'select');
+ }
+
+ /**
+ * @covers onOffice\WPlugin\Model\FormModelBuilder\FormModelBuilderDBForm::createInputModelActionType
+ * @covers onOffice\WPlugin\Model\FormModelBuilder\FormModelBuilderDBForm::fetchDataTypesOfActionAndCharacteristics
+ * @covers onOffice\WPlugin\Model\FormModelBuilder\FormModelBuilderDBForm::generate
+ */
+ public function testCreateInputModelActionType()
+ {
+ $this->_pInstance->setFormType('contact');
+
+ $this->_pInstance->generate('test');
+ $pInputModelDB = $this->_pInstance->createInputModelActionType();
+
+ $this->assertInstanceOf(InputModelDB::class, $pInputModelDB);
+ $this->assertEquals($pInputModelDB->getHtmlType(), 'select');
+ }
+
+ /**
+ * @covers onOffice\WPlugin\Model\FormModelBuilder\FormModelBuilderDBForm::createInputModelWriteActivity
+ * @covers onOffice\WPlugin\Model\FormModelBuilder\FormModelBuilderDBForm::fetchDataTypesOfActionAndCharacteristics
+ */
+ public function testCreateInputModelWriteActivity()
+ {
+ $this->_pInstance->setFormType('contact');
+
+ $pInputModelDB = $this->_pInstance->createInputModelWriteActivity();
+
+ $this->assertInstanceOf(InputModelDB::class, $pInputModelDB);
+ $this->assertEquals($pInputModelDB->getHtmlType(), 'checkbox');
+ }
+
+ /**
+ * @covers onOffice\WPlugin\Model\FormModelBuilder\FormModelBuilderDBForm::createInputModelRemark
+ * @covers onOffice\WPlugin\Model\FormModelBuilder\FormModelBuilderDBForm::fetchDataTypesOfActionAndCharacteristics
+ */
+ public function testCreateInputModelRemark()
+ {
+ $this->_pInstance->setFormType('contact');
+
+ $pInputModelDB = $this->_pInstance->createInputModelRemark();
+
+ $this->assertInstanceOf(InputModelDB::class, $pInputModelDB);
+ $this->assertEquals($pInputModelDB->getHtmlType(), 'textarea');
+ }
+
+ /**
+ * @covers onOffice\WPlugin\Model\FormModelBuilder\FormModelBuilderDBForm::createInputModelOriginContact
+ * @covers onOffice\WPlugin\Model\FormModelBuilder\FormModelBuilderDBForm::fetchDataTypesOfActionAndCharacteristics
+ */
+ public function testCreateInputModelOriginContact()
+ {
+ $this->_pInstance->setFormType('contact');
+
+ $this->_pInstance->generate('test');
+ $pInputModelDB = $this->_pInstance->createInputModelOriginContact();
+
+ $this->assertInstanceOf(InputModelDB::class, $pInputModelDB);
+ $this->assertEquals($pInputModelDB->getHtmlType(), 'select');
+ }
+
+ /**
+ *
+ */
+ private function getResponseFieldCharacteristic()
+ {
+ $responseStr = '
+ {
+ "actionid": "urn:onoffice-de-ns:smart:2.5:smartml:action:get",
+ "resourceid": "",
+ "resourcetype": "fields",
+ "cacheable": true,
+ "identifier": "",
+ "data": {
+ "meta": {
+ "cntabsolute": null
+ },
+ "records": [
+ {
+ "id": "agentsLog",
+ "type": "",
+ "elements": {
+ "merkmal": {
+ "type": "multiselect",
+ "length": null,
+ "permittedvalues": [
+ "invoiceOpen",
+ "invoiceOpen2"
+ ],
+ "default": null,
+ "filters": [],
+ "dependencies": [],
+ "compoundFields": []
+ },
+ "HerkunftKontakt": {
+ "type": "multiselect",
+ "length": null,
+ "permittedvalues": [
+ "invoiceOpen",
+ "invoiceOpen2"
+ ],
+ "default": null,
+ "filters": [],
+ "dependencies": [],
+ "compoundFields": []
+ }
+ }
+ }
+ ]
+ },
+ "status": {
+ "errorcode": 0,
+ "message": "OK"
+ }
+ }';
+
+ return json_decode($responseStr, true);
+ }
}
diff --git a/tests/TestClassFormPostContact.php b/tests/TestClassFormPostContact.php
index a5bd64d03..3a6026c42 100644
--- a/tests/TestClassFormPostContact.php
+++ b/tests/TestClassFormPostContact.php
@@ -181,6 +181,7 @@ public function prepare()
$this->configureSDKWrapperForCreateAddress();
$this->configureSDKWrapperForCreateAddressWithDuplicateCheck();
$this->configureSDKWrapperForFieldsAddressEstate();
+ $this->configureSDKWrapperForCreateAgentsLog();
}
@@ -325,6 +326,29 @@ private function configureSDKWrapperForCreateAddressWithDuplicateCheck()
}
+ /**
+ *
+ */
+
+ private function configureSDKWrapperForCreateAgentsLog()
+ {
+ $parameters = [
+ 'addressids' => [320],
+ 'actionkind' => 'ActionKind',
+ 'actiontype' => 'ActionType',
+ 'origincontact' => 'originContact',
+ 'features' => ['Characteristic1', 'Characteristic2'],
+ 'note' => 'comment'
+ ];
+
+ $responseJson = file_get_contents
+ (__DIR__.'/resources/FormPostContact/ApiResponseCreateAgentLog.json');
+ $response = json_decode($responseJson, true);
+
+ $this->_pSDKWrapperMocker->addResponseByParameters
+ (onOfficeSDK::ACTION_ID_CREATE, 'agentslog', '', $parameters, null, $response);
+ }
+
/**
*
*/
@@ -494,6 +518,40 @@ public function testFormWhenHoneypotInactive()
$this->assertEquals(FormPost::MESSAGE_SUCCESS, $pFormData->getStatus());
}
+
+ /**
+ *
+ */
+
+ public function testCreateAgentsLog()
+ {
+ $_POST = [
+ 'Vorname' => 'John',
+ 'Name' => 'Doe',
+ 'Email' => 'john.doe@my-onoffice.com',
+ 'Plz' => '52068',
+ 'Ort' => 'Aachen',
+ 'Telefon1' => '0815/2345677',
+ 'AGB_akzeptiert' => 'y',
+ 'newsletter' => 'y',
+ 'Id' => '1337',
+ 'Anrede' => '',
+ 'tmpField' => 'content',
+ ];
+
+ $pDataFormConfiguration = $this->getNewDataFormConfiguration();
+ $pDataFormConfiguration->setWriteActivity(true);
+ $pDataFormConfiguration->setActionKind('ActionKind');
+ $pDataFormConfiguration->setActionType('ActionType');
+ $pDataFormConfiguration->setCharacteristic('Characteristic1,Characteristic2');
+ $pDataFormConfiguration->setOriginContact('originContact');
+ $pDataFormConfiguration->setRemark('comment');
+ $this->_pFormPostContact->initialCheck($pDataFormConfiguration, 2);
+
+ $pFormData = $this->_pFormPostContact->getFormDataInstance('contactForm', 2);
+ $this->assertEquals(FormPost::MESSAGE_SUCCESS, $pFormData->getStatus());
+ }
+
/**
*
* @return DataFormConfigurationContact
diff --git a/tests/TestClassInputFieldTextAreaRenderer.php b/tests/TestClassInputFieldTextAreaRenderer.php
new file mode 100644
index 000000000..9b95cb503
--- /dev/null
+++ b/tests/TestClassInputFieldTextAreaRenderer.php
@@ -0,0 +1,76 @@
+.
+ *
+ */
+
+declare (strict_types=1);
+
+namespace onOffice\tests;
+
+use onOffice\WPlugin\Installer\DatabaseChanges;
+use onOffice\WPlugin\WP\WPOptionWrapperTest;
+use DI\Container;
+use DI\ContainerBuilder;
+use WP_UnitTestCase;
+use onOffice\WPlugin\Renderer\InputFieldTextAreaRenderer;
+
+/**
+ * @runTestsInSeparateProcesses
+ * @preserveGlobalState disabled
+ */
+class TestClassInputFieldTextAreaRenderer
+ extends WP_UnitTestCase
+{
+ /**
+ * @before
+ */
+ public function prepare()
+ {
+ global $wpdb;
+
+ $pWpOption = new WPOptionWrapperTest();
+ $pDbChanges = new DatabaseChanges($pWpOption, $wpdb);
+ $pDbChanges->install();
+ }
+
+ /**
+ * @throws \Exception
+ */
+ public function testRenderEmptyValues()
+ {
+ $pSubject = new InputFieldTextAreaRenderer('textarea', 'testRenderer');
+ ob_start();
+ $pSubject->render();
+ $output = ob_get_clean();
+ $this->assertEquals('', $output);
+ }
+
+ /**
+ * @throws \Exception
+ */
+ public function testRenderWithValues()
+ {
+ $pSubject = new InputFieldTextAreaRenderer('textarea', 'testRenderer');
+ $pSubject->setValue('test1');
+ ob_start();
+ $pSubject->render();
+ $output = ob_get_clean();
+ $this->assertEquals('', $output);
+ }
+}
diff --git a/tests/TestClassRecordManagerDeleteForm.php b/tests/TestClassRecordManagerDeleteForm.php
index 7edf295bb..651afa2f2 100644
--- a/tests/TestClassRecordManagerDeleteForm.php
+++ b/tests/TestClassRecordManagerDeleteForm.php
@@ -66,11 +66,12 @@ public function prepare()
public function testDeleteByIds()
{
- $this->_pWpdbMock->expects($this->exactly(12))->method('delete')->with($this->logicalOr(
+ $this->_pWpdbMock->expects($this->exactly(15))->method('delete')->with($this->logicalOr(
$this->equalTo('wp_test_oo_plugin_forms'),
$this->equalTo('wp_test_oo_plugin_form_fieldconfig'),
$this->equalTo('wp_test_oo_plugin_fieldconfig_form_defaults'),
- $this->equalTo('wp_test_oo_plugin_fieldconfig_form_customs_labels')
+ $this->equalTo('wp_test_oo_plugin_fieldconfig_form_customs_labels'),
+ $this->equalTo('wp_test_oo_plugin_form_activityconfig')
));
$this->_pWpdbMock->expects($this->once())->method('prepare')
->with('DELETE FROM wp_test_oo_plugin_fieldconfig_form_defaults_values '
@@ -96,11 +97,12 @@ public function testDeleteByIds()
public function testDeleteTranslatedLabelsByIds()
{
- $this->_pWpdbMock->expects($this->exactly(12))->method('delete')->with($this->logicalOr(
+ $this->_pWpdbMock->expects($this->exactly(15))->method('delete')->with($this->logicalOr(
$this->equalTo('wp_test_oo_plugin_forms'),
$this->equalTo('wp_test_oo_plugin_form_fieldconfig'),
$this->equalTo('wp_test_oo_plugin_fieldconfig_form_defaults'),
- $this->equalTo('wp_test_oo_plugin_fieldconfig_form_customs_labels')
+ $this->equalTo('wp_test_oo_plugin_fieldconfig_form_customs_labels'),
+ $this->equalTo('wp_test_oo_plugin_form_activityconfig')
));
$this->_pWpdbMock->expects($this->once())->method('prepare')
->with('DELETE FROM wp_test_oo_plugin_fieldconfig_form_translated_labels '
diff --git a/tests/TestClassRecordManagerDuplicateForm.php b/tests/TestClassRecordManagerDuplicateForm.php
index 998cf0f8d..72c057524 100644
--- a/tests/TestClassRecordManagerDuplicateForm.php
+++ b/tests/TestClassRecordManagerDuplicateForm.php
@@ -154,6 +154,18 @@ public function testDuplicateByIds()
]
];
+ $sampleDataActivityConfigArr = [
+ [
+ 'form_activityconfig_id' => 43,
+ 'form_id' => 23,
+ 'write_activity' => '1',
+ 'action_kind' => 'action_kind',
+ 'action_type' => 'action_type',
+ 'characteristic' => 'characteristic1,characteristic2',
+ 'remark' => 'test1',
+ ]
+ ];
+
$recordRootCopy = (object) [
'form_id' => 22,
'name' => 'list view root - Copy 1',
@@ -174,16 +186,17 @@ public function testDuplicateByIds()
->method( 'get_row' )
->willReturnOnConsecutiveCalls( $recordRootCopy );
- $this->_pWPDB->expects($this->exactly(4))
+ $this->_pWPDB->expects($this->exactly(5))
->method('get_col')
->willReturnOnConsecutiveCalls(
$colData,
$colData,
$colData,
+ $colData,
$colData
);
- $this->_pWPDB->expects( $this->exactly( 6 ) )
+ $this->_pWPDB->expects( $this->exactly( 7 ) )
->method( 'get_results' )
->willReturnOnConsecutiveCalls(
$fieldConfigRecordOutputArr,
@@ -191,7 +204,8 @@ public function testDuplicateByIds()
$sampleDataObj,
$sampleDataArr,
$sampleDataObj,
- $sampleDataArr
+ $sampleDataArr,
+ $sampleDataActivityConfigArr
);
$this->_pWPDB->insert_id = 23;
diff --git a/tests/TestClassRecordManagerInsertGeneric.php b/tests/TestClassRecordManagerInsertGeneric.php
index f8011ac5a..2e2f6ab70 100644
--- a/tests/TestClassRecordManagerInsertGeneric.php
+++ b/tests/TestClassRecordManagerInsertGeneric.php
@@ -168,4 +168,48 @@ public function testGetTablePrefix()
{
$this->assertEquals('wptests_', $this->_pSubject->getTablePrefix());
}
+
+
+ /**
+ *
+ */
+
+ public function testInsertSingleRow()
+ {
+ $recordInput = [
+ RecordManager::TABLENAME_ACTIVITY_CONFIG_FORM => [
+ 'form_id' => 1,
+ 'write_activity' => true,
+ 'action_kind' => 'action_kind',
+ 'action_type' => null,
+ 'characteristic' => 'characteristic1,characteristic2',
+ 'remark' => 'comment',
+ ],
+ ];
+
+ $recordOutput = [
+ 'form_id' => 1,
+ 'write_activity' => '1',
+ 'action_kind' => 'action_kind',
+ 'action_type' => '',
+ 'characteristic' => 'characteristic1,characteristic2',
+ 'remark' => 'comment'
+ ];
+
+ $this->_pWPDB->expects($this->once())->method('insert')
+ ->with('testPrefix_'.RecordManager::TABLENAME_ACTIVITY_CONFIG_FORM, $recordOutput)
+ ->will($this->returnValue(1));
+ $this->_pSubject->insertSingleRow($recordInput, RecordManager::TABLENAME_ACTIVITY_CONFIG_FORM);
+ }
+
+ /**
+ *
+ */
+
+ public function testInsertSingleRowFail()
+ {
+ $this->expectException(\onOffice\WPlugin\Record\RecordManagerInsertException::class);
+ $this->_pWPDB->expects($this->once())->method('insert')->will($this->returnValue(false));
+ $this->_pSubject->insertSingleRow([RecordManager::TABLENAME_ACTIVITY_CONFIG_FORM => [['a' => 'b']]], RecordManager::TABLENAME_ACTIVITY_CONFIG_FORM);
+ }
}
diff --git a/tests/TestClassRecordManagerReadForm.php b/tests/TestClassRecordManagerReadForm.php
index b93989489..21bdca489 100644
--- a/tests/TestClassRecordManagerReadForm.php
+++ b/tests/TestClassRecordManagerReadForm.php
@@ -147,6 +147,24 @@ private function getContactTypesArray(int $formId): array
];
}
+ /**
+ * @param int $formId
+ *
+ * @return array
+ */
+ private function getActivityConfigRow(int $formId): array
+ {
+ return [
+ 'form_activityconfig_id' => 1,
+ 'form_id' => $formId,
+ 'write_activity' => '1',
+ 'action_kind' => 'action_kind',
+ 'action_type' => 'action_type',
+ 'characteristic' => 'characteristic1,characteristic2',
+ 'remark' => 'comment'
+ ];
+ }
+
public function testGetRecords()
{
$pFieldsForm = $this->_pRecordManagerReadForm->getRecords();
@@ -216,4 +234,16 @@ public function testReadContactTypesByFormId()
$pFieldsForm = $this->_pRecordManagerReadForm->readContactTypesByFormId(1);
$this->assertEquals(2, count($pFieldsForm));
}
+
+ /**
+ *
+ */
+ public function testReadActivityConfigByFormId()
+ {
+ $this->_pRecordManagerReadForm->method('readActivityConfigByFormId')->will($this->returnValueMap([
+ [1, $this->getActivityConfigRow(1)]
+ ]));
+ $pActivityConfig = $this->_pRecordManagerReadForm->readActivityConfigByFormId(1);
+ $this->assertEquals(7, count($pActivityConfig));
+ }
}
diff --git a/tests/resources/ApiResponseActionKindTypes.json b/tests/resources/ApiResponseActionKindTypes.json
new file mode 100644
index 000000000..1f3d8dbb8
--- /dev/null
+++ b/tests/resources/ApiResponseActionKindTypes.json
@@ -0,0 +1,86 @@
+{
+ "actionid": "urn:onoffice-de-ns:smart:2.5:smartml:action:get",
+ "resourceid": "",
+ "resourcetype": "actionkindtypes",
+ "cacheable": true,
+ "identifier": "",
+ "data": {
+ "meta": {
+ "cntabsolute": null
+ },
+ "records": [
+ {
+ "id": 0,
+ "type": "actionkind",
+ "elements": {
+ "key": "Immofeedback / Terminnachbereitung",
+ "label": "Immofeedback / Terminnachbereitung",
+ "types": {
+ "Neuer Aktionstyp": "Neuer Aktionstyp",
+ "Neuer Aktionstypd": "Neuer Aktionstypd",
+ "Neuer Aktionstypa": "Neuer Aktionstypa"
+ },
+ "default": "Neuer Aktionstyp"
+ }
+ },
+ {
+ "id": 1,
+ "type": "actionkind",
+ "elements": {
+ "key": "Termin",
+ "label": "Termin",
+ "types": {
+ "Besuch des Kunden im Beratungsbüro": "Besuch des Kunden im Beratungsbüro",
+ "Besuch beim Kunden zu Hause": "Besuch beim Kunden zu Hause",
+ "Kunde auf Baustelle getroffen": "Kunde auf Baustelle getroffen",
+ "Besichtigung": "Besichtigung",
+ "Notartermin": "Notartermin",
+ "Objektaufnahme": "Objektaufnahme",
+ "Beratung": "Beratung",
+ "Vertragstermin": "Vertragstermin",
+ "Urlaub": "Urlaub",
+ "Folgebesichtigung": "Folgebesichtigung"
+ },
+ "default": "Besuch des Kunden im Beratungsbüro"
+ }
+ },
+ {
+ "id": 2,
+ "type": "actionkind",
+ "elements": {
+ "key": "AGB bestätigt",
+ "label": "AGB bestätigt",
+ "types": [],
+ "default": null
+ }
+ },
+ {
+ "id": 3,
+ "type": "actionkind",
+ "elements": {
+ "key": "Kaufpreisangebot",
+ "label": "Kaufpreisangebot",
+ "types": [],
+ "default": null
+ }
+ },
+ {
+ "id": 4,
+ "type": "actionkind",
+ "elements": {
+ "key": "Widerruf bestätigt",
+ "label": "Widerruf bestätigt",
+ "types": {
+ "Kein vorzeitiger Beginn": "Kein vorzeitiger Beginn",
+ "Vorzeitiger Beginn": "Vorzeitiger Beginn"
+ },
+ "default": "Kein vorzeitiger Beginn"
+ }
+ }
+ ]
+ },
+ "status": {
+ "errorcode": 0,
+ "message": "OK"
+ }
+}
\ No newline at end of file
diff --git a/tests/resources/FormPostContact/ApiResponseCreateAgentLog.json b/tests/resources/FormPostContact/ApiResponseCreateAgentLog.json
new file mode 100644
index 000000000..9f42537f9
--- /dev/null
+++ b/tests/resources/FormPostContact/ApiResponseCreateAgentLog.json
@@ -0,0 +1,23 @@
+{
+ "actionid": "urn:onoffice-de-ns:smart:2.5:smartml:action:create",
+ "resourceid": "",
+ "resourcetype": "agentslog",
+ "cacheable": false,
+ "identifier": "",
+ "data": {
+ "meta": {
+ "cntabsolute": null
+ },
+ "records": [
+ {
+ "id": 6065,
+ "type": "agentsLog",
+ "elements": []
+ }
+ ]
+ },
+ "status": {
+ "errorcode": 0,
+ "message": "OK"
+ }
+}
\ No newline at end of file