?
Current Path : /home1/savoy/public_html/savoyglobal.net/hr/application/views/Timesheet/ |
Linux gator3171.hostgator.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 |
Current File : /home1/savoy/public_html/savoyglobal.net/hr/application/views/Timesheet/timesheetfunctions.php |
<?php /* * To change this template, choose Tools | Templates * and open the template in the editor. */ ?> <script type="text/javascript"> var employee_array= new Array(); function suggestValues(client_timesheet_id,trade_string,end_date) { trade_string=encodeURIComponent(trade_string); $("#employee").autocomplete("<?= site_url()?>/timesheet/employees_not_marked/"+client_timesheet_id+"/"+trade_string+"/"+end_date, { width: 300, selectFirst: false }); } function get_employee_details() { var employee_id = $("#employee_id").val(); var po_id = $("#purchase_order_id").val(); $.ajax({ type: "POST", url: "<?= site_url('timesheet/get_employee_trade/') ?>/"+employee_id, success: function(msg){ var trade = msg.split("~"); $("#employee_trade").text(trade[0]); $("#trade_id").val(trade[1]); } }) $.ajax({ type: "POST", url: "<?= site_url('timesheet/get_employee_no/') ?>/"+employee_id, success: function(msg){ $("#employee_no").text(msg); } }) $.ajax({ type: "POST", url: "<?= site_url('timesheet/get_employee_company/') ?>/"+employee_id, success: function(msg){ var co = msg.split("~"); $("#employee_company").text(co[0]); $("#company_id").val(co[1]); } }) $.ajax({ type: "POST", url: "<?= site_url('timesheet/get_rates_po/') ?>/"+employee_id+"/"+po_id, success: function(msg){ $("#rates_po").val(msg); } }) } function calculate_hours() { var i=1; var basic_hours = $('input#basic_hours').val(); var days = $('input#total_no_days').val(); var rates_po = $('input#rates_po').val(); if(rates_po == '') { var employee_id = $("#employee_id").val(); var po_id = $("#purchase_order_id").val(); $.ajax({ type: "POST", url: "<?= site_url('timesheet/get_rates_po/') ?>/"+employee_id+"/"+po_id, async: false, success: function(msg){ rates_po=msg; } }) } var rates=rates_po.split("~"); var basic_rate; var ot_rate; var hot_rate; if($('input#basic_rate').val()!=0) basic_rate = $('input#basic_rate').val(); else basic_rate = rates[0]; if($('input#ot_rate').val()!=0) ot_rate = $('input#ot_rate').val(); else ot_rate = ot_rate = rates[2]/100*basic_rate; if($('input#hot_rate').val()!=0) hot_rate = $('input#hot_rate').val(); else hot_rate = rates[3]/100*basic_rate; var ot_type = rates[1]; var normal_hours=0; var ot_hours=0; var hot_hours=0; var total_hours_text=0; for (i=1; i<=days; i++) { if(isNaN($('input#attendance_day'+i).val())==false && $('input#attendance_day'+i).val() != '') { if(ot_type==0) { normal_hours=parseFloat(normal_hours)+parseFloat($('input#attendance_day'+i).val()); total_hours_text=parseFloat(total_hours_text)+parseFloat($('input#attendance_day'+i).val()); ot_hours=0; hot_hours=0; } else { var holiday = $('input#holiday_string').val(); var thisdate = $('input#attendance_date'+i).val() total_hours_text=parseFloat(total_hours_text)+parseFloat($('input#attendance_day'+i).val()); if(holiday.indexOf(thisdate) != -1) { hot_hours=parseFloat(hot_hours)+parseFloat($('input#attendance_day'+i).val()); } else if(parseFloat($('input#attendance_day'+i).val()) > parseFloat(basic_hours)) { normal_hours=parseFloat(normal_hours)+parseFloat(basic_hours); ot_hours= parseFloat(ot_hours)+parseFloat($('input#attendance_day'+i).val())-parseFloat(basic_hours) ; } else { normal_hours=parseFloat(normal_hours)+parseFloat($('input#attendance_day'+i).val()); } } } } if(ot_hours<0) ot_hours=0; var normal_amount = normal_hours*basic_rate; var ot_amount = ot_hours*ot_rate; var hot_amount = hot_hours*hot_rate; $('input#normal_hours').val(normal_hours); $('input#ot_hours').val(ot_hours); $('input#hot_hours').val(hot_hours); $('input#basic_rate').val(basic_rate); $('input#ot_type').val(ot_type); $('input#ot_rate').val(ot_rate); $('input#hot_rate').val(hot_rate); $('#total_hours').text(total_hours_text); $('#normal_amount').text(normal_amount); $('#ot_amount').text(ot_amount); $('#hot_amount').text(hot_amount); $('#total_amount').text(normal_amount+ot_amount+hot_amount); } function calculate_total_amounts() { if(jQuery.inArray($("input#employee_id").val(), employee_array)!='-1') { alert("Employee already selected"); $('#employee_trade').text(""); $('#employee_no').text(""); $('input#employee').val(""); $('input#employee_id').val(""); } var rates=rates_po.split("~"); var basic_rate; var ot_rate; var hot_rate; if($('input#basic_rate').val()!=0) basic_rate = $('input#basic_rate').val(); else basic_rate = rates[0]; if($('input#ot_rate').val()!=0) ot_rate = $('input#ot_rate').val(); else ot_rate = ot_rate = rates[2]/100*basic_rate; if($('input#hot_rate').val()!=0) hot_rate = $('input#hot_rate').val(); else hot_rate = rates[3]/100*basic_rate; var ot_type = rates[1]; var normal_hours=$('input#normal_hours').val(); var ot_hours=$('input#ot_hours').val(); var hot_hours=$('input#hot_hours').val(); var normal_amount = normal_hours*basic_rate; var ot_amount = ot_hours*ot_rate; var hot_amount = hot_hours*hot_rate; $('input#basic_rate').val(basic_rate); $('input#ot_type').val(ot_type); $('input#ot_rate').val(ot_rate); $('input#hot_rate').val(hot_rate); $('#normal_amount').text(normal_amount); $('#ot_amount').text(ot_amount); $('#hot_amount').text(hot_amount); $('#total_amount').text(normal_amount+ot_amount+hot_amount); } function calculate_total_amounts_row(status) { var i=1; var rates_po = $('input#rates_po').val(); if(rates_po == '') { var employee_id = $("#employee_id_"+status).val(); var po_id = $("#purchase_order_id").val(); $.ajax({ type: "POST", url: "<?= site_url('timesheet/get_rates_po/') ?>/"+employee_id+"/"+po_id, async: false, success: function(msg){ rates_po=msg; } }) } var rates=rates_po.split("~"); var basic_rate; var ot_rate; var hot_rate; if($('input#calc_basic_rate_'+status).val()!=0) basic_rate = $('input#calc_basic_rate_'+status).val(); else basic_rate = rates[0]; if($('input#calc_ot_rate_'+status).val()!=0) ot_rate = $('input#calc_ot_rate_'+status).val(); else ot_rate = ot_rate = rates[2]/100*basic_rate; if($('input#hot_rate').val()!=0) hot_rate = $('input#hot_rate').val(); else hot_rate = rates[3]/100*basic_rate; var ot_type = rates[1]; var normal_hours=$('input#calc_normal_hours_'+status).val(); var ot_hours=$('input#calc_ot_hours_'+status).val(); var hot_hours=$('input#calc_hot_hours_'+status).val(); var normal_amount = normal_hours*basic_rate; var ot_amount = ot_hours*ot_rate; var hot_amount = hot_hours*hot_rate; $('input#calc_basic_rate_'+status).val(basic_rate); $('input#calc_ot_type_'+status).val(ot_type); $('input#calc_ot_rate_'+status).val(ot_rate); $('input#calc_hot_rate_'+status).val(hot_rate); $('#calc_normal_amount_'+status).text(normal_amount); $('#calc_ot_amount_'+status).text(ot_amount); $('#calc_hot_amount_'+status).text(hot_amount); $('#calc_total_amount_'+status).text(normal_amount+ot_amount+hot_amount); } function calculate_total_amounts_row_load_timesheet(status) { var i=1; var rates_po = $('input#rates_po').val(); if(rates_po == '') { var employee_id = $("#"+status+"_employee_id").val(); var po_id = $("#purchase_order_id").val(); $.ajax({ type: "POST", url: "<?= site_url('timesheet/get_rates_po/') ?>/"+employee_id+"/"+po_id, async: false, success: function(msg){ rates_po=msg; } }) } var rates=rates_po.split("~"); var basic_rate; var ot_rate; var hot_rate; if($('input#'+status+'_basic_rate').val()!=0) basic_rate = $('input#'+status+'_basic_rate').val(); else basic_rate = rates[0]; if($('input#'+status+'_ot_rate').val()!=0) ot_rate = $('input#'+status+'_ot_rate').val(); else ot_rate = ot_rate = rates[2]/100*basic_rate; if($('input#'+status+'_hot_rate').val()!=0) hot_rate = $('input#'+status+'_hot_rate').val(); else hot_rate = rates[3]/100*basic_rate; var ot_type = rates[1]; var normal_hours=$('input#'+status+'_normal_hours').val(); var ot_hours=$('input#'+status+'_ot_hours').val(); var hot_hours=$('input#'+status+'_hot_hours').val(); var normal_amount = normal_hours*basic_rate; var ot_amount = ot_hours*ot_rate; var hot_amount = hot_hours*hot_rate; $('input#'+status+'_basic_rate').val(basic_rate); $('input#'+status+'_ot_type').val(ot_type); $('input#'+status+'_ot_rate').val(ot_rate); $('input#'+status+'_hot_rate').val(hot_rate); $('#'+status+'_normal_amount').text(normal_amount); $('#'+status+'_ot_amount').text(ot_amount); $('#'+status+'_hot_amount').text(hot_amount); $('#'+status+'_total_amount').text(normal_amount+ot_amount+hot_amount); } function check_hours(status) { if(!isNaN($('#'+status).val())) if($('#'+status).val() > 24) { alert("Hours should not be greater than 24") $('#'+status).val(0); $('#'+status).focus(); } } $('.tiny').keyup(function(){ this.value = this.value.toUpperCase(); }); function check_employee_hours_client(status,calendar_date,employee_id) { if(employee_id == 0) employee_id=$('#employee_id').val(); var client_timesheet_id = $('#client_timesheet_id').val(); if(!isNaN($('#'+status).val()) && $('#'+status).val()!=0) { $.ajax({ type: "POST", url: "<?= site_url('timesheet/check_employee_hours_client/') ?>/"+employee_id+"/"+calendar_date+"/"+client_timesheet_id, success: function(msg){ if(msg==1) { alert("Employee has worked elsewhere on the date") $('#'+status).val(0); $('#'+status).focus(); } } }) } } function fill_hours() { if($('#employee_id').val()=='') { alert("Please select employee first"); } else if($('#hours').val() > 24 || $('#hours').val() < 0) { alert($('#hours').val()); alert("Please enter proper hours"); } else { var from_date = new Date($('#from_date').val().substring(6,10),parseInt($('#from_date').val().substring(3,5)) -1,$('#from_date').val().substring(0,2),0,0,0,0); var to_date = new Date($('#to_date').val().substring(6,10),parseInt($('#to_date').val().substring(3,5)) -1,$('#to_date').val().substring(0,2)); var i=parseInt(from_date.getDate()); while (from_date<=to_date) { var strDate = from_date.getDate(); if(strDate.toString().length<2) strDate = '0' + strDate.toString(); var month = (from_date.getMonth()+1); if(month.toString().length<2) month = '0' + month.toString(); var classs = from_date.getFullYear()+"-" +month+"-" +strDate; var this_date = from_date.getFullYear()+"-" +month+"-" +strDate; classs = '[name=attendance_day'+i+']'; if(!isNaN($($(classs)).val())) $($(classs)).val($('#hours').val()); check_employee_hours_client('attendance_day'+i,this_date,0); from_date.setDate(from_date.getDate()+1); i++; } calculate_hours(); } } function calculate_total_hours(status,po_ot_rate_type) { var days = $('input#total_no_days').val(); var total_hours_text = 0; var total_normal_hours = 0; var total_ot_hours = 0; var total_hot_hours = 0; var basic_hours = $('input#basic_hours').val(); for (i=1; i<=days; i++) { if(!isNaN($('input#attendance_date'+i+'_'+status).val()) && $('input#attendance_date'+i+'_'+status).val()!='') { total_hours_text=parseFloat(total_hours_text)+parseFloat($('input#attendance_date'+i+'_'+status).val()); } } if(po_ot_rate_type==0) { for (i=1; i<=days; i++) { if(!isNaN($('input#attendance_date'+i+'_'+status).val()) && $('input#attendance_date'+i+'_'+status).val()!='') { total_normal_hours=parseFloat(total_normal_hours)+parseFloat($('input#attendance_date'+i+'_'+status).val()); } } } else if(po_ot_rate_type==1) { for (i=1; i<=days; i++) { if(!isNaN($('input#attendance_date'+i+'_'+status).val()) && $('input#attendance_date'+i+'_'+status).val()!='') { if($('input#attendance_holiday'+i+'_'+status).val()=='1') { total_hot_hours = parseFloat(total_hot_hours)+parseFloat($('input#attendance_date'+i+'_'+status).val()); } else if(parseFloat($('input#attendance_date'+i+'_'+status).val())>parseFloat(basic_hours)) { total_ot_hours = parseFloat(total_ot_hours)+parseFloat($('input#attendance_date'+i+'_'+status).val())-parseFloat(basic_hours); total_normal_hours = parseFloat(total_normal_hours)+parseFloat(basic_hours); } else { total_normal_hours = parseFloat(total_normal_hours)+parseFloat($('input#attendance_date'+i+'_'+status).val()); } } } } if(total_ot_hours<0) total_ot_hours=0; $('#cal_total_hours_'+status).text(total_hours_text); $('#calc_normal_hours_'+status).val(total_normal_hours); $('#calc_ot_hours_'+status).val(total_ot_hours); $('#calc_hot_hours_'+status).val(total_hot_hours); } function calculate_total_hours_load_timesheet(status) { var days = $('input#total_no_days').val(); var total_hours_text = 0; for (i=1; i<=days; i++) { if(!isNaN($('input#'+status+'_attendance_day_'+i).val())) { total_hours_text=parseFloat(total_hours_text)+parseFloat($('input#'+status+'_attendance_day_'+i).val()); } } $('#'+status+'_total_hours').text(total_hours_text); } function check_hours_added() { var i = 1; while($('#calc_normal_hours_'+i).length != 0) { if($('#cal_total_hours_'+i).text() != (parseFloat($('input#calc_normal_hours_'+i).val()) + parseFloat($('input#calc_ot_hours_'+i).val()) + parseFloat($('input#calc_hot_hours_'+i).val()))) { alert("Normal Hours, OT Hours and HOT Hours should sum upto Total Hours"); $('input#calc_normal_hours_'+i).focus(); $('input#calc_normal_hours_'+i).css('border','solid 1px red'); return false; } i++; } var j = 1; while($('#'+j+'_normal_hours').length != 0) { if($('#'+j+'_total_hours').text() != (parseFloat($('input#'+j+'_normal_hours').val()) + parseFloat($('input#'+j+'_ot_hours').val()) + parseFloat($('input#'+j+'_hot_hours').val()))) { alert("Normal Hours, OT Hours and HOT Hours should sum upto Total Hours"); $('input#'+j+'_normal_hours').focus(); $('input#'+j+'_normal_hours').css('border','solid 1px red'); return false; } j++; } addformdata('validateform'); } </script> <link href="<?=base_url()?>assets/css/tablesorttimesheet.css" rel="stylesheet" type="text/css"/> <style type="text/css"> .calendar { font-family: 'Trebuchet MS', Tahoma, Verdana, Arial, sans-serif; font-size: 0.9em; background-color: #EEE; color: #333; border: 1px solid #DDD; -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; padding: 0.2em; width: 14em; } .calendar a { outline: none; } .calendar .months { background-color: #3a73f6; border: 1px solid #E78F08; -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; color: #FFF; padding: 0.2em; text-align: center; } .calendar .prev-month, .calendar .next-month { padding: 0; } .calendar .prev-month { float: left; } .calendar .next-month { float: right; } .calendar .current-month { margin: 0 auto; } .calendar .months a { color: #FFF; text-decoration: none; padding: 0 0.4em; -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; } .calendar .months a:hover { background-color: #FDF5CE; color: #C77405; } .calendar table { border-collapse: collapse; padding: 0; font-size: 0.8em; width: 100%; } .calendar th { text-align: center; } .calendar td { text-align: right; padding: 1px; width: 14.3%; } .calendar td a { display: block; color: #1C94C4; background-color: #F6F6F6; border: 1px solid #CCC; text-decoration: none; padding: 0.2em; } .calendar td a:hover { color: #C77405; background-color: #FDF5CE; border: 1px solid #FBCB09; } .calendar td.today a { background-color: #FFF0A5; border: 1px solid #FED22F; color: #363636; } </style>