diff --git a/application/controllers/user.php b/application/controllers/user.php index e52ef23a..ce56e54a 100755 --- a/application/controllers/user.php +++ b/application/controllers/user.php @@ -18,6 +18,7 @@ class user extends BaseController { parent::__construct(); $this->load->model('user_model'); + $this->load->model('dahsboard_Model'); $this->load->library('form_validation'); $this->isLoggedIn(); @@ -80,9 +81,241 @@ 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(); + +/* 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")); + +//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['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; + + $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); } + + + +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); +//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; +//die(); +$weekdays = array(); +$date = date('d'); +//echo $date; +for($i=1;$i<=$persent_month;$i++) +{ + +//if($date > 0 ){ + +$weekdays[] = 'WH'.$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 $value; + $values++; + // echo $values; + + + + } + } + + } + + + } +} +//echo $values;die; + + +//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'); + //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['CUR_month'] = $date; + + + + echo json_encode($data); + + + + + +} + + +function attendanceyear() +{ + $CURMONTH = date('m'); + $CURDATE = date('d'); + + //$dates = $start_date.'-04-01'; + $EmpID= $this->input->post('id'); + $day = array(); + + + +$result = $this->dahsboard_Model->attendanceyear($EmpID); +$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 ae1ea56d..21e5aae1 100755 --- a/application/models/dahsboard_model.php +++ b/application/models/dahsboard_model.php @@ -4,6 +4,118 @@ class dahsboard_Model extends CI_Model { + function totemp() + { + + $sql="select count(EmpID) as totemp FROM T_Employee_Details where IsActive ='1'"; + $query =$this->db->query($sql); + return $query->result(); + + } + + + function totloan() + { + + $sql="select sum(Loan_Amount)as totloan FROM T_Loan_Master"; + $query =$this->db->query($sql); + return $query->result(); + + } + + + function totpay() + { + + $sql="select sum(Paid_Amount)as totpay FROM T_Loan_Master"; + $query =$this->db->query($sql); + return $query->result(); + + } + + function totrec() + { + + $sql="select sum(Loan_Amount), sum(Paid_Amount),sum(Loan_Amount)-sum(Paid_Amount) as totrec FROM T_Loan_Master"; + $query =$this->db->query($sql); + return $query->result(); + + } + + function emplist() + { + +$sql="select EmpID,CONCAT(FirstName,' ',LastName) as name FROM T_Employee_Details where IsActive ='1'"; + $query =$this->db->query($sql); + return $query->result(); + + + + } + + + function attyesterday($WH,$date) + { + //echo $EmpID.'-'.$dates; + $sql="select ".$WH." 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; + $sql="select * from T_Attendance where EmpID =? and Month_Year=?"; + $query = $this->db->query($sql,array($EmpID,$dates)); + + return $query->result(); + +} +function getAllAttendance($EmpID,$CURMONTH) +{ + $sql="select * from T_Attendance where EmpID =? and month(Month_Year)=?"; + $query = $this->db->query($sql,array($EmpID,$CURMONTH)); + + return $query->result(); +} + +function daysalary($EmpID,$dates) +{ + //print_r($dates);die; + $sql= "select * FROM T_Emp_Pay_Data as pay + +join T_Attendance att on att.EmpID = pay.EmpID +where att.Month_Year = ? and att.EmpID = ?;"; + $query = $this->db->query($sql,array($dates,$EmpID)); + + return $query->result(); + +} + + + + function attendanceyear($EmpID) + { + + // $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 = ?"; + $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) >= 4 ) 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) >= 4 ) 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($EmpID)); + return $query->result(); + + + + } + function totalpurchaseorder(){ diff --git a/application/views/dashboard.php b/application/views/dashboard.php index f0b18755..47952fbf 100755 --- a/application/views/dashboard.php +++ b/application/views/dashboard.php @@ -56,8 +56,410 @@ if(!empty($EmpCount)) + } + ?> + +
+ +
+ +
+ +
+ +
+
+ +
+
+
+ + + + +
+ TOTAL NO OF EMPLOYEES + totemp;?> +
+ + +
+
+ + + + +
+ +
+
+ TOTAL EMPLOYEES ABSENT +
+ +
+
YESTERDAY
+
+ + + +
+ + +
+ + + +
+
+ +
+ +
TODAY
+ +
+ + +
+ + +
+ +
+ +
+ +
+ + + +
+
+
+ +
+ +
+
+ 'Select Employee'); + //print_r( $options); + + if(!empty($emplist)) + { + foreach ($emplist as $SID): + + + $options[$SID->EmpID] = $SID->name.' '.' - '.' '.$SID->EmpID; + + endforeach; + } + + echo form_dropdown('emp', $options,set_value('emp'),'id="emp"' ,'required="true"' ,'class="form-control select2'); + + ?> +
+
+
+
+
+ +
+


+
+
+ +
0
+
+
+ +
0
+
+ +
+ +
+ +
+ + + + + + + + +
+ +
+
+ 'Select Employee'); + //print_r( $options); + + if(!empty($emplist)) + { + foreach ($emplist as $SID): + + + $options[$SID->EmpID] = $SID->name.' '.' - '.' '.$SID->EmpID; + + endforeach; + } + + echo form_dropdown('employee', $options,set_value('employee'),'id="employee"' ,'required="true"' ,'class="form-control select2'); + + ?> +
+
+
+
+ +
+
+


+
+
+ +
0
+
+
+ +
0
+
+ +
+ +
+ + +
+ + + + + + + + + + +
+
+ +
+
+ + + + - + diff --git a/assets/js/meter.js b/assets/js/meter.js new file mode 100644 index 00000000..bb269ed3 --- /dev/null +++ b/assets/js/meter.js @@ -0,0 +1,226 @@ +(function(){var a="\n//# sourceURL=",k="' of type ",n='