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