 <?php 
 
if(isset($_POST["submit"]))
{


ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

include "dbconfig.php";
$link = opencon();

 
       $created_at=date("Y-m-d");
       $ot_update_date=$created_at;
        $sheetname=$_POST['sheetname'];
                
         $file = $_FILES['file']['tmp_name'];
   
          $handle = fopen($file, "r");
          $filesop =fgetcsv($handle, 1000, ",");
          $c = 0;
          while(($filesop =fgetcsv($handle, 1000, ","))!== false){
       

    //     $fileno=$filesop[1];
    //     $name=$filesop[6];
    //     $STATUS=$filesop[8];
    // $dir=$filesop[4];
    
    $collection_date=$filesop[1];
    $collection_date=date("Y-m-d",strtotime($collection_date));
    $mob=$filesop[8];
    $pro_lo=$filesop[10];
    $direction=$filesop[14];
    $site=$filesop[13];
$collect_amount=$filesop[26];

if($collection_date!=''){
    
    // $sql="update new_site_details set booking_status='$STATUS' where site_no='$fileno' and direction='$dir' and project_name='$name' and site_no!=''";
    
       $sql="update new_collection_details set collection_date='$collection_date' where site_no='$site' and direction='$direction' and project_location='$pro_lo' and site_no!='' and client_mobile='$mob' and client_mobile!='' and collection_amount='$collect_amount'";
       
       echo $sql."<br>";

    mysqli_query($link,$sql);
    

    
    

          
    
    
}      
         $c = $c + 1;
          
 
                    }
                       
   fclose($handle);  
   
        

     if($sql){
                //   header("Refresh:0; url=bulk25.php");
                 echo "<script>alert('success')</script>";
             } 
         else
         {
            //  header("Refresh:0; url=bulk25.php");
             echo "<script>alert('error')</script>";
              
          }

}
 
   ?>

<!doctype html>
<html class="no-js" lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    
    <title></title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
     <!-- ICON
		============================================ -->
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css">
    <!-- favicon
		============================================ -->
    <link rel="shortcut icon" type="image/x-icon" href="https://hrdandrecruitments.com/loan/img/favicon.ico">
    <!-- Google Fonts
		============================================ -->
    <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,700,700i,800" rel="stylesheet">
    <!-- Bootstrap CSS
		============================================ -->
    <link rel="stylesheet" href="https://hrdandrecruitments.com/loan/css/bootstrap.min.css">
    <!-- Bootstrap CSS
		============================================ -->
    <link rel="stylesheet" href="https://hrdandrecruitments.com/loan/css/font-awesome.min.css">
    <!-- adminpro icon CSS
		============================================ -->
    <link rel="stylesheet" href="https://hrdandrecruitments.com/loan/css/adminpro-custon-icon.css">
    <!-- meanmenu icon CSS
		============================================ -->
    <link rel="stylesheet" href="https://hrdandrecruitments.com/loan/css/meanmenu.min.css">
    <!-- mCustomScrollbar CSS
		============================================ -->
    <link rel="stylesheet" href="https://hrdandrecruitments.com/loan/css/jquery.mCustomScrollbar.min.css">
    <!-- animate CSS
		============================================ -->
    <link rel="stylesheet" href="https://hrdandrecruitments.com/loan/css/animate.css">
    <!-- jvectormap CSS
		============================================ -->
    <link rel="stylesheet" href="https://hrdandrecruitments.com/loan/css/jvectormap/jquery-jvectormap-2.0.3.css">
    <!-- normalize CSS
		============================================ -->
    <link rel="stylesheet" href="https://hrdandrecruitments.com/loan/css/data-table/bootstrap-table.css">
    <link rel="stylesheet" href="https://hrdandrecruitments.com/loan/css/data-table/bootstrap-editable.css">
    <!-- normalize CSS
		============================================ -->
    <link rel="stylesheet" href="https://hrdandrecruitments.com/loan/css/normalize.css">
    <!-- charts CSS
		============================================ -->
    <link rel="stylesheet" href="https://hrdandrecruitments.com/loan/css/c3.min.css">
    <!-- style CSS
		============================================ -->
    <link rel="stylesheet" href="https://hrdandrecruitments.com/loan/style.css">
    <!-- responsive CSS
		============================================ -->
    <link rel="stylesheet" href="https://hrdandrecruitments.com/loan/css/responsive.css">
    <!-- modernizr JS
		============================================ -->
    <script src="https://hrdandrecruitments.com/loan/js/vendor/modernizr-2.8.3.min.js"></script>
</head>
<body>
<div class="modal bulkcheck"  tabindex="-1" style="display:block;top: 30%;overflow:scroll" aria-modal="true" role="dialog">
                          <div class="modal-dialog modal-dialog-centered" role="document">
                            <div class="modal-content" style="
    padding: 10px;
">
                              <div class="modal-header" style="
    font-weight: bold;
">
                                <h5 class="modal-title" id="modalCenterTitle" style="
    font-weight: bold;
">UPLOAD FILE</h5>
                                
                              </div>
                              <div class="modal-body">
                                  <div class="row">
                                  <div class="col mb-3">
                                    <label for="nameWithTitle" class="form-label" style="font-weight: 700;">Download Sample file</label>
                                    <br>
                                    <button type="button" class="btn btn-primary " onclick="sampledownload()">Download</button>
                                  </div>
                                </div>
                                <br>
                <form action=''  method="post" enctype="multipart/form-data" >
                                
                                <div class="row">
                                  <div class="col mb-3">
                                    <label  class="form-label">Choose File</label>
                                    <input type="file" name="file"  class="form-control" required >
                                  </div>
                                  <div class="col mb-3">
                                    <label  class="form-label">Date</label>
                                    <input type="date" name="sheetname"  class="form-control" required >
                                  </div>
                                </div>
                                
                              </div>
                              <div id="uploadresult">
                              </div>
                              <div class="modal-footer">
                                <button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal" onclick=showstatus('bulkcheck','none')>
                                  Close
                                </button>
                                <button type="submit" class="btn btn-primary"  name="submit">BULK UPLOAD</button>
                              </div>
                              </form>
                            </div>
                          </div>
                        </div>
                        
                        <script>
    
 function sampledownload()
      {
          window.open("finalsheet.xlsx");
      }
      
</script>
<script>
    
function showstatus(name,status)
{
    document.getElementsByClassName(name)['0'].style.display=status;
}
</script>
