PMC-155-B
This commit is contained in:
@@ -329,6 +329,11 @@ class ReportTable
|
||||
*
|
||||
* @param array $arrayData
|
||||
* @param bool $flagAlterTable
|
||||
*
|
||||
* @see pmTablesProxy->save()
|
||||
* @see ProcessMaker\BusinessModel\ReportTable->createStructureOfTables()
|
||||
* @see Table->validateTableBeforeUpdate()
|
||||
* @link https://wiki.processmaker.com/3.1/Report_Tables
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
@@ -561,6 +566,7 @@ class ReportTable
|
||||
//Delete Report Table
|
||||
$resultDeleteReportTable = $pmTablesProxy->delete($obj);
|
||||
}
|
||||
$this->updateConfigurationCaseList($additionalTableUid, $columns);
|
||||
} catch (Exception $e) {
|
||||
$buildResult = ob_get_contents();
|
||||
|
||||
@@ -579,7 +585,6 @@ class ReportTable
|
||||
|
||||
$result->trace = $e->getTraceAsString();
|
||||
}
|
||||
$this->updateCaseListFieldsConfiguration($columns);
|
||||
//Return
|
||||
return $result;
|
||||
}
|
||||
@@ -588,8 +593,12 @@ class ReportTable
|
||||
* Update the Custom Case List fields configuration.
|
||||
*
|
||||
* @param array $columns
|
||||
*
|
||||
* @see ProcessMaker\BusinessModel\ReportTable->saveStructureOfTable()
|
||||
* @link https://wiki.processmaker.com/3.1/Report_Tables
|
||||
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
|
||||
*/
|
||||
public function updateCaseListFieldsConfiguration($columns)
|
||||
public function updateConfigurationCaseList($addTabUid, $columns)
|
||||
{
|
||||
$actions = [
|
||||
"todo", "draft", "sent", "unassigned", "paused", "completed", "cancelled"
|
||||
@@ -597,21 +606,84 @@ class ReportTable
|
||||
$conf = new Configurations();
|
||||
foreach ($actions as $action) {
|
||||
$confCasesList = $conf->loadObject("casesList", $action, "", "", "");
|
||||
if (is_array($confCasesList) && !empty($confCasesList)) {
|
||||
$this->removeNonExistentElementsCustomCaseList($confCasesList['first']['data'], $columns);
|
||||
$this->removeNonExistentElementsCustomCaseList($confCasesList['second']['data'], $columns);
|
||||
$sw = is_array($confCasesList) && !empty($confCasesList) && !empty($confCasesList['PMTable']) && $confCasesList['PMTable'] === $addTabUid;
|
||||
if ($sw) {
|
||||
$this->addFieldsToCustomCaseList($confCasesList['first']['data'], $confCasesList['second']['data'], $columns);
|
||||
$this->removeFieldsFromCustomCaseList($confCasesList['first']['data'], $columns);
|
||||
$this->removeFieldsFromCustomCaseList($confCasesList['second']['data'], $columns);
|
||||
$conf->saveObject($confCasesList, "casesList", $action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add fields to Custom Case List.
|
||||
* @param array $data1
|
||||
* @param array $data2
|
||||
* @param array $columns
|
||||
*
|
||||
* @see ProcessMaker\BusinessModel\ReportTable->saveStructureOfTable()
|
||||
* @link https://wiki.processmaker.com/3.1/Report_Tables
|
||||
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
|
||||
*/
|
||||
public function addFieldsToCustomCaseList(&$data1, $data2, $columns)
|
||||
{
|
||||
$all = [];
|
||||
$type = 'PM Table';
|
||||
$this->loadFieldTypeValues($data1, $all, $type);
|
||||
$this->loadFieldTypeValues($data2, $all, $type);
|
||||
foreach ($all as $value) {
|
||||
foreach ($columns as $index => $column) {
|
||||
if ($value['name'] === $column->field_name) {
|
||||
unset($columns[$index]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$defaults = ["APP_UID", "APP_NUMBER", "APP_STATUS"];
|
||||
foreach ($defaults as $value) {
|
||||
foreach ($columns as $index => $column) {
|
||||
if ($value === $column->field_name) {
|
||||
unset($columns[$index]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($columns as $value) {
|
||||
$data1[] = [
|
||||
"name" => $column->field_name,
|
||||
"fieldType" => $type
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load field type values.
|
||||
*
|
||||
* @param array $fields
|
||||
* @param array $all
|
||||
* @param string $type
|
||||
*/
|
||||
private function loadFieldTypeValues($fields, array &$all, $type)
|
||||
{
|
||||
foreach ($fields as $value) {
|
||||
if ($value['fieldType'] === $type) {
|
||||
$all[] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove non existent elements in Custom Case List.
|
||||
* Remove fields from Custom Cases List.
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $columns
|
||||
*
|
||||
* @see ProcessMaker\BusinessModel\ReportTable->saveStructureOfTable()
|
||||
* @link https://wiki.processmaker.com/3.1/Report_Tables
|
||||
* @link https://wiki.processmaker.com/3.2/Cases_List_Builder#Installation_and_Configuration
|
||||
*/
|
||||
public function removeNonExistentElementsCustomCaseList(&$data, $columns)
|
||||
public function removeFieldsFromCustomCaseList(&$data, $columns)
|
||||
{
|
||||
$n = count($data);
|
||||
for ($key = 0; $key < $n; $key++) {
|
||||
|
||||
Reference in New Issue
Block a user