<?php
include('header.php');


if(isset($_POST['sub']) && $_POST['sub'] =="1"){
    $link = null;
    $link2 = null;
    $link3 = null;
	$name = mysqli_real_escape_string($conn,$_POST['name']);

	$fname = mysqli_real_escape_string($conn,$_POST['fname']);
	$dob = mysqli_real_escape_string($conn,$_POST['dob']);
	$aadhaar_no = mysqli_real_escape_string($conn,$_POST['aadhaar_no']);
	$mobile_no = mysqli_real_escape_string($conn,$_POST['mobile_no']);
	$email = mysqli_real_escape_string($conn,$_POST['email']);
	$father_aadhaar_no = mysqli_real_escape_string($conn,$_POST['father_aadhaar_no']);
	$child_name_hindi = mysqli_real_escape_string($conn,$_POST['child_name_hindi']);
	$gender = mysqli_real_escape_string($conn,$_POST['gender']);
	$village = mysqli_real_escape_string($conn,$_POST['village']);
	$block = mysqli_real_escape_string($conn,$_POST['block']);
	$tehsil = mysqli_real_escape_string($conn,$_POST['tehsil']);
	$district = mysqli_real_escape_string($conn,$_POST['district']);
	$pincode = mysqli_real_escape_string($conn,$_POST['pincode']);
	$state = mysqli_real_escape_string($conn,$_POST['state']);
	$purpose = mysqli_real_escape_string($conn,$_POST['purpose']);
	$status = "pending";
	// fingers 
	$photo1 = mysqli_real_escape_string($conn,$_POST['photo1']);
	$photo2 = mysqli_real_escape_string($conn,$_POST['photo2']);
	$photo3 = mysqli_real_escape_string($conn,$_POST['photo3']);
	$photo4 = mysqli_real_escape_string($conn,$_POST['photo4']);
	$photo5 = mysqli_real_escape_string($conn,$_POST['photo5']);

	
	$fee = $udata['address'];
	if($udata['walletamount']>=$fee){
        // File Upload 
        if(isset($_FILES['poi']) ){
            $targetfolder = "uploads/";
            $targetfolder = $targetfolder .rand(00000,99999) . basename( $_FILES['poi']['name']) ;
           $file_type=$_FILES['poi']['type'];
           if ($file_type=="application/pdf") {
            if(move_uploaded_file($_FILES['poi']['tmp_name'], $targetfolder))
            {
                $link = $targetfolder;
                
            }else {
            echo "Problem uploading file";
            }
           }else {
            $uploaderror = true;
           
           }
        }
        // Upload POA 
        if(isset($_FILES['poa']) ){
            $targetfolder = "uploads/";
            $targetfolder = $targetfolder .rand(00000,99999) . basename( $_FILES['poa']['name']) ;
           $file_type=$_FILES['poa']['type'];
           if ($file_type=="application/pdf" ) {
            if(move_uploaded_file($_FILES['poa']['tmp_name'], $targetfolder))
            {
                $link2 = $targetfolder;
                
            }else {
            echo "Problem uploading file";
            }
           }else {
            $uploaderror = true;
           
           }
        }
        // Upload POB 
        if(isset($_FILES['pob']) ){
            $targetfolder = "uploads/";
            $targetfolder = $targetfolder .rand(00000,99999) . basename( $_FILES['pob']['name']) ;
           $file_type=$_FILES['pob']['type'];
           if ($file_type=="application/pdf" ) {
            if(move_uploaded_file($_FILES['pob']['tmp_name'], $targetfolder))
            {
                $link3 = $targetfolder;
                
            }else {
            echo "Problem uploading file";
            }
           }else {
            $uploaderror = true;
           
           }
        }
        date_default_timezone_set("Asia/Kolkata");   //India time (GMT+5:30)
        $dateof_issue = date('d-m-y h:i:s');
        $dateof_update = date('d-m-y h:i:s');
        $username = $_SESSION['phone'];
          $userid = $_SESSION['userid'];
        // ?End File Upload 
		$wres = mysqli_query($conn,"UPDATE usertable SET walletamount=walletamount-$fee WHERE phone='$username'");
		$res = mysqli_query($conn,"INSERT INTO `address`(`parent`, `appliedby`, `name`, `fname`, `dob`, `aadhaar_no`,  `mobile_no`,  `email`, `father_aadhaar_no`,`child_name_hindi`,`gender`,`village`,`block`,`tehsil`,`district`,  `pincode`,`state`, `purpose`, `finger1`, `finger2`, `finger3`, `finger4`, `finger5`, `status`,`poi`,`poa`,`pob`) VALUES ('".$udata['userid']."','$username','$name','$fname','$dob','$aadhaar_no',  '$mobile_no','$email', '$father_aadhaar_no',  '$child_name_hindi', '$gender', '$village','$block','$tehsil', '$district','$pincode','$state','$purpose','$photo1','$photo2','$photo3','$photo4','$photo5','$status','$link','$link2','$link3')");
		if($res){
            ?>
			<script>
            $(function(){
                Swal.fire(
                    'Success',
                    'Application Submitted Successfully!',
                    'success'
                )
            });
              window.setTimeout(function() {
  window.location.href = "demographiclistallstate.php";
  }, 1500);
        </script>
        <?php 
    }else{
        ?>
        <script>
            $(function(){
                Swal.fire(
                    'Opps',
                    'Internal Server Error!',
                    'error'
                )
            });
             window.setTimeout(function() {
  window.location.href = "add-customer.php";
  }, 1500);
        </script>
        <?php
    }

    }else{
        ?>
        <script>
            $(function(){
                Swal.fire(
                    'Opps',
                    'Wallet Balance Insufficient ! Please Recharge ',
                    'error'
                )
            });
            window.setTimeout(function(){
                window.location.href='wallet.php';
            },1500);
            
        </script>
        <?php
    }


    
}
?>

   
    <style>
    @media print {

        html,
        body {
            display: none;
        }
    }
    </style>
