<?php
session_start();

if($_SESSION['name']==''){
    header("Location:index.php");die();
}

?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <!-- Bootstrap 3.3.7 -->
  <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css">
  <!-- Ionicons -->
  <link rel="stylesheet" href="bower_components/Ionicons/css/ionicons.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="dist/css/AdminLTE.min.css">
  <!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
  <link rel="stylesheet" href="dist/css/skins/_all-skins.min.css">
  <!-- Morris chart -->
  <link rel="stylesheet" href="bower_components/morris.js/morris.css">
  <!-- jvectormap -->
  <link rel="stylesheet" href="bower_components/jvectormap/jquery-jvectormap.css">
  <!-- Date Picker -->
  <link rel="stylesheet" href="bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css">
  <!-- Daterange picker -->
  <link rel="stylesheet" href="bower_components/bootstrap-daterangepicker/daterangepicker.css">
  <!-- bootstrap wysihtml5 - text editor -->
  <link rel="stylesheet" href="plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">

  <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->

  <!-- Google Font -->
  <link rel="stylesheet" href="bower_components/datatables/css/dataTables.bootstrap.min.css">
  <link rel="stylesheet" href="bower_components/datatables/css/dataTables.bootstrap.css">
  
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<!-- jQuery UI 1.11.4 -->
<script src="bower_components/jquery-ui/jquery-ui.min.js"></script>
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->

<!-- Bootstrap 3.3.7 -->
<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- Morris.js charts -->

<!-- Sparkline -->
 <script src="vendor/datatables/jquery.dataTables.js"></script>
    <script src="vendor/datatables/dataTables.bootstrap4.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/adminlte.min.js"></script>
<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
<!--<script src="dist/js/pages/dashboard.js"></script>-->
<!-- AdminLTE for demo purposes -->
<script src="dist/js/demo.js"></script>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

  <?php include("header.php");?>
  <!-- Left side column. contains the logo and sidebar -->
  <aside class="main-sidebar">
    <!-- sidebar: style can be found in sidebar.less -->
    <?php include("sidebar.php");?>
    <!-- /.sidebar -->
  </aside>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
  

    <!-- Main content -->
    <section class="content">
      
        <div class="row">
            <div class="col-md-12">
          <!-- Custom Tabs -->
          <div class="nav-tabs-custom">
            <ul class="nav nav-tabs">
<!--                 <li class=""><a href="#tab_11" data-toggle="tab">Invoice</a></li>-->
<!--              <li><a href="#tab_21" data-toggle="tab">View Hotel</a></li>-->
              <li class="active rm"><a href="#tab_1" data-toggle="tab">SMTP details</a></li>
            
             <li><a href="#tab_21" data-toggle="tab">View SMTP details</a></li>
             
             
            </ul>
            <div class="tab-content">
                <div class="tab-pane active" id="tab_1">
                    
                    Host:<span class='required'></span><br>
                 <input type='text' id='host'><br>
                  Port:<span class='required'></span><br>
                  <input type='text' id='port'><br>
                   User Name:<span class='required'></span><br>
                 <input type='text' id='uname'><br>
                    Password:<span class='required'></span><br>
                 <input type='password' id='pwd'><br>
                  <br>
                 <br> 
                 <button class='btn btn-primary' id='add_invoice'>Add</button>
                    
              </div>
               <div class="tab-pane" id="tab_21">
                 
              </div>
                
              <div class="tab-pane active" id="tab_1">
              
              </div>
            
              <!-- /.tab-pane -->
              <div class="tab-pane" id="tab_2">
                 
              </div>
              <!-- /.tab-pane -->
              <div class="tab-pane" id="tab_3">
               
              </div>
              <!-- /.tab-pane -->
            </div>
            <!-- /.tab-content -->
          </div>
          <!-- nav-tabs-custom -->
        </div>
            
            
        </div>
        
        
        
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->
 
  <!-- /.control-sidebar -->
  <!-- Add the sidebar's background. This div must be placed
       immediately after the control sidebar -->
  <div class="control-sidebar-bg"></div>
</div>
<!-- ./wrapper -->

<!-- jQuery 3 -->

