ok
Direktori : /home2/selectio/public_html/obnovit-tracking/old/ |
Current File : /home2/selectio/public_html/obnovit-tracking/old/daily-attendance.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]."','1')"; } } 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'],1,$_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-3"> <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="all">All</option> <?php $statement = $pdo->prepare("SELECT * FROM tbl_departement"); $statement->execute(); $result = $statement->fetchAll(PDO::FETCH_ASSOC); foreach($result as $com_user){ echo "<option value='".$com_user['id']."'>".$com_user['departement']."</option>"; } ?> </select> </div> </div> <div class="col-sm-3"> <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 id!=1"); $statement->execute(); $result = $statement->fetchAll(PDO::FETCH_ASSOC); foreach($result as $com_user){ echo "<option value='".$com_user['id']."'>".$com_user['emp_name']."</option>"; } ?> </select> </div> </div> <div class="col-sm-3"> <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-3"> <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(); $('#allowance_rows').empty(); $.ajax({ url: 'api/daily-attendance-api.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>Employee 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+= '<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"><option value="1">Present</option><option value="2">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]['att_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]['emp_name']+'" required="required" /></div><div class="col-sm-2"><input type="time" name="update_att_check_in[]" class="form-control tip input-sm" id="update_att_check_in[]" value="'+response['data'][i]['att_check_in']+'" required="required" /></div> <div class="col-sm-2"><input type="time" name="update_att_check_out[]" value="'+response['data'][i]['att_check_out']+'" class="form-control tip input-sm" id="update_att_check_out" required="required" /></div><div class="col-sm-4"><select class="form-control select2 input-sm"><option value="1">Present</option><option value="2">Absent</option></select></div></div>'; } } $('#allowance_rows').append(html); } } }); } }); </script> <?php include "footer.php";?>