</head>

<body>

             
                
            
    <!-- ============================================================== -->
    <!-- 						Content Start	 						-->
    <!-- ============================================================== -->
    <div class="container-fluid">
                <div class="row page-header">
    
        <div class="col-lg-6 align-self-center ">
           <!---------- <h2>Add Customer</h2>----------->
            <ol class="breadcrumb">
               <!----------- <li class="breadcrumb-item"><a href="#">Home</a></li>----------->
               <!----------- <li class="breadcrumb-item active">Add Customer</li>------------>
            </ol>
        </div>
        <div class="col-lg-6 align-self-center text-right">
            <!-----------<a href="customerlist.php" class="btn btn-success box-shadow btn-icon btn-rounded"><i class="fa fa-users"></i> View Customers</a>------------>
        </div>
    </div>
                             <marque width="auto"   direction="left" height="auto" transition="0.5s" >
     <!-----------<h4 class="mt-2 text-danger"><strong>ATTENTION PLEASE PER ADD CUSTOMER CHARGE ₹<?php echo $udata['address'] ?> Deduct Hoga!</strong></h4>------------>
</marquee>
        <div class="row">
            <div class="col-sm-12">
                <div class="card">
                    <div class="card-header card-default">
                        Request For Address Update (Without Document) <br>
                       
                    </div>
                    <div class="card-body">
                        <form id="regform" method="post" enctype="multipart/form-data" class="form-horizontal"
                            autocomplete="off" onsubmit="myButton.disabled = true; return true;">
                            <div class="form-group">
                                <div class="row">
                                  
                                    <div class="col-md-4">
    <label for="FullName" style="color: black;">Full Name (पुरा नाम)</label>
    <input type="text" placeholder="Full Name(पुरा नाम)" id="fullname" name="name" class="form-control"  maxlength="30" required> 
</div>
<div class="col-md-4" style="display: none;">
    <label for="FullName" style="color: #EF3320;">बच्चे का नाम</label>
    <input type="text" placeholder="बच्चे का नाम" id="email" name="email" class="form-control" >
</div>