</body>
</html>
<style>
    .required:before{
   color: red;
   content: "*";
   position: absolute;
font-weight:bold !important;font-size: 18px;
}
    
    
</style>
<script src="jquery-ui.js"></script>
<link href='jquery-ui.css' rel='stylesheet'>
<script src='notify.min.js'></script>
<script src='notify.js'></script>
<link href='chosen.css' rel='stylesheet'>
<script>
//    $("#from_date").datepicker({ dateFormat: "yy-mm-dd"}).datepicker("setDate", "0");
//    $("#to_date").datepicker({ dateFormat: "yy-mm-dd"}).datepicker("setDate", "0");
    
    function notify(data){
$.notify(data, "success");
    }
     function notify1(data){
$.notify(data, "error");
    }
    
    $("#add_invoice_dialog").click(function(){
      
        $("#tab_11").dialog({"title":"Add Invoice"});
        name_auto();
    });
    
    
    
    var $input = $("#room_type").autocomplete({
    /* select: function (event, ui) {
     var value = ui.item.name
     //ac_name=$("#acc_name_val").val();   
     member_id=ui.item.value;
     }, */
    select: function (event, ui) {
    $("#room_type").val(ui.item.label); //ui.item is your object from the array
   $("#text span").html(" "+ui.item.data)
   
  
    return false;
    }, selectFirst: true,
            change: function (event, ui) {
            if (ui.item == null) {
            //here is null if entered value is not match in suggestion list
            $(this).val((ui.item ? ui.item.id : ""));
            }
            },
            response: function (event, ui) {
            if (!ui.content.length) {
            var noResult = {value: "", label: "No results found"};
            ui.content.push(noResult);
            }
            },
            // source: "car_model.php",
//            source: [
//                       
//                               
//                               
//                                {
//                                  label: "c",
//                            value: "c",
//                                },
//                         
//                            ],
            source: function( request, response ) {
        $.ajax({
          url: "get_room_type.php",
          type:"POST",
          dataType: "json",
          data: {
            q: request.term
          },
          success: function( data ) {
            response( data );
          }
        });
      },
            minLength: 0,
    });
    $("<button class='align' type='button'>&nbsp;</button>")
            .attr("tabIndex", - 1)
            .attr("title", "Show All Items")
            .insertAfter($input)
            .button({
            icons: {
            primary: "ui-icon-triangle-1-s"
            },
                    text: false
            })
            .removeClass("ui-corner-all")
            .addClass("ui-corner-right ui-button-icon")
            .click(function () {
            // close if already visible                        
            if ($input.autocomplete("widget").is(":visible")) {
            $input.autocomplete("close");
            return;
            }
            $(this).blur();
            $input.autocomplete("search", "");
            $input.focus();
            });
     $("span.ui-dialog-title").text('My New Title');

</script>

<style>
   .ui-autocomplete { position: absolute !important; cursor: default;z-index:9999990 !important;}  
    
</style>

<div id='balance_div' style='display: none'></div>
<style>
    .ui-dialog > .ui-widget-header {background: #cc6f6f;}
    #table11_div{background:#da9f9f}
    .align{display:inline-block}
    #table1 thead tr{background: green;

color: white;}
    .highlight{
                         color:red;
                     }
</style>

<script>
$("#add_invoice").click(function(){
    var host=$("#host").val();
    var port=$("#port").val();
    var uname=$("#uname").val();
     var pwd=$("#pwd").val();
     
     if(host==""||port==""||uname==""||pwd==""){
         notify1("All fields are mandatory");return false;
     }
    
    
      $.ajax({
      url:"add_smtp_details.php",
      data:{host:host,port:port,uname:uname,pwd:pwd},
      type:"POST",
      dataType:"JSON",
      success:function(data1){
          notify(data1+ " Row Inserted Successfully");
       
          get_pdf();
        //get_pdf(97);
      },
          error:function(xhr){
              notify1(xhr.responseText);
          }
   });
})
get_pdf();
function  get_pdf(){
   
    $.ajax({
      url:"get_smtp_details.php",
     
      dataType:"JSON",
      success:function(data1){
         var product_data=data1.product_data;
        
            
            var html="";var k=1;
            html="<table class='table'><thead>"
            +"<tr><th>Sl No</th>"
            +"<th>Host</th>"
      +"<th>Port</th>"
        +"<th>User name</th>"
  //+"<th>Password</th>"
            +"</tr>"
            +"</thead>";
        for(var i=0;i<product_data.length;i++){
            html=html+"<tr class='pagebreak1' ><td>"+ k++ +"</td>"
            +"<td>"+product_data[i].host+"</td>"
    +"<td>"+product_data[i].port+"</td>"
    +"<td>"+product_data[i].uname+"</td>"
    //+"<td>"+product_data[i].pwd+"</td>"
   
    
            +"</tr>"
        }
        html=html+"</table>"
         $("#tab_21").html(html); 
         
      },
          error:function(xhr){
              notify1(xhr.responseText);
          }
   });
    
    
}

 

</script>