diff --git a/application/controllers/user.php b/application/controllers/user.php index 424055f8..5ef90b61 100755 --- a/application/controllers/user.php +++ b/application/controllers/user.php @@ -81,7 +81,7 @@ class user extends BaseController $data['capitalbal'] = $this->dahsboard_Model->capitalbal(); - /* HR DASHBOARD Controller Start*/ + /* HR DASHBOARD Controller Start*/ $data['totemp'] = $this->dahsboard_Model->totemp(); $data['totloan'] = $this->dahsboard_Model->totloan(); $data['totpay'] = $this->dahsboard_Model->totpay(); @@ -91,7 +91,7 @@ class user extends BaseController /* yesterday absent list count in employee*/ $dates = date('Y-m'); $date = $dates . '-01'; - // echo $date; + // echo $date; $dat = date('d', strtotime("-1 days")); //echo $date; @@ -110,9 +110,10 @@ class user extends BaseController } - // echo $values; + // echo $values; $data['values'] = $values; + /*Today absent list count in employee*/ $dates = date('Y-m'); //echo $date; @@ -125,22 +126,41 @@ class user extends BaseController //echo $WH;die; $yesterday = $this->dahsboard_Model->attyesterday($WH, $date); - // print_r($yesterday);die; + //print_r($yesterday);die; + + + //$absEmp =array($absEmp); $values = 0; + $absEmp = array(); + //echo $value; die; foreach ($yesterday as $weekda => $value) { if ($value[$WH] == 0) { $values++; + $absendId = $value['EmpID']; + $absendName = $value['FirstName']; + + + $absEmp [] = $absendId . "-" . $absendName; //absend empid and name list + + + // foreach($absEmp as $value => $absentEmpName){ + + // echo $absentEmpName; die; + + // } + } } - // print_r($values);die; - $data['today'] = $values; - // function todayEmployeeSalaylist() - //{ + //print_r($absentName);die; + $data['today'] = $values; + $data['absname'] = $absEmp; + // function todayEmployeeSalaylist() + //{ $date = date('Y-m'); //echo $date; die; @@ -173,7 +193,7 @@ class user extends BaseController //print_r($values); die; $Empid = $value['EmpID']; - // echo $Empid; die; + //echo $Empid; die; $totalEmployeePersent = $this->dahsboard_Model->persentEmployeeDetails($Empid); //print_r($totalEmployeePersent);die; @@ -189,7 +209,11 @@ class user extends BaseController $daySalary = $Basic_Pay / $CUR_month; /**per day salary working hour**/ //echo $daySalary.'
'; - $onehoursSalary = $daySalary / 8; + + $dayHra = $HRA_Amount / $CUR_month; + /** per day hra amount **/ + //echo $dayHra.'
'; + $onehoursSalary = ($daySalary + $dayHra) / 8; /**one hour salay ot calculation**/ if ($totalothour != 0) /** if ot not equal zero **/ { $totSalayOT = $totalothour * $onehoursSalary; @@ -199,9 +223,7 @@ class user extends BaseController $currentDaySalary = $daySalary * $values; /** current day salary working days calculation**/ - $dayHra = $HRA_Amount / $CUR_month; - /** per day hra amount **/ - //echo $dayHra.'
'; + $currentDayHra = $dayHra * $values; /** total working days hra calculations**/ // echo $currentDayHra.'
'; @@ -230,14 +252,13 @@ class user extends BaseController //$salaryInCurrentday++; - $data['employeeSalary'] = $employeeSalary; - + $data['employeeSalary'] = $employeeSalary; - // } + // } - // function monthTodayEmployeeSalaylist() - // { + // function monthTodayEmployeeSalaylist() + // { $date = date('Y-m'); //echo $date; die; @@ -272,73 +293,75 @@ class user extends BaseController // { $totalSalary = 0; - $working = explode(",",$WH); + $working = explode(",", $WH); $overtime = explode(",", $OT); foreach ($toDayEmployee as $value) { $values = 0; foreach ($working as $work) { // foreach ($overtime as $extra) { - if ($value[$work] != 0 || $value['OT'.substr($work, 2)] != 0) { - $totalothour = $value['OT'.substr($work, 2)]; - //echo $totalothour; - $values = 1; + if ($value[$work] != 0 || $value['OT' . substr($work, 2)] != 0) { + $totalothour = $value['OT' . substr($work, 2)]; + //echo $totalothour; + $values = 1; - //print_r($values); die; - $Empid = $value['EmpID']; - //echo $Empid; + //print_r($values); die; + $Empid = $value['EmpID']; + //echo $Empid; - $totalEmployeePersent = $this->dahsboard_Model->persentEmployeeDetails($Empid); - //print_r($totalEmployeePersent); + $totalEmployeePersent = $this->dahsboard_Model->persentEmployeeDetails($Empid); + //print_r($totalEmployeePersent); - $HRA_Amount = $totalEmployeePersent[0]->HRA_Amount; - $Basic_Pay = $totalEmployeePersent[0]->Basic_Pay; - $totalsalary = $totalEmployeePersent[0]->TotalSalary; - $dayFoodAmt = $totalEmployeePersent[0]->Food_Allowances; + $HRA_Amount = $totalEmployeePersent[0]->HRA_Amount; + $Basic_Pay = $totalEmployeePersent[0]->Basic_Pay; + $totalsalary = $totalEmployeePersent[0]->TotalSalary; + $dayFoodAmt = $totalEmployeePersent[0]->Food_Allowances; - $Food_Allowances = $dayFoodAmt * $values; + $Food_Allowances = $dayFoodAmt * $values; - $daySalary = $Basic_Pay / $CUR_month; - /**per day salary working hour**/ - //echo $daySalary.'
'; - $onehoursSalary = $daySalary / 8; - /**one hour salay ot calculation**/ - if ($totalothour != 0) /** if ot not equal zero **/ { - $totSalayOT = $totalothour * $onehoursSalary; - } else { - $totSalayOT = 0; - } - $currentDaySalary = $daySalary * $values; - /** current day salary working days calculation**/ + $daySalary = $Basic_Pay / $CUR_month; + /**per day salary working hour**/ + //echo $daySalary.'
'; - $dayHra = $HRA_Amount / $CUR_month; - /** per day hra amount **/ - //echo $dayHra.'
'; - $currentDayHra = $dayHra * $values; - /** total working days hra calculations**/ - // echo $currentDayHra.'
'; - $currentDatePF = $currentDaySalary + $currentDayHra; - /** current date pf calculation**/ - if ($totalsalary <= 20000) { - - $esiAmount = $currentDatePF * 1.75 / 100; - /** esiamount not elgiable for 20000 **/ - } else { - $esiAmount = 0; - } - $pfAmount = $currentDaySalary * 12 / 100; - /** pf amount per day**/ - - //echo $totalothour;die; - $salaryInCurrentday = $currentDaySalary + $totSalayOT + $currentDayHra + $Food_Allowances; - - - $totalSalarys = $totalSalary + $salaryInCurrentday; - - $totalSalary =round($totalSalarys); -// $salarycurrentdate[] = $salaryInCurrentday;; + $dayHra = $HRA_Amount / $CUR_month; + /** per day hra amount **/ + //echo $dayHra.'
'; + $onehoursSalary = ($daySalary + $dayHra) / 8; + /**one hour salay ot calculation**/ + if ($totalothour != 0) /** if ot not equal zero **/ { + $totSalayOT = $totalothour * $onehoursSalary; + } else { + $totSalayOT = 0; } + $currentDaySalary = $daySalary * $values; + /** current day salary working days calculation**/ + + + $currentDayHra = $dayHra * $values; + /** total working days hra calculations**/ + // echo $currentDayHra.'
'; + $currentDatePF = $currentDaySalary + $currentDayHra; + /** current date pf calculation**/ + if ($totalsalary <= 20000) { + + $esiAmount = $currentDatePF * 1.75 / 100; + /** esiamount not elgiable for 20000 **/ + } else { + $esiAmount = 0; + } + $pfAmount = $currentDaySalary * 12 / 100; + /** pf amount per day**/ + + //echo $totalothour;die; + $salaryInCurrentday = $currentDaySalary + $totSalayOT + $currentDayHra + $Food_Allowances; + + + $totalSalarys = $totalSalary + $salaryInCurrentday; + + $totalSalary = round($totalSalarys); +// $salarycurrentdate[] = $salaryInCurrentday;; + } // } //print_r($salarycurrentdate); @@ -350,11 +373,8 @@ class user extends BaseController } } - $data['totalSalary']= $totalSalary; - //} - - - + $data['totalSalary'] = $totalSalary; + //} $this->loadViews("dashboard", $this->global, $data, NULL); @@ -363,378 +383,17 @@ class user extends BaseController -// function attendancemonth() -// { -// // $EmpID=''; -// $date = date('Y-m'); -// //echo $date; -// $dates = $date.'-01'; -// $EmpID= $this->input->post('id'); -// //echo $dates; die; -// //echo $weekabs;die; -// $monthabs = $this->dahsboard_Model->attendance($EmpID,$dates); -// //print_r($data['monthabs']); - -// //$todate = $this->input->get('todate'); -// $persent_month = date('t'); - -// //$current_month_day = cal_days_in_month(CAL_GREGORIAN,$persent_month,$year); -// //$current_month_day;die; -// $values=0; -// $otvalues = array(); -// $CUR_month = date('t'); -// //die(); -// $weekdays = array(); -// $otHours = array(); -// $date = date('d'); -// //echo $date; die; -// for($i=1;$i<=$persent_month;$i++) -// { - -// //if($date > 0 ){ - -// $weekdays[] = 'WH'.$i; -// $otHours[] ='OT'.$i; -// //print_r($weekdays); - - -// } -// //print_r($weekdays);die; - -// foreach ($monthabs as $weekda ) { -// //print_r($weekda); -// foreach ($weekda as $key => $value) { -// //print_r($key);die; - - -// //print_r($value); -// foreach ($weekdays as $weeks) { -// //print_r($weeks); -// //print_r($key); -// if($weeks == $key) -// { - -// if($value != 0){ - -// //echo $values; -// $values++; -// // echo $values; - - -// } -// } - -// } -// foreach($otHours as $ot){ -// if($ot == $key){ - -// if($value != 0){ -// $otvalues []= $value; -// // echo $otvalue; - -// } -// //echo $otvalues; -// } -// } - -// } -// } -// //echo $values;die; - -// $totalothour = array_sum($otvalues); - - -// if($values !=0){ - -// $currentDateSalary=$this->dahsboard_Model->daysalary($EmpID,$dates); -// $HRA_Amount = $currentDateSalary[0]->HRA_Amount; -// $Basic_Pay = $currentDateSalary[0]->Basic_Pay; -// $totalsalary = $currentDateSalary[0]->TotalSalary; -// $dayFoodAmt = $currentDateSalary[0]->Food_Allowances; - -// $Food_Allowances =$dayFoodAmt * $values; - -// $daySalary=$Basic_Pay/$CUR_month; /**per day salary working hour**/ -// //echo $daySalary.'
'; -// $onehoursSalary =$daySalary/8; /**one hour salay ot calculation**/ -// if($totalothour !=0){ /** if ot not equal zero **/ -// $totSalayOT=$totalothour*$onehoursSalary; -// }else{ -// $totSalayOT = 0; -// } -// $currentDaySalary=$daySalary*$values; /** current day salary working days calculation**/ -// $ -// $dayHra =$HRA_Amount/$CUR_month; /** per day hra amount **/ -// //echo $dayHra.'
'; -// $currentDayHra =$dayHra * $values; /** total working days hra calculations**/ -// // echo $currentDayHra.'
'; -// $currentDatePF =$currentDaySalary+$currentDayHra; /** current date pf calculation**/ -// if($totalsalary <= 20000){ - -// $esiAmount = $currentDatePF *1.75/100; /** esiamount not elgiable for 20000 **/ -// }else{ -// $esiAmount = 0; -// } -// $pfAmount = $currentDaySalary *12/100; /** pf amount per day**/ - -// //echo $totalothour;die; -// $salaryInCurrentday=$currentDaySalary+$totSalayOT+ $currentDayHra +$Food_Allowances; -// //echo $salaryInCurrentday;die; -// $year = date('Y'); -// $current_month = date('m'); -// //echo $current_month;die; - - -// //$current_month_days = cal_days_in_month(CAL_GREGORIAN,$current_month,$year); -// //echo $current_month_days;die; - - -// //echo $CUR_month;// echo $current_month;die; -// // $total_days_percentage = ($values/$date); -// //print_r($total_days_percentage);die; -// $data['values'] = $values; -// $data['$salaryInCurrentday'] =$salaryInCurrentday; -// //$data['otvalues'] = $otvalues; -// //print_r($data['otvalues']);die; -// $data['present_percentage'] = round(($values/$date)*100); -// $data['CUR_month'] = $date; - - -// echo json_encode($data); - -// }else{ -// $data['CUR_month'] = $date; -// $data['values'] = 0; -// $data['$salaryInCurrentday'] = 0; -// //$data = 0; - -// echo json_encode($data); -// } - - -// } - - -// function todayEmployeeSalaylist() -// { - -// $date = date('Y-m'); -// //echo $date; die; -// $date = $date . '-01'; -// $dat = date('d'); - -// //echo $dat; die; -// $WH = 'WH' . date('j'); -// $OT = 'OT' . date('j'); - -// $CUR_month = date('t'); -// // echo $CUR_month; die; - -// $toDayEmployee = $this->dahsboard_Model->dayAllPersentEmpSalary($WH, $OT, $date); -// //$EmpID = $toDayEmployee[0]->EmpID; - -// // print_r($toDayEmployee); die; - -// $EmpID = 0; - -// $employeeSalary = 0; - -// foreach ($toDayEmployee as $value) { -// $values = 0; -// $totalothour = 0; -// if ($value[$WH] != 0) { -// $totalothour = $value[$OT]; -// //echo $totalothour;die; -// $values = 1; - -// //print_r($values); die; -// $Empid = $value['EmpID']; -// // echo $Empid; die; - -// $totalEmployeePersent = $this->dahsboard_Model->persentEmployeeDetails($Empid); -// //print_r($totalEmployeePersent);die; - -// $HRA_Amount = $totalEmployeePersent[0]->HRA_Amount; -// $Basic_Pay = $totalEmployeePersent[0]->Basic_Pay; -// $totalsalary = $totalEmployeePersent[0]->TotalSalary; -// $dayFoodAmt = $totalEmployeePersent[0]->Food_Allowances; - - -// $Food_Allowances = $dayFoodAmt * $values; - -// $daySalary = $Basic_Pay / $CUR_month; -// /**per day salary working hour**/ -// //echo $daySalary.'
'; -// $onehoursSalary = $daySalary / 8; -// /**one hour salay ot calculation**/ -// if ($totalothour != 0) /** if ot not equal zero **/ { -// $totSalayOT = $totalothour * $onehoursSalary; -// } else { -// $totSalayOT = 0; -// } -// $currentDaySalary = $daySalary * $values; -// /** current day salary working days calculation**/ - -// $dayHra = $HRA_Amount / $CUR_month; -// /** per day hra amount **/ -// //echo $dayHra.'
'; -// $currentDayHra = $dayHra * $values; -// /** total working days hra calculations**/ -// // echo $currentDayHra.'
'; -// $currentDatePF = $currentDaySalary + $currentDayHra; -// /** current date pf calculation**/ -// if ($totalsalary <= 20000) { - -// $esiAmount = $currentDatePF * 1.75 / 100; -// /** esiamount not elgiable for 20000 **/ -// } else { -// $esiAmount = 0; -// } -// $pfAmount = $currentDaySalary * 12 / 100; -// /** pf amount per day**/ - -// //echo $totalothour;die; -// $salaryInCurrentday = $currentDaySalary + $totSalayOT + $currentDayHra + $Food_Allowances; - -// $employeeSalary += round($salaryInCurrentday); - -// } - -// } - - -// //$salaryInCurrentday++; - - -// echo $employeeSalary; -// die; - - -// } - -// function monthTodayEmployeeSalaylist() -// { - -// $date = date('Y-m'); -// //echo $date; die; -// $date = $date . '-01'; -// $dat = date('d'); - -// // $currentdaydates =date('d'); -// $working = array(); -// $overtime = array(); -// for ($i = 1; $i <= $dat; $i++) //echo $dat; die; -// { -// $Working [] = 'WH' . $i; -// $overtime [] = 'OT' . $i; - -// $CUR_month = date('t'); -// // echo $CUR_month; die; -// } -// //print_r($WH);die; -// $WH = implode(",", $Working); -// $OT = implode(",", $overtime); -// $salarycurrentdate = array(); -// $toDayEmployee = $this->dahsboard_Model->dayAllPersentEmpSalary($WH, $OT, $date); -// //$EmpID = $toDayEmployee[0]->EmpID; -// // - - -// // print_r($toDayEmployee); die; - -// $employeeSalary = 0; - -// // for($i=1;$i<=$dat;$i++) -// // { - -// $totalSalary = 0; -// $working = explode(",",$WH); -// $overtime = explode(",", $OT); -// foreach ($toDayEmployee as $value) { -// $values = 0; -// foreach ($working as $work) { -// // foreach ($overtime as $extra) { - -// if ($value[$work] != 0 || $value['OT'.substr($work, 2)] != 0) { -// $totalothour = $value['OT'.substr($work, 2)]; -// //echo $totalothour; -// $values = 1; - -// //print_r($values); die; -// $Empid = $value['EmpID']; -// //echo $Empid; - -// $totalEmployeePersent = $this->dahsboard_Model->persentEmployeeDetails($Empid); -// //print_r($totalEmployeePersent); - -// $HRA_Amount = $totalEmployeePersent[0]->HRA_Amount; -// $Basic_Pay = $totalEmployeePersent[0]->Basic_Pay; -// $totalsalary = $totalEmployeePersent[0]->TotalSalary; -// $dayFoodAmt = $totalEmployeePersent[0]->Food_Allowances; - - -// $Food_Allowances = $dayFoodAmt * $values; - -// $daySalary = $Basic_Pay / $CUR_month; -// /**per day salary working hour**/ -// //echo $daySalary.'
'; -// $onehoursSalary = $daySalary / 8; -// /**one hour salay ot calculation**/ -// if ($totalothour != 0) /** if ot not equal zero **/ { -// $totSalayOT = $totalothour * $onehoursSalary; -// } else { -// $totSalayOT = 0; -// } -// $currentDaySalary = $daySalary * $values; -// /** current day salary working days calculation**/ - -// $dayHra = $HRA_Amount / $CUR_month; -// /** per day hra amount **/ -// //echo $dayHra.'
'; -// $currentDayHra = $dayHra * $values; -// /** total working days hra calculations**/ -// // echo $currentDayHra.'
'; -// $currentDatePF = $currentDaySalary + $currentDayHra; -// /** current date pf calculation**/ -// if ($totalsalary <= 20000) { - -// $esiAmount = $currentDatePF * 1.75 / 100; -// /** esiamount not elgiable for 20000 **/ -// } else { -// $esiAmount = 0; -// } -// $pfAmount = $currentDaySalary * 12 / 100; -// /** pf amount per day**/ - -// //echo $totalothour;die; -// $salaryInCurrentday = $currentDaySalary + $totSalayOT + $currentDayHra + $Food_Allowances; - - -// $totalSalary = $totalSalary + $salaryInCurrentday; -// // $salarycurrentdate[] = $salaryInCurrentday;; -// } - -// // } -// //print_r($salarycurrentdate); -// // $currentmonthsalary = array_sum($salarycurrentdate); -// // $totalSalary = $totalSalary + $salarycurrentdate; -// // $salaryInCurrentday++; -// // echo $totalSalary; -// //print_r($currentmonthsalary); - -// } -// } -// echo $totalSalary; -// } public function getFinancialStartDate() { $CURMONTH = date('n'); $CURYEAR = date('Y'); $FINYEAR = 0; - if ($CURMONTH >= 4) { + if ($CURMONTH >= 4) + { $FINYEAR = $CURYEAR; - } else { + } else + { $FINYEAR = $CURYEAR - 1; } @@ -748,9 +407,11 @@ class user extends BaseController $CURMONTH = date('n'); $CURYEAR = date('Y'); $FINYEAR = 0; - if ($CURMONTH < 4) { + if ($CURMONTH < 4) + { $FINYEAR = $CURYEAR; - } else { + } else + { $FINYEAR = $CURYEAR + 1; } @@ -759,104 +420,273 @@ class user extends BaseController return $result; } - function attendanceyear() - { - $CURMONTH = date('m'); - $CURDATE = date('d'); - - //$dates = $start_date.'-04-01'; +function monthattendance() +{ + + $date = date('Y-m'); + //echo $date; + $dates = $date . '-01'; $EmpID = $this->input->post('id'); - $day = array(); + // echo $EmpID;die; + $monthabs = $this->dahsboard_Model->attendance($EmpID, $dates); + $persent_month = date('t');//current month of days 31 + $values = array(); + $otvalues = array(); + + $weekdays = array(); + $otHours = array(); + $date = date('j');//current month current date + + $CURDATE =date('d');//current month current date - $datejoin = $this->dahsboard_Model->joindate($EmpID); + $CUR_month = date('t'); //current month of days 31 + + $CURYEAR = date('Y'); + $CURMONTH = date('m'); + + $datejoin = $this->dahsboard_Model->joindate($EmpID); $DateofJoiningInString = $datejoin[0]->DateofJoining; $DateofJoining = date_create($DateofJoiningInString); + $doj_month = date_format($DateofJoining, "n"); + $doj_year = date_format($DateofJoining, "Y"); + $doj_day = date_format($DateofJoining, "j"); + //echo $doj_day; + for ($i = 1; $i <= $persent_month; $i++) + { + $weekdays[] = 'WH' . $i; + $otHours[] = 'OT' . $i; + } + + foreach ($monthabs as $weekda) + { + //print_r($weekda); + foreach ($weekda as $key => $value) + { + //print_r($key); + foreach ($weekdays as $weeks) + { + if ($weeks == $key) + { + //print_r($key); + if ($value != 0) + { + //echo $value; + $values[] = $value; + + } + //echo $values; + } + + } + foreach ($otHours as $ot) + { + if ($ot == $key) + { + if ($value != 0) + { + $otvalues [] = $value; + + } + + } + } + + } + } + $totalothour = array_sum($otvalues); + $totalwhhour = sizeof($values); + //echo $totalwhhour; + if ($CURMONTH == $doj_month && $CURYEAR == $doj_year) + { + //echo $doj_day; + $month['CUR_month'] = $CURDATE - $doj_day + 1; + //print_r($month); + } + else + { + $month['CUR_month'] = $date; + } + + if ($totalwhhour != 0) + { + // //echo $values; + // $currentDateSalary = $this->dahsboard_Model->daysalary($EmpID, $dates); + // $HRA_Amount = $currentDateSalary[0]->HRA_Amount; + // $Basic_Pay = $currentDateSalary[0]->Basic_Pay; + // $totalsalary = $currentDateSalary[0]->TotalSalary; + // $dayFoodAmt = $currentDateSalary[0]->Food_Allowances; + + // $Food_Allowances = $dayFoodAmt * $values; + + // $daySalary = $Basic_Pay / $CUR_month; + + // $onehoursSalary = $daySalary / 8; + + // if ($totalothour != 0) + // { + // $totSalayOT = $totalothour * $onehoursSalary; + // } + // else + // { + // $totSalayOT = 0; + // } + // $currentDaySalary = $daySalary * $values; + + // $dayHra = $HRA_Amount / $CUR_month; + + // $currentDayHra = $dayHra * $values; + + // $currentDatePF = $currentDaySalary + $currentDayHra; + + // if ($totalsalary <= 20000) + // { + // $esiAmount = $currentDatePF * 1.75 / 100; + + // } + // else + // { + // $esiAmount = 0; + // } + // $pfAmount = $currentDaySalary * 12 / 100; + + // $salaryInCurrentday = $currentDaySalary + $totSalayOT + $currentDayHra + $Food_Allowances; + + $year = date('Y'); + $current_month = date('m'); + + $month['values'] = $totalwhhour; + //$data['salaryInCurrentday'] = round($salaryInCurrentday); + $month['present_percentage'] = round(($totalwhhour / $month['CUR_month']) * 100); + + } + + else { + + $month['values'] = 0; + //$data['salaryInCurrentday'] = 0; + $month['present_percentage'] = 0; + + } + echo json_encode($month); + } + + +function attendanceyear() +{ + //echo "hai";die; + $CURMONTH = date('m'); + $CURDATE = date('d'); + $CURYEAR = date('Y'); + $EmpID = $this->input->post('id'); + // $month = $this->monthattendance($EmpID); + // echo json_encode($month); + $day = array(); + $datejoin = $this->dahsboard_Model->joindate($EmpID); + $DateofJoiningInString = $datejoin[0]->DateofJoining; + $DateofJoining = date_create($DateofJoiningInString); + $doj_month = date_format($DateofJoining, "n"); + $doj_year = date_format($DateofJoining, "Y"); + $doj_day = date_format($DateofJoining, "j"); $finStart = $this->getFinancialStartDate(); $finEnd = $this->getFinancialEndDate(); - - + $JoinedMonth = date_format($DateofJoining, "n"); + // echo $JoinedMonth; die; - if ($DateofJoining >= $finStart && $DateofJoining <= $finEnd) { - - $JoinedMonthAttendance = $this->dahsboard_Model->getAllAttendance($EmpID, $JoinedMonth); - - - $doj_month = date_format($DateofJoining, "n"); - $doj_year = date_format($DateofJoining, "Y"); - $doj_day = date_format($DateofJoining, "j"); - + if ($DateofJoining >= $finStart && $DateofJoining <= $finEnd) + { + $JoinedMonthAttendance = $this->dahsboard_Model->getAllAttendances($EmpID,$JoinedMonth); $joinedMonthDaysCount = cal_days_in_month(CAL_GREGORIAN, $doj_month, $doj_year); - $joinedMonthWorkingDayCount = $joinedMonthDaysCount - $doj_day; + if ($CURMONTH == $doj_month && $CURYEAR == $doj_year) + { + $joinedMonthWorkingDayCount = $CURDATE - $doj_day +1; + } + else + { + $joinedMonthWorkingDayCount = $joinedMonthDaysCount - $doj_day; + } $joinedMonthDays = 0; - for ($j = $doj_day; $j <= $joinedMonthDaysCount; $j++) { + for ($j = $doj_day; $j <= $joinedMonthDaysCount; $j++) + { $weekdays[] = 'WH' . $j; } - foreach ($JoinedMonthAttendance as $day) { - //print_r($weekda); - foreach ($day as $key => $value) { - foreach ($weekdays as $weeks) { - - if ($weeks == $key) { - if ($value != 0) { - + foreach ($JoinedMonthAttendance as $day) + { + foreach ($day as $key => $value) + { + foreach ($weekdays as $weeks) + { + if ($weeks == $key) + { + if ($value != 0) + { + //echo $value; $joinedMonthDays++; } } } - - } } + // echo $joinedMonthWorkingDayCount;die; $result = $this->dahsboard_Model->attendanceyear($EmpID, $JoinedMonth + 1); $yearabs = $this->dahsboard_Model->getAllAttendance($EmpID, $CURMONTH); - -//print_r($yearabs);exit(); $TotalNoofDays = $result[0]->TotalWorkingDays; $DaysWorked = $result[0]->DaysWorked; - + // echo $DaysWorked; die; + // print_r($DaysWorked);die; $values = 0; - $weekdays = array(); $date = date('d'); $Work = array_sum($weekdays); - for ($j = 1; $j <= $date; $j++) { + for ($j = 1; $j <= $date; $j++) + { $weekdays[] = 'WH' . $j; } - foreach ($yearabs as $day) { - //print_r($weekda); - foreach ($day as $key => $value) { - foreach ($weekdays as $weeks) { - - if ($weeks == $key) { - if ($value != 0) { - + + foreach ($yearabs as $day) + { + foreach ($day as $key => $value) + { + foreach ($weekdays as $weeks) + { + if ($weeks == $key) + { + if ($value != 0) + { $values++; } } } - - } } + $DaysWorked = 0; + if ($CURMONTH == $doj_month && $CURYEAR == $doj_year) + { + $TotalNoofDays = $TotalNoofDays + $joinedMonthWorkingDayCount; + $DaysWorked = $joinedMonthDays; + } + else + { + $TotalNoofDays = $TotalNoofDays + $CURDATE + $joinedMonthWorkingDayCount; + $DaysWorked = $DaysWorked + $joinedMonthDays + $values; + } - $TotalNoofDays = $TotalNoofDays + $CURDATE + $joinedMonthWorkingDayCount; - $DaysWorked = $DaysWorked + $values + $joinedMonthDays; + // $DaysWorked = $DaysWorked + $joinedMonthDays + $values; //echo $TotalNoofDays.'-'.$DaysWorked; @@ -867,21 +697,12 @@ class user extends BaseController $data['yeardata'] = $final_res; $data['totaldays'] = $TotalNoofDays; -// if(!empty($working)){ -// $data['total_working_days'] = round($worked/$dayswork); -// }else{ -// $data['total_working_days'] = 0; -// } + } - - //echo json_encode($data); - - - } else { + else + { $result = $this->dahsboard_Model->attendanceyear($EmpID, 4); $yearabs = $this->dahsboard_Model->getAllAttendance($EmpID, $CURMONTH); - -//print_r($yearabs);exit(); $TotalNoofDays = $result[0]->TotalWorkingDays; $DaysWorked = $result[0]->DaysWorked; @@ -893,32 +714,31 @@ class user extends BaseController $Work = array_sum($weekdays); - for ($j = 1; $j <= $date; $j++) { + for ($j = 1; $j <= $date; $j++) + { $weekdays[] = 'WH' . $j; } - foreach ($yearabs as $day) { - //print_r($weekda); - foreach ($day as $key => $value) { - foreach ($weekdays as $weeks) { - - if ($weeks == $key) { - if ($value != 0) { + foreach ($yearabs as $day) + { + foreach ($day as $key => $value) + { + foreach ($weekdays as $weeks) + { + if ($weeks == $key) + { + if ($value != 0) + { $values++; } } } - - } } $TotalNoofDays = $TotalNoofDays + $CURDATE; $DaysWorked = $DaysWorked + $values; -//echo $TotalNoofDays.'-'.$DaysWorked; - - $final_res = round(($DaysWorked / $TotalNoofDays) * 100); // echo "------"; //echo $final_res;exit(); @@ -926,168 +746,20 @@ class user extends BaseController $data['yeardata'] = $final_res; $data['totaldays'] = $TotalNoofDays; -// if(!empty($working)){ -// $data['total_working_days'] = round($worked/$dayswork); -// }else{ -// $data['total_working_days'] = 0; -// } + // $month = $this->monthattendance(); + // $data['values'] = $values; + // $data['salaryInCurrentday'] = round($salaryInCurrentday); + // $data['present_percentage'] = round(($values / $data['CUR_month']) * 100); - //echo json_encode($data); + //print_r($data);die; + } - /**month part start**/ - $date = date('Y-m'); - //echo $date; - $dates = $date . '-01'; - $EmpID = $this->input->post('id'); -//echo $dates; die; - //echo $weekabs;die; - $monthabs = $this->dahsboard_Model->attendance($EmpID, $dates); -//print_r($data['monthabs']); -//$todate = $this->input->get('todate'); - $persent_month = date('t'); + echo json_encode($data); + +} -//$current_month_day = cal_days_in_month(CAL_GREGORIAN,$persent_month,$year); -//$current_month_day;die; - $values = 0; - $otvalues = array(); - $CUR_month = date('t'); -//die(); - $weekdays = array(); - $otHours = array(); - $date = date('d'); -//echo $date; die; - for ($i = 1; $i <= $persent_month; $i++) { - -//if($date > 0 ){ - - $weekdays[] = 'WH' . $i; - $otHours[] = 'OT' . $i; -//print_r($weekdays); - - - } -//print_r($weekdays);die; - - foreach ($monthabs as $weekda) { - //print_r($weekda); - foreach ($weekda as $key => $value) { - //print_r($key);die; - - - //print_r($value); - foreach ($weekdays as $weeks) { - //print_r($weeks); - //print_r($key); - if ($weeks == $key) { - - if ($value != 0) { - - //echo $values; - $values++; - // echo $values; - - - } - } - - } - foreach ($otHours as $ot) { - if ($ot == $key) { - - if ($value != 0) { - $otvalues [] = $value; - // echo $otvalue; - - } - //echo $otvalues; - } - } - - } - } -//echo $values;die; - - $totalothour = array_sum($otvalues); - - - if ($values != 0) { - - $currentDateSalary = $this->dahsboard_Model->daysalary($EmpID, $dates); - $HRA_Amount = $currentDateSalary[0]->HRA_Amount; - $Basic_Pay = $currentDateSalary[0]->Basic_Pay; - $totalsalary = $currentDateSalary[0]->TotalSalary; - $dayFoodAmt = $currentDateSalary[0]->Food_Allowances; - - $Food_Allowances = $dayFoodAmt * $values; - - $daySalary = $Basic_Pay / $CUR_month; - /**per day salary working hour**/ - //echo $daySalary.'
'; - $onehoursSalary = $daySalary / 8; - /**one hour salay ot calculation**/ - if ($totalothour != 0) { - /** if ot not equal zero **/ - $totSalayOT = $totalothour * $onehoursSalary; - } else { - $totSalayOT = 0; - } - $currentDaySalary = $daySalary * $values; - /** current day salary working days calculation**/ - - $dayHra = $HRA_Amount / $CUR_month; - /** per day hra amount **/ - //echo $dayHra.'
'; - $currentDayHra = $dayHra * $values; - /** total working days hra calculations**/ - // echo $currentDayHra.'
'; - $currentDatePF = $currentDaySalary + $currentDayHra; - /** current date pf calculation**/ - if ($totalsalary <= 20000) { - - $esiAmount = $currentDatePF * 1.75 / 100; - /** esiamount not elgiable for 20000 **/ - } else { - $esiAmount = 0; - } - $pfAmount = $currentDaySalary * 12 / 100; - /** pf amount per day**/ - - //echo $totalothour;die; - $salaryInCurrentday = $currentDaySalary + $totSalayOT + $currentDayHra + $Food_Allowances; -//echo $salaryInCurrentday;die; - $year = date('Y'); - $current_month = date('m'); - //echo $current_month;die; - - - //$current_month_days = cal_days_in_month(CAL_GREGORIAN,$current_month,$year); - //echo $current_month_days;die; - - - //echo $CUR_month;// echo $current_month;die; - // $total_days_percentage = ($values/$date); - //print_r($total_days_percentage);die; - $data['values'] = $values; - $data['salaryInCurrentday'] = round($salaryInCurrentday); - //$data['otvalues'] = $otvalues; - //print_r($data['otvalues']);die; - $data['present_percentage'] = round(($values / $date) * 100); - $data['CUR_month'] = $date; - - - } else { - $data['CUR_month'] = $date; - $data['values'] = 0; - $data['salaryInCurrentday'] = 0; - $data['present_percentage'] = round(($values / $date) * 100); - - //echo json_encode($data); - } - /**month part end**/ - echo json_encode($data); - } /****************HR DASHBOART Controller END **************************************/ /** diff --git a/application/models/dahsboard_model.php b/application/models/dahsboard_model.php index 79b6a1a0..0c50b998 100755 --- a/application/models/dahsboard_model.php +++ b/application/models/dahsboard_model.php @@ -4,7 +4,7 @@ class dahsboard_Model extends CI_Model { - /* HR DASHBOART Model START*/ + /* HR DASHBOART Model START*/ function totemp() { @@ -55,10 +55,15 @@ $sql="select EmpID,CONCAT(FirstName,' ',LastName) as name FROM T_Employee_Detai } - function attyesterday($WH,$date) + function attyesterday($WH,$date) { //echo 'model' . $WH.'-'.$date; - $sql="select EmpID,".$WH." from T_Attendance where Month_Year = ? and EmpID in (select EmpID from T_Attendance)" ; + // $sql="select EmpID,".$WH." from T_Attendance where Month_Year = ? and EmpID in (select EmpID from T_Attendance)" ; + + +$sql="select att.EmpID,".$WH.",a.FirstName from T_Attendance as att +join T_Employee_Details as a on a.EmpID= att.EmpID +where Month_Year = ? and att.EmpID in (select EmpID from T_Attendance)"; $query = $this->db->query($sql,array($date)); // print_r($query->result()); //echo count($query->result()); @@ -89,10 +94,30 @@ function attendance($EmpID,$dates) function getAllAttendance($EmpID,$CURMONTH) { $sql="select * from T_Attendance where EmpID =? and month(Month_Year)=?"; + +// $sql=" select T_Attendance.*,emp.FirstName from T_Attendance +// join T_Employee_Details emp on T_Attendance.EmpID = emp.EmpID +// where T_Attendance.EmpID = ? and month(Month_Year)= ? "; + + $query = $this->db->query($sql,array($EmpID,$CURMONTH)); return $query->result(); } + +function getAllAttendances($EmpID,$JoinedMonth) +{ + //$sql="select * from T_Attendance where EmpID =? and month(Month_Year)=?"; + + $sql=" select T_Attendance.*,emp.FirstName from T_Attendance +join T_Employee_Details emp on T_Attendance.EmpID = emp.EmpID +where T_Attendance.EmpID = ? and month(Month_Year)= ? "; + + + $query = $this->db->query($sql,array($EmpID,$JoinedMonth)); + + return $query->result(); +} function joindate($EmpID) { $sql="select DateofJoining from T_Employee_Details where EmpID =? "; diff --git a/application/views/dashboard.php b/application/views/dashboard.php index 53850f88..91091a2a 100755 --- a/application/views/dashboard.php +++ b/application/views/dashboard.php @@ -72,118 +72,131 @@ if(!empty($EmpCount))
-
+
-
-

