<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>resources/css/style_db_config.css">
<link href="<?php echo base_url();?>resources/fonts/pacifico/stylesheet.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<?php echo base_url();?>resources/js/jquery-1.7.1.min.js"></script>
<script src="<?php echo base_url();?>resources/js/jquery-sipp.js"></script>
<script type="text/javascript">
$(document).ready(function() {
	$(".password").focus(function() {
		$(".pass-icon").css("left","-48px");
	});
	$(".password").blur(function() {
		$(".pass-icon").css("left","0px");
	});
});
</script>
</head>
    <body>
        <div id="wrapper" style="top:250px;width:350px;">
            <form id = "login-form" name="login-form" action="dbconfig/validateSave" method="post">
                <table width="350px;">
                    <tr>
                        <td>
                            <div class = "login-form" style="width:350px;">
                                <div class="header">
                                    <h1>Database Utama</h1>
                                    <span>SILAHKAN Masukan Informasi untuk Database.</span>
                                    <br>
                                    <span>MySQL server akan membutuhkan waktu yang relative lama melakukan test koneksi jika alamat server bukan localhost atau 127.0.0.1</span>
                                    <br>
                                    <span><a href="<?php echo base_url("dbconfig/changepass");?>" style="text-decoration:none;">[change password]</a></span>
                                </div>
                                <div class="content">
                                    <input style="width:240px;" id="user_utama" name ="user_utama" class="input password" placeholder="Username DB Utama" />
                                    <input style="width:240px;" id="passwd_utama" name="passwd_utama" type="password" class="input password" placeholder="Password DB Utama" />
                                    <input style="width:240px;" id="server_utama" name="server_utama" class="input password" placeholder="Alamat Server/Localhost" />
                                    <input style="width:240px;" id="db_utama" name="db_utama" class="input password" placeholder="Nama Database DB Utama" />
                                </div>
                                <div class="footer" style="padding: 15px 60px 12px 33px;">
                                    <table>
                                        <tr>
                                            <td><input type="button" value="Test" id="test" class="button" style="padding:8px;width:85px;height:44px;"/></td>
                                            <td><input type="button" value="Keluar" id="close_form" class="button" style="padding:8px;width:85px;height:44px;"/></td>
                                            <td><input style="padding:8px;" type="submit" name="submit" value="Simpan" class="button"/></td>
                                        </tr>
                                    </table>
                                </div>
                            </div>
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </body>
</html>
<script type="text/javascript">
$('.footer').on('click', '#test', function(event) {
    openLoadingDialog()
    $.post('<?php echo base_url("dbconfig/testconn"); ?>', {
        user_utama:$('#user_utama').val(),
        passwd_utama:$('#passwd_utama').val(),
        server_utama:$('#server_utama').val(),
        db_utama:$('#db_utama').val(),
    }, function(response){
        var json = jQuery.parseJSON(response);
        closeLoading()
        if(json.st==1){
            message_show(json.msg);
        }else if(json.st==0){
            message_error_show_parent(json.msg);
        }
    });
})


$('#login-form').SubmitHandling({
    refresh:'1',
    setRefresh:1,
    divRef:'#footer',
    clicked:1,
    btnClicked:'#close_form',
    whenStatus:1,
});
$('.footer').on('click', '#close_form', function(event) {
    window.open('<?php echo base_url("dbconfig");?>','_self');  
})
function closeLoading(){
    $("body").css({ overflow: 'inherit' })
    $('#loading').fadeOut();
}

function openLoadingDialog(){
    $("body").css({overflow: 'hidden'});
    $('#loading').fadeIn();
}
</script>