diff --git a/application/controllers/user.php b/application/controllers/user.php
index afc8783a..4808da90 100755
--- a/application/controllers/user.php
+++ b/application/controllers/user.php
@@ -81,385 +81,1015 @@ class user extends BaseController
$data['capitalbal'] = $this->dahsboard_Model->capitalbal();
- $data['totemp']=$this->dahsboard_Model->totemp();
- $data['totloan']=$this->dahsboard_Model->totloan();
- $data['totpay']=$this->dahsboard_Model->totpay();
- $data['totrec']=$this->dahsboard_Model->totrec();
- $data['emplist']=$this->dahsboard_Model->emplist();
+ /* HR DASHBOARD Controller Start*/
+ $data['totemp'] = $this->dahsboard_Model->totemp();
+ $data['totloan'] = $this->dahsboard_Model->totloan();
+ $data['totpay'] = $this->dahsboard_Model->totpay();
+ $data['totrec'] = $this->dahsboard_Model->totrec();
+ $data['emplist'] = $this->dahsboard_Model->emplist();
-/* yesterday absent list count in employee*/
- $dates = date('Y-m');
- $date = $dates.'-01';
- $dat = date('d',strtotime("-1 days"));
- //echo $date;
-
- $WH = 'WH'.date('j',strtotime("-1 days"));
+ /* yesterday absent list count in employee*/
+ $dates = date('Y-m');
+ $date = $dates . '-01';
+ // echo $date;
+ $dat = date('d', strtotime("-1 days"));
+ //echo $date;
-//echo($WH);die;
-$yesterday = $this->dahsboard_Model->attyesterday($WH,$date);
- //print_r($yesterday);die;
-$values=0;
-foreach ($yesterday as $weekda => $value) {
-
- if($value[$WH] == 0){
-
- $values++;
+ $WH = 'WH' . date('j', strtotime("-1 days"));
+
+ //echo($WH);
+ $yesterday = $this->dahsboard_Model->attyesterday($WH, $date);
+ //print_r($yesterday);die;
+ $values = 0;
+ foreach ($yesterday as $weekda => $value) {
+
+ if ($value[$WH] == 0) {
+
+ $values++;
}
-
-
- }
-$data['values'] = $values;
-/*Today absent list count in employee*/
-$dates = date('Y-m');
- //echo $date;
- $date = $dates.'-01';
- $dat = date('d');
- //echo $date;
-
- $WH = 'WH'.date('j');
- //echo $WH;die;
+ }
+ // echo $values;
+ $data['values'] = $values;
- $yesterday = $this->dahsboard_Model->attyesterday($WH,$date);
- // print_r($yesterday);die;
-$values=0;
-foreach ($yesterday as $weekda => $value) {
-
- if($value[$WH] == 0){
-
- $values++;
+ /*Today absent list count in employee*/
+ $dates = date('Y-m');
+ //echo $date;
+ $date = $dates . '-01';
+
+ $dat = date('d');
+ //echo $date;
+
+ $WH = 'WH' . date('j');
+ //echo $WH;die;
+
+ $yesterday = $this->dahsboard_Model->attyesterday($WH, $date);
+ // print_r($yesterday);die;
+ $values = 0;
+ foreach ($yesterday as $weekda => $value) {
+
+ if ($value[$WH] == 0) {
+
+ $values++;
}
-
-
- }
-$data['today'] = $values;
-//print_r($data['today']);die;
-
-
- $this->loadViews("dashboard", $this->global, $data , NULL);
+
+ }
+ // print_r($values);die;
+ $data['today'] = $values;
+
+ // 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++;
+
+
+ $data['employeeSalary'] = $employeeSalary;
+
+
+
+ // }
+
+ // 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;
+
+
+ $totalSalarys = $totalSalary + $salaryInCurrentday;
+
+ $totalSalary =round($totalSalarys);
+// $salarycurrentdate[] = $salaryInCurrentday;;
+ }
+
+// }
+ //print_r($salarycurrentdate);
+// $currentmonthsalary = array_sum($salarycurrentdate);
+// $totalSalary = $totalSalary + $salarycurrentdate;
+ // $salaryInCurrentday++;
+// echo $totalSalary;
+ //print_r($currentmonthsalary);
+
+ }
+ }
+ $data['totalSalary']= $totalSalary;
+ //}
+
+
+
+
+
+ $this->loadViews("dashboard", $this->global, $data, NULL);
}
-
-function attendancemonth()
-{
- // $EmpID='';
- $date = date('Y-m');
- //echo $date;
- $dates = $date.'-01';
- $EmpID= $this->input->post('id');
-//echo $dates;
- //echo $weekabs;die;
-$monthabs = $this->dahsboard_Model->attendance($EmpID,$dates);
+
+// 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) {
+ $FINYEAR = $CURYEAR;
+ } else {
+ $FINYEAR = $CURYEAR - 1;
+ }
+
+ $dateInString = $FINYEAR . '-4-1';
+ $result = date_create($dateInString);
+ return $result;
+ }
+
+ public function getFinancialEndDate()
+ {
+ $CURMONTH = date('n');
+ $CURYEAR = date('Y');
+ $FINYEAR = 0;
+ if ($CURMONTH < 4) {
+ $FINYEAR = $CURYEAR;
+ } else {
+ $FINYEAR = $CURYEAR + 1;
+ }
+
+ $dateInString = $FINYEAR . '-3-31';
+ $result = date_create($dateInString);
+ return $result;
+ }
+
+ function attendanceyear()
+ {
+ $CURMONTH = date('m');
+ $CURDATE = date('d');
+
+ //$dates = $start_date.'-04-01';
+ $EmpID = $this->input->post('id');
+ $day = array();
+
+
+ $datejoin = $this->dahsboard_Model->joindate($EmpID);
+
+ $DateofJoiningInString = $datejoin[0]->DateofJoining;
+ $DateofJoining = date_create($DateofJoiningInString);
+
+
+ $finStart = $this->getFinancialStartDate();
+ $finEnd = $this->getFinancialEndDate();
+
+
+ $JoinedMonth = date_format($DateofJoining, "n");
+
+ 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");
+
+ $joinedMonthDaysCount = cal_days_in_month(CAL_GREGORIAN, $doj_month, $doj_year);
+ $joinedMonthWorkingDayCount = $joinedMonthDaysCount - $doj_day;
+
+
+ $joinedMonthDays = 0;
+ 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) {
+
+ $joinedMonthDays++;
+ }
+ }
+
+ }
+
+
+ }
+
+ }
+
+
+ $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;
+
+
+ $values = 0;
+
+ $weekdays = array();
+ $date = date('d');
+
+ $Work = array_sum($weekdays);
+
+ 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) {
+
+ $values++;
+ }
+ }
+
+ }
+
+
+ }
+ }
+
+
+ $TotalNoofDays = $TotalNoofDays + $CURDATE + $joinedMonthWorkingDayCount;
+ $DaysWorked = $DaysWorked + $values + $joinedMonthDays;
+//echo $TotalNoofDays.'-'.$DaysWorked;
+
+
+ $final_res = round(($DaysWorked / $TotalNoofDays) * 100);
+ // echo "------";
+ //echo $final_res;exit();
+ $data['workeds'] = $DaysWorked;
+ $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 {
+ $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;
+
+
+ $values = 0;
+
+ $weekdays = array();
+ $date = date('d');
+
+ $Work = array_sum($weekdays);
+
+ 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) {
+
+ $values++;
+ }
+ }
+
+ }
+
+
+ }
+ }
+
+ $TotalNoofDays = $TotalNoofDays + $CURDATE;
+ $DaysWorked = $DaysWorked + $values;
+//echo $TotalNoofDays.'-'.$DaysWorked;
+
+
+ $final_res = round(($DaysWorked / $TotalNoofDays) * 100);
+ // echo "------";
+ //echo $final_res;exit();
+ $data['workeds'] = $DaysWorked;
+ $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);
+ }
+ /**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');
+ $persent_month = date('t');
//$current_month_day = cal_days_in_month(CAL_GREGORIAN,$persent_month,$year);
//$current_month_day;die;
-$values=0;
+ $values = 0;
+ $otvalues = array();
+ $CUR_month = date('t');
//die();
-$weekdays = array();
-$date = date('d');
-//echo $date;
-for($i=1;$i<=$persent_month;$i++)
-{
+ $weekdays = array();
+ $otHours = array();
+ $date = date('d');
+//echo $date; die;
+ for ($i = 1; $i <= $persent_month; $i++) {
//if($date > 0 ){
-$weekdays[] = 'WH'.$i;
+ $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;
-
+ 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 $value;
- $values++;
- // echo $values;
-
-
-
- }
+
+ //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);
-//print_r($week);
- $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;
-
-
-
- $CUR_month = date('t');
+
+ 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;
- // $total_days_percentage = ($values/$date);
+
+
+ //$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['present_percentage'] = round(($values/$date)*100);
+ $data['salaryInCurrentday'] = round($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['present_percentage'] = round(($values / $date) * 100);
-
-}
-
-public function getFinancialStartDate() {
- $CURMONTH = date('n');
- $CURYEAR = date('Y');
- $FINYEAR = 0;
- if($CURMONTH >= 4 ) {
- $FINYEAR = $CURYEAR;
- }else {
- $FINYEAR = $CURYEAR-1;
- }
-
- $dateInString = $FINYEAR.'-4-1';
- $result = date_create($dateInString);
- return $result;
-}
-
-public function getFinancialEndDate() {
- $CURMONTH = date('n');
- $CURYEAR = date('Y');
- $FINYEAR = 0;
- if($CURMONTH < 4 ) {
- $FINYEAR = $CURYEAR;
- }else {
- $FINYEAR = $CURYEAR+1;
- }
-
- $dateInString = $FINYEAR.'-3-31';
- $result = date_create($dateInString);
- return $result;
-}
-
- function attendanceyear()
-{
- $CURMONTH = date('m');
- $CURDATE = date('d');
-
- //$dates = $start_date.'-04-01';
- $EmpID= $this->input->post('id');
- $day = array();
-
-
-$datejoin=$this->dahsboard_Model->joindate($EmpID);
-
- $DateofJoiningInString = $datejoin[0]->DateofJoining;
- $DateofJoining = date_create($DateofJoiningInString);
-
-
-
- $finStart = $this->getFinancialStartDate();
- $finEnd = $this->getFinancialEndDate();
-
-
- $JoinedMonth = date_format($DateofJoining,"n");
-
- 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");
-
- $joinedMonthDaysCount = cal_days_in_month(CAL_GREGORIAN, $doj_month, $doj_year);
- $joinedMonthWorkingDayCount = $joinedMonthDaysCount - $doj_day;
-
-
-
-$joinedMonthDays =0;
-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){
-
- $joinedMonthDays++;
- }
+ //echo json_encode($data);
}
-
- }
-
-
+ /**month part end**/
+ echo json_encode($data);
}
-}
+/****************HR DASHBOART Controller END **************************************/
-
-
-
-$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;
-
-
-$values=0;
-
-$weekdays = array();
-$date = date('d');
-
-$Work= array_sum($weekdays);
-
-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){
-
- $values++;
- }
- }
-
- }
-
-
- }
-}
-
-
- $TotalNoofDays = $TotalNoofDays+$CURDATE + $joinedMonthWorkingDayCount ;
- $DaysWorked = $DaysWorked+$values+$joinedMonthDays;
-//echo $TotalNoofDays.'-'.$DaysWorked;
-
-
-
-
- $final_res = round(($DaysWorked /$TotalNoofDays) * 100);
- // echo "------";
- //echo $final_res;exit();
- $data['workeds']=$DaysWorked;
- $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 {
-$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;
-
-
-$values=0;
-
-$weekdays = array();
-$date = date('d');
-
-$Work= array_sum($weekdays);
-
-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){
-
- $values++;
- }
- }
-
- }
-
-
- }
-}
-
- $TotalNoofDays = $TotalNoofDays+$CURDATE;
- $DaysWorked = $DaysWorked+$values;
-//echo $TotalNoofDays.'-'.$DaysWorked;
-
-
-
-
- $final_res = round(($DaysWorked /$TotalNoofDays) * 100);
- // echo "------";
- //echo $final_res;exit();
- $data['workeds']=$DaysWorked;
- $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);
- }
-}
/**
* This function is used to load the user list
*/
diff --git a/application/models/dahsboard_model.php b/application/models/dahsboard_model.php
index 453479cc..f96ed100 100755
--- a/application/models/dahsboard_model.php
+++ b/application/models/dahsboard_model.php
@@ -4,6 +4,7 @@ class dahsboard_Model extends CI_Model
{
+ /* HR DASHBOART Model START*/
function totemp()
{
@@ -55,15 +56,27 @@ $sql="select EmpID,CONCAT(FirstName,' ',LastName) as name FROM T_Employee_Detai
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)" ;
+ $query = $this->db->query($sql,array($date));
+ // print_r($query->result());
+ //echo count($query->result());
+ return $query->result_array();
+}
+
+
+ function dayAllPersentEmpSalary($WH,$OT,$date)
{
//echo $EmpID.'-'.$dates;
- $sql="select ".$WH." from T_Attendance where Month_Year = ? and EmpID in (select EmpID from T_Attendance)";
+ $sql="select EmpID,".$WH.",".$OT." from T_Attendance where Month_Year = ? and EmpID in (select EmpID from T_Attendance)";
$query = $this->db->query($sql,array($date));
//return
return $query->result_array();
}
+
function attendance($EmpID,$dates)
{
//echo $EmpID.'-'.$dates;
@@ -105,26 +118,44 @@ where att.Month_Year = ? and att.EmpID = ?;";
}
+function persentEmployeeDetails($EmpID){
+//join T_Attendance att on att.EmpID = pay.EmpID
+$sql= "select * FROM T_Emp_Pay_Data where EmpID = ?;";
+ $query = $this->db->query($sql,array($EmpID));
+
+ return $query->result();
- function attendanceyear($EmpID , $MONTH)
+}
+
+
+
+ function attendanceyear($EmpID,$MONTH)
{
// $sql="select Att.EmpID,Att.Month_Year,Att.*,NoofDays,Days_Worked,emp.DateofJoining from T_Attendance Att
// join T_Employee_Details as emp on emp.EmpID = Att.EmpID
// where Att.Month_Year between ? and ? and Att.EmpID = ?";
+ // else
+ // (YEAR(Month_Year) = YEAR(CURRENT_DATE)-1 and MONTH(Month_Year) >= ? ) or ( YEAR(Month_Year) = YEAR(CURRENT_DATE) and MONTH(Month_Year) <= 3 )
$sql = 'select sum(NoofDays) as TotalWorkingDays,sum(Days_worked) as DaysWorked from T_Attendance where
case
when (month(Month_Year) >=4) then
(YEAR(Month_Year) = YEAR(CURRENT_DATE) and MONTH(Month_Year) >= ? ) or ( YEAR(Month_Year) = YEAR(CURRENT_DATE)+1 and MONTH(Month_Year) <= 3 )
- else
- (YEAR(Month_Year) = YEAR(CURRENT_DATE)-1 and MONTH(Month_Year) >= ? ) or ( YEAR(Month_Year) = YEAR(CURRENT_DATE) and MONTH(Month_Year) <= 3 )
+
end and EmpID = ? and month(Month_Year) != month(current_date());';
- $query= $this->db->query($sql,array($MONTH, $MONTH, $EmpID));
+ $query= $this->db->query($sql,array($MONTH, $EmpID));
return $query->result();
}
+
+
+
+
+ /* HR DASHBOARD Model END*/
+
+
function totalpurchaseorder(){
diff --git a/application/views/dashboard.php b/application/views/dashboard.php
index a5bfddc4..42f218ae 100755
--- a/application/views/dashboard.php
+++ b/application/views/dashboard.php
@@ -58,6 +58,13 @@ if(!empty($EmpCount))
+
+
+
TOTAL NO OF EMPLOYEES
++ - -
LOAN TO BE RECOVERED
+-