mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
Fixed JSON values import and export for dashboards
This commit is contained in:
parent
9733ac8717
commit
c7d61902fb
@ -1879,7 +1879,7 @@ class Prd
|
||||
private function searchValue(array $columns, string $table, string $id, $value):string
|
||||
{
|
||||
$sql_column = sprintf(
|
||||
'SELECT %s FROM %s WHERE %s IN (%s)',
|
||||
'SELECT %s FROM %s WHERE %s="%s"',
|
||||
implode(
|
||||
',',
|
||||
$columns
|
||||
@ -2097,12 +2097,51 @@ class Prd
|
||||
) {
|
||||
$ref = $condition['ref'];
|
||||
if (isset($ref['join']) === true) {
|
||||
if (isset($ref['array']) === true
|
||||
&& $ref['array'] === true
|
||||
) {
|
||||
if (is_array($value)) {
|
||||
$ref_arr = [];
|
||||
foreach ($value as $val) {
|
||||
$join_array = $this->recursiveJoin(
|
||||
$ref,
|
||||
$val
|
||||
);
|
||||
$ref_arr[] = [$ref['table'] => $join_array];
|
||||
}
|
||||
|
||||
$value = $ref_arr;
|
||||
}
|
||||
} else if (isset($ref['csv']) === true
|
||||
&& $ref['csv'] === true
|
||||
) {
|
||||
$csv_separator = ',';
|
||||
if (isset($ref['csv_separator']) === true
|
||||
&& $ref['csv_separator'] === true
|
||||
) {
|
||||
$csv_separator = $ref['csv_separator'];
|
||||
}
|
||||
|
||||
$value_arr = explode($csv_separator, $value);
|
||||
$ref_arr = [];
|
||||
foreach ($value_arr as $val) {
|
||||
$join_array = $this->recursiveJoin(
|
||||
$ref,
|
||||
$val
|
||||
);
|
||||
$val = [$ref['table'] => $join_array];
|
||||
$ref_arr[] = json_encode($val);
|
||||
}
|
||||
|
||||
$value = implode($csv_separator, $ref_arr);
|
||||
} else {
|
||||
$join_array = $this->recursiveJoin(
|
||||
$ref,
|
||||
$value
|
||||
);
|
||||
$value = [$ref['table'] => $join_array];
|
||||
$value = json_encode($value);
|
||||
}
|
||||
} else {
|
||||
if (isset($ref['array']) === true
|
||||
&& $ref['array'] === true
|
||||
@ -2125,7 +2164,7 @@ class Prd
|
||||
}
|
||||
}
|
||||
|
||||
$value = json_encode($ref_arr);
|
||||
$value = $ref_arr;
|
||||
}
|
||||
} else if (isset($ref['csv']) === true
|
||||
&& $ref['csv'] === true
|
||||
@ -2170,12 +2209,51 @@ class Prd
|
||||
$ref = $reference['ref'];
|
||||
|
||||
if (isset($ref['join']) === true) {
|
||||
if (isset($ref['array']) === true
|
||||
&& $ref['array'] === true
|
||||
) {
|
||||
if (is_array($value)) {
|
||||
$ref_arr = [];
|
||||
foreach ($value as $val) {
|
||||
$join_array = $this->recursiveJoin(
|
||||
$ref,
|
||||
$val
|
||||
);
|
||||
$ref_arr[] = [$ref['table'] => $join_array];
|
||||
}
|
||||
|
||||
$value = $ref_arr;
|
||||
}
|
||||
} else if (isset($ref['csv']) === true
|
||||
&& $ref['csv'] === true
|
||||
) {
|
||||
$csv_separator = ',';
|
||||
if (isset($ref['csv_separator']) === true
|
||||
&& $ref['csv_separator'] === true
|
||||
) {
|
||||
$csv_separator = $ref['csv_separator'];
|
||||
}
|
||||
|
||||
$value_arr = explode($csv_separator, $value);
|
||||
$ref_arr = [];
|
||||
foreach ($value_arr as $val) {
|
||||
$join_array = $this->recursiveJoin(
|
||||
$ref,
|
||||
$val
|
||||
);
|
||||
$val = [$ref['table'] => $join_array];
|
||||
$ref_arr[] = json_encode($val);
|
||||
}
|
||||
|
||||
$value = implode($csv_separator, $ref_arr);
|
||||
} else {
|
||||
$join_array = $this->recursiveJoin(
|
||||
$ref,
|
||||
$value
|
||||
);
|
||||
$value = [$ref['table'] => $join_array];
|
||||
$value = json_encode($value);
|
||||
}
|
||||
} else {
|
||||
if (isset($ref['array']) === true
|
||||
&& $ref['array'] === true
|
||||
@ -2200,7 +2278,7 @@ class Prd
|
||||
}
|
||||
}
|
||||
|
||||
$value = json_encode($ref_arr);
|
||||
$value = $ref_arr;
|
||||
}
|
||||
}
|
||||
} else if (isset($ref['csv']) === true
|
||||
@ -2267,14 +2345,17 @@ class Prd
|
||||
if (isset($condition['ref']['array']) === true
|
||||
&& $condition['ref']['array'] === true
|
||||
) {
|
||||
if ($this->validateJSON($value)) {
|
||||
if (is_array($value) === true) {
|
||||
$value_arr = $value;
|
||||
} else {
|
||||
$value_arr = json_decode($value, true);
|
||||
}
|
||||
if (is_array($value_arr)) {
|
||||
$ref_arr = [];
|
||||
foreach ($value_arr as $val) {
|
||||
$ref_val = $this->findPrdItem(
|
||||
$condition['ref'],
|
||||
$val
|
||||
is_array($val) ? json_encode($val) : $val
|
||||
);
|
||||
|
||||
if ($ref_val === false && $ref_val != $val) {
|
||||
@ -2294,7 +2375,6 @@ class Prd
|
||||
|
||||
$value = $ref_arr;
|
||||
}
|
||||
}
|
||||
} else if (isset($condition['ref']['csv']) === true
|
||||
&& $condition['ref']['csv'] === true
|
||||
) {
|
||||
@ -2352,14 +2432,17 @@ class Prd
|
||||
if (isset($ref['array']) === true
|
||||
&& $ref['array'] === true
|
||||
) {
|
||||
if ($this->validateJSON($value)) {
|
||||
if (is_array($value) === true) {
|
||||
$value_arr = $value;
|
||||
} else {
|
||||
$value_arr = json_decode($value, true);
|
||||
}
|
||||
if (is_array($value_arr)) {
|
||||
$ref_arr = [];
|
||||
foreach ($value_arr as $val) {
|
||||
$ref_val = $this->findPrdItem(
|
||||
$ref,
|
||||
$val
|
||||
is_array($val) ? json_encode($val) : $val
|
||||
);
|
||||
|
||||
if ($ref_val === false && $ref_val != $val) {
|
||||
@ -2379,7 +2462,6 @@ class Prd
|
||||
|
||||
$value = json_encode($ref_arr);
|
||||
}
|
||||
}
|
||||
} else if (isset($ref['csv']) === true
|
||||
&& $ref['csv'] === true
|
||||
) {
|
||||
@ -2501,7 +2583,7 @@ class Prd
|
||||
}
|
||||
|
||||
$sql = sprintf(
|
||||
'SELECT * FROM %s WHERE %s = %s',
|
||||
'SELECT * FROM %s WHERE %s = "%s"',
|
||||
$element['table'],
|
||||
$sql_field,
|
||||
$id,
|
||||
@ -2597,7 +2679,7 @@ class Prd
|
||||
$result = [];
|
||||
if (empty($data['join']) === false) {
|
||||
$sql = sprintf(
|
||||
'SELECT %s, %s FROM %s WHERE %s=%s',
|
||||
'SELECT %s, %s FROM %s WHERE %s="%s"',
|
||||
implode(
|
||||
',',
|
||||
$data['columns']
|
||||
@ -2615,7 +2697,7 @@ class Prd
|
||||
$result[array_key_first($data['join'])] = $result_deep;
|
||||
} else {
|
||||
$sql = sprintf(
|
||||
'SELECT %s FROM %s WHERE %s=%s',
|
||||
'SELECT %s FROM %s WHERE %s="%s"',
|
||||
implode(
|
||||
',',
|
||||
$data['columns']
|
||||
|
Loading…
x
Reference in New Issue
Block a user