<?php session_start();
require_once 'config.php';
$PageName = "Login";
$UserId = 0; ?>
<!doctype html>
<html lang="en" class="h-100">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">
    <meta name="generator" content="">
     <title><?php echo $Proj_Title; ?></title>
    <!-- manifest meta -->
    <meta name="apple-mobile-web-app-capable" content="yes">

    <!-- Favicons -->
    <link rel="apple-touch-icon" href="img/favicon180.png" sizes="180x180">
    <link rel="icon" href="img/favicon32.png" sizes="32x32" type="image/png">
    <link rel="icon" href="img/favicon16.png" sizes="16x16" type="image/png">

    <!-- Material icons-->
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

    <!-- Google fonts-->
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&amp;display=swap" rel="stylesheet">

    <!-- swiper CSS -->
    <link href="vendor/swiper/css/swiper.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="css/style.css" rel="stylesheet" id="style">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js"></script>
      <link href="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css" rel="stylesheet">
</head>

<body class="body-scroll d-flex flex-column h-100 menu-overlay">
    <!-- screen loader -->
    



    <!-- Begin page content -->
    <main class="flex-shrink-0 main has-footer" style="background-color:#fff;">
       
    
        <header class="header">
            <div class="row">
                <div class="col-auto px-0">
                    <button class="btn btn-40 btn-link back-btn" type="button">
                        <span class="material-icons">keyboard_arrow_left</span>
                    </button>
                </div>
                <div class="text-left col align-self-center">
                   
                </div>
                <div class="ml-auto col-auto align-self-center">
                    <a href="login.php?page=savecal&StateId=<?php echo $_GET['StateId']; ?>&CostHeadId=<?php echo $_GET['CostHeadId']; ?>&CatId=<?php echo $_GET['CatId']; ?>&ItemId=<?php echo $_GET['ItemId']; ?>&qty=<?php echo $_GET['qty']; ?>" class="" style="color:#fff;">
                        Sign In
                    </a>
                </div>
            </div>
        </header>
        
        
        <div class="container h-100 text-white">
            <div class="row h-100">
                <div class="col-12 align-self-center mb-4">
                    <div class="row justify-content-center">
                        <div class="col-11 col-sm-7 col-md-6 col-lg-5 col-xl-4">
                            <h2 class="font-weight-normal" style="font-size:20px;text-align:center;">Create new
account with us</h2>
                              <div class="form-group float-label position-relative">
                            <input type="text" id="Fname" class="form-control ">
                            <label class="form-control-label text-white">First Name</label>
                          
                        </div>
                         <div class="form-group float-label position-relative">
                            <input type="text" id="Lname" class="form-control ">
                            <label class="form-control-label text-white">Last Name</label>
                          
                        </div>
                         <div class="form-group float-label position-relative">
                            <input type="number" id="Phone" class="form-control ">
                            <label class="form-control-label text-white">Contact No</label>
                          
                        </div>
                        <div class="form-group float-label position-relative">
                            <input type="email" id="EmailId" class="form-control ">
                            <label class="form-control-label text-white">Email Id</label>
                          
                        </div>
                        <div class="form-group float-label position-relative">
                            <input type="password" id="Password" class="form-control">
                            <label class="form-control-label text-white">Password</label>
                          
                        </div>
                       
                        <div class="form-group float-label position-relative">
                            <textarea class="form-control " rows="3" id="Address"></textarea>
                            <label class="form-control-label text-white">Address</label>
                        </div>

                         <div class="form-group float-label position-relative">
                            <input type="number" id="Pincode" class="form-control ">
                            <label class="form-control-label text-white">Pincode</label>
                          
                        </div>

                         <div class="form-group float-label position-relative active">
                            <select class="form-control text-white"  name="Type" id="Type" required="">
                               <!--  <option value="Paid" selected>Paid</option> -->
                               <option value="Free">Free</option>
                            </select>
                            <label class="form-control-label text-white active">Course Type</label>
                          
                        </div>

                        <div class="form-group float-label position-relative active">
                          
    <select class="form-control" name="DeptId" id="DeptId" required="">
<option selected="" disabled="">Select Department</option>
    <?php 
      $q = "select * from tbl_departments WHERE Status=1";
      $r = getList($q);
      foreach($r as $rw)
      {
    ?>
      <option <?php if($row7['DeptId']==$rw['id']){ ?> selected <?php } ?> value="<?php echo $rw['id']; ?>"><?php echo $rw['Name']; ?></option>
    <?php } ?>
</select>
<label class="form-control-label text-white active">Department <span class="text-danger">*</span></label>
</div>

<div class="form-group float-label position-relative active">
                          
    <select class="form-control" name="CourseId" id="CourseId" required="">
<option selected="" disabled="">Select Course</option>
   
</select>
<label class="form-control-label text-white active">Course <span class="text-danger">*</span></label>
</div>

<div class="form-group float-label position-relative active">
                          
    <select class="form-control" name="BatchId" id="BatchId" required="">
<option selected="" disabled="">Select Batch</option>
   
