<?php
/*	
 *	Author 	: Ladur / Tanggal : 21-07-2014	
 *	Revisi 	: Ferry / Tanggal : 27-12-2014
 */
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Grand Royal</title>
        <meta name="author" content="Grand Royal" />
        <meta name="description" content="Grand Royal" />
        <meta name="keywords" content="Grand Royal" />
        <meta name="application-name" content="Grand Royal" />

        <!-- Plugin stylesheets -->
        <link href="<?php echo base_url();?>assets/plugins/bootstrap-3.2.0/css/bootstrap.css" rel="stylesheet" />
        <link href="<?php echo base_url();?>assets/plugins/jquery-ui-1.11.0/jquery-ui.theme.css" rel="stylesheet" type="text/css"/>
        <link href="<?php echo base_url();?>assets/plugins/uniform/css/uniform.default.css" type="text/css" rel="stylesheet" />

        <!-- Le stylesheets -->
        <link href="<?php echo base_url();?>assets/login/css/main.css" rel="stylesheet" type="text/css" /> 
        <link href="<?php echo base_url();?>assets/login/css/icons.css" rel="stylesheet" type="text/css" />

        <!-- Le fav icons -->
        <link rel="shortcut icon" href="<?php echo base_url();?>assets/custom/img/logo.png" />    
        <!-- Load modernizr first -->
        <script type="text/javascript" src="<?php echo base_url();?>assets/custom/js/libs/modernizr.js"></script>
        <script type="text/javascript" src="<?php echo base_url();?>assets/custom/js/jquery-1.8.3.min.js"></script>
		
        <style>
            #message {
                padding-top:10px;
                padding-left:25px;
                font-size:16px;
                color:red;
            }
        </style>
    </head>
    
      
    <body class="loginPage">
        <div class="container">
            <div id="header">
                <div class="row">
                    <div class="navbar">
                        <div class="container">
                            <a class="navbar-brand" href="<?php echo base_url();?>welcome"><img src="<?php echo base_url();?>assets/login/images/logo.png" height="65" alt="Grand Royal"/></a>
                        	
                        </div>
                    </div><!-- /navbar -->
                </div><!-- End .row -->
            </div><!-- End #header -->
        </div><!-- End .container --> 
        <a href="#" rel="#mies1">Tes</a>   
        <div class="container">
            <div class="loginContainer">
            
                <?php
                $message = $this->session->flashdata('message');
                echo $message == '' ? '' : '<p id="message">' . $message . '</p>';
                ?>

                <form class="form-horizontal" action="<?php echo base_url();?>login/process_login" id="loginForm" role="form" method="post">
                    <div class="form-group">
                        <label class="col-lg-12 control-label" for="username">Username:</label>

                        <div class="col-lg-12">
                            <input id="c" type="text" name="username" class="form-control" style="height:35px;" value="" placeholder="Enter your username ..." autofocus>
                            <span class="icon16 icomoon-icon-user right gray marginR10"></span>
                        </div>
                    </div><!-- End .form-group  -->

                    <div class="form-group">
                        <label class="col-lg-12 control-label" for="password">Password:</label>

                        <div class="col-lg-12">
                            <input id="password" type="password" name="password" value="" class="form-control" placeholder="Enter your password ...">
                            <span class="icon16 icomoon-icon-lock right gray marginR10"></span>
                            <!--<span class="forgot help-block"><a href="#">Forgot your password?</a></span>-->
                        </div>
                    </div><!-- End .form-group  -->
                    
                    <!-- <div id="company" class="form-group" style="display:none;">
                        <label class="col-lg-12 control-label" for="cmb-company">Branch:</label>

                        <div class="col-lg-12">
                            <select name="cmb-branch" id="cmb-cbranch" class="form-control" >
                            	<option value="">-- Select Branch --</option>
                                <?php
                                //foreach($branch as $data){
                                    //echo '<option value='. $data->BranchCode .'>'. $data->BranchName .'</option>';	
                                //}
                                ?>
                            </select>
                        </div>
                    </div> -->
                    <!-- End .form-group  -->

                    <div class="form-group">
                        <div class="col-lg-12 clearfix form-actions">
                            <button type="submit" class="btn btn-info right" id="loginBtn"><span class="icon16 icomoon-icon-enter white"></span> Login</button>
                        </div>
                    </div><!-- End .form-group  -->
                </form>
            </div>
        </div><!-- End .container -->
		<!-- bagian popup -->
        
        <!-- akhir dari popup -->
        <!-- Plugin stylesheets -->
        <!--<script type="text/javascript" src="<?php echo base_url();?>assets/plugins/bootstrap-3.2.0/js/bootstrap.js"></script>-->  
        <script type="text/javascript" src="<?php echo base_url();?>assets/plugins/validate/js/jquery.validate.min.js"></script>
        <script type="text/javascript" src="<?php echo base_url();?>assets/plugins/uniform/js/jquery.uniform.min.js"></script>

        <script type="text/javascript">
            // Error
			/*var x = parent.get_in_tab();
            
            if (x !== ""){
                parent.location.reload();
            }*/
             
            $(document).ready(function() {
				
                // $('#c').keyup( function(){
                //     username = $(this).val();
					
                //     if(username.length == 5){
                //         $.post(
                //             '<?=base_url()?>login/login/check_full_admin', 
                //             {username:username},
                //             function(result){
                //                 if(result){
                //                     $('#company').css('display','block');
                //                 }
                //                 else{
                //                     $('#company').css('display','none');
                //                 }
                //             }
                //         );
                //     }
                //     else{
                //         $('#company').css('display','none');
                //     }
                // });

                /*================= Checking Date Server and Client ========================*/
                var today = new Date();
                var dd = today.getDate();
                var mm = today.getMonth()+1; //January is 0!
                var yyyy = today.getFullYear();

                if(mm < 10){
                    mm = "0"+mm;
                }

                if(dd < 10){
                    dd = "0"+dd;
                }

                var DateClient = yyyy+"-"+mm+"-"+dd;
                var DateServer = "<?=$DateServer;?>";
                DateClient_Convert   = Date.parse(DateClient); 
                DateServer_Convert   = Date.parse(DateServer);

                if(DateClient_Convert != DateServer_Convert){
                    alert("System Date Error!.");
                    $("#loginForm :input").prop("disabled", true);
                }
                /*===================== END ====================================================*/

                // console.log(DateClient_Convert);
                // console.log(DateServer_Convert);
                // console.log(DateClient);
                // console.log(DateServer);

                // $.ajax({
                //     type: "POST",
                //     dataType: "JSON",
                //     url: url,
                //     data: $.param({no_transaksi: no_transaksi}),
                //     success: function (data) {
                //         myCallback(data);
                //     }, error: function (jqXHR, textStatus, errorThrown) {
                //         if (jqXHR.status == 500) {
                //             alert('Internal error: ' + jqXHR.responseText);
                //         } else {
                //             alert('Unexpected error.');
                //         }
                //     }
                // });

                $("input, textarea, select").not('.nostyle').uniform();

                $("#loginForm").validate({
                    rules: {
                        username: {
                            required: true,
                            minlength: 4
                        },
                        password: {
                            required: true,
                            minlength: 4
                        }  
                    },
                    messages: {
                        username: {
                            required: "Fill me please",
                            minlength: "My name is bigger"
                        },
                        password: {
                            required: "Please provide a password",
                            minlength: "My password is more that 4 chars"
                        }
                    }   
                });
            });
        </script> 
    </body>
</html>