-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchildrenMove.php
More file actions
66 lines (52 loc) · 2.48 KB
/
childrenMove.php
File metadata and controls
66 lines (52 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
include_once('header.php');
require_once("headerHtml.inc.php");
if (empty($_REQUEST['type']) || empty($_REQUEST['itemId'])) die('invalid $_REQUEST');
$values = array();
$values['itemType'] = $_REQUEST['type'];
$values['itemId'] = $_REQUEST['itemId'];
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'replace') {
if (empty($_REQUEST['newVisId'])) die('$_REQUEST missing newVisId');
$values['visId'] = $_REQUEST['newVisId'];
$result = query("updateitemvisqualities",$config,$values,$sort);
nextScreen('childrenMove.php?type=' . $values['itemType'] . '&itemId=' . $values['itemId']);
}
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'truncate') {
if (empty($_REQUEST['oldVisId'])) die('$_REQUEST missing oldVisId');
$values['visId'] = $_REQUEST['oldVisId'];
$values['filterquery'] = "AND `visId` = '" . $values['visId'] . "'";
$result = query("deletequalities",$config,$values,$sort);
nextScreen('childrenMove.php?type=' . $values['itemType'] . '&itemId=' . $values['itemId']);
}
//create blank
$result = query("lookupqualities",$config,$values,$sort);
if (!is_array($result)) die('no matrix entries, just start from scratch');
$visIds = [];
foreach ($result as $row) {
if (isset($visIds[$row['visId']])) $visIds[$row['visId']]++;
else $visIds[$row['visId']] = 1;
}
echo '<pre>Existing vision(s):';
foreach ($visIds as $visId => $count) {
$values['filterquery'] = "WHERE i.`itemId` = " . $visId;
$result = query("getitems",$config,$values,$sort);
if (is_array($result)) {
$row = $result[0];
echo PHP_EOL . 'id: ' . $row["itemId"] . ' count: ' . $count . ' title: ' . $row["title"];
echo ' [truncate <a href="childrenMove.php?type=' . $values['itemType'] . '&itemId=' . $values['itemId'] . '&oldVisId=' . $row["itemId"] . '&action=truncate" class="remove">X</a>]';
echo ' [<a href="matrix.php?vLimit=' . $row["itemId"] . '&qLimit=f">see in Mx vis</a>]';
}
}
echo PHP_EOL . PHP_EOL . 'New vision (replace):';
$values['filterquery'] = "WHERE ia.`type` = 'v' AND its.`dateCompleted` IS NULL";
$result = query("getitems",$config,$values,$sort);
function sortByTitle($a, $b) {
return strcmp($a['title'], $b['title']);
}
usort($result, 'sortByTitle');
foreach ($result as $key => $row) {
echo PHP_EOL . '<a href="childrenMove.php?type=' . $values['itemType'] . '&itemId=' . $values['itemId'] . '&newVisId=' . $row["itemId"] . '&action=replace">id: ' . $row["itemId"] . ' title: ' . $row["title"] . '</a>';
}
// var_dump($result);die;
// var_dump($visIds);die;
?>