</select>
<label class="form-control-label text-white active">Batch <span class="text-danger">*</span></label>
</div>


                         <input type="hidden" id="pageid" value="<?php echo $_GET['page']; ?>">
                            <input type="hidden" id="StateId" value="<?php echo $_GET['StateId']; ?>">
                            <input type="hidden" id="CostHeadId" value="<?php echo $_GET['CostHeadId']; ?>">
                            <input type="hidden" id="CatId" value="<?php echo $_GET['CatId']; ?>">
                            <input type="hidden" id="ItemId" value="<?php echo $_GET['ItemId']; ?>">
                            <input type="hidden" id="qty" value="<?php echo $_GET['qty']; ?>">
                           
                            <div class="form-group float-label position-relative">
                                <div class="custom-control custom-switch">
                                    <input type="checkbox" class="custom-control-input" id="customSwitch1" checked="" disabled="">
                                    <label class="custom-control-label" for="customSwitch1" style="color: #000;">Agree to terms and condition</label>
                                </div>
                            </div> 
                        
                        </div>
                    </div>
                </div>
                
            </div>
        </div>
    </main>

    <!-- footer-->
    <div class="footer no-bg-shadow py-3">
        <div class="row justify-content-center">
            <div class="col">
                <a href="javascript:void(0)" onclick="register()" id="submit" class="btn btn-default rounded btn-block">Sign Up</a>
            </div>
        </div>
    </div>


    <!-- Required jquery and libraries -->
    <script src="js/jquery-3.3.1.min.js"></script>
    <script src="js/popper.min.js"></script>
    <script src="vendor/bootstrap/js/bootstrap.min.js"></script>

    <!-- cookie js -->
    <script src="js/jquery.cookie.js"></script>

    <!-- Swiper slider  js-->
    <script src="vendor/swiper/js/swiper.min.js"></script>

    <!-- Customized jquery file  -->
    <script src="js/main.js"></script>
    <script src="js/color-scheme-demo.js"></script>


    <!-- page level custom script -->
    <script src="js/app.js"></script>
    <script type="text/javascript">
          function register(){
             var action = "Register";
          var Fname = $('#Fname').val();
                var Lname = $('#Lname').val();
                var Phone = $('#Phone').val();
                var EmailId = $('#EmailId').val();
                var Pincode = $('#Pincode').val();
                var Address = $('#Address').val();
                var Password = $('#Password').val();
                 var StateId = $('#StateId').val();
                 var CostHeadId = $('#CostHeadId').val();
                 var CatId = $('#CatId').val();
                 var ItemId = $('#ItemId').val();
                 var qty = $('#qty').val();
                 var pageid = $('#pageid').val();
                 var Type = $('#Type').val();
                 var DeptId = $('#DeptId').val();
                 var CourseId = $('#CourseId').val();
                 var BatchId = $('#BatchId').val();
           if(Fname.trim() == ''){
                    alert("Please Enter First Name");
                    $('#Fname').focus();
                }
                else if(Lname.trim() == ''){
                    alert("Please Enter Last Name");
                    $('#Lname').focus();
                }
                else if(Phone.trim() == ''){
                    alert("Please Enter Phone No");
                    $('#Phone').focus();
                }
                else if(! /^([0-9]{10})+$/.test(Phone)) {
                  alert("Mobile Number must be 10 Digit!");
                  $('#Phone').focus();
                }
                else if(EmailId.trim() == ''){
                    alert("Please Enter Email Id");
                    $('#EmailId').focus();
                }
                else if(Pincode.trim() == ''){
                    alert("Please Enter Pincode");
                    $('#Pincode').focus();
                }
                else if(Address.trim() == ''){
                    alert("Please Enter Address");
                    $('#Address').focus();
                }
                else if(DeptId== null){
                    alert("Please Select Department");
                    $('#DeptId').focus();
                }
                else if(CourseId== null){
                    alert("Please Select Course");
                    $('#CourseId').focus();
                }
                else if(BatchId== null){
                    alert("Please Select Batch");
                    $('#BatchId').focus();
                }
                else{     
         $.ajax({
      url:"ajax_files/ajax_students.php",
      type:"POST",
      data:{action:action,Fname:Fname,Lname:Lname,Phone:Phone,EmailId:EmailId,Pincode:Pincode,Address:Address,Password:Password,Type:Type,DeptId:DeptId,CourseId:CourseId,BatchId:BatchId},
      beforeSend:function(){
     $('#submit').attr('disabled','disabled');
     $('#submit').text('Please Wait...');
    },
      success:function(data){
        res = JSON.parse(data);
        var status = res.status;
        var msg = res.msg;
         var Username = res.Username;
           var uid = res.uid;

        if(status == 0){
        toastr.error(msg, 'Error', {timeOut: 5000}); 
         
     }
     else{
        //Android.loginUser(Username,uid);
         toastr.success(msg, 'Success', {timeOut: 5000}); 
         setTimeout(function(){  
             if(pageid == 'savecal'){
                        window.location.href="calculate.php?StateId="+StateId+"&CostHeadId="+CostHeadId+"&CatId="+CatId+"&ItemId="+ItemId+"&qty="+qty;
                     }
                     
                     else{

                        window.location.href="profile.php";
                    }
        }, 2000); 
     }
     $('#submit').attr('disabled',false);
      $('#submit').text('Place Order');
      }
      });
          }
      }

      function getBatch(val){
    var action = "getBatch";
    $.ajax({
    url:"ajax_files/ajax_dropdown.php",
    method:"POST",
    data : {action:action,id:val},
    success:function(data)
    {
      $('#BatchId').html(data);
    }
    });
  }

 $(document).ready(function(){
      $(document).on("change", "#DeptId", function(event){
  var val = this.value;
  var type = $('#Type').val();
   var action = "getCourse";
    $.ajax({
    url:"ajax_files/ajax_dropdown.php",
    method:"POST",
    data : {action:action,id:val,type:type},
    success:function(data)
    {
      $('#CourseId').html(data);
    }
    });

 });

      $(document).on("change", "#Type", function(event){
  var type = this.value;
  var val = $('#DeptId').val();
   var action = "getCourse";
    $.ajax({
    url:"ajax_files/ajax_dropdown.php",
    method:"POST",
    data : {action:action,id:val,type:type},
    success:function(data)
    {
      $('#CourseId').html(data);
    }
    });

 });

       $(document).on("change", "#CourseId", function(event){
  var val = this.value;
  getBatch(val);
       });
        });
    </script>
</body>

</html>