<input type="hidden" name="sub" value="1">
<div class="col-md-4" style="display: ;">
    <label for="FullName" style="color: black;">Gender (लिंग)</label>
    <select class="form-control" name="fname" id="fname" class="form-control" required>
        <option value="">Select Gender</option>
        <option value="Male">Male(पुरुष)</option>
        <option value="Female">Female(महिला)</option>
     <!----   <option value="TRANSGENDER">Transgender</option>------>
    </select>
</div>
<div class="col-md-4" style="display: none;">
    <label for="FullName" style="color: #FF9933;">Date Of Birth</label>
    <input type="date" id="dob" name="dob" class="form-control" >
</div>

<div class="col-md-4">
    <label for="FullName" style="color: black;">Mobile Number(मोबाइल नंबर))</label>
    <input id="mobileno"  placeholder="Mobile Number(मोबाइल नंबर)" name="mobile_no" type="number" class="form-control" maxlength="10" required>
</div>
<div class="col-md-4">
    <label for="FullName" style="color: black;">Aadhaar Number(आधार नंबर)</label>
    <input id="adhaarno" placeholder="Aadhaar No(आधार नंबर)" id="aadhaar_no" name="aadhaar_no" type="number" class="form-control" maxlength="12"  required>
    </div>
<div class="col-md-4" style="display: ;">
    <label for="FullName" style="color: blue;">Husband Name/Father's Name</label>
    <input type="text" placeholder="W/O - S/O" id="email" name="email" class="form-control" required>
</div>
<div class="col-md-4" style="display:none;">
    <label for="FullName" style="color: blue;">पिता/माता का नाम</label>
    <input type="text" placeholder="पिता/माता का नाम" id="child_name_hindi" name="child_name_hindi" class="form-control" >
</div>
<div class="col-md-4">
    <label for="FullName" style="color: blue;">Village(ग्राम)</label>
    <input type="text" placeholder="Village(ग्राम)" id="village" name="village" class="form-control" required>
</div>
<div class="col-md-4">
    <label for="FullName" style="color: blue;">Post(पोस्ट)</label>
    <input type="text" placeholder="Post(पोस्ट)" id="block" name="block" class="form-control" required>
</div>
<div class="col-md-4">
    <label for="FullName" style="color: blue;">Landmark(लैंडमार्क) Optional</label>
    <input type="text" placeholder="" id="tehsil" name="tehsil" class="form-control">
</div>
<div class="col-md-4">
    <label for="FullName" style="color: blue;">District(ज़िला)</label>
    <input type="text" placeholder="District(ज़िला)" id="district" name="district" class="form-control" required>
    </div>
<div class="col-md-4">
    <label for="FullName" style="color: blue;">State(राज्य)</label>
    <select id="state" name="state" class="form-control" required>
        <option value="">Select state</option>
        <option value="Andhra Pradesh"style="color: green;">Andhra Pradesh</option>
        <option value="Arunachal Pradesh"style="color: green;">Arunachal Pradesh</option>
        <option value="Assam"style="color: greene;">Assam</option>
        <option value="Bihar"style="color: green;">Bihar</option>
        <option value="Chhattisgarh"style="color: green;">Chhattisgarh</option>
        <option value="Goa"style="color: green;">Goa</option>
        <option value="Gujarat"style="color: green;">Gujarat</option>
        <option value="Haryana"style="color: green;">Haryana</option>
        <option value="Himachal Pradesh"style="color: green;">Himachal Pradesh</option>
        <option value="Jharkhand"style="color: blue;">Jharkhand</option>
        <option value="Karnataka"style="color: blue;">Karnataka</option>
        <option value="Kerala"style="color: blue;">Kerala</option>
        <option value="Madhya Pradesh"style="color: blue;">Madhya Pradesh</option>
        <option value="Maharashtra"style="color: blue;">Maharashtra</option>
        <option value="Manipur"style="color: blue;">Manipur</option>
        <option value="Meghalaya"style="color: blue;">Meghalaya</option>
        <option value="Mizoram"style="color: blue;">Mizoram</option>
        <option value="Nagaland"style="color: blue;">Nagaland</option>
        <option value="Odisha"style="color: blue;">Odisha</option>
        <option value="Punjab"style="color: red;">Punjab</option>
        <option value="Rajasthan"style="color: red;">Rajasthan</option>
        <option value="Sikkim"style="color: red;">Sikkim</option>
        <option value="Tamil Nadu"style="color: red;">Tamil Nadu</option>
        <option value="Telangana"style="color: red;">Telangana</option>
        <option value="Tripura"style="color: red;">Tripura</option>
        <option value="Uttar Pradesh"style="color: red;">Uttar Pradesh</option>
        <option value="Uttarakhand"style="color: red;">Uttarakhand</option>
        <option value="West Bengal"style="color: red;">West Bengal</option>
    </select>
