Skip to content
Snippets Groups Projects
Verified Commit e3f517f2 authored by Damien's avatar Damien
Browse files

FEAT #8156 Syncho adjustments

parent 57a6f29f
No related branches found
No related tags found
No related merge requests found
...@@ -134,27 +134,72 @@ function manage_form($arr_id, $history, $id_action, $label_action, $status, $col ...@@ -134,27 +134,72 @@ function manage_form($arr_id, $history, $id_action, $label_action, $status, $col
if ($formValues['note_content_to_users'] != '') { if ($formValues['note_content_to_users'] != '') {
\Note\models\NoteModel::create(['identifier' => $res_id, 'tablename' => 'res_letterbox', 'user_id' => $_SESSION['user']['UserId'], 'coll_id' => 'letterbox_coll', 'note_text' => $formValues['note_content_to_users']]); \Note\models\NoteModel::create(['identifier' => $res_id, 'tablename' => 'res_letterbox', 'user_id' => $_SESSION['user']['UserId'], 'coll_id' => 'letterbox_coll', 'note_text' => $formValues['note_content_to_users']]);
} }
if (\SrcCore\models\CurlModel::isEnabled(['curlCallId' => 'closeResource'])) { if (\SrcCore\models\CurlModel::isEnabled(['curlCallId' => 'closeResource'])) {
$bodyData = []; $bodyData = [];
$config = \SrcCore\models\CurlModel::getConfigByCallId(['curlCallId' => 'closeResource']); $config = \SrcCore\models\CurlModel::getConfigByCallId(['curlCallId' => 'closeResource']);
if (!empty($config['rawData'])) { $resource = \Resource\models\ResModel::getOnView(['select' => ['external_id'], 'where' => ['res_id = ?'], 'data' => [$res_id]]);
$select = [];
foreach ($config['rawData'] as $value) { if (!empty($resource[0]['external_id'])) {
$select[] = $value; if (!empty($config['inObject'])) {
} $multipleObject = true;
foreach ($config['objects'] as $object) {
$select = [];
$tmpBodyData = [];
foreach ($object['rawData'] as $value) {
if ($value != 'note') {
$select[] = $value;
}
}
$document = \Resource\models\ResModel::getOnView(['select' => $select, 'where' => ['res_id = ?'], 'data' => [$res_id]]);
if (!empty($document[0])) {
foreach ($object['rawData'] as $key => $value) {
if ($value == 'note') {
$tmpBodyData[$key] = $formValues['note_content_to_users'];
} else {
$tmpBodyData[$key] = $document[0][$value];
}
}
}
if (!empty($object['data'])) {
$tmpBodyData = array_merge($tmpBodyData, $object['data']);
}
$document = \Resource\models\ResModel::getOnView(['select' => $select, 'where' => ['res_id = ?'], 'data' => [$res_id]]); $bodyData[$object['name']] = $tmpBodyData;
if (!empty($document[0])) { }
$bodyData = $document[0]; } else {
$multipleObject = false;
$select = [];
foreach ($config['rawData'] as $value) {
if ($value != 'note') {
$select[] = $value;
}
}
$document = \Resource\models\ResModel::getOnView(['select' => $select, 'where' => ['res_id = ?'], 'data' => [$res_id]]);
if (!empty($document[0])) {
foreach ($config['rawData'] as $key => $value) {
if ($value == 'note') {
$bodyData[$key] = $formValues['note_content_to_users'];
} else {
$bodyData[$key] = $document[0][$value];
}
}
}
if (!empty($config['data'])) {
$bodyData = array_merge($bodyData, $config['data']);
}
} }
}
if (!empty($config['data'])) { \SrcCore\models\CurlModel::exec(['curlCallId' => 'closeResource', 'bodyData' => $bodyData, 'multipleObject' => $multipleObject, 'noAuth' => true]);
$bodyData = array_merge($bodyData, $config['data']);
} }
\SrcCore\models\CurlModel::exec(['curlCallId' => 'closeResource', 'bodyData' => $bodyData]);
} }
} }
......
...@@ -2088,12 +2088,15 @@ function manage_form($arrId, $history, $actionId, $label_action, $status, $collI ...@@ -2088,12 +2088,15 @@ function manage_form($arrId, $history, $actionId, $label_action, $status, $collI
$select[] = 'address_id'; $select[] = 'address_id';
$document = \Resource\models\ResModel::getOnView(['select' => $select, 'where' => ['res_id = ?'], 'data' => [$resId]]); $document = \Resource\models\ResModel::getOnView(['select' => $select, 'where' => ['res_id = ?'], 'data' => [$resId]]);
if (!empty($document[0])) { if (!empty($document[0])) {
if ($getContact) { if ($getContact && !empty($document[0]['address_id'])) {
$contact = \Contact\models\ContactModel::getOnView(['select' => $columnsInContact, 'where' => ['ca_id = ?'], 'data' => [$document[0]['address_id']]]); $contact = \Contact\models\ContactModel::getOnView(['select' => $columnsInContact, 'where' => ['ca_id = ?'], 'data' => [$document[0]['address_id']]]);
} }
foreach ($object['rawData'] as $key => $value) { foreach ($object['rawData'] as $key => $value) {
if (in_array($value, $columnsInContact)) { if (in_array($value, $columnsInContact)) {
$tmpBodyData[$key] = $contact[0][$value]; $tmpBodyData[$key] = '';
if (!empty($contact[0][$value])) {
$tmpBodyData[$key] = $contact[0][$value];
}
} else { } else {
$tmpBodyData[$key] = $document[0][$value]; $tmpBodyData[$key] = $document[0][$value];
} }
...@@ -2107,9 +2110,9 @@ function manage_form($arrId, $history, $actionId, $label_action, $status, $collI ...@@ -2107,9 +2110,9 @@ function manage_form($arrId, $history, $actionId, $label_action, $status, $collI
$bodyData[$object['name']] = $tmpBodyData; $bodyData[$object['name']] = $tmpBodyData;
} }
if (!empty($config['file']) && $config['file'] == 'true') { if (!empty($config['file'])) {
$docserver = \Docserver\models\DocserverModel::getByDocserverId(['docserverId' => $_SESSION['indexing']['docserver_id'], 'select' => ['path_template']]); $docserver = \Docserver\models\DocserverModel::getByDocserverId(['docserverId' => $_SESSION['indexing']['docserver_id'], 'select' => ['path_template']]);
$bodyData['file'] = \SrcCore\models\CurlModel::makeCurlFile(['path' => $docserver['path_template'] . str_replace('#', '/', $_SESSION['indexing']['destination_dir']) . $_SESSION['indexing']['file_destination_name']]); $bodyData[$config['file']] = \SrcCore\models\CurlModel::makeCurlFile(['path' => $docserver['path_template'] . str_replace('#', '/', $_SESSION['indexing']['destination_dir']) . $_SESSION['indexing']['file_destination_name']]);
} }
} else { } else {
$multipleObject = false; $multipleObject = false;
...@@ -2132,9 +2135,9 @@ function manage_form($arrId, $history, $actionId, $label_action, $status, $collI ...@@ -2132,9 +2135,9 @@ function manage_form($arrId, $history, $actionId, $label_action, $status, $collI
} }
foreach ($config['rawData'] as $key => $value) { foreach ($config['rawData'] as $key => $value) {
if (in_array($value, $columnsInContact)) { if (in_array($value, $columnsInContact)) {
$tmpBodyData[$key] = $contact[0][$value]; $bodyData[$key] = $contact[0][$value];
} else { } else {
$tmpBodyData[$key] = $document[0][$value]; $bodyData[$key] = $document[0][$value];
} }
} }
...@@ -2143,12 +2146,6 @@ function manage_form($arrId, $history, $actionId, $label_action, $status, $collI ...@@ -2143,12 +2146,6 @@ function manage_form($arrId, $history, $actionId, $label_action, $status, $collI
if (!empty($config['data'])) { if (!empty($config['data'])) {
$bodyData = array_merge($bodyData, $config['data']); $bodyData = array_merge($bodyData, $config['data']);
} }
// if (!empty($config['file'])) {
// $docserver = \Docserver\models\DocserverModel::getByDocserverId(['docserverId' => $_SESSION['indexing']['docserver_id'], 'select' => ['path_template']]);
// $file = file_get_contents($docserver['path_template'] . str_replace('#', '/', $_SESSION['indexing']['destination_dir']) . $_SESSION['indexing']['file_destination_name']);
// $bodyData[$config['file']] = base64_encode($file);
// }
} }
$response = \SrcCore\models\CurlModel::exec(['curlCallId' => 'sendResourceToExternalApplication', 'bodyData' => $bodyData, 'multipleObject' => $multipleObject, 'noAuth' => true]); $response = \SrcCore\models\CurlModel::exec(['curlCallId' => 'sendResourceToExternalApplication', 'bodyData' => $bodyData, 'multipleObject' => $multipleObject, 'noAuth' => true]);
......
...@@ -374,31 +374,94 @@ if (isset($_POST['add']) && $_POST['add']) { ...@@ -374,31 +374,94 @@ if (isset($_POST['add']) && $_POST['add']) {
$_SESSION['data'], $_SESSION['data'],
$_SESSION['config']['databasetype'] $_SESSION['config']['databasetype']
); );
if (\SrcCore\models\CurlModel::isEnabled(['curlCallId' => 'sendAttachmentToExternalApplication'])) { if (\SrcCore\models\CurlModel::isEnabled(['curlCallId' => 'sendAttachmentToExternalApplication'])) {
$bodyData = []; $bodyData = [];
$config = \SrcCore\models\CurlModel::getConfigByCallId(['curlCallId' => 'sendAttachmentToExternalApplication']); $config = \SrcCore\models\CurlModel::getConfigByCallId(['curlCallId' => 'sendAttachmentToExternalApplication']);
$select = []; $columnsInContact = ['external_contact_id'];
foreach ($config['rawData'] as $value) { $resource = \Resource\models\ResModel::getOnView(['select' => ['external_id', 'address_id'], 'where' => ['res_id = ?'], 'data' => [$_SESSION['doc_id']]]);
$select[] = $value;
} if (!empty($resource[0]['external_id']) && !empty($resource[0]['address_id'])) {
if (!empty($config['inObject'])) {
$attachment = \Attachment\models\AttachmentModel::getOnView(['select' => $select, 'where' => ['res_id = ?'], 'data' => [$id]]); $multipleObject = true;
if (!empty($attachment[0])) {
$bodyData = $attachment[0]; foreach ($config['objects'] as $object) {
} $select = [];
$tmpBodyData = [];
if (!empty($config['data'])) { $getContact = false;
$bodyData = array_merge($bodyData, $config['data']); foreach ($object['rawData'] as $value) {
} if (in_array($value, $columnsInContact)) {
$getContact = true;
if (!empty($config['file'])) { } elseif (!in_array($value, ['external_id', 'address_id'])) {
$docserver = \Docserver\models\DocserverModel::getByDocserverId(['docserverId' => $storeResult['docserver_id'], 'select' => ['path_template']]); $select[] = $value;
$file = file_get_contents($docserver['path_template'] . str_replace('#', '/', $storeResult['destination_dir']) . $storeResult['file_destination_name']); }
$bodyData[$config['file']] = base64_encode($file); }
if (!empty($select)) {
$document = \Attachment\models\AttachmentModel::getOnView(['select' => $select, 'where' => ['res_id = ?'], 'data' => [$id]]);
}
if ($getContact) {
$contact = \Contact\models\ContactModel::getOnView(['select' => $columnsInContact, 'where' => ['ca_id = ?'], 'data' => [$resource[0]['address_id']]]);
}
foreach ($object['rawData'] as $key => $value) {
if (in_array($value, $columnsInContact)) {
$tmpBodyData[$key] = $contact[0][$value];
} elseif (in_array($value, ['external_id', 'address_id'])) {
$tmpBodyData[$key] = $resource[0][$value];
} else {
$tmpBodyData[$key] = $document[0][$value];
}
}
if (!empty($object['data'])) {
$tmpBodyData = array_merge($tmpBodyData, $object['data']);
}
$bodyData[$object['name']] = $tmpBodyData;
}
if (!empty($config['file'])) {
$docserver = \Docserver\models\DocserverModel::getByDocserverId(['docserverId' => $storeResult['docserver_id'], 'select' => ['path_template']]);
$bodyData[$config['file']] = \SrcCore\models\CurlModel::makeCurlFile(['path' => $docserver['path_template'] . str_replace('#', '/', $storeResult['destination_dir']) . $storeResult['file_destination_name']]);
}
} else {
$multipleObject = false;
$getContact = false;
$select = [];
foreach ($config['rawData'] as $value) {
if (in_array($value, $columnsInContact)) {
$getContact = true;
} elseif (!in_array($value, ['external_id', 'address_id'])) {
$select[] = $value;
}
}
$document = \Attachment\models\AttachmentModel::getOnView(['select' => $select, 'where' => ['res_id = ?'], 'data' => [$id]]);
if (!empty($document[0])) {
if ($getContact) {
$contact = \Contact\models\ContactModel::getOnView(['select' => $columnsInContact, 'where' => ['ca_id = ?'], 'data' => [$resource[0]['address_id']]]);
}
foreach ($config['rawData'] as $key => $value) {
if (in_array($value, $columnsInContact)) {
$bodyData[$key] = $contact[0][$value];
} elseif (in_array($value, ['external_id', 'address_id'])) {
$bodyData[$key] = $resource[0][$value];
} else {
$bodyData[$key] = $document[0][$value];
}
}
}
if (!empty($config['data'])) {
$bodyData = array_merge($bodyData, $config['data']);
}
}
$response = \SrcCore\models\CurlModel::exec(['curlCallId' => 'sendAttachmentToExternalApplication', 'bodyData' => $bodyData, 'multipleObject' => $multipleObject, 'noAuth' => true]);
} }
$response = \SrcCore\models\CurlModel::exec(['curlCallId' => 'sendAttachmentToExternalApplication', 'bodyData' => $bodyData]);
} }
} }
......
...@@ -53,7 +53,7 @@ class CurlModel ...@@ -53,7 +53,7 @@ class CurlModel
if (is_array($aArgs['bodyData']) && !empty($aArgs['bodyData']) && $aArgs['multipleObject']) { if (is_array($aArgs['bodyData']) && !empty($aArgs['bodyData']) && $aArgs['multipleObject']) {
$bodyData = []; $bodyData = [];
foreach ($aArgs['bodyData'] as $key => $value) { foreach ($aArgs['bodyData'] as $key => $value) {
if ($key == 'file') { if (is_object($value)) {
$bodyData[$key] = $value; $bodyData[$key] = $value;
} else { } else {
$bodyData[$key] = json_encode($value); $bodyData[$key] = json_encode($value);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment