                    <?php 
require_once '../system/conn.php';
                      /*$cnt = 1;
                      $stmt1 = $conn->prepare(" SELECT `e_id`,`branch`,`e_doj` from `emp_details` where `status`='0'  "); //total=2866
                      $stmt1->execute();
                      $sql = $stmt1->fetchAll();
                      foreach($sql as $row2) 
                      { 
                       $e_id= $row2['e_id']; 
                       $branch= $row2['branch']; 
                       $entry_date= $row2['e_doj']; 
                       $status='1';
                       $dol=date("Y-m-d");
                       
                       $i = 1;
                       $stmt2 = $conn->prepare(" SELECT * from `left_employee` ");
                       $stmt2->execute();
                       $sql2 = $stmt2->fetchAll();
                       //print_r($sql2);exit;
                       
                       foreach($sql2 as $row3) 
                       { 
                        
                        if($e_id!=$row2['emp_id'] && $branch!=$row2['branch'] &&  $entry_date!=$row2['entry_date'] ) {
                            
                        
                           $query = "INSERT INTO `left_employee` (emp_id, d_o_l, entry_date, branch, status) VALUES  ('$e_id', '$dol', '$entry_date', '$branch', '$status') ";
                           //print_r($query);exit;
                           $statement = $conn->prepare($query)->execute();
                           
                           if($statement){
                               echo "<script>alert('Employees moved to left employees successfully.')</script>";
                               echo " <script>window.location.assign('move-to-leftemp.php')</script>";
                           } else {
                              echo "Not updated";
                           }
                        } else {
                            echo "<script>alert('No data found.')</script>";
                            echo " <script>window.location.assign('move-to-leftemp.php')</script>";
                        }
                        $i=$i+1; }  
                      $cnt=$cnt+1; }*/
                     
                     
                     
                     
                      
                      $cnt = 1;
                      $stmt1 = $conn->prepare(" SELECT emp_details.`e_id`,emp_details.`branch`,emp_details.`e_doj`,emp_details.`status` FROM `emp_details` INNER JOIN `emp_salary` ON emp_details.`e_id` = emp_salary.`emp_id` and emp_details.`branch` = emp_salary.`branch` WHERE  emp_salary.`month`='03' and emp_salary.`year`='2024'  ");
                      $stmt1->execute();
                      $sql = $stmt1->fetchAll();
                      foreach($sql as $row2) 
                      { 
                        $e_id= $row2['e_id']; 
                        //print_r($e_id);exit;
                        $branch= $row2['branch']; 
                        $entry_date= $row2['e_doj']; 
                        $status='1';
                        $dol=date("Y-m-d");
                        
                           $query = "UPDATE `emp_details` SET `status`='1' where `e_id`='$e_id' and `branch`=$branch and `e_doj`='$entry_date'  ";
                           //print_r($query);exit;
                           $statement = $conn->prepare($query)->execute();
                           if($statement){
                               echo "<script>alert('Employees moved to left employees successfully.')</script>";
                               echo " <script>window.location.assign('move-to-leftemp.php')</script>";
                           } else {
                               echo "Not updated";
                           }
                        
                      $cnt=$cnt+1; }
                    ?>