</div>


                     <div class="col-md-4">
    <label for="FullName" style="color: blue;">Pin code(पिन कोड)</label>
    <input type="text" placeholder="Pincode(पिन कोड)" id="pincode" name="pincode"  maxlength="6" class="form-control" required>
</div>
<!------------<div class="col-md-4">
    <label for="FullName" style="color: red; display:">DOCUMENT(Original Document Upload in PDF)</label>
    <input type="file" id="poi" name="poi"  class="form-control" required>--------------->
</div>
<div class="col-md-4" style="display: none;">
    <label for="poa"><strong>CHILD PHOTO IN WHITE BACKGROUND(PDF FILE ONLY)</strong></label>
    <input type="file" id="poa" name="poa" class="form-control">
</div>
<div class="col-md-4" style="display: none;">
    <label for="FullName" style="color: blue;">ADDRESS PROOF (OPTIONAL)</label>
    <input type="file" id="pob" name="pob" class="form-control">
</div>

<!----------<input type="hidden" name="sub" value="1">------------>
<!--------------<div class="col-md-4">------------>
    <label for="FullName" style="color: red;">PURPOSE</label>
    <select class="form-control" name="purpose" id="purpose" required>
        <option value="">Select Purpose</option>
        <option value="ADDRESS UPDATE" style="color: red;">ADDRESS UPDATE</option>
        <option value="HUSBAND NAME UPDATE" style="color: red;">HUSBAND NAME UPDATE</option>
        <option value="FATHER'S NAME UPDATE" style="color: red;">FATHER'S NAME UPDATE</option>
    </select>
