<?php /** * Provides a simple json array of the BU state info for the UI to poll changes. */ function getbu_list_state(){ $db = new SQLite3('bin/data.db', SQLITE3_OPEN_READONLY ); $bu_state = array(); $results = $db->query('SELECT BUID, BuRunning FROM BULIST'); while ($row = $results->fetchArray()) { array_push( $bu_state, array( $row['BUID'], $row['BuRunning'] ) ); } return $bu_state; } /** * Returns the main backup list page. */ function getbu_list_content(){ $db = new SQLite3('bin/data.db', SQLITE3_OPEN_READONLY ); $html_rows=''; $results = $db->query('SELECT * FROM BULIST'); while ($row = $results->fetchArray()) { //var_dump($row); $view_type = 'edit-file-bu'; if($row['BuType']==1){ $view_type = 'edit-db-bu'; } $html_row = '<tr>'; $html_row .= '<td>'.$row['BUID'].'</td>'; $html_row .= "<td class='td_icon' title='edit' ><img class=\"btn_mse\" onclick=\"btn_clk_nav(this, '$view_type', {$row['BUID']})\" src='img/edit-icon-24x24.png'></td>"; // edit icon $html_row .= "<td class='td_icon' title='delete' ><img class=\"btn_mse\" onclick=\"btn_clk_nav(this, 'delete-bu', {$row['BUID']})\" src='img/trash-bin-red-24x24.png'></td>"; // trash icon $html_row .= "<td class=\"btn_mse\" onclick=\"btn_clk_nav(this, '$view_type', {$row['BUID']})\" >{$row['BUName']}</td>"; $but = $row['BuType']==1?'DB':'F'; $html_row .= "<td>$but</td>"; if($row['BuError']!=''){ $html_row .= "<td><span style='color:red;'>!! </span>{$row['LastRunDt']}</td>"; }else{ $html_row .= "<td>{$row['LastRunDt']}</td>"; } if( $row['BU_REPEAT']=='N' ){ $html_row .= "<td title='edit schedule' ><img src=\"img/red-cross.png\" class=\" btn_mse\" onclick=\"btn_clk_nav(this, 'sched', {$row['BUID']})\" ></td>"; }else{ $html_row .= "<td title='edit schedule' ><button class=\"btn_mse btn_exec btn_small\" onclick=\"btn_clk_nav(this, 'sched', {$row['BUID']})\" >Edit</button> {$row['BU_REPEAT']}</td>"; } if($row['BuRunning']){ $html_row .= '<td><img src="img/green-tick.png"></td>'; }else{ $html_row .= "<td id=\"td_run_{$row['BUID']}\" ><button class=\"btn_mse btn_exec btn_small\" onclick=\"btn_clk_nav(this, 'btn_run_bu noTest', {$row['BUID']})\" >Run Now</button></td>"; } $html_row .= '</tr>'; $html_rows .= $html_row; } $content = <<<'EOD' <div class="section_header" >Backup Config List</div> <div class="content_section_text" style="min-height: 350px;" > <br> <table class="tblcenter" > <tr> <th>ID</th> <th></th> <th></th> <th>Name</th> <th>Type</th> <th>Last Run (UTC)</th> <th>Scheduled</th> <th>Running</th> </tr> --INSERT-ROWS-- <tr class="high-row-style"> <td></td> <td></td> <td></td> <td class="td_label_bkup" >Database backup</td> <td> <button class="btn_mse btn_exec" onclick="btn_clk_nav(this, 'new-db-bu')">Create</button> </td> </tr> <tr> <td></td> <td></td> <td></td> <td class="td_label_bkup" >Files backup</td> <td> <button class="btn_mse btn_exec" onclick="btn_clk_nav(this, 'new-file-bu' )">Create</button> </td> </tr> </table> </div> EOD; return str_replace('--INSERT-ROWS--', $html_rows, $content); } ?>