aboutsummaryrefslogtreecommitdiffstats
path: root/A8_srv_build/list.php
blob: c5c3b47aa4571ae09f43f81f1619e57247a784ee (plain)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?php
if( isset( $_SESSION['counter'] )) {
        $_SESSION['counter'] += 1;
} else {
        $_SESSION['counter'] = 1;
}

$con = isset($_SESSION['con']) ? $_SESSION['con'] : null;
$bul = isset($_SESSION['bul']) ? $_SESSION['bul'] : null;
$nst = isset($_SESSION['nst']) ? $_SESSION['nst'] : null;
$set = isset($_SESSION['set']) ? $_SESSION['set'] : null;
$not = isset($_SESSION['not']) ? $_SESSION['not'] : null;
$url = isset($_SESSION['url']) ? $_SESSION['url'] : null;

?>

        <html>
        <head>
        <meta http-equiv="content-type" content="text/html;charset=utf-8">
        <link rel="stylesheet" type="text/css" href="/css/style.css">
        <link rel="stylesheet" type="text/css" href="/css/table.css">
	<title>
        </title>
        </head>
        <body>
<?php
//DEBUG
//echo 'Session: ' . session_id() . '<br>';
//echo '$_SESSION' . var_dump($_SESSION) . '<br>';
//echo '$_POST' . var_dump($_POST) . '<br>';
?>

        <a href="add.php" class="stb">Add Record</a><br><br>
        <form action="sessionvars.php" method="post">
        Select columns:<br>
        <input type="checkbox" name="con" value="Configure"
        <?php echo isSet($con)?" checked":"";?>/>Configure
        <input type="checkbox" name="bul" value="Build"
        <?php echo isSet($bul)?" checked":"";?>/>Build
        <input type="checkbox" name="nst" value="Install"
        <?php echo isSet($nst)?" checked":"";?>/>Install
        <input type="checkbox" name="set" value="Setup"
        <?php echo isSet($set)?" checked":"";?>/>Setup
        <input type="checkbox" name="not" value="Notes"
        <?php echo isSet($not)?" checked":"";?>/>Notes
        <input type="checkbox" name="url" value="URL"
        <?php echo isSet($url)?" checked":"";?>/>URL<br>
        <input type="submit" name="submit" value="Submit"/>
        </form>

<?php
include 'config.inc';

$sqlselect = 'SELECT id, seq, name, version';
$sqlfrom = ' FROM PKG';
$sqlwhere = '';

#if columns are selected
if($con || $bul || $nst || $set || $not || $url) {
        $sqlwhere = ' WHERE';
}
$sqlorder = ' ORDER BY seq ASC';

#if configure is checked
if($con) {
        $sqlselect .= ', configure';
        $sqlfrom .= ', PKG_CFG';
        $sqlwhere .= ' PKG_CFG.pkg_id = PKG.id';
        if($bul || $nst || $set || $not || $url) {
                $sqlwhere .= ' AND';
        }
}

#if build is checked
if($bul) {
        $sqlselect .= ', build';
        $sqlfrom .= ', PKG_BLD';
        $sqlwhere .= ' PKG_BLD.pkg_id = PKG.id';
        if($nst || $set || $not || $url) {

                $sqlwhere .= ' AND';
        }

}

#if install is checked
if($nst) {
        $sqlselect .= ', install';
        $sqlfrom .= ', PKG_NST';
        $sqlwhere .= ' PKG_NST.pkg_id = PKG.id';
        if($set || $not || $url) {

                $sqlwhere .= ' AND';
        }

}

#if setup is checked
if($set) {
        $sqlselect .= ', setup';
        $sqlfrom .= ', PKG_SET';
        $sqlwhere .= ' PKG_SET.pkg_id = PKG.id';
        if($not || $url) {

                $sqlwhere .= ' AND';
        }

}

#if notes is checked
if($not) {
        $sqlselect .= ', notes';
        $sqlfrom .= ', PKG_NOT';
        $sqlwhere .= ' PKG_NOT.pkg_id = PKG.id';
        if($url) {

                $sqlwhere .= ' AND';
        }

}

#if url is checked
if($url) {
        $sqlselect .= ', url';
        $sqlfrom .= ', PKG_URL';
        $sqlwhere .= ' PKG_URL.pkg_id = PKG.id';
}

$sql = $sqlselect . $sqlfrom . $sqlwhere . $sqlorder;
try {
        $stmt = $pdo->prepare($sql);
        $stmt->execute();
} catch (PDOException $e) {
        echo '<pre style="color:Red">Have a big problem</pre>';
        throw $e;
        echo "$e->getMessage()";
}