</div>
</div>
              <div class="form-group">
                                <div class="row">
                                    <div class="col-md-1"></div>
                                    <div class="col-md-2">
                                        <div class="card">
                                            <div class="card-body">
                                                <img src="assets/img/ww.gif" id="im1"
                                                    class="img-fluid rounded-end border p-1">
                                                <input class="form-control" type="hidden" id="pic1" name="photo1" style="width: 205px;" id="cim1"required>
                                                <div style="width:100px;height:auto" class="text-center mt-2">
                                                    <img src="assets/img/check.png" style="display:none; width:205px;"
                                                        id="cim1" alt="">
                                                </div>
                                                <button type="button"
                                                    class="btn btn-outline-info px-4 mt-1 capture btn-sm w-100"
                                                    data-id="1">Finger Capture</button>
                                                <h5 id="q1" class="text-center mt-3"></h5>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-md-2">
                                        <div class="card">
                                            <div class="card-body">
                                                <img src="assets/img/ww.gif" id="im2"
                                                    class="img-fluid rounded-end border p-1">
                                                <input class="form-control" type="hidden" id="pic2" name="photo2" required> 
                                                <div style="width:100px; height : auto" class="text-center mt-2">
                                                    <img src="assets/img/check.png" style="display:none; width:205px;"
                                                        id="cim2" alt="">
                                                </div>
                                                <button type="button"
                                                    class="btn btn-outline-info px-4 mt-1 capture btn-sm w-100"
                                                    data-id="2">Finger Capture</button>
                                                <h5 id="q2" class="text-center mt-3"></h5>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-md-2">
                                        <div class="card">
                                            <div class="card-body">
                                                <img src="assets/img/ww.gif" id="im3"
                                                    class="img-fluid rounded-end border p-1">
                                                <input class="form-control" type="hidden" id="pic3" name="photo3" required>
                                                <div style="width:100px; height : auto" class="text-center mt-2">
                                                    <img src="assets/img/check.png" style="display:none; width:205px;"
                                                        id="cim3" alt=""required>
                                                </div>
                                                <button type="button"
                                                    class="btn btn-outline-info px-4 mt-1 capture btn-sm w-100"
                                                    data-id="3">Finger Capture</button>
                                                <h5 id="q3" class="text-center mt-3"></h5>
                                            </div>
                                        </div>
                                         </div>
                                    <div class="col-md-2">
                                        <div class="card">
                                            <div class="card-body">
                                                <img src="assets/img/ww.gif" id="im4"
                                                    class="img-fluid rounded-end border p-1">
                                                <input class="form-control" type="hidden" id="pic4" name="photo4" required>
                                                <div style="width:100px; height : auto" class="text-center mt-2">
                                                    <img src="assets/img/check.png" style="display:none; width:205px;"
                                                        id="cim4" alt=""required>
                                                </div>
                                                <button type="button"
                                                    class="btn btn-outline-info px-4 mt-1 capture btn-sm w-100"
                                                    data-id="4">Finger Capture</button>
                                                <h5 id="q4" class="text-center mt-3"></h5>
                                            </div>
                                              </div>
                                         </div>
                                    <div class="col-md-2">
                                        <div class="card">
                                            <div class="card-body">
                                                <img src="assets/img/ww.gif" id="im5"
                                                    class="img-fluid rounded-end border p-1">
                                                <input class="form-control" type="hidden" id="pic5" name="photo5" required>
                                                <div style="width:100px; height : auto" class="text-center mt-2">
                                                    <img src="assets/img/check.png" style="display:none; width:205px;"
                                                        id="cim5" alt=""required>
                                                </div>
                                                <button type="button"
                                                    class="btn btn-outline-info px-4 mt-1 capture btn-sm w-100"
                                                    data-id="5">Finger Capture</button>
                                                <h5 id="q5" class="text-center mt-3"></h5>
                                                 </div>
                                               </div>
                                               </div>
                                               </div>
                                               </div>
                                           <div class="card-footer text-right pt-3 pb-3 mt-4">
                                <button type="submit" class="btn btn-success btn-lg">Submit</button>
                            </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        
            <div class="modal fade" id="logoutModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
        aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalLabel">Ready to Leave?</h5>
                    <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">×</span>
                    </button>
                </div>
                <div class="modal-body">Select "Logout" below if you are ready to end your current session.</div>
                <div class="modal-footer">
                    <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
                    <a class="btn btn-primary" href="../logout.php">Logout</a>
                </div>
            </div>
        </div>
    </div>


    </div>
    <!-- End of Page Wrapper -->

    <!-- Scroll to Top Button-->
    <a class="scroll-to-top rounded" href="#page-top">
        <i class="fas fa-angle-up"></i>
    </a>

    <!-- Logout Modal-->
    <div class="modal fade" id="logoutModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
        aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalLabel">Ready to Leave?</h5>
                    <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">×</span>
                    </button>
                </div>
                <div class="modal-body">Select "Logout" below if you are ready to end your current session.</div>
                <div class="modal-footer">
                    <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
                    <a class="btn btn-primary" href="../logout.php">Logout</a>
                </div>
            </div>
        </div>
    </div>

    <!-- Bootstrap core JavaScript-->
    <script src="vendor/jquery/jquery.min.js"></script>
    <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

    <!-- Core plugin JavaScript-->
    <script src="vendor/jquery-easing/jquery.easing.min.js"></script>

    <!-- Custom scripts for all pages-->
    <script src="js/sb-admin-2.min.js"></script>

    <!-- 						Content End		 						-->
    <!-- ============================================================== -->
    <!-- Common Plugins -->

    <script src="assets/lib/jquery/dist/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
    <script src="model/js/mfs100-9.0.2.6.js"></script>
    <script type="text/javascript" src="model/js/capture.js"></script>
    <script src="assets/lib/formatter/jquery.formatter.min.js"></script>
    <script>
    $(function() {
        /* BirthDate */
        $('input[name="birthdate"]').daterangepicker({
            singleDatePicker: true,
            showDropdowns: true,
            minYear: 1901,
            maxYear: parseInt(moment().format('YYYY'), 10),
            locale: {
                format: "DD/MM/YYYY",
            }
        });
    });
    $('#mobileno').formatter({
        'pattern': '+91 {{99}}-{{99}}-{{999999}}',
        'persistent': true
    });
    $('#aadhaar-no').formatter({
        'pattern': '{{9999}} {{9999}} {{9999}}',
        'persistent': true
    });
    document.addEventListener('contextmenu', event => event.preventDefault());
    document.onkeydown = function(e) {
        if (e.keyCode == 123) {
            return false;
        }
        if (e.ctrlKey && e.shiftKey && e.keyCode == 'I'.charCodeAt(0)) {
            return false;
        }
        if (e.ctrlKey && e.shiftKey && e.keyCode == 'J'.charCodeAt(0)) {
            return false;
        }
        if (e.ctrlKey && e.keyCode == 'U'.charCodeAt(0)) {
            return false;
        }
        if (e.ctrlKey && e.shiftKey && e.keyCode == 'C'.charCodeAt(0)) {
            return false;
        }
    }
    document.addEventListener("keyup", function(e) {
        var keyCode = e.keyCode ? e.keyCode : e.which;
        if (keyCode == 44) {
            stopPrntScr();
        }
    });

    function stopPrntScr() {

        var inpFld = document.createElement("input");
        inpFld.setAttribute("value", ".");
        inpFld.setAttribute("width", "0");
        inpFld.style.height = "0px";
        inpFld.style.width = "0px";
        inpFld.style.border = "0px";
        document.body.appendChild(inpFld);
        inpFld.select();
        document.execCommand("copy");
        inpFld.remove(inpFld);
    }

    function AccessClipboardData() {
        try {
            window.clipboardData.setData('text', "Access   Restricted");
        } catch (err) {}
    }
    setInterval("AccessClipboardData()", 300);
    </script>
    <script src="jquery-1.8.2.js"></script>