TOTAL NO OF EMPLOYEES

-
- +

TOTAL NO OF EMPLOYEES

+
+ -

totemp;?>

-

 

+

totemp;?>

+

 

-
-
- -
-
-
-
- -
- -
-

TOTAL LOAN

-
- - - - -

totloan;?>

-

 

- - -
-
- -
-
-
-
- -
- - -
- -

LOAN TO BE RECOVERED

-
- - - -

totrec;?>

-

 

- -
-
- - -
-
+
+
+ +
+
-
-
+
-
-

TOTAL EMPLOYEES ABSENT

- - -
- -

-

TODAY

- -
+
+

TOTAL LOAN

+
+ + +

totloan;?>

+

 

+ + + +
+ +
+ +
+ + + LOAN TO BE RECOVERED : + + + + totrec;?> + + +
+
+ + +
+ + +
+ +

SALARY COST

+
+ +

+

TODAY

+ + +
+
+ + +
+ THIS MONTH : + +
+ +
+ + + + + +
+ +
+

TOTAL EMPLOYEES ABSENT

+ + +
+ +

+

TODAY

+ +
YESTERDAY : -
-
-
+
+ +
@@ -218,6 +231,9 @@ if(!empty($EmpCount)) ?> + +
@@ -288,7 +304,7 @@ if(!empty($EmpCount)) url:"user/attendanceyear", success:function(json) { console.log(json); - //alert(json); + // alert(json.workeds); $('#content').loader('hide'); $('#totaldays').text(json.totaldays); $('#worked').text(json.workeds) @@ -297,6 +313,9 @@ if(!empty($EmpCount)) data.setValue(0, 1, json.yeardata); chart.draw(data, options); + }, + error:function(){ + alert('error'); } }); @@ -357,60 +376,68 @@ if(!empty($EmpCount)) -
-
- + + + - -
- -
-
- -
- -
- -

- Salary Cost -

-
-
-
-
-
-
-
-
-

-
Today
- -
- -
-

-
This Month
- -
- -
-
-
- -
-
- - - -
- -
- + + +
+ +
+
+

NAME OF ABSENTEES

+ +
+ + + + +
+
+ +
+ +
+ + '; + + ?> + + + + + + + + +
+ + + +
+ + + +
+ +
+ + + + + + + - + @@ -426,7 +453,8 @@ if(!empty($EmpCount)) google.charts.load('current', {'packages':['gauge']}); google.charts.setOnLoadCallback(drawChart); - function drawChart() { + function drawChart() + { var data = google.visualization.arrayToDataTable([ ['Label', 'Value'], @@ -443,6 +471,9 @@ if(!empty($EmpCount)) }; var chart = new google.visualization.Gauge(document.getElementById('chart_divs')); chart.draw(data, options); + + + $('#emp').change(function() { // alert(); var id = $('#emp').val(); @@ -456,7 +487,7 @@ $("#monthabs").val(''); data:{id:id}, dataType: 'json', type:"POST", - url:"user/attendanceyear", + url:"user/monthattendance", success:function(json) { console.log(json); @@ -499,7 +530,6 @@ $("#monthabs").val(''); -