if ($stmt->rowCount() > 0) {

        // Data received

	echo '<form method="post" action="delete.php" onSubmit="return confirm(\'Do you really want to delete the selected record(s)?\')">';

        // Begin Table
        $html_table = '<table class="bdb"><caption>A8-3800 CLFS Server</caption>';
	
	// Table Header
        $html_table .= '<thead><tr><th>ACTION</th><th>SEQ</th><th>NAME</th>';
        $html_table .= '<th>VERSION</th>';
        if($con){$html_table .= '<th>CONFIGURE</b></th>';}
        if($bul){$html_table .= '<th>BUILD</th>';}
        if($nst){$html_table .= '<th>INSTALL</th>';}
        if($set){$html_table .= '<th>SETUP</th>';}
        if($not){$html_table .= '<th>NOTES</th>';}
        if($url){$html_table .= '<th>URL</th>';}
        $html_table .= '<th>DELETE</th></tr></thead>';

        // Table Footer
        $html_table .= '<tfoot><tr><th>ACTION</th><th>SEQ</th><th>NAME</th>';
        $html_table .= '<th>VERSION</th>';
        if($con){$html_table .= '<th>CONFIGURE</th>';}
        if($bul){$html_table .= '<th>BUILD</th>';}
        if($nst){$html_table .= '<th>INSTALL</th>';}
        if($set){$html_table .= '<th>SETUP</th>';}
        if($not){$html_table .= '<th>NOTES</th>';}
        if($url){$html_table .= '<th>URL</th>';}
        $html_table .= '<th>DELETE</th></tr></tfoot>';

        // Table Body
        $html_table .= '<tbody>';

        // Table Rows
        while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
                $rowid  = $row['id'];
                $rowseq = $row['seq'];
                $rownm  = $row['name'];
                $rowver = $row['version'];
                if($con) {
                        $rowcfg = nl2br(str_replace(' ', '&nbsp;', $row['configure']));
                }
                if($bul) {
                        $rowbld = nl2br(str_replace(' ', '&nbsp;', $row['build']));
                }
                if($nst) {
                        $rownst = nl2br(str_replace(' ', '&nbsp;', $row['install']));
                }
                if($set) {
                        $rowset = nl2br(str_replace(' ', '&nbsp;', $row['setup']));
                }
                if($not) {
                        $rownot = nl2br(str_replace(' ', '&nbsp;', $row['notes']));
                }
                if($url) {
                        $rowurl = nl2br(str_replace(' ', '&nbsp;', $row['url']));
                }
                $html_table .= '<tr>';
                $html_table .= "<td><a href='edit.php?id=".$rowid."'>View</a></td>";
                $html_table .= '<td><a name="'.$rowseq.'">'.$rowseq.'</a></td>';
                $html_table .= '<td><a href="openfile.php?name='.$rownm.'" title="installed-files"/'.$rownm.'" title="Installed files list" target="_blank">'.($rownm).'</a></td>';
                $html_table .= '<td>'.($rowver).'</td>';
                if($con){$html_table .= '<td>'.($rowcfg).'</td>';}
                if($bul){$html_table .= '<td>'.($rowbld).'</td>';}
                if($nst){$html_table .= '<td>'.($rownst).'</td>';}
                if($set){$html_table .= '<td>'.($rowset).'</td>';}
                if($not){$html_table .= '<td>'.($rownot).'</td>';}
                if($url){$html_table .= '<td>'.($rowurl).'</td>';}
                //$html_table .= "<td><a href='delete.php?id=".$rowid."'>Delete</a></td>";
		$html_table .= '<td align="center"><input type="checkbox" name="delid[]" class="checks" value="'.($rowid).'"/></td>';
                $html_table .= '</tr>';
        }

        // End Table Body
        $html_table .= '</tbody>';

        // End Table
        $html_table .= '</table>';

        //Output Table
        echo $html_table;

} else {
        // No Data received
        echo '<font color="#D00"><pre>No data found!</pre></font>';
}
?>
	<input id="submit" type="submit" value="Delete" disabled="disabled"/>
        <input type="checkbox" id="selectall"/>Check All
        </form>
        <!--- w3c tag -->
        <p align="right">
        <a href="http://validator.w3.org/check?uri=referer"><img
        src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>
        </p>
        <!-- end w3c tag -->
        <script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
        <script type='text/javascript'>
var checkBoxes = $('tbody .checks');
checkBoxes.change(function() {
	$('#submit').prop('disabled', checkBoxes.filter(':checked').length < 1);
});
checkBoxes.change();

$("#selectall").click(function () {
	$(".checks").prop('checked', $(this).prop('checked'));
        $('#submit').prop('disabled', checkBoxes.filter(':checked').length < 1);
});

$(".checks").change(function(){
	if (!$(this).prop("checked")){
		$("#selectall").prop("checked",false);
	}
});
        </script>
        </body>
        </html>