<script src="mfs100-9.0.2.6.js"></script>

    <script src="assets/lib/bootstrap/js/popper.min.js"></script>
    <script src="assets/lib/bootstrap/js/bootstrap.min.js"></script>
    <script src="assets/lib/pace/pace.min.js"></script>
    <script src="assets/lib/jasny-bootstrap/js/jasny-bootstrap.min.js"></script>
    <script src="assets/lib/slimscroll/jquery.slimscroll.min.js"></script>
    <script src="assets/lib/nano-scroll/jquery.nanoscroller.min.js"></script>
    <script src="assets/lib/metisMenu/metisMenu.min.js"></script>
    <script src="assets/js/custom.js"></script>
    <!--Chart Script-->
    <script src="assets/lib/chartjs/chart.min.js"></script>
    <script src="assets/lib/chartjs/chartjs-sass.js"></script>
    <!--Vetor Map Script-->
    <script src="assets/lib/vectormap/jquery-jvectormap-2.0.2.min.js"></script>
    <script src="assets/lib/vectormap/jquery-jvectormap-us-aea-en.js"></script>
    <!-- Chart C3 -->
    <script src="assets/lib/chart-c3/d3.min.js"></script>
    <script src="assets/lib/chart-c3/c3.min.js"></script>
    <!-- Datatables-->
    <script src="assets/lib/datatables/jquery.dataTables.min.js"></script>
    <script src="assets/lib/datatables/dataTables.responsive.min.js"></script>
    <script src="assets/lib/toast/jquery.toast.min.js"></script>
    <script src="assets/js/dashboard.js"></script>
    <!--Sweet Alerts-->
    <script src="assets/lib/sweet-alerts2/sweetalert2.min.js"></script>

</body>

</html>