PMC-1518 Restructure the offline definition over the PM Tables

This commit is contained in:
Roly Rudy Gutierrez Pinto
2019-12-20 09:10:10 -04:00
parent 8a54785b52
commit cf9dfe30f4
7 changed files with 125 additions and 18 deletions

View File

@@ -1,6 +1,7 @@
<?php
use ProcessMaker\Core\System;
use ProcessMaker\Model\AdditionalTables as AdditionalTablesModel;
use ProcessMaker\Validation\ExceptionRestApi;
use ProcessMaker\Validation\ValidationUploadedFiles;
@@ -218,6 +219,34 @@ class pmTablesProxy extends HttpProxyController
}
}
/**
* Update the offline property.
* @param stdClass $httpData
* @return stdClass
*/
public function updateOffline(stdClass $httpData): stdClass
{
$result = new stdClass();
try {
$array = G::json_decode(stripslashes($httpData->rows));
$data = [];
$enable = false;
foreach ($array as $value) {
if ($value->type !== "NORMAL") {
$data[] = $value->id;
$enable = $value->offline ? 1 : 0;
}
}
AdditionalTablesModel::updatePropertyOffline($data, $enable);
$result->success = true;
$result->message = $enable ? G::LoadTranslation("ID_ENABLE") : G::LoadTranslation("ID_DISABLE");
} catch (Exception $e) {
$result->success = false;
$result->message = $e->getMessage();
}
return $result;
}
/**
* delete pm table
*