ok

Mini Shell

Direktori : /home2/selectio/public_html/obnovit-tracking/backups/
Upload File :
Current File : /home2/selectio/public_html/obnovit-tracking/backups/attendance-create.php

<?php  include "header.php";?>
<?php
if(isset($_POST['create_update_attendance']) ){
    $base_query="INSERT INTO `tbl_attendance`( `empid`,`att_date`,`added_by`, `check_in`, `check_out`, `type`) VALUES";
    $base_value=array();
    error_log('date details: '.$_POST['dates']);
    
    if(isset($_POST['create_emp_id'] )){
            for($i=0;$i<count($_POST['create_emp_id']);$i++){
                
                if(isset($_POST['create_att_check_out'][$i])){
                    $_POST['create_att_check_out'][$i]="00:00:00";
                }
                
            $base_value[]="('".$_POST['create_emp_id'][$i]."','".$_POST['dates']."','1','".$_POST['create_att_check_in'][$i]."','".$_POST['create_att_check_out'][$i]."','".$_POST['att_status'][$i]."')";
            
            
        }
    }
    if(isset($_POST['update_attendance_id'])){
            for($i=0;$i<count($_POST['update_attendance_id']);$i++){
            $statement = $pdo->prepare("UPDATE tbl_attendance SET check_out=?,updated_by=?,type=? WHERE id=?");
            $result=$statement->execute(array($_POST['update_att_check_out'][$i],$_SESSION['hrm']['id'],$_POST['update_att_status'][$i],$_POST['update_attendance_id'][$i]));
        }
    }
    
    
    if(count($base_value)){
         $string_version = implode(',', $base_value);
    $base_query.=$string_version;
        $statement = $pdo->prepare($base_query);
            $result=$statement->execute();
    }
}
    
?>
<div class="content-wrapper" style="background:white;">
        <div class="clearfix"></div>

<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div >
                <div class="box-header">

            
   <?php if($_SESSION['hrm']['id']==1 || $allPermissions['category']['create']=="1"){ ?>         <?php } ?>
                    <h3 class="box-title"><b><i class="fa fa-list"></i> Attendance Update</b></h3>
                </div>
                <div class="box-body">
                    <form action="" method="post">
<div class="row">
<div class="col-sm-2">
<div class="form-group">
<label class="control-label" for="user">Department</label>
<select name="filter_year" class="form-control select2" style="width:100%" id="department_id" required>
    <option value="">Select Department</option>
   <?php 
    $statement = $pdo->prepare("SELECT * FROM tbl_department where status=1");
    $statement->execute();
    $result = $statement->fetchAll(PDO::FETCH_ASSOC);
    foreach ($result as $data) { ?>
    <option value="<?=$data['id']?>"><?=$data['name']?></option>
    <?php } ?>
</select>
</div>
</div>
<div class="col-sm-2">
<div class="form-group">
<label class="control-label" for="user">Employee</label>
<select name="emp_id" class="form-control select2" style="width:100%" id="emp_id" required>
    <option value="all">All</option>
    <?php 
    $statement = $pdo->prepare("SELECT * FROM tbl_user where status=1");
    $statement->execute();
    $result = $statement->fetchAll(PDO::FETCH_ASSOC);
    foreach ($result as $data) { ?>
    <option value="<?=$data['id']?>"><?=$data['uname']?></option>
    <?php } ?>
</select>
</div>
</div>

<div class="col-sm-2">
<div class="form-group">
<label class="control-label" for="user">Projects</label>
<select name="project_name" class="form-control select2" style="width:100%" id="project_name" required>
    <option value="all">All</option>
    <?php 
    $statement = $pdo->prepare("SELECT * FROM tbl_site");
    $statement->execute();
    $result = $statement->fetchAll(PDO::FETCH_ASSOC);
    foreach ($result as $data) { ?>
    <option value="<?=$data['id']?>"><?=$data['site_name']?></option>
    <?php } ?>
</select>
</div>
</div>


<div class="col-sm-2">
<div class="form-group">
<label class="control-label" for="user">Date</label>
<input type="date" name="dates" class="form-control" id="date" value="<?php echo date("Y-m-d");?>"  required/>
</div>
</div>
<div class="col-sm-2">
<div class="form-group">
<label class="control-label" for="user"></label>
<br><br><span class="btn btn-warning btn-sm" id="btngetEmployee">Get Employees</span>
</div>
</div>

</div>

<div class="clearfix"></div>
<center><h4 class="box-title"><b><i class="fa fa-list"></i> Update Daily Attendance Details </b></h4></center>
<div id="loading-div">
<center><img src="assets/load.gif" style="10%"><br>
<strong class="blink_me">Loading Pls Wait... </strong></center>
</div>
<div id="content-div">
<div class="row">
    <div class="col-sm-12">
        
        <div id="allowance_rows">
            
            </div>
        </div>
        
    </div>
    <center><br><button class="btn btn-success btn-sm" type="submit" name="create_update_attendance"><i class="fa fa-save"></i> Update Attendance</button></center>
</form></div>

 </div>   

                   
                </div>
            </div>
        </div>
    </div>
</section>

