- <?php
-
- include_once 'bu-common.php';
-
-
- /**
- * This page provides the UI for a backup item for both new items and editing items for both
- * database style and files. So there are 4 combinations:
- *
- * $bDbStyle = true, $db_id = 0: Create new database backup item
- * $bDbStyle = false, $db_id = 0: Create new files backup item
- * $bDbStyle = true, $db_id != 0: Edit an existing database backup item
- * $bDbStyle = false, $db_id != 0: Edit an existing files backup item
- *
- */
- function getbu_cf_content( $bDbStyle = false, $db_id = 0 ){
-
- $id_line='';
- $header_cont='';
- $lab1_cont = '';
- $exfiles_cont = '';
- $btn_new_bu = '';
- $item_data = null;
-
- $bu_name_value = '';
- $bu_src_value = '';
- $bu_dest_value = '';
- $bu_ex_files = '';
- $lastRunTime = '';
- $bu_error_list = '';
-
- if($db_id>0){
- $id_line = "<div>ID</div><div>$db_id</div>";
- $item_data = get_bu_item( $db_id ); // [ BUName, Dir_Src, Dir_Dest, Files_Ex, Bu_Type, BuRunning, BuError, LastRunDt ]
-
- $bu_name_value = "value='{$item_data[0]}'";
- $bu_src_value = "value='{$item_data[1]}'";
- $bu_dest_value = "value='{$item_data[2]}'";
- $bu_ex_files = $item_data[3];
-
- $bu_error_list = str_replace( "\n", '<br>', $item_data[6]);
- $bu_error_list = "<div>Errors</div><div>$bu_error_list</div>";
-
- $lastRunTime = "<div>Last Run (UTC)</div><div>{$item_data[7]}</div>";
-
- }
-
- if($bDbStyle){
- if($db_id>0){
- $header_cont = '<div class="section_header" >Edit Database Backup Item</div>';
- $btn_new_bu = "btn_edit_bu_db','$db_id";
-
- }else{
- $header_cont = '<div class="section_header" >Create New Database Backup Item</div>';
- $btn_new_bu = 'btn_new_bu_db';
-
- }
- $lab1_cont = '<div>Database name</div>';
-
- }else{
- if($db_id>0){
- $header_cont = '<div class="section_header" >Edit File Backup Item</div>';
- $btn_new_bu = "btn_edit_bu_file','$db_id";
-
- }else{
- $header_cont = '<div class="section_header" >Create New File Backup Item</div>';
- $btn_new_bu = 'btn_new_bu_file';
-
- }
-
- $lab1_cont = '<div>Source File/Dir</div>';
- $exfiles_cont = "<div>Exclude Files</div><div><textarea id=\"new_bu_exf\" rows=\"4\" >$bu_ex_files</textarea></div>";
- }
-
- $content = <<<'EOD'
-
- $header_cont
-
- <div class="content_section_text" style="min-height: 350px;" >
-
- <div class="two-col-panel">
-
- $id_line
-
- <div>Backup Name</div>
- <div><input id="new_bu_name" type="text" $bu_name_value > (optional)</div>
-
- $lab1_cont
- <div><input id="new_bu_source" type="text" $bu_src_value ></div>
-
- <div>Destination Dir</div>
- <div><input id="new_bu_dest" type="text" $bu_dest_value ></div>
-
- $exfiles_cont
-
- <div></div>
- <div>
- <button class="btn_exec" onclick="btn_clk_nav(this, 'btn_run_bu')" >Test</button>
- <button class="btn_exec" onclick="btn_clk_nav(this, '$btn_new_bu')" >Save</button>
- <button class="btn_exec" onclick="btn_clk_nav(this, 'btn_cancel_new_bu')" >Cancel</button>
- </div>
-
- <div>Test output</div>
- <div><textarea id="ta_testoutput" rows="8" readonly ></textarea></div>
-
- $lastRunTime
- $bu_error_list
-
- </div>
-
- </div>
- EOD;
-
- $content = str_replace('$bu_error_list', $bu_error_list, $content);
- $content = str_replace('$lastRunTime', $lastRunTime, $content);
- $content = str_replace('btn_run_bu\'', "btn_run_bu', $db_id", $content);
- $content = str_replace('$bu_name_value', $bu_name_value, $content);
- $content = str_replace('$bu_src_value', $bu_src_value, $content);
- $content = str_replace('$bu_dest_value', $bu_dest_value, $content);
-
- $content = str_replace('$id_line', $id_line, $content);
- $content = str_replace('$btn_new_bu', $btn_new_bu, $content);
- $content = str_replace('$exfiles_cont', $exfiles_cont, $content);
- $content = str_replace('$lab1_cont', $lab1_cont, $content);
- $content = str_replace('$header_cont', $header_cont, $content);
- return $content;
- }
-
- /**
- * Both inserts as well as edits a single backup item.
- */
- function save_bu_item( $postVars, $bu_id=0 ){
-
- [$err] = rpc( 'f:save_bu_item', $postVars, $bu_id );
- return $err;
- }
-
-
- ?>