Newer
Older
backup-commander / html / inc / edit-sh-bu.php
  1. <?php
  2.  
  3. function edit_sh_bu_getContent( $db_id ){
  4. $db = new SQLite3('bin/data.db', SQLITE3_OPEN_READONLY );
  5.  
  6. $db_st = $db->prepare('SELECT * FROM BULIST where BUID=:buid');
  7. $db_st->bindValue(':buid', $db_id);
  8. $results = $db_st->execute();
  9. $row = $results->fetchArray();
  10. if ( $row===FALSE ) {
  11. return "Item $db_id not found";
  12. }
  13. $bun = $row['BUName'];
  14. $bus = $row['Dir_Src'];
  15. $bu_dt = $row['BU_DATE'];
  16. if($bu_dt==''){
  17. $bu_dt = date("Y-m-d");
  18. }
  19. $bu_t = $row['BU_TIME'];
  20. if($bu_t==''){
  21. $bu_t = '00:00';
  22. }
  23. $bu_r = $row['BU_REPEAT'];
  24.  
  25. switch($bu_r){
  26. case 'D':
  27. $id_checked = 'id="sched_ip_daily"';
  28. break;
  29. case 'W':
  30. $id_checked = 'id="sched_ip_weekly"';
  31. break;
  32. case 'M':
  33. $id_checked = 'id="sched_ip_monthly"';
  34. break;
  35. case 'N':
  36. default:
  37. $id_checked = 'id="sched_ip_none"';
  38. }
  39. $content = <<<'EOD'
  40.  
  41. <div class="section_header" >Edit Backup Schedule</div>
  42. <div class="content_section_text" style="min-height: 350px;" >
  43. <div class="two-col-panel">
  44. <div>ID</div>
  45. <div>$db_id</div>
  46. <div>Backup Name</div>
  47. <div>$bun</div>
  48. <div>Data Source</div>
  49. <div>$bus</div>
  50.  
  51. <div>Next Run Date/Time</div>
  52. <div><input id="sched_date" type="date" value="$bu_dt" ></div>
  53. <div></div>
  54. <div><input id="sched_time" type="time" value="$bu_t"></div>
  55.  
  56. <div>Repeat</div>
  57. <div>
  58. <input style="width: 25px;" type="radio" name="sched_period" id="sched_ip_none" ><label for="sched_ip_none">None</label><br>
  59. <input style="width: 25px;" type="radio" name="sched_period" id="sched_ip_daily"><label for="sched_ip_daily">Daily</label><br>
  60. <input style="width: 25px;" type="radio" name="sched_period" id="sched_ip_weekly" ><label for="sched_ip_weekly">Weekly</label><br>
  61. <input style="width: 25px;" type="radio" name="sched_period" id="sched_ip_monthly"><label for="sched_ip_monthly">Monthly</label>
  62. </div>
  63.  
  64. <div></div>
  65. <div>
  66. <button class="btn_exec" onclick="btn_clk_nav(this, 'btn_edit_shed_bu', $db_id)" >Save</button>
  67. <button class="btn_exec" onclick="btn_clk_nav(this, 'btn_cancel')" >Cancel</button>
  68. </div>
  69.  
  70. </div>
  71.  
  72. </div>
  73. EOD;
  74. $content = str_replace($id_checked, $id_checked.' checked ', $content );
  75. $content = str_replace('$bus', $bus, $content);
  76. $content = str_replace('$bun', $bun, $content);
  77. $content = str_replace('$bu_dt', $bu_dt, $content);
  78. $content = str_replace('$bu_t', $bu_t, $content);
  79. return str_replace('$db_id', $db_id, $content);
  80. }
  81.  
  82. function save_bu_schedule( $postVars ){
  83. //error_log( $postVars['id'] );
  84. $db = new SQLite3('bin/data.db' );
  85.  
  86. $db_st = $db->prepare('UPDATE BULIST SET BU_DATE=:bud, BU_TIME=:but, BU_REPEAT=:bur where BUID=:buid');
  87. $db_st->bindValue(':buid', $postVars['id'], SQLITE3_INTEGER );
  88. $db_st->bindValue(':bud', $postVars['sched_date'] );
  89. $db_st->bindValue(':but', $postVars['sched_time'] );
  90. $db_st->bindValue(':bur', $postVars['sched_period'] );
  91. $db_st->execute();
  92. if( $db->lastErrorCode()!==0){
  93. return $db->lastErrorCode();
  94. }
  95.  
  96. }
  97.  
  98. ?>