ok
Direktori : /proc/thread-self/root/proc/self/root/home2/selectio/www/obnovit-tracking/ |
Current File : //proc/thread-self/root/proc/self/root/home2/selectio/www/obnovit-tracking/attendance-create.php |
<?php include "header.php";?> <?php if(isset($_POST['create_update_attendance']) ){ try{ $base_query="INSERT INTO `tbl_attendence`(`attendence_date`, `resource_name`, `project_name`, `department`, `salary_per_day`, `attendence_type`, `notes`) VALUES"; $base_value=array(); if(isset($_POST['create_employee_id'] )){ for($i=0;$i<count($_POST['employee_id']);$i++){ $base_value[]="('".$_POST['dates']."','".$_POST['employee_id'][$i]."','".$_POST['update_project'][$i]."','".$_POST['update_department'][$i]."','".$_POST['update_salary'][$i]."','".$_POST['update_attendence_type'][$i]."','".$_POST['notes'][$i]."')"; } } if(isset($_POST['update_employee_id'])){ for($i=0;$i<count($_POST['employee_id']);$i++){ $statement = $pdo->prepare("UPDATE tbl_attendence SET attendence_date=?,attendence_type=?,project_name=?,department=?,salary_per_day=?,notes=? WHERE resource_name=? and attendence_date=?"); $result=$statement->execute(array($_POST['dates'],$_POST['update_attendence_type'][$i],$_POST['update_project'][$i],$_POST['update_department'][$i],$_POST['update_salary'][$i],$_POST['notes'][$i],$_POST['employee_id'][$i],$_POST['dates'])); } } if(count($base_value)){ $string_version = implode(',', $base_value); $base_query.=$string_version; $statement = $pdo->prepare($base_query); $result=$statement->execute(); } if($result){ /*$statement = $pdo->prepare("INSERT INTO `tbl_project_reports`(`user_id`, `project_id`, `project_date`) VALUES (?,?,?)"); $result=$statement->execute(array($_POST['emp_name'],$_POST['project_name'],$_POST['attendence_date']));*/ $message = 'Attendence Updated Successfully!'; unset($_POST); }else{ $warning="Something went wrong try again..."; } }catch(Exception $e){ $error=$e; } } ?> <div class="content-wrapper" style="background:white;"> <div class="col-lg-12 alerts"> <div id="custom-alerts" style="display:none;"> <div class="alert alert-dismissable"> <div class="custom-msg"></div> </div> </div> <br> <?php if ($error) { ?> <div class="alert alert-danger alert-dismissable"> <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button> <h4><i class="icon fa fa-ban"></i> Error</h4> <?= $error; ?> </div> <?php $error=0;} if ($warning) { ?> <div class="alert alert-warning alert-dismissable"> <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button> <h4><i class="icon fa fa-warning"></i> warning</h4> <?= $warning; ?> </div> <?php $warning=0;} if ($message) { ?> <div class="alert alert-success alert-dismissable"> <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button> <h4> <i class="icon fa fa-check"></i> Success</h4> <?= $message; ?> </div> <?php $message=0; } ?> </div> <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="">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-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 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-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(); console.log(department_id); console.log(date); console.log(emp_id); $('#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-2"><b>Employeee Name</b></div><div class="col-sm-2"><b>Department</b></div><div class="col-sm-2"><b>Projects</b></div><div class="col-sm-2"><b>Salary Per Day</b></div><div class="col-sm-1"><b>Status</b></div><div class="col-sm-1"><b>Notes</b></div></div>'; for(var i=0;i<response['data'].length;i++){ if(response['data'][i]['id']==''){ html+= '<div class="row" style="margin-top:10px;"><input type="text" name="create_employee_id[]" value="'+response['data'][i]['id']+'" hidden><div class="col-sm-1">'+(i+1)+'</div> <div class="col-sm-2"><select class="form-control select2 input-sm" name="employee_id[]"><option value="'+response['data'][i]['user_id']+'">'+response['data'][i]['uname']+'</option></select></div> <div class="col-sm-2"><select class="form-control select2 input-sm" name="update_department[]"><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 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-1"><input type="text" name="update_salary[]" style="padding: 1px 2px;" value="'+response['data'][i]['salary']+'" class="form-control tip input-sm" id="update_salary[]" onkeypress="return isNumberKey(this, event);" required="required" /></div><div class="col-sm-2"><select class="form-control select2 input-sm" name="update_attendence_type[]"><option value="1">Full Day</option><option value="2">Half Day</option><option value="3">Absent</option></select></div><div class="col-sm-2"><input type="text" name="notes[]" class="form-control tip input-sm"></div></div>'; }else{ html+= '<div class="row" style="margin-top:10px;"><input type="text" name="update_employee_id[]" value="'+response['data'][i]['id']+'" hidden><div class="col-sm-1">'+(i+1)+'</div> <div class="col-sm-2"><select class="form-control select2 input-sm" name="employee_id[]"><option value="'+response['data'][i]['emp_id']+'">'+response['data'][i]['uname']+'</option></select></div> <div class="col-sm-2"><select class="form-control select2 input-sm" name="update_department[]"><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 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-1"><input type="text" name="update_salary[]" style="padding: 1px 2px;" value="'+response['data'][i]['salary']+'" class="form-control tip input-sm" id="update_salary[]" onkeypress="return isNumberKey(this, event);" required="required" /></div><div class="col-sm-2"><select class="form-control select2 input-sm" name="update_attendence_type[]">'; if(response['data'][i]['att_type']==1){ html+= '<option value="1" selected>Full Day</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 class="col-sm-2"><input type="text" name="notes[]" value="'+response['data'][i]['notes']+'" class="form-control tip input-sm"></div></div>'; } } $('#allowance_rows').append(html); }else{ console.log("Not Work"); } } }); } }); </script> <script> function isNumberKey(txt, evt) { var charCode = (evt.which) ? evt.which : evt.keyCode; if (charCode == 46) { //Check if the text already contains the . character if (txt.value.indexOf('.') === -1) { return true; } else { return false; } } else { if (charCode > 31 && (charCode < 48 || charCode > 57)) return false; } return true; } </script> <?php include "footer.php";?>