ok
Direktori : /home2/selectio/public_html/mm-tailor-billing/hrm/ |
Current File : //home2/selectio/public_html/mm-tailor-billing/hrm/attendance.php |
<?php include "header.php";?> <?php if(isset($_GET['date'])){ $date = $_GET['date']; }else{ $date = date("Y-m-d"); } if(isset($_POST['delete'])){ try{ $statement = $pdo->prepare("DELETE `tbl_reports` WHERE date=?"); $result=$statement->execute(array($date)); if($results){ echo "<script>alert('Datas Deleted Successfully')</script>"; }else{ echo "<script>alert('Something Went Wrong...')</script>"; } }catch(Exception $e){ echo "<script>alert('$e')</script>"; } } $statement_reports = $pdo->prepare("SELECT h.* FROM tbl_reports h where h.date='$date'"); $statement_reports->execute(); $reports_query = $statement_reports->fetchAll(PDO::FETCH_ASSOC); $reports_totalData = $statement_reports->rowCount(); if($reports_totalData>0){ $message = ""; $delete_button = " <a name='delete' onclick='delete_records()' class='btn btn-info btn-xs'>Delete Today Datas Old</a> "; }else{ $message = " --> New Datas"; $delete_button = ""; } $timestamp = strtotime($date); $weekday= date("l", $timestamp ); if ($weekday =="Sunday") { $Week_Days = 0; }else { $Week_Days = 1; } ?> <style> body { font-weight: 400; background: aliceblue; } </style> <style> /*tr:hover{ background-color: red !important; color: white !important; } tr:hover td, tr:hover th { background-color: red !important; color: white !important; }*/ .p0{ padding: 0px; } .tcenter{ text-align: center; } .font_weak_days{ font-size: 28px; font-family: sans-serif; font-style: normal; } .message{ font-size: 20px; font-family: sans-serif; font-style: normal; } table{ width: 100%; border: 1px solid black; } td,th{ border: 1px solid black; } th{ padding: 5px 0px 5px 0px; background: blue !important; color: white; font-family: sans-serif; font-size: 12px; } .form{ text-align: center; font-size: 24px; font-weight: 800; font-family: system-ui; padding: 0px; } .names{ font-weight: 700; font-size: 9px; font-family: sans-serif; } .form-control { padding: 0px !important; } </style> <link href="input-css.css" rel="stylesheet" type="text/css" /> <?php $statement_product = $pdo->prepare("SELECT h.* FROM tbl_products h where h.id!=0 and h.status=1 ORDER BY h.order_no ASC"); $statement_product->execute(); $product_query = $statement_product->fetchAll(PDO::FETCH_ASSOC); $product_totalData = $statement_product->rowCount(); $statement_users = $pdo->prepare("SELECT h.* FROM tec_users h where hrms='HRMS' and status=1 ORDER BY h.order_no ASC"); $statement_users->execute(); $product_users = $statement_users->fetchAll(PDO::FETCH_ASSOC); $users_totalData = $statement_users->rowCount(); ?> <section class="content" style="background-color: aliceblue; margin: 10px 10px 10px 10px;"> <?php //echo phpinfo() ?> <div class="row" style="margin-top: 22px;"> <form action="" method="get"> <div class="row" style="margin-left:10px;"> <div class="col-md-3"> <div class="form-group"> <label>Date <?php if(isset($_COOKIE["MM_Tailor"])){ // echo $_COOKIE["MM_Tailor"]; } ?> </label> <input type="date" name="date" class="form-control date" value="<?=$date?>" style="width:100%; padding: 5px!important;" id="date" required> </div> </div> <div class="col-md-1"> <button type="submit" id="filter" class="btn btn-warning btn-sm" style="margin-top: 28px;"><i class="fa fa-filter"></i> Show Data</button> </div> <div class="col-md-4" style="margin-top: 28px;"> <center><b class="font_weak_days"><?=date('d-m-Y',strtotime($date))?>, <?=$weekday?></b><b class="message" style="color: green;"><?=$message?></b></center> </div> <div class="col-md-4" style="margin-top: 28px;"> <center><b class="font_weak_days"></b><b class="message" style="color: green;"><?=$delete_button?></b></center> </div> </div> </form> <form id="attendance" autocomplete="off"> <input type="hidden" name="type" class="form-control add_new_reports" value="add_new_reports" style="width:100%" id="add_new_reports" required> <input type="hidden" name="date" class="form-control date" value="<?=$date?>" style="width:100%" id="date" required> <div id="product_section" style="margin: 10px 10px 10px 10px;"> <table style="" id="pos_table"> <thead> <tr> <th style="width: 10%;"> Names</th> <th class='changeable'>AD</th> <th>BATA</th> <th>MISC</th> <th>SALARY</th> <th>OT</th> <?php if($product_totalData>0){ foreach($product_query as $query){ if($query['category']=="SHIRT"){ $style="background: brown !important;"; }else{ $style="background: chocolate !important;"; } echo "<th style='".$style."' class='changeable'>".$query['short_name']."</th>"; } } ?> <th>TOTAL</th> <th>P</th> </tr> </thead> <tbody> <?php if($users_totalData>0){ $i=1; foreach($product_users as $users){ ?> <?php $statement_att = $pdo->prepare("SELECT h.* FROM tbl_reports h where h.id!=0 and h.date='".$date."' and h.user_id='".$users['id']."' ORDER BY h.id ASC"); $statement_att->execute(); $att_results = $statement_att->fetchAll(PDO::FETCH_ASSOC); $att_totalData = $statement_att->rowCount(); if($att_totalData>0){ ?> <!-- This Part is Database Rows Here --> <tr> <input type="hidden" name="ids[]" class="ids" value="<?=$att_results[0]['id']?>"> <input type="hidden" name="count[]" class="count" value="<?=$i?>"> <td style="text-align: center; padding: 10px;"> <b class="names"><?=$users['first_name']?></b> <input type="hidden" name="user_id[]" value="<?=$users['id']?>" > </td> <td><input type="text" name="advance[]" id="advance_<?=$i?>" value="<?=$att_results[0]['advance']?>" class="form-control form advance vertical"></td> <td><input type="text" name="beta[]" id="beta_<?=$i?>" value="<?=$att_results[0]['beta']?>" class="form-control form beta vertical"></td> <td><input type="text" name="misc[]" id="misc_<?=$i?>" value="<?=$att_results[0]['misc']?>" class="form-control form misc vertical"></td> <td><input type="text" name="salary[]" id="salary_<?=$i?>" value="<?=$att_results[0]['salary']?>" class="form-control form salary vertical"></td> <td><input type="text" name="ot[]" id="ot_<?=$i?>" value="<?=$att_results[0]['ot']?>" class="form-control form ot vertical"></td> <?php if($product_totalData>0){ $p=1; echo '<input type="hidden" name="product_count[]" class="product_count" value="'.$product_totalData.'">'; foreach($product_query as $query){ if($query['category']=="SHIRT"){ $style="background: bisque; color: black;"; }else{ $style="background: cyan; color: black;"; } $product_id = "pro_".$query['id'].""; if($att_results[0][$product_id]==""){ $att_results[0][$product_id]=""; $product_rate =""; }else{ $product_rate = $att_results[0][$product_id]*$query['product_rate']; } echo '<td> <input type="hidden" value="'.$p.'" class="product_count"> <input type="hidden" name="product_rate_'.$p.'[]" id="product_rate_'.$i.'" value="'.$query['product_rate'].'" class="form-control product_rate product_rate_'.$i.'" > <input type="text" name="product_'.$p.'[]" id="product_'.$i.'" value="'.$att_results[0][$product_id].'" class="form-control form changeable product product_'.$i.' pro_count_'.$p.' vertical" style="'.$style.'"> <input type="hidden" name="product_total_'.$p.'[]" id="product_total_'.$i.'" value="'.$product_rate.'" class="form-control form product_total product_total_'.$i.'"> </td>'; $p++; } } ?> <td> <input type="text" name="grand_total[]" id="grand_total_<?=$i?>" value="<?=$att_results[0]['grand_total']?>" class="form-control form grand_total" readonly> <input type="hidden" name="product_total[]" id="product_totall_<?=$i?>" value="<?=$att_results[0]['product_total']?>" class="form-control form product_total"> </td> <?php if($att_results[0]['leave']!=""){ $leave = $att_results[0]['leave']; }else{ $leave = $Week_Days; } ?> <td><input type="text" name="leave[]" id="leave_<?=$i?>" value="<?=$leave?>" class="form-control form leave"></td> </tr> <?php }else{ ?> <!-- This Part is New Rows Here --> <tr> <input type="hidden" name="ids[]" class="ids" value="0"> <input type="hidden" name="count[]" class="count" value="<?=$i?>"> <td style="text-align: center; padding: 10px;"> <b class="names"><?=$users['first_name']?></b> <input type="hidden" name="user_id[]" value="<?=$users['id']?>" > </td> <td><input type="text" name="advance[]" id="advance_<?=$i?>" value="" class="form-control form advance vertical"></td> <td><input type="text" name="beta[]" id="beta_<?=$i?>" value="" class="form-control form beta vertical"></td> <td><input type="text" name="misc[]" id="misc_<?=$i?>" value="" class="form-control form misc vertical"></td> <td><input type="text" name="salary[]" id="salary_<?=$i?>" value="<?=$users['per_day_salary']?>" class="form-control form salary vertical"></td> <td><input type="text" name="ot[]" id="ot_<?=$i?>" value="<?=$users['ot_amount']?>" class="form-control form ot vertical"></td> <?php if($product_totalData>0){ $p=1; echo '<input type="hidden" name="product_count[]" class="product_total_count" value="'.$product_totalData.'">'; foreach($product_query as $query){ if($query['category']=="SHIRT"){ $style="background: bisque; color: black;"; }else{ $style="background: cyan; color: black;"; } echo '<td> <input type="hidden" value="'.$p.'" class="product_count"> <input type="hidden" name="product_rate_'.$p.'[]" id="product_rate_'.$i.'" value="'.$query['product_rate'].'" class="form-control product_rate product_rate_'.$i.'" > <input type="text" name="product_'.$p.'[]" id="product_'.$i.'" value="" class="form-control form product product_'.$i.' pro_count_'.$p.' vertical" style="'.$style.'"> <input type="hidden" name="product_total_'.$p.'[]" id="product_total_'.$i.'" value="" class="form-control form product_total product_total_'.$i.'"> </td>'; $p++; } } ?> <td> <input type="text" name="grand_total[]" id="grand_total_<?=$i?>" value="" class="form-control form grand_total" readonly> <input type="hidden" name="product_total[]" id="product_totall_<?=$i?>" value="" class="form-control form product_total"> </td> <td><input type="text" name="leave[]" id="leave_<?=$i?>" value="<?=$Week_Days?>" class="form-control form leave"></td> </tr> <?php } ?> <?php $i++; } } ?> </tbody> <tfoot> <tr> <th>Total</th> <td><input type="text" name="total_advance" id="total_advance" value="" class="form-control total total_advance p0 tcenter" style="font-weight: 800; color: black;"></td> <td><input type="text" name="total_beta" id="total_beta" value="" class="form-control total_beta p0 tcenter" style="font-weight: 800; color: black;"></td> <td><input type="text" name="total_misc" id="total_misc" value="" class="form-control total_misc p0 tcenter" style="font-weight: 800; color: black;"></td> <td><input type="text" name="total_salary" id="total_salary" value="" class="form-control total_salary p0 tcenter" style="font-weight: 800; color: black;"></td> <td><input type="text" name="total_ot" id="total_ot" value="" class="form-control total_ot p0 tcenter" style="font-weight: 800; color: black;"></td> <?php if($product_totalData>0){ $i=1; foreach($product_query as $query){ echo "<td style=''><input type='text' name='total_product_".$query['id']."' id='total_product_".$i."' value='' class='form-control product tcenter total_product'></td>"; $i++; } } ?> <td><input type="text" name="grand_totall" id="grand_total" value="" class="form-control p0 tcenter"></td> <td><input type="text" name="total_leaves" id="total_leaves" value="" class="form-control total_leaves"></td> </tr> <!--<tr> <td colspan="3"></td> </tr>--> </tfoot> </table> </div> <br> <center><input type="submit" id="add_new_product_submit" name="add_product " value="Update Data" class="btn btn-success" /></center> </form> </div> </section> <script> function isNumberKey(txt, evt) { var charCode = (evt.which) ? evt.which : evt.keyCode; if (charCode == 46) { if (txt.value.indexOf('.') === -1) { return true; } else { return false; } } else { if (charCode > 31 && (charCode < 48 || charCode > 57)) return false; } return true; } </script> <script type="text/javascript"> $(document).ready(function(){ grand_advance(); grand_beta(); grand_total(); grand_salary(); grand_ot(); grand_misc(); $('table#pos_table tbody tr .product').each(function() { var count=Number($(this).closest("tr").find(".count").val()); var product_count = Number($(this).closest("td").find(".product_count").val()); var product_rate=Number($(this).closest("td").find(".product_rate").val()); var product=Number($(this).val()); console.log('Product Rate:'+product_rate); total_amount = product*product_rate; $(this).find(".product_total").val(total_amount); product_total(count); pro_count(product_count); grand_total(); }); // Product Section Starts Here $("body").on("keyup",".product",function(){ var count=Number($(this).closest("tr").find(".count").val()); var product_count = Number($(this).closest("td").find(".product_count").val()); var product_rate=Number($(this).closest("td").find(".product_rate").val()); var product=Number($(this).val()); total_amount = product*product_rate; $(this).closest("td").find(".product_total").val(total_amount); product_total(count); pro_count(product_count); grand_total(); }); function pro_count(product_count){ var ptot=0; $(".pro_count_"+product_count).each(function(){ ptot+=Number($(this).val()); }); $("#total_product_"+product_count).val(ptot); } function product_total(count){ var tot=0; $(".product_total_"+count).each(function(){ tot+=Number($(this).val()); }); var advance = $("#advance_"+count).val() || 0; var bata = $("#beta_"+count).val() || 0; var misc = $("#misc_"+count).val() || 0; var salary = $("#salary_"+count).val() || 0; var ot = $("#ot_"+count).val() || 0; var credit = parseFloat(bata)+parseFloat(misc)+parseFloat(salary)+parseFloat(ot)+parseFloat(tot); var debit = parseFloat(advance); $("#grand_total_"+count).val(credit-debit); $("#product_totall_"+count).val(tot); } // Product Section Endsss Here $("body").on("keyup",".leave",function(){ var count=Number($(this).closest("tr").find(".count").val()); var leave=Number($(this).val()); if(leave==0){ $("#salary_"+count).val(0); $("#ot_"+count).val(0); } }); $("body").on("keyup",".advance",function(){ var count=Number($(this).closest("tr").find(".count").val()); var advance=Number($(this).val()); grand_advance(); product_total(count); }); $("body").on("keyup",".beta",function(){ var count=Number($(this).closest("tr").find(".count").val()); var beta=Number($(this).val()); grand_beta(); product_total(count); }); $("body").on("keyup",".misc",function(){ var count=Number($(this).closest("tr").find(".count").val()); grand_misc(); product_total(count); }); $("body").on("keyup",".salary",function(){ var count=Number($(this).closest("tr").find(".count").val()); grand_salary(); product_total(count); }); $("body").on("keyup",".ot",function(){ var count=Number($(this).closest("tr").find(".count").val()); grand_ot(); product_total(count); }); function grand_advance(){ var tot=0; $(".advance").each(function(){ tot+=Number($(this).val()); }); $("#total_advance").val(tot); } function grand_beta(){ var tot=0; $(".beta").each(function(){ tot+=Number($(this).val()); }); $("#total_beta").val(tot); } function grand_total(){ var tot=0; $(".grand_total").each(function(){ tot+=Number($(this).val()); }); $("#grand_total").val(tot); } function grand_misc(){ var tot=0; $(".misc").each(function(){ tot+=Number($(this).val()); }); $("#total_misc").val(tot); } function grand_salary(){ var tot=0; $(".salary").each(function(){ tot+=Number($(this).val()); }); $("#total_salary").val(tot); } function grand_ot(){ var tot=0; $(".ot").each(function(){ tot+=Number($(this).val()); }); $("#total_ot").val(tot); } }); </script> <?php include "footer.php";?> <script> $(document).ready(function(){ $('#attendance').on('submit', function(e){ e.preventDefault(); $("#add_new_product_submit").attr('disabled','disabled'); console.log('Product Submit Option Start...'); var formData = new FormData(this); formData.append('type', 'add_new_reports'); $.ajax({ url: 'apis/reports-add.php', type: 'post', dataType: 'json', data: formData, cache: false, contentType: false, processData: false, enctype: 'multipart/form-data', success: function (response) { console.log(response); if(response['status']==200){ $('#add_new_product').trigger("reset"); $("#add_new_product_submit").removeAttr('disabled'); alert(response['message']); }else{ alert(response['message']); $("#add_new_product_submit").removeAttr('disabled'); } } }); }); }); function delete_records(){ var result = confirm("Confirm Want to Delete This Datas?"); if (result) { $.ajax({ type: 'POST', url: 'api/delete.php', data: {type:'records_delete',delete_date:'<?=$date?>',table:'tbl_reports'}, success: function(response) { console.log(response); window.location.href="attendance.php?date=<?=$date?>"; } }); } } </script> <script> $(document).on('click', 'table#pos_table tbody tr', function () { $('table#pos_table tr').css('background', '#ffffff'); $('table#pos_table tr').css('color', 'black'); $(this).css('background', 'red'); $(this).css('color', 'white'); }); /*function handleTableRowClick(selector) { $(document).on('click', selector, function () { $(selector).css('background', '#ffffff'); $(selector).css('color', 'black'); $(this).css('background', 'red'); $(this).css('color', 'white'); $(this).find('input').first().focus(); }); }*/ /*$(document).on('click', 'table#pos_table tbody tr', function () { $('table#pos_table tr').css('background', '#ffffff'); $('table#pos_table td').css('color', ''); $(this).css('background', '#abe2eb'); $(this).find('td').css('color', 'red'); }); /*$(document).on('click', 'table#pos_table tbody tr', function () { // Reset the background color of all rows to white (#ffffff) $('table#pos_table tr').css('background', '#ffffff'); // Reset the text color of all cells to its original color $('table#pos_table td').css('color', ''); // Set the background color of the clicked row to a different color (#abe2eb) $(this).css('background', '#abe2eb'); // Set the text color of the cells within the clicked row to a different color $(this).find('td').css('color', 'red'); // Change 'red' to your desired text color // Reset the background color of all header cells in the thead to its original color $('table#pos_table thead th').css('background', ''); // Set the background color of the header cells in the thead to a different color $(this).closest('table#pos_table').find('th').css('background', 'blue'); // Change 'blue' to your desired background color });*/ /*$(document).on('click', 'table#pos_table tbody tr', function () { // Reset the background color of all rows to white (#ffffff) $('table#pos_table tr').css('background', '#ffffff'); // Reset the text color of all cells to its original color $('table#pos_table td').css('color', ''); // Set the background color of the clicked row to a different color (#abe2eb) $(this).css('background', '#abe2eb'); // Set the text color of the cells within the clicked row to a different color $(this).find('td').css('color', 'red'); // Change 'red' to your desired text color // Reset the background color of all 'changeable' header cells in the thead to its original color $('table#pos_table thead th.changeable').css('background', ''); // Set the background color of the 'changeable' header cells in the thead to a different color $(this).closest('table#pos_table').find('th').css('background', 'blue'); // Change 'blue' to your desired background color // Reset the background color of all 'changeable' columns in the tbody to its original color $('table#pos_table td.changeable').css('background', ''); // Set the background color of the 'changeable' columns in the clicked row to a different color $(this).find('td.changeable').css('background', 'green'); // Change 'green' to your desired column background color });*/ /*$(document).on('click', 'table#pos_table tbody tr', function () { alert("clicked"); $('table#pos_table tr').css('background', 'red'); $(this).css('background', 'red'); });*/ /*$(document).on('click', 'table.table tbody tr', function () { alert("clicked"); $('table tr').css('background','#red !important'); $(this).css('background','#red !important'); });*/ /*$(document).on('click', '#pos_table tr', function () { alert("clicked"); $('table tr').css('background','#red !important'); $(this).css('background','#red !important'); });*/ </script> <script> /*var table = document.getElementById("pos_table"); var rows = table.getElementsByTagName("tr"); for (var i = 0; i < rows.length; i++) { rows[i].addEventListener("click", function() { this.style.backgroundColor = "lightblue"; var cells = this.getElementsByTagName("td"); for (var j = 0; j < cells.length; j++) { cells[j].style.backgroundColor = "lightblue"; } }); }*/ /*var table = document.getElementById("pos_table"); var rows = table.getElementsByTagName("tr"); for (var i = 0; i < rows.length; i++) { rows[i].addEventListener("click", function() { toggleColor(this); }); } function toggleColor(row) { var cells = row.getElementsByTagName("td"); if (row.style.backgroundColor === "lightblue") { row.style.backgroundColor = "lightcoral"; // Change row color on the second click for (var j = 0; j < cells.length; j++) { cells[j].style.backgroundColor = "lightcoral"; // Change cell color on the second click } } else { row.style.backgroundColor = "lightblue"; // Change row color on the first click for (var j = 0; j < cells.length; j++) { cells[j].style.backgroundColor = "lightblue"; // Change cell color on the first click } } }*/ </script> <script> $(document).ready(function(){ $(".finnal_enter").keypress(function(event) { if(event.keyCode == 13) { textboxes = $("input.finnal_enter"); debugger; currentBoxNumber = textboxes.index(this); if (textboxes[currentBoxNumber + 1] != null) { nextBox = textboxes[currentBoxNumber + 1] nextBox.focus(); nextBox.select(); event.preventDefault(); return false } } }); }); $(document).ready(function() { $("form").bind("keypress", function(e) { if (e.keyCode == 13) { return false; } }); }); $(document).ready(function(){ $(".vertical").keypress(function(event) { if(event.keyCode == 13) { textboxes = $("input.vertical"); debugger; currentBoxNumber = textboxes.index(this); if (textboxes[currentBoxNumber + 1] != null) { nextBox = textboxes[currentBoxNumber + 1] nextBox.focus(); nextBox.select(); event.preventDefault(); return false } } }); }); </script>