|
@@ -98,7 +98,13 @@ class StatTreeController extends Controller
|
|
|
$statTree = StatTree::where('id', $statTreeID)->first();
|
|
|
$model = $statTree->model;
|
|
|
DB::beginTransaction();
|
|
|
+
|
|
|
+ // cleanup junk
|
|
|
DB::statement("DELETE FROM stat_tree_line WHERE stat_tree_id = :stat_tree_id", ['stat_tree_id' => $statTree->id]);
|
|
|
+ DB::statement("DELETE FROM stat_tree_line_clause WHERE stat_tree_id = :stat_tree_id", ['stat_tree_id' => $statTree->id]);
|
|
|
+ DB::statement("DELETE FROM stat_tree_line_clause_arg WHERE stat_tree_id = :stat_tree_id", ['stat_tree_id' => $statTree->id]);
|
|
|
+ DB::statement("DELETE FROM stat_tree_line_clause_arg_value WHERE stat_tree_id = :stat_tree_id", ['stat_tree_id' => $statTree->id]);
|
|
|
+ DB::statement("DELETE FROM stat_tree_line_report_column WHERE stat_tree_id = :stat_tree_id", ['stat_tree_id' => $statTree->id]);
|
|
|
|
|
|
for($x = 0; $x < count($rows); $x++){
|
|
|
$row = $rows[$x];
|
|
@@ -112,8 +118,6 @@ class StatTreeController extends Controller
|
|
|
$statTreeLine->tsv_text_for_report_columns = null;
|
|
|
$statTreeLine->save();
|
|
|
|
|
|
- DB::statement("DELETE FROM stat_tree_line_clause WHERE stat_tree_line_id = :stat_tree_line_id", ['stat_tree_line_id' => $statTreeLine->id]);
|
|
|
-
|
|
|
$allClauses = [];
|
|
|
for($i = 0; $i < count($row); $i++){
|
|
|
$cell = $row[$i];
|
|
@@ -137,6 +141,7 @@ class StatTreeController extends Controller
|
|
|
$statTreeLineClause->clause_label = $cell;
|
|
|
$statTreeLineClause->position_index = $i;
|
|
|
$statTreeLineClause->detail_json = json_encode(['model' => $model]);
|
|
|
+ $statTreeLineClause->stat_tree_id = $statTree->id;
|
|
|
$statTreeLineClause->save();
|
|
|
$allClauses[] = $cell;
|
|
|
|
|
@@ -154,6 +159,7 @@ class StatTreeController extends Controller
|
|
|
$column->display_key = $parts[0];
|
|
|
$positionIndex = DB::select("select max(position_index) from stat_tree_line_report_column where stat_tree_line_id = {$column->stat_tree_line_id}");
|
|
|
$column->position_index = is_numeric($positionIndex[0]->max) ? $positionIndex[0]->max + 1 : 1;
|
|
|
+ $column->stat_tree_id = $statTree->id;
|
|
|
$column->save();
|
|
|
}
|
|
|
}
|