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

FEAT #12149 TIME 1:00 Localeo timestamp + doc

parent 92de9435
No related branches found
No related tags found
No related merge requests found
...@@ -143,6 +143,13 @@ class LocaleoScript ...@@ -143,6 +143,13 @@ class LocaleoScript
return; return;
} }
if (!file_exists('bin/external/localeo/updateContact.timestamp')) {
$file = fopen('bin/external/localeo/updateContact.timestamp', 'w');
fwrite($file, time());
fclose($file);
return;
}
$dataToMerge = []; $dataToMerge = [];
if (!empty($configuration->updateContact->data)) { if (!empty($configuration->updateContact->data)) {
foreach ($configuration->updateContact->data as $value) { foreach ($configuration->updateContact->data as $value) {
...@@ -153,24 +160,18 @@ class LocaleoScript ...@@ -153,24 +160,18 @@ class LocaleoScript
\SrcCore\models\DatabasePDO::reset(); \SrcCore\models\DatabasePDO::reset();
new \SrcCore\models\DatabasePDO(['customId' => $customId]); new \SrcCore\models\DatabasePDO(['customId' => $customId]);
$where = ['enabled = ?', "external_id->>'localeoId' is not null"]; $time = file_get_contents('bin/external/localeo/updateContact.timestamp');
$data = [true];
if (file_exists('bin/external/localeo/updateContact.timestamp')) {
$time = file_get_contents('bin/external/localeo/updateContact.timestamp');
$where[] = 'modification_date > ?';
$data[] = date('Y-m-d H:i:s', $time);
}
$file = fopen('bin/external/localeo/updateContact.timestamp', 'w');
fwrite($file, time());
fclose($file);
$contacts = \Contact\models\ContactModel::get([ $contacts = \Contact\models\ContactModel::get([
'select' => ['*'], 'select' => ['*'],
'where' => $where, 'where' => ['enabled = ?', "external_id->>'localeoId' is not null", 'modification_date > ?'],
'data' => $data 'data' => [true, date('Y-m-d H:i:s', $time)]
]); ]);
$file = fopen('bin/external/localeo/updateContact.timestamp', 'w');
fwrite($file, time());
fclose($file);
foreach ($contacts as $contact) { foreach ($contacts as $contact) {
$externalId = json_decode($contact['external_id'], true); $externalId = json_decode($contact['external_id'], true);
...@@ -458,6 +459,13 @@ class LocaleoScript ...@@ -458,6 +459,13 @@ class LocaleoScript
return; return;
} }
if (!file_exists('bin/external/localeo/closeResource.timestamp')) {
$file = fopen('bin/external/localeo/closeResource.timestamp', 'w');
fwrite($file, time());
fclose($file);
return;
}
$dataToMerge = []; $dataToMerge = [];
if (!empty($configuration->closeResource->data)) { if (!empty($configuration->closeResource->data)) {
foreach ($configuration->closeResource->data as $value) { foreach ($configuration->closeResource->data as $value) {
...@@ -468,24 +476,18 @@ class LocaleoScript ...@@ -468,24 +476,18 @@ class LocaleoScript
\SrcCore\models\DatabasePDO::reset(); \SrcCore\models\DatabasePDO::reset();
new \SrcCore\models\DatabasePDO(['customId' => $customId]); new \SrcCore\models\DatabasePDO(['customId' => $customId]);
$where = ["external_id->>'localeoId' is not null", 'status = ?', 'closing_date is not null']; $time = file_get_contents('bin/external/localeo/closeResource.timestamp');
$data = [$status];
if (file_exists('bin/external/localeo/closeResource.timestamp')) {
$time = file_get_contents('bin/external/localeo/closeResource.timestamp');
$where[] = 'closing_date > ?';
$data[] = date('Y-m-d H:i:s', $time);
}
$file = fopen('bin/external/localeo/closeResource.timestamp', 'w');
fwrite($file, time());
fclose($file);
$resources = \Resource\models\ResModel::get([ $resources = \Resource\models\ResModel::get([
'select' => ['res_id', "external_id->>'localeoId' as \"localeoId\""], 'select' => ['res_id', "external_id->>'localeoId' as \"localeoId\""],
'where' => $where, 'where' => ["external_id->>'localeoId' is not null", 'status = ?', 'closing_date is not null', 'closing_date > ?'],
'data' => $data 'data' => [$status, date('Y-m-d H:i:s', $time)]
]); ]);
$file = fopen('bin/external/localeo/closeResource.timestamp', 'w');
fwrite($file, time());
fclose($file);
foreach ($resources as $resource) { foreach ($resources as $resource) {
$body = []; $body = [];
......
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