MMCT TEAM
Server IP : 103.53.40.154  /  Your IP : 3.145.106.7
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/logs/../shsindia.com/crm/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/ppcad7no/logs/../shsindia.com/crm/add-empolyee.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(isset($_POST['add_employe'])) {
    date_default_timezone_set('Asia/Kolkata');
    
    $emp_name = $_POST['emp_name'];
    $emp_father = $_POST['emp_father'];
    $emp_supervisor_id = $_POST['emp_supervisor_id'];
    $emp_dob = $_POST['emp_dob'];
    $emp_number = $_POST['emp_number'];
    $emp_alt_number = $_POST['emp_alt_number'];
    $emp_emergency_number = $_POST['emp_emergency_number'];
    $emp_email = $_POST['emp_email'];
    $emp_address = htmlspecialchars($_POST['emp_address'], ENT_QUOTES);
    $permanent_address = htmlspecialchars($_POST['permanent_address'], ENT_QUOTES);
    $emp_family_detail = htmlspecialchars($_POST['emp_family_detail'], ENT_QUOTES);
    $emp_nominee_name = $_POST['emp_nominee_name'];
    $emp_nominee_relation = $_POST['emp_nominee_relation'];
    $emp_nominee_phone = $_POST['emp_nominee_phone'];
    $emp_bank_name = $_POST['emp_bank_name'];
    $emp_account_no = $_POST['emp_account_no'];
    $emp_ifsc = $_POST['emp_ifsc'];
    $emp_branch = $_POST['emp_branch'];
    $password = $_POST['password'];
    $username = $_POST['username'];
    $maritul_status = $_POST['maritul_status'];
    $emp_code = $_POST['emp_code'];
    $emp_pf_no = $_POST['emp_pf_no'];
    $emp_esic_no = $_POST['emp_esic_no'];
    $emp_uan_no = $_POST['emp_uan_no'];
    $emp_doj = $_POST['emp_doj'];
    $sk_id = isset($_POST['sk_id']) ? implode(',', $_POST['sk_id']) : '';
    
    $emp_status = 'Active';

    // Handle image uploads
    $allowed_extensions = ['jpg', 'jpeg', 'png', 'pdf'];

    // Check and upload emp_photo
    if($_FILES['emp_photo']['name'] != '') {
        $emp_photo_extension = pathinfo($_FILES['emp_photo']['name'], PATHINFO_EXTENSION);
        if (in_array($emp_photo_extension, $allowed_extensions)) {
            $emp_photo_new_name = 'emp_photo_' . date('YmdHis') . '.' . $emp_photo_extension;
            move_uploaded_file($_FILES['emp_photo']['tmp_name'], 'images/employee/' . $emp_photo_new_name);
        } else {
            die("Invalid emp_photo file format. Allowed formats are jpg, jpeg, png");
        }
    }

    // Check and upload emp_aadhar_front
    if($_FILES['emp_aadhar_front']['name']!='') {
        $aadhar_front_extension = pathinfo($_FILES['emp_aadhar_front']['name'], PATHINFO_EXTENSION);
        if (in_array($aadhar_front_extension, $allowed_extensions)) {
            $aadhar_front_new_name = 'emp_aadhar_front_' . date('YmdHis') . '.' . $aadhar_front_extension;
            move_uploaded_file($_FILES['emp_aadhar_front']['tmp_name'], 'images/employee/' . $aadhar_front_new_name);
        } else {
            die("Invalid emp_aadhar_front file format. Allowed formats are jpg, jpeg, png");
        }
    }
    
    // Check and upload emp_aadhar_back
    if($_FILES['emp_aadhar_back']['name']!='') {
        $emp_aadhar_back_extension = pathinfo($_FILES['emp_aadhar_back']['name'], PATHINFO_EXTENSION);
        if (in_array($emp_aadhar_back_extension, $allowed_extensions)) {
            $emp_aadhar_back_new_name = 'emp_aadhar_back_' . date('YmdHis') . '.' . $emp_aadhar_back_extension;
            move_uploaded_file($_FILES['emp_aadhar_back']['tmp_name'], 'images/employee/' . $emp_aadhar_back_new_name);
        } else {
            die("Invalid emp_aadhar_back file format. Allowed formats are jpg, jpeg, png");
        }
    }
    
    // Check and upload emp_pancard
    if($_FILES['emp_pancard']['name']!='') {
        $emp_pancard_extension = pathinfo($_FILES['emp_pancard']['name'], PATHINFO_EXTENSION);
        if (in_array($emp_pancard_extension, $allowed_extensions)) {
            $emp_pancard_new_name = 'emp_pancard_' . date('YmdHis') . '.' . $emp_pancard_extension;
            move_uploaded_file($_FILES['emp_pancard']['tmp_name'], 'images/employee/' . $emp_pancard_new_name);
        } else {
            die("Invalid emp_pancard file format. Allowed formats are jpg, jpeg, png");
        }
    }
    
    // Check and upload emp_elec_card
    if($_FILES['emp_elec_card']['name']!='') {
        $emp_elec_card = pathinfo($_FILES['emp_elec_card']['name'], PATHINFO_EXTENSION);
        if (in_array($emp_elec_card, $allowed_extensions)) {
            $emp_elec_card_new_name = 'emp_elec_card_' . date('YmdHis') . '.' . $emp_elec_card;
            move_uploaded_file($_FILES['emp_elec_card']['tmp_name'], 'images/employee/' . $emp_elec_card_new_name);
        } else {
            die("Invalid emp_elec_card file format. Allowed formats are jpg, jpeg, png");
        }
    }
    
    // Check and upload pol_verify
    if($_FILES['pol_verify']['name']!='') {
        $aadhar_front_extension = pathinfo($_FILES['pol_verify']['name'], PATHINFO_EXTENSION);
        if (in_array($aadhar_front_extension, $allowed_extensions)) {
            $pol_verify_new_name = 'pol_verify_' . date('YmdHis') . '.' . $aadhar_front_extension;
            move_uploaded_file($_FILES['pol_verify']['tmp_name'], 'images/employee/' . $pol_verify_new_name);
        } else {
            die("Invalid police_verify file format. Allowed formats are jpg, jpeg, png");
        }
    }

    
    $sql = "INSERT INTO `tbl_employee`
    (`emp_name`, `skill_id`, `username`, `password`, `emp_father`, `emp_dob`, `emp_number`, `emp_alt_number`, `emp_emergency_number`, `emp_email`, `emp_address`, `permanent_address`, `emp_photo`, `emp_aadhar_front`, `emp_aadhar_back`, `emp_pancard`, `emp_nominee_name`, `emp_nominee_relation`, `emp_nominee_phone`, `emp_bank_name`, `emp_account_no`, `emp_ifsc`, `emp_branch`, `emp_add_date`, `emp_status`, `maritul_status`, `emp_family_detail`, `emp_pf_no`, `emp_esic_no`, `emp_uan_no`, `emp_doj`, `emp_code`, `user_type`, `emp_supervisor_id`) 
        VALUES 
    ('$emp_name', '$sk_id', '$username', '$password', '$emp_father', '$emp_dob', '$emp_number', '$emp_alt_number', '$emp_emergency_number', '$emp_email', '$emp_address', '$permanent_address', '$emp_photo_new_name', '$aadhar_front_new_name', '$emp_aadhar_back_new_name', '$emp_pancard_new_name', '$emp_nominee_name', '$emp_nominee_relation', '$emp_nominee_phone', '$emp_bank_name', '$emp_account_no', '$emp_ifsc', '$emp_branch', NOW(), '$emp_status', '$maritul_status', '$emp_family_detail', '$emp_pf_no', '$emp_esic_no', '$emp_uan_no', '$emp_doj', '$emp_code', 'employee', '$emp_supervisor_id')";

    $result = mysqli_query($db, $sql) or die("Query unsuccessful");

    if($result){
        echo ("<script>
        window.alert('Successfully Added');
        window.location.href='manage-employee.php';
        </script>");
        mysqli_close($db);
    } else {
        echo "Error";
    }
}
?>
<!DOCTYPE html>
<html lang="en">
    
<head>
    <?php include "top-links.php";?>
</head>

    <body>
        <!-- Begin page -->
        <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 mb-0"> Add Empolyee</h4>
                                    </div>
                                    <div class="card-body">
                                        <form action="<?php $_PHP_SELF?>" method="POST" enctype="multipart/form-data">
                                            <div id="basicwizard">
                                                <div class=" b-0 mb-0">
                                                    <div >
                                                        <div class="row">
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="userName">Empolyee Name</label>
                                                                <div>
                                                                    <input type="text" class="form-control" id="userName" name="emp_name" placeholder="Empolyee Name" required>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="userName">Father/Husband Name</label>
                                                                <div>
                                                                    <input type="text" class="form-control" id="userName" name="emp_father" placeholder="Father name" required>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="userName">DOB</label>
                                                                <div>
                                                                    <input type="date" class="form-control" id="userName" name="emp_dob" required>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="userName">Phone Number</label>
                                                                <div>
                                                                    <input type="text" class="form-control" id="userName" name="emp_number" placeholder="Phone Number" required>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="userName">Alt Phone</label>
                                                                <div>
                                                                    <input type="text" class="form-control" id="userName" name="emp_alt_number" placeholder="Alt Phone">
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="userName">Emergency Number</label>
                                                                <div>
                                                                    <input type="text" class="form-control" id="userName" name="emp_emergency_number" placeholder="Emergency Number">
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="userName">Email</label>
                                                                <div>
                                                                    <input type="email" class="form-control" id="userName" name="emp_email" placeholder="Email">
                                                                </div>
                                                            </div>
                                                            
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="maritul_status">Marital Status</label>
                                                                <select class="form-select" id="example-select" name="maritul_status">
                                                                    <option value="Un Married">Un Married</option>
                                                                    <option value="Married">Married</option>
                                                                </select>
                                                            </div>
                                                            
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="emp_supervisor_id">Assign Supervisor</label>
                                                                <select class="form-select" id="example-select" name="emp_supervisor_id">
                                                                <?php
                                                                    $sql = "SELECT * FROM `login_tbl` WHERE `user_status`='Active' AND user_type='Supervisor'";
                                                                    $run = mysqli_query($db, $sql) or die("Query Not run");
                                                                    $count = 0;
                                                                    while ($data = mysqli_fetch_assoc($run)) {
                                                                    $count++;
                                                                ?>
                                                                    <option value="<?php echo $data['id']; ?>"> <?php echo $data['name']; ?> </option>
                                                                <?php } ?>
                                                                </select>
                                                            </div>
                                                            <div class="col-md-6 mb-3">
                                                                <label class="" for="userName">Local Address</label>
                                                                <div>
                                                                    <textarea class="form-control" name="emp_address" id="example-textarea" rows="3"></textarea>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-6 mb-3">
                                                                <div>
                                                                    <label for="example-textarea" class="form-label">Permanent Address</label>
                                                                    <textarea class="form-control" name="permanent_address" id="example-textarea" rows="3"></textarea>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-12 mb-3">
                                                                <div>
                                                                    <label for="example-textarea" class="form-label">Family Details</label>
                                                                    <textarea class="form-control" name="emp_family_detail" id="example-textarea" rows="3"></textarea>
                                                                </div>
                                                            </div>
                                                            
                                                            <!-- Employment Skills -->
                                                            <div class="card-header">
                                                                <h4 class="header-title">Employment Skills</h4>
                                                            </div>
                                                            <div class="row pt-2 pb-2" >
                                                                <div class="col" >
                                                                    <label>Choose Employment Skills</label>
                                                                    <div style="display:flex;flex-wrap:wrap;">
                                                                            <?php
                                                                                $sqlsp = "SELECT * FROM `tbl_emp_skills` WHERE skill_status='Active'";
                                                                                $runsp = mysqli_query($db, $sqlsp) or die("Query Not run");
                                                                                while ($datasp = mysqli_fetch_assoc($runsp)) {
                                                                            ?>
                                                                        <p style="padding-left:10px;"><input type="checkbox" name="sk_id[]" value='<?php echo $datasp['sk_id'];?>'> <?php echo $datasp['skill_name'];?></p>
                                                                            <?php
                                                                            }
                                                                            ?>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            <div class="card-header">
                                                                <h4 class="header-title">Employment Identification</h4>
                                                            </div>
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="userName">Employee Code Number</label>
                                                                <div>
                                                                    <input type="text" class="form-control" id="userName" name="emp_code" placeholder="Employee Code Number">
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="userName">PF Number</label>
                                                                <div>
                                                                    <input type="text" class="form-control" id="userName" name="emp_pf_no" placeholder="PF Number">
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="userName">ESIC Number</label>
                                                                <div>
                                                                    <input type="text" class="form-control" id="userName" name="emp_esic_no" placeholder="ESIC Number">
                                                                </div>
                                                            </div>
                                                            <div class="col-md-6 mb-3">
                                                               <label class="" for="userName">UAN Number</label>
                                                                <div>
                                                                    <input type="text" class="form-control" id="userName" name="emp_uan_no" placeholder="UAN Number">
                                                                </div>
                                                            </div>
                                                            <div class="col-md-6 mb-3">
                                                               <label class="" for="userName">Date Of Joining(DOJ)</label>
                                                                <div>
                                                                    <input type="date" class="form-control" id="userName" name="emp_doj" placeholder="Date Of Joining(DOJ)">
                                                                </div>
                                                            </div>
                                                            
                                                            <div class="card-header">
                                                                <h4 class="header-title">Images</h4>
                                                            </div>
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="userName">Profile Photo</label>
                                                                <div>
                                                                    <input type="file"  class="form-control" id="userName" name="emp_photo" placeholder="image">
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="userName">Aadhar Card(Front)</label>
                                                                <div>
                                                                    <input type="file"  class="form-control" id="userName" name="emp_aadhar_front" placeholder="image">
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="userName">Aadhar Card(Back)</label>
                                                                <div>
                                                                    <input type="file"  class="form-control" id="userName" name="emp_aadhar_back" placeholder="image">
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="userName">Pan Card</label>
                                                                <div>
                                                                    <input type="file"  class="form-control" id="userName" name="emp_pancard" placeholder="image">
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="userName">Election Card</label>
                                                                <div>
                                                                    <input type="file"  class="form-control" id="userName" name="emp_elec_card" placeholder="image">
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="userName">Police Verification</label>
                                                                <div>
                                                                    <input type="file"  class="form-control" id="userName" name="pol_verify" placeholder="image">
                                                                </div>
                                                            </div>
                                                            <div class="card-header">
                                                                <h4 class="header-title">Nominee Details</h4>
                                                            </div>
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="userName">Nominee Name</label>
                                                                <div>
                                                                    <input type="text"  class="form-control" id="userName" name="emp_nominee_name" placeholder="Nominee Name">
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="userName">Nominee Relation</label>
                                                                <div>
                                                                    <input type="text"  class="form-control" id="userName" name="emp_nominee_relation" placeholder="Nominee Relation">
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="userName">Nominee Phone</label>
                                                                <div>
                                                                    <input type="text"  class="form-control" id="userName" name="emp_nominee_phone" placeholder="Nominee Phone">
                                                                </div>
                                                            </div>
                                                            <div class="card-header">
                                                                <h4 class="header-title">Bank Details</h4>
                                                            </div>
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="userName">Bank Name</label>
                                                                <div>
                                                                    <input type="text"  class="form-control" id="userName" name="emp_bank_name" placeholder="Bank Name">
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="userName">Account Number</label>
                                                                <div>
                                                                    <input type="text"  class="form-control" id="userName" name="emp_account_no" placeholder="Account Number">
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="userName">Branch Name</label>
                                                                <div>
                                                                    <input type="text"  class="form-control" id="userName" name="emp_branch" placeholder="Branch">
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="userName">IFSC Code</label>
                                                                <div>
                                                                    <input type="text"  class="form-control" id="userName" name="emp_ifsc" placeholder="IFSC Code">
                                                                </div>
                                                            </div>
                                                            <div class="card-header">
                                                                <h4 class="header-title">Login Details</h4>
                                                            </div>
                                                            <div class="col-md-6 mb-3">
                                                               <label class="" for="userName">Username</label>
                                                                <div>
                                                                    <input type="text"  class="form-control" id="userName" name="username" placeholder="Username" required>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-6 mb-3">
                                                               <label class="" for="userName">Password</label>
                                                                <div>
                                                                    <input type="text"  class="form-control" id="userName" name="password" placeholder="Password" >
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <ul class="list-inline wizard mb-0">
                                                            <li class="next list-inline-item float-end">
                                                                <button class="btn btn-info" name="add_employe">Submit <i class="ri-arrow-right-line ms-1"></i></button>
                                                            </li>
                                                        </ul>
                                                    </div>
                                                </div> 
                                            </div> 
                                        </form>
                                    </div> 
                                </div> 
                            </div>
                        </div> 
                    </div>
                    </div>
                    </div>
        </div>
        
        <?php include "footer.php";?>
        
    </body>

</html> 

MMCT - 2023