diff options
Diffstat (limited to 'A8_srv_build/list.php')
-rw-r--r-- | A8_srv_build/list.php | 253 |
1 files changed, 253 insertions, 0 deletions
diff --git a/A8_srv_build/list.php b/A8_srv_build/list.php new file mode 100644 index 0000000..0bac433 --- /dev/null +++ b/A8_srv_build/list.php @@ -0,0 +1,253 @@ +<?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(' ', ' ', $row['configure'])); + } + if($bul) { + $rowbld = nl2br(str_replace(' ', ' ', $row['build'])); + } + if($nst) { + $rownst = nl2br(str_replace(' ', ' ', $row['install'])); + } + if($set) { + $rowset = nl2br(str_replace(' ', ' ', $row['setup'])); + } + if($not) { + $rownot = nl2br(str_replace(' ', ' ', $row['notes'])); + } + if($url) { + $rowurl = nl2br(str_replace(' ', ' ', $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="Submit" 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'> +$('#submit').prop("disabled", true); +$('input:checkbox').click(function() { + if ($(this).is(':checked')) { + $('#submit').prop("disabled", false); + } else { + if ($('.checks').filter(':checked').length < 1){ + $('#submit').attr('disabled',true);} + } +}); +i </script> + </body> + </html> |