Newer
Older
backup-commander / html / inc / bu_list_content.php
  1. <?php
  2.  
  3. /**
  4. * Provides a simple json array of the BU state info for the UI to poll changes.
  5. */
  6. function getbu_list_state(){
  7.  
  8. $db = new SQLite3('bin/data.db', SQLITE3_OPEN_READONLY );
  9.  
  10. $bu_state = array();
  11. $results = $db->query('SELECT BUID, BuRunning FROM BULIST');
  12. while ($row = $results->fetchArray()) {
  13. array_push( $bu_state, array( $row['BUID'], $row['BuRunning'] ) );
  14. }
  15. return $bu_state;
  16. }
  17.  
  18.  
  19. /**
  20. * Returns the main backup list page.
  21. */
  22. function getbu_list_content(){
  23. $db = new SQLite3('bin/data.db', SQLITE3_OPEN_READONLY );
  24.  
  25. $html_rows='';
  26. $results = $db->query('SELECT * FROM BULIST');
  27. while ($row = $results->fetchArray()) {
  28. //var_dump($row);
  29.  
  30. $view_type = 'edit-file-bu';
  31. if($row['BuType']==1){
  32. $view_type = 'edit-db-bu';
  33. }
  34. $html_row = '<tr>';
  35.  
  36. $html_row .= '<td>'.$row['BUID'].'</td>';
  37. $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
  38. $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
  39. $html_row .= "<td class=\"btn_mse\" onclick=\"btn_clk_nav(this, '$view_type', {$row['BUID']})\" >{$row['BUName']}</td>";
  40. $but = $row['BuType']==1?'DB':'F';
  41. $html_row .= "<td>$but</td>";
  42. if($row['BuError']!=''){
  43. $html_row .= "<td><span style='color:red;'>!! </span>{$row['LastRunDt']}</td>";
  44. }else{
  45. $html_row .= "<td>{$row['LastRunDt']}</td>";
  46. }
  47. if( $row['BU_REPEAT']=='N' ){
  48. $html_row .= "<td title='edit schedule' ><img src=\"img/red-cross.png\" class=\" btn_mse\" onclick=\"btn_clk_nav(this, 'sched', {$row['BUID']})\" ></td>";
  49. }else{
  50. $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>";
  51. }
  52.  
  53. if($row['BuRunning']){
  54. $html_row .= '<td><img src="img/green-tick.png"></td>';
  55. }else{
  56. $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>";
  57. }
  58. $html_row .= '</tr>';
  59. $html_rows .= $html_row;
  60. }
  61.  
  62. $content = <<<'EOD'
  63.  
  64. <div class="section_header" >Backup Config List</div>
  65. <div class="content_section_text" style="min-height: 350px;" >
  66. <br>
  67. <table class="tblcenter" >
  68. <tr>
  69. <th>ID</th>
  70. <th></th>
  71. <th></th>
  72. <th>Name</th>
  73. <th>Type</th>
  74. <th>Last Run (UTC)</th>
  75. <th>Scheduled</th>
  76. <th>Running</th>
  77. </tr>
  78. --INSERT-ROWS--
  79. <tr class="high-row-style">
  80. <td></td>
  81. <td></td>
  82. <td></td>
  83. <td class="td_label_bkup" >Database backup</td>
  84. <td> <button class="btn_mse btn_exec" onclick="btn_clk_nav(this, 'new-db-bu')">Create</button> </td>
  85. </tr>
  86. <tr>
  87. <td></td>
  88. <td></td>
  89. <td></td>
  90. <td class="td_label_bkup" >Files backup</td>
  91. <td> <button class="btn_mse btn_exec" onclick="btn_clk_nav(this, 'new-file-bu' )">Create</button> </td>
  92. </tr>
  93. </table>
  94. </div>
  95. EOD;
  96.  
  97. return str_replace('--INSERT-ROWS--', $html_rows, $content);
  98.  
  99. }
  100.  
  101. ?>