<script>
    $( document ).ready(function() {
        $('#loading-div').hide();
        $('#content-div').hide();
      
    $("#btngetEmployee").click(function() {
  showData();
});
    
        function showData(){
            $('#loading-div').show();
            $('#content-div').hide();
            setTimeout(function() {
                $('#loading-div').hide();
                get_daily_attendance();
                $('#content-div').show('blind', {}, 500)
            }, 800);
        }
    
     
  function get_daily_attendance(){
        var department_id=$('#department_id').val();
        var date=$('#date').val();
        var emp_id=$('#emp_id').val();
        
        console.log(department_id);
        console.log(date);
        console.log(emp_id);
        $('#allowance_rows').empty();
                                $.ajax({
                            url: 'api/daily-attendance-api.php',
                            
                            /*<option value="">Select Project</option><?php $statement = $pdo->prepare("SELECT * FROM tbl_site");$statement->execute();$result = $statement->fetchAll(PDO::FETCH_ASSOC);foreach ($result as $data) { ?><option value="<?=$data['id']?>"><?=$data['site_name']?></option><?php } ?>*/
    
                            type: 'post',
                            dataType: 'json',
                            data: {type:'daily_attendance',emp_id:emp_id,department_id:department_id,date:date},
                            success: function (response) {
                                console.log(response);
                                if(response['error']==false){
                                    var html='<div class="row" style="margin-top:10px;"><div class="col-sm-1"><b>S.no</b></div><div class="col-sm-3"><b>Employeee Name</b></div><div class="col-sm-2"><b>Check In Time</b></div><div class="col-sm-2"><b>Check Out time</b></div><div class="col-sm-4"><b>Status</b></div></div>';
                                    for(var i=0;i<response['data'].length;i++){
                                        if(response['data'][i]['att_id']==''){
                                            html+= 'Please Select Department';
                                            html+= '<div class="row" style="margin-top:10px;"><div class="col-sm-1">'+(i+1)+'</div> <div class="col-sm-3"><input type="text" name="create_emp_id[]" value="'+response['data'][i]['id']+'" hidden>'+response['data'][i]['emp_name']+'</div><div class="col-sm-2"><input type="time" name="create_att_check_in[]"   class="form-control tip input-sm" id="create_att_check_in[]" value="'+response['data'][i]['att_check_in']+'"  required="required" /></div> <div class="col-sm-2"><input type="time" name="create_att_check_out[]" value="'+response['data'][i]['att_check_out']+'"  class="form-control tip input-sm" id="holiday_date" /></div><div class="col-sm-4"><select class="form-control select2 input-sm" name="att_status[]"><option value="1">Present</option><option value="2">Half Day</option><option value="3">Absent</option></select></div></div>';
                                        }else{
                                             html+= '<div class="row" style="margin-top:10px;"><input type="text" name="update_attendance_id[]" value="'+response['data'][i]['id']+'" hidden><div class="col-sm-1">'+(i+1)+'</div> <div class="col-sm-3"><input type="text" name="update_employee_name[]"   class="form-control tip input-sm" id="update_employee_name[]" value="'+response['data'][i]['uname']+'"  required="required" /></div><div class="col-sm-2"><input type="text" name="update_att_check_in[]"   class="form-control tip input-sm" id="update_att_check_in[]" value="'+response['data'][i]['date']+'"  required="required" /></div> <div class="col-sm-2"><input type="text" name="update_department_id[]" value="'+response['data'][i]['department_id']+'" hidden><input type="text" name="update_att_department[]" value="'+response['data'][i]['department_name']+'"  class="form-control tip input-sm" id="update_att_department"  required="required" /></div><div class="col-sm-2"><select class="form-control select2 input-sm" name="update_project[]"><option value="">Select Project</option><?php $statement = $pdo->prepare("SELECT * FROM tbl_site");$statement->execute();$result = $statement->fetchAll(PDO::FETCH_ASSOC);foreach ($result as $data) { ?><option value="<?=$data['id']?>"><?=$data['site_name']?></option><?php } ?></select></div><div class="col-sm-2"><select class="form-control select2 input-sm" name="update_att_status[]">';
                                             
                                             if(response['data'][i]['att_type']==1){ html+= '<option value="1" selected>Present</option>';}
                                             else{  html+= '<option value="1">Present</option>'; }
                                             
                                             if(response['data'][i]['att_type']==2){ html+= '<option value="2" selected>Half Day</option>';}
                                             else{  html+= '<option value="2">Half Day</option>'; }
                                             
                                             if(response['data'][i]['att_type']==3){ html+= '<option value="3" selected>Absent</option>';}
                                             else{  html+= '<option value="3">Absent</option>'; }
                                             
                                            /* if(response['data'][i]['att_type']==4){ html+= '<option value="4" selected>Holiday or Week Off</option>';}
                                             else{  html+= '<option value="4">Holiday or Week Off</option>'; }
                                             
                                             if(response['data'][i]['att_type']==5){ html+= '<option value="5" selected>Bonus Leave</option>';}
                                             else{  html+= '<option value="5">Bonus Leave</option>'; }*/

                                             html+= '</select></div></div>';
                                        }
                                    }
                                   
                                    $('#allowance_rows').append(html);
                                    }else{
                                        console.log("Not Work");
                                    }
                                }
                        });
    }
      
  }); 
</script>

<?php include "footer.php";?>

Zerion Mini Shell 1.0