Fixed demo data cleanup

This commit is contained in:
Enrique Martin 2024-03-15 10:11:10 +01:00
parent 2192acdac2
commit 95e7c7185a
1 changed files with 22 additions and 22 deletions

View File

@ -1068,37 +1068,37 @@ if ($action === 'cleanup_demo_data') {
$demo_items = db_get_all_rows_in_table('tdemo_data'); $demo_items = db_get_all_rows_in_table('tdemo_data');
$module_items = array_filter( $module_items = array_map(
$demo_items,
function ($item) { function ($item) {
return ($item['table_name'] === 'tagente_modulo'); $json_data = json_decode($item['item_id'], true);
} return $json_data['id_agente_modulo'];
},
array_filter(
$demo_items,
function ($item) {
return ($item['table_name'] === 'tagente_modulo');
}
)
); );
$inventory_module_items = array_filter( $inventory_module_items = array_map(
$demo_items,
function ($item) { function ($item) {
return ($item['table_name'] === 'tagent_module_inventory'); $json_data = json_decode($item['item_id'], true);
} return $json_data['id_agent_module_inventory'];
},
array_filter(
$demo_items,
function ($item) {
return ($item['table_name'] === 'tagent_module_inventory');
}
)
); );
$items_delete_id_bfr = []; $in_clause = implode(',', $inventory_module_items);
foreach ($inventory_module_items as $item) {
$items_delete_id_bfr[] = $item['item_id'];
}
$in_clause = implode(',', $items_delete_id_bfr);
// Delete data from tagente_datos_inventory given inventory module id. // Delete data from tagente_datos_inventory given inventory module id.
db_process_sql('DELETE FROM tagente_datos_inventory where id_agent_module_inventory IN ('.$in_clause.')'); db_process_sql('DELETE FROM tagente_datos_inventory where id_agent_module_inventory IN ('.$in_clause.')');
$items_delete_id_bfr = []; $in_clause = implode(',', $module_items);
foreach ($module_items as $item) {
$items_delete_id_bfr[] = $item['item_id'];
}
$in_clause = implode(',', $items_delete_id_bfr);
// Delete data from tagente_datos give agent module id. // Delete data from tagente_datos give agent module id.
db_process_sql('DELETE FROM tagente_datos where id_agente_modulo IN ('.$in_clause.')'); db_process_sql('DELETE FROM tagente_datos where id_agente_modulo IN ('.$in_clause.')');